Migrated attr_sql_plugin_t to INIT/METHOD macros
This commit is contained in:
@@ -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);
|
||||
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)
|
||||
{
|
||||
DBG1(DBG_CFG, "attr-sql plugin failed to connect to database");
|
||||
|
||||
Reference in New Issue
Block a user