summaryrefslogtreecommitdiffstats
path: root/src/jansson.c
diff options
context:
space:
mode:
authorÁlvaro Neira Ayuso <alvaroneay@gmail.com>2013-07-31 15:20:59 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-31 16:42:53 +0200
commit03e3740d654e1e14ccfb8dbfaba605ae72067ef6 (patch)
treee9f05c32b12a61e8e44dc4daf5df08478c4f7aed /src/jansson.c
parent72ba595e37a73c539aa64d22b2dace3e5bbea3bc (diff)
jansson: Add helper function for building the tree and use it
Add a helper function that parses and returns the jansson tree, use it in the table parser. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/jansson.c')
-rw-r--r--src/jansson.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/jansson.c b/src/jansson.c
index cc68ae0..4c778d9 100644
--- a/src/jansson.c
+++ b/src/jansson.c
@@ -71,4 +71,23 @@ bool nft_jansson_node_exist(json_t *root, const char *tag)
{
return json_object_get(root, tag) != NULL;
}
+
+json_t *nft_jansson_get_root(char *json, const char *tag, json_error_t *err)
+{
+ json_t *root;
+
+ root = json_loadb(json, strlen(json), 0, err);
+ if (root == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ root = json_object_get(root, tag);
+ if (root == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ return root;
+}
#endif