Replaced simple iterator usages.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user