From: Alvaro Neira <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [libnftables PATCH 1/2] src: rename the parameter tag to node_name in jansson function
Date: Tue, 31 Dec 2013 12:27:47 +0100 [thread overview]
Message-ID: <20131231112747.11095.53072.stgit@Ph0enix> (raw)
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>
I have changed this parameter for having consistence with the xml helper
function
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
src/internal.h | 18 ++++++++++--------
src/jansson.c | 34 ++++++++++++++++++----------------
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/src/internal.h b/src/internal.h
index a10d874..f975ad1 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -57,19 +57,21 @@ int nft_mxml_set_parse(mxml_node_t *tree, struct nft_set *s);
#ifdef JSON_PARSING
#include <jansson.h>
-int nft_jansson_parse_val(json_t *root, const char *tag, int type, void *out);
-const char *nft_jansson_parse_str(json_t *root, const char *tag);
-bool nft_jansson_node_exist(json_t *root, const char *tag);
+int nft_jansson_parse_val(json_t *root, const char *node_name, int type,
+ void *out);
+const char *nft_jansson_parse_str(json_t *root, const char *node_name);
+bool nft_jansson_node_exist(json_t *root, const char *node_name);
json_t *nft_jansson_create_root(const char *json, json_error_t *err);
-json_t *nft_jansson_get_node(json_t *root, const char *tag);
+json_t *nft_jansson_get_node(json_t *root, const char *node_name);
void nft_jansson_free_root(json_t *root);
int nft_jansson_parse_family(json_t *root, void *out);
-int nft_jansson_str2num(json_t *root, const char *tag, int base, void *out,
- enum nft_type type);
-int nft_jansson_parse_reg(json_t *root, const char *tag, int type, void *out);
+int nft_jansson_str2num(json_t *root, const char *node_name, int base,
+ void *out, enum nft_type type);
+int nft_jansson_parse_reg(json_t *root, const char *node_name, int type,
+ void *out);
struct nft_rule_expr *nft_jansson_expr_parse(json_t *root);
union nft_data_reg;
-int nft_jansson_data_reg_parse(json_t *root, const char *tag,
+int nft_jansson_data_reg_parse(json_t *root, const char *node_name,
union nft_data_reg *data_reg);
struct nft_set_elem;
int nft_set_elem_json_parse(struct nft_set_elem *e, json_t *root);
diff --git a/src/jansson.c b/src/jansson.c
index 04146e2..539f9ab 100644
--- a/src/jansson.c
+++ b/src/jansson.c
@@ -23,12 +23,12 @@
#ifdef JSON_PARSING
-static int nft_jansson_load_int_node(json_t *root, const char *tag,
+static int nft_jansson_load_int_node(json_t *root, const char *node_name,
json_int_t *val)
{
json_t *node;
- node = json_object_get(root, tag);
+ node = json_object_get(root, node_name);
if (node == NULL) {
errno = EINVAL;
return -1;
@@ -43,12 +43,12 @@ static int nft_jansson_load_int_node(json_t *root, const char *tag,
return 0;
}
-const char *nft_jansson_parse_str(json_t *root, const char *tag)
+const char *nft_jansson_parse_str(json_t *root, const char *node_name)
{
json_t *node;
const char *val;
- node = json_object_get(root, tag);
+ node = json_object_get(root, node_name);
if (node == NULL) {
errno = EINVAL;
return NULL;
@@ -58,11 +58,12 @@ const char *nft_jansson_parse_str(json_t *root, const char *tag)
return val;
}
-int nft_jansson_parse_val(json_t *root, const char *tag, int type, void *out)
+int nft_jansson_parse_val(json_t *root, const char *node_name, int type,
+ void *out)
{
json_int_t val;
- if (nft_jansson_load_int_node(root, tag, &val) == -1)
+ if (nft_jansson_load_int_node(root, node_name, &val) == -1)
return -1;
if (nft_get_value(type, &val, out) == -1)
@@ -71,9 +72,9 @@ int nft_jansson_parse_val(json_t *root, const char *tag, int type, void *out)
return 0;
}
-bool nft_jansson_node_exist(json_t *root, const char *tag)
+bool nft_jansson_node_exist(json_t *root, const char *node_name)
{
- return json_object_get(root, tag) != NULL;
+ return json_object_get(root, node_name) != NULL;
}
json_t *nft_jansson_create_root(const char *json, json_error_t *err)
@@ -89,11 +90,11 @@ json_t *nft_jansson_create_root(const char *json, json_error_t *err)
return root;
}
-json_t *nft_jansson_get_node(json_t *root, const char *tag)
+json_t *nft_jansson_get_node(json_t *root, const char *node_name)
{
json_t *node;
- node = json_object_get(root, tag);
+ node = json_object_get(root, node_name);
if (node == NULL) {
errno = EINVAL;
return NULL;
@@ -126,9 +127,10 @@ int nft_jansson_parse_family(json_t *root, void *out)
return 0;
}
-int nft_jansson_parse_reg(json_t *root, const char *tag, int type, void *out)
+int nft_jansson_parse_reg(json_t *root, const char *node_name, int type,
+ void *out)
{
- if (nft_jansson_parse_val(root, tag, type, out) < 0)
+ if (nft_jansson_parse_val(root, node_name, type, out) < 0)
return -1;
if (*((uint32_t *)out) > NFT_REG_MAX){
@@ -139,12 +141,12 @@ int nft_jansson_parse_reg(json_t *root, const char *tag, int type, void *out)
return 0;
}
-int nft_jansson_str2num(json_t *root, const char *tag, int base,
+int nft_jansson_str2num(json_t *root, const char *node_name, int base,
void *out, enum nft_type type)
{
const char *str;
- str = nft_jansson_parse_str(root, tag);
+ str = nft_jansson_parse_str(root, node_name);
if (str == NULL)
return -1;
@@ -170,14 +172,14 @@ struct nft_rule_expr *nft_jansson_expr_parse(json_t *root)
return ret < 0 ? NULL : e;
}
-int nft_jansson_data_reg_parse(json_t *root, const char *tag,
+int nft_jansson_data_reg_parse(json_t *root, const char *node_name,
union nft_data_reg *data_reg)
{
json_t *data;
const char *type;
int ret;
- data = json_object_get(root, tag);
+ data = json_object_get(root, node_name);
if (data == NULL) {
errno = EINVAL;
return -1;
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2013-12-31 11:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-31 11:27 Alvaro Neira [this message]
2013-12-31 11:27 ` [libnftables PATCH 2/2] src: new error reporting approach for XML/JSON parsers Alvaro Neira
2014-01-04 0:42 ` Pablo Neira Ayuso
2013-12-31 18:59 ` [libnftables PATCH 1/2] src: rename the parameter tag to node_name in jansson function Arturo Borrero Gonzalez
2014-01-03 23:32 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131231112747.11095.53072.stgit@Ph0enix \
--to=alvaroneay@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).