diff options
author | Fabio Fiorina <fiorinaf@gnutls.org> | 2002-03-26 21:05:45 +0000 |
---|---|---|
committer | Fabio Fiorina <fiorinaf@gnutls.org> | 2002-03-26 21:05:45 +0000 |
commit | eaecae9f1b1a421593b511ca528d9d25874e6a1b (patch) | |
tree | c91a7994a2c13cd4549f968feb8a98fb6c1f4c05 | |
parent | 9c31075cc5036c6a5e7deed3883fc9ba8b39ddd8 (diff) | |
download | gnutls-eaecae9f1b1a421593b511ca528d9d25874e6a1b.tar.gz |
add asn1_number_of_elements function
-rwxr-xr-x | lib/x509_asn1.c | 38 | ||||
-rwxr-xr-x | lib/x509_asn1.h | 3 |
2 files changed, 41 insertions, 0 deletions
diff --git a/lib/x509_asn1.c b/lib/x509_asn1.c index cec909eecb..30ccd7df52 100755 --- a/lib/x509_asn1.c +++ b/lib/x509_asn1.c @@ -1465,6 +1465,44 @@ asn1_read_value(node_asn *root,char *name,unsigned char *value, int *len) return ASN_OK; } +/** + * asn1_number_of_elements - Counts the number of elements of a structure. + * @root: pointer to the root of an ASN1 structure. + * @name: the name of a sub-structure of ROOT. + * @num: pointer to an integer where the result will be stored + * Description: + * + * Counts the number of elements of a sub-structure called NAME with names equal to "?1","?2", ... + * + * Returns: + * + * ASN_OK: creation OK + * ASN_ELEMENT_NOT_FOUND: NAME isn't known + * ASN_GENERIC_ERROR: parameter num equal to NULL + * + **/ +int +asn1_number_of_elements(node_asn *root,char *name,int *num) +{ + node_asn *node,*p; + + if(num==NULL) return ASN_GENERIC_ERROR; + + *num=0; + + node=_asn1_find_node(root,name); + if(node==NULL) return ASN_ELEMENT_NOT_FOUND; + + p=node->down; + + while(p){ + if((p->name) && (p->name[0]=='?')) (*num)++; + p=p->right; + } + + return ASN_OK; +} + int _asn1_set_default_tag(node_asn *node) diff --git a/lib/x509_asn1.h b/lib/x509_asn1.h index b8165ed836..fb30be6e6b 100755 --- a/lib/x509_asn1.h +++ b/lib/x509_asn1.h @@ -197,5 +197,8 @@ asn1_read_value(node_asn *root,char *name,unsigned char *value,int *len); int asn1_create_tree(const static_asn *root,node_asn **pointer); +int +asn1_number_of_elements(node_asn *root,char *name,int *num); + #endif |