Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in the callback.
This commit is contained in:
@@ -804,20 +804,27 @@ METHOD(ac_t, get_authKeyIdentifier, chunk_t,
|
||||
return this->authKeyIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter function for attribute enumeration
|
||||
*/
|
||||
static bool attr_filter(void *null, group_t **in, ac_group_type_t *type,
|
||||
void *in2, chunk_t *out)
|
||||
CALLBACK(attr_filter, bool,
|
||||
void *null, enumerator_t *orig, va_list args)
|
||||
{
|
||||
if ((*in)->type == AC_GROUP_TYPE_STRING &&
|
||||
!chunk_printable((*in)->value, NULL, 0))
|
||||
{ /* skip non-printable strings */
|
||||
return FALSE;
|
||||
group_t *group;
|
||||
ac_group_type_t *type;
|
||||
chunk_t *out;
|
||||
|
||||
VA_ARGS_VGET(args, type, out);
|
||||
|
||||
while (orig->enumerate(orig, &group))
|
||||
{
|
||||
if (group->type == AC_GROUP_TYPE_STRING &&
|
||||
!chunk_printable(group->value, NULL, 0))
|
||||
{ /* skip non-printable strings */
|
||||
continue;
|
||||
}
|
||||
*type = group->type;
|
||||
*out = group->value;
|
||||
return TRUE;
|
||||
}
|
||||
*type = (*in)->type;
|
||||
*out = (*in)->value;
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(ac_t, create_group_enumerator, enumerator_t*,
|
||||
@@ -825,7 +832,7 @@ METHOD(ac_t, create_group_enumerator, enumerator_t*,
|
||||
{
|
||||
return enumerator_create_filter(
|
||||
this->groups->create_enumerator(this->groups),
|
||||
(void*)attr_filter, NULL, NULL);
|
||||
attr_filter, NULL, NULL);
|
||||
}
|
||||
|
||||
METHOD(certificate_t, get_type, certificate_type_t,
|
||||
|
||||
@@ -364,25 +364,33 @@ end:
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* enumerator filter callback for create_enumerator
|
||||
*/
|
||||
static bool filter(void *data, revoked_t **revoked, chunk_t *serial, void *p2,
|
||||
time_t *date, void *p3, crl_reason_t *reason)
|
||||
CALLBACK(filter, bool,
|
||||
void *data, enumerator_t *orig, va_list args)
|
||||
{
|
||||
if (serial)
|
||||
revoked_t *revoked;
|
||||
crl_reason_t *reason;
|
||||
chunk_t *serial;
|
||||
time_t *date;
|
||||
|
||||
VA_ARGS_VGET(args, serial, date, reason);
|
||||
|
||||
if (orig->enumerate(orig, &revoked))
|
||||
{
|
||||
*serial = (*revoked)->serial;
|
||||
if (serial)
|
||||
{
|
||||
*serial = revoked->serial;
|
||||
}
|
||||
if (date)
|
||||
{
|
||||
*date = revoked->date;
|
||||
}
|
||||
if (reason)
|
||||
{
|
||||
*reason = revoked->reason;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (date)
|
||||
{
|
||||
*date = (*revoked)->date;
|
||||
}
|
||||
if (reason)
|
||||
{
|
||||
*reason = (*revoked)->reason;
|
||||
}
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(crl_t, get_serial, chunk_t,
|
||||
@@ -422,7 +430,7 @@ METHOD(crl_t, create_enumerator, enumerator_t*,
|
||||
{
|
||||
return enumerator_create_filter(
|
||||
this->revoked->create_enumerator(this->revoked),
|
||||
(void*)filter, NULL, NULL);
|
||||
filter, NULL, NULL);
|
||||
}
|
||||
|
||||
METHOD(certificate_t, get_type, certificate_type_t,
|
||||
|
||||
@@ -228,32 +228,38 @@ METHOD(ocsp_response_t, create_cert_enumerator, enumerator_t*,
|
||||
return this->certs->create_enumerator(this->certs);
|
||||
}
|
||||
|
||||
/**
|
||||
* enumerator filter callback for create_response_enumerator
|
||||
*/
|
||||
static bool filter(void *data, single_response_t **response,
|
||||
chunk_t *serialNumber,
|
||||
void *p2, cert_validation_t *status,
|
||||
void *p3, time_t *revocationTime,
|
||||
void *p4, crl_reason_t *revocationReason)
|
||||
CALLBACK(filter, bool,
|
||||
void *data, enumerator_t *orig, va_list args)
|
||||
{
|
||||
if (serialNumber)
|
||||
single_response_t *response;
|
||||
cert_validation_t *status;
|
||||
crl_reason_t *revocationReason;
|
||||
chunk_t *serialNumber;
|
||||
time_t *revocationTime;
|
||||
|
||||
VA_ARGS_VGET(args, serialNumber, status, revocationTime, revocationReason);
|
||||
|
||||
if (orig->enumerate(orig, &response))
|
||||
{
|
||||
*serialNumber = (*response)->serialNumber;
|
||||
if (serialNumber)
|
||||
{
|
||||
*serialNumber = response->serialNumber;
|
||||
}
|
||||
if (status)
|
||||
{
|
||||
*status = response->status;
|
||||
}
|
||||
if (revocationTime)
|
||||
{
|
||||
*revocationTime = response->revocationTime;
|
||||
}
|
||||
if (revocationReason)
|
||||
{
|
||||
*revocationReason = response->revocationReason;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (status)
|
||||
{
|
||||
*status = (*response)->status;
|
||||
}
|
||||
if (revocationTime)
|
||||
{
|
||||
*revocationTime = (*response)->revocationTime;
|
||||
}
|
||||
if (revocationReason)
|
||||
{
|
||||
*revocationReason = (*response)->revocationReason;
|
||||
}
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(ocsp_response_t, create_response_enumerator, enumerator_t*,
|
||||
@@ -261,7 +267,7 @@ METHOD(ocsp_response_t, create_response_enumerator, enumerator_t*,
|
||||
{
|
||||
return enumerator_create_filter(
|
||||
this->responses->create_enumerator(this->responses),
|
||||
(void*)filter, NULL, NULL);
|
||||
filter, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user