aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2011-09-29 23:15:49 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2011-09-29 23:15:49 +0200
commit769b490e05080bd100348b67e97bababe88f65ab (patch)
tree344fdd744799769ca12c4ff3397cb58636a07558 /src/libhydra
parent3cd78d98b7284433cf1eb327476edf3d0d483f98 (diff)
downloadstrongswan-769b490e05080bd100348b67e97bababe88f65ab.tar.bz2
strongswan-769b490e05080bd100348b67e97bababe88f65ab.tar.xz
Migrated resolve_handler to INIT/METHOD macros
Diffstat (limited to 'src/libhydra')
-rw-r--r--src/libhydra/plugins/resolve/resolve_handler.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/libhydra/plugins/resolve/resolve_handler.c b/src/libhydra/plugins/resolve/resolve_handler.c
index feb2fd05a..62376dcc6 100644
--- a/src/libhydra/plugins/resolve/resolve_handler.c
+++ b/src/libhydra/plugins/resolve/resolve_handler.c
@@ -44,11 +44,9 @@ struct private_resolve_handler_t {
mutex_t *mutex;
};
-/**
- * Implementation of attribute_handler_t.handle
- */
-static bool handle(private_resolve_handler_t *this, identification_t *server,
- configuration_attribute_type_t type, chunk_t data)
+METHOD(attribute_handler_t, handle, bool,
+ private_resolve_handler_t *this, identification_t *server,
+ configuration_attribute_type_t type, chunk_t data)
{
FILE *in, *out;
char buf[1024];
@@ -109,11 +107,9 @@ static bool handle(private_resolve_handler_t *this, identification_t *server,
return handled;
}
-/**
- * Implementation of attribute_handler_t.release
- */
-static void release(private_resolve_handler_t *this, identification_t *server,
- configuration_attribute_type_t type, chunk_t data)
+METHOD(attribute_handler_t, release,void,
+ private_resolve_handler_t *this, identification_t *server,
+ configuration_attribute_type_t type, chunk_t data)
{
FILE *in, *out;
char line[1024], matcher[512];
@@ -179,11 +175,9 @@ typedef struct {
host_t *vip;
} attribute_enumerator_t;
-/**
- * Implementation of create_attribute_enumerator().enumerate()
- */
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))
{
@@ -202,11 +196,8 @@ static bool attribute_enumerate(attribute_enumerator_t *this,
return TRUE;
}
-/**
- * Implementation of attribute_handler_t.create_attribute_enumerator
- */
-static enumerator_t* create_attribute_enumerator(private_resolve_handler_t *this,
- identification_t *server, host_t *vip)
+METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
+ private_resolve_handler_t *this, identification_t *server, host_t *vip)
{
if (vip)
{
@@ -222,10 +213,8 @@ static enumerator_t* create_attribute_enumerator(private_resolve_handler_t *this
return enumerator_create_empty();
}
-/**
- * Implementation of resolve_handler_t.destroy.
- */
-static void destroy(private_resolve_handler_t *this)
+METHOD(resolve_handler_t, destroy, void,
+ private_resolve_handler_t *this)
{
this->mutex->destroy(this->mutex);
free(this);
@@ -236,16 +225,21 @@ static void destroy(private_resolve_handler_t *this)
*/
resolve_handler_t *resolve_handler_create()
{
- private_resolve_handler_t *this = malloc_thing(private_resolve_handler_t);
-
- this->public.handler.handle = (bool(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
- this->public.handler.release = (void(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release;
- this->public.handler.create_attribute_enumerator = (enumerator_t*(*)(attribute_handler_t*, identification_t *server, host_t *vip))create_attribute_enumerator;
- this->public.destroy = (void(*)(resolve_handler_t*))destroy;
-
- this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
- this->file = lib->settings->get_str(lib->settings,
- "%s.plugins.resolve.file", RESOLV_CONF, hydra->daemon);
+ private_resolve_handler_t *this;
+
+ INIT(this,
+ .public = {
+ .handler = {
+ .handle = _handle,
+ .release = _release,
+ .create_attribute_enumerator = _create_attribute_enumerator,
+ },
+ .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;
}