From dd6bb6c6b8298ebeff2d1882becb36580b969d6f Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 23 Jul 2021 16:43:57 +0000 Subject: New 2.11.0.0 branch with several modifications - libbiguint removed - cdb_make changed to cdbmake (because different ui) - cdb redesigned Signed-off-by: Laurent Bercot --- src/libstddjb/cdb_traverse_next.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/libstddjb/cdb_traverse_next.c (limited to 'src/libstddjb/cdb_traverse_next.c') diff --git a/src/libstddjb/cdb_traverse_next.c b/src/libstddjb/cdb_traverse_next.c new file mode 100644 index 0000000..887574b --- /dev/null +++ b/src/libstddjb/cdb_traverse_next.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include + +#include +#include +#include "cdb-internal.h" + +int cdb_traverse_next (cdb const *c, cdb_data *key, cdb_data *data, uint32_t *pos) +{ + uint32_t eod ; + char const *p = cdb_p(c, 4, 0) ; + if (!p) return -1 ; + uint32_unpack(p, &eod) ; + if (eod < 8 || eod - 8 < *pos) return 0 ; + if (*pos + 8 < *pos) return -1 ; + p = cdb_p(c, 8, *pos) ; + if (!p) return -1 ; + uint32_unpack(p, &key->len) ; + uint32_unpack(p + 4, &data->len) ; + key->s = c->map + *pos + 8 ; + data->s = key->s + key->len ; + *pos += 8 + key->len + data->len ; + return 1 ; +} -- cgit v1.2.3