Migrated attribute_manager to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-10-02 12:23:31 +02:00
parent 21ce22bb24
commit 71b6235ad8
+47 -75
View File
@@ -59,12 +59,9 @@ typedef struct {
host_t *vip; host_t *vip;
} enum_data_t; } enum_data_t;
/** METHOD(attribute_manager_t, acquire_address, host_t*,
* Implementation of attribute_manager_t.acquire_address. private_attribute_manager_t *this, char *pool, identification_t *id,
*/ host_t *requested)
static host_t* acquire_address(private_attribute_manager_t *this,
char *pool, identification_t *id,
host_t *requested)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
attribute_provider_t *current; attribute_provider_t *current;
@@ -90,11 +87,9 @@ static host_t* acquire_address(private_attribute_manager_t *this,
return host; return host;
} }
/** METHOD(attribute_manager_t, release_address, void,
* Implementation of attribute_manager_t.release_address. private_attribute_manager_t *this, char *pool, host_t *address,
*/ identification_t *id)
static void release_address(private_attribute_manager_t *this,
char *pool, host_t *address, identification_t *id)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
attribute_provider_t *current; attribute_provider_t *current;
@@ -129,12 +124,9 @@ static enumerator_t *responder_enum_create(attribute_provider_t *provider,
data->id, data->vip); data->id, data->vip);
} }
/** METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*,
* Implementation of attribute_manager_t.create_responder_enumerator private_attribute_manager_t *this, char *pool, identification_t *id,
*/ host_t *vip)
static enumerator_t* create_responder_enumerator(
private_attribute_manager_t *this, char *pool,
identification_t *id, host_t *vip)
{ {
enum_data_t *data = malloc_thing(enum_data_t); enum_data_t *data = malloc_thing(enum_data_t);
@@ -149,34 +141,26 @@ static enumerator_t* create_responder_enumerator(
(void*)this->lock->unlock, this->lock); (void*)this->lock->unlock, this->lock);
} }
/** METHOD(attribute_manager_t, add_provider, void,
* Implementation of attribute_manager_t.add_provider. private_attribute_manager_t *this, attribute_provider_t *provider)
*/
static void add_provider(private_attribute_manager_t *this,
attribute_provider_t *provider)
{ {
this->lock->write_lock(this->lock); this->lock->write_lock(this->lock);
this->providers->insert_last(this->providers, provider); this->providers->insert_last(this->providers, provider);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(attribute_manager_t, remove_provider, void,
* Implementation of attribute_manager_t.remove_provider. private_attribute_manager_t *this, attribute_provider_t *provider)
*/
static void remove_provider(private_attribute_manager_t *this,
attribute_provider_t *provider)
{ {
this->lock->write_lock(this->lock); this->lock->write_lock(this->lock);
this->providers->remove(this->providers, provider, NULL); this->providers->remove(this->providers, provider, NULL);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(attribute_manager_t, handle, attribute_handler_t*,
* Implementation of attribute_manager_t.handle private_attribute_manager_t *this, identification_t *server,
*/ attribute_handler_t *handler, configuration_attribute_type_t type,
static attribute_handler_t* handle(private_attribute_manager_t *this, chunk_t data)
identification_t *server, attribute_handler_t *handler,
configuration_attribute_type_t type, chunk_t data)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
attribute_handler_t *current, *handled = NULL; attribute_handler_t *current, *handled = NULL;
@@ -217,13 +201,9 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
return handled; return handled;
} }
/** METHOD(attribute_manager_t, release, void,
* Implementation of attribute_manager_t.release private_attribute_manager_t *this, attribute_handler_t *handler,
*/ identification_t *server, configuration_attribute_type_t type, chunk_t data)
static void release(private_attribute_manager_t *this,
attribute_handler_t *handler,
identification_t *server,
configuration_attribute_type_t type, chunk_t data)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
attribute_handler_t *current; attribute_handler_t *current;
@@ -297,11 +277,8 @@ static void initiator_destroy(initiator_enumerator_t *this)
free(this); free(this);
} }
/** METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*,
* Implementation of attribute_manager_t.create_initiator_enumerator private_attribute_manager_t *this, identification_t *id, host_t *vip)
*/
static enumerator_t* create_initiator_enumerator(
private_attribute_manager_t *this, identification_t *id, host_t *vip)
{ {
initiator_enumerator_t *enumerator = malloc_thing(initiator_enumerator_t); initiator_enumerator_t *enumerator = malloc_thing(initiator_enumerator_t);
@@ -318,32 +295,24 @@ static enumerator_t* create_initiator_enumerator(
return &enumerator->public; return &enumerator->public;
} }
/** METHOD(attribute_manager_t, add_handler, void,
* Implementation of attribute_manager_t.add_handler private_attribute_manager_t *this, attribute_handler_t *handler)
*/
static void add_handler(private_attribute_manager_t *this,
attribute_handler_t *handler)
{ {
this->lock->write_lock(this->lock); this->lock->write_lock(this->lock);
this->handlers->insert_last(this->handlers, handler); this->handlers->insert_last(this->handlers, handler);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(attribute_manager_t, remove_handler, void,
* Implementation of attribute_manager_t.remove_handler private_attribute_manager_t *this, attribute_handler_t *handler)
*/
static void remove_handler(private_attribute_manager_t *this,
attribute_handler_t *handler)
{ {
this->lock->write_lock(this->lock); this->lock->write_lock(this->lock);
this->handlers->remove(this->handlers, handler, NULL); this->handlers->remove(this->handlers, handler, NULL);
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(attribute_manager_t, destroy, void,
* Implementation of attribute_manager_t.destroy private_attribute_manager_t *this)
*/
static void destroy(private_attribute_manager_t *this)
{ {
this->providers->destroy(this->providers); this->providers->destroy(this->providers);
this->handlers->destroy(this->handlers); this->handlers->destroy(this->handlers);
@@ -356,23 +325,26 @@ static void destroy(private_attribute_manager_t *this)
*/ */
attribute_manager_t *attribute_manager_create() attribute_manager_t *attribute_manager_create()
{ {
private_attribute_manager_t *this = malloc_thing(private_attribute_manager_t); private_attribute_manager_t *this;
this->public.acquire_address = (host_t*(*)(attribute_manager_t*, char*, identification_t*,host_t*))acquire_address; INIT(this,
this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*, identification_t*))release_address; .public = {
this->public.create_responder_enumerator = (enumerator_t*(*)(attribute_manager_t*, char *name, identification_t*, host_t*))create_responder_enumerator; .acquire_address = _acquire_address,
this->public.add_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))add_provider; .release_address = _release_address,
this->public.remove_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))remove_provider; .create_responder_enumerator = _create_responder_enumerator,
this->public.handle = (attribute_handler_t*(*)(attribute_manager_t*,identification_t*, attribute_handler_t*, configuration_attribute_type_t, chunk_t))handle; .add_provider = _add_provider,
this->public.release = (void(*)(attribute_manager_t*, attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release; .remove_provider = _remove_provider,
this->public.create_initiator_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_initiator_enumerator; .handle = _handle,
this->public.add_handler = (void(*)(attribute_manager_t*, attribute_handler_t*))add_handler; .release = _release,
this->public.remove_handler = (void(*)(attribute_manager_t*, attribute_handler_t*))remove_handler; .create_initiator_enumerator = _create_initiator_enumerator,
this->public.destroy = (void(*)(attribute_manager_t*))destroy; .add_handler = _add_handler,
.remove_handler = _remove_handler,
this->providers = linked_list_create(); .destroy = _destroy,
this->handlers = linked_list_create(); },
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT); .providers = linked_list_create(),
.handlers = linked_list_create(),
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
);
return &this->public; return &this->public;
} }