diff options
author | thiagoftsm <49162938+thiagoftsm@users.noreply.github.com> | 2019-06-27 08:16:28 -0300 |
---|---|---|
committer | Paul Emm. Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com> | 2019-06-27 13:16:28 +0200 |
commit | 60a73e90de2aa1c2eaae2ebbc45dd1fb96034df2 (patch) | |
tree | 3729a7e43a2a9e6395fc85f2a2cd74b833e414a8 /libnetdata/json/jsmn.h | |
parent | 6fc971fe4d070d7c3e666ee24fb0c43d43084c85 (diff) |
Easily disable alarms, by persisting the silencers configuration (#6274)
* Alarms begin!
* Alarms web interface comments!
* Alarms web interface comments 2!
* Alarms bringing Christopher work!
* Alarms bringing Christopher work!
* Alarms commenting code that will be rewritten!
* Alarms json-c begin!
* Alarms json-c end!
* Alarms missed script!
* Alarms fix json-c parser and change script to test LIST!
* Alarms fix test script!
* Alarms documentation!
* Alarms script step 1!
* Alarms fix script!
* Alarms fix testing script and code!
* Alarms missing arguments to pkg_check_modules
* SSL_backend indentation!
* Alarms, description in Makefile
* Alarms missing extern!
* Alarms compilation!
* Alarms libnetdata/health!
* Alarms fill library!
* Alarms fill CMakeList!
* Alarm fix version!
* Alarm remove readme!
* Alarm fix readme version!
Diffstat (limited to 'libnetdata/json/jsmn.h')
-rw-r--r-- | libnetdata/json/jsmn.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libnetdata/json/jsmn.h b/libnetdata/json/jsmn.h new file mode 100644 index 0000000000..beff586c66 --- /dev/null +++ b/libnetdata/json/jsmn.h @@ -0,0 +1,75 @@ +#ifndef __JSMN_H_ +#define __JSMN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stddef.h> +/** + * JSON type identifier. Basic types are: + * o Object + * o Array + * o String + * o Other primitive: number, boolean (true/false) or null + */ +typedef enum { + JSMN_PRIMITIVE = 0, + JSMN_OBJECT = 1, + JSMN_ARRAY = 2, + JSMN_STRING = 3 +} jsmntype_t; + +typedef enum { + /* Not enough tokens were provided */ + JSMN_ERROR_NOMEM = -1, + /* Invalid character inside JSON string */ + JSMN_ERROR_INVAL = -2, + /* The string is not a full JSON packet, more bytes expected */ + JSMN_ERROR_PART = -3, +} jsmnerr_t; + +/** + * JSON token description. + * + * @param type type (object, array, string etc.) + * @param start start position in JSON data string + * @param end end position in JSON data string + */ +typedef struct { + jsmntype_t type; + int start; + int end; + int size; +#ifdef JSMN_PARENT_LINKS + int parent; +#endif +} jsmntok_t; + +/** + * JSON parser. Contains an array of token blocks available. Also stores + * the string being parsed now and current position in that string + */ +typedef struct { + unsigned int pos; /* offset in the JSON string */ + unsigned int toknext; /* next token to allocate */ + int toksuper; /* superior token node, e.g parent object or array */ +} jsmn_parser; + +/** + * Create JSON parser over an array of tokens + */ +void jsmn_init(jsmn_parser *parser); + +/** + * Run JSON parser. It parses a JSON data string into and array of tokens, each describing + * a single JSON object. + */ +jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, unsigned int num_tokens); + +#ifdef __cplusplus +} +#endif + +#endif /* __JSMN_H_ */
\ No newline at end of file |