php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Andi Gutmans <andi@php.net> |
14 | Zeev Suraski <zeev@php.net> |
15 +----------------------------------------------------------------------+
16 */
17
18#ifndef PHP_H
19#define PHP_H
20
21#ifdef HAVE_DMALLOC
22#include <dmalloc.h>
23#endif
24
25#define PHP_API_VERSION 20240924
26#define PHP_HAVE_STREAMS
27#define YYDEBUG 0
28#define PHP_DEFAULT_CHARSET "UTF-8"
29
30#include "php_version.h"
31#include "zend.h"
32#include "zend_sort.h"
33#include "php_compat.h"
34
35#include "zend_API.h"
36
37#define php_sprintf sprintf
38
39/* Operating system family definition */
40#ifdef PHP_WIN32
41# define PHP_OS_FAMILY "Windows"
42#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
43# define PHP_OS_FAMILY "BSD"
44#elif defined(__APPLE__) || defined(__MACH__)
45# define PHP_OS_FAMILY "Darwin"
46#elif defined(__sun__)
47# define PHP_OS_FAMILY "Solaris"
48#elif defined(__linux__)
49# define PHP_OS_FAMILY "Linux"
50#else
51# define PHP_OS_FAMILY "Unknown"
52#endif
53
54/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
55#undef PHP_DEBUG
56#define PHP_DEBUG ZEND_DEBUG
57
58#ifdef PHP_WIN32
59# include "tsrm_win32.h"
60# ifdef PHP_EXPORTS
61# define PHPAPI __declspec(dllexport)
62# else
63# define PHPAPI __declspec(dllimport)
64# endif
65# define PHP_DIR_SEPARATOR '\\'
66# define PHP_EOL "\r\n"
67#else
68# if defined(__GNUC__) && __GNUC__ >= 4
69# define PHPAPI __attribute__ ((visibility("default")))
70# else
71# define PHPAPI
72# endif
73# define PHP_DIR_SEPARATOR '/'
74# define PHP_EOL "\n"
75#endif
76
77/* Windows specific defines */
78#ifdef PHP_WIN32
79# define PHP_PROG_SENDMAIL "Built in mailer"
80# define WIN32_LEAN_AND_MEAN
81# define NOOPENFILE
82
83# include <io.h>
84# include <malloc.h>
85# include <direct.h>
86# include <stdlib.h>
87# include <stdio.h>
88# include <stdarg.h>
89# include <sys/types.h>
90# include <process.h>
91
92typedef int uid_t;
93typedef int gid_t;
94typedef char * caddr_t;
95typedef int pid_t;
96
97# define M_TWOPI (M_PI * 2.0)
98# define off_t _off_t
99
100# define lstat(x, y) php_sys_lstat(x, y)
101# define chdir(path) _chdir(path)
102# define mkdir(a, b) _mkdir(a)
103# define rmdir(a) _rmdir(a)
104# define getpid _getpid
105# define php_sleep(t) SleepEx(t*1000, TRUE)
106
107# ifndef getcwd
108# define getcwd(a, b) _getcwd(a, b)
109# endif
110#endif
111
112#if PHP_DEBUG
113#undef NDEBUG
114#else
115#ifndef NDEBUG
116#define NDEBUG
117#endif
118#endif
119#include <assert.h>
120
121#ifdef HAVE_UNIX_H
122#include <unix.h>
123#endif
124
125#ifdef HAVE_ALLOCA_H
126#include <alloca.h>
127#endif
128
129#ifdef HAVE_BUILD_DEFS_H
130#include <build-defs.h>
131#endif
132
133/*
134 * This is a fast version of strlcpy which should be used, if you
135 * know the size of the destination buffer and if you know
136 * the length of the source string.
137 *
138 * size is the allocated number of bytes of dst
139 * src_size is the number of bytes excluding the NUL of src
140 */
141
142#define PHP_STRLCPY(dst, src, size, src_size) \
143 { \
144 size_t php_str_len; \
145 \
146 if (src_size >= size) \
147 php_str_len = size - 1; \
148 else \
149 php_str_len = src_size; \
150 memcpy(dst, src, php_str_len); \
151 dst[php_str_len] = '\0'; \
152 }
153
154#ifndef HAVE_STRLCPY
156PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
158#undef strlcpy
159#define strlcpy php_strlcpy
160#define HAVE_STRLCPY 1
161#define USE_STRLCPY_PHP_IMPL 1
162#endif
163
164#ifndef HAVE_STRLCAT
166PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
168#undef strlcat
169#define strlcat php_strlcat
170#define HAVE_STRLCAT 1
171#define USE_STRLCAT_PHP_IMPL 1
172#endif
173
174#ifndef HAVE_EXPLICIT_BZERO
176PHPAPI void php_explicit_bzero(void *dst, size_t siz);
178#undef explicit_bzero
179#define explicit_bzero php_explicit_bzero
180#endif
181
183PHPAPI int php_safe_bcmp(const zend_string *a, const zend_string *b);
185
186#ifndef HAVE_STRTOK_R
188char *strtok_r(char *s, const char *delim, char **last);
190#endif
191
192#ifndef HAVE_SOCKLEN_T
193# ifdef PHP_WIN32
194typedef int socklen_t;
195# else
196typedef unsigned int socklen_t;
197# endif
198#endif
199
200#define CREATE_MUTEX(a, b)
201#define SET_MUTEX(a)
202#define FREE_MUTEX(a)
203
204#include <stdlib.h>
205#include <ctype.h>
206#ifdef HAVE_UNISTD_H
207#include <unistd.h>
208#endif
209
210#include <stdarg.h>
211
212#include "zend_hash.h"
213#include "zend_alloc.h"
214#include "zend_stack.h"
215#include <string.h>
216
217#ifdef HAVE_PWD_H
218# ifdef PHP_WIN32
219#include "win32/param.h"
220# else
221#include <pwd.h>
222#include <sys/param.h>
223# endif
224#endif
225
226#include <limits.h>
227
228#ifndef LONG_MAX
229#define LONG_MAX 2147483647L
230#endif
231
232#ifndef LONG_MIN
233#define LONG_MIN (- LONG_MAX - 1)
234#endif
235
236#ifndef INT_MAX
237#define INT_MAX 2147483647
238#endif
239
240#ifndef INT_MIN
241#define INT_MIN (- INT_MAX - 1)
242#endif
243
244#define PHP_DOUBLE_MAX_LENGTH ZEND_DOUBLE_MAX_LENGTH
245
246#define PHP_GCC_VERSION ZEND_GCC_VERSION
247#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
248#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
249
251#include "snprintf.h"
253#include "spprintf.h"
254
255#define EXEC_INPUT_BUF 4096
256
257#define PHP_MIME_TYPE "application/x-httpd-php"
258
259/* macros */
260#define STR_PRINT(str) ((str)?(str):"")
261
262#ifndef MAXPATHLEN
263# ifdef PHP_WIN32
264# include "win32/ioutil.h"
265# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
266# elif PATH_MAX
267# define MAXPATHLEN PATH_MAX
268# elif defined(MAX_PATH)
269# define MAXPATHLEN MAX_PATH
270# else
271# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
272# endif
273#endif
274
275#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
276
277/* global variables */
278#ifndef PHP_WIN32
279#define php_sleep sleep
280extern char **environ;
281#endif /* ifndef PHP_WIN32 */
282
283#ifdef PHP_PWRITE_64
284ssize_t pwrite(int, void *, size_t, off64_t);
285#endif
286
287#ifdef PHP_PREAD_64
288ssize_t pread(int, void *, size_t, off64_t);
289#endif
290
293PHPAPI size_t php_write(void *buf, size_t size);
294PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
295PHPAPI size_t php_printf_unchecked(const char *format, ...);
299#ifdef HAVE_SYSLOG_H
300#include "php_syslog.h"
301#define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE)
302#else
303#define php_log_err(msg) php_log_err_with_severity(msg, 5)
304#endif
305PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
306int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
307int cfgparse(void);
309
310#define php_error zend_error
311#define error_handling_t zend_error_handling_t
312
314static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class)
315{
316 zend_replace_error_handling(error_handling, exception_class, NULL);
317}
318static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling(void) {}
319
320PHPAPI 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);
321
322/* PHPAPI void php_error(int type, const char *format, ...); */
323PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
325PHPAPI ZEND_COLD void php_error_docref_unchecked(const char *docref, int type, const char *format, ...);
326PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
328PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
330#ifdef PHP_WIN32
331PHPAPI ZEND_COLD void php_win32_docref1_from_error(DWORD error, const char *param1);
332PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
333#endif
335
336#define zenderror phperror
337#define zendlex phplex
338
339#define phpparse zendparse
340#define phprestart zendrestart
341#define phpin zendin
342
343#define php_memnstr zend_memnstr
344#define php_memnistr zend_memnistr
345
346/* functions */
350PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
351PHPAPI void php_com_initialize(void);
352PHPAPI char *php_get_current_user(void);
353
354PHPAPI const char *php_get_internal_encoding(void);
355PHPAPI const char *php_get_input_encoding(void);
356PHPAPI const char *php_get_output_encoding(void);
357PHPAPI extern void (*php_internal_encoding_changed)(void);
359
360/* PHP-named Zend macro wrappers */
361#define PHP_FN ZEND_FN
362#define PHP_MN ZEND_MN
363#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
364#define PHP_FUNCTION ZEND_FUNCTION
365#define PHP_METHOD ZEND_METHOD
366
367#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
368#define PHP_NAMED_FE ZEND_NAMED_FE
369#define PHP_FE ZEND_FE
370#define PHP_DEP_FE ZEND_DEP_FE
371#define PHP_FALIAS ZEND_FALIAS
372#define PHP_DEP_FALIAS ZEND_DEP_FALIAS
373#define PHP_ME ZEND_ME
374#define PHP_MALIAS ZEND_MALIAS
375#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
376#define PHP_ME_MAPPING ZEND_ME_MAPPING
377#define PHP_FE_END ZEND_FE_END
378
379#define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
380#define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
381#define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
382#define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
383#define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
384
385#define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
386#define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
387#define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
388#define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
389#define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
390
391/* Compatibility macros */
392#define PHP_MINIT ZEND_MODULE_STARTUP_N
393#define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
394#define PHP_RINIT ZEND_MODULE_ACTIVATE_N
395#define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
396#define PHP_MINFO ZEND_MODULE_INFO_N
397#define PHP_GINIT ZEND_GINIT
398#define PHP_GSHUTDOWN ZEND_GSHUTDOWN
399
400#define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
401#define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
402#define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
403#define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
404#define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
405#define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
406#define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
407
408#define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
409
410
411/* Output support */
412#include "main/php_output.h"
413
414
415#include "php_streams.h"
416#include "php_memory_streams.h"
417#include "fopen_wrappers.h"
418
419
420/* Virtual current working directory support */
421#include "zend_virtual_cwd.h"
422
423#include "zend_constants.h"
424
425/* connection status states */
426#define PHP_CONNECTION_NORMAL 0
427#define PHP_CONNECTION_ABORTED 1
428#define PHP_CONNECTION_TIMEOUT 2
429
430#include "php_reentrancy.h"
431
432/* the following typedefs are deprecated and will be removed in PHP
433 * 9.0; use the standard C99 types instead */
434typedef bool zend_bool;
435typedef intptr_t zend_intptr_t;
436typedef uintptr_t zend_uintptr_t;
437
438#endif
printf(string $format, mixed ... $values)
char s[4]
Definition cdf.c:77
#define DWORD
Definition exif.c:1762
PHPAPI void php_explicit_bzero(void *dst, size_t siz)
error($message)
Definition ext_skel.php:22
unsigned int socklen_t
Definition fastcgi.c:87
zend_ffi_type * type
Definition ffi.c:3812
new_type size
Definition ffi.c:4365
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
#define NULL
Definition gdcache.h:45
PHPAPI void(* php_internal_encoding_changed)(void)
Definition main.c:584
PHPAPI const char * php_get_output_encoding(void)
Definition main.c:575
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format,...)
Definition main.c:1198
PHPAPI size_t php_printf(const char *format,...)
Definition main.c:938
PHPAPI const char * php_get_input_encoding(void)
Definition main.c:566
PHPAPI bool php_get_module_initialized(void)
Definition main.c:851
PHPAPI bool php_during_module_startup(void)
Definition main.c:837
PHPAPI bool php_during_module_shutdown(void)
Definition main.c:844
PHPAPI const char * php_get_internal_encoding(void)
Definition main.c:557
PHPAPI size_t php_printf_unchecked(const char *format,...)
Definition main.c:956
PHPAPI char * php_get_current_user(void)
Definition main.c:1477
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format,...)
Definition main.c:1186
PHPAPI ZEND_COLD void php_error_docref_unchecked(const char *docref, int type, const char *format,...)
Definition main.c:1178
PHPAPI int(* php_register_internal_extensions_func)(void)
Definition main.c:89
PHPAPI void php_com_initialize(void)
Definition main.c:2005
PHPAPI size_t php_write(void *buf, size_t size)
Definition main.c:931
char * strtok_r(char *s, const char *delim, char **last)
int Debug(char *format,...) PHP_ATTRIBUTE_FORMAT(printf
#define PHP_ATTRIBUTE_FORMAT
Definition php.h:248
intptr_t zend_intptr_t
Definition php.h:435
void phperror(char *error)
PHPAPI int php_register_internal_extensions(void)
uintptr_t zend_uintptr_t
Definition php.h:436
PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int type, const char *format, va_list args) PHP_ATTRIBUTE_FORMAT(printf
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
Definition main.c:858
PHPAPI void php_register_pre_request_shutdown(void(*func)(void *), void *userdata)
char ** environ
PHPAPI int php_safe_bcmp(const zend_string *a, const zend_string *b)
Definition safe_bcmp.c:26
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz)
Definition strlcat.c:64
bool zend_bool
Definition php.h:434
int int cfgparse(void)
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz)
Definition strlcpy.c:62
#define PHPAPI
Definition php.h:71
#define error_handling_t
Definition php.h:311
PHPAPI ZEND_COLD void PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...) PHP_ATTRIBUTE_FORMAT(printf
$obj a
Definition test.php:84
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
Definition zend_API.c:5242
execute_data func
zval * args
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
struct _zend_string zend_string
int last
#define END_EXTERN_C()
#define ZEND_ATTRIBUTE_DEPRECATED
#define ZEND_COLD
#define BEGIN_EXTERN_C()
struct _zend_class_entry zend_class_entry