summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorArturo Borrero <arturo.borrero.glez@gmail.com>2016-09-22 16:58:13 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-23 10:04:16 +0200
commit0758d102627744847d0bd2e4744d27695edb9a14 (patch)
treed8e004ddfba5ba10f63bd857dbf82f1834cdcf3d /src/buffer.c
parentf3bd67823b16fb7ef1ca4e4d93535f77eb0c2b53 (diff)
src: remove libmxml support
This patch removes the libmxml integration in libnftnl, since we have JSON in place and there is no need to support two at the same time. The JSON support is much better, for example libjansson has a better parsing error reporting. Moreover, libmxml 2.10 breaks the integration with libnftnl somehow, as reported in Debian bug #83870 [0]. Also, the XML support inside libnftnl has never been in good shape, with several tiny inconsitencies. [0] https://bugs.debian.org/838370 Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 57d3c0c..d97d517 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -62,10 +62,9 @@ static int nftnl_buf_put(struct nftnl_buf *b, const char *fmt, ...)
int nftnl_buf_open(struct nftnl_buf *b, int type, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>", tag);
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "{\"%s\":{", tag);
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -74,8 +73,6 @@ int nftnl_buf_open(struct nftnl_buf *b, int type, const char *tag)
int nftnl_buf_close(struct nftnl_buf *b, int type, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "</%s>", tag);
case NFTNL_OUTPUT_JSON:
/* Remove trailing comma in json */
if (b->size > 0 && b->buf[b->size - 1] == ',') {
@@ -85,6 +82,7 @@ int nftnl_buf_close(struct nftnl_buf *b, int type, const char *tag)
}
return nftnl_buf_put(b, "}}");
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -96,7 +94,6 @@ int nftnl_buf_open_array(struct nftnl_buf *b, int type, const char *tag)
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "{\"%s\":[", tag);
case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>", tag);
default:
return 0;
}
@@ -108,7 +105,6 @@ int nftnl_buf_close_array(struct nftnl_buf *b, int type, const char *tag)
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "]}");
case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "</%s>", tag);
default:
return 0;
}
@@ -117,10 +113,9 @@ int nftnl_buf_close_array(struct nftnl_buf *b, int type, const char *tag)
int nftnl_buf_u32(struct nftnl_buf *b, int type, uint32_t value, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>%u</%s>", tag, value, tag);
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "\"%s\":%u,", tag, value);
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -129,10 +124,9 @@ int nftnl_buf_u32(struct nftnl_buf *b, int type, uint32_t value, const char *tag
int nftnl_buf_s32(struct nftnl_buf *b, int type, uint32_t value, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>%d</%s>", tag, value, tag);
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "\"%s\":%d,", tag, value);
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -141,10 +135,9 @@ int nftnl_buf_s32(struct nftnl_buf *b, int type, uint32_t value, const char *tag
int nftnl_buf_u64(struct nftnl_buf *b, int type, uint64_t value, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>%"PRIu64"</%s>", tag, value, tag);
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "\"%s\":%"PRIu64",", tag, value);
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -153,10 +146,9 @@ int nftnl_buf_u64(struct nftnl_buf *b, int type, uint64_t value, const char *tag
int nftnl_buf_str(struct nftnl_buf *b, int type, const char *str, const char *tag)
{
switch (type) {
- case NFTNL_OUTPUT_XML:
- return nftnl_buf_put(b, "<%s>%s</%s>", tag, str, tag);
case NFTNL_OUTPUT_JSON:
return nftnl_buf_put(b, "\"%s\":\"%s\",", tag, str);
+ case NFTNL_OUTPUT_XML:
default:
return 0;
}
@@ -169,11 +161,7 @@ int nftnl_buf_reg(struct nftnl_buf *b, int type, union nftnl_data_reg *reg,
switch (type) {
case NFTNL_OUTPUT_XML:
- ret = nftnl_buf_put(b, "<%s>", tag);
- ret = nftnl_data_reg_snprintf(b->buf + b->off, b->len, reg,
- NFTNL_OUTPUT_XML, 0, reg_type);
- nftnl_buf_update(b, ret);
- return nftnl_buf_put(b, "</%s>", tag);
+ return 0;
case NFTNL_OUTPUT_JSON:
nftnl_buf_put(b, "\"%s\":{", tag);
ret = nftnl_data_reg_snprintf(b->buf + b->off, b->len, reg,