Linux Perf
jsmn.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0 */
2
#ifndef __JSMN_H_
3
#define __JSMN_H_
4
5
/*
6
* JSON type identifier. Basic types are:
7
* o Object
8
* o Array
9
* o String
10
* o Other primitive: number, boolean (true/false) or null
11
*/
12
typedef
enum
{
13
JSMN_PRIMITIVE
= 0,
14
JSMN_OBJECT
= 1,
15
JSMN_ARRAY
= 2,
16
JSMN_STRING
= 3
17
}
jsmntype_t
;
18
19
typedef
enum
{
20
/* Not enough tokens were provided */
21
JSMN_ERROR_NOMEM
= -1,
22
/* Invalid character inside JSON string */
23
JSMN_ERROR_INVAL
= -2,
24
/* The string is not a full JSON packet, more bytes expected */
25
JSMN_ERROR_PART
= -3,
26
/* Everything was fine */
27
JSMN_SUCCESS
= 0
28
}
jsmnerr_t
;
29
30
/*
31
* JSON token description.
32
* @param type type (object, array, string etc.)
33
* @param start start position in JSON data string
34
* @param end end position in JSON data string
35
*/
36
typedef
struct
{
37
jsmntype_t
type
;
38
int
start
;
39
int
end
;
40
int
size
;
41
}
jsmntok_t
;
42
43
/*
44
* JSON parser. Contains an array of token blocks available. Also stores
45
* the string being parsed now and current position in that string
46
*/
47
typedef
struct
{
48
unsigned
int
pos
;
/* offset in the JSON string */
49
int
toknext
;
/* next token to allocate */
50
int
toksuper
;
/* superior token node, e.g parent object or array */
51
}
jsmn_parser
;
52
53
/*
54
* Create JSON parser over an array of tokens
55
*/
56
void
jsmn_init
(
jsmn_parser
*
parser
);
57
58
/*
59
* Run JSON parser. It parses a JSON data string into and array of tokens,
60
* each describing a single JSON object.
61
*/
62
jsmnerr_t
jsmn_parse
(
jsmn_parser
*
parser
,
const
char
*js,
63
size_t
len,
64
jsmntok_t
*tokens,
unsigned
int
num_tokens);
65
66
const
char
*
jsmn_strerror
(
jsmnerr_t
err
);
67
68
#endif
/* __JSMN_H_ */
jsmntok_t
Definition:
jsmn.h:36
jsmntype_t
jsmntype_t
Definition:
jsmn.h:12
JSMN_ERROR_NOMEM
Definition:
jsmn.h:21
JSMN_SUCCESS
Definition:
jsmn.h:27
JSMN_STRING
Definition:
jsmn.h:16
err
int int err
Definition:
5sec.c:44
stackcollapse.parser
parser
Definition:
stackcollapse.py:55
JSMN_ERROR_PART
Definition:
jsmn.h:25
jsmn_strerror
const char * jsmn_strerror(jsmnerr_t err)
Definition:
jsmn.c:299
JSMN_OBJECT
Definition:
jsmn.h:14
jsmntok_t::type
jsmntype_t type
Definition:
jsmn.h:37
jsmn_parse
jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Definition:
jsmn.c:173
jsmn_parser
Definition:
jsmn.h:47
JSMN_PRIMITIVE
Definition:
jsmn.h:13
jsmn_init
void jsmn_init(jsmn_parser *parser)
Definition:
jsmn.c:292
jsmn_parser::toksuper
int toksuper
Definition:
jsmn.h:50
jsmntok_t::start
int start
Definition:
jsmn.h:38
JSMN_ARRAY
Definition:
jsmn.h:15
jsmntok_t::end
int end
Definition:
jsmn.h:39
jsmn_parser::toknext
int toknext
Definition:
jsmn.h:49
JSMN_ERROR_INVAL
Definition:
jsmn.h:23
jsmntok_t::size
int size
Definition:
jsmn.h:40
jsmn_parser::pos
unsigned int pos
Definition:
jsmn.h:48
jsmnerr_t
jsmnerr_t
Definition:
jsmn.h:19
pmu-events
jsmn.h
Generated by
1.8.13