xref: /PHP-7.4/ext/standard/php_var.h (revision 1806ce9c)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 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: Jani Lehtimäki <jkl@njet.net>                                |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_VAR_H
20 #define PHP_VAR_H
21 
22 #include "ext/standard/basic_functions.h"
23 #include "zend_smart_str_public.h"
24 
25 PHP_MINIT_FUNCTION(var);
26 PHP_FUNCTION(var_dump);
27 PHP_FUNCTION(var_export);
28 PHP_FUNCTION(debug_zval_dump);
29 PHP_FUNCTION(serialize);
30 PHP_FUNCTION(unserialize);
31 PHP_FUNCTION(memory_get_usage);
32 PHP_FUNCTION(memory_get_peak_usage);
33 
34 PHPAPI void php_var_dump(zval *struc, int level);
35 PHPAPI void php_var_export(zval *struc, int level);
36 PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf);
37 
38 PHPAPI void php_debug_zval_dump(zval *struc, int level);
39 
40 typedef struct php_serialize_data *php_serialize_data_t;
41 typedef struct php_unserialize_data *php_unserialize_data_t;
42 
43 PHPAPI void php_var_serialize(smart_str *buf, zval *struc, php_serialize_data_t *data);
44 PHPAPI int php_var_unserialize(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
45 PHPAPI int php_var_unserialize_ref(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
46 PHPAPI int php_var_unserialize_intern(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
47 
48 PHPAPI php_serialize_data_t php_var_serialize_init(void);
49 PHPAPI void php_var_serialize_destroy(php_serialize_data_t d);
50 PHPAPI php_unserialize_data_t php_var_unserialize_init(void);
51 PHPAPI void php_var_unserialize_destroy(php_unserialize_data_t d);
52 PHPAPI HashTable *php_var_unserialize_get_allowed_classes(php_unserialize_data_t d);
53 PHPAPI void php_var_unserialize_set_allowed_classes(php_unserialize_data_t d, HashTable *classes);
54 PHPAPI void php_var_unserialize_set_max_depth(php_unserialize_data_t d, zend_long max_depth);
55 PHPAPI zend_long php_var_unserialize_get_max_depth(php_unserialize_data_t d);
56 PHPAPI void php_var_unserialize_set_cur_depth(php_unserialize_data_t d, zend_long cur_depth);
57 PHPAPI zend_long php_var_unserialize_get_cur_depth(php_unserialize_data_t d);
58 
59 #define PHP_VAR_SERIALIZE_INIT(d) \
60 	(d) = php_var_serialize_init()
61 
62 #define PHP_VAR_SERIALIZE_DESTROY(d) \
63 	php_var_serialize_destroy(d)
64 
65 #define PHP_VAR_UNSERIALIZE_INIT(d) \
66 	(d) = php_var_unserialize_init()
67 
68 #define PHP_VAR_UNSERIALIZE_DESTROY(d) \
69 	php_var_unserialize_destroy(d)
70 
71 PHPAPI void var_replace(php_unserialize_data_t *var_hash, zval *ozval, zval *nzval);
72 PHPAPI void var_push_dtor(php_unserialize_data_t *var_hash, zval *val);
73 PHPAPI zval *var_tmp_var(php_unserialize_data_t *var_hashx);
74 PHPAPI void var_destroy(php_unserialize_data_t *var_hash);
75 
76 #endif /* PHP_VAR_H */
77