root/Zend/zend.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2    +----------------------------------------------------------------------+
   3    | Zend Engine                                                          |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1998-2016 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    +----------------------------------------------------------------------+
  18 */
  19 
  20 /* $Id$ */
  21 
  22 #ifndef ZEND_H
  23 #define ZEND_H
  24 
  25 #define ZEND_VERSION "3.0.0"
  26 
  27 #define ZEND_ENGINE_3
  28 
  29 #define ZEND_MAX_RESERVED_RESOURCES     4
  30 
  31 #include "zend_types.h"
  32 #include "zend_errors.h"
  33 #include "zend_alloc.h"
  34 #include "zend_llist.h"
  35 #include "zend_string.h"
  36 #include "zend_hash.h"
  37 #include "zend_ast.h"
  38 #include "zend_gc.h"
  39 #include "zend_variables.h"
  40 #include "zend_iterators.h"
  41 #include "zend_stream.h"
  42 
  43 #ifdef ZEND_SIGNALS
  44 # include "zend_signal.h"
  45 #endif
  46 
  47 #ifndef ZEND_SIGNALS
  48 /* block/unblock interruptions callbacks might be used by SAPI, and were used
  49  * by mod_php for Apache 1, but now they are not usefull anymore.
  50  */
  51 # define HANDLE_BLOCK_INTERRUPTIONS()           /*if (zend_block_interruptions) { zend_block_interruptions(); }*/
  52 # define HANDLE_UNBLOCK_INTERRUPTIONS()         /*if (zend_unblock_interruptions) { zend_unblock_interruptions(); }*/
  53 #else
  54 # define HANDLE_BLOCK_INTERRUPTIONS()           ZEND_SIGNAL_BLOCK_INTERRUPUTIONS()
  55 # define HANDLE_UNBLOCK_INTERRUPTIONS()         ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
  56 #endif
  57 
  58 #define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
  59 #define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
  60 
  61 #define USED_RET() \
  62         (!EX(prev_execute_data) || \
  63          !ZEND_USER_CODE(EX(prev_execute_data)->func->common.type) || \
  64          !(EX(prev_execute_data)->opline->result_type & EXT_TYPE_UNUSED))
  65 
  66 #ifdef ZEND_ENABLE_STATIC_TSRMLS_CACHE
  67 #define ZEND_TSRMG TSRMG_STATIC
  68 #define ZEND_TSRMLS_CACHE_EXTERN() TSRMLS_CACHE_EXTERN()
  69 #define ZEND_TSRMLS_CACHE_DEFINE() TSRMLS_CACHE_DEFINE()
  70 #define ZEND_TSRMLS_CACHE_UPDATE() TSRMLS_CACHE_UPDATE()
  71 #define ZEND_TSRMLS_CACHE TSRMLS_CACHE
  72 #else
  73 #define ZEND_TSRMG TSRMG
  74 #define ZEND_TSRMLS_CACHE_EXTERN()
  75 #define ZEND_TSRMLS_CACHE_DEFINE()
  76 #define ZEND_TSRMLS_CACHE_UPDATE()
  77 #define ZEND_TSRMLS_CACHE
  78 #endif
  79 
  80 ZEND_TSRMLS_CACHE_EXTERN()
  81 
  82 #ifdef HAVE_NORETURN
  83 # ifdef ZEND_NORETURN_ALIAS
  84 ZEND_COLD void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN;
  85 # else
  86 ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...);
  87 # endif
  88 #else
  89 # define zend_error_noreturn zend_error
  90 #endif
  91 
  92 /* overloaded elements data types */
  93 #define OE_IS_ARRAY                                     (1<<0)
  94 #define OE_IS_OBJECT                            (1<<1)
  95 #define OE_IS_METHOD                            (1<<2)
  96 
  97 struct _zend_serialize_data;
  98 struct _zend_unserialize_data;
  99 
 100 typedef struct _zend_serialize_data zend_serialize_data;
 101 typedef struct _zend_unserialize_data zend_unserialize_data;
 102 
 103 typedef struct _zend_trait_method_reference {
 104         zend_string *method_name;
 105         zend_class_entry *ce;
 106         zend_string *class_name;
 107 } zend_trait_method_reference;
 108 
 109 typedef struct _zend_trait_precedence {
 110         zend_trait_method_reference *trait_method;
 111         union {
 112                 zend_class_entry  *ce;
 113                 zend_string       *class_name;
 114         } *exclude_from_classes;
 115 } zend_trait_precedence;
 116 
 117 typedef struct _zend_trait_alias {
 118         zend_trait_method_reference *trait_method;
 119 
 120         /**
 121         * name for method to be added
 122         */
 123         zend_string *alias;
 124 
 125         /**
 126         * modifiers to be set on trait method
 127         */
 128         uint32_t modifiers;
 129 } zend_trait_alias;
 130 
 131 struct _zend_class_entry {
 132         char type;
 133         zend_string *name;
 134         struct _zend_class_entry *parent;
 135         int refcount;
 136         uint32_t ce_flags;
 137 
 138         int default_properties_count;
 139         int default_static_members_count;
 140         zval *default_properties_table;
 141         zval *default_static_members_table;
 142         zval *static_members_table;
 143         HashTable function_table;
 144         HashTable properties_info;
 145         HashTable constants_table;
 146 
 147         union _zend_function *constructor;
 148         union _zend_function *destructor;
 149         union _zend_function *clone;
 150         union _zend_function *__get;
 151         union _zend_function *__set;
 152         union _zend_function *__unset;
 153         union _zend_function *__isset;
 154         union _zend_function *__call;
 155         union _zend_function *__callstatic;
 156         union _zend_function *__tostring;
 157         union _zend_function *__debugInfo;
 158         union _zend_function *serialize_func;
 159         union _zend_function *unserialize_func;
 160 
 161         zend_class_iterator_funcs iterator_funcs;
 162 
 163         /* handlers */
 164         zend_object* (*create_object)(zend_class_entry *class_type);
 165         zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref);
 166         int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); /* a class implements this interface */
 167         union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method);
 168 
 169         /* serializer callbacks */
 170         int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
 171         int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
 172 
 173         uint32_t num_interfaces;
 174         uint32_t num_traits;
 175         zend_class_entry **interfaces;
 176 
 177         zend_class_entry **traits;
 178         zend_trait_alias **trait_aliases;
 179         zend_trait_precedence **trait_precedences;
 180 
 181         union {
 182                 struct {
 183                         zend_string *filename;
 184                         uint32_t line_start;
 185                         uint32_t line_end;
 186                         zend_string *doc_comment;
 187                 } user;
 188                 struct {
 189                         const struct _zend_function_entry *builtin_functions;
 190                         struct _zend_module_entry *module;
 191                 } internal;
 192         } info;
 193 };
 194 
 195 typedef struct _zend_utility_functions {
 196         void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
 197         size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
 198         size_t (*write_function)(const char *str, size_t str_length);
 199         FILE *(*fopen_function)(const char *filename, zend_string **opened_path);
 200         void (*message_handler)(zend_long message, const void *data);
 201         void (*block_interruptions)(void);
 202         void (*unblock_interruptions)(void);
 203         zval *(*get_configuration_directive)(zend_string *name);
 204         void (*ticks_function)(int ticks);
 205         void (*on_timeout)(int seconds);
 206         int (*stream_open_function)(const char *filename, zend_file_handle *handle);
 207         size_t (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
 208         zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap);
 209         char *(*getenv_function)(char *name, size_t name_len);
 210         zend_string *(*resolve_path_function)(const char *filename, int filename_len);
 211 } zend_utility_functions;
 212 
 213 typedef struct _zend_utility_values {
 214         char *import_use_extension;
 215         uint import_use_extension_length;
 216         zend_bool html_errors;
 217 } zend_utility_values;
 218 
 219 typedef int (*zend_write_func_t)(const char *str, size_t str_length);
 220 
 221 #define zend_bailout()          _zend_bailout(__FILE__, __LINE__)
 222 
 223 #define zend_try                                                                                                \
 224         {                                                                                                                       \
 225                 JMP_BUF *__orig_bailout = EG(bailout);                                  \
 226                 JMP_BUF __bailout;                                                                              \
 227                                                                                                                                 \
 228                 EG(bailout) = &__bailout;                                                               \
 229                 if (SETJMP(__bailout)==0) {
 230 #define zend_catch                                                                                              \
 231                 } else {                                                                                                \
 232                         EG(bailout) = __orig_bailout;
 233 #define zend_end_try()                                                                                  \
 234                 }                                                                                                               \
 235                 EG(bailout) = __orig_bailout;                                                   \
 236         }
 237 #define zend_first_try          EG(bailout)=NULL;       zend_try
 238 
 239 BEGIN_EXTERN_C()
 240 int zend_startup(zend_utility_functions *utility_functions, char **extensions);
 241 void zend_shutdown(void);
 242 void zend_register_standard_ini_entries(void);
 243 void zend_post_startup(void);
 244 void zend_set_utility_values(zend_utility_values *utility_values);
 245 
 246 ZEND_API ZEND_COLD void _zend_bailout(char *filename, uint lineno);
 247 
 248 ZEND_API char *get_zend_version(void);
 249 ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
 250 ZEND_API size_t zend_print_zval(zval *expr, int indent);
 251 ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
 252 ZEND_API void zend_print_zval_r(zval *expr, int indent);
 253 ZEND_API void zend_print_flat_zval_r(zval *expr);
 254 ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent);
 255 ZEND_API ZEND_COLD void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
 256 
 257 ZEND_API void zend_activate(void);
 258 ZEND_API void zend_deactivate(void);
 259 ZEND_API void zend_call_destructors(void);
 260 ZEND_API void zend_activate_modules(void);
 261 ZEND_API void zend_deactivate_modules(void);
 262 ZEND_API void zend_post_deactivate_modules(void);
 263 
 264 ZEND_API void free_estring(char **str_p);
 265 END_EXTERN_C()
 266 
 267 /* output support */
 268 #define ZEND_WRITE(str, str_len)                zend_write((str), (str_len))
 269 #define ZEND_WRITE_EX(str, str_len)             write_func((str), (str_len))
 270 #define ZEND_PUTS(str)                                  zend_write((str), strlen((str)))
 271 #define ZEND_PUTS_EX(str)                               write_func((str), strlen((str)))
 272 #define ZEND_PUTC(c)                                    zend_write(&(c), 1)
 273 
 274 BEGIN_EXTERN_C()
 275 extern ZEND_API size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
 276 extern ZEND_API zend_write_func_t zend_write;
 277 extern ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
 278 extern ZEND_API void (*zend_block_interruptions)(void);
 279 extern ZEND_API void (*zend_unblock_interruptions)(void);
 280 extern ZEND_API void (*zend_ticks_function)(int ticks);
 281 extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
 282 extern ZEND_API void (*zend_on_timeout)(int seconds);
 283 extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
 284 extern size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
 285 extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
 286 extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
 287 extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
 288 
 289 ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
 290 ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...);
 291 ZEND_API ZEND_COLD void zend_type_error(const char *format, ...);
 292 ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...);
 293 
 294 ZEND_COLD void zenderror(const char *error);
 295 
 296 /* The following #define is used for code duality in PHP for Engine 1 & 2 */
 297 #define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
 298 extern ZEND_API zend_class_entry *zend_standard_class_def;
 299 extern ZEND_API zend_utility_values zend_uv;
 300 extern ZEND_API zval zval_used_for_init;
 301 
 302 END_EXTERN_C()
 303 
 304 #define ZEND_UV(name) (zend_uv.name)
 305 
 306 BEGIN_EXTERN_C()
 307 ZEND_API void zend_message_dispatcher(zend_long message, const void *data);
 308 
 309 ZEND_API zval *zend_get_configuration_directive(zend_string *name);
 310 END_EXTERN_C()
 311 
 312 /* Messages for applications of Zend */
 313 #define ZMSG_FAILED_INCLUDE_FOPEN               1L
 314 #define ZMSG_FAILED_REQUIRE_FOPEN               2L
 315 #define ZMSG_FAILED_HIGHLIGHT_FOPEN             3L
 316 #define ZMSG_MEMORY_LEAK_DETECTED               4L
 317 #define ZMSG_MEMORY_LEAK_REPEATED               5L
 318 #define ZMSG_LOG_SCRIPT_NAME                    6L
 319 #define ZMSG_MEMORY_LEAKS_GRAND_TOTAL   7L
 320 
 321 typedef enum {
 322         EH_NORMAL = 0,
 323         EH_SUPPRESS,
 324         EH_THROW
 325 } zend_error_handling_t;
 326 
 327 typedef struct {
 328         zend_error_handling_t  handling;
 329         zend_class_entry       *exception;
 330         zval                   user_handler;
 331 } zend_error_handling;
 332 
 333 ZEND_API void zend_save_error_handling(zend_error_handling *current);
 334 ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current);
 335 ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
 336 
 337 #define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
 338 #define DEBUG_BACKTRACE_IGNORE_ARGS    (1<<1)
 339 
 340 #include "zend_object_handlers.h"
 341 #include "zend_operators.h"
 342 
 343 #endif /* ZEND_H */
 344 
 345 /*
 346  * Local variables:
 347  * tab-width: 4
 348  * c-basic-offset: 4
 349  * indent-tabs-mode: t
 350  * End:
 351  */

/* [<][>][^][v][top][bottom][index][help] */