~bjori/php/5.next

1 by Mark A. Hershberger
Imported Upstream version 5.0.4
1
/*
2
   +----------------------------------------------------------------------+
3
   | PHP Version 5                                                        |
4
   +----------------------------------------------------------------------+
358 by Ondřej Surý
Imported Upstream version 5.3.6
5
   | Copyright (c) 1997-2011 The PHP Group                                |
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
6
   +----------------------------------------------------------------------+
1.1.3 by Mark A. Hershberger
Imported Upstream version 5.1.2
7
   | This source file is subject to version 3.01 of the PHP license,      |
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
8
   | that is bundled with this package in the file LICENSE, and is        |
9
   | available through the world-wide-web at the following url:           |
1.1.3 by Mark A. Hershberger
Imported Upstream version 5.1.2
10
   | http://www.php.net/license/3_01.txt                                  |
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
11
   | If you did not receive a copy of the PHP license and are unable to   |
12
   | obtain it through the world-wide-web, please send a note to          |
13
   | license@php.net 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
358 by Ondřej Surý
Imported Upstream version 5.3.6
20
/* $Id: php.h 306939 2011-01-01 02:19:59Z felipe $ */
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
21
22
#ifndef PHP_H
23
#define PHP_H
24
25
#ifdef HAVE_DMALLOC
26
#include <dmalloc.h>
27
#endif
28
1.2.3 by Sean Finney
Imported Upstream version 5.3.0
29
#define PHP_API_VERSION 20090626
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
30
#define PHP_HAVE_STREAMS
31
#define YYDEBUG 0
32
33
#include "php_version.h"
34
#include "zend.h"
35
#include "zend_qsort.h"
36
#include "php_compat.h"
37
38
#include "zend_API.h"
39
40
#undef sprintf
41
#define sprintf php_sprintf
42
43
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
44
#undef PHP_DEBUG
45
#define PHP_DEBUG ZEND_DEBUG
46
47
#ifdef PHP_WIN32
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
48
#	include "tsrm_win32.h"
49
#	include "win95nt.h"
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
50
#	ifdef PHP_EXPORTS
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
51
#		define PHPAPI __declspec(dllexport)
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
52
#	else
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
53
#		define PHPAPI __declspec(dllimport)
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
54
#	endif
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
55
#	define PHP_DIR_SEPARATOR '\\'
56
#	define PHP_EOL "\r\n"
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
57
#else
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
58
#	if defined(__GNUC__) && __GNUC__ >= 4
59
#		define PHPAPI __attribute__ ((visibility("default")))
60
#	else
61
#		define PHPAPI
62
#	endif
63
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
64
#define THREAD_LS
65
#define PHP_DIR_SEPARATOR '/'
66
#if defined(__MacOSX__)
67
#define PHP_EOL "\r"
68
#else 
69
#define PHP_EOL "\n"
70
#endif
71
#endif
72
1.1.2 by Mark A. Hershberger
Imported Upstream version 5.1.1
73
#ifdef NETWARE
74
/* For php_get_uname() function */
75
#define PHP_UNAME  "NetWare"
76
#define PHP_OS      PHP_UNAME
77
#endif
78
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
79
#if HAVE_ASSERT_H
80
#if PHP_DEBUG
81
#undef NDEBUG
82
#else
83
#ifndef NDEBUG
84
#define NDEBUG
85
#endif
86
#endif
87
#include <assert.h>
88
#else /* HAVE_ASSERT_H */
89
#define assert(expr) ((void) (0))
90
#endif /* HAVE_ASSERT_H */
91
92
#define APACHE 0
93
94
#if HAVE_UNIX_H
95
#include <unix.h>
96
#endif
97
98
#if HAVE_ALLOCA_H
99
#include <alloca.h>
100
#endif
101
102
#if HAVE_BUILD_DEFS_H
103
#include <build-defs.h>
104
#endif
105
106
/*
107
 * This is a fast version of strlcpy which should be used, if you
108
 * know the size of the destination buffer and if you know
109
 * the length of the source string.
110
 *
111
 * size is the allocated number of bytes of dst
112
 * src_size is the number of bytes excluding the NUL of src
113
 */
114
115
#define PHP_STRLCPY(dst, src, size, src_size)	\
116
	{											\
117
		size_t php_str_len;						\
118
												\
119
		if (src_size >= size)					\
120
			php_str_len = size - 1;				\
121
		else									\
122
			php_str_len = src_size;				\
123
		memcpy(dst, src, php_str_len);			\
124
		dst[php_str_len] = '\0';				\
125
	}
126
127
#ifndef HAVE_STRLCPY
128
BEGIN_EXTERN_C()
129
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
130
END_EXTERN_C()
131
#undef strlcpy
132
#define strlcpy php_strlcpy
133
#endif
134
135
#ifndef HAVE_STRLCAT
136
BEGIN_EXTERN_C()
137
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
138
END_EXTERN_C()
139
#undef strlcat
140
#define strlcat php_strlcat
141
#endif
142
143
#ifndef HAVE_STRTOK_R
144
BEGIN_EXTERN_C()
145
char *strtok_r(char *s, const char *delim, char **last);
146
END_EXTERN_C()
147
#endif
148
149
#ifndef HAVE_SOCKLEN_T
150
typedef unsigned int socklen_t;
151
#endif
152
153
#define CREATE_MUTEX(a, b)
154
#define SET_MUTEX(a)
155
#define FREE_MUTEX(a)
156
157
/*
158
 * Then the ODBC support can use both iodbc and Solid,
159
 * uncomment this.
160
 * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
161
 */
162
163
#include <stdlib.h>
164
#include <ctype.h>
165
#if HAVE_UNISTD_H
166
#include <unistd.h>
167
#endif
168
#if HAVE_STDARG_H
169
#include <stdarg.h>
170
#else
171
# if HAVE_SYS_VARARGS_H
172
# include <sys/varargs.h>
173
# endif
174
#endif
175
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
176
#ifndef va_copy
177
# ifdef __va_copy
178
#  define va_copy(ap1, ap2)         __va_copy((ap1), (ap2))
179
# else
180
#  define va_copy(ap1, ap2)         memcpy((&ap1), (&ap2), sizeof(va_list))
181
# endif
182
#endif
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
183
184
#include "zend_hash.h"
185
#include "php3_compat.h"
186
#include "zend_alloc.h"
187
#include "zend_stack.h"
188
189
#if STDC_HEADERS
190
# include <string.h>
191
#else
192
# ifndef HAVE_MEMCPY
193
#  define memcpy(d, s, n)	bcopy((s), (d), (n))
194
# endif
195
# ifndef HAVE_MEMMOVE
196
#  define memmove(d, s, n)	bcopy ((s), (d), (n))
197
# endif
198
#endif
199
200
#include "safe_mode.h"
201
202
#ifndef HAVE_STRERROR
203
char *strerror(int);
204
#endif
205
206
#if HAVE_PWD_H
207
# ifdef PHP_WIN32
208
#include "win32/param.h"
209
# else
210
#include <pwd.h>
211
#include <sys/param.h>
212
# endif
213
#endif
214
215
#if HAVE_LIMITS_H
216
#include <limits.h>
217
#endif
218
219
#ifndef LONG_MAX
220
#define LONG_MAX 2147483647L
221
#endif
222
223
#ifndef LONG_MIN
224
#define LONG_MIN (- LONG_MAX - 1)
225
#endif
226
227
#ifndef INT_MAX
228
#define INT_MAX 2147483647
229
#endif
230
231
#ifndef INT_MIN
232
#define INT_MIN (- INT_MAX - 1)
233
#endif
234
235
#define PHP_GCC_VERSION ZEND_GCC_VERSION
236
#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
237
#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
238
239
BEGIN_EXTERN_C()
240
#include "snprintf.h"
241
END_EXTERN_C()
242
#include "spprintf.h"
243
244
#define EXEC_INPUT_BUF 4096
245
246
#define PHP_MIME_TYPE "application/x-httpd-php"
247
248
/* macros */
249
#define STR_PRINT(str)	((str)?(str):"")
250
251
#ifndef MAXPATHLEN
252
# ifdef PATH_MAX
253
#  define MAXPATHLEN PATH_MAX
1.1.3 by Mark A. Hershberger
Imported Upstream version 5.1.2
254
# elif defined(MAX_PATH)
255
#  define MAXPATHLEN MAX_PATH
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
256
# else
257
#  define MAXPATHLEN 256    /* Should be safe for any weird systems that do not define it */
258
# endif
259
#endif
260
261
262
/* global variables */
263
#if !defined(PHP_WIN32)
1.1.2 by Mark A. Hershberger
Imported Upstream version 5.1.1
264
#define PHP_SLEEP_NON_VOID
265
#define php_sleep sleep
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
266
extern char **environ;
267
#endif	/* !defined(PHP_WIN32) */
268
269
#ifdef PHP_PWRITE_64
270
ssize_t pwrite(int, void *, size_t, off64_t);
271
#endif
272
273
#ifdef PHP_PREAD_64
274
ssize_t pread(int, void *, size_t, off64_t);
275
#endif
276
277
BEGIN_EXTERN_C()
278
void phperror(char *error);
279
PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
280
PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
281
		2);
282
PHPAPI void php_log_err(char *log_message TSRMLS_DC);
283
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
284
int cfgparse(void);
285
END_EXTERN_C()
286
287
#define php_error zend_error
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
288
#define error_handling_t zend_error_handling_t
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
289
290
BEGIN_EXTERN_C()
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
291
static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC)
292
{
293
	zend_replace_error_handling(error_handling, exception_class, NULL TSRMLS_CC);
294
}
295
static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
296
297
PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
298
299
#ifdef ZTS
300
#define PHP_ATTR_FMT_OFFSET 1
301
#else
302
#define PHP_ATTR_FMT_OFFSET 0
303
#endif
304
305
/* PHPAPI void php_error(int type, const char *format, ...); */
306
PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
307
	PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
308
PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
309
	PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
310
PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
311
	PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
1.1.18 by Ondřej Surý
Imported Upstream version 5.3.2
312
#ifdef PHP_WIN32
313
PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC);
314
#endif
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
315
END_EXTERN_C()
316
317
#define php_error_docref php_error_docref0
318
319
#define zenderror phperror
320
#define zendlex phplex
321
322
#define phpparse zendparse
323
#define phprestart zendrestart
324
#define phpin zendin
325
326
#define php_memnstr zend_memnstr
327
328
/* functions */
329
BEGIN_EXTERN_C()
1.2.1 by Mark A. Hershberger
Imported Upstream version 5.3.0RC1
330
PHPAPI extern int (*php_register_internal_extensions_func)(TSRMLS_D);
331
PHPAPI int php_register_internal_extensions(TSRMLS_D);
332
PHPAPI int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
333
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
1.1.7 by Mark A. Hershberger
Imported Upstream version 5.2.2
334
PHPAPI void php_com_initialize(TSRMLS_D);
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
335
END_EXTERN_C()
336
337
/* PHP-named Zend macro wrappers */
338
#define PHP_FN					ZEND_FN
1.1.6 by Mark A. Hershberger
Imported Upstream version 5.2.0
339
#define PHP_MN					ZEND_MN
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
340
#define PHP_NAMED_FUNCTION		ZEND_NAMED_FUNCTION
341
#define PHP_FUNCTION			ZEND_FUNCTION
342
#define PHP_METHOD  			ZEND_METHOD
343
1.1.7 by Mark A. Hershberger
Imported Upstream version 5.2.2
344
#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
345
#define PHP_NAMED_FE	ZEND_NAMED_FE
346
#define PHP_FE			ZEND_FE
1.1.4 by Mark A. Hershberger
Imported Upstream version 5.1.5
347
#define PHP_DEP_FE      ZEND_DEP_FE
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
348
#define PHP_FALIAS		ZEND_FALIAS
1.1.4 by Mark A. Hershberger
Imported Upstream version 5.1.5
349
#define PHP_DEP_FALIAS	ZEND_DEP_FALIAS
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
350
#define PHP_ME          ZEND_ME
1.1.2 by Mark A. Hershberger
Imported Upstream version 5.1.1
351
#define PHP_MALIAS      ZEND_MALIAS
352
#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
353
#define PHP_ME_MAPPING  ZEND_ME_MAPPING
354
355
#define PHP_MODULE_STARTUP_N	ZEND_MODULE_STARTUP_N
356
#define PHP_MODULE_SHUTDOWN_N	ZEND_MODULE_SHUTDOWN_N
357
#define PHP_MODULE_ACTIVATE_N	ZEND_MODULE_ACTIVATE_N
358
#define PHP_MODULE_DEACTIVATE_N	ZEND_MODULE_DEACTIVATE_N
359
#define PHP_MODULE_INFO_N		ZEND_MODULE_INFO_N
360
361
#define PHP_MODULE_STARTUP_D	ZEND_MODULE_STARTUP_D
362
#define PHP_MODULE_SHUTDOWN_D	ZEND_MODULE_SHUTDOWN_D
363
#define PHP_MODULE_ACTIVATE_D	ZEND_MODULE_ACTIVATE_D
364
#define PHP_MODULE_DEACTIVATE_D	ZEND_MODULE_DEACTIVATE_D
365
#define PHP_MODULE_INFO_D		ZEND_MODULE_INFO_D
366
367
/* Compatibility macros */
368
#define PHP_MINIT		ZEND_MODULE_STARTUP_N
369
#define PHP_MSHUTDOWN	ZEND_MODULE_SHUTDOWN_N
370
#define PHP_RINIT		ZEND_MODULE_ACTIVATE_N
371
#define PHP_RSHUTDOWN	ZEND_MODULE_DEACTIVATE_N
372
#define PHP_MINFO		ZEND_MODULE_INFO_N
1.1.6 by Mark A. Hershberger
Imported Upstream version 5.2.0
373
#define PHP_GINIT		ZEND_GINIT
374
#define PHP_GSHUTDOWN	ZEND_GSHUTDOWN
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
375
376
#define PHP_MINIT_FUNCTION		ZEND_MODULE_STARTUP_D
377
#define PHP_MSHUTDOWN_FUNCTION	ZEND_MODULE_SHUTDOWN_D
378
#define PHP_RINIT_FUNCTION		ZEND_MODULE_ACTIVATE_D
379
#define PHP_RSHUTDOWN_FUNCTION	ZEND_MODULE_DEACTIVATE_D
380
#define PHP_MINFO_FUNCTION		ZEND_MODULE_INFO_D
1.1.6 by Mark A. Hershberger
Imported Upstream version 5.2.0
381
#define PHP_GINIT_FUNCTION		ZEND_GINIT_FUNCTION
382
#define PHP_GSHUTDOWN_FUNCTION	ZEND_GSHUTDOWN_FUNCTION
383
 
384
#define PHP_MODULE_GLOBALS		ZEND_MODULE_GLOBALS
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
385
386
387
/* Output support */
388
#include "main/php_output.h"
389
#define PHPWRITE(str, str_len)		php_body_write((str), (str_len) TSRMLS_CC)
390
#define PUTS(str)					do {			\
391
	const char *__str = (str);						\
392
	php_body_write(__str, strlen(__str) TSRMLS_CC);	\
393
} while (0)
394
395
#define PUTC(c)						(php_body_write(&(c), 1 TSRMLS_CC), (c))
396
#define PHPWRITE_H(str, str_len)	php_header_write((str), (str_len) TSRMLS_CC)
397
#define PUTS_H(str)					do {				\
398
	const char *__str = (str);							\
399
	php_header_write(__str, strlen(__str) TSRMLS_CC);	\
400
} while (0)
401
402
#define PUTC_H(c)					(php_header_write(&(c), 1 TSRMLS_CC), (c))
403
404
#include "php_streams.h"
405
#include "php_memory_streams.h"
406
#include "fopen_wrappers.h"
407
408
409
/* Virtual current working directory support */
410
#include "tsrm_virtual_cwd.h"
411
412
#include "zend_constants.h"
413
414
/* connection status states */
415
#define PHP_CONNECTION_NORMAL  0
416
#define PHP_CONNECTION_ABORTED 1
417
#define PHP_CONNECTION_TIMEOUT 2
418
419
#include "php_reentrancy.h"
420
421
/* Finding offsets of elements within structures.
422
 * Taken from the Apache code, which in turn, was taken from X code...
423
 */
424
425
#ifndef XtOffset
1.1.4 by Mark A. Hershberger
Imported Upstream version 5.1.5
426
#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
1 by Mark A. Hershberger
Imported Upstream version 5.0.4
427
#ifdef __STDC__
428
#define XtOffset(p_type, field) _Offsetof(p_type, field)
429
#else
430
#ifdef CRAY2
431
#define XtOffset(p_type, field) \
432
    (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
433
434
#else /* !CRAY2 */
435
436
#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
437
438
#endif /* !CRAY2 */
439
#endif /* __STDC__ */
440
#else /* ! (CRAY || __arm) */
441
442
#define XtOffset(p_type, field) \
443
    ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
444
445
#endif /* !CRAY */
446
#endif /* ! XtOffset */
447
448
#ifndef XtOffsetOf
449
#ifdef offsetof
450
#define XtOffsetOf(s_type, field) offsetof(s_type, field)
451
#else
452
#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
453
#endif
454
#endif /* !XtOffsetOf */
455
456
#endif
457
458
/*
459
 * Local variables:
460
 * tab-width: 4
461
 * c-basic-offset: 4
462
 * End:
463
 * vim600: sw=4 ts=4 fdm=marker
464
 * vim<600: sw=4 ts=4
465
 */