* 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
static int
sexp_iterator_parse(struct sexp_iterator *iterator)
{
+ iterator->start = iterator->pos;
+
if (EMPTY(iterator))
{
if (iterator->level)
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)
{
unsigned length;
const uint8_t *buffer;
-
+
+ /* Points at the start of the current sub expression. */
+ unsigned start;
/* If type is SEXP_LIST, pos points at the start of the current
* element. Otherwise, it points at the end. */
unsigned pos;
int
sexp_iterator_exit_list(struct sexp_iterator *iterator);
+/* Gets start and length of the current subexpression. Implies
+ * sexp_iterator_next. */
+const uint8_t *
+sexp_iterator_subexpr(struct sexp_iterator *iterator,
+ unsigned *length);
+
\f
/* Checks the type of the current expression, which should be a list
*