From 5fa477db9becfdac797f66e5532d118f82bc1cd9 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Fri, 11 Jul 2014 15:03:12 -0400 Subject: [PATCH 1/1] Back port jansson iterators --- Makefile.am | 1 + common/jansson_iterators.h | 22 ++++++++++++++++++++++ common/tr_constraint.c | 1 + 3 files changed, 24 insertions(+) create mode 100644 common/jansson_iterators.h diff --git a/Makefile.am b/Makefile.am index 8747765..3e18e37 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..c4e8a32 --- /dev/null +++ b/common/jansson_iterators.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2009-2013 Petri Lehtinen + * + * 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 diff --git a/common/tr_constraint.c b/common/tr_constraint.c index 78c88f3..ac36958 100644 --- a/common/tr_constraint.c +++ b/common/tr_constraint.c @@ -32,6 +32,7 @@ * */ #include +#include "jansson_iterators.h" #include #include -- 2.1.4