15dbb3a77SWez Furlong/*
2aceaabceSZeev Suraski   +----------------------------------------------------------------------+
3d0cb7153SJohannes Schlüter   | PHP Version 7                                                        |
4aceaabceSZeev Suraski   +----------------------------------------------------------------------+
5a6519d05SXinchen Hui   | Copyright (c) 1997-2018 The PHP Group                                |
6aceaabceSZeev Suraski   +----------------------------------------------------------------------+
75bd93221Sfoobar   | This source file is subject to version 3.01 of the PHP license,      |
8c5724cbdSZeev 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:           |
105bd93221Sfoobar   | http://www.php.net/license/3_01.txt                                  |
11c5724cbdSZeev Suraski   | If you did not receive a copy of the PHP license and are unable to   |
12c5724cbdSZeev Suraski   | obtain it through the world-wide-web, please send a note to          |
13c5724cbdSZeev Suraski   | license@php.net so we can mail you a copy immediately.               |
14aceaabceSZeev Suraski   +----------------------------------------------------------------------+
159afce019SZeev Suraski   | Authors: Andi Gutmans <andi@php.net>                                 |
169afce019SZeev Suraski   |          Zeev Suraski <zeev@php.net>                                 |
17aceaabceSZeev Suraski   +----------------------------------------------------------------------+
18aceaabceSZeev Suraski */
19aceaabceSZeev Suraski
2016017f6dSSascha Schumann#ifndef PHP_H
2116017f6dSSascha Schumann#define PHP_H
22aceaabceSZeev Suraski
236ec71637SSascha Schumann#ifdef HAVE_DMALLOC
246ec71637SSascha Schumann#include <dmalloc.h>
256ec71637SSascha Schumann#endif
266ec71637SSascha Schumann
27144e8d1fSChristoph M. Becker#define PHP_API_VERSION 20180731
2868d2592fSSascha Schumann#define PHP_HAVE_STREAMS
29aceaabceSZeev Suraski#define YYDEBUG 0
30cbd108abSYasuo Ohgaki#define PHP_DEFAULT_CHARSET "UTF-8"
31aceaabceSZeev Suraski
32aceaabceSZeev Suraski#include "php_version.h"
33aceaabceSZeev Suraski#include "zend.h"
342193de0dSXinchen Hui#include "zend_sort.h"
35315999daSSascha Schumann#include "php_compat.h"
36f9f82960SStig Bakken
37aceaabceSZeev Suraski#include "zend_API.h"
38aceaabceSZeev Suraski
39d180634eSSascha Schumann#undef sprintf
40d180634eSSascha Schumann#define sprintf php_sprintf
41aceaabceSZeev Suraski
42c136fda1SJavier Eguiluz/* Operating system family definition */
43f9959ee7SKalle Sommer Nielsen#ifdef PHP_WIN32
44f9959ee7SKalle Sommer Nielsen# define PHP_OS_FAMILY			"Windows"
45f9959ee7SKalle Sommer Nielsen#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
46f9959ee7SKalle Sommer Nielsen# define PHP_OS_FAMILY			"BSD"
47f9959ee7SKalle Sommer Nielsen#elif defined(__APPLE__) || defined(__MACH__)
48a251d9b2SKalle Sommer Nielsen# define PHP_OS_FAMILY			"Darwin"
49f9959ee7SKalle Sommer Nielsen#elif defined(__sun__)
50f9959ee7SKalle Sommer Nielsen# define PHP_OS_FAMILY			"Solaris"
51f9959ee7SKalle Sommer Nielsen#elif defined(__linux__)
52db982bbaSKalle Sommer Nielsen# define PHP_OS_FAMILY			"Linux"
53db982bbaSKalle Sommer Nielsen#else
54f9959ee7SKalle Sommer Nielsen# define PHP_OS_FAMILY			"Unknown"
55f9959ee7SKalle Sommer Nielsen#endif
56f9959ee7SKalle Sommer Nielsen
57a9fcfb13SShane Caraveo/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
58a9fcfb13SShane Caraveo#undef PHP_DEBUG
59a9fcfb13SShane Caraveo#define PHP_DEBUG ZEND_DEBUG
60a9fcfb13SShane Caraveo
6180bdd19eSZeev Suraski#ifdef PHP_WIN32
62240fa244SDmitry Stogov#	include "tsrm_win32.h"
637942eaf3SZeev Suraski#	ifdef PHP_EXPORTS
64240fa244SDmitry Stogov#		define PHPAPI __declspec(dllexport)
657942eaf3SZeev Suraski#	else
66240fa244SDmitry Stogov#		define PHPAPI __declspec(dllimport)
677942eaf3SZeev Suraski#	endif
68240fa244SDmitry Stogov#	define PHP_DIR_SEPARATOR '\\'
69240fa244SDmitry Stogov#	define PHP_EOL "\r\n"
70aceaabceSZeev Suraski#else
71240fa244SDmitry Stogov#	if defined(__GNUC__) && __GNUC__ >= 4
72240fa244SDmitry Stogov#		define PHPAPI __attribute__ ((visibility("default")))
73240fa244SDmitry Stogov#	else
74240fa244SDmitry Stogov#		define PHPAPI
75240fa244SDmitry Stogov#	endif
764ac6c512SRasmus Lerdorf#	define THREAD_LS
774ac6c512SRasmus Lerdorf#	define PHP_DIR_SEPARATOR '/'
784ac6c512SRasmus Lerdorf#	define PHP_EOL "\n"
79aceaabceSZeev Suraski#endif
80aceaabceSZeev Suraski
81d4831e2dSKalle Sommer Nielsen/* Windows specific defines */
82d4831e2dSKalle Sommer Nielsen#ifdef PHP_WIN32
83d4831e2dSKalle Sommer Nielsen# define PHP_PROG_SENDMAIL		"Built in mailer"
84d4831e2dSKalle Sommer Nielsen# define HAVE_DECLARED_TIMEZONE
85d4831e2dSKalle Sommer Nielsen# define WIN32_LEAN_AND_MEAN
86d4831e2dSKalle Sommer Nielsen# define NOOPENFILE
87d4831e2dSKalle Sommer Nielsen
88d4831e2dSKalle Sommer Nielsen# include <io.h>
89d4831e2dSKalle Sommer Nielsen# include <malloc.h>
90d4831e2dSKalle Sommer Nielsen# include <direct.h>
91d4831e2dSKalle Sommer Nielsen# include <stdlib.h>
92d4831e2dSKalle Sommer Nielsen# include <stdio.h>
93d4831e2dSKalle Sommer Nielsen# include <stdarg.h>
94d4831e2dSKalle Sommer Nielsen# include <sys/types.h>
95d4831e2dSKalle Sommer Nielsen# include <process.h>
96d4831e2dSKalle Sommer Nielsen
97d4831e2dSKalle Sommer Nielsentypedef int uid_t;
98d4831e2dSKalle Sommer Nielsentypedef int gid_t;
99d4831e2dSKalle Sommer Nielsentypedef char * caddr_t;
100d4831e2dSKalle Sommer Nielsentypedef unsigned int uint;
101d4831e2dSKalle Sommer Nielsentypedef unsigned long ulong;
102d4831e2dSKalle Sommer Nielsentypedef int pid_t;
103d4831e2dSKalle Sommer Nielsen
104d4831e2dSKalle Sommer Nielsen# ifndef PHP_DEBUG
105d4831e2dSKalle Sommer Nielsen#  ifdef inline
106d4831e2dSKalle Sommer Nielsen#   undef inline
107d4831e2dSKalle Sommer Nielsen#  endif
108d4831e2dSKalle Sommer Nielsen#  define inline		__inline
109d4831e2dSKalle Sommer Nielsen# endif
110d4831e2dSKalle Sommer Nielsen
111d4831e2dSKalle Sommer Nielsen# define M_TWOPI        (M_PI * 2.0)
112d4831e2dSKalle Sommer Nielsen# define off_t			_off_t
113d4831e2dSKalle Sommer Nielsen
114d4831e2dSKalle Sommer Nielsen# define lstat(x, y)	php_sys_lstat(x, y)
115d4831e2dSKalle Sommer Nielsen# define chdir(path)	_chdir(path)
116d4831e2dSKalle Sommer Nielsen# define mkdir(a, b)	_mkdir(a)
117d4831e2dSKalle Sommer Nielsen# define rmdir(a)		_rmdir(a)
118d4831e2dSKalle Sommer Nielsen# define getpid			_getpid
119d4831e2dSKalle Sommer Nielsen# define php_sleep(t)	SleepEx(t*1000, TRUE)
120d4831e2dSKalle Sommer Nielsen
121d4831e2dSKalle Sommer Nielsen# ifndef getcwd
122d4831e2dSKalle Sommer Nielsen#  define getcwd(a, b)	_getcwd(a, b)
123d4831e2dSKalle Sommer Nielsen# endif
124d4831e2dSKalle Sommer Nielsen#endif
125d4831e2dSKalle Sommer Nielsen
126cbc1cd80SYasuo Ohgaki#if HAVE_ASSERT_H
127cbc1cd80SYasuo Ohgaki#if PHP_DEBUG
128cbc1cd80SYasuo Ohgaki#undef NDEBUG
129cbc1cd80SYasuo Ohgaki#else
13012bc9543Sjim winstead#ifndef NDEBUG
131cbc1cd80SYasuo Ohgaki#define NDEBUG
132cbc1cd80SYasuo Ohgaki#endif
13312bc9543Sjim winstead#endif
134cbc1cd80SYasuo Ohgaki#include <assert.h>
135cbc1cd80SYasuo Ohgaki#else /* HAVE_ASSERT_H */
136cbc1cd80SYasuo Ohgaki#define assert(expr) ((void) (0))
137cbc1cd80SYasuo Ohgaki#endif /* HAVE_ASSERT_H */
138aceaabceSZeev Suraski
1396d0ab616SZeev Suraski#define APACHE 0
140aceaabceSZeev Suraski
141aceaabceSZeev Suraski#if HAVE_UNIX_H
142aceaabceSZeev Suraski#include <unix.h>
143aceaabceSZeev Suraski#endif
144aceaabceSZeev Suraski
145aceaabceSZeev Suraski#if HAVE_ALLOCA_H
146aceaabceSZeev Suraski#include <alloca.h>
147aceaabceSZeev Suraski#endif
148aceaabceSZeev Suraski
1492909e5c9SSascha Schumann#if HAVE_BUILD_DEFS_H
15014058c83Sfoobar#include <build-defs.h>
1512909e5c9SSascha Schumann#endif
1522909e5c9SSascha Schumann
153365edaddSSascha Schumann/*
154365edaddSSascha Schumann * This is a fast version of strlcpy which should be used, if you
1552eb8688fSSascha Schumann * know the size of the destination buffer and if you know
156365edaddSSascha Schumann * the length of the source string.
157365edaddSSascha Schumann *
1582eb8688fSSascha Schumann * size is the allocated number of bytes of dst
1592eb8688fSSascha Schumann * src_size is the number of bytes excluding the NUL of src
160365edaddSSascha Schumann */
161365edaddSSascha Schumann
162365edaddSSascha Schumann#define PHP_STRLCPY(dst, src, size, src_size)	\
163365edaddSSascha Schumann	{											\
164365edaddSSascha Schumann		size_t php_str_len;						\
165365edaddSSascha Schumann												\
166365edaddSSascha Schumann		if (src_size >= size)					\
167365edaddSSascha Schumann			php_str_len = size - 1;				\
168365edaddSSascha Schumann		else									\
169365edaddSSascha Schumann			php_str_len = src_size;				\
170365edaddSSascha Schumann		memcpy(dst, src, php_str_len);			\
171365edaddSSascha Schumann		dst[php_str_len] = '\0';				\
172365edaddSSascha Schumann	}
173365edaddSSascha Schumann
1741740e6eeSStig Bakken#ifndef HAVE_STRLCPY
175e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
17639e28225SSterling HughesPHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
177e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
1789979003eSSascha Schumann#undef strlcpy
17939e28225SSterling Hughes#define strlcpy php_strlcpy
1805d5679c4SAnatol Belski#define HAVE_STRLCPY 1
18165afcf81SAnatol Belski#define USE_STRLCPY_PHP_IMPL 1
18261a3c147SAndi Gutmans#endif
18361a3c147SAndi Gutmans
1841740e6eeSStig Bakken#ifndef HAVE_STRLCAT
185e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
18639e28225SSterling HughesPHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
187e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
1889979003eSSascha Schumann#undef strlcat
18939e28225SSterling Hughes#define strlcat php_strlcat
1905d5679c4SAnatol Belski#define HAVE_STRLCAT 1
19165afcf81SAnatol Belski#define USE_STRLCAT_PHP_IMPL 1
19261a3c147SAndi Gutmans#endif
19361a3c147SAndi Gutmans
1941ece7641SDavid Carlier#ifndef HAVE_EXPLICIT_BZERO
1952464dbd5SDavid CarlierBEGIN_EXTERN_C()
1962464dbd5SDavid CarlierPHPAPI void php_explicit_bzero(void *dst, size_t siz);
1972464dbd5SDavid CarlierEND_EXTERN_C()
1982464dbd5SDavid Carlier#undef explicit_bzero
1992464dbd5SDavid Carlier#define explicit_bzero php_explicit_bzero
2002464dbd5SDavid Carlier#endif
2012464dbd5SDavid Carlier
20285210ed9SZeev Suraski#ifndef HAVE_STRTOK_R
203e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
20485210ed9SZeev Suraskichar *strtok_r(char *s, const char *delim, char **last);
205e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
20685210ed9SZeev Suraski#endif
20785210ed9SZeev Suraski
2085b2ecc5bSSascha Schumann#ifndef HAVE_SOCKLEN_T
209d2923ec1SXinchen Hui# ifdef PHP_WIN32
210a7ffa09eSPierre Joyetypedef int socklen_t;
211a7ffa09eSPierre Joye# else
2125b2ecc5bSSascha Schumanntypedef unsigned int socklen_t;
213a7ffa09eSPierre Joye# endif
2145b2ecc5bSSascha Schumann#endif
2155b2ecc5bSSascha Schumann
2161159c84aSZeev Suraski#define CREATE_MUTEX(a, b)
217aceaabceSZeev Suraski#define SET_MUTEX(a)
218aceaabceSZeev Suraski#define FREE_MUTEX(a)
219aceaabceSZeev Suraski
220aceaabceSZeev Suraski/*
221aceaabceSZeev Suraski * Then the ODBC support can use both iodbc and Solid,
222aceaabceSZeev Suraski * uncomment this.
223aceaabceSZeev Suraski * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
224aceaabceSZeev Suraski */
225aceaabceSZeev Suraski
226aceaabceSZeev Suraski#include <stdlib.h>
227aceaabceSZeev Suraski#include <ctype.h>
228aceaabceSZeev Suraski#if HAVE_UNISTD_H
229aceaabceSZeev Suraski#include <unistd.h>
230aceaabceSZeev Suraski#endif
231aceaabceSZeev Suraski#if HAVE_STDARG_H
232aceaabceSZeev Suraski#include <stdarg.h>
2335dbb3a77SWez Furlong#else
234aceaabceSZeev Suraski# if HAVE_SYS_VARARGS_H
235aceaabceSZeev Suraski# include <sys/varargs.h>
2365dbb3a77SWez Furlong# endif
2375dbb3a77SWez Furlong#endif
238aceaabceSZeev Suraski
23914caf174SMichael Wallner#include "php_stdint.h"
24014caf174SMichael Wallner
241aceaabceSZeev Suraski#include "zend_hash.h"
242aceaabceSZeev Suraski#include "zend_alloc.h"
243aceaabceSZeev Suraski#include "zend_stack.h"
244aceaabceSZeev Suraski
245aceaabceSZeev Suraski#if STDC_HEADERS
246aceaabceSZeev Suraski# include <string.h>
247aceaabceSZeev Suraski#else
248aceaabceSZeev Suraski# ifndef HAVE_MEMCPY
249aceaabceSZeev Suraski#  define memcpy(d, s, n)	bcopy((s), (d), (n))
250a8f0c5a3SRasmus Lerdorf# endif
251a8f0c5a3SRasmus Lerdorf# ifndef HAVE_MEMMOVE
252aceaabceSZeev Suraski#  define memmove(d, s, n)	bcopy ((s), (d), (n))
253aceaabceSZeev Suraski# endif
254aceaabceSZeev Suraski#endif
255aceaabceSZeev Suraski
256aceaabceSZeev Suraski#ifndef HAVE_STRERROR
2578e0ae5d1SSascha Schumannchar *strerror(int);
258aceaabceSZeev Suraski#endif
259aceaabceSZeev Suraski
260aceaabceSZeev Suraski#if HAVE_PWD_H
26180bdd19eSZeev Suraski# ifdef PHP_WIN32
262aceaabceSZeev Suraski#include "win32/param.h"
263aceaabceSZeev Suraski# else
264aceaabceSZeev Suraski#include <pwd.h>
265aceaabceSZeev Suraski#include <sys/param.h>
266aceaabceSZeev Suraski# endif
267aceaabceSZeev Suraski#endif
268aceaabceSZeev Suraski
269aceaabceSZeev Suraski#if HAVE_LIMITS_H
270aceaabceSZeev Suraski#include <limits.h>
271aceaabceSZeev Suraski#endif
272aceaabceSZeev Suraski
273aceaabceSZeev Suraski#ifndef LONG_MAX
274aceaabceSZeev Suraski#define LONG_MAX 2147483647L
275aceaabceSZeev Suraski#endif
276aceaabceSZeev Suraski
277aceaabceSZeev Suraski#ifndef LONG_MIN
278aceaabceSZeev Suraski#define LONG_MIN (- LONG_MAX - 1)
279aceaabceSZeev Suraski#endif
280aceaabceSZeev Suraski
2816d98fc38SStefan Esser#ifndef INT_MAX
2826d98fc38SStefan Esser#define INT_MAX 2147483647
2836d98fc38SStefan Esser#endif
2846d98fc38SStefan Esser
2856d98fc38SStefan Esser#ifndef INT_MIN
2866d98fc38SStefan Esser#define INT_MIN (- INT_MAX - 1)
2876d98fc38SStefan Esser#endif
2886d98fc38SStefan Esser
2893f13507dSJakub Zelenka/* double limits */
2903f13507dSJakub Zelenka#include <float.h>
2913f13507dSJakub Zelenka#if defined(DBL_MANT_DIG) && defined(DBL_MIN_EXP)
2923f13507dSJakub Zelenka#define PHP_DOUBLE_MAX_LENGTH (3 + DBL_MANT_DIG - DBL_MIN_EXP)
2933f13507dSJakub Zelenka#else
2943f13507dSJakub Zelenka#define PHP_DOUBLE_MAX_LENGTH 1080
2953f13507dSJakub Zelenka#endif
2963f13507dSJakub Zelenka
297258d958dSSascha Schumann#define PHP_GCC_VERSION ZEND_GCC_VERSION
298258d958dSSascha Schumann#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
299341b7b5dSSascha Schumann#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
3005ef7cc4cSSascha Schumann
301816bcd3aSFrank M. KromannBEGIN_EXTERN_C()
302caeaaf4dSSascha Schumann#include "snprintf.h"
303816bcd3aSFrank M. KromannEND_EXTERN_C()
3043e70f373SMarcus Boerger#include "spprintf.h"
305aceaabceSZeev Suraski
306aceaabceSZeev Suraski#define EXEC_INPUT_BUF 4096
307aceaabceSZeev Suraski
308cc205c60SAndrei Zmievski#define PHP_MIME_TYPE "application/x-httpd-php"
309aceaabceSZeev Suraski
310aceaabceSZeev Suraski/* macros */
311cb2a2ea9SZeev Suraski#define STR_PRINT(str)	((str)?(str):"")
312aceaabceSZeev Suraski
313aceaabceSZeev Suraski#ifndef MAXPATHLEN
314d65459f4SXinchen Hui# ifdef PHP_WIN32
3153d3f11edSAnatol Belski#  include "win32/ioutil.h"
3163d3f11edSAnatol Belski#  define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
3173d3f11edSAnatol Belski# elif PATH_MAX
318204f4adcSAndi Gutmans#  define MAXPATHLEN PATH_MAX
319cd82349bSIlia Alshanetsky# elif defined(MAX_PATH)
320cd82349bSIlia Alshanetsky#  define MAXPATHLEN MAX_PATH
321204f4adcSAndi Gutmans# else
322204f4adcSAndi Gutmans#  define MAXPATHLEN 256    /* Should be safe for any weird systems that do not define it */
323204f4adcSAndi Gutmans# endif
324aceaabceSZeev Suraski#endif
325aceaabceSZeev Suraski
326c568ffe5SNikita Popov#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
327b10b24d5SWez Furlong
328aceaabceSZeev Suraski/* global variables */
32980bdd19eSZeev Suraski#if !defined(PHP_WIN32)
330494d6659SAndrey Hristov#define PHP_SLEEP_NON_VOID
3311b18be12SAnantha Kesari H Y#define php_sleep sleep
332aceaabceSZeev Suraskiextern char **environ;
3333e2f1526SAnantha Kesari H Y#endif	/* !defined(PHP_WIN32) */
3347942eaf3SZeev Suraski
335e2eaf634SSascha Schumann#ifdef PHP_PWRITE_64
336e2eaf634SSascha Schumannssize_t pwrite(int, void *, size_t, off64_t);
337e2eaf634SSascha Schumann#endif
338e2eaf634SSascha Schumann
339e2eaf634SSascha Schumann#ifdef PHP_PREAD_64
340e2eaf634SSascha Schumannssize_t pread(int, void *, size_t, off64_t);
341e2eaf634SSascha Schumann#endif
342e2eaf634SSascha Schumann
343e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
3448e0ae5d1SSascha Schumannvoid phperror(char *error);
345bdeb220fSAnatol BelskiPHPAPI size_t php_write(void *buf, size_t size);
346fdd1e96fSNikita PopovPHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
347fdd1e96fSNikita Popov		2);
34829565d1aSDerick RethansPHPAPI int php_get_module_initialized(void);
349d2bc8258SAnatol Belski#ifdef HAVE_SYSLOG_H
350d2bc8258SAnatol Belski#include "php_syslog.h"
35173fd1fc6SAnatol Belski#define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE)
352d2bc8258SAnatol Belski#else
353d2bc8258SAnatol Belski#define php_log_err(msg) php_log_err_with_severity(msg, 5)
354d2bc8258SAnatol Belski#endif
3550a04f614SJani OllikainenPHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int);
356fdd1e96fSNikita Popovint Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
357fdd1e96fSNikita Popovint cfgparse(void);
358e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
359aceaabceSZeev Suraski
36039aa59bdSZeev Suraski#define php_error zend_error
361e9a6f0f2SEtienne Kneuss#define error_handling_t zend_error_handling_t
3623fc4a327SMarcus Boerger
363e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
364bdeb220fSAnatol Belskistatic inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class)
3653f7a4b7eSMarcus Boerger{
366bdeb220fSAnatol Belski	zend_replace_error_handling(error_handling, exception_class, NULL);
3673f7a4b7eSMarcus Boerger}
3684c3563deSMarcus Boergerstatic inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
3693fc4a327SMarcus Boerger
37096ea4a0aSDmitry StogovPHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int type, const char *format, va_list args) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
371341b7b5dSSascha Schumann
372e50228abSMarcus Boerger/* PHPAPI void php_error(int type, const char *format, ...); */
37396ea4a0aSDmitry StogovPHPAPI ZEND_COLD void php_error_docref0(const char *docref, int type, const char *format, ...)
37459833783SNikita Popov	PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
37596ea4a0aSDmitry StogovPHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
37659833783SNikita Popov	PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
37796ea4a0aSDmitry StogovPHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
37859833783SNikita Popov	PHP_ATTRIBUTE_FORMAT(printf, 5, 6);
379bbf9b6dcSPierre Joye#ifdef PHP_WIN32
38096ea4a0aSDmitry StogovPHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
381bbf9b6dcSPierre Joye#endif
382e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
38388c385e8SMarcus Boerger
384d0bb8f5fSfoobar#define php_error_docref php_error_docref0
385d0bb8f5fSfoobar
386aceaabceSZeev Suraski#define zenderror phperror
387aceaabceSZeev Suraski#define zendlex phplex
388aceaabceSZeev Suraski
389aceaabceSZeev Suraski#define phpparse zendparse
390aceaabceSZeev Suraski#define phprestart zendrestart
391aceaabceSZeev Suraski#define phpin zendin
392aceaabceSZeev Suraski
3932154cdddSAndrei Zmievski#define php_memnstr zend_memnstr
3942154cdddSAndrei Zmievski
395aceaabceSZeev Suraski/* functions */
396e6ea5ca9SArd BiesheuvelBEGIN_EXTERN_C()
397bdeb220fSAnatol BelskiPHPAPI extern int (*php_register_internal_extensions_func)(void);
398bdeb220fSAnatol BelskiPHPAPI int php_register_internal_extensions(void);
399af66ad28SNikita PopovPHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *));
4003ff75e5bSThies C. ArntzenPHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
401bdeb220fSAnatol BelskiPHPAPI void php_com_initialize(void);
402bdeb220fSAnatol BelskiPHPAPI char *php_get_current_user(void);
403e6ea5ca9SArd BiesheuvelEND_EXTERN_C()
404aceaabceSZeev Suraski
405a2dd6625SZeev Suraski/* PHP-named Zend macro wrappers */
406a2dd6625SZeev Suraski#define PHP_FN					ZEND_FN
40758962c73SEdin Kadribasic#define PHP_MN					ZEND_MN
408a2dd6625SZeev Suraski#define PHP_NAMED_FUNCTION		ZEND_NAMED_FUNCTION
409a2dd6625SZeev Suraski#define PHP_FUNCTION			ZEND_FUNCTION
41081482833SAndrei Zmievski#define PHP_METHOD  			ZEND_METHOD
411a2dd6625SZeev Suraski
4121e19ee87SHannes Magnusson#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
413a2dd6625SZeev Suraski#define PHP_NAMED_FE	ZEND_NAMED_FE
414a2dd6625SZeev Suraski#define PHP_FE			ZEND_FE
415941b0651SMarcus Boerger#define PHP_DEP_FE      ZEND_DEP_FE
416a2dd6625SZeev Suraski#define PHP_FALIAS		ZEND_FALIAS
417941b0651SMarcus Boerger#define PHP_DEP_FALIAS	ZEND_DEP_FALIAS
41881482833SAndrei Zmievski#define PHP_ME          ZEND_ME
419854b3ebdSMarcus Boerger#define PHP_MALIAS      ZEND_MALIAS
42047ae4b0cSHartmut Holzgraefe#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
42161fc2a92SMarcus Boerger#define PHP_ME_MAPPING  ZEND_ME_MAPPING
422f8a3334cSFelipe Pena#define PHP_FE_END      ZEND_FE_END
423a2dd6625SZeev Suraski
424a2dd6625SZeev Suraski#define PHP_MODULE_STARTUP_N	ZEND_MODULE_STARTUP_N
425a2dd6625SZeev Suraski#define PHP_MODULE_SHUTDOWN_N	ZEND_MODULE_SHUTDOWN_N
426a2dd6625SZeev Suraski#define PHP_MODULE_ACTIVATE_N	ZEND_MODULE_ACTIVATE_N
427a2dd6625SZeev Suraski#define PHP_MODULE_DEACTIVATE_N	ZEND_MODULE_DEACTIVATE_N
428a2dd6625SZeev Suraski#define PHP_MODULE_INFO_N		ZEND_MODULE_INFO_N
429a2dd6625SZeev Suraski
430a2dd6625SZeev Suraski#define PHP_MODULE_STARTUP_D	ZEND_MODULE_STARTUP_D
431a2dd6625SZeev Suraski#define PHP_MODULE_SHUTDOWN_D	ZEND_MODULE_SHUTDOWN_D
432a2dd6625SZeev Suraski#define PHP_MODULE_ACTIVATE_D	ZEND_MODULE_ACTIVATE_D
433a2dd6625SZeev Suraski#define PHP_MODULE_DEACTIVATE_D	ZEND_MODULE_DEACTIVATE_D
434a2dd6625SZeev Suraski#define PHP_MODULE_INFO_D		ZEND_MODULE_INFO_D
435a2dd6625SZeev Suraski
436a2dd6625SZeev Suraski/* Compatibility macros */
437a2dd6625SZeev Suraski#define PHP_MINIT		ZEND_MODULE_STARTUP_N
438a2dd6625SZeev Suraski#define PHP_MSHUTDOWN	ZEND_MODULE_SHUTDOWN_N
439a2dd6625SZeev Suraski#define PHP_RINIT		ZEND_MODULE_ACTIVATE_N
440a2dd6625SZeev Suraski#define PHP_RSHUTDOWN	ZEND_MODULE_DEACTIVATE_N
441a2dd6625SZeev Suraski#define PHP_MINFO		ZEND_MODULE_INFO_N
44260328ea7SDmitry Stogov#define PHP_GINIT		ZEND_GINIT
44360328ea7SDmitry Stogov#define PHP_GSHUTDOWN	ZEND_GSHUTDOWN
444a2dd6625SZeev Suraski
445a2dd6625SZeev Suraski#define PHP_MINIT_FUNCTION		ZEND_MODULE_STARTUP_D
446a2dd6625SZeev Suraski#define PHP_MSHUTDOWN_FUNCTION	ZEND_MODULE_SHUTDOWN_D
447a2dd6625SZeev Suraski#define PHP_RINIT_FUNCTION		ZEND_MODULE_ACTIVATE_D
448a2dd6625SZeev Suraski#define PHP_RSHUTDOWN_FUNCTION	ZEND_MODULE_DEACTIVATE_D
449a2dd6625SZeev Suraski#define PHP_MINFO_FUNCTION		ZEND_MODULE_INFO_D
45060328ea7SDmitry Stogov#define PHP_GINIT_FUNCTION		ZEND_GINIT_FUNCTION
45160328ea7SDmitry Stogov#define PHP_GSHUTDOWN_FUNCTION	ZEND_GSHUTDOWN_FUNCTION
452b7a7b1a6SStanislav Malyshev
45360328ea7SDmitry Stogov#define PHP_MODULE_GLOBALS		ZEND_MODULE_GLOBALS
454a2dd6625SZeev Suraski
455a2dd6625SZeev Suraski
456aceaabceSZeev Suraski/* Output support */
4576f297a37SZeev Suraski#include "main/php_output.h"
45811d24c15SMichael Wallner
459aceaabceSZeev Suraski
460696e0a23SWez Furlong#include "php_streams.h"
461696e0a23SWez Furlong#include "php_memory_streams.h"
462696e0a23SWez Furlong#include "fopen_wrappers.h"
463696e0a23SWez Furlong
464696e0a23SWez Furlong
465341a0d46SAndi Gutmans/* Virtual current working directory support */
466e30b2aaeSAnatol Belski#include "zend_virtual_cwd.h"
467f118d947SAndi Gutmans
468aceaabceSZeev Suraski#include "zend_constants.h"
469aceaabceSZeev Suraski
4700bede914SRasmus Lerdorf/* connection status states */
4710bede914SRasmus Lerdorf#define PHP_CONNECTION_NORMAL  0
4720bede914SRasmus Lerdorf#define PHP_CONNECTION_ABORTED 1
4730bede914SRasmus Lerdorf#define PHP_CONNECTION_TIMEOUT 2
474aceaabceSZeev Suraski
47535b30a8dSSascha Schumann#include "php_reentrancy.h"
4763e584505SZeev Suraski
4773e584505SZeev Suraski/* Finding offsets of elements within structures.
4783e584505SZeev Suraski * Taken from the Apache code, which in turn, was taken from X code...
4793e584505SZeev Suraski */
4803e584505SZeev Suraski
48115b1e4baSSterling Hughes#ifndef XtOffset
482b8d26da1SAlex Waugh#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
4833e584505SZeev Suraski#ifdef __STDC__
4841159c84aSZeev Suraski#define XtOffset(p_type, field) _Offsetof(p_type, field)
4853e584505SZeev Suraski#else
4863e584505SZeev Suraski#ifdef CRAY2
4871159c84aSZeev Suraski#define XtOffset(p_type, field) \
4883e584505SZeev Suraski    (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
4893e584505SZeev Suraski
4903e584505SZeev Suraski#else /* !CRAY2 */
4913e584505SZeev Suraski
4921159c84aSZeev Suraski#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
4933e584505SZeev Suraski
4945dbb3a77SWez Furlong#endif /* !CRAY2 */
4953e584505SZeev Suraski#endif /* __STDC__ */
4963e584505SZeev Suraski#else /* ! (CRAY || __arm) */
4973e584505SZeev Suraski
4981159c84aSZeev Suraski#define XtOffset(p_type, field) \
499202e8db1SAnatol Belski    ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
5003e584505SZeev Suraski
5013e584505SZeev Suraski#endif /* !CRAY */
50215b1e4baSSterling Hughes#endif /* ! XtOffset */
5033e584505SZeev Suraski
50415b1e4baSSterling Hughes#ifndef XtOffsetOf
5053e584505SZeev Suraski#ifdef offsetof
5061159c84aSZeev Suraski#define XtOffsetOf(s_type, field) offsetof(s_type, field)
5073e584505SZeev Suraski#else
5081159c84aSZeev Suraski#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
5093e584505SZeev Suraski#endif
51015b1e4baSSterling Hughes#endif /* !XtOffsetOf */
5118c3535e1SMarcus Boerger
512aceaabceSZeev Suraski#endif
513aceaabceSZeev Suraski
514aceaabceSZeev Suraski/*
515aceaabceSZeev Suraski * Local variables:
516aceaabceSZeev Suraski * tab-width: 4
517aceaabceSZeev Suraski * c-basic-offset: 4
518aceaabceSZeev Suraski * End:
51978747bd2SDerick Rethans * vim600: sw=4 ts=4 fdm=marker
52078747bd2SDerick Rethans * vim<600: sw=4 ts=4
521aceaabceSZeev Suraski */
522