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 /sharkd_session.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 'sharkd_session.c')
-rw-r--r-- | sharkd_session.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/sharkd_session.c b/sharkd_session.c index 79f266d239..dea7d9bc9a 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -79,12 +79,6 @@ struct sharkd_filter_item static GHashTable *filter_table = NULL; -static gboolean -json_unescape_str(char *input) -{ - return wsjson_unescape_json_string(input, input); -} - static const char * json_find_attr(const char *buf, const jsmntok_t *tokens, int count, const char *attr) { @@ -4321,7 +4315,7 @@ sharkd_session_process(char *buf, const jsmntok_t *tokens, int count) buf[tokens[i + 1].end] = '\0'; /* unescape only value, as keys are simple strings */ - if (tokens[i + 1].type == JSMN_STRING && !json_unescape_str(&buf[tokens[i + 1].start])) + if (tokens[i + 1].type == JSMN_STRING && !json_decode_string_inplace(&buf[tokens[i + 1].start])) { fprintf(stderr, "sanity check(3b): [%d] cannot unescape string\n", i + 1); return; @@ -4416,7 +4410,7 @@ sharkd_session_main(void) /* every command is line seperated JSON */ int ret; - ret = wsjson_parse(buf, NULL, 0); + ret = json_parse(buf, NULL, 0); if (ret < 0) { fprintf(stderr, "invalid JSON -> closing\n"); @@ -4434,7 +4428,7 @@ sharkd_session_main(void) memset(tokens, 0, ret * sizeof(jsmntok_t)); - ret = wsjson_parse(buf, tokens, ret); + ret = json_parse(buf, tokens, ret); if (ret < 0) { fprintf(stderr, "invalid JSON(2) -> closing\n"); |