diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-02-06 18:48:28 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-02-06 18:48:28 +0300 |
commit | 01ad5162b27b29fd0bfe5b862a1a719ba4870e0a (patch) | |
tree | 95149a7c9f84a7fd6c1499dbb8933652edcd6b16 /blobmsg.h | |
parent | be416140606328d677283247553c122314e8ce8f (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.h | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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); \ |