diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2010-11-25 22:49:44 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2010-11-25 22:49:44 +0100 |
commit | bd801f1b970d3577cebba6cb831d77308222369d (patch) | |
tree | 95fd79c92c7b26e35d779a713c1d2c1a7fc98370 /src/libhydra/plugins/attr_sql/attr_sql_plugin.c | |
parent | efc1c86e21e8a78ec14abc1cc30aed569497cfc8 (diff) | |
download | strongswan-bd801f1b970d3577cebba6cb831d77308222369d.tar.bz2 strongswan-bd801f1b970d3577cebba6cb831d77308222369d.tar.xz |
Migrated attr_sql_plugin_t to INIT/METHOD macros
Diffstat (limited to 'src/libhydra/plugins/attr_sql/attr_sql_plugin.c')
-rw-r--r-- | src/libhydra/plugins/attr_sql/attr_sql_plugin.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libhydra/plugins/attr_sql/attr_sql_plugin.c b/src/libhydra/plugins/attr_sql/attr_sql_plugin.c index 70e7a2247..ac0304db5 100644 --- a/src/libhydra/plugins/attr_sql/attr_sql_plugin.c +++ b/src/libhydra/plugins/attr_sql/attr_sql_plugin.c @@ -43,10 +43,8 @@ struct private_attr_sql_plugin_t { }; -/** - * Implementation of plugin_t.destroy - */ -static void destroy(private_attr_sql_plugin_t *this) +METHOD(plugin_t, destroy, void, + private_attr_sql_plugin_t *this) { hydra->attributes->remove_provider(hydra->attributes, &this->attribute->provider); this->attribute->destroy(this->attribute); @@ -59,21 +57,26 @@ static void destroy(private_attr_sql_plugin_t *this) */ plugin_t *attr_sql_plugin_create() { - char *uri; private_attr_sql_plugin_t *this; + char *uri; - uri = lib->settings->get_str(lib->settings, "libhydra.plugins.attr-sql.database", NULL); + uri = lib->settings->get_str(lib->settings, "libhydra.plugins.attr-sql.database", + NULL); if (!uri) { DBG1(DBG_CFG, "attr-sql plugin: database URI not set"); return NULL; } - this = malloc_thing(private_attr_sql_plugin_t); - - this->public.plugin.destroy = (void(*)(plugin_t*))destroy; + INIT(this, + .public = { + .plugin = { + .destroy = _destroy + }, + }, + .db = lib->db->create(lib->db, uri) + ); - this->db = lib->db->create(lib->db, uri); if (!this->db) { DBG1(DBG_CFG, "attr-sql plugin failed to connect to database"); |