My Project
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
src
global_controller
jsmn.h
Go to the documentation of this file.
1
/*
2
START OF LICENSE STUB
3
DeDOS: Declarative Dispersion-Oriented Software
4
Copyright (C) 2017 University of Pennsylvania, Georgetown University
5
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
END OF LICENSE STUB
19
*/
20
#ifndef __JSMN_H_
21
#define __JSMN_H_
22
23
#include <stddef.h>
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
30
38
typedef
enum
{
39
JSMN_UNDEFINED
= 0,
40
JSMN_OBJECT
= 1,
41
JSMN_ARRAY
= 2,
42
JSMN_STRING
= 3,
43
JSMN_PRIMITIVE
= 4
44
}
jsmntype_t
;
45
46
enum
jsmnerr
{
47
/* Not enough tokens were provided */
48
JSMN_ERROR_NOMEM
= -1,
49
/* Invalid character inside JSON string */
50
JSMN_ERROR_INVAL
= -2,
51
/* The string is not a full JSON packet, more bytes expected */
52
JSMN_ERROR_PART
= -3
53
};
54
61
typedef
struct
{
62
jsmntype_t
type
;
63
int
start
;
64
int
end
;
65
int
size
;
66
#ifdef JSMN_PARENT_LINKS
67
int
parent;
68
#endif
69
}
jsmntok_t
;
70
75
typedef
struct
{
76
unsigned
int
pos
;
/* offset in the JSON string */
77
unsigned
int
toknext
;
/* next token to allocate */
78
int
toksuper
;
/* superior token node, e.g parent object or array */
79
}
jsmn_parser
;
80
84
void
jsmn_init
(
jsmn_parser
*parser);
85
90
int
jsmn_parse
(
jsmn_parser
*parser,
const
char
*js,
size_t
len,
91
jsmntok_t
*
tokens
,
unsigned
int
num_tokens);
92
93
#ifdef __cplusplus
94
}
95
#endif
96
97
#endif
/* __JSMN_H_ */
jsmntok_t
JSON token description.
Definition:
jsmn.h:61
JSMN_STRING
Definition:
jsmn.h:42
JSMN_PRIMITIVE
Definition:
jsmn.h:43
jsmn_parser::toknext
unsigned int toknext
Definition:
jsmn.h:77
JSMN_ARRAY
Definition:
jsmn.h:41
jsmntype_t
jsmntype_t
JSON type identifier.
Definition:
jsmn.h:38
JSMN_ERROR_INVAL
Definition:
jsmn.h:50
JSMN_ERROR_PART
Definition:
jsmn.h:52
jsmntok_t::type
jsmntype_t type
Definition:
jsmn.h:62
jsmn_parser
JSON parser.
Definition:
jsmn.h:75
JSMN_ERROR_NOMEM
Definition:
jsmn.h:48
JSMN_OBJECT
Definition:
jsmn.h:40
jsmn_parser::toksuper
int toksuper
Definition:
jsmn.h:78
jsmntok_t::start
int start
Definition:
jsmn.h:63
jsmn_init
void jsmn_init(jsmn_parser *parser)
Create JSON parser over an array of tokens.
Definition:
jsmn.c:331
jsmntok_t::end
int end
Definition:
jsmn.h:64
jsmn_parse
int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Run JSON parser.
Definition:
jsmn.c:173
jsmntok_t::size
int size
Definition:
jsmn.h:65
jsmn_parser::pos
unsigned int pos
Definition:
jsmn.h:76
JSMN_UNDEFINED
Definition:
jsmn.h:39
tokens
static const char tokens[256]
Definition:
http_parser.c:208
jsmnerr
jsmnerr
Definition:
jsmn.h:46
Generated by
1.8.6