Migrate all enumerators to venumerate() interface change
authorTobias Brunner <tobias@strongswan.org>
Thu, 11 May 2017 07:17:02 +0000 (09:17 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 26 May 2017 11:56:44 +0000 (13:56 +0200)
68 files changed:
src/charon-nm/nm/nm_creds.c
src/charon-nm/nm/nm_handler.c
src/dumm/dumm.c
src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_attr.c
src/libcharon/attributes/attribute_manager.c
src/libcharon/attributes/mem_pool.c
src/libcharon/config/peer_cfg.c
src/libcharon/encoding/payloads/certreq_payload.c
src/libcharon/encoding/payloads/delete_payload.c
src/libcharon/encoding/payloads/eap_payload.c
src/libcharon/plugins/android_dns/android_dns_handler.c
src/libcharon/plugins/dnscert/dnscert_cred.c
src/libcharon/plugins/eap_radius/eap_radius_provider.c
src/libcharon/plugins/eap_sim_file/eap_sim_file_triplets.c
src/libcharon/plugins/ha/ha_message.c
src/libcharon/plugins/ha/ha_tunnel.c
src/libcharon/plugins/ipseckey/ipseckey_cred.c
src/libcharon/plugins/kernel_iph/kernel_iph_net.c
src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c
src/libcharon/plugins/kernel_pfroute/kernel_pfroute_net.c
src/libcharon/plugins/medcli/medcli_config.c
src/libcharon/plugins/medcli/medcli_creds.c
src/libcharon/plugins/medsrv/medsrv_creds.c
src/libcharon/plugins/osx_attr/osx_attr_handler.c
src/libcharon/plugins/p_cscf/p_cscf_handler.c
src/libcharon/plugins/resolve/resolve_handler.c
src/libcharon/plugins/sql/sql_config.c
src/libcharon/plugins/sql/sql_cred.c
src/libcharon/plugins/uci/uci_config.c
src/libcharon/plugins/uci/uci_creds.c
src/libcharon/plugins/uci/uci_parser.c
src/libcharon/plugins/unity/unity_handler.c
src/libcharon/plugins/unity/unity_provider.c
src/libcharon/plugins/vici/suites/test_message.c
src/libcharon/plugins/vici/vici_message.c
src/libcharon/sa/child_sa.c
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ike_sa_manager.c
src/libimcv/imc/imc_os_info.c
src/libimcv/imv/imv_agent.c
src/libimcv/pts/pts_pcr.c
src/libpttls/sasl/sasl_mechanism.c
src/libradius/radius_message.c
src/libstrongswan/collections/array.c
src/libstrongswan/collections/enumerator.c
src/libstrongswan/collections/enumerator.h
src/libstrongswan/collections/hashtable.c
src/libstrongswan/collections/linked_list.c
src/libstrongswan/credentials/auth_cfg.c
src/libstrongswan/credentials/credential_manager.c
src/libstrongswan/credentials/keys/public_key.c
src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
src/libstrongswan/credentials/sets/callback_cred.c
src/libstrongswan/credentials/sets/cert_cache.c
src/libstrongswan/credentials/sets/ocsp_response_wrapper.c
src/libstrongswan/crypto/crypto_factory.c
src/libstrongswan/plugins/mysql/mysql_database.c
src/libstrongswan/plugins/openssl/openssl_crl.c
src/libstrongswan/plugins/openssl/openssl_pkcs7.c
src/libstrongswan/plugins/pkcs11/pkcs11_library.c
src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
src/libstrongswan/plugins/pkcs7/pkcs7_signed_data.c
src/libstrongswan/plugins/sqlite/sqlite_database.c
src/libstrongswan/settings/settings.c
src/libstrongswan/utils/backtrace.c
src/libstrongswan/utils/identification.c
src/manager/xml.c
src/starter/parser/conf_parser.c

index f8fae95..c191ffd 100644 (file)
@@ -235,9 +235,13 @@ typedef struct {
 } shared_enumerator_t;
 
 METHOD(enumerator_t, shared_enumerate, bool,
-       shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
-       id_match_t *other)
+       shared_enumerator_t *this, va_list args)
 {
+       shared_key_t **key;
+       id_match_t *me, *other;
+
+       VA_ARGS_VGET(args, key, me, other);
+
        if (this->done)
        {
                return FALSE;
@@ -307,7 +311,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_shared_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _shared_enumerate,
                        .destroy = _shared_destroy,
                },
                .this = this,
index bdc0667..6c81afa 100644 (file)
@@ -65,29 +65,33 @@ METHOD(attribute_handler_t, handle, bool,
        return TRUE;
 }
 
-/**
- * Implementation of create_attribute_enumerator().enumerate() for WINS
- */
-static bool enumerate_nbns(enumerator_t *this,
-                                                  configuration_attribute_type_t *type, chunk_t *data)
+METHOD(enumerator_t, enumerate_nbns, bool,
+       enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        *type = INTERNAL_IP4_NBNS;
        *data = chunk_empty;
-       /* done */
-       this->enumerate = (void*)return_false;
+       this->venumerate = (void*)return_false;
        return TRUE;
 }
 
 /**
  * Implementation of create_attribute_enumerator().enumerate() for DNS
  */
-static bool enumerate_dns(enumerator_t *this,
-                                                 configuration_attribute_type_t *type, chunk_t *data)
+METHOD(enumerator_t, enumerate_dns, bool,
+       enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        *type = INTERNAL_IP4_DNS;
        *data = chunk_empty;
        /* enumerate WINS server as next attribute ... */
-       this->enumerate = (void*)enumerate_nbns;
+       this->venumerate = _enumerate_nbns;
        return TRUE;
 }
 
@@ -100,7 +104,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
 
                INIT(enumerator,
                        /* enumerate DNS attribute first ... */
-                       .enumerate = (void*)enumerate_dns,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_dns,
                        .destroy = (void*)free,
                );
                return enumerator;
index cc4f5a1..d147b2d 100644 (file)
@@ -267,10 +267,12 @@ typedef struct {
 } template_enumerator_t;
 
 METHOD(enumerator_t, template_enumerate, bool,
-       template_enumerator_t *this, char **template)
+       template_enumerator_t *this, va_list args)
 {
        struct stat st;
-       char *rel;
+       char *rel, **template;
+
+       VA_ARGS_VGET(args, template);
 
        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;
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_template_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _template_enumerate,
                        .destroy = (void*)_template_enumerator_destroy,
                },
                .inner = enumerator_create_directory(TEMPLATE_DIR),
index 47933d1..5e4898f 100644 (file)
@@ -73,20 +73,28 @@ METHOD(attribute_handler_t, release, void,
 }
 
 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;
        *data = chunk_empty;
-       this->enumerate = (void*)return_false;
+       this->venumerate = (void*)return_false;
        return TRUE;
 }
 
 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;
        *data = chunk_empty;
-       this->enumerate = (void*)_enumerate_dns6;
+       this->venumerate = _enumerate_dns6;
        return TRUE;
 }
 
@@ -96,7 +104,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
        enumerator_t *enumerator;
 
        INIT(enumerator,
-                       .enumerate = (void*)_enumerate_dns4,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_dns4,
                        .destroy = (void*)free,
        );
        return enumerator;
index 2ab7ed1..3a4a21a 100644 (file)
@@ -237,14 +237,14 @@ typedef struct {
        linked_list_t *vips;
 } initiator_enumerator_t;
 
-/**
- * Enumerator implementation for initiator attributes
- */
-static bool initiator_enumerate(initiator_enumerator_t *this,
-                                                               attribute_handler_t **handler,
-                                                               configuration_attribute_type_t *type,
-                                                               chunk_t *value)
+METHOD(enumerator_t, initiator_enumerate, bool,
+       initiator_enumerator_t *this, va_list args)
 {
+       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 */
        while (!this->inner || !this->inner->enumerate(this->inner, type, value))
        {
@@ -261,10 +261,8 @@ static bool initiator_enumerate(initiator_enumerator_t *this,
        return TRUE;
 }
 
-/**
- * Cleanup function of initiator attribute enumerator
- */
-static void initiator_destroy(initiator_enumerator_t *this)
+METHOD(enumerator_t, initiator_destroy, void,
+       initiator_enumerator_t *this)
 {
        this->this->lock->unlock(this->this->lock);
        this->outer->destroy(this->outer);
@@ -281,8 +279,9 @@ METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)initiator_enumerate,
-                       .destroy = (void*)initiator_destroy,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _initiator_enumerate,
+                       .destroy = _initiator_destroy,
                },
                .this = this,
                .ike_sa = ike_sa,
index a2b7c28..e1a9a6d 100644 (file)
@@ -512,10 +512,15 @@ typedef struct {
 } lease_enumerator_t;
 
 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;
+       host_t **addr;
+       u_int *offset;
+       bool *online;
+
+       VA_ARGS_VGET(args, id, addr, online);
 
        DESTROY_IF(this->addr);
        this->addr = NULL;
@@ -570,7 +575,8 @@ METHOD(mem_pool_t, create_lease_enumerator, enumerator_t*,
        this->mutex->lock(this->mutex);
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_lease_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _lease_enumerate,
                        .destroy = _lease_enumerator_destroy,
                },
                .pool = this,
index 5d7ab07..fcdd6fd 100644 (file)
@@ -209,9 +209,12 @@ typedef struct {
 } child_cfgs_replace_enumerator_t;
 
 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)
        {
@@ -303,8 +306,9 @@ METHOD(peer_cfg_t, replace_child_cfgs, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_child_cfgs_replace_enumerate,
-                       .destroy = (void*)_child_cfgs_replace_enumerator_destroy,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _child_cfgs_replace_enumerate,
+                       .destroy = _child_cfgs_replace_enumerator_destroy,
                },
                .removed = removed,
                .added = added,
@@ -336,8 +340,11 @@ METHOD(enumerator_t, child_cfg_enumerator_destroy, void,
 }
 
 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);
 }
 
@@ -348,8 +355,9 @@ METHOD(peer_cfg_t, create_child_cfg_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_child_cfg_enumerate,
-                       .destroy = (void*)_child_cfg_enumerator_destroy,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _child_cfg_enumerate,
+                       .destroy = _child_cfg_enumerator_destroy,
                },
                .mutex = this->mutex,
                .wrapped = this->child_cfgs->create_enumerator(this->child_cfgs),
index 09bfa24..643fbc4 100644 (file)
@@ -190,8 +190,12 @@ struct keyid_enumerator_t  {
 };
 
 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)
        {
                this->pos = this->full.ptr;
@@ -224,7 +228,8 @@ METHOD(certreq_payload_t, create_keyid_enumerator, enumerator_t*,
        }
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_keyid_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _keyid_enumerate,
                        .destroy = (void*)free,
                },
                .full = this->data,
index 584e6f2..3634cd3 100644 (file)
@@ -306,8 +306,12 @@ typedef struct {
 } spi_enumerator_t;
 
 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))
        {
                memcpy(spi, this->spis.ptr, sizeof(*spi));
@@ -328,7 +332,8 @@ METHOD(delete_payload_t, create_spi_enumerator, enumerator_t*,
        }
        INIT(e,
                .public = {
-                       .enumerate = (void*)_spis_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _spis_enumerate,
                        .destroy = (void*)free,
                },
                .spis = this->spis,
index 8c3fc59..923135d 100644 (file)
@@ -270,8 +270,12 @@ typedef struct {
 } type_enumerator_t;
 
 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);
        return this->offset;
 }
@@ -289,7 +293,8 @@ METHOD(eap_payload_t, get_types, enumerator_t*,
        {
                INIT(enumerator,
                        .public = {
-                               .enumerate = (void*)_enumerate_types,
+                               .enumerate = enumerator_enumerate_default,
+                               .venumerate = _enumerate_types,
                                .destroy = (void*)free,
                        },
                        .payload = this,
index 160a145..68bbaec 100644 (file)
@@ -182,12 +182,15 @@ METHOD(attribute_handler_t, release, void,
 }
 
 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;
        *data = chunk_empty;
-       /* stop enumeration */
-       this->enumerate = (void*)return_false;
+       this->venumerate = return_false;
        return TRUE;
 }
 
@@ -198,7 +201,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
        enumerator_t *enumerator;
 
        INIT(enumerator,
-               .enumerate = (void*)_enumerate_dns,
+               .enumerate = enumerator_enumerate_default,
+               .venumerate = _enumerate_dns,
                .destroy = (void*)free,
        );
        return enumerator;
index d32794c..533bd5b 100644 (file)
@@ -75,12 +75,15 @@ typedef struct {
 } cert_enumerator_t;
 
 METHOD(enumerator_t, cert_enumerator_enumerate, bool,
-       cert_enumerator_t *this, certificate_t **cert)
+       cert_enumerator_t *this, va_list args)
 {
+       certificate_t **cert;
        dnscert_t *cur_crt;
        rr_t *cur_rr;
        chunk_t certificate;
 
+       VA_ARGS_VGET(args, cert);
+
        /* Get the next supported CERT using the inner enumerator. */
        while (this->inner->enumerate(this->inner, &cur_rr))
        {
@@ -175,7 +178,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cert_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerator_enumerate,
                        .destroy = _cert_enumerator_destroy,
                },
                .inner = response->get_rr_set(response)->create_rr_enumerator(
index 9a87ad3..58bbc2e 100644 (file)
@@ -404,11 +404,13 @@ typedef struct {
        attr_t *current;
 } attribute_enumerator_t;
 
-
 METHOD(enumerator_t, attribute_enumerate, bool,
-       attribute_enumerator_t *this, configuration_attribute_type_t *type,
-       chunk_t *data)
+       attribute_enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        if (this->current)
        {
                destroy_attr(this->current);
@@ -446,7 +448,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_attribute_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _attribute_enumerate,
                        .destroy = _attribute_destroy,
                },
                .list = linked_list_create(),
index ec16869..e11e0e5 100644 (file)
@@ -79,10 +79,8 @@ typedef struct {
        private_eap_sim_file_triplets_t *this;
 } triplet_enumerator_t;
 
-/**
- * destroy a triplet enumerator
- */
-static void enumerator_destroy(triplet_enumerator_t *e)
+METHOD(enumerator_t, enumerator_destroy, void,
+       triplet_enumerator_t *e)
 {
        if (e->current)
        {
@@ -97,13 +95,14 @@ static void enumerator_destroy(triplet_enumerator_t *e)
        free(e);
 }
 
-/**
- * enumerate through triplets
- */
-static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **imsi,
-                                                                char **rand, char **sres, char **kc)
+METHOD(enumerator_t, enumerator_enumerate, bool,
+       triplet_enumerator_t *e, va_list args)
 {
+       identification_t **imsi;
        triplet_t *triplet;
+       char **rand, **sres, **kc;
+
+       VA_ARGS_VGET(args, imsi, rand, sres, kc);
 
        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);
 
        this->mutex->lock(this->mutex);
-       enumerator->public.enumerate = (void*)enumerator_enumerate;
-       enumerator->public.destroy = (void*)enumerator_destroy;
-       enumerator->inner = this->triplets->create_enumerator(this->triplets);
-       enumerator->current = NULL;
-       enumerator->this = this;
-
+       INIT(enumerator,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerator_enumerate,
+                       .destroy = _enumerator_destroy,
+               },
+               .inner = this->triplets->create_enumerator(this->triplets),
+               .this = this,
+       );
        return &enumerator->public;
 }
 
index 42dfaf0..5f73b71 100644 (file)
@@ -331,10 +331,12 @@ typedef struct {
 } attribute_enumerator_t;
 
 METHOD(enumerator_t, attribute_enumerate, bool,
-       attribute_enumerator_t *this, ha_message_attribute_t *attr_out,
-       ha_message_value_t *value)
+       attribute_enumerator_t *this, va_list args)
 {
-       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)
        {
@@ -602,7 +604,8 @@ METHOD(ha_message_t, create_attribute_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_attribute_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _attribute_enumerate,
                        .destroy = _enum_destroy,
                },
                .buf = chunk_skip(this->buf, 2),
index a0e5146..1a6108e 100644 (file)
@@ -111,8 +111,12 @@ typedef struct {
 } shared_enum_t;
 
 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 (me)
@@ -151,7 +155,8 @@ METHOD(ha_creds_t, create_shared_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_shared_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _shared_enumerate,
                        .destroy = (void*)free,
                },
                .key = this->key,
index ff50d8a..b3ac2b3 100644 (file)
@@ -62,13 +62,16 @@ typedef struct {
 } cert_enumerator_t;
 
 METHOD(enumerator_t, cert_enumerator_enumerate, bool,
-       cert_enumerator_t *this, certificate_t **cert)
+       cert_enumerator_t *this, va_list args)
 {
+       certificate_t **cert;
        ipseckey_t *cur_ipseckey;
        public_key_t *public;
        rr_t *cur_rr;
        chunk_t key;
 
+       VA_ARGS_VGET(args, cert);
+
        /* Get the next supported IPSECKEY using the inner enumerator. */
        while (this->inner->enumerate(this->inner, &cur_rr))
        {
@@ -211,7 +214,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cert_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerator_enumerate,
                        .destroy = _cert_enumerator_destroy,
                },
                .inner = rrset->create_rr_enumerator(rrset),
index efeb980..18a87b7 100644 (file)
@@ -466,9 +466,12 @@ typedef struct {
 } addr_enumerator_t;
 
 METHOD(enumerator_t, addr_enumerate, bool,
-       addr_enumerator_t *this, host_t **host)
+       addr_enumerator_t *this, va_list args)
 {
        iface_t *entry;
+       host_t **host;
+
+       VA_ARGS_VGET(args, host);
 
        while (TRUE)
        {
@@ -523,7 +526,8 @@ METHOD(kernel_net_t, create_address_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_addr_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _addr_enumerate,
                        .destroy = _addr_destroy,
                },
                .which = which,
index 2dc76d9..f94992d 100644 (file)
@@ -2165,8 +2165,14 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
 }
 
 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)
        {
                this->current = this->msg;
@@ -2270,7 +2276,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_subnets,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_subnets,
                        .destroy = _destroy_subnet_enumerator,
                },
                .private = this,
index efcf1c2..7b37066 100644 (file)
@@ -601,9 +601,12 @@ typedef struct {
 } rt_enumerator_t;
 
 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) ||
                this->remaining < this->addr->sa_len)
@@ -637,7 +640,8 @@ static enumerator_t *create_rt_enumerator(int types, int remaining,
 
        INIT(this,
                .public = {
-                       .enumerate = (void*)_rt_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _rt_enumerate,
                        .destroy = (void*)free,
                },
                .types = types,
@@ -1789,13 +1793,18 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
 }
 
 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;
+       host_t **net;
        struct rt_msghdr *rtm;
        struct sockaddr *addr;
+       uint8_t *mask;
+       char **ifname;
        int type;
 
+       VA_ARGS_VGET(args, net, mask, ifname);
+
        if (!this->current)
        {
                this->current = this->buf;
@@ -1888,7 +1897,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_subnets,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_subnets,
                        .destroy = _destroy_subnet_enumerator,
                },
                .buf = buf,
index 78159c8..f349901 100644 (file)
@@ -223,10 +223,11 @@ typedef struct {
 } peer_enumerator_t;
 
 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;
        chunk_t me, other;
+       peer_cfg_t **cfg;
        child_cfg_t *child_cfg;
        auth_cfg_t *auth;
        peer_cfg_create_t peer = {
@@ -249,6 +250,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
                .mode = MODE_TUNNEL,
        };
 
+       VA_ARGS_VGET(args, cfg);
+
        DESTROY_IF(this->current);
        if (!this->inner->enumerate(this->inner, &name, &me, &other,
                                                                &local_net, &remote_net))
@@ -295,7 +298,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_peer_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _peer_enumerator_enumerate,
                        .destroy = _peer_enumerator_destroy,
                },
                .ike = this->ike,
index 677229b..528fc00 100644 (file)
@@ -50,10 +50,13 @@ typedef struct {
 } private_enumerator_t;
 
 METHOD(enumerator_t, private_enumerator_enumerate, bool,
-       private_enumerator_t *this, private_key_t **key)
+       private_enumerator_t *this, va_list args)
 {
+       private_key_t **key;
        chunk_t chunk;
 
+       VA_ARGS_VGET(args, key);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &chunk))
        {
@@ -92,7 +95,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_private_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _private_enumerator_enumerate,
                        .destroy = _private_enumerator_destroy,
                },
        );
@@ -123,11 +127,14 @@ typedef struct {
 } cert_enumerator_t;
 
 METHOD(enumerator_t, cert_enumerator_enumerate, bool,
-       cert_enumerator_t *this, certificate_t **cert)
+       cert_enumerator_t *this, va_list args)
 {
+       certificate_t **cert;
        public_key_t *public;
        chunk_t chunk;
 
+       VA_ARGS_VGET(args, cert);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &chunk))
        {
@@ -180,7 +187,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cert_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerator_enumerate,
                        .destroy = _cert_enumerator_destroy,
                },
                .type = key,
index 0d99c4f..16d4bd7 100644 (file)
@@ -52,12 +52,14 @@ typedef struct {
 } cert_enumerator_t;
 
 METHOD(enumerator_t, cert_enumerator_enumerate, bool,
-       cert_enumerator_t *this, certificate_t **cert)
+       cert_enumerator_t *this, va_list args)
 {
-       certificate_t *trusted;
+       certificate_t *trusted, **cert;
        public_key_t *public;
        chunk_t chunk;
 
+       VA_ARGS_VGET(args, cert);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &chunk))
        {
@@ -110,7 +112,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cert_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerator_enumerate,
                        .destroy = _cert_enumerator_destroy,
                },
                .type = key,
index 6baf76d..e7a627b 100644 (file)
@@ -218,12 +218,15 @@ METHOD(attribute_handler_t, release, void,
 }
 
 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;
        *data = chunk_empty;
-       /* stop enumeration */
-       this->enumerate = (void*)return_false;
+       this->venumerate = (void*)return_false;
        return TRUE;
 }
 
@@ -234,7 +237,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
        enumerator_t *enumerator;
 
        INIT(enumerator,
-               .enumerate = (void*)_enumerate_dns,
+               .enumerate = enumerator_enumerate_default,
+               .venumerate = _enumerate_dns,
                .destroy = (void*)free,
        );
        return enumerator;
index 7663384..880e80a 100644 (file)
@@ -83,9 +83,12 @@ typedef struct {
 } attr_enumerator_t;
 
 METHOD(enumerator_t, enumerate_attrs, bool,
-       attr_enumerator_t *this, configuration_attribute_type_t *type,
-       chunk_t *data)
+       attr_enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        if (this->request_ipv4)
        {
                *type = P_CSCF_IP4_ADDRESS;
@@ -132,7 +135,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_attrs,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_attrs,
                        .destroy = (void*)free,
                },
        );
index 9077b51..05b8654 100644 (file)
@@ -391,10 +391,13 @@ typedef struct {
        bool v6;
 } attribute_enumerator_t;
 
-static bool attribute_enumerate(attribute_enumerator_t *this,
-                                                               configuration_attribute_type_t *type,
-                                                               chunk_t *data)
+METHOD(enumerator_t, attribute_enumerate, bool,
+       attribute_enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        if (this->v4)
        {
                *type = INTERNAL_IP4_DNS;
@@ -443,7 +446,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)attribute_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _attribute_enumerate,
                        .destroy = (void*)free,
                },
                .v4 = has_host_family(vips, AF_INET),
index cf7c3b8..55e8181 100644 (file)
@@ -504,11 +504,12 @@ typedef struct {
        ike_cfg_t *current;
 } ike_enumerator_t;
 
-/**
- * Implementation of ike_enumerator_t.public.enumerate
- */
-static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
+METHOD(enumerator_t, ike_enumerator_enumerate, bool,
+       ike_enumerator_t *this, va_list args)
 {
+       ike_cfg_t **cfg;
+
+       VA_ARGS_VGET(args, cfg);
        DESTROY_IF(this->current);
        this->current = build_ike_cfg(this->this, this->inner, this->me, this->other);
        if (this->current)
@@ -519,10 +520,8 @@ static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
        return FALSE;
 }
 
-/**
- * Implementation of ike_enumerator_t.public.destroy
- */
-static void ike_enumerator_destroy(ike_enumerator_t *this)
+METHOD(enumerator_t, ike_enumerator_destroy, void,
+       ike_enumerator_t *this)
 {
        DESTROY_IF(this->current);
        this->inner->destroy(this->inner);
@@ -532,19 +531,22 @@ static void ike_enumerator_destroy(ike_enumerator_t *this)
 METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
        private_sql_config_t *this, host_t *me, host_t *other)
 {
-       ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
-
-       e->this = this;
-       e->me = me;
-       e->other = other;
-       e->current = NULL;
-       e->public.enumerate = (void*)ike_enumerator_enumerate;
-       e->public.destroy = (void*)ike_enumerator_destroy;
+       ike_enumerator_t *e;
 
+       INIT(e,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _ike_enumerator_enumerate,
+                       .destroy = _ike_enumerator_destroy,
+               },
+               .this = this,
+               .me = me,
+               .other = other,
+       );
        e->inner = this->db->query(this->db,
-                       "SELECT id, certreq, force_encap, local, remote "
-                       "FROM ike_configs",
-                       DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
+                                                          "SELECT id, certreq, force_encap, local, remote "
+                                                          "FROM ike_configs",
+                                                          DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
        if (!e->inner)
        {
                free(e);
@@ -569,11 +571,12 @@ typedef struct {
        peer_cfg_t *current;
 } peer_enumerator_t;
 
-/**
- * Implementation of peer_enumerator_t.public.enumerate
- */
-static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
+METHOD(enumerator_t, peer_enumerator_enumerate, bool,
+       peer_enumerator_t *this, va_list args)
 {
+       peer_cfg_t **cfg;
+
+       VA_ARGS_VGET(args, cfg);
        DESTROY_IF(this->current);
        this->current = build_peer_cfg(this->this, this->inner, this->me, this->other);
        if (this->current)
@@ -584,10 +587,8 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
        return FALSE;
 }
 
-/**
- * Implementation of peer_enumerator_t.public.destroy
- */
-static void peer_enumerator_destroy(peer_enumerator_t *this)
+METHOD(enumerator_t, peer_enumerator_destroy, void,
+       peer_enumerator_t *this)
 {
        DESTROY_IF(this->current);
        this->inner->destroy(this->inner);
@@ -599,12 +600,16 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
 {
        peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
 
-       e->this = this;
-       e->me = me;
-       e->other = other;
-       e->current = NULL;
-       e->public.enumerate = (void*)peer_enumerator_enumerate;
-       e->public.destroy = (void*)peer_enumerator_destroy;
+       INIT(e,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _peer_enumerator_enumerate,
+                       .destroy = _peer_enumerator_destroy,
+               },
+               .this = this,
+               .me = me,
+               .other = other,
+       );
 
        /* TODO: only get configs whose IDs match exactly or contain wildcards */
        e->inner = this->db->query(this->db,
index 117eec9..3317de6 100644 (file)
@@ -52,11 +52,14 @@ typedef struct {
 } private_enumerator_t;
 
 METHOD(enumerator_t, private_enumerator_enumerate, bool,
-          private_enumerator_t *this, private_key_t **key)
+          private_enumerator_t *this, va_list args)
 {
+       private_key_t **key;
        chunk_t blob;
        int type;
 
+       VA_ARGS_VGET(args, key);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &type, &blob))
        {
@@ -88,7 +91,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_private_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _private_enumerator_enumerate,
                        .destroy = _private_enumerator_destroy,
                },
        );
@@ -132,11 +136,14 @@ typedef struct {
 } cert_enumerator_t;
 
 METHOD(enumerator_t, cert_enumerator_enumerate, bool,
-          cert_enumerator_t *this, certificate_t **cert)
+          cert_enumerator_t *this, va_list args)
 {
+       certificate_t **cert;
        chunk_t blob;
        int type;
 
+       VA_ARGS_VGET(args, cert);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &type, &blob))
        {
@@ -169,7 +176,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cert_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerator_enumerate,
                        .destroy = _cert_enumerator_destroy,
                },
        );
@@ -221,12 +229,15 @@ typedef struct {
 } shared_enumerator_t;
 
 METHOD(enumerator_t, shared_enumerator_enumerate, bool,
-          shared_enumerator_t *this, shared_key_t **shared,
-          id_match_t *me, id_match_t *other)
+          shared_enumerator_t *this, va_list args)
 {
+       shared_key_t **shared;
+       id_match_t *me, *other;
        chunk_t blob;
        int type;
 
+       VA_ARGS_VGET(args, shared, me, other);
+
        DESTROY_IF(this->current);
        while (this->inner->enumerate(this->inner, &type, &blob))
        {
@@ -265,7 +276,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_shared_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _shared_enumerator_enumerate,
                        .destroy = _shared_enumerator_destroy,
                },
                .me = me,
@@ -340,9 +352,11 @@ typedef enum {
 } cdp_type_t;
 
 METHOD(enumerator_t, cdp_enumerator_enumerate, bool,
-          cdp_enumerator_t *this, char **uri)
+          cdp_enumerator_t *this, va_list args)
 {
-       char *text;
+       char *text, **uri;
+
+       VA_ARGS_VGET(args, uri);
 
        free(this->current);
        while (this->inner->enumerate(this->inner, &text))
@@ -384,7 +398,8 @@ METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
        }
        INIT(e,
                .public = {
-                       .enumerate = (void*)_cdp_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cdp_enumerator_enumerate,
                        .destroy = _cdp_enumerator_destroy,
                },
        );
index e0578fe..dcd4ae3 100644 (file)
@@ -118,11 +118,12 @@ static u_int create_rekey(char *string)
 }
 
 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 *local_id, *local_addr, *local_net;
        char *remote_id, *remote_addr, *remote_net;
+       peer_cfg_t **cfg;
        child_cfg_t *child_cfg;
        ike_cfg_t *ike_cfg;
        auth_cfg_t *auth;
@@ -145,6 +146,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
                .mode = MODE_TUNNEL,
        };
 
+       VA_ARGS_VGET(args, cfg);
+
        /* defaults */
        name = "unnamed";
        local_id = NULL;
@@ -212,7 +215,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_peer_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _peer_enumerator_enumerate,
                        .destroy = _peer_enumerator_destroy,
                },
                .inner = this->parser->create_section_enumerator(this->parser,
@@ -241,10 +245,13 @@ typedef struct {
 } ike_enumerator_t;
 
 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;
 
+       VA_ARGS_VGET(args, cfg);
+
        /* defaults */
        local_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,
                .public = {
-                       .enumerate = (void*)_ike_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _ike_enumerator_enumerate,
                        .destroy = _ike_enumerator_destroy,
                },
                .inner = this->parser->create_section_enumerator(this->parser,
index f5d5ace..404a3e3 100644 (file)
@@ -52,12 +52,15 @@ typedef struct {
 } shared_enumerator_t;
 
 METHOD(enumerator_t, shared_enumerator_enumerate, bool,
-       shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
-       id_match_t *other)
+       shared_enumerator_t *this, va_list args)
 {
+       shared_key_t **key;
+       id_match_t *me, *other;
        char *local_id, *remote_id, *psk;
        identification_t *local, *remote;
 
+       VA_ARGS_VGET(args, key, me, other);
+
        while (TRUE)
        {
                /* defaults */
@@ -126,7 +129,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_shared_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _shared_enumerator_enumerate,
                        .destroy = _shared_enumerator_destroy,
                },
                .me = me,
index 2429e9e..e847dd3 100644 (file)
@@ -58,11 +58,10 @@ typedef struct {
 } section_enumerator_t;
 
 METHOD(enumerator_t, section_enumerator_enumerate, bool,
-       section_enumerator_t *this, ...)
+       section_enumerator_t *this, va_list args)
 {
        struct uci_element *element;
        char **value;
-       va_list args;
        int i;
 
        if (&this->current->list == this->list)
@@ -70,8 +69,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
                return FALSE;
        }
 
-       va_start(args, this);
-
        value = va_arg(args, char**);
        if (value)
        {
@@ -96,7 +93,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
                        *value = uci_to_option(element)->value;
                }
        }
-       va_end(args);
 
        this->current = list_to_element(this->current->list.next);
        return TRUE;
@@ -124,7 +120,13 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
                i++;
        }
        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;
        va_start(args, this);
        do
@@ -134,9 +136,6 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
        while (e->keywords[i++]);
        va_end(args);
 
-       e->public.enumerate = (void*)_section_enumerator_enumerate;
-       e->public.destroy = _section_enumerator_destroy;
-
        /* load uci context */
        e->ctx = uci_alloc_context();
        if (uci_load(e->ctx, this->package, &e->package) != UCI_OK)
index 25e0756..f640f9f 100644 (file)
@@ -368,9 +368,12 @@ typedef struct {
 } attribute_enumerator_t;
 
 METHOD(enumerator_t, enumerate_attributes, bool,
-       attribute_enumerator_t *this, configuration_attribute_type_t *type,
-       chunk_t *data)
+       attribute_enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *data;
+
+       VA_ARGS_VGET(args, type, data);
        if (this->i < countof(attributes))
        {
                *type = attributes[this->i++];
@@ -393,7 +396,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
        }
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_attributes,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_attributes,
                        .destroy = (void*)free,
                },
        );
index 07f5f9b..b6a5564 100644 (file)
@@ -77,12 +77,15 @@ static void append_ts(bio_writer_t *writer, traffic_selector_t *ts)
 }
 
 METHOD(enumerator_t, attribute_enumerate, bool,
-       attribute_enumerator_t *this, configuration_attribute_type_t *type,
-       chunk_t *attr)
+       attribute_enumerator_t *this, va_list args)
 {
+       configuration_attribute_type_t *type;
+       chunk_t *attr;
        traffic_selector_t *ts;
        bio_writer_t *writer;
 
+       VA_ARGS_VGET(args, type, attr);
+
        if (this->list->get_count(this->list) == 0)
        {
                return FALSE;
@@ -183,7 +186,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
 
        INIT(attr_enum,
                .public = {
-                       .enumerate = (void*)_attribute_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _attribute_enumerate,
                        .destroy = _attribute_destroy,
                },
                .list = list,
index 045e34f..73bba23 100644 (file)
@@ -122,9 +122,14 @@ typedef struct {
        endecode_test_t *next;
 } endecode_enum_t;
 
-static bool endecode_enumerate(endecode_enum_t *this, vici_type_t *type,
-                                                          char **name, chunk_t *data)
+METHOD(enumerator_t, endecode_enumerate, bool,
+       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)
        {
                *type = this->next->type;
@@ -149,7 +154,8 @@ static enumerator_t *endecode_create_enumerator(endecode_test_t *test)
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)endecode_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _endecode_enumerate,
                        .destroy = (void*)free,
                },
                .next = test,
index 58b8967..91d3449 100644 (file)
@@ -135,11 +135,16 @@ typedef struct {
 } parse_enumerator_t;
 
 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;
        chunk_t data;
 
+       VA_ARGS_VGET(args, out, name, value);
+
        if (!this->reader->remaining(this->reader) ||
                !this->reader->read_uint8(this->reader, &type))
        {
@@ -218,7 +223,8 @@ METHOD(vici_message_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_parse_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _parse_enumerate,
                        .destroy = _parse_destroy,
                },
                .reader = bio_reader_create(this->encoding),
index e1ffc2a..2a8ef02 100644 (file)
@@ -435,10 +435,11 @@ struct policy_enumerator_t {
 };
 
 METHOD(enumerator_t, policy_enumerate, bool,
-          policy_enumerator_t *this, traffic_selector_t **my_out,
-          traffic_selector_t **other_out)
+          policy_enumerator_t *this, va_list args)
 {
-       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))
        {
@@ -487,7 +488,8 @@ METHOD(child_sa_t, create_policy_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_policy_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _policy_enumerate,
                        .destroy = _policy_destroy,
                },
                .mine = array_create_enumerator(this->my_ts),
index 76e1069..723da72 100644 (file)
@@ -1699,8 +1699,11 @@ typedef struct {
 } child_enumerator_t;
 
 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))
        {
                *child_sa = this->current;
@@ -1723,7 +1726,8 @@ METHOD(ike_sa_t, create_child_sa_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_child_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _child_enumerate,
                        .destroy = _child_enumerator_destroy,
                },
                .inner = array_create_enumerator(this->child_sas),
index 15629fe..fcb4cf0 100644 (file)
@@ -513,8 +513,13 @@ struct private_enumerator_t {
 };
 
 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)
        {
                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,
                .enumerator = {
-                       .enumerate = (void*)_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
                        .destroy = _enumerator_destroy,
                },
                .manager = this,
index 3315c20..a40c30d 100644 (file)
@@ -283,23 +283,20 @@ typedef struct {
 
 } package_enumerator_t;
 
-/**
- * Implementation of package_enumerator.destroy.
- */
-static void package_enumerator_destroy(package_enumerator_t *this)
+METHOD(enumerator_t, package_enumerator_destroy, void,
+       package_enumerator_t *this)
 {
        pclose(this->file);
        free(this);
 }
 
-/**
- * Implementation of package_enumerator.enumerate
- */
-static bool package_enumerator_enumerate(package_enumerator_t *this, ...)
+METHOD(enumerator_t, package_enumerator_enumerate, bool,
+       package_enumerator_t *this, va_list args)
 {
        chunk_t *name, *version;
        u_char *pos;
-       va_list args;
+
+       VA_ARGS_VGET(args, name, version);
 
        while (TRUE)
        {
@@ -319,23 +316,16 @@ static bool package_enumerator_enumerate(package_enumerator_t *this, ...)
                {
                        continue;
                }
-               va_start(args, this);
-
-               name = va_arg(args, chunk_t*);
                name->ptr = pos;
                pos = strchr(pos, '\t');
                if (!pos)
                {
-                       va_end(args);
                        return FALSE;
                }
                name->len = pos++ - name->ptr;
 
-               version = va_arg(args, chunk_t*);
                version->ptr = pos;
                version->len = strlen(pos) - 1;
-
-               va_end(args);
                return TRUE;
        }
 }
@@ -362,12 +352,14 @@ METHOD(imc_os_info_t, create_package_enumerator, enumerator_t*,
                return NULL;
        }
 
-       /* Create a package enumerator instance */
-       enumerator = malloc_thing(package_enumerator_t);
-       enumerator->public.enumerate = (void*)package_enumerator_enumerate;
-       enumerator->public.destroy = (void*)package_enumerator_destroy;
-       enumerator->file = file;
-
+       INIT(enumerator,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _package_enumerator_enumerate,
+                       .destroy = _package_enumerator_destroy,
+               },
+               .file = file,
+       );
        return (enumerator_t*)enumerator;
 }
 
index d050862..e96faa7 100644 (file)
@@ -626,22 +626,13 @@ typedef struct {
 
 } language_enumerator_t;
 
-/**
- * Implementation of language_enumerator.destroy.
- */
-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, ...)
+METHOD(enumerator_t, language_enumerator_enumerate, bool,
+       language_enumerator_t *this, va_list args)
 {
        char *pos, *cur_lang, **lang;
        TNC_UInt32 len;
-       va_list args;
+
+       VA_ARGS_VGET(args, lang);
 
        if (!this->lang_len)
        {
@@ -676,11 +667,7 @@ static bool language_enumerator_enumerate(language_enumerator_t *this, ...)
        }
        cur_lang[len] = '\0';
 
-       va_start(args, this);
-       lang = va_arg(args, char**);
        *lang = cur_lang;
-       va_end(args);
-
        return TRUE;
 }
 
@@ -689,10 +676,13 @@ METHOD(imv_agent_t, create_language_enumerator, enumerator_t*,
 {
        language_enumerator_t *e;
 
-       /* Create a language enumerator instance */
-       e = malloc_thing(language_enumerator_t);
-       e->public.enumerate = (void*)language_enumerator_enumerate;
-       e->public.destroy = (void*)language_enumerator_destroy;
+       INIT(e,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _language_enumerator_enumerate,
+                       .destroy = (void*)free,
+               },
+       );
 
        if (!this->get_attribute ||
                !this->get_attribute(this->id, state->get_connection_id(state),
index d514532..9f098c0 100644 (file)
@@ -111,17 +111,12 @@ typedef struct {
        private_pts_pcr_t *pcrs;
 } pcr_enumerator_t;
 
-/**
- * Implementation of enumerator.enumerate
- */
-static bool pcr_enumerator_enumerate(pcr_enumerator_t *this, ...)
+METHOD(enumerator_t, pcr_enumerator_enumerate, bool,
+       pcr_enumerator_t *this, va_list args)
 {
-       uint32_t *pcr, i, f;
-       va_list args;
+       uint32_t i, f, *pcr;
 
-       va_start(args, this);
-       pcr = va_arg(args, uint32_t*);
-       va_end(args);
+       VA_ARGS_VGET(args, pcr);
 
        while (this->pcr <= this->pcrs->pcr_max)
        {
@@ -148,7 +143,8 @@ METHOD(pts_pcr_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)pcr_enumerator_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _pcr_enumerator_enumerate,
                        .destroy = (void*)free,
                },
                .pcrs = this,
index 05a02e5..4e54de3 100644 (file)
@@ -59,8 +59,11 @@ typedef struct {
 } mech_enumerator_t;
 
 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))
        {
                if (mechs[this->i].server == this->server)
@@ -83,7 +86,8 @@ enumerator_t* sasl_mechanism_create_enumerator(bool server)
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_mech_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _mech_enumerate,
                        .destroy = (void*)free,
                },
                .server = server,
index 9705d3b..51135fb 100644 (file)
@@ -244,8 +244,12 @@ typedef struct {
 } attribute_enumerator_t;
 
 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)
        {
                return FALSE;
@@ -275,7 +279,8 @@ METHOD(radius_message_t, create_enumerator, enumerator_t*,
        }
        INIT(e,
                .public = {
-                       .enumerate = (void*)_attribute_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _attribute_enumerate,
                        .destroy = (void*)free,
                },
                .next = (rattr_t*)this->msg->attributes,
@@ -299,12 +304,14 @@ typedef struct {
 } vendor_enumerator_t;
 
 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;
-       int inner_type;
+       chunk_t inner_data, *data;
+       int inner_type, *vendor, *type;
        uint8_t type8, len;
 
+       VA_ARGS_VGET(args, vendor, type, data);
+
        while (TRUE)
        {
                if (this->reader)
@@ -354,7 +361,8 @@ METHOD(radius_message_t, create_vendor_enumerator, enumerator_t*,
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_vendor_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _vendor_enumerate,
                        .destroy = _vendor_destroy,
                },
                .inner = create_enumerator(this),
index 69e7df9..c3dd6e0 100644 (file)
@@ -214,9 +214,11 @@ typedef struct {
 } array_enumerator_t;
 
 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)
        {
@@ -250,7 +252,8 @@ enumerator_t* array_create_enumerator(array_t *array)
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
                        .destroy = (void*)free,
                },
                .array = array,
index e96b235..cdf05d5 100644 (file)
@@ -50,22 +50,24 @@ bool enumerator_enumerate_default(enumerator_t *enumerator, ...)
        return result;
 }
 
-/**
- * Implementation of enumerator_create_empty().enumerate
- */
-static bool enumerate_empty(enumerator_t *enumerator, ...)
+METHOD(enumerator_t, enumerate_empty, bool,
+       enumerator_t *enumerator, va_list args)
 {
        return FALSE;
 }
 
-/**
- * See header
+/*
+ * Described in header
  */
 enumerator_t* enumerator_create_empty()
 {
-       enumerator_t *this = malloc_thing(enumerator_t);
-       this->enumerate = enumerate_empty;
-       this->destroy = (void*)free;
+       enumerator_t *this;
+
+       INIT(this,
+               .enumerate = enumerator_enumerate_default,
+               .venumerate = _enumerate_empty,
+               .destroy = (void*)free,
+       );
        return this;
 }
 
@@ -83,32 +85,31 @@ typedef struct {
        char *full_end;
 } dir_enum_t;
 
-/**
- * Implementation of enumerator_create_directory().destroy
- */
-static void destroy_dir_enum(dir_enum_t *this)
+METHOD(enumerator_t, destroy_dir_enum, void,
+       dir_enum_t *this)
 {
        closedir(this->dir);
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_directory().enumerate
- */
-static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
-                                                          char **absolute, struct stat *st)
+METHOD(enumerator_t, enumerate_dir_enum, bool,
+       dir_enum_t *this, va_list args)
 {
        struct dirent *entry = readdir(this->dir);
+       struct stat *st;
        size_t remaining;
+       char **relative, **absolute;
        int len;
 
+       VA_ARGS_VGET(args, relative, absolute, st);
+
        if (!entry)
        {
                return FALSE;
        }
        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)
        {
@@ -141,15 +142,21 @@ static bool enumerate_dir_enum(dir_enum_t *this, char **relative,
        return TRUE;
 }
 
-/**
- * See header
+/*
+ * Described in header
  */
 enumerator_t* enumerator_create_directory(const char *path)
 {
+       dir_enum_t *this;
        int len;
-       dir_enum_t *this = malloc_thing(dir_enum_t);
-       this->public.enumerate = (void*)enumerate_dir_enum;
-       this->public.destroy = (void*)destroy_dir_enum;
+
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_dir_enum,
+                       .destroy = _destroy_dir_enum,
+               },
+       );
 
        if (*path == '\0')
        {
@@ -171,9 +178,10 @@ enumerator_t* enumerator_create_directory(const char *path)
        this->full_end = &this->full[len];
 
        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);
                return NULL;
        }
@@ -196,21 +204,21 @@ typedef struct {
        char full[PATH_MAX];
 } glob_enum_t;
 
-/**
- * Implementation of enumerator_create_glob().destroy
- */
-static void destroy_glob_enum(glob_enum_t *this)
+METHOD(enumerator_t, destroy_glob_enum, void,
+       glob_enum_t *this)
 {
        globfree(&this->glob);
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_glob().enumerate
- */
-static bool enumerate_glob_enum(glob_enum_t *this, char **file, struct stat *st)
+METHOD(enumerator_t, enumerate_glob_enum, bool,
+       glob_enum_t *this, va_list args)
 {
+       struct stat *st;
        char *match;
+       char **file;
+
+       VA_ARGS_VGET(args, file, st);
 
        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;
        }
-       if (st)
+       if (st && stat(match, st))
        {
-               if (stat(match, st))
-               {
-                       DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
-                                strerror(errno));
-                       return FALSE;
-               }
+               DBG1(DBG_LIB, "stat() on '%s' failed: %s", match,
+                        strerror(errno));
+               return FALSE;
        }
        return TRUE;
 }
 
-/**
- * See header
+/*
+ * Described in header
  */
 enumerator_t* enumerator_create_glob(const char *pattern)
 {
@@ -248,8 +253,9 @@ enumerator_t* enumerator_create_glob(const char *pattern)
 
        INIT(this,
                .public = {
-                       .enumerate = (void*)enumerate_glob_enum,
-                       .destroy = (void*)destroy_glob_enum,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_glob_enum,
+                       .destroy = _destroy_glob_enum,
                },
        );
 
@@ -291,24 +297,22 @@ typedef struct {
        const char *trim;
 } token_enum_t;
 
-/**
- * Implementation of enumerator_create_token().destroy
- */
-static void destroy_token_enum(token_enum_t *this)
+METHOD(enumerator_t, destroy_token_enum, void,
+       token_enum_t *this)
 {
        free(this->string);
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_token().enumerate
- */
-static bool enumerate_token_enum(token_enum_t *this, char **token)
+METHOD(enumerator_t, enumerate_token_enum, bool,
+       token_enum_t *this, va_list args)
 {
        const char *sep, *trim;
-       char *pos = NULL, *tmp;
+       char *pos = NULL, *tmp, **token;
        bool last = FALSE;
 
+       VA_ARGS_VGET(args, token);
+
        /* trim leading characters/separators */
        while (*this->pos)
        {
@@ -409,52 +413,48 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
        return FALSE;
 }
 
-/**
- * See header
+/*
+ * Described in header
  */
 enumerator_t* enumerator_create_token(const char *string, const char *sep,
                                                                          const char *trim)
 {
-       token_enum_t *enumerator = malloc_thing(token_enum_t);
+       token_enum_t *this;
 
-       enumerator->public.enumerate = (void*)enumerate_token_enum;
-       enumerator->public.destroy = (void*)destroy_token_enum;
-       enumerator->string = strdup(string);
-       enumerator->pos = enumerator->string;
-       enumerator->sep = sep;
-       enumerator->trim = trim;
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_token_enum,
+                       .destroy = _destroy_token_enum,
+               },
+               .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 {
-       /* implements enumerator_t */
        enumerator_t public;
-       /* outer enumerator */
        enumerator_t *outer;
-       /* inner enumerator */
        enumerator_t *inner;
-       /* constructor for inner enumerator */
        enumerator_t *(*create_inner)(void *outer, void *data);
-       /* data to pass to constructor above */
        void *data;
-       /* destructor for data */
-       void (*destroy_data)(void *data);
+       void (*destructor)(void *data);
 } nested_enumerator_t;
 
 
-/**
- * Implementation of enumerator_create_nested().enumerate()
- */
-static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
-                                                        void *v3, void *v4, void *v5)
+METHOD(enumerator_t, enumerate_nested, bool,
+       nested_enumerator_t *this, va_list args)
 {
        while (TRUE)
        {
-               while (this->inner == NULL)
+               while (!this->inner)
                {
                        void *outer;
 
@@ -463,8 +463,13 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
                                return FALSE;
                        }
                        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;
                }
@@ -473,42 +478,43 @@ static bool enumerate_nested(nested_enumerator_t *this, void *v1, void *v2,
        }
 }
 
-/**
- * Implementation of enumerator_create_nested().destroy()
- **/
-static void destroy_nested(nested_enumerator_t *this)
+METHOD(enumerator_t, destroy_nested, void,
+       nested_enumerator_t *this)
 {
-       if (this->destroy_data)
+       if (this->destructor)
        {
-               this->destroy_data(this->data);
+               this->destructor(this->data);
        }
        DESTROY_IF(this->inner);
        this->outer->destroy(this->outer);
        free(this);
 }
 
-/**
- * See header
+/*
+ * Described in header
  */
 enumerator_t *enumerator_create_nested(enumerator_t *outer,
                                        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);
-
-       enumerator->public.enumerate = (void*)enumerate_nested;
-       enumerator->public.destroy = (void*)destroy_nested;
-       enumerator->outer = outer;
-       enumerator->inner = NULL;
-       enumerator->create_inner = (void*)inner_constructor;
-       enumerator->data = data;
-       enumerator->destroy_data = destroy_data;
+       nested_enumerator_t *this;
 
-       return &enumerator->public;
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_nested,
+                       .destroy = _destroy_nested,
+               },
+               .outer = outer,
+               .create_inner = inner_constructor,
+               .data = data,
+               .destructor = destructor,
+       );
+       return &this->public;
 }
 
 /**
- * enumerator for filtered enumerator
+ * Enumerator for filtered enumerator
  */
 typedef struct {
        enumerator_t public;
@@ -518,10 +524,8 @@ typedef struct {
        void (*destructor)(void *data);
 } filter_enumerator_t;
 
-/**
- * Implementation of enumerator_create_filter().destroy
- */
-static void destroy_filter(filter_enumerator_t *this)
+METHOD(enumerator_t, destroy_filter, void,
+       filter_enumerator_t *this)
 {
        if (this->destructor)
        {
@@ -531,13 +535,14 @@ static void destroy_filter(filter_enumerator_t *this)
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_filter().enumerate
- */
-static bool enumerate_filter(filter_enumerator_t *this, void *o1, void *o2,
-                                                        void *o3, void *o4, void *o5)
+METHOD(enumerator_t, enumerate_filter, bool,
+       filter_enumerator_t *this, va_list args)
 {
        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))
        {
@@ -549,27 +554,31 @@ static bool enumerate_filter(filter_enumerator_t *this, void *o1, void *o2,
        return FALSE;
 }
 
-/**
- * see header
+/*
+ * Described in header
  */
 enumerator_t *enumerator_create_filter(enumerator_t *unfiltered,
                                                                           bool (*filter)(void *data, ...),
                                                                           void *data, void (*destructor)(void *data))
 {
-       filter_enumerator_t *this = malloc_thing(filter_enumerator_t);
-
-       this->public.enumerate = (void*)enumerate_filter;
-       this->public.destroy = (void*)destroy_filter;
-       this->unfiltered = unfiltered;
-       this->filter = filter;
-       this->data = data;
-       this->destructor = destructor;
+       filter_enumerator_t *this;
 
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_filter,
+                       .destroy = _destroy_filter,
+               },
+               .unfiltered = unfiltered,
+               .filter = filter,
+               .data = data,
+               .destructor = destructor,
+       );
        return &this->public;
 }
 
 /**
- * enumerator for cleaner enumerator
+ * Enumerator for cleaner enumerator
  */
 typedef struct {
        enumerator_t public;
@@ -578,44 +587,48 @@ typedef struct {
        void *data;
 } cleaner_enumerator_t;
 
-/**
- * Implementation of enumerator_create_cleanup().destroy
- */
-static void destroy_cleaner(cleaner_enumerator_t *this)
+METHOD(enumerator_t, destroy_cleaner, void,
+       cleaner_enumerator_t *this)
 {
        this->cleanup(this->data);
        this->wrapped->destroy(this->wrapped);
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_cleaner().enumerate
- */
-static bool enumerate_cleaner(cleaner_enumerator_t *this, void *v1, void *v2,
-                                                         void *v3, void *v4, void *v5)
+METHOD(enumerator_t, enumerate_cleaner, bool,
+       cleaner_enumerator_t *this, va_list args)
 {
-       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,
                                                                                void (*cleanup)(void *data), void *data)
 {
-       cleaner_enumerator_t *this = malloc_thing(cleaner_enumerator_t);
-
-       this->public.enumerate = (void*)enumerate_cleaner;
-       this->public.destroy = (void*)destroy_cleaner;
-       this->wrapped = wrapped;
-       this->cleanup = cleanup;
-       this->data = data;
+       cleaner_enumerator_t *this;
 
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_cleaner,
+                       .destroy = _destroy_cleaner,
+               },
+               .wrapped = wrapped,
+               .cleanup = cleanup,
+               .data = data,
+       );
        return &this->public;
 }
 
 /**
- * enumerator for single enumerator
+ * Enumerator for single enumerator
  */
 typedef struct {
        enumerator_t public;
@@ -624,10 +637,8 @@ typedef struct {
        bool done;
 } single_enumerator_t;
 
-/**
- * Implementation of enumerator_create_single().destroy
- */
-static void destroy_single(single_enumerator_t *this)
+METHOD(enumerator_t, destroy_single, void,
+       single_enumerator_t *this)
 {
        if (this->cleanup)
        {
@@ -636,11 +647,12 @@ static void destroy_single(single_enumerator_t *this)
        free(this);
 }
 
-/**
- * Implementation of enumerator_create_single().enumerate
- */
-static bool enumerate_single(single_enumerator_t *this, void **item)
+METHOD(enumerator_t, enumerate_single, bool,
+       single_enumerator_t *this, va_list args)
 {
+       void **item;
+
+       VA_ARGS_VGET(args, item);
        if (this->done)
        {
                return FALSE;
@@ -650,18 +662,21 @@ static bool enumerate_single(single_enumerator_t *this, void **item)
        return TRUE;
 }
 
-/**
- * see header
+/*
+ * Described in header
  */
 enumerator_t *enumerator_create_single(void *item, void (*cleanup)(void *item))
 {
-       single_enumerator_t *this = malloc_thing(single_enumerator_t);
-
-       this->public.enumerate = (void*)enumerate_single;
-       this->public.destroy = (void*)destroy_single;
-       this->item = item;
-       this->cleanup = cleanup;
-       this->done = FALSE;
+       single_enumerator_t *this;
 
+       INIT(this,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_single,
+                       .destroy = _destroy_single,
+               },
+               .item = item,
+               .cleanup = cleanup,
+       );
        return &this->public;
 }
index 224fe7e..e4b0547 100644 (file)
@@ -172,17 +172,21 @@ enumerator_t* enumerator_create_token(const char *string, const char *sep,
 /**
  * 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 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 destroy_data                 destructor to pass to data
+ * @param destructor                   destructor function to clean up data after use
  * @return                                             the nested enumerator
  */
 enumerator_t *enumerator_create_nested(enumerator_t *outer,
                                        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.
index 2b77a37..b0eda9e 100644 (file)
@@ -379,8 +379,13 @@ METHOD(hashtable_t, get_count, u_int,
 }
 
 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)
        {
                this->prev = this->current;
@@ -417,7 +422,8 @@ METHOD(hashtable_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .enumerator = {
-                       .enumerate = (void*)_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
                        .destroy = (void*)free,
                },
                .table = this,
index b8fe815..eb11339 100644 (file)
@@ -119,8 +119,12 @@ struct private_enumerator_t {
 };
 
 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)
        {
                return FALSE;
@@ -152,7 +156,8 @@ METHOD(linked_list_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .enumerator = {
-                       .enumerate = (void*)_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
                        .destroy = (void*)free,
                },
                .list = this,
index 8a3e659..a9c8b39 100644 (file)
@@ -146,12 +146,14 @@ typedef struct {
        bool enumerated[AUTH_RULE_MAX];
 } entry_enumerator_t;
 
-/**
- * enumerate function for item_enumerator_t
- */
-static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
+METHOD(enumerator_t, enumerate, bool,
+       entry_enumerator_t *this, va_list args)
 {
+       auth_rule_t *type;
        entry_t *entry;
+       void **value;
+
+       VA_ARGS_VGET(args, type, value);
 
        while (this->inner->enumerate(this->inner, &entry))
        {
@@ -174,10 +176,8 @@ static bool enumerate(entry_enumerator_t *this, auth_rule_t *type, void **value)
        return FALSE;
 }
 
-/**
- * destroy function for item_enumerator_t
- */
-static void entry_enumerator_destroy(entry_enumerator_t *this)
+METHOD(enumerator_t, entry_enumerator_destroy, void,
+       entry_enumerator_t *this)
 {
        this->inner->destroy(this->inner);
        free(this);
@@ -190,8 +190,9 @@ METHOD(auth_cfg_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)enumerate,
-                       .destroy = (void*)entry_enumerator_destroy,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
+                       .destroy = _entry_enumerator_destroy,
                },
                .inner = array_create_enumerator(this->entries),
        );
index 8e8be7e..5dd8e42 100644 (file)
@@ -155,8 +155,12 @@ METHOD(credential_manager_t, call_hook, void,
 }
 
 METHOD(enumerator_t, sets_enumerate, bool,
-       sets_enumerator_t *this, credential_set_t **set)
+       sets_enumerator_t *this, va_list args)
 {
+       credential_set_t **set;
+
+       VA_ARGS_VGET(args, set);
+
        if (this->exclusive)
        {
                if (this->exclusive->enumerate(this->exclusive, set))
@@ -202,7 +206,8 @@ static enumerator_t *create_sets_enumerator(private_credential_manager_t *this)
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_sets_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _sets_enumerate,
                        .destroy = _sets_destroy,
                },
        );
@@ -840,9 +845,12 @@ typedef struct {
 } trusted_enumerator_t;
 
 METHOD(enumerator_t, trusted_enumerate, bool,
-       trusted_enumerator_t *this, certificate_t **cert, auth_cfg_t **auth)
+       trusted_enumerator_t *this, va_list args)
 {
-       certificate_t *current;
+       certificate_t *current, **cert;
+       auth_cfg_t **auth;
+
+       VA_ARGS_VGET(args, cert, auth);
 
        DESTROY_IF(this->auth);
        this->auth = auth_cfg_create();
@@ -931,7 +939,8 @@ METHOD(credential_manager_t, create_trusted_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_trusted_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _trusted_enumerate,
                        .destroy = _trusted_destroy,
                },
                .this = this,
@@ -960,9 +969,13 @@ typedef struct {
 } public_enumerator_t;
 
 METHOD(enumerator_t, public_enumerate, bool,
-       public_enumerator_t *this, public_key_t **key, auth_cfg_t **auth)
+       public_enumerator_t *this, va_list args)
 {
        certificate_t *cert;
+       public_key_t **key;
+       auth_cfg_t **auth;
+
+       VA_ARGS_VGET(args, key, auth);
 
        while (this->inner->enumerate(this->inner, &cert, auth))
        {
@@ -1001,7 +1014,8 @@ METHOD(credential_manager_t, create_public_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_public_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _public_enumerate,
                        .destroy = _public_destroy,
                },
                .inner = create_trusted_enumerator(this, type, id, online),
index 2c76ad6..87f7e66 100644 (file)
@@ -272,8 +272,12 @@ typedef struct  {
 } private_enumerator_t;
 
 METHOD(enumerator_t, signature_schemes_enumerate, bool,
-       private_enumerator_t *this, signature_scheme_t *scheme)
+       private_enumerator_t *this, va_list args)
 {
+       signature_scheme_t *scheme;
+
+       VA_ARGS_VGET(args, scheme);
+
        while (++this->index < countof(scheme_map))
        {
                if (this->type == scheme_map[this->index].type &&
@@ -296,7 +300,8 @@ enumerator_t *signature_schemes_for_key(key_type_t type, int size)
 
        INIT(this,
                .public = {
-                       .enumerate = (void*)_signature_schemes_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _signature_schemes_enumerate,
                        .destroy = (void*)free,
                },
                .index = -1,
index 8393d5b..1cd4b9d 100644 (file)
@@ -112,15 +112,15 @@ static bool fetch_cert(wrapper_enumerator_t *enumerator,
        return TRUE;
 }
 
-/**
- * enumerate function for wrapper_enumerator_t
- */
-static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
+METHOD(enumerator_t, enumerate, bool,
+       wrapper_enumerator_t *this, va_list args)
 {
        auth_rule_t rule;
-       certificate_t *current;
+       certificate_t *current, **cert;
        public_key_t *public;
 
+       VA_ARGS_VGET(args, cert);
+
        while (this->inner->enumerate(this->inner, &rule, &current))
        {
                if (rule == AUTH_HELPER_IM_HASH_URL ||
@@ -164,10 +164,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
        return FALSE;
 }
 
-/**
- * destroy function for wrapper_enumerator_t
- */
-static void wrapper_enumerator_destroy(wrapper_enumerator_t *this)
+METHOD(enumerator_t, wrapper_enumerator_destroy, void,
+       wrapper_enumerator_t *this)
 {
        this->inner->destroy(this->inner);
        free(this);
@@ -183,14 +181,18 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
        {
                return NULL;
        }
-       enumerator = malloc_thing(wrapper_enumerator_t);
-       enumerator->auth = this->auth;
-       enumerator->cert = cert;
-       enumerator->key = key;
-       enumerator->id = id;
-       enumerator->inner = this->auth->create_enumerator(this->auth);
-       enumerator->public.enumerate = (void*)enumerate;
-       enumerator->public.destroy = (void*)wrapper_enumerator_destroy;
+       INIT(enumerator,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
+                       .destroy = _wrapper_enumerator_destroy,
+               },
+               .auth = this->auth,
+               .cert = cert,
+               .key = key,
+               .id = id,
+               .inner = this->auth->create_enumerator(this->auth),
+       );
        return &enumerator->public;
 }
 
index bff33f0..0d72452 100644 (file)
@@ -60,9 +60,12 @@ typedef struct {
 } shared_enumerator_t;
 
 METHOD(enumerator_t, shared_enumerate, bool,
-       shared_enumerator_t *this, shared_key_t **out,
-       id_match_t *match_me, id_match_t *match_other)
+       shared_enumerator_t *this, va_list args)
 {
+       shared_key_t **out;
+       id_match_t *match_me, *match_other;
+
+       VA_ARGS_VGET(args, out, match_me, match_other);
        DESTROY_IF(this->current);
        this->current = this->this->cb.shared(this->this->data, this->type,
                                                                this->me, this->other, match_me, match_other);
@@ -89,7 +92,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_shared_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _shared_enumerate,
                        .destroy = _shared_destroy,
                },
                .this = this,
index 24fdb19..92d5efd 100644 (file)
@@ -252,13 +252,14 @@ typedef struct {
        int locked;
 } cert_enumerator_t;
 
-/**
- * filter function for certs enumerator
- */
-static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
+METHOD(enumerator_t, cert_enumerate, bool,
+       cert_enumerator_t *this, va_list args)
 {
        public_key_t *public;
        relation_t *rel;
+       certificate_t **out;
+
+       VA_ARGS_VGET(args, out);
 
        if (this->locked >= 0)
        {
@@ -311,10 +312,8 @@ static bool cert_enumerate(cert_enumerator_t *this, certificate_t **out)
        return FALSE;
 }
 
-/**
- * clean up enumeration data
- */
-static void cert_enumerator_destroy(cert_enumerator_t *this)
+METHOD(enumerator_t, cert_enumerator_destroy, void,
+       cert_enumerator_t *this)
 {
        relation_t *rel;
 
@@ -336,16 +335,19 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
        {
                return NULL;
        }
-       enumerator = malloc_thing(cert_enumerator_t);
-       enumerator->public.enumerate = (void*)cert_enumerate;
-       enumerator->public.destroy = (void*)cert_enumerator_destroy;
-       enumerator->cert = cert;
-       enumerator->key = key;
-       enumerator->id = id;
-       enumerator->relations = this->relations;
-       enumerator->index = -1;
-       enumerator->locked = -1;
-
+       INIT(enumerator,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _cert_enumerate,
+                       .destroy = _cert_enumerator_destroy,
+               },
+               .cert = cert,
+               .key = key,
+               .id = id,
+               .relations = this->relations,
+               .index = -1,
+               .locked = -1,
+       );
        return &enumerator->public;
 }
 
index 151d692..12d3f81 100644 (file)
@@ -49,14 +49,15 @@ typedef struct {
        identification_t *id;
 } wrapper_enumerator_t;
 
-/**
- * enumerate function wrapper_enumerator_t
- */
-static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
+METHOD(enumerator_t, enumerate, bool,
+       wrapper_enumerator_t *this, va_list args)
 {
-       certificate_t *current;
+       certificate_t *current, **cert;
        public_key_t *public;
 
+
+       VA_ARGS_VGET(args, cert);
+
        while (this->inner->enumerate(this->inner, &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;
 }
 
-/**
- * destroy function for wrapper_enumerator_t
- */
-static void enumerator_destroy(wrapper_enumerator_t *this)
+METHOD(enumerator_t, enumerator_destroy, void,
+       wrapper_enumerator_t *this)
 {
        this->inner->destroy(this->inner);
        free(this);
@@ -105,13 +104,17 @@ METHOD(credential_set_t, create_enumerator, enumerator_t*,
                return NULL;
        }
 
-       enumerator = malloc_thing(wrapper_enumerator_t);
-       enumerator->cert = cert;
-       enumerator->key = key;
-       enumerator->id = id;
-       enumerator->inner = this->response->create_cert_enumerator(this->response);
-       enumerator->public.enumerate = (void*)enumerate;
-       enumerator->public.destroy = (void*)enumerator_destroy;
+       INIT(enumerator,
+               .public = {
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
+                       .destroy = _enumerator_destroy,
+               },
+               .cert = cert,
+               .key = key,
+               .id = id,
+               .inner = this->response->create_cert_enumerator(this->response),
+       );
        return &enumerator->public;
 }
 
index bab59a0..3414a21 100644 (file)
@@ -1026,9 +1026,14 @@ typedef struct {
 } verify_enumerator_t;
 
 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;
+       u_int *alg;
+       bool *valid;
+
+       VA_ARGS_VGET(args, alg, plugin, valid);
 
        if (!this->inner->enumerate(this->inner, &entry))
        {
@@ -1123,7 +1128,8 @@ METHOD(crypto_factory_t, create_verify_enumerator, enumerator_t*,
        }
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_verify_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _verify_enumerate,
                        .destroy = _verify_destroy,
                },
                .inner = inner,
index 871cc59..211eba7 100644 (file)
@@ -403,10 +403,8 @@ typedef struct {
        unsigned long *length;
 } mysql_enumerator_t;
 
-/**
- * create a mysql enumerator
- */
-static void mysql_enumerator_destroy(mysql_enumerator_t *this)
+METHOD(enumerator_t, mysql_enumerator_destroy, void,
+       mysql_enumerator_t *this)
 {
        int columns, i;
 
@@ -434,13 +432,10 @@ static void mysql_enumerator_destroy(mysql_enumerator_t *this)
        free(this);
 }
 
-/**
- * Implementation of database.query().enumerate
- */
-static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
+METHOD(enumerator_t, mysql_enumerator_enumerate, bool,
+       mysql_enumerator_t *this, va_list args)
 {
        int i, columns;
-       va_list args;
 
        columns = mysql_stmt_field_count(this->stmt);
 
@@ -477,7 +472,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
                        return FALSE;
        }
 
-       va_start(args, this);
        for (i = 0; i < columns; i++)
        {
                switch (this->bind[i].buffer_type)
@@ -526,7 +520,6 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
                                break;
                }
        }
-       va_end(args);
        return TRUE;
 }
 
@@ -552,9 +545,9 @@ METHOD(database_t, query, enumerator_t*,
 
                INIT(enumerator,
                        .public = {
-                               .enumerate = (void*)mysql_enumerator_enumerate,
-                               .destroy = (void*)mysql_enumerator_destroy,
-
+                               .enumerate = enumerator_enumerate_default,
+                               .venumerate = _mysql_enumerator_enumerate,
+                               .destroy = _mysql_enumerator_destroy,
                        },
                        .db = this,
                        .stmt = stmt,
index 20bac6b..61cf3e8 100644 (file)
@@ -142,8 +142,14 @@ typedef struct {
 
 
 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)
        {
                X509_REVOKED *revoked;
@@ -188,7 +194,8 @@ METHOD(crl_t, create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_crl_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _crl_enumerate,
                        .destroy = (void*)free,
                },
                .stack = X509_CRL_get_REVOKED(this->crl),
index 5752d96..83ac8df 100644 (file)
@@ -136,8 +136,12 @@ METHOD(enumerator_t, cert_destroy, void,
 }
 
 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)
        {
                return FALSE;
@@ -176,7 +180,8 @@ METHOD(pkcs7_t, create_cert_enumerator, enumerator_t*,
        {
                INIT(enumerator,
                        .public = {
-                               .enumerate = (void*)_cert_enumerate,
+                               .enumerate = enumerator_enumerate_default,
+                               .venumerate = _cert_enumerate,
                                .destroy = _cert_destroy,
                        },
                        .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,
-       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)
        {
                return FALSE;
@@ -382,7 +391,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
 
                INIT(enumerator,
                        .public = {
-                               .enumerate = (void*)_signature_enumerate,
+                               .enumerate = enumerator_enumerate_default,
+                               .venumerate = _signature_enumerate,
                                .destroy = _signature_destroy,
                        },
                        .cms = this->cms,
index dc8a1f1..89ae196 100644 (file)
@@ -719,12 +719,14 @@ static bool get_attributes(object_enumerator_t *this, CK_OBJECT_HANDLE object)
 }
 
 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_RV rv;
 
+       VA_ARGS_VGET(args, out);
+
        if (!this->object)
        {
                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,
                .public = {
-                       .enumerate = (void*)_object_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _object_enumerate,
                        .destroy = _object_destroy,
                },
                .session = session,
@@ -806,7 +809,8 @@ METHOD(pkcs11_library_t, create_object_attr_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_object_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _object_enumerate,
                        .destroy = _object_destroy,
                },
                .session = session,
@@ -838,11 +842,14 @@ typedef struct {
 } mechanism_enumerator_t;
 
 METHOD(enumerator_t, enumerate_mech, bool,
-       mechanism_enumerator_t *this, CK_MECHANISM_TYPE* type,
-       CK_MECHANISM_INFO *info)
+       mechanism_enumerator_t *this, va_list args)
 {
+       CK_MECHANISM_INFO *info;
+       CK_MECHANISM_TYPE *type;
        CK_RV rv;
 
+       VA_ARGS_VGET(args, type, info);
+
        if (this->current >= this->count)
        {
                return FALSE;
@@ -876,7 +883,8 @@ METHOD(pkcs11_library_t, create_mechanism_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_mech,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_mech,
                        .destroy = _destroy_mech,
                },
                .lib = &this->public,
index 96c4a18..31bcb0d 100644 (file)
@@ -265,8 +265,13 @@ typedef struct {
 } token_enumerator_t;
 
 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)
        {
                free(this->slots);
@@ -301,7 +306,8 @@ METHOD(pkcs11_manager_t, create_token_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate_token,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate_token,
                        .destroy = _destroy_token,
                },
                .inner = this->libs->create_enumerator(this->libs),
index d224ef3..413c3ff 100644 (file)
@@ -179,7 +179,7 @@ typedef struct {
 } signature_enumerator_t;
 
 METHOD(enumerator_t, enumerate, bool,
-       signature_enumerator_t *this, auth_cfg_t **out)
+       signature_enumerator_t *this, va_list args)
 {
        signerinfo_t *info;
        signature_scheme_t scheme;
@@ -187,11 +187,13 @@ METHOD(enumerator_t, enumerate, bool,
        enumerator_t *enumerator;
        certificate_t *cert;
        public_key_t *key;
-       auth_cfg_t *auth;
+       auth_cfg_t *auth, **out;
        chunk_t chunk, hash, content;
        hasher_t *hasher;
        bool valid;
 
+       VA_ARGS_VGET(args, out);
+
        while (this->inner->enumerate(this->inner, &info))
        {
                /* clean up previous round */
@@ -300,7 +302,8 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _enumerate,
                        .destroy = _enumerator_destroy,
                },
                .inner = this->signerinfos->create_enumerator(this->signerinfos),
index 0a35e30..9f87421 100644 (file)
@@ -174,10 +174,8 @@ typedef struct {
        private_sqlite_database_t *database;
 } sqlite_enumerator_t;
 
-/**
- * destroy a sqlite enumerator
- */
-static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
+METHOD(enumerator_t, sqlite_enumerator_destroy, void,
+       sqlite_enumerator_t *this)
 {
        sqlite3_finalize(this->stmt);
        if (!is_threadsave())
@@ -188,13 +186,10 @@ static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
        free(this);
 }
 
-/**
- * Implementation of database.query().enumerate
- */
-static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
+METHOD(enumerator_t, sqlite_enumerator_enumerate, bool,
+       sqlite_enumerator_t *this, va_list args)
 {
        int i;
-       va_list args;
 
        switch (sqlite3_step(this->stmt))
        {
@@ -207,7 +202,7 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
                case SQLITE_DONE:
                        return FALSE;
        }
-       va_start(args, this);
+
        for (i = 0; i < this->count; i++)
        {
                switch (this->columns[i])
@@ -245,11 +240,9 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
                        }
                        default:
                                DBG1(DBG_LIB, "invalid result type supplied");
-                               va_end(args);
                                return FALSE;
                }
        }
-       va_end(args);
        return TRUE;
 }
 
@@ -270,13 +263,17 @@ METHOD(database_t, query, enumerator_t*,
        stmt = run(this, sql, &args);
        if (stmt)
        {
-               enumerator = malloc_thing(sqlite_enumerator_t);
-               enumerator->public.enumerate = (void*)sqlite_enumerator_enumerate;
-               enumerator->public.destroy = (void*)sqlite_enumerator_destroy;
-               enumerator->stmt = stmt;
-               enumerator->count = sqlite3_column_count(stmt);
+               INIT(enumerator,
+                       .public = {
+                               .enumerate = enumerator_enumerate_default,
+                               .venumerate = _sqlite_enumerator_enumerate,
+                               .destroy = _sqlite_enumerator_destroy,
+                       },
+                       .stmt = stmt,
+                       .count = sqlite3_column_count(stmt),
+                       .database = this,
+               );
                enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count);
-               enumerator->database = this;
                for (i = 0; i < enumerator->count; i++)
                {
                        enumerator->columns[i] = va_arg(args, db_type_t);
index b00e819..bef5180 100644 (file)
@@ -744,10 +744,8 @@ typedef struct {
        hashtable_t *seen;
 } enumerator_data_t;
 
-/**
- * Destroy enumerator data
- */
-static void enumerator_destroy(enumerator_data_t *this)
+CALLBACK(enumerator_destroy, void,
+       enumerator_data_t *this)
 {
        this->settings->lock->unlock(this->settings->lock);
        this->seen->destroy(this->seen);
index 6dd68d6..18b1916 100644 (file)
@@ -668,8 +668,12 @@ typedef struct {
 } frame_enumerator_t;
 
 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)
        {
                *addr = this->bt->frames[this->i++];
@@ -685,7 +689,8 @@ METHOD(backtrace_t, create_frame_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_frame_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _frame_enumerate,
                        .destroy = (void*)free,
                },
                .bt = this,
index 384bd6c..1a47690 100644 (file)
@@ -136,9 +136,12 @@ typedef struct {
 } rdn_enumerator_t;
 
 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,
         * each containing a OID/value RDN */
@@ -173,7 +176,8 @@ static enumerator_t* create_rdn_enumerator(chunk_t dn)
 
        INIT(e,
                .public = {
-                       .enumerate = (void*)_rdn_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _rdn_enumerate,
                        .destroy = (void*)free,
                },
        );
@@ -199,10 +203,11 @@ typedef struct {
 } rdn_part_enumerator_t;
 
 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;
-       chunk_t oid, inner_data;
+       chunk_t oid, inner_data, *data;
+       id_part_t *type;
        static const struct {
                int oid;
                id_part_t type;
@@ -228,6 +233,8 @@ METHOD(enumerator_t, rdn_part_enumerate, bool,
                {OID_EMPLOYEE_NUMBER,   ID_PART_RDN_EN},
        };
 
+       VA_ARGS_VGET(args, type, data);
+
        while (this->inner->enumerate(this->inner, &oid, &strtype, &inner_data))
        {
                known_oid = asn1_known_oid(oid);
@@ -263,7 +270,8 @@ METHOD(identification_t, create_part_enumerator, enumerator_t*,
                        INIT(e,
                                .inner = create_rdn_enumerator(this->encoded),
                                .public = {
-                                       .enumerate = (void*)_rdn_part_enumerate,
+                                       .enumerate = enumerator_enumerate_default,
+                                       .venumerate = _rdn_part_enumerate,
                                        .destroy = _rdn_part_enumerator_destroy,
                                },
                        );
index bf5bbbf..0aee5f6 100644 (file)
@@ -67,8 +67,13 @@ typedef struct {
 } child_enum_t;
 
 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)
        {
                e->node = e->node->next;
@@ -120,7 +125,8 @@ METHOD(xml_t, children, enumerator_t*,
        child_enum_t *ce;
        INIT(ce,
                .e = {
-                       .enumerate = (void*)_child_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _child_enumerate,
                        .destroy = _child_destroy,
                },
                .child = {
index 6d1c54d..9f71a05 100644 (file)
@@ -158,10 +158,13 @@ typedef struct {
 } dictionary_enumerator_t;
 
 METHOD(enumerator_t, dictionary_enumerate, bool,
-       dictionary_enumerator_t *this, char **key, char **value)
+       dictionary_enumerator_t *this, va_list args)
 {
        setting_t *setting;
        section_t *parent;
+       char **key, **value;
+
+       VA_ARGS_VGET(args, key, value);
 
        while (TRUE)
        {
@@ -221,7 +224,8 @@ METHOD(dictionary_t, dictionary_create_enumerator, enumerator_t*,
 
        INIT(enumerator,
                .public = {
-                       .enumerate = (void*)_dictionary_enumerate,
+                       .enumerate = enumerator_enumerate_default,
+                       .venumerate = _dictionary_enumerate,
                        .destroy = _dictionary_enumerator_destroy,
                },
                .seen = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8),