Back port jansson iterators
authorSam Hartman <hartmans@debian.org>
Fri, 11 Jul 2014 19:03:12 +0000 (15:03 -0400)
committerSam Hartman <hartmans@debian.org>
Mon, 14 Jul 2014 20:07:34 +0000 (16:07 -0400)
Makefile.am
common/jansson_iterators.h [new file with mode: 0644]
common/tr_constraint.c

index 8747765..3e18e37 100644 (file)
@@ -4,6 +4,7 @@ AM_CFLAGS = -Wall -Werror=missing-prototypes -Werror -Wno-parentheses
 SUBDIRS = gsscon 
 common_srcs = common/tr_name.c \
        common/tr_constraint.c \
+       common/jansson_iterators.h \
        common/tr_msg.c \
        common/tr_dh.c \
        common/tr_util.c
diff --git a/common/jansson_iterators.h b/common/jansson_iterators.h
new file mode 100644 (file)
index 0000000..c4e8a32
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
+ *
+ * Jansson is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+/*See the LICENSE file in the jansson source distribution.
+ */
+
+#ifndef json_object_foreach
+#define json_object_foreach(object, key, value) \
+    for(key = json_object_iter_key(json_object_iter(object)); \
+        key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
+        key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
+#endif
+
+#ifndef json_array_foreach
+#define json_array_foreach(array, index, value) \
+       for(index = 0; \
+               index < json_array_size(array) && (value = json_array_get(array, index)); \
+               index++)
+#endif
index 78c88f3..ac36958 100644 (file)
@@ -32,6 +32,7 @@
  *
  */
 #include <jansson.h>
+#include "jansson_iterators.h"
 #include <assert.h>
 #include <talloc.h>