Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 291 lines (242 sloc) 11.617 kb
573b460 andigutmans Zend Library
andigutmans authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998, 1999 Andi Gutmans, Zeev Suraski |
6 +----------------------------------------------------------------------+
8d1de13 Zeev Suraski 0.91 update
zsuraski authored
7 | This source file is subject to version 0.91 of the Zend license, |
b5b1117 Zeev Suraski License update
zsuraski authored
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
8d1de13 Zeev Suraski 0.91 update
zsuraski authored
10 | http://www.zend.com/license/0_91.txt. |
b5b1117 Zeev Suraski License update
zsuraski authored
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. |
573b460 andigutmans Zend Library
andigutmans authored
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
b5b1117 Zeev Suraski License update
zsuraski authored
20
573b460 andigutmans Zend Library
andigutmans authored
21 #ifndef _ZEND_API_H
22 #define _ZEND_API_H
23
24 #include "modules.h"
25 #include "zend_list.h"
26
27
342c6e0 Zeev Suraski Whatnot:
zsuraski authored
28 #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
29 #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(zend_if_##name)
30
31 #define ZEND_NAMED_FE(runtime_name, name, arg_types) { #runtime_name, name, arg_types },
32 #define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, zend_if_##name, arg_types)
33
34
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
35 #define INIT_CLASS_ENTRY(class_container, class_name, functions) \
36 { \
37 class_container.name = strdup(class_name); \
38 class_container.name_length = sizeof(class_name)-1; \
39 class_container.builtin_functions = functions; \
40 class_container.handle_function_call = NULL; \
41 class_container.handle_property_get = NULL; \
42 class_container.handle_property_set = NULL; \
43 }
44
45 #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
46 { \
47 class_container.name = strdup(class_name); \
48 class_container.name_length = sizeof(class_name)-1; \
49 class_container.builtin_functions = functions; \
50 class_container.handle_function_call = handle_fcall; \
51 class_container.handle_property_get = handle_propget; \
52 class_container.handle_property_set = handle_propset; \
53 }
54
55
56
573b460 andigutmans Zend Library
andigutmans authored
57 int zend_next_free_module(void);
58
9deab41 andigutmans Add a couple of ZEND_API's
andigutmans authored
59 ZEND_API int getParameters(int ht, int param_count,...);
60 ZEND_API int getParametersArray(int ht, int param_count, zval **argument_array);
61 ZEND_API int getParametersEx(int param_count,...);
62 ZEND_API int getParametersArrayEx(int param_count, zval ***argument_array);
39f9487 andigutmans -Tiny patches
andigutmans authored
63
9deab41 andigutmans Add a couple of ZEND_API's
andigutmans authored
64 ZEND_API int ParameterPassedByReference(int ht, uint n);
39f9487 andigutmans -Tiny patches
andigutmans authored
65
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
66 int zend_register_functions(zend_function_entry *functions, HashTable *function_table);
67 void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
7a87fcb Zeev Suraski Thread safety patch. We're still not quite there but it compiles again,...
zsuraski authored
68 ZEND_API int zend_register_module(zend_module_entry *module_entry);
bfbe861 Zeev Suraski Almost forgot to commit those
zsuraski authored
69 ZEND_API zend_class_entry *register_internal_class(zend_class_entry *class_entry);
70 ZEND_API zend_module_entry *zend_get_module(int module_number);
573b460 andigutmans Zend Library
andigutmans authored
71
72 ZEND_API void wrong_param_count(void);
73
741b816 Zeev Suraski * Support getThis() for internal functions.
zsuraski authored
74 #define getThis() (this_ptr)
75
573b460 andigutmans Zend Library
andigutmans authored
76 #define WRONG_PARAM_COUNT { wrong_param_count(); return; }
77 #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) { wrong_param_count(); return ret; }
39a7f4c Zeev Suraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
78 #define ARG_COUNT(ht) (ht)
573b460 andigutmans Zend Library
andigutmans authored
79
80 #define BYREF_NONE 0
81 #define BYREF_FORCE 1
82 #define BYREF_ALLOW 2
6d988ec andigutmans - Add support for BYREF_FORCE_REST
andigutmans authored
83 #define BYREF_FORCE_REST 3
573b460 andigutmans Zend Library
andigutmans authored
84
9108abc Zeev Suraski Minor updates (mostly __declspec() stuff)
zsuraski authored
85 #if !(WIN32||WINNT)
573b460 andigutmans Zend Library
andigutmans authored
86 #define DLEXPORT
87 #endif
88
89 int zend_startup_module(zend_module_entry *module);
90
91 ZEND_API int array_init(zval *arg);
92 ZEND_API int object_init(zval *arg);
93 ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
94
95 /* no longer supported */
96 ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
97
573b460 andigutmans Zend Library
andigutmans authored
98 ZEND_API int add_assoc_long(zval *arg, char *key, long n);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
99 ZEND_API int add_assoc_bool(zval *arg, char *key, int b);
100 ZEND_API int add_assoc_resource(zval *arg, char *key, int r);
573b460 andigutmans Zend Library
andigutmans authored
101 ZEND_API int add_assoc_double(zval *arg, char *key, double d);
102 ZEND_API int add_assoc_string(zval *arg, char *key, char *str, int duplicate);
103 ZEND_API int add_assoc_stringl(zval *arg, char *key, char *str, uint length, int duplicate);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
104
573b460 andigutmans Zend Library
andigutmans authored
105 ZEND_API int add_index_long(zval *arg, uint idx, long n);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
106 ZEND_API int add_index_bool(zval *arg, uint idx, int b);
107 ZEND_API int add_index_resource(zval *arg, uint idx, int r);
573b460 andigutmans Zend Library
andigutmans authored
108 ZEND_API int add_index_double(zval *arg, uint idx, double d);
109 ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
110 ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
111
573b460 andigutmans Zend Library
andigutmans authored
112 ZEND_API int add_next_index_long(zval *arg, long n);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
113 ZEND_API int add_next_index_bool(zval *arg, int b);
114 ZEND_API int add_next_index_resource(zval *arg, int r);
573b460 andigutmans Zend Library
andigutmans authored
115 ZEND_API int add_next_index_double(zval *arg, double d);
116 ZEND_API int add_next_index_string(zval *arg, char *str, int duplicate);
117 ZEND_API int add_next_index_stringl(zval *arg, char *str, uint length, int duplicate);
118
119 ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
120 ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
6847fef added add_*_resource() and add_*_bool() functions
Thies C. Arntzen authored
121 ZEND_API int add_get_assoc_string(zval *arg, char *key, char *str, void **dest, int duplicate);
122 ZEND_API int add_get_assoc_stringl(zval *arg, char *key, char *str, uint length, void **dest, int duplicate);
573b460 andigutmans Zend Library
andigutmans authored
123 ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
124 ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
125
126 ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval, int param_count, zval *params[]);
f95edc0 Zeev Suraski Introduce call_user_func_ex()
zsuraski authored
127 ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval, int param_count, zval **params[], int no_separation);
573b460 andigutmans Zend Library
andigutmans authored
128
129 ZEND_API int add_property_long(zval *arg, char *key, long l);
446e5d0 added add_property_resource
Thies C. Arntzen authored
130 ZEND_API int add_property_resource(zval *arg, char *key, long r);
573b460 andigutmans Zend Library
andigutmans authored
131 ZEND_API int add_property_double(zval *arg, char *key, double d);
132 ZEND_API int add_property_string(zval *arg, char *key, char *str, int duplicate);
133 ZEND_API int add_property_stringl(zval *arg, char *key, char *str, uint length, int duplicate);
134
135 #define add_method(arg,key,method) add_assoc_function((arg),(key),(method))
136
eb5c6da added RETVAL_RESOURCE and RETURN_RESOURCE
Thies C. Arntzen authored
137 #define RETVAL_RESOURCE(l) { \
138 return_value->type = IS_RESOURCE;\
139 return_value->value.lval = l; \
140 }
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
141 #define RETVAL_LONG(l) { \
142 return_value->type = IS_LONG; \
143 return_value->value.lval = l; \
144 }
145 #define RETVAL_DOUBLE(d) { \
146 return_value->type = IS_DOUBLE; \
147 return_value->value.dval = d; \
148 }
149 #define RETVAL_STRING(s,duplicate) { \
150 char *__s=(s); \
151 return_value->value.str.len = strlen(__s); \
152 return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
153 return_value->type = IS_STRING; \
154 }
155 #define RETVAL_STRINGL(s,l,duplicate) { \
156 char *__s=(s); int __l=l; \
157 return_value->value.str.len = __l; \
158 return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
159 return_value->type = IS_STRING; \
160 }
161
162 #define RETVAL_FALSE { return_value->value.lval = 0; return_value->type = IS_BOOL; }
163 #define RETVAL_TRUE { return_value->value.lval = 1; return_value->type = IS_BOOL; }
164
eb5c6da added RETVAL_RESOURCE and RETURN_RESOURCE
Thies C. Arntzen authored
165 #define RETURN_RESOURCE(l) { \
166 return_value->type = IS_RESOURCE;\
167 return_value->value.lval = l; \
168 return; \
169 }
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
170 #define RETURN_LONG(l) { \
171 return_value->type = IS_LONG; \
172 return_value->value.lval = l; \
173 return; \
174 }
175 #define RETURN_DOUBLE(d) { \
176 return_value->type = IS_DOUBLE; \
177 return_value->value.dval = d; \
178 return; \
179 }
180 #define RETURN_STRING(s,duplicate) { \
181 char *__s=(s); \
182 return_value->value.str.len = strlen(__s); \
183 return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
184 return_value->type = IS_STRING; \
185 return; \
186 }
187 #define RETURN_STRINGL(s,l,duplicate) { \
188 char *__s=(s); int __l=l; \
189 return_value->value.str.len = __l; \
190 return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
191 return_value->type = IS_STRING; \
192 return; \
193 }
194
195 #define RETURN_FALSE { RETVAL_FALSE; return; }
196 #define RETURN_TRUE { RETVAL_TRUE; return; }
197
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
198 #define SET_VAR_STRING(n,v) { \
199 { \
200 zval *var = (zval *) emalloc(sizeof(zval)); \
201 char *str=(v); /* prevent 'v' from being evaluated more than once */ \
202 \
203 var->value.str.val = (str); \
204 var->value.str.len = strlen((str)); \
205 var->type = IS_STRING; \
6393ab1 Zeev Suraski Now that's an annoying bug.
zsuraski authored
206 ZEND_SET_GLOBAL_VAR(n, var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
207 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
208 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
209
210 #define SET_VAR_STRINGL(n,v,l) { \
211 { \
212 zval *var = (zval *) emalloc(sizeof(zval)); \
213 \
214 var->value.str.val = (v); \
215 var->value.str.len = (l); \
216 var->type = IS_STRING; \
217 ZEND_SET_GLOBAL_VAR(n, var); \
218 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
219 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
220
221 #define SET_VAR_LONG(n,v) { \
222 { \
223 zval *var = (zval *) emalloc(sizeof(zval)); \
224 \
225 var->value.lval = (v); \
226 var->type = IS_LONG; \
227 ZEND_SET_GLOBAL_VAR(n, var); \
228 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
229 }
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
230
231 #define SET_VAR_DOUBLE(n,v) { \
232 { \
233 zval *var = (zval *) emalloc(sizeof(zval)); \
234 \
235 var->value.dval = (v); \
236 var->type = IS_DOUBLE; \
237 ZEND_SET_GLOBAL_VAR(n, var); \
238 } \
1f985ed Zeev Suraski Moved all #define's for SET_ and RETURN_ to zend_API.h
zsuraski authored
239 }
240
241
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
242 #define ZEND_SET_SYMBOL(symtable, name, var) \
243 { \
244 char *_name = (name); \
245 \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
246 ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 0); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
247 }
248
249
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
250 #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount) \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
251 { \
252 zval **orig_var; \
253 \
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
254 if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
255 && PZVAL_IS_REF(*orig_var)) { \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
256 (var)->refcount = (*orig_var)->refcount; \
52a30fd Be safe, use ().
Andrei Zmievski authored
257 (var)->is_ref = 1; \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
258 \
2ddc4fe Zeev Suraski Make it possible to explicitly set refcount in ZEND_SET_SYMBOL_WITH_LENG...
zsuraski authored
259 if (_refcount) { \
260 (var)->refcount += _refcount-1; \
261 } \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
262 zval_dtor(*orig_var); \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
263 **orig_var = *(var); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
264 efree(var); \
265 } else { \
52a30fd Be safe, use ().
Andrei Zmievski authored
266 INIT_PZVAL((var)); \
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
267 if (_refcount) { \
268 (var)->refcount = _refcount; \
269 } \
270 zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \
48ffdd7 Zeev Suraski * Setting variables in the global scope wasn't handling is_ref's properl...
zsuraski authored
271 } \
272 }
273
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
274
275 #define ZEND_SET_GLOBAL_VAR(name, var) \
276 ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
277
158088c Zeev Suraski Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_LEN...
zsuraski authored
278 #define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount) \
279 ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount)
620d013 Zeev Suraski Support symbols in any symbol table, not just the active one
zsuraski authored
280
06a18f1 andigutmans - Add some internal functions to Zend
andigutmans authored
281 #define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
282
573b460 andigutmans Zend Library
andigutmans authored
283 #endif /* _ZEND_API_H */
284
285 /*
286 * Local variables:
287 * tab-width: 4
288 * c-basic-offset: 4
289 * End:
290 */
Something went wrong with that request. Please try again.