php_json_scanner.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef PHP_JSON_SCANNER_H
  17. #define PHP_JSON_SCANNER_H
  18. #include "php.h"
  19. #include "php_json.h"
  20. typedef unsigned char php_json_ctype;
  21. typedef struct _php_json_scanner {
  22. php_json_ctype *cursor; /* cursor position */
  23. php_json_ctype *token; /* token position */
  24. php_json_ctype *limit; /* the last read character + 1 position */
  25. php_json_ctype *marker; /* marker position for backtracking */
  26. php_json_ctype *ctxmarker; /* marker position for context backtracking */
  27. php_json_ctype *str_start; /* start position of the string */
  28. php_json_ctype *pstr; /* string pointer for escapes conversion */
  29. zval value; /* value */
  30. int str_esc; /* number of extra characters for escaping */
  31. int state; /* condition state */
  32. int options; /* options */
  33. php_json_error_code errcode; /* error type if there is an error */
  34. int utf8_invalid; /* whether utf8 is invalid */
  35. int utf8_invalid_count; /* number of extra character for invalid utf8 */
  36. } php_json_scanner;
  37. void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);
  38. int php_json_scan(php_json_scanner *s);
  39. #endif /* PHP_JSON_SCANNER_H */