home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / PHP / include / php / Zend / zend_API.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-12  |  19.6 KB  |  460 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | Zend Engine                                                          |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 0.92 of the Zend license,     |
  8.    | that is bundled with this package in the file LICENSE, and is        | 
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.zend.com/license/0_92.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.    +----------------------------------------------------------------------+
  18. */
  19.  
  20.  
  21. #ifndef ZEND_API_H
  22. #define ZEND_API_H
  23.  
  24. #include "zend_modules.h"
  25. #include "zend_list.h"
  26. #include "zend_fast_cache.h"
  27. #include "zend_operators.h"
  28. #include "zend_variables.h"
  29. #include "zend_execute.h"
  30.  
  31. #define ZEND_FN(name) zend_if_##name
  32. #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
  33. #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
  34.  
  35. #define ZEND_NAMED_FE(zend_name, name, arg_types) { #zend_name, name, arg_types },
  36. #define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(name), arg_types)
  37. #define ZEND_FALIAS(name, alias, arg_types) ZEND_NAMED_FE(name, ZEND_FN(alias), arg_types)
  38.  
  39. #define ZEND_MINIT(module)       zend_minit_##module
  40. #define ZEND_MSHUTDOWN(module)   zend_mshutdown_##module
  41. #define ZEND_RINIT(module)       zend_rinit_##module
  42. #define ZEND_RSHUTDOWN(module)   zend_rshutdown_##module
  43. #define ZEND_MINFO(module)       zend_info_##module
  44. #define ZEND_GINIT(module)       zend_ginit_##module
  45. #define ZEND_GSHUTDOWN(module)   zend_gshutdown_##module
  46.  
  47. #define ZEND_MINIT_FUNCTION(module)      int ZEND_MINIT(module)(INIT_FUNC_ARGS)
  48. #define ZEND_MSHUTDOWN_FUNCTION(module)  int ZEND_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
  49. #define ZEND_RINIT_FUNCTION(module)      int ZEND_RINIT(module)(INIT_FUNC_ARGS)
  50. #define ZEND_RSHUTDOWN_FUNCTION(module)  int ZEND_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
  51. #define ZEND_MINFO_FUNCTION(module)      void ZEND_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
  52. #define ZEND_GINIT_FUNCTION(module)      int ZEND_GINIT(module)(GINIT_FUNC_ARGS)
  53. #define ZEND_GSHUTDOWN_FUNCTION(module)  int ZEND_GSHUTDOWN(module)(void)
  54.  
  55. #define ZEND_GET_MODULE(name) \
  56.     ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }
  57.  
  58. #define ZEND_BEGIN_MODULE_GLOBALS(module_name)        \
  59.     typedef struct _zend_##module_name##_globals {
  60. #define ZEND_END_MODULE_GLOBALS(module_name)        \
  61.     } zend_##module_name##_globals;
  62.  
  63. #ifdef ZTS
  64.  
  65. #define ZEND_DECLARE_MODULE_GLOBALS(module_name)                            \
  66.     static ts_rsrc_id module_name##_globals_id;
  67. #define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)    \
  68.     module_name##_globals_id = ts_allocate_id(sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
  69.  
  70. #else
  71.  
  72. #define ZEND_DECLARE_MODULE_GLOBALS(module_name)                            \
  73.     static zend_##module_name##_globals module_name##_globals;
  74. #define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)    \
  75.     globals_ctor(&module_name##_globals);
  76.  
  77. #endif
  78.  
  79.  
  80.  
  81. #define INIT_CLASS_ENTRY(class_container, class_name, functions)    \
  82.     {                                                                \
  83.         class_container.name = strdup(class_name);                    \
  84.         class_container.name_length = sizeof(class_name)-1;            \
  85.         class_container.builtin_functions = functions;                \
  86.         class_container.handle_function_call = NULL;                \
  87.         class_container.handle_property_get = NULL;                    \
  88.         class_container.handle_property_set = NULL;                    \
  89.     }
  90.  
  91. #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
  92.     {                                                            \
  93.         class_container.name = strdup(class_name);                \
  94.         class_container.name_length = sizeof(class_name)-1;        \
  95.         class_container.builtin_functions = functions;            \
  96.         class_container.handle_function_call = handle_fcall;    \
  97.         class_container.handle_property_get = handle_propget;    \
  98.         class_container.handle_property_set = handle_propset;    \
  99.     }
  100.  
  101.  
  102.  
  103. int zend_next_free_module(void);
  104.  
  105. ZEND_API int zend_get_parameters(int ht, int param_count, ...);
  106. ZEND_API int zend_get_parameters_array(int ht, int param_count, zval **argument_array);
  107. ZEND_API int zend_get_parameters_ex(int param_count, ...);
  108. ZEND_API int zend_get_parameters_array_ex(int param_count, zval ***argument_array);
  109.  
  110. ZEND_API int ParameterPassedByReference(int ht, uint n);
  111.  
  112. int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type);
  113. void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
  114. ZEND_API int zend_register_module(zend_module_entry *module_entry);
  115.  
  116. ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
  117. ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name);
  118.  
  119. ZEND_API zend_module_entry *zend_get_module(int module_number);
  120. ZEND_API int zend_disable_function(char *function_name, uint function_name_length);
  121.  
  122. ZEND_API void wrong_param_count(void);
  123. ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name);
  124.  
  125. #define getThis() (this_ptr)
  126.  
  127. #define WRONG_PARAM_COUNT                    ZEND_WRONG_PARAM_COUNT()
  128. #define WRONG_PARAM_COUNT_WITH_RETVAL(ret)    ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
  129. #define ARG_COUNT(dummy)    (ht)
  130. #define ZEND_NUM_ARGS()        (ht)
  131. #define ZEND_WRONG_PARAM_COUNT()                    { wrong_param_count(); return; }
  132. #define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)        { wrong_param_count(); return ret; }
  133.  
  134. #ifndef ZEND_WIN32
  135. #define DLEXPORT
  136. #endif
  137.  
  138. ZEND_API int zend_startup_module(zend_module_entry *module);
  139.  
  140. #define array_init(arg)            _array_init((arg) ZEND_FILE_LINE_CC)
  141. #define object_init(arg)        _object_init((arg) ZEND_FILE_LINE_CC)
  142. #define object_init_ex(arg, ce)    _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
  143. ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
  144. ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
  145. ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
  146.  
  147. /* no longer supported */
  148. ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
  149.  
  150. ZEND_API int add_assoc_long_ex(zval *arg, char *key, uint key_len, long n);
  151. ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len);
  152. ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b);
  153. ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r);
  154. ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d);
  155. ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
  156. ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate);
  157. ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
  158.  
  159. #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
  160. #define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
  161. #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
  162. #define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key)+1, __r)
  163. #define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key)+1, __d)
  164. #define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
  165. #define add_assoc_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
  166. #define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key)+1, __value)
  167.  
  168. /* unset() functions are only suported for legacy modules and null() functions should be used */
  169. #define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
  170. #define add_index_unset(__arg, __key) add_index_null(__arg, __key)
  171. #define add_next_index_unset(__arg) add_next_index_null(__arg)
  172. #define add_property_unset(__arg, __key) add_property_null(__arg, __key)
  173.  
  174. ZEND_API int add_index_long(zval *arg, uint idx, long n);
  175. ZEND_API int add_index_null(zval *arg, uint idx);
  176. ZEND_API int add_index_bool(zval *arg, uint idx, int b);
  177. ZEND_API int add_index_resource(zval *arg, uint idx, int r);
  178. ZEND_API int add_index_double(zval *arg, uint idx, double d);
  179. ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
  180. ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
  181. ZEND_API int add_index_zval(zval *arg, uint index, zval *value);
  182.  
  183. ZEND_API int add_next_index_long(zval *arg, long n);
  184. ZEND_API int add_next_index_null(zval *arg);
  185. ZEND_API int add_next_index_bool(zval *arg, int b);
  186. ZEND_API int add_next_index_resource(zval *arg, int r);
  187. ZEND_API int add_next_index_double(zval *arg, double d);
  188. ZEND_API int add_next_index_string(zval *arg, char *str, int duplicate);
  189. ZEND_API int add_next_index_stringl(zval *arg, char *str, uint length, int duplicate);
  190. ZEND_API int add_next_index_zval(zval *arg, zval *value);
  191.  
  192. ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, void **dest, int duplicate);
  193. ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, void **dest, int duplicate);
  194.  
  195. #define add_get_assoc_string(__arg, __key, __str, __dest, __duplicate) add_get_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __dest, __duplicate)
  196. #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)
  197.  
  198. ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
  199. ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
  200. ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
  201. ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
  202.  
  203. ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long l);
  204. ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len);
  205. ZEND_API int add_property_bool_ex(zval *arg, char *key, uint key_len, int b);
  206. ZEND_API int add_property_resource_ex(zval *arg, char *key, uint key_len, long r);
  207. ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d);
  208. ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
  209. ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len,  char *str, uint length, int duplicate);
  210. ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value);
  211.  
  212. #define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n)
  213. #define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1)
  214. #define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key)+1, __b)
  215. #define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key)+1, __r)
  216. #define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d) 
  217. #define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
  218. #define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
  219. #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value)       
  220.  
  221. ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[]);
  222. ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table);
  223.  
  224. ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
  225.                                   int is_ref, int num_symbol_tables, ...);
  226.  
  227. #define add_method(arg,key,method)    add_assoc_function((arg),(key),(method))
  228.  
  229. #define ZVAL_RESOURCE(z,l) {            \
  230.         (z)->type = IS_RESOURCE;        \
  231.         (z)->value.lval = l;            \
  232.     }
  233. #define ZVAL_BOOL(z,b) {                \
  234.         (z)->type = IS_BOOL;            \
  235.         (z)->value.lval = b;            \
  236.     }
  237. #define ZVAL_NULL(z) {                    \
  238.         (z)->type = IS_NULL;            \
  239.     }
  240. #define ZVAL_LONG(z,l) {                \
  241.         (z)->type = IS_LONG;            \
  242.         (z)->value.lval = l;            \
  243.     }
  244. #define ZVAL_DOUBLE(z,d) {                \
  245.         (z)->type = IS_DOUBLE;            \
  246.         (z)->value.dval = d;            \
  247.     }
  248. #define ZVAL_STRING(z,s,duplicate) {    \
  249.         char *__s=(s);                    \
  250.         (z)->value.str.len = strlen(__s);    \
  251.         (z)->value.str.val = (duplicate?estrndup(__s,(z)->value.str.len):__s);    \
  252.         (z)->type = IS_STRING;            \
  253.     }
  254. #define ZVAL_STRINGL(z,s,l,duplicate) {    \
  255.         char *__s=(s); int __l=l;        \
  256.         (z)->value.str.len = __l;        \
  257.         (z)->value.str.val = (duplicate?estrndup(__s,__l):__s);    \
  258.         (z)->type = IS_STRING;            \
  259.     }
  260.  
  261. #define ZVAL_EMPTY_STRING(z) {            \
  262.         (z)->value.str.len = 0;          \
  263.         (z)->value.str.val = empty_string; \
  264.         (z)->type = IS_STRING;            \
  265.     }
  266.  
  267. #define ZVAL_FALSE  { (z)->value.lval = 0;  (z)->type = IS_BOOL; }
  268. #define ZVAL_TRUE   { (z)->value.lval = 1;  (z)->type = IS_BOOL; }
  269.  
  270. #define RETVAL_RESOURCE(l) {            \
  271.         return_value->type = IS_RESOURCE;\
  272.         return_value->value.lval = l;    \
  273.     }
  274. #define RETVAL_BOOL(b) {                \
  275.         return_value->type = IS_BOOL;    \
  276.         return_value->value.lval = b;    \
  277.     }
  278. #define RETVAL_NULL() {                    \
  279.         return_value->type = IS_NULL;    \
  280.     }
  281. #define RETVAL_LONG(l) {                \
  282.         return_value->type = IS_LONG;    \
  283.         return_value->value.lval = l;    \
  284.     }
  285. #define RETVAL_DOUBLE(d) {                \
  286.         return_value->type = IS_DOUBLE;    \
  287.         return_value->value.dval = d;    \
  288.     }
  289. #define RETVAL_STRING(s,duplicate) {    \
  290.         char *__s=(s);                    \
  291.         return_value->value.str.len = strlen(__s);    \
  292.         return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s);    \
  293.         return_value->type = IS_STRING;    \
  294.     }
  295. #define RETVAL_STRINGL(s,l,duplicate) {        \
  296.         char *__s=(s); int __l=l;            \
  297.         return_value->value.str.len = __l;    \
  298.         return_value->value.str.val = (duplicate?estrndup(__s,__l):__s);    \
  299.         return_value->type = IS_STRING;        \
  300.     }
  301.  
  302. #define RETVAL_EMPTY_STRING() {                \
  303.         return_value->value.str.len = 0;      \
  304.         return_value->value.str.val = empty_string; \
  305.         return_value->type = IS_STRING;        \
  306.     }
  307.  
  308. #define RETVAL_FALSE  { return_value->value.lval = 0;  return_value->type = IS_BOOL; }
  309. #define RETVAL_TRUE   { return_value->value.lval = 1;  return_value->type = IS_BOOL; }
  310.  
  311. #define RETURN_RESOURCE(l) {            \
  312.         return_value->type = IS_RESOURCE;\
  313.         return_value->value.lval = l;    \
  314.         return;                            \
  315.     }
  316.  
  317. #define RETURN_BOOL(b) {                \
  318.         return_value->type = IS_BOOL;    \
  319.         return_value->value.lval = b;    \
  320.         return;                            \
  321.     }
  322.  
  323. #define RETURN_NULL() {                \
  324.         return_value->type = IS_NULL;    \
  325.         return;                            \
  326.     }
  327.  
  328. #define RETURN_LONG(l) {                \
  329.         return_value->type = IS_LONG;    \
  330.         return_value->value.lval = l;    \
  331.         return;                            \
  332.     }
  333. #define RETURN_DOUBLE(d) {                \
  334.         return_value->type = IS_DOUBLE;    \
  335.         return_value->value.dval = d;    \
  336.         return;                            \
  337.     }
  338. #define RETURN_STRING(s,duplicate) {    \
  339.         char *__s=(s);                    \
  340.         return_value->value.str.len = strlen(__s);    \
  341.         return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s);    \
  342.         return_value->type = IS_STRING;    \
  343.         return;                            \
  344.     }
  345. #define RETURN_STRINGL(s,l,duplicate) {        \
  346.         char *__s=(s); int __l=l;            \
  347.         return_value->value.str.len = __l;    \
  348.         return_value->value.str.val = (duplicate?estrndup(__s,__l):__s);    \
  349.           return_value->type = IS_STRING;        \
  350.         return;                                \
  351.     }
  352.  
  353. #define RETURN_EMPTY_STRING() {                \
  354.         return_value->value.str.len = 0;      \
  355.         return_value->value.str.val = empty_string; \
  356.         return_value->type = IS_STRING;        \
  357.         return;                             \
  358.     }
  359.  
  360. #define RETURN_FALSE  { RETVAL_FALSE; return; }
  361. #define RETURN_TRUE   { RETVAL_TRUE; return; }
  362.  
  363. #define SET_VAR_STRING(n,v)    {                                                                                \
  364.                                 {                                                                            \
  365.                                     zval *var;                                                                \
  366.                                     char *str=(v); /* prevent 'v' from being evaluated more than once */    \
  367.                                                                                                             \
  368.                                     ALLOC_ZVAL(var);                                                        \
  369.                                     var->value.str.val = (str);                                                \
  370.                                     var->value.str.len = strlen((str));                                        \
  371.                                     var->type = IS_STRING;                                                    \
  372.                                     ZEND_SET_GLOBAL_VAR(n, var);                                            \
  373.                                 }                                                                            \
  374.                             }
  375.  
  376. #define SET_VAR_STRINGL(n,v,l)    {                                                        \
  377.                                     {                                                    \
  378.                                         zval *var;                                        \
  379.                                                                                         \
  380.                                         ALLOC_ZVAL(var);                                \
  381.                                         var->value.str.val = (v);                        \
  382.                                         var->value.str.len = (l);                        \
  383.                                         var->type = IS_STRING;                            \
  384.                                         ZEND_SET_GLOBAL_VAR(n, var);                    \
  385.                                     }                                                    \
  386.                                 }
  387.  
  388. #define SET_VAR_LONG(n,v)    {                                                            \
  389.                                 {                                                        \
  390.                                     zval *var;                                            \
  391.                                                                                         \
  392.                                     ALLOC_ZVAL(var);                                    \
  393.                                     var->value.lval = (v);                                \
  394.                                     var->type = IS_LONG;                                \
  395.                                     ZEND_SET_GLOBAL_VAR(n, var);                        \
  396.                                 }                                                        \
  397.                             }
  398.  
  399. #define SET_VAR_DOUBLE(n,v)    {                                                            \
  400.                                 {                                                        \
  401.                                     zval *var;                                            \
  402.                                                                                         \
  403.                                     ALLOC_ZVAL(var);                                    \
  404.                                     var->value.dval = (v);                                \
  405.                                     var->type = IS_DOUBLE;                                \
  406.                                     ZEND_SET_GLOBAL_VAR(n, var);                        \
  407.                                 }                                                        \
  408.                             }
  409.  
  410.  
  411. #define ZEND_SET_SYMBOL(symtable, name, var)                                        \
  412.     {                                                                                \
  413.         char *_name = (name);                                                        \
  414.                                                                                     \
  415.         ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 1, 0);    \
  416.     }
  417.  
  418. #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref)                \
  419.     {                                                                                                    \
  420.         zval **orig_var;                                                                                \
  421.                                                                                                         \
  422.         if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS                \
  423.             && PZVAL_IS_REF(*orig_var)) {                                                                \
  424.             (var)->refcount = (*orig_var)->refcount;                                                    \
  425.             (var)->is_ref = 1;                                                                            \
  426.                                                                                                         \
  427.             if (_refcount) {                                                                            \
  428.                 (var)->refcount += _refcount-1;                                                            \
  429.             }                                                                                            \
  430.             zval_dtor(*orig_var);                                                                        \
  431.             **orig_var = *(var);                                                                        \
  432.             FREE_ZVAL(var);                                                                                    \
  433.         } else {                                                                                        \
  434.             (var)->is_ref = _is_ref;                                                                    \
  435.             if (_refcount) {                                                                            \
  436.                 (var)->refcount = _refcount;                                                            \
  437.             }                                                                                            \
  438.             zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL);            \
  439.         }                                                                                                \
  440.     }
  441.  
  442.  
  443. #define ZEND_SET_GLOBAL_VAR(name, var)                \
  444.     ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
  445.  
  446. #define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref)        \
  447.     ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
  448.  
  449. #define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
  450. #define ZVAL_IS_NULL(z) ((z)->type==IS_NULL)
  451.  
  452. #endif /* ZEND_API_H */
  453.  
  454. /*
  455.  * Local variables:
  456.  * tab-width: 4
  457.  * c-basic-offset: 4
  458.  * End:
  459.  */
  460.