diff options
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 4cedb9e..97567db 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -90,6 +90,30 @@ int nft_buf_close(struct nft_buf *b, int type, const char *tag) } } +int nft_buf_open_array(struct nft_buf *b, int type, const char *tag) +{ + switch (type) { + case NFT_OUTPUT_JSON: + return nft_buf_put(b, "{\"%s\":[", tag); + case NFT_OUTPUT_XML: + return nft_buf_put(b, "<%s>", tag); + default: + return 0; + } +} + +int nft_buf_close_array(struct nft_buf *b, int type, const char *tag) +{ + switch (type) { + case NFT_OUTPUT_JSON: + return nft_buf_put(b, "]}"); + case NFT_OUTPUT_XML: + return nft_buf_put(b, "</%s>", tag); + default: + return 0; + } +} + int nft_buf_u32(struct nft_buf *b, int type, uint32_t value, const char *tag) { switch (type) { |