diff options
author | Tobias Brunner <tobias@strongswan.org> | 2011-05-19 16:18:30 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2011-07-06 09:43:45 +0200 |
commit | e26304348c80697ae299081567bddf1acbf022e2 (patch) | |
tree | 8566f2a7cc12d8653ef6d46fe1a360b535f14c60 /src/libstrongswan | |
parent | 28623fc5389829858c78c759a214aa5c64ea26c6 (diff) | |
download | strongswan-e26304348c80697ae299081567bddf1acbf022e2.tar.bz2 strongswan-e26304348c80697ae299081567bddf1acbf022e2.tar.xz |
Replaced simple iterator usages.
Diffstat (limited to 'src/libstrongswan')
-rw-r--r-- | src/libstrongswan/crypto/pkcs9.c | 21 | ||||
-rw-r--r-- | src/libstrongswan/plugins/x509/x509_ac.c | 6 | ||||
-rw-r--r-- | src/libstrongswan/selectors/traffic_selector.c | 20 | ||||
-rw-r--r-- | src/libstrongswan/utils/enumerator.h | 2 |
4 files changed, 25 insertions, 24 deletions
diff --git a/src/libstrongswan/crypto/pkcs9.c b/src/libstrongswan/crypto/pkcs9.c index 0226fbd49..af34cfa07 100644 --- a/src/libstrongswan/crypto/pkcs9.c +++ b/src/libstrongswan/crypto/pkcs9.c @@ -198,7 +198,7 @@ static attribute_t *attribute_create(int oid, chunk_t value) */ static void build_encoding(private_pkcs9_t *this) { - iterator_t *iterator; + enumerator_t *enumerator; attribute_t *attribute; u_int attributes_len = 0; @@ -212,26 +212,26 @@ static void build_encoding(private_pkcs9_t *this) } /* compute the total length of the encoded attributes */ - iterator = this->attributes->create_iterator(this->attributes, TRUE); + enumerator = this->attributes->create_enumerator(this->attributes); - while (iterator->iterate(iterator, (void**)&attribute)) + while (enumerator->enumerate(enumerator, (void**)&attribute)) { attributes_len += attribute->encoding.len; } - iterator->destroy(iterator); + enumerator->destroy(enumerator); /* allocate memory for the attributes and build the encoding */ { u_char *pos = asn1_build_object(&this->encoding, ASN1_SET, attributes_len); - iterator = this->attributes->create_iterator(this->attributes, TRUE); + enumerator = this->attributes->create_enumerator(this->attributes); - while (iterator->iterate(iterator, (void**)&attribute)) + while (enumerator->enumerate(enumerator, (void**)&attribute)) { memcpy(pos, attribute->encoding.ptr, attribute->encoding.len); pos += attribute->encoding.len; } - iterator->destroy(iterator); + enumerator->destroy(enumerator); } } @@ -252,11 +252,12 @@ static chunk_t get_encoding(private_pkcs9_t *this) */ static chunk_t get_attribute(private_pkcs9_t *this, int oid) { - iterator_t *iterator = this->attributes->create_iterator(this->attributes, TRUE); + enumerator_t *enumerator; chunk_t value = chunk_empty; attribute_t *attribute; - while (iterator->iterate(iterator, (void**)&attribute)) + enumerator = this->attributes->create_enumerator(this->attributes); + while (enumerator->enumerate(enumerator, (void**)&attribute)) { if (attribute->oid == oid) { @@ -264,7 +265,7 @@ static chunk_t get_attribute(private_pkcs9_t *this, int oid) break; } } - iterator->destroy(iterator); + enumerator->destroy(enumerator); return value; } diff --git a/src/libstrongswan/plugins/x509/x509_ac.c b/src/libstrongswan/plugins/x509/x509_ac.c index ba0357cc4..72b101bfd 100644 --- a/src/libstrongswan/plugins/x509/x509_ac.c +++ b/src/libstrongswan/plugins/x509/x509_ac.c @@ -179,11 +179,11 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi if (has_directoryName) { - iterator_t *iterator = list->create_iterator(list, TRUE); + enumerator_t *enumerator = list->create_enumerator(list); identification_t *directoryName; bool first = TRUE; - while (iterator->iterate(iterator, (void**)&directoryName)) + while (enumerator->enumerate(enumerator, (void**)&directoryName)) { if (first) { @@ -196,7 +196,7 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi directoryName->destroy(directoryName); } } - iterator->destroy(iterator); + enumerator->destroy(enumerator); } else { diff --git a/src/libstrongswan/selectors/traffic_selector.c b/src/libstrongswan/selectors/traffic_selector.c index 8af5c8419..98cc3bd00 100644 --- a/src/libstrongswan/selectors/traffic_selector.c +++ b/src/libstrongswan/selectors/traffic_selector.c @@ -62,7 +62,7 @@ struct private_traffic_selector_t { bool dynamic; /** - * subnet size in CIDR notation, 255 means a non-subnet address range + * subnet size in CIDR notation, 255 means a non-subnet address range */ u_int8_t netbits; @@ -130,12 +130,12 @@ static void calc_range(private_traffic_selector_t *this, u_int8_t netbits) static u_int8_t calc_netbits(private_traffic_selector_t *this) { int byte, bit; - u_int8_t netbits; + u_int8_t netbits; size_t size = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16; bool prefix = TRUE; - + /* a perfect match results in a single address with a /32 or /128 netmask */ - netbits = (size * 8); + netbits = (size * 8); this->netbits = netbits; /* go through all bits of the addresses, beginning in the front. @@ -153,7 +153,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this) { /* store the common prefix which might be a true subnet */ netbits = (7 - bit) + (byte * 8); - this->netbits = netbits; + this->netbits = netbits; prefix = FALSE; } } @@ -165,7 +165,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this) return netbits; /* return a pseudo subnet */ } - } + } } } return netbits; /* return a true subnet */ @@ -184,7 +184,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec { private_traffic_selector_t *this = *((private_traffic_selector_t**)(args[0])); linked_list_t *list = *((linked_list_t**)(args[0])); - iterator_t *iterator; + enumerator_t *enumerator; char from_str[INET6_ADDRSTRLEN] = ""; char to_str[INET6_ADDRSTRLEN] = ""; char *serv_proto = NULL; @@ -200,13 +200,13 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec if (spec->hash) { - iterator = list->create_iterator(list, TRUE); - while (iterator->iterate(iterator, (void**)&this)) + enumerator = list->create_enumerator(list); + while (enumerator->enumerate(enumerator, (void**)&this)) { /* call recursivly */ written += print_in_hook(dst, len, "%R ", this); } - iterator->destroy(iterator); + enumerator->destroy(enumerator); return written; } diff --git a/src/libstrongswan/utils/enumerator.h b/src/libstrongswan/utils/enumerator.h index 537bf69e1..e9693a5b6 100644 --- a/src/libstrongswan/utils/enumerator.h +++ b/src/libstrongswan/utils/enumerator.h @@ -26,7 +26,7 @@ typedef struct enumerator_t enumerator_t; #include "../utils.h" /** - * Enumerate is simpler, but more flexible than iterator. + * Enumerator interface, allows enumeration over collections. */ struct enumerator_t { |