1999-04-07 18:10:10 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 09:29:37 +00:00
|
|
|
| Copyright (c) 1998-2007 Zend Technologies Ltd. (http://www.zend.com) |
|
1999-04-07 18:10:10 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 15:16:21 +00:00
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
2006-02-21 08:00:39 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2001-12-11 15:16:21 +00:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
1999-07-16 14:58:16 +00:00
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
1999-04-07 18:10:10 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2001-12-11 09:17:38 +00:00
|
|
|
/* $Id$ */
|
1999-07-16 14:58:16 +00:00
|
|
|
|
2000-07-02 23:54:19 +00:00
|
|
|
#ifndef ZEND_H
|
|
|
|
#define ZEND_H
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2005-08-17 16:43:11 +00:00
|
|
|
#define ZEND_VERSION "3.0.0-dev"
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2001-12-29 18:07:08 +00:00
|
|
|
#define ZEND_ENGINE_2
|
|
|
|
|
1999-04-23 03:32:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#define BEGIN_EXTERN_C() extern "C" {
|
|
|
|
#define END_EXTERN_C() }
|
|
|
|
#else
|
|
|
|
#define BEGIN_EXTERN_C()
|
|
|
|
#define END_EXTERN_C()
|
|
|
|
#endif
|
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
#include <stdio.h>
|
2005-08-11 23:35:03 +00:00
|
|
|
#include <assert.h>
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* general definitions
|
|
|
|
*/
|
|
|
|
|
2000-02-11 15:59:30 +00:00
|
|
|
#ifdef ZEND_WIN32
|
1999-09-06 16:14:08 +00:00
|
|
|
# include "zend_config.w32.h"
|
2001-01-03 08:35:23 +00:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
2002-05-30 08:52:21 +00:00
|
|
|
#elif defined(NETWARE)
|
2005-02-22 08:48:33 +00:00
|
|
|
# include <zend_config.h>
|
2004-09-22 12:49:08 +00:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
2001-11-03 13:35:14 +00:00
|
|
|
#elif defined(__riscos__)
|
2005-01-09 21:05:06 +00:00
|
|
|
# include <zend_config.h>
|
2001-11-03 13:35:14 +00:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
1999-04-07 18:10:10 +00:00
|
|
|
#else
|
2005-01-09 21:05:06 +00:00
|
|
|
# include <zend_config.h>
|
2001-01-03 08:35:23 +00:00
|
|
|
# define ZEND_PATHS_SEPARATOR ':'
|
1999-09-06 16:14:08 +00:00
|
|
|
#endif
|
|
|
|
|
2002-06-08 13:01:05 +00:00
|
|
|
|
|
|
|
#ifdef ZEND_WIN32
|
|
|
|
/* Only use this macro if you know for sure that all of the switches values
|
|
|
|
are covered by its case statements */
|
|
|
|
#define EMPTY_SWITCH_DEFAULT_CASE() \
|
|
|
|
default: \
|
|
|
|
__assume(0); \
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
#define EMPTY_SWITCH_DEFAULT_CASE()
|
|
|
|
#endif
|
|
|
|
|
1999-09-06 16:14:08 +00:00
|
|
|
/* all HAVE_XXX test have to be after the include of zend_config above */
|
|
|
|
|
|
|
|
#ifdef HAVE_UNIX_H
|
|
|
|
# include <unix.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
# include <stdarg.h>
|
1999-04-07 18:10:10 +00:00
|
|
|
#endif
|
|
|
|
|
2000-01-12 19:52:33 +00:00
|
|
|
#ifdef HAVE_DLFCN_H
|
|
|
|
# include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-18 11:16:34 +00:00
|
|
|
#if HAVE_MACH_O_DYLD_H
|
|
|
|
#include <mach-o/dyld.h>
|
|
|
|
|
|
|
|
/* MH_BUNDLE loading functions for Mac OS X / Darwin */
|
|
|
|
void *zend_mh_bundle_load (char* bundle_path);
|
|
|
|
int zend_mh_bundle_unload (void *bundle_handle);
|
|
|
|
void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name);
|
|
|
|
const char *zend_mh_bundle_error(void);
|
|
|
|
|
|
|
|
#endif /* HAVE_MACH_O_DYLD_H */
|
|
|
|
|
2006-03-14 14:19:19 +00:00
|
|
|
#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H) && !defined(ZEND_WIN32)
|
2000-03-25 15:40:08 +00:00
|
|
|
|
|
|
|
# ifndef RTLD_LAZY
|
|
|
|
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef RTLD_GLOBAL
|
|
|
|
# define RTLD_GLOBAL 0
|
|
|
|
# endif
|
|
|
|
|
2004-03-15 16:06:29 +00:00
|
|
|
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
|
2005-01-25 13:08:05 +00:00
|
|
|
# elif defined(RTLD_DEEPBIND)
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
|
2004-03-15 16:06:29 +00:00
|
|
|
# else
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
|
|
|
|
# endif
|
2000-01-13 20:34:45 +00:00
|
|
|
# define DL_UNLOAD dlclose
|
2001-08-26 15:25:55 +00:00
|
|
|
# if defined(DLSYM_NEEDS_UNDERSCORE)
|
2002-08-13 15:14:45 +00:00
|
|
|
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
|
2001-08-26 15:25:55 +00:00
|
|
|
# else
|
|
|
|
# define DL_FETCH_SYMBOL dlsym
|
|
|
|
# endif
|
2002-04-07 17:12:38 +00:00
|
|
|
# define DL_ERROR dlerror
|
|
|
|
# define DL_HANDLE void *
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 1
|
|
|
|
#elif defined(HAVE_MACH_O_DYLD_H)
|
|
|
|
# define DL_LOAD(libname) zend_mh_bundle_load(libname)
|
2005-01-10 21:57:30 +00:00
|
|
|
# define DL_UNLOAD zend_mh_bundle_unload
|
2003-04-18 17:55:45 +00:00
|
|
|
# define DL_FETCH_SYMBOL(h,s) zend_mh_bundle_symbol(h,s)
|
2002-04-07 17:12:38 +00:00
|
|
|
# define DL_ERROR zend_mh_bundle_error
|
2000-01-13 20:34:45 +00:00
|
|
|
# define DL_HANDLE void *
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 1
|
2000-02-11 15:59:30 +00:00
|
|
|
#elif defined(ZEND_WIN32)
|
2000-01-13 20:34:45 +00:00
|
|
|
# define DL_LOAD(libname) LoadLibrary(libname)
|
|
|
|
# define DL_FETCH_SYMBOL GetProcAddress
|
|
|
|
# define DL_UNLOAD FreeLibrary
|
|
|
|
# define DL_HANDLE HMODULE
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 1
|
2000-01-12 19:52:33 +00:00
|
|
|
#else
|
2000-01-13 20:34:45 +00:00
|
|
|
# define DL_HANDLE void *
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 0
|
2000-01-12 19:52:33 +00:00
|
|
|
#endif
|
|
|
|
|
2002-11-11 16:32:57 +00:00
|
|
|
#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
|
|
|
|
# include <alloca.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-11 09:17:38 +00:00
|
|
|
/* AIX requires this to be the first thing in the file. */
|
|
|
|
#ifndef __GNUC__
|
2002-11-11 16:32:57 +00:00
|
|
|
# ifndef HAVE_ALLOCA_H
|
2001-12-11 09:17:38 +00:00
|
|
|
# ifdef _AIX
|
2003-08-25 23:24:29 +00:00
|
|
|
#pragma alloca
|
2001-12-11 09:17:38 +00:00
|
|
|
# else
|
|
|
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
|
|
|
char *alloca ();
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
2000-03-26 14:46:25 +00:00
|
|
|
#endif
|
2000-03-26 16:28:37 +00:00
|
|
|
|
2004-03-16 17:35:57 +00:00
|
|
|
/* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */
|
2003-08-28 14:53:02 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
|
|
|
#else
|
2003-08-28 17:04:16 +00:00
|
|
|
# define ZEND_GCC_VERSION 0
|
2003-08-28 14:53:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ZEND_GCC_VERSION >= 2096
|
|
|
|
# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_MALLOC
|
|
|
|
#endif
|
|
|
|
|
2003-08-28 16:41:20 +00:00
|
|
|
#if ZEND_GCC_VERSION >= 2007
|
|
|
|
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
|
|
|
|
#endif
|
|
|
|
|
2005-11-25 12:25:22 +00:00
|
|
|
#if ZEND_GCC_VERSION >= 3001 && !defined(__INTEL_COMPILER)
|
2003-08-28 17:31:31 +00:00
|
|
|
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-11-03 23:05:18 +00:00
|
|
|
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
|
2000-03-26 14:46:25 +00:00
|
|
|
# define do_alloca(p) alloca(p)
|
|
|
|
# define free_alloca(p)
|
2000-03-15 17:32:29 +00:00
|
|
|
#else
|
2000-03-26 14:46:25 +00:00
|
|
|
# define do_alloca(p) emalloc(p)
|
|
|
|
# define free_alloca(p) efree(p)
|
2000-03-15 17:32:29 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-28 21:43:24 +00:00
|
|
|
#if ZEND_DEBUG
|
1999-08-28 10:18:54 +00:00
|
|
|
#define ZEND_FILE_LINE_D char *__zend_filename, uint __zend_lineno
|
|
|
|
#define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
|
|
|
|
#define ZEND_FILE_LINE_ORIG_D char *__zend_orig_filename, uint __zend_orig_lineno
|
|
|
|
#define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
|
|
|
|
#define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
|
|
|
|
#define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_C __FILE__, __LINE__
|
|
|
|
#define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_C NULL, 0
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
|
1999-08-27 19:17:19 +00:00
|
|
|
#else
|
|
|
|
#define ZEND_FILE_LINE_D
|
|
|
|
#define ZEND_FILE_LINE_DC
|
1999-08-28 10:18:54 +00:00
|
|
|
#define ZEND_FILE_LINE_ORIG_D
|
|
|
|
#define ZEND_FILE_LINE_ORIG_DC
|
1999-08-27 19:17:19 +00:00
|
|
|
#define ZEND_FILE_LINE_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_RELAY_CC
|
|
|
|
#define ZEND_FILE_LINE_C
|
|
|
|
#define ZEND_FILE_LINE_CC
|
1999-08-28 10:18:54 +00:00
|
|
|
#define ZEND_FILE_LINE_EMPTY_C
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_CC
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_CC
|
1999-08-27 19:17:19 +00:00
|
|
|
#endif /* ZEND_DEBUG */
|
|
|
|
|
2000-06-26 18:15:33 +00:00
|
|
|
#ifdef ZTS
|
|
|
|
#define ZTS_V 1
|
|
|
|
#else
|
|
|
|
#define ZTS_V 0
|
|
|
|
#endif
|
1999-08-27 19:17:19 +00:00
|
|
|
|
2006-12-20 20:12:11 +00:00
|
|
|
#include <unicode/utypes.h>
|
|
|
|
|
|
|
|
typedef union _zstr {
|
|
|
|
char *s;
|
|
|
|
UChar *u;
|
|
|
|
void *v;
|
|
|
|
} zstr;
|
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
#include "zend_errors.h"
|
|
|
|
#include "zend_alloc.h"
|
|
|
|
|
2002-06-24 07:11:12 +00:00
|
|
|
#include "zend_types.h"
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2001-04-28 20:21:42 +00:00
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-28 20:13:25 +00:00
|
|
|
#ifndef LONG_MAX
|
|
|
|
#define LONG_MAX 2147483647L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LONG_MIN
|
|
|
|
#define LONG_MIN (- LONG_MAX - 1)
|
|
|
|
#endif
|
|
|
|
|
2006-05-04 21:29:21 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# define ZSTR(x) ((zstr)(x))
|
|
|
|
# define NULL_ZSTR ZSTR((void*)NULL)
|
|
|
|
# define EMPTY_ZSTR ZSTR("\0\0")
|
|
|
|
#else
|
2006-02-26 11:57:14 +00:00
|
|
|
extern ZEND_API zstr null_zstr;
|
|
|
|
extern ZEND_API zstr empty_zstr;
|
|
|
|
|
|
|
|
static inline zstr _to_zstr(void *v) {
|
|
|
|
zstr ret;
|
|
|
|
ret.v = v;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
# define ZSTR(x) _to_zstr(x)
|
|
|
|
# define NULL_ZSTR null_zstr
|
|
|
|
# define EMPTY_ZSTR empty_zstr
|
2006-05-04 21:29:21 +00:00
|
|
|
#endif
|
2006-02-26 11:57:14 +00:00
|
|
|
|
2005-08-18 07:34:49 +00:00
|
|
|
#define EMPTY_STR ((UChar*)"\0\0")
|
2005-08-11 23:35:03 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
#undef SUCCESS
|
|
|
|
#undef FAILURE
|
|
|
|
#define SUCCESS 0
|
1999-09-06 16:14:08 +00:00
|
|
|
#define FAILURE -1 /* this MUST stay a negative number, or it may affect functions! */
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "zend_hash.h"
|
2002-03-20 21:26:46 +00:00
|
|
|
#include "zend_ts_hash.h"
|
1999-04-07 18:10:10 +00:00
|
|
|
#include "zend_llist.h"
|
|
|
|
|
2005-06-16 14:56:13 +00:00
|
|
|
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
|
|
|
|
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2007-04-26 19:08:24 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
|
2005-08-11 23:35:03 +00:00
|
|
|
# define ZEND_VM_ALWAYS_INLINE __attribute__ ((always_inline))
|
|
|
|
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
|
|
|
|
#else
|
|
|
|
# define ZEND_VM_ALWAYS_INLINE
|
|
|
|
# define zend_error_noreturn zend_error
|
|
|
|
#endif
|
2001-09-30 17:29:55 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
/*
|
|
|
|
* zval
|
|
|
|
*/
|
|
|
|
typedef struct _zval_struct zval;
|
|
|
|
typedef struct _zend_class_entry zend_class_entry;
|
|
|
|
|
2005-11-15 15:21:47 +00:00
|
|
|
typedef struct _zend_guard {
|
|
|
|
zend_bool in_get;
|
|
|
|
zend_bool in_set;
|
|
|
|
zend_bool in_unset;
|
|
|
|
zend_bool in_isset;
|
|
|
|
zend_bool dummy; /* sizeof(zend_guard) must not be equal to sizeof(void*) */
|
|
|
|
} zend_guard;
|
|
|
|
|
2001-07-28 18:33:06 +00:00
|
|
|
typedef struct _zend_object {
|
|
|
|
zend_class_entry *ce;
|
|
|
|
HashTable *properties;
|
2005-11-15 15:21:47 +00:00
|
|
|
HashTable *guards; /* protects from __get/__set ... recursion */
|
2001-07-28 18:33:06 +00:00
|
|
|
} zend_object;
|
|
|
|
|
2002-02-07 14:08:43 +00:00
|
|
|
#include "zend_object_handlers.h"
|
2001-08-16 14:04:04 +00:00
|
|
|
|
1999-05-22 16:10:51 +00:00
|
|
|
typedef union _zvalue_value {
|
1999-04-07 18:10:10 +00:00
|
|
|
long lval; /* long value */
|
|
|
|
double dval; /* double value */
|
2006-07-21 23:37:15 +00:00
|
|
|
struct { /* 8-bit binary string type */
|
1999-04-07 18:10:10 +00:00
|
|
|
char *val;
|
2003-01-15 19:10:14 +00:00
|
|
|
int len;
|
1999-04-07 18:10:10 +00:00
|
|
|
} str;
|
2005-08-11 23:35:03 +00:00
|
|
|
struct { /* Unicode string type */
|
|
|
|
UChar *val;
|
2006-02-21 20:12:43 +00:00
|
|
|
int len;
|
2005-08-11 23:35:03 +00:00
|
|
|
} ustr;
|
2006-03-03 09:56:47 +00:00
|
|
|
struct { /* Universal string type */
|
2006-02-26 11:57:14 +00:00
|
|
|
zstr val;
|
|
|
|
int len;
|
|
|
|
} uni;
|
1999-04-07 18:10:10 +00:00
|
|
|
HashTable *ht; /* hash table value */
|
2001-08-07 03:17:33 +00:00
|
|
|
zend_object_value obj;
|
1999-04-07 18:10:10 +00:00
|
|
|
} zvalue_value;
|
|
|
|
|
|
|
|
|
|
|
|
struct _zval_struct {
|
|
|
|
/* Variable information */
|
|
|
|
zvalue_value value; /* value */
|
2002-03-19 19:09:53 +00:00
|
|
|
zend_uint refcount;
|
2000-03-18 16:00:30 +00:00
|
|
|
zend_uchar type; /* active type */
|
|
|
|
zend_uchar is_ref;
|
1999-04-07 18:10:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-10-05 15:13:22 +00:00
|
|
|
/* excpt.h on Digital Unix 4.0 defines function_table */
|
|
|
|
#undef function_table
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2001-11-03 11:59:14 +00:00
|
|
|
/* A lot of stuff needs shifiting around in order to include zend_compile.h here */
|
|
|
|
union _zend_function;
|
|
|
|
|
2003-10-17 17:19:44 +00:00
|
|
|
#include "zend_iterators.h"
|
|
|
|
|
2005-02-23 11:15:51 +00:00
|
|
|
struct _zend_serialize_data;
|
|
|
|
struct _zend_unserialize_data;
|
|
|
|
|
|
|
|
typedef struct _zend_serialize_data zend_serialize_data;
|
|
|
|
typedef struct _zend_unserialize_data zend_unserialize_data;
|
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
struct _zend_class_entry {
|
|
|
|
char type;
|
2006-02-21 20:12:43 +00:00
|
|
|
zstr name;
|
2002-04-23 18:06:54 +00:00
|
|
|
zend_uint name_length;
|
2006-02-21 08:00:39 +00:00
|
|
|
struct _zend_class_entry *parent;
|
2002-03-12 19:22:29 +00:00
|
|
|
int refcount;
|
1999-11-21 18:11:10 +00:00
|
|
|
zend_bool constants_updated;
|
2002-12-06 17:09:44 +00:00
|
|
|
zend_uint ce_flags;
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
HashTable function_table;
|
|
|
|
HashTable default_properties;
|
2003-02-05 13:35:52 +00:00
|
|
|
HashTable properties_info;
|
2005-09-01 10:05:01 +00:00
|
|
|
HashTable default_static_members;
|
2001-12-13 16:55:04 +00:00
|
|
|
HashTable *static_members;
|
2001-12-11 18:46:43 +00:00
|
|
|
HashTable constants_table;
|
ntroduce infrastructure for supplying information about arguments,
including:
- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance
Both user and builtin functions share the same data structures.
To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:
ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.
The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.
The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-03 17:40:44 +00:00
|
|
|
struct _zend_function_entry *builtin_functions;
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2001-11-03 11:59:14 +00:00
|
|
|
union _zend_function *constructor;
|
2001-12-27 14:35:09 +00:00
|
|
|
union _zend_function *destructor;
|
2001-12-26 19:54:20 +00:00
|
|
|
union _zend_function *clone;
|
2002-09-04 09:07:58 +00:00
|
|
|
union _zend_function *__get;
|
|
|
|
union _zend_function *__set;
|
2005-07-07 16:07:09 +00:00
|
|
|
union _zend_function *__unset;
|
|
|
|
union _zend_function *__isset;
|
2002-09-04 09:07:58 +00:00
|
|
|
union _zend_function *__call;
|
2007-07-21 05:27:07 +00:00
|
|
|
union _zend_function *__callstatic;
|
2005-09-27 07:59:18 +00:00
|
|
|
union _zend_function *__tostring;
|
2005-03-07 22:23:14 +00:00
|
|
|
union _zend_function *serialize_func;
|
|
|
|
union _zend_function *unserialize_func;
|
2001-11-03 11:59:14 +00:00
|
|
|
|
2003-10-18 18:43:31 +00:00
|
|
|
zend_class_iterator_funcs iterator_funcs;
|
2003-10-17 17:19:44 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
/* handlers */
|
2002-02-14 09:20:51 +00:00
|
|
|
zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
|
2006-02-05 23:26:55 +00:00
|
|
|
zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
|
2003-10-22 19:59:58 +00:00
|
|
|
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
|
2007-07-21 05:27:07 +00:00
|
|
|
union _zend_function *(*get_static_method)(zend_class_entry *ce, zstr method, int method_len TSRMLS_DC);
|
2002-09-04 09:07:58 +00:00
|
|
|
|
2005-02-23 11:15:51 +00:00
|
|
|
/* serializer callbacks */
|
2006-12-22 00:29:11 +00:00
|
|
|
int (*serialize)(zval *object, int *type, zstr *buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
|
|
|
|
int (*unserialize)(zval **object, zend_class_entry *ce, int type, const zstr buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
|
2005-02-23 11:15:51 +00:00
|
|
|
|
2003-03-05 11:14:44 +00:00
|
|
|
zend_class_entry **interfaces;
|
|
|
|
zend_uint num_interfaces;
|
|
|
|
|
2003-03-31 20:42:01 +00:00
|
|
|
char *filename;
|
|
|
|
zend_uint line_start;
|
|
|
|
zend_uint line_end;
|
2006-10-27 21:22:05 +00:00
|
|
|
zstr doc_comment;
|
2003-03-31 20:42:01 +00:00
|
|
|
zend_uint doc_comment_len;
|
2005-08-12 11:29:33 +00:00
|
|
|
|
2004-03-30 18:36:53 +00:00
|
|
|
struct _zend_module_entry *module;
|
1999-04-07 18:10:10 +00:00
|
|
|
};
|
|
|
|
|
2003-02-18 09:37:54 +00:00
|
|
|
#include "zend_stream.h"
|
1999-05-22 16:10:51 +00:00
|
|
|
typedef struct _zend_utility_functions {
|
2005-08-11 23:35:03 +00:00
|
|
|
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
|
|
|
int (*printf_function)(const char *format, ...);
|
1999-04-07 18:10:10 +00:00
|
|
|
int (*write_function)(const char *str, uint str_length);
|
2006-07-12 17:04:13 +00:00
|
|
|
int (*path_encode_function)(char **encpath, int *encpath_len, const UChar *path, int path_len TSRMLS_DC);
|
2006-10-03 16:28:02 +00:00
|
|
|
int (*path_decode_function)(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC);
|
1999-11-30 20:15:04 +00:00
|
|
|
FILE *(*fopen_function)(const char *filename, char **opened_path);
|
1999-04-07 18:10:10 +00:00
|
|
|
void (*message_handler)(long message, void *data);
|
1999-12-01 22:55:20 +00:00
|
|
|
void (*block_interruptions)(void);
|
|
|
|
void (*unblock_interruptions)(void);
|
2001-01-07 18:39:11 +00:00
|
|
|
int (*get_configuration_directive)(char *name, uint name_length, zval *contents);
|
2000-01-24 19:00:30 +00:00
|
|
|
void (*ticks_function)(int ticks);
|
2002-09-19 15:58:01 +00:00
|
|
|
void (*on_timeout)(int seconds TSRMLS_DC);
|
2003-02-18 09:37:54 +00:00
|
|
|
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
2003-08-31 09:35:54 +00:00
|
|
|
int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
|
2004-09-05 22:40:35 +00:00
|
|
|
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
|
1999-04-07 18:10:10 +00:00
|
|
|
} zend_utility_functions;
|
|
|
|
|
2006-02-21 08:00:39 +00:00
|
|
|
|
1999-05-22 16:10:51 +00:00
|
|
|
typedef struct _zend_utility_values {
|
1999-12-04 13:26:57 +00:00
|
|
|
char *import_use_extension;
|
|
|
|
uint import_use_extension_length;
|
2002-09-03 09:41:41 +00:00
|
|
|
zend_bool html_errors;
|
1999-04-07 18:10:10 +00:00
|
|
|
} zend_utility_values;
|
|
|
|
|
|
|
|
|
2000-03-25 19:10:07 +00:00
|
|
|
typedef int (*zend_write_func_t)(const char *str, uint str_length);
|
|
|
|
|
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
#undef MIN
|
|
|
|
#undef MAX
|
2001-08-11 15:56:40 +00:00
|
|
|
#define MAX(a, b) (((a)>(b))?(a):(b))
|
|
|
|
#define MIN(a, b) (((a)<(b))?(a):(b))
|
1999-12-31 13:56:59 +00:00
|
|
|
#define ZEND_STRL(str) (str), (sizeof(str)-1)
|
2005-01-20 02:02:09 +00:00
|
|
|
#define ZEND_STRS(str) (str), (sizeof(str))
|
2000-06-03 03:05:01 +00:00
|
|
|
#define ZEND_NORMALIZE_BOOL(n) \
|
|
|
|
((n) ? (((n)>0) ? 1 : -1) : 0)
|
2003-08-04 07:52:36 +00:00
|
|
|
#define ZEND_TRUTH(x) ((x) ? 1 : 0)
|
|
|
|
#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
|
2005-08-11 23:35:03 +00:00
|
|
|
#define ZEND_COLL_RESULT(n) \
|
|
|
|
((n) == UCOL_EQUAL ? 0 : ((n) == UCOL_GREATER ? 1 : -1))
|
2003-08-04 07:52:36 +00:00
|
|
|
|
1999-12-31 13:56:59 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
/* data types */
|
2004-09-26 20:03:54 +00:00
|
|
|
/* All data types <= IS_BOOL have their constructor/destructors skipped */
|
2000-01-04 13:52:52 +00:00
|
|
|
#define IS_NULL 0
|
1999-04-07 18:10:10 +00:00
|
|
|
#define IS_LONG 1
|
|
|
|
#define IS_DOUBLE 2
|
2004-09-26 20:03:54 +00:00
|
|
|
#define IS_BOOL 3
|
1999-04-07 18:10:10 +00:00
|
|
|
#define IS_ARRAY 4
|
|
|
|
#define IS_OBJECT 5
|
2004-09-26 20:03:54 +00:00
|
|
|
#define IS_STRING 6
|
2000-01-04 14:25:42 +00:00
|
|
|
#define IS_RESOURCE 7
|
|
|
|
#define IS_CONSTANT 8
|
2000-05-31 19:07:09 +00:00
|
|
|
#define IS_CONSTANT_ARRAY 9
|
2005-08-11 23:35:03 +00:00
|
|
|
#define IS_UNICODE 10
|
2000-01-04 14:25:42 +00:00
|
|
|
|
2001-07-16 11:41:06 +00:00
|
|
|
/* Ugly hack to support constants as static array indices */
|
|
|
|
#define IS_CONSTANT_INDEX 0x80
|
|
|
|
|
|
|
|
|
2000-01-04 13:52:52 +00:00
|
|
|
/* overloaded elements data types */
|
|
|
|
#define OE_IS_ARRAY (1<<0)
|
|
|
|
#define OE_IS_OBJECT (1<<1)
|
|
|
|
#define OE_IS_METHOD (1<<2)
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2006-06-12 17:06:39 +00:00
|
|
|
/* default engine string type */
|
|
|
|
#define ZEND_STR_TYPE (UG(unicode)?IS_UNICODE:IS_STRING)
|
|
|
|
|
2000-03-21 19:01:19 +00:00
|
|
|
int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions);
|
2001-07-31 04:53:54 +00:00
|
|
|
void zend_shutdown(TSRMLS_D);
|
2002-11-19 17:51:30 +00:00
|
|
|
void zend_register_standard_ini_entries(TSRMLS_D);
|
1999-06-05 20:00:00 +00:00
|
|
|
|
2006-05-09 21:30:11 +00:00
|
|
|
/*#ifdef ZTS*/
|
2002-09-17 12:42:11 +00:00
|
|
|
void zend_post_startup(TSRMLS_D);
|
2006-05-09 21:30:11 +00:00
|
|
|
/*#endif*/
|
2002-09-17 12:42:11 +00:00
|
|
|
|
1999-04-10 11:21:55 +00:00
|
|
|
void zend_set_utility_values(zend_utility_values *utility_values);
|
2001-07-21 14:25:27 +00:00
|
|
|
|
1999-05-15 15:47:24 +00:00
|
|
|
BEGIN_EXTERN_C()
|
2001-07-21 16:21:22 +00:00
|
|
|
ZEND_API void _zend_bailout(char *filename, uint lineno);
|
1999-05-15 15:47:24 +00:00
|
|
|
END_EXTERN_C()
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2001-07-21 16:21:22 +00:00
|
|
|
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
|
2001-07-21 14:25:27 +00:00
|
|
|
|
|
|
|
#define zend_try \
|
|
|
|
{ \
|
2006-09-14 10:32:57 +00:00
|
|
|
jmp_buf *__orig_bailout = EG(bailout); \
|
|
|
|
jmp_buf __bailout; \
|
2001-07-21 14:25:27 +00:00
|
|
|
\
|
2006-09-14 10:32:57 +00:00
|
|
|
EG(bailout) = &__bailout; \
|
|
|
|
if (setjmp(__bailout)==0) {
|
2001-07-21 14:25:27 +00:00
|
|
|
#define zend_catch \
|
2006-05-19 06:11:02 +00:00
|
|
|
} else { \
|
2006-09-14 10:32:57 +00:00
|
|
|
EG(bailout) = __orig_bailout;
|
2001-07-21 14:25:27 +00:00
|
|
|
#define zend_end_try() \
|
2006-05-19 06:11:02 +00:00
|
|
|
} \
|
2006-09-14 10:32:57 +00:00
|
|
|
EG(bailout) = __orig_bailout; \
|
2001-07-21 14:25:27 +00:00
|
|
|
}
|
2006-05-19 06:11:02 +00:00
|
|
|
#define zend_first_try EG(bailout)=NULL; zend_try
|
2001-07-21 14:25:27 +00:00
|
|
|
|
2004-02-18 22:44:40 +00:00
|
|
|
BEGIN_EXTERN_C()
|
2001-07-21 14:25:27 +00:00
|
|
|
ZEND_API char *get_zend_version(void);
|
1999-06-11 10:44:26 +00:00
|
|
|
ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
|
2005-08-11 23:35:03 +00:00
|
|
|
ZEND_API void zend_make_string_zval(zval *expr, zval *expr_copy, int *use_copy);
|
|
|
|
ZEND_API void zend_make_unicode_zval(zval *expr, zval *expr_copy, int *use_copy);
|
1999-04-07 18:10:10 +00:00
|
|
|
ZEND_API int zend_print_zval(zval *expr, int indent);
|
2000-03-25 19:10:07 +00:00
|
|
|
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
|
2003-01-12 14:25:58 +00:00
|
|
|
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
|
|
|
|
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
|
|
|
|
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
|
2005-08-11 23:35:03 +00:00
|
|
|
ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...);
|
2004-02-18 22:44:40 +00:00
|
|
|
END_EXTERN_C()
|
2001-07-21 14:25:27 +00:00
|
|
|
|
2003-07-30 16:13:52 +00:00
|
|
|
void zend_activate(TSRMLS_D);
|
|
|
|
void zend_deactivate(TSRMLS_D);
|
2004-07-25 07:14:49 +00:00
|
|
|
void zend_call_destructors(TSRMLS_D);
|
2003-07-30 16:13:52 +00:00
|
|
|
void zend_activate_modules(TSRMLS_D);
|
|
|
|
void zend_deactivate_modules(TSRMLS_D);
|
2004-03-16 22:27:26 +00:00
|
|
|
void zend_post_deactivate_modules(TSRMLS_D);
|
2003-07-30 16:13:52 +00:00
|
|
|
|
2000-06-03 01:49:49 +00:00
|
|
|
#if ZEND_DEBUG
|
|
|
|
#define Z_DBG(expr) (expr)
|
|
|
|
#else
|
|
|
|
#define Z_DBG(expr)
|
|
|
|
#endif
|
|
|
|
|
2004-02-20 08:03:27 +00:00
|
|
|
BEGIN_EXTERN_C()
|
2001-01-15 10:52:06 +00:00
|
|
|
ZEND_API void free_estring(char **str_p);
|
2004-02-20 08:03:27 +00:00
|
|
|
END_EXTERN_C()
|
2003-02-10 16:11:24 +00:00
|
|
|
|
2004-07-19 07:19:50 +00:00
|
|
|
/* FIXME: Check if we can save if (ptr) too */
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2004-07-19 07:19:50 +00:00
|
|
|
#define STR_FREE(ptr) if (ptr) { efree(ptr); }
|
|
|
|
#define STR_FREE_REL(ptr) if (ptr) { efree_rel(ptr); }
|
|
|
|
|
|
|
|
#define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
|
|
|
|
|
|
|
|
#define STR_REALLOC(ptr, size) \
|
|
|
|
ptr = (char *) erealloc(ptr, size);
|
1999-12-21 20:30:04 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
/* output support */
|
|
|
|
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
|
|
|
|
#define ZEND_PUTS(str) zend_write((str), strlen((str)))
|
|
|
|
#define ZEND_PUTC(c) zend_write(&(c), 1), (c)
|
|
|
|
|
2000-03-25 19:10:07 +00:00
|
|
|
|
1999-04-23 03:32:33 +00:00
|
|
|
BEGIN_EXTERN_C()
|
2005-08-11 23:35:03 +00:00
|
|
|
extern ZEND_API int (*zend_printf)(const char *format, ...);
|
2000-03-25 19:10:07 +00:00
|
|
|
extern ZEND_API zend_write_func_t zend_write;
|
2006-07-12 17:04:13 +00:00
|
|
|
extern ZEND_API int (*zend_path_encode)(char **encpath, int *encpath_len, const UChar *path, int path_len TSRMLS_DC);
|
2006-10-03 16:28:02 +00:00
|
|
|
extern ZEND_API int (*zend_path_decode)(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC);
|
1999-11-30 20:15:04 +00:00
|
|
|
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
|
1999-12-01 22:55:20 +00:00
|
|
|
extern ZEND_API void (*zend_block_interruptions)(void);
|
|
|
|
extern ZEND_API void (*zend_unblock_interruptions)(void);
|
2000-02-17 08:03:13 +00:00
|
|
|
extern ZEND_API void (*zend_ticks_function)(int ticks);
|
2005-08-11 23:35:03 +00:00
|
|
|
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
2002-09-19 15:58:01 +00:00
|
|
|
extern void (*zend_on_timeout)(int seconds TSRMLS_DC);
|
2003-02-18 09:37:54 +00:00
|
|
|
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
2006-05-09 21:30:11 +00:00
|
|
|
extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
|
2004-09-05 22:40:35 +00:00
|
|
|
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
|
2000-04-19 15:08:06 +00:00
|
|
|
|
|
|
|
|
2005-08-11 23:35:03 +00:00
|
|
|
ZEND_API void zend_error(int type, const char *format, ...);
|
2000-04-19 15:08:06 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
void zenderror(char *error);
|
|
|
|
|
2002-03-12 19:41:02 +00:00
|
|
|
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
|
2006-02-13 10:23:59 +00:00
|
|
|
#define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
|
2002-03-12 10:08:47 +00:00
|
|
|
extern ZEND_API zend_class_entry *zend_standard_class_def;
|
2002-09-03 10:25:06 +00:00
|
|
|
extern ZEND_API zend_utility_values zend_uv;
|
1999-12-22 20:24:52 +00:00
|
|
|
extern ZEND_API zval zval_used_for_init;
|
1999-12-19 06:39:17 +00:00
|
|
|
|
1999-12-04 13:26:57 +00:00
|
|
|
END_EXTERN_C()
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
#define ZEND_UV(name) (zend_uv.name)
|
|
|
|
|
|
|
|
|
|
|
|
#define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
|
|
|
|
#define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
|
|
|
|
|
2000-03-06 10:46:40 +00:00
|
|
|
BEGIN_EXTERN_C()
|
2000-03-05 19:50:10 +00:00
|
|
|
ZEND_API void zend_message_dispatcher(long message, void *data);
|
2000-03-06 10:46:40 +00:00
|
|
|
|
2001-01-07 18:39:11 +00:00
|
|
|
ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents);
|
2005-08-11 23:35:03 +00:00
|
|
|
ZEND_API void zend_reset_locale_deps(TSRMLS_D);
|
2004-02-20 08:03:27 +00:00
|
|
|
END_EXTERN_C()
|
2000-03-05 19:50:10 +00:00
|
|
|
|
1999-04-07 18:10:10 +00:00
|
|
|
|
|
|
|
/* Messages for applications of Zend */
|
2000-06-12 16:07:15 +00:00
|
|
|
#define ZMSG_FAILED_INCLUDE_FOPEN 1L
|
|
|
|
#define ZMSG_FAILED_REQUIRE_FOPEN 2L
|
|
|
|
#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
|
|
|
|
#define ZMSG_MEMORY_LEAK_DETECTED 4L
|
|
|
|
#define ZMSG_MEMORY_LEAK_REPEATED 5L
|
|
|
|
#define ZMSG_LOG_SCRIPT_NAME 6L
|
2003-08-18 22:31:11 +00:00
|
|
|
#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
|
1999-04-07 18:10:10 +00:00
|
|
|
|
2000-06-29 15:07:59 +00:00
|
|
|
|
|
|
|
#define ZVAL_ADDREF(pz) (++(pz)->refcount)
|
|
|
|
#define ZVAL_DELREF(pz) (--(pz)->refcount)
|
|
|
|
#define ZVAL_REFCOUNT(pz) ((pz)->refcount)
|
|
|
|
|
1999-07-09 20:43:59 +00:00
|
|
|
#define INIT_PZVAL(z) \
|
|
|
|
(z)->refcount = 1; \
|
2006-02-21 08:00:39 +00:00
|
|
|
(z)->is_ref = 0;
|
1999-07-09 20:43:59 +00:00
|
|
|
|
1999-12-19 06:39:17 +00:00
|
|
|
#define INIT_ZVAL(z) z = zval_used_for_init;
|
|
|
|
|
1999-12-19 18:54:40 +00:00
|
|
|
#define ALLOC_INIT_ZVAL(zp) \
|
1999-12-26 21:21:33 +00:00
|
|
|
ALLOC_ZVAL(zp); \
|
1999-12-19 18:54:40 +00:00
|
|
|
INIT_ZVAL(*zp);
|
|
|
|
|
1999-07-23 16:02:51 +00:00
|
|
|
#define MAKE_STD_ZVAL(zv) \
|
1999-12-26 21:21:33 +00:00
|
|
|
ALLOC_ZVAL(zv); \
|
1999-07-09 20:43:59 +00:00
|
|
|
INIT_PZVAL(zv);
|
|
|
|
|
2000-02-16 16:00:02 +00:00
|
|
|
#define PZVAL_IS_REF(z) ((z)->is_ref)
|
|
|
|
|
1999-07-23 16:02:51 +00:00
|
|
|
#define SEPARATE_ZVAL(ppzv) \
|
|
|
|
{ \
|
|
|
|
zval *orig_ptr = *(ppzv); \
|
|
|
|
\
|
|
|
|
if (orig_ptr->refcount>1) { \
|
|
|
|
orig_ptr->refcount--; \
|
2000-02-16 16:00:02 +00:00
|
|
|
ALLOC_ZVAL(*(ppzv)); \
|
1999-07-23 16:02:51 +00:00
|
|
|
**(ppzv) = *orig_ptr; \
|
|
|
|
zval_copy_ctor(*(ppzv)); \
|
|
|
|
(*(ppzv))->refcount=1; \
|
1999-12-19 18:54:40 +00:00
|
|
|
(*(ppzv))->is_ref = 0; \
|
1999-07-23 16:02:51 +00:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2000-02-16 16:00:02 +00:00
|
|
|
#define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
|
|
|
|
if (!PZVAL_IS_REF(*ppzv)) { \
|
|
|
|
SEPARATE_ZVAL(ppzv); \
|
|
|
|
}
|
|
|
|
|
2000-08-04 08:11:54 +00:00
|
|
|
#define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
|
|
|
|
if (!PZVAL_IS_REF(*ppzv)) { \
|
|
|
|
SEPARATE_ZVAL(ppzv); \
|
|
|
|
(*(ppzv))->is_ref = 1; \
|
|
|
|
}
|
2000-02-16 16:00:02 +00:00
|
|
|
|
1999-12-19 18:54:40 +00:00
|
|
|
#define COPY_PZVAL_TO_ZVAL(zv, pzv) \
|
|
|
|
(zv) = *(pzv); \
|
|
|
|
if ((pzv)->refcount>1) { \
|
|
|
|
zval_copy_ctor(&(zv)); \
|
|
|
|
(pzv)->refcount--; \
|
1999-12-20 16:05:36 +00:00
|
|
|
} else { \
|
2000-08-04 08:11:54 +00:00
|
|
|
FREE_ZVAL(pzv); \
|
1999-12-19 18:54:40 +00:00
|
|
|
} \
|
|
|
|
INIT_PZVAL(&(zv));
|
|
|
|
|
2001-08-11 15:56:40 +00:00
|
|
|
#define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
|
|
|
|
int is_ref, refcount; \
|
2000-11-20 12:35:08 +00:00
|
|
|
\
|
|
|
|
SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
|
|
|
|
is_ref = (*ppzv_dest)->is_ref; \
|
|
|
|
refcount = (*ppzv_dest)->refcount; \
|
|
|
|
zval_dtor(*ppzv_dest); \
|
|
|
|
**ppzv_dest = *pzv_src; \
|
2001-08-11 15:56:40 +00:00
|
|
|
if (copy) { \
|
2000-11-20 12:35:08 +00:00
|
|
|
zval_copy_ctor(*ppzv_dest); \
|
|
|
|
} \
|
|
|
|
(*ppzv_dest)->is_ref = is_ref; \
|
|
|
|
(*ppzv_dest)->refcount = refcount; \
|
|
|
|
}
|
|
|
|
|
2005-02-02 07:19:22 +00:00
|
|
|
#define SEPARATE_ARG_IF_REF(varptr) \
|
|
|
|
if (PZVAL_IS_REF(varptr)) { \
|
|
|
|
zval *original_var = varptr; \
|
|
|
|
ALLOC_ZVAL(varptr); \
|
|
|
|
varptr->value = original_var->value; \
|
2006-02-20 19:03:43 +00:00
|
|
|
Z_TYPE_P(varptr) = Z_TYPE_P(original_var); \
|
2005-02-02 07:19:22 +00:00
|
|
|
varptr->is_ref = 0; \
|
|
|
|
varptr->refcount = 1; \
|
|
|
|
zval_copy_ctor(varptr); \
|
|
|
|
} else { \
|
|
|
|
varptr->refcount++; \
|
|
|
|
}
|
|
|
|
|
2006-08-07 15:15:36 +00:00
|
|
|
#define READY_TO_DESTROY(zv) \
|
|
|
|
((zv)->refcount == 1 && \
|
|
|
|
(Z_TYPE_P(zv) != IS_OBJECT || \
|
|
|
|
zend_objects_store_get_refcount(zv TSRMLS_CC) == 1))
|
|
|
|
|
2005-02-02 07:19:22 +00:00
|
|
|
|
2001-02-14 13:17:49 +00:00
|
|
|
#define ZEND_MAX_RESERVED_RESOURCES 4
|
1999-08-15 19:29:39 +00:00
|
|
|
|
2005-08-11 23:35:03 +00:00
|
|
|
#define ZEND_INTERNAL_ENCODING "UTF-16"
|
|
|
|
|
2006-02-20 19:03:43 +00:00
|
|
|
#include "zend_operators.h"
|
2004-09-26 22:19:57 +00:00
|
|
|
#include "zend_variables.h"
|
2000-01-28 21:43:46 +00:00
|
|
|
|
2005-08-11 23:35:03 +00:00
|
|
|
#define ZEND_U_EQUAL(type, ustr, ulen, str, slen) \
|
|
|
|
((type == IS_STRING)? \
|
2006-02-21 20:12:43 +00:00
|
|
|
(!memcmp((ustr).s,(str),(slen))): \
|
|
|
|
(!zend_cmp_unicode_and_literal((ustr).u, ulen, str, slen)))
|
2005-08-11 23:35:03 +00:00
|
|
|
|
2006-10-16 21:13:13 +00:00
|
|
|
static inline int ZEND_U_CASE_EQUAL(zend_uchar type, zstr ustr, int ulen, char *str, int slen)
|
|
|
|
{
|
|
|
|
zstr lcname;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (type == IS_UNICODE) {
|
|
|
|
lcname.u = zend_ascii_to_unicode(str, slen+1 ZEND_FILE_LINE_CC);
|
|
|
|
ret = !u_memcasecmp(lcname.u, ustr.u, slen, 0);
|
|
|
|
} else {
|
|
|
|
lcname.s = zend_str_tolower_dup(ustr.s, ulen);
|
|
|
|
ret = !memcmp(lcname.s, str, slen);
|
|
|
|
}
|
|
|
|
efree(lcname.v);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-15 16:50:07 +00:00
|
|
|
|
2000-07-02 23:54:19 +00:00
|
|
|
#endif /* ZEND_H */
|
1999-09-06 16:14:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2003-02-01 01:49:15 +00:00
|
|
|
* indent-tabs-mode: t
|
1999-09-06 16:14:08 +00:00
|
|
|
* End:
|
|
|
|
*/
|