diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-11-19 15:52:30 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-11-20 05:03:26 +0000 |
commit | fb9c6905eff10f6f49a433ead8bd78e232fa068d (patch) | |
tree | 31154d39f805ba9527ad93a58f7dc7212799eef7 /wsutil/wsjson.c | |
parent | e2a5ad1febd5352563407ad13057ef82f7756d43 (diff) |
wsutil: rename some wsjson functions
Rename wsjson_unescape_json_string to json_decode_string_inplace
(inspired by the g_base64_decode_inplace name). Rename
wsjson_is_valid_json to json_validate (inspired by g_unichar_validate).
Ideally json_parse is inlined with its user (sharkd_session.c), but that
requires exporting the jsmn_init and jsmn_parse functions... Hence the
dependency on jsmn.h remains in wsjson.h.
Change-Id: I7ecfe3565f15516e9115cbd7e025362df2da5416
Reviewed-on: https://code.wireshark.org/review/30731
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil/wsjson.c')
-rw-r--r-- | wsutil/wsjson.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/wsutil/wsjson.c b/wsutil/wsjson.c index 9ede1aee1e..dd10832bfb 100644 --- a/wsutil/wsjson.c +++ b/wsutil/wsjson.c @@ -1,5 +1,5 @@ /* wsjson.c - * Utility to check if a payload is json using other libraries. + * JSON parsing functions. * * Copyright 2016, Dario Lombardo * @@ -24,7 +24,8 @@ #include <json-glib/json-glib.h> #endif -gboolean wsjson_is_valid_json(const guint8* buf, const size_t len) +gboolean +json_validate(const guint8 *buf, const size_t len) { gboolean ret = TRUE; #ifdef HAVE_JSONGLIB @@ -69,7 +70,8 @@ gboolean wsjson_is_valid_json(const guint8* buf, const size_t len) return ret; } -int wsjson_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens) +int +json_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens) { jsmn_parser p; @@ -77,8 +79,11 @@ int wsjson_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens) return jsmn_parse(&p, buf, strlen(buf), tokens, max_tokens); } -gboolean wsjson_unescape_json_string(const char *input, char *output) +gboolean +json_decode_string_inplace(char *text) { + const char *input = text; + char *output = text; while (*input) { char ch = *input++; |