php_json_parser.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Jakub Zelenka <bukka@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef PHP_JSON_PARSER_H
  19. #define PHP_JSON_PARSER_H
  20. #include "php.h"
  21. #include "php_json_scanner.h"
  22. typedef struct _php_json_parser php_json_parser;
  23. typedef int (*php_json_parser_func_array_create_t)(
  24. php_json_parser *parser, zval *array);
  25. typedef int (*php_json_parser_func_array_append_t)(
  26. php_json_parser *parser, zval *array, zval *zvalue);
  27. typedef int (*php_json_parser_func_array_start_t)(
  28. php_json_parser *parser);
  29. typedef int (*php_json_parser_func_array_end_t)(
  30. php_json_parser *parser, zval *object);
  31. typedef int (*php_json_parser_func_object_create_t)(
  32. php_json_parser *parser, zval *object);
  33. typedef int (*php_json_parser_func_object_update_t)(
  34. php_json_parser *parser, zval *object, zend_string *key, zval *zvalue);
  35. typedef int (*php_json_parser_func_object_start_t)(
  36. php_json_parser *parser);
  37. typedef int (*php_json_parser_func_object_end_t)(
  38. php_json_parser *parser, zval *object);
  39. typedef struct _php_json_parser_methods {
  40. php_json_parser_func_array_create_t array_create;
  41. php_json_parser_func_array_append_t array_append;
  42. php_json_parser_func_array_start_t array_start;
  43. php_json_parser_func_array_end_t array_end;
  44. php_json_parser_func_object_create_t object_create;
  45. php_json_parser_func_object_update_t object_update;
  46. php_json_parser_func_object_start_t object_start;
  47. php_json_parser_func_object_end_t object_end;
  48. } php_json_parser_methods;
  49. struct _php_json_parser {
  50. php_json_scanner scanner;
  51. zval *return_value;
  52. int depth;
  53. int max_depth;
  54. php_json_parser_methods methods;
  55. };
  56. PHP_JSON_API void php_json_parser_init_ex(
  57. php_json_parser *parser,
  58. zval *return_value,
  59. char *str,
  60. size_t str_len,
  61. int options,
  62. int max_depth,
  63. const php_json_parser_methods *methods);
  64. PHP_JSON_API void php_json_parser_init(
  65. php_json_parser *parser,
  66. zval *return_value,
  67. char *str,
  68. size_t str_len,
  69. int options,
  70. int max_depth);
  71. PHP_JSON_API php_json_error_code php_json_parser_error_code(const php_json_parser *parser);
  72. PHP_JSON_API int php_json_parse(php_json_parser *parser);
  73. int php_json_yyparse(php_json_parser *parser);
  74. #endif /* PHP_JSON_PARSER_H */