|
|
@ -119,9 +119,9 @@ enomem: |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
KeyList_t *KeyList_from_stringlist( |
|
|
|
const stringlist_t *list, |
|
|
|
KeyList_t *result |
|
|
|
IdentityList_t *IdentityList_from_identity_list( |
|
|
|
const identity_list *list, |
|
|
|
IdentityList_t *result |
|
|
|
) |
|
|
|
{ |
|
|
|
assert(list); |
|
|
@ -129,18 +129,15 @@ KeyList_t *KeyList_from_stringlist( |
|
|
|
return NULL; |
|
|
|
|
|
|
|
if (!result) |
|
|
|
result = (KeyList_t *) calloc(1, sizeof(KeyList_t)); |
|
|
|
result = (IdentityList_t *) calloc(1, sizeof(IdentityList_t)); |
|
|
|
assert(result); |
|
|
|
if (!result) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
for (const stringlist_t *l = list; l && l->value; l=l->next) { |
|
|
|
Hash_t *key = OCTET_STRING_new_fromBuf(&asn_DEF_Hash, l->value, -1); |
|
|
|
if (!key) |
|
|
|
goto enomem; |
|
|
|
|
|
|
|
if (ASN_SEQUENCE_ADD(&result->list, key)) { |
|
|
|
ASN_STRUCT_FREE(asn_DEF_Hash, key); |
|
|
|
for (const identity_list *l = list; l && l->ident; l=l->next) { |
|
|
|
Identity_t *ident = Identity_from_Struct(l->ident, NULL); |
|
|
|
if (ASN_SEQUENCE_ADD(&result->list, ident)) { |
|
|
|
ASN_STRUCT_FREE(asn_DEF_Identity, ident); |
|
|
|
goto enomem; |
|
|
|
} |
|
|
|
} |
|
|
@ -148,30 +145,25 @@ KeyList_t *KeyList_from_stringlist( |
|
|
|
return result; |
|
|
|
|
|
|
|
enomem: |
|
|
|
ASN_STRUCT_FREE(asn_DEF_KeyList, result); |
|
|
|
ASN_STRUCT_FREE(asn_DEF_IdentityList, result); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result) |
|
|
|
identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result) |
|
|
|
{ |
|
|
|
assert(list); |
|
|
|
if (!list) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
if (!result) |
|
|
|
result = new_stringlist(NULL); |
|
|
|
result = new_identity_list(NULL); |
|
|
|
if (!result) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
stringlist_t *r = result; |
|
|
|
identity_list *r = result; |
|
|
|
for (int i=0; i<list->list.count; i++) { |
|
|
|
char *str = strndup((char *) list->list.array[i]->buf, |
|
|
|
list->list.array[i]->size); |
|
|
|
assert(str); |
|
|
|
if (!str) |
|
|
|
goto enomem; |
|
|
|
r = stringlist_add(r, str); |
|
|
|
free(str); |
|
|
|
pEp_identity *ident = Identity_to_Struct(list->list.array[i], NULL); |
|
|
|
r = identity_list_add(r, ident); |
|
|
|
if (!r) |
|
|
|
goto enomem; |
|
|
|
} |
|
|
@ -179,7 +171,7 @@ stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result) |
|
|
|
return result; |
|
|
|
|
|
|
|
enomem: |
|
|
|
free_stringlist(result); |
|
|
|
free_identity_list(result); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|