Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 289 lines (242 sloc) 11.649 kb
573b4602 » andigutmans
1999-04-07 Zend Library
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998, 1999 Andi Gutmans, Zeev Suraski |
6 +----------------------------------------------------------------------+
8d1de13a » zsuraski
1999-07-19 0.91 update
7 | This source file is subject to version 0.91 of the Zend license, |
b5b11177 » zsuraski
1999-07-16 License update
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
8d1de13a » zsuraski
1999-07-19 0.91 update
10 | http://www.zend.com/license/0_91.txt. |
b5b11177 » zsuraski
1999-07-16 License update
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. |
573b4602 » andigutmans
1999-04-07 Zend Library
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
b5b11177 » zsuraski
1999-07-16 License update
20
573b4602 » andigutmans
1999-04-07 Zend Library
21 #ifndef _ZEND_API_H
22 #define _ZEND_API_H
23
24 #include "modules.h"
25 #include "zend_list.h"
26
27
342c6e0b » zsuraski
1999-04-18 Whatnot:
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
741b8161 » zsuraski
1999-05-28 * Support getThis() for internal functions.
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
573b4602 » andigutmans
1999-04-07 Zend Library
57 int zend_next_free_module(void);
58
9deab411 » andigutmans
1999-04-19 Add a couple of ZEND_API's
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);
39f9487e » andigutmans
1999-04-14 -Tiny patches
63
9deab411 » andigutmans
1999-04-19 Add a couple of ZEND_API's
64 ZEND_API int ParameterPassedByReference(int ht, uint n);
39f9487e » andigutmans
1999-04-14 -Tiny patches
65
741b8161 » zsuraski
1999-05-28 * Support getThis() for internal functions.
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);
7a87fcbb » zsuraski
1999-04-21 Thread safety patch. We're still not quite there but it compiles agai…
68 ZEND_API int zend_register_module(zend_module_entry *module_entry);
bfbe8618 » zsuraski
1999-05-09 Almost forgot to commit those
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);
573b4602 » andigutmans
1999-04-07 Zend Library
71
72 ZEND_API void wrong_param_count(void);
73
741b8161 » zsuraski
1999-05-28 * Support getThis() for internal functions.
74 #define getThis() (this_ptr)
75
573b4602 » andigutmans
1999-04-07 Zend Library
76 #define WRONG_PARAM_COUNT { wrong_param_count(); return; }
77 #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) { wrong_param_count(); return ret; }
39a7f4c3 » zsuraski
1999-04-12 This patch is a go. Not fully optimized yet, but working properly.
78 #define ARG_COUNT(ht) (ht)
573b4602 » andigutmans
1999-04-07 Zend Library
79
80 #define BYREF_NONE 0
81 #define BYREF_FORCE 1
82 #define BYREF_ALLOW 2
6d988ec6 » andigutmans
1999-11-03 - Add support for BYREF_FORCE_REST
83 #define BYREF_FORCE_REST 3
573b4602 » andigutmans
1999-04-07 Zend Library
84
9108abc2 » zsuraski
1999-06-04 Minor updates (mostly __declspec() stuff)
85 #if !(WIN32||WINNT)
573b4602 » andigutmans
1999-04-07 Zend Library
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);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
94
95 /* no longer supported */
96 ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
97
573b4602 » andigutmans
1999-04-07 Zend Library
98 ZEND_API int add_assoc_long(zval *arg, char *key, long n);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
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);
573b4602 » andigutmans
1999-04-07 Zend Library
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);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
104
573b4602 » andigutmans
1999-04-07 Zend Library
105 ZEND_API int add_index_long(zval *arg, uint idx, long n);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
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);
573b4602 » andigutmans
1999-04-07 Zend Library
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);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
111
573b4602 » andigutmans
1999-04-07 Zend Library
112 ZEND_API int add_next_index_long(zval *arg, long n);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
113 ZEND_API int add_next_index_bool(zval *arg, int b);
114 ZEND_API int add_next_index_resource(zval *arg, int r);
573b4602 » andigutmans
1999-04-07 Zend Library
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);
6847fefa » Thies C. Arntzen
1999-10-04 added add_*_resource() and add_*_bool() functions
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);
573b4602 » andigutmans
1999-04-07 Zend Library
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[]);
f95edc01 » zsuraski
1999-08-06 Introduce call_user_func_ex()
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);
573b4602 » andigutmans
1999-04-07 Zend Library
128
129 ZEND_API int add_property_long(zval *arg, char *key, long l);
446e5d0f » Thies C. Arntzen
1999-09-29 added add_property_resource
130 ZEND_API int add_property_resource(zval *arg, char *key, long r);
573b4602 » andigutmans
1999-04-07 Zend Library
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
eb5c6da5 » Thies C. Arntzen
1999-07-05 added RETVAL_RESOURCE and RETURN_RESOURCE
137 #define RETVAL_RESOURCE(l) { \
138 return_value->type = IS_RESOURCE;\
139 return_value->value.lval = l; \
140 }
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
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
eb5c6da5 » Thies C. Arntzen
1999-07-05 added RETVAL_RESOURCE and RETURN_RESOURCE
165 #define RETURN_RESOURCE(l) { \
166 return_value->type = IS_RESOURCE;\
167 return_value->value.lval = l; \
168 return; \
169 }
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
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
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
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; \
6393ab14 » zsuraski
1999-08-06 Now that's an annoying bug.
206 ZEND_SET_GLOBAL_VAR(n, var); \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
207 } \
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
208 }
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
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 } \
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
219 }
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
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 } \
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
229 }
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
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 } \
1f985ede » zsuraski
1999-05-27 Moved all #define's for SET_ and RETURN_ to zend_API.h
239 }
240
241
c34560b5 » andigutmans
1999-12-03 - Remove _EX and make it the old _LENGTH
242 #define ZEND_SET_SYMBOL(symtable, name, var) \
243 { \
244 char *_name = (name); \
245 \
246 ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 0, 0); \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
247 }
248
c34560b5 » andigutmans
1999-12-03 - Remove _EX and make it the old _LENGTH
249 #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
250 { \
251 zval **orig_var; \
252 \
620d0134 » zsuraski
1999-07-30 Support symbols in any symbol table, not just the active one
253 if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
254 && PZVAL_IS_REF(*orig_var)) { \
158088ca » zsuraski
1999-12-01 Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_…
255 (var)->refcount = (*orig_var)->refcount; \
52a30fd2 » Andrei Zmievski
1999-10-18 Be safe, use ().
256 (var)->is_ref = 1; \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
257 \
2ddc4fe4 » zsuraski
1999-12-01 Make it possible to explicitly set refcount in ZEND_SET_SYMBOL_WITH_L…
258 if (_refcount) { \
259 (var)->refcount += _refcount-1; \
260 } \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
261 zval_dtor(*orig_var); \
158088ca » zsuraski
1999-12-01 Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_…
262 **orig_var = *(var); \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
263 efree(var); \
264 } else { \
2f5efbde » andigutmans
1999-12-02 - Add _EX macro for Andrei
265 (var)->is_ref = _is_ref; \
158088ca » zsuraski
1999-12-01 Allow to set the reference count explicitly for ZEND_SET_SYMBOL_WITH_…
266 if (_refcount) { \
267 (var)->refcount = _refcount; \
268 } \
269 zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \
48ffdd79 » zsuraski
1999-07-30 * Setting variables in the global scope wasn't handling is_ref's prop…
270 } \
271 }
272
620d0134 » zsuraski
1999-07-30 Support symbols in any symbol table, not just the active one
273
274 #define ZEND_SET_GLOBAL_VAR(name, var) \
275 ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
276
e3450661 » Andrei Zmievski
1999-12-03 *** empty log message ***
277 #define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref) \
278 ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
fec413c5 » Andrei Zmievski
1999-12-03 Added ZEND_SET_GLOBAL_VAR_WITH_LENGTH_EX() macro.
279
06a18f16 » andigutmans
1999-09-20 - Add some internal functions to Zend
280 #define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
281
573b4602 » andigutmans
1999-04-07 Zend Library
282 #endif /* _ZEND_API_H */
283
284 /*
285 * Local variables:
286 * tab-width: 4
287 * c-basic-offset: 4
288 * End:
289 */
Something went wrong with that request. Please try again.