summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-06-04 14:26:35 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-06-04 14:26:41 +0200
commitdee899dd68f595549493d8929478fd298e115ade (patch)
treef9652cf71c41c39d26a4d7b38781342fd3df2bea /lib
parent4010bb04588fca86a9f6d683b637c05b4cec24e0 (diff)
downloadlibtasn1-dee899dd68f595549493d8929478fd298e115ade.tar.gz
libtasn1-dee899dd68f595549493d8929478fd298e115ade.tar.bz2
libtasn1-dee899dd68f595549493d8929478fd298e115ade.zip
asn1_read_value() and friends understand the ?CURRENT keyword.
That keyword allows to specify the current element if the given node is a node in a sequence or set.
Diffstat (limited to 'lib')
-rw-r--r--lib/element.c10
-rw-r--r--lib/parser_aux.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/element.c b/lib/element.c
index c2b7107..b45c3ec 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -676,7 +676,9 @@ asn1_write_value (asn1_node node_root, const char *name,
* %ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present
* in the der encoding that created the structure. The first element
* of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
- * so on.
+ * so on. If the @root provided is a node to specific sequence element,
+ * then the keyword "?CURRENT" is also acceptable and indicates the
+ * current sequence element of this node.
*
* Note that there can be valid values with length zero. In these case
* this function will succeed and @len will be zero.
@@ -741,12 +743,14 @@ asn1_read_value (asn1_node root, const char *name, void *ivalue, int *len)
* holds the sizeof value.
* @etype: The type of the value read (ASN1_ETYPE)
*
- * Returns the value of one element inside a structure.
+ * Returns the type and value of one element inside a structure.
* If an element is OPTIONAL and this returns
* %ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present
* in the der encoding that created the structure. The first element
* of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
- * so on.
+ * so on. If the @root provided is a node to specific sequence element,
+ * then the keyword "?CURRENT" is also acceptable and indicates the
+ * current sequence element of this node.
*
* Note that there can be valid values with length zero. In these case
* this function will succeed and @len will be zero.
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index 32dfba0..4b15000 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -108,7 +108,13 @@ asn1_find_node (asn1_node pointer, const char *name)
p = pointer;
n_start = name;
- if (p->name[0] != 0)
+ if (name[0] == '?' && name[1] == 'C' && p->name[0] == '?')
+ { /* ?CURRENT */
+ n_start = strchr(n_start, '.');
+ if (n_start)
+ n_start++;
+ }
+ else if (p->name[0] != 0)
{ /* has *pointer got a name ? */
n_end = strchr (n_start, '.'); /* search the first dot */
if (n_end)