2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 1998-2004 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
+----------------------------------------------------------------------+
21
/* $Id: zend_API.h,v 1.185.2.4 2005/06/27 17:42:06 stas Exp $ */
26
#include "zend_modules.h"
27
#include "zend_list.h"
28
#include "zend_fast_cache.h"
29
#include "zend_operators.h"
30
#include "zend_variables.h"
31
#include "zend_execute.h"
36
typedef struct _zend_function_entry {
38
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
39
struct _zend_arg_info *arg_info;
42
} zend_function_entry;
44
#define ZEND_FN(name) zif_##name
45
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
46
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
47
#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_FN(classname##_##name))
49
#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
51
#define ZEND_NAMED_FE(zend_name, name, arg_info) ZEND_FENTRY(zend_name, name, arg_info, 0)
52
#define ZEND_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
53
#define ZEND_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
54
#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_FN(classname##_##name), arg_info, flags)
55
#define ZEND_ABSTRACT_ME(classname, name, arg_info) ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
56
#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
57
ZEND_FENTRY(name, ZEND_FN(classname##_##alias), arg_info, flags)
58
#define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
60
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref, 0, 0 },
61
#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, pass_by_ref, 0, 0 },
62
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, allow_null, pass_by_ref, 0, 0 },
63
#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference, required_num_args) \
64
zend_arg_info name[] = { \
65
{ NULL, 0, NULL, 0, 0, pass_rest_by_reference, return_reference, required_num_args },
66
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
67
ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_REFERENCE_AGNOSTIC, -1)
68
#define ZEND_END_ARG_INFO() };
71
#define ZEND_MODULE_STARTUP_N(module) zm_startup_##module
72
#define ZEND_MODULE_SHUTDOWN_N(module) zm_shutdown_##module
73
#define ZEND_MODULE_ACTIVATE_N(module) zm_activate_##module
74
#define ZEND_MODULE_DEACTIVATE_N(module) zm_deactivate_##module
75
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module) zm_post_zend_deactivate_##module
76
#define ZEND_MODULE_INFO_N(module) zm_info_##module
78
/* Declaration macros */
79
#define ZEND_MODULE_STARTUP_D(module) int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS)
80
#define ZEND_MODULE_SHUTDOWN_D(module) int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS)
81
#define ZEND_MODULE_ACTIVATE_D(module) int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
82
#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
83
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
84
#define ZEND_MODULE_INFO_D(module) void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
86
#define ZEND_GET_MODULE(name) \
88
ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }\
91
#define ZEND_BEGIN_MODULE_GLOBALS(module_name) \
92
typedef struct _zend_##module_name##_globals {
93
#define ZEND_END_MODULE_GLOBALS(module_name) \
94
} zend_##module_name##_globals;
98
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
99
ts_rsrc_id module_name##_globals_id;
100
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
101
extern ts_rsrc_id module_name##_globals_id;
102
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
103
ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
107
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
108
zend_##module_name##_globals module_name##_globals;
109
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
110
extern zend_##module_name##_globals module_name##_globals;
111
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
112
globals_ctor(&module_name##_globals);
118
#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
120
#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
122
class_container.name = strdup(class_name); \
123
class_container.name_length = sizeof(class_name) - 1; \
124
class_container.builtin_functions = functions; \
125
class_container.constructor = NULL; \
126
class_container.destructor = NULL; \
127
class_container.clone = NULL; \
128
class_container.create_object = NULL; \
129
class_container.interface_gets_implemented = NULL; \
130
class_container.__call = handle_fcall; \
131
class_container.__get = handle_propget; \
132
class_container.__set = handle_propset; \
133
class_container.parent = NULL; \
134
class_container.num_interfaces = 0; \
135
class_container.interfaces = NULL; \
136
class_container.get_iterator = NULL; \
137
class_container.iterator_funcs.funcs = NULL; \
138
class_container.module = NULL; \
141
int zend_next_free_module(void);
144
ZEND_API int zend_get_parameters(int ht, int param_count, ...);
145
ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument_array TSRMLS_DC);
146
ZEND_API int zend_get_parameters_ex(int param_count, ...);
147
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_array TSRMLS_DC);
149
#define zend_get_parameters_array(ht, param_count, argument_array) \
150
_zend_get_parameters_array(ht, param_count, argument_array TSRMLS_CC)
151
#define zend_get_parameters_array_ex(param_count, argument_array) \
152
_zend_get_parameters_array_ex(param_count, argument_array TSRMLS_CC)
155
/* Parameter parsing API -- andrei */
157
#define ZEND_PARSE_PARAMS_QUIET 1<<1
158
ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);
159
ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);
160
ZEND_API char *zend_zval_type_name(zval *arg);
162
ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
163
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
165
/* End of parameter parsing API -- andrei */
167
ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);
168
ZEND_API void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC);
169
ZEND_API int zend_register_module(zend_module_entry *module_entry);
170
ZEND_API int zend_register_module_ex(zend_module_entry *module TSRMLS_DC);
171
void zend_check_magic_method_implementation(zend_class_entry *ce, zend_function *fptr, int error_type TSRMLS_DC);
173
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
174
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
175
ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry TSRMLS_DC);
176
ZEND_API void zend_class_implements(zend_class_entry *class_entry TSRMLS_DC, int num_interfaces, ...);
178
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC);
179
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC);
181
ZEND_API void zend_wrong_param_count(TSRMLS_D);
183
#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
184
#define IS_CALLABLE_CHECK_NO_ACCESS (1<<1)
186
ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, char **callable_name);
187
ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC);
188
ZEND_API char *zend_get_module_version(char *module_name);
189
ZEND_API int zend_get_module_started(char *module_name);
190
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC);
191
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC);
192
ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
193
ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type TSRMLS_DC);
195
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
196
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC);
197
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC);
198
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
199
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC);
201
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC);
203
ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC);
204
ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC);
206
#define getThis() (this_ptr)
208
#define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT()
209
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
210
#define ARG_COUNT(dummy) (ht)
211
#define ZEND_NUM_ARGS() (ht)
212
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; }
213
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; }
219
ZEND_API int zend_startup_module(zend_module_entry *module);
221
#define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
222
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC TSRMLS_CC)
223
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC TSRMLS_CC)
224
#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC TSRMLS_CC)
225
ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
226
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC);
227
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC);
228
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC);
230
ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC);
232
/* no longer supported */
233
ZEND_API int add_assoc_function(zval *arg, char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
235
ZEND_API int add_assoc_long_ex(zval *arg, char *key, uint key_len, long n);
236
ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len);
237
ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b);
238
ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r);
239
ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d);
240
ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
241
ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate);
242
ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
244
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
245
#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
246
#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
247
#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key)+1, __r)
248
#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key)+1, __d)
249
#define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
250
#define add_assoc_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
251
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key)+1, __value)
253
/* unset() functions are only suported for legacy modules and null() functions should be used */
254
#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
255
#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
256
#define add_next_index_unset(__arg) add_next_index_null(__arg)
257
#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
259
ZEND_API int add_index_long(zval *arg, uint idx, long n);
260
ZEND_API int add_index_null(zval *arg, uint idx);
261
ZEND_API int add_index_bool(zval *arg, uint idx, int b);
262
ZEND_API int add_index_resource(zval *arg, uint idx, int r);
263
ZEND_API int add_index_double(zval *arg, uint idx, double d);
264
ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
265
ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
266
ZEND_API int add_index_zval(zval *arg, uint index, zval *value);
268
ZEND_API int add_next_index_long(zval *arg, long n);
269
ZEND_API int add_next_index_null(zval *arg);
270
ZEND_API int add_next_index_bool(zval *arg, int b);
271
ZEND_API int add_next_index_resource(zval *arg, int r);
272
ZEND_API int add_next_index_double(zval *arg, double d);
273
ZEND_API int add_next_index_string(zval *arg, char *str, int duplicate);
274
ZEND_API int add_next_index_stringl(zval *arg, char *str, uint length, int duplicate);
275
ZEND_API int add_next_index_zval(zval *arg, zval *value);
277
ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, void **dest, int duplicate);
278
ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, void **dest, int duplicate);
280
#define add_get_assoc_string(__arg, __key, __str, __dest, __duplicate) add_get_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __dest, __duplicate)
281
#define add_get_assoc_stringl(__arg, __key, __str, __length, __dest, __duplicate) add_get_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __dest, __duplicate)
283
ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
284
ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
285
ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
286
ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
288
ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long l TSRMLS_DC);
289
ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len TSRMLS_DC);
290
ZEND_API int add_property_bool_ex(zval *arg, char *key, uint key_len, int b TSRMLS_DC);
291
ZEND_API int add_property_resource_ex(zval *arg, char *key, uint key_len, long r TSRMLS_DC);
292
ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d TSRMLS_DC);
293
ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC);
294
ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC);
295
ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value TSRMLS_DC);
297
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n TSRMLS_CC)
298
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1 TSRMLS_CC)
299
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key)+1, __b TSRMLS_CC)
300
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key)+1, __r TSRMLS_CC)
301
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d TSRMLS_CC)
302
#define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC)
303
#define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC)
304
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC)
307
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC);
308
ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, zend_uint param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC);
311
typedef struct _zend_fcall_info {
313
HashTable *function_table;
315
HashTable *symbol_table;
316
zval **retval_ptr_ptr;
317
zend_uint param_count;
320
zend_bool no_separation;
323
typedef struct _zend_fcall_info_cache {
324
zend_bool initialized;
325
zend_function *function_handler;
326
zend_class_entry *calling_scope;
328
} zend_fcall_info_cache;
331
ZEND_API extern zend_fcall_info_cache empty_fcall_info_cache;
333
ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC);
336
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
337
zend_bool is_ref, int num_symbol_tables, ...);
339
#define add_method(arg, key, method) add_assoc_function((arg), (key), (method))
341
ZEND_API ZEND_FUNCTION(display_disabled_function);
342
ZEND_API ZEND_FUNCTION(display_disabled_class);
346
#define CHECK_ZVAL_STRING(z) \
347
if ((z)->value.str.val[ (z)->value.str.len ] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", (z)->value.str.val); }
348
#define CHECK_ZVAL_STRING_REL(z) \
349
if ((z)->value.str.val[ (z)->value.str.len ] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", (z)->value.str.val ZEND_FILE_LINE_RELAY_CC); }
351
#define CHECK_ZVAL_STRING(z)
352
#define CHECK_ZVAL_STRING_REL(z)
355
#define ZVAL_RESOURCE(z, l) { \
356
(z)->type = IS_RESOURCE; \
357
(z)->value.lval = l; \
360
#define ZVAL_BOOL(z, b) { \
361
(z)->type = IS_BOOL; \
362
(z)->value.lval = ((b) != 0); \
365
#define ZVAL_NULL(z) { \
366
(z)->type = IS_NULL; \
369
#define ZVAL_LONG(z, l) { \
370
(z)->type = IS_LONG; \
371
(z)->value.lval = l; \
374
#define ZVAL_DOUBLE(z, d) { \
375
(z)->type = IS_DOUBLE; \
376
(z)->value.dval = d; \
379
#define ZVAL_STRING(z, s, duplicate) { \
381
(z)->value.str.len = strlen(__s); \
382
(z)->value.str.val = (duplicate?estrndup(__s, (z)->value.str.len):__s); \
383
(z)->type = IS_STRING; \
386
#define ZVAL_STRINGL(z, s, l, duplicate) { \
387
char *__s=(s); int __l=l; \
388
(z)->value.str.len = __l; \
389
(z)->value.str.val = (duplicate?estrndup(__s, __l):__s); \
390
(z)->type = IS_STRING; \
393
#define ZVAL_EMPTY_STRING(z) { \
394
(z)->value.str.len = 0; \
395
(z)->value.str.val = empty_string; \
396
(z)->type = IS_STRING; \
399
#define ZVAL_ZVAL(z, zv, copy, dtor) { \
400
int is_ref, refcount; \
401
is_ref = (z)->is_ref; \
402
refcount = (z)->refcount; \
411
zval_ptr_dtor(&zv); \
413
(z)->is_ref = is_ref; \
414
(z)->refcount = refcount; \
417
#define ZVAL_FALSE(z) ZVAL_BOOL(z, 0)
418
#define ZVAL_TRUE(z) ZVAL_BOOL(z, 1)
420
#define RETVAL_RESOURCE(l) ZVAL_RESOURCE(return_value, l)
421
#define RETVAL_BOOL(b) ZVAL_BOOL(return_value, b)
422
#define RETVAL_NULL() ZVAL_NULL(return_value)
423
#define RETVAL_LONG(l) ZVAL_LONG(return_value, l)
424
#define RETVAL_DOUBLE(d) ZVAL_DOUBLE(return_value, d)
425
#define RETVAL_STRING(s, duplicate) ZVAL_STRING(return_value, s, duplicate)
426
#define RETVAL_STRINGL(s, l, duplicate) ZVAL_STRINGL(return_value, s, l, duplicate)
427
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
428
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
429
#define RETVAL_FALSE ZVAL_BOOL(return_value, 0)
430
#define RETVAL_TRUE ZVAL_BOOL(return_value, 1)
432
#define RETURN_RESOURCE(l) { RETVAL_RESOURCE(l); return; }
433
#define RETURN_BOOL(b) { RETVAL_BOOL(b); return; }
434
#define RETURN_NULL() { RETVAL_NULL(); return;}
435
#define RETURN_LONG(l) { RETVAL_LONG(l); return; }
436
#define RETURN_DOUBLE(d) { RETVAL_DOUBLE(d); return; }
437
#define RETURN_STRING(s, duplicate) { RETVAL_STRING(s, duplicate); return; }
438
#define RETURN_STRINGL(s, l, duplicate) { RETVAL_STRINGL(s, l, duplicate); return; }
439
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
440
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
441
#define RETURN_FALSE { RETVAL_FALSE; return; }
442
#define RETURN_TRUE { RETVAL_TRUE; return; }
444
#define SET_VAR_STRING(n, v) { \
448
ZVAL_STRING(var, v, 0); \
449
ZEND_SET_GLOBAL_VAR(n, var); \
453
#define SET_VAR_STRINGL(n, v, l) { \
457
ZVAL_STRINGL(var, v, l, 0); \
458
ZEND_SET_GLOBAL_VAR(n, var); \
462
#define SET_VAR_LONG(n, v) { \
467
ZEND_SET_GLOBAL_VAR(n, var); \
471
#define SET_VAR_DOUBLE(n, v) { \
475
ZVAL_DOUBLE(var, v); \
476
ZEND_SET_GLOBAL_VAR(n, var); \
481
#define ZEND_SET_SYMBOL(symtable, name, var) \
483
char *_name = (name); \
485
ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 1, 0); \
488
#define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) \
492
if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \
493
&& PZVAL_IS_REF(*orig_var)) { \
494
(var)->refcount = (*orig_var)->refcount; \
498
(var)->refcount += _refcount-1; \
500
zval_dtor(*orig_var); \
501
**orig_var = *(var); \
504
(var)->is_ref = _is_ref; \
506
(var)->refcount = _refcount; \
508
zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \
513
#define ZEND_SET_GLOBAL_VAR(name, var) \
514
ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
516
#define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref) \
517
ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
519
#define ZEND_DEFINE_PROPERTY(class_ptr, name, value, mask) \
521
char *_name = (name); \
522
int namelen = strlen(_name); \
523
zend_declare_property(class_ptr, _name, namelen, value, mask TSRMLS_CC); \
526
#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL)))
527
#define ZVAL_IS_NULL(z) ((z)->type==IS_NULL)
529
/* For compatibility */
530
#define ZEND_MINIT ZEND_MODULE_STARTUP_N
531
#define ZEND_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
532
#define ZEND_RINIT ZEND_MODULE_ACTIVATE_N
533
#define ZEND_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
534
#define ZEND_MINFO ZEND_MODULE_INFO_N
536
#define ZEND_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
537
#define ZEND_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
538
#define ZEND_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
539
#define ZEND_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
540
#define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D
544
#endif /* ZEND_API_H */
551
* indent-tabs-mode: t