Migrate all enumerators to venumerate() interface change
This commit is contained in:
@@ -504,11 +504,12 @@ typedef struct {
|
||||
ike_cfg_t *current;
|
||||
} ike_enumerator_t;
|
||||
|
||||
/**
|
||||
* Implementation of ike_enumerator_t.public.enumerate
|
||||
*/
|
||||
static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
||||
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
||||
ike_enumerator_t *this, va_list args)
|
||||
{
|
||||
ike_cfg_t **cfg;
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
DESTROY_IF(this->current);
|
||||
this->current = build_ike_cfg(this->this, this->inner, this->me, this->other);
|
||||
if (this->current)
|
||||
@@ -519,10 +520,8 @@ static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ike_enumerator_t.public.destroy
|
||||
*/
|
||||
static void ike_enumerator_destroy(ike_enumerator_t *this)
|
||||
METHOD(enumerator_t, ike_enumerator_destroy, void,
|
||||
ike_enumerator_t *this)
|
||||
{
|
||||
DESTROY_IF(this->current);
|
||||
this->inner->destroy(this->inner);
|
||||
@@ -532,19 +531,22 @@ static void ike_enumerator_destroy(ike_enumerator_t *this)
|
||||
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||
private_sql_config_t *this, host_t *me, host_t *other)
|
||||
{
|
||||
ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
|
||||
|
||||
e->this = this;
|
||||
e->me = me;
|
||||
e->other = other;
|
||||
e->current = NULL;
|
||||
e->public.enumerate = (void*)ike_enumerator_enumerate;
|
||||
e->public.destroy = (void*)ike_enumerator_destroy;
|
||||
ike_enumerator_t *e;
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _ike_enumerator_enumerate,
|
||||
.destroy = _ike_enumerator_destroy,
|
||||
},
|
||||
.this = this,
|
||||
.me = me,
|
||||
.other = other,
|
||||
);
|
||||
e->inner = this->db->query(this->db,
|
||||
"SELECT id, certreq, force_encap, local, remote "
|
||||
"FROM ike_configs",
|
||||
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
||||
"SELECT id, certreq, force_encap, local, remote "
|
||||
"FROM ike_configs",
|
||||
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
||||
if (!e->inner)
|
||||
{
|
||||
free(e);
|
||||
@@ -569,11 +571,12 @@ typedef struct {
|
||||
peer_cfg_t *current;
|
||||
} peer_enumerator_t;
|
||||
|
||||
/**
|
||||
* Implementation of peer_enumerator_t.public.enumerate
|
||||
*/
|
||||
static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
peer_enumerator_t *this, va_list args)
|
||||
{
|
||||
peer_cfg_t **cfg;
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
DESTROY_IF(this->current);
|
||||
this->current = build_peer_cfg(this->this, this->inner, this->me, this->other);
|
||||
if (this->current)
|
||||
@@ -584,10 +587,8 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of peer_enumerator_t.public.destroy
|
||||
*/
|
||||
static void peer_enumerator_destroy(peer_enumerator_t *this)
|
||||
METHOD(enumerator_t, peer_enumerator_destroy, void,
|
||||
peer_enumerator_t *this)
|
||||
{
|
||||
DESTROY_IF(this->current);
|
||||
this->inner->destroy(this->inner);
|
||||
@@ -599,12 +600,16 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||
{
|
||||
peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
|
||||
|
||||
e->this = this;
|
||||
e->me = me;
|
||||
e->other = other;
|
||||
e->current = NULL;
|
||||
e->public.enumerate = (void*)peer_enumerator_enumerate;
|
||||
e->public.destroy = (void*)peer_enumerator_destroy;
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _peer_enumerator_enumerate,
|
||||
.destroy = _peer_enumerator_destroy,
|
||||
},
|
||||
.this = this,
|
||||
.me = me,
|
||||
.other = other,
|
||||
);
|
||||
|
||||
/* TODO: only get configs whose IDs match exactly or contain wildcards */
|
||||
e->inner = this->db->query(this->db,
|
||||
|
||||
@@ -52,11 +52,14 @@ typedef struct {
|
||||
} private_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, private_enumerator_enumerate, bool,
|
||||
private_enumerator_t *this, private_key_t **key)
|
||||
private_enumerator_t *this, va_list args)
|
||||
{
|
||||
private_key_t **key;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, key);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -88,7 +91,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_private_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _private_enumerator_enumerate,
|
||||
.destroy = _private_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
@@ -132,11 +136,14 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t **cert;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -169,7 +176,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
@@ -221,12 +229,15 @@ typedef struct {
|
||||
} shared_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
||||
shared_enumerator_t *this, shared_key_t **shared,
|
||||
id_match_t *me, id_match_t *other)
|
||||
shared_enumerator_t *this, va_list args)
|
||||
{
|
||||
shared_key_t **shared;
|
||||
id_match_t *me, *other;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, shared, me, other);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -265,7 +276,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_shared_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _shared_enumerator_enumerate,
|
||||
.destroy = _shared_enumerator_destroy,
|
||||
},
|
||||
.me = me,
|
||||
@@ -340,9 +352,11 @@ typedef enum {
|
||||
} cdp_type_t;
|
||||
|
||||
METHOD(enumerator_t, cdp_enumerator_enumerate, bool,
|
||||
cdp_enumerator_t *this, char **uri)
|
||||
cdp_enumerator_t *this, va_list args)
|
||||
{
|
||||
char *text;
|
||||
char *text, **uri;
|
||||
|
||||
VA_ARGS_VGET(args, uri);
|
||||
|
||||
free(this->current);
|
||||
while (this->inner->enumerate(this->inner, &text))
|
||||
@@ -384,7 +398,8 @@ METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
|
||||
}
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cdp_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cdp_enumerator_enumerate,
|
||||
.destroy = _cdp_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user