#include <stdlib.h>
#include <string.h>
-void
+/* Initializes the iterator. You have to call next to get to the first
+ * element. */
+static void
sexp_iterator_init(struct sexp_iterator *iterator,
unsigned length, const uint8_t *input)
{
* skip white space here. */
}
+int
+sexp_iterator_first(struct sexp_iterator *iterator,
+ unsigned length, const uint8_t *input)
+{
+ sexp_iterator_init(iterator, length, input);
+ return sexp_iterator_next(iterator);
+}
+
#define EMPTY(i) ((i)->pos == (i)->length)
#define NEXT(i) ((i)->buffer[(i)->pos++])
};
-/* Initializes the iterator. You have to call next to get to the first
- * element. */
-void
-sexp_iterator_init(struct sexp_iterator *iterator,
- unsigned length, const uint8_t *input);
-
/* All these functions return 1 on success, 0 on failure */
+
+/* Initializes the iterator. */
+int
+sexp_iterator_first(struct sexp_iterator *iterator,
+ unsigned length, const uint8_t *input);
+
int
sexp_iterator_next(struct sexp_iterator *iterator);