};
-/**
- * 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);
*/
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");