1/*
2   +----------------------------------------------------------------------+
3   | Zend Engine                                                          |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
11   | If you did not receive a copy of the Zend license and are unable to  |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@zend.com so we can mail you a copy immediately.              |
14   +----------------------------------------------------------------------+
15   | Authors: Andi Gutmans <andi@zend.com>                                |
16   |          Zeev Suraski <zeev@zend.com>                                |
17   |          Andrei Zmievski <andrei@php.net>                            |
18   +----------------------------------------------------------------------+
19*/
20
21/* $Id$ */
22
23#ifndef ZEND_API_H
24#define ZEND_API_H
25
26#include "zend_modules.h"
27#include "zend_list.h"
28#include "zend_operators.h"
29#include "zend_variables.h"
30#include "zend_execute.h"
31
32
33BEGIN_EXTERN_C()
34
35typedef struct _zend_function_entry {
36    const char *fname;
37    void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
38    const struct _zend_internal_arg_info *arg_info;
39    uint32_t num_args;
40    uint32_t flags;
41} zend_function_entry;
42
43typedef struct _zend_fcall_info {
44    size_t size;
45    HashTable *function_table;
46    zval function_name;
47    zend_array *symbol_table;
48    zval *retval;
49    zval *params;
50    zend_object *object;
51    zend_bool no_separation;
52    uint32_t param_count;
53} zend_fcall_info;
54
55typedef struct _zend_fcall_info_cache {
56    zend_bool initialized;
57    zend_function *function_handler;
58    zend_class_entry *calling_scope;
59    zend_class_entry *called_scope;
60    zend_object *object;
61} zend_fcall_info_cache;
62
63#define ZEND_NS_NAME(ns, name)          ns "\\" name
64
65#define ZEND_FN(name) zif_##name
66#define ZEND_MN(name) zim_##name
67#define ZEND_NAMED_FUNCTION(name)       void name(INTERNAL_FUNCTION_PARAMETERS)
68#define ZEND_FUNCTION(name)             ZEND_NAMED_FUNCTION(ZEND_FN(name))
69#define ZEND_METHOD(classname, name)    ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
70
71#define ZEND_FENTRY(zend_name, name, arg_info, flags)   { #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
72
73#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags)   { zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
74#define ZEND_RAW_NAMED_FE(zend_name, name, arg_info) ZEND_RAW_FENTRY(#zend_name, name, arg_info, 0)
75
76#define ZEND_NAMED_FE(zend_name, name, arg_info)    ZEND_FENTRY(zend_name, name, arg_info, 0)
77#define ZEND_FE(name, arg_info)                     ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
78#define ZEND_DEP_FE(name, arg_info)                 ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
79#define ZEND_FALIAS(name, alias, arg_info)          ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
80#define ZEND_DEP_FALIAS(name, alias, arg_info)      ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
81#define ZEND_NAMED_ME(zend_name, name, arg_info, flags) ZEND_FENTRY(zend_name, name, arg_info, flags)
82#define ZEND_ME(classname, name, arg_info, flags)   ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags)
83#define ZEND_ABSTRACT_ME(classname, name, arg_info) ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
84#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
85                                                    ZEND_FENTRY(name, ZEND_MN(classname##_##alias), arg_info, flags)
86#define ZEND_ME_MAPPING(name, func_name, arg_types, flags) ZEND_NAMED_ME(name, ZEND_FN(func_name), arg_types, flags)
87
88#define ZEND_NS_FENTRY(ns, zend_name, name, arg_info, flags)        ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, #zend_name), name, arg_info, flags)
89
90#define ZEND_NS_RAW_FENTRY(ns, zend_name, name, arg_info, flags)    ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, zend_name), name, arg_info, flags)
91#define ZEND_NS_RAW_NAMED_FE(ns, zend_name, name, arg_info)         ZEND_NS_RAW_FENTRY(ns, #zend_name, name, arg_info, 0)
92
93#define ZEND_NS_NAMED_FE(ns, zend_name, name, arg_info) ZEND_NS_FENTRY(ns, zend_name, name, arg_info, 0)
94#define ZEND_NS_FE(ns, name, arg_info)                  ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, 0)
95#define ZEND_NS_DEP_FE(ns, name, arg_info)              ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
96#define ZEND_NS_FALIAS(ns, name, alias, arg_info)       ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, 0)
97#define ZEND_NS_DEP_FALIAS(ns, name, alias, arg_info)   ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
98
99#define ZEND_FE_END            { NULL, NULL, NULL, 0, 0 }
100
101#define ZEND_ARG_INFO(pass_by_ref, name)                             { #name, NULL, 0, pass_by_ref, 0, 0 },
102#define ZEND_ARG_PASS_INFO(pass_by_ref)                              { NULL,  NULL, 0, pass_by_ref, 0, 0 },
103#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null)  { #name, #classname, IS_OBJECT, pass_by_ref, allow_null, 0 },
104#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null)           { #name, NULL, IS_ARRAY, pass_by_ref, allow_null, 0 },
105#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, NULL, type_hint, pass_by_ref, allow_null, 0 },
106#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name)                    { #name, NULL, 0, pass_by_ref, 0, 1 },
107
108
109#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, class_name, allow_null) \
110    static const zend_internal_arg_info name[] = { \
111        { (const char*)(zend_uintptr_t)(required_num_args), class_name, type, return_reference, allow_null, 0 },
112#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, class_name, allow_null) \
113    ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, class_name, allow_null)
114
115#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)  \
116    static const zend_internal_arg_info name[] = { \
117        { (const char*)(zend_uintptr_t)(required_num_args), NULL, 0, return_reference, 0, 0 },
118#define ZEND_BEGIN_ARG_INFO(name, _unused)  \
119    ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, -1)
120#define ZEND_END_ARG_INFO()     };
121
122/* Name macros */
123#define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
124#define ZEND_MODULE_SHUTDOWN_N(module)      zm_shutdown_##module
125#define ZEND_MODULE_ACTIVATE_N(module)      zm_activate_##module
126#define ZEND_MODULE_DEACTIVATE_N(module)    zm_deactivate_##module
127#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)  zm_post_zend_deactivate_##module
128#define ZEND_MODULE_INFO_N(module)          zm_info_##module
129#define ZEND_MODULE_GLOBALS_CTOR_N(module)  zm_globals_ctor_##module
130#define ZEND_MODULE_GLOBALS_DTOR_N(module)  zm_globals_dtor_##module
131
132/* Declaration macros */
133#define ZEND_MODULE_STARTUP_D(module)       int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS)
134#define ZEND_MODULE_SHUTDOWN_D(module)      int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS)
135#define ZEND_MODULE_ACTIVATE_D(module)      int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
136#define ZEND_MODULE_DEACTIVATE_D(module)    int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
137#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module)  int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
138#define ZEND_MODULE_INFO_D(module)          void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
139#define ZEND_MODULE_GLOBALS_CTOR_D(module)  void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals)
140#define ZEND_MODULE_GLOBALS_DTOR_D(module)  void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals)
141
142#define ZEND_GET_MODULE(name) \
143    BEGIN_EXTERN_C()\
144    ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }\
145    END_EXTERN_C()
146
147#define ZEND_BEGIN_MODULE_GLOBALS(module_name)      \
148    typedef struct _zend_##module_name##_globals {
149#define ZEND_END_MODULE_GLOBALS(module_name)        \
150    } zend_##module_name##_globals;
151
152#ifdef ZTS
153
154#define ZEND_DECLARE_MODULE_GLOBALS(module_name)                            \
155    ts_rsrc_id module_name##_globals_id;
156#define ZEND_EXTERN_MODULE_GLOBALS(module_name)                             \
157    extern ts_rsrc_id module_name##_globals_id;
158#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)   \
159    ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
160
161#else
162
163#define ZEND_DECLARE_MODULE_GLOBALS(module_name)                            \
164    zend_##module_name##_globals module_name##_globals;
165#define ZEND_EXTERN_MODULE_GLOBALS(module_name)                             \
166    extern zend_##module_name##_globals module_name##_globals;
167#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)   \
168    globals_ctor(&module_name##_globals);
169
170#endif
171
172#define INIT_CLASS_ENTRY(class_container, class_name, functions) \
173    INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
174
175#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \
176    INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL)
177
178#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
179    {                                                           \
180        zend_string *cl_name;                                   \
181        cl_name = zend_string_init(class_name, class_name_len, 1);      \
182        class_container.name = zend_new_interned_string(cl_name);   \
183        INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
184    }
185
186#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
187    {                                                           \
188        class_container.constructor = NULL;                     \
189        class_container.destructor = NULL;                      \
190        class_container.clone = NULL;                           \
191        class_container.serialize = NULL;                       \
192        class_container.unserialize = NULL;                     \
193        class_container.create_object = NULL;                   \
194        class_container.interface_gets_implemented = NULL;      \
195        class_container.get_static_method = NULL;               \
196        class_container.__call = handle_fcall;                  \
197        class_container.__callstatic = NULL;                    \
198        class_container.__tostring = NULL;                      \
199        class_container.__get = handle_propget;                 \
200        class_container.__set = handle_propset;                 \
201        class_container.__unset = handle_propunset;             \
202        class_container.__isset = handle_propisset;             \
203        class_container.__debugInfo = NULL;                 \
204        class_container.serialize_func = NULL;                  \
205        class_container.unserialize_func = NULL;                \
206        class_container.serialize = NULL;                       \
207        class_container.unserialize = NULL;                     \
208        class_container.parent = NULL;                          \
209        class_container.num_interfaces = 0;                     \
210        class_container.traits = NULL;                          \
211        class_container.num_traits = 0;                         \
212        class_container.trait_aliases = NULL;                   \
213        class_container.trait_precedences = NULL;               \
214        class_container.interfaces = NULL;                      \
215        class_container.get_iterator = NULL;                    \
216        class_container.iterator_funcs.funcs = NULL;            \
217        class_container.info.internal.module = NULL;            \
218        class_container.info.internal.builtin_functions = functions;    \
219    }
220
221#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
222    INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)
223
224#define INIT_NS_CLASS_ENTRY(class_container, ns, class_name, functions) \
225    INIT_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions)
226#define INIT_OVERLOADED_NS_CLASS_ENTRY_EX(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
227    INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, ZEND_NS_NAME(ns, class_name), sizeof(ZEND_NS_NAME(ns, class_name))-1, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset)
228#define INIT_OVERLOADED_NS_CLASS_ENTRY(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset) \
229    INIT_OVERLOADED_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions, handle_fcall, handle_propget, handle_propset)
230
231#ifdef ZTS
232#   define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members_table:CG(static_members_table)[(zend_intptr_t)(ce)->static_members_table])
233#else
234#   define CE_STATIC_MEMBERS(ce) ((ce)->static_members_table)
235#endif
236
237#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
238
239ZEND_API int zend_next_free_module(void);
240
241BEGIN_EXTERN_C()
242ZEND_API int zend_get_parameters(int ht, int param_count, ...);
243ZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...);
244ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
245
246/* internal function to efficiently copy parameters when executing __call() */
247ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
248
249#define zend_get_parameters_array(ht, param_count, argument_array)          \
250    _zend_get_parameters_array_ex(param_count, argument_array)
251#define zend_get_parameters_array_ex(param_count, argument_array)           \
252    _zend_get_parameters_array_ex(param_count, argument_array)
253#define zend_parse_parameters_none()                                        \
254    zend_parse_parameters(ZEND_NUM_ARGS(), "")
255
256/* Parameter parsing API -- andrei */
257
258#define ZEND_PARSE_PARAMS_QUIET (1<<1)
259ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
260ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
261ZEND_API char *zend_zval_type_name(const zval *arg);
262
263ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
264ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...);
265
266ZEND_API int zend_parse_parameter(int flags, int arg_num, zval *arg, const char *spec, ...);
267
268/* End of parameter parsing API -- andrei */
269
270ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type);
271ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table);
272ZEND_API int zend_startup_module(zend_module_entry *module_entry);
273ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry);
274ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module);
275ZEND_API int zend_startup_module_ex(zend_module_entry *module);
276ZEND_API int zend_startup_modules(void);
277ZEND_API void zend_collect_module_handlers(void);
278ZEND_API void zend_destroy_modules(void);
279ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type);
280
281ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
282ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
283ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry);
284ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...);
285
286ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce);
287
288#define zend_register_class_alias(name, ce) \
289    zend_register_class_alias_ex(name, sizeof(name)-1, ce)
290#define zend_register_ns_class_alias(ns, name, ce) \
291    zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce)
292
293ZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
294ZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
295
296ZEND_API void zend_wrong_param_count(void);
297
298#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
299#define IS_CALLABLE_CHECK_NO_ACCESS   (1<<1)
300#define IS_CALLABLE_CHECK_IS_STATIC   (1<<2)
301#define IS_CALLABLE_CHECK_SILENT      (1<<3)
302
303#define IS_CALLABLE_STRICT  (IS_CALLABLE_CHECK_IS_STATIC)
304
305ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error);
306ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name);
307ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name);
308ZEND_API const char *zend_get_module_version(const char *module_name);
309ZEND_API int zend_get_module_started(const char *module_name);
310ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment);
311ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type);
312ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type);
313ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
314ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
315ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type);
316ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type);
317ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type);
318
319ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value);
320ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length);
321ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value);
322ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value);
323ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value);
324ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length);
325ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value);
326
327ZEND_API void zend_update_class_constants(zend_class_entry *class_type);
328ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value);
329ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length);
330ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
331ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
332ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value);
333ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value);
334ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value);
335ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length);
336
337ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
338ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
339ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
340ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
341ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value);
342ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
343ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length);
344
345ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
346
347ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
348
349ZEND_API char *zend_get_type_by_const(int type);
350
351#define getThis()                           (Z_OBJ(EX(This)) ? &EX(This) : NULL)
352#define ZEND_IS_METHOD_CALL()               (EX(func)->common.scope != NULL)
353
354#define WRONG_PARAM_COUNT                   ZEND_WRONG_PARAM_COUNT()
355#define WRONG_PARAM_COUNT_WITH_RETVAL(ret)  ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
356#define ARG_COUNT(dummy)                    EX_NUM_ARGS()
357#define ZEND_NUM_ARGS()                     EX_NUM_ARGS()
358#define ZEND_WRONG_PARAM_COUNT()                    { zend_wrong_param_count(); return; }
359#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)     { zend_wrong_param_count(); return ret; }
360
361#ifndef ZEND_WIN32
362#define DLEXPORT
363#endif
364
365#define array_init(arg)         _array_init((arg), 0 ZEND_FILE_LINE_CC)
366#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC)
367#define object_init(arg)        _object_init((arg) ZEND_FILE_LINE_CC)
368#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
369#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC)
370ZEND_API int _array_init(zval *arg, uint32_t size ZEND_FILE_LINE_DC);
371ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
372ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
373ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC);
374ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
375ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties);
376ZEND_API void object_properties_load(zend_object *object, HashTable *properties);
377
378ZEND_API void zend_merge_properties(zval *obj, HashTable *properties);
379
380/* no longer supported */
381ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
382
383ZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n);
384ZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len);
385ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b);
386ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
387ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d);
388ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
389ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
390ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length);
391ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
392
393#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
394#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
395#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
396#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r)
397#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
398#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
399#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
400#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
401#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
402
403/* unset() functions are only suported for legacy modules and null() functions should be used */
404#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
405#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
406#define add_next_index_unset(__arg) add_next_index_null(__arg)
407#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
408
409ZEND_API int add_index_long(zval *arg, zend_ulong idx, zend_long n);
410ZEND_API int add_index_null(zval *arg, zend_ulong idx);
411ZEND_API int add_index_bool(zval *arg, zend_ulong idx, int b);
412ZEND_API int add_index_resource(zval *arg, zend_ulong idx, zend_resource *r);
413ZEND_API int add_index_double(zval *arg, zend_ulong idx, double d);
414ZEND_API int add_index_str(zval *arg, zend_ulong idx, zend_string *str);
415ZEND_API int add_index_string(zval *arg, zend_ulong idx, const char *str);
416ZEND_API int add_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
417ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value);
418
419ZEND_API int add_next_index_long(zval *arg, zend_long n);
420ZEND_API int add_next_index_null(zval *arg);
421ZEND_API int add_next_index_bool(zval *arg, int b);
422ZEND_API int add_next_index_resource(zval *arg, zend_resource *r);
423ZEND_API int add_next_index_double(zval *arg, double d);
424ZEND_API int add_next_index_str(zval *arg, zend_string *str);
425ZEND_API int add_next_index_string(zval *arg, const char *str);
426ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length);
427ZEND_API int add_next_index_zval(zval *arg, zval *value);
428
429ZEND_API zval *add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str);
430ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length);
431
432#define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str)
433#define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
434
435ZEND_API zval *add_get_index_long(zval *arg, zend_ulong idx, zend_long l);
436ZEND_API zval *add_get_index_double(zval *arg, zend_ulong idx, double d);
437ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str);
438ZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str);
439ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
440
441ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value);
442
443ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l);
444ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len);
445ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b);
446ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
447ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d);
448ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
449ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
450ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len,  const char *str, size_t length);
451ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
452
453#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
454#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
455#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
456#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
457#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
458#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
459#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
460#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
461#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
462
463
464ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]);
465ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table);
466
467ZEND_API extern const zend_fcall_info empty_fcall_info;
468ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
469
470/** Build zend_call_info/cache from a zval*
471 *
472 * Caller is responsible to provide a return value, otherwise the we will crash.
473 * fci->retval_ptr_ptr = NULL;
474 * In order to pass parameters the following members need to be set:
475 * fci->param_count = 0;
476 * fci->params = NULL;
477 * The callable_name argument may be NULL.
478 * Set check_flags to IS_CALLABLE_STRICT for every new usage!
479 */
480ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error);
481
482/** Clear arguments connected with zend_fcall_info *fci
483 * If free_mem is not zero then the params array gets free'd as well
484 */
485ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem);
486
487/** Save current arguments from zend_fcall_info *fci
488 * params array will be set to NULL
489 */
490ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, int *param_count, zval **params);
491
492/** Free arguments connected with zend_fcall_info *fci andset back saved ones.
493 */
494ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count, zval *params);
495
496/** Set or clear the arguments in the zend_call_info struct taking care of
497 * refcount. If args is NULL and arguments are set then those are cleared.
498 */
499ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args);
500ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args);
501
502/** Set arguments in the zend_fcall_info struct taking care of refcount.
503 * If argc is 0 the arguments which are set will be cleared, else pass
504 * a variable amount of zval** arguments.
505 */
506ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci, int argc, zval *argv);
507
508/** Set arguments in the zend_fcall_info struct taking care of refcount.
509 * If argc is 0 the arguments which are set will be cleared, else pass
510 * a variable amount of zval** arguments.
511 */
512ZEND_API int zend_fcall_info_argv(zend_fcall_info *fci, int argc, va_list *argv);
513
514/** Set arguments in the zend_fcall_info struct taking care of refcount.
515 * If argc is 0 the arguments which are set will be cleared, else pass
516 * a variable amount of zval** arguments.
517 */
518ZEND_API int zend_fcall_info_argn(zend_fcall_info *fci, int argc, ...);
519
520/** Call a function using information created by zend_fcall_info_init()/args().
521 * If args is given then those replace the argument info in fci is temporarily.
522 */
523ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args);
524
525ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
526
527ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...);
528
529ZEND_API int zend_delete_global_variable(zend_string *name);
530
531ZEND_API zend_array *zend_rebuild_symbol_table(void);
532ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data);
533ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
534ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force);
535ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force);
536
537ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
538ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
539
540ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data);
541
542#define add_method(arg, key, method)    add_assoc_function((arg), (key), (method))
543
544ZEND_API ZEND_FUNCTION(display_disabled_function);
545ZEND_API ZEND_FUNCTION(display_disabled_class);
546END_EXTERN_C()
547
548#if ZEND_DEBUG
549#define CHECK_ZVAL_STRING(str) \
550    if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", (str)->val); }
551#define CHECK_ZVAL_STRING_REL(str) \
552    if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", (str)->val ZEND_FILE_LINE_RELAY_CC); }
553#else
554#define CHECK_ZVAL_STRING(z)
555#define CHECK_ZVAL_STRING_REL(z)
556#endif
557
558#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p)))
559#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
560
561#define ZVAL_STRINGL(z, s, l) do {              \
562        ZVAL_NEW_STR(z, zend_string_init(s, l, 0));     \
563    } while (0)
564
565#define ZVAL_STRING(z, s) do {                  \
566        const char *_s = (s);                   \
567        ZVAL_STRINGL(z, _s, strlen(_s));        \
568    } while (0)
569
570#define ZVAL_EMPTY_STRING(z) do {               \
571        ZVAL_INTERNED_STR(z, STR_EMPTY_ALLOC());        \
572    } while (0)
573
574#define ZVAL_PSTRINGL(z, s, l) do {             \
575        ZVAL_NEW_STR(z, zend_string_init(s, l, 1));     \
576    } while (0)
577
578#define ZVAL_PSTRING(z, s) do {                 \
579        const char *_s = (s);                   \
580        ZVAL_PSTRINGL(z, _s, strlen(_s));       \
581    } while (0)
582
583#define ZVAL_EMPTY_PSTRING(z) do {              \
584        ZVAL_PSTRINGL(z, "", 0);                \
585    } while (0)
586
587#define ZVAL_ZVAL(z, zv, copy, dtor) do {       \
588        zval *__z = (z);                        \
589        zval *__zv = (zv);                      \
590        if (EXPECTED(!Z_ISREF_P(__zv))) {       \
591            ZVAL_COPY_VALUE(__z, __zv);         \
592        } else {                                \
593            ZVAL_COPY_VALUE(__z,                \
594                Z_REFVAL_P(__zv));              \
595        }                                       \
596        if (copy) {                             \
597            zval_opt_copy_ctor(__z);            \
598        }                                       \
599        if (dtor) {                             \
600            if (!copy) {                        \
601                ZVAL_NULL(__zv);                \
602            }                                   \
603            zval_ptr_dtor(__zv);                \
604        }                                       \
605    } while (0)
606
607#define RETVAL_BOOL(b)                  ZVAL_BOOL(return_value, b)
608#define RETVAL_NULL()                   ZVAL_NULL(return_value)
609#define RETVAL_LONG(l)                  ZVAL_LONG(return_value, l)
610#define RETVAL_DOUBLE(d)                ZVAL_DOUBLE(return_value, d)
611#define RETVAL_STR(s)                   ZVAL_STR(return_value, s)
612#define RETVAL_LONG_STR(s)              ZVAL_INTERNED_STR(return_value, s)
613#define RETVAL_NEW_STR(s)               ZVAL_NEW_STR(return_value, s)
614#define RETVAL_STRING(s)                ZVAL_STRING(return_value, s)
615#define RETVAL_STRINGL(s, l)            ZVAL_STRINGL(return_value, s, l)
616#define RETVAL_EMPTY_STRING()           ZVAL_EMPTY_STRING(return_value)
617#define RETVAL_RES(r)                   ZVAL_RES(return_value, r)
618#define RETVAL_OBJ(r)                   ZVAL_OBJ(return_value, r)
619#define RETVAL_ZVAL(zv, copy, dtor)     ZVAL_ZVAL(return_value, zv, copy, dtor)
620#define RETVAL_FALSE                    ZVAL_FALSE(return_value)
621#define RETVAL_TRUE                     ZVAL_TRUE(return_value)
622
623#define RETURN_BOOL(b)                  { RETVAL_BOOL(b); return; }
624#define RETURN_NULL()                   { RETVAL_NULL(); return;}
625#define RETURN_LONG(l)                  { RETVAL_LONG(l); return; }
626#define RETURN_DOUBLE(d)                { RETVAL_DOUBLE(d); return; }
627#define RETURN_STR(s)                   { RETVAL_STR(s); return; }
628#define RETURN_LONG_STR(s)              { RETVAL_LONG_STR(s); return; }
629#define RETURN_NEW_STR(s)               { RETVAL_NEW_STR(s); return; }
630#define RETURN_STRING(s)                { RETVAL_STRING(s); return; }
631#define RETURN_STRINGL(s, l)            { RETVAL_STRINGL(s, l); return; }
632#define RETURN_EMPTY_STRING()           { RETVAL_EMPTY_STRING(); return; }
633#define RETURN_RES(r)                   { RETVAL_RES(r); return; }
634#define RETURN_OBJ(r)                   { RETVAL_OBJ(r); return; }
635#define RETURN_ZVAL(zv, copy, dtor)     { RETVAL_ZVAL(zv, copy, dtor); return; }
636#define RETURN_FALSE                    { RETVAL_FALSE; return; }
637#define RETURN_TRUE                     { RETVAL_TRUE; return; }
638
639#define RETVAL_ZVAL_FAST(z) do {      \
640    zval *_z = (z);                   \
641    if (Z_ISREF_P(_z)) {              \
642        RETVAL_ZVAL(_z, 1, 0);        \
643    } else {                          \
644        zval_ptr_dtor(return_value);  \
645        ZVAL_COPY(return_value, _z);  \
646    }                                 \
647} while (0)
648
649/* May be used in internal constructors to make them return NULL */
650#define ZEND_CTOR_MAKE_NULL() \
651    zend_ctor_make_null(execute_data)
652
653#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
654
655#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
656#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
657
658/* For compatibility */
659#define ZEND_MINIT          ZEND_MODULE_STARTUP_N
660#define ZEND_MSHUTDOWN      ZEND_MODULE_SHUTDOWN_N
661#define ZEND_RINIT          ZEND_MODULE_ACTIVATE_N
662#define ZEND_RSHUTDOWN      ZEND_MODULE_DEACTIVATE_N
663#define ZEND_MINFO          ZEND_MODULE_INFO_N
664#define ZEND_GINIT(module)      ((void (*)(void*))(ZEND_MODULE_GLOBALS_CTOR_N(module)))
665#define ZEND_GSHUTDOWN(module)  ((void (*)(void*))(ZEND_MODULE_GLOBALS_DTOR_N(module)))
666
667#define ZEND_MINIT_FUNCTION         ZEND_MODULE_STARTUP_D
668#define ZEND_MSHUTDOWN_FUNCTION     ZEND_MODULE_SHUTDOWN_D
669#define ZEND_RINIT_FUNCTION         ZEND_MODULE_ACTIVATE_D
670#define ZEND_RSHUTDOWN_FUNCTION     ZEND_MODULE_DEACTIVATE_D
671#define ZEND_MINFO_FUNCTION         ZEND_MODULE_INFO_D
672#define ZEND_GINIT_FUNCTION         ZEND_MODULE_GLOBALS_CTOR_D
673#define ZEND_GSHUTDOWN_FUNCTION     ZEND_MODULE_GLOBALS_DTOR_D
674
675/* Fast parameter parsing API */
676
677/* TODO: This API is experimental. It may be changed or removed ???
678 * It should be used only for really often used functions.
679 * (Keep the original parsing code and wrap usage with #ifndef FAST_ZPP)
680 */
681#define FAST_ZPP 1
682
683#ifdef FAST_ZPP
684
685#define Z_EXPECTED_TYPES(_) \
686    _(Z_EXPECTED_LONG,      "integer") \
687    _(Z_EXPECTED_BOOL,      "boolean") \
688    _(Z_EXPECTED_STRING,    "string") \
689    _(Z_EXPECTED_ARRAY,     "array") \
690    _(Z_EXPECTED_FUNC,      "valid callback") \
691    _(Z_EXPECTED_RESOURCE,  "resource") \
692    _(Z_EXPECTED_PATH,      "a valid path") \
693    _(Z_EXPECTED_OBJECT,    "object") \
694    _(Z_EXPECTED_DOUBLE,    "float")
695
696#define Z_EXPECTED_TYPE_ENUM(id, str) id,
697#define Z_EXPECTED_TYPE_STR(id, str)  str,
698
699typedef enum _zend_expected_type {
700    Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_ENUM)
701    Z_EXPECTED_LAST
702} zend_expected_type;
703
704ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args);
705ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg);
706ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg);
707ZEND_API void zend_wrong_callback_error(int severity, int num, char *error);
708
709#define ZPP_ERROR_OK             0
710#define ZPP_ERROR_FAILURE        1
711#define ZPP_ERROR_WRONG_CALLBACK 2
712#define ZPP_ERROR_WRONG_CLASS    3
713#define ZPP_ERROR_WRONG_ARG      4
714#define ZPP_ERROR_WRONG_COUNT    5
715
716#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
717        const int _flags = (flags); \
718        int _min_num_args = (min_num_args); \
719        int _max_num_args = (max_num_args); \
720        int _num_args = EX_NUM_ARGS(); \
721        int _i; \
722        zval *_real_arg, *_arg = NULL; \
723        zend_expected_type _expected_type = IS_UNDEF; \
724        char *_error = NULL; \
725        zend_bool _dummy; \
726        zend_bool _optional = 0; \
727        int error_code = ZPP_ERROR_OK; \
728        ((void)_i); \
729        ((void)_real_arg); \
730        ((void)_arg); \
731        ((void)_expected_type); \
732        ((void)_error); \
733        ((void)_dummy); \
734        ((void)_optional); \
735        \
736        do { \
737            if (UNEXPECTED(_num_args < _min_num_args) || \
738                (UNEXPECTED(_num_args > _max_num_args) && \
739                 EXPECTED(_max_num_args >= 0))) { \
740                if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
741                    zend_wrong_paramers_count_error(_num_args, _min_num_args, _max_num_args); \
742                } \
743                error_code = ZPP_ERROR_FAILURE; \
744                break; \
745            } \
746            _i = 0; \
747            _real_arg = ZEND_CALL_ARG(execute_data, 0);
748
749#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
750    ZEND_PARSE_PARAMETERS_START_EX(0, min_num_args, max_num_args)
751
752#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
753        } while (0); \
754        if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
755            if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
756                if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
757                    zend_wrong_callback_error(E_WARNING, _i, _error); \
758                } else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
759                    zend_wrong_paramer_class_error(_i, _error, _arg); \
760                } else if (error_code == ZPP_ERROR_WRONG_ARG) { \
761                    zend_wrong_paramer_type_error(_i, _expected_type, _arg); \
762                } \
763            } \
764            failure; \
765        } \
766    } while (0)
767
768#define ZEND_PARSE_PARAMETERS_END() \
769    ZEND_PARSE_PARAMETERS_END_EX(return)
770
771#define Z_PARAM_PROLOGUE(separate) \
772    ++_i; \
773    if (_optional) { \
774        if (UNEXPECTED(_i >_num_args)) break; \
775    } \
776    _real_arg++; \
777    _arg = _real_arg; \
778    ZVAL_DEREF(_arg); \
779    if (separate) { \
780        SEPARATE_ZVAL_NOREF(_arg); \
781    }
782
783/* old "|" */
784#define Z_PARAM_OPTIONAL \
785    _optional = 1;
786
787/* old "a" */
788#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \
789        Z_PARAM_PROLOGUE(separate); \
790        if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
791            _expected_type = Z_EXPECTED_ARRAY; \
792            error_code = ZPP_ERROR_WRONG_ARG; \
793            break; \
794        }
795
796#define Z_PARAM_ARRAY(dest) \
797    Z_PARAM_ARRAY_EX(dest, 0, 0)
798
799/* old "A" */
800#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \
801        Z_PARAM_PROLOGUE(separate); \
802        if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 1))) { \
803            _expected_type = Z_EXPECTED_ARRAY; \
804            error_code = ZPP_ERROR_WRONG_ARG; \
805            break; \
806        }
807
808#define Z_PARAM_ARRAY_OR_OBJECT(dest, check_null, separate) \
809    Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0)
810
811/* old "b" */
812#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
813        Z_PARAM_PROLOGUE(separate); \
814        if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
815            _expected_type = Z_EXPECTED_BOOL; \
816            error_code = ZPP_ERROR_WRONG_ARG; \
817            break; \
818        }
819
820#define Z_PARAM_BOOL(dest) \
821    Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
822
823/* old "C" */
824#define Z_PARAM_CLASS_EX(dest, check_null, separate) \
825        Z_PARAM_PROLOGUE(separate); \
826        if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \
827            error_code = ZPP_ERROR_FAILURE; \
828            break; \
829        }
830
831#define Z_PARAM_CLASS(dest) \
832    Z_PARAM_CLASS_EX(dest, 0, 0)
833
834/* old "d" */
835#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \
836        Z_PARAM_PROLOGUE(separate); \
837        if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
838            _expected_type = Z_EXPECTED_DOUBLE; \
839            error_code = ZPP_ERROR_WRONG_ARG; \
840            break; \
841        }
842
843#define Z_PARAM_DOUBLE(dest) \
844    Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0)
845
846/* old "f" */
847#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
848        Z_PARAM_PROLOGUE(separate); \
849        if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
850            if (!_error) { \
851                _expected_type = Z_EXPECTED_FUNC; \
852                error_code = ZPP_ERROR_WRONG_ARG; \
853                break; \
854            } else { \
855                error_code = ZPP_ERROR_WRONG_CALLBACK; \
856                break; \
857            } \
858        } else if (UNEXPECTED(_error != NULL)) { \
859            zend_wrong_callback_error(E_STRICT, _i, _error); \
860        }
861
862#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
863    Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
864
865/* old "h" */
866#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \
867        Z_PARAM_PROLOGUE(separate); \
868        if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0))) { \
869            _expected_type = Z_EXPECTED_ARRAY; \
870            error_code = ZPP_ERROR_WRONG_ARG; \
871            break; \
872        }
873
874#define Z_PARAM_ARRAY_HT(dest) \
875    Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
876
877/* old "H" */
878#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \
879        Z_PARAM_PROLOGUE(separate); \
880        if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1))) { \
881            _expected_type = Z_EXPECTED_ARRAY; \
882            error_code = ZPP_ERROR_WRONG_ARG; \
883            break; \
884        }
885
886#define Z_PARAM_ARRAY_OR_OBJECT_HT(dest) \
887    Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0)
888
889/* old "l" */
890#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \
891        Z_PARAM_PROLOGUE(separate); \
892        if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
893            _expected_type = Z_EXPECTED_LONG; \
894            error_code = ZPP_ERROR_WRONG_ARG; \
895            break; \
896        }
897
898#define Z_PARAM_LONG(dest) \
899    Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
900
901/* old "L" */
902#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
903        Z_PARAM_PROLOGUE(separate); \
904        if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
905            _expected_type = Z_EXPECTED_LONG; \
906            error_code = ZPP_ERROR_WRONG_ARG; \
907            break; \
908        }
909
910#define Z_PARAM_STRICT_LONG(dest) \
911    Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0)
912
913/* old "o" */
914#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \
915        Z_PARAM_PROLOGUE(separate); \
916        if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, NULL, check_null))) { \
917            _expected_type = Z_EXPECTED_OBJECT; \
918            error_code = ZPP_ERROR_WRONG_ARG; \
919            break; \
920        }
921
922#define Z_PARAM_OBJECT(dest) \
923    Z_PARAM_OBJECT_EX(dest, 0, 0)
924
925/* old "O" */
926#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \
927        Z_PARAM_PROLOGUE(separate); \
928        if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \
929            if (_ce) { \
930                _error = (_ce)->name->val; \
931                error_code = ZPP_ERROR_WRONG_CLASS; \
932                break; \
933            } else { \
934                _expected_type = Z_EXPECTED_OBJECT; \
935                error_code = ZPP_ERROR_WRONG_ARG; \
936                break; \
937            } \
938        }
939
940#define Z_PARAM_OBJECT_OF_CLASS(dest, _ce) \
941    Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 0, 0)
942
943/* old "p" */
944#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \
945        Z_PARAM_PROLOGUE(separate); \
946        if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \
947            _expected_type = Z_EXPECTED_PATH; \
948            error_code = ZPP_ERROR_WRONG_ARG; \
949            break; \
950        }
951
952#define Z_PARAM_PATH(dest, dest_len) \
953    Z_PARAM_PATH_EX(dest, dest_len, 0, 0)
954
955/* old "P" */
956#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \
957        Z_PARAM_PROLOGUE(separate); \
958        if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \
959            _expected_type = Z_EXPECTED_PATH; \
960            error_code = ZPP_ERROR_WRONG_ARG; \
961            break; \
962        }
963
964#define Z_PARAM_PATH_STR(dest) \
965    Z_PARAM_PATH_STR_EX(dest, 0, 0)
966
967/* old "r" */
968#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \
969        Z_PARAM_PROLOGUE(separate); \
970        if (UNEXPECTED(!zend_parse_arg_resource(_arg, &dest, check_null))) { \
971            _expected_type = Z_EXPECTED_RESOURCE; \
972            error_code = ZPP_ERROR_WRONG_ARG; \
973            break; \
974        }
975
976#define Z_PARAM_RESOURCE(dest) \
977    Z_PARAM_RESOURCE_EX(dest, 0, 0)
978
979/* old "s" */
980#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \
981        Z_PARAM_PROLOGUE(separate); \
982        if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \
983            _expected_type = Z_EXPECTED_STRING; \
984            error_code = ZPP_ERROR_WRONG_ARG; \
985            break; \
986        }
987
988#define Z_PARAM_STRING(dest, dest_len) \
989    Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
990
991/* old "S" */
992#define Z_PARAM_STR_EX(dest, check_null, separate) \
993        Z_PARAM_PROLOGUE(separate); \
994        if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
995            _expected_type = Z_EXPECTED_STRING; \
996            error_code = ZPP_ERROR_WRONG_ARG; \
997            break; \
998        }
999
1000#define Z_PARAM_STR(dest) \
1001    Z_PARAM_STR_EX(dest, 0, 0)
1002
1003/* old "z" */
1004#define Z_PARAM_ZVAL_EX(dest, check_null, separate) \
1005        if (separate) { \
1006            Z_PARAM_PROLOGUE(separate); \
1007            zend_parse_arg_zval_deref(_arg, &dest, check_null); \
1008        } else { \
1009            if (UNEXPECTED(++_i >_num_args)) break; \
1010            _real_arg++; \
1011            zend_parse_arg_zval(_real_arg, &dest, check_null); \
1012        }
1013
1014#define Z_PARAM_ZVAL(dest) \
1015    Z_PARAM_ZVAL_EX(dest, 0, 0)
1016
1017/* old "z" (with dereference) */
1018#define Z_PARAM_ZVAL_DEREF_EX(dest, check_null, separate) \
1019        Z_PARAM_PROLOGUE(separate); \
1020        zend_parse_arg_zval_deref(_arg, &dest, check_null);
1021
1022#define Z_PARAM_ZVAL_DEREF(dest) \
1023    Z_PARAM_ZVAL_DEREF_EX(dest, 0, 0)
1024
1025/* old "+" and "*" */
1026#define Z_PARAM_VARIADIC_EX(spec, dest, dest_num, post_varargs) do { \
1027        int _num_varargs = _num_args - _i - (post_varargs); \
1028        if (EXPECTED(_num_varargs > 0)) { \
1029            dest = _real_arg + 1; \
1030            dest_num = _num_varargs; \
1031            _i += _num_varargs; \
1032            _real_arg += _num_varargs; \
1033        } else { \
1034            dest = NULL; \
1035            dest_num = 0; \
1036        } \
1037    } while (0);
1038
1039#define Z_PARAM_VARIADIC(spec, dest, dest_num) \
1040    Z_PARAM_VARIADIC_EX(spec, dest, dest_num, 0)
1041
1042#endif /* FAST_ZPP */
1043
1044/* End of new parameter parsing API */
1045
1046/* Inlined implementations shared by new and old parameter parsing APIs */
1047
1048ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type);
1049ZEND_API int zend_parse_arg_class(zval *arg, zend_class_entry **pce, int num, int check_null);
1050
1051static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
1052{
1053    if (check_null) {
1054        *is_null = 0;
1055    }
1056    if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
1057        *dest = 1;
1058    } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
1059        if (check_null) {
1060            *is_null = (Z_TYPE_P(arg) == IS_NULL);
1061        }
1062        *dest = 0;
1063    } else if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
1064        *dest = zend_is_true(arg);
1065    } else {
1066        return 0;
1067    }
1068    return 1;
1069}
1070
1071static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int strict)
1072{
1073    if (check_null) {
1074        *is_null = 0;
1075    }
1076    if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
1077        *dest = Z_LVAL_P(arg);
1078    } else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
1079        if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
1080            return 0;
1081        }
1082        if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) {
1083            /* Ironically, the strict parameter makes zpp *non*-strict here */
1084            if (strict) {
1085                *dest = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
1086            } else {
1087                return 0;
1088            }
1089        } else {
1090            *dest = zend_dval_to_lval(Z_DVAL_P(arg));
1091        }
1092    } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
1093        double d;
1094        int type;
1095
1096        if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
1097            if (EXPECTED(type != 0)) {
1098                if (UNEXPECTED(zend_isnan(d))) {
1099                    return 0;
1100                }
1101                if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) {
1102                    if (strict) {
1103                        *dest = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
1104                    } else {
1105                        return 0;
1106                    }
1107                } else {
1108                    *dest = zend_dval_to_lval(d);
1109                }
1110            } else {
1111                return 0;
1112            }
1113        }
1114    } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
1115        if (check_null) {
1116            *is_null = (Z_TYPE_P(arg) == IS_NULL);
1117        }
1118        *dest = 0;
1119    } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
1120        *dest = 1;
1121    } else {
1122        return 0;
1123    }
1124    return 1;
1125}
1126
1127static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, int check_null)
1128{
1129    if (check_null) {
1130        *is_null = 0;
1131    }
1132    if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
1133        *dest = Z_DVAL_P(arg);
1134    } else if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
1135        *dest = (double)Z_LVAL_P(arg);
1136    } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
1137        zend_long l;
1138        int type;
1139
1140        if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) {
1141            if (EXPECTED(type != 0)) {
1142                *dest = (double)(l);
1143            } else {
1144                return 0;
1145            }
1146        }
1147    } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
1148        if (check_null) {
1149            *is_null = (Z_TYPE_P(arg) == IS_NULL);
1150        }
1151        *dest = 0.0;
1152    } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
1153        *dest = 1.0;
1154    } else {
1155        return 0;
1156    }
1157    return 1;
1158}
1159
1160static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, int check_null)
1161{
1162    if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
1163        *dest = Z_STR_P(arg);
1164    } else if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
1165        if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1166            *dest = NULL;
1167        } else {
1168            if (Z_COPYABLE_P(arg) && Z_REFCOUNT_P(arg) > 1) {
1169                Z_DELREF_P(arg);
1170                zval_copy_ctor_func(arg);
1171            }
1172            convert_to_string(arg);
1173            *dest = Z_STR_P(arg);
1174        }
1175    } else if (UNEXPECTED(Z_TYPE_P(arg) != IS_OBJECT) ||
1176               UNEXPECTED(parse_arg_object_to_str(arg, dest, IS_STRING) != SUCCESS)) {
1177        return 0;
1178    }
1179    return 1;
1180}
1181
1182static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, int check_null)
1183{
1184    zend_string *str;
1185
1186    if (!zend_parse_arg_str(arg, &str, check_null)) {
1187        return 0;
1188    }
1189    if (check_null && UNEXPECTED(!str)) {
1190        *dest = NULL;
1191        *dest_len = 0;
1192    } else {
1193        *dest = str->val;
1194        *dest_len = str->len;
1195    }
1196    return 1;
1197}
1198
1199static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **dest, int check_null)
1200{
1201    if (!zend_parse_arg_str(arg, dest, check_null) ||
1202        (*dest && UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len)))) {
1203        return 0;
1204    }
1205    return 1;
1206}
1207
1208static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, int check_null)
1209{
1210    zend_string *str;
1211
1212    if (!zend_parse_arg_path_str(arg, &str, check_null)) {
1213        return 0;
1214    }
1215    if (check_null && UNEXPECTED(!str)) {
1216        *dest = NULL;
1217        *dest_len = 0;
1218    } else {
1219        *dest = str->val;
1220        *dest_len = str->len;
1221    }
1222    return 1;
1223}
1224
1225static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int check_null, int or_object)
1226{
1227    if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) ||
1228        (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) {
1229        *dest = arg;
1230    } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1231        *dest = NULL;
1232    } else {
1233        return 0;
1234    }
1235    return 1;
1236}
1237
1238static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
1239{
1240    if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) {
1241        *dest = Z_ARRVAL_P(arg);
1242    } else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
1243        *dest = Z_OBJ_HT_P(arg)->get_properties(arg);
1244    } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1245        *dest = NULL;
1246    } else {
1247        return 0;
1248    }
1249    return 1;
1250}
1251
1252static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
1253{
1254    if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
1255        (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) {
1256        *dest = arg;
1257    } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1258        *dest = NULL;
1259    } else {
1260        return 0;
1261    }
1262    return 1;
1263}
1264
1265static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, int check_null)
1266{
1267    if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) {
1268        *dest = arg;
1269    } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1270        *dest = NULL;
1271    } else {
1272        return 0;
1273    }
1274    return 1;
1275}
1276
1277static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
1278{
1279    if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1280        dest_fci->size = 0;
1281        dest_fcc->initialized = 0;
1282        *error = NULL;
1283    } else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error) != SUCCESS)) {
1284        return 0;
1285    }
1286    return 1;
1287}
1288
1289static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int check_null)
1290{
1291    *dest = (check_null &&
1292        (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) ||
1293         (UNEXPECTED(Z_ISREF_P(arg)) &&
1294          UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg;
1295}
1296
1297static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, int check_null)
1298{
1299    *dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg;
1300}
1301
1302END_EXTERN_C()
1303
1304#endif /* ZEND_API_H */
1305
1306
1307/*
1308 * Local variables:
1309 * tab-width: 4
1310 * c-basic-offset: 4
1311 * indent-tabs-mode: t
1312 * End:
1313 */
1314