Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-02-06 18:48:28 +0300
committerFelix Fietkau <nbd@openwrt.org>2011-02-06 18:48:28 +0300
commit01ad5162b27b29fd0bfe5b862a1a719ba4870e0a (patch)
tree95149a7c9f84a7fd6c1499dbb8933652edcd6b16 /blobmsg.h
parentbe416140606328d677283247553c122314e8ce8f (diff)
add a callback to the blobmsg-to-json function to override the formatting of specific attributes
Diffstat (limited to 'blobmsg.h')
-rw-r--r--blobmsg.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/blobmsg.h b/blobmsg.h
index e51c39d..728f9e3 100644
--- a/blobmsg.h
+++ b/blobmsg.h
@@ -162,7 +162,18 @@ static inline uint64_t blobmsg_get_u64(struct blob_attr *attr)
void *blobmsg_alloc_string_buffer(struct blob_buf *buf, const char *name, int maxlen);
void blobmsg_add_string_buffer(struct blob_buf *buf);
-char *blobmsg_format_json(struct blob_attr *attr, bool list);
+/* blobmsg to json formatting */
+
+typedef const char *(*blobmsg_json_format_t)(void *priv, struct blob_attr *attr);
+
+char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list,
+ blobmsg_json_format_t cb, void *priv);
+
+static inline char *blobmsg_format_json(struct blob_attr *attr, bool list)
+{
+ return blobmsg_format_json_with_cb(attr, list, NULL, NULL);
+}
+
#define blobmsg_for_each_attr(pos, attr, rem) \
for (rem = blobmsg_data_len(attr), pos = blobmsg_data(attr); \