Migrated resolve_handler to INIT/METHOD macros
This commit is contained in:
@@ -44,11 +44,9 @@ struct private_resolve_handler_t {
|
|||||||
mutex_t *mutex;
|
mutex_t *mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(attribute_handler_t, handle, bool,
|
||||||
* Implementation of attribute_handler_t.handle
|
private_resolve_handler_t *this, identification_t *server,
|
||||||
*/
|
configuration_attribute_type_t type, chunk_t data)
|
||||||
static bool handle(private_resolve_handler_t *this, identification_t *server,
|
|
||||||
configuration_attribute_type_t type, chunk_t data)
|
|
||||||
{
|
{
|
||||||
FILE *in, *out;
|
FILE *in, *out;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@@ -109,11 +107,9 @@ static bool handle(private_resolve_handler_t *this, identification_t *server,
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_handler_t, release,void,
|
||||||
* Implementation of attribute_handler_t.release
|
private_resolve_handler_t *this, identification_t *server,
|
||||||
*/
|
configuration_attribute_type_t type, chunk_t data)
|
||||||
static void release(private_resolve_handler_t *this, identification_t *server,
|
|
||||||
configuration_attribute_type_t type, chunk_t data)
|
|
||||||
{
|
{
|
||||||
FILE *in, *out;
|
FILE *in, *out;
|
||||||
char line[1024], matcher[512];
|
char line[1024], matcher[512];
|
||||||
@@ -179,11 +175,9 @@ typedef struct {
|
|||||||
host_t *vip;
|
host_t *vip;
|
||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of create_attribute_enumerator().enumerate()
|
|
||||||
*/
|
|
||||||
static bool attribute_enumerate(attribute_enumerator_t *this,
|
static bool attribute_enumerate(attribute_enumerator_t *this,
|
||||||
configuration_attribute_type_t *type, chunk_t *data)
|
configuration_attribute_type_t *type,
|
||||||
|
chunk_t *data)
|
||||||
{
|
{
|
||||||
switch (this->vip->get_family(this->vip))
|
switch (this->vip->get_family(this->vip))
|
||||||
{
|
{
|
||||||
@@ -202,11 +196,8 @@ static bool attribute_enumerate(attribute_enumerator_t *this,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
|
||||||
* Implementation of attribute_handler_t.create_attribute_enumerator
|
private_resolve_handler_t *this, identification_t *server, host_t *vip)
|
||||||
*/
|
|
||||||
static enumerator_t* create_attribute_enumerator(private_resolve_handler_t *this,
|
|
||||||
identification_t *server, host_t *vip)
|
|
||||||
{
|
{
|
||||||
if (vip)
|
if (vip)
|
||||||
{
|
{
|
||||||
@@ -222,10 +213,8 @@ static enumerator_t* create_attribute_enumerator(private_resolve_handler_t *this
|
|||||||
return enumerator_create_empty();
|
return enumerator_create_empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(resolve_handler_t, destroy, void,
|
||||||
* Implementation of resolve_handler_t.destroy.
|
private_resolve_handler_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_resolve_handler_t *this)
|
|
||||||
{
|
{
|
||||||
this->mutex->destroy(this->mutex);
|
this->mutex->destroy(this->mutex);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -236,16 +225,21 @@ static void destroy(private_resolve_handler_t *this)
|
|||||||
*/
|
*/
|
||||||
resolve_handler_t *resolve_handler_create()
|
resolve_handler_t *resolve_handler_create()
|
||||||
{
|
{
|
||||||
private_resolve_handler_t *this = malloc_thing(private_resolve_handler_t);
|
private_resolve_handler_t *this;
|
||||||
|
|
||||||
this->public.handler.handle = (bool(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
|
INIT(this,
|
||||||
this->public.handler.release = (void(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release;
|
.public = {
|
||||||
this->public.handler.create_attribute_enumerator = (enumerator_t*(*)(attribute_handler_t*, identification_t *server, host_t *vip))create_attribute_enumerator;
|
.handler = {
|
||||||
this->public.destroy = (void(*)(resolve_handler_t*))destroy;
|
.handle = _handle,
|
||||||
|
.release = _release,
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
.create_attribute_enumerator = _create_attribute_enumerator,
|
||||||
this->file = lib->settings->get_str(lib->settings,
|
},
|
||||||
"%s.plugins.resolve.file", RESOLV_CONF, hydra->daemon);
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||||
|
.file = lib->settings->get_str(lib->settings, "%s.plugins.resolve.file",
|
||||||
|
RESOLV_CONF, hydra->daemon),
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user