Migrated attr_sql_plugin_t to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2010-11-25 22:49:44 +01:00
parent efc1c86e21
commit bd801f1b97
+13 -10
View File
@@ -43,10 +43,8 @@ struct private_attr_sql_plugin_t {
}; };
/** METHOD(plugin_t, destroy, void,
* Implementation of plugin_t.destroy private_attr_sql_plugin_t *this)
*/
static void destroy(private_attr_sql_plugin_t *this)
{ {
hydra->attributes->remove_provider(hydra->attributes, &this->attribute->provider); hydra->attributes->remove_provider(hydra->attributes, &this->attribute->provider);
this->attribute->destroy(this->attribute); this->attribute->destroy(this->attribute);
@@ -59,21 +57,26 @@ static void destroy(private_attr_sql_plugin_t *this)
*/ */
plugin_t *attr_sql_plugin_create() plugin_t *attr_sql_plugin_create()
{ {
char *uri;
private_attr_sql_plugin_t *this; 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) if (!uri)
{ {
DBG1(DBG_CFG, "attr-sql plugin: database URI not set"); DBG1(DBG_CFG, "attr-sql plugin: database URI not set");
return NULL; return NULL;
} }
this = malloc_thing(private_attr_sql_plugin_t); INIT(this,
.public = {
.plugin = {
.destroy = _destroy
},
},
.db = lib->db->create(lib->db, uri)
);
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
this->db = lib->db->create(lib->db, uri);
if (!this->db) if (!this->db)
{ {
DBG1(DBG_CFG, "attr-sql plugin failed to connect to database"); DBG1(DBG_CFG, "attr-sql plugin failed to connect to database");