Change interface for enumerator_create_filter() callback

This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
This commit is contained in:
Tobias Brunner
2017-05-26 13:56:44 +02:00
parent 95a63bf281
commit 525cc46cab
50 changed files with 1331 additions and 929 deletions
+16 -10
View File
@@ -184,16 +184,22 @@ METHOD(attribute_provider_t, release_address, bool,
return found;
}
/**
* Filter mapping attribute_t to enumerated type/value arguments
*/
static bool attr_filter(void *data, attribute_t **attr,
configuration_attribute_type_t *type,
void *in, chunk_t *value)
CALLBACK(attr_filter, bool,
void *data, enumerator_t *orig, va_list args)
{
*type = (*attr)->type;
*value = (*attr)->value;
return TRUE;
attribute_t *attr;
configuration_attribute_type_t *type;
chunk_t *value;
VA_ARGS_VGET(args, type, value);
if (orig->enumerate(orig, &attr))
{
*type = attr->type;
*value = attr->value;
return TRUE;
}
return FALSE;
}
/**
@@ -203,7 +209,7 @@ CALLBACK(create_nested, enumerator_t*,
pool_t *pool, void *this)
{
return enumerator_create_filter(array_create_enumerator(pool->attrs),
(void*)attr_filter, NULL, NULL);
attr_filter, NULL, NULL);
}
/**
+14 -7
View File
@@ -141,13 +141,20 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
(void*)this->lock->unlock, this->lock);
}
/**
* Enumerator filter function for ike configs
*/
static bool ike_filter(void *data, peer_cfg_t **in, ike_cfg_t **out)
CALLBACK(ike_filter, bool,
void *data, enumerator_t *orig, va_list args)
{
*out = (*in)->get_ike_cfg(*in);
return TRUE;
peer_cfg_t *cfg;
ike_cfg_t **out;
VA_ARGS_VGET(args, out);
if (orig->enumerate(orig, &cfg))
{
*out = cfg->get_ike_cfg(cfg);
return TRUE;
}
return FALSE;
}
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
@@ -155,7 +162,7 @@ METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
{
this->lock->read_lock(this->lock);
return enumerator_create_filter(this->conns->create_enumerator(this->conns),
(void*)ike_filter, this->lock,
ike_filter, this->lock,
(void*)this->lock->unlock);
}