Wireshark  4.3.0
The Wireshark network protocol analyzer
jsmn.h
Go to the documentation of this file.
1 
24 #ifndef __JSMN_H_
25 #define __JSMN_H_
26 
27 #include <stddef.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
40 typedef enum {
41  JSMN_UNDEFINED = 0,
42  JSMN_OBJECT = 1,
43  JSMN_ARRAY = 2,
44  JSMN_STRING = 3,
45  JSMN_PRIMITIVE = 4
46 } jsmntype_t;
47 
48 enum jsmnerr {
49  /* Not enough tokens were provided */
50  JSMN_ERROR_NOMEM = -1,
51  /* Invalid character inside JSON string */
52  JSMN_ERROR_INVAL = -2,
53  /* The string is not a full JSON packet, more bytes expected */
54  JSMN_ERROR_PART = -3
55 };
56 
63 typedef struct {
64  jsmntype_t type;
65  int start;
66  int end;
67  int size;
68 #ifdef JSMN_PARENT_LINKS
69  int parent;
70 #endif
71 } jsmntok_t;
72 
77 typedef struct {
78  unsigned int pos; /* offset in the JSON string */
79  unsigned int toknext; /* next token to allocate */
80  int toksuper; /* superior token node, e.g parent object or array */
81 } jsmn_parser;
82 
86 void jsmn_init(jsmn_parser *parser);
87 
92 int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
93  jsmntok_t *tokens, unsigned int num_tokens);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* __JSMN_H_ */
jsmntype_t
Definition: jsmn.h:40
int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Definition: jsmn.c:173
void jsmn_init(jsmn_parser *parser)
Definition: jsmn.c:328
Definition: jsmn.h:77
Definition: jsmn.h:63