Migrated sql_attribute to INIT/METHOD macros
This commit is contained in:
@@ -232,12 +232,9 @@ static host_t* get_lease(private_sql_attribute_t *this, char *name,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_provider_t, acquire_address, host_t*,
|
||||||
* Implementation of attribute_provider_t.acquire_address
|
private_sql_attribute_t *this, char *names, identification_t *id,
|
||||||
*/
|
host_t *requested)
|
||||||
static host_t* acquire_address(private_sql_attribute_t *this,
|
|
||||||
char *names, identification_t *id,
|
|
||||||
host_t *requested)
|
|
||||||
{
|
{
|
||||||
host_t *address = NULL;
|
host_t *address = NULL;
|
||||||
u_int identity, pool, timeout;
|
u_int identity, pool, timeout;
|
||||||
@@ -302,11 +299,9 @@ static host_t* acquire_address(private_sql_attribute_t *this,
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_provider_t, release_address, bool,
|
||||||
* Implementation of attribute_provider_t.release_address
|
private_sql_attribute_t *this, char *name, host_t *address,
|
||||||
*/
|
identification_t *id)
|
||||||
static bool release_address(private_sql_attribute_t *this,
|
|
||||||
char *name, host_t *address, identification_t *id)
|
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
bool found = FALSE;
|
bool found = FALSE;
|
||||||
@@ -343,11 +338,9 @@ static bool release_address(private_sql_attribute_t *this,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
||||||
* Implementation of sql_attribute_t.create_attribute_enumerator
|
private_sql_attribute_t *this, char *names, identification_t *id,
|
||||||
*/
|
host_t *vip)
|
||||||
static enumerator_t* create_attribute_enumerator(private_sql_attribute_t *this,
|
|
||||||
char *names, identification_t *id, host_t *vip)
|
|
||||||
{
|
{
|
||||||
enumerator_t *attr_enumerator = NULL;
|
enumerator_t *attr_enumerator = NULL;
|
||||||
|
|
||||||
@@ -444,10 +437,8 @@ static enumerator_t* create_attribute_enumerator(private_sql_attribute_t *this,
|
|||||||
return (attr_enumerator ? attr_enumerator : enumerator_create_empty());
|
return (attr_enumerator ? attr_enumerator : enumerator_create_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(sql_attribute_t, destroy, void,
|
||||||
* Implementation of sql_attribute_t.destroy
|
private_sql_attribute_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_sql_attribute_t *this)
|
|
||||||
{
|
{
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
@@ -457,17 +448,22 @@ static void destroy(private_sql_attribute_t *this)
|
|||||||
*/
|
*/
|
||||||
sql_attribute_t *sql_attribute_create(database_t *db)
|
sql_attribute_t *sql_attribute_create(database_t *db)
|
||||||
{
|
{
|
||||||
private_sql_attribute_t *this = malloc_thing(private_sql_attribute_t);
|
private_sql_attribute_t *this;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *, host_t *))acquire_address;
|
INIT(this,
|
||||||
this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))release_address;
|
.public = {
|
||||||
this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, char *names, identification_t *id, host_t *host))create_attribute_enumerator;
|
.provider = {
|
||||||
this->public.destroy = (void(*)(sql_attribute_t*))destroy;
|
.acquire_address = _acquire_address,
|
||||||
|
.release_address = _release_address,
|
||||||
this->db = db;
|
.create_attribute_enumerator = _create_attribute_enumerator,
|
||||||
this->history = lib->settings->get_bool(lib->settings,
|
},
|
||||||
"libhydra.plugins.attr-sql.lease_history", TRUE);
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.db = db,
|
||||||
|
.history = lib->settings->get_bool(lib->settings,
|
||||||
|
"libhydra.plugins.attr-sql.lease_history", TRUE),
|
||||||
|
);
|
||||||
|
|
||||||
/* close any "online" leases in the case we crashed */
|
/* close any "online" leases in the case we crashed */
|
||||||
if (this->history)
|
if (this->history)
|
||||||
|
|||||||
Reference in New Issue
Block a user