]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: mjson: remove MJSON_ENABLE_NEXT code
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 1 Oct 2025 16:53:41 +0000 (18:53 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 3 Oct 2025 14:08:17 +0000 (16:08 +0200)
Remove the code used under #if MJSON_ENABLE_NEXT, which is not used
within haproxy, to ease the maintenance of mjson.

include/import/mjson.h
src/mjson.c

index 55c1995d466ce7ab1c7f4c76ac4a23b9014ad668..faa7ebf91fd29b1a243e0a73cb36d673b3e6a2d3 100644 (file)
@@ -98,11 +98,6 @@ int mjson_get_bool(const char *s, int len, const char *path, int *v);
 int mjson_get_string(const char *s, int len, const char *path, char *to, int n);
 int mjson_get_hex(const char *s, int len, const char *path, char *to, int n);
 
-#if MJSON_ENABLE_NEXT
-int mjson_next(const char *s, int n, int off, int *koff, int *klen, int *voff,
-               int *vlen, int *vtype);
-#endif
-
 #if MJSON_ENABLE_BASE64
 int mjson_get_base64(const char *s, int len, const char *path, char *to, int n);
 int mjson_base64_dec(const char *src, int n, char *dst, int dlen);
index 1a1733fbffaba5c81376421d42b5e4b1c03916eb..539fd690cda9f751672fe212d502eee23b8894b9 100644 (file)
@@ -393,79 +393,6 @@ int mjson_get_base64(const char *s, int len, const char *path, char *to,
 }
 #endif  // MJSON_ENABLE_BASE64
 
-#if MJSON_ENABLE_NEXT
-struct nextdata {
-  int off, len, depth, t, vo, arrayindex;
-  int *koff, *klen, *voff, *vlen, *vtype;
-};
-
-static int next_cb(int tok, const char *s, int off, int len, void *ud) {
-  struct nextdata *d = (struct nextdata *) ud;
-  // int i;
-  switch (tok) {
-    case '{':
-    case '[':
-      if (d->depth == 0 && tok == '[') d->arrayindex = 0;
-      if (d->depth == 1 && off > d->off) {
-        d->vo = off;
-        d->t = tok == '{' ? MJSON_TOK_OBJECT : MJSON_TOK_ARRAY;
-        if (d->voff) *d->voff = off;
-        if (d->vtype) *d->vtype = d->t;
-      }
-      d->depth++;
-      break;
-    case '}':
-    case ']':
-      d->depth--;
-      if (d->depth == 1 && d->vo) {
-        d->len = off + len;
-        if (d->vlen) *d->vlen = d->len - d->vo;
-        if (d->arrayindex >= 0) {
-          if (d->koff) *d->koff = d->arrayindex;  // koff holds array index
-          if (d->klen) *d->klen = 0;              // klen holds 0
-        }
-        return 1;
-      }
-      if (d->depth == 1 && d->arrayindex >= 0) d->arrayindex++;
-      break;
-    case ',':
-    case ':':
-      break;
-    case MJSON_TOK_KEY:
-      if (d->depth == 1 && d->off < off) {
-        if (d->koff) *d->koff = off;  // And report back to the user
-        if (d->klen) *d->klen = len;  // If we have to
-      }
-      break;
-    default:
-      if (d->depth != 1) break;
-      // If we're iterating over the array
-      if (off > d->off) {
-        d->len = off + len;
-        if (d->vlen) *d->vlen = len;    // value length
-        if (d->voff) *d->voff = off;    // value offset
-        if (d->vtype) *d->vtype = tok;  // value type
-        if (d->arrayindex >= 0) {
-          if (d->koff) *d->koff = d->arrayindex;  // koff holds array index
-          if (d->klen) *d->klen = 0;              // klen holds 0
-        }
-        return 1;
-      }
-      if (d->arrayindex >= 0) d->arrayindex++;
-      break;
-  }
-  (void) s;
-  return 0;
-}
-
-int mjson_next(const char *s, int n, int off, int *koff, int *klen, int *voff,
-               int *vlen, int *vtype) {
-  struct nextdata d = {off, 0, 0, 0, 0, -1, koff, klen, voff, vlen, vtype};
-  mjson(s, n, next_cb, &d);
-  return d.len;
-}
-#endif
-
 static int is_digit(int c) {
   return c >= '0' && c <= '9';
 }