xref: /PHP-5.4/ext/json/JSON_parser.h (revision b7903f97)
1 /* JSON_parser.h */
2 
3 #ifndef JSON_PARSER_H
4 #define JSON_PARSER_H
5 
6 #include "php.h"
7 #include "ext/standard/php_smart_str.h"
8 #include "php_json.h"
9 
10 #define JSON_PARSER_DEFAULT_DEPTH 512
11 
12 typedef struct JSON_parser_struct {
13     int state;
14     int depth;
15     int top;
16 	int error_code;
17     int* stack;
18     zval **the_zstack;
19     zval *the_static_zstack[JSON_PARSER_DEFAULT_DEPTH];
20 } * JSON_parser;
21 
22 enum error_codes {
23 	PHP_JSON_ERROR_NONE = 0,
24     PHP_JSON_ERROR_DEPTH,
25     PHP_JSON_ERROR_STATE_MISMATCH,
26     PHP_JSON_ERROR_CTRL_CHAR,
27     PHP_JSON_ERROR_SYNTAX,
28     PHP_JSON_ERROR_UTF8
29 };
30 
31 extern JSON_parser new_JSON_parser(int depth);
32 extern int parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int options TSRMLS_DC);
33 extern int free_JSON_parser(JSON_parser jp);
34 
parse_JSON(JSON_parser jp,zval * z,unsigned short utf16_json[],int length,int assoc TSRMLS_DC)35 static inline int parse_JSON(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int assoc TSRMLS_DC)
36 {
37 	return parse_JSON_ex(jp, z, utf16_json, length, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0 TSRMLS_CC);
38 }
39 
40 #endif
41