diff options
author | Dario Lombardo <lomato@gmail.com> | 2018-04-20 16:55:00 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-04-21 07:13:31 +0000 |
commit | 57fee051c6a37ab152d303be4d156c8e5c64b36a (patch) | |
tree | 68bc4d1d14e3a1cb4ce738018cabb2a83febe696 /wsutil/wsjson.h | |
parent | 119a497652d2436824a733c0c853dbdc80aaf9eb (diff) |
wsutil: rename wsjsmn to wsjson.
This puts more distance between the caller and the underlying
library. At the moment we're using libjsmn, but other libraries
(like json-glib) could be used.
Change-Id: I1431424a998fc8188ad47b71d6d95afdc92a3f9e
Reviewed-on: https://code.wireshark.org/review/27055
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil/wsjson.h')
-rw-r--r-- | wsutil/wsjson.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/wsutil/wsjson.h b/wsutil/wsjson.h new file mode 100644 index 0000000000..e55f6a991d --- /dev/null +++ b/wsutil/wsjson.h @@ -0,0 +1,54 @@ +/* wsjson.h + * Utility to check if a payload is json using libjsmn + * + * Copyright 2016, Dario Lombardo + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __WSJSON_H__ +#define __WSJSON_H__ + +#include "ws_symbol_export.h" +#include <glib.h> + +#include "jsmn.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check if a buffer is json an returns true if it is. + */ +WS_DLL_PUBLIC gboolean jsmn_is_json(const guint8* buf, const size_t len); + +WS_DLL_PUBLIC int wsjson_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens); + +/** + * Try to unescape input JSON string. output can be the same pointer as input, or must have the same buffer size as input. + */ +WS_DLL_PUBLIC gboolean wsjson_unescape_json_string(const char *input, char *output); + +#ifdef __cplusplus +} +#endif + +#endif + +/* + * Editor modelines - https://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=4 tabstop=8 noexpandtab: + * :indentSize=4:tabSize=8:noTabs=false: + */ |