2001-04-18 01:03:18 +08:00
|
|
|
/*
|
1999-04-08 05:05:13 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 17:00:23 +08:00
|
|
|
| Copyright (c) The PHP Group |
|
1999-04-08 05:05:13 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
1999-07-16 21:13:16 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2021-05-06 18:16:35 +08:00
|
|
|
| https://www.php.net/license/3_01.txt |
|
1999-07-16 21:13:16 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
1999-04-08 05:05:13 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2018-11-02 00:30:28 +08:00
|
|
|
| Authors: Andi Gutmans <andi@php.net> |
|
|
|
|
| Zeev Suraski <zeev@php.net> |
|
1999-04-08 05:05:13 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2000-07-03 07:46:51 +08:00
|
|
|
#ifndef PHP_H
|
|
|
|
#define PHP_H
|
1999-04-08 05:05:13 +08:00
|
|
|
|
1999-06-26 08:34:36 +08:00
|
|
|
#ifdef HAVE_DMALLOC
|
|
|
|
#include <dmalloc.h>
|
|
|
|
#endif
|
|
|
|
|
2022-08-30 23:17:15 +08:00
|
|
|
#define PHP_API_VERSION 20220830
|
2002-03-18 16:29:17 +08:00
|
|
|
#define PHP_HAVE_STREAMS
|
1999-04-08 05:05:13 +08:00
|
|
|
#define YYDEBUG 0
|
2014-02-13 10:54:52 +08:00
|
|
|
#define PHP_DEFAULT_CHARSET "UTF-8"
|
1999-04-08 05:05:13 +08:00
|
|
|
|
|
|
|
#include "php_version.h"
|
|
|
|
#include "zend.h"
|
2015-01-14 17:22:58 +08:00
|
|
|
#include "zend_sort.h"
|
2000-03-04 22:44:01 +08:00
|
|
|
#include "php_compat.h"
|
1999-04-22 07:28:00 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#include "zend_API.h"
|
|
|
|
|
2019-02-21 06:17:15 +08:00
|
|
|
#define php_sprintf sprintf
|
1999-04-08 05:05:13 +08:00
|
|
|
|
2017-11-30 23:52:29 +08:00
|
|
|
/* Operating system family definition */
|
2017-02-22 19:31:06 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
# define PHP_OS_FAMILY "Windows"
|
|
|
|
#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
|
|
|
# define PHP_OS_FAMILY "BSD"
|
|
|
|
#elif defined(__APPLE__) || defined(__MACH__)
|
2017-06-14 09:29:06 +08:00
|
|
|
# define PHP_OS_FAMILY "Darwin"
|
2017-02-22 19:31:06 +08:00
|
|
|
#elif defined(__sun__)
|
|
|
|
# define PHP_OS_FAMILY "Solaris"
|
|
|
|
#elif defined(__linux__)
|
2017-02-23 05:13:33 +08:00
|
|
|
# define PHP_OS_FAMILY "Linux"
|
|
|
|
#else
|
2017-02-22 19:31:06 +08:00
|
|
|
# define PHP_OS_FAMILY "Unknown"
|
|
|
|
#endif
|
|
|
|
|
2002-03-01 08:16:58 +08:00
|
|
|
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
|
|
|
|
#undef PHP_DEBUG
|
|
|
|
#define PHP_DEBUG ZEND_DEBUG
|
|
|
|
|
2000-02-11 23:59:30 +08:00
|
|
|
#ifdef PHP_WIN32
|
2008-01-30 17:41:12 +08:00
|
|
|
# include "tsrm_win32.h"
|
1999-04-26 22:00:49 +08:00
|
|
|
# ifdef PHP_EXPORTS
|
2008-01-30 17:41:12 +08:00
|
|
|
# define PHPAPI __declspec(dllexport)
|
1999-04-26 22:00:49 +08:00
|
|
|
# else
|
2008-01-30 17:41:12 +08:00
|
|
|
# define PHPAPI __declspec(dllimport)
|
1999-04-26 22:00:49 +08:00
|
|
|
# endif
|
2008-01-30 17:41:12 +08:00
|
|
|
# define PHP_DIR_SEPARATOR '\\'
|
|
|
|
# define PHP_EOL "\r\n"
|
1999-04-08 05:05:13 +08:00
|
|
|
#else
|
2008-01-30 17:41:12 +08:00
|
|
|
# if defined(__GNUC__) && __GNUC__ >= 4
|
|
|
|
# define PHPAPI __attribute__ ((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define PHPAPI
|
|
|
|
# endif
|
2012-02-27 20:16:39 +08:00
|
|
|
# define PHP_DIR_SEPARATOR '/'
|
|
|
|
# define PHP_EOL "\n"
|
1999-04-08 05:05:13 +08:00
|
|
|
#endif
|
|
|
|
|
2016-12-22 13:51:18 +08:00
|
|
|
/* Windows specific defines */
|
|
|
|
#ifdef PHP_WIN32
|
|
|
|
# define PHP_PROG_SENDMAIL "Built in mailer"
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# define NOOPENFILE
|
|
|
|
|
|
|
|
# include <io.h>
|
|
|
|
# include <malloc.h>
|
|
|
|
# include <direct.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdarg.h>
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <process.h>
|
|
|
|
|
|
|
|
typedef int uid_t;
|
|
|
|
typedef int gid_t;
|
|
|
|
typedef char * caddr_t;
|
|
|
|
typedef int pid_t;
|
|
|
|
|
|
|
|
# define M_TWOPI (M_PI * 2.0)
|
|
|
|
# define off_t _off_t
|
|
|
|
|
|
|
|
# define lstat(x, y) php_sys_lstat(x, y)
|
|
|
|
# define chdir(path) _chdir(path)
|
|
|
|
# define mkdir(a, b) _mkdir(a)
|
|
|
|
# define rmdir(a) _rmdir(a)
|
|
|
|
# define getpid _getpid
|
|
|
|
# define php_sleep(t) SleepEx(t*1000, TRUE)
|
|
|
|
|
|
|
|
# ifndef getcwd
|
|
|
|
# define getcwd(a, b) _getcwd(a, b)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2002-03-14 10:17:23 +08:00
|
|
|
#if PHP_DEBUG
|
|
|
|
#undef NDEBUG
|
|
|
|
#else
|
2002-03-16 01:10:38 +08:00
|
|
|
#ifndef NDEBUG
|
2002-03-14 10:17:23 +08:00
|
|
|
#define NDEBUG
|
|
|
|
#endif
|
2002-03-16 01:10:38 +08:00
|
|
|
#endif
|
2002-03-14 10:17:23 +08:00
|
|
|
#include <assert.h>
|
1999-04-08 05:05:13 +08:00
|
|
|
|
2020-05-12 23:50:35 +08:00
|
|
|
#ifdef HAVE_UNIX_H
|
1999-04-08 05:05:13 +08:00
|
|
|
#include <unix.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_ALLOCA_H
|
|
|
|
#include <alloca.h>
|
|
|
|
#endif
|
|
|
|
|
2002-10-24 21:15:49 +08:00
|
|
|
#if HAVE_BUILD_DEFS_H
|
2005-01-15 04:44:28 +08:00
|
|
|
#include <build-defs.h>
|
2002-10-24 21:15:49 +08:00
|
|
|
#endif
|
|
|
|
|
2000-08-27 17:30:15 +08:00
|
|
|
/*
|
|
|
|
* This is a fast version of strlcpy which should be used, if you
|
2000-08-27 17:38:33 +08:00
|
|
|
* know the size of the destination buffer and if you know
|
2000-08-27 17:30:15 +08:00
|
|
|
* the length of the source string.
|
|
|
|
*
|
2000-08-27 17:38:33 +08:00
|
|
|
* size is the allocated number of bytes of dst
|
|
|
|
* src_size is the number of bytes excluding the NUL of src
|
2000-08-27 17:30:15 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define PHP_STRLCPY(dst, src, size, src_size) \
|
|
|
|
{ \
|
|
|
|
size_t php_str_len; \
|
|
|
|
\
|
|
|
|
if (src_size >= size) \
|
|
|
|
php_str_len = size - 1; \
|
|
|
|
else \
|
|
|
|
php_str_len = src_size; \
|
|
|
|
memcpy(dst, src, php_str_len); \
|
|
|
|
dst[php_str_len] = '\0'; \
|
|
|
|
}
|
|
|
|
|
1999-09-15 17:35:20 +08:00
|
|
|
#ifndef HAVE_STRLCPY
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-05-30 13:00:39 +08:00
|
|
|
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
2003-06-27 15:43:42 +08:00
|
|
|
#undef strlcpy
|
2001-05-30 13:00:39 +08:00
|
|
|
#define strlcpy php_strlcpy
|
2017-03-20 05:14:14 +08:00
|
|
|
#define HAVE_STRLCPY 1
|
2017-03-20 06:19:31 +08:00
|
|
|
#define USE_STRLCPY_PHP_IMPL 1
|
1999-09-15 03:12:57 +08:00
|
|
|
#endif
|
|
|
|
|
1999-09-15 17:35:20 +08:00
|
|
|
#ifndef HAVE_STRLCAT
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-05-30 13:00:39 +08:00
|
|
|
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
2003-06-27 15:43:42 +08:00
|
|
|
#undef strlcat
|
2001-05-30 13:00:39 +08:00
|
|
|
#define strlcat php_strlcat
|
2017-03-20 05:14:14 +08:00
|
|
|
#define HAVE_STRLCAT 1
|
2017-03-20 06:19:31 +08:00
|
|
|
#define USE_STRLCAT_PHP_IMPL 1
|
1999-09-15 03:12:57 +08:00
|
|
|
#endif
|
|
|
|
|
2016-10-16 00:55:44 +08:00
|
|
|
#ifndef HAVE_EXPLICIT_BZERO
|
2016-10-15 21:53:38 +08:00
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
PHPAPI void php_explicit_bzero(void *dst, size_t siz);
|
|
|
|
END_EXTERN_C()
|
|
|
|
#undef explicit_bzero
|
|
|
|
#define explicit_bzero php_explicit_bzero
|
|
|
|
#endif
|
|
|
|
|
2019-09-20 23:42:47 +08:00
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
PHPAPI int php_safe_bcmp(const zend_string *a, const zend_string *b);
|
|
|
|
END_EXTERN_C()
|
|
|
|
|
1999-11-27 08:48:50 +08:00
|
|
|
#ifndef HAVE_STRTOK_R
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
1999-11-27 08:48:50 +08:00
|
|
|
char *strtok_r(char *s, const char *delim, char **last);
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
1999-11-27 08:48:50 +08:00
|
|
|
#endif
|
|
|
|
|
1999-12-31 00:09:17 +08:00
|
|
|
#ifndef HAVE_SOCKLEN_T
|
2017-04-10 14:40:44 +08:00
|
|
|
# ifdef PHP_WIN32
|
2010-12-12 06:18:10 +08:00
|
|
|
typedef int socklen_t;
|
|
|
|
# else
|
1999-12-31 00:09:17 +08:00
|
|
|
typedef unsigned int socklen_t;
|
2010-12-12 06:18:10 +08:00
|
|
|
# endif
|
1999-12-31 00:09:17 +08:00
|
|
|
#endif
|
|
|
|
|
2001-08-05 09:43:02 +08:00
|
|
|
#define CREATE_MUTEX(a, b)
|
1999-04-08 05:05:13 +08:00
|
|
|
#define SET_MUTEX(a)
|
|
|
|
#define FREE_MUTEX(a)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Then the ODBC support can use both iodbc and Solid,
|
|
|
|
* uncomment this.
|
|
|
|
* #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2018-09-16 09:31:24 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "zend_hash.h"
|
|
|
|
#include "zend_alloc.h"
|
|
|
|
#include "zend_stack.h"
|
2019-02-28 07:41:30 +08:00
|
|
|
#include <string.h>
|
1999-04-08 05:05:13 +08:00
|
|
|
|
|
|
|
#if HAVE_PWD_H
|
2000-02-11 23:59:30 +08:00
|
|
|
# ifdef PHP_WIN32
|
1999-04-08 05:05:13 +08:00
|
|
|
#include "win32/param.h"
|
|
|
|
# else
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#ifndef LONG_MAX
|
|
|
|
#define LONG_MAX 2147483647L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LONG_MIN
|
|
|
|
#define LONG_MIN (- LONG_MAX - 1)
|
|
|
|
#endif
|
|
|
|
|
2004-11-28 20:44:28 +08:00
|
|
|
#ifndef INT_MAX
|
|
|
|
#define INT_MAX 2147483647
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INT_MIN
|
|
|
|
#define INT_MIN (- INT_MAX - 1)
|
|
|
|
#endif
|
|
|
|
|
2021-08-02 20:40:01 +08:00
|
|
|
#define PHP_DOUBLE_MAX_LENGTH ZEND_DOUBLE_MAX_LENGTH
|
2016-06-26 21:03:01 +08:00
|
|
|
|
2003-08-28 22:53:36 +08:00
|
|
|
#define PHP_GCC_VERSION ZEND_GCC_VERSION
|
|
|
|
#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
|
2003-08-29 00:49:43 +08:00
|
|
|
#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
|
2003-08-28 13:23:08 +08:00
|
|
|
|
2004-11-16 05:04:09 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2000-03-12 23:47:34 +08:00
|
|
|
#include "snprintf.h"
|
2004-11-16 05:04:09 +08:00
|
|
|
END_EXTERN_C()
|
2002-04-10 09:13:18 +08:00
|
|
|
#include "spprintf.h"
|
1999-04-08 05:05:13 +08:00
|
|
|
|
|
|
|
#define EXEC_INPUT_BUF 4096
|
|
|
|
|
1999-12-22 03:40:27 +08:00
|
|
|
#define PHP_MIME_TYPE "application/x-httpd-php"
|
1999-04-08 05:05:13 +08:00
|
|
|
|
|
|
|
/* macros */
|
1999-07-09 03:18:42 +08:00
|
|
|
#define STR_PRINT(str) ((str)?(str):"")
|
1999-04-08 05:05:13 +08:00
|
|
|
|
|
|
|
#ifndef MAXPATHLEN
|
2017-04-10 14:42:48 +08:00
|
|
|
# ifdef PHP_WIN32
|
Fixed the UTF-8 and long path support in the streams on Windows.
Since long the default PHP charset is UTF-8, however the Windows part is
out of step with this important point. The current implementation in PHP
doesn't technically permit to handle UTF-8 filepath and several other
things. Till now, only the ANSI compatible APIs are being used. Here is more
about it
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx
The patch fixes not only issues with multibyte filenames under
incompatible codepages, but indirectly also issues with some other multibyte
encodings like BIG5, Shift-JIS, etc. by providing a clean way to access
filenames in UTF-8. Below is a small list of issues from the bug tracker,
that are getting fixed:
https://bugs.php.net/63401
https://bugs.php.net/41199
https://bugs.php.net/50203
https://bugs.php.net/71509
https://bugs.php.net/64699
https://bugs.php.net/64506
https://bugs.php.net/30195
https://bugs.php.net/65358
https://bugs.php.net/61315
https://bugs.php.net/70943
https://bugs.php.net/70903
https://bugs.php.net/63593
https://bugs.php.net/54977
https://bugs.php.net/54028
https://bugs.php.net/43148
https://bugs.php.net/30730
https://bugs.php.net/33350
https://bugs.php.net/35300
https://bugs.php.net/46990
https://bugs.php.net/61309
https://bugs.php.net/69333
https://bugs.php.net/45517
https://bugs.php.net/70551
https://bugs.php.net/50197
https://bugs.php.net/72200
https://bugs.php.net/37672
Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow
and Github. Some of the bugs are pretty recent, some descend to early
2000th, but the user comments in there last even till today. Just for example,
bug #30195 was opened in 2004, the latest comment in there was made in 2014. It
is certain, that these bugs descend not only to pure PHP use cases, but get also
redirected from the popular PHP based projects. Given the modern systems (and
those supported by PHP) are always based on NTFS, there is no excuse to keep
these issues unresolved.
The internalization approach on Windows is in many ways different from
UNIX and Linux, while it supports and is based on Unicode. It depends on the
current system code page, APIs used and exact kind how the binary was compiled
The locale doesn't affect the way Unicode or ANSI API work. PHP in particular
is being compiled without _UNICODE defined and this is conditioned by the
way we handle strings. Here is more about it
https://msdn.microsoft.com/en-us/library/tsbaswba.aspx
However, with any system code page ANSI functions automatically convert
paths to UTF-16. Paths in some encodings incompatible with the
current system code page, won't work correctly with ANSI APIs. PHP
till now only uses the ANSI Windows APIs.
For example, on a system with the current code page 1252, the paths
in cp1252 are supported and transparently converted to UTF-16 by the
ANSI functions. Once one wants to handle a filepath encoded with cp932 on
that particular system, an ANSI or a POSIX compatible function used in
PHP will produce an erroneous result. When trying to convert that cp932 path
to UTF-8 and passing to the ANSI functions, an ANSI function would
likely interpret the UTF-8 string as some string in the current code page and
create a filepath that represents every single byte of the UTF-8 string.
These behaviors are not only broken but also disregard the documented
INI settings.
This patch solves the issies with the multibyte paths on Windows by
intelligently enforcing the usage of the Unicode aware APIs. For
functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments
will be converted to UTF-16 wide chars. For functions returning Unicode
aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is
converted back to char's depending on the current PHP charset settings,
either to the current ANSI codepage (this is the behavior prior to this patch)
or to UTF-8 (the default behavior).
In a particular case, users might have to explicitly set
internal_encoding or default_charset, if filenames in ANSI codepage are
necessary. Current tests show no regressions and witness that this will be an
exotic case, the current default UTF-8 encoding is compatible with any
supported system. The dependency libraries are long switching to Unicode APIs,
so some tests were also added for extensions not directly related to streams.
At large, the patch brings over 150 related tests into the core. Those target
and was run on various environments with European, Asian, etc. codepages.
General PHP frameworks was tested and showed no regressions.
The impact on the current C code base is low, the most places affected
are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c
and plain_wrapper.c. The actual implementation of the most of the wide
char supporting functionality is in win32/ioutil.* and win32/codepage.*,
several low level functionsare extended in place to avoid reimplementation for
now. No performance impact was sighted. As previously mentioned, the ANSI APIs
used prior the patch perform Unicode conversions internally. Using the
Unicode APIs directly while doing custom conversions just retains the status
quo. The ways to optimize it are open (fe. by implementing caching for the
strings converted to wide variants).
The long path implementation is user transparent. If a path exceeds the
length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN
is set to 2048 bytes.
Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas
and testing.
Thanks.
2016-06-20 15:32:19 +08:00
|
|
|
# include "win32/ioutil.h"
|
|
|
|
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
|
|
|
|
# elif PATH_MAX
|
2000-09-07 23:20:29 +08:00
|
|
|
# define MAXPATHLEN PATH_MAX
|
2005-12-20 22:24:24 +08:00
|
|
|
# elif defined(MAX_PATH)
|
|
|
|
# define MAXPATHLEN MAX_PATH
|
2000-09-07 23:20:29 +08:00
|
|
|
# else
|
|
|
|
# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
|
|
|
|
# endif
|
1999-04-08 05:05:13 +08:00
|
|
|
#endif
|
|
|
|
|
2015-07-17 04:48:56 +08:00
|
|
|
#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
|
2002-04-17 06:14:27 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
/* global variables */
|
2020-05-12 23:50:35 +08:00
|
|
|
#ifndef PHP_WIN32
|
2002-09-09 19:31:03 +08:00
|
|
|
#define php_sleep sleep
|
1999-04-08 05:05:13 +08:00
|
|
|
extern char **environ;
|
2020-05-12 23:50:35 +08:00
|
|
|
#endif /* ifndef PHP_WIN32 */
|
1999-04-26 22:00:49 +08:00
|
|
|
|
2001-05-21 07:39:09 +08:00
|
|
|
#ifdef PHP_PWRITE_64
|
|
|
|
ssize_t pwrite(int, void *, size_t, off64_t);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PHP_PREAD_64
|
|
|
|
ssize_t pread(int, void *, size_t, off64_t);
|
|
|
|
#endif
|
|
|
|
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2000-08-21 17:50:53 +08:00
|
|
|
void phperror(char *error);
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI size_t php_write(void *buf, size_t size);
|
2020-03-01 05:47:04 +08:00
|
|
|
PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
|
|
|
|
PHPAPI size_t php_printf_unchecked(const char *format, ...);
|
2022-05-24 15:34:55 +08:00
|
|
|
PHPAPI bool php_during_module_startup(void);
|
|
|
|
PHPAPI bool php_during_module_shutdown(void);
|
|
|
|
PHPAPI bool php_get_module_initialized(void);
|
2016-06-08 14:10:09 +08:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
#include "php_syslog.h"
|
2016-06-02 19:28:09 +08:00
|
|
|
#define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE)
|
2016-06-08 14:10:09 +08:00
|
|
|
#else
|
|
|
|
#define php_log_err(msg) php_log_err_with_severity(msg, 5)
|
|
|
|
#endif
|
2020-06-07 17:01:19 +08:00
|
|
|
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
|
2014-09-03 21:22:08 +08:00
|
|
|
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
|
|
|
|
int cfgparse(void);
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
1999-04-08 05:05:13 +08:00
|
|
|
|
2000-04-28 02:37:02 +08:00
|
|
|
#define php_error zend_error
|
2008-03-09 06:12:32 +08:00
|
|
|
#define error_handling_t zend_error_handling_t
|
2003-05-07 09:02:23 +08:00
|
|
|
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2014-12-14 06:06:14 +08:00
|
|
|
static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class)
|
2008-08-09 01:47:31 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_replace_error_handling(error_handling, exception_class, NULL);
|
2008-08-09 01:47:31 +08:00
|
|
|
}
|
2021-05-12 21:55:23 +08:00
|
|
|
static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling(void) {}
|
2003-05-07 09:02:23 +08:00
|
|
|
|
2015-08-24 23:07:59 +08:00
|
|
|
PHPAPI 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);
|
2003-08-29 00:49:43 +08:00
|
|
|
|
2002-08-08 02:29:36 +08:00
|
|
|
/* PHPAPI void php_error(int type, const char *format, ...); */
|
2019-07-13 08:05:17 +08:00
|
|
|
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
|
2016-02-14 20:50:59 +08:00
|
|
|
PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
|
2015-08-24 23:07:59 +08:00
|
|
|
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
|
2016-02-14 20:50:59 +08:00
|
|
|
PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
|
2015-08-24 23:07:59 +08:00
|
|
|
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
|
2016-02-14 20:50:59 +08:00
|
|
|
PHP_ATTRIBUTE_FORMAT(printf, 5, 6);
|
2010-01-27 15:48:31 +08:00
|
|
|
#ifdef PHP_WIN32
|
2021-04-19 19:47:25 +08:00
|
|
|
PHPAPI ZEND_COLD void php_win32_docref1_from_error(DWORD error, const char *param1);
|
2015-08-24 23:07:59 +08:00
|
|
|
PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
|
2010-01-27 15:48:31 +08:00
|
|
|
#endif
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
2002-08-09 03:12:27 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#define zenderror phperror
|
|
|
|
#define zendlex phplex
|
|
|
|
|
|
|
|
#define phpparse zendparse
|
|
|
|
#define phprestart zendrestart
|
|
|
|
#define phpin zendin
|
|
|
|
|
2003-04-08 23:04:26 +08:00
|
|
|
#define php_memnstr zend_memnstr
|
2021-12-29 19:51:18 +08:00
|
|
|
#define php_memnistr zend_memnistr
|
2003-04-08 23:04:26 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
/* functions */
|
2003-09-02 21:07:17 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI extern int (*php_register_internal_extensions_func)(void);
|
|
|
|
PHPAPI int php_register_internal_extensions(void);
|
2000-01-15 21:02:54 +08:00
|
|
|
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
|
2014-12-14 06:06:14 +08:00
|
|
|
PHPAPI void php_com_initialize(void);
|
|
|
|
PHPAPI char *php_get_current_user(void);
|
2019-04-16 22:35:35 +08:00
|
|
|
|
|
|
|
PHPAPI const char *php_get_internal_encoding(void);
|
|
|
|
PHPAPI const char *php_get_input_encoding(void);
|
|
|
|
PHPAPI const char *php_get_output_encoding(void);
|
|
|
|
PHPAPI extern void (*php_internal_encoding_changed)(void);
|
2003-09-02 21:07:17 +08:00
|
|
|
END_EXTERN_C()
|
1999-04-08 05:05:13 +08:00
|
|
|
|
2001-08-11 09:13:31 +08:00
|
|
|
/* PHP-named Zend macro wrappers */
|
|
|
|
#define PHP_FN ZEND_FN
|
2006-05-26 02:47:21 +08:00
|
|
|
#define PHP_MN ZEND_MN
|
2001-08-11 09:13:31 +08:00
|
|
|
#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
|
|
|
|
#define PHP_FUNCTION ZEND_FUNCTION
|
2003-04-04 23:38:20 +08:00
|
|
|
#define PHP_METHOD ZEND_METHOD
|
2001-08-11 09:13:31 +08:00
|
|
|
|
2006-12-20 18:34:36 +08:00
|
|
|
#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
|
2001-08-11 09:13:31 +08:00
|
|
|
#define PHP_NAMED_FE ZEND_NAMED_FE
|
|
|
|
#define PHP_FE ZEND_FE
|
2006-02-26 02:25:45 +08:00
|
|
|
#define PHP_DEP_FE ZEND_DEP_FE
|
2001-08-11 09:13:31 +08:00
|
|
|
#define PHP_FALIAS ZEND_FALIAS
|
2006-02-26 02:25:45 +08:00
|
|
|
#define PHP_DEP_FALIAS ZEND_DEP_FALIAS
|
2003-04-04 23:38:20 +08:00
|
|
|
#define PHP_ME ZEND_ME
|
2004-09-30 16:03:38 +08:00
|
|
|
#define PHP_MALIAS ZEND_MALIAS
|
2005-08-07 23:13:50 +08:00
|
|
|
#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
|
2004-01-12 08:19:40 +08:00
|
|
|
#define PHP_ME_MAPPING ZEND_ME_MAPPING
|
2011-07-25 19:30:53 +08:00
|
|
|
#define PHP_FE_END ZEND_FE_END
|
2001-08-11 09:13:31 +08:00
|
|
|
|
|
|
|
#define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
|
|
|
|
#define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
|
|
|
|
#define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
|
|
|
|
#define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
|
|
|
|
#define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
|
|
|
|
|
|
|
|
#define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
|
|
|
|
#define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
|
|
|
|
#define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
|
|
|
|
#define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
|
|
|
|
#define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
|
|
|
|
|
|
|
|
/* Compatibility macros */
|
|
|
|
#define PHP_MINIT ZEND_MODULE_STARTUP_N
|
|
|
|
#define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
|
|
|
|
#define PHP_RINIT ZEND_MODULE_ACTIVATE_N
|
|
|
|
#define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
|
|
|
|
#define PHP_MINFO ZEND_MODULE_INFO_N
|
2006-06-15 22:06:35 +08:00
|
|
|
#define PHP_GINIT ZEND_GINIT
|
|
|
|
#define PHP_GSHUTDOWN ZEND_GSHUTDOWN
|
2001-08-11 09:13:31 +08:00
|
|
|
|
|
|
|
#define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
|
|
|
|
#define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
|
|
|
|
#define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
|
|
|
|
#define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
|
|
|
|
#define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
|
2006-06-15 22:06:35 +08:00
|
|
|
#define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
|
|
|
|
#define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2006-06-15 22:06:35 +08:00
|
|
|
#define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
|
2001-08-11 09:13:31 +08:00
|
|
|
|
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
/* Output support */
|
2001-07-20 22:40:30 +08:00
|
|
|
#include "main/php_output.h"
|
2010-05-31 18:29:43 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
|
2002-09-25 23:25:12 +08:00
|
|
|
#include "php_streams.h"
|
|
|
|
#include "php_memory_streams.h"
|
|
|
|
#include "fopen_wrappers.h"
|
|
|
|
|
|
|
|
|
2000-09-04 12:18:04 +08:00
|
|
|
/* Virtual current working directory support */
|
2013-10-17 15:43:52 +08:00
|
|
|
#include "zend_virtual_cwd.h"
|
2000-04-07 18:26:28 +08:00
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#include "zend_constants.h"
|
|
|
|
|
1999-09-05 04:12:47 +08:00
|
|
|
/* connection status states */
|
|
|
|
#define PHP_CONNECTION_NORMAL 0
|
|
|
|
#define PHP_CONNECTION_ABORTED 1
|
|
|
|
#define PHP_CONNECTION_TIMEOUT 2
|
1999-04-08 05:05:13 +08:00
|
|
|
|
1999-11-27 01:07:41 +08:00
|
|
|
#include "php_reentrancy.h"
|
1999-04-10 03:09:29 +08:00
|
|
|
|
2023-02-19 03:31:28 +08:00
|
|
|
/* the following typedefs are deprecated and will be removed in PHP
|
|
|
|
* 9.0; use the standard C99 types instead */
|
|
|
|
typedef bool zend_bool;
|
|
|
|
typedef intptr_t zend_intptr_t;
|
|
|
|
typedef uintptr_t zend_uintptr_t;
|
|
|
|
|
1999-04-08 05:05:13 +08:00
|
|
|
#endif
|