xref: /PHP-8.3/ext/json/php_json_scanner.h (revision 01b3fc03)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Author: Jakub Zelenka <bukka@php.net>                                |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_JSON_SCANNER_H
18 #define	PHP_JSON_SCANNER_H
19 
20 #include "php.h"
21 #include "php_json.h"
22 
23 typedef unsigned char php_json_ctype;
24 
25 typedef struct _php_json_scanner {
26 	php_json_ctype *cursor;         /* cursor position */
27 	php_json_ctype *token;          /* token position */
28 	php_json_ctype *limit;          /* the last read character + 1 position */
29 	php_json_ctype *marker;         /* marker position for backtracking */
30 	php_json_ctype *ctxmarker;      /* marker position for context backtracking */
31 	php_json_ctype *str_start;      /* start position of the string */
32 	php_json_ctype *pstr;           /* string pointer for escapes conversion */
33 	zval value;                     /* value */
34 	int str_esc;                    /* number of extra characters for escaping */
35 	int state;                      /* condition state */
36 	int options;                    /* options */
37 	php_json_error_code errcode;    /* error type if there is an error */
38 	int utf8_invalid;               /* whether utf8 is invalid */
39 	int utf8_invalid_count;         /* number of extra character for invalid utf8 */
40 } php_json_scanner;
41 
42 
43 void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);
44 int php_json_scan(php_json_scanner *s);
45 
46 #endif	/* PHP_JSON_SCANNER_H */
47