Delta Chat Core C-API
src
dc_jsmn.h
1
/*
2
Copyright (c) 2010 Serge A. Zaitsev
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
21
*/
22
23
#ifndef __JSMN_H_
24
#define __JSMN_H_
25
26
#include <stddef.h>
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
39
typedef
enum
{
40
JSMN_UNDEFINED = 0,
41
JSMN_OBJECT = 1,
42
JSMN_ARRAY = 2,
43
JSMN_STRING = 3,
44
JSMN_PRIMITIVE = 4
45
} jsmntype_t;
46
47
enum
jsmnerr {
48
/* Not enough tokens were provided */
49
JSMN_ERROR_NOMEM = -1,
50
/* Invalid character inside JSON string */
51
JSMN_ERROR_INVAL = -2,
52
/* The string is not a full JSON packet, more bytes expected */
53
JSMN_ERROR_PART = -3
54
};
55
62
typedef
struct
{
63
jsmntype_t type;
64
int
start;
65
int
end;
66
int
size;
67
#ifdef JSMN_PARENT_LINKS
68
int
parent;
69
#endif
70
} jsmntok_t;
71
76
typedef
struct
{
77
unsigned
int
pos;
/* offset in the JSON string */
78
unsigned
int
toknext;
/* next token to allocate */
79
int
toksuper;
/* superior token node, e.g parent object or array */
80
} jsmn_parser;
81
85
void
jsmn_init(jsmn_parser *parser);
86
91
int
jsmn_parse(jsmn_parser *parser,
const
char
*js,
size_t
len,
92
jsmntok_t *tokens,
unsigned
int
num_tokens);
93
94
#ifdef __cplusplus
95
}
96
#endif
97
98
#endif
/* __JSMN_H_ */
Generated by
1.8.17