root/ext/json/php_json.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ZEND_TSRMLS_CACHE_EXTERN

   1 /*
   2   +----------------------------------------------------------------------+
   3   | PHP Version 7                                                        |
   4   +----------------------------------------------------------------------+
   5   | Copyright (c) 1997-2016 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: Omar Kilani <omar@php.net>                                   |
  16   |         Jakub Zelenka <bukka@php.net>                                |
  17   +----------------------------------------------------------------------+
  18 */
  19 
  20 /* $Id$ */
  21 
  22 #ifndef PHP_JSON_H
  23 #define PHP_JSON_H
  24 
  25 #define PHP_JSON_VERSION "1.4.0"
  26 #include "zend_smart_str_public.h"
  27 
  28 extern zend_module_entry json_module_entry;
  29 #define phpext_json_ptr &json_module_entry
  30 
  31 #if defined(PHP_WIN32) && defined(JSON_EXPORTS)
  32 #define PHP_JSON_API __declspec(dllexport)
  33 #else
  34 #define PHP_JSON_API PHPAPI
  35 #endif
  36 
  37 #ifdef ZTS
  38 #include "TSRM.h"
  39 #endif
  40 
  41 extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
  42 
  43 /* error codes */
  44 typedef enum {
  45         PHP_JSON_ERROR_NONE = 0,
  46         PHP_JSON_ERROR_DEPTH,
  47         PHP_JSON_ERROR_STATE_MISMATCH,
  48         PHP_JSON_ERROR_CTRL_CHAR,
  49         PHP_JSON_ERROR_SYNTAX,
  50         PHP_JSON_ERROR_UTF8,
  51         PHP_JSON_ERROR_RECURSION,
  52         PHP_JSON_ERROR_INF_OR_NAN,
  53         PHP_JSON_ERROR_UNSUPPORTED_TYPE,
  54         PHP_JSON_ERROR_INVALID_PROPERTY_NAME,
  55         PHP_JSON_ERROR_UTF16
  56 } php_json_error_code;
  57 
  58 /* json_encode() options */
  59 #define PHP_JSON_HEX_TAG                 (1<<0)
  60 #define PHP_JSON_HEX_AMP                 (1<<1)
  61 #define PHP_JSON_HEX_APOS                (1<<2)
  62 #define PHP_JSON_HEX_QUOT                (1<<3)
  63 #define PHP_JSON_FORCE_OBJECT            (1<<4)
  64 #define PHP_JSON_NUMERIC_CHECK           (1<<5)
  65 #define PHP_JSON_UNESCAPED_SLASHES       (1<<6)
  66 #define PHP_JSON_PRETTY_PRINT            (1<<7)
  67 #define PHP_JSON_UNESCAPED_UNICODE       (1<<8)
  68 #define PHP_JSON_PARTIAL_OUTPUT_ON_ERROR (1<<9)
  69 #define PHP_JSON_PRESERVE_ZERO_FRACTION  (1<<10)
  70 
  71 /* json_decode() options */
  72 #define PHP_JSON_OBJECT_AS_ARRAY         (1<<0)
  73 #define PHP_JSON_BIGINT_AS_STRING        (1<<1)
  74 
  75 /* Internal flags */
  76 #define PHP_JSON_OUTPUT_ARRAY   0
  77 #define PHP_JSON_OUTPUT_OBJECT  1
  78 
  79 /* default depth */
  80 #define PHP_JSON_PARSER_DEFAULT_DEPTH 512
  81 
  82 ZEND_BEGIN_MODULE_GLOBALS(json)
  83         int encoder_depth;
  84         int encode_max_depth;
  85         php_json_error_code error_code;
  86 ZEND_END_MODULE_GLOBALS(json)
  87 
  88 PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS(json)
  89 #define JSON_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(json, v)
  90 
  91 #if defined(ZTS) && defined(COMPILE_DL_JSON)
  92 ZEND_TSRMLS_CACHE_EXTERN()
  93 #endif
  94 
  95 PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options);
  96 PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth);
  97 
  98 static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth)
  99 {
 100         php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth);
 101 }
 102 
 103 
 104 #endif  /* PHP_JSON_H */
 105 
 106 /*
 107  * Local variables:
 108  * tab-width: 4
 109  * c-basic-offset: 4
 110  * End:
 111  * vim600: noet sw=4 ts=4 fdm=marker
 112  * vim<600: noet sw=4 ts=4
 113  */

/* [<][>][^][v][top][bottom][index][help] */