zend.c revision 1b29e0ca
1573b4602SAndi Gutmans/*
2573b4602SAndi Gutmans   +----------------------------------------------------------------------+
3573b4602SAndi Gutmans   | Zend Engine                                                          |
4573b4602SAndi Gutmans   +----------------------------------------------------------------------+
597a9470dSXinchen Hui   | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
6573b4602SAndi Gutmans   +----------------------------------------------------------------------+
7d863d52aSSebastian Bergmann   | This source file is subject to version 2.00 of the Zend license,     |
8b5b11177SZeev Suraski   | that is bundled with this package in the file LICENSE, and is        |
9f68c7ff2SJames Cox   | available through the world-wide-web at the following url:           |
10d863d52aSSebastian Bergmann   | http://www.zend.com/license/2_00.txt.                                |
11b5b11177SZeev Suraski   | If you did not receive a copy of the Zend license and are unable to  |
12b5b11177SZeev Suraski   | obtain it through the world-wide-web, please send a note to          |
13b5b11177SZeev Suraski   | license@zend.com so we can mail you a copy immediately.              |
14573b4602SAndi Gutmans   +----------------------------------------------------------------------+
15573b4602SAndi Gutmans   | Authors: Andi Gutmans <andi@zend.com>                                |
16573b4602SAndi Gutmans   |          Zeev Suraski <zeev@zend.com>                                |
17573b4602SAndi Gutmans   +----------------------------------------------------------------------+
18573b4602SAndi Gutmans*/
19573b4602SAndi Gutmans
20333406bdSfoobar/* $Id$ */
21a6043d3eSRasmus Lerdorf
22573b4602SAndi Gutmans#include "zend.h"
23573b4602SAndi Gutmans#include "zend_extensions.h"
247080fa5bSAndi Gutmans#include "zend_modules.h"
25573b4602SAndi Gutmans#include "zend_constants.h"
26573b4602SAndi Gutmans#include "zend_list.h"
27da9faa2cSZeev Suraski#include "zend_API.h"
2800ed3badSZeev Suraski#include "zend_exceptions.h"
2913d840bcSZeev Suraski#include "zend_builtin_functions.h"
3054d53055SZeev Suraski#include "zend_ini.h"
31fcaa1c6dSDmitry Stogov#include "zend_vm.h"
3208b9fdc8SDavid Soria Parra#include "zend_dtrace.h"
33cf6ab0e9SAnatol Belski#include "zend_virtual_cwd.h"
341b29e0caSNikita Popov#include "zend_smart_str.h"
35573b4602SAndi Gutmans
367a87fcbbSZeev Suraski#ifdef ZTS
37b4892511SJani Taskinen# define GLOBAL_FUNCTION_TABLE		global_function_table
38b4892511SJani Taskinen# define GLOBAL_CLASS_TABLE			global_class_table
39b4892511SJani Taskinen# define GLOBAL_CONSTANTS_TABLE		global_constants_table
40b4892511SJani Taskinen# define GLOBAL_AUTO_GLOBALS_TABLE	global_auto_globals_table
417a87fcbbSZeev Suraski#else
42b4892511SJani Taskinen# define GLOBAL_FUNCTION_TABLE		CG(function_table)
43b4892511SJani Taskinen# define GLOBAL_CLASS_TABLE			CG(class_table)
44b4892511SJani Taskinen# define GLOBAL_AUTO_GLOBALS_TABLE	CG(auto_globals)
45b4892511SJani Taskinen# define GLOBAL_CONSTANTS_TABLE		EG(zend_constants)
467a87fcbbSZeev Suraski#endif
477a87fcbbSZeev Suraski
48573b4602SAndi Gutmans/* true multithread-shared globals */
4992dd5e61SStanislav MalyshevZEND_API zend_class_entry *zend_standard_class_def = NULL;
50c3e3c98eSAnatol BelskiZEND_API size_t (*zend_printf)(const char *format, ...);
515dba4774SZeev SuraskiZEND_API zend_write_func_t zend_write;
522fa8d67aSDmitry StogovZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
53bdeb220fSAnatol BelskiZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
5493536507SStig S. BakkenZEND_API void (*zend_block_interruptions)(void);
5593536507SStig S. BakkenZEND_API void (*zend_unblock_interruptions)(void);
56bdeb220fSAnatol BelskiZEND_API void (*zend_ticks_function)(int ticks);
57536221beSStanislav MalyshevZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
58c3e3c98eSAnatol Belskisize_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
5988c550a7SXinchen Huizend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
60bdeb220fSAnatol BelskiZEND_API char *(*zend_getenv)(char *name, size_t name_len);
612fa8d67aSDmitry StogovZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
62536221beSStanislav Malyshev
63bdeb220fSAnatol Belskivoid (*zend_on_timeout)(int seconds);
64bd115087SZeev Suraski
65bdeb220fSAnatol Belskistatic void (*zend_message_dispatcher_p)(zend_long message, const void *data);
6688d7ca44SDmitry Stogovstatic zval *(*zend_get_configuration_directive_p)(zend_string *name);
67d035af4aSZeev Suraski
68b4892511SJani Taskinenstatic ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
694be862b0SZeev Suraski{
704be862b0SZeev Suraski	if (!new_value) {
71d3e50265SMarcus Boerger		EG(error_reporting) = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;
724be862b0SZeev Suraski	} else {
737aa76271SDmitry Stogov		EG(error_reporting) = atoi(ZSTR_VAL(new_value));
744be862b0SZeev Suraski	}
754be862b0SZeev Suraski	return SUCCESS;
764be862b0SZeev Suraski}
77b4892511SJani Taskinen/* }}} */
784be862b0SZeev Suraski
7971592cecSDmitry Stogovstatic ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
8071592cecSDmitry Stogov{
81bdeb220fSAnatol Belski	OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
8271592cecSDmitry Stogov
8371592cecSDmitry Stogov	if (GC_G(gc_enabled)) {
84bdeb220fSAnatol Belski		gc_init();
8571592cecSDmitry Stogov	}
8671592cecSDmitry Stogov
8771592cecSDmitry Stogov	return SUCCESS;
8871592cecSDmitry Stogov}
8971592cecSDmitry Stogov/* }}} */
9071592cecSDmitry Stogov
91bbf3d43cSMoriyoshi Koizumistatic ZEND_INI_MH(OnUpdateScriptEncoding) /* {{{ */
92bbf3d43cSMoriyoshi Koizumi{
93e46852d2SAnatol Belski	if (!CG(multibyte)) {
94bbf3d43cSMoriyoshi Koizumi		return FAILURE;
95bbf3d43cSMoriyoshi Koizumi	}
96bdeb220fSAnatol Belski	if (!zend_multibyte_get_functions()) {
97bbf3d43cSMoriyoshi Koizumi		return SUCCESS;
98bbf3d43cSMoriyoshi Koizumi	}
997aa76271SDmitry Stogov	return zend_multibyte_set_script_encoding_by_string(new_value ? ZSTR_VAL(new_value) : NULL, new_value ? ZSTR_LEN(new_value) : 0);
100bbf3d43cSMoriyoshi Koizumi}
101bbf3d43cSMoriyoshi Koizumi/* }}} */
102bbf3d43cSMoriyoshi Koizumi
1039a20323eSDmitry Stogovstatic ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
1049a20323eSDmitry Stogov{
1059a20323eSDmitry Stogov	zend_long *p, val;
1069a20323eSDmitry Stogov#ifndef ZTS
1079a20323eSDmitry Stogov	char *base = (char *) mh_arg2;
1089a20323eSDmitry Stogov#else
1099a20323eSDmitry Stogov	char *base;
1109a20323eSDmitry Stogov
1119a20323eSDmitry Stogov	base = (char *) ts_resource(*((int *) mh_arg2));
1129a20323eSDmitry Stogov#endif
1139a20323eSDmitry Stogov
1149a20323eSDmitry Stogov	p = (zend_long *) (base+(size_t) mh_arg1);
1159a20323eSDmitry Stogov
1167aa76271SDmitry Stogov	val = zend_atol(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value));
1179a20323eSDmitry Stogov
1189a20323eSDmitry Stogov	if (stage != ZEND_INI_STAGE_STARTUP &&
1199a20323eSDmitry Stogov	    stage != ZEND_INI_STAGE_SHUTDOWN &&
1209a20323eSDmitry Stogov	    *p != val &&
1219a20323eSDmitry Stogov	    (*p < 0 || val < 0)) {
1229a20323eSDmitry Stogov		zend_error(E_WARNING, "zend.assertions may be completely enabled or disabled only in php.ini");
1239a20323eSDmitry Stogov		return FAILURE;
1249a20323eSDmitry Stogov	}
1259a20323eSDmitry Stogov
1269a20323eSDmitry Stogov	*p = val;
1279a20323eSDmitry Stogov	return SUCCESS;
1289a20323eSDmitry Stogov}
1299a20323eSDmitry Stogov/* }}} */
130bbf3d43cSMoriyoshi Koizumi
1314be862b0SZeev SuraskiZEND_INI_BEGIN()
132eb6fd52eSZeev Suraski	ZEND_INI_ENTRY("error_reporting",				NULL,		ZEND_INI_ALL,		OnUpdateErrorReporting)
133fb2c890cSRasmus Lerdorf	STD_ZEND_INI_ENTRY("zend.assertions",				"1",    ZEND_INI_ALL,       OnUpdateAssertions,           assertions,   zend_executor_globals,  executor_globals)
13471592cecSDmitry Stogov	STD_ZEND_INI_BOOLEAN("zend.enable_gc",				"1",	ZEND_INI_ALL,		OnUpdateGCEnabled,      gc_enabled,     zend_gc_globals,        gc_globals)
135ab93d8c6SDmitry Stogov 	STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR, OnUpdateBool, multibyte,      zend_compiler_globals, compiler_globals)
136bbf3d43cSMoriyoshi Koizumi 	ZEND_INI_ENTRY("zend.script_encoding",			NULL,		ZEND_INI_ALL,		OnUpdateScriptEncoding)
137bbf3d43cSMoriyoshi Koizumi 	STD_ZEND_INI_BOOLEAN("zend.detect_unicode",			"1",	ZEND_INI_ALL,		OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
13834d93f0cSIlia Alshanetsky#ifdef ZEND_SIGNALS
13934d93f0cSIlia Alshanetsky	STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
14034d93f0cSIlia Alshanetsky#endif
1414be862b0SZeev SuraskiZEND_INI_END()
1424be862b0SZeev Suraski
1434be862b0SZeev Suraski
1447a87fcbbSZeev Suraski#ifdef ZTS
145d11734b4SAnatol BelskiZEND_API int compiler_globals_id;
146d11734b4SAnatol BelskiZEND_API int executor_globals_id;
147b4892511SJani Taskinenstatic HashTable *global_function_table = NULL;
148b4892511SJani Taskinenstatic HashTable *global_class_table = NULL;
149b4892511SJani Taskinenstatic HashTable *global_constants_table = NULL;
150b4892511SJani Taskinenstatic HashTable *global_auto_globals_table = NULL;
15121698c12SDmitry Stogovstatic HashTable *global_persistent_list = NULL;
1521ac15293SNikita PopovZEND_TSRMLS_CACHE_DEFINE()
1537a87fcbbSZeev Suraski#endif
154573b4602SAndi Gutmans
155e801a99aSZeev SuraskiZEND_API zend_utility_values zend_uv;
156573b4602SAndi Gutmans
157573b4602SAndi Gutmans/* version information */
158573b4602SAndi Gutmansstatic char *zend_version_info;
159573b4602SAndi Gutmansstatic uint zend_version_info_length;
16097a9470dSXinchen Hui#define ZEND_CORE_VERSION_INFO	"Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2016 Zend Technologies\n"
16180bab9d9SAndrei Zmievski#define PRINT_ZVAL_INDENT 4
162573b4602SAndi Gutmans
1631b29e0caSNikita Popovstatic void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent);
1641b29e0caSNikita Popov
1651b29e0caSNikita Popovstatic void print_hash(smart_str *buf, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
166573b4602SAndi Gutmans{
167f4cfaf36SDmitry Stogov	zval *tmp;
168f4cfaf36SDmitry Stogov	zend_string *string_key;
169c3e3c98eSAnatol Belski	zend_ulong num_key;
170573b4602SAndi Gutmans	int i;
171573b4602SAndi Gutmans
172b4892511SJani Taskinen	for (i = 0; i < indent; i++) {
1731b29e0caSNikita Popov		smart_str_appendc(buf, ' ');
174573b4602SAndi Gutmans	}
1751b29e0caSNikita Popov	smart_str_appends(buf, "(\n");
17680bab9d9SAndrei Zmievski	indent += PRINT_ZVAL_INDENT;
1771b29e0caSNikita Popov	ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
178b4892511SJani Taskinen		for (i = 0; i < indent; i++) {
1791b29e0caSNikita Popov			smart_str_appendc(buf, ' ');
180573b4602SAndi Gutmans		}
1811b29e0caSNikita Popov		smart_str_appendc(buf, '[');
1827652a977SDmitry Stogov		if (string_key) {
1837652a977SDmitry Stogov			if (is_object) {
1847652a977SDmitry Stogov				const char *prop_name, *class_name;
185079409bbSNikita Popov				size_t prop_len;
186079409bbSNikita Popov				int mangled = zend_unmangle_property_name_ex(string_key, &class_name, &prop_name, &prop_len);
1877652a977SDmitry Stogov
1881b29e0caSNikita Popov				smart_str_appendl(buf, prop_name, prop_len);
1897652a977SDmitry Stogov				if (class_name && mangled == SUCCESS) {
1901b29e0caSNikita Popov					if (class_name[0] == '*') {
1911b29e0caSNikita Popov						smart_str_appends(buf, ":protected");
1927652a977SDmitry Stogov					} else {
1931b29e0caSNikita Popov						smart_str_appends(buf, ":");
1941b29e0caSNikita Popov						smart_str_appends(buf, class_name);
1951b29e0caSNikita Popov						smart_str_appends(buf, ":private");
196d329ce93SZeev Suraski					}
197d3d02fbcSDmitry Stogov				}
1987652a977SDmitry Stogov			} else {
1991b29e0caSNikita Popov				smart_str_append(buf, string_key);
2007652a977SDmitry Stogov			}
2017652a977SDmitry Stogov		} else {
2021b29e0caSNikita Popov			smart_str_append_long(buf, num_key);
203573b4602SAndi Gutmans		}
2041b29e0caSNikita Popov		smart_str_appends(buf, "] => ");
2051b29e0caSNikita Popov		zend_print_zval_r_to_buf(buf, tmp, indent+PRINT_ZVAL_INDENT);
2061b29e0caSNikita Popov		smart_str_appends(buf, "\n");
2077652a977SDmitry Stogov	} ZEND_HASH_FOREACH_END();
20880bab9d9SAndrei Zmievski	indent -= PRINT_ZVAL_INDENT;
209b4892511SJani Taskinen	for (i = 0; i < indent; i++) {
2101b29e0caSNikita Popov		smart_str_appendc(buf, ' ');
211573b4602SAndi Gutmans	}
2121b29e0caSNikita Popov	smart_str_appends(buf, ")\n");
213573b4602SAndi Gutmans}
214b4892511SJani Taskinen/* }}} */
215573b4602SAndi Gutmans
216bdeb220fSAnatol Belskistatic void print_flat_hash(HashTable *ht) /* {{{ */
21727de54b0SAndi Gutmans{
218f4cfaf36SDmitry Stogov	zval *tmp;
219f4cfaf36SDmitry Stogov	zend_string *string_key;
220c3e3c98eSAnatol Belski	zend_ulong num_key;
221b4892511SJani Taskinen	int i = 0;
222b4892511SJani Taskinen
2230ade00c8SNikita Popov	ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
224b4892511SJani Taskinen		if (i++ > 0) {
225b4892511SJani Taskinen			ZEND_PUTS(",");
226b4892511SJani Taskinen		}
227b4892511SJani Taskinen		ZEND_PUTS("[");
2287652a977SDmitry Stogov		if (string_key) {
2297aa76271SDmitry Stogov			ZEND_WRITE(ZSTR_VAL(string_key), ZSTR_LEN(string_key));
2307652a977SDmitry Stogov		} else {
2314d997f63SAnatol Belski			zend_printf(ZEND_ULONG_FMT, num_key);
232b4892511SJani Taskinen		}
233b4892511SJani Taskinen		ZEND_PUTS("] => ");
234bdeb220fSAnatol Belski		zend_print_flat_zval_r(tmp);
2357652a977SDmitry Stogov	} ZEND_HASH_FOREACH_END();
23627de54b0SAndi Gutmans}
237b4892511SJani Taskinen/* }}} */
2387a87fcbbSZeev Suraski
239bdeb220fSAnatol BelskiZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
240573b4602SAndi Gutmans{
241f3a6c30cSXinchen Hui	if (Z_TYPE_P(expr) == IS_STRING) {
2429d6e45a0SDmitry Stogov		return 0;
24322fbfdfbSXinchen Hui	} else {
244bdeb220fSAnatol Belski		ZVAL_STR(expr_copy, _zval_get_string_func(expr));
24522fbfdfbSXinchen Hui		return 1;
246da9faa2cSZeev Suraski	}
247da9faa2cSZeev Suraski}
248b4892511SJani Taskinen/* }}} */
249da9faa2cSZeev Suraski
250bdeb220fSAnatol BelskiZEND_API size_t zend_print_zval(zval *expr, int indent) /* {{{ */
251da9faa2cSZeev Suraski{
2524ed452c1SDmitry Stogov	zend_string *str = zval_get_string(expr);
2537aa76271SDmitry Stogov	size_t len = ZSTR_LEN(str);
254da9faa2cSZeev Suraski
255bda96e3cSNikita Popov	if (len != 0) {
2561b29e0caSNikita Popov		zend_write(ZSTR_VAL(str), len);
257573b4602SAndi Gutmans	}
258bda96e3cSNikita Popov
259c3e3c98eSAnatol Belski	zend_string_release(str);
260bda96e3cSNikita Popov	return len;
261573b4602SAndi Gutmans}
262b4892511SJani Taskinen/* }}} */
263573b4602SAndi Gutmans
264bdeb220fSAnatol BelskiZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
26527de54b0SAndi Gutmans{
266b4892511SJani Taskinen	switch (Z_TYPE_P(expr)) {
267b4892511SJani Taskinen		case IS_ARRAY:
268b4892511SJani Taskinen			ZEND_PUTS("Array (");
269b3b616cfSDmitry Stogov			if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
270b3b616cfSDmitry Stogov			    ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
271b4892511SJani Taskinen				ZEND_PUTS(" *RECURSION*");
27272c287bdSDmitry Stogov				Z_ARRVAL_P(expr)->u.v.nApplyCount--;
273b4892511SJani Taskinen				return;
274b4892511SJani Taskinen			}
275bdeb220fSAnatol Belski			print_flat_hash(Z_ARRVAL_P(expr));
276b4892511SJani Taskinen			ZEND_PUTS(")");
277b3b616cfSDmitry Stogov			if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
278b3b616cfSDmitry Stogov				Z_ARRVAL_P(expr)->u.v.nApplyCount--;
279b3b616cfSDmitry Stogov			}
280b4892511SJani Taskinen			break;
281b4892511SJani Taskinen		case IS_OBJECT:
282b4892511SJani Taskinen		{
2839bba373aSStanislav Malyshev			HashTable *properties = NULL;
284bdeb220fSAnatol Belski			zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
2857aa76271SDmitry Stogov			zend_printf("%s Object (", ZSTR_VAL(class_name));
286df79b9b2SNikita Popov			zend_string_release(class_name);
2878ce1211aSMarcus Boerger
288dc764bf6SNikita Popov			if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
289dc764bf6SNikita Popov				ZEND_PUTS(" *RECURSION*");
290dc764bf6SNikita Popov				return;
291dc764bf6SNikita Popov			}
292dc764bf6SNikita Popov
293f30f3590SStanislav Malyshev			if (Z_OBJ_HANDLER_P(expr, get_properties)) {
2949bba373aSStanislav Malyshev				properties = Z_OBJPROP_P(expr);
2959bba373aSStanislav Malyshev			}
296f30f3590SStanislav Malyshev			if (properties) {
297dc764bf6SNikita Popov				Z_OBJ_INC_APPLY_COUNT_P(expr);
298bdeb220fSAnatol Belski				print_flat_hash(properties);
299dc764bf6SNikita Popov				Z_OBJ_DEC_APPLY_COUNT_P(expr);
3009bba373aSStanislav Malyshev			}
3019bba373aSStanislav Malyshev			ZEND_PUTS(")");
3029bba373aSStanislav Malyshev			break;
303b4892511SJani Taskinen		}
304b4892511SJani Taskinen		default:
305bdeb220fSAnatol Belski			zend_print_variable(expr);
306b4892511SJani Taskinen			break;
307b4892511SJani Taskinen	}
30827de54b0SAndi Gutmans}
309b4892511SJani Taskinen/* }}} */
310573b4602SAndi Gutmans
3111b29e0caSNikita Popovstatic void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* {{{ */
312573b4602SAndi Gutmans{
313c6cba554SDmitry Stogov	ZVAL_DEREF(expr);
314b4892511SJani Taskinen	switch (Z_TYPE_P(expr)) {
315573b4602SAndi Gutmans		case IS_ARRAY:
3161b29e0caSNikita Popov			smart_str_appends(buf, "Array\n");
317b3b616cfSDmitry Stogov			if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
318b3b616cfSDmitry Stogov			    ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
3191b29e0caSNikita Popov				smart_str_appends(buf, " *RECURSION*");
32072c287bdSDmitry Stogov				Z_ARRVAL_P(expr)->u.v.nApplyCount--;
3216053f2a1SZeev Suraski				return;
3226053f2a1SZeev Suraski			}
3231b29e0caSNikita Popov			print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
324b3b616cfSDmitry Stogov			if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
325b3b616cfSDmitry Stogov				Z_ARRVAL_P(expr)->u.v.nApplyCount--;
326b3b616cfSDmitry Stogov			}
327573b4602SAndi Gutmans			break;
328573b4602SAndi Gutmans		case IS_OBJECT:
329c259cb7cSAndi Gutmans			{
3308ce1211aSMarcus Boerger				HashTable *properties;
3318ce1211aSMarcus Boerger				int is_temp;
3328ce1211aSMarcus Boerger
333bdeb220fSAnatol Belski				zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
3341b29e0caSNikita Popov				smart_str_appends(buf, ZSTR_VAL(class_name));
335df79b9b2SNikita Popov				zend_string_release(class_name);
336df79b9b2SNikita Popov
3371b29e0caSNikita Popov				smart_str_appends(buf, " Object\n");
338dc764bf6SNikita Popov				if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
3391b29e0caSNikita Popov					smart_str_appends(buf, " *RECURSION*");
3408ce1211aSMarcus Boerger					return;
3418ce1211aSMarcus Boerger				}
342dc764bf6SNikita Popov				if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
343dc764bf6SNikita Popov					break;
344dc764bf6SNikita Popov				}
345dc764bf6SNikita Popov
346dc764bf6SNikita Popov				Z_OBJ_INC_APPLY_COUNT_P(expr);
3471b29e0caSNikita Popov				print_hash(buf, properties, indent, 1);
348dc764bf6SNikita Popov				Z_OBJ_DEC_APPLY_COUNT_P(expr);
349dc764bf6SNikita Popov
3508ce1211aSMarcus Boerger				if (is_temp) {
3518ce1211aSMarcus Boerger					zend_hash_destroy(properties);
3524e7cbf3fSDmitry Stogov					FREE_HASHTABLE(properties);
353c259cb7cSAndi Gutmans				}
354c259cb7cSAndi Gutmans				break;
3556053f2a1SZeev Suraski			}
3561b29e0caSNikita Popov		case IS_LONG:
3571b29e0caSNikita Popov			smart_str_append_long(buf, Z_LVAL_P(expr));
3581b29e0caSNikita Popov			break;
359573b4602SAndi Gutmans		default:
3601b29e0caSNikita Popov			{
3611b29e0caSNikita Popov				zend_string *str = zval_get_string(expr);
3621b29e0caSNikita Popov				smart_str_append(buf, str);
3631b29e0caSNikita Popov				zend_string_release(str);
3641b29e0caSNikita Popov			}
365573b4602SAndi Gutmans			break;
366573b4602SAndi Gutmans	}
367573b4602SAndi Gutmans}
368b4892511SJani Taskinen/* }}} */
369573b4602SAndi Gutmans
3701b29e0caSNikita PopovZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent) /* {{{ */
3711b29e0caSNikita Popov{
3721b29e0caSNikita Popov	smart_str buf = {0};
3731b29e0caSNikita Popov	zend_print_zval_r_to_buf(&buf, expr, indent);
3741b29e0caSNikita Popov	smart_str_0(&buf);
3751b29e0caSNikita Popov	return buf.s;
3761b29e0caSNikita Popov}
3771b29e0caSNikita Popov/* }}} */
3781b29e0caSNikita Popov
3791b29e0caSNikita PopovZEND_API void zend_print_zval_r(zval *expr, int indent) /* {{{ */
3801b29e0caSNikita Popov{
3811b29e0caSNikita Popov	zend_string *str = zend_print_zval_r_to_str(expr, indent);
3821b29e0caSNikita Popov	zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
3831b29e0caSNikita Popov	zend_string_release(str);
3841b29e0caSNikita Popov}
3851b29e0caSNikita Popov/* }}} */
3861b29e0caSNikita Popov
3872fa8d67aSDmitry Stogovstatic FILE *zend_fopen_wrapper(const char *filename, zend_string **opened_path) /* {{{ */
388573b4602SAndi Gutmans{
3895463dd5bSAndi Gutmans	if (opened_path) {
3902fa8d67aSDmitry Stogov		*opened_path = zend_string_init(filename, strlen(filename), 0);
3915463dd5bSAndi Gutmans	}
392f311ab16SAndi Gutmans	return fopen(filename, "rb");
393573b4602SAndi Gutmans}
394b4892511SJani Taskinen/* }}} */
395573b4602SAndi Gutmans
3962f586e96SDmitry Stogov#ifdef ZTS
397e756333bSNikita Popovstatic zend_bool short_tags_default      = 1;
3986f9f0bf2SAnatol Belskistatic uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
3992f586e96SDmitry Stogov#else
4008c885b89SDmitry Stogov# define short_tags_default			1
401