Migrated uci_creds_t to INIT/METHOD macros.

This commit is contained in:
Tobias Brunner
2011-10-04 14:34:25 +02:00
parent e751bc9aab
commit 66633c0580
+33 -35
View File
@@ -51,11 +51,9 @@ typedef struct {
identification_t *other; identification_t *other;
} shared_enumerator_t; } shared_enumerator_t;
/** METHOD(enumerator_t, shared_enumerator_enumerate, bool,
* Implementation of shared_enumerator_t.public.enumerate shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
*/ id_match_t *other)
static bool shared_enumerator_enumerate(shared_enumerator_t *this,
shared_key_t **key, id_match_t *me, id_match_t *other)
{ {
char *local_id, *remote_id, *psk; char *local_id, *remote_id, *psk;
identification_t *local, *remote; identification_t *local, *remote;
@@ -107,23 +105,17 @@ static bool shared_enumerator_enumerate(shared_enumerator_t *this,
return TRUE; return TRUE;
} }
/** METHOD(enumerator_t, shared_enumerator_destroy, void,
* Implementation of shared_enumerator_t.public.destroy shared_enumerator_t *this)
*/
static void shared_enumerator_destroy(shared_enumerator_t *this)
{ {
this->inner->destroy(this->inner); this->inner->destroy(this->inner);
DESTROY_IF(this->current); DESTROY_IF(this->current);
free(this); free(this);
} }
/** METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
* Implementation of backend_t.create_shared_cfg_enumerator. private_uci_creds_t *this, shared_key_type_t type,
*/ identification_t *me, identification_t *other)
static enumerator_t* create_shared_enumerator(private_uci_creds_t *this,
shared_key_type_t type,
identification_t *me,
identification_t *other)
{ {
shared_enumerator_t *e; shared_enumerator_t *e;
@@ -132,14 +124,16 @@ static enumerator_t* create_shared_enumerator(private_uci_creds_t *this,
return NULL; return NULL;
} }
e = malloc_thing(shared_enumerator_t); INIT(e,
e->current = NULL; .public = {
e->public.enumerate = (void*)shared_enumerator_enumerate; .enumerate = (void*)_shared_enumerator_enumerate,
e->public.destroy = (void*)shared_enumerator_destroy; .destroy = _shared_enumerator_destroy,
e->me = me; },
e->other = other; .me = me,
e->inner = this->parser->create_section_enumerator(this->parser, .other = other,
"local_id", "remote_id", "psk", NULL); .inner = this->parser->create_section_enumerator(this->parser,
"local_id", "remote_id", "psk", NULL),
);
if (!e->inner) if (!e->inner)
{ {
free(e); free(e);
@@ -148,24 +142,28 @@ static enumerator_t* create_shared_enumerator(private_uci_creds_t *this,
return &e->public; return &e->public;
} }
/** METHOD(uci_creds_t, destroy, void,
* Implementation of uci_creds_t.destroy private_uci_creds_t *this)
*/
static void destroy(private_uci_creds_t *this)
{ {
free(this); free(this);
} }
uci_creds_t *uci_creds_create(uci_parser_t *parser) uci_creds_t *uci_creds_create(uci_parser_t *parser)
{ {
private_uci_creds_t *this = malloc_thing(private_uci_creds_t); private_uci_creds_t *this;
this->public.credential_set.create_shared_enumerator = (enumerator_t*(*)(credential_set_t*, shared_key_type_t, identification_t*, identification_t*))create_shared_enumerator; INIT(this,
this->public.credential_set.create_private_enumerator = (enumerator_t*(*) (credential_set_t*, key_type_t, identification_t*))return_null; .public = {
this->public.credential_set.create_cert_enumerator = (enumerator_t*(*) (credential_set_t*, certificate_type_t, key_type_t,identification_t *, bool))return_null; .credential_set = {
this->public.credential_set.create_cdp_enumerator = (enumerator_t*(*) (credential_set_t *,certificate_type_t, identification_t *))return_null; .create_shared_enumerator = _create_shared_enumerator,
this->public.credential_set.cache_cert = (void (*)(credential_set_t *, certificate_t *))nop; .create_private_enumerator = (void*)return_null,
this->public.destroy = (void(*) (uci_creds_t*))destroy; .create_cert_enumerator = (void*)return_null,
.create_cdp_enumerator = (void*)return_null,
.cache_cert = (void*)nop,
},
.destroy = _destroy,
},
);
this->parser = parser; this->parser = parser;