summaryrefslogtreecommitdiff
path: root/sexp.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2002-11-10 14:38:50 +0100
committerNiels Möller <nisse@lysator.liu.se>2002-11-10 14:38:50 +0100
commit1343434e1c21f1ad4441339d1b8a30d2ffe9c268 (patch)
tree25444ee886799180b952894ab194217b8e05e436 /sexp.c
parenta8ff180596b0f16837bc08cf493c0f9224c6233f (diff)
downloadnettle-1343434e1c21f1ad4441339d1b8a30d2ffe9c268.tar.gz
* sexp.h (struct sexp_iterator): New field start.
* sexp.c (sexp_iterator_subexpr): New function. (sexp_iterator_parse): Initialize ITERATOR->start. Rev: src/nettle/sexp.c:1.11 Rev: src/nettle/sexp.h:1.8
Diffstat (limited to 'sexp.c')
-rw-r--r--sexp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sexp.c b/sexp.c
index 2a49fdcf..b35f9cb1 100644
--- a/sexp.c
+++ b/sexp.c
@@ -99,6 +99,8 @@ sexp_iterator_simple(struct sexp_iterator *iterator,
static int
sexp_iterator_parse(struct sexp_iterator *iterator)
{
+ iterator->start = iterator->pos;
+
if (EMPTY(iterator))
{
if (iterator->level)
@@ -208,6 +210,19 @@ sexp_iterator_exit_list(struct sexp_iterator *iterator)
return sexp_iterator_parse(iterator);
}
+const uint8_t *
+sexp_iterator_subexpr(struct sexp_iterator *iterator,
+ unsigned *length)
+{
+ unsigned start = iterator->start;
+ if (!sexp_iterator_next(iterator))
+ return 0;
+
+ *length = iterator->start - start;
+ return iterator->buffer + start;
+}
+
+
int
sexp_iterator_check_type(struct sexp_iterator *iterator,
const uint8_t *type)