Migrate all enumerators to venumerate() interface change
This commit is contained in:
@@ -235,9 +235,13 @@ typedef struct {
|
|||||||
} shared_enumerator_t;
|
} shared_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, shared_enumerate, bool,
|
METHOD(enumerator_t, shared_enumerate, bool,
|
||||||
shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
|
shared_enumerator_t *this, va_list args)
|
||||||
id_match_t *other)
|
|
||||||
{
|
{
|
||||||
|
shared_key_t **key;
|
||||||
|
id_match_t *me, *other;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key, me, other);
|
||||||
|
|
||||||
if (this->done)
|
if (this->done)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -307,7 +311,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_shared_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _shared_enumerate,
|
||||||
.destroy = _shared_destroy,
|
.destroy = _shared_destroy,
|
||||||
},
|
},
|
||||||
.this = this,
|
.this = this,
|
||||||
|
|||||||
@@ -65,29 +65,33 @@ METHOD(attribute_handler_t, handle, bool,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_nbns, bool,
|
||||||
* Implementation of create_attribute_enumerator().enumerate() for WINS
|
enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_nbns(enumerator_t *this,
|
|
||||||
configuration_attribute_type_t *type, chunk_t *data)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP4_NBNS;
|
*type = INTERNAL_IP4_NBNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
/* done */
|
this->venumerate = (void*)return_false;
|
||||||
this->enumerate = (void*)return_false;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of create_attribute_enumerator().enumerate() for DNS
|
* Implementation of create_attribute_enumerator().enumerate() for DNS
|
||||||
*/
|
*/
|
||||||
static bool enumerate_dns(enumerator_t *this,
|
METHOD(enumerator_t, enumerate_dns, bool,
|
||||||
configuration_attribute_type_t *type, chunk_t *data)
|
enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP4_DNS;
|
*type = INTERNAL_IP4_DNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
/* enumerate WINS server as next attribute ... */
|
/* enumerate WINS server as next attribute ... */
|
||||||
this->enumerate = (void*)enumerate_nbns;
|
this->venumerate = _enumerate_nbns;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +104,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
/* enumerate DNS attribute first ... */
|
/* enumerate DNS attribute first ... */
|
||||||
.enumerate = (void*)enumerate_dns,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_dns,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
);
|
);
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|||||||
+6
-3
@@ -267,10 +267,12 @@ typedef struct {
|
|||||||
} template_enumerator_t;
|
} template_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, template_enumerate, bool,
|
METHOD(enumerator_t, template_enumerate, bool,
|
||||||
template_enumerator_t *this, char **template)
|
template_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *rel;
|
char *rel, **template;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, template);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, &rel, NULL, &st))
|
while (this->inner->enumerate(this->inner, &rel, NULL, &st))
|
||||||
{
|
{
|
||||||
@@ -296,7 +298,8 @@ METHOD(dumm_t, create_template_enumerator, enumerator_t*,
|
|||||||
template_enumerator_t *enumerator;
|
template_enumerator_t *enumerator;
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_template_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _template_enumerate,
|
||||||
.destroy = (void*)_template_enumerator_destroy,
|
.destroy = (void*)_template_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = enumerator_create_directory(TEMPLATE_DIR),
|
.inner = enumerator_create_directory(TEMPLATE_DIR),
|
||||||
|
|||||||
@@ -73,20 +73,28 @@ METHOD(attribute_handler_t, release, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_dns6, bool,
|
METHOD(enumerator_t, enumerate_dns6, bool,
|
||||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP6_DNS;
|
*type = INTERNAL_IP6_DNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
this->enumerate = (void*)return_false;
|
this->venumerate = (void*)return_false;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_dns4, bool,
|
METHOD(enumerator_t, enumerate_dns4, bool,
|
||||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP4_DNS;
|
*type = INTERNAL_IP4_DNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
this->enumerate = (void*)_enumerate_dns6;
|
this->venumerate = _enumerate_dns6;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +104,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerate = (void*)_enumerate_dns4,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_dns4,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
);
|
);
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|||||||
@@ -237,14 +237,14 @@ typedef struct {
|
|||||||
linked_list_t *vips;
|
linked_list_t *vips;
|
||||||
} initiator_enumerator_t;
|
} initiator_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, initiator_enumerate, bool,
|
||||||
* Enumerator implementation for initiator attributes
|
initiator_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool initiator_enumerate(initiator_enumerator_t *this,
|
|
||||||
attribute_handler_t **handler,
|
|
||||||
configuration_attribute_type_t *type,
|
|
||||||
chunk_t *value)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
attribute_handler_t **handler;
|
||||||
|
chunk_t *value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, handler, type, value);
|
||||||
/* enumerate inner attributes using outer handler enumerator */
|
/* enumerate inner attributes using outer handler enumerator */
|
||||||
while (!this->inner || !this->inner->enumerate(this->inner, type, value))
|
while (!this->inner || !this->inner->enumerate(this->inner, type, value))
|
||||||
{
|
{
|
||||||
@@ -261,10 +261,8 @@ static bool initiator_enumerate(initiator_enumerator_t *this,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, initiator_destroy, void,
|
||||||
* Cleanup function of initiator attribute enumerator
|
initiator_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void initiator_destroy(initiator_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
this->this->lock->unlock(this->this->lock);
|
this->this->lock->unlock(this->this->lock);
|
||||||
this->outer->destroy(this->outer);
|
this->outer->destroy(this->outer);
|
||||||
@@ -281,8 +279,9 @@ METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)initiator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)initiator_destroy,
|
.venumerate = _initiator_enumerate,
|
||||||
|
.destroy = _initiator_destroy,
|
||||||
},
|
},
|
||||||
.this = this,
|
.this = this,
|
||||||
.ike_sa = ike_sa,
|
.ike_sa = ike_sa,
|
||||||
|
|||||||
@@ -512,10 +512,15 @@ typedef struct {
|
|||||||
} lease_enumerator_t;
|
} lease_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, lease_enumerate, bool,
|
METHOD(enumerator_t, lease_enumerate, bool,
|
||||||
lease_enumerator_t *this, identification_t **id, host_t **addr, bool *online)
|
lease_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
u_int *offset;
|
identification_t **id;
|
||||||
unique_lease_t *lease;
|
unique_lease_t *lease;
|
||||||
|
host_t **addr;
|
||||||
|
u_int *offset;
|
||||||
|
bool *online;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, id, addr, online);
|
||||||
|
|
||||||
DESTROY_IF(this->addr);
|
DESTROY_IF(this->addr);
|
||||||
this->addr = NULL;
|
this->addr = NULL;
|
||||||
@@ -570,7 +575,8 @@ METHOD(mem_pool_t, create_lease_enumerator, enumerator_t*,
|
|||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_lease_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _lease_enumerate,
|
||||||
.destroy = _lease_enumerator_destroy,
|
.destroy = _lease_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.pool = this,
|
.pool = this,
|
||||||
|
|||||||
@@ -209,9 +209,12 @@ typedef struct {
|
|||||||
} child_cfgs_replace_enumerator_t;
|
} child_cfgs_replace_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, child_cfgs_replace_enumerate, bool,
|
METHOD(enumerator_t, child_cfgs_replace_enumerate, bool,
|
||||||
child_cfgs_replace_enumerator_t *this, child_cfg_t **chd, bool *added)
|
child_cfgs_replace_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg, **chd;
|
||||||
|
bool *added;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, chd, added);
|
||||||
|
|
||||||
if (!this->wrapped)
|
if (!this->wrapped)
|
||||||
{
|
{
|
||||||
@@ -303,8 +306,9 @@ METHOD(peer_cfg_t, replace_child_cfgs, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_child_cfgs_replace_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)_child_cfgs_replace_enumerator_destroy,
|
.venumerate = _child_cfgs_replace_enumerate,
|
||||||
|
.destroy = _child_cfgs_replace_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.removed = removed,
|
.removed = removed,
|
||||||
.added = added,
|
.added = added,
|
||||||
@@ -336,8 +340,11 @@ METHOD(enumerator_t, child_cfg_enumerator_destroy, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, child_cfg_enumerate, bool,
|
METHOD(enumerator_t, child_cfg_enumerate, bool,
|
||||||
child_cfg_enumerator_t *this, child_cfg_t **chd)
|
child_cfg_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
child_cfg_t **chd;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, chd);
|
||||||
return this->wrapped->enumerate(this->wrapped, chd);
|
return this->wrapped->enumerate(this->wrapped, chd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,8 +355,9 @@ METHOD(peer_cfg_t, create_child_cfg_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_child_cfg_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)_child_cfg_enumerator_destroy,
|
.venumerate = _child_cfg_enumerate,
|
||||||
|
.destroy = _child_cfg_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.mutex = this->mutex,
|
.mutex = this->mutex,
|
||||||
.wrapped = this->child_cfgs->create_enumerator(this->child_cfgs),
|
.wrapped = this->child_cfgs->create_enumerator(this->child_cfgs),
|
||||||
|
|||||||
@@ -190,8 +190,12 @@ struct keyid_enumerator_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
METHOD(enumerator_t, keyid_enumerate, bool,
|
METHOD(enumerator_t, keyid_enumerate, bool,
|
||||||
keyid_enumerator_t *this, chunk_t *chunk)
|
keyid_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
chunk_t *chunk;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, chunk);
|
||||||
|
|
||||||
if (this->pos == NULL)
|
if (this->pos == NULL)
|
||||||
{
|
{
|
||||||
this->pos = this->full.ptr;
|
this->pos = this->full.ptr;
|
||||||
@@ -224,7 +228,8 @@ METHOD(certreq_payload_t, create_keyid_enumerator, enumerator_t*,
|
|||||||
}
|
}
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_keyid_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _keyid_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.full = this->data,
|
.full = this->data,
|
||||||
|
|||||||
@@ -306,8 +306,12 @@ typedef struct {
|
|||||||
} spi_enumerator_t;
|
} spi_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, spis_enumerate, bool,
|
METHOD(enumerator_t, spis_enumerate, bool,
|
||||||
spi_enumerator_t *this, uint32_t *spi)
|
spi_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
uint32_t *spi;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, spi);
|
||||||
|
|
||||||
if (this->spis.len >= sizeof(*spi))
|
if (this->spis.len >= sizeof(*spi))
|
||||||
{
|
{
|
||||||
memcpy(spi, this->spis.ptr, sizeof(*spi));
|
memcpy(spi, this->spis.ptr, sizeof(*spi));
|
||||||
@@ -328,7 +332,8 @@ METHOD(delete_payload_t, create_spi_enumerator, enumerator_t*,
|
|||||||
}
|
}
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_spis_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _spis_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.spis = this->spis,
|
.spis = this->spis,
|
||||||
|
|||||||
@@ -270,8 +270,12 @@ typedef struct {
|
|||||||
} type_enumerator_t;
|
} type_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_types, bool,
|
METHOD(enumerator_t, enumerate_types, bool,
|
||||||
type_enumerator_t *this, eap_type_t *type, uint32_t *vendor)
|
type_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
eap_type_t *type;
|
||||||
|
uint32_t *vendor;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, vendor);
|
||||||
this->offset = extract_type(this->payload, this->offset, type, vendor);
|
this->offset = extract_type(this->payload, this->offset, type, vendor);
|
||||||
return this->offset;
|
return this->offset;
|
||||||
}
|
}
|
||||||
@@ -289,7 +293,8 @@ METHOD(eap_payload_t, get_types, enumerator_t*,
|
|||||||
{
|
{
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_types,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_types,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.payload = this,
|
.payload = this,
|
||||||
|
|||||||
@@ -182,12 +182,15 @@ METHOD(attribute_handler_t, release, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_dns, bool,
|
METHOD(enumerator_t, enumerate_dns, bool,
|
||||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP4_DNS;
|
*type = INTERNAL_IP4_DNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
/* stop enumeration */
|
this->venumerate = return_false;
|
||||||
this->enumerate = (void*)return_false;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +201,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerate = (void*)_enumerate_dns,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_dns,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
);
|
);
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|||||||
@@ -75,12 +75,15 @@ typedef struct {
|
|||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||||
cert_enumerator_t *this, certificate_t **cert)
|
cert_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
certificate_t **cert;
|
||||||
dnscert_t *cur_crt;
|
dnscert_t *cur_crt;
|
||||||
rr_t *cur_rr;
|
rr_t *cur_rr;
|
||||||
chunk_t certificate;
|
chunk_t certificate;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
/* Get the next supported CERT using the inner enumerator. */
|
/* Get the next supported CERT using the inner enumerator. */
|
||||||
while (this->inner->enumerate(this->inner, &cur_rr))
|
while (this->inner->enumerate(this->inner, &cur_rr))
|
||||||
{
|
{
|
||||||
@@ -175,7 +178,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerator_enumerate,
|
||||||
.destroy = _cert_enumerator_destroy,
|
.destroy = _cert_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = response->get_rr_set(response)->create_rr_enumerator(
|
.inner = response->get_rr_set(response)->create_rr_enumerator(
|
||||||
|
|||||||
@@ -404,11 +404,13 @@ typedef struct {
|
|||||||
attr_t *current;
|
attr_t *current;
|
||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
|
|
||||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
attribute_enumerator_t *this, va_list args)
|
||||||
chunk_t *data)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
if (this->current)
|
if (this->current)
|
||||||
{
|
{
|
||||||
destroy_attr(this->current);
|
destroy_attr(this->current);
|
||||||
@@ -446,7 +448,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_attribute_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _attribute_enumerate,
|
||||||
.destroy = _attribute_destroy,
|
.destroy = _attribute_destroy,
|
||||||
},
|
},
|
||||||
.list = linked_list_create(),
|
.list = linked_list_create(),
|
||||||
|
|||||||
@@ -79,10 +79,8 @@ typedef struct {
|
|||||||
private_eap_sim_file_triplets_t *this;
|
private_eap_sim_file_triplets_t *this;
|
||||||
} triplet_enumerator_t;
|
} triplet_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerator_destroy, void,
|
||||||
* destroy a triplet enumerator
|
triplet_enumerator_t *e)
|
||||||
*/
|
|
||||||
static void enumerator_destroy(triplet_enumerator_t *e)
|
|
||||||
{
|
{
|
||||||
if (e->current)
|
if (e->current)
|
||||||
{
|
{
|
||||||
@@ -97,13 +95,14 @@ static void enumerator_destroy(triplet_enumerator_t *e)
|
|||||||
free(e);
|
free(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerator_enumerate, bool,
|
||||||
* enumerate through triplets
|
triplet_enumerator_t *e, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **imsi,
|
|
||||||
char **rand, char **sres, char **kc)
|
|
||||||
{
|
{
|
||||||
|
identification_t **imsi;
|
||||||
triplet_t *triplet;
|
triplet_t *triplet;
|
||||||
|
char **rand, **sres, **kc;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, imsi, rand, sres, kc);
|
||||||
|
|
||||||
if (e->inner->enumerate(e->inner, &triplet))
|
if (e->inner->enumerate(e->inner, &triplet))
|
||||||
{
|
{
|
||||||
@@ -124,12 +123,15 @@ METHOD(eap_sim_file_triplets_t, create_enumerator, enumerator_t*,
|
|||||||
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
|
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
enumerator->public.enumerate = (void*)enumerator_enumerate;
|
INIT(enumerator,
|
||||||
enumerator->public.destroy = (void*)enumerator_destroy;
|
.public = {
|
||||||
enumerator->inner = this->triplets->create_enumerator(this->triplets);
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->current = NULL;
|
.venumerate = _enumerator_enumerate,
|
||||||
enumerator->this = this;
|
.destroy = _enumerator_destroy,
|
||||||
|
},
|
||||||
|
.inner = this->triplets->create_enumerator(this->triplets),
|
||||||
|
.this = this,
|
||||||
|
);
|
||||||
return &enumerator->public;
|
return &enumerator->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -331,10 +331,12 @@ typedef struct {
|
|||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||||
attribute_enumerator_t *this, ha_message_attribute_t *attr_out,
|
attribute_enumerator_t *this, va_list args)
|
||||||
ha_message_value_t *value)
|
|
||||||
{
|
{
|
||||||
ha_message_attribute_t attr;
|
ha_message_attribute_t attr, *attr_out;
|
||||||
|
ha_message_value_t *value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, attr_out, value);
|
||||||
|
|
||||||
if (this->cleanup)
|
if (this->cleanup)
|
||||||
{
|
{
|
||||||
@@ -602,7 +604,8 @@ METHOD(ha_message_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_attribute_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _attribute_enumerate,
|
||||||
.destroy = _enum_destroy,
|
.destroy = _enum_destroy,
|
||||||
},
|
},
|
||||||
.buf = chunk_skip(this->buf, 2),
|
.buf = chunk_skip(this->buf, 2),
|
||||||
|
|||||||
@@ -111,8 +111,12 @@ typedef struct {
|
|||||||
} shared_enum_t;
|
} shared_enum_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, shared_enumerate, bool,
|
METHOD(enumerator_t, shared_enumerate, bool,
|
||||||
shared_enum_t *this, shared_key_t **key, id_match_t *me, id_match_t *other)
|
shared_enum_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
shared_key_t **key;
|
||||||
|
id_match_t *me, *other;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key, me, other);
|
||||||
if (this->key)
|
if (this->key)
|
||||||
{
|
{
|
||||||
if (me)
|
if (me)
|
||||||
@@ -151,7 +155,8 @@ METHOD(ha_creds_t, create_shared_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_shared_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _shared_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.key = this->key,
|
.key = this->key,
|
||||||
|
|||||||
@@ -62,13 +62,16 @@ typedef struct {
|
|||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||||
cert_enumerator_t *this, certificate_t **cert)
|
cert_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
certificate_t **cert;
|
||||||
ipseckey_t *cur_ipseckey;
|
ipseckey_t *cur_ipseckey;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
rr_t *cur_rr;
|
rr_t *cur_rr;
|
||||||
chunk_t key;
|
chunk_t key;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
/* Get the next supported IPSECKEY using the inner enumerator. */
|
/* Get the next supported IPSECKEY using the inner enumerator. */
|
||||||
while (this->inner->enumerate(this->inner, &cur_rr))
|
while (this->inner->enumerate(this->inner, &cur_rr))
|
||||||
{
|
{
|
||||||
@@ -211,7 +214,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerator_enumerate,
|
||||||
.destroy = _cert_enumerator_destroy,
|
.destroy = _cert_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = rrset->create_rr_enumerator(rrset),
|
.inner = rrset->create_rr_enumerator(rrset),
|
||||||
|
|||||||
@@ -466,9 +466,12 @@ typedef struct {
|
|||||||
} addr_enumerator_t;
|
} addr_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, addr_enumerate, bool,
|
METHOD(enumerator_t, addr_enumerate, bool,
|
||||||
addr_enumerator_t *this, host_t **host)
|
addr_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
iface_t *entry;
|
iface_t *entry;
|
||||||
|
host_t **host;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, host);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@@ -523,7 +526,8 @@ METHOD(kernel_net_t, create_address_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_addr_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _addr_enumerate,
|
||||||
.destroy = _addr_destroy,
|
.destroy = _addr_destroy,
|
||||||
},
|
},
|
||||||
.which = which,
|
.which = which,
|
||||||
|
|||||||
@@ -2165,8 +2165,14 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_subnets, bool,
|
METHOD(enumerator_t, enumerate_subnets, bool,
|
||||||
subnet_enumerator_t *this, host_t **net, uint8_t *mask, char **ifname)
|
subnet_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
host_t **net;
|
||||||
|
uint8_t *mask;
|
||||||
|
char **ifname;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, net, mask, ifname);
|
||||||
|
|
||||||
if (!this->current)
|
if (!this->current)
|
||||||
{
|
{
|
||||||
this->current = this->msg;
|
this->current = this->msg;
|
||||||
@@ -2270,7 +2276,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_subnets,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_subnets,
|
||||||
.destroy = _destroy_subnet_enumerator,
|
.destroy = _destroy_subnet_enumerator,
|
||||||
},
|
},
|
||||||
.private = this,
|
.private = this,
|
||||||
|
|||||||
@@ -601,9 +601,12 @@ typedef struct {
|
|||||||
} rt_enumerator_t;
|
} rt_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, rt_enumerate, bool,
|
METHOD(enumerator_t, rt_enumerate, bool,
|
||||||
rt_enumerator_t *this, int *xtype, struct sockaddr **addr)
|
rt_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
int i, type;
|
struct sockaddr **addr;
|
||||||
|
int i, type, *xtype;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, xtype, addr);
|
||||||
|
|
||||||
if (this->remaining < sizeof(this->addr->sa_len) ||
|
if (this->remaining < sizeof(this->addr->sa_len) ||
|
||||||
this->remaining < this->addr->sa_len)
|
this->remaining < this->addr->sa_len)
|
||||||
@@ -637,7 +640,8 @@ static enumerator_t *create_rt_enumerator(int types, int remaining,
|
|||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_rt_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _rt_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.types = types,
|
.types = types,
|
||||||
@@ -1789,13 +1793,18 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_subnets, bool,
|
METHOD(enumerator_t, enumerate_subnets, bool,
|
||||||
subnet_enumerator_t *this, host_t **net, uint8_t *mask, char **ifname)
|
subnet_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
|
host_t **net;
|
||||||
struct rt_msghdr *rtm;
|
struct rt_msghdr *rtm;
|
||||||
struct sockaddr *addr;
|
struct sockaddr *addr;
|
||||||
|
uint8_t *mask;
|
||||||
|
char **ifname;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, net, mask, ifname);
|
||||||
|
|
||||||
if (!this->current)
|
if (!this->current)
|
||||||
{
|
{
|
||||||
this->current = this->buf;
|
this->current = this->buf;
|
||||||
@@ -1888,7 +1897,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_subnets,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_subnets,
|
||||||
.destroy = _destroy_subnet_enumerator,
|
.destroy = _destroy_subnet_enumerator,
|
||||||
},
|
},
|
||||||
.buf = buf,
|
.buf = buf,
|
||||||
|
|||||||
@@ -223,10 +223,11 @@ typedef struct {
|
|||||||
} peer_enumerator_t;
|
} peer_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||||
peer_enumerator_t *this, peer_cfg_t **cfg)
|
peer_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
char *name, *local_net, *remote_net;
|
char *name, *local_net, *remote_net;
|
||||||
chunk_t me, other;
|
chunk_t me, other;
|
||||||
|
peer_cfg_t **cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
peer_cfg_create_t peer = {
|
peer_cfg_create_t peer = {
|
||||||
@@ -249,6 +250,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
|||||||
.mode = MODE_TUNNEL,
|
.mode = MODE_TUNNEL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cfg);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
if (!this->inner->enumerate(this->inner, &name, &me, &other,
|
if (!this->inner->enumerate(this->inner, &name, &me, &other,
|
||||||
&local_net, &remote_net))
|
&local_net, &remote_net))
|
||||||
@@ -295,7 +298,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_peer_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _peer_enumerator_enumerate,
|
||||||
.destroy = _peer_enumerator_destroy,
|
.destroy = _peer_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.ike = this->ike,
|
.ike = this->ike,
|
||||||
|
|||||||
@@ -50,10 +50,13 @@ typedef struct {
|
|||||||
} private_enumerator_t;
|
} private_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, private_enumerator_enumerate, bool,
|
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 chunk;
|
chunk_t chunk;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &chunk))
|
while (this->inner->enumerate(this->inner, &chunk))
|
||||||
{
|
{
|
||||||
@@ -92,7 +95,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_private_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _private_enumerator_enumerate,
|
||||||
.destroy = _private_enumerator_destroy,
|
.destroy = _private_enumerator_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -123,11 +127,14 @@ typedef struct {
|
|||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||||
cert_enumerator_t *this, certificate_t **cert)
|
cert_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
certificate_t **cert;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
chunk_t chunk;
|
chunk_t chunk;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &chunk))
|
while (this->inner->enumerate(this->inner, &chunk))
|
||||||
{
|
{
|
||||||
@@ -180,7 +187,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerator_enumerate,
|
||||||
.destroy = _cert_enumerator_destroy,
|
.destroy = _cert_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.type = key,
|
.type = key,
|
||||||
|
|||||||
@@ -52,12 +52,14 @@ typedef struct {
|
|||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||||
cert_enumerator_t *this, certificate_t **cert)
|
cert_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
certificate_t *trusted;
|
certificate_t *trusted, **cert;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
chunk_t chunk;
|
chunk_t chunk;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &chunk))
|
while (this->inner->enumerate(this->inner, &chunk))
|
||||||
{
|
{
|
||||||
@@ -110,7 +112,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerator_enumerate,
|
||||||
.destroy = _cert_enumerator_destroy,
|
.destroy = _cert_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.type = key,
|
.type = key,
|
||||||
|
|||||||
@@ -218,12 +218,15 @@ METHOD(attribute_handler_t, release, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_dns, bool,
|
METHOD(enumerator_t, enumerate_dns, bool,
|
||||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
*type = INTERNAL_IP4_DNS;
|
*type = INTERNAL_IP4_DNS;
|
||||||
*data = chunk_empty;
|
*data = chunk_empty;
|
||||||
/* stop enumeration */
|
this->venumerate = (void*)return_false;
|
||||||
this->enumerate = (void*)return_false;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +237,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerate = (void*)_enumerate_dns,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_dns,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
);
|
);
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|||||||
@@ -83,9 +83,12 @@ typedef struct {
|
|||||||
} attr_enumerator_t;
|
} attr_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_attrs, bool,
|
METHOD(enumerator_t, enumerate_attrs, bool,
|
||||||
attr_enumerator_t *this, configuration_attribute_type_t *type,
|
attr_enumerator_t *this, va_list args)
|
||||||
chunk_t *data)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
if (this->request_ipv4)
|
if (this->request_ipv4)
|
||||||
{
|
{
|
||||||
*type = P_CSCF_IP4_ADDRESS;
|
*type = P_CSCF_IP4_ADDRESS;
|
||||||
@@ -132,7 +135,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_attrs,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_attrs,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -391,10 +391,13 @@ typedef struct {
|
|||||||
bool v6;
|
bool v6;
|
||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
static bool attribute_enumerate(attribute_enumerator_t *this,
|
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||||
configuration_attribute_type_t *type,
|
attribute_enumerator_t *this, va_list args)
|
||||||
chunk_t *data)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
if (this->v4)
|
if (this->v4)
|
||||||
{
|
{
|
||||||
*type = INTERNAL_IP4_DNS;
|
*type = INTERNAL_IP4_DNS;
|
||||||
@@ -443,7 +446,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)attribute_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _attribute_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.v4 = has_host_family(vips, AF_INET),
|
.v4 = has_host_family(vips, AF_INET),
|
||||||
|
|||||||
@@ -504,11 +504,12 @@ typedef struct {
|
|||||||
ike_cfg_t *current;
|
ike_cfg_t *current;
|
||||||
} ike_enumerator_t;
|
} ike_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
||||||
* Implementation of ike_enumerator_t.public.enumerate
|
ike_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
|
||||||
{
|
{
|
||||||
|
ike_cfg_t **cfg;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cfg);
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->current = build_ike_cfg(this->this, this->inner, this->me, this->other);
|
this->current = build_ike_cfg(this->this, this->inner, this->me, this->other);
|
||||||
if (this->current)
|
if (this->current)
|
||||||
@@ -519,10 +520,8 @@ static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, ike_enumerator_destroy, void,
|
||||||
* Implementation of ike_enumerator_t.public.destroy
|
ike_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void ike_enumerator_destroy(ike_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->inner->destroy(this->inner);
|
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*,
|
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||||
private_sql_config_t *this, host_t *me, host_t *other)
|
private_sql_config_t *this, host_t *me, host_t *other)
|
||||||
{
|
{
|
||||||
ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
|
ike_enumerator_t *e;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
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,
|
e->inner = this->db->query(this->db,
|
||||||
"SELECT id, certreq, force_encap, local, remote "
|
"SELECT id, certreq, force_encap, local, remote "
|
||||||
"FROM ike_configs",
|
"FROM ike_configs",
|
||||||
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
||||||
if (!e->inner)
|
if (!e->inner)
|
||||||
{
|
{
|
||||||
free(e);
|
free(e);
|
||||||
@@ -569,11 +571,12 @@ typedef struct {
|
|||||||
peer_cfg_t *current;
|
peer_cfg_t *current;
|
||||||
} peer_enumerator_t;
|
} peer_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||||
* Implementation of peer_enumerator_t.public.enumerate
|
peer_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
|
||||||
{
|
{
|
||||||
|
peer_cfg_t **cfg;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cfg);
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->current = build_peer_cfg(this->this, this->inner, this->me, this->other);
|
this->current = build_peer_cfg(this->this, this->inner, this->me, this->other);
|
||||||
if (this->current)
|
if (this->current)
|
||||||
@@ -584,10 +587,8 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, peer_enumerator_destroy, void,
|
||||||
* Implementation of peer_enumerator_t.public.destroy
|
peer_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void peer_enumerator_destroy(peer_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->inner->destroy(this->inner);
|
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);
|
peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
|
||||||
|
|
||||||
e->this = this;
|
INIT(e,
|
||||||
e->me = me;
|
.public = {
|
||||||
e->other = other;
|
.enumerate = enumerator_enumerate_default,
|
||||||
e->current = NULL;
|
.venumerate = _peer_enumerator_enumerate,
|
||||||
e->public.enumerate = (void*)peer_enumerator_enumerate;
|
.destroy = _peer_enumerator_destroy,
|
||||||
e->public.destroy = (void*)peer_enumerator_destroy;
|
},
|
||||||
|
.this = this,
|
||||||
|
.me = me,
|
||||||
|
.other = other,
|
||||||
|
);
|
||||||
|
|
||||||
/* TODO: only get configs whose IDs match exactly or contain wildcards */
|
/* TODO: only get configs whose IDs match exactly or contain wildcards */
|
||||||
e->inner = this->db->query(this->db,
|
e->inner = this->db->query(this->db,
|
||||||
|
|||||||
@@ -52,11 +52,14 @@ typedef struct {
|
|||||||
} private_enumerator_t;
|
} private_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, private_enumerator_enumerate, bool,
|
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;
|
chunk_t blob;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||||
{
|
{
|
||||||
@@ -88,7 +91,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_private_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _private_enumerator_enumerate,
|
||||||
.destroy = _private_enumerator_destroy,
|
.destroy = _private_enumerator_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -132,11 +136,14 @@ typedef struct {
|
|||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
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;
|
chunk_t blob;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||||
{
|
{
|
||||||
@@ -169,7 +176,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerator_enumerate,
|
||||||
.destroy = _cert_enumerator_destroy,
|
.destroy = _cert_enumerator_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -221,12 +229,15 @@ typedef struct {
|
|||||||
} shared_enumerator_t;
|
} shared_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
||||||
shared_enumerator_t *this, shared_key_t **shared,
|
shared_enumerator_t *this, va_list args)
|
||||||
id_match_t *me, id_match_t *other)
|
|
||||||
{
|
{
|
||||||
|
shared_key_t **shared;
|
||||||
|
id_match_t *me, *other;
|
||||||
chunk_t blob;
|
chunk_t blob;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, shared, me, other);
|
||||||
|
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||||
{
|
{
|
||||||
@@ -265,7 +276,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_shared_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _shared_enumerator_enumerate,
|
||||||
.destroy = _shared_enumerator_destroy,
|
.destroy = _shared_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.me = me,
|
.me = me,
|
||||||
@@ -340,9 +352,11 @@ typedef enum {
|
|||||||
} cdp_type_t;
|
} cdp_type_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, cdp_enumerator_enumerate, bool,
|
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);
|
free(this->current);
|
||||||
while (this->inner->enumerate(this->inner, &text))
|
while (this->inner->enumerate(this->inner, &text))
|
||||||
@@ -384,7 +398,8 @@ METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
|
|||||||
}
|
}
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cdp_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cdp_enumerator_enumerate,
|
||||||
.destroy = _cdp_enumerator_destroy,
|
.destroy = _cdp_enumerator_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -118,11 +118,12 @@ static u_int create_rekey(char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||||
peer_enumerator_t *this, peer_cfg_t **cfg)
|
peer_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
char *name, *ike_proposal, *esp_proposal, *ike_rekey, *esp_rekey;
|
char *name, *ike_proposal, *esp_proposal, *ike_rekey, *esp_rekey;
|
||||||
char *local_id, *local_addr, *local_net;
|
char *local_id, *local_addr, *local_net;
|
||||||
char *remote_id, *remote_addr, *remote_net;
|
char *remote_id, *remote_addr, *remote_net;
|
||||||
|
peer_cfg_t **cfg;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
ike_cfg_t *ike_cfg;
|
ike_cfg_t *ike_cfg;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
@@ -145,6 +146,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
|||||||
.mode = MODE_TUNNEL,
|
.mode = MODE_TUNNEL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cfg);
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
name = "unnamed";
|
name = "unnamed";
|
||||||
local_id = NULL;
|
local_id = NULL;
|
||||||
@@ -212,7 +215,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_peer_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _peer_enumerator_enumerate,
|
||||||
.destroy = _peer_enumerator_destroy,
|
.destroy = _peer_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = this->parser->create_section_enumerator(this->parser,
|
.inner = this->parser->create_section_enumerator(this->parser,
|
||||||
@@ -241,10 +245,13 @@ typedef struct {
|
|||||||
} ike_enumerator_t;
|
} ike_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
||||||
ike_enumerator_t *this, ike_cfg_t **cfg)
|
ike_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
ike_cfg_t **cfg;
|
||||||
char *local_addr, *remote_addr, *ike_proposal;
|
char *local_addr, *remote_addr, *ike_proposal;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cfg);
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
local_addr = "0.0.0.0";
|
local_addr = "0.0.0.0";
|
||||||
remote_addr = "0.0.0.0";
|
remote_addr = "0.0.0.0";
|
||||||
@@ -282,7 +289,8 @@ METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_ike_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _ike_enumerator_enumerate,
|
||||||
.destroy = _ike_enumerator_destroy,
|
.destroy = _ike_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = this->parser->create_section_enumerator(this->parser,
|
.inner = this->parser->create_section_enumerator(this->parser,
|
||||||
|
|||||||
@@ -52,12 +52,15 @@ typedef struct {
|
|||||||
} shared_enumerator_t;
|
} shared_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
||||||
shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
|
shared_enumerator_t *this, va_list args)
|
||||||
id_match_t *other)
|
|
||||||
{
|
{
|
||||||
|
shared_key_t **key;
|
||||||
|
id_match_t *me, *other;
|
||||||
char *local_id, *remote_id, *psk;
|
char *local_id, *remote_id, *psk;
|
||||||
identification_t *local, *remote;
|
identification_t *local, *remote;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key, me, other);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
/* defaults */
|
/* defaults */
|
||||||
@@ -126,7 +129,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_shared_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _shared_enumerator_enumerate,
|
||||||
.destroy = _shared_enumerator_destroy,
|
.destroy = _shared_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.me = me,
|
.me = me,
|
||||||
|
|||||||
@@ -58,11 +58,10 @@ typedef struct {
|
|||||||
} section_enumerator_t;
|
} section_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
||||||
section_enumerator_t *this, ...)
|
section_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
struct uci_element *element;
|
struct uci_element *element;
|
||||||
char **value;
|
char **value;
|
||||||
va_list args;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (&this->current->list == this->list)
|
if (&this->current->list == this->list)
|
||||||
@@ -70,8 +69,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(args, this);
|
|
||||||
|
|
||||||
value = va_arg(args, char**);
|
value = va_arg(args, char**);
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
@@ -96,7 +93,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
|||||||
*value = uci_to_option(element)->value;
|
*value = uci_to_option(element)->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
this->current = list_to_element(this->current->list.next);
|
this->current = list_to_element(this->current->list.next);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -124,7 +120,13 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
e = malloc(sizeof(section_enumerator_t) + sizeof(char*) * i);
|
INIT_EXTRA(e, sizeof(char*) * i,
|
||||||
|
.public = {
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _section_enumerator_enumerate,
|
||||||
|
.destroy = _section_enumerator_destroy,
|
||||||
|
},
|
||||||
|
);
|
||||||
i = 0;
|
i = 0;
|
||||||
va_start(args, this);
|
va_start(args, this);
|
||||||
do
|
do
|
||||||
@@ -134,9 +136,6 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
|
|||||||
while (e->keywords[i++]);
|
while (e->keywords[i++]);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
e->public.enumerate = (void*)_section_enumerator_enumerate;
|
|
||||||
e->public.destroy = _section_enumerator_destroy;
|
|
||||||
|
|
||||||
/* load uci context */
|
/* load uci context */
|
||||||
e->ctx = uci_alloc_context();
|
e->ctx = uci_alloc_context();
|
||||||
if (uci_load(e->ctx, this->package, &e->package) != UCI_OK)
|
if (uci_load(e->ctx, this->package, &e->package) != UCI_OK)
|
||||||
|
|||||||
@@ -368,9 +368,12 @@ typedef struct {
|
|||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_attributes, bool,
|
METHOD(enumerator_t, enumerate_attributes, bool,
|
||||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
attribute_enumerator_t *this, va_list args)
|
||||||
chunk_t *data)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
if (this->i < countof(attributes))
|
if (this->i < countof(attributes))
|
||||||
{
|
{
|
||||||
*type = attributes[this->i++];
|
*type = attributes[this->i++];
|
||||||
@@ -393,7 +396,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
|||||||
}
|
}
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_attributes,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_attributes,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -77,12 +77,15 @@ static void append_ts(bio_writer_t *writer, traffic_selector_t *ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
attribute_enumerator_t *this, va_list args)
|
||||||
chunk_t *attr)
|
|
||||||
{
|
{
|
||||||
|
configuration_attribute_type_t *type;
|
||||||
|
chunk_t *attr;
|
||||||
traffic_selector_t *ts;
|
traffic_selector_t *ts;
|
||||||
bio_writer_t *writer;
|
bio_writer_t *writer;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, attr);
|
||||||
|
|
||||||
if (this->list->get_count(this->list) == 0)
|
if (this->list->get_count(this->list) == 0)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -183,7 +186,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(attr_enum,
|
INIT(attr_enum,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_attribute_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _attribute_enumerate,
|
||||||
.destroy = _attribute_destroy,
|
.destroy = _attribute_destroy,
|
||||||
},
|
},
|
||||||
.list = list,
|
.list = list,
|
||||||
|
|||||||
@@ -122,9 +122,14 @@ typedef struct {
|
|||||||
endecode_test_t *next;
|
endecode_test_t *next;
|
||||||
} endecode_enum_t;
|
} endecode_enum_t;
|
||||||
|
|
||||||
static bool endecode_enumerate(endecode_enum_t *this, vici_type_t *type,
|
METHOD(enumerator_t, endecode_enumerate, bool,
|
||||||
char **name, chunk_t *data)
|
endecode_enum_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
vici_type_t *type;
|
||||||
|
chunk_t *data;
|
||||||
|
char **name;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, name, data);
|
||||||
if (this->next)
|
if (this->next)
|
||||||
{
|
{
|
||||||
*type = this->next->type;
|
*type = this->next->type;
|
||||||
@@ -149,7 +154,8 @@ static enumerator_t *endecode_create_enumerator(endecode_test_t *test)
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)endecode_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _endecode_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.next = test,
|
.next = test,
|
||||||
|
|||||||
@@ -135,11 +135,16 @@ typedef struct {
|
|||||||
} parse_enumerator_t;
|
} parse_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, parse_enumerate, bool,
|
METHOD(enumerator_t, parse_enumerate, bool,
|
||||||
parse_enumerator_t *this, vici_type_t *out, char **name, chunk_t *value)
|
parse_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
vici_type_t *out;
|
||||||
|
chunk_t *value;
|
||||||
|
char **name;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
chunk_t data;
|
chunk_t data;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out, name, value);
|
||||||
|
|
||||||
if (!this->reader->remaining(this->reader) ||
|
if (!this->reader->remaining(this->reader) ||
|
||||||
!this->reader->read_uint8(this->reader, &type))
|
!this->reader->read_uint8(this->reader, &type))
|
||||||
{
|
{
|
||||||
@@ -218,7 +223,8 @@ METHOD(vici_message_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_parse_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _parse_enumerate,
|
||||||
.destroy = _parse_destroy,
|
.destroy = _parse_destroy,
|
||||||
},
|
},
|
||||||
.reader = bio_reader_create(this->encoding),
|
.reader = bio_reader_create(this->encoding),
|
||||||
|
|||||||
@@ -435,10 +435,11 @@ struct policy_enumerator_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
METHOD(enumerator_t, policy_enumerate, bool,
|
METHOD(enumerator_t, policy_enumerate, bool,
|
||||||
policy_enumerator_t *this, traffic_selector_t **my_out,
|
policy_enumerator_t *this, va_list args)
|
||||||
traffic_selector_t **other_out)
|
|
||||||
{
|
{
|
||||||
traffic_selector_t *other_ts;
|
traffic_selector_t *other_ts, **my_out, **other_out;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, my_out, other_out);
|
||||||
|
|
||||||
while (this->ts || this->mine->enumerate(this->mine, &this->ts))
|
while (this->ts || this->mine->enumerate(this->mine, &this->ts))
|
||||||
{
|
{
|
||||||
@@ -487,7 +488,8 @@ METHOD(child_sa_t, create_policy_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_policy_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _policy_enumerate,
|
||||||
.destroy = _policy_destroy,
|
.destroy = _policy_destroy,
|
||||||
},
|
},
|
||||||
.mine = array_create_enumerator(this->my_ts),
|
.mine = array_create_enumerator(this->my_ts),
|
||||||
|
|||||||
@@ -1699,8 +1699,11 @@ typedef struct {
|
|||||||
} child_enumerator_t;
|
} child_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, child_enumerate, bool,
|
METHOD(enumerator_t, child_enumerate, bool,
|
||||||
child_enumerator_t *this, child_sa_t **child_sa)
|
child_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
child_sa_t **child_sa;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, child_sa);
|
||||||
if (this->inner->enumerate(this->inner, &this->current))
|
if (this->inner->enumerate(this->inner, &this->current))
|
||||||
{
|
{
|
||||||
*child_sa = this->current;
|
*child_sa = this->current;
|
||||||
@@ -1723,7 +1726,8 @@ METHOD(ike_sa_t, create_child_sa_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_child_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _child_enumerate,
|
||||||
.destroy = _child_enumerator_destroy,
|
.destroy = _child_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = array_create_enumerator(this->child_sas),
|
.inner = array_create_enumerator(this->child_sas),
|
||||||
|
|||||||
@@ -513,8 +513,13 @@ struct private_enumerator_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate, bool,
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
private_enumerator_t *this, entry_t **entry, u_int *segment)
|
private_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
entry_t **entry;
|
||||||
|
u_int *segment;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, entry, segment);
|
||||||
|
|
||||||
if (this->entry)
|
if (this->entry)
|
||||||
{
|
{
|
||||||
this->entry->condvar->signal(this->entry->condvar);
|
this->entry->condvar->signal(this->entry->condvar);
|
||||||
@@ -572,7 +577,8 @@ static enumerator_t* create_table_enumerator(private_ike_sa_manager_t *this)
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerator = {
|
.enumerator = {
|
||||||
.enumerate = (void*)_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate,
|
||||||
.destroy = _enumerator_destroy,
|
.destroy = _enumerator_destroy,
|
||||||
},
|
},
|
||||||
.manager = this,
|
.manager = this,
|
||||||
|
|||||||
@@ -283,23 +283,20 @@ typedef struct {
|
|||||||
|
|
||||||
} package_enumerator_t;
|
} package_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, package_enumerator_destroy, void,
|
||||||
* Implementation of package_enumerator.destroy.
|
package_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void package_enumerator_destroy(package_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
pclose(this->file);
|
pclose(this->file);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, package_enumerator_enumerate, bool,
|
||||||
* Implementation of package_enumerator.enumerate
|
package_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool package_enumerator_enumerate(package_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
chunk_t *name, *version;
|
chunk_t *name, *version;
|
||||||
u_char *pos;
|
u_char *pos;
|
||||||
va_list args;
|
|
||||||
|
VA_ARGS_VGET(args, name, version);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@@ -319,23 +316,16 @@ static bool package_enumerator_enumerate(package_enumerator_t *this, ...)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
va_start(args, this);
|
|
||||||
|
|
||||||
name = va_arg(args, chunk_t*);
|
|
||||||
name->ptr = pos;
|
name->ptr = pos;
|
||||||
pos = strchr(pos, '\t');
|
pos = strchr(pos, '\t');
|
||||||
if (!pos)
|
if (!pos)
|
||||||
{
|
{
|
||||||
va_end(args);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
name->len = pos++ - name->ptr;
|
name->len = pos++ - name->ptr;
|
||||||
|
|
||||||
version = va_arg(args, chunk_t*);
|
|
||||||
version->ptr = pos;
|
version->ptr = pos;
|
||||||
version->len = strlen(pos) - 1;
|
version->len = strlen(pos) - 1;
|
||||||
|
|
||||||
va_end(args);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,12 +352,14 @@ METHOD(imc_os_info_t, create_package_enumerator, enumerator_t*,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a package enumerator instance */
|
INIT(enumerator,
|
||||||
enumerator = malloc_thing(package_enumerator_t);
|
.public = {
|
||||||
enumerator->public.enumerate = (void*)package_enumerator_enumerate;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->public.destroy = (void*)package_enumerator_destroy;
|
.venumerate = _package_enumerator_enumerate,
|
||||||
enumerator->file = file;
|
.destroy = _package_enumerator_destroy,
|
||||||
|
},
|
||||||
|
.file = file,
|
||||||
|
);
|
||||||
return (enumerator_t*)enumerator;
|
return (enumerator_t*)enumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-21
@@ -626,22 +626,13 @@ typedef struct {
|
|||||||
|
|
||||||
} language_enumerator_t;
|
} language_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, language_enumerator_enumerate, bool,
|
||||||
* Implementation of language_enumerator.destroy.
|
language_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static void language_enumerator_destroy(language_enumerator_t *this)
|
|
||||||
{
|
|
||||||
free(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of language_enumerator.enumerate
|
|
||||||
*/
|
|
||||||
static bool language_enumerator_enumerate(language_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
char *pos, *cur_lang, **lang;
|
char *pos, *cur_lang, **lang;
|
||||||
TNC_UInt32 len;
|
TNC_UInt32 len;
|
||||||
va_list args;
|
|
||||||
|
VA_ARGS_VGET(args, lang);
|
||||||
|
|
||||||
if (!this->lang_len)
|
if (!this->lang_len)
|
||||||
{
|
{
|
||||||
@@ -676,11 +667,7 @@ static bool language_enumerator_enumerate(language_enumerator_t *this, ...)
|
|||||||
}
|
}
|
||||||
cur_lang[len] = '\0';
|
cur_lang[len] = '\0';
|
||||||
|
|
||||||
va_start(args, this);
|
|
||||||
lang = va_arg(args, char**);
|
|
||||||
*lang = cur_lang;
|
*lang = cur_lang;
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,10 +676,13 @@ METHOD(imv_agent_t, create_language_enumerator, enumerator_t*,
|
|||||||
{
|
{
|
||||||
language_enumerator_t *e;
|
language_enumerator_t *e;
|
||||||
|
|
||||||
/* Create a language enumerator instance */
|
INIT(e,
|
||||||
e = malloc_thing(language_enumerator_t);
|
.public = {
|
||||||
e->public.enumerate = (void*)language_enumerator_enumerate;
|
.enumerate = enumerator_enumerate_default,
|
||||||
e->public.destroy = (void*)language_enumerator_destroy;
|
.venumerate = _language_enumerator_enumerate,
|
||||||
|
.destroy = (void*)free,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!this->get_attribute ||
|
if (!this->get_attribute ||
|
||||||
!this->get_attribute(this->id, state->get_connection_id(state),
|
!this->get_attribute(this->id, state->get_connection_id(state),
|
||||||
|
|||||||
@@ -111,17 +111,12 @@ typedef struct {
|
|||||||
private_pts_pcr_t *pcrs;
|
private_pts_pcr_t *pcrs;
|
||||||
} pcr_enumerator_t;
|
} pcr_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, pcr_enumerator_enumerate, bool,
|
||||||
* Implementation of enumerator.enumerate
|
pcr_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool pcr_enumerator_enumerate(pcr_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
uint32_t *pcr, i, f;
|
uint32_t i, f, *pcr;
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, this);
|
VA_ARGS_VGET(args, pcr);
|
||||||
pcr = va_arg(args, uint32_t*);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
while (this->pcr <= this->pcrs->pcr_max)
|
while (this->pcr <= this->pcrs->pcr_max)
|
||||||
{
|
{
|
||||||
@@ -148,7 +143,8 @@ METHOD(pts_pcr_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)pcr_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _pcr_enumerator_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.pcrs = this,
|
.pcrs = this,
|
||||||
|
|||||||
@@ -59,8 +59,11 @@ typedef struct {
|
|||||||
} mech_enumerator_t;
|
} mech_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, mech_enumerate, bool,
|
METHOD(enumerator_t, mech_enumerate, bool,
|
||||||
mech_enumerator_t *this, char **name)
|
mech_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
char **name;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, name);
|
||||||
while (this->i < countof(mechs))
|
while (this->i < countof(mechs))
|
||||||
{
|
{
|
||||||
if (mechs[this->i].server == this->server)
|
if (mechs[this->i].server == this->server)
|
||||||
@@ -83,7 +86,8 @@ enumerator_t* sasl_mechanism_create_enumerator(bool server)
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_mech_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _mech_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.server = server,
|
.server = server,
|
||||||
|
|||||||
@@ -244,8 +244,12 @@ typedef struct {
|
|||||||
} attribute_enumerator_t;
|
} attribute_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||||
attribute_enumerator_t *this, int *type, chunk_t *data)
|
attribute_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
chunk_t *data;
|
||||||
|
int *type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
if (this->left == 0)
|
if (this->left == 0)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -275,7 +279,8 @@ METHOD(radius_message_t, create_enumerator, enumerator_t*,
|
|||||||
}
|
}
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_attribute_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _attribute_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.next = (rattr_t*)this->msg->attributes,
|
.next = (rattr_t*)this->msg->attributes,
|
||||||
@@ -299,12 +304,14 @@ typedef struct {
|
|||||||
} vendor_enumerator_t;
|
} vendor_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, vendor_enumerate, bool,
|
METHOD(enumerator_t, vendor_enumerate, bool,
|
||||||
vendor_enumerator_t *this, int *vendor, int *type, chunk_t *data)
|
vendor_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
chunk_t inner_data;
|
chunk_t inner_data, *data;
|
||||||
int inner_type;
|
int inner_type, *vendor, *type;
|
||||||
uint8_t type8, len;
|
uint8_t type8, len;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, vendor, type, data);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (this->reader)
|
if (this->reader)
|
||||||
@@ -354,7 +361,8 @@ METHOD(radius_message_t, create_vendor_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_vendor_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _vendor_enumerate,
|
||||||
.destroy = _vendor_destroy,
|
.destroy = _vendor_destroy,
|
||||||
},
|
},
|
||||||
.inner = create_enumerator(this),
|
.inner = create_enumerator(this),
|
||||||
|
|||||||
@@ -214,9 +214,11 @@ typedef struct {
|
|||||||
} array_enumerator_t;
|
} array_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate, bool,
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
array_enumerator_t *this, void **out)
|
array_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
void *pos;
|
void *pos, **out;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
if (this->idx >= this->array->count)
|
if (this->idx >= this->array->count)
|
||||||
{
|
{
|
||||||
@@ -250,7 +252,8 @@ enumerator_t* array_create_enumerator(array_t *array)
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.array = array,
|
.array = array,
|
||||||
|
|||||||
@@ -50,22 +50,24 @@ bool enumerator_enumerate_default(enumerator_t *enumerator, ...)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_empty, bool,
|
||||||
* Implementation of enumerator_create_empty().enumerate
|
enumerator_t *enumerator, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_empty(enumerator_t *enumerator, ...)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* See header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t* enumerator_create_empty()
|
enumerator_t* enumerator_create_empty()
|
||||||
{
|
{
|
||||||
enumerator_t *this = malloc_thing(enumerator_t);
|
enumerator_t *this;
|
||||||
this->enumerate = enumerate_empty;
|
|
||||||
this->destroy = (void*)free;
|
INIT(this,
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_empty,
|
||||||
|
.destroy = (void*)free,
|
||||||
|
);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,32 +85,31 @@ typedef struct {
|
|||||||
char *full_end;
|
char *full_end;
|
||||||
} dir_enum_t;
|
} dir_enum_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_dir_enum, void,
|
||||||
* Implementation of enumerator_create_directory().destroy
|
dir_enum_t *this)
|
||||||
*/
|
|
||||||
static void destroy_dir_enum(dir_enum_t *this)
|
|
||||||
{
|
{
|
||||||
closedir(this->dir);
|
closedir(this->dir);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_dir_enum, bool,
|
||||||
* Implementation of enumerator_create_directory().enumerate
|
dir_enum_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
|
|
||||||
char **absolute, struct stat *st)
|
|
||||||
{
|
{
|
||||||
struct dirent *entry = readdir(this->dir);
|
struct dirent *entry = readdir(this->dir);
|
||||||
|
struct stat *st;
|
||||||
size_t remaining;
|
size_t remaining;
|
||||||
|
char **relative, **absolute;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, relative, absolute, st);
|
||||||
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (streq(entry->d_name, ".") || streq(entry->d_name, ".."))
|
if (streq(entry->d_name, ".") || streq(entry->d_name, ".."))
|
||||||
{
|
{
|
||||||
return enumerate_dir_enum(this, relative, absolute, st);
|
return this->public.enumerate(&this->public, relative, absolute, st);
|
||||||
}
|
}
|
||||||
if (relative)
|
if (relative)
|
||||||
{
|
{
|
||||||
@@ -141,15 +142,21 @@ static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* See header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t* enumerator_create_directory(const char *path)
|
enumerator_t* enumerator_create_directory(const char *path)
|
||||||
{
|
{
|
||||||
|
dir_enum_t *this;
|
||||||
int len;
|
int len;
|
||||||
dir_enum_t *this = malloc_thing(dir_enum_t);
|
|
||||||
this->public.enumerate = (void*)enumerate_dir_enum;
|
INIT(this,
|
||||||
this->public.destroy = (void*)destroy_dir_enum;
|
.public = {
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_dir_enum,
|
||||||
|
.destroy = _destroy_dir_enum,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (*path == '\0')
|
if (*path == '\0')
|
||||||
{
|
{
|
||||||
@@ -171,9 +178,10 @@ enumerator_t* enumerator_create_directory(const char *path)
|
|||||||
this->full_end = &this->full[len];
|
this->full_end = &this->full[len];
|
||||||
|
|
||||||
this->dir = opendir(path);
|
this->dir = opendir(path);
|
||||||
if (this->dir == NULL)
|
if (!this->dir)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "opening directory '%s' failed: %s", path, strerror(errno));
|
DBG1(DBG_LIB, "opening directory '%s' failed: %s", path,
|
||||||
|
strerror(errno));
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -196,21 +204,21 @@ typedef struct {
|
|||||||
char full[PATH_MAX];
|
char full[PATH_MAX];
|
||||||
} glob_enum_t;
|
} glob_enum_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_glob_enum, void,
|
||||||
* Implementation of enumerator_create_glob().destroy
|
glob_enum_t *this)
|
||||||
*/
|
|
||||||
static void destroy_glob_enum(glob_enum_t *this)
|
|
||||||
{
|
{
|
||||||
globfree(&this->glob);
|
globfree(&this->glob);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_glob_enum, bool,
|
||||||
* Implementation of enumerator_create_glob().enumerate
|
glob_enum_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_glob_enum(glob_enum_t *this, char **file, struct stat *st)
|
|
||||||
{
|
{
|
||||||
|
struct stat *st;
|
||||||
char *match;
|
char *match;
|
||||||
|
char **file;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, file, st);
|
||||||
|
|
||||||
if (this->pos >= this->glob.gl_pathc)
|
if (this->pos >= this->glob.gl_pathc)
|
||||||
{
|
{
|
||||||
@@ -221,20 +229,17 @@ static bool enumerate_glob_enum(glob_enum_t *this, char **file, struct stat *st)
|
|||||||
{
|
{
|
||||||
*file = match;
|
*file = match;
|
||||||
}
|
}
|
||||||
if (st)
|
if (st && stat(match, st))
|
||||||
{
|
{
|
||||||
if (stat(match, st))
|
DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
|
||||||
{
|
strerror(errno));
|
||||||
DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
|
return FALSE;
|
||||||
strerror(errno));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* See header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t* enumerator_create_glob(const char *pattern)
|
enumerator_t* enumerator_create_glob(const char *pattern)
|
||||||
{
|
{
|
||||||
@@ -248,8 +253,9 @@ enumerator_t* enumerator_create_glob(const char *pattern)
|
|||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)enumerate_glob_enum,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)destroy_glob_enum,
|
.venumerate = _enumerate_glob_enum,
|
||||||
|
.destroy = _destroy_glob_enum,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -291,24 +297,22 @@ typedef struct {
|
|||||||
const char *trim;
|
const char *trim;
|
||||||
} token_enum_t;
|
} token_enum_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_token_enum, void,
|
||||||
* Implementation of enumerator_create_token().destroy
|
token_enum_t *this)
|
||||||
*/
|
|
||||||
static void destroy_token_enum(token_enum_t *this)
|
|
||||||
{
|
{
|
||||||
free(this->string);
|
free(this->string);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_token_enum, bool,
|
||||||
* Implementation of enumerator_create_token().enumerate
|
token_enum_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_token_enum(token_enum_t *this, char **token)
|
|
||||||
{
|
{
|
||||||
const char *sep, *trim;
|
const char *sep, *trim;
|
||||||
char *pos = NULL, *tmp;
|
char *pos = NULL, *tmp, **token;
|
||||||
bool last = FALSE;
|
bool last = FALSE;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, token);
|
||||||
|
|
||||||
/* trim leading characters/separators */
|
/* trim leading characters/separators */
|
||||||
while (*this->pos)
|
while (*this->pos)
|
||||||
{
|
{
|
||||||
@@ -409,52 +413,48 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* See header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t* enumerator_create_token(const char *string, const char *sep,
|
enumerator_t* enumerator_create_token(const char *string, const char *sep,
|
||||||
const char *trim)
|
const char *trim)
|
||||||
{
|
{
|
||||||
token_enum_t *enumerator = malloc_thing(token_enum_t);
|
token_enum_t *this;
|
||||||
|
|
||||||
enumerator->public.enumerate = (void*)enumerate_token_enum;
|
INIT(this,
|
||||||
enumerator->public.destroy = (void*)destroy_token_enum;
|
.public = {
|
||||||
enumerator->string = strdup(string);
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->pos = enumerator->string;
|
.venumerate = _enumerate_token_enum,
|
||||||
enumerator->sep = sep;
|
.destroy = _destroy_token_enum,
|
||||||
enumerator->trim = trim;
|
},
|
||||||
|
.string = strdup(string),
|
||||||
|
.sep = sep,
|
||||||
|
.trim = trim,
|
||||||
|
);
|
||||||
|
this->pos = this->string;
|
||||||
|
|
||||||
return &enumerator->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enumerator for nested enumerations
|
* Enumerator for nested enumerations
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* implements enumerator_t */
|
|
||||||
enumerator_t public;
|
enumerator_t public;
|
||||||
/* outer enumerator */
|
|
||||||
enumerator_t *outer;
|
enumerator_t *outer;
|
||||||
/* inner enumerator */
|
|
||||||
enumerator_t *inner;
|
enumerator_t *inner;
|
||||||
/* constructor for inner enumerator */
|
|
||||||
enumerator_t *(*create_inner)(void *outer, void *data);
|
enumerator_t *(*create_inner)(void *outer, void *data);
|
||||||
/* data to pass to constructor above */
|
|
||||||
void *data;
|
void *data;
|
||||||
/* destructor for data */
|
void (*destructor)(void *data);
|
||||||
void (*destroy_data)(void *data);
|
|
||||||
} nested_enumerator_t;
|
} nested_enumerator_t;
|
||||||
|
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_nested, bool,
|
||||||
* Implementation of enumerator_create_nested().enumerate()
|
nested_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
|
|
||||||
void *v3, void *v4, void *v5)
|
|
||||||
{
|
{
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
while (this->inner == NULL)
|
while (!this->inner)
|
||||||
{
|
{
|
||||||
void *outer;
|
void *outer;
|
||||||
|
|
||||||
@@ -463,8 +463,13 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
this->inner = this->create_inner(outer, this->data);
|
this->inner = this->create_inner(outer, this->data);
|
||||||
|
if (this->inner && !this->inner->venumerate)
|
||||||
|
{
|
||||||
|
DBG1(DBG_LIB, "!!! ENUMERATE NESTED: venumerate() missing !!!");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this->inner->enumerate(this->inner, v1, v2, v3, v4, v5))
|
if (this->inner->venumerate(this->inner, args))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -473,42 +478,43 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_nested, void,
|
||||||
* Implementation of enumerator_create_nested().destroy()
|
nested_enumerator_t *this)
|
||||||
**/
|
|
||||||
static void destroy_nested(nested_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->destroy_data)
|
if (this->destructor)
|
||||||
{
|
{
|
||||||
this->destroy_data(this->data);
|
this->destructor(this->data);
|
||||||
}
|
}
|
||||||
DESTROY_IF(this->inner);
|
DESTROY_IF(this->inner);
|
||||||
this->outer->destroy(this->outer);
|
this->outer->destroy(this->outer);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* See header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t *enumerator_create_nested(enumerator_t *outer,
|
enumerator_t *enumerator_create_nested(enumerator_t *outer,
|
||||||
enumerator_t *(inner_constructor)(void *outer, void *data),
|
enumerator_t *(inner_constructor)(void *outer, void *data),
|
||||||
void *data, void (*destroy_data)(void *data))
|
void *data, void (*destructor)(void *data))
|
||||||
{
|
{
|
||||||
nested_enumerator_t *enumerator = malloc_thing(nested_enumerator_t);
|
nested_enumerator_t *this;
|
||||||
|
|
||||||
enumerator->public.enumerate = (void*)enumerate_nested;
|
INIT(this,
|
||||||
enumerator->public.destroy = (void*)destroy_nested;
|
.public = {
|
||||||
enumerator->outer = outer;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->inner = NULL;
|
.venumerate = _enumerate_nested,
|
||||||
enumerator->create_inner = (void*)inner_constructor;
|
.destroy = _destroy_nested,
|
||||||
enumerator->data = data;
|
},
|
||||||
enumerator->destroy_data = destroy_data;
|
.outer = outer,
|
||||||
|
.create_inner = inner_constructor,
|
||||||
return &enumerator->public;
|
.data = data,
|
||||||
|
.destructor = destructor,
|
||||||
|
);
|
||||||
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enumerator for filtered enumerator
|
* Enumerator for filtered enumerator
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enumerator_t public;
|
enumerator_t public;
|
||||||
@@ -518,10 +524,8 @@ typedef struct {
|
|||||||
void (*destructor)(void *data);
|
void (*destructor)(void *data);
|
||||||
} filter_enumerator_t;
|
} filter_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_filter, void,
|
||||||
* Implementation of enumerator_create_filter().destroy
|
filter_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void destroy_filter(filter_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->destructor)
|
if (this->destructor)
|
||||||
{
|
{
|
||||||
@@ -531,13 +535,14 @@ static void destroy_filter(filter_enumerator_t *this)
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_filter, bool,
|
||||||
* Implementation of enumerator_create_filter().enumerate
|
filter_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_filter(filter_enumerator_t *this, void *o1, void *o2,
|
|
||||||
void *o3, void *o4, void *o5)
|
|
||||||
{
|
{
|
||||||
void *i1, *i2, *i3, *i4, *i5;
|
void *i1, *i2, *i3, *i4, *i5;
|
||||||
|
void *o1, *o2, *o3, *o4, *o5;
|
||||||
|
|
||||||
|
/* FIXME: what happens if there are less than five arguments is not defined */
|
||||||
|
VA_ARGS_VGET(args, o1, o2, o3, o4, o5);
|
||||||
|
|
||||||
while (this->unfiltered->enumerate(this->unfiltered, &i1, &i2, &i3, &i4, &i5))
|
while (this->unfiltered->enumerate(this->unfiltered, &i1, &i2, &i3, &i4, &i5))
|
||||||
{
|
{
|
||||||
@@ -549,27 +554,31 @@ static bool enumerate_filter(filter_enumerator_t *this, void *o1, void *o2,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* see header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
|
enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
|
||||||
bool (*filter)(void *data, ...),
|
bool (*filter)(void *data, ...),
|
||||||
void *data, void (*destructor)(void *data))
|
void *data, void (*destructor)(void *data))
|
||||||
{
|
{
|
||||||
filter_enumerator_t *this = malloc_thing(filter_enumerator_t);
|
filter_enumerator_t *this;
|
||||||
|
|
||||||
this->public.enumerate = (void*)enumerate_filter;
|
|
||||||
this->public.destroy = (void*)destroy_filter;
|
|
||||||
this->unfiltered = unfiltered;
|
|
||||||
this->filter = filter;
|
|
||||||
this->data = data;
|
|
||||||
this->destructor = destructor;
|
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_filter,
|
||||||
|
.destroy = _destroy_filter,
|
||||||
|
},
|
||||||
|
.unfiltered = unfiltered,
|
||||||
|
.filter = filter,
|
||||||
|
.data = data,
|
||||||
|
.destructor = destructor,
|
||||||
|
);
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enumerator for cleaner enumerator
|
* Enumerator for cleaner enumerator
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enumerator_t public;
|
enumerator_t public;
|
||||||
@@ -578,44 +587,48 @@ typedef struct {
|
|||||||
void *data;
|
void *data;
|
||||||
} cleaner_enumerator_t;
|
} cleaner_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_cleaner, void,
|
||||||
* Implementation of enumerator_create_cleanup().destroy
|
cleaner_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void destroy_cleaner(cleaner_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
this->cleanup(this->data);
|
this->cleanup(this->data);
|
||||||
this->wrapped->destroy(this->wrapped);
|
this->wrapped->destroy(this->wrapped);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_cleaner, bool,
|
||||||
* Implementation of enumerator_create_cleaner().enumerate
|
cleaner_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_cleaner(cleaner_enumerator_t *this, void *v1, void *v2,
|
|
||||||
void *v3, void *v4, void *v5)
|
|
||||||
{
|
{
|
||||||
return this->wrapped->enumerate(this->wrapped, v1, v2, v3, v4, v5);
|
if (!this->wrapped->venumerate)
|
||||||
|
{
|
||||||
|
DBG1(DBG_LIB, "!!! CLEANER ENUMERATOR: venumerate() missing !!!");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return this->wrapped->venumerate(this->wrapped, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* see header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t *enumerator_create_cleaner(enumerator_t *wrapped,
|
enumerator_t *enumerator_create_cleaner(enumerator_t *wrapped,
|
||||||
void (*cleanup)(void *data), void *data)
|
void (*cleanup)(void *data), void *data)
|
||||||
{
|
{
|
||||||
cleaner_enumerator_t *this = malloc_thing(cleaner_enumerator_t);
|
cleaner_enumerator_t *this;
|
||||||
|
|
||||||
this->public.enumerate = (void*)enumerate_cleaner;
|
|
||||||
this->public.destroy = (void*)destroy_cleaner;
|
|
||||||
this->wrapped = wrapped;
|
|
||||||
this->cleanup = cleanup;
|
|
||||||
this->data = data;
|
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_cleaner,
|
||||||
|
.destroy = _destroy_cleaner,
|
||||||
|
},
|
||||||
|
.wrapped = wrapped,
|
||||||
|
.cleanup = cleanup,
|
||||||
|
.data = data,
|
||||||
|
);
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enumerator for single enumerator
|
* Enumerator for single enumerator
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enumerator_t public;
|
enumerator_t public;
|
||||||
@@ -624,10 +637,8 @@ typedef struct {
|
|||||||
bool done;
|
bool done;
|
||||||
} single_enumerator_t;
|
} single_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, destroy_single, void,
|
||||||
* Implementation of enumerator_create_single().destroy
|
single_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void destroy_single(single_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->cleanup)
|
if (this->cleanup)
|
||||||
{
|
{
|
||||||
@@ -636,11 +647,12 @@ static void destroy_single(single_enumerator_t *this)
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate_single, bool,
|
||||||
* Implementation of enumerator_create_single().enumerate
|
single_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate_single(single_enumerator_t *this, void **item)
|
|
||||||
{
|
{
|
||||||
|
void **item;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, item);
|
||||||
if (this->done)
|
if (this->done)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -650,18 +662,21 @@ static bool enumerate_single(single_enumerator_t *this, void **item)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* see header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item))
|
enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item))
|
||||||
{
|
{
|
||||||
single_enumerator_t *this = malloc_thing(single_enumerator_t);
|
single_enumerator_t *this;
|
||||||
|
|
||||||
this->public.enumerate = (void*)enumerate_single;
|
|
||||||
this->public.destroy = (void*)destroy_single;
|
|
||||||
this->item = item;
|
|
||||||
this->cleanup = cleanup;
|
|
||||||
this->done = FALSE;
|
|
||||||
|
|
||||||
|
INIT(this,
|
||||||
|
.public = {
|
||||||
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_single,
|
||||||
|
.destroy = _destroy_single,
|
||||||
|
},
|
||||||
|
.item = item,
|
||||||
|
.cleanup = cleanup,
|
||||||
|
);
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,17 +172,21 @@ enumerator_t* enumerator_create_token(const char *string, const char *sep,
|
|||||||
/**
|
/**
|
||||||
* Creates an enumerator which enumerates over enumerated enumerators :-).
|
* Creates an enumerator which enumerates over enumerated enumerators :-).
|
||||||
*
|
*
|
||||||
* The variable argument list of enumeration values is limit to 5.
|
* The outer enumerator is expected to return objects that, when passed to
|
||||||
|
* inner_contructor, will create a new enumerator that will be enumerated until
|
||||||
|
* completion (to this enumerator will the pointer arguments that are passed to
|
||||||
|
* this enumerator be forwarded) at which point a new element from the outer
|
||||||
|
* enumerator is requested to create a new inner enumerator.
|
||||||
*
|
*
|
||||||
* @param outer outer enumerator
|
* @param outer outer enumerator
|
||||||
* @param inner_constructor constructor to inner enumerator
|
* @param inner_constructor constructor to create inner enumerator
|
||||||
* @param data data to pass to each inner_constructor call
|
* @param data data to pass to each inner_constructor call
|
||||||
* @param destroy_data destructor to pass to data
|
* @param destructor destructor function to clean up data after use
|
||||||
* @return the nested enumerator
|
* @return the nested enumerator
|
||||||
*/
|
*/
|
||||||
enumerator_t *enumerator_create_nested(enumerator_t *outer,
|
enumerator_t *enumerator_create_nested(enumerator_t *outer,
|
||||||
enumerator_t *(*inner_constructor)(void *outer, void *data),
|
enumerator_t *(*inner_constructor)(void *outer, void *data),
|
||||||
void *data, void (*destroy_data)(void *data));
|
void *data, void (*destructor)(void *data));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an enumerator which filters output of another enumerator.
|
* Creates an enumerator which filters output of another enumerator.
|
||||||
|
|||||||
@@ -379,8 +379,13 @@ METHOD(hashtable_t, get_count, u_int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate, bool,
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
private_enumerator_t *this, const void **key, void **value)
|
private_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
const void **key;
|
||||||
|
void **value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key, value);
|
||||||
|
|
||||||
while (this->count && this->row < this->table->capacity)
|
while (this->count && this->row < this->table->capacity)
|
||||||
{
|
{
|
||||||
this->prev = this->current;
|
this->prev = this->current;
|
||||||
@@ -417,7 +422,8 @@ METHOD(hashtable_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerator = {
|
.enumerator = {
|
||||||
.enumerate = (void*)_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.table = this,
|
.table = this,
|
||||||
|
|||||||
@@ -119,8 +119,12 @@ struct private_enumerator_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate, bool,
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
private_enumerator_t *this, void **item)
|
private_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
void **item;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, item);
|
||||||
|
|
||||||
if (this->finished)
|
if (this->finished)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -152,7 +156,8 @@ METHOD(linked_list_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.enumerator = {
|
.enumerator = {
|
||||||
.enumerate = (void*)_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.list = this,
|
.list = this,
|
||||||
|
|||||||
@@ -146,12 +146,14 @@ typedef struct {
|
|||||||
bool enumerated[AUTH_RULE_MAX];
|
bool enumerated[AUTH_RULE_MAX];
|
||||||
} entry_enumerator_t;
|
} entry_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
* enumerate function for item_enumerator_t
|
entry_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
|
|
||||||
{
|
{
|
||||||
|
auth_rule_t *type;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
|
void **value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, value);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, &entry))
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, entry_enumerator_destroy, void,
|
||||||
* destroy function for item_enumerator_t
|
entry_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void entry_enumerator_destroy(entry_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
this->inner->destroy(this->inner);
|
this->inner->destroy(this->inner);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -190,8 +190,9 @@ METHOD(auth_cfg_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)entry_enumerator_destroy,
|
.venumerate = _enumerate,
|
||||||
|
.destroy = _entry_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = array_create_enumerator(this->entries),
|
.inner = array_create_enumerator(this->entries),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -155,8 +155,12 @@ METHOD(credential_manager_t, call_hook, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, sets_enumerate, bool,
|
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)
|
||||||
{
|
{
|
||||||
if (this->exclusive->enumerate(this->exclusive, set))
|
if (this->exclusive->enumerate(this->exclusive, set))
|
||||||
@@ -202,7 +206,8 @@ static enumerator_t *create_sets_enumerator(private_credential_manager_t *this)
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_sets_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _sets_enumerate,
|
||||||
.destroy = _sets_destroy,
|
.destroy = _sets_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -840,9 +845,12 @@ typedef struct {
|
|||||||
} trusted_enumerator_t;
|
} trusted_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, trusted_enumerate, bool,
|
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);
|
DESTROY_IF(this->auth);
|
||||||
this->auth = auth_cfg_create();
|
this->auth = auth_cfg_create();
|
||||||
@@ -931,7 +939,8 @@ METHOD(credential_manager_t, create_trusted_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_trusted_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _trusted_enumerate,
|
||||||
.destroy = _trusted_destroy,
|
.destroy = _trusted_destroy,
|
||||||
},
|
},
|
||||||
.this = this,
|
.this = this,
|
||||||
@@ -960,9 +969,13 @@ typedef struct {
|
|||||||
} public_enumerator_t;
|
} public_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, public_enumerate, bool,
|
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;
|
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))
|
while (this->inner->enumerate(this->inner, &cert, auth))
|
||||||
{
|
{
|
||||||
@@ -1001,7 +1014,8 @@ METHOD(credential_manager_t, create_public_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_public_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _public_enumerate,
|
||||||
.destroy = _public_destroy,
|
.destroy = _public_destroy,
|
||||||
},
|
},
|
||||||
.inner = create_trusted_enumerator(this, type, id, online),
|
.inner = create_trusted_enumerator(this, type, id, online),
|
||||||
|
|||||||
@@ -272,8 +272,12 @@ typedef struct {
|
|||||||
} private_enumerator_t;
|
} private_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, signature_schemes_enumerate, bool,
|
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))
|
while (++this->index < countof(scheme_map))
|
||||||
{
|
{
|
||||||
if (this->type == scheme_map[this->index].type &&
|
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,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_signature_schemes_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _signature_schemes_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.index = -1,
|
.index = -1,
|
||||||
|
|||||||
@@ -112,15 +112,15 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
* enumerate function for wrapper_enumerator_t
|
wrapper_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
|
||||||
{
|
{
|
||||||
auth_rule_t rule;
|
auth_rule_t rule;
|
||||||
certificate_t *current;
|
certificate_t *current, **cert;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, &rule, ¤t))
|
while (this->inner->enumerate(this->inner, &rule, ¤t))
|
||||||
{
|
{
|
||||||
if (rule == AUTH_HELPER_IM_HASH_URL ||
|
if (rule == AUTH_HELPER_IM_HASH_URL ||
|
||||||
@@ -164,10 +164,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, wrapper_enumerator_destroy, void,
|
||||||
* destroy function for wrapper_enumerator_t
|
wrapper_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void wrapper_enumerator_destroy(wrapper_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
this->inner->destroy(this->inner);
|
this->inner->destroy(this->inner);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -183,14 +181,18 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
enumerator = malloc_thing(wrapper_enumerator_t);
|
INIT(enumerator,
|
||||||
enumerator->auth = this->auth;
|
.public = {
|
||||||
enumerator->cert = cert;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->key = key;
|
.venumerate = _enumerate,
|
||||||
enumerator->id = id;
|
.destroy = _wrapper_enumerator_destroy,
|
||||||
enumerator->inner = this->auth->create_enumerator(this->auth);
|
},
|
||||||
enumerator->public.enumerate = (void*)enumerate;
|
.auth = this->auth,
|
||||||
enumerator->public.destroy = (void*)wrapper_enumerator_destroy;
|
.cert = cert,
|
||||||
|
.key = key,
|
||||||
|
.id = id,
|
||||||
|
.inner = this->auth->create_enumerator(this->auth),
|
||||||
|
);
|
||||||
return &enumerator->public;
|
return &enumerator->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,12 @@ typedef struct {
|
|||||||
} shared_enumerator_t;
|
} shared_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, shared_enumerate, bool,
|
METHOD(enumerator_t, shared_enumerate, bool,
|
||||||
shared_enumerator_t *this, shared_key_t **out,
|
shared_enumerator_t *this, va_list args)
|
||||||
id_match_t *match_me, id_match_t *match_other)
|
|
||||||
{
|
{
|
||||||
|
shared_key_t **out;
|
||||||
|
id_match_t *match_me, *match_other;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out, match_me, match_other);
|
||||||
DESTROY_IF(this->current);
|
DESTROY_IF(this->current);
|
||||||
this->current = this->this->cb.shared(this->this->data, this->type,
|
this->current = this->this->cb.shared(this->this->data, this->type,
|
||||||
this->me, this->other, match_me, match_other);
|
this->me, this->other, match_me, match_other);
|
||||||
@@ -89,7 +92,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_shared_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _shared_enumerate,
|
||||||
.destroy = _shared_destroy,
|
.destroy = _shared_destroy,
|
||||||
},
|
},
|
||||||
.this = this,
|
.this = this,
|
||||||
|
|||||||
@@ -252,13 +252,14 @@ typedef struct {
|
|||||||
int locked;
|
int locked;
|
||||||
} cert_enumerator_t;
|
} cert_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, cert_enumerate, bool,
|
||||||
* filter function for certs enumerator
|
cert_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
|
|
||||||
{
|
{
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
relation_t *rel;
|
relation_t *rel;
|
||||||
|
certificate_t **out;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
if (this->locked >= 0)
|
if (this->locked >= 0)
|
||||||
{
|
{
|
||||||
@@ -311,10 +312,8 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, cert_enumerator_destroy, void,
|
||||||
* clean up enumeration data
|
cert_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void cert_enumerator_destroy(cert_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
relation_t *rel;
|
relation_t *rel;
|
||||||
|
|
||||||
@@ -336,16 +335,19 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
enumerator = malloc_thing(cert_enumerator_t);
|
INIT(enumerator,
|
||||||
enumerator->public.enumerate = (void*)cert_enumerate;
|
.public = {
|
||||||
enumerator->public.destroy = (void*)cert_enumerator_destroy;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->cert = cert;
|
.venumerate = _cert_enumerate,
|
||||||
enumerator->key = key;
|
.destroy = _cert_enumerator_destroy,
|
||||||
enumerator->id = id;
|
},
|
||||||
enumerator->relations = this->relations;
|
.cert = cert,
|
||||||
enumerator->index = -1;
|
.key = key,
|
||||||
enumerator->locked = -1;
|
.id = id,
|
||||||
|
.relations = this->relations,
|
||||||
|
.index = -1,
|
||||||
|
.locked = -1,
|
||||||
|
);
|
||||||
return &enumerator->public;
|
return &enumerator->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,14 +49,15 @@ typedef struct {
|
|||||||
identification_t *id;
|
identification_t *id;
|
||||||
} wrapper_enumerator_t;
|
} wrapper_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
* enumerate function wrapper_enumerator_t
|
wrapper_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
|
|
||||||
{
|
{
|
||||||
certificate_t *current;
|
certificate_t *current, **cert;
|
||||||
public_key_t *public;
|
public_key_t *public;
|
||||||
|
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, cert);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, ¤t))
|
while (this->inner->enumerate(this->inner, ¤t))
|
||||||
{
|
{
|
||||||
if (this->cert != CERT_ANY && this->cert != current->get_type(current))
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, enumerator_destroy, void,
|
||||||
* destroy function for wrapper_enumerator_t
|
wrapper_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void enumerator_destroy(wrapper_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
this->inner->destroy(this->inner);
|
this->inner->destroy(this->inner);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -105,13 +104,17 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerator = malloc_thing(wrapper_enumerator_t);
|
INIT(enumerator,
|
||||||
enumerator->cert = cert;
|
.public = {
|
||||||
enumerator->key = key;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->id = id;
|
.venumerate = _enumerate,
|
||||||
enumerator->inner = this->response->create_cert_enumerator(this->response);
|
.destroy = _enumerator_destroy,
|
||||||
enumerator->public.enumerate = (void*)enumerate;
|
},
|
||||||
enumerator->public.destroy = (void*)enumerator_destroy;
|
.cert = cert,
|
||||||
|
.key = key,
|
||||||
|
.id = id,
|
||||||
|
.inner = this->response->create_cert_enumerator(this->response),
|
||||||
|
);
|
||||||
return &enumerator->public;
|
return &enumerator->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1026,9 +1026,14 @@ typedef struct {
|
|||||||
} verify_enumerator_t;
|
} verify_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, verify_enumerate, bool,
|
METHOD(enumerator_t, verify_enumerate, bool,
|
||||||
verify_enumerator_t *this, u_int *alg, const char **plugin, bool *valid)
|
verify_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
const char **plugin;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
|
u_int *alg;
|
||||||
|
bool *valid;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, alg, plugin, valid);
|
||||||
|
|
||||||
if (!this->inner->enumerate(this->inner, &entry))
|
if (!this->inner->enumerate(this->inner, &entry))
|
||||||
{
|
{
|
||||||
@@ -1123,7 +1128,8 @@ METHOD(crypto_factory_t, create_verify_enumerator, enumerator_t*,
|
|||||||
}
|
}
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_verify_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _verify_enumerate,
|
||||||
.destroy = _verify_destroy,
|
.destroy = _verify_destroy,
|
||||||
},
|
},
|
||||||
.inner = inner,
|
.inner = inner,
|
||||||
|
|||||||
@@ -403,10 +403,8 @@ typedef struct {
|
|||||||
unsigned long *length;
|
unsigned long *length;
|
||||||
} mysql_enumerator_t;
|
} mysql_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, mysql_enumerator_destroy, void,
|
||||||
* create a mysql enumerator
|
mysql_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void mysql_enumerator_destroy(mysql_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
int columns, i;
|
int columns, i;
|
||||||
|
|
||||||
@@ -434,13 +432,10 @@ static void mysql_enumerator_destroy(mysql_enumerator_t *this)
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, mysql_enumerator_enumerate, bool,
|
||||||
* Implementation of database.query().enumerate
|
mysql_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
int i, columns;
|
int i, columns;
|
||||||
va_list args;
|
|
||||||
|
|
||||||
columns = mysql_stmt_field_count(this->stmt);
|
columns = mysql_stmt_field_count(this->stmt);
|
||||||
|
|
||||||
@@ -477,7 +472,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(args, this);
|
|
||||||
for (i = 0; i < columns; i++)
|
for (i = 0; i < columns; i++)
|
||||||
{
|
{
|
||||||
switch (this->bind[i].buffer_type)
|
switch (this->bind[i].buffer_type)
|
||||||
@@ -526,7 +520,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(args);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,9 +545,9 @@ METHOD(database_t, query, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)mysql_enumerator_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
.destroy = (void*)mysql_enumerator_destroy,
|
.venumerate = _mysql_enumerator_enumerate,
|
||||||
|
.destroy = _mysql_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.db = this,
|
.db = this,
|
||||||
.stmt = stmt,
|
.stmt = stmt,
|
||||||
|
|||||||
@@ -142,8 +142,14 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
METHOD(enumerator_t, crl_enumerate, bool,
|
METHOD(enumerator_t, crl_enumerate, bool,
|
||||||
crl_enumerator_t *this, chunk_t *serial, time_t *date, crl_reason_t *reason)
|
crl_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
crl_reason_t *reason;
|
||||||
|
chunk_t *serial;
|
||||||
|
time_t *date;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, serial, date, reason);
|
||||||
|
|
||||||
if (this->i < this->num)
|
if (this->i < this->num)
|
||||||
{
|
{
|
||||||
X509_REVOKED *revoked;
|
X509_REVOKED *revoked;
|
||||||
@@ -188,7 +194,8 @@ METHOD(crl_t, create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_crl_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _crl_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.stack = X509_CRL_get_REVOKED(this->crl),
|
.stack = X509_CRL_get_REVOKED(this->crl),
|
||||||
|
|||||||
@@ -136,8 +136,12 @@ METHOD(enumerator_t, cert_destroy, void,
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, cert_enumerate, bool,
|
METHOD(enumerator_t, cert_enumerate, bool,
|
||||||
cert_enumerator_t *this, certificate_t **out)
|
cert_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
certificate_t **out;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
if (!this->certs)
|
if (!this->certs)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -176,7 +180,8 @@ METHOD(pkcs7_t, create_cert_enumerator, enumerator_t*,
|
|||||||
{
|
{
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_cert_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _cert_enumerate,
|
||||||
.destroy = _cert_destroy,
|
.destroy = _cert_destroy,
|
||||||
},
|
},
|
||||||
.certs = CMS_get1_certs(this->cms),
|
.certs = CMS_get1_certs(this->cms),
|
||||||
@@ -320,8 +325,12 @@ static bool verify_digest(CMS_ContentInfo *cms, CMS_SignerInfo *si, int hash_oid
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, signature_enumerate, bool,
|
METHOD(enumerator_t, signature_enumerate, bool,
|
||||||
signature_enumerator_t *this, auth_cfg_t **out)
|
signature_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
auth_cfg_t **out;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
if (!this->signers)
|
if (!this->signers)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -382,7 +391,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_signature_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _signature_enumerate,
|
||||||
.destroy = _signature_destroy,
|
.destroy = _signature_destroy,
|
||||||
},
|
},
|
||||||
.cms = this->cms,
|
.cms = this->cms,
|
||||||
|
|||||||
@@ -719,12 +719,14 @@ static bool get_attributes(object_enumerator_t *this, CK_OBJECT_HANDLE object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(enumerator_t, object_enumerate, bool,
|
METHOD(enumerator_t, object_enumerate, bool,
|
||||||
object_enumerator_t *this, CK_OBJECT_HANDLE *out)
|
object_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
CK_OBJECT_HANDLE object;
|
CK_OBJECT_HANDLE object, *out;
|
||||||
CK_ULONG found;
|
CK_ULONG found;
|
||||||
CK_RV rv;
|
CK_RV rv;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
if (!this->object)
|
if (!this->object)
|
||||||
{
|
{
|
||||||
rv = this->lib->f->C_FindObjects(this->session, &object, 1, &found);
|
rv = this->lib->f->C_FindObjects(this->session, &object, 1, &found);
|
||||||
@@ -786,7 +788,8 @@ METHOD(pkcs11_library_t, create_object_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_object_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _object_enumerate,
|
||||||
.destroy = _object_destroy,
|
.destroy = _object_destroy,
|
||||||
},
|
},
|
||||||
.session = session,
|
.session = session,
|
||||||
@@ -806,7 +809,8 @@ METHOD(pkcs11_library_t, create_object_attr_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_object_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _object_enumerate,
|
||||||
.destroy = _object_destroy,
|
.destroy = _object_destroy,
|
||||||
},
|
},
|
||||||
.session = session,
|
.session = session,
|
||||||
@@ -838,11 +842,14 @@ typedef struct {
|
|||||||
} mechanism_enumerator_t;
|
} mechanism_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_mech, bool,
|
METHOD(enumerator_t, enumerate_mech, bool,
|
||||||
mechanism_enumerator_t *this, CK_MECHANISM_TYPE* type,
|
mechanism_enumerator_t *this, va_list args)
|
||||||
CK_MECHANISM_INFO *info)
|
|
||||||
{
|
{
|
||||||
|
CK_MECHANISM_INFO *info;
|
||||||
|
CK_MECHANISM_TYPE *type;
|
||||||
CK_RV rv;
|
CK_RV rv;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, info);
|
||||||
|
|
||||||
if (this->current >= this->count)
|
if (this->current >= this->count)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -876,7 +883,8 @@ METHOD(pkcs11_library_t, create_mechanism_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_mech,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_mech,
|
||||||
.destroy = _destroy_mech,
|
.destroy = _destroy_mech,
|
||||||
},
|
},
|
||||||
.lib = &this->public,
|
.lib = &this->public,
|
||||||
|
|||||||
@@ -265,8 +265,13 @@ typedef struct {
|
|||||||
} token_enumerator_t;
|
} token_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate_token, bool,
|
METHOD(enumerator_t, enumerate_token, bool,
|
||||||
token_enumerator_t *this, pkcs11_library_t **out, CK_SLOT_ID *slot)
|
token_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
pkcs11_library_t **out;
|
||||||
|
CK_SLOT_ID *slot;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out, slot);
|
||||||
|
|
||||||
if (this->current >= this->count)
|
if (this->current >= this->count)
|
||||||
{
|
{
|
||||||
free(this->slots);
|
free(this->slots);
|
||||||
@@ -301,7 +306,8 @@ METHOD(pkcs11_manager_t, create_token_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate_token,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate_token,
|
||||||
.destroy = _destroy_token,
|
.destroy = _destroy_token,
|
||||||
},
|
},
|
||||||
.inner = this->libs->create_enumerator(this->libs),
|
.inner = this->libs->create_enumerator(this->libs),
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ typedef struct {
|
|||||||
} signature_enumerator_t;
|
} signature_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, enumerate, bool,
|
METHOD(enumerator_t, enumerate, bool,
|
||||||
signature_enumerator_t *this, auth_cfg_t **out)
|
signature_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
signerinfo_t *info;
|
signerinfo_t *info;
|
||||||
signature_scheme_t scheme;
|
signature_scheme_t scheme;
|
||||||
@@ -187,11 +187,13 @@ METHOD(enumerator_t, enumerate, bool,
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
certificate_t *cert;
|
certificate_t *cert;
|
||||||
public_key_t *key;
|
public_key_t *key;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth, **out;
|
||||||
chunk_t chunk, hash, content;
|
chunk_t chunk, hash, content;
|
||||||
hasher_t *hasher;
|
hasher_t *hasher;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, out);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, &info))
|
while (this->inner->enumerate(this->inner, &info))
|
||||||
{
|
{
|
||||||
/* clean up previous round */
|
/* clean up previous round */
|
||||||
@@ -300,7 +302,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _enumerate,
|
||||||
.destroy = _enumerator_destroy,
|
.destroy = _enumerator_destroy,
|
||||||
},
|
},
|
||||||
.inner = this->signerinfos->create_enumerator(this->signerinfos),
|
.inner = this->signerinfos->create_enumerator(this->signerinfos),
|
||||||
|
|||||||
@@ -174,10 +174,8 @@ typedef struct {
|
|||||||
private_sqlite_database_t *database;
|
private_sqlite_database_t *database;
|
||||||
} sqlite_enumerator_t;
|
} sqlite_enumerator_t;
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, sqlite_enumerator_destroy, void,
|
||||||
* destroy a sqlite enumerator
|
sqlite_enumerator_t *this)
|
||||||
*/
|
|
||||||
static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
|
|
||||||
{
|
{
|
||||||
sqlite3_finalize(this->stmt);
|
sqlite3_finalize(this->stmt);
|
||||||
if (!is_threadsave())
|
if (!is_threadsave())
|
||||||
@@ -188,13 +186,10 @@ static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(enumerator_t, sqlite_enumerator_enumerate, bool,
|
||||||
* Implementation of database.query().enumerate
|
sqlite_enumerator_t *this, va_list args)
|
||||||
*/
|
|
||||||
static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
va_list args;
|
|
||||||
|
|
||||||
switch (sqlite3_step(this->stmt))
|
switch (sqlite3_step(this->stmt))
|
||||||
{
|
{
|
||||||
@@ -207,7 +202,7 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
|
|||||||
case SQLITE_DONE:
|
case SQLITE_DONE:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
va_start(args, this);
|
|
||||||
for (i = 0; i < this->count; i++)
|
for (i = 0; i < this->count; i++)
|
||||||
{
|
{
|
||||||
switch (this->columns[i])
|
switch (this->columns[i])
|
||||||
@@ -245,11 +240,9 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
DBG1(DBG_LIB, "invalid result type supplied");
|
DBG1(DBG_LIB, "invalid result type supplied");
|
||||||
va_end(args);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(args);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,13 +263,17 @@ METHOD(database_t, query, enumerator_t*,
|
|||||||
stmt = run(this, sql, &args);
|
stmt = run(this, sql, &args);
|
||||||
if (stmt)
|
if (stmt)
|
||||||
{
|
{
|
||||||
enumerator = malloc_thing(sqlite_enumerator_t);
|
INIT(enumerator,
|
||||||
enumerator->public.enumerate = (void*)sqlite_enumerator_enumerate;
|
.public = {
|
||||||
enumerator->public.destroy = (void*)sqlite_enumerator_destroy;
|
.enumerate = enumerator_enumerate_default,
|
||||||
enumerator->stmt = stmt;
|
.venumerate = _sqlite_enumerator_enumerate,
|
||||||
enumerator->count = sqlite3_column_count(stmt);
|
.destroy = _sqlite_enumerator_destroy,
|
||||||
|
},
|
||||||
|
.stmt = stmt,
|
||||||
|
.count = sqlite3_column_count(stmt),
|
||||||
|
.database = this,
|
||||||
|
);
|
||||||
enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count);
|
enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count);
|
||||||
enumerator->database = this;
|
|
||||||
for (i = 0; i < enumerator->count; i++)
|
for (i = 0; i < enumerator->count; i++)
|
||||||
{
|
{
|
||||||
enumerator->columns[i] = va_arg(args, db_type_t);
|
enumerator->columns[i] = va_arg(args, db_type_t);
|
||||||
|
|||||||
@@ -744,10 +744,8 @@ typedef struct {
|
|||||||
hashtable_t *seen;
|
hashtable_t *seen;
|
||||||
} enumerator_data_t;
|
} enumerator_data_t;
|
||||||
|
|
||||||
/**
|
CALLBACK(enumerator_destroy, void,
|
||||||
* Destroy enumerator data
|
enumerator_data_t *this)
|
||||||
*/
|
|
||||||
static void enumerator_destroy(enumerator_data_t *this)
|
|
||||||
{
|
{
|
||||||
this->settings->lock->unlock(this->settings->lock);
|
this->settings->lock->unlock(this->settings->lock);
|
||||||
this->seen->destroy(this->seen);
|
this->seen->destroy(this->seen);
|
||||||
|
|||||||
@@ -668,8 +668,12 @@ typedef struct {
|
|||||||
} frame_enumerator_t;
|
} frame_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, frame_enumerate, bool,
|
METHOD(enumerator_t, frame_enumerate, bool,
|
||||||
frame_enumerator_t *this, void **addr)
|
frame_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
|
void **addr;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, addr);
|
||||||
|
|
||||||
if (this->i < this->bt->frame_count)
|
if (this->i < this->bt->frame_count)
|
||||||
{
|
{
|
||||||
*addr = this->bt->frames[this->i++];
|
*addr = this->bt->frames[this->i++];
|
||||||
@@ -685,7 +689,8 @@ METHOD(backtrace_t, create_frame_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_frame_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _frame_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
.bt = this,
|
.bt = this,
|
||||||
|
|||||||
@@ -136,9 +136,12 @@ typedef struct {
|
|||||||
} rdn_enumerator_t;
|
} rdn_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, rdn_enumerate, bool,
|
METHOD(enumerator_t, rdn_enumerate, bool,
|
||||||
rdn_enumerator_t *this, chunk_t *oid, u_char *type, chunk_t *data)
|
rdn_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
chunk_t rdn;
|
chunk_t rdn, *oid, *data;
|
||||||
|
u_char *type;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, oid, type, data);
|
||||||
|
|
||||||
/* a DN contains one or more SET, each containing one or more SEQUENCES,
|
/* a DN contains one or more SET, each containing one or more SEQUENCES,
|
||||||
* each containing a OID/value RDN */
|
* each containing a OID/value RDN */
|
||||||
@@ -173,7 +176,8 @@ static enumerator_t* create_rdn_enumerator(chunk_t dn)
|
|||||||
|
|
||||||
INIT(e,
|
INIT(e,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_rdn_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _rdn_enumerate,
|
||||||
.destroy = (void*)free,
|
.destroy = (void*)free,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -199,10 +203,11 @@ typedef struct {
|
|||||||
} rdn_part_enumerator_t;
|
} rdn_part_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, rdn_part_enumerate, bool,
|
METHOD(enumerator_t, rdn_part_enumerate, bool,
|
||||||
rdn_part_enumerator_t *this, id_part_t *type, chunk_t *data)
|
rdn_part_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
int i, known_oid, strtype;
|
int i, known_oid, strtype;
|
||||||
chunk_t oid, inner_data;
|
chunk_t oid, inner_data, *data;
|
||||||
|
id_part_t *type;
|
||||||
static const struct {
|
static const struct {
|
||||||
int oid;
|
int oid;
|
||||||
id_part_t type;
|
id_part_t type;
|
||||||
@@ -228,6 +233,8 @@ METHOD(enumerator_t, rdn_part_enumerate, bool,
|
|||||||
{OID_EMPLOYEE_NUMBER, ID_PART_RDN_EN},
|
{OID_EMPLOYEE_NUMBER, ID_PART_RDN_EN},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, type, data);
|
||||||
|
|
||||||
while (this->inner->enumerate(this->inner, &oid, &strtype, &inner_data))
|
while (this->inner->enumerate(this->inner, &oid, &strtype, &inner_data))
|
||||||
{
|
{
|
||||||
known_oid = asn1_known_oid(oid);
|
known_oid = asn1_known_oid(oid);
|
||||||
@@ -263,7 +270,8 @@ METHOD(identification_t, create_part_enumerator, enumerator_t*,
|
|||||||
INIT(e,
|
INIT(e,
|
||||||
.inner = create_rdn_enumerator(this->encoded),
|
.inner = create_rdn_enumerator(this->encoded),
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_rdn_part_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _rdn_part_enumerate,
|
||||||
.destroy = _rdn_part_enumerator_destroy,
|
.destroy = _rdn_part_enumerator_destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
+8
-2
@@ -67,8 +67,13 @@ typedef struct {
|
|||||||
} child_enum_t;
|
} child_enum_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, child_enumerate, bool,
|
METHOD(enumerator_t, child_enumerate, bool,
|
||||||
child_enum_t *e, private_xml_t **child, char **name, char **value)
|
child_enum_t *e, va_list args)
|
||||||
{
|
{
|
||||||
|
private_xml_t **child;
|
||||||
|
char **name, **value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, child, name, value);
|
||||||
|
|
||||||
while (e->node && e->node->type != XML_ELEMENT_NODE)
|
while (e->node && e->node->type != XML_ELEMENT_NODE)
|
||||||
{
|
{
|
||||||
e->node = e->node->next;
|
e->node = e->node->next;
|
||||||
@@ -120,7 +125,8 @@ METHOD(xml_t, children, enumerator_t*,
|
|||||||
child_enum_t *ce;
|
child_enum_t *ce;
|
||||||
INIT(ce,
|
INIT(ce,
|
||||||
.e = {
|
.e = {
|
||||||
.enumerate = (void*)_child_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _child_enumerate,
|
||||||
.destroy = _child_destroy,
|
.destroy = _child_destroy,
|
||||||
},
|
},
|
||||||
.child = {
|
.child = {
|
||||||
|
|||||||
@@ -158,10 +158,13 @@ typedef struct {
|
|||||||
} dictionary_enumerator_t;
|
} dictionary_enumerator_t;
|
||||||
|
|
||||||
METHOD(enumerator_t, dictionary_enumerate, bool,
|
METHOD(enumerator_t, dictionary_enumerate, bool,
|
||||||
dictionary_enumerator_t *this, char **key, char **value)
|
dictionary_enumerator_t *this, va_list args)
|
||||||
{
|
{
|
||||||
setting_t *setting;
|
setting_t *setting;
|
||||||
section_t *parent;
|
section_t *parent;
|
||||||
|
char **key, **value;
|
||||||
|
|
||||||
|
VA_ARGS_VGET(args, key, value);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
@@ -221,7 +224,8 @@ METHOD(dictionary_t, dictionary_create_enumerator, enumerator_t*,
|
|||||||
|
|
||||||
INIT(enumerator,
|
INIT(enumerator,
|
||||||
.public = {
|
.public = {
|
||||||
.enumerate = (void*)_dictionary_enumerate,
|
.enumerate = enumerator_enumerate_default,
|
||||||
|
.venumerate = _dictionary_enumerate,
|
||||||
.destroy = _dictionary_enumerator_destroy,
|
.destroy = _dictionary_enumerator_destroy,
|
||||||
},
|
},
|
||||||
.seen = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8),
|
.seen = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8),
|
||||||
|
|||||||
Reference in New Issue
Block a user