Migrate all enumerators to venumerate() interface change
This commit is contained in:
@@ -146,12 +146,14 @@ typedef struct {
|
||||
bool enumerated[AUTH_RULE_MAX];
|
||||
} entry_enumerator_t;
|
||||
|
||||
/**
|
||||
* enumerate function for item_enumerator_t
|
||||
*/
|
||||
static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
|
||||
METHOD(enumerator_t, enumerate, bool,
|
||||
entry_enumerator_t *this, va_list args)
|
||||
{
|
||||
auth_rule_t *type;
|
||||
entry_t *entry;
|
||||
void **value;
|
||||
|
||||
VA_ARGS_VGET(args, type, value);
|
||||
|
||||
while (this->inner->enumerate(this->inner, &entry))
|
||||
{
|
||||
@@ -174,10 +176,8 @@ static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy function for item_enumerator_t
|
||||
*/
|
||||
static void entry_enumerator_destroy(entry_enumerator_t *this)
|
||||
METHOD(enumerator_t, entry_enumerator_destroy, void,
|
||||
entry_enumerator_t *this)
|
||||
{
|
||||
this->inner->destroy(this->inner);
|
||||
free(this);
|
||||
@@ -190,8 +190,9 @@ METHOD(auth_cfg_t, create_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)enumerate,
|
||||
.destroy = (void*)entry_enumerator_destroy,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate,
|
||||
.destroy = _entry_enumerator_destroy,
|
||||
},
|
||||
.inner = array_create_enumerator(this->entries),
|
||||
);
|
||||
|
||||
@@ -155,8 +155,12 @@ METHOD(credential_manager_t, call_hook, void,
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, sets_enumerate, bool,
|
||||
sets_enumerator_t *this, credential_set_t **set)
|
||||
sets_enumerator_t *this, va_list args)
|
||||
{
|
||||
credential_set_t **set;
|
||||
|
||||
VA_ARGS_VGET(args, set);
|
||||
|
||||
if (this->exclusive)
|
||||
{
|
||||
if (this->exclusive->enumerate(this->exclusive, set))
|
||||
@@ -202,7 +206,8 @@ static enumerator_t *create_sets_enumerator(private_credential_manager_t *this)
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_sets_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _sets_enumerate,
|
||||
.destroy = _sets_destroy,
|
||||
},
|
||||
);
|
||||
@@ -840,9 +845,12 @@ typedef struct {
|
||||
} trusted_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, trusted_enumerate, bool,
|
||||
trusted_enumerator_t *this, certificate_t **cert, auth_cfg_t **auth)
|
||||
trusted_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t *current;
|
||||
certificate_t *current, **cert;
|
||||
auth_cfg_t **auth;
|
||||
|
||||
VA_ARGS_VGET(args, cert, auth);
|
||||
|
||||
DESTROY_IF(this->auth);
|
||||
this->auth = auth_cfg_create();
|
||||
@@ -931,7 +939,8 @@ METHOD(credential_manager_t, create_trusted_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_trusted_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _trusted_enumerate,
|
||||
.destroy = _trusted_destroy,
|
||||
},
|
||||
.this = this,
|
||||
@@ -960,9 +969,13 @@ typedef struct {
|
||||
} public_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, public_enumerate, bool,
|
||||
public_enumerator_t *this, public_key_t **key, auth_cfg_t **auth)
|
||||
public_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t *cert;
|
||||
public_key_t **key;
|
||||
auth_cfg_t **auth;
|
||||
|
||||
VA_ARGS_VGET(args, key, auth);
|
||||
|
||||
while (this->inner->enumerate(this->inner, &cert, auth))
|
||||
{
|
||||
@@ -1001,7 +1014,8 @@ METHOD(credential_manager_t, create_public_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_public_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _public_enumerate,
|
||||
.destroy = _public_destroy,
|
||||
},
|
||||
.inner = create_trusted_enumerator(this, type, id, online),
|
||||
|
||||
@@ -272,8 +272,12 @@ typedef struct {
|
||||
} private_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, signature_schemes_enumerate, bool,
|
||||
private_enumerator_t *this, signature_scheme_t *scheme)
|
||||
private_enumerator_t *this, va_list args)
|
||||
{
|
||||
signature_scheme_t *scheme;
|
||||
|
||||
VA_ARGS_VGET(args, scheme);
|
||||
|
||||
while (++this->index < countof(scheme_map))
|
||||
{
|
||||
if (this->type == scheme_map[this->index].type &&
|
||||
@@ -296,7 +300,8 @@ enumerator_t *signature_schemes_for_key(key_type_t type, int size)
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.enumerate = (void*)_signature_schemes_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _signature_schemes_enumerate,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
.index = -1,
|
||||
|
||||
@@ -112,15 +112,15 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* enumerate function for wrapper_enumerator_t
|
||||
*/
|
||||
static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
||||
METHOD(enumerator_t, enumerate, bool,
|
||||
wrapper_enumerator_t *this, va_list args)
|
||||
{
|
||||
auth_rule_t rule;
|
||||
certificate_t *current;
|
||||
certificate_t *current, **cert;
|
||||
public_key_t *public;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
while (this->inner->enumerate(this->inner, &rule, ¤t))
|
||||
{
|
||||
if (rule == AUTH_HELPER_IM_HASH_URL ||
|
||||
@@ -164,10 +164,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy function for wrapper_enumerator_t
|
||||
*/
|
||||
static void wrapper_enumerator_destroy(wrapper_enumerator_t *this)
|
||||
METHOD(enumerator_t, wrapper_enumerator_destroy, void,
|
||||
wrapper_enumerator_t *this)
|
||||
{
|
||||
this->inner->destroy(this->inner);
|
||||
free(this);
|
||||
@@ -183,14 +181,18 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
enumerator = malloc_thing(wrapper_enumerator_t);
|
||||
enumerator->auth = this->auth;
|
||||
enumerator->cert = cert;
|
||||
enumerator->key = key;
|
||||
enumerator->id = id;
|
||||
enumerator->inner = this->auth->create_enumerator(this->auth);
|
||||
enumerator->public.enumerate = (void*)enumerate;
|
||||
enumerator->public.destroy = (void*)wrapper_enumerator_destroy;
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate,
|
||||
.destroy = _wrapper_enumerator_destroy,
|
||||
},
|
||||
.auth = this->auth,
|
||||
.cert = cert,
|
||||
.key = key,
|
||||
.id = id,
|
||||
.inner = this->auth->create_enumerator(this->auth),
|
||||
);
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,12 @@ typedef struct {
|
||||
} shared_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, shared_enumerate, bool,
|
||||
shared_enumerator_t *this, shared_key_t **out,
|
||||
id_match_t *match_me, id_match_t *match_other)
|
||||
shared_enumerator_t *this, va_list args)
|
||||
{
|
||||
shared_key_t **out;
|
||||
id_match_t *match_me, *match_other;
|
||||
|
||||
VA_ARGS_VGET(args, out, match_me, match_other);
|
||||
DESTROY_IF(this->current);
|
||||
this->current = this->this->cb.shared(this->this->data, this->type,
|
||||
this->me, this->other, match_me, match_other);
|
||||
@@ -89,7 +92,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_shared_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _shared_enumerate,
|
||||
.destroy = _shared_destroy,
|
||||
},
|
||||
.this = this,
|
||||
|
||||
@@ -252,13 +252,14 @@ typedef struct {
|
||||
int locked;
|
||||
} cert_enumerator_t;
|
||||
|
||||
/**
|
||||
* filter function for certs enumerator
|
||||
*/
|
||||
static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
|
||||
METHOD(enumerator_t, cert_enumerate, bool,
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
public_key_t *public;
|
||||
relation_t *rel;
|
||||
certificate_t **out;
|
||||
|
||||
VA_ARGS_VGET(args, out);
|
||||
|
||||
if (this->locked >= 0)
|
||||
{
|
||||
@@ -311,10 +312,8 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* clean up enumeration data
|
||||
*/
|
||||
static void cert_enumerator_destroy(cert_enumerator_t *this)
|
||||
METHOD(enumerator_t, cert_enumerator_destroy, void,
|
||||
cert_enumerator_t *this)
|
||||
{
|
||||
relation_t *rel;
|
||||
|
||||
@@ -336,16 +335,19 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
enumerator = malloc_thing(cert_enumerator_t);
|
||||
enumerator->public.enumerate = (void*)cert_enumerate;
|
||||
enumerator->public.destroy = (void*)cert_enumerator_destroy;
|
||||
enumerator->cert = cert;
|
||||
enumerator->key = key;
|
||||
enumerator->id = id;
|
||||
enumerator->relations = this->relations;
|
||||
enumerator->index = -1;
|
||||
enumerator->locked = -1;
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
.cert = cert,
|
||||
.key = key,
|
||||
.id = id,
|
||||
.relations = this->relations,
|
||||
.index = -1,
|
||||
.locked = -1,
|
||||
);
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,15 @@ typedef struct {
|
||||
identification_t *id;
|
||||
} wrapper_enumerator_t;
|
||||
|
||||
/**
|
||||
* enumerate function wrapper_enumerator_t
|
||||
*/
|
||||
static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
||||
METHOD(enumerator_t, enumerate, bool,
|
||||
wrapper_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t *current;
|
||||
certificate_t *current, **cert;
|
||||
public_key_t *public;
|
||||
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
while (this->inner->enumerate(this->inner, ¤t))
|
||||
{
|
||||
if (this->cert != CERT_ANY && this->cert != current->get_type(current))
|
||||
@@ -85,10 +86,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy function for wrapper_enumerator_t
|
||||
*/
|
||||
static void enumerator_destroy(wrapper_enumerator_t *this)
|
||||
METHOD(enumerator_t, enumerator_destroy, void,
|
||||
wrapper_enumerator_t *this)
|
||||
{
|
||||
this->inner->destroy(this->inner);
|
||||
free(this);
|
||||
@@ -105,13 +104,17 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enumerator = malloc_thing(wrapper_enumerator_t);
|
||||
enumerator->cert = cert;
|
||||
enumerator->key = key;
|
||||
enumerator->id = id;
|
||||
enumerator->inner = this->response->create_cert_enumerator(this->response);
|
||||
enumerator->public.enumerate = (void*)enumerate;
|
||||
enumerator->public.destroy = (void*)enumerator_destroy;
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate,
|
||||
.destroy = _enumerator_destroy,
|
||||
},
|
||||
.cert = cert,
|
||||
.key = key,
|
||||
.id = id,
|
||||
.inner = this->response->create_cert_enumerator(this->response),
|
||||
);
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user