Initial commit

This commit is contained in:
wrenge 2024-04-10 10:42:31 +03:00
commit 7a8181cb61
299 changed files with 167682 additions and 0 deletions

1
bin/phar Symbolic link
View File

@ -0,0 +1 @@
phar.phar

BIN
bin/phar.phar Executable file

Binary file not shown.

BIN
bin/php Executable file

Binary file not shown.

BIN
bin/php-cgi Executable file

Binary file not shown.

98
bin/php-config Executable file
View File

@ -0,0 +1,98 @@
#! /bin/sh
SED="/usr/bin/sed"
prefix="/home/wreng/php-8.3.3-linux"
datarootdir="/home/wreng/php-8.3.3-linux/php"
exec_prefix="${prefix}"
version="8.3.3-dev"
vernum="80303"
include_dir="${prefix}/include/php"
includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
ldflags=""
libs=" -lrt -lrt -lm -lxml2 -lsqlite3 -lxml2 -lsqlite3 -lxml2 -lxml2 -lxml2 -lxml2 "
extension_dir='/home/wreng/php-8.3.3-linux/lib/php/extensions/no-debug-non-zts-20230831'
man_dir=`eval echo ${datarootdir}/man`
program_prefix=""
program_suffix=""
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" '--prefix=/home/wreng/php-8.3.3-linux/'"
php_sapis=" cli phpdbg cgi"
ini_dir=""
ini_path="/home/wreng/php-8.3.3-linux/lib"
# Set php_cli_binary and php_cgi_binary if available
for sapi in $php_sapis; do
case $sapi in
cli)
php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"
;;
cgi)
php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"
;;
esac
done
# Determine which (if any) php binary is available
if test "$php_cli_binary" != "NONE"; then
php_binary="$php_cli_binary"
else
php_binary="$php_cgi_binary"
fi
# Remove quotes
configure_options=`echo $configure_options | $SED -e "s#'##g"`
case "$1" in
--prefix)
echo $prefix;;
--includes)
echo $includes;;
--ldflags)
echo $ldflags;;
--libs)
echo $libs;;
--extension-dir)
echo $extension_dir;;
--include-dir)
echo $include_dir;;
--php-binary)
echo $php_binary;;
--php-sapis)
echo $php_sapis;;
--configure-options)
echo $configure_options;;
--man-dir)
echo $man_dir;;
--ini-path)
echo $ini_path;;
--ini-dir)
echo $ini_dir;;
--version)
echo $version;;
--vernum)
echo $vernum;;
*)
cat << EOF
Usage: $0 [OPTION]
Options:
--prefix [$prefix]
--includes [$includes]
--ldflags [$ldflags]
--libs [$libs]
--extension-dir [$extension_dir]
--include-dir [$include_dir]
--man-dir [$man_dir]
--php-binary [$php_binary]
--php-sapis [$php_sapis]
--ini-path [$ini_path]
--ini-dir [$ini_dir]
--configure-options [$configure_options]
--version [$version]
--vernum [$vernum]
EOF
exit 1;;
esac
exit 0

BIN
bin/phpdbg Executable file

Binary file not shown.

211
bin/phpize Executable file
View File

@ -0,0 +1,211 @@
#!/bin/sh
# Variable declaration
prefix='/home/wreng/php-8.3.3-linux'
datarootdir='/home/wreng/php-8.3.3-linux/php'
exec_prefix="`eval echo ${prefix}`"
phpdir="`eval echo ${exec_prefix}/lib/php`/build"
includedir="`eval echo ${prefix}/include`/php"
builddir="`pwd`"
SED="/usr/bin/sed"
FILES_BUILD="php.m4 shtool libtool.m4 ax_check_compile_flag.m4 ax_gcc_func_attribute.m4 php_cxx_compile_stdcxx.m4 pkg.m4 \
config.guess config.sub ltmain.sh Makefile.global gen_stub.php"
FILES="run-tests*.php"
CLEAN_FILES="$FILES *.o *.lo *.la .libs/ build/ modules/ \
config.nice configure configure.ac \
config.h config.h.in conftest* libtool config.cache autom4te.cache/ \
config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h \
run-tests*.php tests/*.diff tests/*.exp tests/*.log tests/*.out tests/*.php"
# function declaration
phpize_usage()
{
echo "Usage: $0 [--clean|--help|--version|-v]"
}
phpize_no_configm4()
{
if test $@ -eq 1; then
clean=" --clean"
fi
echo "Cannot find config.m4. "
echo "Make sure that you run '$0$clean' in the top level source directory of the module"
echo
}
phpize_clean()
{
echo "Cleaning.."
for i in $CLEAN_FILES; do
if test -f "$i"; then
rm -f $i
elif test -d "$i"; then
rm -rf $i
fi
done
}
phpize_check_configm4()
{
if test ! -r config.m4; then
phpize_no_configm4 $@
exit 1
fi
}
phpize_get_api_numbers()
{
# extracting API NOs:
PHP_API_VERSION=`grep '#define PHP_API_VERSION' $includedir/main/php.h|$SED 's/#define PHP_API_VERSION//'`
ZEND_MODULE_API_NO=`grep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO//'`
ZEND_EXTENSION_API_NO=`grep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|$SED 's/#define ZEND_EXTENSION_API_NO//'`
}
phpize_print_api_numbers()
{
phpize_get_api_numbers
echo "Configuring for:"
echo "PHP Api Version: "$PHP_API_VERSION
echo "Zend Module Api No: "$ZEND_MODULE_API_NO
echo "Zend Extension Api No: "$ZEND_EXTENSION_API_NO
}
phpize_check_build_files()
{
if test ! -d "$phpdir"; then
cat <<EOF
Cannot find build files at '$phpdir'. Please check your PHP installation.
EOF
exit 1
fi
case "$phpdir" in
*\ * | *\ *)
cat <<EOF
Invalid source path '$phpdir'. Whitespace is not allowed in source path.
EOF
exit 1;;
esac
case "$builddir" in
*\ * | *\ *)
cat <<EOF
Invalid build path '$builddir'. Whitespace is not allowed in build path.
EOF
exit 1;;
esac
}
phpize_check_shtool()
{
test -x "$builddir/build/shtool" || chmod +x "$builddir/build/shtool"
if test ! -x "$builddir/build/shtool"; then
cat <<EOF
shtool at '$builddir/build/shtool' does not exist or is not executable.
Make sure that the file exists and is executable and then rerun this script.
EOF
exit 1
else
php_shtool=$builddir/build/shtool
fi
}
phpize_check_autotools()
{
test -z "$PHP_AUTOCONF" && PHP_AUTOCONF=autoconf
test -z "$PHP_AUTOHEADER" && PHP_AUTOHEADER=autoheader
if test ! -x "$PHP_AUTOCONF" && test ! -x "`$php_shtool path $PHP_AUTOCONF`"; then
cat <<EOF
Cannot find autoconf. Please check your autoconf installation and the
\$PHP_AUTOCONF environment variable. Then, rerun this script.
EOF
exit 1
fi
if test ! -x "$PHP_AUTOHEADER" && test ! -x "`$php_shtool path $PHP_AUTOHEADER`"; then
cat <<EOF
Cannot find autoheader. Please check your autoconf installation and the
\$PHP_AUTOHEADER environment variable. Then, rerun this script.
EOF
exit 1
fi
}
phpize_copy_files()
{
test -d build || mkdir build
(cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
(cd "$phpdir" && cp $FILES "$builddir")
}
phpize_replace_prefix()
{
$SED \
-e "s#/home/wreng/php-8.3.3-linux#$prefix#" \
< "$phpdir/phpize.m4" > configure.ac
}
phpize_autotools()
{
# Remove aclocal.m4 if present. It is automatically included by autoconf but
# not used by the PHP build system since PHP 7.4.
rm -f aclocal.m4
$PHP_AUTOCONF || exit 1
$PHP_AUTOHEADER || exit 1
}
# Main script
case "$1" in
# Cleanup
--clean)
phpize_check_configm4 1
phpize_clean
exit 0
;;
# Usage
--help)
phpize_usage
exit 0
;;
# Version
--version|-v)
phpize_print_api_numbers
exit 0
;;
# Default
*)
phpize_check_configm4 0
phpize_check_build_files
phpize_print_api_numbers
phpize_copy_files
phpize_replace_prefix
phpize_check_shtool
phpize_check_autotools
phpize_autotools
;;
esac
exit 0

200
include/php/TSRM/TSRM.h Normal file
View File

@ -0,0 +1,200 @@
/*
+----------------------------------------------------------------------+
| Thread Safe Resource Manager |
+----------------------------------------------------------------------+
| Copyright (c) 1999-2011, Andi Gutmans, Sascha Schumann, Zeev Suraski |
| This source file is subject to the TSRM license, that is bundled |
| with this package in the file LICENSE |
+----------------------------------------------------------------------+
| Authors: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef TSRM_H
#define TSRM_H
#if !defined(__CYGWIN__) && defined(WIN32)
# define TSRM_WIN32
# include "Zend/zend_config.w32.h"
#else
# include "main/php_config.h"
#endif
#include <stdint.h>
#include <stdbool.h>
#ifdef TSRM_WIN32
# ifdef TSRM_EXPORTS
# define TSRM_API __declspec(dllexport)
# else
# define TSRM_API __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define TSRM_API __attribute__ ((visibility("default")))
#else
# define TSRM_API
#endif
typedef intptr_t tsrm_intptr_t;
typedef uintptr_t tsrm_uintptr_t;
/* Only compile multi-threading functions if we're in ZTS mode */
#ifdef ZTS
#ifdef TSRM_WIN32
# ifndef TSRM_INCLUDE_FULL_WINDOWS_HEADERS
# define WIN32_LEAN_AND_MEAN
# endif
#else
# include <pthread.h>
#endif
#if SIZEOF_SIZE_T == 4
# define TSRM_ALIGNED_SIZE(size) \
(((size) + INT32_C(15)) & ~INT32_C(15))
#else
# define TSRM_ALIGNED_SIZE(size) \
(((size) + INT64_C(15)) & ~INT64_C(15))
#endif
typedef int ts_rsrc_id;
/* Define THREAD_T and MUTEX_T */
#ifdef TSRM_WIN32
# define THREAD_T DWORD
# define MUTEX_T CRITICAL_SECTION *
#else
# define THREAD_T pthread_t
# define MUTEX_T pthread_mutex_t *
#endif
#include <signal.h>
typedef void (*ts_allocate_ctor)(void *);
typedef void (*ts_allocate_dtor)(void *);
#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts
#ifdef __cplusplus
extern "C" {
#endif
/* startup/shutdown */
TSRM_API bool tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename);
TSRM_API void tsrm_shutdown(void);
/* environ lock API */
TSRM_API void tsrm_env_lock(void);
TSRM_API void tsrm_env_unlock(void);
/* allocates a new thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* Fast resource in reserved (pre-allocated) space */
TSRM_API void tsrm_reserve(size_t size);
TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* fetches the requested resource for the current thread */
TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
#define ts_resource(id) ts_resource_ex(id, NULL)
/* frees all resources allocated for the current thread */
TSRM_API void ts_free_thread(void);
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);
/* Debug support */
#define TSRM_ERROR_LEVEL_ERROR 1
#define TSRM_ERROR_LEVEL_CORE 2
#define TSRM_ERROR_LEVEL_INFO 3
typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id);
typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id);
typedef void (*tsrm_shutdown_func_t)(void);
TSRM_API int tsrm_error(int level, const char *format, ...);
TSRM_API void tsrm_error_set(int level, const char *debug_filename);
/* utility functions */
TSRM_API THREAD_T tsrm_thread_id(void);
TSRM_API MUTEX_T tsrm_mutex_alloc(void);
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp);
#ifdef HAVE_SIGPROCMASK
TSRM_API int tsrm_sigmask(int how, const sigset_t *set, sigset_t *oldset);
#endif
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler);
TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler);
TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler);
TSRM_API void *tsrm_get_ls_cache(void);
TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void);
TSRM_API bool tsrm_is_main_thread(void);
TSRM_API bool tsrm_is_shutdown(void);
TSRM_API const char *tsrm_api_name(void);
TSRM_API bool tsrm_is_managed_thread(void);
#ifdef TSRM_WIN32
# define TSRM_TLS __declspec(thread)
#else
# define TSRM_TLS __thread
#endif
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#if !__has_attribute(tls_model) || defined(__FreeBSD__) || defined(__MUSL__) || defined(__HAIKU__)
# define TSRM_TLS_MODEL_ATTR
#elif __PIC__
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
#else
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("local-exec")))
#endif
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
#define TSRMG(id, type, element) (TSRMG_BULK(id, type)->element)
#define TSRMG_BULK(id, type) ((type) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(id)])
#define TSRMG_FAST(offset, type, element) (TSRMG_FAST_BULK(offset, type)->element)
#define TSRMG_FAST_BULK(offset, type) ((type) (((char*) tsrm_get_ls_cache())+(offset)))
#define TSRMG_STATIC(id, type, element) (TSRMG_BULK_STATIC(id, type)->element)
#define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
#define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element)
#define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset)))
#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR;
#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE _tsrm_ls_cache
#ifdef __cplusplus
}
#endif
#else /* non ZTS */
#define tsrm_env_lock()
#define tsrm_env_unlock()
#define TSRMG_STATIC(id, type, element)
#define TSRMLS_MAIN_CACHE_EXTERN()
#define TSRMLS_MAIN_CACHE_DEFINE()
#define TSRMLS_CACHE_EXTERN()
#define TSRMLS_CACHE_DEFINE()
#define TSRMLS_CACHE_UPDATE()
#define TSRMLS_CACHE
#define TSRM_TLS
#endif /* ZTS */
#endif /* TSRM_H */

View File

@ -0,0 +1,106 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Daniel Beulshausen <daniel@php4win.de> |
+----------------------------------------------------------------------+
*/
#ifndef TSRM_WIN32_H
#define TSRM_WIN32_H
#include "TSRM.h"
#include <windows.h>
#include <sys/utime.h>
#include "win32/ipc.h"
struct ipc_perm {
key_t key;
unsigned short uid;
unsigned short gid;
unsigned short cuid;
unsigned short cgid;
unsigned short mode;
unsigned short seq;
};
struct shmid_ds {
struct ipc_perm shm_perm;
size_t shm_segsz;
time_t shm_atime;
time_t shm_dtime;
time_t shm_ctime;
unsigned short shm_cpid;
unsigned short shm_lpid;
short shm_nattch;
};
typedef struct {
FILE *stream;
HANDLE prochnd;
} process_pair;
typedef struct {
void *addr;
HANDLE segment;
struct shmid_ds *descriptor;
} shm_pair;
typedef struct {
process_pair *process;
shm_pair *shm;
int process_size;
int shm_size;
char *comspec;
HANDLE impersonation_token;
PSID impersonation_token_sid;
} tsrm_win32_globals;
#ifdef ZTS
# define TWG(v) TSRMG_STATIC(win32_globals_id, tsrm_win32_globals *, v)
TSRMLS_CACHE_EXTERN()
#else
# define TWG(v) (win32_globals.v)
#endif
#define IPC_PRIVATE 0
#define IPC_CREAT 00001000
#define IPC_EXCL 00002000
#define IPC_NOWAIT 00004000
#define IPC_RMID 0
#define IPC_SET 1
#define IPC_STAT 2
#define IPC_INFO 3
#define SHM_R PAGE_READONLY
#define SHM_W PAGE_READWRITE
#define SHM_RDONLY FILE_MAP_READ
#define SHM_RND FILE_MAP_WRITE
#define SHM_REMAP FILE_MAP_COPY
const char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_len, size_t *key_len);
TSRM_API void tsrm_win32_startup(void);
TSRM_API void tsrm_win32_shutdown(void);
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env);
TSRM_API FILE *popen(const char *command, const char *type);
TSRM_API int pclose(FILE *stream);
TSRM_API int tsrm_win32_access(const char *pathname, int mode);
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
TSRM_API int shmget(key_t key, size_t size, int flags);
TSRM_API void *shmat(int key, const void *shmaddr, int flags);
TSRM_API int shmdt(const void *shmaddr);
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
#endif

View File

@ -0,0 +1,70 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, Call Graph |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CALL_GRAPH_H
#define ZEND_CALL_GRAPH_H
#include "zend_ssa.h"
#include "zend_func_info.h"
#include "zend_optimizer.h"
typedef struct _zend_send_arg_info {
zend_op *opline;
} zend_send_arg_info;
struct _zend_call_info {
zend_op_array *caller_op_array;
zend_op *caller_init_opline;
zend_op *caller_call_opline;
zend_function *callee_func;
zend_call_info *next_caller;
zend_call_info *next_callee;
bool recursive;
bool send_unpack; /* Parameters passed by SEND_UNPACK or SEND_ARRAY */
bool named_args; /* Function has named arguments */
bool is_prototype; /* An overridden child method may be called */
int num_args; /* Number of arguments, excluding named and variadic arguments */
zend_send_arg_info arg_info[1];
};
struct _zend_func_info {
int num;
uint32_t flags;
zend_ssa ssa; /* Static Single Assignment Form */
zend_call_info *caller_info; /* where this function is called from */
zend_call_info *callee_info; /* which functions are called from this one */
zend_call_info **call_map; /* Call info associated with init/call/send opnum */
zend_ssa_var_info return_info;
};
typedef struct _zend_call_graph {
int op_arrays_count;
zend_op_array **op_arrays;
zend_func_info *func_infos;
} zend_call_graph;
BEGIN_EXTERN_C()
ZEND_API void zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array);
ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info);
END_EXTERN_C()
#endif /* ZEND_CALL_GRAPH_H */

View File

@ -0,0 +1,126 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, CFG - Control Flow Graph |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CFG_H
#define ZEND_CFG_H
/* zend_basic_block.flags */
#define ZEND_BB_START (1<<0) /* first block */
#define ZEND_BB_FOLLOW (1<<1) /* follows the next block */
#define ZEND_BB_TARGET (1<<2) /* jump target */
#define ZEND_BB_EXIT (1<<3) /* without successors */
#define ZEND_BB_ENTRY (1<<4) /* stackless entry */
#define ZEND_BB_TRY (1<<5) /* start of try block */
#define ZEND_BB_CATCH (1<<6) /* start of catch block */
#define ZEND_BB_FINALLY (1<<7) /* start of finally block */
#define ZEND_BB_FINALLY_END (1<<8) /* end of finally block */
#define ZEND_BB_UNREACHABLE_FREE (1<<11) /* unreachable loop free */
#define ZEND_BB_RECV_ENTRY (1<<12) /* RECV entry */
#define ZEND_BB_LOOP_HEADER (1<<16)
#define ZEND_BB_IRREDUCIBLE_LOOP (1<<17)
#define ZEND_BB_REACHABLE (1U<<31)
#define ZEND_BB_PROTECTED (ZEND_BB_ENTRY|ZEND_BB_RECV_ENTRY|ZEND_BB_TRY|ZEND_BB_CATCH|ZEND_BB_FINALLY|ZEND_BB_FINALLY_END|ZEND_BB_UNREACHABLE_FREE)
typedef struct _zend_basic_block {
int *successors; /* successor block indices */
uint32_t flags;
uint32_t start; /* first opcode number */
uint32_t len; /* number of opcodes */
int successors_count; /* number of successors */
int predecessors_count; /* number of predecessors */
int predecessor_offset; /* offset of 1-st predecessor */
int idom; /* immediate dominator block */
int loop_header; /* closest loop header, or -1 */
int level; /* steps away from the entry in the dom. tree */
int children; /* list of dominated blocks */
int next_child; /* next dominated block */
int successors_storage[2]; /* up to 2 successor blocks */
} zend_basic_block;
/*
+------------+---+---+---+---+---+
| |OP1|OP2|EXT| 0 | 1 |
+------------+---+---+---+---+---+
|JMP |ADR| | |OP1| - |
|JMPZ | |ADR| |OP2|FOL|
|JMPNZ | |ADR| |OP2|FOL|
|JMPZ_EX | |ADR| |OP2|FOL|
|JMPNZ_EX | |ADR| |OP2|FOL|
|JMP_SET | |ADR| |OP2|FOL|
|COALESCE | |ADR| |OP2|FOL|
|ASSERT_CHK | |ADR| |OP2|FOL|
|NEW | |ADR| |OP2|FOL|
|DCL_ANON* |ADR| | |OP1|FOL|
|FE_RESET_* | |ADR| |OP2|FOL|
|FE_FETCH_* | | |ADR|EXT|FOL|
|CATCH | | |ADR|EXT|FOL|
|FAST_CALL |ADR| | |OP1|FOL|
|FAST_RET | | | | - | - |
|RETURN* | | | | - | - |
|EXIT | | | | - | - |
|THROW | | | | - | - |
|* | | | |FOL| - |
+------------+---+---+---+---+---+
*/
typedef struct _zend_cfg {
int blocks_count; /* number of basic blocks */
int edges_count; /* number of edges */
zend_basic_block *blocks; /* array of basic blocks */
int *predecessors;
uint32_t *map;
uint32_t flags;
} zend_cfg;
/* Build Flags */
#define ZEND_CFG_STACKLESS (1<<30)
#define ZEND_SSA_DEBUG_LIVENESS (1<<29)
#define ZEND_SSA_DEBUG_PHI_PLACEMENT (1<<28)
#define ZEND_SSA_RC_INFERENCE (1<<27)
#define ZEND_CFG_NO_ENTRY_PREDECESSORS (1<<25)
#define ZEND_CFG_RECV_ENTRY (1<<24)
#define ZEND_CALL_TREE (1<<23)
#define ZEND_SSA_USE_CV_RESULTS (1<<22)
#define CRT_CONSTANT_EX(op_array, opline, node) \
(((op_array)->fn_flags & ZEND_ACC_DONE_PASS_TWO) ? \
RT_CONSTANT(opline, (node)) \
: \
CT_CONSTANT_EX(op_array, (node).constant) \
)
#define CRT_CONSTANT(node) \
CRT_CONSTANT_EX(op_array, opline, node)
#define RETURN_VALUE_USED(opline) \
((opline)->result_type != IS_UNUSED)
BEGIN_EXTERN_C()
ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg);
void zend_cfg_remark_reachable_blocks(const zend_op_array *op_array, zend_cfg *cfg);
ZEND_API void zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg);
ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg);
ZEND_API void zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg);
END_EXTERN_C()
#endif /* ZEND_CFG_H */

View File

@ -0,0 +1,51 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, DFG - Data Flow Graph |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_DFG_H
#define ZEND_DFG_H
#include "zend_bitset.h"
#include "zend_cfg.h"
typedef struct _zend_dfg {
int vars;
uint32_t size;
zend_bitset tmp;
zend_bitset def;
zend_bitset use;
zend_bitset in;
zend_bitset out;
} zend_dfg;
#define DFG_BITSET(set, set_size, block_num) \
((set) + ((block_num) * (set_size)))
#define DFG_SET(set, set_size, block_num, var_num) \
zend_bitset_incl(DFG_BITSET(set, set_size, block_num), (var_num))
#define DFG_ISSET(set, set_size, block_num, var_num) \
zend_bitset_in(DFG_BITSET(set, set_size, block_num), (var_num))
BEGIN_EXTERN_C()
void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg *dfg, uint32_t build_flags);
ZEND_API void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def);
END_EXTERN_C()
#endif /* ZEND_DFG_H */

View File

@ -0,0 +1,52 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, Bytecode Visualisation |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_DUMP_H
#define ZEND_DUMP_H
#include "zend_ssa.h"
#include "zend_dfg.h"
#include <stdint.h>
#define ZEND_DUMP_HIDE_UNREACHABLE (1<<0)
#define ZEND_DUMP_RC_INFERENCE (1<<1)
#define ZEND_DUMP_CFG (1<<2)
#define ZEND_DUMP_SSA (1<<3)
#define ZEND_DUMP_LIVE_RANGES (1<<4)
#define ZEND_DUMP_LINE_NUMBERS (1<<5)
BEGIN_EXTERN_C()
ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, const char *msg, const void *data);
ZEND_API void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const zend_ssa *ssa, const zend_ssa_op *ssa_op);
ZEND_API void zend_dump_op_line(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const void *data);
void zend_dump_dominators(const zend_op_array *op_array, const zend_cfg *cfg);
void zend_dump_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg);
void zend_dump_phi_placement(const zend_op_array *op_array, const zend_ssa *ssa);
void zend_dump_variables(const zend_op_array *op_array);
void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, uint32_t dump_flags);
ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, uint8_t var_type, int var_num, uint32_t dump_flags);
ZEND_API void zend_dump_var(const zend_op_array *op_array, uint8_t var_type, int var_num);
void zend_dump_op_array_name(const zend_op_array *op_array);
void zend_dump_const(const zval *zv);
void zend_dump_ht(HashTable *ht);
END_EXTERN_C()
#endif /* ZEND_DUMP_H */

View File

@ -0,0 +1,70 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, Func Info |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_FUNC_INFO_H
#define ZEND_FUNC_INFO_H
#include "zend_ssa.h"
/* func/cfg flags */
#define ZEND_FUNC_INDIRECT_VAR_ACCESS (1<<0) /* accesses variables by name */
#define ZEND_FUNC_HAS_CALLS (1<<1)
#define ZEND_FUNC_VARARG (1<<2) /* uses func_get_args() */
#define ZEND_FUNC_NO_LOOPS (1<<3)
#define ZEND_FUNC_IRREDUCIBLE (1<<4)
#define ZEND_FUNC_FREE_LOOP_VAR (1<<5)
#define ZEND_FUNC_RECURSIVE (1<<7)
#define ZEND_FUNC_RECURSIVE_DIRECTLY (1<<8)
#define ZEND_FUNC_RECURSIVE_INDIRECTLY (1<<9)
#define ZEND_FUNC_HAS_EXTENDED_FCALL (1<<10)
#define ZEND_FUNC_HAS_EXTENDED_STMT (1<<11)
#define ZEND_SSA_TSSA (1<<12) /* used by tracing JIT */
#define ZEND_FUNC_JIT_ON_FIRST_EXEC (1<<13) /* used by JIT */
#define ZEND_FUNC_JIT_ON_PROF_REQUEST (1<<14) /* used by JIT */
#define ZEND_FUNC_JIT_ON_HOT_COUNTERS (1<<15) /* used by JIT */
#define ZEND_FUNC_JIT_ON_HOT_TRACE (1<<16) /* used by JIT */
typedef struct _zend_func_info zend_func_info;
typedef struct _zend_call_info zend_call_info;
#define ZEND_FUNC_INFO(op_array) \
((zend_func_info*)((op_array)->reserved[zend_func_info_rid]))
#define ZEND_SET_FUNC_INFO(op_array, info) do { \
zend_func_info** pinfo = (zend_func_info**)&(op_array)->reserved[zend_func_info_rid]; \
*pinfo = info; \
} while (0)
BEGIN_EXTERN_C()
extern ZEND_API int zend_func_info_rid;
uint32_t zend_get_internal_func_info(
const zend_function *callee_func, const zend_call_info *call_info, const zend_ssa *ssa);
ZEND_API uint32_t zend_get_func_info(
const zend_call_info *call_info, const zend_ssa *ssa,
zend_class_entry **ce, bool *ce_is_instanceof);
zend_result zend_func_info_startup(void);
zend_result zend_func_info_shutdown(void);
END_EXTERN_C()
#endif /* ZEND_FUNC_INFO_H */

View File

@ -0,0 +1,246 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, e-SSA based Type & Range Inference |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_INFERENCE_H
#define ZEND_INFERENCE_H
#include "zend_optimizer.h"
#include "zend_ssa.h"
#include "zend_bitset.h"
/* Bitmask for type inference (zend_ssa_var_info.type) */
#include "zend_type_info.h"
#include <stdint.h>
#define MAY_BE_PACKED_GUARD (1<<27) /* needs packed array guard */
#define MAY_BE_CLASS_GUARD (1<<27) /* needs class guard */
#define MAY_BE_GUARD (1<<28) /* needs type guard */
#define MAY_HAVE_DTOR \
(MAY_BE_OBJECT|MAY_BE_RESOURCE \
|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE)
#define DEFINE_SSA_OP_HAS_RANGE(opN) \
static zend_always_inline bool _ssa_##opN##_has_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
return (Z_TYPE_P(zv) == IS_LONG); \
} else { \
return (opline->opN##_type != IS_UNUSED && \
ssa->var_info && \
ssa_op->opN##_use >= 0 && \
ssa->var_info[ssa_op->opN##_use].has_range); \
} \
return 0; \
} \
#define DEFINE_SSA_OP_MIN_RANGE(opN) \
static zend_always_inline zend_long _ssa_##opN##_min_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
if (Z_TYPE_P(zv) == IS_LONG) { \
return Z_LVAL_P(zv); \
} \
} else if (opline->opN##_type != IS_UNUSED && \
ssa->var_info && \
ssa_op->opN##_use >= 0 && \
ssa->var_info[ssa_op->opN##_use].has_range) { \
return ssa->var_info[ssa_op->opN##_use].range.min; \
} \
return ZEND_LONG_MIN; \
} \
#define DEFINE_SSA_OP_MAX_RANGE(opN) \
static zend_always_inline zend_long _ssa_##opN##_max_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
if (Z_TYPE_P(zv) == IS_LONG) { \
return Z_LVAL_P(zv); \
} \
} else if (opline->opN##_type != IS_UNUSED && \
ssa->var_info && \
ssa_op->opN##_use >= 0 && \
ssa->var_info[ssa_op->opN##_use].has_range) { \
return ssa->var_info[ssa_op->opN##_use].range.max; \
} \
return ZEND_LONG_MAX; \
} \
#define DEFINE_SSA_OP_RANGE_UNDERFLOW(opN) \
static zend_always_inline char _ssa_##opN##_range_underflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
if (Z_TYPE_P(zv) == IS_LONG) { \
return 0; \
} \
} else if (opline->opN##_type != IS_UNUSED && \
ssa->var_info && \
ssa_op->opN##_use >= 0 && \
ssa->var_info[ssa_op->opN##_use].has_range) { \
return ssa->var_info[ssa_op->opN##_use].range.underflow; \
} \
return 1; \
} \
#define DEFINE_SSA_OP_RANGE_OVERFLOW(opN) \
static zend_always_inline char _ssa_##opN##_range_overflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
if (Z_TYPE_P(zv) == IS_LONG) { \
return 0; \
} \
} else if (opline->opN##_type != IS_UNUSED && \
ssa->var_info && \
ssa_op->opN##_use >= 0 && \
ssa->var_info[ssa_op->opN##_use].has_range) { \
return ssa->var_info[ssa_op->opN##_use].range.overflow; \
} \
return 1; \
} \
DEFINE_SSA_OP_HAS_RANGE(op1)
DEFINE_SSA_OP_MIN_RANGE(op1)
DEFINE_SSA_OP_MAX_RANGE(op1)
DEFINE_SSA_OP_RANGE_UNDERFLOW(op1)
DEFINE_SSA_OP_RANGE_OVERFLOW(op1)
DEFINE_SSA_OP_HAS_RANGE(op2)
DEFINE_SSA_OP_MIN_RANGE(op2)
DEFINE_SSA_OP_MAX_RANGE(op2)
DEFINE_SSA_OP_RANGE_UNDERFLOW(op2)
DEFINE_SSA_OP_RANGE_OVERFLOW(op2)
#define OP1_HAS_RANGE() (_ssa_op1_has_range (op_array, ssa, opline, ssa_op))
#define OP1_MIN_RANGE() (_ssa_op1_min_range (op_array, ssa, opline, ssa_op))
#define OP1_MAX_RANGE() (_ssa_op1_max_range (op_array, ssa, opline, ssa_op))
#define OP1_RANGE_UNDERFLOW() (_ssa_op1_range_underflow (op_array, ssa, opline, ssa_op))
#define OP1_RANGE_OVERFLOW() (_ssa_op1_range_overflow (op_array, ssa, opline, ssa_op))
#define OP2_HAS_RANGE() (_ssa_op2_has_range (op_array, ssa, opline, ssa_op))
#define OP2_MIN_RANGE() (_ssa_op2_min_range (op_array, ssa, opline, ssa_op))
#define OP2_MAX_RANGE() (_ssa_op2_max_range (op_array, ssa, opline, ssa_op))
#define OP2_RANGE_UNDERFLOW() (_ssa_op2_range_underflow (op_array, ssa, opline, ssa_op))
#define OP2_RANGE_OVERFLOW() (_ssa_op2_range_overflow (op_array, ssa, opline, ssa_op))
BEGIN_EXTERN_C()
ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv);
END_EXTERN_C()
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
return zend_array_type_info(zv);
} else {
uint32_t tmp = (1 << Z_TYPE_P(zv));
if (Z_REFCOUNTED_P(zv)) {
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
} else if (Z_TYPE_P(zv) == IS_STRING) {
tmp |= MAY_BE_RCN;
}
return tmp;
}
}
static zend_always_inline uint32_t get_ssa_var_info(const zend_ssa *ssa, int ssa_var_num)
{
if (ssa->var_info && ssa_var_num >= 0) {
return ssa->var_info[ssa_var_num].type;
} else {
return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
}
}
#define DEFINE_SSA_OP_INFO(opN) \
static zend_always_inline uint32_t _ssa_##opN##_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
return _const_op_type(CRT_CONSTANT(opline->opN)); \
} else { \
return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
} \
} \
#define DEFINE_SSA_OP_DEF_INFO(opN) \
static zend_always_inline uint32_t _ssa_##opN##_def_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
} \
DEFINE_SSA_OP_INFO(op1)
DEFINE_SSA_OP_INFO(op2)
DEFINE_SSA_OP_INFO(result)
DEFINE_SSA_OP_DEF_INFO(op1)
DEFINE_SSA_OP_DEF_INFO(op2)
DEFINE_SSA_OP_DEF_INFO(result)
#define OP1_INFO() (_ssa_op1_info(op_array, ssa, opline, ssa_op))
#define OP2_INFO() (_ssa_op2_info(op_array, ssa, opline, ssa_op))
#define OP1_DATA_INFO() (_ssa_op1_info(op_array, ssa, (opline+1), (ssa_op+1)))
#define OP2_DATA_INFO() (_ssa_op2_info(op_array, ssa, (opline+1), (ssa_op+1)))
#define RES_USE_INFO() (_ssa_result_info(op_array, ssa, opline, ssa_op))
#define OP1_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, opline, ssa_op))
#define OP2_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, opline, ssa_op))
#define OP1_DATA_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, (opline+1), (ssa_op+1)))
#define OP2_DATA_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, (opline+1), (ssa_op+1)))
#define RES_INFO() (_ssa_result_def_info(op_array, ssa, opline, ssa_op))
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a > ZEND_LONG_MAX - b)
|| (b < 0 && a < ZEND_LONG_MIN - b);
}
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a < ZEND_LONG_MIN + b)
|| (b < 0 && a > ZEND_LONG_MAX + b);
}
BEGIN_EXTERN_C()
ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API zend_result zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert);
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
ZEND_API uint32_t zend_fetch_arg_info_type(
const zend_script *script, const zend_arg_info *arg_info, zend_class_entry **pce);
ZEND_API void zend_init_func_return_info(
const zend_op_array *op_array, const zend_script *script, zend_ssa_var_info *ret);
uint32_t zend_get_return_info_from_signature_only(
const zend_function *func, const zend_script *script,
zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info);
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2);
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa);
ZEND_API zend_result zend_update_type_info(
const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script,
zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes,
zend_long optimization_level);
END_EXTERN_C()
#endif /* ZEND_INFERENCE_H */

View File

@ -0,0 +1,103 @@
/*
+----------------------------------------------------------------------+
| Zend OPcache |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Stanislav Malyshev <stas@zend.com> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OPTIMIZER_H
#define ZEND_OPTIMIZER_H
#include "zend.h"
#include "zend_compile.h"
#define ZEND_OPTIMIZER_PASS_1 (1<<0) /* Simple local optimizations */
#define ZEND_OPTIMIZER_PASS_2 (1<<1) /* */
#define ZEND_OPTIMIZER_PASS_3 (1<<2) /* Jump optimization */
#define ZEND_OPTIMIZER_PASS_4 (1<<3) /* INIT_FCALL_BY_NAME -> DO_FCALL */
#define ZEND_OPTIMIZER_PASS_5 (1<<4) /* CFG based optimization */
#define ZEND_OPTIMIZER_PASS_6 (1<<5) /* DFA based optimization */
#define ZEND_OPTIMIZER_PASS_7 (1<<6) /* CALL GRAPH optimization */
#define ZEND_OPTIMIZER_PASS_8 (1<<7) /* SCCP (constant propagation) */
#define ZEND_OPTIMIZER_PASS_9 (1<<8) /* TMP VAR usage */
#define ZEND_OPTIMIZER_PASS_10 (1<<9) /* NOP removal */
#define ZEND_OPTIMIZER_PASS_11 (1<<10) /* Merge equal constants */
#define ZEND_OPTIMIZER_PASS_12 (1<<11) /* Adjust used stack */
#define ZEND_OPTIMIZER_PASS_13 (1<<12) /* Remove unused variables */
#define ZEND_OPTIMIZER_PASS_14 (1<<13) /* DCE (dead code elimination) */
#define ZEND_OPTIMIZER_PASS_15 (1<<14) /* (unsafe) Collect constants */
#define ZEND_OPTIMIZER_PASS_16 (1<<15) /* Inline functions */
#define ZEND_OPTIMIZER_IGNORE_OVERLOADING (1<<16) /* (unsafe) Ignore possibility of operator overloading */
#define ZEND_OPTIMIZER_NARROW_TO_DOUBLE (1<<17) /* try to narrow long constant assignments to double */
#define ZEND_OPTIMIZER_ALL_PASSES 0x7FFFFFFF
#define DEFAULT_OPTIMIZATION_LEVEL "0x7FFEBFFF"
#define ZEND_DUMP_AFTER_PASS_1 ZEND_OPTIMIZER_PASS_1
#define ZEND_DUMP_AFTER_PASS_2 ZEND_OPTIMIZER_PASS_2
#define ZEND_DUMP_AFTER_PASS_3 ZEND_OPTIMIZER_PASS_3
#define ZEND_DUMP_AFTER_PASS_4 ZEND_OPTIMIZER_PASS_4
#define ZEND_DUMP_AFTER_PASS_5 ZEND_OPTIMIZER_PASS_5
#define ZEND_DUMP_AFTER_PASS_6 ZEND_OPTIMIZER_PASS_6
#define ZEND_DUMP_AFTER_PASS_7 ZEND_OPTIMIZER_PASS_7
#define ZEND_DUMP_AFTER_PASS_8 ZEND_OPTIMIZER_PASS_8
#define ZEND_DUMP_AFTER_PASS_9 ZEND_OPTIMIZER_PASS_9
#define ZEND_DUMP_AFTER_PASS_10 ZEND_OPTIMIZER_PASS_10
#define ZEND_DUMP_AFTER_PASS_11 ZEND_OPTIMIZER_PASS_11
#define ZEND_DUMP_AFTER_PASS_12 ZEND_OPTIMIZER_PASS_12
#define ZEND_DUMP_AFTER_PASS_13 ZEND_OPTIMIZER_PASS_13
#define ZEND_DUMP_AFTER_PASS_14 ZEND_OPTIMIZER_PASS_14
#define ZEND_DUMP_BEFORE_OPTIMIZER (1<<16)
#define ZEND_DUMP_AFTER_OPTIMIZER (1<<17)
#define ZEND_DUMP_BEFORE_BLOCK_PASS (1<<18)
#define ZEND_DUMP_AFTER_BLOCK_PASS (1<<19)
#define ZEND_DUMP_BLOCK_PASS_VARS (1<<20)
#define ZEND_DUMP_BEFORE_DFA_PASS (1<<21)
#define ZEND_DUMP_AFTER_DFA_PASS (1<<22)
#define ZEND_DUMP_DFA_CFG (1<<23)
#define ZEND_DUMP_DFA_DOMINATORS (1<<24)
#define ZEND_DUMP_DFA_LIVENESS (1<<25)
#define ZEND_DUMP_DFA_PHI (1<<26)
#define ZEND_DUMP_DFA_SSA (1<<27)
#define ZEND_DUMP_DFA_SSA_VARS (1<<28)
#define ZEND_DUMP_SCCP (1<<29)
typedef struct _zend_script {
zend_string *filename;
zend_op_array main_op_array;
HashTable function_table;
HashTable class_table;
} zend_script;
typedef void (*zend_optimizer_pass_t)(zend_script *, void *context);
BEGIN_EXTERN_C()
ZEND_API void zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level);
ZEND_API int zend_optimizer_register_pass(zend_optimizer_pass_t pass);
ZEND_API void zend_optimizer_unregister_pass(int idx);
zend_result zend_optimizer_startup(void);
zend_result zend_optimizer_shutdown(void);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,328 @@
/*
+----------------------------------------------------------------------+
| Zend Engine, SSA - Static Single Assignment Form |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SSA_H
#define ZEND_SSA_H
#include "zend_optimizer.h"
#include "zend_cfg.h"
typedef struct _zend_ssa_range {
zend_long min;
zend_long max;
bool underflow;
bool overflow;
} zend_ssa_range;
typedef enum _zend_ssa_negative_lat {
NEG_NONE = 0,
NEG_INIT = 1,
NEG_INVARIANT = 2,
NEG_USE_LT = 3,
NEG_USE_GT = 4,
NEG_UNKNOWN = 5
} zend_ssa_negative_lat;
/* Special kind of SSA Phi function used in eSSA */
typedef struct _zend_ssa_range_constraint {
zend_ssa_range range; /* simple range constraint */
int min_var;
int max_var;
int min_ssa_var; /* ((min_var>0) ? MIN(ssa_var) : 0) + range.min */
int max_ssa_var; /* ((max_var>0) ? MAX(ssa_var) : 0) + range.max */
zend_ssa_negative_lat negative;
} zend_ssa_range_constraint;
typedef struct _zend_ssa_type_constraint {
uint32_t type_mask; /* Type mask to intersect with */
zend_class_entry *ce; /* Class entry for instanceof constraints */
} zend_ssa_type_constraint;
typedef union _zend_ssa_pi_constraint {
zend_ssa_range_constraint range;
zend_ssa_type_constraint type;
} zend_ssa_pi_constraint;
/* SSA Phi - ssa_var = Phi(source0, source1, ...sourceN) */
typedef struct _zend_ssa_phi zend_ssa_phi;
struct _zend_ssa_phi {
zend_ssa_phi *next; /* next Phi in the same BB */
int pi; /* if >= 0 this is actually a e-SSA Pi */
zend_ssa_pi_constraint constraint; /* e-SSA Pi constraint */
int var; /* Original CV, VAR or TMP variable index */
int ssa_var; /* SSA variable index */
int block; /* current BB index */
bool has_range_constraint : 1;
zend_ssa_phi **use_chains;
zend_ssa_phi *sym_use_chain;
int *sources; /* Array of SSA IDs that produce this var.
As many as this block has
predecessors. */
};
typedef struct _zend_ssa_block {
zend_ssa_phi *phis;
} zend_ssa_block;
typedef struct _zend_ssa_op {
int op1_use;
int op2_use;
int result_use;
int op1_def;
int op2_def;
int result_def;
int op1_use_chain;
int op2_use_chain;
int res_use_chain;
} zend_ssa_op;
typedef enum _zend_ssa_alias_kind {
NO_ALIAS,
SYMTABLE_ALIAS,
HTTP_RESPONSE_HEADER_ALIAS
} zend_ssa_alias_kind;
typedef enum _zend_ssa_escape_state {
ESCAPE_STATE_UNKNOWN,
ESCAPE_STATE_NO_ESCAPE,
ESCAPE_STATE_FUNCTION_ESCAPE,
ESCAPE_STATE_GLOBAL_ESCAPE
} zend_ssa_escape_state;
typedef struct _zend_ssa_var {
int var; /* original var number; op.var for CVs and following numbers for VARs and TMP_VARs */
int scc; /* strongly connected component */
int definition; /* opcode that defines this value */
int use_chain; /* uses of this value, linked through opN_use_chain */
zend_ssa_phi *definition_phi; /* phi that defines this value */
zend_ssa_phi *phi_use_chain; /* uses of this value in Phi, linked through use_chain */
zend_ssa_phi *sym_use_chain; /* uses of this value in Pi constraints */
unsigned int no_val : 1; /* value doesn't matter (used as op1 in ZEND_ASSIGN) */
unsigned int scc_entry : 1;
unsigned int alias : 2; /* value may be changed indirectly */
unsigned int escape_state : 2;
} zend_ssa_var;
typedef struct _zend_ssa_var_info {
uint32_t type; /* inferred type (see zend_inference.h) */
bool has_range : 1;
bool is_instanceof : 1; /* 0 - class == "ce", 1 - may be child of "ce" */
bool recursive : 1;
bool use_as_double : 1;
bool delayed_fetch_this : 1;
bool avoid_refcounting : 1;
bool guarded_reference : 1;
bool indirect_reference : 1; /* IS_INDIRECT returned by FETCH_DIM_W/FETCH_OBJ_W */
zend_ssa_range range;
zend_class_entry *ce;
} zend_ssa_var_info;
typedef struct _zend_ssa {
zend_cfg cfg; /* control flow graph */
int vars_count; /* number of SSA variables */
int sccs; /* number of SCCs */
zend_ssa_block *blocks; /* array of SSA blocks */
zend_ssa_op *ops; /* array of SSA instructions */
zend_ssa_var *vars; /* use/def chain of SSA variables */
zend_ssa_var_info *var_info;
} zend_ssa;
BEGIN_EXTERN_C()
ZEND_API zend_result zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa);
ZEND_API void zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var);
void zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var);
void zend_ssa_replace_use_chain(zend_ssa *ssa, int op, int new_op, int var);
void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to);
void zend_ssa_remove_defs_of_instr(zend_ssa *ssa, zend_ssa_op *ssa_op);
void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op);
void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi);
void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num);
void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int b);
void zend_ssa_rename_var_uses(zend_ssa *ssa, int old_var, int new_var, bool update_types);
void zend_ssa_remove_block_from_cfg(zend_ssa *ssa, int b);
static zend_always_inline void _zend_ssa_remove_def(zend_ssa_var *var)
{
ZEND_ASSERT(var->definition >= 0);
ZEND_ASSERT(var->use_chain < 0);
ZEND_ASSERT(!var->phi_use_chain);
var->definition = -1;
}
static zend_always_inline void zend_ssa_remove_result_def(zend_ssa *ssa, zend_ssa_op *ssa_op)
{
zend_ssa_var *var = &ssa->vars[ssa_op->result_def];
_zend_ssa_remove_def(var);
ssa_op->result_def = -1;
}
static zend_always_inline void zend_ssa_remove_op1_def(zend_ssa *ssa, zend_ssa_op *ssa_op)
{
zend_ssa_var *var = &ssa->vars[ssa_op->op1_def];
_zend_ssa_remove_def(var);
ssa_op->op1_def = -1;
}
static zend_always_inline void zend_ssa_remove_op2_def(zend_ssa *ssa, zend_ssa_op *ssa_op)
{
zend_ssa_var *var = &ssa->vars[ssa_op->op2_def];
_zend_ssa_remove_def(var);
ssa_op->op2_def = -1;
}
END_EXTERN_C()
static zend_always_inline int zend_ssa_next_use(const zend_ssa_op *ssa_op, int var, int use)
{
ssa_op += use;
if (ssa_op->op1_use == var) {
return ssa_op->op1_use_chain;
} else if (ssa_op->op2_use == var) {
return ssa_op->op2_use_chain;
} else {
return ssa_op->res_use_chain;
}
}
static zend_always_inline zend_ssa_phi* zend_ssa_next_use_phi(const zend_ssa *ssa, int var, const zend_ssa_phi *p)
{
if (p->pi >= 0) {
return p->use_chains[0];
} else {
int j;
for (j = 0; j < ssa->cfg.blocks[p->block].predecessors_count; j++) {
if (p->sources[j] == var) {
return p->use_chains[j];
}
}
}
return NULL;
}
static zend_always_inline bool zend_ssa_is_no_val_use(const zend_op *opline, const zend_ssa_op *ssa_op, int var)
{
if (opline->opcode == ZEND_ASSIGN
|| opline->opcode == ZEND_UNSET_CV
|| opline->opcode == ZEND_BIND_GLOBAL
|| opline->opcode == ZEND_BIND_STATIC) {
return ssa_op->op1_use == var && ssa_op->op2_use != var;
}
if (opline->opcode == ZEND_FE_FETCH_R || opline->opcode == ZEND_FE_FETCH_RW) {
return ssa_op->op2_use == var && ssa_op->op1_use != var;
}
if (ssa_op->result_use == var
&& opline->opcode != ZEND_ADD_ARRAY_ELEMENT
&& opline->opcode != ZEND_ADD_ARRAY_UNPACK) {
return ssa_op->op1_use != var && ssa_op->op2_use != var;
}
return 0;
}
static zend_always_inline void zend_ssa_rename_defs_of_instr(zend_ssa *ssa, zend_ssa_op *ssa_op) {
/* Rename def to use if possible. Mark variable as not defined otherwise. */
if (ssa_op->op1_def >= 0) {
if (ssa_op->op1_use >= 0) {
zend_ssa_rename_var_uses(ssa, ssa_op->op1_def, ssa_op->op1_use, 1);
}
ssa->vars[ssa_op->op1_def].definition = -1;
ssa_op->op1_def = -1;
}
if (ssa_op->op2_def >= 0) {
if (ssa_op->op2_use >= 0) {
zend_ssa_rename_var_uses(ssa, ssa_op->op2_def, ssa_op->op2_use, 1);
}
ssa->vars[ssa_op->op2_def].definition = -1;
ssa_op->op2_def = -1;
}
if (ssa_op->result_def >= 0) {
if (ssa_op->result_use >= 0) {
zend_ssa_rename_var_uses(ssa, ssa_op->result_def, ssa_op->result_use, 1);
}
ssa->vars[ssa_op->result_def].definition = -1;
ssa_op->result_def = -1;
}
}
#define NUM_PHI_SOURCES(phi) \
((phi)->pi >= 0 ? 1 : (ssa->cfg.blocks[(phi)->block].predecessors_count))
/* FOREACH_USE and FOREACH_PHI_USE explicitly support "continue"
* and changing the use chain of the current element */
#define FOREACH_USE(var, use) do { \
int _var_num = (var) - ssa->vars, next; \
for (use = (var)->use_chain; use >= 0; use = next) { \
next = zend_ssa_next_use(ssa->ops, _var_num, use);
#define FOREACH_USE_END() \
} \
} while (0)
#define FOREACH_PHI_USE(var, phi) do { \
int _var_num = (var) - ssa->vars; \
zend_ssa_phi *next_phi; \
for (phi = (var)->phi_use_chain; phi; phi = next_phi) { \
next_phi = zend_ssa_next_use_phi(ssa, _var_num, phi);
#define FOREACH_PHI_USE_END() \
} \
} while (0)
#define FOREACH_PHI_SOURCE(phi, source) do { \
zend_ssa_phi *_phi = (phi); \
int _i, _end = NUM_PHI_SOURCES(phi); \
for (_i = 0; _i < _end; _i++) { \
ZEND_ASSERT(_phi->sources[_i] >= 0); \
source = _phi->sources[_i];
#define FOREACH_PHI_SOURCE_END() \
} \
} while (0)
#define FOREACH_PHI(phi) do { \
int _i; \
for (_i = 0; _i < ssa->cfg.blocks_count; _i++) { \
phi = ssa->blocks[_i].phis; \
for (; phi; phi = phi->next) {
#define FOREACH_PHI_END() \
} \
} \
} while (0)
#define FOREACH_BLOCK(block) do { \
int _i; \
for (_i = 0; _i < ssa->cfg.blocks_count; _i++) { \
(block) = &ssa->cfg.blocks[_i]; \
if (!((block)->flags & ZEND_BB_REACHABLE)) { \
continue; \
}
#define FOREACH_BLOCK_END() \
} \
} while (0)
/* Does not support "break" */
#define FOREACH_INSTR_NUM(i) do { \
zend_basic_block *_block; \
FOREACH_BLOCK(_block) { \
uint32_t _end = _block->start + _block->len; \
for ((i) = _block->start; (i) < _end; (i)++) {
#define FOREACH_INSTR_NUM_END() \
} \
} FOREACH_BLOCK_END(); \
} while (0)
#endif /* ZEND_SSA_H */

419
include/php/Zend/zend.h Normal file
View File

@ -0,0 +1,419 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "4.3.3-dev"
#define ZEND_ENGINE_3
#include "zend_types.h"
#include "zend_map_ptr.h"
#include "zend_errors.h"
#include "zend_alloc.h"
#include "zend_llist.h"
#include "zend_string.h"
#include "zend_hash.h"
#include "zend_ast.h"
#include "zend_gc.h"
#include "zend_variables.h"
#include "zend_iterators.h"
#include "zend_stream.h"
#include "zend_smart_str_public.h"
#include "zend_smart_string_public.h"
#include "zend_signal.h"
#include "zend_max_execution_timer.h"
#define zend_sprintf sprintf
#define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
#define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
#define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
#define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
#define USED_RET() \
(!EX(prev_execute_data) || \
!ZEND_USER_CODE(EX(prev_execute_data)->func->common.type) || \
(EX(prev_execute_data)->opline->result_type != IS_UNUSED))
#ifdef ZEND_ENABLE_STATIC_TSRMLS_CACHE
#define ZEND_TSRMG TSRMG_STATIC
#define ZEND_TSRMG_FAST TSRMG_FAST_STATIC
#define ZEND_TSRMLS_CACHE_EXTERN() TSRMLS_CACHE_EXTERN()
#define ZEND_TSRMLS_CACHE_DEFINE() TSRMLS_CACHE_DEFINE()
#define ZEND_TSRMLS_CACHE_UPDATE() TSRMLS_CACHE_UPDATE()
#define ZEND_TSRMLS_CACHE TSRMLS_CACHE
#else
#define ZEND_TSRMG TSRMG
#define ZEND_TSRMG_FAST TSRMG_FAST
#define ZEND_TSRMLS_CACHE_EXTERN()
#define ZEND_TSRMLS_CACHE_DEFINE()
#define ZEND_TSRMLS_CACHE_UPDATE()
#define ZEND_TSRMLS_CACHE
#endif
#ifndef ZEND_COMPILE_DL_EXT
TSRMLS_MAIN_CACHE_EXTERN()
#else
ZEND_TSRMLS_CACHE_EXTERN()
#endif
struct _zend_serialize_data;
struct _zend_unserialize_data;
typedef struct _zend_serialize_data zend_serialize_data;
typedef struct _zend_unserialize_data zend_unserialize_data;
typedef struct _zend_class_name {
zend_string *name;
zend_string *lc_name;
} zend_class_name;
typedef struct _zend_trait_method_reference {
zend_string *method_name;
zend_string *class_name;
} zend_trait_method_reference;
typedef struct _zend_trait_precedence {
zend_trait_method_reference trait_method;
uint32_t num_excludes;
zend_string *exclude_class_names[1];
} zend_trait_precedence;
typedef struct _zend_trait_alias {
zend_trait_method_reference trait_method;
/**
* name for method to be added
*/
zend_string *alias;
/**
* modifiers to be set on trait method
*/
uint32_t modifiers;
} zend_trait_alias;
typedef struct _zend_class_mutable_data {
zval *default_properties_table;
HashTable *constants_table;
uint32_t ce_flags;
HashTable *backed_enum_table;
} zend_class_mutable_data;
typedef struct _zend_class_dependency {
zend_string *name;
zend_class_entry *ce;
} zend_class_dependency;
typedef struct _zend_inheritance_cache_entry zend_inheritance_cache_entry;
typedef struct _zend_error_info {
int type;
uint32_t lineno;
zend_string *filename;
zend_string *message;
} zend_error_info;
struct _zend_inheritance_cache_entry {
zend_inheritance_cache_entry *next;
zend_class_entry *ce;
zend_class_entry *parent;
zend_class_dependency *dependencies;
uint32_t dependencies_count;
uint32_t num_warnings;
zend_error_info **warnings;
zend_class_entry *traits_and_interfaces[1];
};
struct _zend_class_entry {
char type;
zend_string *name;
/* class_entry or string depending on ZEND_ACC_LINKED */
union {
zend_class_entry *parent;
zend_string *parent_name;
};
int refcount;
uint32_t ce_flags;
int default_properties_count;
int default_static_members_count;
zval *default_properties_table;
zval *default_static_members_table;
ZEND_MAP_PTR_DEF(zval *, static_members_table);
HashTable function_table;
HashTable properties_info;
HashTable constants_table;
ZEND_MAP_PTR_DEF(zend_class_mutable_data*, mutable_data);
zend_inheritance_cache_entry *inheritance_cache;
struct _zend_property_info **properties_info_table;
zend_function *constructor;
zend_function *destructor;
zend_function *clone;
zend_function *__get;
zend_function *__set;
zend_function *__unset;
zend_function *__isset;
zend_function *__call;
zend_function *__callstatic;
zend_function *__tostring;
zend_function *__debugInfo;
zend_function *__serialize;
zend_function *__unserialize;
const zend_object_handlers *default_object_handlers;
/* allocated only if class implements Iterator or IteratorAggregate interface */
zend_class_iterator_funcs *iterator_funcs_ptr;
/* allocated only if class implements ArrayAccess interface */
zend_class_arrayaccess_funcs *arrayaccess_funcs_ptr;
/* handlers */
union {
zend_object* (*create_object)(zend_class_entry *class_type);
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); /* a class implements this interface */
};
zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref);
zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method);
/* serializer callbacks */
int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
uint32_t num_interfaces;
uint32_t num_traits;
/* class_entry or string(s) depending on ZEND_ACC_LINKED */
union {
zend_class_entry **interfaces;
zend_class_name *interface_names;
};
zend_class_name *trait_names;
zend_trait_alias **trait_aliases;
zend_trait_precedence **trait_precedences;
HashTable *attributes;
uint32_t enum_backing_type;
HashTable *backed_enum_table;
union {
struct {
zend_string *filename;
uint32_t line_start;
uint32_t line_end;
zend_string *doc_comment;
} user;
struct {
const struct _zend_function_entry *builtin_functions;
struct _zend_module_entry *module;
} internal;
} info;
};
typedef struct _zend_utility_functions {
void (*error_function)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
size_t (*write_function)(const char *str, size_t str_length);
FILE *(*fopen_function)(zend_string *filename, zend_string **opened_path);
void (*message_handler)(zend_long message, const void *data);
zval *(*get_configuration_directive)(zend_string *name);
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds);
zend_result (*stream_open_function)(zend_file_handle *handle);
void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap);
void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap);
char *(*getenv_function)(const char *name, size_t name_len);
zend_string *(*resolve_path_function)(zend_string *filename);
} zend_utility_functions;
typedef struct _zend_utility_values {
bool html_errors;
} zend_utility_values;
typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
#define zend_try \
{ \
JMP_BUF *__orig_bailout = EG(bailout); \
JMP_BUF __bailout; \
\
EG(bailout) = &__bailout; \
if (SETJMP(__bailout)==0) {
#define zend_catch \
} else { \
EG(bailout) = __orig_bailout;
#define zend_end_try() \
} \
EG(bailout) = __orig_bailout; \
}
#define zend_first_try EG(bailout)=NULL; zend_try
BEGIN_EXTERN_C()
void zend_startup(zend_utility_functions *utility_functions);
void zend_shutdown(void);
void zend_register_standard_ini_entries(void);
zend_result zend_post_startup(void);
void zend_set_utility_values(zend_utility_values *utility_values);
ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
ZEND_API size_t zend_get_page_size(void);
ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap);
ZEND_API size_t zend_spprintf(char **message, size_t max_len, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
ZEND_API zend_string *zend_vstrpprintf(size_t max_len, const char *format, va_list ap);
ZEND_API zend_string *zend_strpprintf(size_t max_len, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
/* Same as zend_spprintf and zend_strpprintf, without checking of format validity.
* For use with custom printf specifiers such as %H. */
ZEND_API size_t zend_spprintf_unchecked(char **message, size_t max_len, const char *format, ...);
ZEND_API zend_string *zend_strpprintf_unchecked(size_t max_len, const char *format, ...);
ZEND_API const char *get_zend_version(void);
ZEND_API bool zend_make_printable_zval(zval *expr, zval *expr_copy);
ZEND_API size_t zend_print_zval(zval *expr, int indent);
ZEND_API void zend_print_zval_r(zval *expr, int indent);
ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent);
ZEND_API void zend_print_flat_zval_r(zval *expr);
void zend_print_flat_zval_r_to_buf(smart_str *str, zval *expr);
static zend_always_inline size_t zend_print_variable(zval *var) {
return zend_print_zval(var, 0);
}
ZEND_API ZEND_COLD void zend_output_debug_string(bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API void zend_activate(void);
ZEND_API void zend_deactivate(void);
ZEND_API void zend_call_destructors(void);
ZEND_API void zend_activate_modules(void);
ZEND_API void zend_deactivate_modules(void);
ZEND_API void zend_post_deactivate_modules(void);
ZEND_API void free_estring(char **str_p);
END_EXTERN_C()
/* output support */
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
#define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
#define ZEND_PUTS(str) zend_write((str), strlen((str)))
#define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
#define ZEND_PUTC(c) zend_write(&(c), 1)
BEGIN_EXTERN_C()
extern ZEND_API size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(zend_string *filename, zend_string **opened_path);
extern ZEND_API void (*zend_ticks_function)(int ticks);
extern ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
extern ZEND_API void (*zend_error_cb)(int type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
extern ZEND_API void (*zend_on_timeout)(int seconds);
extern ZEND_API zend_result (*zend_stream_open_function)(zend_file_handle *handle);
extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
extern ZEND_API zend_string *(*zend_resolve_path)(zend_string *filename);
/* These two callbacks are especially for opcache */
extern ZEND_API zend_result (*zend_post_startup_cb)(void);
extern ZEND_API void (*zend_post_shutdown_cb)(void);
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
/* For custom format specifiers like H */
ZEND_API ZEND_COLD void zend_error_unchecked(int type, const char *format, ...);
/* If filename is NULL the default filename is used. */
ZEND_API ZEND_COLD void zend_error_at(int type, zend_string *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_at_noreturn(int type, zend_string *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
ZEND_API ZEND_COLD void zend_error_zstr(int type, zend_string *message);
ZEND_API ZEND_COLD void zend_error_zstr_at(int type, zend_string *filename, uint32_t lineno, zend_string *message);
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
ZEND_API ZEND_COLD void zend_argument_count_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
ZEND_API ZEND_COLD void zend_value_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
/* type should be one of the BP_VAR_* constants, only special messages happen for isset/empty and unset */
ZEND_API ZEND_COLD void zend_illegal_container_offset(const zend_string *container, const zval *offset, int type);
ZEND_COLD void zenderror(const char *error);
/* For internal C errors */
ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn, const char *message);
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
#define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
extern ZEND_API zend_class_entry *zend_standard_class_def;
extern ZEND_API zend_utility_values zend_uv;
/* If DTrace is available and enabled */
extern ZEND_API bool zend_dtrace_enabled;
END_EXTERN_C()
#define ZEND_UV(name) (zend_uv.name)
BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(zend_long message, const void *data);
ZEND_API zval *zend_get_configuration_directive(zend_string *name);
END_EXTERN_C()
/* Messages for applications of Zend */
#define ZMSG_FAILED_INCLUDE_FOPEN 1L
#define ZMSG_FAILED_REQUIRE_FOPEN 2L
#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
#define ZMSG_MEMORY_LEAK_DETECTED 4L
#define ZMSG_MEMORY_LEAK_REPEATED 5L
#define ZMSG_LOG_SCRIPT_NAME 6L
#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
typedef enum {
EH_NORMAL = 0,
EH_THROW
} zend_error_handling_t;
typedef struct {
zend_error_handling_t handling;
zend_class_entry *exception;
} zend_error_handling;
BEGIN_EXTERN_C()
ZEND_API void zend_save_error_handling(zend_error_handling *current);
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current);
ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
ZEND_API void zend_begin_record_errors(void);
ZEND_API void zend_emit_recorded_errors(void);
ZEND_API void zend_free_recorded_errors(void);
END_EXTERN_C()
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
#include "zend_object_handlers.h"
#include "zend_operators.h"
#endif /* ZEND_H */

2534
include/php/Zend/zend_API.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,404 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ALLOC_H
#define ZEND_ALLOC_H
#include <stdio.h>
#include "../TSRM/TSRM.h"
#include "zend.h"
#ifndef ZEND_MM_ALIGNMENT
# error "ZEND_MM_ALIGNMENT was not defined during configure"
#endif
#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT - 1)
#define ZEND_MM_ALIGNED_SIZE(size) (((size) + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK)
#define ZEND_MM_ALIGNED_SIZE_EX(size, alignment) \
(((size) + ((alignment) - 1)) & ~((alignment) - 1))
typedef struct _zend_leak_info {
void *addr;
size_t size;
const char *filename;
const char *orig_filename;
uint32_t lineno;
uint32_t orig_lineno;
} zend_leak_info;
#if ZEND_DEBUG
typedef struct _zend_mm_debug_info {
size_t size;
const char *filename;
const char *orig_filename;
uint32_t lineno;
uint32_t orig_lineno;
} zend_mm_debug_info;
# define ZEND_MM_OVERHEAD ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info))
#else
# define ZEND_MM_OVERHEAD 0
#endif
BEGIN_EXTERN_C()
ZEND_API ZEND_ATTRIBUTE_MALLOC char* ZEND_FASTCALL zend_strndup(const char *s, size_t length);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(1);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset);
ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2);
ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset);
ZEND_API ZEND_ATTRIBUTE_MALLOC char* ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API ZEND_ATTRIBUTE_MALLOC char* ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
#include "zend_alloc_sizes.h"
/* _emalloc() & _efree() specialization */
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
# define _ZEND_BIN_ALLOCATOR_DEF(_num, _size, _elements, _pages, x, y) \
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _emalloc_ ## _size(void);
ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR_DEF, x, y)
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _emalloc_large(size_t size) ZEND_ATTRIBUTE_ALLOC_SIZE(1);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _emalloc_huge(size_t size) ZEND_ATTRIBUTE_ALLOC_SIZE(1);
# define _ZEND_BIN_ALLOCATOR_SELECTOR_START(_num, _size, _elements, _pages, size, y) \
((size <= _size) ? _emalloc_ ## _size() :
# define _ZEND_BIN_ALLOCATOR_SELECTOR_END(_num, _size, _elements, _pages, size, y) \
)
# define ZEND_ALLOCATOR(size) \
ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR_SELECTOR_START, size, y) \
((size <= ZEND_MM_MAX_LARGE_SIZE) ? _emalloc_large(size) : _emalloc_huge(size)) \
ZEND_MM_BINS_INFO(_ZEND_BIN_ALLOCATOR_SELECTOR_END, size, y)
# define _emalloc(size) \
(__builtin_constant_p(size) ? \
ZEND_ALLOCATOR(size) \
: \
_emalloc(size) \
)
# define _ZEND_BIN_DEALLOCATOR_DEF(_num, _size, _elements, _pages, x, y) \
ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *);
ZEND_MM_BINS_INFO(_ZEND_BIN_DEALLOCATOR_DEF, x, y)
ZEND_API void ZEND_FASTCALL _efree_large(void *, size_t size);
ZEND_API void ZEND_FASTCALL _efree_huge(void *, size_t size);
# define _ZEND_BIN_DEALLOCATOR_SELECTOR_START(_num, _size, _elements, _pages, ptr, size) \
if (size <= _size) { _efree_ ## _size(ptr); } else
# define ZEND_DEALLOCATOR(ptr, size) \
ZEND_MM_BINS_INFO(_ZEND_BIN_DEALLOCATOR_SELECTOR_START, ptr, size) \
if (size <= ZEND_MM_MAX_LARGE_SIZE) { _efree_large(ptr, size); } \
else { _efree_huge(ptr, size); }
# define efree_size(ptr, size) do { \
if (__builtin_constant_p(size)) { \
ZEND_DEALLOCATOR(ptr, size) \
} else { \
_efree(ptr); \
} \
} while (0)
# define efree_size_rel(ptr, size) \
efree_size(ptr, size)
#else
# define efree_size(ptr, size) \
efree(ptr)
# define efree_size_rel(ptr, size) \
efree_rel(ptr)
#define _emalloc_large _emalloc
#define _emalloc_huge _emalloc
#define _efree_large _efree
#define _efree_huge _efree
#endif
/* Standard wrapper macros */
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define emalloc_large(size) _emalloc_large((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define emalloc_huge(size) _emalloc_huge((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define efree(ptr) _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define efree_large(ptr) _efree_large((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define efree_huge(ptr) _efree_huge((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define ecalloc(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define erealloc(ptr, size) _erealloc((ptr), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define erealloc2(ptr, size, copy_size) _erealloc2((ptr), (size), (copy_size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define safe_erealloc(ptr, nmemb, size, offset) _safe_erealloc((ptr), (nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define erealloc_recoverable(ptr, size) _erealloc((ptr), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define erealloc2_recoverable(ptr, size, copy_size) _erealloc2((ptr), (size), (copy_size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mem_block_size(ptr) _zend_mem_block_size((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
/* Relay wrapper macros */
#define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define safe_emalloc_rel(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define efree_rel(ptr) _efree((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define ecalloc_rel(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define erealloc_rel(ptr, size) _erealloc((ptr), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define erealloc2_rel(ptr, size, copy_size) _erealloc2((ptr), (size), (copy_size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define erealloc2_recoverable_rel(ptr, size, copy_size) _erealloc2((ptr), (size), (copy_size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define safe_erealloc_rel(ptr, nmemb, size, offset) _safe_erealloc((ptr), (nmemb), (size), (offset) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mem_block_size_rel(ptr) _zend_mem_block_size((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
ZEND_API ZEND_ATTRIBUTE_MALLOC void * __zend_malloc(size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(1);
ZEND_API ZEND_ATTRIBUTE_MALLOC void * __zend_calloc(size_t nmemb, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2);
ZEND_API void * __zend_realloc(void *p, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
ZEND_API ZEND_ATTRIBUTE_MALLOC char * __zend_strdup(const char *s);
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))
#define safe_pemalloc(nmemb, size, offset, persistent) ((persistent)?_safe_malloc(nmemb, size, offset):safe_emalloc(nmemb, size, offset))
#define pefree(ptr, persistent) ((persistent)?free(ptr):efree(ptr))
#define pefree_size(ptr, size, persistent) do { \
if (persistent) { \
free(ptr); \
} else { \
efree_size(ptr, size);\
} \
} while (0)
#define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size)))
#define perealloc(ptr, size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc((ptr), (size)))
#define perealloc2(ptr, size, copy_size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc2((ptr), (size), (copy_size)))
#define safe_perealloc(ptr, nmemb, size, offset, persistent) ((persistent)?_safe_realloc((ptr), (nmemb), (size), (offset)):safe_erealloc((ptr), (nmemb), (size), (offset)))
#define perealloc_recoverable(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc_recoverable((ptr), (size)))
#define perealloc2_recoverable(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc2_recoverable((ptr), (size), (copy_size)))
#define pestrdup(s, persistent) ((persistent)?__zend_strdup(s):estrdup(s))
#define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
#define pemalloc_rel(size, persistent) ((persistent)?__zend_malloc(size):emalloc_rel(size))
#define pefree_rel(ptr, persistent) ((persistent)?free(ptr):efree_rel(ptr))
#define pecalloc_rel(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc_rel((nmemb), (size)))
#define perealloc_rel(ptr, size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc_rel((ptr), (size)))
#define perealloc2_rel(ptr, size, copy_size, persistent) ((persistent)?__zend_realloc((ptr), (size)):erealloc2_rel((ptr), (size), (copy_size)))
#define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size)))
#define perealloc2_recoverable_rel(ptr, size, copy_size, persistent) ((persistent)?realloc((ptr), (size)):erealloc2_recoverable_rel((ptr), (size), (copy_size)))
#define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s))
ZEND_API zend_result zend_set_memory_limit(size_t memory_limit);
ZEND_API bool zend_alloc_in_memory_limit_error_reporting(void);
ZEND_API void start_memory_manager(void);
ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown);
ZEND_API bool is_zend_mm(void);
ZEND_API bool is_zend_ptr(const void *ptr);
ZEND_API size_t zend_memory_usage(bool real_usage);
ZEND_API size_t zend_memory_peak_usage(bool real_usage);
ZEND_API void zend_memory_reset_peak_usage(void);
/* fast cache for HashTables */
#define ALLOC_HASHTABLE(ht) \
(ht) = (HashTable *) emalloc(sizeof(HashTable))
#define FREE_HASHTABLE(ht) \
efree_size(ht, sizeof(HashTable))
#define ALLOC_HASHTABLE_REL(ht) \
(ht) = (HashTable *) emalloc_rel(sizeof(HashTable))
#define FREE_HASHTABLE_REL(ht) \
efree_size_rel(ht, sizeof(HashTable))
/* Heap functions */
typedef struct _zend_mm_heap zend_mm_heap;
ZEND_API zend_mm_heap *zend_mm_startup(void);
ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full_shutdown, bool silent);
ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *p, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
#define zend_mm_alloc(heap, size) _zend_mm_alloc((heap), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mm_free(heap, p) _zend_mm_free((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mm_realloc(heap, p, size) _zend_mm_realloc((heap), (p), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mm_realloc2(heap, p, size, copy_size) _zend_mm_realloc2((heap), (p), (size), (copy_size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mm_block_size(heap, p) _zend_mm_block_size((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define zend_mm_alloc_rel(heap, size) _zend_mm_alloc((heap), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mm_free_rel(heap, p) _zend_mm_free((heap), (p) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mm_realloc_rel(heap, p, size) _zend_mm_realloc((heap), (p), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mm_realloc2_rel(heap, p, size, copy_size) _zend_mm_realloc2((heap), (p), (size), (copy_size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define zend_mm_block_size_rel(heap, p) _zend_mm_block_size((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap);
ZEND_API zend_mm_heap *zend_mm_get_heap(void);
ZEND_API size_t zend_mm_gc(zend_mm_heap *heap);
#define ZEND_MM_CUSTOM_HEAP_NONE 0
#define ZEND_MM_CUSTOM_HEAP_STD 1
#define ZEND_MM_CUSTOM_HEAP_DEBUG 2
ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap);
ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
void* (*_malloc)(size_t),
void (*_free)(void*),
void* (*_realloc)(void*, size_t));
ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap,
void* (**_malloc)(size_t),
void (**_free)(void*),
void* (**_realloc)(void*, size_t));
#if ZEND_DEBUG
ZEND_API void zend_mm_set_custom_debug_handlers(zend_mm_heap *heap,
void* (*_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC),
void (*_free)(void* ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC),
void* (*_realloc)(void*, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC));
#endif
typedef struct _zend_mm_storage zend_mm_storage;
typedef void* (*zend_mm_chunk_alloc_t)(zend_mm_storage *storage, size_t size, size_t alignment);
typedef void (*zend_mm_chunk_free_t)(zend_mm_storage *storage, void *chunk, size_t size);
typedef bool (*zend_mm_chunk_truncate_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size);
typedef bool (*zend_mm_chunk_extend_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size);
typedef struct _zend_mm_handlers {
zend_mm_chunk_alloc_t chunk_alloc;
zend_mm_chunk_free_t chunk_free;
zend_mm_chunk_truncate_t chunk_truncate;
zend_mm_chunk_extend_t chunk_extend;
} zend_mm_handlers;
struct _zend_mm_storage {
const zend_mm_handlers handlers;
void *data;
};
ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap);
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size);
/*
// The following example shows how to use zend_mm_heap API with custom storage
static zend_mm_heap *apc_heap = NULL;
static HashTable *apc_ht = NULL;
typedef struct _apc_data {
void *mem;
uint32_t free_pages;
} apc_data;
static void *apc_chunk_alloc(zend_mm_storage *storage, size_t size, size_t alignment)
{
apc_data *data = (apc_data*)(storage->data);
size_t real_size = ((size + (ZEND_MM_CHUNK_SIZE-1)) & ~(ZEND_MM_CHUNK_SIZE-1));
uint32_t count = real_size / ZEND_MM_CHUNK_SIZE;
uint32_t first, last, i;
ZEND_ASSERT(alignment == ZEND_MM_CHUNK_SIZE);
for (first = 0; first < 32; first++) {
if (!(data->free_pages & (1 << first))) {
last = first;
do {
if (last - first == count - 1) {
for (i = first; i <= last; i++) {
data->free_pages |= (1 << i);
}
return (void *)(((char*)(data->mem)) + ZEND_MM_CHUNK_SIZE * (1 << first));
}
last++;
} while (last < 32 && !(data->free_pages & (1 << last)));
first = last;
}
}
return NULL;
}
static void apc_chunk_free(zend_mm_storage *storage, void *chunk, size_t size)
{
apc_data *data = (apc_data*)(storage->data);
uint32_t i;
ZEND_ASSERT(((uintptr_t)chunk & (ZEND_MM_CHUNK_SIZE - 1)) == 0);
i = ((uintptr_t)chunk - (uintptr_t)(data->mem)) / ZEND_MM_CHUNK_SIZE;
while (1) {
data->free_pages &= ~(1 << i);
if (size <= ZEND_MM_CHUNK_SIZE) {
break;
}
size -= ZEND_MM_CHUNK_SIZE;
}
}
static void apc_init_heap(void)
{
zend_mm_handlers apc_handlers = {
apc_chunk_alloc,
apc_chunk_free,
NULL,
NULL,
};
apc_data tmp_data;
zend_mm_heap *old_heap;
// Preallocate properly aligned SHM chunks (64MB)
tmp_data.mem = shm_memalign(ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE * 32);
// Initialize temporary storage data
tmp_data.free_pages = 0;
// Create heap
apc_heap = zend_mm_startup_ex(&apc_handlers, &tmp_data, sizeof(tmp_data));
// Allocate some data in the heap
old_heap = zend_mm_set_heap(apc_heap);
ALLOC_HASHTABLE(apc_ht);
zend_hash_init(apc_ht, 64, NULL, ZVAL_PTR_DTOR, 0);
zend_mm_set_heap(old_heap);
}
*/
#ifdef ZTS
size_t zend_mm_globals_size(void);
#endif
END_EXTERN_C()
#endif

View File

@ -0,0 +1,64 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ALLOC_SIZES_H
#define ZEND_ALLOC_SIZES_H
#define ZEND_MM_CHUNK_SIZE ((size_t) (2 * 1024 * 1024)) /* 2 MB */
#define ZEND_MM_PAGE_SIZE (4 * 1024) /* 4 KB */
#define ZEND_MM_PAGES (ZEND_MM_CHUNK_SIZE / ZEND_MM_PAGE_SIZE) /* 512 */
#define ZEND_MM_FIRST_PAGE (1)
#define ZEND_MM_MIN_SMALL_SIZE 8
#define ZEND_MM_MAX_SMALL_SIZE 3072
#define ZEND_MM_MAX_LARGE_SIZE (ZEND_MM_CHUNK_SIZE - (ZEND_MM_PAGE_SIZE * ZEND_MM_FIRST_PAGE))
/* num, size, count, pages */
#define ZEND_MM_BINS_INFO(_, x, y) \
_( 0, 8, 512, 1, x, y) \
_( 1, 16, 256, 1, x, y) \
_( 2, 24, 170, 1, x, y) \
_( 3, 32, 128, 1, x, y) \
_( 4, 40, 102, 1, x, y) \
_( 5, 48, 85, 1, x, y) \
_( 6, 56, 73, 1, x, y) \
_( 7, 64, 64, 1, x, y) \
_( 8, 80, 51, 1, x, y) \
_( 9, 96, 42, 1, x, y) \
_(10, 112, 36, 1, x, y) \
_(11, 128, 32, 1, x, y) \
_(12, 160, 25, 1, x, y) \
_(13, 192, 21, 1, x, y) \
_(14, 224, 18, 1, x, y) \
_(15, 256, 16, 1, x, y) \
_(16, 320, 64, 5, x, y) \
_(17, 384, 32, 3, x, y) \
_(18, 448, 9, 1, x, y) \
_(19, 512, 8, 1, x, y) \
_(20, 640, 32, 5, x, y) \
_(21, 768, 16, 3, x, y) \
_(22, 896, 9, 2, x, y) \
_(23, 1024, 8, 2, x, y) \
_(24, 1280, 16, 5, x, y) \
_(25, 1536, 8, 3, x, y) \
_(26, 1792, 16, 7, x, y) \
_(27, 2048, 8, 4, x, y) \
_(28, 2560, 8, 5, x, y) \
_(29, 3072, 4, 3, x, y)
#endif /* ZEND_ALLOC_SIZES_H */

View File

@ -0,0 +1,224 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef _ZEND_ARENA_H_
#define _ZEND_ARENA_H_
#include "zend.h"
#ifndef ZEND_TRACK_ARENA_ALLOC
typedef struct _zend_arena zend_arena;
struct _zend_arena {
char *ptr;
char *end;
zend_arena *prev;
};
static zend_always_inline zend_arena* zend_arena_create(size_t size)
{
zend_arena *arena = (zend_arena*)emalloc(size);
arena->ptr = (char*) arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
arena->end = (char*) arena + size;
arena->prev = NULL;
return arena;
}
static zend_always_inline void zend_arena_destroy(zend_arena *arena)
{
do {
zend_arena *prev = arena->prev;
efree(arena);
arena = prev;
} while (arena);
}
static zend_always_inline void* zend_arena_alloc(zend_arena **arena_ptr, size_t size)
{
zend_arena *arena = *arena_ptr;
char *ptr = arena->ptr;
size = ZEND_MM_ALIGNED_SIZE(size);
if (EXPECTED(size <= (size_t)(arena->end - ptr))) {
arena->ptr = ptr + size;
} else {
size_t arena_size =
UNEXPECTED((size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) > (size_t)(arena->end - (char*) arena)) ?
(size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) :
(size_t)(arena->end - (char*) arena);
zend_arena *new_arena = (zend_arena*)emalloc(arena_size);
ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
new_arena->ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena)) + size;
new_arena->end = (char*) new_arena + arena_size;
new_arena->prev = arena;
*arena_ptr = new_arena;
}
return (void*) ptr;
}
static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size)
{
bool overflow;
size_t size;
void *ret;
size = zend_safe_address(unit_size, count, 0, &overflow);
if (UNEXPECTED(overflow)) {
zend_error(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
}
ret = zend_arena_alloc(arena_ptr, size);
memset(ret, 0, size);
return ret;
}
static zend_always_inline void* zend_arena_checkpoint(zend_arena *arena)
{
return arena->ptr;
}
static zend_always_inline void zend_arena_release(zend_arena **arena_ptr, void *checkpoint)
{
zend_arena *arena = *arena_ptr;
while (UNEXPECTED((char*)checkpoint > arena->end) ||
UNEXPECTED((char*)checkpoint <= (char*)arena)) {
zend_arena *prev = arena->prev;
efree(arena);
*arena_ptr = arena = prev;
}
ZEND_ASSERT((char*)checkpoint > (char*)arena && (char*)checkpoint <= arena->end);
arena->ptr = (char*)checkpoint;
}
static zend_always_inline bool zend_arena_contains(zend_arena *arena, void *ptr)
{
while (arena) {
if ((char*)ptr > (char*)arena && (char*)ptr <= arena->ptr) {
return 1;
}
arena = arena->prev;
}
return 0;
}
#else
/* Use normal allocations and keep track of them for mass-freeing.
* This is intended for use with asan/valgrind. */
typedef struct _zend_arena zend_arena;
struct _zend_arena {
void **ptr;
void **end;
struct _zend_arena *prev;
void *ptrs[0];
};
#define ZEND_TRACKED_ARENA_SIZE 1000
static zend_always_inline zend_arena *zend_arena_create(size_t _size)
{
zend_arena *arena = (zend_arena*) emalloc(
sizeof(zend_arena) + sizeof(void *) * ZEND_TRACKED_ARENA_SIZE);
arena->ptr = &arena->ptrs[0];
arena->end = &arena->ptrs[ZEND_TRACKED_ARENA_SIZE];
arena->prev = NULL;
return arena;
}
static zend_always_inline void zend_arena_destroy(zend_arena *arena)
{
do {
zend_arena *prev = arena->prev;
void **ptr;
for (ptr = arena->ptrs; ptr < arena->ptr; ptr++) {
efree(*ptr);
}
efree(arena);
arena = prev;
} while (arena);
}
static zend_always_inline void *zend_arena_alloc(zend_arena **arena_ptr, size_t size)
{
zend_arena *arena = *arena_ptr;
if (arena->ptr == arena->end) {
*arena_ptr = zend_arena_create(0);
(*arena_ptr)->prev = arena;
arena = *arena_ptr;
}
return *arena->ptr++ = emalloc(size);
}
static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size)
{
bool overflow;
size_t size;
void *ret;
size = zend_safe_address(unit_size, count, 0, &overflow);
if (UNEXPECTED(overflow)) {
zend_error(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
}
ret = zend_arena_alloc(arena_ptr, size);
memset(ret, 0, size);
return ret;
}
static zend_always_inline void* zend_arena_checkpoint(zend_arena *arena)
{
return arena->ptr;
}
static zend_always_inline void zend_arena_release(zend_arena **arena_ptr, void *checkpoint)
{
while (1) {
zend_arena *arena = *arena_ptr;
zend_arena *prev = arena->prev;
while (1) {
if (arena->ptr == (void **) checkpoint) {
return;
}
if (arena->ptr == arena->ptrs) {
break;
}
arena->ptr--;
efree(*arena->ptr);
}
efree(arena);
*arena_ptr = prev;
ZEND_ASSERT(*arena_ptr);
}
}
static zend_always_inline bool zend_arena_contains(zend_arena *arena, void *ptr)
{
/* TODO: Dummy */
return 1;
}
#endif
#endif /* _ZEND_ARENA_H_ */

385
include/php/Zend/zend_ast.h Normal file
View File

@ -0,0 +1,385 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Bob Weinand <bwoebi@php.net> |
| Dmitry Stogov <dmitry@php.net> |
| Nikita Popov <nikic@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_AST_H
#define ZEND_AST_H
#include "zend.h"
#ifndef ZEND_AST_SPEC
# define ZEND_AST_SPEC 1
#endif
#define ZEND_AST_SPECIAL_SHIFT 6
#define ZEND_AST_IS_LIST_SHIFT 7
#define ZEND_AST_NUM_CHILDREN_SHIFT 8
enum _zend_ast_kind {
/* special nodes */
ZEND_AST_ZVAL = 1 << ZEND_AST_SPECIAL_SHIFT,
ZEND_AST_CONSTANT,
ZEND_AST_ZNODE,
/* declaration nodes */
ZEND_AST_FUNC_DECL,
ZEND_AST_CLOSURE,
ZEND_AST_METHOD,
ZEND_AST_CLASS,
ZEND_AST_ARROW_FUNC,
/* list nodes */
ZEND_AST_ARG_LIST = 1 << ZEND_AST_IS_LIST_SHIFT,
ZEND_AST_ARRAY,
ZEND_AST_ENCAPS_LIST,
ZEND_AST_EXPR_LIST,
ZEND_AST_STMT_LIST,
ZEND_AST_IF,
ZEND_AST_SWITCH_LIST,
ZEND_AST_CATCH_LIST,
ZEND_AST_PARAM_LIST,
ZEND_AST_CLOSURE_USES,
ZEND_AST_PROP_DECL,
ZEND_AST_CONST_DECL,
ZEND_AST_CLASS_CONST_DECL,
ZEND_AST_NAME_LIST,
ZEND_AST_TRAIT_ADAPTATIONS,
ZEND_AST_USE,
ZEND_AST_TYPE_UNION,
ZEND_AST_TYPE_INTERSECTION,
ZEND_AST_ATTRIBUTE_LIST,
ZEND_AST_ATTRIBUTE_GROUP,
ZEND_AST_MATCH_ARM_LIST,
ZEND_AST_MODIFIER_LIST,
/* 0 child nodes */
ZEND_AST_MAGIC_CONST = 0 << ZEND_AST_NUM_CHILDREN_SHIFT,
ZEND_AST_TYPE,
ZEND_AST_CONSTANT_CLASS,
ZEND_AST_CALLABLE_CONVERT,
/* 1 child node */
ZEND_AST_VAR = 1 << ZEND_AST_NUM_CHILDREN_SHIFT,
ZEND_AST_CONST,
ZEND_AST_UNPACK,
ZEND_AST_UNARY_PLUS,
ZEND_AST_UNARY_MINUS,
ZEND_AST_CAST,
ZEND_AST_EMPTY,
ZEND_AST_ISSET,
ZEND_AST_SILENCE,
ZEND_AST_SHELL_EXEC,
ZEND_AST_CLONE,
ZEND_AST_EXIT,
ZEND_AST_PRINT,
ZEND_AST_INCLUDE_OR_EVAL,
ZEND_AST_UNARY_OP,
ZEND_AST_PRE_INC,
ZEND_AST_PRE_DEC,
ZEND_AST_POST_INC,
ZEND_AST_POST_DEC,
ZEND_AST_YIELD_FROM,
ZEND_AST_CLASS_NAME,
ZEND_AST_GLOBAL,
ZEND_AST_UNSET,
ZEND_AST_RETURN,
ZEND_AST_LABEL,
ZEND_AST_REF,
ZEND_AST_HALT_COMPILER,
ZEND_AST_ECHO,
ZEND_AST_THROW,
ZEND_AST_GOTO,
ZEND_AST_BREAK,
ZEND_AST_CONTINUE,
/* 2 child nodes */
ZEND_AST_DIM = 2 << ZEND_AST_NUM_CHILDREN_SHIFT,
ZEND_AST_PROP,
ZEND_AST_NULLSAFE_PROP,
ZEND_AST_STATIC_PROP,
ZEND_AST_CALL,
ZEND_AST_CLASS_CONST,
ZEND_AST_ASSIGN,
ZEND_AST_ASSIGN_REF,
ZEND_AST_ASSIGN_OP,
ZEND_AST_BINARY_OP,
ZEND_AST_GREATER,
ZEND_AST_GREATER_EQUAL,
ZEND_AST_AND,
ZEND_AST_OR,
ZEND_AST_ARRAY_ELEM,
ZEND_AST_NEW,
ZEND_AST_INSTANCEOF,
ZEND_AST_YIELD,
ZEND_AST_COALESCE,
ZEND_AST_ASSIGN_COALESCE,
ZEND_AST_STATIC,
ZEND_AST_WHILE,
ZEND_AST_DO_WHILE,
ZEND_AST_IF_ELEM,
ZEND_AST_SWITCH,
ZEND_AST_SWITCH_CASE,
ZEND_AST_DECLARE,
ZEND_AST_USE_TRAIT,
ZEND_AST_TRAIT_PRECEDENCE,
ZEND_AST_METHOD_REFERENCE,
ZEND_AST_NAMESPACE,
ZEND_AST_USE_ELEM,
ZEND_AST_TRAIT_ALIAS,
ZEND_AST_GROUP_USE,
ZEND_AST_ATTRIBUTE,
ZEND_AST_MATCH,
ZEND_AST_MATCH_ARM,
ZEND_AST_NAMED_ARG,
/* 3 child nodes */
ZEND_AST_METHOD_CALL = 3 << ZEND_AST_NUM_CHILDREN_SHIFT,
ZEND_AST_NULLSAFE_METHOD_CALL,
ZEND_AST_STATIC_CALL,
ZEND_AST_CONDITIONAL,
ZEND_AST_TRY,
ZEND_AST_CATCH,
ZEND_AST_PROP_GROUP,
ZEND_AST_PROP_ELEM,
ZEND_AST_CONST_ELEM,
ZEND_AST_CLASS_CONST_GROUP,
// Pseudo node for initializing enums
ZEND_AST_CONST_ENUM_INIT,
/* 4 child nodes */
ZEND_AST_FOR = 4 << ZEND_AST_NUM_CHILDREN_SHIFT,
ZEND_AST_FOREACH,
ZEND_AST_ENUM_CASE,
/* 5 child nodes */
ZEND_AST_PARAM = 5 << ZEND_AST_NUM_CHILDREN_SHIFT,
};
typedef uint16_t zend_ast_kind;
typedef uint16_t zend_ast_attr;
struct _zend_ast {
zend_ast_kind kind; /* Type of the node (ZEND_AST_* enum constant) */
zend_ast_attr attr; /* Additional attribute, use depending on node type */
uint32_t lineno; /* Line number */
zend_ast *child[1]; /* Array of children (using struct hack) */
};
/* Same as zend_ast, but with children count, which is updated dynamically */
typedef struct _zend_ast_list {
zend_ast_kind kind;
zend_ast_attr attr;
uint32_t lineno;
uint32_t children;
zend_ast *child[1];
} zend_ast_list;
/* Lineno is stored in val.u2.lineno */
typedef struct _zend_ast_zval {
zend_ast_kind kind;
zend_ast_attr attr;
zval val;
} zend_ast_zval;
/* Separate structure for function and class declaration, as they need extra information. */
typedef struct _zend_ast_decl {
zend_ast_kind kind;
zend_ast_attr attr; /* Unused - for structure compatibility */
uint32_t start_lineno;
uint32_t end_lineno;
uint32_t flags;
zend_string *doc_comment;
zend_string *name;
zend_ast *child[5];
} zend_ast_decl;
typedef void (*zend_ast_process_t)(zend_ast *ast);
extern ZEND_API zend_ast_process_t zend_ast_process;
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, zend_ast_attr attr);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name);
#if ZEND_AST_SPEC
# define ZEND_AST_SPEC_CALL(name, ...) \
ZEND_EXPAND_VA(ZEND_AST_SPEC_CALL_(name, __VA_ARGS__, _5, _4, _3, _2, _1, _0)(__VA_ARGS__))
# define ZEND_AST_SPEC_CALL_(name, _, _5, _4, _3, _2, _1, suffix, ...) \
name ## suffix
# define ZEND_AST_SPEC_CALL_EX(name, ...) \
ZEND_EXPAND_VA(ZEND_AST_SPEC_CALL_EX_(name, __VA_ARGS__, _5, _4, _3, _2, _1, _0)(__VA_ARGS__))
# define ZEND_AST_SPEC_CALL_EX_(name, _, _6, _5, _4, _3, _2, _1, suffix, ...) \
name ## suffix
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0(zend_ast_kind kind);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1(zend_ast_kind kind, zend_ast *child);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_5(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4, zend_ast *child5);
static zend_always_inline zend_ast * zend_ast_create_ex_0(zend_ast_kind kind, zend_ast_attr attr) {
zend_ast *ast = zend_ast_create_0(kind);
ast->attr = attr;
return ast;
}
static zend_always_inline zend_ast * zend_ast_create_ex_1(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child) {
zend_ast *ast = zend_ast_create_1(kind, child);
ast->attr = attr;
return ast;
}
static zend_always_inline zend_ast * zend_ast_create_ex_2(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2) {
zend_ast *ast = zend_ast_create_2(kind, child1, child2);
ast->attr = attr;
return ast;
}
static zend_always_inline zend_ast * zend_ast_create_ex_3(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3) {
zend_ast *ast = zend_ast_create_3(kind, child1, child2, child3);
ast->attr = attr;
return ast;
}
static zend_always_inline zend_ast * zend_ast_create_ex_4(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4) {
zend_ast *ast = zend_ast_create_4(kind, child1, child2, child3, child4);
ast->attr = attr;
return ast;
}
static zend_always_inline zend_ast * zend_ast_create_ex_5(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4, zend_ast *child5) {
zend_ast *ast = zend_ast_create_5(kind, child1, child2, child3, child4, child5);
ast->attr = attr;
return ast;
}
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_kind kind);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(zend_ast_kind kind, zend_ast *child);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
# define zend_ast_create(...) \
ZEND_AST_SPEC_CALL(zend_ast_create, __VA_ARGS__)
# define zend_ast_create_ex(...) \
ZEND_AST_SPEC_CALL_EX(zend_ast_create_ex, __VA_ARGS__)
# define zend_ast_create_list(init_children, ...) \
ZEND_AST_SPEC_CALL(zend_ast_create_list, __VA_ARGS__)
#else
ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...);
ZEND_API zend_ast *zend_ast_create_ex(zend_ast_kind kind, zend_ast_attr attr, ...);
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...);
#endif
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *list, zend_ast *op);
ZEND_API zend_ast *zend_ast_create_decl(
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4
);
typedef struct {
bool had_side_effects;
} zend_ast_evaluate_ctx;
ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope);
ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *ast, zend_class_entry *scope, bool *short_circuited_ptr, zend_ast_evaluate_ctx *ctx);
ZEND_API zend_string *zend_ast_export(const char *prefix, zend_ast *ast, const char *suffix);
ZEND_API zend_ast_ref * ZEND_FASTCALL zend_ast_copy(zend_ast *ast);
ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast);
ZEND_API void ZEND_FASTCALL zend_ast_ref_destroy(zend_ast_ref *ast);
typedef void (*zend_ast_apply_func)(zend_ast **ast_ptr, void *context);
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *context);
static zend_always_inline size_t zend_ast_size(uint32_t children) {
return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children);
}
static zend_always_inline bool zend_ast_is_special(zend_ast *ast) {
return (ast->kind >> ZEND_AST_SPECIAL_SHIFT) & 1;
}
static zend_always_inline bool zend_ast_is_list(zend_ast *ast) {
return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1;
}
static zend_always_inline zend_ast_list *zend_ast_get_list(zend_ast *ast) {
ZEND_ASSERT(zend_ast_is_list(ast));
return (zend_ast_list *) ast;
}
static zend_always_inline zval *zend_ast_get_zval(zend_ast *ast) {
ZEND_ASSERT(ast->kind == ZEND_AST_ZVAL);
return &((zend_ast_zval *) ast)->val;
}
static zend_always_inline zend_string *zend_ast_get_str(zend_ast *ast) {
zval *zv = zend_ast_get_zval(ast);
ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING);
return Z_STR_P(zv);
}
static zend_always_inline zend_string *zend_ast_get_constant_name(zend_ast *ast) {
ZEND_ASSERT(ast->kind == ZEND_AST_CONSTANT);
ZEND_ASSERT(Z_TYPE(((zend_ast_zval *) ast)->val) == IS_STRING);
return Z_STR(((zend_ast_zval *) ast)->val);
}
static zend_always_inline uint32_t zend_ast_get_num_children(zend_ast *ast) {
ZEND_ASSERT(!zend_ast_is_list(ast));
return ast->kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
}
static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) {
if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast);
return Z_LINENO_P(zv);
} else if (ast->kind == ZEND_AST_CONSTANT) {
zval *zv = &((zend_ast_zval *) ast)->val;
return Z_LINENO_P(zv);
} else {
return ast->lineno;
}
}
static zend_always_inline zend_ast *zend_ast_create_binary_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
return zend_ast_create_ex(ZEND_AST_BINARY_OP, opcode, op0, op1);
}
zend_ast *zend_ast_create_concat_op(zend_ast *op0, zend_ast *op1);
static zend_always_inline zend_ast *zend_ast_create_assign_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
return zend_ast_create_ex(ZEND_AST_ASSIGN_OP, opcode, op0, op1);
}
static zend_always_inline zend_ast *zend_ast_create_cast(uint32_t type, zend_ast *op0) {
return zend_ast_create_ex(ZEND_AST_CAST, type, op0);
}
static zend_always_inline zend_ast *zend_ast_list_rtrim(zend_ast *ast) {
zend_ast_list *list = zend_ast_get_list(ast);
if (list->children && list->child[list->children - 1] == NULL) {
list->children--;
}
return ast;
}
zend_ast * ZEND_FASTCALL zend_ast_with_attributes(zend_ast *ast, zend_ast *attr);
#endif

View File

@ -0,0 +1,179 @@
/*
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Levi Morrison <morrison.levi@gmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ATOMIC_H
#define ZEND_ATOMIC_H
#include "zend_portability.h"
#include <stdbool.h>
#define ZEND_GCC_PREREQ(x, y) \
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || (__GNUC__ > (x)))
/* Builtins are used to avoid library linkage */
#if __has_feature(c_atomic) && defined(__clang__)
#define HAVE_C11_ATOMICS 1
#elif ZEND_GCC_PREREQ(4, 7)
#define HAVE_GNUC_ATOMICS 1
#elif defined(__GNUC__)
#define HAVE_SYNC_ATOMICS 1
#elif !defined(ZEND_WIN32)
#define HAVE_NO_ATOMICS 1
#endif
#undef ZEND_GCC_PREREQ
/* Treat zend_atomic_* types as opaque. They have definitions only for size
* and alignment purposes.
*/
#if defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)
typedef struct zend_atomic_bool_s {
volatile char value;
} zend_atomic_bool;
#elif defined(HAVE_C11_ATOMICS)
typedef struct zend_atomic_bool_s {
_Atomic(bool) value;
} zend_atomic_bool;
#else
typedef struct zend_atomic_bool_s {
volatile bool value;
} zend_atomic_bool;
#endif
BEGIN_EXTERN_C()
#ifdef ZEND_WIN32
#ifndef InterlockedExchange8
#define InterlockedExchange8 _InterlockedExchange8
#endif
#ifndef InterlockedOr8
#define InterlockedOr8 _InterlockedOr8
#endif
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) ((obj)->value = (desired))
static zend_always_inline bool zend_atomic_bool_exchange_ex(zend_atomic_bool *obj, bool desired) {
return InterlockedExchange8(&obj->value, desired);
}
/* On this platform it is non-const due to Iterlocked API*/
static zend_always_inline bool zend_atomic_bool_load_ex(zend_atomic_bool *obj) {
/* Or'ing with false won't change the value. */
return InterlockedOr8(&obj->value, false);
}
static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, bool desired) {
(void)InterlockedExchange8(&obj->value, desired);
}
#elif defined(HAVE_C11_ATOMICS)
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) __c11_atomic_init(&(obj)->value, (desired))
static zend_always_inline bool zend_atomic_bool_exchange_ex(zend_atomic_bool *obj, bool desired) {
return __c11_atomic_exchange(&obj->value, desired, __ATOMIC_SEQ_CST);
}
static zend_always_inline bool zend_atomic_bool_load_ex(const zend_atomic_bool *obj) {
return __c11_atomic_load(&obj->value, __ATOMIC_SEQ_CST);
}
static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, bool desired) {
__c11_atomic_store(&obj->value, desired, __ATOMIC_SEQ_CST);
}
#elif defined(HAVE_GNUC_ATOMICS)
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) ((obj)->value = (desired))
static zend_always_inline bool zend_atomic_bool_exchange_ex(zend_atomic_bool *obj, bool desired) {
bool prev = false;
__atomic_exchange(&obj->value, &desired, &prev, __ATOMIC_SEQ_CST);
return prev;
}
static zend_always_inline bool zend_atomic_bool_load_ex(const zend_atomic_bool *obj) {
bool prev = false;
__atomic_load(&obj->value, &prev, __ATOMIC_SEQ_CST);
return prev;
}
static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, bool desired) {
__atomic_store(&obj->value, &desired, __ATOMIC_SEQ_CST);
}
#elif defined(HAVE_SYNC_ATOMICS)
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) ((obj)->value = (desired))
static zend_always_inline bool zend_atomic_bool_exchange_ex(zend_atomic_bool *obj, bool desired) {
bool prev = __sync_lock_test_and_set(&obj->value, desired);
/* __sync_lock_test_and_set only does an acquire barrier, so sync
* immediately after.
*/
__sync_synchronize();
return prev;
}
static zend_always_inline bool zend_atomic_bool_load_ex(zend_atomic_bool *obj) {
/* Or'ing false won't change the value */
return __sync_fetch_and_or(&obj->value, false);
}
static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, bool desired) {
__sync_synchronize();
obj->value = desired;
__sync_synchronize();
}
#elif defined(HAVE_NO_ATOMICS)
#warning No atomics support detected. Please open an issue with platform details.
#define ZEND_ATOMIC_BOOL_INIT(obj, desired) ((obj)->value = (desired))
static zend_always_inline void zend_atomic_bool_store_ex(zend_atomic_bool *obj, bool desired) {
obj->value = desired;
}
static zend_always_inline bool zend_atomic_bool_load_ex(const zend_atomic_bool *obj) {
return obj->value;
}
static zend_always_inline bool zend_atomic_bool_exchange_ex(zend_atomic_bool *obj, bool desired) {
bool prev = obj->value;
obj->value = desired;
return prev;
}
#endif
ZEND_API void zend_atomic_bool_init(zend_atomic_bool *obj, bool desired);
ZEND_API bool zend_atomic_bool_exchange(zend_atomic_bool *obj, bool desired);
ZEND_API void zend_atomic_bool_store(zend_atomic_bool *obj, bool desired);
#if defined(ZEND_WIN32) || defined(HAVE_SYNC_ATOMICS)
/* On these platforms it is non-const due to underlying APIs. */
ZEND_API bool zend_atomic_bool_load(zend_atomic_bool *obj);
#else
ZEND_API bool zend_atomic_bool_load(const zend_atomic_bool *obj);
#endif
END_EXTERN_C()
#endif

View File

@ -0,0 +1,124 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Benjamin Eberlei <kontakt@beberlei.de> |
| Martin Schröder <m.schroeder2007@gmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ATTRIBUTES_H
#define ZEND_ATTRIBUTES_H
#define ZEND_ATTRIBUTE_TARGET_CLASS (1<<0)
#define ZEND_ATTRIBUTE_TARGET_FUNCTION (1<<1)
#define ZEND_ATTRIBUTE_TARGET_METHOD (1<<2)
#define ZEND_ATTRIBUTE_TARGET_PROPERTY (1<<3)
#define ZEND_ATTRIBUTE_TARGET_CLASS_CONST (1<<4)
#define ZEND_ATTRIBUTE_TARGET_PARAMETER (1<<5)
#define ZEND_ATTRIBUTE_TARGET_ALL ((1<<6) - 1)
#define ZEND_ATTRIBUTE_IS_REPEATABLE (1<<6)
#define ZEND_ATTRIBUTE_FLAGS ((1<<7) - 1)
/* Flags for zend_attribute.flags */
#define ZEND_ATTRIBUTE_PERSISTENT (1<<0)
#define ZEND_ATTRIBUTE_STRICT_TYPES (1<<1)
#define ZEND_ATTRIBUTE_SIZE(argc) \
(sizeof(zend_attribute) + sizeof(zend_attribute_arg) * (argc) - sizeof(zend_attribute_arg))
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_attribute;
extern ZEND_API zend_class_entry *zend_ce_allow_dynamic_properties;
extern ZEND_API zend_class_entry *zend_ce_sensitive_parameter;
extern ZEND_API zend_class_entry *zend_ce_sensitive_parameter_value;
extern ZEND_API zend_class_entry *zend_ce_override;
typedef struct {
zend_string *name;
zval value;
} zend_attribute_arg;
typedef struct _zend_attribute {
zend_string *name;
zend_string *lcname;
uint32_t flags;
uint32_t lineno;
/* Parameter offsets start at 1, everything else uses 0. */
uint32_t offset;
uint32_t argc;
zend_attribute_arg args[1];
} zend_attribute;
typedef struct _zend_internal_attribute {
zend_class_entry *ce;
uint32_t flags;
void (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope);
} zend_internal_attribute;
ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname);
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope);
ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets);
ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr);
ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce);
ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags);
ZEND_API zend_internal_attribute *zend_internal_attribute_get(zend_string *lcname);
ZEND_API zend_attribute *zend_add_attribute(
HashTable **attributes, zend_string *name, uint32_t argc,
uint32_t flags, uint32_t offset, uint32_t lineno);
END_EXTERN_C()
static zend_always_inline zend_attribute *zend_add_class_attribute(zend_class_entry *ce, zend_string *name, uint32_t argc)
{
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
}
static zend_always_inline zend_attribute *zend_add_function_attribute(zend_function *func, zend_string *name, uint32_t argc)
{
uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
}
static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_function *func, uint32_t offset, zend_string *name, uint32_t argc)
{
uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
}
static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
{
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0);
}
static zend_always_inline zend_attribute *zend_add_class_constant_attribute(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
{
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
}
void zend_register_attribute_ce(void);
void zend_attributes_shutdown(void);
#endif

View File

@ -0,0 +1,234 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 32f0458c20f04099e353a8300ffb19e40bc38f69 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Attribute___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "Attribute::TARGET_ALL")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReturnTypeWillChange___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_AllowDynamicProperties___construct arginfo_class_ReturnTypeWillChange___construct
#define arginfo_class_SensitiveParameter___construct arginfo_class_ReturnTypeWillChange___construct
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SensitiveParameterValue___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SensitiveParameterValue_getValue, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SensitiveParameterValue___debugInfo, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Override___construct arginfo_class_ReturnTypeWillChange___construct
ZEND_METHOD(Attribute, __construct);
ZEND_METHOD(ReturnTypeWillChange, __construct);
ZEND_METHOD(AllowDynamicProperties, __construct);
ZEND_METHOD(SensitiveParameter, __construct);
ZEND_METHOD(SensitiveParameterValue, __construct);
ZEND_METHOD(SensitiveParameterValue, getValue);
ZEND_METHOD(SensitiveParameterValue, __debugInfo);
ZEND_METHOD(Override, __construct);
static const zend_function_entry class_Attribute_methods[] = {
ZEND_ME(Attribute, __construct, arginfo_class_Attribute___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ReturnTypeWillChange_methods[] = {
ZEND_ME(ReturnTypeWillChange, __construct, arginfo_class_ReturnTypeWillChange___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_AllowDynamicProperties_methods[] = {
ZEND_ME(AllowDynamicProperties, __construct, arginfo_class_AllowDynamicProperties___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_SensitiveParameter_methods[] = {
ZEND_ME(SensitiveParameter, __construct, arginfo_class_SensitiveParameter___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_SensitiveParameterValue_methods[] = {
ZEND_ME(SensitiveParameterValue, __construct, arginfo_class_SensitiveParameterValue___construct, ZEND_ACC_PUBLIC)
ZEND_ME(SensitiveParameterValue, getValue, arginfo_class_SensitiveParameterValue_getValue, ZEND_ACC_PUBLIC)
ZEND_ME(SensitiveParameterValue, __debugInfo, arginfo_class_SensitiveParameterValue___debugInfo, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_Override_methods[] = {
ZEND_ME(Override, __construct, arginfo_class_Override___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static zend_class_entry *register_class_Attribute(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Attribute", class_Attribute_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
zval const_TARGET_CLASS_value;
ZVAL_LONG(&const_TARGET_CLASS_value, ZEND_ATTRIBUTE_TARGET_CLASS);
zend_string *const_TARGET_CLASS_name = zend_string_init_interned("TARGET_CLASS", sizeof("TARGET_CLASS") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_CLASS_name, &const_TARGET_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_CLASS_name);
zval const_TARGET_FUNCTION_value;
ZVAL_LONG(&const_TARGET_FUNCTION_value, ZEND_ATTRIBUTE_TARGET_FUNCTION);
zend_string *const_TARGET_FUNCTION_name = zend_string_init_interned("TARGET_FUNCTION", sizeof("TARGET_FUNCTION") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_FUNCTION_name, &const_TARGET_FUNCTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_FUNCTION_name);
zval const_TARGET_METHOD_value;
ZVAL_LONG(&const_TARGET_METHOD_value, ZEND_ATTRIBUTE_TARGET_METHOD);
zend_string *const_TARGET_METHOD_name = zend_string_init_interned("TARGET_METHOD", sizeof("TARGET_METHOD") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_METHOD_name, &const_TARGET_METHOD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_METHOD_name);
zval const_TARGET_PROPERTY_value;
ZVAL_LONG(&const_TARGET_PROPERTY_value, ZEND_ATTRIBUTE_TARGET_PROPERTY);
zend_string *const_TARGET_PROPERTY_name = zend_string_init_interned("TARGET_PROPERTY", sizeof("TARGET_PROPERTY") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_PROPERTY_name, &const_TARGET_PROPERTY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_PROPERTY_name);
zval const_TARGET_CLASS_CONSTANT_value;
ZVAL_LONG(&const_TARGET_CLASS_CONSTANT_value, ZEND_ATTRIBUTE_TARGET_CLASS_CONST);
zend_string *const_TARGET_CLASS_CONSTANT_name = zend_string_init_interned("TARGET_CLASS_CONSTANT", sizeof("TARGET_CLASS_CONSTANT") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_CLASS_CONSTANT_name, &const_TARGET_CLASS_CONSTANT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_CLASS_CONSTANT_name);
zval const_TARGET_PARAMETER_value;
ZVAL_LONG(&const_TARGET_PARAMETER_value, ZEND_ATTRIBUTE_TARGET_PARAMETER);
zend_string *const_TARGET_PARAMETER_name = zend_string_init_interned("TARGET_PARAMETER", sizeof("TARGET_PARAMETER") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_PARAMETER_name, &const_TARGET_PARAMETER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_PARAMETER_name);
zval const_TARGET_ALL_value;
ZVAL_LONG(&const_TARGET_ALL_value, ZEND_ATTRIBUTE_TARGET_ALL);
zend_string *const_TARGET_ALL_name = zend_string_init_interned("TARGET_ALL", sizeof("TARGET_ALL") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_TARGET_ALL_name, &const_TARGET_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_TARGET_ALL_name);
zval const_IS_REPEATABLE_value;
ZVAL_LONG(&const_IS_REPEATABLE_value, ZEND_ATTRIBUTE_IS_REPEATABLE);
zend_string *const_IS_REPEATABLE_name = zend_string_init_interned("IS_REPEATABLE", sizeof("IS_REPEATABLE") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_IS_REPEATABLE_name, &const_IS_REPEATABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_IS_REPEATABLE_name);
zval property_flags_default_value;
ZVAL_UNDEF(&property_flags_default_value);
zend_string *property_flags_name = zend_string_init("flags", sizeof("flags") - 1, 1);
zend_declare_typed_property(class_entry, property_flags_name, &property_flags_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(property_flags_name);
zend_string *attribute_name_Attribute_class_Attribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_Attribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_Attribute_0, 1);
zend_string_release(attribute_name_Attribute_class_Attribute_0);
zval attribute_Attribute_class_Attribute_0_arg0;
ZVAL_LONG(&attribute_Attribute_class_Attribute_0_arg0, ZEND_ATTRIBUTE_TARGET_CLASS);
ZVAL_COPY_VALUE(&attribute_Attribute_class_Attribute_0->args[0].value, &attribute_Attribute_class_Attribute_0_arg0);
return class_entry;
}
static zend_class_entry *register_class_ReturnTypeWillChange(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ReturnTypeWillChange", class_ReturnTypeWillChange_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
zend_string *attribute_name_Attribute_class_ReturnTypeWillChange_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_ReturnTypeWillChange_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ReturnTypeWillChange_0, 1);
zend_string_release(attribute_name_Attribute_class_ReturnTypeWillChange_0);
zval attribute_Attribute_class_ReturnTypeWillChange_0_arg0;
ZVAL_LONG(&attribute_Attribute_class_ReturnTypeWillChange_0_arg0, ZEND_ATTRIBUTE_TARGET_METHOD);
ZVAL_COPY_VALUE(&attribute_Attribute_class_ReturnTypeWillChange_0->args[0].value, &attribute_Attribute_class_ReturnTypeWillChange_0_arg0);
return class_entry;
}
static zend_class_entry *register_class_AllowDynamicProperties(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "AllowDynamicProperties", class_AllowDynamicProperties_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
zend_string *attribute_name_Attribute_class_AllowDynamicProperties_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_AllowDynamicProperties_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_AllowDynamicProperties_0, 1);
zend_string_release(attribute_name_Attribute_class_AllowDynamicProperties_0);
zval attribute_Attribute_class_AllowDynamicProperties_0_arg0;
ZVAL_LONG(&attribute_Attribute_class_AllowDynamicProperties_0_arg0, ZEND_ATTRIBUTE_TARGET_CLASS);
ZVAL_COPY_VALUE(&attribute_Attribute_class_AllowDynamicProperties_0->args[0].value, &attribute_Attribute_class_AllowDynamicProperties_0_arg0);
return class_entry;
}
static zend_class_entry *register_class_SensitiveParameter(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "SensitiveParameter", class_SensitiveParameter_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
zend_string *attribute_name_Attribute_class_SensitiveParameter_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_SensitiveParameter_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_SensitiveParameter_0, 1);
zend_string_release(attribute_name_Attribute_class_SensitiveParameter_0);
zval attribute_Attribute_class_SensitiveParameter_0_arg0;
ZVAL_LONG(&attribute_Attribute_class_SensitiveParameter_0_arg0, ZEND_ATTRIBUTE_TARGET_PARAMETER);
ZVAL_COPY_VALUE(&attribute_Attribute_class_SensitiveParameter_0->args[0].value, &attribute_Attribute_class_SensitiveParameter_0_arg0);
return class_entry;
}
static zend_class_entry *register_class_SensitiveParameterValue(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "SensitiveParameterValue", class_SensitiveParameterValue_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
zval property_value_default_value;
ZVAL_UNDEF(&property_value_default_value);
zend_string *property_value_name = zend_string_init("value", sizeof("value") - 1, 1);
zend_declare_typed_property(class_entry, property_value_name, &property_value_default_value, ZEND_ACC_PRIVATE|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY));
zend_string_release(property_value_name);
return class_entry;
}
static zend_class_entry *register_class_Override(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Override", class_Override_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
zend_string *attribute_name_Attribute_class_Override_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_Override_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_Override_0, 1);
zend_string_release(attribute_name_Attribute_class_Override_0);
zval attribute_Attribute_class_Override_0_arg0;
ZVAL_LONG(&attribute_Attribute_class_Override_0_arg0, ZEND_ATTRIBUTE_TARGET_METHOD);
ZVAL_COPY_VALUE(&attribute_Attribute_class_Override_0->args[0].value, &attribute_Attribute_class_Override_0_arg0);
return class_entry;
}

View File

@ -0,0 +1,301 @@
/*
+----------------------------------------------------------------------+
| Zend OPcache JIT |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef _ZEND_BITSET_H_
#define _ZEND_BITSET_H_
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "zend_portability.h"
#include "zend_long.h"
typedef zend_ulong *zend_bitset;
#define ZEND_BITSET_ELM_SIZE sizeof(zend_ulong)
#if SIZEOF_ZEND_LONG == 4
# define ZEND_BITSET_ELM_NUM(n) ((n) >> 5)
# define ZEND_BITSET_BIT_NUM(n) ((zend_ulong)(n) & Z_UL(0x1f))
#elif SIZEOF_ZEND_LONG == 8
# define ZEND_BITSET_ELM_NUM(n) ((n) >> 6)
# define ZEND_BITSET_BIT_NUM(n) ((zend_ulong)(n) & Z_UL(0x3f))
#else
# define ZEND_BITSET_ELM_NUM(n) ((n) / (sizeof(zend_long) * 8))
# define ZEND_BITSET_BIT_NUM(n) ((n) % (sizeof(zend_long) * 8))
#endif
#define ZEND_BITSET_ALLOCA(n, use_heap) \
(zend_bitset)do_alloca((n) * ZEND_BITSET_ELM_SIZE, use_heap)
/* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */
static zend_always_inline int zend_ulong_ntz(zend_ulong num)
{
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) \
&& SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL)
return __builtin_ctzl(num);
#elif (defined(__GNUC__) || __has_builtin(__builtin_ctzll)) && defined(PHP_HAVE_BUILTIN_CTZLL)
return __builtin_ctzll(num);
#elif defined(_WIN32)
unsigned long index;
#if defined(_WIN64)
if (!BitScanForward64(&index, num)) {
#else
if (!BitScanForward(&index, num)) {
#endif
/* undefined behavior */
return SIZEOF_ZEND_LONG * 8;
}
return (int) index;
#else
int n;
if (num == Z_UL(0)) return SIZEOF_ZEND_LONG * 8;
n = 1;
#if SIZEOF_ZEND_LONG == 8
if ((num & 0xffffffff) == 0) {n += 32; num = num >> Z_UL(32);}
#endif
if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;}
if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;}
if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;}
if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;}
return n - (num & 1);
#endif
}
/* Number of leading zero bits (Undefined for zero) */
static zend_always_inline int zend_ulong_nlz(zend_ulong num)
{
#if (defined(__GNUC__) || __has_builtin(__builtin_clzl)) \
&& SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CLZL)
return __builtin_clzl(num);
#elif (defined(__GNUC__) || __has_builtin(__builtin_clzll)) && defined(PHP_HAVE_BUILTIN_CLZLL)
return __builtin_clzll(num);
#elif defined(_WIN32)
unsigned long index;
#if defined(_WIN64)
if (!BitScanReverse64(&index, num)) {
#else
if (!BitScanReverse(&index, num)) {
#endif
/* undefined behavior */
return SIZEOF_ZEND_LONG * 8;
}
return (int) (SIZEOF_ZEND_LONG * 8 - 1)- index;
#else
zend_ulong x;
int n;
#if SIZEOF_ZEND_LONG == 8
n = 64;
x = num >> 32; if (x != 0) {n -= 32; num = x;}
#else
n = 32;
#endif
x = num >> 16; if (x != 0) {n -= 16; num = x;}
x = num >> 8; if (x != 0) {n -= 8; num = x;}
x = num >> 4; if (x != 0) {n -= 4; num = x;}
x = num >> 2; if (x != 0) {n -= 2; num = x;}
x = num >> 1; if (x != 0) return n - 2;
return n - num;
#endif
}
/* Returns the number of zend_ulong words needed to store a bitset that is N
bits long. */
static inline uint32_t zend_bitset_len(uint32_t n)
{
return (n + ((sizeof(zend_long) * 8) - 1)) / (sizeof(zend_long) * 8);
}
static inline bool zend_bitset_in(zend_bitset set, uint32_t n)
{
return ZEND_BIT_TEST(set, n);
}
static inline void zend_bitset_incl(zend_bitset set, uint32_t n)
{
set[ZEND_BITSET_ELM_NUM(n)] |= Z_UL(1) << ZEND_BITSET_BIT_NUM(n);
}
static inline void zend_bitset_excl(zend_bitset set, uint32_t n)
{
set[ZEND_BITSET_ELM_NUM(n)] &= ~(Z_UL(1) << ZEND_BITSET_BIT_NUM(n));
}
static inline void zend_bitset_clear(zend_bitset set, uint32_t len)
{
memset(set, 0, len * ZEND_BITSET_ELM_SIZE);
}
static inline bool zend_bitset_empty(zend_bitset set, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
if (set[i]) {
return 0;
}
}
return 1;
}
static inline void zend_bitset_fill(zend_bitset set, uint32_t len)
{
memset(set, 0xff, len * ZEND_BITSET_ELM_SIZE);
}
static inline bool zend_bitset_equal(zend_bitset set1, zend_bitset set2, uint32_t len)
{
return memcmp(set1, set2, len * ZEND_BITSET_ELM_SIZE) == 0;
}
static inline void zend_bitset_copy(zend_bitset set1, zend_bitset set2, uint32_t len)
{
memcpy(set1, set2, len * ZEND_BITSET_ELM_SIZE);
}
static inline void zend_bitset_intersection(zend_bitset set1, zend_bitset set2, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
set1[i] &= set2[i];
}
}
static inline void zend_bitset_union(zend_bitset set1, zend_bitset set2, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
set1[i] |= set2[i];
}
}
static inline void zend_bitset_difference(zend_bitset set1, zend_bitset set2, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
set1[i] = set1[i] & ~set2[i];
}
}
static inline void zend_bitset_union_with_intersection(zend_bitset set1, zend_bitset set2, zend_bitset set3, zend_bitset set4, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
set1[i] = set2[i] | (set3[i] & set4[i]);
}
}
static inline void zend_bitset_union_with_difference(zend_bitset set1, zend_bitset set2, zend_bitset set3, zend_bitset set4, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
set1[i] = set2[i] | (set3[i] & ~set4[i]);
}
}
static inline bool zend_bitset_subset(zend_bitset set1, zend_bitset set2, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
if (set1[i] & ~set2[i]) {
return 0;
}
}
return 1;
}
static inline int zend_bitset_first(zend_bitset set, uint32_t len)
{
uint32_t i;
for (i = 0; i < len; i++) {
if (set[i]) {
return ZEND_BITSET_ELM_SIZE * 8 * i + zend_ulong_ntz(set[i]);
}
}
return -1; /* empty set */
}
static inline int zend_bitset_last(zend_bitset set, uint32_t len)
{
uint32_t i = len;
while (i > 0) {
i--;
if (set[i]) {
int j = ZEND_BITSET_ELM_SIZE * 8 * i - 1;
zend_ulong x = set[i];
while (x != Z_UL(0)) {
x = x >> Z_UL(1);
j++;
}
return j;
}
}
return -1; /* empty set */
}
#define ZEND_BITSET_FOREACH(set, len, bit) do { \
zend_bitset _set = (set); \
uint32_t _i, _len = (len); \
for (_i = 0; _i < _len; _i++) { \
zend_ulong _x = _set[_i]; \
if (_x) { \
(bit) = ZEND_BITSET_ELM_SIZE * 8 * _i; \
for (; _x != 0; _x >>= Z_UL(1), (bit)++) { \
if (!(_x & Z_UL(1))) continue;
#define ZEND_BITSET_REVERSE_FOREACH(set, len, bit) do { \
zend_bitset _set = (set); \
uint32_t _i = (len); \
zend_ulong _test = Z_UL(1) << (ZEND_BITSET_ELM_SIZE * 8 - 1); \
while (_i-- > 0) { \
zend_ulong _x = _set[_i]; \
if (_x) { \
(bit) = ZEND_BITSET_ELM_SIZE * 8 * (_i + 1) - 1; \
for (; _x != 0; _x <<= Z_UL(1), (bit)--) { \
if (!(_x & _test)) continue; \
#define ZEND_BITSET_FOREACH_END() \
} \
} \
} \
} while (0)
static inline int zend_bitset_pop_first(zend_bitset set, uint32_t len) {
int i = zend_bitset_first(set, len);
if (i >= 0) {
zend_bitset_excl(set, i);
}
return i;
}
#endif /* _ZEND_BITSET_H_ */

View File

@ -0,0 +1,46 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Stanislav Malyshev <stas@zend.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_BUILD_H
#define ZEND_BUILD_H
#define ZEND_TOSTR_(x) #x
#define ZEND_TOSTR(x) ZEND_TOSTR_(x)
#ifdef ZTS
#define ZEND_BUILD_TS ",TS"
#else
#define ZEND_BUILD_TS ",NTS"
#endif
#if ZEND_DEBUG
#define ZEND_BUILD_DEBUG ",debug"
#else
#define ZEND_BUILD_DEBUG
#endif
#if defined(ZEND_WIN32) && defined(PHP_COMPILER_ID)
#define ZEND_BUILD_SYSTEM "," PHP_COMPILER_ID
#else
#define ZEND_BUILD_SYSTEM
#endif
/* for private applications */
#define ZEND_BUILD_EXTRA
#endif

View File

@ -0,0 +1,29 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_BUILTIN_FUNCTIONS_H
#define ZEND_BUILTIN_FUNCTIONS_H
zend_result zend_startup_builtin_functions(void);
BEGIN_EXTERN_C()
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit);
END_EXTERN_C()
#endif /* ZEND_BUILTIN_FUNCTIONS_H */

View File

@ -0,0 +1,363 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 12899073f3791c5da31aa555c0e612ee1faadf55 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_func_num_args, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_func_get_arg, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, position, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_func_get_args, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strlen, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strcmp, 0, 2, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, string1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string2, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strncmp, 0, 3, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, string1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_strcasecmp arginfo_strcmp
#define arginfo_strncasecmp arginfo_strncmp
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_reporting, 0, 0, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, error_level, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_define, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, case_insensitive, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_defined, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_class, 0, 0, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
#define arginfo_get_called_class arginfo_zend_version
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_parent_class, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_MASK(0, object_or_class, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_is_subclass_of, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, object_or_class, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allow_string, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_is_a, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, object_or_class, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, allow_string, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_class_vars, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_object_vars, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
#define arginfo_get_mangled_object_vars arginfo_get_object_vars
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_class_methods, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_MASK(0, object_or_class, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_method_exists, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, object_or_class)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_property_exists, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, object_or_class)
ZEND_ARG_TYPE_INFO(0, property, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_exists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, autoload, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_interface_exists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, interface, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, autoload, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_trait_exists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, trait, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, autoload, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enum_exists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, enum, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, autoload, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_function_exists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_alias, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, class, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, alias, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, autoload, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
#define arginfo_get_included_files arginfo_func_get_args
#define arginfo_get_required_files arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_trigger_error, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, error_level, IS_LONG, 0, "E_USER_NOTICE")
ZEND_END_ARG_INFO()
#define arginfo_user_error arginfo_trigger_error
ZEND_BEGIN_ARG_INFO_EX(arginfo_set_error_handler, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 1)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, error_levels, IS_LONG, 0, "E_ALL")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_restore_error_handler, 0, 0, IS_TRUE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_set_exception_handler, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 1)
ZEND_END_ARG_INFO()
#define arginfo_restore_exception_handler arginfo_restore_error_handler
#define arginfo_get_declared_classes arginfo_func_get_args
#define arginfo_get_declared_traits arginfo_func_get_args
#define arginfo_get_declared_interfaces arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_functions, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, exclude_disabled, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
#define arginfo_get_defined_vars arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_type, 0, 1, IS_STRING, 0)
ZEND_ARG_INFO(0, resource)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_id, 0, 1, IS_LONG, 0)
ZEND_ARG_INFO(0, resource)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resources, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_loaded_extensions, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, zend_extensions, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_constants, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, categorize, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_debug_backtrace, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "DEBUG_BACKTRACE_PROVIDE_OBJECT")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, limit, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_debug_print_backtrace, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, limit, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_extension_loaded, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_extension_funcs, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 0)
ZEND_END_ARG_INFO()
#if ZEND_DEBUG && defined(ZTS)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_thread_id, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
#endif
#define arginfo_gc_mem_caches arginfo_func_num_args
#define arginfo_gc_collect_cycles arginfo_func_num_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gc_enabled, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gc_enable, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
#define arginfo_gc_disable arginfo_gc_enable
#define arginfo_gc_status arginfo_func_get_args
ZEND_FUNCTION(zend_version);
ZEND_FUNCTION(func_num_args);
ZEND_FUNCTION(func_get_arg);
ZEND_FUNCTION(func_get_args);
ZEND_FUNCTION(strlen);
ZEND_FUNCTION(strcmp);
ZEND_FUNCTION(strncmp);
ZEND_FUNCTION(strcasecmp);
ZEND_FUNCTION(strncasecmp);
ZEND_FUNCTION(error_reporting);
ZEND_FUNCTION(define);
ZEND_FUNCTION(defined);
ZEND_FUNCTION(get_class);
ZEND_FUNCTION(get_called_class);
ZEND_FUNCTION(get_parent_class);
ZEND_FUNCTION(is_subclass_of);
ZEND_FUNCTION(is_a);
ZEND_FUNCTION(get_class_vars);
ZEND_FUNCTION(get_object_vars);
ZEND_FUNCTION(get_mangled_object_vars);
ZEND_FUNCTION(get_class_methods);
ZEND_FUNCTION(method_exists);
ZEND_FUNCTION(property_exists);
ZEND_FUNCTION(class_exists);
ZEND_FUNCTION(interface_exists);
ZEND_FUNCTION(trait_exists);
ZEND_FUNCTION(enum_exists);
ZEND_FUNCTION(function_exists);
ZEND_FUNCTION(class_alias);
ZEND_FUNCTION(get_included_files);
ZEND_FUNCTION(trigger_error);
ZEND_FUNCTION(set_error_handler);
ZEND_FUNCTION(restore_error_handler);
ZEND_FUNCTION(set_exception_handler);
ZEND_FUNCTION(restore_exception_handler);
ZEND_FUNCTION(get_declared_classes);
ZEND_FUNCTION(get_declared_traits);
ZEND_FUNCTION(get_declared_interfaces);
ZEND_FUNCTION(get_defined_functions);
ZEND_FUNCTION(get_defined_vars);
ZEND_FUNCTION(get_resource_type);
ZEND_FUNCTION(get_resource_id);
ZEND_FUNCTION(get_resources);
ZEND_FUNCTION(get_loaded_extensions);
ZEND_FUNCTION(get_defined_constants);
ZEND_FUNCTION(debug_backtrace);
ZEND_FUNCTION(debug_print_backtrace);
ZEND_FUNCTION(extension_loaded);
ZEND_FUNCTION(get_extension_funcs);
#if ZEND_DEBUG && defined(ZTS)
ZEND_FUNCTION(zend_thread_id);
#endif
ZEND_FUNCTION(gc_mem_caches);
ZEND_FUNCTION(gc_collect_cycles);
ZEND_FUNCTION(gc_enabled);
ZEND_FUNCTION(gc_enable);
ZEND_FUNCTION(gc_disable);
ZEND_FUNCTION(gc_status);
static const zend_function_entry ext_functions[] = {
ZEND_FE(zend_version, arginfo_zend_version)
ZEND_FE(func_num_args, arginfo_func_num_args)
ZEND_FE(func_get_arg, arginfo_func_get_arg)
ZEND_FE(func_get_args, arginfo_func_get_args)
ZEND_FE(strlen, arginfo_strlen)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strcmp, arginfo_strcmp)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strncmp, arginfo_strncmp)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strcasecmp, arginfo_strcasecmp)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strncasecmp, arginfo_strncasecmp)
ZEND_FE(error_reporting, arginfo_error_reporting)
ZEND_FE(define, arginfo_define)
ZEND_FE(defined, arginfo_defined)
ZEND_FE(get_class, arginfo_get_class)
ZEND_FE(get_called_class, arginfo_get_called_class)
ZEND_FE(get_parent_class, arginfo_get_parent_class)
ZEND_FE(is_subclass_of, arginfo_is_subclass_of)
ZEND_FE(is_a, arginfo_is_a)
ZEND_FE(get_class_vars, arginfo_get_class_vars)
ZEND_FE(get_object_vars, arginfo_get_object_vars)
ZEND_FE(get_mangled_object_vars, arginfo_get_mangled_object_vars)
ZEND_FE(get_class_methods, arginfo_get_class_methods)
ZEND_FE(method_exists, arginfo_method_exists)
ZEND_FE(property_exists, arginfo_property_exists)
ZEND_FE(class_exists, arginfo_class_exists)
ZEND_FE(interface_exists, arginfo_interface_exists)
ZEND_FE(trait_exists, arginfo_trait_exists)
ZEND_FE(enum_exists, arginfo_enum_exists)
ZEND_FE(function_exists, arginfo_function_exists)
ZEND_FE(class_alias, arginfo_class_alias)
ZEND_FE(get_included_files, arginfo_get_included_files)
ZEND_FALIAS(get_required_files, get_included_files, arginfo_get_required_files)
ZEND_FE(trigger_error, arginfo_trigger_error)
ZEND_FALIAS(user_error, trigger_error, arginfo_user_error)
ZEND_FE(set_error_handler, arginfo_set_error_handler)
ZEND_FE(restore_error_handler, arginfo_restore_error_handler)
ZEND_FE(set_exception_handler, arginfo_set_exception_handler)
ZEND_FE(restore_exception_handler, arginfo_restore_exception_handler)
ZEND_FE(get_declared_classes, arginfo_get_declared_classes)
ZEND_FE(get_declared_traits, arginfo_get_declared_traits)
ZEND_FE(get_declared_interfaces, arginfo_get_declared_interfaces)
ZEND_FE(get_defined_functions, arginfo_get_defined_functions)
ZEND_FE(get_defined_vars, arginfo_get_defined_vars)
ZEND_FE(get_resource_type, arginfo_get_resource_type)
ZEND_FE(get_resource_id, arginfo_get_resource_id)
ZEND_FE(get_resources, arginfo_get_resources)
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
ZEND_FE(get_defined_constants, arginfo_get_defined_constants)
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
ZEND_FE(extension_loaded, arginfo_extension_loaded)
ZEND_FE(get_extension_funcs, arginfo_get_extension_funcs)
#if ZEND_DEBUG && defined(ZTS)
ZEND_FE(zend_thread_id, arginfo_zend_thread_id)
#endif
ZEND_FE(gc_mem_caches, arginfo_gc_mem_caches)
ZEND_FE(gc_collect_cycles, arginfo_gc_collect_cycles)
ZEND_FE(gc_enabled, arginfo_gc_enabled)
ZEND_FE(gc_enable, arginfo_gc_enable)
ZEND_FE(gc_disable, arginfo_gc_disable)
ZEND_FE(gc_status, arginfo_gc_status)
ZEND_FE_END
};
static const zend_function_entry class_stdClass_methods[] = {
ZEND_FE_END
};
static zend_class_entry *register_class_stdClass(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "stdClass", class_stdClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
zend_string *attribute_name_AllowDynamicProperties_class_stdClass_0 = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1);
zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_stdClass_0, 0);
zend_string_release(attribute_name_AllowDynamicProperties_class_stdClass_0);
return class_entry;
}

View File

@ -0,0 +1,94 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Arnaud Le Blanc <arnaud.lb@gmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CALL_STACK_H
#define ZEND_CALL_STACK_H
#include "zend.h"
#include "zend_portability.h"
#ifdef __APPLE__
# include <pthread.h>
#endif
#ifdef ZEND_CHECK_STACK_LIMIT
typedef struct _zend_call_stack {
void *base;
size_t max_size;
} zend_call_stack;
ZEND_API void zend_call_stack_init(void);
ZEND_API bool zend_call_stack_get(zend_call_stack *stack);
/** Returns an approximation of the current stack position */
static zend_always_inline void *zend_call_stack_position(void) {
#ifdef ZEND_WIN32
return _AddressOfReturnAddress();
#elif PHP_HAVE_BUILTIN_FRAME_ADDRESS
return __builtin_frame_address(0);
#else
void *a;
void *pos = (void*)&a;
return pos;
#endif
}
static zend_always_inline bool zend_call_stack_overflowed(void *stack_limit) {
return (uintptr_t) zend_call_stack_position() <= (uintptr_t) stack_limit;
}
static inline void* zend_call_stack_limit(void *base, size_t size, size_t reserved_size)
{
if (UNEXPECTED(size > (uintptr_t)base)) {
return (void*)0;
}
base = (int8_t*)base - size;
if (UNEXPECTED(UINTPTR_MAX - (uintptr_t)base < reserved_size)) {
return (void*)UINTPTR_MAX;
}
return (int8_t*)base + reserved_size;
}
static inline size_t zend_call_stack_default_size(void)
{
#ifdef __linux__
return 8 * 1024 * 1024;
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
return 4 * 1024 * 1024;
#endif
#ifdef __OpenBSD__
return 512 * 1024;
#endif
#ifdef __APPLE__
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html
if (pthread_main_np()) {
return 8 * 1024 * 1024;
}
return 512 * 1024;
#endif
return 2 * 1024 * 1024;
}
#endif /* ZEND_CHECK_STACK_LIMIT */
#endif /* ZEND_CALL_STACK_H */

View File

@ -0,0 +1,44 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Christian Seiler <chris_se@gmx.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CLOSURES_H
#define ZEND_CLOSURES_H
BEGIN_EXTERN_C()
/* This macro depends on zend_closure structure layout */
#define ZEND_CLOSURE_OBJECT(op_array) \
((zend_object*)((char*)(op_array) - sizeof(zend_object)))
void zend_register_closure_ce(void);
void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var);
void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val);
void zend_closure_from_frame(zval *closure_zv, zend_execute_data *frame);
extern ZEND_API zend_class_entry *zend_ce_closure;
ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr);
ZEND_API void zend_create_fake_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr);
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *obj);
ZEND_API const zend_function *zend_get_closure_method_def(zend_object *obj);
ZEND_API zval* zend_get_closure_this_ptr(zval *obj);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,53 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e3b480674671a698814db282c5ea34d438fe519d */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Closure___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bind, 0, 2, Closure, 1)
ZEND_ARG_OBJ_INFO(0, closure, Closure, 0)
ZEND_ARG_TYPE_INFO(0, newThis, IS_OBJECT, 1)
ZEND_ARG_TYPE_MASK(0, newScope, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, "\"static\"")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_bindTo, 0, 1, Closure, 1)
ZEND_ARG_TYPE_INFO(0, newThis, IS_OBJECT, 1)
ZEND_ARG_TYPE_MASK(0, newScope, MAY_BE_OBJECT|MAY_BE_STRING|MAY_BE_NULL, "\"static\"")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Closure_call, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, newThis, IS_OBJECT, 0)
ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Closure_fromCallable, 0, 1, Closure, 0)
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
ZEND_METHOD(Closure, __construct);
ZEND_METHOD(Closure, bind);
ZEND_METHOD(Closure, bindTo);
ZEND_METHOD(Closure, call);
ZEND_METHOD(Closure, fromCallable);
static const zend_function_entry class_Closure_methods[] = {
ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(Closure, bindTo, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END
};
static zend_class_entry *register_class_Closure(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Closure", class_Closure_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
return class_entry;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
#include <../main/php_config.h>

View File

@ -0,0 +1,60 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CONFIG_W32_H
#define ZEND_CONFIG_W32_H
#include <../main/config.w32.h>
#define _CRTDBG_MAP_ALLOC
#include <malloc.h>
#include <stdlib.h>
#include <crtdbg.h>
#include <string.h>
#ifndef ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#include <float.h>
#define HAVE_STDIOSTR_H 1
#define HAVE_CLASS_ISTDIOSTREAM
#define istdiostream stdiostream
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define strcasecmp(s1, s2) _stricmp(s1, s2)
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
#ifdef LIBZEND_EXPORTS
# define ZEND_API __declspec(dllexport)
#else
# define ZEND_API __declspec(dllimport)
#endif
#define ZEND_DLEXPORT __declspec(dllexport)
#define ZEND_DLIMPORT __declspec(dllimport)
#endif /* ZEND_CONFIG_W32_H */

View File

@ -0,0 +1,106 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CONSTANTS_H
#define ZEND_CONSTANTS_H
#include "zend_globals.h"
#define CONST_CS 0 /* No longer used -- always case sensitive */
#define CONST_PERSISTENT (1<<0) /* Persistent */
#define CONST_NO_FILE_CACHE (1<<1) /* Can't be saved in file cache */
#define CONST_DEPRECATED (1<<2) /* Deprecated */
#define CONST_OWNED (1<<3) /* constant should be destroyed together with class */
#define PHP_USER_CONSTANT 0x7fffff /* a constant defined in user space */
typedef struct _zend_constant {
zval value;
zend_string *name;
} zend_constant;
#define ZEND_CONSTANT_FLAGS(c) \
(Z_CONSTANT_FLAGS((c)->value) & 0xff)
#define ZEND_CONSTANT_MODULE_NUMBER(c) \
(Z_CONSTANT_FLAGS((c)->value) >> 8)
#define ZEND_CONSTANT_SET_FLAGS(c, _flags, _module_number) do { \
Z_CONSTANT_FLAGS((c)->value) = \
((_flags) & 0xff) | ((_module_number) << 8); \
} while (0)
#define REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)
#define REGISTER_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number)
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
#define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number)
#define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number)
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number)
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number)
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number)
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number)
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number)
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number)
#define REGISTER_MAIN_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), 0)
#define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0)
#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0)
#define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0)
#define REGISTER_MAIN_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0)
#define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0)
BEGIN_EXTERN_C()
void clean_module_constants(int module_number);
void free_zend_constant(zval *zv);
void zend_startup_constants(void);
void zend_shutdown_constants(void);
void zend_register_standard_constants(void);
ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
ZEND_API zval *zend_get_constant(zend_string *name);
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
ZEND_API zend_result zend_register_constant(zend_constant *c);
#ifdef ZTS
void zend_copy_constants(HashTable *target, HashTable *source);
#endif
ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t name_len);
static zend_always_inline zend_constant *zend_get_special_const(
const char *name, size_t name_len) {
if (name_len == 4 || name_len == 5) {
return _zend_get_special_const(name, name_len);
}
return NULL;
}
END_EXTERN_C()
#define ZEND_CONSTANT_DTOR free_zend_constant
#endif

View File

@ -0,0 +1,31 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: df76f4e5a735baba96c4ac3538e9e3e48d934f0f */
static void register_zend_constants_symbols(int module_number)
{
REGISTER_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DEBUG_BACKTRACE_PROVIDE_OBJECT", DEBUG_BACKTRACE_PROVIDE_OBJECT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT);
REGISTER_BOOL_CONSTANT("ZEND_THREAD_SAFE", ZTS_V, CONST_PERSISTENT);
REGISTER_BOOL_CONSTANT("ZEND_DEBUG_BUILD", ZEND_DEBUG, CONST_PERSISTENT);
REGISTER_BOOL_CONSTANT("TRUE", true, CONST_PERSISTENT);
REGISTER_BOOL_CONSTANT("FALSE", false, CONST_PERSISTENT);
REGISTER_NULL_CONSTANT("NULL", CONST_PERSISTENT);
}

View File

@ -0,0 +1,272 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_CPU_INFO_H
#define ZEND_CPU_INFO_H
#include "zend.h"
#define ZEND_CPU_EBX_MASK (1<<30)
#define ZEND_CPU_EDX_MASK (1U<<31)
typedef enum _zend_cpu_feature {
/* ECX */
ZEND_CPU_FEATURE_SSE3 = (1<<0),
ZEND_CPU_FEATURE_PCLMULQDQ = (1<<1),
ZEND_CPU_FEATURE_DTES64 = (1<<2),
ZEND_CPU_FEATURE_MONITOR = (1<<3),
ZEND_CPU_FEATURE_DSCPL = (1<<4),
ZEND_CPU_FEATURE_VMX = (1<<5),
ZEND_CPU_FEATURE_SMX = (1<<6),
ZEND_CPU_FEATURE_EST = (1<<7),
ZEND_CPU_FEATURE_TM2 = (1<<8),
ZEND_CPU_FEATURE_SSSE3 = (1<<9),
ZEND_CPU_FEATURE_CID = (1<<10),
ZEND_CPU_FEATURE_SDBG = (1<<11),
ZEND_CPU_FEATURE_FMA = (1<<12),
ZEND_CPU_FEATURE_CX16 = (1<<13),
ZEND_CPU_FEATURE_XTPR = (1<<14),
ZEND_CPU_FEATURE_PDCM = (1<<15),
/* reserved = (1<<16),*/
ZEND_CPU_FEATURE_PCID = (1<<17),
ZEND_CPU_FEATURE_DCA = (1<<18),
ZEND_CPU_FEATURE_SSE41 = (1<<19),
ZEND_CPU_FEATURE_SSE42 = (1<<20),
ZEND_CPU_FEATURE_X2APIC = (1<<21),
ZEND_CPU_FEATURE_MOVBE = (1<<22),
ZEND_CPU_FEATURE_POPCNT = (1<<23),
ZEND_CPU_FEATURE_TSC_DEADLINE = (1<<24),
ZEND_CPU_FEATURE_AES = (1<<25),
ZEND_CPU_FEATURE_XSAVE = (1<<26),
ZEND_CPU_FEATURE_OSXSAVE = (1<<27) ,
ZEND_CPU_FEATURE_AVX = (1<<28),
ZEND_CPU_FEATURE_F16C = (1<<29),
/* intentionally don't support = (1<<30) */
/* intentionally don't support = (1<<31) */
/* EBX */
ZEND_CPU_FEATURE_AVX2 = (1<<5 | ZEND_CPU_EBX_MASK),
ZEND_CPU_FEATURE_AVX512F = (1<<16 | ZEND_CPU_EBX_MASK),
ZEND_CPU_FEATURE_AVX512DQ = (1<<17 | ZEND_CPU_EBX_MASK),
ZEND_CPU_FEATURE_AVX512CD = (1<<28 | ZEND_CPU_EBX_MASK),
/* intentionally don't support = (1<<30 | ZEND_CPU_EBX_MASK) */
/* intentionally don't support = (1<<31 | ZEND_CPU_EBX_MASK) */
/* EDX */
ZEND_CPU_FEATURE_FPU = (1<<0 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_VME = (1<<1 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_DE = (1<<2 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PSE = (1<<3 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_TSC = (1<<4 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_MSR = (1<<5 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PAE = (1<<6 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_MCE = (1<<7 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_CX8 = (1<<8 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_APIC = (1<<9 | ZEND_CPU_EDX_MASK),
/* reserved = (1<<10 | ZEND_CPU_EDX_MASK),*/
ZEND_CPU_FEATURE_SEP = (1<<11 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_MTRR = (1<<12 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PGE = (1<<13 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_MCA = (1<<14 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_CMOV = (1<<15 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PAT = (1<<16 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PSE36 = (1<<17 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_PN = (1<<18 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_CLFLUSH = (1<<19 | ZEND_CPU_EDX_MASK),
/* reserved = (1<<20 | ZEND_CPU_EDX_MASK),*/
ZEND_CPU_FEATURE_DS = (1<<21 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_ACPI = (1<<22 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_MMX = (1<<23 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_FXSR = (1<<24 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_SSE = (1<<25 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_SSE2 = (1<<26 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_SS = (1<<27 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_HT = (1<<28 | ZEND_CPU_EDX_MASK),
ZEND_CPU_FEATURE_TM = (1<<29 | ZEND_CPU_EDX_MASK)
/*intentionally don't support = (1<<30 | ZEND_CPU_EDX_MASK)*/
/*intentionally don't support = (1<<31 | ZEND_CPU_EDX_MASK)*/
} zend_cpu_feature;
void zend_cpu_startup(void);
ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
/* Address sanitizer is incompatible with ifunc resolvers, so exclude the
* CPU support helpers from asan.
* See also https://github.com/google/sanitizers/issues/342. */
#if __has_attribute(no_sanitize_address)
# define ZEND_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
# define ZEND_NO_SANITIZE_ADDRESS
#endif
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS
/* NOTE: you should use following inline function in
* resolver functions (ifunc), as it could be called
* before all PLT symbols are resolved. in other words,
* resolver functions should not depend on any external
* functions */
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse2(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse2");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse3(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse3");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_ssse3(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("ssse3");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse41(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.1");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse42(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.2");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx");
}
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx2(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx2");
}
#if PHP_HAVE_AVX512_SUPPORTS
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx512(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512dq")
&& __builtin_cpu_supports("avx512cd") && __builtin_cpu_supports("avx512bw")
&& __builtin_cpu_supports("avx512vl");
}
#endif
#if PHP_HAVE_AVX512_VBMI_SUPPORTS
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx512_vbmi(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return zend_cpu_supports_avx512() && __builtin_cpu_supports("avx512vbmi");
}
#endif
#else
static inline int zend_cpu_supports_sse2(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_SSE2);
}
static inline int zend_cpu_supports_sse3(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_SSE3);
}
static inline int zend_cpu_supports_ssse3(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_SSSE3);
}
static inline int zend_cpu_supports_sse41(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_SSE41);
}
static inline int zend_cpu_supports_sse42(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_SSE42);
}
static inline int zend_cpu_supports_avx(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_AVX);
}
static inline int zend_cpu_supports_avx2(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_AVX2);
}
static inline int zend_cpu_supports_avx512(void) {
/* TODO: avx512_bw/avx512_vl use bit 30/31 which are reserved for mask */
return 0;
}
static zend_always_inline int zend_cpu_supports_avx512_vbmi(void) {
/* TODO: avx512_vbmi use ECX of cpuid 7 */
return 0;
}
#endif
/* __builtin_cpu_supports has pclmul from gcc9 */
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_pclmul(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("pclmul");
}
#else
static inline int zend_cpu_supports_pclmul(void) {
return zend_cpu_supports(ZEND_CPU_FEATURE_PCLMULQDQ);
}
#endif
/* __builtin_cpu_supports has cldemote from gcc11 */
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS && defined(__GNUC__) && (ZEND_GCC_VERSION >= 11000)
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_cldemote(void) {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("cldemote");
}
#endif
#endif

View File

@ -0,0 +1,48 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: David Soria Parra <david.soriaparra@sun.com> |
+----------------------------------------------------------------------+
*/
#ifndef _ZEND_DTRACE_H
#define _ZEND_DTRACE_H
#ifndef ZEND_WIN32
# include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_DTRACE
ZEND_API extern zend_op_array *(*zend_dtrace_compile_file)(zend_file_handle *file_handle, int type);
ZEND_API extern void (*zend_dtrace_execute)(zend_op_array *op_array);
ZEND_API extern void (*zend_dtrace_execute_internal)(zend_execute_data *execute_data, zval *return_value);
ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type);
ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data);
ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data, zval *return_value);
#include <zend_dtrace_gen.h>
void dtrace_error_notify_cb(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message);
#endif /* HAVE_DTRACE */
#ifdef __cplusplus
}
#endif
#endif /* _ZEND_DTRACE_H */

View File

@ -0,0 +1,64 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Ilija Tovilo <ilutov@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ENUM_H
#define ZEND_ENUM_H
#include "zend.h"
#include "zend_types.h"
#include <stdint.h>
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_unit_enum;
extern ZEND_API zend_class_entry *zend_ce_backed_enum;
extern ZEND_API zend_object_handlers zend_enum_object_handlers;
void zend_register_enum_ce(void);
void zend_enum_add_interfaces(zend_class_entry *ce);
zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce);
zend_object *zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv);
void zend_verify_enum(zend_class_entry *ce);
void zend_enum_register_funcs(zend_class_entry *ce);
void zend_enum_register_props(zend_class_entry *ce);
ZEND_API zend_class_entry *zend_register_internal_enum(
const char *name, uint8_t type, const zend_function_entry *functions);
ZEND_API void zend_enum_add_case(zend_class_entry *ce, zend_string *case_name, zval *value);
ZEND_API void zend_enum_add_case_cstr(zend_class_entry *ce, const char *name, zval *value);
ZEND_API zend_object *zend_enum_get_case(zend_class_entry *ce, zend_string *name);
ZEND_API zend_object *zend_enum_get_case_cstr(zend_class_entry *ce, const char *name);
ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_class_entry *ce, zend_long long_key, zend_string *string_key, bool try);
static zend_always_inline zval *zend_enum_fetch_case_name(zend_object *zobj)
{
ZEND_ASSERT(zobj->ce->ce_flags & ZEND_ACC_ENUM);
return OBJ_PROP_NUM(zobj, 0);
}
static zend_always_inline zval *zend_enum_fetch_case_value(zend_object *zobj)
{
ZEND_ASSERT(zobj->ce->ce_flags & ZEND_ACC_ENUM);
ZEND_ASSERT(zobj->ce->enum_backing_type != IS_UNDEF);
return OBJ_PROP_NUM(zobj, 1);
}
END_EXTERN_C()
#endif /* ZEND_ENUM_H */

View File

@ -0,0 +1,49 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 7092f1d4ba651f077cff37050899f090f00abf22 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_UnitEnum_cases, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_BackedEnum_from, 0, 1, IS_STATIC, 0)
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_LONG|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_BackedEnum_tryFrom, 0, 1, IS_STATIC, 1)
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_LONG|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()
static const zend_function_entry class_UnitEnum_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(UnitEnum, cases, arginfo_class_UnitEnum_cases, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_BackedEnum_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(BackedEnum, from, arginfo_class_BackedEnum_from, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(BackedEnum, tryFrom, arginfo_class_BackedEnum_tryFrom, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static zend_class_entry *register_class_UnitEnum(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "UnitEnum", class_UnitEnum_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_BackedEnum(zend_class_entry *class_entry_UnitEnum)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "BackedEnum", class_BackedEnum_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_UnitEnum);
return class_entry;
}

View File

@ -0,0 +1,50 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_ERRORS_H
#define ZEND_ERRORS_H
#define E_ERROR (1<<0L)
#define E_WARNING (1<<1L)
#define E_PARSE (1<<2L)
#define E_NOTICE (1<<3L)
#define E_CORE_ERROR (1<<4L)
#define E_CORE_WARNING (1<<5L)
#define E_COMPILE_ERROR (1<<6L)
#define E_COMPILE_WARNING (1<<7L)
#define E_USER_ERROR (1<<8L)
#define E_USER_WARNING (1<<9L)
#define E_USER_NOTICE (1<<10L)
#define E_STRICT (1<<11L)
#define E_RECOVERABLE_ERROR (1<<12L)
#define E_DEPRECATED (1<<13L)
#define E_USER_DEPRECATED (1<<14L)
/* Indicates that this usually fatal error should not result in a bailout */
#define E_DONT_BAIL (1<<15L)
#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
/* Fatal errors that are ignored by the silence operator */
#define E_FATAL_ERRORS (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE)
#define E_HAS_ONLY_FATAL_ERRORS(mask) !((mask) & ~E_FATAL_ERRORS)
#endif /* ZEND_ERRORS_H */

View File

@ -0,0 +1,93 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_EXCEPTIONS_H
#define ZEND_EXCEPTIONS_H
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_throwable;
extern ZEND_API zend_class_entry *zend_ce_exception;
extern ZEND_API zend_class_entry *zend_ce_error_exception;
extern ZEND_API zend_class_entry *zend_ce_error;
extern ZEND_API zend_class_entry *zend_ce_compile_error;
extern ZEND_API zend_class_entry *zend_ce_parse_error;
extern ZEND_API zend_class_entry *zend_ce_type_error;
extern ZEND_API zend_class_entry *zend_ce_argument_count_error;
extern ZEND_API zend_class_entry *zend_ce_value_error;
extern ZEND_API zend_class_entry *zend_ce_arithmetic_error;
extern ZEND_API zend_class_entry *zend_ce_division_by_zero_error;
extern ZEND_API zend_class_entry *zend_ce_unhandled_match_error;
ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous);
ZEND_API void zend_exception_save(void);
ZEND_API void zend_exception_restore(void);
ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception);
void zend_register_default_exception(void);
ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object);
/* Deprecated - Use zend_ce_exception directly instead */
ZEND_API zend_class_entry *zend_exception_get_default(void);
/* Deprecated - Use zend_ce_error_exception directly instead */
ZEND_API zend_class_entry *zend_get_error_exception(void);
ZEND_API void zend_register_default_classes(void);
/* exception_ce NULL, zend_ce_exception, zend_ce_error, or a derived class
* message NULL or the message of the exception */
ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code);
ZEND_API ZEND_COLD zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
ZEND_API ZEND_COLD void zend_throw_exception_object(zval *exception);
ZEND_API void zend_clear_exception(void);
ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, zend_string *message, zend_long code, int severity);
extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex);
/* show an exception using zend_error(severity,...), severity should be E_ERROR */
ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity);
ZEND_NORETURN void zend_exception_uncaught_error(const char *prefix, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
ZEND_API zend_string *zend_trace_to_string(HashTable *trace, bool include_main);
ZEND_API ZEND_COLD zend_object *zend_create_unwind_exit(void);
ZEND_API ZEND_COLD zend_object *zend_create_graceful_exit(void);
ZEND_API ZEND_COLD void zend_throw_unwind_exit(void);
ZEND_API ZEND_COLD void zend_throw_graceful_exit(void);
ZEND_API bool zend_is_unwind_exit(const zend_object *ex);
ZEND_API bool zend_is_graceful_exit(const zend_object *ex);
#include "zend_globals.h"
static zend_always_inline void zend_rethrow_exception(zend_execute_data *execute_data)
{
if (EX(opline)->opcode != ZEND_HANDLE_EXCEPTION) {
EG(opline_before_exception) = EX(opline);
EX(opline) = EG(exception_op);
}
}
END_EXTERN_C()
#endif

View File

@ -0,0 +1,403 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 4cf2c620393f468968a219b5bd12a2b5f6b03ecc */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getMessage, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Throwable_getCode, 0, 0, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Throwable_getFile arginfo_class_Throwable_getMessage
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getLine, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getTrace, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Throwable_getPrevious, 0, 0, Throwable, 1)
ZEND_END_ARG_INFO()
#define arginfo_class_Throwable_getTraceAsString arginfo_class_Throwable_getMessage
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Exception___clone, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Exception___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, message, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_LONG, 0, "0")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, previous, Throwable, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Exception___wakeup, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Exception_getMessage arginfo_class_Throwable_getMessage
#define arginfo_class_Exception_getCode arginfo_class_Throwable_getCode
#define arginfo_class_Exception_getFile arginfo_class_Throwable_getMessage
#define arginfo_class_Exception_getLine arginfo_class_Throwable_getLine
#define arginfo_class_Exception_getTrace arginfo_class_Throwable_getTrace
#define arginfo_class_Exception_getPrevious arginfo_class_Throwable_getPrevious
#define arginfo_class_Exception_getTraceAsString arginfo_class_Throwable_getMessage
#define arginfo_class_Exception___toString arginfo_class_Throwable_getMessage
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ErrorException___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, message, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, severity, IS_LONG, 0, "E_ERROR")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, line, IS_LONG, 1, "null")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, previous, Throwable, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_class_ErrorException_getSeverity arginfo_class_Throwable_getLine
#define arginfo_class_Error___clone arginfo_class_Exception___clone
#define arginfo_class_Error___construct arginfo_class_Exception___construct
#define arginfo_class_Error___wakeup arginfo_class_Exception___wakeup
#define arginfo_class_Error_getMessage arginfo_class_Throwable_getMessage
#define arginfo_class_Error_getCode arginfo_class_Throwable_getCode
#define arginfo_class_Error_getFile arginfo_class_Throwable_getMessage
#define arginfo_class_Error_getLine arginfo_class_Throwable_getLine
#define arginfo_class_Error_getTrace arginfo_class_Throwable_getTrace
#define arginfo_class_Error_getPrevious arginfo_class_Throwable_getPrevious
#define arginfo_class_Error_getTraceAsString arginfo_class_Throwable_getMessage
#define arginfo_class_Error___toString arginfo_class_Throwable_getMessage
ZEND_METHOD(Exception, __clone);
ZEND_METHOD(Exception, __construct);
ZEND_METHOD(Exception, __wakeup);
ZEND_METHOD(Exception, getMessage);
ZEND_METHOD(Exception, getCode);
ZEND_METHOD(Exception, getFile);
ZEND_METHOD(Exception, getLine);
ZEND_METHOD(Exception, getTrace);
ZEND_METHOD(Exception, getPrevious);
ZEND_METHOD(Exception, getTraceAsString);
ZEND_METHOD(Exception, __toString);
ZEND_METHOD(ErrorException, __construct);
ZEND_METHOD(ErrorException, getSeverity);
static const zend_function_entry class_Throwable_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getMessage, arginfo_class_Throwable_getMessage, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getCode, arginfo_class_Throwable_getCode, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getFile, arginfo_class_Throwable_getFile, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getLine, arginfo_class_Throwable_getLine, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getTrace, arginfo_class_Throwable_getTrace, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getPrevious, arginfo_class_Throwable_getPrevious, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Throwable, getTraceAsString, arginfo_class_Throwable_getTraceAsString, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_Exception_methods[] = {
ZEND_ME(Exception, __clone, arginfo_class_Exception___clone, ZEND_ACC_PRIVATE)
ZEND_ME(Exception, __construct, arginfo_class_Exception___construct, ZEND_ACC_PUBLIC)
ZEND_ME(Exception, __wakeup, arginfo_class_Exception___wakeup, ZEND_ACC_PUBLIC)
ZEND_ME(Exception, getMessage, arginfo_class_Exception_getMessage, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getCode, arginfo_class_Exception_getCode, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getFile, arginfo_class_Exception_getFile, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getLine, arginfo_class_Exception_getLine, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getTrace, arginfo_class_Exception_getTrace, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getPrevious, arginfo_class_Exception_getPrevious, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, getTraceAsString, arginfo_class_Exception_getTraceAsString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(Exception, __toString, arginfo_class_Exception___toString, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ErrorException_methods[] = {
ZEND_ME(ErrorException, __construct, arginfo_class_ErrorException___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ErrorException, getSeverity, arginfo_class_ErrorException_getSeverity, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_FE_END
};
static const zend_function_entry class_Error_methods[] = {
ZEND_MALIAS(Exception, __clone, __clone, arginfo_class_Error___clone, ZEND_ACC_PRIVATE)
ZEND_MALIAS(Exception, __construct, __construct, arginfo_class_Error___construct, ZEND_ACC_PUBLIC)
ZEND_MALIAS(Exception, __wakeup, __wakeup, arginfo_class_Error___wakeup, ZEND_ACC_PUBLIC)
ZEND_MALIAS(Exception, getMessage, getMessage, arginfo_class_Error_getMessage, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getCode, getCode, arginfo_class_Error_getCode, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getFile, getFile, arginfo_class_Error_getFile, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getLine, getLine, arginfo_class_Error_getLine, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getTrace, getTrace, arginfo_class_Error_getTrace, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getPrevious, getPrevious, arginfo_class_Error_getPrevious, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, getTraceAsString, getTraceAsString, arginfo_class_Error_getTraceAsString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_MALIAS(Exception, __toString, __toString, arginfo_class_Error___toString, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_CompileError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_ParseError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_TypeError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_ArgumentCountError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_ValueError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_ArithmeticError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_DivisionByZeroError_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_UnhandledMatchError_methods[] = {
ZEND_FE_END
};
static zend_class_entry *register_class_Throwable(zend_class_entry *class_entry_Stringable)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Throwable", class_Throwable_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_Stringable);
return class_entry;
}
static zend_class_entry *register_class_Exception(zend_class_entry *class_entry_Throwable)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Exception", class_Exception_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zend_class_implements(class_entry, 1, class_entry_Throwable);
zval property_message_default_value;
ZVAL_EMPTY_STRING(&property_message_default_value);
zend_string *property_message_name = zend_string_init("message", sizeof("message") - 1, 1);
zend_declare_typed_property(class_entry, property_message_name, &property_message_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_string_release(property_message_name);
zval property_string_default_value;
ZVAL_EMPTY_STRING(&property_string_default_value);
zend_string *property_string_name = zend_string_init("string", sizeof("string") - 1, 1);
zend_declare_typed_property(class_entry, property_string_name, &property_string_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_string_name);
zval property_code_default_value;
ZVAL_LONG(&property_code_default_value, 0);
zend_string *property_code_name = zend_string_init("code", sizeof("code") - 1, 1);
zend_declare_typed_property(class_entry, property_code_name, &property_code_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_string_release(property_code_name);
zval property_file_default_value;
ZVAL_EMPTY_STRING(&property_file_default_value);
zend_string *property_file_name = zend_string_init("file", sizeof("file") - 1, 1);
zend_declare_typed_property(class_entry, property_file_name, &property_file_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_file_name);
zval property_line_default_value;
ZVAL_LONG(&property_line_default_value, 0);
zend_string *property_line_name = zend_string_init("line", sizeof("line") - 1, 1);
zend_declare_typed_property(class_entry, property_line_name, &property_line_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(property_line_name);
zval property_trace_default_value;
ZVAL_EMPTY_ARRAY(&property_trace_default_value);
zend_string *property_trace_name = zend_string_init("trace", sizeof("trace") - 1, 1);
zend_declare_typed_property(class_entry, property_trace_name, &property_trace_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
zend_string_release(property_trace_name);
zval property_previous_default_value;
ZVAL_NULL(&property_previous_default_value);
zend_string *property_previous_name = zend_string_init("previous", sizeof("previous") - 1, 1);
zend_string *property_previous_class_Throwable = zend_string_init("Throwable", sizeof("Throwable")-1, 1);
zend_declare_typed_property(class_entry, property_previous_name, &property_previous_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previous_class_Throwable, 0, MAY_BE_NULL));
zend_string_release(property_previous_name);
return class_entry;
}
static zend_class_entry *register_class_ErrorException(zend_class_entry *class_entry_Exception)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ErrorException", class_ErrorException_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zval property_severity_default_value;
ZVAL_LONG(&property_severity_default_value, E_ERROR);
zend_string *property_severity_name = zend_string_init("severity", sizeof("severity") - 1, 1);
zend_declare_typed_property(class_entry, property_severity_name, &property_severity_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(property_severity_name);
return class_entry;
}
static zend_class_entry *register_class_Error(zend_class_entry *class_entry_Throwable)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Error", class_Error_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zend_class_implements(class_entry, 1, class_entry_Throwable);
zval property_message_default_value;
ZVAL_EMPTY_STRING(&property_message_default_value);
zend_string *property_message_name = zend_string_init("message", sizeof("message") - 1, 1);
zend_declare_typed_property(class_entry, property_message_name, &property_message_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_string_release(property_message_name);
zval property_string_default_value;
ZVAL_EMPTY_STRING(&property_string_default_value);
zend_string *property_string_name = zend_string_init("string", sizeof("string") - 1, 1);
zend_declare_typed_property(class_entry, property_string_name, &property_string_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_string_name);
zval property_code_default_value;
ZVAL_LONG(&property_code_default_value, 0);
zend_string *property_code_name = zend_string_init("code", sizeof("code") - 1, 1);
zend_declare_typed_property(class_entry, property_code_name, &property_code_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_string_release(property_code_name);
zval property_file_default_value;
ZVAL_EMPTY_STRING(&property_file_default_value);
zend_string *property_file_name = zend_string_init("file", sizeof("file") - 1, 1);
zend_declare_typed_property(class_entry, property_file_name, &property_file_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_file_name);
zval property_line_default_value;
ZVAL_UNDEF(&property_line_default_value);
zend_string *property_line_name = zend_string_init("line", sizeof("line") - 1, 1);
zend_declare_typed_property(class_entry, property_line_name, &property_line_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(property_line_name);
zval property_trace_default_value;
ZVAL_EMPTY_ARRAY(&property_trace_default_value);
zend_string *property_trace_name = zend_string_init("trace", sizeof("trace") - 1, 1);
zend_declare_typed_property(class_entry, property_trace_name, &property_trace_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
zend_string_release(property_trace_name);
zval property_previous_default_value;
ZVAL_NULL(&property_previous_default_value);
zend_string *property_previous_name = zend_string_init("previous", sizeof("previous") - 1, 1);
zend_string *property_previous_class_Throwable = zend_string_init("Throwable", sizeof("Throwable")-1, 1);
zend_declare_typed_property(class_entry, property_previous_name, &property_previous_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previous_class_Throwable, 0, MAY_BE_NULL));
zend_string_release(property_previous_name);
return class_entry;
}
static zend_class_entry *register_class_CompileError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "CompileError", class_CompileError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
return class_entry;
}
static zend_class_entry *register_class_ParseError(zend_class_entry *class_entry_CompileError)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ParseError", class_ParseError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_CompileError);
return class_entry;
}
static zend_class_entry *register_class_TypeError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "TypeError", class_TypeError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
return class_entry;
}
static zend_class_entry *register_class_ArgumentCountError(zend_class_entry *class_entry_TypeError)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ArgumentCountError", class_ArgumentCountError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_TypeError);
return class_entry;
}
static zend_class_entry *register_class_ValueError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ValueError", class_ValueError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
return class_entry;
}
static zend_class_entry *register_class_ArithmeticError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ArithmeticError", class_ArithmeticError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
return class_entry;
}
static zend_class_entry *register_class_DivisionByZeroError(zend_class_entry *class_entry_ArithmeticError)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "DivisionByZeroError", class_DivisionByZeroError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_ArithmeticError);
return class_entry;
}
static zend_class_entry *register_class_UnhandledMatchError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "UnhandledMatchError", class_UnhandledMatchError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
return class_entry;
}

View File

@ -0,0 +1,534 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_EXECUTE_H
#define ZEND_EXECUTE_H
#include "zend_compile.h"
#include "zend_hash.h"
#include "zend_operators.h"
#include "zend_variables.h"
#include <stdint.h>
BEGIN_EXTERN_C()
struct _zend_fcall_info;
ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
/* The lc_name may be stack allocated! */
ZEND_API extern zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
void init_executor(void);
void shutdown_executor(void);
void shutdown_destructors(void);
ZEND_API void zend_shutdown_executor_values(bool fast_shutdown);
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
ZEND_API void zend_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
ZEND_API void zend_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
ZEND_API void execute_ex(zend_execute_data *execute_data);
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
ZEND_API bool zend_is_valid_class_name(zend_string *name);
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags);
ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex);
ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex);
ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name);
ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name);
ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions);
ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions);
/* export zend_pass_function to allow comparisons against it */
extern ZEND_API const zend_internal_function zend_pass_function;
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_false_to_array_deprecated(void);
ZEND_COLD void ZEND_FASTCALL zend_param_must_be_ref(const zend_function *func, uint32_t arg_num);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim);
ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, zval *zv, bool strict);
typedef enum {
ZEND_VERIFY_PROP_ASSIGNABLE_BY_REF_CONTEXT_ASSIGNMENT,
ZEND_VERIFY_PROP_ASSIGNABLE_BY_REF_CONTEXT_MAGIC_GET,
} zend_verify_prop_assignable_by_ref_context;
ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex(const zend_property_info *prop_info, zval *orig_val, bool strict, zend_verify_prop_assignable_by_ref_context context);
ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(const zend_property_info *prop_info, zval *orig_val, bool strict);
ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(const zend_property_info *prop, const zval *zv);
ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(const zend_property_info *prop1, const zend_property_info *prop2, const zval *zv);
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(const zend_property_info *info);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error(const zend_property_info *info);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_invalid_class_constant_type_error(uint8_t type);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_object_released_while_assigning_to_property_error(const zend_property_info *info);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_add_element(void);
ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg);
ZEND_API ZEND_COLD void zend_verify_arg_error(
const zend_function *zf, const zend_arg_info *arg_info, uint32_t arg_num, zval *value);
ZEND_API ZEND_COLD void zend_verify_return_error(
const zend_function *zf, zval *value);
ZEND_API ZEND_COLD void zend_verify_never_error(
const zend_function *zf);
ZEND_API bool zend_verify_ref_array_assignable(zend_reference *ref);
ZEND_API bool zend_check_user_type_slow(
zend_type *type, zval *arg, zend_reference *ref, void **cache_slot, bool is_return_type);
#if ZEND_DEBUG
ZEND_API bool zend_internal_call_should_throw(zend_function *fbc, zend_execute_data *call);
ZEND_API ZEND_COLD void zend_internal_call_arginfo_violation(zend_function *fbc);
ZEND_API bool zend_verify_internal_return_type(zend_function *zf, zval *ret);
#endif
#define ZEND_REF_TYPE_SOURCES(ref) \
(ref)->sources
#define ZEND_REF_HAS_TYPE_SOURCES(ref) \
(ZEND_REF_TYPE_SOURCES(ref).ptr != NULL)
#define ZEND_REF_FIRST_SOURCE(ref) \
(ZEND_PROPERTY_INFO_SOURCE_IS_LIST((ref)->sources.list) \
? ZEND_PROPERTY_INFO_SOURCE_TO_LIST((ref)->sources.list)->ptr[0] \
: (ref)->sources.ptr)
ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_list *source_list, const zend_property_info *prop);
ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, uint8_t value_type, bool strict);
ZEND_API zval* zend_assign_to_typed_ref_ex(zval *variable_ptr, zval *value, uint8_t value_type, bool strict, zend_refcounted **garbage_ptr);
static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, uint8_t value_type)
{
zend_refcounted *ref = NULL;
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
ref = Z_COUNTED_P(value);
value = Z_REFVAL_P(value);
}
ZVAL_COPY_VALUE(variable_ptr, value);
if (ZEND_CONST_COND(value_type == IS_CONST, 0)) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
} else if (value_type & (IS_CONST|IS_CV)) {
if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
Z_ADDREF_P(variable_ptr);
}
} else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
if (UNEXPECTED(GC_DELREF(ref) == 0)) {
efree_size(ref, sizeof(zend_reference));
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
Z_ADDREF_P(variable_ptr);
}
}
}
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, uint8_t value_type, bool strict)
{
do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
zend_refcounted *garbage;
if (Z_ISREF_P(variable_ptr)) {
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) {
return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict);
}
variable_ptr = Z_REFVAL_P(variable_ptr);
if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
break;
}
}
garbage = Z_COUNTED_P(variable_ptr);
zend_copy_to_variable(variable_ptr, value, value_type);
GC_DTOR_NO_REF(garbage);
return variable_ptr;
}
} while (0);
zend_copy_to_variable(variable_ptr, value, value_type);
return variable_ptr;
}
static zend_always_inline zval* zend_assign_to_variable_ex(zval *variable_ptr, zval *value, zend_uchar value_type, bool strict, zend_refcounted **garbage_ptr)
{
do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
if (Z_ISREF_P(variable_ptr)) {
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) {
return zend_assign_to_typed_ref_ex(variable_ptr, value, value_type, strict, garbage_ptr);
}
variable_ptr = Z_REFVAL_P(variable_ptr);
if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
break;
}
}
*garbage_ptr = Z_COUNTED_P(variable_ptr);
}
} while (0);
zend_copy_to_variable(variable_ptr, value, value_type);
return variable_ptr;
}
ZEND_API zend_result ZEND_FASTCALL zval_update_constant(zval *pp);
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_entry *scope);
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *pp, zend_class_entry *scope, zend_ast_evaluate_ctx *ctx);
/* dedicated Zend executor functions - do not use! */
struct _zend_vm_stack {
zval *top;
zval *end;
zend_vm_stack prev;
};
/* Ensure the correct alignment before slots calculation */
ZEND_STATIC_ASSERT(ZEND_MM_ALIGNED_SIZE(sizeof(zval)) == sizeof(zval),
"zval must be aligned by ZEND_MM_ALIGNMENT");
/* A number of call frame slots (zvals) reserved for _zend_vm_stack. */
#define ZEND_VM_STACK_HEADER_SLOTS \
((sizeof(struct _zend_vm_stack) + sizeof(zval) - 1) / sizeof(zval))
#define ZEND_VM_STACK_ELEMENTS(stack) \
(((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
/*
* In general in RELEASE build ZEND_ASSERT() must be zero-cost, but for some
* reason, GCC generated worse code, performing CSE on assertion code and the
* following "slow path" and moving memory read operations from slow path into
* common header. This made a degradation for the fast path.
* The following "#if ZEND_DEBUG" eliminates it.
*/
#if ZEND_DEBUG
# define ZEND_ASSERT_VM_STACK(stack) ZEND_ASSERT(stack->top > (zval *) stack && stack->end > (zval *) stack && stack->top <= stack->end)
# define ZEND_ASSERT_VM_STACK_GLOBAL ZEND_ASSERT(EG(vm_stack_top) > (zval *) EG(vm_stack) && EG(vm_stack_end) > (zval *) EG(vm_stack) && EG(vm_stack_top) <= EG(vm_stack_end))
#else
# define ZEND_ASSERT_VM_STACK(stack)
# define ZEND_ASSERT_VM_STACK_GLOBAL
#endif
ZEND_API void zend_vm_stack_init(void);
ZEND_API void zend_vm_stack_init_ex(size_t page_size);
ZEND_API void zend_vm_stack_destroy(void);
ZEND_API void* zend_vm_stack_extend(size_t size);
static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
zend_vm_stack page = (zend_vm_stack)emalloc(size);
page->top = ZEND_VM_STACK_ELEMENTS(page);
page->end = (zval*)((char*)page + size);
page->prev = prev;
return page;
}
static zend_always_inline void zend_vm_init_call_frame(zend_execute_data *call, uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
{
ZEND_ASSERT(!func->common.scope || object_or_called_scope);
call->func = func;
Z_PTR(call->This) = object_or_called_scope;
ZEND_CALL_INFO(call) = call_info;
ZEND_CALL_NUM_ARGS(call) = num_args;
}
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(uint32_t used_stack, uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
{
zend_execute_data *call = (zend_execute_data*)EG(vm_stack_top);
ZEND_ASSERT_VM_STACK_GLOBAL;
if (UNEXPECTED(used_stack > (size_t)(((char*)EG(vm_stack_end)) - (char*)call))) {
call = (zend_execute_data*)zend_vm_stack_extend(used_stack);
ZEND_ASSERT_VM_STACK_GLOBAL;
zend_vm_init_call_frame(call, call_info | ZEND_CALL_ALLOCATED, func, num_args, object_or_called_scope);
return call;
} else {
EG(vm_stack_top) = (zval*)((char*)call + used_stack);
zend_vm_init_call_frame(call, call_info, func, num_args, object_or_called_scope);
return call;
}
}
static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, zend_function *func)
{
uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args + func->common.T;
if (EXPECTED(ZEND_USER_CODE(func->type))) {
used_stack += func->op_array.last_var - MIN(func->op_array.num_args, num_args);
}
return used_stack * sizeof(zval);
}
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
{
uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);
return zend_vm_stack_push_call_frame_ex(used_stack, call_info,
func, num_args, object_or_called_scope);
}
static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_info, zend_execute_data *call)
{
if (UNEXPECTED(call_info & ZEND_CALL_FREE_EXTRA_ARGS)) {
uint32_t count = ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args;
zval *p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
do {
i_zval_ptr_dtor(p);
p++;
} while (--count);
}
}
static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call)
{
zend_vm_stack_free_extra_args_ex(ZEND_CALL_INFO(call), call);
}
static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
{
uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
if (EXPECTED(num_args > 0)) {
zval *p = ZEND_CALL_ARG(call, 1);
do {
zval_ptr_dtor_nogc(p);
p++;
} while (--num_args);
}
}
static zend_always_inline void zend_vm_stack_free_call_frame_ex(uint32_t call_info, zend_execute_data *call)
{
ZEND_ASSERT_VM_STACK_GLOBAL;
if (UNEXPECTED(call_info & ZEND_CALL_ALLOCATED)) {
zend_vm_stack p = EG(vm_stack);
zend_vm_stack prev = p->prev;
ZEND_ASSERT(call == (zend_execute_data*)ZEND_VM_STACK_ELEMENTS(EG(vm_stack)));
EG(vm_stack_top) = prev->top;
EG(vm_stack_end) = prev->end;
EG(vm_stack) = prev;
efree(p);
} else {
EG(vm_stack_top) = (zval*)call;
}
ZEND_ASSERT_VM_STACK_GLOBAL;
}
static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call)
{
zend_vm_stack_free_call_frame_ex(ZEND_CALL_INFO(call), call);
}
zend_execute_data *zend_vm_stack_copy_call_frame(
zend_execute_data *call, uint32_t passed_args, uint32_t additional_args);
static zend_always_inline void zend_vm_stack_extend_call_frame(
zend_execute_data **call, uint32_t passed_args, uint32_t additional_args)
{
if (EXPECTED((uint32_t)(EG(vm_stack_end) - EG(vm_stack_top)) > additional_args)) {
EG(vm_stack_top) += additional_args;
} else {
*call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args);
}
}
ZEND_API void ZEND_FASTCALL zend_free_extra_named_params(zend_array *extra_named_params);
/* services */
ZEND_API const char *get_active_class_name(const char **space);
ZEND_API const char *get_active_function_name(void);
ZEND_API const char *get_active_function_arg_name(uint32_t arg_num);
ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num);
ZEND_API zend_string *get_active_function_or_method_name(void);
ZEND_API zend_string *get_function_or_method_name(const zend_function *func);
ZEND_API const char *zend_get_executed_filename(void);
ZEND_API zend_string *zend_get_executed_filename_ex(void);
ZEND_API uint32_t zend_get_executed_lineno(void);
ZEND_API zend_class_entry *zend_get_executed_scope(void);
ZEND_API bool zend_is_executing(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_reference(uint32_t arg_num);
ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals);
ZEND_API void zend_unset_timeout(void);
ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void);
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, uint32_t fetch_type);
ZEND_API zend_class_entry *zend_fetch_class_with_scope(zend_string *class_name, uint32_t fetch_type, zend_class_entry *scope);
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, uint32_t fetch_type);
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name);
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len);
ZEND_API void ZEND_FASTCALL zend_init_func_run_time_cache(zend_op_array *op_array);
ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type);
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
ZEND_API bool zend_gcc_global_regs(void);
#define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
#define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
#define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */
#define ZEND_USER_OPCODE_ENTER 3 /* enter into new op_array without recursion */
#define ZEND_USER_OPCODE_LEAVE 4 /* return to calling op_array within the same executor */
#define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
ZEND_API zend_result zend_set_user_opcode_handler(uint8_t opcode, user_opcode_handler_t handler);
ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(uint8_t opcode);
ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data);
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
ZEND_API void ZEND_FASTCALL zend_free_compiled_variables(zend_execute_data *execute_data);
ZEND_API void zend_unfinished_calls_gc(zend_execute_data *execute_data, zend_execute_data *call, uint32_t op_num, zend_get_gc_buffer *buf);
ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num);
ZEND_API ZEND_ATTRIBUTE_DEPRECATED HashTable *zend_unfinished_execution_gc(zend_execute_data *execute_data, zend_execute_data *call, zend_get_gc_buffer *gc_buffer);
ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_data, zend_execute_data *call, zend_get_gc_buffer *gc_buffer, bool suspended_by_yield);
zval * ZEND_FASTCALL zend_handle_named_arg(
zend_execute_data **call_ptr, zend_string *arg_name,
uint32_t *arg_num_ptr, void **cache_slot);
ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call);
#define CACHE_ADDR(num) \
((void**)((char*)EX(run_time_cache) + (num)))
#define CACHED_PTR(num) \
((void**)((char*)EX(run_time_cache) + (num)))[0]
#define CACHE_PTR(num, ptr) do { \
((void**)((char*)EX(run_time_cache) + (num)))[0] = (ptr); \
} while (0)
#define CACHED_POLYMORPHIC_PTR(num, ce) \
(EXPECTED(((void**)((char*)EX(run_time_cache) + (num)))[0] == (void*)(ce)) ? \
((void**)((char*)EX(run_time_cache) + (num)))[1] : \
NULL)
#define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
void **slot = (void**)((char*)EX(run_time_cache) + (num)); \
slot[0] = (ce); \
slot[1] = (ptr); \
} while (0)
#define CACHED_PTR_EX(slot) \
(slot)[0]
#define CACHE_PTR_EX(slot, ptr) do { \
(slot)[0] = (ptr); \
} while (0)
#define CACHED_POLYMORPHIC_PTR_EX(slot, ce) \
(EXPECTED((slot)[0] == (ce)) ? (slot)[1] : NULL)
#define CACHE_POLYMORPHIC_PTR_EX(slot, ce, ptr) do { \
(slot)[0] = (ce); \
(slot)[1] = (ptr); \
} while (0)
#define CACHE_SPECIAL (1<<0)
#define IS_SPECIAL_CACHE_VAL(ptr) \
(((uintptr_t)(ptr)) & CACHE_SPECIAL)
#define ENCODE_SPECIAL_CACHE_NUM(num) \
((void*)((((uintptr_t)(num)) << 1) | CACHE_SPECIAL))
#define DECODE_SPECIAL_CACHE_NUM(ptr) \
(((uintptr_t)(ptr)) >> 1)
#define ENCODE_SPECIAL_CACHE_PTR(ptr) \
((void*)(((uintptr_t)(ptr)) | CACHE_SPECIAL))
#define DECODE_SPECIAL_CACHE_PTR(ptr) \
((void*)(((uintptr_t)(ptr)) & ~CACHE_SPECIAL))
#define SKIP_EXT_OPLINE(opline) do { \
while (UNEXPECTED((opline)->opcode >= ZEND_EXT_STMT \
&& (opline)->opcode <= ZEND_TICKS)) { \
(opline)--; \
} \
} while (0)
#define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) == ZEND_ACC_HAS_TYPE_HINTS)
#define ZEND_CLASS_HAS_READONLY_PROPS(ce) ((ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS) == ZEND_ACC_HAS_READONLY_PROPS)
ZEND_API bool zend_verify_class_constant_type(zend_class_constant *c, const zend_string *name, zval *constant);
ZEND_COLD void zend_verify_class_constant_type_error(const zend_class_constant *c, const zend_string *name, const zval *constant);
ZEND_API bool zend_verify_property_type(const zend_property_info *info, zval *property, bool strict);
ZEND_COLD void zend_verify_property_type_error(const zend_property_info *info, const zval *property);
ZEND_COLD void zend_magic_get_property_type_inconsistency_error(const zend_property_info *info, const zval *property);
#define ZEND_REF_ADD_TYPE_SOURCE(ref, source) \
zend_ref_add_type_source(&ZEND_REF_TYPE_SOURCES(ref), source)
#define ZEND_REF_DEL_TYPE_SOURCE(ref, source) \
zend_ref_del_type_source(&ZEND_REF_TYPE_SOURCES(ref), source)
#define ZEND_REF_FOREACH_TYPE_SOURCES(ref, prop) do { \
zend_property_info_source_list *_source_list = &ZEND_REF_TYPE_SOURCES(ref); \
zend_property_info **_prop, **_end; \
zend_property_info_list *_list; \
if (_source_list->ptr) { \
if (ZEND_PROPERTY_INFO_SOURCE_IS_LIST(_source_list->list)) { \
_list = ZEND_PROPERTY_INFO_SOURCE_TO_LIST(_source_list->list); \
_prop = _list->ptr; \
_end = _list->ptr + _list->num; \
} else { \
_prop = &_source_list->ptr; \
_end = _prop + 1; \
} \
for (; _prop < _end; _prop++) { \
prop = *_prop; \
#define ZEND_REF_FOREACH_TYPE_SOURCES_END() \
} \
} \
} while (0)
ZEND_COLD void zend_match_unhandled_error(const zval *value);
static zend_always_inline void *zend_get_bad_ptr(void)
{
ZEND_UNREACHABLE();
return NULL;
}
END_EXTERN_C()
#endif /* ZEND_EXECUTE_H */

View File

@ -0,0 +1,160 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_EXTENSIONS_H
#define ZEND_EXTENSIONS_H
#include "zend_compile.h"
#include "zend_build.h"
/*
The constants below are derived from ext/opcache/ZendAccelerator.h
You can use the following macro to check the extension API version for compatibilities:
#define ZEND_EXTENSION_API_NO_5_0_X 220040412
#define ZEND_EXTENSION_API_NO_5_1_X 220051025
#define ZEND_EXTENSION_API_NO_5_2_X 220060519
#define ZEND_EXTENSION_API_NO_5_3_X 220090626
#define ZEND_EXTENSION_API_NO_5_4_X 220100525
#define ZEND_EXTENSION_API_NO_5_5_X 220121212
#define ZEND_EXTENSION_API_NO_5_6_X 220131226
#define ZEND_EXTENSION_API_NO_7_0_X 320151012
#if ZEND_EXTENSION_API_NO < ZEND_EXTENSION_API_NO_5_5_X
// do something for php versions lower than 5.5.x
#endif
*/
/* The first number is the engine version and the rest is the date (YYYYMMDD).
* This way engine 2/3 API no. is always greater than engine 1 API no.. */
#define ZEND_EXTENSION_API_NO 420230831
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
const char *build_id;
} zend_extension_version_info;
#define ZEND_EXTENSION_BUILD_ID "API" ZEND_TOSTR(ZEND_EXTENSION_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
typedef struct _zend_extension zend_extension;
/* Typedef's for zend_extension function pointers */
typedef int (*startup_func_t)(zend_extension *extension);
typedef void (*shutdown_func_t)(zend_extension *extension);
typedef void (*activate_func_t)(void);
typedef void (*deactivate_func_t)(void);
typedef void (*message_handler_func_t)(int message, void *arg);
typedef void (*op_array_handler_func_t)(zend_op_array *op_array);
typedef void (*statement_handler_func_t)(zend_execute_data *frame);
typedef void (*fcall_begin_handler_func_t)(zend_execute_data *frame);
typedef void (*fcall_end_handler_func_t)(zend_execute_data *frame);
typedef void (*op_array_ctor_func_t)(zend_op_array *op_array);
typedef void (*op_array_dtor_func_t)(zend_op_array *op_array);
typedef size_t (*op_array_persist_calc_func_t)(zend_op_array *op_array);
typedef size_t (*op_array_persist_func_t)(zend_op_array *op_array, void *mem);
struct _zend_extension {
const char *name;
const char *version;
const char *author;
const char *URL;
const char *copyright;
startup_func_t startup;
shutdown_func_t shutdown;
activate_func_t activate;
deactivate_func_t deactivate;
message_handler_func_t message_handler;
op_array_handler_func_t op_array_handler;
statement_handler_func_t statement_handler;
fcall_begin_handler_func_t fcall_begin_handler;
fcall_end_handler_func_t fcall_end_handler;
op_array_ctor_func_t op_array_ctor;
op_array_dtor_func_t op_array_dtor;
int (*api_no_check)(int api_no);
int (*build_id_check)(const char* build_id);
op_array_persist_calc_func_t op_array_persist_calc;
op_array_persist_func_t op_array_persist;
void *reserved5;
void *reserved6;
void *reserved7;
void *reserved8;
DL_HANDLE handle;
int resource_number;
};
BEGIN_EXTERN_C()
extern ZEND_API int zend_op_array_extension_handles;
ZEND_API int zend_get_resource_handle(const char *module_name);
ZEND_API int zend_get_op_array_extension_handle(const char *module_name);
ZEND_API int zend_get_op_array_extension_handles(const char *module_name, int handles);
ZEND_API void zend_extension_dispatch_message(int message, void *arg);
END_EXTERN_C()
#define ZEND_EXTMSG_NEW_EXTENSION 1
#define ZEND_EXTENSION() \
ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_EXTENSION_BUILD_ID }
#define STANDARD_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
#define COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
#define BUILD_COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
ZEND_API extern zend_llist zend_extensions;
ZEND_API extern uint32_t zend_extension_flags;
#define ZEND_EXTENSIONS_HAVE_OP_ARRAY_CTOR (1<<0)
#define ZEND_EXTENSIONS_HAVE_OP_ARRAY_DTOR (1<<1)
#define ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER (1<<2)
#define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST_CALC (1<<3)
#define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST (1<<4)
void zend_extension_dtor(zend_extension *extension);
ZEND_API void zend_append_version_info(const zend_extension *extension);
void zend_startup_extensions_mechanism(void);
void zend_startup_extensions(void);
void zend_shutdown_extensions(void);
ZEND_API size_t zend_internal_run_time_cache_reserved_size(void);
ZEND_API void zend_init_internal_run_time_cache(void);
BEGIN_EXTERN_C()
ZEND_API zend_result zend_load_extension(const char *path);
ZEND_API zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path);
ZEND_API void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
ZEND_API zend_extension *zend_get_extension(const char *extension_name);
ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array);
ZEND_API size_t zend_extensions_op_array_persist(zend_op_array *op_array, void *mem);
END_EXTERN_C()
#endif /* ZEND_EXTENSIONS_H */

View File

@ -0,0 +1,162 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Aaron Piotrowski <aaron@trowski.com> |
| Martin Schröder <m.schroeder2007@gmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_FIBERS_H
#define ZEND_FIBERS_H
#include "zend_API.h"
#include "zend_types.h"
#define ZEND_FIBER_GUARD_PAGES 1
#define ZEND_FIBER_DEFAULT_C_STACK_SIZE (4096 * (((sizeof(void *)) < 8) ? 256 : 512))
#define ZEND_FIBER_VM_STACK_SIZE (1024 * sizeof(zval))
BEGIN_EXTERN_C()
typedef enum {
ZEND_FIBER_STATUS_INIT,
ZEND_FIBER_STATUS_RUNNING,
ZEND_FIBER_STATUS_SUSPENDED,
ZEND_FIBER_STATUS_DEAD,
} zend_fiber_status;
typedef enum {
ZEND_FIBER_FLAG_THREW = 1 << 0,
ZEND_FIBER_FLAG_BAILOUT = 1 << 1,
ZEND_FIBER_FLAG_DESTROYED = 1 << 2,
} zend_fiber_flag;
typedef enum {
ZEND_FIBER_TRANSFER_FLAG_ERROR = 1 << 0,
ZEND_FIBER_TRANSFER_FLAG_BAILOUT = 1 << 1
} zend_fiber_transfer_flag;
void zend_register_fiber_ce(void);
void zend_fiber_init(void);
void zend_fiber_shutdown(void);
extern ZEND_API zend_class_entry *zend_ce_fiber;
typedef struct _zend_fiber_stack zend_fiber_stack;
/* Encapsulates data needed for a context switch. */
typedef struct _zend_fiber_transfer {
/* Fiber that will be switched to / has resumed us. */
zend_fiber_context *context;
/* Value to that should be send to (or was received from) a fiber. */
zval value;
/* Bitmask of flags defined in enum zend_fiber_transfer_flag. */
uint8_t flags;
} zend_fiber_transfer;
/* Coroutine functions must populate the given transfer with a new context
* and (optional) data before they return. */
typedef void (*zend_fiber_coroutine)(zend_fiber_transfer *transfer);
typedef void (*zend_fiber_clean)(zend_fiber_context *context);
struct _zend_fiber_context {
/* Pointer to boost.context or ucontext_t data. */
void *handle;
/* Pointer that identifies the fiber type. */
void *kind;
/* Entrypoint function of the fiber. */
zend_fiber_coroutine function;
/* Cleanup function for fiber. */
zend_fiber_clean cleanup;
/* Assigned C stack. */
zend_fiber_stack *stack;
/* Fiber status. */
zend_fiber_status status;
/* Observer state */
zend_execute_data *top_observed_frame;
/* Reserved for extensions */
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
struct _zend_fiber {
/* PHP object handle. */
zend_object std;
/* Flags are defined in enum zend_fiber_flag. */
uint8_t flags;
/* Native C fiber context. */
zend_fiber_context context;
/* Fiber that resumed us. */
zend_fiber_context *caller;
/* Fiber that suspended us. */
zend_fiber_context *previous;
/* Callback and info / cache to be used when fiber is started. */
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
/* Current Zend VM execute data being run by the fiber. */
zend_execute_data *execute_data;
/* Frame on the bottom of the fiber vm stack. */
zend_execute_data *stack_bottom;
/* Active fiber vm stack. */
zend_vm_stack vm_stack;
/* Storage for fiber return value. */
zval result;
};
/* These functions may be used to create custom fiber objects using the bundled fiber switching context. */
ZEND_API zend_result zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size);
ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context);
ZEND_API void zend_fiber_switch_context(zend_fiber_transfer *transfer);
#ifdef ZEND_CHECK_STACK_LIMIT
ZEND_API void* zend_fiber_stack_limit(zend_fiber_stack *stack);
ZEND_API void* zend_fiber_stack_base(zend_fiber_stack *stack);
#endif /* ZEND_CHECK_STACK_LIMIT */
ZEND_API void zend_fiber_switch_block(void);
ZEND_API void zend_fiber_switch_unblock(void);
ZEND_API bool zend_fiber_switch_blocked(void);
END_EXTERN_C()
static zend_always_inline zend_fiber *zend_fiber_from_context(zend_fiber_context *context)
{
ZEND_ASSERT(context->kind == zend_ce_fiber && "Fiber context does not belong to a Zend fiber");
return (zend_fiber *)(((char *) context) - XtOffsetOf(zend_fiber, context));
}
static zend_always_inline zend_fiber_context *zend_fiber_get_context(zend_fiber *fiber)
{
return &fiber->context;
}
#endif

View File

@ -0,0 +1,96 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e82bbc8e81fe98873a9a5697a4b38e63a24379da */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Fiber___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Fiber_start, 0, 0, IS_MIXED, 0)
ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Fiber_resume, 0, 0, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_MIXED, 0, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Fiber_throw, 0, 1, IS_MIXED, 0)
ZEND_ARG_OBJ_INFO(0, exception, Throwable, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Fiber_isStarted, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Fiber_isSuspended arginfo_class_Fiber_isStarted
#define arginfo_class_Fiber_isRunning arginfo_class_Fiber_isStarted
#define arginfo_class_Fiber_isTerminated arginfo_class_Fiber_isStarted
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Fiber_getReturn, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Fiber_getCurrent, 0, 0, Fiber, 1)
ZEND_END_ARG_INFO()
#define arginfo_class_Fiber_suspend arginfo_class_Fiber_resume
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FiberError___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_METHOD(Fiber, __construct);
ZEND_METHOD(Fiber, start);
ZEND_METHOD(Fiber, resume);
ZEND_METHOD(Fiber, throw);
ZEND_METHOD(Fiber, isStarted);
ZEND_METHOD(Fiber, isSuspended);
ZEND_METHOD(Fiber, isRunning);
ZEND_METHOD(Fiber, isTerminated);
ZEND_METHOD(Fiber, getReturn);
ZEND_METHOD(Fiber, getCurrent);
ZEND_METHOD(Fiber, suspend);
ZEND_METHOD(FiberError, __construct);
static const zend_function_entry class_Fiber_methods[] = {
ZEND_ME(Fiber, __construct, arginfo_class_Fiber___construct, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, start, arginfo_class_Fiber_start, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, resume, arginfo_class_Fiber_resume, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, throw, arginfo_class_Fiber_throw, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, isStarted, arginfo_class_Fiber_isStarted, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, isSuspended, arginfo_class_Fiber_isSuspended, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, isRunning, arginfo_class_Fiber_isRunning, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, isTerminated, arginfo_class_Fiber_isTerminated, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, getReturn, arginfo_class_Fiber_getReturn, ZEND_ACC_PUBLIC)
ZEND_ME(Fiber, getCurrent, arginfo_class_Fiber_getCurrent, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(Fiber, suspend, arginfo_class_Fiber_suspend, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END
};
static const zend_function_entry class_FiberError_methods[] = {
ZEND_ME(FiberError, __construct, arginfo_class_FiberError___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static zend_class_entry *register_class_Fiber(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Fiber", class_Fiber_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
return class_entry;
}
static zend_class_entry *register_class_FiberError(zend_class_entry *class_entry_Error)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "FiberError", class_FiberError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
class_entry->ce_flags |= ZEND_ACC_FINAL;
return class_entry;
}

View File

@ -0,0 +1,415 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Christian Seiler <chris_se@gmx.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_FLOAT_H
#define ZEND_FLOAT_H
BEGIN_EXTERN_C()
/*
Define functions for FP initialization and de-initialization.
*/
extern ZEND_API void zend_init_fpu(void);
extern ZEND_API void zend_shutdown_fpu(void);
extern ZEND_API void zend_ensure_fpu_mode(void);
END_EXTERN_C()
/* Copy of the contents of xpfpa.h (which is under public domain)
See http://wiki.php.net/rfc/rounding for details.
Cross Platform Floating Point Arithmetics
This header file defines several platform-dependent macros that ensure
equal and deterministic floating point behaviour across several platforms,
compilers and architectures.
The current macros are currently only used on x86 and x86_64 architectures,
on every other architecture, these macros expand to NOPs. This assumes that
other architectures do not have an internal precision and the operhand types
define the computational precision of floating point operations. This
assumption may be false, in that case, the author is interested in further
details on the other platform.
For further details, please visit:
http://www.christian-seiler.de/projekte/fpmath/
Version: 20090317 */
/*
Implementation notes:
x86_64:
- Since all x86_64 compilers use SSE by default, we do not define these
macros there. We ignore the compiler option -mfpmath=i387, because there is
no reason to use it on x86_64.
General:
- It would be nice if one could detect whether SSE if used for math via some
funky compiler defines and if so, make the macros go to NOPs. Any ideas
on how to do that?
MS Visual C:
- Since MSVC users typically don't use autoconf or CMake, we will detect
MSVC via compile time define.
*/
/* MSVC detection (MSVC people usually don't use autoconf) */
#if defined(_MSC_VER) && !defined(_WIN64)
# define HAVE__CONTROLFP_S
#endif /* _MSC_VER */
#if defined(HAVE__CONTROLFP_S) && !defined(__x86_64__)
/* float.h defines _controlfp_s */
# include <float.h>
# define XPFPA_HAVE_CW 1
# define XPFPA_CW_DATATYPE \
unsigned int
# define XPFPA_STORE_CW(vptr) do { \
_controlfp_s((unsigned int *)(vptr), 0, 0); \
} while (0)
# define XPFPA_RESTORE_CW(vptr) do { \
unsigned int _xpfpa_fpu_cw; \
_controlfp_s(&_xpfpa_fpu_cw, *((unsigned int *)(vptr)), _MCW_PC); \
} while (0)
# define XPFPA_DECLARE \
unsigned int _xpfpa_fpu_oldcw, _xpfpa_fpu_cw;
# define XPFPA_SWITCH_DOUBLE() do { \
_controlfp_s(&_xpfpa_fpu_cw, 0, 0); \
_xpfpa_fpu_oldcw = _xpfpa_fpu_cw; \
_controlfp_s(&_xpfpa_fpu_cw, _PC_53, _MCW_PC); \
} while (0)
# define XPFPA_SWITCH_SINGLE() do { \
_controlfp_s(&_xpfpa_fpu_cw, 0, 0); \
_xpfpa_fpu_oldcw = _xpfpa_fpu_cw; \
_controlfp_s(&_xpfpa_fpu_cw, _PC_24, _MCW_PC); \
} while (0)
/* NOTE: This only sets internal precision. MSVC does NOT support double-
extended precision! */
# define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
_controlfp_s(&_xpfpa_fpu_cw, 0, 0); \
_xpfpa_fpu_oldcw = _xpfpa_fpu_cw; \
_controlfp_s(&_xpfpa_fpu_cw, _PC_64, _MCW_PC); \
} while (0)
# define XPFPA_RESTORE() \
_controlfp_s(&_xpfpa_fpu_cw, _xpfpa_fpu_oldcw, _MCW_PC)
/* We do NOT use the volatile return trick since _controlfp_s is a function
call and thus FP registers are saved in memory anyway. However, we do use
a variable to ensure that the expression passed into val will be evaluated
*before* switching back contexts. */
# define XPFPA_RETURN_DOUBLE(val) \
do { \
double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_SINGLE(val) \
do { \
float _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
/* This won't work, but we add a macro for it anyway. */
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
do { \
long double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
#elif defined(HAVE__CONTROLFP) && !defined(__x86_64__)
/* float.h defines _controlfp */
# include <float.h>
# define XPFPA_DECLARE \
unsigned int _xpfpa_fpu_oldcw;
# define XPFPA_HAVE_CW 1
# define XPFPA_CW_DATATYPE \
unsigned int
# define XPFPA_STORE_CW(vptr) do { \
*((unsigned int *)(vptr)) = _controlfp(0, 0); \
} while (0)
# define XPFPA_RESTORE_CW(vptr) do { \
_controlfp(*((unsigned int *)(vptr)), _MCW_PC); \
} while (0)
# define XPFPA_SWITCH_DOUBLE() do { \
_xpfpa_fpu_oldcw = _controlfp(0, 0); \
_controlfp(_PC_53, _MCW_PC); \
} while (0)
# define XPFPA_SWITCH_SINGLE() do { \
_xpfpa_fpu_oldcw = _controlfp(0, 0); \
_controlfp(_PC_24, _MCW_PC); \
} while (0)
/* NOTE: This will only work as expected on MinGW. */
# define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
_xpfpa_fpu_oldcw = _controlfp(0, 0); \
_controlfp(_PC_64, _MCW_PC); \
} while (0)
# define XPFPA_RESTORE() \
_controlfp(_xpfpa_fpu_oldcw, _MCW_PC)
/* We do NOT use the volatile return trick since _controlfp is a function
call and thus FP registers are saved in memory anyway. However, we do use
a variable to ensure that the expression passed into val will be evaluated
*before* switching back contexts. */
# define XPFPA_RETURN_DOUBLE(val) \
do { \
double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_SINGLE(val) \
do { \
float _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
/* This will only work on MinGW */
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
do { \
long double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
#elif defined(HAVE__FPU_SETCW) && !defined(__x86_64__) /* glibc systems */
/* fpu_control.h defines _FPU_[GS]ETCW */
# include <fpu_control.h>
# define XPFPA_DECLARE \
fpu_control_t _xpfpa_fpu_oldcw, _xpfpa_fpu_cw;
# define XPFPA_HAVE_CW 1
# define XPFPA_CW_DATATYPE \
fpu_control_t
# define XPFPA_STORE_CW(vptr) do { \
_FPU_GETCW((*((fpu_control_t *)(vptr)))); \
} while (0)
# define XPFPA_RESTORE_CW(vptr) do { \
_FPU_SETCW((*((fpu_control_t *)(vptr)))); \
} while (0)
# define XPFPA_SWITCH_DOUBLE() do { \
_FPU_GETCW(_xpfpa_fpu_oldcw); \
_xpfpa_fpu_cw = (_xpfpa_fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_SINGLE) | _FPU_DOUBLE; \
_FPU_SETCW(_xpfpa_fpu_cw); \
} while (0)
# define XPFPA_SWITCH_SINGLE() do { \
_FPU_GETCW(_xpfpa_fpu_oldcw); \
_xpfpa_fpu_cw = (_xpfpa_fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_DOUBLE) | _FPU_SINGLE; \
_FPU_SETCW(_xpfpa_fpu_cw); \
} while (0)
# define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
_FPU_GETCW(_xpfpa_fpu_oldcw); \
_xpfpa_fpu_cw = (_xpfpa_fpu_oldcw & ~_FPU_SINGLE & ~_FPU_DOUBLE) | _FPU_EXTENDED; \
_FPU_SETCW(_xpfpa_fpu_cw); \
} while (0)
# define XPFPA_RESTORE() \
_FPU_SETCW(_xpfpa_fpu_oldcw)
/* We use a temporary volatile variable (in a new block) in order to ensure
that the optimizer does not mis-optimize the instructions. Also, a volatile
variable ensures truncation to correct precision. */
# define XPFPA_RETURN_DOUBLE(val) \
do { \
volatile double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_SINGLE(val) \
do { \
volatile float _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
do { \
volatile long double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
#elif defined(HAVE_FPSETPREC) && !defined(__x86_64__) /* FreeBSD */
/* fpu_control.h defines _FPU_[GS]ETCW */
# include <machine/ieeefp.h>
# define XPFPA_DECLARE \
fp_prec_t _xpfpa_fpu_oldprec;
# define XPFPA_HAVE_CW 1
# define XPFPA_CW_DATATYPE \
fp_prec_t
# define XPFPA_STORE_CW(vptr) do { \
*((fp_prec_t *)(vptr)) = fpgetprec(); \
} while (0)
# define XPFPA_RESTORE_CW(vptr) do { \
fpsetprec(*((fp_prec_t *)(vptr))); \
} while (0)
# define XPFPA_SWITCH_DOUBLE() do { \
_xpfpa_fpu_oldprec = fpgetprec(); \
fpsetprec(FP_PD); \
} while (0)
# define XPFPA_SWITCH_SINGLE() do { \
_xpfpa_fpu_oldprec = fpgetprec(); \
fpsetprec(FP_PS); \
} while (0)
# define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
_xpfpa_fpu_oldprec = fpgetprec(); \
fpsetprec(FP_PE); \
} while (0)
# define XPFPA_RESTORE() \
fpsetprec(_xpfpa_fpu_oldprec)
/* We use a temporary volatile variable (in a new block) in order to ensure
that the optimizer does not mis-optimize the instructions. Also, a volatile
variable ensures truncation to correct precision. */
# define XPFPA_RETURN_DOUBLE(val) \
do { \
volatile double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_SINGLE(val) \
do { \
volatile float _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
do { \
volatile long double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
#elif defined(HAVE_FPU_INLINE_ASM_X86) && !defined(__x86_64__)
/*
Custom x86 inline assembler implementation.
This implementation does not use predefined wrappers of the OS / compiler
but rather uses x86/x87 inline assembler directly. Basic instructions:
fnstcw - Store the FPU control word in a variable
fldcw - Load the FPU control word from a variable
Bits (only bits 8 and 9 are relevant, bits 0 to 7 are for other things):
0x0yy: Single precision
0x1yy: Reserved
0x2yy: Double precision
0x3yy: Double-extended precision
We use an unsigned int for the datatype. glibc sources add __mode__ (__HI__)
attribute to it (HI stands for half-integer according to docs). It is unclear
what the does exactly and how portable it is.
The assembly syntax works with GNU CC, Intel CC and Sun CC.
*/
# define XPFPA_DECLARE \
unsigned int _xpfpa_fpu_oldcw, _xpfpa_fpu_cw;
# define XPFPA_HAVE_CW 1
# define XPFPA_CW_DATATYPE \
unsigned int
# define XPFPA_STORE_CW(vptr) do { \
__asm__ __volatile__ ("fnstcw %0" : "=m" (*((unsigned int *)(vptr)))); \
} while (0)
# define XPFPA_RESTORE_CW(vptr) do { \
__asm__ __volatile__ ("fldcw %0" : : "m" (*((unsigned int *)(vptr)))); \
} while (0)
# define XPFPA_SWITCH_DOUBLE() do { \
__asm__ __volatile__ ("fnstcw %0" : "=m" (*&_xpfpa_fpu_oldcw)); \
_xpfpa_fpu_cw = (_xpfpa_fpu_oldcw & ~0x100) | 0x200; \
__asm__ __volatile__ ("fldcw %0" : : "m" (*&_xpfpa_fpu_cw)); \
} while (0)
# define XPFPA_SWITCH_SINGLE() do { \
__asm__ __volatile__ ("fnstcw %0" : "=m" (*&_xpfpa_fpu_oldcw)); \
_xpfpa_fpu_cw = (_xpfpa_fpu_oldcw & ~0x300); \
__asm__ __volatile__ ("fldcw %0" : : "m" (*&_xpfpa_fpu_cw)); \
} while (0)
# define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
__asm__ __volatile__ ("fnstcw %0" : "=m" (*&_xpfpa_fpu_oldcw)); \
_xpfpa_fpu_cw = _xpfpa_fpu_oldcw | 0x300; \
__asm__ __volatile__ ("fldcw %0" : : "m" (*&_xpfpa_fpu_cw)); \
} while (0)
# define XPFPA_RESTORE() \
__asm__ __volatile__ ("fldcw %0" : : "m" (*&_xpfpa_fpu_oldcw))
/* We use a temporary volatile variable (in a new block) in order to ensure
that the optimizer does not mis-optimize the instructions. Also, a volatile
variable ensures truncation to correct precision. */
# define XPFPA_RETURN_DOUBLE(val) \
do { \
volatile double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_SINGLE(val) \
do { \
volatile float _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
do { \
volatile long double _xpfpa_result = (val); \
XPFPA_RESTORE(); \
return _xpfpa_result; \
} while (0)
#else /* FPU CONTROL */
/*
This is either not an x87 FPU or the inline assembly syntax was not
recognized. In any case, default to NOPs for the macros and hope the
generated code will behave as planned.
*/
# define XPFPA_DECLARE /* NOP */
# define XPFPA_HAVE_CW 0
# define XPFPA_CW_DATATYPE unsigned int
# define XPFPA_STORE_CW(variable) /* NOP */
# define XPFPA_RESTORE_CW(variable) /* NOP */
# define XPFPA_SWITCH_DOUBLE() /* NOP */
# define XPFPA_SWITCH_SINGLE() /* NOP */
# define XPFPA_SWITCH_DOUBLE_EXTENDED() /* NOP */
# define XPFPA_RESTORE() /* NOP */
# define XPFPA_RETURN_DOUBLE(val) return (val)
# define XPFPA_RETURN_SINGLE(val) return (val)
# define XPFPA_RETURN_DOUBLE_EXTENDED(val) return (val)
#endif /* FPU CONTROL */
#endif

160
include/php/Zend/zend_gc.h Normal file
View File

@ -0,0 +1,160 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: David Wang <planetbeing@gmail.com> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_GC_H
#define ZEND_GC_H
#include "zend_hrtime.h"
#ifndef GC_BENCH
# define GC_BENCH 0
#endif
BEGIN_EXTERN_C()
typedef struct _zend_gc_status {
bool active;
bool gc_protected;
bool full;
uint32_t runs;
uint32_t collected;
uint32_t threshold;
uint32_t buf_size;
uint32_t num_roots;
zend_hrtime_t application_time;
zend_hrtime_t collector_time;
zend_hrtime_t dtor_time;
zend_hrtime_t free_time;
} zend_gc_status;
ZEND_API extern int (*gc_collect_cycles)(void);
ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref);
ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref);
/* enable/disable automatic start of GC collection */
ZEND_API bool gc_enable(bool enable);
ZEND_API bool gc_enabled(void);
/* enable/disable possible root additions */
ZEND_API bool gc_protect(bool protect);
ZEND_API bool gc_protected(void);
#if GC_BENCH
void gc_bench_print(void);
#endif
/* The default implementation of the gc_collect_cycles callback. */
ZEND_API int zend_gc_collect_cycles(void);
ZEND_API void zend_gc_get_status(zend_gc_status *status);
void gc_globals_ctor(void);
void gc_globals_dtor(void);
void gc_reset(void);
#ifdef ZTS
size_t zend_gc_globals_size(void);
#endif
#define GC_REMOVE_FROM_BUFFER(p) do { \
zend_refcounted *_p = (zend_refcounted*)(p); \
if (GC_TYPE_INFO(_p) & GC_INFO_MASK) { \
gc_remove_from_buffer(_p); \
} \
} while (0)
#define GC_MAY_LEAK(ref) \
((GC_TYPE_INFO(ref) & \
(GC_INFO_MASK | (GC_NOT_COLLECTABLE << GC_FLAGS_SHIFT))) == 0)
static zend_always_inline void gc_check_possible_root(zend_refcounted *ref)
{
if (EXPECTED(GC_TYPE_INFO(ref) == GC_REFERENCE)) {
zval *zv = &((zend_reference*)ref)->val;
if (!Z_COLLECTABLE_P(zv)) {
return;
}
ref = Z_COUNTED_P(zv);
}
if (UNEXPECTED(GC_MAY_LEAK(ref))) {
gc_possible_root(ref);
}
}
static zend_always_inline void gc_check_possible_root_no_ref(zend_refcounted *ref)
{
ZEND_ASSERT(GC_TYPE_INFO(ref) != GC_REFERENCE);
if (UNEXPECTED(GC_MAY_LEAK(ref))) {
gc_possible_root(ref);
}
}
/* These APIs can be used to simplify object get_gc implementations
* over heterogeneous structures. See zend_generator_get_gc() for
* a usage example. */
typedef struct {
zval *cur;
zval *end;
zval *start;
} zend_get_gc_buffer;
ZEND_API zend_get_gc_buffer *zend_get_gc_buffer_create(void);
ZEND_API void zend_get_gc_buffer_grow(zend_get_gc_buffer *gc_buffer);
static zend_always_inline void zend_get_gc_buffer_add_zval(
zend_get_gc_buffer *gc_buffer, zval *zv) {
if (Z_REFCOUNTED_P(zv)) {
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
zend_get_gc_buffer_grow(gc_buffer);
}
ZVAL_COPY_VALUE(gc_buffer->cur, zv);
gc_buffer->cur++;
}
}
static zend_always_inline void zend_get_gc_buffer_add_obj(
zend_get_gc_buffer *gc_buffer, zend_object *obj) {
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
zend_get_gc_buffer_grow(gc_buffer);
}
ZVAL_OBJ(gc_buffer->cur, obj);
gc_buffer->cur++;
}
static zend_always_inline void zend_get_gc_buffer_add_ptr(
zend_get_gc_buffer *gc_buffer, void *ptr) {
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
zend_get_gc_buffer_grow(gc_buffer);
}
ZVAL_PTR(gc_buffer->cur, ptr);
gc_buffer->cur++;
}
static zend_always_inline void zend_get_gc_buffer_use(
zend_get_gc_buffer *gc_buffer, zval **table, int *n) {
*table = gc_buffer->start;
*n = gc_buffer->cur - gc_buffer->start;
}
END_EXTERN_C()
#endif /* ZEND_GC_H */

View File

@ -0,0 +1,27 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@zend.com> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_GDB
#define ZEND_GDB
ZEND_API bool zend_gdb_register_code(const void *object, size_t size);
ZEND_API void zend_gdb_unregister_all(void);
ZEND_API bool zend_gdb_present(void);
#endif

View File

@ -0,0 +1,133 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Nikita Popov <nikic@php.net> |
| Bob Weinand <bobwei9@hotmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_GENERATORS_H
#define ZEND_GENERATORS_H
#include <stdint.h>
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_generator;
extern ZEND_API zend_class_entry *zend_ce_ClosedGeneratorException;
typedef struct _zend_generator_node zend_generator_node;
typedef struct _zend_generator zend_generator;
/* The concept of `yield from` exposes problems when accessed at different levels of the chain of delegated generators. We need to be able to reference the currently executed Generator in all cases and still being able to access the return values of finished Generators.
* The solution to this problem is a doubly-linked tree, which all Generators referenced in maintain a reference to. It should be impossible to avoid walking the tree in all cases. This way, we only need tree walks from leaf to root in case where some part of the `yield from` chain is passed to another `yield from`. (Update of leaf node pointer and list of multi-children nodes needed when leaf gets a child in direct path from leaf to root node.) But only in that case, which should be a fairly rare case (which is then possible, but not totally cheap).
* The root of the tree is then the currently executed Generator. The subnodes of the tree (all except the root node) are all Generators which do `yield from`. Each node of the tree knows a pointer to one leaf descendant node. Each node with multiple children needs a list of all leaf descendant nodes paired with pointers to their respective child node. (The stack is determined by leaf node pointers) Nodes with only one child just don't need a list, there it is enough to just have a pointer to the child node. Further, leaf nodes store a pointer to the root node.
* That way, when we advance any generator, we just need to look up a leaf node (which all have a reference to a root node). Then we can see at the root node whether current Generator is finished. If it isn't, all is fine and we can just continue. If the Generator finished, there will be two cases. Either it is a simple node with just one child, then go down to child node. Or it has multiple children and we now will remove the current leaf node from the list of nodes (unnecessary, is microoptimization) and go down to the child node whose reference was paired with current leaf node. Child node is then removed its parent reference and becomes new top node. Or the current node references the Generator we're currently executing, then we can continue from the YIELD_FROM opcode. When a node referenced as root node in a leaf node has a parent, then we go the way up until we find a root node without parent.
* In case we go into a new `yield from` level, a node is created on top of current root and becomes the new root. Leaf node needs to be updated with new root node then.
* When a Generator referenced by a node of the tree is added to `yield from`, that node now gets a list of children (we need to walk the descendants of that node and nodes of the tree of the other Generator down to the first multi-children node and copy all the leaf node pointers from there). In case there was no multi-children node (linear tree), we just add a pair (pointer to leaf node, pointer to child node), with the child node being in a direct path from leaf to this node.
*/
struct _zend_generator_node {
zend_generator *parent; /* NULL for root */
uint32_t children;
union {
HashTable *ht; /* if multiple children */
zend_generator *single; /* if one child */
} child;
/* One generator can cache a direct pointer to the current root.
* The leaf member points back to the generator using the root cache. */
union {
zend_generator *leaf; /* if parent != NULL */
zend_generator *root; /* if parent == NULL */
} ptr;
};
struct _zend_generator {
zend_object std;
/* The suspended execution context. */
zend_execute_data *execute_data;
/* Frozen call stack for "yield" used in context of other calls */
zend_execute_data *frozen_call_stack;
/* Current value */
zval value;
/* Current key */
zval key;
/* Return value */
zval retval;
/* Variable to put sent value into */
zval *send_target;
/* Largest used integer key for auto-incrementing keys */
zend_long largest_used_integer_key;
/* Values specified by "yield from" to yield from this generator.
* This is only used for arrays or non-generator Traversables.
* This zval also uses the u2 structure in the same way as
* by-value foreach. */
zval values;
/* Node of waiting generators when multiple "yield from" expressions
* are nested. */
zend_generator_node node;
/* Fake execute_data for stacktraces */
zend_execute_data execute_fake;
/* ZEND_GENERATOR_* flags */
uint8_t flags;
};
static const uint8_t ZEND_GENERATOR_CURRENTLY_RUNNING = 0x1;
static const uint8_t ZEND_GENERATOR_FORCED_CLOSE = 0x2;
static const uint8_t ZEND_GENERATOR_AT_FIRST_YIELD = 0x4;
static const uint8_t ZEND_GENERATOR_DO_INIT = 0x8;
static const uint8_t ZEND_GENERATOR_IN_FIBER = 0x10;
void zend_register_generator_ce(void);
ZEND_API void zend_generator_close(zend_generator *generator, bool finished_execution);
ZEND_API void zend_generator_resume(zend_generator *generator);
ZEND_API void zend_generator_restore_call_stack(zend_generator *generator);
ZEND_API zend_execute_data* zend_generator_freeze_call_stack(zend_execute_data *execute_data);
void zend_generator_yield_from(zend_generator *generator, zend_generator *from);
ZEND_API zend_execute_data *zend_generator_check_placeholder_frame(zend_execute_data *ptr);
ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator);
ZEND_API zend_generator *zend_generator_update_root(zend_generator *generator);
static zend_always_inline zend_generator *zend_generator_get_current(zend_generator *generator)
{
if (EXPECTED(generator->node.parent == NULL)) {
/* we're not in yield from mode */
return generator;
}
zend_generator *root = generator->node.ptr.root;
if (!root) {
root = zend_generator_update_root(generator);
}
if (EXPECTED(root->execute_data)) {
/* generator still running */
return root;
}
return zend_generator_update_current(generator);
}
END_EXTERN_C()
#endif

View File

@ -0,0 +1,75 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 0af5e8985dd4645bf23490b8cec312f8fd1fee2e */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_rewind, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_valid, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_current, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Generator_key arginfo_class_Generator_current
#define arginfo_class_Generator_next arginfo_class_Generator_rewind
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_send, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Generator_throw, 0, 1, IS_MIXED, 0)
ZEND_ARG_OBJ_INFO(0, exception, Throwable, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Generator_getReturn arginfo_class_Generator_current
ZEND_METHOD(Generator, rewind);
ZEND_METHOD(Generator, valid);
ZEND_METHOD(Generator, current);
ZEND_METHOD(Generator, key);
ZEND_METHOD(Generator, next);
ZEND_METHOD(Generator, send);
ZEND_METHOD(Generator, throw);
ZEND_METHOD(Generator, getReturn);
static const zend_function_entry class_Generator_methods[] = {
ZEND_ME(Generator, rewind, arginfo_class_Generator_rewind, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, valid, arginfo_class_Generator_valid, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, current, arginfo_class_Generator_current, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, key, arginfo_class_Generator_key, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, next, arginfo_class_Generator_next, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, send, arginfo_class_Generator_send, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, throw, arginfo_class_Generator_throw, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, getReturn, arginfo_class_Generator_getReturn, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ClosedGeneratorException_methods[] = {
ZEND_FE_END
};
static zend_class_entry *register_class_Generator(zend_class_entry *class_entry_Iterator)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Generator", class_Generator_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
zend_class_implements(class_entry, 1, class_entry_Iterator);
return class_entry;
}
static zend_class_entry *register_class_ClosedGeneratorException(zend_class_entry *class_entry_Exception)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ClosedGeneratorException", class_ClosedGeneratorException_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
return class_entry;
}

View File

@ -0,0 +1,382 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
#include <setjmp.h>
#include <stdint.h>
#include <sys/types.h>
#include "zend_globals_macros.h"
#include "zend_atomic.h"
#include "zend_stack.h"
#include "zend_ptr_stack.h"
#include "zend_hash.h"
#include "zend_llist.h"
#include "zend_objects.h"
#include "zend_objects_API.h"
#include "zend_modules.h"
#include "zend_float.h"
#include "zend_multibyte.h"
#include "zend_multiply.h"
#include "zend_arena.h"
#include "zend_call_stack.h"
#include "zend_max_execution_timer.h"
/* Define ZTS if you want a thread-safe Zend */
/*#undef ZTS*/
#ifdef ZTS
BEGIN_EXTERN_C()
ZEND_API extern int compiler_globals_id;
ZEND_API extern int executor_globals_id;
ZEND_API extern size_t compiler_globals_offset;
ZEND_API extern size_t executor_globals_offset;
END_EXTERN_C()
#endif
#define SYMTABLE_CACHE_SIZE 32
#ifdef ZEND_CHECK_STACK_LIMIT
# define ZEND_MAX_ALLOWED_STACK_SIZE_UNCHECKED -1
# define ZEND_MAX_ALLOWED_STACK_SIZE_DETECT 0
#endif
#include "zend_compile.h"
/* excpt.h on Digital Unix 4.0 defines function_table */
#undef function_table
typedef struct _zend_vm_stack *zend_vm_stack;
typedef struct _zend_ini_entry zend_ini_entry;
typedef struct _zend_fiber_context zend_fiber_context;
typedef struct _zend_fiber zend_fiber;
typedef enum {
ZEND_MEMOIZE_NONE,
ZEND_MEMOIZE_COMPILE,
ZEND_MEMOIZE_FETCH,
} zend_memoize_mode;
struct _zend_compiler_globals {
zend_stack loop_var_stack;
zend_class_entry *active_class_entry;
zend_string *compiled_filename;
int zend_lineno;
zend_op_array *active_op_array;
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable *auto_globals;
/* Refer to zend_yytnamerr() in zend_language_parser.y for meaning of values */
uint8_t parse_error;
bool in_compilation;
bool short_tags;
bool unclean_shutdown;
bool ini_parser_unbuffered_errors;
zend_llist open_files;
struct _zend_ini_parser_param *ini_parser_param;
bool skip_shebang;
bool increment_lineno;
bool variable_width_locale; /* UTF-8, Shift-JIS, Big5, ISO 2022, EUC, etc */
bool ascii_compatible_locale; /* locale uses ASCII characters as singletons */
/* and don't use them as lead/trail units */
zend_string *doc_comment;
uint32_t extra_fn_flags;
uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */
zend_oparray_context context;
zend_file_context file_context;
zend_arena *arena;
HashTable interned_strings;
const zend_encoding **script_encoding_list;
size_t script_encoding_list_size;
bool multibyte;
bool detect_unicode;
bool encoding_declared;
zend_ast *ast;
zend_arena *ast_arena;
zend_stack delayed_oplines_stack;
HashTable *memoized_exprs;
zend_memoize_mode memoize_mode;
void *map_ptr_real_base;
void *map_ptr_base;
size_t map_ptr_size;
size_t map_ptr_last;
HashTable *delayed_variance_obligations;
HashTable *delayed_autoloads;
HashTable *unlinked_uses;
zend_class_entry *current_linking_class;
uint32_t rtd_key_counter;
zend_stack short_circuiting_opnums;
#ifdef ZTS
uint32_t copied_functions_count;
#endif
};
struct _zend_executor_globals {
zval uninitialized_zval;
zval error_zval;
/* symbol table cache */
zend_array *symtable_cache[SYMTABLE_CACHE_SIZE];
/* Pointer to one past the end of the symtable_cache */
zend_array **symtable_cache_limit;
/* Pointer to first unused symtable_cache slot */
zend_array **symtable_cache_ptr;
zend_array symbol_table; /* main symbol table */
HashTable included_files; /* files already included */
JMP_BUF *bailout;
int error_reporting;
int exit_status;
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable *zend_constants; /* constants table */
zval *vm_stack_top;
zval *vm_stack_end;
zend_vm_stack vm_stack;
size_t vm_stack_page_size;
struct _zend_execute_data *current_execute_data;
zend_class_entry *fake_scope; /* used to avoid checks accessing properties */
uint32_t jit_trace_num; /* Used by tracing JIT to reference the currently running trace */
int ticks_count;
zend_long precision;
uint32_t persistent_constants_count;
uint32_t persistent_functions_count;
uint32_t persistent_classes_count;
/* for extended information support */
bool no_extensions;
bool full_tables_cleanup;
zend_atomic_bool vm_interrupt;
zend_atomic_bool timed_out;
HashTable *in_autoload;
zend_long hard_timeout;
void *stack_base;
void *stack_limit;
#ifdef ZEND_WIN32
OSVERSIONINFOEX windows_version_info;
#endif
HashTable regular_list;
HashTable persistent_list;
int user_error_handler_error_reporting;
bool exception_ignore_args;
zval user_error_handler;
zval user_exception_handler;
zend_stack user_error_handlers_error_reporting;
zend_stack user_error_handlers;
zend_stack user_exception_handlers;
zend_class_entry *exception_class;
zend_error_handling_t error_handling;
int capture_warnings_during_sccp;
/* timeout support */
zend_long timeout_seconds;
HashTable *ini_directives;
HashTable *modified_ini_directives;
zend_ini_entry *error_reporting_ini_entry;
zend_objects_store objects_store;
zend_object *exception, *prev_exception;
const zend_op *opline_before_exception;
zend_op exception_op[3];
struct _zend_module_entry *current_module;
bool active;
uint8_t flags;
zend_long assertions;
uint32_t ht_iterators_count; /* number of allocated slots */
uint32_t ht_iterators_used; /* number of used slots */
HashTableIterator *ht_iterators;
HashTableIterator ht_iterators_slots[16];
void *saved_fpu_cw_ptr;
#if XPFPA_HAVE_CW
XPFPA_CW_DATATYPE saved_fpu_cw;
#endif
zend_function trampoline;
zend_op call_trampoline_op;
HashTable weakrefs;
zend_long exception_string_param_max_len;
zend_get_gc_buffer get_gc_buffer;
zend_fiber_context *main_fiber_context;
zend_fiber_context *current_fiber_context;
/* Active instance of Fiber. */
zend_fiber *active_fiber;
/* Default fiber C stack size. */
size_t fiber_stack_size;
/* If record_errors is enabled, all emitted diagnostics will be recorded,
* in addition to being processed as usual. */
bool record_errors;
uint32_t num_errors;
zend_error_info **errors;
/* Override filename or line number of thrown errors and exceptions */
zend_string *filename_override;
zend_long lineno_override;
#ifdef ZEND_CHECK_STACK_LIMIT
zend_call_stack call_stack;
zend_long max_allowed_stack_size;
zend_ulong reserved_stack_size;
#endif
#ifdef ZEND_MAX_EXECUTION_TIMERS
timer_t max_execution_timer_timer;
pid_t pid;
struct sigaction oldact;
#endif
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
#define EG_FLAGS_INITIAL (0)
#define EG_FLAGS_IN_SHUTDOWN (1<<0)
#define EG_FLAGS_OBJECT_STORE_NO_REUSE (1<<1)
#define EG_FLAGS_IN_RESOURCE_SHUTDOWN (1<<2)
struct _zend_ini_scanner_globals {
zend_file_handle *yy_in;
zend_file_handle *yy_out;
unsigned int yy_leng;
const unsigned char *yy_start;
const unsigned char *yy_text;
const unsigned char *yy_cursor;
const unsigned char *yy_marker;
const unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
zend_string *filename;
int lineno;
/* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW, ZEND_INI_SCANNER_TYPED */
int scanner_mode;
};
typedef enum {
ON_TOKEN,
ON_FEEDBACK,
ON_STOP
} zend_php_scanner_event;
struct _zend_php_scanner_globals {
zend_file_handle *yy_in;
zend_file_handle *yy_out;
unsigned int yy_leng;
unsigned char *yy_start;
unsigned char *yy_text;
unsigned char *yy_cursor;
unsigned char *yy_marker;
unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
zend_ptr_stack heredoc_label_stack;
zend_stack nest_location_stack; /* for syntax error reporting */
bool heredoc_scan_ahead;
int heredoc_indentation;
bool heredoc_indentation_uses_spaces;
/* original (unfiltered) script */
unsigned char *script_org;
size_t script_org_size;
/* filtered script */
unsigned char *script_filtered;
size_t script_filtered_size;
/* input/output filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
const zend_encoding *script_encoding;
/* initial string length after scanning to first variable */
int scanned_string_len;
/* hooks */
void (*on_event)(
zend_php_scanner_event event, int token, int line,
const char *text, size_t length, void *context);
void *on_event_context;
};
#endif /* ZEND_GLOBALS_H */

View File

@ -0,0 +1,71 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_GLOBALS_MACROS_H
#define ZEND_GLOBALS_MACROS_H
typedef struct _zend_compiler_globals zend_compiler_globals;
typedef struct _zend_executor_globals zend_executor_globals;
typedef struct _zend_php_scanner_globals zend_php_scanner_globals;
typedef struct _zend_ini_scanner_globals zend_ini_scanner_globals;
BEGIN_EXTERN_C()
/* Compiler */
#ifdef ZTS
# define CG(v) ZEND_TSRMG_FAST(compiler_globals_offset, zend_compiler_globals *, v)
#else
# define CG(v) (compiler_globals.v)
extern ZEND_API struct _zend_compiler_globals compiler_globals;
#endif
ZEND_API int zendparse(void);
/* Executor */
#ifdef ZTS
# define EG(v) ZEND_TSRMG_FAST(executor_globals_offset, zend_executor_globals *, v)
#else
# define EG(v) (executor_globals.v)
extern ZEND_API zend_executor_globals executor_globals;
#endif
/* Language Scanner */
#ifdef ZTS
# define LANG_SCNG(v) ZEND_TSRMG_FAST(language_scanner_globals_offset, zend_php_scanner_globals *, v)
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
extern ZEND_API size_t language_scanner_globals_offset;
#else
# define LANG_SCNG(v) (language_scanner_globals.v)
extern ZEND_API zend_php_scanner_globals language_scanner_globals;
#endif
/* INI Scanner */
#ifdef ZTS
# define INI_SCNG(v) ZEND_TSRMG_FAST(ini_scanner_globals_offset, zend_ini_scanner_globals *, v)
extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
extern ZEND_API size_t ini_scanner_globals_offset;
#else
# define INI_SCNG(v) (ini_scanner_globals.v)
extern ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#endif
END_EXTERN_C()
#endif /* ZEND_GLOBALS_MACROS_H */

1677
include/php/Zend/zend_hash.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_HIGHLIGHT_H
#define ZEND_HIGHLIGHT_H
#define HL_COMMENT_COLOR "#FF8000" /* orange */
#define HL_DEFAULT_COLOR "#0000BB" /* blue */
#define HL_HTML_COLOR "#000000" /* black */
#define HL_STRING_COLOR "#DD0000" /* red */
#define HL_KEYWORD_COLOR "#007700" /* green */
typedef struct _zend_syntax_highlighter_ini {
char *highlight_html;
char *highlight_comment;
char *highlight_default;
char *highlight_string;
char *highlight_keyword;
} zend_syntax_highlighter_ini;
BEGIN_EXTERN_C()
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API void zend_strip(void);
ZEND_API zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name);
ZEND_API void zend_html_putc(char c);
ZEND_API void zend_html_puts(const char *s, size_t len);
END_EXTERN_C()
extern zend_syntax_highlighter_ini syntax_highlighter_ini;
#endif

View File

@ -0,0 +1,107 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Niklas Keller <kelunik@php.net> |
| Author: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_HRTIME_H
#define ZEND_HRTIME_H
#include "zend_portability.h"
#include "zend_types.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef PHP_WIN32
# include <time.h>
#endif
/* This file reuses code parts from the cross-platform timer library
Public Domain - 2011 Mattias Jansson / Rampant Pixels */
#define ZEND_HRTIME_PLATFORM_POSIX 0
#define ZEND_HRTIME_PLATFORM_WINDOWS 0
#define ZEND_HRTIME_PLATFORM_APPLE 0
#define ZEND_HRTIME_PLATFORM_HPUX 0
#define ZEND_HRTIME_PLATFORM_AIX 0
#if defined(_POSIX_TIMERS) && ((_POSIX_TIMERS > 0) || defined(__OpenBSD__)) && defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
# undef ZEND_HRTIME_PLATFORM_POSIX
# define ZEND_HRTIME_PLATFORM_POSIX 1
#elif defined(_WIN32) || defined(_WIN64)
# undef ZEND_HRTIME_PLATFORM_WINDOWS
# define ZEND_HRTIME_PLATFORM_WINDOWS 1
#elif defined(__APPLE__)
# undef ZEND_HRTIME_PLATFORM_APPLE
# define ZEND_HRTIME_PLATFORM_APPLE 1
#elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
# undef ZEND_HRTIME_PLATFORM_HPUX
# define ZEND_HRTIME_PLATFORM_HPUX 1
#elif defined(_AIX)
# undef ZEND_HRTIME_PLATFORM_AIX
# define ZEND_HRTIME_PLATFORM_AIX 1
#endif
#define ZEND_HRTIME_AVAILABLE (ZEND_HRTIME_PLATFORM_POSIX || ZEND_HRTIME_PLATFORM_WINDOWS || ZEND_HRTIME_PLATFORM_APPLE || ZEND_HRTIME_PLATFORM_HPUX || ZEND_HRTIME_PLATFORM_AIX)
BEGIN_EXTERN_C()
#if ZEND_HRTIME_PLATFORM_WINDOWS
extern double zend_hrtime_timer_scale;
#elif ZEND_HRTIME_PLATFORM_APPLE
# include <mach/mach_time.h>
# include <string.h>
extern mach_timebase_info_data_t zend_hrtime_timerlib_info;
#endif
#define ZEND_NANO_IN_SEC UINT64_C(1000000000)
typedef uint64_t zend_hrtime_t;
void zend_startup_hrtime(void);
static zend_always_inline zend_hrtime_t zend_hrtime(void)
{
#if ZEND_HRTIME_PLATFORM_WINDOWS
LARGE_INTEGER lt = {0};
QueryPerformanceCounter(&lt);
return (zend_hrtime_t)((zend_hrtime_t)lt.QuadPart * zend_hrtime_timer_scale);
#elif ZEND_HRTIME_PLATFORM_APPLE
return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom;
#elif ZEND_HRTIME_PLATFORM_POSIX
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC, &ts))) {
return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec;
}
return 0;
#elif ZEND_HRTIME_PLATFORM_HPUX
return (zend_hrtime_t) gethrtime();
#elif ZEND_HRTIME_PLATFORM_AIX
timebasestruct_t t;
read_wall_time(&t, TIMEBASE_SZ);
time_base_to_time(&t, TIMEBASE_SZ);
return (zend_hrtime_t) t.tb_high * (zend_hrtime_t)NANO_IN_SEC + t.tb_low;
#else
return 0;
#endif
}
END_EXTERN_C()
#endif /* ZEND_HRTIME_H */

View File

@ -0,0 +1,47 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_INHERITANCE_H
#define ZEND_INHERITANCE_H
#include "zend.h"
BEGIN_EXTERN_C()
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface);
ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, bool checked);
static zend_always_inline void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce) {
zend_do_inheritance_ex(ce, parent_ce, 0);
}
ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name, zend_string *key);
void zend_verify_abstract_class(zend_class_entry *ce);
void zend_build_properties_info_table(zend_class_entry *ce);
ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_entry *parent_ce, zend_string *lcname, zval *delayed_early_binding);
void zend_inheritance_check_override(zend_class_entry *ce);
ZEND_API extern zend_class_entry* (*zend_inheritance_cache_get)(zend_class_entry *ce, zend_class_entry *parent, zend_class_entry **traits_and_interfaces);
ZEND_API extern zend_class_entry* (*zend_inheritance_cache_add)(zend_class_entry *ce, zend_class_entry *proto, zend_class_entry *parent, zend_class_entry **traits_and_interfaces, HashTable *dependencies);
END_EXTERN_C()
#endif

259
include/php/Zend/zend_ini.h Normal file
View File

@ -0,0 +1,259 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_INI_H
#define ZEND_INI_H
#define ZEND_INI_USER (1<<0)
#define ZEND_INI_PERDIR (1<<1)
#define ZEND_INI_SYSTEM (1<<2)
#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define ZEND_INI_DISP(name) ZEND_COLD void name(zend_ini_entry *ini_entry, int type)
typedef struct _zend_ini_entry_def {
const char *name;
ZEND_INI_MH((*on_modify));
void *mh_arg1;
void *mh_arg2;
void *mh_arg3;
const char *value;
void (*displayer)(zend_ini_entry *ini_entry, int type);
uint32_t value_length;
uint16_t name_length;
uint8_t modifiable;
} zend_ini_entry_def;
struct _zend_ini_entry {
zend_string *name;
ZEND_INI_MH((*on_modify));
void *mh_arg1;
void *mh_arg2;
void *mh_arg3;
zend_string *value;
zend_string *orig_value;
void (*displayer)(zend_ini_entry *ini_entry, int type);
int module_number;
uint8_t modifiable;
uint8_t orig_modifiable;
uint8_t modified;
};
BEGIN_EXTERN_C()
ZEND_API void zend_ini_startup(void);
ZEND_API void zend_ini_shutdown(void);
ZEND_API void zend_ini_global_shutdown(void);
ZEND_API void zend_ini_deactivate(void);
ZEND_API void zend_ini_dtor(HashTable *ini_directives);
ZEND_API void zend_copy_ini_directives(void);
ZEND_API void zend_ini_sort_entries(void);
ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number);
ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int module_number, int module_type);
ZEND_API void zend_unregister_ini_entries(int module_number);
ZEND_API void zend_unregister_ini_entries_ex(int module_number, int module_type);
ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change);
ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change);
ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module);
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig);
ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig);
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, bool *exists);
ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig);
ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool orig, bool *exists);
ZEND_API zend_string *zend_ini_get_value(zend_string *name);
ZEND_API bool zend_ini_parse_bool(zend_string *str);
/**
* Parses an ini quantity
*
* The value parameter must be a string in the form
*
* sign? digits ws* multiplier?
*
* with
*
* sign: [+-]
* digit: [0-9]
* digits: digit+
* ws: [ \t\n\r\v\f]
* multiplier: [KMG]
*
* Leading and trailing whitespaces are ignored.
*
* If the string is empty or consists only of only whitespaces, 0 is returned.
*
* Digits is parsed as decimal unless the first digit is '0', in which case
* digits is parsed as octal.
*
* The multiplier is case-insensitive. K, M, and G multiply the quantity by
* 2**10, 2**20, and 2**30, respectively.
*
* For backwards compatibility, ill-formatted values are handled as follows:
* - No leading digits: value is treated as '0'
* - Invalid multiplier: multiplier is ignored
* - Invalid characters between digits and multiplier: invalid characters are
* ignored
* - Integer overflow: The result of the overflow is returned
*
* In any of these cases an error string is stored in *errstr (caller must
* release it), otherwise *errstr is set to NULL.
*/
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr);
/**
* Unsigned variant of zend_ini_parse_quantity
*/
ZEND_API zend_ulong zend_ini_parse_uquantity(zend_string *value, zend_string **errstr);
ZEND_API zend_long zend_ini_parse_quantity_warn(zend_string *value, zend_string *setting);
ZEND_API zend_ulong zend_ini_parse_uquantity_warn(zend_string *value, zend_string *setting);
ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
ZEND_API ZEND_INI_DISP(display_link_numbers);
END_EXTERN_C()
#define ZEND_INI_BEGIN() static const zend_ini_entry_def ini_entries[] = {
#define ZEND_INI_END() { NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0} };
#define ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, displayer) \
{ name, on_modify, arg1, arg2, arg3, default_value, displayer, sizeof(default_value)-1, sizeof(name)-1, modifiable },
#define ZEND_INI_ENTRY3(name, default_value, modifiable, on_modify, arg1, arg2, arg3) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, NULL)
#define ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL, displayer)
#define ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, arg1, arg2) \
ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL)
#define ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, NULL, NULL, displayer)
#define ZEND_INI_ENTRY1(name, default_value, modifiable, on_modify, arg1) \
ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, NULL)
#define ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, NULL, NULL, NULL, displayer)
#define ZEND_INI_ENTRY(name, default_value, modifiable, on_modify) \
ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, NULL)
#ifdef ZTS
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
#else
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
#endif
#define INI_INT(name) zend_ini_long((name), strlen(name), 0)
#define INI_FLT(name) zend_ini_double((name), strlen(name), 0)
#define INI_STR(name) zend_ini_string_ex((name), strlen(name), 0, NULL)
#define INI_BOOL(name) ((bool) INI_INT(name))
#define INI_ORIG_INT(name) zend_ini_long((name), strlen(name), 1)
#define INI_ORIG_FLT(name) zend_ini_double((name), strlen(name), 1)
#define INI_ORIG_STR(name) zend_ini_string((name), strlen(name), 1)
#define INI_ORIG_BOOL(name) ((bool) INI_ORIG_INT(name))
#define REGISTER_INI_ENTRIES() zend_register_ini_entries_ex(ini_entries, module_number, type)
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries_ex(module_number, type)
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
#define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), strlen(name), displayer)
#define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
/* Standard message handlers */
BEGIN_EXTERN_C()
ZEND_API ZEND_INI_MH(OnUpdateBool);
ZEND_API ZEND_INI_MH(OnUpdateLong);
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
ZEND_API ZEND_INI_MH(OnUpdateReal);
/* char* versions */
ZEND_API ZEND_INI_MH(OnUpdateString);
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
/* zend_string* versions */
ZEND_API ZEND_INI_MH(OnUpdateStr);
ZEND_API ZEND_INI_MH(OnUpdateStrNotEmpty);
END_EXTERN_C()
#define ZEND_INI_DISPLAY_ORIG 1
#define ZEND_INI_DISPLAY_ACTIVE 2
#define ZEND_INI_STAGE_STARTUP (1<<0)
#define ZEND_INI_STAGE_SHUTDOWN (1<<1)
#define ZEND_INI_STAGE_ACTIVATE (1<<2)
#define ZEND_INI_STAGE_DEACTIVATE (1<<3)
#define ZEND_INI_STAGE_RUNTIME (1<<4)
#define ZEND_INI_STAGE_HTACCESS (1<<5)
#define ZEND_INI_STAGE_IN_REQUEST (ZEND_INI_STAGE_ACTIVATE|ZEND_INI_STAGE_DEACTIVATE|ZEND_INI_STAGE_RUNTIME|ZEND_INI_STAGE_HTACCESS)
/* INI parsing engine */
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
BEGIN_EXTERN_C()
ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
ZEND_API zend_result zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
END_EXTERN_C()
/* INI entries */
#define ZEND_INI_PARSER_ENTRY 1 /* Normal entry: foo = bar */
#define ZEND_INI_PARSER_SECTION 2 /* Section: [foobar] */
#define ZEND_INI_PARSER_POP_ENTRY 3 /* Offset entry: foo[] = bar */
typedef struct _zend_ini_parser_param {
zend_ini_parser_cb_t ini_parser_cb;
void *arg;
} zend_ini_parser_param;
#ifndef ZTS
# define ZEND_INI_GET_BASE() ((char *) mh_arg2)
#else
# define ZEND_INI_GET_BASE() ((char *) ts_resource(*((int *) mh_arg2)))
#endif
#define ZEND_INI_GET_ADDR() (ZEND_INI_GET_BASE() + (size_t) mh_arg1)
#endif /* ZEND_INI_H */

View File

@ -0,0 +1,98 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_INI_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_INI_PARSER_H_INCLUDED
# define YY_INI_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_INI_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef INI_DEBUG
# if defined YYDEBUG
#if YYDEBUG
# define INI_DEBUG 1
# else
# define INI_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define INI_DEBUG 0
# endif /* ! defined YYDEBUG */
#endif /* ! defined INI_DEBUG */
#if INI_DEBUG
extern int ini_debug;
#endif
/* Token kinds. */
#ifndef INI_TOKENTYPE
# define INI_TOKENTYPE
enum ini_tokentype
{
INI_EMPTY = -2,
END = 0, /* "end of file" */
INI_error = 256, /* error */
INI_UNDEF = 257, /* "invalid token" */
TC_SECTION = 258, /* TC_SECTION */
TC_RAW = 259, /* TC_RAW */
TC_CONSTANT = 260, /* TC_CONSTANT */
TC_NUMBER = 261, /* TC_NUMBER */
TC_STRING = 262, /* TC_STRING */
TC_WHITESPACE = 263, /* TC_WHITESPACE */
TC_LABEL = 264, /* TC_LABEL */
TC_OFFSET = 265, /* TC_OFFSET */
TC_DOLLAR_CURLY = 266, /* TC_DOLLAR_CURLY */
TC_VARNAME = 267, /* TC_VARNAME */
TC_QUOTED_STRING = 268, /* TC_QUOTED_STRING */
TC_FALLBACK = 269, /* TC_FALLBACK */
BOOL_TRUE = 270, /* BOOL_TRUE */
BOOL_FALSE = 271, /* BOOL_FALSE */
NULL_NULL = 272, /* NULL_NULL */
END_OF_LINE = 273 /* END_OF_LINE */
};
typedef enum ini_tokentype ini_token_kind_t;
#endif
/* Value type. */
#if ! defined INI_STYPE && ! defined INI_STYPE_IS_DECLARED
typedef zval INI_STYPE;
# define INI_STYPE_IS_TRIVIAL 1
# define INI_STYPE_IS_DECLARED 1
#endif
int ini_parse (void);
#endif /* !YY_INI_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_INI_PARSER_H_INCLUDED */

View File

@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef _ZEND_INI_SCANNER_H
#define _ZEND_INI_SCANNER_H
/* Scanner modes */
#define ZEND_INI_SCANNER_NORMAL 0 /* Normal mode. [DEFAULT] */
#define ZEND_INI_SCANNER_RAW 1 /* Raw mode. Option values are not parsed */
#define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */
BEGIN_EXTERN_C()
ZEND_COLD int zend_ini_scanner_get_lineno(void);
ZEND_COLD const char *zend_ini_scanner_get_filename(void);
zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode);
zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode);
int ini_lex(zval *ini_lval);
void shutdown_ini_scanner(void);
END_EXTERN_C()
#endif /* _ZEND_INI_SCANNER_H */

View File

@ -0,0 +1,13 @@
/* Generated by re2c 2.1.1 */
enum YYCONDTYPE {
yycINITIAL,
yycST_OFFSET,
yycST_SECTION_VALUE,
yycST_VALUE,
yycST_SECTION_RAW,
yycST_DOUBLE_QUOTES,
yycST_VAR_FALLBACK,
yycST_VARNAME,
yycST_RAW,
};

View File

@ -0,0 +1,81 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_INTERFACES_H
#define ZEND_INTERFACES_H
#include "zend.h"
#include "zend_API.h"
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_traversable;
extern ZEND_API zend_class_entry *zend_ce_aggregate;
extern ZEND_API zend_class_entry *zend_ce_iterator;
extern ZEND_API zend_class_entry *zend_ce_arrayaccess;
extern ZEND_API zend_class_entry *zend_ce_serializable;
extern ZEND_API zend_class_entry *zend_ce_countable;
extern ZEND_API zend_class_entry *zend_ce_stringable;
typedef struct _zend_user_iterator {
zend_object_iterator it;
zend_class_entry *ce;
zval value;
} zend_user_iterator;
ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, uint32_t param_count, zval* arg1, zval* arg2);
static zend_always_inline zval* zend_call_method_with_0_params(zend_object *object, zend_class_entry *obj_ce,
zend_function **fn_proxy, const char *function_name, zval *retval)
{
return zend_call_method(object, obj_ce, fn_proxy, function_name, strlen(function_name), retval, 0, NULL, NULL);
}
static zend_always_inline zval* zend_call_method_with_1_params(zend_object *object, zend_class_entry *obj_ce,
zend_function **fn_proxy, const char *function_name, zval *retval, zval* arg1)
{
return zend_call_method(object, obj_ce, fn_proxy, function_name, strlen(function_name), retval, 1, arg1, NULL);
}
static zend_always_inline zval* zend_call_method_with_2_params(zend_object *object, zend_class_entry *obj_ce,
zend_function **fn_proxy, const char *function_name, zval *retval, zval* arg1, zval* arg2)
{
return zend_call_method(object, obj_ce, fn_proxy, function_name, strlen(function_name), retval, 2, arg1, arg2);
}
ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter);
ZEND_API zend_result zend_user_it_valid(zend_object_iterator *_iter);
ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key);
ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter);
ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter);
ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter);
ZEND_API HashTable *zend_user_it_get_gc(zend_object_iterator *_iter, zval **table, int *n);
ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *iterator);
ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref);
ZEND_API void zend_register_interfaces(void);
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj);
END_EXTERN_C()
#endif /* ZEND_INTERFACES_H */

View File

@ -0,0 +1,215 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: a9c915c11e5989d8c7cf2d704ada09ca765670c3 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, Traversable, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_current, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_next, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Iterator_key arginfo_class_Iterator_current
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_valid, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Iterator_rewind arginfo_class_Iterator_next
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetExists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetGet, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetSet, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetUnset, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_serialize, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_unserialize, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Countable_count, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Stringable___toString, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_InternalIterator___construct arginfo_class_Serializable_serialize
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_current, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_InternalIterator_key arginfo_class_InternalIterator_current
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_next, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_valid, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_InternalIterator_rewind arginfo_class_InternalIterator_next
ZEND_METHOD(InternalIterator, __construct);
ZEND_METHOD(InternalIterator, current);
ZEND_METHOD(InternalIterator, key);
ZEND_METHOD(InternalIterator, next);
ZEND_METHOD(InternalIterator, valid);
ZEND_METHOD(InternalIterator, rewind);
static const zend_function_entry class_Traversable_methods[] = {
ZEND_FE_END
};
static const zend_function_entry class_IteratorAggregate_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(IteratorAggregate, getIterator, arginfo_class_IteratorAggregate_getIterator, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_Iterator_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(Iterator, current, arginfo_class_Iterator_current, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Iterator, next, arginfo_class_Iterator_next, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Iterator, key, arginfo_class_Iterator_key, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Iterator, valid, arginfo_class_Iterator_valid, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Iterator, rewind, arginfo_class_Iterator_rewind, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_ArrayAccess_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(ArrayAccess, offsetExists, arginfo_class_ArrayAccess_offsetExists, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(ArrayAccess, offsetGet, arginfo_class_ArrayAccess_offsetGet, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(ArrayAccess, offsetSet, arginfo_class_ArrayAccess_offsetSet, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(ArrayAccess, offsetUnset, arginfo_class_ArrayAccess_offsetUnset, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_Serializable_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(Serializable, serialize, arginfo_class_Serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_ABSTRACT_ME_WITH_FLAGS(Serializable, unserialize, arginfo_class_Serializable_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_Countable_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(Countable, count, arginfo_class_Countable_count, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_Stringable_methods[] = {
ZEND_ABSTRACT_ME_WITH_FLAGS(Stringable, __toString, arginfo_class_Stringable___toString, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_InternalIterator_methods[] = {
ZEND_ME(InternalIterator, __construct, arginfo_class_InternalIterator___construct, ZEND_ACC_PRIVATE)
ZEND_ME(InternalIterator, current, arginfo_class_InternalIterator_current, ZEND_ACC_PUBLIC)
ZEND_ME(InternalIterator, key, arginfo_class_InternalIterator_key, ZEND_ACC_PUBLIC)
ZEND_ME(InternalIterator, next, arginfo_class_InternalIterator_next, ZEND_ACC_PUBLIC)
ZEND_ME(InternalIterator, valid, arginfo_class_InternalIterator_valid, ZEND_ACC_PUBLIC)
ZEND_ME(InternalIterator, rewind, arginfo_class_InternalIterator_rewind, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static zend_class_entry *register_class_Traversable(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Traversable", class_Traversable_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_IteratorAggregate(zend_class_entry *class_entry_Traversable)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "IteratorAggregate", class_IteratorAggregate_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_Traversable);
return class_entry;
}
static zend_class_entry *register_class_Iterator(zend_class_entry *class_entry_Traversable)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Iterator", class_Iterator_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_Traversable);
return class_entry;
}
static zend_class_entry *register_class_ArrayAccess(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "ArrayAccess", class_ArrayAccess_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_Serializable(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Serializable", class_Serializable_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_Countable(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Countable", class_Countable_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_Stringable(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Stringable", class_Stringable_methods);
class_entry = zend_register_internal_interface(&ce);
return class_entry;
}
static zend_class_entry *register_class_InternalIterator(zend_class_entry *class_entry_Iterator)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "InternalIterator", class_InternalIterator_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NOT_SERIALIZABLE;
zend_class_implements(class_entry, 1, class_entry_Iterator);
return class_entry;
}

View File

@ -0,0 +1,34 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef _ZEND_STDIOSTREAM
#define _ZEND_STDIOSTREAM
#if defined(ZTS) && !defined(HAVE_CLASS_ISTDIOSTREAM)
class istdiostream : public istream
{
private:
stdiobuf _file;
public:
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
};
#endif
#endif

View File

@ -0,0 +1,91 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
/* These iterators were designed to operate within the foreach()
* structures provided by the engine, but could be extended for use
* with other iterative engine opcodes.
* These methods have similar semantics to the zend_hash API functions
* with similar names.
* */
typedef struct _zend_object_iterator zend_object_iterator;
typedef struct _zend_object_iterator_funcs {
/* release all resources associated with this iterator instance */
void (*dtor)(zend_object_iterator *iter);
/* check for end of iteration (FAILURE or SUCCESS if data is valid) */
int (*valid)(zend_object_iterator *iter);
/* fetch the item data for the current element */
zval *(*get_current_data)(zend_object_iterator *iter);
/* fetch the key for the current element (optional, may be NULL). The key
* should be written into the provided zval* using the ZVAL_* macros. If
* this handler is not provided auto-incrementing integer keys will be
* used. */
void (*get_current_key)(zend_object_iterator *iter, zval *key);
/* step forwards to next element */
void (*move_forward)(zend_object_iterator *iter);
/* rewind to start of data (optional, may be NULL) */
void (*rewind)(zend_object_iterator *iter);
/* invalidate current value/key (optional, may be NULL) */
void (*invalidate_current)(zend_object_iterator *iter);
/* Expose owned values to GC.
* This has the same semantics as the corresponding object handler. */
HashTable *(*get_gc)(zend_object_iterator *iter, zval **table, int *n);
} zend_object_iterator_funcs;
struct _zend_object_iterator {
zend_object std;
zval data;
const zend_object_iterator_funcs *funcs;
zend_ulong index; /* private to fe_reset/fe_fetch opcodes */
};
typedef struct _zend_class_iterator_funcs {
zend_function *zf_new_iterator;
zend_function *zf_valid;
zend_function *zf_current;
zend_function *zf_key;
zend_function *zf_next;
zend_function *zf_rewind;
} zend_class_iterator_funcs;
typedef struct _zend_class_arrayaccess_funcs {
zend_function *zf_offsetget;
zend_function *zf_offsetexists;
zend_function *zf_offsetset;
zend_function *zf_offsetunset;
} zend_class_arrayaccess_funcs;
BEGIN_EXTERN_C()
/* given a zval, returns stuff that can be used to iterate it. */
ZEND_API zend_object_iterator* zend_iterator_unwrap(zval *array_ptr);
/* given an iterator, wrap it up as a zval for use by the engine opcodes */
ZEND_API void zend_iterator_init(zend_object_iterator *iter);
ZEND_API void zend_iterator_dtor(zend_object_iterator *iter);
ZEND_API void zend_register_iterator_wrapper(void);
END_EXTERN_C()

View File

@ -0,0 +1,237 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_ZEND_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_LANGUAGE_PARSER_H_INCLUDED
# define YY_ZEND_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_LANGUAGE_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef ZENDDEBUG
# if defined YYDEBUG
#if YYDEBUG
# define ZENDDEBUG 1
# else
# define ZENDDEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define ZENDDEBUG 0
# endif /* ! defined YYDEBUG */
#endif /* ! defined ZENDDEBUG */
#if ZENDDEBUG
extern int zenddebug;
#endif
/* "%code requires" blocks. */
#line 41 "/mnt/c/Users/wreng/php-src/Zend/zend_language_parser.y"
#include "zend_compile.h"
#line 61 "/mnt/c/Users/wreng/php-src/Zend/zend_language_parser.h"
/* Token kinds. */
#ifndef ZENDTOKENTYPE
# define ZENDTOKENTYPE
enum zendtokentype
{
ZENDEMPTY = -2,
END = 0, /* "end of file" */
ZENDerror = 256, /* error */
ZENDUNDEF = 257, /* "invalid token" */
PREC_ARROW_FUNCTION = 258, /* PREC_ARROW_FUNCTION */
T_NOELSE = 259, /* T_NOELSE */
T_LNUMBER = 260, /* "integer" */
T_DNUMBER = 261, /* "floating-point number" */
T_STRING = 262, /* "identifier" */
T_NAME_FULLY_QUALIFIED = 263, /* "fully qualified name" */
T_NAME_RELATIVE = 264, /* "namespace-relative name" */
T_NAME_QUALIFIED = 265, /* "namespaced name" */
T_VARIABLE = 266, /* "variable" */
T_INLINE_HTML = 267, /* T_INLINE_HTML */
T_ENCAPSED_AND_WHITESPACE = 268, /* "string content" */
T_CONSTANT_ENCAPSED_STRING = 269, /* "quoted string" */
T_STRING_VARNAME = 270, /* "variable name" */
T_NUM_STRING = 271, /* "number" */
T_INCLUDE = 272, /* "'include'" */
T_INCLUDE_ONCE = 273, /* "'include_once'" */
T_EVAL = 274, /* "'eval'" */
T_REQUIRE = 275, /* "'require'" */
T_REQUIRE_ONCE = 276, /* "'require_once'" */
T_LOGICAL_OR = 277, /* "'or'" */
T_LOGICAL_XOR = 278, /* "'xor'" */
T_LOGICAL_AND = 279, /* "'and'" */
T_PRINT = 280, /* "'print'" */
T_YIELD = 281, /* "'yield'" */
T_YIELD_FROM = 282, /* "'yield from'" */
T_INSTANCEOF = 283, /* "'instanceof'" */
T_NEW = 284, /* "'new'" */
T_CLONE = 285, /* "'clone'" */
T_EXIT = 286, /* "'exit'" */
T_IF = 287, /* "'if'" */
T_ELSEIF = 288, /* "'elseif'" */
T_ELSE = 289, /* "'else'" */
T_ENDIF = 290, /* "'endif'" */
T_ECHO = 291, /* "'echo'" */
T_DO = 292, /* "'do'" */
T_WHILE = 293, /* "'while'" */
T_ENDWHILE = 294, /* "'endwhile'" */
T_FOR = 295, /* "'for'" */
T_ENDFOR = 296, /* "'endfor'" */
T_FOREACH = 297, /* "'foreach'" */
T_ENDFOREACH = 298, /* "'endforeach'" */
T_DECLARE = 299, /* "'declare'" */
T_ENDDECLARE = 300, /* "'enddeclare'" */
T_AS = 301, /* "'as'" */
T_SWITCH = 302, /* "'switch'" */
T_ENDSWITCH = 303, /* "'endswitch'" */
T_CASE = 304, /* "'case'" */
T_DEFAULT = 305, /* "'default'" */
T_MATCH = 306, /* "'match'" */
T_BREAK = 307, /* "'break'" */
T_CONTINUE = 308, /* "'continue'" */
T_GOTO = 309, /* "'goto'" */
T_FUNCTION = 310, /* "'function'" */
T_FN = 311, /* "'fn'" */
T_CONST = 312, /* "'const'" */
T_RETURN = 313, /* "'return'" */
T_TRY = 314, /* "'try'" */
T_CATCH = 315, /* "'catch'" */
T_FINALLY = 316, /* "'finally'" */
T_THROW = 317, /* "'throw'" */
T_USE = 318, /* "'use'" */
T_INSTEADOF = 319, /* "'insteadof'" */
T_GLOBAL = 320, /* "'global'" */
T_STATIC = 321, /* "'static'" */
T_ABSTRACT = 322, /* "'abstract'" */
T_FINAL = 323, /* "'final'" */
T_PRIVATE = 324, /* "'private'" */
T_PROTECTED = 325, /* "'protected'" */
T_PUBLIC = 326, /* "'public'" */
T_READONLY = 327, /* "'readonly'" */
T_VAR = 328, /* "'var'" */
T_UNSET = 329, /* "'unset'" */
T_ISSET = 330, /* "'isset'" */
T_EMPTY = 331, /* "'empty'" */
T_HALT_COMPILER = 332, /* "'__halt_compiler'" */
T_CLASS = 333, /* "'class'" */
T_TRAIT = 334, /* "'trait'" */
T_INTERFACE = 335, /* "'interface'" */
T_ENUM = 336, /* "'enum'" */
T_EXTENDS = 337, /* "'extends'" */
T_IMPLEMENTS = 338, /* "'implements'" */
T_NAMESPACE = 339, /* "'namespace'" */
T_LIST = 340, /* "'list'" */
T_ARRAY = 341, /* "'array'" */
T_CALLABLE = 342, /* "'callable'" */
T_LINE = 343, /* "'__LINE__'" */
T_FILE = 344, /* "'__FILE__'" */
T_DIR = 345, /* "'__DIR__'" */
T_CLASS_C = 346, /* "'__CLASS__'" */
T_TRAIT_C = 347, /* "'__TRAIT__'" */
T_METHOD_C = 348, /* "'__METHOD__'" */
T_FUNC_C = 349, /* "'__FUNCTION__'" */
T_NS_C = 350, /* "'__NAMESPACE__'" */
T_ATTRIBUTE = 351, /* "'#['" */
T_PLUS_EQUAL = 352, /* "'+='" */
T_MINUS_EQUAL = 353, /* "'-='" */
T_MUL_EQUAL = 354, /* "'*='" */
T_DIV_EQUAL = 355, /* "'/='" */
T_CONCAT_EQUAL = 356, /* "'.='" */
T_MOD_EQUAL = 357, /* "'%='" */
T_AND_EQUAL = 358, /* "'&='" */
T_OR_EQUAL = 359, /* "'|='" */
T_XOR_EQUAL = 360, /* "'^='" */
T_SL_EQUAL = 361, /* "'<<='" */
T_SR_EQUAL = 362, /* "'>>='" */
T_COALESCE_EQUAL = 363, /* "'??='" */
T_BOOLEAN_OR = 364, /* "'||'" */
T_BOOLEAN_AND = 365, /* "'&&'" */
T_IS_EQUAL = 366, /* "'=='" */
T_IS_NOT_EQUAL = 367, /* "'!='" */
T_IS_IDENTICAL = 368, /* "'==='" */
T_IS_NOT_IDENTICAL = 369, /* "'!=='" */
T_IS_SMALLER_OR_EQUAL = 370, /* "'<='" */
T_IS_GREATER_OR_EQUAL = 371, /* "'>='" */
T_SPACESHIP = 372, /* "'<=>'" */
T_SL = 373, /* "'<<'" */
T_SR = 374, /* "'>>'" */
T_INC = 375, /* "'++'" */
T_DEC = 376, /* "'--'" */
T_INT_CAST = 377, /* "'(int)'" */
T_DOUBLE_CAST = 378, /* "'(double)'" */
T_STRING_CAST = 379, /* "'(string)'" */
T_ARRAY_CAST = 380, /* "'(array)'" */
T_OBJECT_CAST = 381, /* "'(object)'" */
T_BOOL_CAST = 382, /* "'(bool)'" */
T_UNSET_CAST = 383, /* "'(unset)'" */
T_OBJECT_OPERATOR = 384, /* "'->'" */
T_NULLSAFE_OBJECT_OPERATOR = 385, /* "'?->'" */
T_DOUBLE_ARROW = 386, /* "'=>'" */
T_COMMENT = 387, /* "comment" */
T_DOC_COMMENT = 388, /* "doc comment" */
T_OPEN_TAG = 389, /* "open tag" */
T_OPEN_TAG_WITH_ECHO = 390, /* "'<?='" */
T_CLOSE_TAG = 391, /* "'?>'" */
T_WHITESPACE = 392, /* "whitespace" */
T_START_HEREDOC = 393, /* "heredoc start" */
T_END_HEREDOC = 394, /* "heredoc end" */
T_DOLLAR_OPEN_CURLY_BRACES = 395, /* "'${'" */
T_CURLY_OPEN = 396, /* "'{$'" */
T_PAAMAYIM_NEKUDOTAYIM = 397, /* "'::'" */
T_NS_SEPARATOR = 398, /* "'\\'" */
T_ELLIPSIS = 399, /* "'...'" */
T_COALESCE = 400, /* "'??'" */
T_POW = 401, /* "'**'" */
T_POW_EQUAL = 402, /* "'**='" */
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG = 403, /* "'&'" */
T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG = 404, /* "amp" */
T_BAD_CHARACTER = 405, /* "invalid character" */
T_ERROR = 406 /* T_ERROR */
};
typedef enum zendtokentype zendtoken_kind_t;
#endif
/* Value type. */
#if ! defined ZENDSTYPE && ! defined ZENDSTYPE_IS_DECLARED
typedef zend_parser_stack_elem ZENDSTYPE;
# define ZENDSTYPE_IS_TRIVIAL 1
# define ZENDSTYPE_IS_DECLARED 1
#endif
ZEND_API int zendparse (void);
#endif /* !YY_ZEND_MNT_C_USERS_WRENG_PHP_SRC_ZEND_ZEND_LANGUAGE_PARSER_H_INCLUDED */

View File

@ -0,0 +1,85 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SCANNER_H
#define ZEND_SCANNER_H
typedef struct _zend_lex_state {
unsigned int yy_leng;
unsigned char *yy_start;
unsigned char *yy_text;
unsigned char *yy_cursor;
unsigned char *yy_marker;
unsigned char *yy_limit;
int yy_state;
zend_stack state_stack;
zend_ptr_stack heredoc_label_stack;
zend_stack nest_location_stack; /* for syntax error reporting */
zend_file_handle *in;
uint32_t lineno;
zend_string *filename;
/* original (unfiltered) script */
unsigned char *script_org;
size_t script_org_size;
/* filtered script */
unsigned char *script_filtered;
size_t script_filtered_size;
/* input/output filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
const zend_encoding *script_encoding;
/* hooks */
void (*on_event)(
zend_php_scanner_event event, int token, int line,
const char *text, size_t length, void *context);
void *on_event_context;
zend_ast *ast;
zend_arena *ast_arena;
} zend_lex_state;
typedef struct _zend_heredoc_label {
char *label;
int length;
int indentation;
bool indentation_uses_spaces;
} zend_heredoc_label;
/* Track locations of unclosed {, [, (, etc. for better syntax error reporting */
typedef struct _zend_nest_location {
char text;
int lineno;
} zend_nest_location;
BEGIN_EXTERN_C()
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state);
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state);
ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename);
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding);
ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding);
ZEND_API zend_result zend_lex_tstring(zval *zv, unsigned char *ident);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,15 @@
/* Generated by re2c 2.1.1 */
enum YYCONDTYPE {
yycST_IN_SCRIPTING,
yycST_LOOKING_FOR_PROPERTY,
yycST_BACKQUOTE,
yycST_DOUBLE_QUOTES,
yycST_HEREDOC,
yycST_LOOKING_FOR_VARNAME,
yycST_VAR_OFFSET,
yycSHEBANG,
yycINITIAL,
yycST_END_HEREDOC,
yycST_NOWDOC,
};

View File

@ -0,0 +1,76 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_LIST_H
#define ZEND_LIST_H
#include "zend_hash.h"
#include "zend_globals.h"
BEGIN_EXTERN_C()
typedef void (*rsrc_dtor_func_t)(zend_resource *res);
#define ZEND_RSRC_DTOR_FUNC(name) void name(zend_resource *res)
typedef struct _zend_rsrc_list_dtors_entry {
rsrc_dtor_func_t list_dtor_ex;
rsrc_dtor_func_t plist_dtor_ex;
const char *type_name;
int module_number;
int resource_id;
} zend_rsrc_list_dtors_entry;
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number);
void list_entry_destructor(zval *ptr);
void plist_entry_destructor(zval *ptr);
void zend_clean_module_rsrc_dtors(int module_number);
ZEND_API void zend_init_rsrc_list(void); /* Exported for phar hack */
void zend_init_rsrc_plist(void);
void zend_close_rsrc_list(HashTable *ht);
void zend_destroy_rsrc_list(HashTable *ht);
void zend_init_rsrc_list_dtors(void);
void zend_destroy_rsrc_list_dtors(void);
ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type);
ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res);
ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res);
ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res);
ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type);
ZEND_API void *zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type);
ZEND_API void *zend_fetch_resource2(zend_resource *res, const char *resource_type_name, int resource_type, int resource_type2);
ZEND_API void *zend_fetch_resource_ex(zval *res, const char *resource_type_name, int resource_type);
ZEND_API void *zend_fetch_resource2_ex(zval *res, const char *resource_type_name, int resource_type, int resource_type2);
ZEND_API const char *zend_rsrc_list_get_rsrc_type(zend_resource *res);
ZEND_API int zend_fetch_list_dtor_id(const char *type_name);
ZEND_API zend_resource* zend_register_persistent_resource(const char *key, size_t key_len, void *rsrc_pointer, int rsrc_type);
ZEND_API zend_resource* zend_register_persistent_resource_ex(zend_string *key, void *rsrc_pointer, int rsrc_type);
extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
END_EXTERN_C()
#endif

View File

@ -0,0 +1,91 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_LLIST_H
#define ZEND_LLIST_H
typedef struct _zend_llist_element {
struct _zend_llist_element *next;
struct _zend_llist_element *prev;
char data[1]; /* Needs to always be last in the struct */
} zend_llist_element;
typedef void (*llist_dtor_func_t)(void *);
typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element **);
typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args);
typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg);
typedef void (*llist_apply_func_t)(void *);
typedef struct _zend_llist {
zend_llist_element *head;
zend_llist_element *tail;
size_t count;
size_t size;
llist_dtor_func_t dtor;
unsigned char persistent;
zend_llist_element *traverse_ptr;
} zend_llist;
typedef zend_llist_element* zend_llist_position;
BEGIN_EXTERN_C()
ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent);
ZEND_API void zend_llist_add_element(zend_llist *l, const void *element);
ZEND_API void zend_llist_prepend_element(zend_llist *l, const void *element);
ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2));
ZEND_API void zend_llist_destroy(zend_llist *l);
ZEND_API void zend_llist_clean(zend_llist *l);
ZEND_API void zend_llist_remove_tail(zend_llist *l);
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func);
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg);
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...);
ZEND_API size_t zend_llist_count(zend_llist *l);
ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func);
/* traversal */
ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos);
ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos);
ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos);
ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos);
static zend_always_inline void *zend_llist_get_first(zend_llist *l)
{
return zend_llist_get_first_ex(l, NULL);
}
static zend_always_inline void *zend_llist_get_last(zend_llist *l)
{
return zend_llist_get_last_ex(l, NULL);
}
static zend_always_inline void *zend_llist_get_next(zend_llist *l)
{
return zend_llist_get_next_ex(l, NULL);
}
static zend_always_inline void *zend_llist_get_prev(zend_llist *l)
{
return zend_llist_get_prev_ex(l, NULL);
}
END_EXTERN_C()
#endif /* ZEND_LLIST_H */

View File

@ -0,0 +1,128 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_LONG_H
#define ZEND_LONG_H
#include <inttypes.h>
#include <stdint.h>
/* This is the heart of the whole int64 enablement in zval. */
#if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)
# define ZEND_ENABLE_ZVAL_LONG64 1
#endif
/* Integer types. */
#ifdef ZEND_ENABLE_ZVAL_LONG64
typedef int64_t zend_long;
typedef uint64_t zend_ulong;
typedef int64_t zend_off_t;
# define ZEND_LONG_MAX INT64_MAX
# define ZEND_LONG_MIN INT64_MIN
# define ZEND_ULONG_MAX UINT64_MAX
# define Z_L(i) INT64_C(i)
# define Z_UL(i) UINT64_C(i)
# define SIZEOF_ZEND_LONG 8
#else
typedef int32_t zend_long;
typedef uint32_t zend_ulong;
typedef int32_t zend_off_t;
# define ZEND_LONG_MAX INT32_MAX
# define ZEND_LONG_MIN INT32_MIN
# define ZEND_ULONG_MAX UINT32_MAX
# define Z_L(i) INT32_C(i)
# define Z_UL(i) UINT32_C(i)
# define SIZEOF_ZEND_LONG 4
#endif
/* Conversion macros. */
#define ZEND_LTOA_BUF_LEN 65
#ifdef ZEND_ENABLE_ZVAL_LONG64
# define ZEND_LONG_FMT "%" PRId64
# define ZEND_ULONG_FMT "%" PRIu64
# define ZEND_XLONG_FMT "%" PRIx64
# define ZEND_LONG_FMT_SPEC PRId64
# define ZEND_ULONG_FMT_SPEC PRIu64
# ifdef ZEND_WIN32
# define ZEND_LTOA(i, s, len) _i64toa_s((i), (s), (len), 10)
# define ZEND_ATOL(s) _atoi64((s))
# define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base))
# define ZEND_STRTOL_PTR _strtoi64
# define ZEND_STRTOUL_PTR _strtoui64
# define ZEND_ABS _abs64
# else
# define ZEND_LTOA(i, s, len) \
do { \
int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
(s)[st] = '\0'; \
} while (0)
# define ZEND_ATOL(s) atoll((s))
# define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base))
# define ZEND_STRTOL_PTR strtoll
# define ZEND_STRTOUL_PTR strtoull
# define ZEND_ABS imaxabs
# endif
#else
# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
# define ZEND_STRTOUL(s0, s1, base) strtoul((s0), (s1), (base))
# define ZEND_LONG_FMT "%" PRId32
# define ZEND_ULONG_FMT "%" PRIu32
# define ZEND_XLONG_FMT "%" PRIx32
# define ZEND_LONG_FMT_SPEC PRId32
# define ZEND_ULONG_FMT_SPEC PRIu32
# ifdef ZEND_WIN32
# define ZEND_LTOA(i, s, len) _ltoa_s((i), (s), (len), 10)
# define ZEND_ATOL(s) atol((s))
# else
# define ZEND_LTOA(i, s, len) \
do { \
int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \
(s)[st] = '\0'; \
} while (0)
# define ZEND_ATOL(s) atol((s))
# endif
# define ZEND_STRTOL_PTR strtol
# define ZEND_STRTOUL_PTR strtoul
# define ZEND_ABS abs
#endif
#if SIZEOF_ZEND_LONG == 4
# define MAX_LENGTH_OF_LONG 11
# define LONG_MIN_DIGITS "2147483648"
#elif SIZEOF_ZEND_LONG == 8
# define MAX_LENGTH_OF_LONG 20
# define LONG_MIN_DIGITS "9223372036854775808"
#else
# error "Unknown SIZEOF_ZEND_LONG"
#endif
static const char long_min_digits[] = LONG_MIN_DIGITS;
#if SIZEOF_SIZE_T == 4
# define ZEND_ADDR_FMT "0x%08zx"
#elif SIZEOF_SIZE_T == 8
# define ZEND_ADDR_FMT "0x%016zx"
#else
# error "Unknown SIZEOF_SIZE_T"
#endif
#endif /* ZEND_LONG_H */

View File

@ -0,0 +1,81 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_MAP_PTR_H
#define ZEND_MAP_PTR_H
#include "zend_portability.h"
#define ZEND_MAP_PTR_KIND_PTR 0
#define ZEND_MAP_PTR_KIND_PTR_OR_OFFSET 1
#define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
#define ZEND_MAP_PTR(ptr) \
ptr ## __ptr
#define ZEND_MAP_PTR_DEF(type, name) \
type ZEND_MAP_PTR(name)
#define ZEND_MAP_PTR_OFFSET2PTR(offset) \
((void**)((char*)CG(map_ptr_base) + offset))
#define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
#define ZEND_MAP_PTR_INIT(ptr, val) do { \
ZEND_MAP_PTR(ptr) = (val); \
} while (0)
#define ZEND_MAP_PTR_NEW(ptr) do { \
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
} while (0)
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
# define ZEND_MAP_PTR_NEW_OFFSET() \
((uint32_t)(uintptr_t)zend_map_ptr_new())
# define ZEND_MAP_PTR_IS_OFFSET(ptr) \
(((uintptr_t)ZEND_MAP_PTR(ptr)) & 1L)
# define ZEND_MAP_PTR_GET(ptr) \
((ZEND_MAP_PTR_IS_OFFSET(ptr) ? \
ZEND_MAP_PTR_GET_IMM(ptr) : \
((void*)(ZEND_MAP_PTR(ptr)))))
# define ZEND_MAP_PTR_GET_IMM(ptr) \
(*ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)))
# define ZEND_MAP_PTR_SET(ptr, val) do { \
if (ZEND_MAP_PTR_IS_OFFSET(ptr)) { \
ZEND_MAP_PTR_SET_IMM(ptr, val); \
} else { \
ZEND_MAP_PTR_INIT(ptr, val); \
} \
} while (0)
# define ZEND_MAP_PTR_SET_IMM(ptr, val) do { \
void **__p = ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)); \
*__p = (val); \
} while (0)
# define ZEND_MAP_PTR_BIASED_BASE(real_base) \
((void*)(((uintptr_t)(real_base)) - 1))
#else
# error "Unknown ZEND_MAP_PTR_KIND"
#endif
BEGIN_EXTERN_C()
ZEND_API void zend_map_ptr_reset(void);
ZEND_API void *zend_map_ptr_new(void);
ZEND_API void zend_map_ptr_extend(size_t last);
ZEND_API void zend_alloc_ce_cache(zend_string *type_name);
END_EXTERN_C()
#endif /* ZEND_MAP_PTR_H */

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Kévin Dunglas <kevin@dunglas.dev> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_MAX_EXECUTION_TIMER_H
#define ZEND_MAX_EXECUTION_TIMER_H
# ifdef ZEND_MAX_EXECUTION_TIMERS
#include "zend_long.h"
/* Must be called after calls to fork() */
ZEND_API void zend_max_execution_timer_init(void);
void zend_max_execution_timer_settime(zend_long seconds);
void zend_max_execution_timer_shutdown(void);
# else
#define zend_max_execution_timer_init()
#define zend_max_execution_timer_settime(seconds)
#define zend_max_execution_timer_shutdown()
# endif
#endif

View File

@ -0,0 +1,44 @@
/*
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Max Kellermann <max.kellermann@ionos.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_MMAP_H
#define ZEND_MMAP_H
#include "zend_portability.h"
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
/* fallback definitions if our libc is older than the kernel */
# ifndef PR_SET_VMA
# define PR_SET_VMA 0x53564d41
# endif
# ifndef PR_SET_VMA_ANON_NAME
# define PR_SET_VMA_ANON_NAME 0
# endif
#endif // HAVE_PRCTL
/**
* Set a name for the specified memory area.
*
* This feature requires Linux 5.17.
*/
static zend_always_inline void zend_mmap_set_name(const void *start, size_t len, const char *name)
{
#ifdef HAVE_PRCTL
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)start, len, (unsigned long)name);
#endif
}
#endif /* ZEND_MMAP_H */

View File

@ -0,0 +1,131 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef MODULES_H
#define MODULES_H
#include "zend.h"
#include "zend_compile.h"
#include "zend_build.h"
#define INIT_FUNC_ARGS int type, int module_number
#define INIT_FUNC_ARGS_PASSTHRU type, module_number
#define SHUTDOWN_FUNC_ARGS int type, int module_number
#define SHUTDOWN_FUNC_ARGS_PASSTHRU type, module_number
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module
#define ZEND_MODULE_API_NO 20230831
#ifdef ZTS
#define USING_ZTS 1
#else
#define USING_ZTS 0
#endif
#define STANDARD_MODULE_HEADER_EX sizeof(zend_module_entry), ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS
#define STANDARD_MODULE_HEADER \
STANDARD_MODULE_HEADER_EX, NULL, NULL
#define ZE2_STANDARD_MODULE_HEADER \
STANDARD_MODULE_HEADER_EX, ini_entries, NULL
#define ZEND_MODULE_BUILD_ID "API" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
#define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0, ZEND_MODULE_BUILD_ID
#define NO_MODULE_GLOBALS 0, NULL, NULL, NULL
#ifdef ZTS
# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id
#else
# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals
#endif
#define STANDARD_MODULE_PROPERTIES \
NO_MODULE_GLOBALS, NULL, STANDARD_MODULE_PROPERTIES_EX
#define NO_VERSION_YET NULL
#define MODULE_PERSISTENT 1
#define MODULE_TEMPORARY 2
struct _zend_ini_entry;
typedef struct _zend_module_entry zend_module_entry;
typedef struct _zend_module_dep zend_module_dep;
struct _zend_module_entry {
unsigned short size;
unsigned int zend_api;
unsigned char zend_debug;
unsigned char zts;
const struct _zend_ini_entry *ini_entry;
const struct _zend_module_dep *deps;
const char *name;
const struct _zend_function_entry *functions;
zend_result (*module_startup_func)(INIT_FUNC_ARGS);
zend_result (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS);
zend_result (*request_startup_func)(INIT_FUNC_ARGS);
zend_result (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS);
void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS);
const char *version;
size_t globals_size;
#ifdef ZTS
ts_rsrc_id* globals_id_ptr;
#else
void* globals_ptr;
#endif
void (*globals_ctor)(void *global);
void (*globals_dtor)(void *global);
zend_result (*post_deactivate_func)(void);
int module_started;
unsigned char type;
void *handle;
int module_number;
const char *build_id;
};
#define MODULE_DEP_REQUIRED 1
#define MODULE_DEP_CONFLICTS 2
#define MODULE_DEP_OPTIONAL 3
#define ZEND_MOD_REQUIRED_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_REQUIRED },
#define ZEND_MOD_CONFLICTS_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_CONFLICTS },
#define ZEND_MOD_OPTIONAL_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_OPTIONAL },
#define ZEND_MOD_REQUIRED(name) ZEND_MOD_REQUIRED_EX(name, NULL, NULL)
#define ZEND_MOD_CONFLICTS(name) ZEND_MOD_CONFLICTS_EX(name, NULL, NULL)
#define ZEND_MOD_OPTIONAL(name) ZEND_MOD_OPTIONAL_EX(name, NULL, NULL)
#define ZEND_MOD_END { NULL, NULL, NULL, 0 }
struct _zend_module_dep {
const char *name; /* module name */
const char *rel; /* version relationship: NULL (exists), lt|le|eq|ge|gt (to given version) */
const char *version; /* version */
unsigned char type; /* dependency type */
};
BEGIN_EXTERN_C()
extern ZEND_API HashTable module_registry;
void module_destructor(zend_module_entry *module);
int module_registry_request_startup(zend_module_entry *module);
int module_registry_unload_temp(const zend_module_entry *module);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,79 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Masaki Fujimoto <fujimoto@php.net> |
| Rui Hirokawa <hirokawa@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_MULTIBYTE_H
#define ZEND_MULTIBYTE_H
typedef struct _zend_encoding zend_encoding;
typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length);
typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name);
typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding);
typedef bool (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding);
typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
typedef zend_result (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void);
typedef zend_result (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding);
typedef struct _zend_multibyte_functions {
const char *provider_name;
zend_encoding_fetcher encoding_fetcher;
zend_encoding_name_getter encoding_name_getter;
zend_encoding_lexer_compatibility_checker lexer_compatibility_checker;
zend_encoding_detector encoding_detector;
zend_encoding_converter encoding_converter;
zend_encoding_list_parser encoding_list_parser;
zend_encoding_internal_encoding_getter internal_encoding_getter;
zend_encoding_internal_encoding_setter internal_encoding_setter;
} zend_multibyte_functions;
/*
* zend multibyte APIs
*/
BEGIN_EXTERN_C()
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32be;
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32le;
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16be;
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le;
ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
/* multibyte utility functions */
ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions);
ZEND_API void zend_multibyte_restore_functions(void);
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
ZEND_API zend_result zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void);
ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void);
ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size);
ZEND_API zend_result zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);
END_EXTERN_C()
#endif /* ZEND_MULTIBYTE_H */

View File

@ -0,0 +1,356 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Sascha Schumann <sascha@schumann.cx> |
| Ard Biesheuvel <ard.biesheuvel@linaro.org> |
+----------------------------------------------------------------------+
*/
#include "zend_portability.h"
#ifndef ZEND_MULTIPLY_H
#define ZEND_MULTIPLY_H
#if PHP_HAVE_BUILTIN_SMULL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long __tmpvar; \
if (((usedval) = __builtin_smull_overflow((a), (b), &__tmpvar))) { \
(dval) = (double) (a) * (double) (b); \
} \
else (lval) = __tmpvar; \
} while (0)
#elif PHP_HAVE_BUILTIN_SMULLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long long __tmpvar; \
if (((usedval) = __builtin_smulll_overflow((a), (b), &__tmpvar))) { \
(dval) = (double) (a) * (double) (b); \
} \
else (lval) = __tmpvar; \
} while (0)
#elif (defined(__i386__) || defined(__x86_64__)) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
zend_long __tmpvar; \
__asm__ ("imul %3,%0\n" \
"adc $0,%1" \
: "=r"(__tmpvar),"=r"(usedval) \
: "0"(a), "r"(b), "1"(0)); \
if (usedval) (dval) = (double) (a) * (double) (b); \
else (lval) = __tmpvar; \
} while (0)
#elif defined(__arm__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
zend_long __tmpvar; \
__asm__("smull %0, %1, %2, %3\n" \
"sub %1, %1, %0, asr #31" \
: "=r"(__tmpvar), "=r"(usedval) \
: "r"(a), "r"(b)); \
if (usedval) (dval) = (double) (a) * (double) (b); \
else (lval) = __tmpvar; \
} while (0)
#elif defined(__aarch64__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
zend_long __tmpvar; \
__asm__("mul %0, %2, %3\n" \
"smulh %1, %2, %3\n" \
"sub %1, %1, %0, asr #63\n" \
: "=&r"(__tmpvar), "=&r"(usedval) \
: "r"(a), "r"(b)); \
if (usedval) (dval) = (double) (a) * (double) (b); \
else (lval) = __tmpvar; \
} while (0)
#elif defined(ZEND_WIN32)
# ifdef _M_X64
# pragma intrinsic(_mul128)
# define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
__int64 __high; \
__int64 __low = _mul128((a), (b), &__high); \
if ((__low >> 63I64) == __high) { \
(usedval) = 0; \
(lval) = __low; \
} else { \
(usedval) = 1; \
(dval) = (double)(a) * (double)(b); \
} \
} while (0)
# elif defined(_M_ARM64)
# pragma intrinsic(__mulh)
# define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
__int64 __high = __mulh((a), (b)); \
__int64 __low = (a) * (b); \
if ((__low >> 63I64) == __high) { \
(usedval) = 0; \
(lval) = __low; \
} else { \
(usedval) = 1; \
(dval) = (double)(a) * (double)(b); \
} \
} while (0)
# else
# define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
zend_long __lres = (a) * (b); \
long double __dres = (long double)(a) * (long double)(b); \
long double __delta = (long double) __lres - __dres; \
if ( ((usedval) = (( __dres + __delta ) != __dres))) { \
(dval) = __dres; \
} else { \
(lval) = __lres; \
} \
} while (0)
# endif
#elif defined(__powerpc64__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long __low, __high; \
__asm__("mulld %0,%2,%3\n\t" \
"mulhd %1,%2,%3\n" \
: "=&r"(__low), "=&r"(__high) \
: "r"(a), "r"(b)); \
if ((__low >> 63) != __high) { \
(dval) = (double) (a) * (double) (b); \
(usedval) = 1; \
} else { \
(lval) = __low; \
(usedval) = 0; \
} \
} while (0)
#elif SIZEOF_ZEND_LONG == 4
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
int64_t __result = (int64_t) (a) * (int64_t) (b); \
if (__result > ZEND_LONG_MAX || __result < ZEND_LONG_MIN) { \
(dval) = (double) __result; \
(usedval) = 1; \
} else { \
(lval) = (long) __result; \
(usedval) = 0; \
} \
} while (0)
#else
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long __lres = (a) * (b); \
long double __dres = (long double)(a) * (long double)(b); \
long double __delta = (long double) __lres - __dres; \
if ( ((usedval) = (( __dres + __delta ) != __dres))) { \
(dval) = __dres; \
} else { \
(lval) = __lres; \
} \
} while (0)
#endif
#if defined(__GNUC__) && (defined(__native_client__) || defined(i386))
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res = nmemb;
size_t m_overflow = 0;
if (ZEND_CONST_COND(offset == 0, 0)) {
__asm__ ("mull %3\n\tadcl $0,%1"
: "=&a"(res), "=&d" (m_overflow)
: "%0"(res),
"rm"(size));
} else {
__asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1"
: "=&a"(res), "=&d" (m_overflow)
: "%0"(res),
"rm"(size),
"rm"(offset));
}
if (UNEXPECTED(m_overflow)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#elif defined(__GNUC__) && defined(__x86_64__)
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res = nmemb;
zend_ulong m_overflow = 0;
#ifdef __ILP32__ /* x32 */
# define LP_SUFF "l"
#else /* amd64 */
# define LP_SUFF "q"
#endif
if (ZEND_CONST_COND(offset == 0, 0)) {
__asm__ ("mul" LP_SUFF " %3\n\t"
"adc $0,%1"
: "=&a"(res), "=&d" (m_overflow)
: "%0"(res),
"rm"(size));
} else {
__asm__ ("mul" LP_SUFF " %3\n\t"
"add %4,%0\n\t"
"adc $0,%1"
: "=&a"(res), "=&d" (m_overflow)
: "%0"(res),
"rm"(size),
"rm"(offset));
}
#undef LP_SUFF
if (UNEXPECTED(m_overflow)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#elif defined(__GNUC__) && defined(__arm__)
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res;
zend_ulong m_overflow;
__asm__ ("umlal %0,%1,%2,%3"
: "=r"(res), "=r"(m_overflow)
: "r"(nmemb),
"r"(size),
"0"(offset),
"1"(0));
if (UNEXPECTED(m_overflow)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#elif defined(__GNUC__) && defined(__aarch64__)
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res;
zend_ulong m_overflow;
__asm__ ("mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc %1,%1,xzr"
: "=&r"(res), "=&r"(m_overflow)
: "r"(nmemb),
"r"(size),
"r"(offset));
if (UNEXPECTED(m_overflow)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#elif defined(__GNUC__) && defined(__powerpc64__)
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res;
unsigned long m_overflow;
__asm__ ("mulld %0,%2,%3\n\t"
"mulhdu %1,%2,%3\n\t"
"addc %0,%0,%4\n\t"
"addze %1,%1\n"
: "=&r"(res), "=&r"(m_overflow)
: "r"(nmemb),
"r"(size),
"r"(offset));
if (UNEXPECTED(m_overflow)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#elif SIZEOF_SIZE_T == 4
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
uint64_t res = (uint64_t) nmemb * (uint64_t) size + (uint64_t) offset;
if (UNEXPECTED(res > UINT64_C(0xFFFFFFFF))) {
*overflow = 1;
return 0;
}
*overflow = 0;
return (size_t) res;
}
#else
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow)
{
size_t res = nmemb * size + offset;
double _d = (double)nmemb * (double)size + (double)offset;
double _delta = (double)res - _d;
if (UNEXPECTED((_d + _delta ) != _d)) {
*overflow = 1;
return 0;
}
*overflow = 0;
return res;
}
#endif
static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t size, size_t offset)
{
bool overflow;
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
return 0;
}
return ret;
}
/* A bit more generic version of the same */
static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, size_t offset, const char *message)
{
bool overflow;
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
return 0;
}
return ret;
}
#endif /* ZEND_MULTIPLY_H */

View File

@ -0,0 +1,282 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OBJECT_HANDLERS_H
#define ZEND_OBJECT_HANDLERS_H
#include <stdint.h>
struct _zend_property_info;
#define ZEND_WRONG_PROPERTY_INFO \
((struct _zend_property_info*)((intptr_t)-1))
#define ZEND_DYNAMIC_PROPERTY_OFFSET ((uintptr_t)(intptr_t)(-1))
#define IS_VALID_PROPERTY_OFFSET(offset) ((intptr_t)(offset) > 0)
#define IS_WRONG_PROPERTY_OFFSET(offset) ((intptr_t)(offset) == 0)
#define IS_DYNAMIC_PROPERTY_OFFSET(offset) ((intptr_t)(offset) < 0)
#define IS_UNKNOWN_DYNAMIC_PROPERTY_OFFSET(offset) (offset == ZEND_DYNAMIC_PROPERTY_OFFSET)
#define ZEND_DECODE_DYN_PROP_OFFSET(offset) ((uintptr_t)(-(intptr_t)(offset) - 2))
#define ZEND_ENCODE_DYN_PROP_OFFSET(offset) ((uintptr_t)(-((intptr_t)(offset) + 2)))
/* Used to fetch property from the object, read-only */
typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
/* Used to fetch dimension from the object, read-only */
typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv);
/* Used to set property of the object
You must return the final value of the assigned property.
*/
typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot);
/* Used to set dimension of the object */
typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value);
/* Used to create pointer to the property of the object, for future direct r/w access.
* May return one of:
* * A zval pointer, without incrementing the reference count.
* * &EG(error_zval), if an exception has been thrown.
* * NULL, if acquiring a direct pointer is not possible.
* In this case, the VM will fall back to using read_property and write_property.
*/
typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot);
/* Used to check if a property of the object exists */
/* param has_set_exists:
* 0 (has) whether property exists and is not NULL
* 1 (set) whether property exists and is true
* 2 (exists) whether property exists
*/
typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot);
/* Used to check if a dimension of the object exists */
typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty);
/* Used to remove a property of the object */
typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot);
/* Used to remove a dimension of the object */
typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset);
/* Used to get hash of the properties of the object, as hash of zval's */
typedef HashTable *(*zend_object_get_properties_t)(zend_object *object);
typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp);
typedef enum _zend_prop_purpose {
/* Used for debugging. Supersedes get_debug_info handler. */
ZEND_PROP_PURPOSE_DEBUG,
/* Used for (array) casts. */
ZEND_PROP_PURPOSE_ARRAY_CAST,
/* Used for serialization using the "O" scheme.
* Unserialization will use __wakeup(). */
ZEND_PROP_PURPOSE_SERIALIZE,
/* Used for var_export().
* The data will be passed to __set_state() when evaluated. */
ZEND_PROP_PURPOSE_VAR_EXPORT,
/* Used for json_encode(). */
ZEND_PROP_PURPOSE_JSON,
/* Dummy member to ensure that "default" is specified. */
_ZEND_PROP_PURPOSE_NON_EXHAUSTIVE_ENUM
} zend_prop_purpose;
/* The return value must be released using zend_release_properties(). */
typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose);
/* Used to call methods */
/* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
*/
typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key);
typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object);
/* free_obj should release any resources the object holds, without freeing the
* object structure itself. The object does not need to be in a valid state after
* free_obj finishes running.
*
* free_obj will always be invoked, even if the object leaks or a fatal error
* occurs. However, during shutdown it may be called once the executor is no
* longer active, in which case execution of user code may be skipped.
*/
typedef void (*zend_object_free_obj_t)(zend_object *object);
/* dtor_obj is called before free_obj. The object must remain in a valid state
* after dtor_obj finishes running. Unlike free_obj, it is run prior to
* deactivation of the executor during shutdown, which allows user code to run.
*
* This handler is not guaranteed to be called (e.g. on fatal error), and as
* such should not be used to release resources or deallocate memory. Furthermore,
* releasing resources in this handler can break detection of memory leaks, as
* cycles may be broken early.
*
* dtor_obj should be used *only* to call user destruction hooks, such as __destruct.
*/
typedef void (*zend_object_dtor_obj_t)(zend_object *object);
typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object);
/* Get class name for display in var_dump and other debugging functions.
* Must be defined and must return a non-NULL value. */
typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2);
/* Cast an object to some other type.
* readobj and retval must point to distinct zvals.
*/
typedef zend_result (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type);
/* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
typedef zend_result (*zend_object_count_elements_t)(zend_object *object, zend_long *count);
typedef zend_result (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n);
typedef zend_result (*zend_object_do_operation_t)(uint8_t opcode, zval *result, zval *op1, zval *op2);
struct _zend_object_handlers {
/* offset of real object header (usually zero) */
int offset;
/* object handlers */
zend_object_free_obj_t free_obj; /* required */
zend_object_dtor_obj_t dtor_obj; /* required */
zend_object_clone_obj_t clone_obj; /* optional */
zend_object_read_property_t read_property; /* required */
zend_object_write_property_t write_property; /* required */
zend_object_read_dimension_t read_dimension; /* required */
zend_object_write_dimension_t write_dimension; /* required */
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */
zend_object_has_property_t has_property; /* required */
zend_object_unset_property_t unset_property; /* required */
zend_object_has_dimension_t has_dimension; /* required */
zend_object_unset_dimension_t unset_dimension; /* required */
zend_object_get_properties_t get_properties; /* required */
zend_object_get_method_t get_method; /* required */
zend_object_get_constructor_t get_constructor; /* required */
zend_object_get_class_name_t get_class_name; /* required */
zend_object_cast_t cast_object; /* required */
zend_object_count_elements_t count_elements; /* optional */
zend_object_get_debug_info_t get_debug_info; /* optional */
zend_object_get_closure_t get_closure; /* optional */
zend_object_get_gc_t get_gc; /* required */
zend_object_do_operation_t do_operation; /* optional */
zend_object_compare_t compare; /* required */
zend_object_get_properties_for_t get_properties_for; /* optional */
};
BEGIN_EXTERN_C()
extern const ZEND_API zend_object_handlers std_object_handlers;
#define zend_get_std_object_handlers() \
(&std_object_handlers)
#define zend_get_function_root_class(fbc) \
((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)
#define ZEND_PROPERTY_ISSET 0x0 /* Property exists and is not NULL */
#define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
#define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */
ZEND_API void zend_class_init_statics(zend_class_entry *ce);
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, struct _zend_property_info **prop_info);
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type);
ZEND_API ZEND_COLD bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
ZEND_API zend_function *zend_std_get_constructor(zend_object *object);
ZEND_API struct _zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent);
ZEND_API HashTable *zend_std_get_properties(zend_object *object);
ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n);
ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp);
ZEND_API zend_result zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type);
ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot);
ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot);
ZEND_API int zend_std_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot);
ZEND_API void zend_std_unset_property(zend_object *object, zend_string *member, void **cache_slot);
ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv);
ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value);
ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty);
ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset);
ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key);
ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj);
ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
ZEND_API void rebuild_object_properties(zend_object *zobj);
ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj);
/* Handler for objects that cannot be meaningfully compared.
* Only objects with the same identity will be considered equal. */
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2);
ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_entry *scope);
ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_string *prop_info_name, bool is_dynamic);
ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static);
ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member);
ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member);
ZEND_API uint32_t *zend_get_recursion_guard(zend_object *zobj);
/* Default behavior for get_properties_for. For use as a fallback in custom
* get_properties_for implementations. */
ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purpose purpose);
/* Will call get_properties_for handler or use default behavior. For use by
* consumers of the get_properties_for API. */
ZEND_API HashTable *zend_get_properties_for(zval *obj, zend_prop_purpose purpose);
#define zend_release_properties(ht) do { \
if ((ht) && !(GC_FLAGS(ht) & GC_IMMUTABLE) && !GC_DELREF(ht)) { \
zend_array_destroy(ht); \
} \
} while (0)
#define zend_free_trampoline(func) do { \
if ((func) == &EG(trampoline)) { \
EG(trampoline).common.function_name = NULL; \
} else { \
efree(func); \
} \
} while (0)
/* Fallback to default comparison implementation if the arguments aren't both objects
* and have the same compare() handler. You'll likely want to use this unless you
* explicitly wish to support comparisons between objects and non-objects. */
#define ZEND_COMPARE_OBJECTS_FALLBACK(op1, op2) \
if (Z_TYPE_P(op1) != IS_OBJECT || \
Z_TYPE_P(op2) != IS_OBJECT || \
Z_OBJ_HT_P(op1)->compare != Z_OBJ_HT_P(op2)->compare) { \
return zend_std_compare_objects(op1, op2); \
}
END_EXTERN_C()
#endif

View File

@ -0,0 +1,35 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OBJECTS_H
#define ZEND_OBJECTS_H
#include "zend.h"
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce);
ZEND_API zend_object* ZEND_FASTCALL zend_objects_new(zend_class_entry *ce);
ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object);
ZEND_API void zend_object_std_dtor(zend_object *object);
ZEND_API void zend_objects_destroy_object(zend_object *object);
ZEND_API zend_object *zend_objects_clone_obj(zend_object *object);
END_EXTERN_C()
#endif /* ZEND_OBJECTS_H */

View File

@ -0,0 +1,116 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OBJECTS_API_H
#define ZEND_OBJECTS_API_H
#include "zend.h"
#include "zend_compile.h"
#define OBJ_BUCKET_INVALID (1<<0)
#define IS_OBJ_VALID(o) (!(((uintptr_t)(o)) & OBJ_BUCKET_INVALID))
#define SET_OBJ_INVALID(o) ((zend_object*)((((uintptr_t)(o)) | OBJ_BUCKET_INVALID)))
#define GET_OBJ_BUCKET_NUMBER(o) (((intptr_t)(o)) >> 1)
#define SET_OBJ_BUCKET_NUMBER(o, n) do { \
(o) = (zend_object*)((((uintptr_t)(n)) << 1) | OBJ_BUCKET_INVALID); \
} while (0)
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(h) do { \
SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[(h)], EG(objects_store).free_list_head); \
EG(objects_store).free_list_head = (h); \
} while (0)
#define OBJ_RELEASE(obj) zend_object_release(obj)
typedef struct _zend_objects_store {
zend_object **object_buckets;
uint32_t top;
uint32_t size;
int free_list_head;
} zend_objects_store;
/* Global store handling functions */
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
ZEND_API void ZEND_FASTCALL zend_objects_store_call_destructors(zend_objects_store *objects);
ZEND_API void ZEND_FASTCALL zend_objects_store_mark_destructed(zend_objects_store *objects);
ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_store *objects, bool fast_shutdown);
ZEND_API void ZEND_FASTCALL zend_objects_store_destroy(zend_objects_store *objects);
/* Store API functions */
ZEND_API void ZEND_FASTCALL zend_objects_store_put(zend_object *object);
ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object);
/* Called when the ctor was terminated by an exception */
static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
{
GC_ADD_FLAGS(obj, IS_OBJ_DESTRUCTOR_CALLED);
}
END_EXTERN_C()
static zend_always_inline void zend_object_release(zend_object *obj)
{
if (GC_DELREF(obj) == 0) {
zend_objects_store_del(obj);
} else if (UNEXPECTED(GC_MAY_LEAK((zend_refcounted*)obj))) {
gc_possible_root((zend_refcounted*)obj);
}
}
static zend_always_inline size_t zend_object_properties_size(zend_class_entry *ce)
{
return sizeof(zval) *
(ce->default_properties_count -
((ce->ce_flags & ZEND_ACC_USE_GUARDS) ? 0 : 1));
}
/* Allocates object type and zeros it, but not the standard zend_object and properties.
* Standard object MUST be initialized using zend_object_std_init().
* Properties MUST be initialized using object_properties_init(). */
static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
void *obj = emalloc(obj_size + zend_object_properties_size(ce));
memset(obj, 0, obj_size - sizeof(zend_object));
return obj;
}
static inline zend_property_info *zend_get_property_info_for_slot(zend_object *obj, zval *slot)
{
zend_property_info **table = obj->ce->properties_info_table;
intptr_t prop_num = slot - obj->properties_table;
ZEND_ASSERT(prop_num >= 0 && prop_num < obj->ce->default_properties_count);
return table[prop_num];
}
/* Helper for cases where we're only interested in property info of typed properties. */
static inline zend_property_info *zend_get_typed_property_info_for_slot(zend_object *obj, zval *slot)
{
zend_property_info *prop_info = zend_get_property_info_for_slot(obj, slot);
if (prop_info && ZEND_TYPE_IS_SET(prop_info->type)) {
return prop_info;
}
return NULL;
}
#endif /* ZEND_OBJECTS_H */

View File

@ -0,0 +1,130 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Levi Morrison <levim@php.net> |
| Sammy Kaye Powers <sammyk@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OBSERVER_H
#define ZEND_OBSERVER_H
#include "zend.h"
#include "zend_compile.h"
#include "zend_fibers.h"
BEGIN_EXTERN_C()
extern ZEND_API int zend_observer_fcall_op_array_extension;
extern ZEND_API bool zend_observer_errors_observed;
extern ZEND_API bool zend_observer_function_declared_observed;
extern ZEND_API bool zend_observer_class_linked_observed;
#define ZEND_OBSERVER_ENABLED (zend_observer_fcall_op_array_extension != -1)
#define ZEND_OBSERVER_FCALL_BEGIN(execute_data) do { \
if (ZEND_OBSERVER_ENABLED) { \
zend_observer_fcall_begin(execute_data); \
} \
} while (0)
#define ZEND_OBSERVER_FCALL_END(execute_data, return_value) do { \
if (ZEND_OBSERVER_ENABLED) { \
zend_observer_fcall_end(execute_data, return_value); \
} \
} while (0)
typedef void (*zend_observer_fcall_begin_handler)(zend_execute_data *execute_data);
typedef void (*zend_observer_fcall_end_handler)(zend_execute_data *execute_data, zval *retval);
typedef struct _zend_observer_fcall_handlers {
zend_observer_fcall_begin_handler begin;
zend_observer_fcall_end_handler end;
} zend_observer_fcall_handlers;
/* If the fn should not be observed then return {NULL, NULL} */
typedef zend_observer_fcall_handlers (*zend_observer_fcall_init)(zend_execute_data *execute_data);
// Call during minit/startup ONLY
ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init);
// Call during runtime, but only if you have used zend_observer_fcall_register.
// You must not have more than one begin and one end handler active at the same time. Remove the old one first, if there is an existing one.
ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin);
ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin);
ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end);
ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end);
ZEND_API void zend_observer_startup(void); // Called by engine before MINITs
ZEND_API void zend_observer_post_startup(void); // Called by engine after MINITs
ZEND_API void zend_observer_activate(void);
ZEND_API void zend_observer_shutdown(void);
ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(
zend_execute_data *execute_data);
ZEND_API void ZEND_FASTCALL zend_observer_generator_resume(
zend_execute_data *execute_data);
ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
zend_execute_data *execute_data,
zval *return_value);
ZEND_API void zend_observer_fcall_end_all(void);
typedef void (*zend_observer_function_declared_cb)(zend_op_array *op_array, zend_string *name);
ZEND_API void zend_observer_function_declared_register(zend_observer_function_declared_cb cb);
ZEND_API void ZEND_FASTCALL _zend_observer_function_declared_notify(zend_op_array *op_array, zend_string *name);
static inline void zend_observer_function_declared_notify(zend_op_array *op_array, zend_string *name) {
if (UNEXPECTED(zend_observer_function_declared_observed)) {
_zend_observer_function_declared_notify(op_array, name);
}
}
typedef void (*zend_observer_class_linked_cb)(zend_class_entry *ce, zend_string *name);
ZEND_API void zend_observer_class_linked_register(zend_observer_class_linked_cb cb);
ZEND_API void ZEND_FASTCALL _zend_observer_class_linked_notify(zend_class_entry *ce, zend_string *name);
static inline void zend_observer_class_linked_notify(zend_class_entry *ce, zend_string *name) {
if (UNEXPECTED(zend_observer_class_linked_observed)) {
_zend_observer_class_linked_notify(ce, name);
}
}
typedef void (*zend_observer_error_cb)(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message);
ZEND_API void zend_observer_error_register(zend_observer_error_cb callback);
ZEND_API void _zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message);
static inline void zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message) {
if (UNEXPECTED(zend_observer_errors_observed)) {
_zend_observer_error_notify(type, error_filename, error_lineno, message);
}
}
typedef void (*zend_observer_fiber_init_handler)(zend_fiber_context *initializing);
typedef void (*zend_observer_fiber_switch_handler)(zend_fiber_context *from, zend_fiber_context *to);
typedef void (*zend_observer_fiber_destroy_handler)(zend_fiber_context *destroying);
ZEND_API void zend_observer_fiber_init_register(zend_observer_fiber_init_handler handler);
ZEND_API void zend_observer_fiber_switch_register(zend_observer_fiber_switch_handler handler);
ZEND_API void zend_observer_fiber_destroy_register(zend_observer_fiber_destroy_handler handler);
ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *initializing);
ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context *from, zend_fiber_context *to);
ZEND_API void ZEND_FASTCALL zend_observer_fiber_destroy_notify(zend_fiber_context *destroying);
END_EXTERN_C()
#endif /* ZEND_OBSERVER_H */

View File

@ -0,0 +1,974 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
#include <errno.h>
#include <math.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#include "zend_portability.h"
#include "zend_strtod.h"
#include "zend_multiply.h"
#include "zend_object_handlers.h"
#define LONG_SIGN_MASK ZEND_LONG_MIN
BEGIN_EXTERN_C()
ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1);
ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1);
ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2);
ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce);
ZEND_API bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce);
static zend_always_inline bool instanceof_function(
const zend_class_entry *instance_ce, const zend_class_entry *ce) {
return instance_ce == ce || instanceof_function_slow(instance_ce, ce);
}
ZEND_API bool zend_string_only_has_ascii_alphanumeric(const zend_string *str);
/**
* Checks whether the string "str" with length "length" is numeric. The value
* of allow_errors determines whether it's required to be entirely numeric, or
* just its prefix. Leading whitespace is allowed.
*
* The function returns 0 if the string did not contain a valid number; IS_LONG
* if it contained a number that fits within the range of a long; or IS_DOUBLE
* if the number was out of long range or contained a decimal point/exponent.
* The number's value is returned into the respective pointer, *lval or *dval,
* if that pointer is not NULL.
*
* This variant also gives information if a string that represents an integer
* could not be represented as such due to overflow. It writes 1 to oflow_info
* if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN.
*/
ZEND_API uint8_t ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval,
double *dval, bool allow_errors, int *oflow_info, bool *trailing_data);
ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end);
ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end);
#if SIZEOF_ZEND_LONG == 4
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) > (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
#else
/* >= as (double)ZEND_LONG_MAX is outside signed range */
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) >= (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
#endif
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d);
static zend_always_inline zend_long zend_dval_to_lval(double d)
{
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
return 0;
} else if (!ZEND_DOUBLE_FITS_LONG(d)) {
return zend_dval_to_lval_slow(d);
}
return (zend_long)d;
}
/* Used to convert a string float to integer during an (int) cast */
static zend_always_inline zend_long zend_dval_to_lval_cap(double d)
{
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
return 0;
} else if (!ZEND_DOUBLE_FITS_LONG(d)) {
return (d > 0 ? ZEND_LONG_MAX : ZEND_LONG_MIN);
}
return (zend_long)d;
}
/* }}} */
static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) {
return (double)l == d;
}
ZEND_API void zend_incompatible_double_to_long_error(double d);
ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s);
static zend_always_inline zend_long zend_dval_to_lval_safe(double d)
{
zend_long l = zend_dval_to_lval(d);
if (!zend_is_long_compatible(d, l)) {
zend_incompatible_double_to_long_error(d);
}
return l;
}
#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
static zend_always_inline uint8_t is_numeric_string_ex(const char *str, size_t length, zend_long *lval,
double *dval, bool allow_errors, int *oflow_info, bool *trailing_data)
{
if (*str > '9') {
return 0;
}
return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info, trailing_data);
}
static zend_always_inline uint8_t is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors) {
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL, NULL);
}
ZEND_API uint8_t ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval);
static zend_always_inline const char *
zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end)
{
const char *p = haystack;
size_t off_s;
ZEND_ASSERT(end >= p);
if (needle_len == 1) {
return (const char *)memchr(p, *needle, (end-p));
} else if (UNEXPECTED(needle_len == 0)) {
return p;
}
off_s = (size_t)(end - p);
if (needle_len > off_s) {
return NULL;
}
if (EXPECTED(off_s < 1024 || needle_len < 9)) { /* glibc memchr is faster when needle is too short */
const char ne = needle[needle_len-1];
end -= needle_len;
while (p <= end) {
if ((p = (const char *)memchr(p, *needle, (end-p+1)))) {
if (ne == p[needle_len-1] && !memcmp(needle+1, p+1, needle_len-2)) {
return p;
}
} else {
return NULL;
}
p++;
}
return NULL;
} else {
return zend_memnstr_ex(haystack, needle, needle_len, end);
}
}
static zend_always_inline const void *zend_memrchr(const void *s, int c, size_t n)
{
#if defined(HAVE_MEMRCHR) && !defined(i386)
/* On x86 memrchr() doesn't use SSE/AVX, so inlined version is faster */
return (const void*)memrchr(s, c, n);
#else
const unsigned char *e;
if (0 == n) {
return NULL;
}
for (e = (const unsigned char *)s + n - 1; e >= (const unsigned char *)s; e--) {
if (*e == (unsigned char)c) {
return (const void *)e;
}
}
return NULL;
#endif
}
static zend_always_inline const char *
zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const char *end)
{
const char *p = end;
ptrdiff_t off_p;
size_t off_s;
if (needle_len == 0) {
return p;
}
if (needle_len == 1) {
return (const char *)zend_memrchr(haystack, *needle, (p - haystack));
}
off_p = end - haystack;
off_s = (off_p > 0) ? (size_t)off_p : 0;
if (needle_len > off_s) {
return NULL;
}
if (EXPECTED(off_s < 1024 || needle_len < 3)) {
const char ne = needle[needle_len-1];
p -= needle_len;
do {
p = (const char *)zend_memrchr(haystack, *needle, (p - haystack) + 1);
if (!p) {
return NULL;
}
if (ne == p[needle_len-1] && !memcmp(needle + 1, p + 1, needle_len - 2)) {
return p;
}
} while (p-- >= haystack);
return NULL;
} else {
return zend_memnrstr_ex(haystack, needle, needle_len, end);
}
}
static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen)
{
#if defined(HAVE_STRNLEN)
return strnlen(s, maxlen);
#else
const char *p = (const char *)memchr(s, '\0', maxlen);
return p ? p-s : maxlen;
#endif
}
ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1);
ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op2);
ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op);
ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_double(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_null(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_array(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_object(zval *op);
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_strict);
ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *failed);
ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op);
static zend_always_inline zend_long zval_get_long(const zval *op) {
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false);
}
static zend_always_inline zend_long zval_get_long_ex(const zval *op, bool is_strict) {
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_strict);
}
static zend_always_inline double zval_get_double(const zval *op) {
return EXPECTED(Z_TYPE_P(op) == IS_DOUBLE) ? Z_DVAL_P(op) : zval_get_double_func(op);
}
static zend_always_inline zend_string *zval_get_string(zval *op) {
return EXPECTED(Z_TYPE_P(op) == IS_STRING) ? zend_string_copy(Z_STR_P(op)) : zval_get_string_func(op);
}
static zend_always_inline zend_string *zval_get_tmp_string(zval *op, zend_string **tmp) {
if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) {
*tmp = NULL;
return Z_STR_P(op);
} else {
return *tmp = zval_get_string_func(op);
}
}
static zend_always_inline void zend_tmp_string_release(zend_string *tmp) {
if (UNEXPECTED(tmp)) {
zend_string_release_ex(tmp, 0);
}
}
/* Like zval_get_string, but returns NULL if the conversion fails with an exception. */
static zend_always_inline zend_string *zval_try_get_string(zval *op) {
if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) {
zend_string *ret = zend_string_copy(Z_STR_P(op));
ZEND_ASSUME(ret != NULL);
return ret;
} else {
return zval_try_get_string_func(op);
}
}
/* Like zval_get_tmp_string, but returns NULL if the conversion fails with an exception. */
static zend_always_inline zend_string *zval_try_get_tmp_string(zval *op, zend_string **tmp) {
if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) {
zend_string *ret = Z_STR_P(op);
*tmp = NULL;
ZEND_ASSUME(ret != NULL);
return ret;
} else {
return *tmp = zval_try_get_string_func(op);
}
}
/* Like convert_to_string(), but returns whether the conversion succeeded and does not modify the
* zval in-place if it fails. */
ZEND_API bool ZEND_FASTCALL _try_convert_to_string(zval *op);
static zend_always_inline bool try_convert_to_string(zval *op) {
if (Z_TYPE_P(op) == IS_STRING) {
return 1;
}
return _try_convert_to_string(op);
}
/* Compatibility macros for 7.2 and below */
#define _zval_get_long(op) zval_get_long(op)
#define _zval_get_double(op) zval_get_double(op)
#define _zval_get_string(op) zval_get_string(op)
#define _zval_get_long_func(op) zval_get_long_func(op)
#define _zval_get_double_func(op) zval_get_double_func(op)
#define _zval_get_string_func(op) zval_get_string_func(op)
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); }
ZEND_API int ZEND_FASTCALL zend_is_true(const zval *op);
ZEND_API bool ZEND_FASTCALL zend_object_is_true(const zval *op);
#define zval_is_true(op) \
zend_is_true(op)
static zend_always_inline bool i_zend_is_true(const zval *op)
{
bool result = 0;
again:
switch (Z_TYPE_P(op)) {
case IS_TRUE:
result = 1;
break;
case IS_LONG:
if (Z_LVAL_P(op)) {
result = 1;
}
break;
case IS_DOUBLE:
if (Z_DVAL_P(op)) {
result = 1;
}
break;
case IS_STRING:
if (Z_STRLEN_P(op) > 1 || (Z_STRLEN_P(op) && Z_STRVAL_P(op)[0] != '0')) {
result = 1;
}
break;
case IS_ARRAY:
if (zend_hash_num_elements(Z_ARRVAL_P(op))) {
result = 1;
}
break;
case IS_OBJECT:
if (EXPECTED(Z_OBJ_HT_P(op)->cast_object == zend_std_cast_object_tostring)) {
result = 1;
} else {
result = zend_object_is_true(op);
}
break;
case IS_RESOURCE:
if (EXPECTED(Z_RES_HANDLE_P(op))) {
result = 1;
}
break;
case IS_REFERENCE:
op = Z_REFVAL_P(op);
goto again;
break;
default:
break;
}
return result;
}
/* Indicate that two values cannot be compared. This value should be returned for both orderings
* of the operands. This implies that all of ==, <, <= and >, >= will return false, because we
* canonicalize >/>= to </<= with swapped operands. */
// TODO: Use a different value to allow an actual distinction here.
#define ZEND_UNCOMPARABLE 1
ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2);
ZEND_API zend_result ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2);
ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2);
ZEND_API int ZEND_FASTCALL string_compare_function_ex(zval *op1, zval *op2, bool case_insensitive);
ZEND_API int ZEND_FASTCALL string_compare_function(zval *op1, zval *op2);
ZEND_API int ZEND_FASTCALL string_case_compare_function(zval *op1, zval *op2);
ZEND_API int ZEND_FASTCALL string_locale_compare_function(zval *op1, zval *op2);
ZEND_API extern const unsigned char zend_tolower_map[256];
ZEND_API extern const unsigned char zend_toupper_map[256];
#define zend_tolower_ascii(c) (zend_tolower_map[(unsigned char)(c)])
#define zend_toupper_ascii(c) (zend_toupper_map[(unsigned char)(c)])
ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length);
ZEND_API void ZEND_FASTCALL zend_str_toupper(char *str, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_toupper_copy(char *dest, const char *source, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup(const char *source, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_toupper_dup(const char *source, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t length);
ZEND_API char* ZEND_FASTCALL zend_str_toupper_dup_ex(const char *source, size_t length);
ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent);
ZEND_API zend_string* ZEND_FASTCALL zend_string_toupper_ex(zend_string *str, bool persistent);
static zend_always_inline zend_string* zend_string_tolower(zend_string *str) {
return zend_string_tolower_ex(str, false);
}
static zend_always_inline zend_string* zend_string_toupper(zend_string *str) {
return zend_string_toupper_ex(str, false);
}
ZEND_API int ZEND_FASTCALL zend_binary_zval_strcmp(zval *s1, zval *s2);
ZEND_API int ZEND_FASTCALL zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3);
ZEND_API int ZEND_FASTCALL zend_binary_strcmp(const char *s1, size_t len1, const char *s2, size_t len2);
ZEND_API int ZEND_FASTCALL zend_binary_strncmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2);
ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2);
ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2);
ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2);
ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2);
ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2);
ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2);
/** Deprecatd in favor of ZEND_STRTOL() */
ZEND_ATTRIBUTE_DEPRECATED ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len);
/** Deprecatd in favor of ZEND_STRTOL() */
ZEND_ATTRIBUTE_DEPRECATED ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len);
#define convert_to_null_ex(zv) convert_to_null(zv)
#define convert_to_boolean_ex(zv) convert_to_boolean(zv)
#define convert_to_long_ex(zv) convert_to_long(zv)
#define convert_to_double_ex(zv) convert_to_double(zv)
#define convert_to_string_ex(zv) convert_to_string(zv)
#define convert_to_array_ex(zv) convert_to_array(zv)
#define convert_to_object_ex(zv) convert_to_object(zv)
#define convert_scalar_to_number_ex(zv) convert_scalar_to_number(zv)
ZEND_API void zend_update_current_locale(void);
ZEND_API void zend_reset_lc_ctype_locale(void);
/* The offset in bytes between the value and type fields of a zval */
#define ZVAL_OFFSETOF_TYPE \
(offsetof(zval, u1.type_info) - offsetof(zval, value))
#if defined(HAVE_ASM_GOTO) && !__has_feature(memory_sanitizer)
# define ZEND_USE_ASM_ARITHMETIC 1
#else
# define ZEND_USE_ASM_ARITHMETIC 0
#endif
static zend_always_inline void fast_long_increment_function(zval *op1)
{
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"addl $1,(%0)\n\t"
"jo %l1\n"
:
: "r"(&op1->value)
: "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"addq $1,(%0)\n\t"
"jo %l1\n"
:
: "r"(&op1->value)
: "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto (
"ldr x5, [%0]\n\t"
"adds x5, x5, 1\n\t"
"bvs %l1\n"
"str x5, [%0]"
:
: "r"(&op1->value)
: "x5", "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
#elif PHP_HAVE_BUILTIN_SADDL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
} else {
Z_LVAL_P(op1) = lresult;
}
#elif PHP_HAVE_BUILTIN_SADDLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_saddll_overflow(Z_LVAL_P(op1), 1, &llresult))) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
} else {
Z_LVAL_P(op1) = llresult;
}
#else
if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MAX)) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
} else {
Z_LVAL_P(op1)++;
}
#endif
}
static zend_always_inline void fast_long_decrement_function(zval *op1)
{
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"subl $1,(%0)\n\t"
"jo %l1\n"
:
: "r"(&op1->value)
: "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"subq $1,(%0)\n\t"
"jo %l1\n"
:
: "r"(&op1->value)
: "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto (
"ldr x5, [%0]\n\t"
"subs x5 ,x5, 1\n\t"
"bvs %l1\n"
"str x5, [%0]"
:
: "r"(&op1->value)
: "x5", "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
#elif PHP_HAVE_BUILTIN_SSUBL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
} else {
Z_LVAL_P(op1) = lresult;
}
#elif PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_ssubll_overflow(Z_LVAL_P(op1), 1, &llresult))) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
} else {
Z_LVAL_P(op1) = llresult;
}
#else
if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MIN)) {
/* switch to double */
ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
} else {
Z_LVAL_P(op1)--;
}
#endif
}
static zend_always_inline void fast_long_add_function(zval *result, zval *op1, zval *op2)
{
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"movl (%1), %%eax\n\t"
"addl (%2), %%eax\n\t"
"jo %l5\n\t"
"movl %%eax, (%0)\n\t"
"movl %3, %c4(%0)\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "eax","cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"movq (%1), %%rax\n\t"
"addq (%2), %%rax\n\t"
"jo %l5\n\t"
"movq %%rax, (%0)\n\t"
"movl %3, %c4(%0)\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "rax","cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto(
"ldr x5, [%1]\n\t"
"ldr x6, [%2]\n\t"
"adds x5, x5, x6\n\t"
"bvs %l5\n\t"
"mov w6, %3\n\t"
"str x5, [%0]\n\t"
"str w6, [%0, %c4]\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "x5", "x6", "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
#elif PHP_HAVE_BUILTIN_SADDL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, lresult);
}
#elif PHP_HAVE_BUILTIN_SADDLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_saddll_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, llresult);
}
#else
/*
* 'result' may alias with op1 or op2, so we need to
* ensure that 'result' is not updated until after we
* have read the values of op1 and op2.
*/
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != ((Z_LVAL_P(op1) + Z_LVAL_P(op2)) & LONG_SIGN_MASK))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, Z_LVAL_P(op1) + Z_LVAL_P(op2));
}
#endif
}
static zend_always_inline void fast_long_sub_function(zval *result, zval *op1, zval *op2)
{
#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
__asm__ goto(
"movl (%1), %%eax\n\t"
"subl (%2), %%eax\n\t"
"jo %l5\n\t"
"movl %%eax, (%0)\n\t"
"movl %3, %c4(%0)\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "eax","cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
__asm__ goto(
"movq (%1), %%rax\n\t"
"subq (%2), %%rax\n\t"
"jo %l5\n\t"
"movq %%rax, (%0)\n\t"
"movl %3, %c4(%0)\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "rax","cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
__asm__ goto(
"ldr x5, [%1]\n\t"
"ldr x6, [%2]\n\t"
"subs x5, x5, x6\n\t"
"bvs %l5\n\t"
"mov w6, %3\n\t"
"str x5, [%0]\n\t"
"str w6, [%0, %c4]\n"
:
: "r"(&result->value),
"r"(&op1->value),
"r"(&op2->value),
"n"(IS_LONG),
"n"(ZVAL_OFFSETOF_TYPE)
: "x5", "x6", "cc", "memory"
: overflow);
return;
overflow: ZEND_ATTRIBUTE_COLD_LABEL
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
#elif PHP_HAVE_BUILTIN_SSUBL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, lresult);
}
#elif PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_ssubll_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, llresult);
}
#else
ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2));
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
}
#endif
}
static zend_always_inline bool zend_fast_equal_strings(zend_string *s1, zend_string *s2)
{
if (s1 == s2) {
return 1;
} else if (ZSTR_VAL(s1)[0] > '9' || ZSTR_VAL(s2)[0] > '9') {
return zend_string_equal_content(s1, s2);
} else {
return zendi_smart_streq(s1, s2);
}
}
static zend_always_inline bool fast_equal_check_function(zval *op1, zval *op2)
{
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
return Z_LVAL_P(op1) == Z_LVAL_P(op2);
} else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
return ((double)Z_LVAL_P(op1)) == Z_DVAL_P(op2);
}
} else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
return Z_DVAL_P(op1) == Z_DVAL_P(op2);
} else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
return Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2));
}
} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2));
}
}
return zend_compare(op1, op2) == 0;
}
static zend_always_inline bool fast_equal_check_long(zval *op1, zval *op2)
{
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
return Z_LVAL_P(op1) == Z_LVAL_P(op2);
}
return zend_compare(op1, op2) == 0;
}
static zend_always_inline bool fast_equal_check_string(zval *op1, zval *op2)
{
if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2));
}
return zend_compare(op1, op2) == 0;
}
static zend_always_inline bool fast_is_identical_function(zval *op1, zval *op2)
{
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
return 0;
} else if (Z_TYPE_P(op1) <= IS_TRUE) {
return 1;
}
return zend_is_identical(op1, op2);
}
static zend_always_inline bool fast_is_not_identical_function(zval *op1, zval *op2)
{
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
return 1;
} else if (Z_TYPE_P(op1) <= IS_TRUE) {
return 0;
}
return !zend_is_identical(op1, op2);
}
/* buf points to the END of the buffer */
static zend_always_inline char *zend_print_ulong_to_buf(char *buf, zend_ulong num) {
*buf = '\0';
do {
*--buf = (char) (num % 10) + '0';
num /= 10;
} while (num > 0);
return buf;
}
/* buf points to the END of the buffer */
static zend_always_inline char *zend_print_long_to_buf(char *buf, zend_long num) {
if (num < 0) {
char *result = zend_print_ulong_to_buf(buf, ~((zend_ulong) num) + 1);
*--result = '-';
return result;
} else {
return zend_print_ulong_to_buf(buf, num);
}
}
ZEND_API zend_string* ZEND_FASTCALL zend_long_to_str(zend_long num);
ZEND_API zend_string* ZEND_FASTCALL zend_ulong_to_str(zend_ulong num);
ZEND_API zend_string* ZEND_FASTCALL zend_u64_to_str(uint64_t num);
ZEND_API zend_string* ZEND_FASTCALL zend_i64_to_str(int64_t num);
ZEND_API zend_string* ZEND_FASTCALL zend_double_to_str(double num);
static zend_always_inline void zend_unwrap_reference(zval *op) /* {{{ */
{
if (Z_REFCOUNT_P(op) == 1) {
ZVAL_UNREF(op);
} else {
Z_DELREF_P(op);
ZVAL_COPY(op, Z_REFVAL_P(op));
}
}
/* }}} */
static zend_always_inline bool zend_strnieq(const char *ptr1, const char *ptr2, size_t num)
{
const char *end = ptr1 + num;
while (ptr1 < end) {
if (zend_tolower_ascii(*ptr1++) != zend_tolower_ascii(*ptr2++)) {
return 0;
}
}
return 1;
}
static zend_always_inline const char *
zend_memnistr(const char *haystack, const char *needle, size_t needle_len, const char *end)
{
ZEND_ASSERT(end >= haystack);
if (UNEXPECTED(needle_len == 0)) {
return haystack;
}
if (UNEXPECTED(needle_len > (size_t)(end - haystack))) {
return NULL;
}
const char first_lower = zend_tolower_ascii(*needle);
const char first_upper = zend_toupper_ascii(*needle);
const char *p_lower = (const char *)memchr(haystack, first_lower, end - haystack);
const char *p_upper = NULL;
if (first_lower != first_upper) {
// If the needle length is 1 we don't need to look beyond p_lower as it is a guaranteed match
size_t upper_search_length = needle_len == 1 && p_lower != NULL ? p_lower - haystack : end - haystack;
p_upper = (const char *)memchr(haystack, first_upper, upper_search_length);
}
const char *p = !p_upper || (p_lower && p_lower < p_upper) ? p_lower : p_upper;
if (needle_len == 1) {
return p;
}
const char needle_end_lower = zend_tolower_ascii(needle[needle_len - 1]);
const char needle_end_upper = zend_toupper_ascii(needle[needle_len - 1]);
end -= needle_len;
while (p && p <= end) {
if (needle_end_lower == p[needle_len - 1] || needle_end_upper == p[needle_len - 1]) {
if (zend_strnieq(needle + 1, p + 1, needle_len - 2)) {
return p;
}
}
if (p_lower == p) {
p_lower = (const char *)memchr(p_lower + 1, first_lower, end - p_lower);
}
if (p_upper == p) {
p_upper = (const char *)memchr(p_upper + 1, first_upper, end - p_upper);
}
p = !p_upper || (p_lower && p_lower < p_upper) ? p_lower : p_upper;
}
return NULL;
}
END_EXTERN_C()
#endif

View File

@ -0,0 +1,770 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_PORTABILITY_H
#define ZEND_PORTABILITY_H
#ifdef __cplusplus
#define BEGIN_EXTERN_C() extern "C" {
#define END_EXTERN_C() }
#else
#define BEGIN_EXTERN_C()
#define END_EXTERN_C()
#endif
/*
* general definitions
*/
#ifdef ZEND_WIN32
# include "zend_config.w32.h"
# define ZEND_PATHS_SEPARATOR ';'
#elif defined(__riscos__)
# include <zend_config.h>
# define ZEND_PATHS_SEPARATOR ';'
#else
# include <zend_config.h>
# define ZEND_PATHS_SEPARATOR ':'
#endif
#include "../TSRM/TSRM.h"
#include <stdio.h>
#include <assert.h>
#include <math.h>
#ifdef HAVE_UNIX_H
# include <unix.h>
#endif
#include <stdarg.h>
#include <stddef.h>
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
#include <limits.h>
#if defined(ZEND_WIN32) && !defined(__clang__)
#include <intrin.h>
#endif
#include "zend_range_check.h"
/* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */
#ifdef __GNUC__
# define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
#else
# define ZEND_GCC_VERSION 0
#endif
/* Compatibility with non-clang compilers */
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#if defined(ZEND_WIN32) && !defined(__clang__)
# define ZEND_ASSUME(c) __assume(c)
#elif defined(__clang__) && __has_builtin(__builtin_assume)
# pragma clang diagnostic ignored "-Wassume"
# define ZEND_ASSUME(c) __builtin_assume(c)
#elif ((defined(__GNUC__) && ZEND_GCC_VERSION >= 4005) || __has_builtin(__builtin_unreachable)) && PHP_HAVE_BUILTIN_EXPECT
# define ZEND_ASSUME(c) do { \
if (__builtin_expect(!(c), 0)) __builtin_unreachable(); \
} while (0)
#else
# define ZEND_ASSUME(c)
#endif
#if ZEND_DEBUG
# define ZEND_ASSERT(c) assert(c)
#else
# define ZEND_ASSERT(c) ZEND_ASSUME(c)
#endif
#if ZEND_DEBUG
# define ZEND_UNREACHABLE() do {ZEND_ASSERT(0); ZEND_ASSUME(0);} while (0)
#else
# define ZEND_UNREACHABLE() ZEND_ASSUME(0)
#endif
/* pseudo fallthrough keyword; */
#if defined(__GNUC__) && __GNUC__ >= 7
# define ZEND_FALLTHROUGH __attribute__((__fallthrough__))
#else
# define ZEND_FALLTHROUGH ((void)0)
#endif
/* Only use this macro if you know for sure that all of the switches values
are covered by its case statements */
#define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_UNREACHABLE(); break;
#if defined(__GNUC__) && __GNUC__ >= 4
# define ZEND_IGNORE_VALUE(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
#else
# define ZEND_IGNORE_VALUE(x) ((void) (x))
#endif
#define zend_quiet_write(...) ZEND_IGNORE_VALUE(write(__VA_ARGS__))
/* all HAVE_XXX test have to be after the include of zend_config above */
#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
# if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__
# endif
# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
# endif
# ifndef RTLD_GLOBAL
# define RTLD_GLOBAL 0
# endif
# ifdef PHP_USE_RTLD_NOW
# define PHP_RTLD_MODE RTLD_NOW
# else
# define PHP_RTLD_MODE RTLD_LAZY
# endif
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
# else
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
# endif
# define DL_UNLOAD dlclose
# if defined(DLSYM_NEEDS_UNDERSCORE)
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
# else
# define DL_FETCH_SYMBOL dlsym
# endif
# define DL_ERROR dlerror
# define DL_HANDLE void *
# define ZEND_EXTENSIONS_SUPPORT 1
#elif defined(ZEND_WIN32)
# define DL_LOAD(libname) LoadLibrary(libname)
# define DL_FETCH_SYMBOL GetProcAddress
# define DL_UNLOAD FreeLibrary
# define DL_HANDLE HMODULE
# define ZEND_EXTENSIONS_SUPPORT 1
#else
# define DL_HANDLE void *
# define ZEND_EXTENSIONS_SUPPORT 0
#endif
#if defined(HAVE_ALLOCA_H) && !defined(_ALLOCA_H)
# include <alloca.h>
#endif
/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# ifndef HAVE_ALLOCA_H
# ifdef _AIX
# pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca();
# endif
# endif
# endif
#endif
#if !ZEND_DEBUG && (defined(HAVE_ALLOCA) || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
# define ALLOCA_FLAG(name) \
bool name;
# define SET_ALLOCA_FLAG(name) \
name = true
# define do_alloca_ex(size, limit, use_heap) \
((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
# define do_alloca(size, use_heap) \
do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
# define free_alloca(p, use_heap) \
do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
#else
# define ALLOCA_FLAG(name)
# define SET_ALLOCA_FLAG(name)
# define do_alloca(p, use_heap) emalloc(p)
# define free_alloca(p, use_heap) efree(p)
#endif
#if ZEND_GCC_VERSION >= 2096 || __has_attribute(__malloc__)
# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
#elif defined(ZEND_WIN32)
# define ZEND_ATTRIBUTE_MALLOC __declspec(allocator) __declspec(restrict)
#else
# define ZEND_ATTRIBUTE_MALLOC
#endif
#if ZEND_GCC_VERSION >= 4003 || __has_attribute(alloc_size)
# define ZEND_ATTRIBUTE_ALLOC_SIZE(X) __attribute__ ((alloc_size(X)))
# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y) __attribute__ ((alloc_size(X,Y)))
#else
# define ZEND_ATTRIBUTE_ALLOC_SIZE(X)
# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y)
#endif
#if ZEND_GCC_VERSION >= 3000
# define ZEND_ATTRIBUTE_CONST __attribute__((const))
#else
# define ZEND_ATTRIBUTE_CONST
#endif
#if ZEND_GCC_VERSION >= 2007 || __has_attribute(format)
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
#else
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
#endif
#if (ZEND_GCC_VERSION >= 3001 && !defined(__INTEL_COMPILER)) || __has_attribute(format)
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
#else
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
#endif
#if ZEND_GCC_VERSION >= 3001 || __has_attribute(deprecated)
# define ZEND_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
#elif defined(ZEND_WIN32)
# define ZEND_ATTRIBUTE_DEPRECATED __declspec(deprecated)
#else
# define ZEND_ATTRIBUTE_DEPRECATED
#endif
#if ZEND_GCC_VERSION >= 4003 || __has_attribute(unused)
# define ZEND_ATTRIBUTE_UNUSED __attribute__((unused))
#else
# define ZEND_ATTRIBUTE_UNUSED
#endif
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 4003
# define ZEND_COLD __attribute__((cold))
# ifdef __OPTIMIZE__
# define ZEND_OPT_SIZE __attribute__((optimize("Os")))
# define ZEND_OPT_SPEED __attribute__((optimize("Ofast")))
# else
# define ZEND_OPT_SIZE
# define ZEND_OPT_SPEED
# endif
#else
# define ZEND_COLD
# define ZEND_OPT_SIZE
# define ZEND_OPT_SPEED
#endif
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 5000
# define ZEND_ATTRIBUTE_UNUSED_LABEL __attribute__((unused));
# define ZEND_ATTRIBUTE_COLD_LABEL __attribute__((cold));
#else
# define ZEND_ATTRIBUTE_UNUSED_LABEL
# define ZEND_ATTRIBUTE_COLD_LABEL
#endif
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
# define ZEND_FASTCALL __attribute__((fastcall))
#elif defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER == 1700
# define ZEND_FASTCALL __fastcall
#elif defined(_MSC_VER) && _MSC_VER >= 1800 && !defined(__clang__)
# define ZEND_FASTCALL __vectorcall
#else
# define ZEND_FASTCALL
#endif
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
# define HAVE_NORETURN
# define ZEND_NORETURN __attribute__((noreturn))
#elif defined(ZEND_WIN32)
# define HAVE_NORETURN
# define ZEND_NORETURN __declspec(noreturn)
#else
# define ZEND_NORETURN
#endif
#if __has_attribute(force_align_arg_pointer)
# define ZEND_STACK_ALIGNED __attribute__((force_align_arg_pointer))
#else
# define ZEND_STACK_ALIGNED
#endif
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__))
# define HAVE_NORETURN_ALIAS
# define HAVE_ATTRIBUTE_WEAK
#endif
#if ZEND_GCC_VERSION >= 3001 || __has_builtin(__builtin_constant_p)
# define HAVE_BUILTIN_CONSTANT_P
#endif
#ifdef HAVE_BUILTIN_CONSTANT_P
# define ZEND_CONST_COND(_condition, _default) \
(__builtin_constant_p(_condition) ? (_condition) : (_default))
#else
# define ZEND_CONST_COND(_condition, _default) \
(_default)
#endif
#if ZEND_DEBUG || defined(ZEND_WIN32_NEVER_INLINE)
# define zend_always_inline inline
# define zend_never_inline
#else
# if defined(__GNUC__)
# if __GNUC__ >= 3
# define zend_always_inline inline __attribute__((always_inline))
# define zend_never_inline __attribute__((noinline))
# else
# define zend_always_inline inline
# define zend_never_inline
# endif
# elif defined(_MSC_VER)
# define zend_always_inline __forceinline
# define zend_never_inline __declspec(noinline)
# else
# if __has_attribute(always_inline)
# define zend_always_inline inline __attribute__((always_inline))
# else
# define zend_always_inline inline
# endif
# if __has_attribute(noinline)
# define zend_never_inline __attribute__((noinline))
# else
# define zend_never_inline
# endif
# endif
#endif /* ZEND_DEBUG */
#ifdef PHP_HAVE_BUILTIN_EXPECT
# define EXPECTED(condition) __builtin_expect(!!(condition), 1)
# define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
#else
# define EXPECTED(condition) (condition)
# define UNEXPECTED(condition) (condition)
#endif
#ifndef XtOffsetOf
# define XtOffsetOf(s_type, field) offsetof(s_type, field)
#endif
#ifdef HAVE_SIGSETJMP
# define SETJMP(a) sigsetjmp(a, 0)
# define LONGJMP(a,b) siglongjmp(a, b)
# define JMP_BUF sigjmp_buf
#else
# define SETJMP(a) setjmp(a)
# define LONGJMP(a,b) longjmp(a, b)
# define JMP_BUF jmp_buf
#endif
#if ZEND_DEBUG
# define ZEND_FILE_LINE_D const char *__zend_filename, const uint32_t __zend_lineno
# define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
# define ZEND_FILE_LINE_ORIG_D const char *__zend_orig_filename, const uint32_t __zend_orig_lineno
# define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
# define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
# define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
# define ZEND_FILE_LINE_C __FILE__, __LINE__
# define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
# define ZEND_FILE_LINE_EMPTY_C NULL, 0
# define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
# define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
# define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
#else
# define ZEND_FILE_LINE_D void
# define ZEND_FILE_LINE_DC
# define ZEND_FILE_LINE_ORIG_D void
# define ZEND_FILE_LINE_ORIG_DC
# define ZEND_FILE_LINE_RELAY_C
# define ZEND_FILE_LINE_RELAY_CC
# define ZEND_FILE_LINE_C
# define ZEND_FILE_LINE_CC
# define ZEND_FILE_LINE_EMPTY_C
# define ZEND_FILE_LINE_EMPTY_CC
# define ZEND_FILE_LINE_ORIG_RELAY_C
# define ZEND_FILE_LINE_ORIG_RELAY_CC
#endif /* ZEND_DEBUG */
#if ZEND_DEBUG
# define Z_DBG(expr) (expr)
#else
# define Z_DBG(expr)
#endif
#ifdef ZTS
# define ZTS_V 1
#else
# define ZTS_V 0
#endif
#ifndef LONG_MAX
# define LONG_MAX 2147483647L
#endif
#ifndef LONG_MIN
# define LONG_MIN (- LONG_MAX - 1)
#endif
#define MAX_LENGTH_OF_DOUBLE 32
#undef MIN
#undef MAX
#define MAX(a, b) (((a)>(b))?(a):(b))
#define MIN(a, b) (((a)<(b))?(a):(b))
#define ZEND_BIT_TEST(bits, bit) \
(((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
#define ZEND_INFINITY INFINITY
#define ZEND_NAN NAN
#if defined(__cplusplus) && __cplusplus >= 201103L
extern "C++" {
# include <cmath>
}
# define zend_isnan std::isnan
# define zend_isinf std::isinf
# define zend_finite std::isfinite
#else
# include <math.h>
# define zend_isnan(a) isnan(a)
# define zend_isinf(a) isinf(a)
# define zend_finite(a) isfinite(a)
#endif
#define ZEND_STRL(str) (str), (sizeof(str)-1)
#define ZEND_STRS(str) (str), (sizeof(str))
#define ZEND_NORMALIZE_BOOL(n) \
((n) ? (((n)<0) ? -1 : 1) : 0)
#define ZEND_TRUTH(x) ((x) ? 1 : 0)
#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
/**
* Do a three-way comparison of two integers and returns -1, 0 or 1
* depending on whether #a is smaller, equal or larger than #b.
*/
#define ZEND_THREEWAY_COMPARE(a, b) ((a) == (b) ? 0 : ((a) < (b) ? -1 : 1))
#define ZEND_MAX_RESERVED_RESOURCES 6
/* excpt.h on Digital Unix 4.0 defines function_table */
#undef function_table
#ifdef ZEND_WIN32
#define ZEND_SECURE_ZERO(var, size) RtlSecureZeroMemory((var), (size))
#else
#define ZEND_SECURE_ZERO(var, size) explicit_bzero((var), (size))
#endif
/* This check should only be used on network socket, not file descriptors */
#ifdef ZEND_WIN32
#define ZEND_VALID_SOCKET(sock) (INVALID_SOCKET != (sock))
#else
#define ZEND_VALID_SOCKET(sock) ((sock) >= 0)
#endif
/* Intrinsics macros start. */
/* Memory sanitizer is incompatible with ifunc resolvers. Even if the resolver
* is marked as no_sanitize("memory") it will still be instrumented and crash. */
#if __has_feature(memory_sanitizer) || __has_feature(thread_sanitizer) || \
__has_feature(dataflow_sanitizer)
# undef HAVE_FUNC_ATTRIBUTE_IFUNC
#endif
/* Only use ifunc resolvers if we have __builtin_cpu_supports() and __builtin_cpu_init(),
* otherwise the use of zend_cpu_supports() may not be safe inside ifunc resolvers. */
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \
defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(PHP_HAVE_BUILTIN_CPU_INIT)
# define ZEND_INTRIN_HAVE_IFUNC_TARGET 1
#endif
#if (defined(__i386__) || defined(__x86_64__))
# if defined(HAVE_TMMINTRIN_H)
# define PHP_HAVE_SSSE3
# endif
# if defined(HAVE_NMMINTRIN_H)
# define PHP_HAVE_SSE4_2
# endif
# if defined(HAVE_WMMINTRIN_H)
# define PHP_HAVE_PCLMUL
# endif
/*
* AVX2 support was added in gcc 4.7, but AVX2 intrinsics don't work in
* __attribute__((target("avx2"))) functions until gcc 4.9.
*/
# if defined(HAVE_IMMINTRIN_H) && \
(defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
# define PHP_HAVE_AVX2
# endif
#endif
#ifdef __SSSE3__
/* Instructions compiled directly. */
# define ZEND_INTRIN_SSSE3_NATIVE 1
#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSSE3)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
/* Function resolved by ifunc or MINIT. */
# define ZEND_INTRIN_SSSE3_RESOLVER 1
#endif
/* Do not use for conditional declaration of API functions! */
#if defined(ZEND_INTRIN_SSSE3_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
# define ZEND_INTRIN_SSSE3_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_SSSE3_RESOLVER)
# define ZEND_INTRIN_SSSE3_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_SSSE3_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) ZEND_API func __attribute__((target("ssse3")))
# else
# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_SSSE3_FUNC_DECL(func)
#endif
#ifdef __SSE4_2__
/* Instructions compiled directly. */
# define ZEND_INTRIN_SSE4_2_NATIVE 1
#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSE4_2)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
/* Function resolved by ifunc or MINIT. */
# define ZEND_INTRIN_SSE4_2_RESOLVER 1
#endif
/* Do not use for conditional declaration of API functions! */
#if defined(ZEND_INTRIN_SSE4_2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
# define ZEND_INTRIN_SSE4_2_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_SSE4_2_RESOLVER)
# define ZEND_INTRIN_SSE4_2_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_SSE4_2_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2")))
# else
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func)
#endif
#ifdef __PCLMUL__
/* Instructions compiled directly. */
# define ZEND_INTRIN_PCLMUL_NATIVE 1
#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_PCLMUL)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
/* Function resolved by ifunc or MINIT. */
# define ZEND_INTRIN_PCLMUL_RESOLVER 1
#endif
/* Do not use for conditional declaration of API functions! */
#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
/* __builtin_cpu_supports has pclmul from gcc9 */
# define ZEND_INTRIN_PCLMUL_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_PCLMUL_RESOLVER)
# define ZEND_INTRIN_PCLMUL_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_PCLMUL_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func) ZEND_API func __attribute__((target("pclmul")))
# else
# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func)
#endif
#if defined(ZEND_INTRIN_SSE4_2_NATIVE) && defined(ZEND_INTRIN_PCLMUL_NATIVE)
/* Instructions compiled directly. */
# define ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE 1
#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSE4_2) && defined(PHP_HAVE_PCLMUL)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
/* Function resolved by ifunc or MINIT. */
# define ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER 1
#endif
/* Do not use for conditional declaration of API functions! */
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
/* __builtin_cpu_supports has pclmul from gcc9 */
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2,pclmul")))
# else
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func)
#endif
#ifdef __AVX2__
# define ZEND_INTRIN_AVX2_NATIVE 1
#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_AVX2)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
# define ZEND_INTRIN_AVX2_RESOLVER 1
#endif
/* Do not use for conditional declaration of API functions! */
#if defined(ZEND_INTRIN_AVX2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
# define ZEND_INTRIN_AVX2_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_AVX2_RESOLVER)
# define ZEND_INTRIN_AVX2_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_AVX2_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_AVX2_FUNC_DECL(func) ZEND_API func __attribute__((target("avx2")))
# else
# define ZEND_INTRIN_AVX2_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_AVX2_FUNC_DECL(func)
#endif
#if PHP_HAVE_AVX512_SUPPORTS && defined(HAVE_FUNC_ATTRIBUTE_TARGET) || defined(ZEND_WIN32)
#define ZEND_INTRIN_AVX512_RESOLVER 1
#endif
#if defined(ZEND_INTRIN_AVX512_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
# define ZEND_INTRIN_AVX512_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_AVX512_RESOLVER)
# define ZEND_INTRIN_AVX512_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_AVX512_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_AVX512_FUNC_DECL(func) ZEND_API func __attribute__((target("avx512f,avx512cd,avx512vl,avx512dq,avx512bw")))
# else
# define ZEND_INTRIN_AVX512_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_AVX512_FUNC_DECL(func)
#endif
#if PHP_HAVE_AVX512_VBMI_SUPPORTS && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
#define ZEND_INTRIN_AVX512_VBMI_RESOLVER 1
#endif
#if defined(ZEND_INTRIN_AVX512_VBMI_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
# define ZEND_INTRIN_AVX512_VBMI_FUNC_PROTO 1
#elif defined(ZEND_INTRIN_AVX512_VBMI_RESOLVER)
# define ZEND_INTRIN_AVX512_VBMI_FUNC_PTR 1
#endif
#ifdef ZEND_INTRIN_AVX512_VBMI_RESOLVER
# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func) ZEND_API func __attribute__((target("avx512f,avx512cd,avx512vl,avx512dq,avx512bw,avx512vbmi")))
# else
# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func) func
# endif
#else
# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func)
#endif
/* Intrinsics macros end. */
#ifdef ZEND_WIN32
# define ZEND_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl
#elif defined(HAVE_ATTRIBUTE_ALIGNED)
# define ZEND_SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment)))
#else
# define ZEND_SET_ALIGNED(alignment, decl) decl
#endif
#define ZEND_SLIDE_TO_ALIGNED(alignment, ptr) (((uintptr_t)(ptr) + ((alignment)-1)) & ~((alignment)-1))
#define ZEND_SLIDE_TO_ALIGNED16(ptr) ZEND_SLIDE_TO_ALIGNED(Z_UL(16), ptr)
#ifdef ZEND_WIN32
# define _ZEND_EXPAND_VA(a) a
# define ZEND_EXPAND_VA(code) _ZEND_EXPAND_VA(code)
#else
# define ZEND_EXPAND_VA(code) code
#endif
/* On CPU with few registers, it's cheaper to reload value then use spill slot */
#if defined(__i386__) || (defined(_WIN32) && !defined(_WIN64))
# define ZEND_PREFER_RELOAD
#endif
#if defined(ZEND_WIN32) && defined(_DEBUG)
# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
#else
# define ZEND_IGNORE_LEAKS_BEGIN()
# define ZEND_IGNORE_LEAKS_END()
#endif
/* MSVC yields C4090 when a (const T **) is passed to a (void *); ZEND_VOIDP works around that */
#ifdef _MSC_VER
# define ZEND_VOIDP(ptr) ((void *) ptr)
#else
# define ZEND_VOIDP(ptr) (ptr)
#endif
#if __has_attribute(__indirect_return__)
# define ZEND_INDIRECT_RETURN __attribute__((__indirect_return__))
#else
# define ZEND_INDIRECT_RETURN
#endif
#define __ZEND_DO_PRAGMA(x) _Pragma(#x)
#define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
#if defined(__clang__)
# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
_Pragma("clang diagnostic push") \
_ZEND_DO_PRAGMA(clang diagnostic ignored warning)
# define ZEND_DIAGNOSTIC_IGNORED_END \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
_Pragma("GCC diagnostic push") \
_ZEND_DO_PRAGMA(GCC diagnostic ignored warning)
# define ZEND_DIAGNOSTIC_IGNORED_END \
_Pragma("GCC diagnostic pop")
#else
# define ZEND_DIAGNOSTIC_IGNORED_START(warning)
# define ZEND_DIAGNOSTIC_IGNORED_END
#endif
/** @deprecated */
#define ZEND_CGG_DIAGNOSTIC_IGNORED_START ZEND_DIAGNOSTIC_IGNORED_START
/** @deprecated */
#define ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
# define ZEND_STATIC_ASSERT(c, m) _Static_assert((c), m)
#else
# define ZEND_STATIC_ASSERT(c, m)
#endif
#endif /* ZEND_PORTABILITY_H */

View File

@ -0,0 +1,118 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_PTR_STACK_H
#define ZEND_PTR_STACK_H
typedef struct _zend_ptr_stack {
int top, max;
void **elements;
void **top_element;
bool persistent;
} zend_ptr_stack;
#define PTR_STACK_BLOCK_SIZE 64
BEGIN_EXTERN_C()
ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack);
ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, bool persistent);
ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...);
ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...);
ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack);
ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *));
ZEND_API void zend_ptr_stack_reverse_apply(zend_ptr_stack *stack, void (*func)(void *));
ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), bool free_elements);
ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack);
END_EXTERN_C()
#define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count) \
if (stack->top+count > stack->max) { \
/* we need to allocate more memory */ \
do { \
stack->max += PTR_STACK_BLOCK_SIZE; \
} while (stack->top+count > stack->max); \
stack->elements = (void **) safe_perealloc(stack->elements, sizeof(void *), (stack->max), 0, stack->persistent); \
stack->top_element = stack->elements+stack->top; \
}
/* Not doing this with a macro because of the loop unrolling in the element assignment.
Just using a macro for 3 in the body for readability sake. */
static zend_always_inline void zend_ptr_stack_3_push(zend_ptr_stack *stack, void *a, void *b, void *c)
{
#define ZEND_PTR_STACK_NUM_ARGS 3
ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
stack->top += ZEND_PTR_STACK_NUM_ARGS;
*(stack->top_element++) = a;
*(stack->top_element++) = b;
*(stack->top_element++) = c;
#undef ZEND_PTR_STACK_NUM_ARGS
}
static zend_always_inline void zend_ptr_stack_2_push(zend_ptr_stack *stack, void *a, void *b)
{
#define ZEND_PTR_STACK_NUM_ARGS 2
ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
stack->top += ZEND_PTR_STACK_NUM_ARGS;
*(stack->top_element++) = a;
*(stack->top_element++) = b;
#undef ZEND_PTR_STACK_NUM_ARGS
}
static zend_always_inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void **b, void **c)
{
*a = *(--stack->top_element);
*b = *(--stack->top_element);
*c = *(--stack->top_element);
stack->top -= 3;
}
static zend_always_inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, void **a, void **b)
{
*a = *(--stack->top_element);
*b = *(--stack->top_element);
stack->top -= 2;
}
static zend_always_inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)
{
ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, 1)
stack->top++;
*(stack->top_element++) = ptr;
}
static zend_always_inline void *zend_ptr_stack_pop(zend_ptr_stack *stack)
{
stack->top--;
return *(--stack->top_element);
}
static zend_always_inline void *zend_ptr_stack_top(zend_ptr_stack *stack)
{
return stack->elements[stack->top - 1];
}
#endif /* ZEND_PTR_STACK_H */

View File

@ -0,0 +1,67 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_RANGE_CHECK_H
#define ZEND_RANGE_CHECK_H
#include "zend_long.h"
/* Flag macros for basic range recognition. Notable is that
always sizeof(signed) == sizeof(unsigned), so no need to
overcomplicate things. */
#if SIZEOF_INT < SIZEOF_ZEND_LONG
# define ZEND_LONG_CAN_OVFL_INT 1
# define ZEND_LONG_CAN_OVFL_UINT 1
#endif
#if SIZEOF_INT < SIZEOF_SIZE_T
/* size_t can always overflow signed int on the same platform.
Furthermore, by the current design, size_t can always
overflow zend_long. */
# define ZEND_SIZE_T_CAN_OVFL_UINT 1
#endif
/* zend_long vs. (unsigned) int checks. */
#ifdef ZEND_LONG_CAN_OVFL_INT
# define ZEND_LONG_INT_OVFL(zlong) UNEXPECTED((zlong) > (zend_long)INT_MAX)
# define ZEND_LONG_INT_UDFL(zlong) UNEXPECTED((zlong) < (zend_long)INT_MIN)
# define ZEND_LONG_EXCEEDS_INT(zlong) UNEXPECTED(ZEND_LONG_INT_OVFL(zlong) || ZEND_LONG_INT_UDFL(zlong))
# define ZEND_LONG_UINT_OVFL(zlong) UNEXPECTED((zlong) < 0 || (zlong) > (zend_long)UINT_MAX)
#else
# define ZEND_LONG_INT_OVFL(zl) (0)
# define ZEND_LONG_INT_UDFL(zl) (0)
# define ZEND_LONG_EXCEEDS_INT(zlong) (0)
# define ZEND_LONG_UINT_OVFL(zl) (0)
#endif
/* size_t vs (unsigned) int checks. */
#define ZEND_SIZE_T_INT_OVFL(size) UNEXPECTED((size) > (size_t)INT_MAX)
#ifdef ZEND_SIZE_T_CAN_OVFL_UINT
# define ZEND_SIZE_T_UINT_OVFL(size) UNEXPECTED((size) > (size_t)UINT_MAX)
#else
# define ZEND_SIZE_T_UINT_OVFL(size) (0)
#endif
/* Comparison zend_long vs size_t */
#define ZEND_SIZE_T_GT_ZEND_LONG(size, zlong) ((zlong) < 0 || (size) > (size_t)(zlong))
#define ZEND_SIZE_T_GTE_ZEND_LONG(size, zlong) ((zlong) < 0 || (size) >= (size_t)(zlong))
#define ZEND_SIZE_T_LT_ZEND_LONG(size, zlong) ((zlong) >= 0 && (size) < (size_t)(zlong))
#define ZEND_SIZE_T_LTE_ZEND_LONG(size, zlong) ((zlong) >= 0 && (size) <= (size_t)(zlong))
#endif /* ZEND_RANGE_CHECK_H */

View File

@ -0,0 +1,112 @@
/*
+----------------------------------------------------------------------+
| Zend Signal Handling |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Lucas Nealan <lucas@php.net> |
| Arnaud Le Blanc <lbarnaud@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SIGNAL_H
#define ZEND_SIGNAL_H
#ifdef ZEND_SIGNALS
#include <signal.h>
#ifndef NSIG
#define NSIG 65
#endif
#ifndef ZEND_SIGNAL_QUEUE_SIZE
#define ZEND_SIGNAL_QUEUE_SIZE 64
#endif
/* Signal structs */
typedef struct _zend_signal_entry_t {
int flags; /* sigaction style flags */
void* handler; /* signal handler or context */
} zend_signal_entry_t;
typedef struct _zend_signal_t {
int signo;
siginfo_t *siginfo;
void* context;
} zend_signal_t;
typedef struct _zend_signal_queue_t {
zend_signal_t zend_signal;
struct _zend_signal_queue_t *next;
} zend_signal_queue_t;
/* Signal Globals */
typedef struct _zend_signal_globals_t {
int depth;
int blocked; /* 1==TRUE, 0==FALSE */
int running; /* in signal handler execution */
int active; /* internal signal handling is enabled */
bool check; /* check for replaced handlers on shutdown */
bool reset; /* reset signal handlers on each request */
zend_signal_entry_t handlers[NSIG];
zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
} zend_signal_globals_t;
# ifdef ZTS
# define SIGG(v) ZEND_TSRMG_FAST(zend_signal_globals_offset, zend_signal_globals_t *, v)
BEGIN_EXTERN_C()
ZEND_API extern int zend_signal_globals_id;
ZEND_API extern size_t zend_signal_globals_offset;
END_EXTERN_C()
# else
# define SIGG(v) (zend_signal_globals.v)
BEGIN_EXTERN_C()
ZEND_API extern zend_signal_globals_t zend_signal_globals;
END_EXTERN_C()
# endif /* not ZTS */
# ifdef ZTS
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED(((SIGG(depth)--) == SIGG(blocked)))) { zend_signal_handler_unblock(); }
# else /* ZTS */
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() SIGG(depth)++;
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (((SIGG(depth)--) == SIGG(blocked))) { zend_signal_handler_unblock(); }
# endif /* not ZTS */
ZEND_API void zend_signal_handler_unblock(void);
void zend_signal_activate(void);
void zend_signal_deactivate(void);
BEGIN_EXTERN_C()
ZEND_API void zend_signal_startup(void);
END_EXTERN_C()
void zend_signal_init(void);
ZEND_API void zend_signal(int signo, void (*handler)(int));
ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact);
#else /* ZEND_SIGNALS */
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
# define zend_signal_activate()
# define zend_signal_deactivate()
# define zend_signal_startup()
# define zend_signal_init()
# define zend_signal(signo, handler) signal(signo, handler)
# define zend_sigaction(signo, act, oldact) sigaction(signo, act, oldact)
#endif /* ZEND_SIGNALS */
#endif /* ZEND_SIGNAL_H */

View File

@ -0,0 +1,200 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SMART_STR_H
#define ZEND_SMART_STR_H
#include <zend.h>
#include "zend_globals.h"
#include "zend_smart_str_public.h"
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL smart_str_erealloc(smart_str *str, size_t len);
ZEND_API void ZEND_FASTCALL smart_str_realloc(smart_str *str, size_t len);
ZEND_API void ZEND_FASTCALL smart_str_append_escaped(smart_str *str, const char *s, size_t l);
/* If zero_fraction is true, then a ".0" will be added to numbers that would not otherwise
* have a fractional part and look like integers. */
ZEND_API void ZEND_FASTCALL smart_str_append_double(
smart_str *str, double num, int precision, bool zero_fraction);
ZEND_API void smart_str_append_printf(smart_str *dest, const char *format, ...)
ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API void ZEND_FASTCALL smart_str_append_escaped_truncated(smart_str *str, const zend_string *value, size_t length);
ZEND_API void ZEND_FASTCALL smart_str_append_scalar(smart_str *str, const zval *value, size_t truncate);
END_EXTERN_C()
static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, bool persistent) {
if (UNEXPECTED(!str->s)) {
goto do_smart_str_realloc;
} else {
len += ZSTR_LEN(str->s);
if (UNEXPECTED(len >= str->a)) {
do_smart_str_realloc:
if (persistent) {
smart_str_realloc(str, len);
} else {
smart_str_erealloc(str, len);
}
}
}
return len;
}
static zend_always_inline char* smart_str_extend_ex(smart_str *dest, size_t len, bool persistent) {
size_t new_len = smart_str_alloc(dest, len, persistent);
char *ret = ZSTR_VAL(dest->s) + ZSTR_LEN(dest->s);
ZSTR_LEN(dest->s) = new_len;
return ret;
}
static zend_always_inline char* smart_str_extend(smart_str *dest, size_t length)
{
return smart_str_extend_ex(dest, length, false);
}
static zend_always_inline void smart_str_free_ex(smart_str *str, bool persistent) {
if (str->s) {
zend_string_release_ex(str->s, persistent);
str->s = NULL;
}
str->a = 0;
}
static zend_always_inline void smart_str_free(smart_str *str)
{
smart_str_free_ex(str, false);
}
static zend_always_inline void smart_str_0(smart_str *str) {
if (str->s) {
ZSTR_VAL(str->s)[ZSTR_LEN(str->s)] = '\0';
}
}
static zend_always_inline size_t smart_str_get_len(smart_str *str) {
return str->s ? ZSTR_LEN(str->s) : 0;
}
static zend_always_inline void smart_str_trim_to_size_ex(smart_str *str, bool persistent)
{
if (str->s && str->a > ZSTR_LEN(str->s)) {
str->s = zend_string_realloc(str->s, ZSTR_LEN(str->s), persistent);
str->a = ZSTR_LEN(str->s);
}
}
static zend_always_inline void smart_str_trim_to_size(smart_str *dest)
{
smart_str_trim_to_size_ex(dest, false);
}
static zend_always_inline zend_string *smart_str_extract_ex(smart_str *str, bool persistent) {
if (str->s) {
zend_string *res;
smart_str_0(str);
smart_str_trim_to_size_ex(str, persistent);
res = str->s;
str->s = NULL;
return res;
} else {
return ZSTR_EMPTY_ALLOC();
}
}
static zend_always_inline zend_string *smart_str_extract(smart_str *dest)
{
return smart_str_extract_ex(dest, false);
}
static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, bool persistent) {
size_t new_len = smart_str_alloc(dest, 1, persistent);
ZSTR_VAL(dest->s)[new_len - 1] = ch;
ZSTR_LEN(dest->s) = new_len;
}
static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, bool persistent) {
size_t new_len = smart_str_alloc(dest, len, persistent);
memcpy(ZSTR_VAL(dest->s) + ZSTR_LEN(dest->s), str, len);
ZSTR_LEN(dest->s) = new_len;
}
static zend_always_inline void smart_str_append_ex(smart_str *dest, const zend_string *src, bool persistent) {
smart_str_appendl_ex(dest, ZSTR_VAL(src), ZSTR_LEN(src), persistent);
}
static zend_always_inline void smart_str_append_smart_str_ex(smart_str *dest, const smart_str *src, bool persistent) {
if (src->s && ZSTR_LEN(src->s)) {
smart_str_append_ex(dest, src->s, persistent);
}
}
static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, bool persistent) {
char buf[32];
char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
static zend_always_inline void smart_str_append_long(smart_str *dest, zend_long num)
{
smart_str_append_long_ex(dest, num, false);
}
static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, bool persistent) {
char buf[32];
char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num);
smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
static zend_always_inline void smart_str_append_unsigned(smart_str *dest, zend_ulong num)
{
smart_str_append_unsigned_ex(dest, num, false);
}
static zend_always_inline void smart_str_appendl(smart_str *dest, const char *src, size_t length)
{
smart_str_appendl_ex(dest, src, length, false);
}
static zend_always_inline void smart_str_appends_ex(smart_str *dest, const char *src, bool persistent)
{
smart_str_appendl_ex(dest, src, strlen(src), persistent);
}
static zend_always_inline void smart_str_appends(smart_str *dest, const char *src)
{
smart_str_appendl_ex(dest, src, strlen(src), false);
}
static zend_always_inline void smart_str_append(smart_str *dest, const zend_string *src)
{
smart_str_append_ex(dest, src, false);
}
static zend_always_inline void smart_str_appendc(smart_str *dest, char ch)
{
smart_str_appendc_ex(dest, ch, false);
}
static zend_always_inline void smart_str_append_smart_str(smart_str *dest, const smart_str *src)
{
smart_str_append_smart_str_ex(dest, src, false);
}
static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
smart_str_free(dest);
smart_str_appendl(dest, src, len);
}
static zend_always_inline void smart_str_sets(smart_str *dest, const char *src)
{
smart_str_setl(dest, src, strlen(src));
}
#endif

View File

@ -0,0 +1,26 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SMART_STR_PUBLIC_H
#define ZEND_SMART_STR_PUBLIC_H
typedef struct {
/** See smart_str_extract() */
zend_string *s;
size_t a;
} smart_str;
#endif

View File

@ -0,0 +1,113 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SMART_STRING_H
#define PHP_SMART_STRING_H
#include "zend_smart_string_public.h"
#include <stdlib.h>
#include <zend.h>
/* wrapper */
#define smart_string_appends_ex(str, src, what) \
smart_string_appendl_ex((str), (src), strlen(src), (what))
#define smart_string_appends(str, src) \
smart_string_appendl((str), (src), strlen(src))
#define smart_string_append_ex(str, src, what) \
smart_string_appendl_ex((str), ((smart_string *)(src))->c, \
((smart_string *)(src))->len, (what));
#define smart_string_sets(str, src) \
smart_string_setl((str), (src), strlen(src));
#define smart_string_appendc(str, c) \
smart_string_appendc_ex((str), (c), 0)
#define smart_string_free(s) \
smart_string_free_ex((s), 0)
#define smart_string_appendl(str, src, len) \
smart_string_appendl_ex((str), (src), (len), 0)
#define smart_string_append(str, src) \
smart_string_append_ex((str), (src), 0)
#define smart_string_append_long(str, val) \
smart_string_append_long_ex((str), (val), 0)
#define smart_string_append_unsigned(str, val) \
smart_string_append_unsigned_ex((str), (val), 0)
ZEND_API void ZEND_FASTCALL _smart_string_alloc_persistent(smart_string *str, size_t len);
ZEND_API void ZEND_FASTCALL _smart_string_alloc(smart_string *str, size_t len);
static zend_always_inline size_t smart_string_alloc(smart_string *str, size_t len, bool persistent) {
if (UNEXPECTED(!str->c) || UNEXPECTED(len >= str->a - str->len)) {
if (persistent) {
_smart_string_alloc_persistent(str, len);
} else {
_smart_string_alloc(str, len);
}
}
return str->len + len;
}
static zend_always_inline void smart_string_free_ex(smart_string *str, bool persistent) {
if (str->c) {
pefree(str->c, persistent);
str->c = NULL;
}
str->a = str->len = 0;
}
static zend_always_inline void smart_string_0(smart_string *str) {
if (str->c) {
str->c[str->len] = '\0';
}
}
static zend_always_inline void smart_string_appendc_ex(smart_string *dest, char ch, bool persistent) {
dest->len = smart_string_alloc(dest, 1, persistent);
dest->c[dest->len - 1] = ch;
}
static zend_always_inline void smart_string_appendl_ex(smart_string *dest, const char *str, size_t len, bool persistent) {
size_t new_len = smart_string_alloc(dest, len, persistent);
memcpy(dest->c + dest->len, str, len);
dest->len = new_len;
}
static zend_always_inline void smart_string_append_long_ex(smart_string *dest, zend_long num, bool persistent) {
char buf[32];
char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
smart_string_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
static zend_always_inline void smart_string_append_unsigned_ex(smart_string *dest, zend_ulong num, bool persistent) {
char buf[32];
char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num);
smart_string_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
static zend_always_inline void smart_string_setl(smart_string *dest, char *src, size_t len) {
dest->len = len;
dest->a = len + 1;
dest->c = src;
}
static zend_always_inline void smart_string_reset(smart_string *str) {
str->len = 0;
}
#endif

View File

@ -0,0 +1,29 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SMART_STRING_PUBLIC_H
#define PHP_SMART_STRING_PUBLIC_H
#include <sys/types.h>
typedef struct {
char *c;
size_t len;
size_t a;
} smart_string;
#endif

View File

@ -0,0 +1,28 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Xinchen Hui <laruence@php.net> |
| Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SORT_H
#define ZEND_SORT_H
BEGIN_EXTERN_C()
ZEND_API void zend_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp);
ZEND_API void zend_insert_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp);
END_EXTERN_C()
#endif /* ZEND_SORT_H */

View File

@ -0,0 +1,51 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_STACK_H
#define ZEND_STACK_H
typedef struct _zend_stack {
int size, top, max;
void *elements;
} zend_stack;
#define STACK_BLOCK_SIZE 16
typedef enum {
ZEND_STACK_APPLY_TOPDOWN,
ZEND_STACK_APPLY_BOTTOMUP,
} zend_stack_apply_direction;
BEGIN_EXTERN_C()
ZEND_API void zend_stack_init(zend_stack *stack, int size);
ZEND_API int zend_stack_push(zend_stack *stack, const void *element);
ZEND_API void *zend_stack_top(const zend_stack *stack);
ZEND_API void zend_stack_del_top(zend_stack *stack);
ZEND_API int zend_stack_int_top(const zend_stack *stack);
ZEND_API bool zend_stack_is_empty(const zend_stack *stack);
ZEND_API void zend_stack_destroy(zend_stack *stack);
ZEND_API void *zend_stack_base(const zend_stack *stack);
ZEND_API int zend_stack_count(const zend_stack *stack);
ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element));
ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, zend_stack_apply_direction type, int (*apply_function)(void *element, void *arg), void *arg);
ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), bool free_elements);
END_EXTERN_C()
#endif /* ZEND_STACK_H */

View File

@ -0,0 +1,100 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Wez Furlong <wez@thebrainroom.com> |
| Scott MacVicar <scottmac@php.net> |
| Nuno Lopes <nlopess@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_STREAM_H
#define ZEND_STREAM_H
#include <sys/types.h>
#include <sys/stat.h>
/* Lightweight stream implementation for the ZE scanners.
* These functions are private to the engine.
* */
typedef size_t (*zend_stream_fsizer_t)(void* handle);
typedef ssize_t (*zend_stream_reader_t)(void* handle, char *buf, size_t len);
typedef void (*zend_stream_closer_t)(void* handle);
#define ZEND_MMAP_AHEAD 32
typedef enum {
ZEND_HANDLE_FILENAME,
ZEND_HANDLE_FP,
ZEND_HANDLE_STREAM
} zend_stream_type;
typedef struct _zend_stream {
void *handle;
int isatty;
zend_stream_reader_t reader;
zend_stream_fsizer_t fsizer;
zend_stream_closer_t closer;
} zend_stream;
typedef struct _zend_file_handle {
union {
FILE *fp;
zend_stream stream;
} handle;
zend_string *filename;
zend_string *opened_path;
uint8_t type; /* packed zend_stream_type */
bool primary_script;
bool in_list; /* added into CG(open_file) */
char *buf;
size_t len;
} zend_file_handle;
BEGIN_EXTERN_C()
ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename);
ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename);
ZEND_API void zend_stream_init_filename_ex(zend_file_handle *handle, zend_string *filename);
ZEND_API zend_result zend_stream_open(zend_file_handle *handle);
ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len);
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle);
void zend_stream_init(void);
void zend_stream_shutdown(void);
END_EXTERN_C()
#ifdef ZEND_WIN32
# include "win32/ioutil.h"
typedef php_win32_ioutil_stat_t zend_stat_t;
#ifdef _WIN64
# define zend_fseek _fseeki64
# define zend_ftell _ftelli64
# define zend_lseek _lseeki64
# else
# define zend_fseek fseek
# define zend_ftell ftell
# define zend_lseek lseek
# endif
# define zend_fstat php_win32_ioutil_fstat
# define zend_stat php_win32_ioutil_stat
#else
typedef struct stat zend_stat_t;
# define zend_fseek fseek
# define zend_ftell ftell
# define zend_lseek lseek
# define zend_fstat fstat
# define zend_stat stat
#endif
#endif

View File

@ -0,0 +1,643 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_STRING_H
#define ZEND_STRING_H
#include "zend.h"
BEGIN_EXTERN_C()
typedef void (*zend_string_copy_storage_func_t)(void);
typedef zend_string *(ZEND_FASTCALL *zend_new_interned_string_func_t)(zend_string *str);
typedef zend_string *(ZEND_FASTCALL *zend_string_init_interned_func_t)(const char *str, size_t size, bool permanent);
typedef zend_string *(ZEND_FASTCALL *zend_string_init_existing_interned_func_t)(const char *str, size_t size, bool permanent);
ZEND_API extern zend_new_interned_string_func_t zend_new_interned_string;
ZEND_API extern zend_string_init_interned_func_t zend_string_init_interned;
/* Init an interned string if it already exists, but do not create a new one if it does not. */
ZEND_API extern zend_string_init_existing_interned_func_t zend_string_init_existing_interned;
ZEND_API zend_ulong ZEND_FASTCALL zend_string_hash_func(zend_string *str);
ZEND_API zend_ulong ZEND_FASTCALL zend_hash_func(const char *str, size_t len);
ZEND_API zend_string* ZEND_FASTCALL zend_interned_string_find_permanent(zend_string *str);
ZEND_API zend_string *zend_string_concat2(
const char *str1, size_t str1_len,
const char *str2, size_t str2_len);
ZEND_API zend_string *zend_string_concat3(
const char *str1, size_t str1_len,
const char *str2, size_t str2_len,
const char *str3, size_t str3_len);
ZEND_API void zend_interned_strings_init(void);
ZEND_API void zend_interned_strings_dtor(void);
ZEND_API void zend_interned_strings_activate(void);
ZEND_API void zend_interned_strings_deactivate(void);
ZEND_API void zend_interned_strings_set_request_storage_handlers(
zend_new_interned_string_func_t handler,
zend_string_init_interned_func_t init_handler,
zend_string_init_existing_interned_func_t init_existing_handler);
ZEND_API void zend_interned_strings_switch_storage(bool request);
ZEND_API extern zend_string *zend_empty_string;
ZEND_API extern zend_string *zend_one_char_string[256];
ZEND_API extern zend_string **zend_known_strings;
END_EXTERN_C()
/* Shortcuts */
#define ZSTR_VAL(zstr) (zstr)->val
#define ZSTR_LEN(zstr) (zstr)->len
#define ZSTR_H(zstr) (zstr)->h
#define ZSTR_HASH(zstr) zend_string_hash_val(zstr)
/* Compatibility macros */
#define IS_INTERNED(s) ZSTR_IS_INTERNED(s)
#define STR_EMPTY_ALLOC() ZSTR_EMPTY_ALLOC()
#define _STR_HEADER_SIZE _ZSTR_HEADER_SIZE
#define STR_ALLOCA_ALLOC(str, _len, use_heap) ZSTR_ALLOCA_ALLOC(str, _len, use_heap)
#define STR_ALLOCA_INIT(str, s, len, use_heap) ZSTR_ALLOCA_INIT(str, s, len, use_heap)
#define STR_ALLOCA_FREE(str, use_heap) ZSTR_ALLOCA_FREE(str, use_heap)
/*---*/
#define ZSTR_IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED)
#define ZSTR_IS_VALID_UTF8(s) (GC_FLAGS(s) & IS_STR_VALID_UTF8)
/* These are properties, encoded as flags, that will hold on the resulting string
* after concatenating two strings that have these property.
* Example: concatenating two UTF-8 strings yields another UTF-8 string. */
#define ZSTR_COPYABLE_CONCAT_PROPERTIES (IS_STR_VALID_UTF8)
#define ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(s) (GC_FLAGS(s) & ZSTR_COPYABLE_CONCAT_PROPERTIES)
/* This macro returns the copyable concat properties which hold on both strings. */
#define ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(s1, s2) (GC_FLAGS(s1) & GC_FLAGS(s2) & ZSTR_COPYABLE_CONCAT_PROPERTIES)
#define ZSTR_COPY_CONCAT_PROPERTIES(out, in) do { \
zend_string *_out = (out); \
uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES((in)); \
GC_ADD_FLAGS(_out, properties); \
} while (0)
#define ZSTR_COPY_CONCAT_PROPERTIES_BOTH(out, in1, in2) do { \
zend_string *_out = (out); \
uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH((in1), (in2)); \
GC_ADD_FLAGS(_out, properties); \
} while (0)
#define ZSTR_EMPTY_ALLOC() zend_empty_string
#define ZSTR_CHAR(c) zend_one_char_string[c]
#define ZSTR_KNOWN(idx) zend_known_strings[idx]
#define _ZSTR_HEADER_SIZE XtOffsetOf(zend_string, val)
#define _ZSTR_STRUCT_SIZE(len) (_ZSTR_HEADER_SIZE + len + 1)
#define ZSTR_MAX_OVERHEAD (ZEND_MM_ALIGNED_SIZE(_ZSTR_HEADER_SIZE + 1))
#define ZSTR_MAX_LEN (SIZE_MAX - ZSTR_MAX_OVERHEAD)
#define ZSTR_ALLOCA_ALLOC(str, _len, use_heap) do { \
(str) = (zend_string *)do_alloca(ZEND_MM_ALIGNED_SIZE_EX(_ZSTR_STRUCT_SIZE(_len), 8), (use_heap)); \
GC_SET_REFCOUNT(str, 1); \
GC_TYPE_INFO(str) = GC_STRING; \
ZSTR_H(str) = 0; \
ZSTR_LEN(str) = _len; \
} while (0)
#define ZSTR_ALLOCA_INIT(str, s, len, use_heap) do { \
ZSTR_ALLOCA_ALLOC(str, len, use_heap); \
memcpy(ZSTR_VAL(str), (s), (len)); \
ZSTR_VAL(str)[(len)] = '\0'; \
} while (0)
#define ZSTR_ALLOCA_FREE(str, use_heap) free_alloca(str, use_heap)
#define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init((s), strlen(s), (persistent)))
/*---*/
static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s)
{
return ZSTR_H(s) ? ZSTR_H(s) : zend_string_hash_func(s);
}
static zend_always_inline void zend_string_forget_hash_val(zend_string *s)
{
ZSTR_H(s) = 0;
GC_DEL_FLAGS(s, IS_STR_VALID_UTF8);
}
static zend_always_inline uint32_t zend_string_refcount(const zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
return GC_REFCOUNT(s);
}
return 1;
}
static zend_always_inline uint32_t zend_string_addref(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
return GC_ADDREF(s);
}
return 1;
}
static zend_always_inline uint32_t zend_string_delref(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
return GC_DELREF(s);
}
return 1;
}
static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persistent)
{
zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
GC_SET_REFCOUNT(ret, 1);
GC_TYPE_INFO(ret) = GC_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << GC_FLAGS_SHIFT);
ZSTR_H(ret) = 0;
ZSTR_LEN(ret) = len;
return ret;
}
static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent)
{
zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent);
GC_SET_REFCOUNT(ret, 1);
GC_TYPE_INFO(ret) = GC_STRING | ((persistent ? IS_STR_PERSISTENT : 0) << GC_FLAGS_SHIFT);
ZSTR_H(ret) = 0;
ZSTR_LEN(ret) = (n * m) + l;
return ret;
}
static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent)
{
zend_string *ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), str, len);
ZSTR_VAL(ret)[len] = '\0';
return ret;
}
static zend_always_inline zend_string *zend_string_init_fast(const char *str, size_t len)
{
if (len > 1) {
return zend_string_init(str, len, 0);
} else if (len == 0) {
return zend_empty_string;
} else /* if (len == 1) */ {
return ZSTR_CHAR((zend_uchar) *str);
}
}
static zend_always_inline zend_string *zend_string_copy(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
GC_ADDREF(s);
}
return s;
}
static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent)
{
if (ZSTR_IS_INTERNED(s)) {
return s;
} else {
return zend_string_init(ZSTR_VAL(s), ZSTR_LEN(s), persistent);
}
}
static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent)
{
if (ZSTR_IS_INTERNED(s) || GC_REFCOUNT(s) > 1) {
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return zend_string_init(ZSTR_VAL(s), ZSTR_LEN(s), persistent);
}
zend_string_forget_hash_val(s);
return s;
}
static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent)
{
zend_string *ret;
if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN(len, ZSTR_LEN(s)) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent)
{
zend_string *ret;
ZEND_ASSERT(len >= ZSTR_LEN(s));
if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), ZSTR_LEN(s) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, bool persistent)
{
zend_string *ret;
ZEND_ASSERT(len <= ZSTR_LEN(s));
if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), len + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, bool persistent)
{
zend_string *ret;
if (!ZSTR_IS_INTERNED(s)) {
if (GC_REFCOUNT(s) == 1) {
ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent);
ZSTR_LEN(ret) = (n * m) + l;
zend_string_forget_hash_val(ret);
return ret;
}
}
ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN((n * m) + l, ZSTR_LEN(s)) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
static zend_always_inline void zend_string_free(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
ZEND_ASSERT(GC_REFCOUNT(s) <= 1);
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
static zend_always_inline void zend_string_efree(zend_string *s)
{
ZEND_ASSERT(!ZSTR_IS_INTERNED(s));
ZEND_ASSERT(GC_REFCOUNT(s) <= 1);
ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT));
efree(s);
}
static zend_always_inline void zend_string_release(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
if (GC_DELREF(s) == 0) {
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
}
static zend_always_inline void zend_string_release_ex(zend_string *s, bool persistent)
{
if (!ZSTR_IS_INTERNED(s)) {
if (GC_DELREF(s) == 0) {
if (persistent) {
ZEND_ASSERT(GC_FLAGS(s) & IS_STR_PERSISTENT);
free(s);
} else {
ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT));
efree(s);
}
}
}
}
static zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length)
{
return ZSTR_LEN(s1) == s2_length && !memcmp(ZSTR_VAL(s1), s2, s2_length);
}
#if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__)))
BEGIN_EXTERN_C()
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2);
END_EXTERN_C()
#else
static zend_always_inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2)
{
return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
}
#endif
static zend_always_inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2)
{
return ZSTR_LEN(s1) == ZSTR_LEN(s2) && zend_string_equal_val(s1, s2);
}
static zend_always_inline bool zend_string_equals(const zend_string *s1, const zend_string *s2)
{
return s1 == s2 || zend_string_equal_content(s1, s2);
}
#define zend_string_equals_ci(s1, s2) \
(ZSTR_LEN(s1) == ZSTR_LEN(s2) && !zend_binary_strcasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)))
#define zend_string_equals_literal_ci(str, c) \
(ZSTR_LEN(str) == sizeof("" c) - 1 && !zend_binary_strcasecmp(ZSTR_VAL(str), ZSTR_LEN(str), (c), sizeof(c) - 1))
#define zend_string_equals_literal(str, literal) \
zend_string_equals_cstr(str, "" literal, sizeof(literal) - 1)
static zend_always_inline bool zend_string_starts_with_cstr(const zend_string *str, const char *prefix, size_t prefix_length)
{
return ZSTR_LEN(str) >= prefix_length && !memcmp(ZSTR_VAL(str), prefix, prefix_length);
}
static zend_always_inline bool zend_string_starts_with(const zend_string *str, const zend_string *prefix)
{
return zend_string_starts_with_cstr(str, ZSTR_VAL(prefix), ZSTR_LEN(prefix));
}
#define zend_string_starts_with_literal(str, prefix) \
zend_string_starts_with_cstr(str, prefix, strlen(prefix))
static zend_always_inline bool zend_string_starts_with_cstr_ci(const zend_string *str, const char *prefix, size_t prefix_length)
{
return ZSTR_LEN(str) >= prefix_length && !strncasecmp(ZSTR_VAL(str), prefix, prefix_length);
}
static zend_always_inline bool zend_string_starts_with_ci(const zend_string *str, const zend_string *prefix)
{
return zend_string_starts_with_cstr_ci(str, ZSTR_VAL(prefix), ZSTR_LEN(prefix));
}
#define zend_string_starts_with_literal_ci(str, prefix) \
zend_string_starts_with_cstr(str, prefix, strlen(prefix))
/*
* DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
*
* This is Daniel J. Bernstein's popular `times 33' hash function as
* posted by him years ago on comp.lang.c. It basically uses a function
* like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best
* known hash functions for strings. Because it is both computed very
* fast and distributes very well.
*
* The magic of number 33, i.e. why it works better than many other
* constants, prime or not, has never been adequately explained by
* anyone. So I try an explanation: if one experimentally tests all
* multipliers between 1 and 256 (as RSE did now) one detects that even
* numbers are not usable at all. The remaining 128 odd numbers
* (except for the number 1) work more or less all equally well. They
* all distribute in an acceptable way and this way fill a hash table
* with an average percent of approx. 86%.
*
* If one compares the Chi^2 values of the variants, the number 33 not
* even has the best value. But the number 33 and a few other equally
* good numbers like 17, 31, 63, 127 and 129 have nevertheless a great
* advantage to the remaining numbers in the large set of possible
* multipliers: their multiply operation can be replaced by a faster
* operation based on just one shift plus either a single addition
* or subtraction operation. And because a hash function has to both
* distribute good _and_ has to be very fast to compute, those few
* numbers should be preferred and seems to be the reason why Daniel J.
* Bernstein also preferred it.
*
*
* -- Ralf S. Engelschall <rse@engelschall.com>
*/
static zend_always_inline zend_ulong zend_inline_hash_func(const char *str, size_t len)
{
zend_ulong hash = Z_UL(5381);
#if defined(_WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
/* Version with multiplication works better on modern CPU */
for (; len >= 8; len -= 8, str += 8) {
# if defined(__aarch64__) && !defined(WORDS_BIGENDIAN)
/* On some architectures it is beneficial to load 8 bytes at a
time and extract each byte with a bit field extract instr. */
uint64_t chunk;
memcpy(&chunk, str, sizeof(chunk));
hash =
hash * 33 * 33 * 33 * 33 +
((chunk >> (8 * 0)) & 0xff) * 33 * 33 * 33 +
((chunk >> (8 * 1)) & 0xff) * 33 * 33 +
((chunk >> (8 * 2)) & 0xff) * 33 +
((chunk >> (8 * 3)) & 0xff);
hash =
hash * 33 * 33 * 33 * 33 +
((chunk >> (8 * 4)) & 0xff) * 33 * 33 * 33 +
((chunk >> (8 * 5)) & 0xff) * 33 * 33 +
((chunk >> (8 * 6)) & 0xff) * 33 +
((chunk >> (8 * 7)) & 0xff);
# else
hash =
hash * Z_L(33 * 33 * 33 * 33) +
str[0] * Z_L(33 * 33 * 33) +
str[1] * Z_L(33 * 33) +
str[2] * Z_L(33) +
str[3];
hash =
hash * Z_L(33 * 33 * 33 * 33) +
str[4] * Z_L(33 * 33 * 33) +
str[5] * Z_L(33 * 33) +
str[6] * Z_L(33) +
str[7];
# endif
}
if (len >= 4) {
hash =
hash * Z_L(33 * 33 * 33 * 33) +
str[0] * Z_L(33 * 33 * 33) +
str[1] * Z_L(33 * 33) +
str[2] * Z_L(33) +
str[3];
len -= 4;
str += 4;
}
if (len >= 2) {
if (len > 2) {
hash =
hash * Z_L(33 * 33 * 33) +
str[0] * Z_L(33 * 33) +
str[1] * Z_L(33) +
str[2];
} else {
hash =
hash * Z_L(33 * 33) +
str[0] * Z_L(33) +
str[1];
}
} else if (len != 0) {
hash = hash * Z_L(33) + *str;
}
#else
/* variant with the hash unrolled eight times */
for (; len >= 8; len -= 8) {
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
hash = ((hash << 5) + hash) + *str++;
}
switch (len) {
case 7: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 6: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 5: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 4: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 3: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 2: hash = ((hash << 5) + hash) + *str++; /* fallthrough... */
case 1: hash = ((hash << 5) + hash) + *str++; break;
case 0: break;
EMPTY_SWITCH_DEFAULT_CASE()
}
#endif
/* Hash value can't be zero, so we always set the high bit */
#if SIZEOF_ZEND_LONG == 8
return hash | Z_UL(0x8000000000000000);
#elif SIZEOF_ZEND_LONG == 4
return hash | Z_UL(0x80000000);
#else
# error "Unknown SIZEOF_ZEND_LONG"
#endif
}
#define ZEND_KNOWN_STRINGS(_) \
_(ZEND_STR_FILE, "file") \
_(ZEND_STR_LINE, "line") \
_(ZEND_STR_FUNCTION, "function") \
_(ZEND_STR_CLASS, "class") \
_(ZEND_STR_OBJECT, "object") \
_(ZEND_STR_TYPE, "type") \
_(ZEND_STR_OBJECT_OPERATOR, "->") \
_(ZEND_STR_PAAMAYIM_NEKUDOTAYIM, "::") \
_(ZEND_STR_ARGS, "args") \
_(ZEND_STR_UNKNOWN, "unknown") \
_(ZEND_STR_UNKNOWN_CAPITALIZED, "Unknown") \
_(ZEND_STR_EVAL, "eval") \
_(ZEND_STR_INCLUDE, "include") \
_(ZEND_STR_REQUIRE, "require") \
_(ZEND_STR_INCLUDE_ONCE, "include_once") \
_(ZEND_STR_REQUIRE_ONCE, "require_once") \
_(ZEND_STR_SCALAR, "scalar") \
_(ZEND_STR_ERROR_REPORTING, "error_reporting") \
_(ZEND_STR_STATIC, "static") \
_(ZEND_STR_THIS, "this") \
_(ZEND_STR_VALUE, "value") \
_(ZEND_STR_KEY, "key") \
_(ZEND_STR_MAGIC_INVOKE, "__invoke") \
_(ZEND_STR_PREVIOUS, "previous") \
_(ZEND_STR_CODE, "code") \
_(ZEND_STR_MESSAGE, "message") \
_(ZEND_STR_SEVERITY, "severity") \
_(ZEND_STR_STRING, "string") \
_(ZEND_STR_TRACE, "trace") \
_(ZEND_STR_SCHEME, "scheme") \
_(ZEND_STR_HOST, "host") \
_(ZEND_STR_PORT, "port") \
_(ZEND_STR_USER, "user") \
_(ZEND_STR_PASS, "pass") \
_(ZEND_STR_PATH, "path") \
_(ZEND_STR_QUERY, "query") \
_(ZEND_STR_FRAGMENT, "fragment") \
_(ZEND_STR_NULL, "NULL") \
_(ZEND_STR_BOOLEAN, "boolean") \
_(ZEND_STR_INTEGER, "integer") \
_(ZEND_STR_DOUBLE, "double") \
_(ZEND_STR_ARRAY, "array") \
_(ZEND_STR_RESOURCE, "resource") \
_(ZEND_STR_CLOSED_RESOURCE, "resource (closed)") \
_(ZEND_STR_NAME, "name") \
_(ZEND_STR_ARGV, "argv") \
_(ZEND_STR_ARGC, "argc") \
_(ZEND_STR_ARRAY_CAPITALIZED, "Array") \
_(ZEND_STR_BOOL, "bool") \
_(ZEND_STR_INT, "int") \
_(ZEND_STR_FLOAT, "float") \
_(ZEND_STR_CALLABLE, "callable") \
_(ZEND_STR_ITERABLE, "iterable") \
_(ZEND_STR_VOID, "void") \
_(ZEND_STR_NEVER, "never") \
_(ZEND_STR_FALSE, "false") \
_(ZEND_STR_TRUE, "true") \
_(ZEND_STR_NULL_LOWERCASE, "null") \
_(ZEND_STR_MIXED, "mixed") \
_(ZEND_STR_TRAVERSABLE, "Traversable") \
_(ZEND_STR_SLEEP, "__sleep") \
_(ZEND_STR_WAKEUP, "__wakeup") \
_(ZEND_STR_CASES, "cases") \
_(ZEND_STR_FROM, "from") \
_(ZEND_STR_TRYFROM, "tryFrom") \
_(ZEND_STR_TRYFROM_LOWERCASE, "tryfrom") \
_(ZEND_STR_AUTOGLOBAL_SERVER, "_SERVER") \
_(ZEND_STR_AUTOGLOBAL_ENV, "_ENV") \
_(ZEND_STR_AUTOGLOBAL_REQUEST, "_REQUEST") \
_(ZEND_STR_COUNT, "count") \
_(ZEND_STR_SENSITIVEPARAMETER, "SensitiveParameter") \
_(ZEND_STR_CONST_EXPR_PLACEHOLDER, "[constant expression]") \
typedef enum _zend_known_string_id {
#define _ZEND_STR_ID(id, str) id,
ZEND_KNOWN_STRINGS(_ZEND_STR_ID)
#undef _ZEND_STR_ID
ZEND_STR_LAST_KNOWN
} zend_known_string_id;
#endif /* ZEND_STRING_H */

View File

@ -0,0 +1,45 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Derick Rethans <derick@php.net> |
+----------------------------------------------------------------------+
*/
/* This is a header file for the strtod implementation by David M. Gay which
* can be found in zend_strtod.c */
#ifndef ZEND_STRTOD_H
#define ZEND_STRTOD_H
#include <zend.h>
BEGIN_EXTERN_C()
ZEND_API void zend_freedtoa(char *s);
ZEND_API char *zend_dtoa(double _d, int mode, int ndigits, int *decpt, bool *sign, char **rve);
ZEND_API char *zend_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
ZEND_API double zend_strtod(const char *s00, const char **se);
ZEND_API double zend_hex_strtod(const char *str, const char **endptr);
ZEND_API double zend_oct_strtod(const char *str, const char **endptr);
ZEND_API double zend_bin_strtod(const char *str, const char **endptr);
ZEND_API int zend_startup_strtod(void);
ZEND_API int zend_shutdown_strtod(void);
END_EXTERN_C()
/* double limits */
#include <float.h>
#if defined(DBL_MANT_DIG) && defined(DBL_MIN_EXP)
#define ZEND_DOUBLE_MAX_LENGTH (3 + DBL_MANT_DIG - DBL_MIN_EXP)
#else
#define ZEND_DOUBLE_MAX_LENGTH 1080
#endif
#endif

View File

@ -0,0 +1,127 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_STRTOD_INT_H
#define ZEND_STRTOD_INT_H
#ifdef ZTS
#include <TSRM.h>
#endif
#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* TODO check to undef this option, this might
make more perf. destroy_freelist()
should be adapted then. */
#define Omit_Private_Memory 1
/* HEX strings aren't supported as per
https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings */
#define NO_HEX_FP 1
#include <inttypes.h>
#ifdef USE_LOCALE
#undef USE_LOCALE
#endif
#ifndef NO_INFNAN_CHECK
#define NO_INFNAN_CHECK
#endif
#ifndef NO_ERRNO
#define NO_ERRNO
#endif
#ifdef WORDS_BIGENDIAN
#define IEEE_BIG_ENDIAN 1
#else
#define IEEE_LITTLE_ENDIAN 1
#endif
#if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
# if defined(__LITTLE_ENDIAN__)
# undef WORDS_BIGENDIAN
# else
# if defined(__BIG_ENDIAN__)
# define WORDS_BIGENDIAN
# endif
# endif
#endif
#if defined(__arm__) && !defined(__VFP_FP__)
/*
* * Although the CPU is little endian the FP has different
* * byte and word endianness. The byte order is still little endian
* * but the word order is big endian.
* */
#define IEEE_BIG_ENDIAN
#undef IEEE_LITTLE_ENDIAN
#endif
#ifdef __vax__
#define VAX
#undef IEEE_LITTLE_ENDIAN
#endif
#ifdef IEEE_LITTLE_ENDIAN
#define IEEE_8087 1
#endif
#ifdef IEEE_BIG_ENDIAN
#define IEEE_MC68k 1
#endif
#if defined(_MSC_VER)
#ifndef int32_t
#define int32_t __int32
#endif
#ifndef uint32_t
#define uint32_t unsigned __int32
#endif
#endif
#ifdef ZTS
#define MULTIPLE_THREADS 1
#define ACQUIRE_DTOA_LOCK(x) \
if (0 == x) { \
tsrm_mutex_lock(dtoa_mutex); \
} else if (1 == x) { \
tsrm_mutex_lock(pow5mult_mutex); \
}
#define FREE_DTOA_LOCK(x) \
if (0 == x) { \
tsrm_mutex_unlock(dtoa_mutex); \
} else if (1 == x) { \
tsrm_mutex_unlock(pow5mult_mutex); \
}
#endif
#endif /* ZEND_STRTOD_INT_H */

View File

@ -0,0 +1,30 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sammy Kaye Powers <sammyk@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_SYSTEM_ID_H
#define ZEND_SYSTEM_ID_H
BEGIN_EXTERN_C()
/* True global; Write-only during MINIT/startup */
extern ZEND_API char zend_system_id[32];
ZEND_API ZEND_RESULT_CODE zend_add_system_entropy(const char *module_name, const char *hook_name, const void *data, size_t size);
END_EXTERN_C()
void zend_startup_system_id(void);
void zend_finalize_system_id(void);
#endif /* ZEND_SYSTEM_ID_H */

View File

@ -0,0 +1,84 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_TYPE_INFO_H
#define ZEND_TYPE_INFO_H
#include "zend_types.h"
#define MAY_BE_UNDEF (1 << IS_UNDEF)
#define MAY_BE_NULL (1 << IS_NULL)
#define MAY_BE_FALSE (1 << IS_FALSE)
#define MAY_BE_TRUE (1 << IS_TRUE)
#define MAY_BE_BOOL (MAY_BE_FALSE|MAY_BE_TRUE)
#define MAY_BE_LONG (1 << IS_LONG)
#define MAY_BE_DOUBLE (1 << IS_DOUBLE)
#define MAY_BE_STRING (1 << IS_STRING)
#define MAY_BE_ARRAY (1 << IS_ARRAY)
#define MAY_BE_OBJECT (1 << IS_OBJECT)
#define MAY_BE_RESOURCE (1 << IS_RESOURCE)
#define MAY_BE_ANY (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)
#define MAY_BE_REF (1 << IS_REFERENCE) /* may be reference */
/* These are used in zend_type, but not for type inference.
* They are allowed to overlap with types used during inference. */
#define MAY_BE_CALLABLE (1 << IS_CALLABLE)
#define MAY_BE_VOID (1 << IS_VOID)
#define MAY_BE_NEVER (1 << IS_NEVER)
#define MAY_BE_STATIC (1 << IS_STATIC)
#define MAY_BE_ARRAY_SHIFT (IS_REFERENCE)
#define MAY_BE_ARRAY_OF_NULL (MAY_BE_NULL << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_FALSE (MAY_BE_FALSE << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_TRUE (MAY_BE_TRUE << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_LONG (MAY_BE_LONG << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_DOUBLE (MAY_BE_DOUBLE << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_STRING (MAY_BE_STRING << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_ARRAY (MAY_BE_ARRAY << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_OBJECT (MAY_BE_OBJECT << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_RESOURCE (MAY_BE_RESOURCE << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_ANY (MAY_BE_ANY << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_OF_REF (MAY_BE_REF << MAY_BE_ARRAY_SHIFT)
#define MAY_BE_ARRAY_PACKED (1<<21)
#define MAY_BE_ARRAY_NUMERIC_HASH (1<<22) /* hash with numeric keys */
#define MAY_BE_ARRAY_STRING_HASH (1<<23) /* hash with string keys */
#define MAY_BE_ARRAY_EMPTY (1<<29)
#define MAY_BE_ARRAY_KEY_LONG (MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_NUMERIC_HASH)
#define MAY_BE_ARRAY_KEY_STRING MAY_BE_ARRAY_STRING_HASH
#define MAY_BE_ARRAY_KEY_ANY (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_EMPTY)
#define MAY_BE_PACKED(t) ((t) & MAY_BE_ARRAY_PACKED)
#define MAY_BE_HASH(t) ((t) & (MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_KEY_STRING))
#define MAY_BE_PACKED_ONLY(t) (((t) & MAY_BE_ARRAY_KEY_ANY) == MAY_BE_ARRAY_PACKED)
#define MAY_BE_HASH_ONLY(t) (MAY_BE_HASH(t) && !((t) & (MAY_BE_ARRAY_PACKED|MAY_BE_ARRAY_EMPTY)))
#define MAY_BE_EMPTY_ONLY(t) (((t) & MAY_BE_ARRAY_KEY_ANY) == MAY_BE_ARRAY_EMPTY)
#define MAY_BE_CLASS (1<<24)
#define MAY_BE_INDIRECT (1<<25)
#define MAY_BE_RC1 (1<<30) /* may be non-reference with refcount == 1 */
#define MAY_BE_RCN (1u<<31) /* may be non-reference with refcount > 1 */
#define MAY_BE_ANY_ARRAY \
(MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF)
#endif /* ZEND_TYPE_INFO_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_VARIABLES_H
#define ZEND_VARIABLES_H
#include "zend_types.h"
#include "zend_gc.h"
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p);
ZEND_API void ZEND_FASTCALL zval_copy_ctor_func(zval *zvalue);
static zend_always_inline void zval_ptr_dtor_nogc(zval *zval_ptr)
{
if (Z_REFCOUNTED_P(zval_ptr) && !Z_DELREF_P(zval_ptr)) {
rc_dtor_func(Z_COUNTED_P(zval_ptr));
}
}
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr)
{
if (Z_REFCOUNTED_P(zval_ptr)) {
zend_refcounted *ref = Z_COUNTED_P(zval_ptr);
if (!GC_DELREF(ref)) {
rc_dtor_func(ref);
} else {
gc_check_possible_root(ref);
}
}
}
static zend_always_inline void zval_copy_ctor(zval *zvalue)
{
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
ZVAL_ARR(zvalue, zend_array_dup(Z_ARR_P(zvalue)));
} else if (Z_REFCOUNTED_P(zvalue)) {
Z_ADDREF_P(zvalue);
}
}
static zend_always_inline void zval_opt_copy_ctor(zval *zvalue)
{
if (Z_OPT_TYPE_P(zvalue) == IS_ARRAY) {
ZVAL_ARR(zvalue, zend_array_dup(Z_ARR_P(zvalue)));
} else if (Z_OPT_REFCOUNTED_P(zvalue)) {
Z_ADDREF_P(zvalue);
}
}
static zend_always_inline void zval_ptr_dtor_str(zval *zval_ptr)
{
if (Z_REFCOUNTED_P(zval_ptr) && !Z_DELREF_P(zval_ptr)) {
ZEND_ASSERT(Z_TYPE_P(zval_ptr) == IS_STRING);
ZEND_ASSERT(!ZSTR_IS_INTERNED(Z_STR_P(zval_ptr)));
ZEND_ASSERT(!(GC_FLAGS(Z_STR_P(zval_ptr)) & IS_STR_PERSISTENT));
efree(Z_STR_P(zval_ptr));
}
}
ZEND_API void zval_ptr_dtor(zval *zval_ptr);
ZEND_API void zval_internal_ptr_dtor(zval *zvalue);
/* Kept for compatibility */
#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue)
ZEND_API void zval_add_ref(zval *p);
END_EXTERN_C()
#define ZVAL_PTR_DTOR zval_ptr_dtor
#define ZVAL_INTERNAL_PTR_DTOR zval_internal_ptr_dtor
#endif

View File

@ -0,0 +1,394 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Sascha Schumann <sascha@schumann.cx> |
| Pierre Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
#include "TSRM.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#include <stdarg.h>
#include <limits.h>
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifndef MAXPATHLEN
# if _WIN32
# include "win32/ioutil.h"
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
# elif PATH_MAX
# define MAXPATHLEN PATH_MAX
# elif defined(MAX_PATH)
# define MAXPATHLEN MAX_PATH
# else
# define MAXPATHLEN 256
# endif
#endif
#ifdef ZTS
#define VIRTUAL_DIR
#endif
#ifndef ZEND_WIN32
#include <unistd.h>
#else
#include <direct.h>
#endif
#if defined(__osf__) || defined(_AIX)
#include <errno.h>
#endif
#ifdef ZEND_WIN32
#include "win32/readdir.h"
#include <sys/utime.h>
#include "win32/ioutil.h"
/* mode_t isn't defined on Windows */
typedef unsigned short mode_t;
#define DEFAULT_SLASH '\\'
#define DEFAULT_DIR_SEPARATOR ';'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
#define IS_SLASH_P(c) (*(c) == '/' || \
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
/* COPY_WHEN_ABSOLUTE is 2 under Win32 because by chance both regular absolute paths
in the file system and UNC paths need copying of two characters */
#define COPY_WHEN_ABSOLUTE(path) 2
#define IS_UNC_PATH(path, len) \
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && (/* is local */isalpha(path[0]) && path[1] == ':' || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
#else
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#ifndef DT_UNKNOWN
# define DT_UNKNOWN 0
#endif
#ifndef DT_DIR
# define DT_DIR 4
#endif
#ifndef DT_REG
# define DT_REG 8
#endif
#endif
#define DEFAULT_SLASH '/'
#ifdef __riscos__
#define DEFAULT_DIR_SEPARATOR ';'
#else
#define DEFAULT_DIR_SEPARATOR ':'
#endif
#define IS_SLASH(c) ((c) == '/')
#define IS_SLASH_P(c) (*(c) == '/')
#endif
#ifndef COPY_WHEN_ABSOLUTE
#define COPY_WHEN_ABSOLUTE(path) 0
#endif
#ifndef IS_ABSOLUTE_PATH
#define IS_ABSOLUTE_PATH(path, len) \
(IS_SLASH(path[0]))
#endif
#ifdef TSRM_EXPORTS
#define CWD_EXPORTS
#endif
#ifdef ZEND_WIN32
# ifdef CWD_EXPORTS
# define CWD_API __declspec(dllexport)
# else
# define CWD_API __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define CWD_API __attribute__ ((visibility("default")))
#else
# define CWD_API
#endif
#ifdef ZEND_WIN32
# define php_sys_stat_ex php_win32_ioutil_stat_ex
# define php_sys_stat php_win32_ioutil_stat
# define php_sys_lstat php_win32_ioutil_lstat
# define php_sys_fstat php_win32_ioutil_fstat
# define php_sys_readlink php_win32_ioutil_readlink
# define php_sys_symlink php_win32_ioutil_symlink
# define php_sys_link php_win32_ioutil_link
#else
# define php_sys_stat stat
# define php_sys_lstat lstat
# define php_sys_fstat fstat
# ifdef HAVE_SYMLINK
# define php_sys_readlink(link, target, target_len) readlink(link, target, target_len)
# define php_sys_symlink symlink
# define php_sys_link link
# endif
#endif
typedef struct _cwd_state {
char *cwd;
size_t cwd_length;
} cwd_state;
typedef int (*verify_path_func)(const cwd_state *);
CWD_API void virtual_cwd_startup(void);
CWD_API void virtual_cwd_shutdown(void);
CWD_API int virtual_cwd_activate(void);
CWD_API int virtual_cwd_deactivate(void);
CWD_API char *virtual_getcwd_ex(size_t *length);
CWD_API char *virtual_getcwd(char *buf, size_t size);
CWD_API zend_result virtual_chdir(const char *path);
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path));
CWD_API int virtual_filepath(const char *path, char **filepath);
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path);
CWD_API char *virtual_realpath(const char *path, char *real_path);
CWD_API FILE *virtual_fopen(const char *path, const char *mode);
CWD_API int virtual_open(const char *path, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode);
CWD_API int virtual_rename(const char *oldname, const char *newname);
CWD_API int virtual_stat(const char *path, zend_stat_t *buf);
CWD_API int virtual_lstat(const char *path, zend_stat_t *buf);
CWD_API int virtual_unlink(const char *path);
CWD_API int virtual_mkdir(const char *pathname, mode_t mode);
CWD_API int virtual_rmdir(const char *pathname);
CWD_API DIR *virtual_opendir(const char *pathname);
CWD_API FILE *virtual_popen(const char *command, const char *type);
CWD_API int virtual_access(const char *pathname, int mode);
#if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf);
#endif
CWD_API int virtual_chmod(const char *filename, mode_t mode);
#if !defined(ZEND_WIN32)
CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link);
#endif
/* One of the following constants must be used as the last argument
in virtual_file_ex() call. */
// TODO Make this into an enum
#define CWD_EXPAND 0 /* expand "." and ".." but don't resolve symlinks */
#define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */
#define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
CWD_API char *tsrm_realpath(const char *path, char *real_path);
#define REALPATH_CACHE_TTL (2*60) /* 2 minutes */
#define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */
typedef struct _realpath_cache_bucket {
zend_ulong key;
char *path;
char *realpath;
struct _realpath_cache_bucket *next;
time_t expires;
uint16_t path_len;
uint16_t realpath_len;
uint8_t is_dir:1;
#ifdef ZEND_WIN32
uint8_t is_rvalid:1;
uint8_t is_readable:1;
uint8_t is_wvalid:1;
uint8_t is_writable:1;
#endif
} realpath_cache_bucket;
typedef struct _virtual_cwd_globals {
cwd_state cwd;
zend_long realpath_cache_size;
zend_long realpath_cache_size_limit;
zend_long realpath_cache_ttl;
realpath_cache_bucket *realpath_cache[1024];
} virtual_cwd_globals;
#ifdef ZTS
extern ts_rsrc_id cwd_globals_id;
extern size_t cwd_globals_offset;
# define CWDG(v) ZEND_TSRMG_FAST(cwd_globals_offset, virtual_cwd_globals *, v)
#else
extern virtual_cwd_globals cwd_globals;
# define CWDG(v) (cwd_globals.v)
#endif
CWD_API void realpath_cache_clean(void);
CWD_API void realpath_cache_del(const char *path, size_t path_len);
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, size_t path_len, time_t t);
CWD_API zend_long realpath_cache_size(void);
CWD_API zend_long realpath_cache_max_buckets(void);
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void);
#ifdef CWD_EXPORTS
extern void virtual_cwd_main_cwd_init(uint8_t);
#endif
/* The actual macros to be used in programs using TSRM
* If the program defines VIRTUAL_DIR it will use the
* virtual_* functions
*/
#ifdef VIRTUAL_DIR
#define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size)
#define VCWD_FOPEN(path, mode) virtual_fopen(path, mode)
/* Because open() has two modes, we have to macros to replace it */
#define VCWD_OPEN(path, flags) virtual_open(path, flags)
#define VCWD_OPEN_MODE(path, flags, mode) virtual_open(path, flags, mode)
#define VCWD_CREAT(path, mode) virtual_creat(path, mode)
#define VCWD_CHDIR(path) virtual_chdir(path)
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, (int (*)(const char *)) virtual_chdir)
#define VCWD_GETWD(buf)
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path)
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname)
#define VCWD_STAT(path, buff) virtual_stat(path, buff)
# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff)
#define VCWD_UNLINK(path) virtual_unlink(path)
#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode)
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname)
#define VCWD_OPENDIR(pathname) virtual_opendir(pathname)
#define VCWD_POPEN(command, type) virtual_popen(command, type)
#define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode)
#if HAVE_UTIME
#define VCWD_UTIME(path, time) virtual_utime(path, time)
#endif
#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode)
#if !defined(ZEND_WIN32)
#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0)
#if HAVE_LCHOWN
#define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1)
#endif
#endif
#else
#define VCWD_CREAT(path, mode) creat(path, mode)
/* rename on windows will fail if newname already exists.
MoveFileEx has to be used */
#if defined(ZEND_WIN32)
#define VCWD_FOPEN(path, mode) php_win32_ioutil_fopen(path, mode)
#define VCWD_OPEN(path, flags) php_win32_ioutil_open(path, flags)
#define VCWD_OPEN_MODE(path, flags, mode) php_win32_ioutil_open(path, flags, mode)
# define VCWD_RENAME(oldname, newname) php_win32_ioutil_rename(oldname, newname)
#define VCWD_MKDIR(pathname, mode) php_win32_ioutil_mkdir(pathname, mode)
#define VCWD_RMDIR(pathname) php_win32_ioutil_rmdir(pathname)
#define VCWD_UNLINK(path) php_win32_ioutil_unlink(path)
#define VCWD_CHDIR(path) php_win32_ioutil_chdir(path)
#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
#define VCWD_GETCWD(buff, size) php_win32_ioutil_getcwd(buff, size)
#define VCWD_CHMOD(path, mode) php_win32_ioutil_chmod(path, mode)
#else
#define VCWD_FOPEN(path, mode) fopen(path, mode)
#define VCWD_OPEN(path, flags) open(path, flags)
#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
# define VCWD_RENAME(oldname, newname) rename(oldname, newname)
#define VCWD_MKDIR(pathname, mode) mkdir(pathname, mode)
#define VCWD_RMDIR(pathname) rmdir(pathname)
#define VCWD_UNLINK(path) unlink(path)
#define VCWD_CHDIR(path) chdir(path)
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
#define VCWD_GETCWD(buff, size) getcwd(buff, size)
#define VCWD_CHMOD(path, mode) chmod(path, mode)
#endif
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
#define VCWD_GETWD(buf) getwd(buf)
#define VCWD_STAT(path, buff) php_sys_stat(path, buff)
#define VCWD_LSTAT(path, buff) lstat(path, buff)
#define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type)
#define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path)
#if HAVE_UTIME
# ifdef ZEND_WIN32
# define VCWD_UTIME(path, time) win32_utime(path, time)
# else
# define VCWD_UTIME(path, time) utime(path, time)
# endif
#endif
#if !defined(ZEND_WIN32)
#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
#if HAVE_LCHOWN
#define VCWD_LCHOWN(path, owner, group) lchown(path, owner, group)
#endif
#endif
#endif
/* Global stat declarations */
#ifndef _S_IFDIR
#define _S_IFDIR S_IFDIR
#endif
#ifndef _S_IFREG
#define _S_IFREG S_IFREG
#endif
#ifndef S_IFLNK
#define _IFLNK 0120000 /* symbolic link */
#define S_IFLNK _IFLNK
#endif
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISREG
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
#endif
#ifndef S_ISLNK
#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
#endif
#ifndef S_IXROOT
#define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH )
#endif
/* XXX should be _S_IFIFO? */
#ifndef S_IFIFO
#define _IFIFO 0010000 /* fifo */
#define S_IFIFO _IFIFO
#endif
#ifndef S_IFBLK
#define _IFBLK 0060000 /* block special */
#define S_IFBLK _IFBLK
#endif
#endif /* VIRTUAL_CWD_H */

View File

@ -0,0 +1,41 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_VM_H
#define ZEND_VM_H
BEGIN_EXTERN_C()
ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler(zend_op* opcode);
ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler_ex(zend_op* opcode, uint32_t op1_info, uint32_t op2_info, uint32_t res_info);
ZEND_API void ZEND_FASTCALL zend_serialize_opcode_handler(zend_op *op);
ZEND_API void ZEND_FASTCALL zend_deserialize_opcode_handler(zend_op *op);
ZEND_API const void* ZEND_FASTCALL zend_get_opcode_handler_func(const zend_op *op);
ZEND_API const zend_op *zend_get_halt_op(void);
ZEND_API int ZEND_FASTCALL zend_vm_call_opcode_handler(zend_execute_data *ex);
ZEND_API int zend_vm_kind(void);
ZEND_API bool zend_gcc_global_regs(void);
void zend_vm_init(void);
void zend_vm_dtor(void);
END_EXTERN_C()
#define ZEND_VM_SET_OPCODE_HANDLER(opline) zend_vm_set_opcode_handler(opline)
#endif

10142
include/php/Zend/zend_vm_def.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,292 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_VM_OPCODES_H
#define ZEND_VM_OPCODES_H
#define ZEND_VM_SPEC 1
#define ZEND_VM_LINES 0
#define ZEND_VM_KIND_CALL 1
#define ZEND_VM_KIND_SWITCH 2
#define ZEND_VM_KIND_GOTO 3
#define ZEND_VM_KIND_HYBRID 4
/* HYBRID requires support for computed GOTO and global register variables*/
#if (defined(__GNUC__) && defined(HAVE_GCC_GLOBAL_REGS))
# define ZEND_VM_KIND ZEND_VM_KIND_HYBRID
#else
# define ZEND_VM_KIND ZEND_VM_KIND_CALL
#endif
#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) && !defined(__SANITIZE_ADDRESS__)
# if ((defined(i386) && !defined(__PIC__)) || defined(__x86_64__) || defined(_M_X64))
# define ZEND_VM_HYBRID_JIT_RED_ZONE_SIZE 16
# endif
#endif
#define ZEND_VM_OP_SPEC 0x00000001
#define ZEND_VM_OP_CONST 0x00000002
#define ZEND_VM_OP_TMPVAR 0x00000004
#define ZEND_VM_OP_TMPVARCV 0x00000008
#define ZEND_VM_OP_MASK 0x000000f0
#define ZEND_VM_OP_NUM 0x00000010
#define ZEND_VM_OP_JMP_ADDR 0x00000020
#define ZEND_VM_OP_TRY_CATCH 0x00000030
#define ZEND_VM_OP_THIS 0x00000050
#define ZEND_VM_OP_NEXT 0x00000060
#define ZEND_VM_OP_CLASS_FETCH 0x00000070
#define ZEND_VM_OP_CONSTRUCTOR 0x00000080
#define ZEND_VM_OP_CONST_FETCH 0x00000090
#define ZEND_VM_OP_CACHE_SLOT 0x000000a0
#define ZEND_VM_EXT_VAR_FETCH 0x00010000
#define ZEND_VM_EXT_ISSET 0x00020000
#define ZEND_VM_EXT_CACHE_SLOT 0x00040000
#define ZEND_VM_EXT_ARRAY_INIT 0x00080000
#define ZEND_VM_EXT_REF 0x00100000
#define ZEND_VM_EXT_FETCH_REF 0x00200000
#define ZEND_VM_EXT_DIM_WRITE 0x00400000
#define ZEND_VM_EXT_MASK 0x0f000000
#define ZEND_VM_EXT_NUM 0x01000000
#define ZEND_VM_EXT_LAST_CATCH 0x02000000
#define ZEND_VM_EXT_JMP_ADDR 0x03000000
#define ZEND_VM_EXT_OP 0x04000000
#define ZEND_VM_EXT_TYPE 0x07000000
#define ZEND_VM_EXT_EVAL 0x08000000
#define ZEND_VM_EXT_TYPE_MASK 0x09000000
#define ZEND_VM_EXT_SRC 0x0b000000
#define ZEND_VM_NO_CONST_CONST 0x40000000
#define ZEND_VM_COMMUTATIVE 0x80000000
#define ZEND_VM_OP1_FLAGS(flags) (flags & 0xff)
#define ZEND_VM_OP2_FLAGS(flags) ((flags >> 8) & 0xff)
BEGIN_EXTERN_C()
ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(uint8_t opcode);
ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(uint8_t opcode);
ZEND_API uint8_t zend_get_opcode_id(const char *name, size_t length);
END_EXTERN_C()
#define ZEND_NOP 0
#define ZEND_ADD 1
#define ZEND_SUB 2
#define ZEND_MUL 3
#define ZEND_DIV 4
#define ZEND_MOD 5
#define ZEND_SL 6
#define ZEND_SR 7
#define ZEND_CONCAT 8
#define ZEND_BW_OR 9
#define ZEND_BW_AND 10
#define ZEND_BW_XOR 11
#define ZEND_POW 12
#define ZEND_BW_NOT 13
#define ZEND_BOOL_NOT 14
#define ZEND_BOOL_XOR 15
#define ZEND_IS_IDENTICAL 16
#define ZEND_IS_NOT_IDENTICAL 17
#define ZEND_IS_EQUAL 18
#define ZEND_IS_NOT_EQUAL 19
#define ZEND_IS_SMALLER 20
#define ZEND_IS_SMALLER_OR_EQUAL 21
#define ZEND_ASSIGN 22
#define ZEND_ASSIGN_DIM 23
#define ZEND_ASSIGN_OBJ 24
#define ZEND_ASSIGN_STATIC_PROP 25
#define ZEND_ASSIGN_OP 26
#define ZEND_ASSIGN_DIM_OP 27
#define ZEND_ASSIGN_OBJ_OP 28
#define ZEND_ASSIGN_STATIC_PROP_OP 29
#define ZEND_ASSIGN_REF 30
#define ZEND_QM_ASSIGN 31
#define ZEND_ASSIGN_OBJ_REF 32
#define ZEND_ASSIGN_STATIC_PROP_REF 33
#define ZEND_PRE_INC 34
#define ZEND_PRE_DEC 35
#define ZEND_POST_INC 36
#define ZEND_POST_DEC 37
#define ZEND_PRE_INC_STATIC_PROP 38
#define ZEND_PRE_DEC_STATIC_PROP 39
#define ZEND_POST_INC_STATIC_PROP 40
#define ZEND_POST_DEC_STATIC_PROP 41
#define ZEND_JMP 42
#define ZEND_JMPZ 43
#define ZEND_JMPNZ 44
#define ZEND_JMPZ_EX 46
#define ZEND_JMPNZ_EX 47
#define ZEND_CASE 48
#define ZEND_CHECK_VAR 49
#define ZEND_SEND_VAR_NO_REF_EX 50
#define ZEND_CAST 51
#define ZEND_BOOL 52
#define ZEND_FAST_CONCAT 53
#define ZEND_ROPE_INIT 54
#define ZEND_ROPE_ADD 55
#define ZEND_ROPE_END 56
#define ZEND_BEGIN_SILENCE 57
#define ZEND_END_SILENCE 58
#define ZEND_INIT_FCALL_BY_NAME 59
#define ZEND_DO_FCALL 60
#define ZEND_INIT_FCALL 61
#define ZEND_RETURN 62
#define ZEND_RECV 63
#define ZEND_RECV_INIT 64
#define ZEND_SEND_VAL 65
#define ZEND_SEND_VAR_EX 66
#define ZEND_SEND_REF 67
#define ZEND_NEW 68
#define ZEND_INIT_NS_FCALL_BY_NAME 69
#define ZEND_FREE 70
#define ZEND_INIT_ARRAY 71
#define ZEND_ADD_ARRAY_ELEMENT 72
#define ZEND_INCLUDE_OR_EVAL 73
#define ZEND_UNSET_VAR 74
#define ZEND_UNSET_DIM 75
#define ZEND_UNSET_OBJ 76
#define ZEND_FE_RESET_R 77
#define ZEND_FE_FETCH_R 78
#define ZEND_EXIT 79
#define ZEND_FETCH_R 80
#define ZEND_FETCH_DIM_R 81
#define ZEND_FETCH_OBJ_R 82
#define ZEND_FETCH_W 83
#define ZEND_FETCH_DIM_W 84
#define ZEND_FETCH_OBJ_W 85
#define ZEND_FETCH_RW 86
#define ZEND_FETCH_DIM_RW 87
#define ZEND_FETCH_OBJ_RW 88
#define ZEND_FETCH_IS 89
#define ZEND_FETCH_DIM_IS 90
#define ZEND_FETCH_OBJ_IS 91
#define ZEND_FETCH_FUNC_ARG 92
#define ZEND_FETCH_DIM_FUNC_ARG 93
#define ZEND_FETCH_OBJ_FUNC_ARG 94
#define ZEND_FETCH_UNSET 95
#define ZEND_FETCH_DIM_UNSET 96
#define ZEND_FETCH_OBJ_UNSET 97
#define ZEND_FETCH_LIST_R 98
#define ZEND_FETCH_CONSTANT 99
#define ZEND_CHECK_FUNC_ARG 100
#define ZEND_EXT_STMT 101
#define ZEND_EXT_FCALL_BEGIN 102
#define ZEND_EXT_FCALL_END 103
#define ZEND_EXT_NOP 104
#define ZEND_TICKS 105
#define ZEND_SEND_VAR_NO_REF 106
#define ZEND_CATCH 107
#define ZEND_THROW 108
#define ZEND_FETCH_CLASS 109
#define ZEND_CLONE 110
#define ZEND_RETURN_BY_REF 111
#define ZEND_INIT_METHOD_CALL 112
#define ZEND_INIT_STATIC_METHOD_CALL 113
#define ZEND_ISSET_ISEMPTY_VAR 114
#define ZEND_ISSET_ISEMPTY_DIM_OBJ 115
#define ZEND_SEND_VAL_EX 116
#define ZEND_SEND_VAR 117
#define ZEND_INIT_USER_CALL 118
#define ZEND_SEND_ARRAY 119
#define ZEND_SEND_USER 120
#define ZEND_STRLEN 121
#define ZEND_DEFINED 122
#define ZEND_TYPE_CHECK 123
#define ZEND_VERIFY_RETURN_TYPE 124
#define ZEND_FE_RESET_RW 125
#define ZEND_FE_FETCH_RW 126
#define ZEND_FE_FREE 127
#define ZEND_INIT_DYNAMIC_CALL 128
#define ZEND_DO_ICALL 129
#define ZEND_DO_UCALL 130
#define ZEND_DO_FCALL_BY_NAME 131
#define ZEND_PRE_INC_OBJ 132
#define ZEND_PRE_DEC_OBJ 133
#define ZEND_POST_INC_OBJ 134
#define ZEND_POST_DEC_OBJ 135
#define ZEND_ECHO 136
#define ZEND_OP_DATA 137
#define ZEND_INSTANCEOF 138
#define ZEND_GENERATOR_CREATE 139
#define ZEND_MAKE_REF 140
#define ZEND_DECLARE_FUNCTION 141
#define ZEND_DECLARE_LAMBDA_FUNCTION 142
#define ZEND_DECLARE_CONST 143
#define ZEND_DECLARE_CLASS 144
#define ZEND_DECLARE_CLASS_DELAYED 145
#define ZEND_DECLARE_ANON_CLASS 146
#define ZEND_ADD_ARRAY_UNPACK 147
#define ZEND_ISSET_ISEMPTY_PROP_OBJ 148
#define ZEND_HANDLE_EXCEPTION 149
#define ZEND_USER_OPCODE 150
#define ZEND_ASSERT_CHECK 151
#define ZEND_JMP_SET 152
#define ZEND_UNSET_CV 153
#define ZEND_ISSET_ISEMPTY_CV 154
#define ZEND_FETCH_LIST_W 155
#define ZEND_SEPARATE 156
#define ZEND_FETCH_CLASS_NAME 157
#define ZEND_CALL_TRAMPOLINE 158
#define ZEND_DISCARD_EXCEPTION 159
#define ZEND_YIELD 160
#define ZEND_GENERATOR_RETURN 161
#define ZEND_FAST_CALL 162
#define ZEND_FAST_RET 163
#define ZEND_RECV_VARIADIC 164
#define ZEND_SEND_UNPACK 165
#define ZEND_YIELD_FROM 166
#define ZEND_COPY_TMP 167
#define ZEND_BIND_GLOBAL 168
#define ZEND_COALESCE 169
#define ZEND_SPACESHIP 170
#define ZEND_FUNC_NUM_ARGS 171
#define ZEND_FUNC_GET_ARGS 172
#define ZEND_FETCH_STATIC_PROP_R 173
#define ZEND_FETCH_STATIC_PROP_W 174
#define ZEND_FETCH_STATIC_PROP_RW 175
#define ZEND_FETCH_STATIC_PROP_IS 176
#define ZEND_FETCH_STATIC_PROP_FUNC_ARG 177
#define ZEND_FETCH_STATIC_PROP_UNSET 178
#define ZEND_UNSET_STATIC_PROP 179
#define ZEND_ISSET_ISEMPTY_STATIC_PROP 180
#define ZEND_FETCH_CLASS_CONSTANT 181
#define ZEND_BIND_LEXICAL 182
#define ZEND_BIND_STATIC 183
#define ZEND_FETCH_THIS 184
#define ZEND_SEND_FUNC_ARG 185
#define ZEND_ISSET_ISEMPTY_THIS 186
#define ZEND_SWITCH_LONG 187
#define ZEND_SWITCH_STRING 188
#define ZEND_IN_ARRAY 189
#define ZEND_COUNT 190
#define ZEND_GET_CLASS 191
#define ZEND_GET_CALLED_CLASS 192
#define ZEND_GET_TYPE 193
#define ZEND_ARRAY_KEY_EXISTS 194
#define ZEND_MATCH 195
#define ZEND_CASE_STRICT 196
#define ZEND_MATCH_ERROR 197
#define ZEND_JMP_NULL 198
#define ZEND_CHECK_UNDEF_ARGS 199
#define ZEND_FETCH_GLOBALS 200
#define ZEND_VERIFY_NEVER_TYPE 201
#define ZEND_CALLABLE_CONVERT 202
#define ZEND_BIND_INIT_STATIC_OR_JMP 203
#define ZEND_VM_LAST_OPCODE 203
#endif

View File

@ -0,0 +1,112 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#include "zend_sort.h"
#define VM_TRACE(op) zend_vm_trace(#op, sizeof(#op)-1);
#define VM_TRACE_START() zend_vm_trace_init();
#define VM_TRACE_END() zend_vm_trace_finish();
static HashTable vm_trace_ht;
static void zend_vm_trace(const char *op, size_t op_len)
{
static const char *last = NULL;
static size_t last_len = 0;
char buf[256];
size_t len;
zval tmp, *zv;
if (EXPECTED(last)) {
len = last_len + 1 + op_len;
memcpy(buf, last, last_len);
buf[last_len] = ' ';
memcpy(buf + last_len + 1, op, op_len + 1);
zv = zend_hash_str_find(&vm_trace_ht, buf, len);
if (EXPECTED(zv)) {
if (EXPECTED(Z_LVAL_P(zv) < ZEND_LONG_MAX)) {
Z_LVAL_P(zv)++;
}
} else {
ZVAL_LONG(&tmp, 1);
zend_hash_str_add_new(&vm_trace_ht, buf, len, &tmp);
}
}
last = op;
last_len = op_len;
}
static int zend_vm_trace_compare(const Bucket *p1, const Bucket *p2)
{
if (Z_LVAL(p1->val) < Z_LVAL(p2->val)) {
return 1;
} else if (Z_LVAL(p1->val) > Z_LVAL(p2->val)) {
return -1;
} else {
return 0;
}
}
static void zend_vm_trace_finish(void)
{
zend_string *key;
zval *val;
FILE *f;
f = fopen("zend_vm_trace.log", "w+");
if (f) {
zend_hash_sort(&vm_trace_ht, (compare_func_t)zend_vm_trace_compare, 0);
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(&vm_trace_ht, key, val) {
fprintf(f, "%s "ZEND_LONG_FMT"\n", ZSTR_VAL(key), Z_LVAL_P(val));
} ZEND_HASH_FOREACH_END();
fclose(f);
}
zend_hash_destroy(&vm_trace_ht);
}
static void zend_vm_trace_init(void)
{
FILE *f;
zend_hash_init(&vm_trace_ht, 0, NULL, NULL, 1);
f = fopen("zend_vm_trace.log", "r");
if (f) {
char buf[256];
size_t len;
zval tmp;
while (!feof(f)) {
if (fgets(buf, sizeof(buf)-1, f)) {
len = strlen(buf);
while (len > 0 && buf[len-1] <= ' ') {
len--;
buf[len] = 0;
}
while (len > 0 && buf[len-1] >= '0' && buf[len-1] <= '9') {
len--;
}
if (len > 1) {
buf[len-1] = 0;
ZVAL_LONG(&tmp, ZEND_STRTOL(buf + len, NULL, 10));
zend_hash_str_add(&vm_trace_ht, buf, len - 1, &tmp);
}
}
}
fclose(f);
}
}

View File

@ -0,0 +1,42 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#include "zend_sort.h"
#define VM_TRACE(op) zend_vm_trace(execute_data, opline);
#define VM_TRACE_START() zend_vm_trace_init();
#define VM_TRACE_END() zend_vm_trace_finish();
static FILE *vm_trace_file;
static void zend_vm_trace(const zend_execute_data *execute_data, const zend_op *opline)
{
if (EX(func) && EX(func)->op_array.filename) {
fprintf(vm_trace_file, "%s:%d\n", ZSTR_VAL(EX(func)->op_array.filename), opline->lineno);
}
}
static void zend_vm_trace_finish(void)
{
fclose(vm_trace_file);
}
static void zend_vm_trace_init(void)
{
vm_trace_file = fopen("zend_vm_trace.log", "w+");
}

View File

@ -0,0 +1,81 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
#include "zend_vm_handlers.h"
#include "zend_sort.h"
#define GEN_MAP(n, name) do { \
ZVAL_LONG(&tmp, (zend_long)(uintptr_t)zend_opcode_handlers[n]); \
zend_hash_str_add(&vm_trace_ht, #name, sizeof(#name) - 1, &tmp); \
} while (0);
#define VM_TRACE_START() do { \
zval tmp; \
zend_hash_init(&vm_trace_ht, 0, NULL, NULL, 1); \
VM_HANDLERS(GEN_MAP) \
zend_vm_trace_init(); \
} while (0)
#ifdef _WIN64
# define ADDR_FMT "%016I64x"
#elif SIZEOF_SIZE_T == 4
# define ADDR_FMT "%08zx"
#elif SIZEOF_SIZE_T == 8
# define ADDR_FMT "%016zx"
#else
# error "Unknown SIZEOF_SIZE_T"
#endif
static HashTable vm_trace_ht;
static int zend_vm_trace_compare(const Bucket *p1, const Bucket *p2)
{
if (Z_LVAL(p1->val) > Z_LVAL(p2->val)) {
return 1;
} else if (Z_LVAL(p1->val) < Z_LVAL(p2->val)) {
return -1;
} else {
return 0;
}
}
static void zend_vm_trace_init(void)
{
FILE *f;
zend_string *key, *prev_key;
zval *val;
zend_long prev_addr;
f = fopen("zend_vm.map", "w+");
if (f) {
zend_hash_sort(&vm_trace_ht, (bucket_compare_func_t)zend_vm_trace_compare, 0);
prev_key = NULL;
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(&vm_trace_ht, key, val) {
if (prev_key) {
fprintf(f, ADDR_FMT" "ADDR_FMT" t %s\n", prev_addr, Z_LVAL_P(val) - prev_addr, ZSTR_VAL(prev_key));
}
prev_key = key;
prev_addr = Z_LVAL_P(val);
} ZEND_HASH_FOREACH_END();
if (prev_key) {
fprintf(f, ADDR_FMT" "ADDR_FMT" t %s\n", prev_addr, 0, ZSTR_VAL(prev_key));
}
fclose(f);
}
zend_hash_destroy(&vm_trace_ht);
}

View File

@ -0,0 +1,74 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: krakjoe@php.net |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_WEAKREFS_H
#define ZEND_WEAKREFS_H
#include "zend_alloc.h"
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_weakref;
void zend_register_weakref_ce(void);
void zend_weakrefs_init(void);
void zend_weakrefs_shutdown(void);
ZEND_API void zend_weakrefs_notify(zend_object *object);
ZEND_API zval *zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pData);
ZEND_API zend_result zend_weakrefs_hash_del(HashTable *ht, zend_object *key);
static zend_always_inline void *zend_weakrefs_hash_add_ptr(HashTable *ht, zend_object *key, void *ptr) {
zval tmp, *zv;
ZVAL_PTR(&tmp, ptr);
if ((zv = zend_weakrefs_hash_add(ht, key, &tmp))) {
return Z_PTR_P(zv);
} else {
return NULL;
}
}
/* Because php uses the raw numbers as a hash function, raw pointers will lead to hash collisions.
* We have a guarantee that the lowest ZEND_MM_ALIGNED_OFFSET_LOG2 bits of a pointer are zero.
*
* E.g. On most 64-bit platforms, pointers are aligned to 8 bytes, so the least significant 3 bits are always 0 and can be discarded.
*
* NOTE: This function is only used for EG(weakrefs) and zend_weakmap->ht.
* It is not used for the HashTable instances associated with ZEND_WEAKREF_TAG_HT tags (created in zend_weakref_register, which uses ZEND_WEAKREF_ENCODE instead).
* The ZEND_WEAKREF_TAG_HT instances are used to disambiguate between multiple weak references to the same zend_object.
*/
static zend_always_inline zend_ulong zend_object_to_weakref_key(const zend_object *object)
{
ZEND_ASSERT(((uintptr_t)object) % ZEND_MM_ALIGNMENT == 0);
return ((uintptr_t) object) >> ZEND_MM_ALIGNMENT_LOG2;
}
static zend_always_inline zend_object *zend_weakref_key_to_object(zend_ulong key)
{
return (zend_object *) (((uintptr_t) key) << ZEND_MM_ALIGNMENT_LOG2);
}
HashTable *zend_weakmap_get_gc(zend_object *object, zval **table, int *n);
HashTable *zend_weakmap_get_key_entry_gc(zend_object *object, zval **table, int *n);
HashTable *zend_weakmap_get_entry_gc(zend_object *object, zval **table, int *n);
HashTable *zend_weakmap_get_object_key_entry_gc(zend_object *object, zval **table, int *n);
HashTable *zend_weakmap_get_object_entry_gc(zend_object *object, zval **table, int *n);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,88 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d91889851d9732d41e43fffddb6235d033c67534 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_WeakReference___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_WeakReference_create, 0, 1, WeakReference, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakReference_get, 0, 0, IS_OBJECT, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetGet, 0, 1, IS_MIXED, 0)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetSet, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, object)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetExists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetUnset, 0, 1, IS_VOID, 0)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_count, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_WeakMap_getIterator, 0, 0, Iterator, 0)
ZEND_END_ARG_INFO()
ZEND_METHOD(WeakReference, __construct);
ZEND_METHOD(WeakReference, create);
ZEND_METHOD(WeakReference, get);
ZEND_METHOD(WeakMap, offsetGet);
ZEND_METHOD(WeakMap, offsetSet);
ZEND_METHOD(WeakMap, offsetExists);
ZEND_METHOD(WeakMap, offsetUnset);
ZEND_METHOD(WeakMap, count);
ZEND_METHOD(WeakMap, getIterator);
static const zend_function_entry class_WeakReference_methods[] = {
ZEND_ME(WeakReference, __construct, arginfo_class_WeakReference___construct, ZEND_ACC_PUBLIC)
ZEND_ME(WeakReference, create, arginfo_class_WeakReference_create, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(WeakReference, get, arginfo_class_WeakReference_get, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_WeakMap_methods[] = {
ZEND_ME(WeakMap, offsetGet, arginfo_class_WeakMap_offsetGet, ZEND_ACC_PUBLIC)
ZEND_ME(WeakMap, offsetSet, arginfo_class_WeakMap_offsetSet, ZEND_ACC_PUBLIC)
ZEND_ME(WeakMap, offsetExists, arginfo_class_WeakMap_offsetExists, ZEND_ACC_PUBLIC)
ZEND_ME(WeakMap, offsetUnset, arginfo_class_WeakMap_offsetUnset, ZEND_ACC_PUBLIC)
ZEND_ME(WeakMap, count, arginfo_class_WeakMap_count, ZEND_ACC_PUBLIC)
ZEND_ME(WeakMap, getIterator, arginfo_class_WeakMap_getIterator, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static zend_class_entry *register_class_WeakReference(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "WeakReference", class_WeakReference_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
return class_entry;
}
static zend_class_entry *register_class_WeakMap(zend_class_entry *class_entry_ArrayAccess, zend_class_entry *class_entry_Countable, zend_class_entry *class_entry_IteratorAggregate)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "WeakMap", class_WeakMap_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
zend_class_implements(class_entry, 3, class_entry_ArrayAccess, class_entry_Countable, class_entry_IteratorAggregate);
return class_entry;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
#ifdef PHP_WIN32
# include "config.w32.h"
#else
# include <php_config.h>
#endif
#include <inttypes.h>
#include <stdint.h>
#include "zend.h"
#define timelib_malloc emalloc
#define timelib_realloc erealloc
#define timelib_calloc ecalloc
#define timelib_strdup estrdup
#define timelib_strndup estrndup
#define timelib_free efree

View File

@ -0,0 +1,147 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Derick Rethans <derick@derickrethans.nl> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_DATE_H
#define PHP_DATE_H
#include "lib/timelib.h"
#include "Zend/zend_hash.h"
#include "php_version.h"
#define PHP_DATE_VERSION PHP_VERSION
extern zend_module_entry date_module_entry;
#define phpext_date_ptr &date_module_entry
PHP_RINIT_FUNCTION(date);
PHP_RSHUTDOWN_FUNCTION(date);
PHP_MINIT_FUNCTION(date);
PHP_MSHUTDOWN_FUNCTION(date);
PHP_MINFO_FUNCTION(date);
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(date);
typedef struct _php_date_obj php_date_obj;
typedef struct _php_timezone_obj php_timezone_obj;
typedef struct _php_interval_obj php_interval_obj;
typedef struct _php_period_obj php_period_obj;
struct _php_date_obj {
timelib_time *time;
zend_object std;
};
static inline php_date_obj *php_date_obj_from_obj(zend_object *obj) {
return (php_date_obj*)((char*)(obj) - XtOffsetOf(php_date_obj, std));
}
#define Z_PHPDATE_P(zv) php_date_obj_from_obj(Z_OBJ_P((zv)))
struct _php_timezone_obj {
bool initialized;
int type;
union {
timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID */
timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
timelib_abbr_info z; /* TIMELIB_ZONETYPE_ABBR */
} tzi;
zend_object std;
};
static inline php_timezone_obj *php_timezone_obj_from_obj(zend_object *obj) {
return (php_timezone_obj*)((char*)(obj) - XtOffsetOf(php_timezone_obj, std));
}
#define Z_PHPTIMEZONE_P(zv) php_timezone_obj_from_obj(Z_OBJ_P((zv)))
#define PHP_DATE_CIVIL 1
#define PHP_DATE_WALL 2
struct _php_interval_obj {
timelib_rel_time *diff;
int civil_or_wall;
bool from_string;
zend_string *date_string;
bool initialized;
zend_object std;
};
static inline php_interval_obj *php_interval_obj_from_obj(zend_object *obj) {
return (php_interval_obj*)((char*)(obj) - XtOffsetOf(php_interval_obj, std));
}
#define Z_PHPINTERVAL_P(zv) php_interval_obj_from_obj(Z_OBJ_P((zv)))
struct _php_period_obj {
timelib_time *start;
zend_class_entry *start_ce;
timelib_time *current;
timelib_time *end;
timelib_rel_time *interval;
int recurrences;
bool initialized;
bool include_start_date;
bool include_end_date;
zend_object std;
};
static inline php_period_obj *php_period_obj_from_obj(zend_object *obj) {
return (php_period_obj*)((char*)(obj) - XtOffsetOf(php_period_obj, std));
}
#define Z_PHPPERIOD_P(zv) php_period_obj_from_obj(Z_OBJ_P((zv)))
ZEND_BEGIN_MODULE_GLOBALS(date)
char *default_timezone;
char *timezone;
HashTable *tzcache;
timelib_error_container *last_errors;
ZEND_END_MODULE_GLOBALS(date)
#define DATEG(v) ZEND_MODULE_GLOBALS_ACCESSOR(date, v)
PHPAPI time_t php_time(void);
/* Backwards compatibility wrapper */
PHPAPI zend_long php_parse_date(const char *string, zend_long *now);
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, bool gmt);
PHPAPI int php_idate(char format, time_t ts, bool localtime);
#define _php_strftime php_strftime
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gm);
PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, bool localtime);
/* Mechanism to set new TZ database */
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
PHPAPI timelib_tzinfo *get_timezone_info(void);
/* Grabbing CE's so that other exts can use the date objects too */
PHPAPI zend_class_entry *php_date_get_date_ce(void);
PHPAPI zend_class_entry *php_date_get_immutable_ce(void);
PHPAPI zend_class_entry *php_date_get_interface_ce(void);
PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
PHPAPI zend_class_entry *php_date_get_interval_ce(void);
PHPAPI zend_class_entry *php_date_get_period_ce(void);
/* Functions for creating DateTime objects, and initializing them from a string */
#define PHP_DATE_INIT_CTOR 0x01
#define PHP_DATE_INIT_FORMAT 0x02
PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object);
PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags);
#endif /* PHP_DATE_H */

View File

@ -0,0 +1,86 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Christian Stocker <chregu@php.net> |
| Rob Richards <rrichards@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_XML_COMMON_H
#define PHP_XML_COMMON_H
#include "ext/libxml/php_libxml.h"
typedef libxml_doc_props *dom_doc_propsptr;
typedef struct _dom_object {
void *ptr;
php_libxml_ref_obj *document;
HashTable *prop_handler;
zend_object std;
} dom_object;
static inline dom_object *php_dom_obj_from_obj(zend_object *obj) {
return (dom_object*)((char*)(obj) - XtOffsetOf(dom_object, std));
}
#define Z_DOMOBJ_P(zv) php_dom_obj_from_obj(Z_OBJ_P((zv)))
#ifdef PHP_WIN32
# ifdef DOM_EXPORTS
# define PHP_DOM_EXPORT __declspec(dllexport)
# elif !defined(DOM_LOCAL_DEFINES) /* Allow to counteract LNK4049 warning. */
# define PHP_DOM_EXPORT __declspec(dllimport)
# else
# define PHP_DOM_EXPORT
# endif /* DOM_EXPORTS */
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_DOM_EXPORT __attribute__ ((visibility("default")))
#elif defined(PHPAPI)
# define PHP_DOM_EXPORT PHPAPI
#else
# define PHP_DOM_EXPORT
#endif
PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
PHP_DOM_EXPORT bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
#define DOM_XMLNS_NAMESPACE \
(const xmlChar *) "http://www.w3.org/2000/xmlns/"
#define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
__intern = Z_LIBXML_NODE_P(__id); \
if (UNEXPECTED(__intern->node == NULL)) { \
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
ZSTR_VAL(__intern->std.ce->name));\
RETURN_NULL();\
} \
__ptr = (__prtype)__intern->node->node; \
}
#define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
__intern = Z_LIBXML_NODE_P(__id); \
if (EXPECTED(__intern->document != NULL)) { \
__ptr = (__prtype)__intern->document->ptr); \
} \
}
#define DOM_RET_OBJ(obj, ret, domobject) \
*ret = php_dom_create_object(obj, return_value, domobject)
#define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
__id = ZEND_THIS; \
DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
#endif

View File

@ -0,0 +1,88 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Derick Rethans <derick@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_FILTER_H
#define PHP_FILTER_H
#include "SAPI.h"
#include "zend_API.h"
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "ext/standard/html.h"
#include "php_variables.h"
extern zend_module_entry filter_module_entry;
#define phpext_filter_ptr &filter_module_entry
#ifdef ZTS
#include "TSRM.h"
#endif
#define PHP_FILTER_VERSION PHP_VERSION
PHP_MINIT_FUNCTION(filter);
PHP_MSHUTDOWN_FUNCTION(filter);
PHP_RINIT_FUNCTION(filter);
PHP_RSHUTDOWN_FUNCTION(filter);
PHP_MINFO_FUNCTION(filter);
ZEND_BEGIN_MODULE_GLOBALS(filter)
zval post_array;
zval get_array;
zval cookie_array;
zval env_array;
zval server_array;
#if 0
zval session_array;
#endif
zend_long default_filter;
zend_long default_filter_flags;
ZEND_END_MODULE_GLOBALS(filter)
#if defined(COMPILE_DL_FILTER) && defined(ZTS)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
#define IF_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(filter, v)
#define PHP_INPUT_FILTER_PARAM_DECL zval *value, zend_long flags, zval *option_array, char *charset
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL);
#endif /* FILTER_H */

View File

@ -0,0 +1,172 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_H
#define PHP_HASH_H
#include "php.h"
#define PHP_HASH_EXTNAME "hash"
#define PHP_HASH_VERSION PHP_VERSION
#define PHP_MHASH_VERSION PHP_VERSION
#define PHP_HASH_HMAC 0x0001
#define PHP_HASH_SERIALIZE_MAGIC_SPEC 2
#define L64 INT64_C
typedef struct _php_hashcontext_object php_hashcontext_object;
typedef void (*php_hash_init_func_t)(void *context, HashTable *args);
typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, size_t count);
typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);
typedef int (*php_hash_copy_func_t)(const void *ops, void *orig_context, void *dest_context);
typedef int (*php_hash_serialize_func_t)(const php_hashcontext_object *hash, zend_long *magic, zval *zv);
typedef int (*php_hash_unserialize_func_t)(php_hashcontext_object *hash, zend_long magic, const zval *zv);
typedef struct _php_hash_ops {
const char *algo;
php_hash_init_func_t hash_init;
php_hash_update_func_t hash_update;
php_hash_final_func_t hash_final;
php_hash_copy_func_t hash_copy;
php_hash_serialize_func_t hash_serialize;
php_hash_unserialize_func_t hash_unserialize;
const char *serialize_spec;
size_t digest_size;
size_t block_size;
size_t context_size;
unsigned is_crypto: 1;
} php_hash_ops;
struct _php_hashcontext_object {
const php_hash_ops *ops;
void *context;
zend_long options;
unsigned char *key;
zend_object std;
};
static inline php_hashcontext_object *php_hashcontext_from_object(zend_object *obj) {
return ((php_hashcontext_object*)(obj + 1)) - 1;
}
extern const php_hash_ops php_hash_md2_ops;
extern const php_hash_ops php_hash_md4_ops;
extern const php_hash_ops php_hash_md5_ops;
extern const php_hash_ops php_hash_sha1_ops;
extern const php_hash_ops php_hash_sha224_ops;
extern const php_hash_ops php_hash_sha256_ops;
extern const php_hash_ops php_hash_sha384_ops;
extern const php_hash_ops php_hash_sha512_ops;
extern const php_hash_ops php_hash_sha512_256_ops;
extern const php_hash_ops php_hash_sha512_224_ops;
extern const php_hash_ops php_hash_sha3_224_ops;
extern const php_hash_ops php_hash_sha3_256_ops;
extern const php_hash_ops php_hash_sha3_384_ops;
extern const php_hash_ops php_hash_sha3_512_ops;
extern const php_hash_ops php_hash_ripemd128_ops;
extern const php_hash_ops php_hash_ripemd160_ops;
extern const php_hash_ops php_hash_ripemd256_ops;
extern const php_hash_ops php_hash_ripemd320_ops;
extern const php_hash_ops php_hash_whirlpool_ops;
extern const php_hash_ops php_hash_3tiger128_ops;
extern const php_hash_ops php_hash_3tiger160_ops;
extern const php_hash_ops php_hash_3tiger192_ops;
extern const php_hash_ops php_hash_4tiger128_ops;
extern const php_hash_ops php_hash_4tiger160_ops;
extern const php_hash_ops php_hash_4tiger192_ops;
extern const php_hash_ops php_hash_snefru_ops;
extern const php_hash_ops php_hash_gost_ops;
extern const php_hash_ops php_hash_gost_crypto_ops;
extern const php_hash_ops php_hash_adler32_ops;
extern const php_hash_ops php_hash_crc32_ops;
extern const php_hash_ops php_hash_crc32b_ops;
extern const php_hash_ops php_hash_crc32c_ops;
extern const php_hash_ops php_hash_fnv132_ops;
extern const php_hash_ops php_hash_fnv1a32_ops;
extern const php_hash_ops php_hash_fnv164_ops;
extern const php_hash_ops php_hash_fnv1a64_ops;
extern const php_hash_ops php_hash_joaat_ops;
extern const php_hash_ops php_hash_murmur3a_ops;
extern const php_hash_ops php_hash_murmur3c_ops;
extern const php_hash_ops php_hash_murmur3f_ops;
extern const php_hash_ops php_hash_xxh32_ops;
extern const php_hash_ops php_hash_xxh64_ops;
extern const php_hash_ops php_hash_xxh3_64_ops;
extern const php_hash_ops php_hash_xxh3_128_ops;
#define PHP_HASH_HAVAL_OPS(p,b) extern const php_hash_ops php_hash_##p##haval##b##_ops;
PHP_HASH_HAVAL_OPS(3,128)
PHP_HASH_HAVAL_OPS(3,160)
PHP_HASH_HAVAL_OPS(3,192)
PHP_HASH_HAVAL_OPS(3,224)
PHP_HASH_HAVAL_OPS(3,256)
PHP_HASH_HAVAL_OPS(4,128)
PHP_HASH_HAVAL_OPS(4,160)
PHP_HASH_HAVAL_OPS(4,192)
PHP_HASH_HAVAL_OPS(4,224)
PHP_HASH_HAVAL_OPS(4,256)
PHP_HASH_HAVAL_OPS(5,128)
PHP_HASH_HAVAL_OPS(5,160)
PHP_HASH_HAVAL_OPS(5,192)
PHP_HASH_HAVAL_OPS(5,224)
PHP_HASH_HAVAL_OPS(5,256)
extern zend_module_entry hash_module_entry;
#define phpext_hash_ptr &hash_module_entry
#ifdef PHP_WIN32
# define PHP_HASH_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_HASH_API __attribute__ ((visibility("default")))
#else
# define PHP_HASH_API
#endif
extern PHP_HASH_API zend_class_entry *php_hashcontext_ce;
PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(zend_string *algo);
PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops);
PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_context);
PHP_HASH_API int php_hash_serialize(const php_hashcontext_object *context, zend_long *magic, zval *zv);
PHP_HASH_API int php_hash_unserialize(php_hashcontext_object *context, zend_long magic, const zval *zv);
PHP_HASH_API int php_hash_serialize_spec(const php_hashcontext_object *context, zval *zv, const char *spec);
PHP_HASH_API int php_hash_unserialize_spec(php_hashcontext_object *hash, const zval *zv, const char *spec);
static inline void *php_hash_alloc_context(const php_hash_ops *ops) {
/* Zero out context memory so serialization doesn't expose internals */
return ecalloc(1, ops->context_size);
}
static inline void php_hash_bin2hex(char *out, const unsigned char *in, size_t in_len)
{
static const char hexits[17] = "0123456789abcdef";
size_t i;
for(i = 0; i < in_len; i++) {
out[i * 2] = hexits[in[i] >> 4];
out[(i * 2) + 1] = hexits[in[i] & 0x0F];
}
}
#endif /* PHP_HASH_H */

View File

@ -0,0 +1,32 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_ADLER32_H
#define PHP_HASH_ADLER32_H
#include "ext/standard/basic_functions.h"
typedef struct {
uint32_t state;
} PHP_ADLER32_CTX;
#define PHP_ADLER32_SPEC "l."
PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len);
PHP_HASH_API void PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context);
PHP_HASH_API int PHP_ADLER32Copy(const php_hash_ops *ops, PHP_ADLER32_CTX *orig_context, PHP_ADLER32_CTX *copy_context);
#endif

View File

@ -0,0 +1,35 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_CRC32_H
#define PHP_HASH_CRC32_H
#include "ext/standard/basic_functions.h"
typedef struct {
uint32_t state;
} PHP_CRC32_CTX;
#define PHP_CRC32_SPEC "l."
PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *input, size_t len);
PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len);
PHP_HASH_API void PHP_CRC32CUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len);
PHP_HASH_API void PHP_CRC32LEFinal(unsigned char digest[4], PHP_CRC32_CTX *context);
PHP_HASH_API void PHP_CRC32BEFinal(unsigned char digest[4], PHP_CRC32_CTX *context);
PHP_HASH_API int PHP_CRC32Copy(const php_hash_ops *ops, PHP_CRC32_CTX *orig_context, PHP_CRC32_CTX *copy_context);
#endif

View File

@ -0,0 +1,66 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Maclean <mgdm@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_FNV_H
#define PHP_HASH_FNV_H
#define PHP_FNV1_32_INIT ((uint32_t)0x811c9dc5)
#define PHP_FNV_32_PRIME ((uint32_t)0x01000193)
#define PHP_FNV1_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
#define PHP_FNV_64_PRIME ((uint64_t)0x100000001b3ULL)
/*
* hash types
*/
enum php_fnv_type {
PHP_FNV_NONE = 0, /* invalid FNV hash type */
PHP_FNV0_32 = 1, /* FNV-0 32 bit hash */
PHP_FNV1_32 = 2, /* FNV-1 32 bit hash */
PHP_FNV1a_32 = 3, /* FNV-1a 32 bit hash */
PHP_FNV0_64 = 4, /* FNV-0 64 bit hash */
PHP_FNV1_64 = 5, /* FNV-1 64 bit hash */
PHP_FNV1a_64 = 6, /* FNV-1a 64 bit hash */
};
typedef struct {
uint32_t state;
} PHP_FNV132_CTX;
#define PHP_FNV132_SPEC "l."
typedef struct {
uint64_t state;
} PHP_FNV164_CTX;
#define PHP_FNV164_SPEC "q."
PHP_HASH_API void PHP_FNV132Init(PHP_FNV132_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_FNV132Update(PHP_FNV132_CTX *context, const unsigned char *input, size_t inputLen);
PHP_HASH_API void PHP_FNV1a32Update(PHP_FNV132_CTX *context, const unsigned char *input, size_t inputLen);
PHP_HASH_API void PHP_FNV132Final(unsigned char digest[4], PHP_FNV132_CTX * context);
PHP_HASH_API void PHP_FNV164Init(PHP_FNV164_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_FNV164Update(PHP_FNV164_CTX *context, const unsigned char *input, size_t inputLen);
PHP_HASH_API void PHP_FNV1a64Update(PHP_FNV164_CTX *context, const unsigned char *input, size_t inputLen);
PHP_HASH_API void PHP_FNV164Final(unsigned char digest[8], PHP_FNV164_CTX * context);
static uint32_t fnv_32_buf(void *buf, size_t len, uint32_t hval, int alternate);
static uint64_t fnv_64_buf(void *buf, size_t len, uint64_t hval, int alternate);
#endif

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_GOST_H
#define PHP_HASH_GOST_H
#include "ext/standard/basic_functions.h"
/* GOST context */
typedef struct {
uint32_t state[16];
uint32_t count[2];
unsigned char length;
unsigned char buffer[32];
const uint32_t (*tables)[4][256];
} PHP_GOST_CTX;
#define PHP_GOST_SPEC "l16l2bb32"
PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_GOSTFinal(unsigned char[32], PHP_GOST_CTX *);
#endif

View File

@ -0,0 +1,56 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_HAVAL_H
#define PHP_HASH_HAVAL_H
#include "ext/standard/basic_functions.h"
/* HAVAL context. */
typedef struct {
uint32_t state[8];
uint32_t count[2];
unsigned char buffer[128];
char passes;
short output;
void (*Transform)(uint32_t state[8], const unsigned char block[128]);
} PHP_HAVAL_CTX;
#define PHP_HAVAL_SPEC "l8l2b128"
#define PHP_HASH_HAVAL_INIT_DECL(p,b) PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *); \
PHP_HASH_API void PHP_HAVAL##b##Final(unsigned char*, PHP_HAVAL_CTX *);
PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *, const unsigned char *, size_t);
PHP_HASH_HAVAL_INIT_DECL(3,128)
PHP_HASH_HAVAL_INIT_DECL(3,160)
PHP_HASH_HAVAL_INIT_DECL(3,192)
PHP_HASH_HAVAL_INIT_DECL(3,224)
PHP_HASH_HAVAL_INIT_DECL(3,256)
PHP_HASH_HAVAL_INIT_DECL(4,128)
PHP_HASH_HAVAL_INIT_DECL(4,160)
PHP_HASH_HAVAL_INIT_DECL(4,192)
PHP_HASH_HAVAL_INIT_DECL(4,224)
PHP_HASH_HAVAL_INIT_DECL(4,256)
PHP_HASH_HAVAL_INIT_DECL(5,128)
PHP_HASH_HAVAL_INIT_DECL(5,160)
PHP_HASH_HAVAL_INIT_DECL(5,192)
PHP_HASH_HAVAL_INIT_DECL(5,224)
PHP_HASH_HAVAL_INIT_DECL(5,256)
#endif

View File

@ -0,0 +1,31 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Martin Jansen <mj@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_JOAAT_H
#define PHP_HASH_JOAAT_H
typedef struct {
uint32_t state;
} PHP_JOAAT_CTX;
#define PHP_JOAAT_SPEC "l."
PHP_HASH_API void PHP_JOAATInit(PHP_JOAAT_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_JOAATUpdate(PHP_JOAAT_CTX *context, const unsigned char *input, size_t inputLen);
PHP_HASH_API void PHP_JOAATFinal(unsigned char digest[4], PHP_JOAAT_CTX * context);
static uint32_t joaat_buf(void *buf, size_t len, uint32_t hval);
#endif

View File

@ -0,0 +1,50 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Original Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Modified for pHASH by: Sara Golemon <pollita@php.net>
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_MD_H
#define PHP_HASH_MD_H
#include "ext/standard/md5.h"
/* MD4 context */
typedef struct {
uint32_t state[4];
uint32_t count[2];
unsigned char buffer[64];
} PHP_MD4_CTX;
#define PHP_MD4_SPEC "l4l2b64."
#define PHP_MD4Init(ctx) PHP_MD4InitArgs(ctx, NULL)
PHP_HASH_API void PHP_MD4InitArgs(PHP_MD4_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, size_t);
PHP_HASH_API void PHP_MD4Final(unsigned char[16], PHP_MD4_CTX *);
/* MD2 context */
typedef struct {
unsigned char state[48];
unsigned char checksum[16];
unsigned char buffer[16];
unsigned char in_buffer;
} PHP_MD2_CTX;
#define PHP_MD2_SPEC "b48b16b16b."
#define PHP_MD2Init(ctx) PHP_MD2InitArgs(ctx, NULL)
PHP_HASH_API void PHP_MD2InitArgs(PHP_MD2_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *, size_t);
PHP_HASH_API void PHP_MD2Final(unsigned char[16], PHP_MD2_CTX *);
#endif

View File

@ -0,0 +1,57 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_MURMUR_H
#define PHP_HASH_MURMUR_H
typedef struct {
uint32_t h;
uint32_t carry;
uint32_t len;
} PHP_MURMUR3A_CTX;
#define PHP_MURMUR3A_SPEC "lll"
PHP_HASH_API void PHP_MURMUR3AInit(PHP_MURMUR3A_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_MURMUR3AUpdate(PHP_MURMUR3A_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_MURMUR3AFinal(unsigned char digest[4], PHP_MURMUR3A_CTX *ctx);
PHP_HASH_API int PHP_MURMUR3ACopy(const php_hash_ops *ops, PHP_MURMUR3A_CTX *orig_context, PHP_MURMUR3A_CTX *copy_context);
typedef struct {
uint32_t h[4];
uint32_t carry[4];
uint32_t len;
} PHP_MURMUR3C_CTX;
#define PHP_MURMUR3C_SPEC "lllllllll"
PHP_HASH_API void PHP_MURMUR3CInit(PHP_MURMUR3C_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_MURMUR3CUpdate(PHP_MURMUR3C_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_MURMUR3CFinal(unsigned char digest[16], PHP_MURMUR3C_CTX *ctx);
PHP_HASH_API int PHP_MURMUR3CCopy(const php_hash_ops *ops, PHP_MURMUR3C_CTX *orig_context, PHP_MURMUR3C_CTX *copy_context);
typedef struct {
uint64_t h[2];
uint64_t carry[2];
uint32_t len;
} PHP_MURMUR3F_CTX;
#define PHP_MURMUR3F_SPEC "qqqql"
PHP_HASH_API void PHP_MURMUR3FInit(PHP_MURMUR3F_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_MURMUR3FUpdate(PHP_MURMUR3F_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_MURMUR3FFinal(unsigned char digest[16], PHP_MURMUR3F_CTX *ctx);
PHP_HASH_API int PHP_MURMUR3FCopy(const php_hash_ops *ops, PHP_MURMUR3F_CTX *orig_context, PHP_MURMUR3F_CTX *copy_context);
#endif /* PHP_HASH_MURMUR_H */

View File

@ -0,0 +1,66 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_RIPEMD_H
#define PHP_HASH_RIPEMD_H
#include "ext/standard/basic_functions.h"
/* RIPEMD context. */
typedef struct {
uint32_t state[4]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_RIPEMD128_CTX;
#define PHP_RIPEMD128_SPEC "l4l2b64."
typedef struct {
uint32_t state[5]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_RIPEMD160_CTX;
#define PHP_RIPEMD160_SPEC "l5l2b64."
typedef struct {
uint32_t state[8]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_RIPEMD256_CTX;
#define PHP_RIPEMD256_SPEC "l8l2b64."
typedef struct {
uint32_t state[10]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_RIPEMD320_CTX;
#define PHP_RIPEMD320_SPEC "l10l2b64."
PHP_HASH_API void PHP_RIPEMD128Init(PHP_RIPEMD128_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_RIPEMD128Final(unsigned char[16], PHP_RIPEMD128_CTX *);
PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_RIPEMD160Final(unsigned char[20], PHP_RIPEMD160_CTX *);
PHP_HASH_API void PHP_RIPEMD256Init(PHP_RIPEMD256_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_RIPEMD256Final(unsigned char[32], PHP_RIPEMD256_CTX *);
PHP_HASH_API void PHP_RIPEMD320Init(PHP_RIPEMD320_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_RIPEMD320Final(unsigned char[40], PHP_RIPEMD320_CTX *);
#endif /* PHP_HASH_RIPEMD_H */

View File

@ -0,0 +1,86 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| SHA1 Author: Stefan Esser <sesser@php.net> |
| SHA256 Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_SHA_H
#define PHP_HASH_SHA_H
#include "ext/standard/sha1.h"
#include "ext/standard/basic_functions.h"
/* SHA224 context. */
typedef struct {
uint32_t state[8]; /* state */
uint32_t count[2]; /* number of bits, modulo 2^64 */
unsigned char buffer[64]; /* input buffer */
} PHP_SHA224_CTX;
#define PHP_SHA224_SPEC "l8l2b64."
#define PHP_SHA224Init(ctx) PHP_SHA224InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA224InitArgs(PHP_SHA224_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_SHA224Final(unsigned char[28], PHP_SHA224_CTX *);
/* SHA256 context. */
typedef struct {
uint32_t state[8]; /* state */
uint32_t count[2]; /* number of bits, modulo 2^64 */
unsigned char buffer[64]; /* input buffer */
} PHP_SHA256_CTX;
#define PHP_SHA256_SPEC "l8l2b64."
#define PHP_SHA256Init(ctx) PHP_SHA256InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA256InitArgs(PHP_SHA256_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *);
/* SHA384 context */
typedef struct {
uint64_t state[8]; /* state */
uint64_t count[2]; /* number of bits, modulo 2^128 */
unsigned char buffer[128]; /* input buffer */
} PHP_SHA384_CTX;
#define PHP_SHA384_SPEC "q8q2b128."
#define PHP_SHA384Init(ctx) PHP_SHA384InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA384InitArgs(PHP_SHA384_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_SHA384Final(unsigned char[48], PHP_SHA384_CTX *);
/* SHA512 context */
typedef struct {
uint64_t state[8]; /* state */
uint64_t count[2]; /* number of bits, modulo 2^128 */
unsigned char buffer[128]; /* input buffer */
} PHP_SHA512_CTX;
#define PHP_SHA512_SPEC "q8q2b128."
#define PHP_SHA512Init(ctx) PHP_SHA512InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA512InitArgs(PHP_SHA512_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_SHA512Final(unsigned char[64], PHP_SHA512_CTX *);
#define PHP_SHA512_256Init(ctx) PHP_SHA512_256InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA512_256InitArgs(PHP_SHA512_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
#define PHP_SHA512_256Update PHP_SHA512Update
PHP_HASH_API void PHP_SHA512_256Final(unsigned char[32], PHP_SHA512_CTX *);
#define PHP_SHA512_224Init(ctx) PHP_SHA512_224InitArgs(ctx, NULL)
PHP_HASH_API void PHP_SHA512_224InitArgs(PHP_SHA512_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
#define PHP_SHA512_224Update PHP_SHA512Update
PHP_HASH_API void PHP_SHA512_224Final(unsigned char[28], PHP_SHA512_CTX *);
#endif /* PHP_HASH_SHA_H */

View File

@ -0,0 +1,55 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_SHA3_H
#define PHP_HASH_SHA3_H
#include "php.h"
typedef struct {
#ifdef HAVE_SLOW_HASH3
unsigned char state[200]; // 5 * 5 * sizeof(uint64)
uint32_t pos;
#else
unsigned char state[224]; // this must fit a Keccak_HashInstance
#endif
} PHP_SHA3_CTX;
#ifdef HAVE_SLOW_HASH3
#define PHP_SHA3_SPEC "b200l."
#endif
typedef PHP_SHA3_CTX PHP_SHA3_224_CTX;
typedef PHP_SHA3_CTX PHP_SHA3_256_CTX;
typedef PHP_SHA3_CTX PHP_SHA3_384_CTX;
typedef PHP_SHA3_CTX PHP_SHA3_512_CTX;
PHP_HASH_API void PHP_SHA3224Init(PHP_SHA3_224_CTX*, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA3224Update(PHP_SHA3_224_CTX*, const unsigned char*, size_t);
PHP_HASH_API void PHP_SAH3224Final(unsigned char[32], PHP_SHA3_224_CTX*);
PHP_HASH_API void PHP_SHA3256Init(PHP_SHA3_256_CTX*, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA3256Update(PHP_SHA3_256_CTX*, const unsigned char*, size_t);
PHP_HASH_API void PHP_SAH3256Final(unsigned char[32], PHP_SHA3_256_CTX*);
PHP_HASH_API void PHP_SHA3384Init(PHP_SHA3_384_CTX*, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA3384Update(PHP_SHA3_384_CTX*, const unsigned char*, size_t);
PHP_HASH_API void PHP_SAH3384Final(unsigned char[32], PHP_SHA3_384_CTX*);
PHP_HASH_API void PHP_SHA3512Init(PHP_SHA3_512_CTX*, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SHA3512Update(PHP_SHA3_512_CTX*, const unsigned char*, size_t);
PHP_HASH_API void PHP_SAH3512Final(unsigned char[32], PHP_SHA3_512_CTX*);
#endif

View File

@ -0,0 +1,39 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_SNEFRU_H
#define PHP_HASH_SNEFRU_H
/* SNEFRU-2.5a with 8 passes and 256 bit hash output
* AKA "Xerox Secure Hash Function"
*/
#include "ext/standard/basic_functions.h"
/* SNEFRU context */
typedef struct {
uint32_t state[16];
uint32_t count[2];
unsigned char length;
unsigned char buffer[32];
} PHP_SNEFRU_CTX;
#define PHP_SNEFRU_SPEC "l16l2bb32"
PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_SNEFRUFinal(unsigned char[32], PHP_SNEFRU_CTX *);
#endif

View File

@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_TIGER_H
#define PHP_HASH_TIGER_H
/* TIGER context */
typedef struct {
uint64_t state[3];
uint64_t passed;
unsigned char buffer[64];
uint32_t length;
unsigned int passes:1;
} PHP_TIGER_CTX;
#define PHP_TIGER_SPEC "q3qb64l"
PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len);
PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context);
PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context);
PHP_HASH_API void PHP_TIGER192Final(unsigned char digest[24], PHP_TIGER_CTX *context);
#endif

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_WHIRLPOOL_H
#define PHP_HASH_WHIRLPOOL_H
/* WHIRLPOOL context */
typedef struct {
uint64_t state[8];
unsigned char bitlength[32];
struct {
int pos;
int bits;
unsigned char data[64];
} buffer;
} PHP_WHIRLPOOL_CTX;
#define PHP_WHIRLPOOL_SPEC "q8b32iib64."
PHP_HASH_API void PHP_WHIRLPOOLInit(PHP_WHIRLPOOL_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *, const unsigned char *, size_t);
PHP_HASH_API void PHP_WHIRLPOOLFinal(unsigned char[64], PHP_WHIRLPOOL_CTX *);
#endif

View File

@ -0,0 +1,73 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HASH_XXHASH_H
#define PHP_HASH_XXHASH_H
#define XXH_INLINE_ALL 1
#include "xxhash.h"
typedef struct {
XXH32_state_t s;
} PHP_XXH32_CTX;
#define PHP_XXH32_SPEC "llllllllllll"
PHP_HASH_API void PHP_XXH32Init(PHP_XXH32_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_XXH32Update(PHP_XXH32_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_XXH32Final(unsigned char digest[4], PHP_XXH32_CTX *ctx);
PHP_HASH_API int PHP_XXH32Copy(const php_hash_ops *ops, PHP_XXH32_CTX *orig_context, PHP_XXH32_CTX *copy_context);
typedef struct {
XXH64_state_t s;
} PHP_XXH64_CTX;
#define PHP_XXH64_SPEC "qqqqqqqqqllq"
PHP_HASH_API void PHP_XXH64Init(PHP_XXH64_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_XXH64Update(PHP_XXH64_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_XXH64Final(unsigned char digest[8], PHP_XXH64_CTX *ctx);
PHP_HASH_API int PHP_XXH64Copy(const php_hash_ops *ops, PHP_XXH64_CTX *orig_context, PHP_XXH64_CTX *copy_context);
#define PHP_XXH3_SECRET_SIZE_MIN XXH3_SECRET_SIZE_MIN
#define PHP_XXH3_SECRET_SIZE_MAX 256
typedef struct {
XXH3_state_t s;
/* The value must survive the whole streaming cycle from init to final.
A more flexible mechanism would be to carry zend_string* passed through
the options. However, that will require to introduce a destructor
handler for ctx, so then it wolud be automatically called from the
object destructor. Until that is given, the viable way is to use a
plausible max secret length. */
const unsigned char secret[PHP_XXH3_SECRET_SIZE_MAX];
} PHP_XXH3_CTX;
typedef PHP_XXH3_CTX PHP_XXH3_64_CTX;
PHP_HASH_API void PHP_XXH3_64_Init(PHP_XXH3_64_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_XXH3_64_Update(PHP_XXH3_64_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_XXH3_64_Final(unsigned char digest[8], PHP_XXH3_64_CTX *ctx);
PHP_HASH_API int PHP_XXH3_64_Copy(const php_hash_ops *ops, PHP_XXH3_64_CTX *orig_context, PHP_XXH3_64_CTX *copy_context);
typedef PHP_XXH3_CTX PHP_XXH3_128_CTX;
PHP_HASH_API void PHP_XXH3_128_Init(PHP_XXH3_128_CTX *ctx, HashTable *args);
PHP_HASH_API void PHP_XXH3_128_Update(PHP_XXH3_128_CTX *ctx, const unsigned char *in, size_t len);
PHP_HASH_API void PHP_XXH3_128_Final(unsigned char digest[16], PHP_XXH3_128_CTX *ctx);
PHP_HASH_API int PHP_XXH3_128_Copy(const php_hash_ops *ops, PHP_XXH3_128_CTX *orig_context, PHP_XXH3_128_CTX *copy_context);
#endif /* PHP_HASH_XXHASH_H */

View File

@ -0,0 +1,95 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 4367fa431d3e4814e42d9aa514c10cae1d842d8f */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strlen, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_substr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strrpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_encode, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, field_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, field_value, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode_headers, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, headers, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, from_encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, to_encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iconv_set_encoding, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_get_encoding, 0, 0, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 0, "\"all\"")
ZEND_END_ARG_INFO()
ZEND_FUNCTION(iconv_strlen);
ZEND_FUNCTION(iconv_substr);
ZEND_FUNCTION(iconv_strpos);
ZEND_FUNCTION(iconv_strrpos);
ZEND_FUNCTION(iconv_mime_encode);
ZEND_FUNCTION(iconv_mime_decode);
ZEND_FUNCTION(iconv_mime_decode_headers);
ZEND_FUNCTION(iconv);
ZEND_FUNCTION(iconv_set_encoding);
ZEND_FUNCTION(iconv_get_encoding);
static const zend_function_entry ext_functions[] = {
ZEND_FE(iconv_strlen, arginfo_iconv_strlen)
ZEND_FE(iconv_substr, arginfo_iconv_substr)
ZEND_FE(iconv_strpos, arginfo_iconv_strpos)
ZEND_FE(iconv_strrpos, arginfo_iconv_strrpos)
ZEND_FE(iconv_mime_encode, arginfo_iconv_mime_encode)
ZEND_FE(iconv_mime_decode, arginfo_iconv_mime_decode)
ZEND_FE(iconv_mime_decode_headers, arginfo_iconv_mime_decode_headers)
ZEND_FE(iconv, arginfo_iconv)
ZEND_FE(iconv_set_encoding, arginfo_iconv_set_encoding)
ZEND_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
ZEND_FE_END
};
static void register_iconv_symbols(int module_number)
{
REGISTER_STRING_CONSTANT("ICONV_IMPL", PHP_ICONV_IMPL_VALUE, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("ICONV_VERSION", get_iconv_version(), CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_STRICT", PHP_ICONV_MIME_DECODE_STRICT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ICONV_MIME_DECODE_CONTINUE_ON_ERROR", PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR, CONST_PERSISTENT);
}

View File

@ -0,0 +1,93 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rui Hirokawa <rui_hirokawa@ybb.ne.jp> |
| Stig Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_ICONV_H
#define PHP_ICONV_H
#ifdef PHP_WIN32
# ifdef PHP_ICONV_EXPORTS
# define PHP_ICONV_API __declspec(dllexport)
# else
# define PHP_ICONV_API __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_ICONV_API __attribute__ ((visibility("default")))
#else
# define PHP_ICONV_API
#endif
#include "php_version.h"
#define PHP_ICONV_VERSION PHP_VERSION
#ifdef HAVE_ICONV
extern zend_module_entry iconv_module_entry;
#define iconv_module_ptr &iconv_module_entry
PHP_MINIT_FUNCTION(miconv);
PHP_MSHUTDOWN_FUNCTION(miconv);
PHP_MINFO_FUNCTION(miconv);
ZEND_BEGIN_MODULE_GLOBALS(iconv)
char *input_encoding;
char *internal_encoding;
char *output_encoding;
ZEND_END_MODULE_GLOBALS(iconv)
#define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
#if defined(ZTS) && defined(COMPILE_DL_ICONV)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
#ifdef HAVE_IBM_ICONV
# define ICONV_ASCII_ENCODING "IBM-850"
# define ICONV_UCS4_ENCODING "UCS-4"
#else
# define ICONV_ASCII_ENCODING "ASCII"
# define ICONV_UCS4_ENCODING "UCS-4LE"
#endif
#ifndef ICONV_CSNMAXLEN
#define ICONV_CSNMAXLEN 64
#endif
/* {{{ typedef enum php_iconv_err_t */
typedef enum _php_iconv_err_t {
PHP_ICONV_ERR_SUCCESS = SUCCESS,
PHP_ICONV_ERR_CONVERTER = 1,
PHP_ICONV_ERR_WRONG_CHARSET = 2,
PHP_ICONV_ERR_TOO_BIG = 3,
PHP_ICONV_ERR_ILLEGAL_SEQ = 4,
PHP_ICONV_ERR_ILLEGAL_CHAR = 5,
PHP_ICONV_ERR_UNKNOWN = 6,
PHP_ICONV_ERR_MALFORMED = 7,
PHP_ICONV_ERR_ALLOC = 8,
PHP_ICONV_ERR_OUT_BY_BOUNDS = 9
} php_iconv_err_t;
/* }}} */
PHP_ICONV_API php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len, zend_string **out, const char *out_charset, const char *in_charset);
#else
#define iconv_module_ptr NULL
#endif /* HAVE_ICONV */
#define phpext_iconv_ptr iconv_module_ptr
#endif /* PHP_ICONV_H */

View File

@ -0,0 +1,114 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Omar Kilani <omar@php.net> |
| Jakub Zelenka <bukka@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_JSON_H
#define PHP_JSON_H
#include "php_version.h"
#include "zend_smart_str_public.h"
#define PHP_JSON_VERSION PHP_VERSION
extern zend_module_entry json_module_entry;
#define phpext_json_ptr &json_module_entry
#if defined(PHP_WIN32) && defined(JSON_EXPORTS)
#define PHP_JSON_API __declspec(dllexport)
#else
#define PHP_JSON_API PHPAPI
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
/* error codes */
typedef enum {
PHP_JSON_ERROR_NONE = 0,
PHP_JSON_ERROR_DEPTH,
PHP_JSON_ERROR_STATE_MISMATCH,
PHP_JSON_ERROR_CTRL_CHAR,
PHP_JSON_ERROR_SYNTAX,
PHP_JSON_ERROR_UTF8,
PHP_JSON_ERROR_RECURSION,
PHP_JSON_ERROR_INF_OR_NAN,
PHP_JSON_ERROR_UNSUPPORTED_TYPE,
PHP_JSON_ERROR_INVALID_PROPERTY_NAME,
PHP_JSON_ERROR_UTF16,
PHP_JSON_ERROR_NON_BACKED_ENUM,
} php_json_error_code;
/* json_decode() options */
#define PHP_JSON_OBJECT_AS_ARRAY (1<<0)
#define PHP_JSON_BIGINT_AS_STRING (1<<1)
/* json_encode() options */
#define PHP_JSON_HEX_TAG (1<<0)
#define PHP_JSON_HEX_AMP (1<<1)
#define PHP_JSON_HEX_APOS (1<<2)
#define PHP_JSON_HEX_QUOT (1<<3)
#define PHP_JSON_FORCE_OBJECT (1<<4)
#define PHP_JSON_NUMERIC_CHECK (1<<5)
#define PHP_JSON_UNESCAPED_SLASHES (1<<6)
#define PHP_JSON_PRETTY_PRINT (1<<7)
#define PHP_JSON_UNESCAPED_UNICODE (1<<8)
#define PHP_JSON_PARTIAL_OUTPUT_ON_ERROR (1<<9)
#define PHP_JSON_PRESERVE_ZERO_FRACTION (1<<10)
#define PHP_JSON_UNESCAPED_LINE_TERMINATORS (1<<11)
/* json_validate(), json_decode() and json_encode() common options */
#define PHP_JSON_INVALID_UTF8_IGNORE (1<<20)
/* json_decode() and json_encode() common options */
#define PHP_JSON_INVALID_UTF8_SUBSTITUTE (1<<21)
#define PHP_JSON_THROW_ON_ERROR (1<<22)
/* Internal flags */
#define PHP_JSON_OUTPUT_ARRAY 0
#define PHP_JSON_OUTPUT_OBJECT 1
/* default depth */
#define PHP_JSON_PARSER_DEFAULT_DEPTH 512
ZEND_BEGIN_MODULE_GLOBALS(json)
int encoder_depth;
int encode_max_depth;
php_json_error_code error_code;
ZEND_END_MODULE_GLOBALS(json)
PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS(json)
#define JSON_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(json, v)
#if defined(ZTS) && defined(COMPILE_DL_JSON)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
PHP_JSON_API zend_string *php_json_encode_string(const char *s, size_t len, int options);
PHP_JSON_API zend_result php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth);
PHP_JSON_API zend_result php_json_encode(smart_str *buf, zval *val, int options);
PHP_JSON_API zend_result php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth);
PHP_JSON_API bool php_json_validate_ex(const char *str, size_t str_len, zend_long options, zend_long depth);
static inline zend_result php_json_decode(zval *return_value, const char *str, size_t str_len, bool assoc, zend_long depth)
{
return php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth);
}
#endif /* PHP_JSON_H */

View File

@ -0,0 +1,86 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jakub Zelenka <bukka@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_JSON_PARSER_H
#define PHP_JSON_PARSER_H
#include "php.h"
#include "php_json_scanner.h"
typedef struct _php_json_parser php_json_parser;
typedef int (*php_json_parser_func_array_create_t)(
php_json_parser *parser, zval *array);
typedef int (*php_json_parser_func_array_append_t)(
php_json_parser *parser, zval *array, zval *zvalue);
typedef int (*php_json_parser_func_array_start_t)(
php_json_parser *parser);
typedef int (*php_json_parser_func_array_end_t)(
php_json_parser *parser, zval *object);
typedef int (*php_json_parser_func_object_create_t)(
php_json_parser *parser, zval *object);
typedef int (*php_json_parser_func_object_update_t)(
php_json_parser *parser, zval *object, zend_string *key, zval *zvalue);
typedef int (*php_json_parser_func_object_start_t)(
php_json_parser *parser);
typedef int (*php_json_parser_func_object_end_t)(
php_json_parser *parser, zval *object);
typedef struct _php_json_parser_methods {
php_json_parser_func_array_create_t array_create;
php_json_parser_func_array_append_t array_append;
php_json_parser_func_array_start_t array_start;
php_json_parser_func_array_end_t array_end;
php_json_parser_func_object_create_t object_create;
php_json_parser_func_object_update_t object_update;
php_json_parser_func_object_start_t object_start;
php_json_parser_func_object_end_t object_end;
} php_json_parser_methods;
struct _php_json_parser {
php_json_scanner scanner;
zval *return_value;
int depth;
int max_depth;
php_json_parser_methods methods;
};
PHP_JSON_API void php_json_parser_init_ex(
php_json_parser *parser,
zval *return_value,
const char *str,
size_t str_len,
int options,
int max_depth,
const php_json_parser_methods *methods);
PHP_JSON_API void php_json_parser_init(
php_json_parser *parser,
zval *return_value,
const char *str,
size_t str_len,
int options,
int max_depth);
PHP_JSON_API php_json_error_code php_json_parser_error_code(const php_json_parser *parser);
PHP_JSON_API int php_json_parse(php_json_parser *parser);
int php_json_yyparse(php_json_parser *parser);
const php_json_parser_methods* php_json_get_validate_methods(void);
#endif /* PHP_JSON_PARSER_H */

View File

@ -0,0 +1,46 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jakub Zelenka <bukka@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_JSON_SCANNER_H
#define PHP_JSON_SCANNER_H
#include "php.h"
#include "php_json.h"
typedef unsigned char php_json_ctype;
typedef struct _php_json_scanner {
php_json_ctype *cursor; /* cursor position */
php_json_ctype *token; /* token position */
php_json_ctype *limit; /* the last read character + 1 position */
php_json_ctype *marker; /* marker position for backtracking */
php_json_ctype *ctxmarker; /* marker position for context backtracking */
php_json_ctype *str_start; /* start position of the string */
php_json_ctype *pstr; /* string pointer for escapes conversion */
zval value; /* value */
int str_esc; /* number of extra characters for escaping */
int state; /* condition state */
int options; /* options */
php_json_error_code errcode; /* error type if there is an error */
int utf8_invalid; /* whether utf8 is invalid */
int utf8_invalid_count; /* number of extra character for invalid utf8 */
} php_json_scanner;
void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);
int php_json_scan(php_json_scanner *s);
#endif /* PHP_JSON_SCANNER_H */

View File

@ -0,0 +1,215 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Shane Caraveo <shane@php.net> |
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_LIBXML_H
#define PHP_LIBXML_H
#ifdef HAVE_LIBXML
extern zend_module_entry libxml_module_entry;
#define libxml_module_ptr &libxml_module_entry
#include "php_version.h"
#define PHP_LIBXML_VERSION PHP_VERSION
#ifdef PHP_WIN32
# define PHP_LIBXML_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_LIBXML_API __attribute__ ((visibility("default")))
#else
# define PHP_LIBXML_API
#endif
#include "zend_smart_str.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
#define LIBXML_SAVE_NOEMPTYTAG 1<<2
ZEND_BEGIN_MODULE_GLOBALS(libxml)
zval stream_context;
smart_str error_buffer;
zend_llist *error_list;
zend_fcall_info_cache entity_loader_callback;
bool entity_loader_disabled;
ZEND_END_MODULE_GLOBALS(libxml)
typedef struct _libxml_doc_props {
HashTable *classmap;
bool formatoutput;
bool validateonparse;
bool resolveexternals;
bool preservewhitespace;
bool substituteentities;
bool stricterror;
bool recover;
} libxml_doc_props;
typedef struct {
size_t modification_nr;
} php_libxml_cache_tag;
typedef struct _php_libxml_ref_obj {
void *ptr;
int refcount;
libxml_doc_props *doc_props;
php_libxml_cache_tag cache_tag;
} php_libxml_ref_obj;
typedef struct _php_libxml_node_ptr {
xmlNodePtr node;
int refcount;
void *_private;
} php_libxml_node_ptr;
typedef struct _php_libxml_node_object {
php_libxml_node_ptr *node;
php_libxml_ref_obj *document;
HashTable *properties;
zend_object std;
} php_libxml_node_object;
static inline php_libxml_node_object *php_libxml_node_fetch_object(zend_object *obj) {
return (php_libxml_node_object *)((char*)(obj) - obj->handlers->offset);
}
static zend_always_inline void php_libxml_invalidate_node_list_cache(php_libxml_ref_obj *doc_ptr)
{
if (!doc_ptr) {
return;
}
#if SIZEOF_SIZE_T == 8
/* If one operation happens every nanosecond, then it would still require 584 years to overflow
* the counter. So we'll just assume this never happens. */
doc_ptr->cache_tag.modification_nr++;
#else
size_t new_modification_nr = doc_ptr->cache_tag.modification_nr + 1;
if (EXPECTED(new_modification_nr > 0)) { /* unsigned overflow; checking after addition results in one less instruction */
doc_ptr->cache_tag.modification_nr = new_modification_nr;
}
#endif
}
static zend_always_inline void php_libxml_invalidate_node_list_cache_from_doc(xmlDocPtr docp)
{
if (docp && docp->_private) { /* docp is NULL for detached nodes */
php_libxml_node_ptr *node_private = (php_libxml_node_ptr *) docp->_private;
php_libxml_node_object *object_private = (php_libxml_node_object *) node_private->_private;
if (object_private) {
php_libxml_invalidate_node_list_cache(object_private->document);
}
}
}
#define Z_LIBXML_NODE_P(zv) php_libxml_node_fetch_object(Z_OBJ_P((zv)))
typedef void * (*php_libxml_export_node) (zval *object);
PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data);
PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object);
PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp);
PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object);
PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object);
PHP_LIBXML_API zval *php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
/* When an explicit freeing of node and children is required */
PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node);
PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node);
/* When object dtor is called as node may still be referenced */
PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object);
PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
PHP_LIBXML_API void php_libxml_switch_context(zval *context, zval *oldcontext);
PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable);
PHP_LIBXML_API void php_libxml_set_old_ns(xmlDocPtr doc, xmlNsPtr ns);
/* Init/shutdown functions*/
PHP_LIBXML_API void php_libxml_initialize(void);
PHP_LIBXML_API void php_libxml_shutdown(void);
#define LIBXML(v) ZEND_MODULE_GLOBALS_ACCESSOR(libxml, v)
#if defined(ZTS) && defined(COMPILE_DL_LIBXML)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
#if defined(__clang__)
# define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
# define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
_Pragma("GCC diagnostic pop")
#else
# define PHP_LIBXML_IGNORE_DEPRECATIONS_START
# define PHP_LIBXML_IGNORE_DEPRECATIONS_END
#endif
/* Other extension may override the global state options, these global options
* are copied initially to ctxt->options. Set the options to a known good value.
* See libxml2 globals.c and parserInternals.c.
* The unique_name argument allows multiple sanitizes and restores within the
* same function, even nested is necessary. */
#define PHP_LIBXML_SANITIZE_GLOBALS(unique_name) \
PHP_LIBXML_IGNORE_DEPRECATIONS_START \
int xml_old_loadsubset_##unique_name = xmlLoadExtDtdDefaultValue; \
xmlLoadExtDtdDefaultValue = 0; \
int xml_old_validate_##unique_name = xmlDoValidityCheckingDefaultValue; \
xmlDoValidityCheckingDefaultValue = 0; \
int xml_old_pedantic_##unique_name = xmlPedanticParserDefault(0); \
int xml_old_substitute_##unique_name = xmlSubstituteEntitiesDefault(0); \
int xml_old_linenrs_##unique_name = xmlLineNumbersDefault(0); \
int xml_old_blanks_##unique_name = xmlKeepBlanksDefault(1); \
PHP_LIBXML_IGNORE_DEPRECATIONS_END
#define PHP_LIBXML_RESTORE_GLOBALS(unique_name) \
PHP_LIBXML_IGNORE_DEPRECATIONS_START \
xmlLoadExtDtdDefaultValue = xml_old_loadsubset_##unique_name; \
xmlDoValidityCheckingDefaultValue = xml_old_validate_##unique_name; \
(void) xmlPedanticParserDefault(xml_old_pedantic_##unique_name); \
(void) xmlSubstituteEntitiesDefault(xml_old_substitute_##unique_name); \
(void) xmlLineNumbersDefault(xml_old_linenrs_##unique_name); \
(void) xmlKeepBlanksDefault(xml_old_blanks_##unique_name); \
PHP_LIBXML_IGNORE_DEPRECATIONS_END
/* Alternative for above, working directly on the context and not setting globals.
* Generally faster because no locking is involved, and this has the advantage that it sets the options to a known good value. */
static zend_always_inline void php_libxml_sanitize_parse_ctxt_options(xmlParserCtxtPtr ctxt)
{
ctxt->loadsubset = 0;
ctxt->validate = 0;
ctxt->pedantic = 0;
ctxt->replaceEntities = 0;
ctxt->linenumbers = 0;
ctxt->keepBlanks = 1;
ctxt->options = 0;
}
#else /* HAVE_LIBXML */
#define libxml_module_ptr NULL
#endif
#define phpext_libxml_ptr libxml_module_ptr
#endif /* PHP_LIBXML_H */

View File

@ -0,0 +1,100 @@
#include <php_compat.h>
#ifdef PHP_WIN32
# include <config.w32.h>
#else
# include <php_config.h>
#endif
#define SUPPORT_UNICODE 1
#define SUPPORT_PCRE2_8 1
#if defined(__GNUC__) && __GNUC__ >= 4
# ifdef __cplusplus
# define PCRE2_EXP_DECL extern "C" __attribute__ ((visibility("default")))
# else
# define PCRE2_EXP_DECL extern __attribute__ ((visibility("default")))
# endif
# define PCRE2_EXP_DEFN __attribute__ ((visibility("default")))
#endif
/* Define to any value for valgrind support to find invalid memory reads. */
#ifdef HAVE_PCRE_VALGRIND_SUPPORT
#define SUPPORT_VALGRIND 1
#endif
/* Define to any value to enable support for Just-In-Time compiling. */
#ifdef HAVE_PCRE_JIT_SUPPORT
#define SUPPORT_JIT
#endif
/* This limits the amount of memory that pcre2_match() may use while matching
a pattern. The value is in kilobytes. */
#ifndef HEAP_LIMIT
#define HEAP_LIMIT 20000000
#endif
/* The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
parentheses (of any kind) in a pattern. This limits the amount of system
stack that is used while compiling a pattern. */
#ifndef PARENS_NEST_LIMIT
#define PARENS_NEST_LIMIT 250
#endif
/* The value of MATCH_LIMIT determines the default number of times the
pcre2_match() function can record a backtrack position during a single
matching attempt. There is a runtime interface for setting a different
limit. The limit exists in order to catch runaway regular expressions that
take for ever to determine that they do not match. The default is set very
large so that it does not accidentally catch legitimate cases. */
#ifndef MATCH_LIMIT
#define MATCH_LIMIT 10000000
#endif
/* The above limit applies to all backtracks, whether or not they are nested.
In some environments it is desirable to limit the nesting of backtracking
(that is, the depth of tree that is searched) more strictly, in order to
restrict the maximum amount of heap memory that is used. The value of
MATCH_LIMIT_DEPTH provides this facility. To have any useful effect, it
must be less than the value of MATCH_LIMIT. The default is to use the same
value as MATCH_LIMIT. There is a runtime method for setting a different
limit. */
#ifndef MATCH_LIMIT_DEPTH
#define MATCH_LIMIT_DEPTH MATCH_LIMIT
#endif
/* This limit is parameterized just in case anybody ever wants to change it.
Care must be taken if it is increased, because it guards against integer
overflow caused by enormously large patterns. */
#ifndef MAX_NAME_COUNT
#define MAX_NAME_COUNT 10000
#endif
/* This limit is parameterized just in case anybody ever wants to change it.
Care must be taken if it is increased, because it guards against integer
overflow caused by enormously large patterns. */
#ifndef MAX_NAME_SIZE
#define MAX_NAME_SIZE 32
#endif
/* Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns. */
/* #undef NEVER_BACKSLASH_C */
/* The value of NEWLINE_DEFAULT determines the default newline character
sequence. PCRE2 client programs can override this by selecting other values
at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY), 5
(ANYCRLF), and 6 (NUL). */
#ifndef NEWLINE_DEFAULT
#define NEWLINE_DEFAULT 2
#endif
/* The value of LINK_SIZE determines the number of bytes used to store links
as offsets within the compiled regex. The default is 2, which allows for
compiled patterns up to 64K long. This covers the vast majority of cases.
However, PCRE2 can also be compiled to use 3 or 4 bytes instead. This
allows for longer patterns in extreme cases. */
#ifndef LINK_SIZE
#define LINK_SIZE 2
#endif

View File

@ -0,0 +1,993 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This is the public header file for the PCRE library, second API, to be
#included by applications that call PCRE2 functions.
Copyright (c) 2016-2021 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifndef PCRE2_H_IDEMPOTENT_GUARD
#define PCRE2_H_IDEMPOTENT_GUARD
/* The current PCRE version information. */
#define PCRE2_MAJOR 10
#define PCRE2_MINOR 42
#define PCRE2_PRERELEASE
#define PCRE2_DATE 2022-12-12
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
export setting is defined in pcre2_internal.h, which includes this file. So we
don't change existing definitions of PCRE2_EXP_DECL. */
#if defined(_WIN32) && !defined(PCRE2_STATIC)
# ifndef PCRE2_EXP_DECL
# define PCRE2_EXP_DECL extern __declspec(dllimport)
# endif
#endif
/* By default, we use the standard "extern" declarations. */
#ifndef PCRE2_EXP_DECL
# ifdef __cplusplus
# define PCRE2_EXP_DECL extern "C"
# else
# define PCRE2_EXP_DECL extern
# endif
#endif
/* When compiling with the MSVC compiler, it is sometimes necessary to include
a "calling convention" before exported function names. (This is secondhand
information; I know nothing about MSVC myself). For example, something like
void __cdecl function(....)
might be needed. In order so make this easy, all the exported functions have
PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not
set, we ensure here that it has no effect. */
#ifndef PCRE2_CALL_CONVENTION
#define PCRE2_CALL_CONVENTION
#endif
/* Have to include limits.h, stdlib.h, and inttypes.h to ensure that size_t and
uint8_t, UCHAR_MAX, etc are defined. Some systems that do have inttypes.h do
not have stdint.h, which is why we use inttypes.h, which according to the C
standard is a superset of stdint.h. If inttypes.h is not available the build
will break and the relevant values must be provided by some other means. */
#include <limits.h>
#include <stdlib.h>
#include <inttypes.h>
/* Allow for C++ users compiling this directly. */
#ifdef __cplusplus
extern "C" {
#endif
/* The following option bits can be passed to pcre2_compile(), pcre2_match(),
or pcre2_dfa_match(). PCRE2_NO_UTF_CHECK affects only the function to which it
is passed. Put these bits at the most significant end of the options word so
others can be added next to them */
#define PCRE2_ANCHORED 0x80000000u
#define PCRE2_NO_UTF_CHECK 0x40000000u
#define PCRE2_ENDANCHORED 0x20000000u
/* The following option bits can be passed only to pcre2_compile(). However,
they may affect compilation, JIT compilation, and/or interpretive execution.
The following tags indicate which:
C alters what is compiled by pcre2_compile()
J alters what is compiled by pcre2_jit_compile()
M is inspected during pcre2_match() execution
D is inspected during pcre2_dfa_match() execution
*/
#define PCRE2_ALLOW_EMPTY_CLASS 0x00000001u /* C */
#define PCRE2_ALT_BSUX 0x00000002u /* C */
#define PCRE2_AUTO_CALLOUT 0x00000004u /* C */
#define PCRE2_CASELESS 0x00000008u /* C */
#define PCRE2_DOLLAR_ENDONLY 0x00000010u /* J M D */
#define PCRE2_DOTALL 0x00000020u /* C */
#define PCRE2_DUPNAMES 0x00000040u /* C */
#define PCRE2_EXTENDED 0x00000080u /* C */
#define PCRE2_FIRSTLINE 0x00000100u /* J M D */
#define PCRE2_MATCH_UNSET_BACKREF 0x00000200u /* C J M */
#define PCRE2_MULTILINE 0x00000400u /* C */
#define PCRE2_NEVER_UCP 0x00000800u /* C */
#define PCRE2_NEVER_UTF 0x00001000u /* C */
#define PCRE2_NO_AUTO_CAPTURE 0x00002000u /* C */
#define PCRE2_NO_AUTO_POSSESS 0x00004000u /* C */
#define PCRE2_NO_DOTSTAR_ANCHOR 0x00008000u /* C */
#define PCRE2_NO_START_OPTIMIZE 0x00010000u /* J M D */
#define PCRE2_UCP 0x00020000u /* C J M D */
#define PCRE2_UNGREEDY 0x00040000u /* C */
#define PCRE2_UTF 0x00080000u /* C J M D */
#define PCRE2_NEVER_BACKSLASH_C 0x00100000u /* C */
#define PCRE2_ALT_CIRCUMFLEX 0x00200000u /* J M D */
#define PCRE2_ALT_VERBNAMES 0x00400000u /* C */
#define PCRE2_USE_OFFSET_LIMIT 0x00800000u /* J M D */
#define PCRE2_EXTENDED_MORE 0x01000000u /* C */
#define PCRE2_LITERAL 0x02000000u /* C */
#define PCRE2_MATCH_INVALID_UTF 0x04000000u /* J M D */
/* An additional compile options word is available in the compile context. */
#define PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES 0x00000001u /* C */
#define PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL 0x00000002u /* C */
#define PCRE2_EXTRA_MATCH_WORD 0x00000004u /* C */
#define PCRE2_EXTRA_MATCH_LINE 0x00000008u /* C */
#define PCRE2_EXTRA_ESCAPED_CR_IS_LF 0x00000010u /* C */
#define PCRE2_EXTRA_ALT_BSUX 0x00000020u /* C */
#define PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK 0x00000040u /* C */
/* These are for pcre2_jit_compile(). */
#define PCRE2_JIT_COMPLETE 0x00000001u /* For full matching */
#define PCRE2_JIT_PARTIAL_SOFT 0x00000002u
#define PCRE2_JIT_PARTIAL_HARD 0x00000004u
#define PCRE2_JIT_INVALID_UTF 0x00000100u
/* These are for pcre2_match(), pcre2_dfa_match(), pcre2_jit_match(), and
pcre2_substitute(). Some are allowed only for one of the functions, and in
these cases it is noted below. Note that PCRE2_ANCHORED, PCRE2_ENDANCHORED and
PCRE2_NO_UTF_CHECK can also be passed to these functions (though
pcre2_jit_match() ignores the latter since it bypasses all sanity checks). */
#define PCRE2_NOTBOL 0x00000001u
#define PCRE2_NOTEOL 0x00000002u
#define PCRE2_NOTEMPTY 0x00000004u /* ) These two must be kept */
#define PCRE2_NOTEMPTY_ATSTART 0x00000008u /* ) adjacent to each other. */
#define PCRE2_PARTIAL_SOFT 0x00000010u
#define PCRE2_PARTIAL_HARD 0x00000020u
#define PCRE2_DFA_RESTART 0x00000040u /* pcre2_dfa_match() only */
#define PCRE2_DFA_SHORTEST 0x00000080u /* pcre2_dfa_match() only */
#define PCRE2_SUBSTITUTE_GLOBAL 0x00000100u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_EXTENDED 0x00000200u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_UNSET_EMPTY 0x00000400u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_UNKNOWN_UNSET 0x00000800u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_OVERFLOW_LENGTH 0x00001000u /* pcre2_substitute() only */
#define PCRE2_NO_JIT 0x00002000u /* Not for pcre2_dfa_match() */
#define PCRE2_COPY_MATCHED_SUBJECT 0x00004000u
#define PCRE2_SUBSTITUTE_LITERAL 0x00008000u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_MATCHED 0x00010000u /* pcre2_substitute() only */
#define PCRE2_SUBSTITUTE_REPLACEMENT_ONLY 0x00020000u /* pcre2_substitute() only */
/* Options for pcre2_pattern_convert(). */
#define PCRE2_CONVERT_UTF 0x00000001u
#define PCRE2_CONVERT_NO_UTF_CHECK 0x00000002u
#define PCRE2_CONVERT_POSIX_BASIC 0x00000004u
#define PCRE2_CONVERT_POSIX_EXTENDED 0x00000008u
#define PCRE2_CONVERT_GLOB 0x00000010u
#define PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR 0x00000030u
#define PCRE2_CONVERT_GLOB_NO_STARSTAR 0x00000050u
/* Newline and \R settings, for use in compile contexts. The newline values
must be kept in step with values set in config.h and both sets must all be
greater than zero. */
#define PCRE2_NEWLINE_CR 1
#define PCRE2_NEWLINE_LF 2
#define PCRE2_NEWLINE_CRLF 3
#define PCRE2_NEWLINE_ANY 4
#define PCRE2_NEWLINE_ANYCRLF 5
#define PCRE2_NEWLINE_NUL 6
#define PCRE2_BSR_UNICODE 1
#define PCRE2_BSR_ANYCRLF 2
/* Error codes for pcre2_compile(). Some of these are also used by
pcre2_pattern_convert(). */
#define PCRE2_ERROR_END_BACKSLASH 101
#define PCRE2_ERROR_END_BACKSLASH_C 102
#define PCRE2_ERROR_UNKNOWN_ESCAPE 103
#define PCRE2_ERROR_QUANTIFIER_OUT_OF_ORDER 104
#define PCRE2_ERROR_QUANTIFIER_TOO_BIG 105
#define PCRE2_ERROR_MISSING_SQUARE_BRACKET 106
#define PCRE2_ERROR_ESCAPE_INVALID_IN_CLASS 107
#define PCRE2_ERROR_CLASS_RANGE_ORDER 108
#define PCRE2_ERROR_QUANTIFIER_INVALID 109
#define PCRE2_ERROR_INTERNAL_UNEXPECTED_REPEAT 110
#define PCRE2_ERROR_INVALID_AFTER_PARENS_QUERY 111
#define PCRE2_ERROR_POSIX_CLASS_NOT_IN_CLASS 112
#define PCRE2_ERROR_POSIX_NO_SUPPORT_COLLATING 113
#define PCRE2_ERROR_MISSING_CLOSING_PARENTHESIS 114
#define PCRE2_ERROR_BAD_SUBPATTERN_REFERENCE 115
#define PCRE2_ERROR_NULL_PATTERN 116
#define PCRE2_ERROR_BAD_OPTIONS 117
#define PCRE2_ERROR_MISSING_COMMENT_CLOSING 118
#define PCRE2_ERROR_PARENTHESES_NEST_TOO_DEEP 119
#define PCRE2_ERROR_PATTERN_TOO_LARGE 120
#define PCRE2_ERROR_HEAP_FAILED 121
#define PCRE2_ERROR_UNMATCHED_CLOSING_PARENTHESIS 122
#define PCRE2_ERROR_INTERNAL_CODE_OVERFLOW 123
#define PCRE2_ERROR_MISSING_CONDITION_CLOSING 124
#define PCRE2_ERROR_LOOKBEHIND_NOT_FIXED_LENGTH 125
#define PCRE2_ERROR_ZERO_RELATIVE_REFERENCE 126
#define PCRE2_ERROR_TOO_MANY_CONDITION_BRANCHES 127
#define PCRE2_ERROR_CONDITION_ASSERTION_EXPECTED 128
#define PCRE2_ERROR_BAD_RELATIVE_REFERENCE 129
#define PCRE2_ERROR_UNKNOWN_POSIX_CLASS 130
#define PCRE2_ERROR_INTERNAL_STUDY_ERROR 131
#define PCRE2_ERROR_UNICODE_NOT_SUPPORTED 132
#define PCRE2_ERROR_PARENTHESES_STACK_CHECK 133
#define PCRE2_ERROR_CODE_POINT_TOO_BIG 134
#define PCRE2_ERROR_LOOKBEHIND_TOO_COMPLICATED 135
#define PCRE2_ERROR_LOOKBEHIND_INVALID_BACKSLASH_C 136
#define PCRE2_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE 137
#define PCRE2_ERROR_CALLOUT_NUMBER_TOO_BIG 138
#define PCRE2_ERROR_MISSING_CALLOUT_CLOSING 139
#define PCRE2_ERROR_ESCAPE_INVALID_IN_VERB 140
#define PCRE2_ERROR_UNRECOGNIZED_AFTER_QUERY_P 141
#define PCRE2_ERROR_MISSING_NAME_TERMINATOR 142
#define PCRE2_ERROR_DUPLICATE_SUBPATTERN_NAME 143
#define PCRE2_ERROR_INVALID_SUBPATTERN_NAME 144
#define PCRE2_ERROR_UNICODE_PROPERTIES_UNAVAILABLE 145
#define PCRE2_ERROR_MALFORMED_UNICODE_PROPERTY 146
#define PCRE2_ERROR_UNKNOWN_UNICODE_PROPERTY 147
#define PCRE2_ERROR_SUBPATTERN_NAME_TOO_LONG 148
#define PCRE2_ERROR_TOO_MANY_NAMED_SUBPATTERNS 149
#define PCRE2_ERROR_CLASS_INVALID_RANGE 150
#define PCRE2_ERROR_OCTAL_BYTE_TOO_BIG 151
#define PCRE2_ERROR_INTERNAL_OVERRAN_WORKSPACE 152
#define PCRE2_ERROR_INTERNAL_MISSING_SUBPATTERN 153
#define PCRE2_ERROR_DEFINE_TOO_MANY_BRANCHES 154
#define PCRE2_ERROR_BACKSLASH_O_MISSING_BRACE 155
#define PCRE2_ERROR_INTERNAL_UNKNOWN_NEWLINE 156
#define PCRE2_ERROR_BACKSLASH_G_SYNTAX 157
#define PCRE2_ERROR_PARENS_QUERY_R_MISSING_CLOSING 158
/* Error 159 is obsolete and should now never occur */
#define PCRE2_ERROR_VERB_ARGUMENT_NOT_ALLOWED 159
#define PCRE2_ERROR_VERB_UNKNOWN 160
#define PCRE2_ERROR_SUBPATTERN_NUMBER_TOO_BIG 161
#define PCRE2_ERROR_SUBPATTERN_NAME_EXPECTED 162
#define PCRE2_ERROR_INTERNAL_PARSED_OVERFLOW 163
#define PCRE2_ERROR_INVALID_OCTAL 164
#define PCRE2_ERROR_SUBPATTERN_NAMES_MISMATCH 165
#define PCRE2_ERROR_MARK_MISSING_ARGUMENT 166
#define PCRE2_ERROR_INVALID_HEXADECIMAL 167
#define PCRE2_ERROR_BACKSLASH_C_SYNTAX 168
#define PCRE2_ERROR_BACKSLASH_K_SYNTAX 169
#define PCRE2_ERROR_INTERNAL_BAD_CODE_LOOKBEHINDS 170
#define PCRE2_ERROR_BACKSLASH_N_IN_CLASS 171
#define PCRE2_ERROR_CALLOUT_STRING_TOO_LONG 172
#define PCRE2_ERROR_UNICODE_DISALLOWED_CODE_POINT 173
#define PCRE2_ERROR_UTF_IS_DISABLED 174
#define PCRE2_ERROR_UCP_IS_DISABLED 175
#define PCRE2_ERROR_VERB_NAME_TOO_LONG 176
#define PCRE2_ERROR_BACKSLASH_U_CODE_POINT_TOO_BIG 177
#define PCRE2_ERROR_MISSING_OCTAL_OR_HEX_DIGITS 178
#define PCRE2_ERROR_VERSION_CONDITION_SYNTAX 179
#define PCRE2_ERROR_INTERNAL_BAD_CODE_AUTO_POSSESS 180
#define PCRE2_ERROR_CALLOUT_NO_STRING_DELIMITER 181
#define PCRE2_ERROR_CALLOUT_BAD_STRING_DELIMITER 182
#define PCRE2_ERROR_BACKSLASH_C_CALLER_DISABLED 183
#define PCRE2_ERROR_QUERY_BARJX_NEST_TOO_DEEP 184
#define PCRE2_ERROR_BACKSLASH_C_LIBRARY_DISABLED 185
#define PCRE2_ERROR_PATTERN_TOO_COMPLICATED 186
#define PCRE2_ERROR_LOOKBEHIND_TOO_LONG 187
#define PCRE2_ERROR_PATTERN_STRING_TOO_LONG 188
#define PCRE2_ERROR_INTERNAL_BAD_CODE 189
#define PCRE2_ERROR_INTERNAL_BAD_CODE_IN_SKIP 190
#define PCRE2_ERROR_NO_SURROGATES_IN_UTF16 191
#define PCRE2_ERROR_BAD_LITERAL_OPTIONS 192
#define PCRE2_ERROR_SUPPORTED_ONLY_IN_UNICODE 193
#define PCRE2_ERROR_INVALID_HYPHEN_IN_OPTIONS 194
#define PCRE2_ERROR_ALPHA_ASSERTION_UNKNOWN 195
#define PCRE2_ERROR_SCRIPT_RUN_NOT_AVAILABLE 196
#define PCRE2_ERROR_TOO_MANY_CAPTURES 197
#define PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED 198
#define PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND 199
/* "Expected" matching error codes: no match and partial match. */
#define PCRE2_ERROR_NOMATCH (-1)
#define PCRE2_ERROR_PARTIAL (-2)
/* Error codes for UTF-8 validity checks */
#define PCRE2_ERROR_UTF8_ERR1 (-3)
#define PCRE2_ERROR_UTF8_ERR2 (-4)
#define PCRE2_ERROR_UTF8_ERR3 (-5)
#define PCRE2_ERROR_UTF8_ERR4 (-6)
#define PCRE2_ERROR_UTF8_ERR5 (-7)
#define PCRE2_ERROR_UTF8_ERR6 (-8)
#define PCRE2_ERROR_UTF8_ERR7 (-9)
#define PCRE2_ERROR_UTF8_ERR8 (-10)
#define PCRE2_ERROR_UTF8_ERR9 (-11)
#define PCRE2_ERROR_UTF8_ERR10 (-12)
#define PCRE2_ERROR_UTF8_ERR11 (-13)
#define PCRE2_ERROR_UTF8_ERR12 (-14)
#define PCRE2_ERROR_UTF8_ERR13 (-15)
#define PCRE2_ERROR_UTF8_ERR14 (-16)
#define PCRE2_ERROR_UTF8_ERR15 (-17)
#define PCRE2_ERROR_UTF8_ERR16 (-18)
#define PCRE2_ERROR_UTF8_ERR17 (-19)
#define PCRE2_ERROR_UTF8_ERR18 (-20)
#define PCRE2_ERROR_UTF8_ERR19 (-21)
#define PCRE2_ERROR_UTF8_ERR20 (-22)
#define PCRE2_ERROR_UTF8_ERR21 (-23)
/* Error codes for UTF-16 validity checks */
#define PCRE2_ERROR_UTF16_ERR1 (-24)
#define PCRE2_ERROR_UTF16_ERR2 (-25)
#define PCRE2_ERROR_UTF16_ERR3 (-26)
/* Error codes for UTF-32 validity checks */
#define PCRE2_ERROR_UTF32_ERR1 (-27)
#define PCRE2_ERROR_UTF32_ERR2 (-28)
/* Miscellaneous error codes for pcre2[_dfa]_match(), substring extraction
functions, context functions, and serializing functions. They are in numerical
order. Originally they were in alphabetical order too, but now that PCRE2 is
released, the numbers must not be changed. */
#define PCRE2_ERROR_BADDATA (-29)
#define PCRE2_ERROR_MIXEDTABLES (-30) /* Name was changed */
#define PCRE2_ERROR_BADMAGIC (-31)
#define PCRE2_ERROR_BADMODE (-32)
#define PCRE2_ERROR_BADOFFSET (-33)
#define PCRE2_ERROR_BADOPTION (-34)
#define PCRE2_ERROR_BADREPLACEMENT (-35)
#define PCRE2_ERROR_BADUTFOFFSET (-36)
#define PCRE2_ERROR_CALLOUT (-37) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_DFA_BADRESTART (-38)
#define PCRE2_ERROR_DFA_RECURSE (-39)
#define PCRE2_ERROR_DFA_UCOND (-40)
#define PCRE2_ERROR_DFA_UFUNC (-41)
#define PCRE2_ERROR_DFA_UITEM (-42)
#define PCRE2_ERROR_DFA_WSSIZE (-43)
#define PCRE2_ERROR_INTERNAL (-44)
#define PCRE2_ERROR_JIT_BADOPTION (-45)
#define PCRE2_ERROR_JIT_STACKLIMIT (-46)
#define PCRE2_ERROR_MATCHLIMIT (-47)
#define PCRE2_ERROR_NOMEMORY (-48)
#define PCRE2_ERROR_NOSUBSTRING (-49)
#define PCRE2_ERROR_NOUNIQUESUBSTRING (-50)
#define PCRE2_ERROR_NULL (-51)
#define PCRE2_ERROR_RECURSELOOP (-52)
#define PCRE2_ERROR_DEPTHLIMIT (-53)
#define PCRE2_ERROR_RECURSIONLIMIT (-53) /* Obsolete synonym */
#define PCRE2_ERROR_UNAVAILABLE (-54)
#define PCRE2_ERROR_UNSET (-55)
#define PCRE2_ERROR_BADOFFSETLIMIT (-56)
#define PCRE2_ERROR_BADREPESCAPE (-57)
#define PCRE2_ERROR_REPMISSINGBRACE (-58)
#define PCRE2_ERROR_BADSUBSTITUTION (-59)
#define PCRE2_ERROR_BADSUBSPATTERN (-60)
#define PCRE2_ERROR_TOOMANYREPLACE (-61)
#define PCRE2_ERROR_BADSERIALIZEDDATA (-62)
#define PCRE2_ERROR_HEAPLIMIT (-63)
#define PCRE2_ERROR_CONVERT_SYNTAX (-64)
#define PCRE2_ERROR_INTERNAL_DUPMATCH (-65)
#define PCRE2_ERROR_DFA_UINVALID_UTF (-66)
/* Request types for pcre2_pattern_info() */
#define PCRE2_INFO_ALLOPTIONS 0
#define PCRE2_INFO_ARGOPTIONS 1
#define PCRE2_INFO_BACKREFMAX 2
#define PCRE2_INFO_BSR 3
#define PCRE2_INFO_CAPTURECOUNT 4
#define PCRE2_INFO_FIRSTCODEUNIT 5
#define PCRE2_INFO_FIRSTCODETYPE 6
#define PCRE2_INFO_FIRSTBITMAP 7
#define PCRE2_INFO_HASCRORLF 8
#define PCRE2_INFO_JCHANGED 9
#define PCRE2_INFO_JITSIZE 10
#define PCRE2_INFO_LASTCODEUNIT 11
#define PCRE2_INFO_LASTCODETYPE 12
#define PCRE2_INFO_MATCHEMPTY 13
#define PCRE2_INFO_MATCHLIMIT 14
#define PCRE2_INFO_MAXLOOKBEHIND 15
#define PCRE2_INFO_MINLENGTH 16
#define PCRE2_INFO_NAMECOUNT 17
#define PCRE2_INFO_NAMEENTRYSIZE 18
#define PCRE2_INFO_NAMETABLE 19
#define PCRE2_INFO_NEWLINE 20
#define PCRE2_INFO_DEPTHLIMIT 21
#define PCRE2_INFO_RECURSIONLIMIT 21 /* Obsolete synonym */
#define PCRE2_INFO_SIZE 22
#define PCRE2_INFO_HASBACKSLASHC 23
#define PCRE2_INFO_FRAMESIZE 24
#define PCRE2_INFO_HEAPLIMIT 25
#define PCRE2_INFO_EXTRAOPTIONS 26
/* Request types for pcre2_config(). */
#define PCRE2_CONFIG_BSR 0
#define PCRE2_CONFIG_JIT 1
#define PCRE2_CONFIG_JITTARGET 2
#define PCRE2_CONFIG_LINKSIZE 3
#define PCRE2_CONFIG_MATCHLIMIT 4
#define PCRE2_CONFIG_NEWLINE 5
#define PCRE2_CONFIG_PARENSLIMIT 6
#define PCRE2_CONFIG_DEPTHLIMIT 7
#define PCRE2_CONFIG_RECURSIONLIMIT 7 /* Obsolete synonym */
#define PCRE2_CONFIG_STACKRECURSE 8 /* Obsolete */
#define PCRE2_CONFIG_UNICODE 9
#define PCRE2_CONFIG_UNICODE_VERSION 10
#define PCRE2_CONFIG_VERSION 11
#define PCRE2_CONFIG_HEAPLIMIT 12
#define PCRE2_CONFIG_NEVER_BACKSLASH_C 13
#define PCRE2_CONFIG_COMPILED_WIDTHS 14
#define PCRE2_CONFIG_TABLES_LENGTH 15
/* Types for code units in patterns and subject strings. */
typedef uint8_t PCRE2_UCHAR8;
typedef uint16_t PCRE2_UCHAR16;
typedef uint32_t PCRE2_UCHAR32;
typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE2,
including pattern offsets for errors and subject offsets after a match. We
define special values to indicate zero-terminated strings and unset offsets in
the offset vector (ovector). */
#define PCRE2_SIZE size_t
#define PCRE2_SIZE_MAX SIZE_MAX
#define PCRE2_ZERO_TERMINATED (~(PCRE2_SIZE)0)
#define PCRE2_UNSET (~(PCRE2_SIZE)0)
/* Generic types for opaque structures and JIT callback functions. These
declarations are defined in a macro that is expanded for each width later. */
#define PCRE2_TYPES_LIST \
struct pcre2_real_general_context; \
typedef struct pcre2_real_general_context pcre2_general_context; \
\
struct pcre2_real_compile_context; \
typedef struct pcre2_real_compile_context pcre2_compile_context; \
\
struct pcre2_real_match_context; \
typedef struct pcre2_real_match_context pcre2_match_context; \
\
struct pcre2_real_convert_context; \
typedef struct pcre2_real_convert_context pcre2_convert_context; \
\
struct pcre2_real_code; \
typedef struct pcre2_real_code pcre2_code; \
\
struct pcre2_real_match_data; \
typedef struct pcre2_real_match_data pcre2_match_data; \
\
struct pcre2_real_jit_stack; \
typedef struct pcre2_real_jit_stack pcre2_jit_stack; \
\
typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *);
/* The structures for passing out data via callout functions. We use structures
so that new fields can be added on the end in future versions, without changing
the API of the function, thereby allowing old clients to work without
modification. Define the generic versions in a macro; the width-specific
versions are generated from this macro below. */
/* Flags for the callout_flags field. These are cleared after a callout. */
#define PCRE2_CALLOUT_STARTMATCH 0x00000001u /* Set for each bumpalong */
#define PCRE2_CALLOUT_BACKTRACK 0x00000002u /* Set after a backtrack */
#define PCRE2_STRUCTURE_LIST \
typedef struct pcre2_callout_block { \
uint32_t version; /* Identifies version of block */ \
/* ------------------------ Version 0 ------------------------------- */ \
uint32_t callout_number; /* Number compiled into pattern */ \
uint32_t capture_top; /* Max current capture */ \
uint32_t capture_last; /* Most recently closed capture */ \
PCRE2_SIZE *offset_vector; /* The offset vector */ \
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
PCRE2_SPTR subject; /* The subject being matched */ \
PCRE2_SIZE subject_length; /* The length of the subject */ \
PCRE2_SIZE start_match; /* Offset to start of this match attempt */ \
PCRE2_SIZE current_position; /* Where we currently are in the subject */ \
PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \
PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \
/* ------------------- Added for Version 1 -------------------------- */ \
PCRE2_SIZE callout_string_offset; /* Offset to string within pattern */ \
PCRE2_SIZE callout_string_length; /* Length of string compiled into pattern */ \
PCRE2_SPTR callout_string; /* String compiled into pattern */ \
/* ------------------- Added for Version 2 -------------------------- */ \
uint32_t callout_flags; /* See above for list */ \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_block; \
\
typedef struct pcre2_callout_enumerate_block { \
uint32_t version; /* Identifies version of block */ \
/* ------------------------ Version 0 ------------------------------- */ \
PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \
PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \
uint32_t callout_number; /* Number compiled into pattern */ \
PCRE2_SIZE callout_string_offset; /* Offset to string within pattern */ \
PCRE2_SIZE callout_string_length; /* Length of string compiled into pattern */ \
PCRE2_SPTR callout_string; /* String compiled into pattern */ \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_enumerate_block; \
\
typedef struct pcre2_substitute_callout_block { \
uint32_t version; /* Identifies version of block */ \
/* ------------------------ Version 0 ------------------------------- */ \
PCRE2_SPTR input; /* Pointer to input subject string */ \
PCRE2_SPTR output; /* Pointer to output buffer */ \
PCRE2_SIZE output_offsets[2]; /* Changed portion of the output */ \
PCRE2_SIZE *ovector; /* Pointer to current ovector */ \
uint32_t oveccount; /* Count of pairs set in ovector */ \
uint32_t subscount; /* Substitution number */ \
/* ------------------------------------------------------------------ */ \
} pcre2_substitute_callout_block;
/* List the generic forms of all other functions in macros, which will be
expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_config(uint32_t, void *);
/* Functions for manipulating contexts. */
#define PCRE2_GENERAL_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL pcre2_general_context PCRE2_CALL_CONVENTION \
*pcre2_general_context_copy(pcre2_general_context *); \
PCRE2_EXP_DECL pcre2_general_context PCRE2_CALL_CONVENTION \
*pcre2_general_context_create(void *(*)(PCRE2_SIZE, void *), \
void (*)(void *, void *), void *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_general_context_free(pcre2_general_context *);
#define PCRE2_COMPILE_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL pcre2_compile_context PCRE2_CALL_CONVENTION \
*pcre2_compile_context_copy(pcre2_compile_context *); \
PCRE2_EXP_DECL pcre2_compile_context PCRE2_CALL_CONVENTION \
*pcre2_compile_context_create(pcre2_general_context *);\
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_compile_context_free(pcre2_compile_context *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_bsr(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_character_tables(pcre2_compile_context *, const uint8_t *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_compile_extra_options(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_max_pattern_length(pcre2_compile_context *, PCRE2_SIZE); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_newline(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_parens_nest_limit(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_compile_recursion_guard(pcre2_compile_context *, \
int (*)(uint32_t, void *), void *);
#define PCRE2_MATCH_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL pcre2_match_context PCRE2_CALL_CONVENTION \
*pcre2_match_context_copy(pcre2_match_context *); \
PCRE2_EXP_DECL pcre2_match_context PCRE2_CALL_CONVENTION \
*pcre2_match_context_create(pcre2_general_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_match_context_free(pcre2_match_context *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_callout(pcre2_match_context *, \
int (*)(pcre2_callout_block *, void *), void *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_substitute_callout(pcre2_match_context *, \
int (*)(pcre2_substitute_callout_block *, void *), void *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_depth_limit(pcre2_match_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_heap_limit(pcre2_match_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_match_limit(pcre2_match_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_offset_limit(pcre2_match_context *, PCRE2_SIZE); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_recursion_limit(pcre2_match_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_recursion_memory_management(pcre2_match_context *, \
void *(*)(PCRE2_SIZE, void *), void (*)(void *, void *), void *);
#define PCRE2_CONVERT_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL pcre2_convert_context PCRE2_CALL_CONVENTION \
*pcre2_convert_context_copy(pcre2_convert_context *); \
PCRE2_EXP_DECL pcre2_convert_context PCRE2_CALL_CONVENTION \
*pcre2_convert_context_create(pcre2_general_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_convert_context_free(pcre2_convert_context *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_glob_escape(pcre2_convert_context *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_set_glob_separator(pcre2_convert_context *, uint32_t);
/* Functions concerned with compiling a pattern to PCRE internal code. */
#define PCRE2_COMPILE_FUNCTIONS \
PCRE2_EXP_DECL pcre2_code PCRE2_CALL_CONVENTION \
*pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, \
pcre2_compile_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_code_free(pcre2_code *); \
PCRE2_EXP_DECL pcre2_code PCRE2_CALL_CONVENTION \
*pcre2_code_copy(const pcre2_code *); \
PCRE2_EXP_DECL pcre2_code PCRE2_CALL_CONVENTION \
*pcre2_code_copy_with_tables(const pcre2_code *);
/* Functions that give information about a compiled pattern. */
#define PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_pattern_info(const pcre2_code *, uint32_t, void *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_callout_enumerate(const pcre2_code *, \
int (*)(pcre2_callout_enumerate_block *, void *), void *);
/* Functions for running a match and inspecting the result. */
#define PCRE2_MATCH_FUNCTIONS \
PCRE2_EXP_DECL pcre2_match_data PCRE2_CALL_CONVENTION \
*pcre2_match_data_create(uint32_t, pcre2_general_context *); \
PCRE2_EXP_DECL pcre2_match_data PCRE2_CALL_CONVENTION \
*pcre2_match_data_create_from_pattern(const pcre2_code *, \
pcre2_general_context *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_dfa_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
uint32_t, pcre2_match_data *, pcre2_match_context *, int *, PCRE2_SIZE); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
uint32_t, pcre2_match_data *, pcre2_match_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_match_data_free(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SPTR PCRE2_CALL_CONVENTION \
pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \
pcre2_get_match_data_size(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t PCRE2_CALL_CONVENTION \
pcre2_get_ovector_count(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \
*pcre2_get_ovector_pointer(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \
pcre2_get_startchar(pcre2_match_data *);
/* Convenience functions for handling matched substrings. */
#define PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_copy_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR *, \
PCRE2_SIZE *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_copy_bynumber(pcre2_match_data *, uint32_t, PCRE2_UCHAR *, \
PCRE2_SIZE *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_substring_free(PCRE2_UCHAR *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_get_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **, \
PCRE2_SIZE *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_get_bynumber(pcre2_match_data *, uint32_t, PCRE2_UCHAR **, \
PCRE2_SIZE *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_length_byname(pcre2_match_data *, PCRE2_SPTR, PCRE2_SIZE *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_length_bynumber(pcre2_match_data *, uint32_t, PCRE2_SIZE *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_nametable_scan(const pcre2_code *, PCRE2_SPTR, PCRE2_SPTR *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_number_from_name(const pcre2_code *, PCRE2_SPTR); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_substring_list_free(PCRE2_SPTR *); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substring_list_get(pcre2_match_data *, PCRE2_UCHAR ***, PCRE2_SIZE **);
/* Functions for serializing / deserializing compiled patterns. */
#define PCRE2_SERIALIZE_FUNCTIONS \
PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \
pcre2_serialize_encode(const pcre2_code **, int32_t, uint8_t **, \
PCRE2_SIZE *, pcre2_general_context *); \
PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \
pcre2_serialize_decode(pcre2_code **, int32_t, const uint8_t *, \
pcre2_general_context *); \
PCRE2_EXP_DECL int32_t PCRE2_CALL_CONVENTION \
pcre2_serialize_get_number_of_codes(const uint8_t *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_serialize_free(uint8_t *);
/* Convenience function for match + substitute. */
#define PCRE2_SUBSTITUTE_FUNCTION \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_substitute(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
uint32_t, pcre2_match_data *, pcre2_match_context *, PCRE2_SPTR, \
PCRE2_SIZE, PCRE2_UCHAR *, PCRE2_SIZE *);
/* Functions for converting pattern source strings. */
#define PCRE2_CONVERT_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_pattern_convert(PCRE2_SPTR, PCRE2_SIZE, uint32_t, PCRE2_UCHAR **, \
PCRE2_SIZE *, pcre2_convert_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_converted_pattern_free(PCRE2_UCHAR *);
/* Functions for JIT processing */
#define PCRE2_JIT_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_jit_compile(pcre2_code *, uint32_t); \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_jit_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
uint32_t, pcre2_match_data *, pcre2_match_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_jit_free_unused_memory(pcre2_general_context *); \
PCRE2_EXP_DECL pcre2_jit_stack PCRE2_CALL_CONVENTION \
*pcre2_jit_stack_create(PCRE2_SIZE, PCRE2_SIZE, pcre2_general_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_jit_stack_assign(pcre2_match_context *, pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_jit_stack_free(pcre2_jit_stack *);
/* Other miscellaneous functions. */
#define PCRE2_OTHER_FUNCTIONS \
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \
PCRE2_EXP_DECL const uint8_t PCRE2_CALL_CONVENTION \
*pcre2_maketables(pcre2_general_context *); \
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
pcre2_maketables_free(pcre2_general_context *, const uint8_t *);
/* Define macros that generate width-specific names from generic versions. The
three-level macro scheme is necessary to get the macros expanded when we want
them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for
generating three versions of everything below. After that, PCRE2_SUFFIX will be
re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as
pcre2_compile are called by application code. */
#define PCRE2_JOIN(a,b) a ## b
#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
/* Data types */
#define PCRE2_UCHAR PCRE2_SUFFIX(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_SUFFIX(PCRE2_SPTR)
#define pcre2_code PCRE2_SUFFIX(pcre2_code_)
#define pcre2_jit_callback PCRE2_SUFFIX(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_SUFFIX(pcre2_jit_stack_)
#define pcre2_real_code PCRE2_SUFFIX(pcre2_real_code_)
#define pcre2_real_general_context PCRE2_SUFFIX(pcre2_real_general_context_)
#define pcre2_real_compile_context PCRE2_SUFFIX(pcre2_real_compile_context_)
#define pcre2_real_convert_context PCRE2_SUFFIX(pcre2_real_convert_context_)
#define pcre2_real_match_context PCRE2_SUFFIX(pcre2_real_match_context_)
#define pcre2_real_jit_stack PCRE2_SUFFIX(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_SUFFIX(pcre2_real_match_data_)
/* Data blocks */
#define pcre2_callout_block PCRE2_SUFFIX(pcre2_callout_block_)
#define pcre2_callout_enumerate_block PCRE2_SUFFIX(pcre2_callout_enumerate_block_)
#define pcre2_substitute_callout_block PCRE2_SUFFIX(pcre2_substitute_callout_block_)
#define pcre2_general_context PCRE2_SUFFIX(pcre2_general_context_)
#define pcre2_compile_context PCRE2_SUFFIX(pcre2_compile_context_)
#define pcre2_convert_context PCRE2_SUFFIX(pcre2_convert_context_)
#define pcre2_match_context PCRE2_SUFFIX(pcre2_match_context_)
#define pcre2_match_data PCRE2_SUFFIX(pcre2_match_data_)
/* Functions: the complete list in alphabetical order */
#define pcre2_callout_enumerate PCRE2_SUFFIX(pcre2_callout_enumerate_)
#define pcre2_code_copy PCRE2_SUFFIX(pcre2_code_copy_)
#define pcre2_code_copy_with_tables PCRE2_SUFFIX(pcre2_code_copy_with_tables_)
#define pcre2_code_free PCRE2_SUFFIX(pcre2_code_free_)
#define pcre2_compile PCRE2_SUFFIX(pcre2_compile_)
#define pcre2_compile_context_copy PCRE2_SUFFIX(pcre2_compile_context_copy_)
#define pcre2_compile_context_create PCRE2_SUFFIX(pcre2_compile_context_create_)
#define pcre2_compile_context_free PCRE2_SUFFIX(pcre2_compile_context_free_)
#define pcre2_config PCRE2_SUFFIX(pcre2_config_)
#define pcre2_convert_context_copy PCRE2_SUFFIX(pcre2_convert_context_copy_)
#define pcre2_convert_context_create PCRE2_SUFFIX(pcre2_convert_context_create_)
#define pcre2_convert_context_free PCRE2_SUFFIX(pcre2_convert_context_free_)
#define pcre2_converted_pattern_free PCRE2_SUFFIX(pcre2_converted_pattern_free_)
#define pcre2_dfa_match PCRE2_SUFFIX(pcre2_dfa_match_)
#define pcre2_general_context_copy PCRE2_SUFFIX(pcre2_general_context_copy_)
#define pcre2_general_context_create PCRE2_SUFFIX(pcre2_general_context_create_)
#define pcre2_general_context_free PCRE2_SUFFIX(pcre2_general_context_free_)
#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_)
#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_)
#define pcre2_get_match_data_size PCRE2_SUFFIX(pcre2_get_match_data_size_)
#define pcre2_get_ovector_pointer PCRE2_SUFFIX(pcre2_get_ovector_pointer_)
#define pcre2_get_ovector_count PCRE2_SUFFIX(pcre2_get_ovector_count_)
#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_)
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_match PCRE2_SUFFIX(pcre2_jit_match_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_create PCRE2_SUFFIX(pcre2_jit_stack_create_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_maketables_free PCRE2_SUFFIX(pcre2_maketables_free_)
#define pcre2_match PCRE2_SUFFIX(pcre2_match_)
#define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_)
#define pcre2_match_context_create PCRE2_SUFFIX(pcre2_match_context_create_)
#define pcre2_match_context_free PCRE2_SUFFIX(pcre2_match_context_free_)
#define pcre2_match_data_create PCRE2_SUFFIX(pcre2_match_data_create_)
#define pcre2_match_data_create_from_pattern PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_)
#define pcre2_match_data_free PCRE2_SUFFIX(pcre2_match_data_free_)
#define pcre2_pattern_convert PCRE2_SUFFIX(pcre2_pattern_convert_)
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
#define pcre2_serialize_decode PCRE2_SUFFIX(pcre2_serialize_decode_)
#define pcre2_serialize_encode PCRE2_SUFFIX(pcre2_serialize_encode_)
#define pcre2_serialize_free PCRE2_SUFFIX(pcre2_serialize_free_)
#define pcre2_serialize_get_number_of_codes PCRE2_SUFFIX(pcre2_serialize_get_number_of_codes_)
#define pcre2_set_bsr PCRE2_SUFFIX(pcre2_set_bsr_)
#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_)
#define pcre2_set_compile_extra_options PCRE2_SUFFIX(pcre2_set_compile_extra_options_)
#define pcre2_set_compile_recursion_guard PCRE2_SUFFIX(pcre2_set_compile_recursion_guard_)
#define pcre2_set_depth_limit PCRE2_SUFFIX(pcre2_set_depth_limit_)
#define pcre2_set_glob_escape PCRE2_SUFFIX(pcre2_set_glob_escape_)
#define pcre2_set_glob_separator PCRE2_SUFFIX(pcre2_set_glob_separator_)
#define pcre2_set_heap_limit PCRE2_SUFFIX(pcre2_set_heap_limit_)
#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_)
#define pcre2_set_max_pattern_length PCRE2_SUFFIX(pcre2_set_max_pattern_length_)
#define pcre2_set_newline PCRE2_SUFFIX(pcre2_set_newline_)
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
#define pcre2_set_offset_limit PCRE2_SUFFIX(pcre2_set_offset_limit_)
#define pcre2_set_substitute_callout PCRE2_SUFFIX(pcre2_set_substitute_callout_)
#define pcre2_substitute PCRE2_SUFFIX(pcre2_substitute_)
#define pcre2_substring_copy_byname PCRE2_SUFFIX(pcre2_substring_copy_byname_)
#define pcre2_substring_copy_bynumber PCRE2_SUFFIX(pcre2_substring_copy_bynumber_)
#define pcre2_substring_free PCRE2_SUFFIX(pcre2_substring_free_)
#define pcre2_substring_get_byname PCRE2_SUFFIX(pcre2_substring_get_byname_)
#define pcre2_substring_get_bynumber PCRE2_SUFFIX(pcre2_substring_get_bynumber_)
#define pcre2_substring_length_byname PCRE2_SUFFIX(pcre2_substring_length_byname_)
#define pcre2_substring_length_bynumber PCRE2_SUFFIX(pcre2_substring_length_bynumber_)
#define pcre2_substring_list_get PCRE2_SUFFIX(pcre2_substring_list_get_)
#define pcre2_substring_list_free PCRE2_SUFFIX(pcre2_substring_list_free_)
#define pcre2_substring_nametable_scan PCRE2_SUFFIX(pcre2_substring_nametable_scan_)
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
/* Keep this old function name for backwards compatibility */
#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
/* Keep this obsolete function for backwards compatibility: it is now a noop. */
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
/* Now generate all three sets of width-specific structures and function
prototypes. */
#define PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS \
PCRE2_TYPES_LIST \
PCRE2_STRUCTURE_LIST \
PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_GENERAL_CONTEXT_FUNCTIONS \
PCRE2_COMPILE_CONTEXT_FUNCTIONS \
PCRE2_CONVERT_CONTEXT_FUNCTIONS \
PCRE2_CONVERT_FUNCTIONS \
PCRE2_MATCH_CONTEXT_FUNCTIONS \
PCRE2_COMPILE_FUNCTIONS \
PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_MATCH_FUNCTIONS \
PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_SERIALIZE_FUNCTIONS \
PCRE2_SUBSTITUTE_FUNCTION \
PCRE2_JIT_FUNCTIONS \
PCRE2_OTHER_FUNCTIONS
#define PCRE2_LOCAL_WIDTH 8
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 16
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 32
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
/* Undefine the list macros; they are no longer needed. */
#undef PCRE2_TYPES_LIST
#undef PCRE2_STRUCTURE_LIST
#undef PCRE2_GENERAL_INFO_FUNCTIONS
#undef PCRE2_GENERAL_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_CONTEXT_FUNCTIONS
#undef PCRE2_CONVERT_CONTEXT_FUNCTIONS
#undef PCRE2_MATCH_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_FUNCTIONS
#undef PCRE2_PATTERN_INFO_FUNCTIONS
#undef PCRE2_MATCH_FUNCTIONS
#undef PCRE2_SUBSTRING_FUNCTIONS
#undef PCRE2_SERIALIZE_FUNCTIONS
#undef PCRE2_SUBSTITUTE_FUNCTION
#undef PCRE2_JIT_FUNCTIONS
#undef PCRE2_OTHER_FUNCTIONS
#undef PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
/* PCRE2_CODE_UNIT_WIDTH must be defined. If it is 8, 16, or 32, redefine
PCRE2_SUFFIX to use it. If it is 0, undefine the other macros and make
PCRE2_SUFFIX a no-op. Otherwise, generate an error. */
#undef PCRE2_SUFFIX
#ifndef PCRE2_CODE_UNIT_WIDTH
#error PCRE2_CODE_UNIT_WIDTH must be defined before including pcre2.h.
#error Use 8, 16, or 32; or 0 for a multi-width application.
#else /* PCRE2_CODE_UNIT_WIDTH is defined */
#if PCRE2_CODE_UNIT_WIDTH == 8 || \
PCRE2_CODE_UNIT_WIDTH == 16 || \
PCRE2_CODE_UNIT_WIDTH == 32
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
#elif PCRE2_CODE_UNIT_WIDTH == 0
#undef PCRE2_JOIN
#undef PCRE2_GLUE
#define PCRE2_SUFFIX(a) a
#else
#error PCRE2_CODE_UNIT_WIDTH must be 0, 8, 16, or 32.
#endif
#endif /* PCRE2_CODE_UNIT_WIDTH is defined */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PCRE2_H_IDEMPOTENT_GUARD */
/* End of pcre2.h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,934 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2022 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains mode-dependent macro and structure definitions. The
file is #included by pcre2_internal.h if PCRE2_CODE_UNIT_WIDTH is defined.
These mode-dependent items are kept in a separate file so that they can also be
#included multiple times for different code unit widths by pcre2test in order
to have access to the hidden structures at all supported widths.
Some of the mode-dependent macros are required at different widths for
different parts of the pcre2test code (in particular, the included
pcre_printint.c file). We undefine them here so that they can be re-defined for
multiple inclusions. Not all of these are used in pcre2test, but it's easier
just to undefine them all. */
#undef ACROSSCHAR
#undef BACKCHAR
#undef BYTES2CU
#undef CHMAX_255
#undef CU2BYTES
#undef FORWARDCHAR
#undef FORWARDCHARTEST
#undef GET
#undef GET2
#undef GETCHAR
#undef GETCHARINC
#undef GETCHARINCTEST
#undef GETCHARLEN
#undef GETCHARLENTEST
#undef GETCHARTEST
#undef GET_EXTRALEN
#undef HAS_EXTRALEN
#undef IMM2_SIZE
#undef MAX_255
#undef MAX_MARK
#undef MAX_PATTERN_SIZE
#undef MAX_UTF_SINGLE_CU
#undef NOT_FIRSTCU
#undef PUT
#undef PUT2
#undef PUT2INC
#undef PUTCHAR
#undef PUTINC
#undef TABLE_GET
/* -------------------------- MACROS ----------------------------- */
/* PCRE keeps offsets in its compiled code as at least 16-bit quantities
(always stored in big-endian order in 8-bit mode) by default. These are used,
for example, to link from the start of a subpattern to its alternatives and its
end. The use of 16 bits per offset limits the size of an 8-bit compiled regex
to around 64K, which is big enough for almost everybody. However, I received a
request for an even bigger limit. For this reason, and also to make the code
easier to maintain, the storing and loading of offsets from the compiled code
unit string is now handled by the macros that are defined here.
The macros are controlled by the value of LINK_SIZE. This defaults to 2, but
values of 3 or 4 are also supported. */
/* ------------------- 8-bit support ------------------ */
#if PCRE2_CODE_UNIT_WIDTH == 8
#if LINK_SIZE == 2
#define PUT(a,n,d) \
(a[n] = (PCRE2_UCHAR)((d) >> 8)), \
(a[(n)+1] = (PCRE2_UCHAR)((d) & 255))
#define GET(a,n) \
(unsigned int)(((a)[n] << 8) | (a)[(n)+1])
#define MAX_PATTERN_SIZE (1 << 16)
#elif LINK_SIZE == 3
#define PUT(a,n,d) \
(a[n] = (PCRE2_UCHAR)((d) >> 16)), \
(a[(n)+1] = (PCRE2_UCHAR)((d) >> 8)), \
(a[(n)+2] = (PCRE2_UCHAR)((d) & 255))
#define GET(a,n) \
(unsigned int)(((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
#define MAX_PATTERN_SIZE (1 << 24)
#elif LINK_SIZE == 4
#define PUT(a,n,d) \
(a[n] = (PCRE2_UCHAR)((d) >> 24)), \
(a[(n)+1] = (PCRE2_UCHAR)((d) >> 16)), \
(a[(n)+2] = (PCRE2_UCHAR)((d) >> 8)), \
(a[(n)+3] = (PCRE2_UCHAR)((d) & 255))
#define GET(a,n) \
(unsigned int)(((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
#else
#error LINK_SIZE must be 2, 3, or 4
#endif
/* ------------------- 16-bit support ------------------ */
#elif PCRE2_CODE_UNIT_WIDTH == 16
#if LINK_SIZE == 2
#undef LINK_SIZE
#define LINK_SIZE 1
#define PUT(a,n,d) \
(a[n] = (PCRE2_UCHAR)(d))
#define GET(a,n) \
(a[n])
#define MAX_PATTERN_SIZE (1 << 16)
#elif LINK_SIZE == 3 || LINK_SIZE == 4
#undef LINK_SIZE
#define LINK_SIZE 2
#define PUT(a,n,d) \
(a[n] = (PCRE2_UCHAR)((d) >> 16)), \
(a[(n)+1] = (PCRE2_UCHAR)((d) & 65535))
#define GET(a,n) \
(unsigned int)(((a)[n] << 16) | (a)[(n)+1])
#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
#else
#error LINK_SIZE must be 2, 3, or 4
#endif
/* ------------------- 32-bit support ------------------ */
#elif PCRE2_CODE_UNIT_WIDTH == 32
#undef LINK_SIZE
#define LINK_SIZE 1
#define PUT(a,n,d) \
(a[n] = (d))
#define GET(a,n) \
(a[n])
#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
#else
#error Unsupported compiling mode
#endif
/* --------------- Other mode-specific macros ----------------- */
/* PCRE uses some other (at least) 16-bit quantities that do not change when
the size of offsets changes. There are used for repeat counts and for other
things such as capturing parenthesis numbers in back references.
Define the number of code units required to hold a 16-bit count/offset, and
macros to load and store such a value. For reasons that I do not understand,
the expression in the 8-bit GET2 macro is treated by gcc as a signed
expression, even when a is declared as unsigned. It seems that any kind of
arithmetic results in a signed value. Hence the cast. */
#if PCRE2_CODE_UNIT_WIDTH == 8
#define IMM2_SIZE 2
#define GET2(a,n) (unsigned int)(((a)[n] << 8) | (a)[(n)+1])
#define PUT2(a,n,d) a[n] = (d) >> 8, a[(n)+1] = (d) & 255
#else /* Code units are 16 or 32 bits */
#define IMM2_SIZE 1
#define GET2(a,n) a[n]
#define PUT2(a,n,d) a[n] = d
#endif
/* Other macros that are different for 8-bit mode. The MAX_255 macro checks
whether its argument, which is assumed to be one code unit, is less than 256.
The CHMAX_255 macro does not assume one code unit. The maximum length of a MARK
name must fit in one code unit; currently it is set to 255 or 65535. The
TABLE_GET macro is used to access elements of tables containing exactly 256
items. Its argument is a code unit. When code points can be greater than 255, a
check is needed before accessing these tables. */
#if PCRE2_CODE_UNIT_WIDTH == 8
#define MAX_255(c) TRUE
#define MAX_MARK ((1u << 8) - 1)
#define TABLE_GET(c, table, default) ((table)[c])
#ifdef SUPPORT_UNICODE
#define SUPPORT_WIDE_CHARS
#define CHMAX_255(c) ((c) <= 255u)
#else
#define CHMAX_255(c) TRUE
#endif /* SUPPORT_UNICODE */
#else /* Code units are 16 or 32 bits */
#define CHMAX_255(c) ((c) <= 255u)
#define MAX_255(c) ((c) <= 255u)
#define MAX_MARK ((1u << 16) - 1)
#define SUPPORT_WIDE_CHARS
#define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
#endif
/* ----------------- Character-handling macros ----------------- */
/* There is a proposed future special "UTF-21" mode, in which only the lowest
21 bits of a 32-bit character are interpreted as UTF, with the remaining 11
high-order bits available to the application for other uses. In preparation for
the future implementation of this mode, there are macros that load a data item
and, if in this special mode, mask it to 21 bits. These macros all have names
starting with UCHAR21. In all other modes, including the normal 32-bit
library, the macros all have the same simple definitions. When the new mode is
implemented, it is expected that these definitions will be varied appropriately
using #ifdef when compiling the library that supports the special mode. */
#define UCHAR21(eptr) (*(eptr))
#define UCHAR21TEST(eptr) (*(eptr))
#define UCHAR21INC(eptr) (*(eptr)++)
#define UCHAR21INCTEST(eptr) (*(eptr)++)
/* When UTF encoding is being used, a character is no longer just a single
byte in 8-bit mode or a single short in 16-bit mode. The macros for character
handling generate simple sequences when used in the basic mode, and more
complicated ones for UTF characters. GETCHARLENTEST and other macros are not
used when UTF is not supported. To make sure they can never even appear when
UTF support is omitted, we don't even define them. */
#ifndef SUPPORT_UNICODE
/* #define MAX_UTF_SINGLE_CU */
/* #define HAS_EXTRALEN(c) */
/* #define GET_EXTRALEN(c) */
/* #define NOT_FIRSTCU(c) */
#define GETCHAR(c, eptr) c = *eptr;
#define GETCHARTEST(c, eptr) c = *eptr;
#define GETCHARINC(c, eptr) c = *eptr++;
#define GETCHARINCTEST(c, eptr) c = *eptr++;
#define GETCHARLEN(c, eptr, len) c = *eptr;
#define PUTCHAR(c, p) (*p = c, 1)
/* #define GETCHARLENTEST(c, eptr, len) */
/* #define BACKCHAR(eptr) */
/* #define FORWARDCHAR(eptr) */
/* #define FORWARCCHARTEST(eptr,end) */
/* #define ACROSSCHAR(condition, eptr, action) */
#else /* SUPPORT_UNICODE */
/* ------------------- 8-bit support ------------------ */
#if PCRE2_CODE_UNIT_WIDTH == 8
#define MAYBE_UTF_MULTI /* UTF chars may use multiple code units */
/* The largest UTF code point that can be encoded as a single code unit. */
#define MAX_UTF_SINGLE_CU 127
/* Tests whether the code point needs extra characters to decode. */
#define HAS_EXTRALEN(c) HASUTF8EXTRALEN(c)
/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
Otherwise it has an undefined behaviour. */
#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3fu])
/* Returns TRUE, if the given value is not the first code unit of a UTF
sequence. */
#define NOT_FIRSTCU(c) (((c) & 0xc0u) == 0x80u)
/* Get the next UTF-8 character, not advancing the pointer. This is called when
we know we are in UTF-8 mode. */
#define GETCHAR(c, eptr) \
c = *eptr; \
if (c >= 0xc0u) GETUTF8(c, eptr);
/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
pointer. */
#define GETCHARTEST(c, eptr) \
c = *eptr; \
if (utf && c >= 0xc0u) GETUTF8(c, eptr);
/* Get the next UTF-8 character, advancing the pointer. This is called when we
know we are in UTF-8 mode. */
#define GETCHARINC(c, eptr) \
c = *eptr++; \
if (c >= 0xc0u) GETUTF8INC(c, eptr);
/* Get the next character, testing for UTF-8 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-8 mode. */
#define GETCHARINCTEST(c, eptr) \
c = *eptr++; \
if (utf && c >= 0xc0u) GETUTF8INC(c, eptr);
/* Get the next UTF-8 character, not advancing the pointer, incrementing length
if there are extra bytes. This is called when we know we are in UTF-8 mode. */
#define GETCHARLEN(c, eptr, len) \
c = *eptr; \
if (c >= 0xc0u) GETUTF8LEN(c, eptr, len);
/* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
pointer, incrementing length if there are extra bytes. This is called when we
do not know if we are in UTF-8 mode. */
#define GETCHARLENTEST(c, eptr, len) \
c = *eptr; \
if (utf && c >= 0xc0u) GETUTF8LEN(c, eptr, len);
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-8 mode - we don't put a test within the macro
because almost all calls are already within a block of UTF-8 only code. */
#define BACKCHAR(eptr) while((*eptr & 0xc0u) == 0x80u) eptr--
/* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) while((*eptr & 0xc0u) == 0x80u) eptr++
#define FORWARDCHARTEST(eptr,end) while(eptr < end && (*eptr & 0xc0u) == 0x80u) eptr++
/* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \
while((condition) && ((*eptr) & 0xc0u) == 0x80u) action
/* Deposit a character into memory, returning the number of code units. */
#define PUTCHAR(c, p) ((utf && c > MAX_UTF_SINGLE_CU)? \
PRIV(ord2utf)(c,p) : (*p = c, 1))
/* ------------------- 16-bit support ------------------ */
#elif PCRE2_CODE_UNIT_WIDTH == 16
#define MAYBE_UTF_MULTI /* UTF chars may use multiple code units */
/* The largest UTF code point that can be encoded as a single code unit. */
#define MAX_UTF_SINGLE_CU 65535
/* Tests whether the code point needs extra characters to decode. */
#define HAS_EXTRALEN(c) (((c) & 0xfc00u) == 0xd800u)
/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
Otherwise it has an undefined behaviour. */
#define GET_EXTRALEN(c) 1
/* Returns TRUE, if the given value is not the first code unit of a UTF
sequence. */
#define NOT_FIRSTCU(c) (((c) & 0xfc00u) == 0xdc00u)
/* Base macro to pick up the low surrogate of a UTF-16 character, not
advancing the pointer. */
#define GETUTF16(c, eptr) \
{ c = (((c & 0x3ffu) << 10) | (eptr[1] & 0x3ffu)) + 0x10000u; }
/* Get the next UTF-16 character, not advancing the pointer. This is called when
we know we are in UTF-16 mode. */
#define GETCHAR(c, eptr) \
c = *eptr; \
if ((c & 0xfc00u) == 0xd800u) GETUTF16(c, eptr);
/* Get the next UTF-16 character, testing for UTF-16 mode, and not advancing the
pointer. */
#define GETCHARTEST(c, eptr) \
c = *eptr; \
if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16(c, eptr);
/* Base macro to pick up the low surrogate of a UTF-16 character, advancing
the pointer. */
#define GETUTF16INC(c, eptr) \
{ c = (((c & 0x3ffu) << 10) | (*eptr++ & 0x3ffu)) + 0x10000u; }
/* Get the next UTF-16 character, advancing the pointer. This is called when we
know we are in UTF-16 mode. */
#define GETCHARINC(c, eptr) \
c = *eptr++; \
if ((c & 0xfc00u) == 0xd800u) GETUTF16INC(c, eptr);
/* Get the next character, testing for UTF-16 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-16 mode. */
#define GETCHARINCTEST(c, eptr) \
c = *eptr++; \
if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16INC(c, eptr);
/* Base macro to pick up the low surrogate of a UTF-16 character, not
advancing the pointer, incrementing the length. */
#define GETUTF16LEN(c, eptr, len) \
{ c = (((c & 0x3ffu) << 10) | (eptr[1] & 0x3ffu)) + 0x10000u; len++; }
/* Get the next UTF-16 character, not advancing the pointer, incrementing
length if there is a low surrogate. This is called when we know we are in
UTF-16 mode. */
#define GETCHARLEN(c, eptr, len) \
c = *eptr; \
if ((c & 0xfc00u) == 0xd800u) GETUTF16LEN(c, eptr, len);
/* Get the next UTF-816character, testing for UTF-16 mode, not advancing the
pointer, incrementing length if there is a low surrogate. This is called when
we do not know if we are in UTF-16 mode. */
#define GETCHARLENTEST(c, eptr, len) \
c = *eptr; \
if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16LEN(c, eptr, len);
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-16 mode - we don't put a test within the
macro because almost all calls are already within a block of UTF-16 only
code. */
#define BACKCHAR(eptr) if ((*eptr & 0xfc00u) == 0xdc00u) eptr--
/* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) if ((*eptr & 0xfc00u) == 0xdc00u) eptr++
#define FORWARDCHARTEST(eptr,end) if (eptr < end && (*eptr & 0xfc00u) == 0xdc00u) eptr++
/* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \
if ((condition) && ((*eptr) & 0xfc00u) == 0xdc00u) action
/* Deposit a character into memory, returning the number of code units. */
#define PUTCHAR(c, p) ((utf && c > MAX_UTF_SINGLE_CU)? \
PRIV(ord2utf)(c,p) : (*p = c, 1))
/* ------------------- 32-bit support ------------------ */
#else
/* These are trivial for the 32-bit library, since all UTF-32 characters fit
into one PCRE2_UCHAR unit. */
#define MAX_UTF_SINGLE_CU (0x10ffffu)
#define HAS_EXTRALEN(c) (0)
#define GET_EXTRALEN(c) (0)
#define NOT_FIRSTCU(c) (0)
/* Get the next UTF-32 character, not advancing the pointer. This is called when
we know we are in UTF-32 mode. */
#define GETCHAR(c, eptr) \
c = *(eptr);
/* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the
pointer. */
#define GETCHARTEST(c, eptr) \
c = *(eptr);
/* Get the next UTF-32 character, advancing the pointer. This is called when we
know we are in UTF-32 mode. */
#define GETCHARINC(c, eptr) \
c = *((eptr)++);
/* Get the next character, testing for UTF-32 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-32 mode. */
#define GETCHARINCTEST(c, eptr) \
c = *((eptr)++);
/* Get the next UTF-32 character, not advancing the pointer, not incrementing
length (since all UTF-32 is of length 1). This is called when we know we are in
UTF-32 mode. */
#define GETCHARLEN(c, eptr, len) \
GETCHAR(c, eptr)
/* Get the next UTF-32character, testing for UTF-32 mode, not advancing the
pointer, not incrementing the length (since all UTF-32 is of length 1).
This is called when we do not know if we are in UTF-32 mode. */
#define GETCHARLENTEST(c, eptr, len) \
GETCHARTEST(c, eptr)
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-32 mode - we don't put a test within the
macro because almost all calls are already within a block of UTF-32 only
code.
These are all no-ops since all UTF-32 characters fit into one PCRE2_UCHAR. */
#define BACKCHAR(eptr) do { } while (0)
/* Same as above, just in the other direction. */
#define FORWARDCHAR(eptr) do { } while (0)
#define FORWARDCHARTEST(eptr,end) do { } while (0)
/* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) do { } while (0)
/* Deposit a character into memory, returning the number of code units. */
#define PUTCHAR(c, p) (*p = c, 1)
#endif /* UTF-32 character handling */
#endif /* SUPPORT_UNICODE */
/* Mode-dependent macros that have the same definition in all modes. */
#define CU2BYTES(x) ((x)*((PCRE2_CODE_UNIT_WIDTH/8)))
#define BYTES2CU(x) ((x)/((PCRE2_CODE_UNIT_WIDTH/8)))
#define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
#define PUT2INC(a,n,d) PUT2(a,n,d), a += IMM2_SIZE
/* ----------------------- HIDDEN STRUCTURES ----------------------------- */
/* NOTE: All these structures *must* start with a pcre2_memctl structure. The
code that uses them is simpler because it assumes this. */
/* The real general context structure. At present it holds only data for custom
memory control. */
typedef struct pcre2_real_general_context {
pcre2_memctl memctl;
} pcre2_real_general_context;
/* The real compile context structure */
typedef struct pcre2_real_compile_context {
pcre2_memctl memctl;
int (*stack_guard)(uint32_t, void *);
void *stack_guard_data;
const uint8_t *tables;
PCRE2_SIZE max_pattern_length;
uint16_t bsr_convention;
uint16_t newline_convention;
uint32_t parens_nest_limit;
uint32_t extra_options;
} pcre2_real_compile_context;
/* The real match context structure. */
typedef struct pcre2_real_match_context {
pcre2_memctl memctl;
#ifdef SUPPORT_JIT
pcre2_jit_callback jit_callback;
void *jit_callback_data;
#endif
int (*callout)(pcre2_callout_block *, void *);
void *callout_data;
int (*substitute_callout)(pcre2_substitute_callout_block *, void *);
void *substitute_callout_data;
PCRE2_SIZE offset_limit;
uint32_t heap_limit;
uint32_t match_limit;
uint32_t depth_limit;
} pcre2_real_match_context;
/* The real convert context structure. */
typedef struct pcre2_real_convert_context {
pcre2_memctl memctl;
uint32_t glob_separator;
uint32_t glob_escape;
} pcre2_real_convert_context;
/* The real compiled code structure. The type for the blocksize field is
defined specially because it is required in pcre2_serialize_decode() when
copying the size from possibly unaligned memory into a variable of the same
type. Use a macro rather than a typedef to avoid compiler warnings when this
file is included multiple times by pcre2test. LOOKBEHIND_MAX specifies the
largest lookbehind that is supported. (OP_REVERSE in a pattern has a 16-bit
argument in 8-bit and 16-bit modes, so we need no more than a 16-bit field
here.) */
#undef CODE_BLOCKSIZE_TYPE
#define CODE_BLOCKSIZE_TYPE size_t
#undef LOOKBEHIND_MAX
#define LOOKBEHIND_MAX UINT16_MAX
typedef struct pcre2_real_code {
pcre2_memctl memctl; /* Memory control fields */
const uint8_t *tables; /* The character tables */
void *executable_jit; /* Pointer to JIT code */
uint8_t start_bitmap[32]; /* Bitmap for starting code unit < 256 */
CODE_BLOCKSIZE_TYPE blocksize; /* Total (bytes) that was malloc-ed */
uint32_t magic_number; /* Paranoid and endianness check */
uint32_t compile_options; /* Options passed to pcre2_compile() */
uint32_t overall_options; /* Options after processing the pattern */
uint32_t extra_options; /* Taken from compile_context */
uint32_t flags; /* Various state flags */
uint32_t limit_heap; /* Limit set in the pattern */
uint32_t limit_match; /* Limit set in the pattern */
uint32_t limit_depth; /* Limit set in the pattern */
uint32_t first_codeunit; /* Starting code unit */
uint32_t last_codeunit; /* This codeunit must be seen */
uint16_t bsr_convention; /* What \R matches */
uint16_t newline_convention; /* What is a newline? */
uint16_t max_lookbehind; /* Longest lookbehind (characters) */
uint16_t minlength; /* Minimum length of match */
uint16_t top_bracket; /* Highest numbered group */
uint16_t top_backref; /* Highest numbered back reference */
uint16_t name_entry_size; /* Size (code units) of table entries */
uint16_t name_count; /* Number of name entries in the table */
} pcre2_real_code;
/* The real match data structure. Define ovector as large as it can ever
actually be so that array bound checkers don't grumble. Memory for this
structure is obtained by calling pcre2_match_data_create(), which sets the size
as the offset of ovector plus a pair of elements for each capturable string, so
the size varies from call to call. As the maximum number of capturing
subpatterns is 65535 we must allow for 65536 strings to include the overall
match. (See also the heapframe structure below.) */
struct heapframe; /* Forward reference */
typedef struct pcre2_real_match_data {
pcre2_memctl memctl; /* Memory control fields */
const pcre2_real_code *code; /* The pattern used for the match */
PCRE2_SPTR subject; /* The subject that was matched */
PCRE2_SPTR mark; /* Pointer to last mark */
struct heapframe *heapframes; /* Backtracking frames heap memory */
PCRE2_SIZE heapframes_size; /* Malloc-ed size */
PCRE2_SIZE leftchar; /* Offset to leftmost code unit */
PCRE2_SIZE rightchar; /* Offset to rightmost code unit */
PCRE2_SIZE startchar; /* Offset to starting code unit */
uint8_t matchedby; /* Type of match (normal, JIT, DFA) */
uint8_t flags; /* Various flags */
uint16_t oveccount; /* Number of pairs */
int rc; /* The return code from the match */
PCRE2_SIZE ovector[131072]; /* Must be last in the structure */
} pcre2_real_match_data;
/* ----------------------- PRIVATE STRUCTURES ----------------------------- */
/* These structures are not needed for pcre2test. */
#ifndef PCRE2_PCRE2TEST
/* Structures for checking for mutual recursion when scanning compiled or
parsed code. */
typedef struct recurse_check {
struct recurse_check *prev;
PCRE2_SPTR group;
} recurse_check;
typedef struct parsed_recurse_check {
struct parsed_recurse_check *prev;
uint32_t *groupptr;
} parsed_recurse_check;
/* Structure for building a cache when filling in recursion offsets. */
typedef struct recurse_cache {
PCRE2_SPTR group;
int groupnumber;
} recurse_cache;
/* Structure for maintaining a chain of pointers to the currently incomplete
branches, for testing for left recursion while compiling. */
typedef struct branch_chain {
struct branch_chain *outer;
PCRE2_UCHAR *current_branch;
} branch_chain;
/* Structure for building a list of named groups during the first pass of
compiling. */
typedef struct named_group {
PCRE2_SPTR name; /* Points to the name in the pattern */
uint32_t number; /* Group number */
uint16_t length; /* Length of the name */
uint16_t isdup; /* TRUE if a duplicate */
} named_group;
/* Structure for passing "static" information around between the functions
doing the compiling, so that they are thread-safe. */
typedef struct compile_block {
pcre2_real_compile_context *cx; /* Points to the compile context */
const uint8_t *lcc; /* Points to lower casing table */
const uint8_t *fcc; /* Points to case-flipping table */
const uint8_t *cbits; /* Points to character type table */
const uint8_t *ctypes; /* Points to table of type maps */
PCRE2_SPTR start_workspace; /* The start of working space */
PCRE2_SPTR start_code; /* The start of the compiled code */
PCRE2_SPTR start_pattern; /* The start of the pattern */
PCRE2_SPTR end_pattern; /* The end of the pattern */
PCRE2_UCHAR *name_table; /* The name/number table */
PCRE2_SIZE workspace_size; /* Size of workspace */
PCRE2_SIZE small_ref_offset[10]; /* Offsets for \1 to \9 */
PCRE2_SIZE erroroffset; /* Offset of error in pattern */
uint16_t names_found; /* Number of entries so far */
uint16_t name_entry_size; /* Size of each entry */
uint16_t parens_depth; /* Depth of nested parentheses */
uint16_t assert_depth; /* Depth of nested assertions */
open_capitem *open_caps; /* Chain of open capture items */
named_group *named_groups; /* Points to vector in pre-compile */
uint32_t named_group_list_size; /* Number of entries in the list */
uint32_t external_options; /* External (initial) options */
uint32_t external_flags; /* External flag bits to be set */
uint32_t bracount; /* Count of capturing parentheses */
uint32_t lastcapture; /* Last capture encountered */
uint32_t *parsed_pattern; /* Parsed pattern buffer */
uint32_t *parsed_pattern_end; /* Parsed pattern should not get here */
uint32_t *groupinfo; /* Group info vector */
uint32_t top_backref; /* Maximum back reference */
uint32_t backref_map; /* Bitmap of low back refs */
uint32_t nltype; /* Newline type */
uint32_t nllen; /* Newline string length */
uint32_t class_range_start; /* Overall class range start */
uint32_t class_range_end; /* Overall class range end */
PCRE2_UCHAR nl[4]; /* Newline string when fixed length */
uint32_t req_varyopt; /* "After variable item" flag for reqbyte */
int max_lookbehind; /* Maximum lookbehind (characters) */
BOOL had_accept; /* (*ACCEPT) encountered */
BOOL had_pruneorskip; /* (*PRUNE) or (*SKIP) encountered */
BOOL had_recurse; /* Had a recursion or subroutine call */
BOOL dupnames; /* Duplicate names exist */
} compile_block;
/* Structure for keeping the properties of the in-memory stack used
by the JIT matcher. */
typedef struct pcre2_real_jit_stack {
pcre2_memctl memctl;
void* stack;
} pcre2_real_jit_stack;
/* Structure for items in a linked list that represents an explicit recursive
call within the pattern when running pcre2_dfa_match(). */
typedef struct dfa_recursion_info {
struct dfa_recursion_info *prevrec;
PCRE2_SPTR subject_position;
uint32_t group_num;
} dfa_recursion_info;
/* Structure for "stack" frames that are used for remembering backtracking
positions during matching. As these are used in a vector, with the ovector item
being extended, the size of the structure must be a multiple of PCRE2_SIZE. The
only way to check this at compile time is to force an error by generating an
array with a negative size. By putting this in a typedef (which is never used),
we don't generate any code when all is well. */
typedef struct heapframe {
/* The first set of fields are variables that have to be preserved over calls
to RRMATCH(), but which do not need to be copied to new frames. */
PCRE2_SPTR ecode; /* The current position in the pattern */
PCRE2_SPTR temp_sptr[2]; /* Used for short-term PCRE_SPTR values */
PCRE2_SIZE length; /* Used for character, string, or code lengths */
PCRE2_SIZE back_frame; /* Amount to subtract on RRETURN */
PCRE2_SIZE temp_size; /* Used for short-term PCRE2_SIZE values */
uint32_t rdepth; /* "Recursion" depth */
uint32_t group_frame_type; /* Type information for group frames */
uint32_t temp_32[4]; /* Used for short-term 32-bit or BOOL values */
uint8_t return_id; /* Where to go on in internal "return" */
uint8_t op; /* Processing opcode */
/* At this point, the structure is 16-bit aligned. On most architectures
the alignment requirement for a pointer will ensure that the eptr field below
is 32-bit or 64-bit aligned. However, on m68k it is fine to have a pointer
that is 16-bit aligned. We must therefore ensure that what comes between here
and eptr is an odd multiple of 16 bits so as to get back into 32-bit
alignment. This happens naturally when PCRE2_UCHAR is 8 bits wide, but needs
fudges in the other cases. In the 32-bit case the padding comes first so that
the occu field itself is 32-bit aligned. Without the padding, this structure
is no longer a multiple of PCRE2_SIZE on m68k, and the check below fails. */
#if PCRE2_CODE_UNIT_WIDTH == 8
PCRE2_UCHAR occu[6]; /* Used for other case code units */
#elif PCRE2_CODE_UNIT_WIDTH == 16
PCRE2_UCHAR occu[2]; /* Used for other case code units */
uint8_t unused[2]; /* Ensure 32-bit alignment (see above) */
#else
uint8_t unused[2]; /* Ensure 32-bit alignment (see above) */
PCRE2_UCHAR occu[1]; /* Used for other case code units */
#endif
/* The rest have to be copied from the previous frame whenever a new frame
becomes current. The final field is specified as a large vector so that
runtime array bound checks don't catch references to it. However, for any
specific call to pcre2_match() the memory allocated for each frame structure
allows for exactly the right size ovector for the number of capturing
parentheses. (See also the comment for pcre2_real_match_data above.) */
PCRE2_SPTR eptr; /* MUST BE FIRST */
PCRE2_SPTR start_match; /* Can be adjusted by \K */
PCRE2_SPTR mark; /* Most recent mark on the success path */
uint32_t current_recurse; /* Current (deepest) recursion number */
uint32_t capture_last; /* Most recent capture */
PCRE2_SIZE last_group_offset; /* Saved offset to most recent group frame */
PCRE2_SIZE offset_top; /* Offset after highest capture */
PCRE2_SIZE ovector[131072]; /* Must be last in the structure */
} heapframe;
/* This typedef is a check that the size of the heapframe structure is a
multiple of PCRE2_SIZE. See various comments above. */
typedef char check_heapframe_size[
((sizeof(heapframe) % sizeof(PCRE2_SIZE)) == 0)? (+1):(-1)];
/* Structure for computing the alignment of heapframe. */
typedef struct heapframe_align {
char unalign; /* Completely unalign the current offset */
heapframe frame; /* Offset is its alignment */
} heapframe_align;
/* This define is the minimum alignment required for a heapframe, in bytes. */
#define HEAPFRAME_ALIGNMENT offsetof(heapframe_align, frame)
/* Structure for passing "static" information around between the functions
doing traditional NFA matching (pcre2_match() and friends). */
typedef struct match_block {
pcre2_memctl memctl; /* For general use */
PCRE2_SIZE heap_limit; /* As it says */
uint32_t match_limit; /* As it says */
uint32_t match_limit_depth; /* As it says */
uint32_t match_call_count; /* Number of times a new frame is created */
BOOL hitend; /* Hit the end of the subject at some point */
BOOL hasthen; /* Pattern contains (*THEN) */
BOOL allowemptypartial; /* Allow empty hard partial */
const uint8_t *lcc; /* Points to lower casing table */
const uint8_t *fcc; /* Points to case-flipping table */
const uint8_t *ctypes; /* Points to table of type maps */
PCRE2_SIZE start_offset; /* The start offset value */
PCRE2_SIZE end_offset_top; /* Highwater mark at end of match */
uint16_t partial; /* PARTIAL options */
uint16_t bsr_convention; /* \R interpretation */
uint16_t name_count; /* Number of names in name table */
uint16_t name_entry_size; /* Size of entry in names table */
PCRE2_SPTR name_table; /* Table of group names */
PCRE2_SPTR start_code; /* For use when recursing */
PCRE2_SPTR start_subject; /* Start of the subject string */
PCRE2_SPTR check_subject; /* Where UTF-checked from */
PCRE2_SPTR end_subject; /* End of the subject string */
PCRE2_SPTR end_match_ptr; /* Subject position at end match */
PCRE2_SPTR start_used_ptr; /* Earliest consulted character */
PCRE2_SPTR last_used_ptr; /* Latest consulted character */
PCRE2_SPTR mark; /* Mark pointer to pass back on success */
PCRE2_SPTR nomatch_mark; /* Mark pointer to pass back on failure */
PCRE2_SPTR verb_ecode_ptr; /* For passing back info */
PCRE2_SPTR verb_skip_ptr; /* For passing back a (*SKIP) name */
uint32_t verb_current_recurse; /* Current recurse when (*VERB) happens */
uint32_t moptions; /* Match options */
uint32_t poptions; /* Pattern options */
uint32_t skip_arg_count; /* For counting SKIP_ARGs */
uint32_t ignore_skip_arg; /* For re-run when SKIP arg name not found */
uint32_t nltype; /* Newline type */
uint32_t nllen; /* Newline string length */
PCRE2_UCHAR nl[4]; /* Newline string when fixed */
pcre2_callout_block *cb; /* Points to a callout block */
void *callout_data; /* To pass back to callouts */
int (*callout)(pcre2_callout_block *,void *); /* Callout function or NULL */
} match_block;
/* A similar structure is used for the same purpose by the DFA matching
functions. */
typedef struct dfa_match_block {
pcre2_memctl memctl; /* For general use */
PCRE2_SPTR start_code; /* Start of the compiled pattern */
PCRE2_SPTR start_subject ; /* Start of the subject string */
PCRE2_SPTR end_subject; /* End of subject string */
PCRE2_SPTR start_used_ptr; /* Earliest consulted character */
PCRE2_SPTR last_used_ptr; /* Latest consulted character */
const uint8_t *tables; /* Character tables */
PCRE2_SIZE start_offset; /* The start offset value */
PCRE2_SIZE heap_limit; /* As it says */
PCRE2_SIZE heap_used; /* As it says */
uint32_t match_limit; /* As it says */
uint32_t match_limit_depth; /* As it says */
uint32_t match_call_count; /* Number of calls of internal function */
uint32_t moptions; /* Match options */
uint32_t poptions; /* Pattern options */
uint32_t nltype; /* Newline type */
uint32_t nllen; /* Newline string length */
BOOL allowemptypartial; /* Allow empty hard partial */
PCRE2_UCHAR nl[4]; /* Newline string when fixed */
uint16_t bsr_convention; /* \R interpretation */
pcre2_callout_block *cb; /* Points to a callout block */
void *callout_data; /* To pass back to callouts */
int (*callout)(pcre2_callout_block *,void *); /* Callout function or NULL */
dfa_recursion_info *recursive; /* Linked list of recursion data */
} dfa_match_block;
#endif /* PCRE2_PCRE2TEST */
/* End of pcre2_intmodedep.h */

View File

@ -0,0 +1,349 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
This module by Zoltan Herczeg and Sebastian Pop
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2019 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
# if defined(FFCS)
# if defined(FF_UTF)
# define FF_FUN ffcs_utf
# else
# define FF_FUN ffcs
# endif
# elif defined(FFCS_2)
# if defined(FF_UTF)
# define FF_FUN ffcs_2_utf
# else
# define FF_FUN ffcs_2
# endif
# elif defined(FFCS_MASK)
# if defined(FF_UTF)
# define FF_FUN ffcs_mask_utf
# else
# define FF_FUN ffcs_mask
# endif
# elif defined(FFCPS_0)
# if defined (FF_UTF)
# define FF_FUN ffcps_0_utf
# else
# define FF_FUN ffcps_0
# endif
# elif defined (FFCPS_1)
# if defined (FF_UTF)
# define FF_FUN ffcps_1_utf
# else
# define FF_FUN ffcps_1
# endif
# elif defined (FFCPS_DEFAULT)
# if defined (FF_UTF)
# define FF_FUN ffcps_default_utf
# else
# define FF_FUN ffcps_default
# endif
# endif
static sljit_u8* SLJIT_FUNC FF_FUN(sljit_u8 *str_end, sljit_u8 *str_ptr, sljit_uw offs1, sljit_uw offs2, sljit_uw chars)
#undef FF_FUN
{
quad_word qw;
int_char ic;
SLJIT_UNUSED_ARG(offs1);
SLJIT_UNUSED_ARG(offs2);
ic.x = chars;
#if defined(FFCS)
sljit_u8 c1 = ic.c.c1;
vect_t vc1 = VDUPQ(c1);
#elif defined(FFCS_2)
sljit_u8 c1 = ic.c.c1;
vect_t vc1 = VDUPQ(c1);
sljit_u8 c2 = ic.c.c2;
vect_t vc2 = VDUPQ(c2);
#elif defined(FFCS_MASK)
sljit_u8 c1 = ic.c.c1;
vect_t vc1 = VDUPQ(c1);
sljit_u8 mask = ic.c.c2;
vect_t vmask = VDUPQ(mask);
#endif
#if defined(FFCPS)
compare_type compare1_type = compare_match1;
compare_type compare2_type = compare_match1;
vect_t cmp1a, cmp1b, cmp2a, cmp2b;
const sljit_u32 diff = IN_UCHARS(offs1 - offs2);
PCRE2_UCHAR char1a = ic.c.c1;
PCRE2_UCHAR char2a = ic.c.c3;
# ifdef FFCPS_CHAR1A2A
cmp1a = VDUPQ(char1a);
cmp2a = VDUPQ(char2a);
cmp1b = VDUPQ(0); /* to avoid errors on older compilers -Werror=maybe-uninitialized */
cmp2b = VDUPQ(0); /* to avoid errors on older compilers -Werror=maybe-uninitialized */
# else
PCRE2_UCHAR char1b = ic.c.c2;
PCRE2_UCHAR char2b = ic.c.c4;
if (char1a == char1b)
{
cmp1a = VDUPQ(char1a);
cmp1b = VDUPQ(0); /* to avoid errors on older compilers -Werror=maybe-uninitialized */
}
else
{
sljit_u32 bit1 = char1a ^ char1b;
if (is_powerof2(bit1))
{
compare1_type = compare_match1i;
cmp1a = VDUPQ(char1a | bit1);
cmp1b = VDUPQ(bit1);
}
else
{
compare1_type = compare_match2;
cmp1a = VDUPQ(char1a);
cmp1b = VDUPQ(char1b);
}
}
if (char2a == char2b)
{
cmp2a = VDUPQ(char2a);
cmp2b = VDUPQ(0); /* to avoid errors on older compilers -Werror=maybe-uninitialized */
}
else
{
sljit_u32 bit2 = char2a ^ char2b;
if (is_powerof2(bit2))
{
compare2_type = compare_match1i;
cmp2a = VDUPQ(char2a | bit2);
cmp2b = VDUPQ(bit2);
}
else
{
compare2_type = compare_match2;
cmp2a = VDUPQ(char2a);
cmp2b = VDUPQ(char2b);
}
}
# endif
str_ptr += IN_UCHARS(offs1);
#endif
#if PCRE2_CODE_UNIT_WIDTH != 8
vect_t char_mask = VDUPQ(0xff);
#endif
#if defined(FF_UTF)
restart:;
#endif
#if defined(FFCPS)
if (str_ptr >= str_end)
return NULL;
sljit_u8 *p1 = str_ptr - diff;
#endif
sljit_s32 align_offset = ((uint64_t)str_ptr & 0xf);
str_ptr = (sljit_u8 *) ((uint64_t)str_ptr & ~0xf);
vect_t data = VLD1Q(str_ptr);
#if PCRE2_CODE_UNIT_WIDTH != 8
data = VANDQ(data, char_mask);
#endif
#if defined(FFCS)
vect_t eq = VCEQQ(data, vc1);
#elif defined(FFCS_2)
vect_t eq1 = VCEQQ(data, vc1);
vect_t eq2 = VCEQQ(data, vc2);
vect_t eq = VORRQ(eq1, eq2);
#elif defined(FFCS_MASK)
vect_t eq = VORRQ(data, vmask);
eq = VCEQQ(eq, vc1);
#elif defined(FFCPS)
# if defined(FFCPS_DIFF1)
vect_t prev_data = data;
# endif
vect_t data2;
if (p1 < str_ptr)
{
data2 = VLD1Q(str_ptr - diff);
#if PCRE2_CODE_UNIT_WIDTH != 8
data2 = VANDQ(data2, char_mask);
#endif
}
else
data2 = shift_left_n_lanes(data, offs1 - offs2);
if (compare1_type == compare_match1)
data = VCEQQ(data, cmp1a);
else
data = fast_forward_char_pair_compare(compare1_type, data, cmp1a, cmp1b);
if (compare2_type == compare_match1)
data2 = VCEQQ(data2, cmp2a);
else
data2 = fast_forward_char_pair_compare(compare2_type, data2, cmp2a, cmp2b);
vect_t eq = VANDQ(data, data2);
#endif
VST1Q(qw.mem, eq);
/* Ignore matches before the first STR_PTR. */
if (align_offset < 8)
{
qw.dw[0] >>= align_offset * 8;
if (qw.dw[0])
{
str_ptr += align_offset + __builtin_ctzll(qw.dw[0]) / 8;
goto match;
}
if (qw.dw[1])
{
str_ptr += 8 + __builtin_ctzll(qw.dw[1]) / 8;
goto match;
}
}
else
{
qw.dw[1] >>= (align_offset - 8) * 8;
if (qw.dw[1])
{
str_ptr += align_offset + __builtin_ctzll(qw.dw[1]) / 8;
goto match;
}
}
str_ptr += 16;
while (str_ptr < str_end)
{
vect_t orig_data = VLD1Q(str_ptr);
#if PCRE2_CODE_UNIT_WIDTH != 8
orig_data = VANDQ(orig_data, char_mask);
#endif
data = orig_data;
#if defined(FFCS)
eq = VCEQQ(data, vc1);
#elif defined(FFCS_2)
eq1 = VCEQQ(data, vc1);
eq2 = VCEQQ(data, vc2);
eq = VORRQ(eq1, eq2);
#elif defined(FFCS_MASK)
eq = VORRQ(data, vmask);
eq = VCEQQ(eq, vc1);
#endif
#if defined(FFCPS)
# if defined (FFCPS_DIFF1)
data2 = VEXTQ(prev_data, data, VECTOR_FACTOR - 1);
# else
data2 = VLD1Q(str_ptr - diff);
# if PCRE2_CODE_UNIT_WIDTH != 8
data2 = VANDQ(data2, char_mask);
# endif
# endif
# ifdef FFCPS_CHAR1A2A
data = VCEQQ(data, cmp1a);
data2 = VCEQQ(data2, cmp2a);
# else
if (compare1_type == compare_match1)
data = VCEQQ(data, cmp1a);
else
data = fast_forward_char_pair_compare(compare1_type, data, cmp1a, cmp1b);
if (compare2_type == compare_match1)
data2 = VCEQQ(data2, cmp2a);
else
data2 = fast_forward_char_pair_compare(compare2_type, data2, cmp2a, cmp2b);
# endif
eq = VANDQ(data, data2);
#endif
VST1Q(qw.mem, eq);
if (qw.dw[0])
str_ptr += __builtin_ctzll(qw.dw[0]) / 8;
else if (qw.dw[1])
str_ptr += 8 + __builtin_ctzll(qw.dw[1]) / 8;
else {
str_ptr += 16;
#if defined (FFCPS_DIFF1)
prev_data = orig_data;
#endif
continue;
}
match:;
if (str_ptr >= str_end)
/* Failed match. */
return NULL;
#if defined(FF_UTF)
if (utf_continue((PCRE2_SPTR)str_ptr - offs1))
{
/* Not a match. */
str_ptr += IN_UCHARS(1);
goto restart;
}
#endif
/* Match. */
#if defined (FFCPS)
str_ptr -= IN_UCHARS(offs1);
#endif
return str_ptr;
}
/* Failed match. */
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,394 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2022 University of Cambridge
This module is auto-generated from Unicode data files. DO NOT EDIT MANUALLY!
Instead, modify the maint/GenerateUcpHeader.py script and run it to generate
a new version of this code.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifndef PCRE2_UCP_H_IDEMPOTENT_GUARD
#define PCRE2_UCP_H_IDEMPOTENT_GUARD
/* This file contains definitions of the Unicode property values that are
returned by the UCD access macros and used throughout PCRE2.
IMPORTANT: The specific values of the first two enums (general and particular
character categories) are assumed by the table called catposstab in the file
pcre2_auto_possess.c. They are unlikely to change, but should be checked after
an update. */
/* These are the general character categories. */
enum {
ucp_C,
ucp_L,
ucp_M,
ucp_N,
ucp_P,
ucp_S,
ucp_Z,
};
/* These are the particular character categories. */
enum {
ucp_Cc, /* Control */
ucp_Cf, /* Format */
ucp_Cn, /* Unassigned */
ucp_Co, /* Private use */
ucp_Cs, /* Surrogate */
ucp_Ll, /* Lower case letter */
ucp_Lm, /* Modifier letter */
ucp_Lo, /* Other letter */
ucp_Lt, /* Title case letter */
ucp_Lu, /* Upper case letter */
ucp_Mc, /* Spacing mark */
ucp_Me, /* Enclosing mark */
ucp_Mn, /* Non-spacing mark */
ucp_Nd, /* Decimal number */
ucp_Nl, /* Letter number */
ucp_No, /* Other number */
ucp_Pc, /* Connector punctuation */
ucp_Pd, /* Dash punctuation */
ucp_Pe, /* Close punctuation */
ucp_Pf, /* Final punctuation */
ucp_Pi, /* Initial punctuation */
ucp_Po, /* Other punctuation */
ucp_Ps, /* Open punctuation */
ucp_Sc, /* Currency symbol */
ucp_Sk, /* Modifier symbol */
ucp_Sm, /* Mathematical symbol */
ucp_So, /* Other symbol */
ucp_Zl, /* Line separator */
ucp_Zp, /* Paragraph separator */
ucp_Zs, /* Space separator */
};
/* These are Boolean properties. */
enum {
ucp_ASCII,
ucp_ASCII_Hex_Digit,
ucp_Alphabetic,
ucp_Bidi_Control,
ucp_Bidi_Mirrored,
ucp_Case_Ignorable,
ucp_Cased,
ucp_Changes_When_Casefolded,
ucp_Changes_When_Casemapped,
ucp_Changes_When_Lowercased,
ucp_Changes_When_Titlecased,
ucp_Changes_When_Uppercased,
ucp_Dash,
ucp_Default_Ignorable_Code_Point,
ucp_Deprecated,
ucp_Diacritic,
ucp_Emoji,
ucp_Emoji_Component,
ucp_Emoji_Modifier,
ucp_Emoji_Modifier_Base,
ucp_Emoji_Presentation,
ucp_Extended_Pictographic,
ucp_Extender,
ucp_Grapheme_Base,
ucp_Grapheme_Extend,
ucp_Grapheme_Link,
ucp_Hex_Digit,
ucp_IDS_Binary_Operator,
ucp_IDS_Trinary_Operator,
ucp_ID_Continue,
ucp_ID_Start,
ucp_Ideographic,
ucp_Join_Control,
ucp_Logical_Order_Exception,
ucp_Lowercase,
ucp_Math,
ucp_Noncharacter_Code_Point,
ucp_Pattern_Syntax,
ucp_Pattern_White_Space,
ucp_Prepended_Concatenation_Mark,
ucp_Quotation_Mark,
ucp_Radical,
ucp_Regional_Indicator,
ucp_Sentence_Terminal,
ucp_Soft_Dotted,
ucp_Terminal_Punctuation,
ucp_Unified_Ideograph,
ucp_Uppercase,
ucp_Variation_Selector,
ucp_White_Space,
ucp_XID_Continue,
ucp_XID_Start,
/* This must be last */
ucp_Bprop_Count
};
/* Size of entries in ucd_boolprop_sets[] */
#define ucd_boolprop_sets_item_size 2
/* These are the bidi class values. */
enum {
ucp_bidiAL, /* Arabic letter */
ucp_bidiAN, /* Arabic number */
ucp_bidiB, /* Paragraph separator */
ucp_bidiBN, /* Boundary neutral */
ucp_bidiCS, /* Common separator */
ucp_bidiEN, /* European number */
ucp_bidiES, /* European separator */
ucp_bidiET, /* European terminator */
ucp_bidiFSI, /* First strong isolate */
ucp_bidiL, /* Left to right */
ucp_bidiLRE, /* Left to right embedding */
ucp_bidiLRI, /* Left to right isolate */
ucp_bidiLRO, /* Left to right override */
ucp_bidiNSM, /* Non-spacing mark */
ucp_bidiON, /* Other neutral */
ucp_bidiPDF, /* Pop directional format */
ucp_bidiPDI, /* Pop directional isolate */
ucp_bidiR, /* Right to left */
ucp_bidiRLE, /* Right to left embedding */
ucp_bidiRLI, /* Right to left isolate */
ucp_bidiRLO, /* Right to left override */
ucp_bidiS, /* Segment separator */
ucp_bidiWS, /* White space */
};
/* These are grapheme break properties. The Extended Pictographic property
comes from the emoji-data.txt file. */
enum {
ucp_gbCR, /* 0 */
ucp_gbLF, /* 1 */
ucp_gbControl, /* 2 */
ucp_gbExtend, /* 3 */
ucp_gbPrepend, /* 4 */
ucp_gbSpacingMark, /* 5 */
ucp_gbL, /* 6 Hangul syllable type L */
ucp_gbV, /* 7 Hangul syllable type V */
ucp_gbT, /* 8 Hangul syllable type T */
ucp_gbLV, /* 9 Hangul syllable type LV */
ucp_gbLVT, /* 10 Hangul syllable type LVT */
ucp_gbRegional_Indicator, /* 11 */
ucp_gbOther, /* 12 */
ucp_gbZWJ, /* 13 */
ucp_gbExtended_Pictographic, /* 14 */
};
/* These are the script identifications. */
enum {
/* Scripts which has characters in other scripts. */
ucp_Latin,
ucp_Greek,
ucp_Cyrillic,
ucp_Arabic,
ucp_Syriac,
ucp_Thaana,
ucp_Devanagari,
ucp_Bengali,
ucp_Gurmukhi,
ucp_Gujarati,
ucp_Oriya,
ucp_Tamil,
ucp_Telugu,
ucp_Kannada,
ucp_Malayalam,
ucp_Sinhala,
ucp_Myanmar,
ucp_Georgian,
ucp_Hangul,
ucp_Mongolian,
ucp_Hiragana,
ucp_Katakana,
ucp_Bopomofo,
ucp_Han,
ucp_Yi,
ucp_Tagalog,
ucp_Hanunoo,
ucp_Buhid,
ucp_Tagbanwa,
ucp_Limbu,
ucp_Tai_Le,
ucp_Linear_B,
ucp_Cypriot,
ucp_Buginese,
ucp_Coptic,
ucp_Glagolitic,
ucp_Syloti_Nagri,
ucp_Phags_Pa,
ucp_Nko,
ucp_Kayah_Li,
ucp_Javanese,
ucp_Kaithi,
ucp_Mandaic,
ucp_Chakma,
ucp_Sharada,
ucp_Takri,
ucp_Duployan,
ucp_Grantha,
ucp_Khojki,
ucp_Linear_A,
ucp_Mahajani,
ucp_Manichaean,
ucp_Modi,
ucp_Old_Permic,
ucp_Psalter_Pahlavi,
ucp_Khudawadi,
ucp_Tirhuta,
ucp_Multani,
ucp_Adlam,
ucp_Masaram_Gondi,
ucp_Dogra,
ucp_Gunjala_Gondi,
ucp_Hanifi_Rohingya,
ucp_Sogdian,
ucp_Nandinagari,
ucp_Yezidi,
ucp_Cypro_Minoan,
ucp_Old_Uyghur,
/* Scripts which has no characters in other scripts. */
ucp_Unknown,
ucp_Common,
ucp_Armenian,
ucp_Hebrew,
ucp_Thai,
ucp_Lao,
ucp_Tibetan,
ucp_Ethiopic,
ucp_Cherokee,
ucp_Canadian_Aboriginal,
ucp_Ogham,
ucp_Runic,
ucp_Khmer,
ucp_Old_Italic,
ucp_Gothic,
ucp_Deseret,
ucp_Inherited,
ucp_Ugaritic,
ucp_Shavian,
ucp_Osmanya,
ucp_Braille,
ucp_New_Tai_Lue,
ucp_Tifinagh,
ucp_Old_Persian,
ucp_Kharoshthi,
ucp_Balinese,
ucp_Cuneiform,
ucp_Phoenician,
ucp_Sundanese,
ucp_Lepcha,
ucp_Ol_Chiki,
ucp_Vai,
ucp_Saurashtra,
ucp_Rejang,
ucp_Lycian,
ucp_Carian,
ucp_Lydian,
ucp_Cham,
ucp_Tai_Tham,
ucp_Tai_Viet,
ucp_Avestan,
ucp_Egyptian_Hieroglyphs,
ucp_Samaritan,
ucp_Lisu,
ucp_Bamum,
ucp_Meetei_Mayek,
ucp_Imperial_Aramaic,
ucp_Old_South_Arabian,
ucp_Inscriptional_Parthian,
ucp_Inscriptional_Pahlavi,
ucp_Old_Turkic,
ucp_Batak,
ucp_Brahmi,
ucp_Meroitic_Cursive,
ucp_Meroitic_Hieroglyphs,
ucp_Miao,
ucp_Sora_Sompeng,
ucp_Caucasian_Albanian,
ucp_Bassa_Vah,
ucp_Elbasan,
ucp_Pahawh_Hmong,
ucp_Mende_Kikakui,
ucp_Mro,
ucp_Old_North_Arabian,
ucp_Nabataean,
ucp_Palmyrene,
ucp_Pau_Cin_Hau,
ucp_Siddham,
ucp_Warang_Citi,
ucp_Ahom,
ucp_Anatolian_Hieroglyphs,
ucp_Hatran,
ucp_Old_Hungarian,
ucp_SignWriting,
ucp_Bhaiksuki,
ucp_Marchen,
ucp_Newa,
ucp_Osage,
ucp_Tangut,
ucp_Nushu,
ucp_Soyombo,
ucp_Zanabazar_Square,
ucp_Makasar,
ucp_Medefaidrin,
ucp_Old_Sogdian,
ucp_Elymaic,
ucp_Nyiakeng_Puachue_Hmong,
ucp_Wancho,
ucp_Chorasmian,
ucp_Dives_Akuru,
ucp_Khitan_Small_Script,
ucp_Tangsa,
ucp_Toto,
ucp_Vithkuqi,
/* This must be last */
ucp_Script_Count
};
/* Size of entries in ucd_script_sets[] */
#define ucd_script_sets_item_size 3
#endif /* PCRE2_UCP_H_IDEMPOTENT_GUARD */
/* End of pcre2_ucp.h */

View File

@ -0,0 +1,95 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Andrei Zmievski <andrei@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PCRE_H
#define PHP_PCRE_H
#ifdef HAVE_BUNDLED_PCRE
#include "pcre2lib/pcre2.h"
#else
#include "pcre2.h"
#endif
#include <locale.h>
PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count);
extern zend_module_entry pcre_module_entry;
#define pcre_module_ptr &pcre_module_entry
#include "php_version.h"
#define PHP_PCRE_VERSION PHP_VERSION
typedef struct _pcre_cache_entry pcre_cache_entry;
typedef enum {
PHP_PCRE_NO_ERROR = 0,
PHP_PCRE_INTERNAL_ERROR,
PHP_PCRE_BACKTRACK_LIMIT_ERROR,
PHP_PCRE_RECURSION_LIMIT_ERROR,
PHP_PCRE_BAD_UTF8_ERROR,
PHP_PCRE_BAD_UTF8_OFFSET_ERROR,
PHP_PCRE_JIT_STACKLIMIT_ERROR
} php_pcre_error_code;
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex);
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, int locale_aware);
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset);
PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str,
size_t limit, size_t *replace_count);
PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zend_long limit_val, zend_long flags);
PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value,
zend_long flags);
PHPAPI pcre2_match_context *php_pcre_mctx(void);
PHPAPI pcre2_general_context *php_pcre_gctx(void);
PHPAPI pcre2_compile_context *php_pcre_cctx(void);
PHPAPI void php_pcre_pce_incref(pcre_cache_entry *);
PHPAPI void php_pcre_pce_decref(pcre_cache_entry *);
PHPAPI pcre2_code *php_pcre_pce_re(pcre_cache_entry *);
/* capture_count can be ignored, re is required. */
PHPAPI pcre2_match_data *php_pcre_create_match_data(uint32_t, pcre2_code *);
PHPAPI void php_pcre_free_match_data(pcre2_match_data *);
ZEND_BEGIN_MODULE_GLOBALS(pcre)
HashTable pcre_cache;
zend_long backtrack_limit;
zend_long recursion_limit;
#ifdef HAVE_PCRE_JIT_SUPPORT
bool jit;
#endif
bool per_request_cache;
php_pcre_error_code error_code;
/* Used for unmatched subpatterns in OFFSET_CAPTURE mode */
zval unmatched_null_pair;
zval unmatched_empty_pair;
/* General context using per-request allocator (ZMM). */
pcre2_general_context *gctx_zmm;
ZEND_END_MODULE_GLOBALS(pcre)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(pcre)
#define PCRE_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(pcre, v)
#define phpext_pcre_ptr pcre_module_ptr
#endif /* PHP_PCRE_H */

View File

@ -0,0 +1,65 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PDO_H
#define PHP_PDO_H
#include "zend.h"
extern zend_module_entry pdo_module_entry;
#define phpext_pdo_ptr &pdo_module_entry
#include "php_version.h"
#define PHP_PDO_VERSION PHP_VERSION
#ifdef PHP_WIN32
# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
# define PDO_API __declspec(dllexport)
# elif defined(COMPILE_DL_PDO)
# define PDO_API __declspec(dllimport)
# else
# define PDO_API /* nothing special */
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PDO_API __attribute__ ((visibility("default")))
#else
# define PDO_API /* nothing special */
#endif
#ifdef ZTS
# include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(pdo);
PHP_MSHUTDOWN_FUNCTION(pdo);
PHP_MINFO_FUNCTION(pdo);
#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \
zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (zend_long)value);
#define REGISTER_PDO_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_stringl(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, value, sizeof(value)-1);
#define LONG_CONST(c) (zend_long) c
#define PDO_CONSTRUCT_CHECK \
if (!dbh->driver) { \
zend_throw_error(NULL, "PDO object is not initialized, constructor was not called"); \
RETURN_THROWS(); \
} \
#endif /* PHP_PDO_H */

View File

@ -0,0 +1,688 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PDO_DRIVER_H
#define PHP_PDO_DRIVER_H
#include "php_pdo.h"
/* forward declarations */
typedef struct _pdo_dbh_t pdo_dbh_t;
typedef struct _pdo_dbh_object_t pdo_dbh_object_t;
typedef struct _pdo_stmt_t pdo_stmt_t;
typedef struct _pdo_row_t pdo_row_t;
struct pdo_bound_param_data;
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
#define PDO_DRIVER_API 20170320
/* Doctrine hardcodes these constants, avoid changing their values. */
enum pdo_param_type {
PDO_PARAM_NULL = 0,
PDO_PARAM_BOOL = 5,
PDO_PARAM_INT = 1,
PDO_PARAM_STR = 2,
PDO_PARAM_LOB = 3,
/* get_col: Not supported (yet?) */
PDO_PARAM_STMT = 4, /* hierarchical result set */
/* magic flag to denote a parameter as being input/output */
PDO_PARAM_INPUT_OUTPUT = 0x80000000,
/* magic flag to denote a string that uses the national character set
see section 4.2.1 of SQL-92: http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
*/
PDO_PARAM_STR_NATL = 0x40000000,
/* magic flag to denote a string that uses the regular character set */
PDO_PARAM_STR_CHAR = 0x20000000,
};
#define PDO_PARAM_FLAGS 0xFFFF0000
#define PDO_PARAM_TYPE(x) ((x) & ~PDO_PARAM_FLAGS)
enum pdo_fetch_type {
PDO_FETCH_USE_DEFAULT,
PDO_FETCH_LAZY,
PDO_FETCH_ASSOC,
PDO_FETCH_NUM,
PDO_FETCH_BOTH,
PDO_FETCH_OBJ,
PDO_FETCH_BOUND, /* return true/false only; rely on bound columns */
PDO_FETCH_COLUMN, /* fetch a numbered column only */
PDO_FETCH_CLASS, /* create an instance of named class, call ctor and set properties */
PDO_FETCH_INTO, /* fetch row into an existing object */
PDO_FETCH_FUNC, /* fetch into function and return its result */
PDO_FETCH_NAMED, /* like PDO_FETCH_ASSOC, but can handle duplicate names */
PDO_FETCH_KEY_PAIR, /* fetch into an array where the 1st column is a key and all subsequent columns are values */
PDO_FETCH__MAX /* must be last */
};
#define PDO_FETCH_FLAGS 0xFFFF0000 /* fetchAll() modes or'd to PDO_FETCH_XYZ */
#define PDO_FETCH_GROUP 0x00010000 /* fetch into groups */
#define PDO_FETCH_UNIQUE 0x00030000 /* fetch into groups assuming first col is unique */
#define PDO_FETCH_CLASSTYPE 0x00040000 /* fetch class gets its class name from 1st column */
#define PDO_FETCH_SERIALIZE 0x00080000 /* fetch class instances by calling serialize */
#define PDO_FETCH_PROPS_LATE 0x00100000 /* fetch props after calling ctor */
/* fetch orientation for scrollable cursors */
enum pdo_fetch_orientation {
PDO_FETCH_ORI_NEXT, /* default: fetch the next available row */
PDO_FETCH_ORI_PRIOR, /* scroll back to prior row and fetch that */
PDO_FETCH_ORI_FIRST, /* scroll to the first row and fetch that */
PDO_FETCH_ORI_LAST, /* scroll to the last row and fetch that */
PDO_FETCH_ORI_ABS, /* scroll to an absolute numbered row and fetch that */
PDO_FETCH_ORI_REL /* scroll relative to the current row, and fetch that */
};
enum pdo_attribute_type {
PDO_ATTR_AUTOCOMMIT, /* use to turn on or off auto-commit mode */
PDO_ATTR_PREFETCH, /* configure the prefetch size for drivers that support it. Size is in KB */
PDO_ATTR_TIMEOUT, /* connection timeout in seconds */
PDO_ATTR_ERRMODE, /* control how errors are handled */
PDO_ATTR_SERVER_VERSION, /* database server version */
PDO_ATTR_CLIENT_VERSION, /* client library version */
PDO_ATTR_SERVER_INFO, /* server information */
PDO_ATTR_CONNECTION_STATUS, /* connection status */
PDO_ATTR_CASE, /* control case folding for portability */
PDO_ATTR_CURSOR_NAME, /* name a cursor for use in "WHERE CURRENT OF <name>" */
PDO_ATTR_CURSOR, /* cursor type */
PDO_ATTR_ORACLE_NULLS, /* convert empty strings to NULL */
PDO_ATTR_PERSISTENT, /* pconnect style connection */
PDO_ATTR_STATEMENT_CLASS, /* array(classname, array(ctor_args)) to specify the class of the constructed statement */
PDO_ATTR_FETCH_TABLE_NAMES, /* include table names in the column names, where available */
PDO_ATTR_FETCH_CATALOG_NAMES, /* include the catalog/db name names in the column names, where available */
PDO_ATTR_DRIVER_NAME, /* name of the driver (as used in the constructor) */
PDO_ATTR_STRINGIFY_FETCHES, /* converts integer/float types to strings during fetch */
PDO_ATTR_MAX_COLUMN_LEN, /* make database calculate maximum length of data found in a column */
PDO_ATTR_DEFAULT_FETCH_MODE, /* Set the default fetch mode */
PDO_ATTR_EMULATE_PREPARES, /* use query emulation rather than native */
PDO_ATTR_DEFAULT_STR_PARAM, /* set the default string parameter type (see the PDO::PARAM_STR_* magic flags) */
/* this defines the start of the range for driver specific options.
* Drivers should define their own attribute constants beginning with this
* value. */
PDO_ATTR_DRIVER_SPECIFIC = 1000
};
enum pdo_cursor_type {
PDO_CURSOR_FWDONLY, /* forward only cursor (default) */
PDO_CURSOR_SCROLL /* scrollable cursor */
};
/* SQL-92 SQLSTATE error codes.
The character string value returned for an SQLSTATE consists of a two-character
class value followed by a three-character subclass value. A class value of 01
indicates a warning and is accompanied by a return code of
SQL_SUCCESS_WITH_INFO.
Class values other than '01', except for the class 'IM',
indicate an error and are accompanied by a return code of SQL_ERROR. The class
'IM' is specific to warnings and errors that derive from the implementation of
ODBC itself.
The subclass value '000' in any class indicates that there is no
subclass for that SQLSTATE. The assignment of class and subclass values is
defined by SQL-92.
*/
typedef char pdo_error_type[6]; /* SQLSTATE */
#define PDO_ERR_NONE "00000"
enum pdo_error_mode {
PDO_ERRMODE_SILENT, /* just set error codes */
PDO_ERRMODE_WARNING, /* raise E_WARNING */
PDO_ERRMODE_EXCEPTION /* throw exceptions */
};
enum pdo_case_conversion {
PDO_CASE_NATURAL,
PDO_CASE_UPPER,
PDO_CASE_LOWER
};
/* oracle interop settings */
enum pdo_null_handling {
PDO_NULL_NATURAL = 0,
PDO_NULL_EMPTY_STRING = 1,
PDO_NULL_TO_STRING = 2
};
/* {{{ utils for reading attributes set as driver_options */
static inline zend_long pdo_attr_lval(zval *options, unsigned option_name, zend_long defval)
{
zval *v;
if (options && (v = zend_hash_index_find(Z_ARRVAL_P(options), option_name))) {
return zval_get_long(v);
}
return defval;
}
static inline zend_string *pdo_attr_strval(zval *options, unsigned option_name, zend_string *defval)
{
zval *v;
if (options && (v = zend_hash_index_find(Z_ARRVAL_P(options), option_name))) {
return zval_try_get_string(v);
}
return defval ? zend_string_copy(defval) : NULL;
}
/* }}} */
/* This structure is registered with PDO when a PDO driver extension is
* initialized */
typedef struct {
const char *driver_name;
size_t driver_name_len;
zend_ulong api_version; /* needs to be compatible with PDO */
#define PDO_DRIVER_HEADER(name) \
#name, sizeof(#name)-1, \
PDO_DRIVER_API
/* create driver specific portion of the database handle and stash it into
* the dbh. dbh contains the data source string and flags for this
* instance. You MUST respect dbh->is_persistent and pass that flag to
* pemalloc() for all allocations that are stored in the dbh or your instance
* data in the db, otherwise you will crash PHP when persistent connections
* are used.
*/
int (*db_handle_factory)(pdo_dbh_t *dbh, zval *driver_options);
} pdo_driver_t;
/* {{{ methods for a database handle */
/* close or otherwise disconnect the database */
typedef void (*pdo_dbh_close_func)(pdo_dbh_t *dbh);
/* prepare a statement and stash driver specific portion into stmt
* return true on success, false otherwise */
typedef bool (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, zend_string *sql, pdo_stmt_t *stmt, zval *driver_options);
/* execute a statement (that does not return a result set)
* Return -1 on failure, otherwise the number of affected rows */
typedef zend_long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const zend_string *sql);
/* quote a string */
typedef zend_string* (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype);
/* transaction related (beingTransaction(), commit, rollBack, inTransaction)
* Return true if currently inside a transaction, false otherwise. */
typedef bool (*pdo_dbh_txn_func)(pdo_dbh_t *dbh);
/* setting of attributes
* Return true on success and false in case of failure */
typedef bool (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, zend_long attr, zval *val);
/* return last insert id. NULL indicates error condition.
* name MIGHT be NULL */
typedef zend_string *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const zend_string *name);
/* Fetch error information.
* If stmt is not null, fetch information pertaining to the statement,
* otherwise fetch global error information.
* info is an initialized PHP array, if there are no messages leave it empty.
* The driver should add the following information to the array "info" in this order:
* - native error code
* - string representation of the error code ... any other optional driver
* specific data ...
* PDO takes care of normalizing the array. */
typedef void (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info);
/* fetching of attributes
* There are 3 return states:
* * -1 for errors while retrieving a valid attribute
* * 0 for attempting to retrieve an attribute which is not supported by the driver
* * any other value for success, *val must be set to the attribute value */
typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, zend_long attr, zval *val);
/* checking/pinging persistent connections; return SUCCESS if the connection
* is still alive and ready to be used, FAILURE otherwise.
* You may set this handler to NULL, which is equivalent to returning SUCCESS. */
typedef zend_result (*pdo_dbh_check_liveness_func)(pdo_dbh_t *dbh);
/* called at request end for each persistent dbh; this gives the driver
* the opportunity to safely release resources that only have per-request
* scope */
typedef void (*pdo_dbh_request_shutdown)(pdo_dbh_t *dbh);
/* Called when the PDO handle is scanned for GC. Should populate the get_gc buffer
* with any zvals in the driver_data that would be freed if the handle is destroyed. */
typedef void (*pdo_dbh_get_gc_func)(pdo_dbh_t *dbh, zend_get_gc_buffer *buffer);
/* for adding methods to the dbh or stmt objects
pointer to a list of driver specific functions. The convention is
to prefix the function names using the PDO driver name; this will
reduce the chance of collisions with future functionality in the
PDO class or in user code (they can extend the PDO object).
*/
enum {
PDO_DBH_DRIVER_METHOD_KIND_DBH = 0,
PDO_DBH_DRIVER_METHOD_KIND_STMT,
PDO_DBH_DRIVER_METHOD_KIND__MAX
};
typedef const zend_function_entry *(*pdo_dbh_get_driver_methods_func)(pdo_dbh_t *dbh, int kind);
struct pdo_dbh_methods {
pdo_dbh_close_func closer;
pdo_dbh_prepare_func preparer;
pdo_dbh_do_func doer;
pdo_dbh_quote_func quoter;
pdo_dbh_txn_func begin;
pdo_dbh_txn_func commit;
pdo_dbh_txn_func rollback;
pdo_dbh_set_attr_func set_attribute;
pdo_dbh_last_id_func last_id;
pdo_dbh_fetch_error_func fetch_err;
pdo_dbh_get_attr_func get_attribute;
pdo_dbh_check_liveness_func check_liveness;
pdo_dbh_get_driver_methods_func get_driver_methods;
pdo_dbh_request_shutdown persistent_shutdown;
/* if defined to NULL, PDO will use its internal transaction tracking state */
pdo_dbh_txn_func in_transaction;
pdo_dbh_get_gc_func get_gc;
};
/* }}} */
/* {{{ methods for a statement handle */
/* free the statement handle */
typedef int (*pdo_stmt_dtor_func)(pdo_stmt_t *stmt);
/* start the query */
typedef int (*pdo_stmt_execute_func)(pdo_stmt_t *stmt);
/* causes the next row in the set to be fetched; indicates if there are no
* more rows. The ori and offset params modify which row should be returned,
* if the stmt represents a scrollable cursor */
typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt,
enum pdo_fetch_orientation ori, zend_long offset);
/* queries information about the type of a column, by index (0 based).
* Driver should populate stmt->columns[colno] with appropriate info */
typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno);
/* Retrieves zval value of a column. If type is non-NULL, then this specifies the type which
* the user requested through bindColumn(). The driver does not need to check this argument,
* as PDO will perform any necessary conversions itself. However, it might be used to fetch
* a value more efficiently into the final type, or make the behavior dependent on the requested
* type. */
typedef int (*pdo_stmt_get_col_data_func)(
pdo_stmt_t *stmt, int colno, zval *result, enum pdo_param_type *type);
/* hook for bound params */
enum pdo_param_event {
PDO_PARAM_EVT_ALLOC,
PDO_PARAM_EVT_FREE,
PDO_PARAM_EVT_EXEC_PRE,
PDO_PARAM_EVT_EXEC_POST,
PDO_PARAM_EVT_FETCH_PRE,
PDO_PARAM_EVT_FETCH_POST,
PDO_PARAM_EVT_NORMALIZE
};
typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type);
/* setting of attributes */
typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, zend_long attr, zval *val);
/* fetching of attributes */
typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, zend_long attr, zval *val);
/* retrieves meta data for a numbered column.
* Returns SUCCESS/FAILURE.
* On SUCCESS, fill in return_value with an array with the following fields.
* If a particular field is not supported, then the driver simply does not add it to
* the array, so that scripts can use isset() to check for it.
*
* ### this is just a rough first cut, and subject to change ###
*
* these are added by PDO itself, based on data from the describe handler:
* name => the column name
* len => the length/size of the column
* precision => precision of the column
*
* pdo_type => an integer, one of the PDO_PARAM_XXX values
* scale => the floating point scale
* table => the table for that column
* type => a string representation of the type, mapped to the PHP equivalent type name
* native_type => a string representation of the type, native style, if different from
* the mapped name.
* flags => an array of flags including zero or more of the following:
* primary_key, not_null, unique_key, multiple_key, unsigned, auto_increment, blob
*
* Any driver specific data should be returned using a prefixed key or value.
* Eg: custom data for the mysql driver would use either
* 'mysql:foobar' => 'some data' // to add a new key to the array
* or
* 'flags' => array('not_null', 'mysql:some_flag'); // to add data to an existing key
*/
typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, zend_long colno, zval *return_value);
/* advances the statement to the next rowset of the batch.
* If it returns 1, PDO will tear down its idea of columns
* and meta data. If it returns 0, PDO will indicate an error
* to the caller. */
typedef int (*pdo_stmt_next_rowset_func)(pdo_stmt_t *stmt);
/* closes the active cursor on a statement, leaving the prepared
* statement ready for re-execution. Useful to explicitly state
* that you are done with a given rowset, without having to explicitly
* fetch all the rows. */
typedef int (*pdo_stmt_cursor_closer_func)(pdo_stmt_t *stmt);
struct pdo_stmt_methods {
pdo_stmt_dtor_func dtor;
pdo_stmt_execute_func executer;
pdo_stmt_fetch_func fetcher;
pdo_stmt_describe_col_func describer;
pdo_stmt_get_col_data_func get_col;
pdo_stmt_param_hook_func param_hook;
pdo_stmt_set_attr_func set_attribute;
pdo_stmt_get_attr_func get_attribute;
pdo_stmt_get_column_meta_func get_column_meta;
pdo_stmt_next_rowset_func next_rowset;
pdo_stmt_cursor_closer_func cursor_closer;
};
/* }}} */
enum pdo_placeholder_support {
PDO_PLACEHOLDER_NONE=0,
PDO_PLACEHOLDER_NAMED=1,
PDO_PLACEHOLDER_POSITIONAL=2
};
struct _pdo_dbh_t {
/* driver specific methods */
const struct pdo_dbh_methods *methods;
/* driver specific data */
void *driver_data;
/* credentials */
char *username, *password;
/* if true, then data stored and pointed at by this handle must all be
* persistently allocated */
unsigned is_persistent:1;
/* if true, driver should act as though a COMMIT were executed between
* each executed statement; otherwise, COMMIT must be carried out manually
* */
unsigned auto_commit:1;
/* if true, the handle has been closed and will not function anymore */
unsigned is_closed:1;
/* if true, the driver requires that memory be allocated explicitly for
* the columns that are returned */
unsigned alloc_own_columns:1;
/* if true, commit or rollBack is allowed to be called */
bool in_txn:1;
/* max length a single character can become after correct quoting */
unsigned max_escaped_char_length:3;
/* oracle compat; see enum pdo_null_handling */
unsigned oracle_nulls:2;
/* when set, convert int/floats to strings */
unsigned stringify:1;
/* bitmap for pdo_param_event(s) to skip in dispatch_param_event */
unsigned skip_param_evt:7;
/* the sum of the number of bits here and the bit fields preceding should
* equal 32 */
unsigned _reserved_flags:14;
/* data source string used to open this handle */
const char *data_source;
size_t data_source_len;
/* the global error code. */
pdo_error_type error_code;
enum pdo_error_mode error_mode;
enum pdo_case_conversion native_case, desired_case;
/* persistent hash key associated with this handle */
const char *persistent_id;
size_t persistent_id_len;
unsigned int refcount;
/* driver specific "class" methods for the dbh and stmt */
HashTable *cls_methods[PDO_DBH_DRIVER_METHOD_KIND__MAX];
pdo_driver_t *driver;
zend_class_entry *def_stmt_ce;
zval def_stmt_ctor_args;
/* when calling PDO::query(), we need to keep the error
* context from the statement around until we next clear it.
* This will allow us to report the correct error message
* when PDO::query() fails */
pdo_stmt_t *query_stmt;
zval query_stmt_zval;
/* defaults for fetches */
enum pdo_fetch_type default_fetch_type;
};
/* represents a connection to a database */
struct _pdo_dbh_object_t {
pdo_dbh_t *inner;
/* these items must appear in this order at the beginning of the
struct so that this can be cast as a zend_object. we need this
to allow the extending class to escape all the custom handlers
that PDO declares.
*/
zend_object std;
};
static inline pdo_dbh_t *php_pdo_dbh_fetch_inner(zend_object *obj) {
return (pdo_dbh_t *)(((pdo_dbh_object_t *)((char*)(obj) - XtOffsetOf(pdo_dbh_object_t, std)))->inner);
}
static inline pdo_dbh_object_t *php_pdo_dbh_fetch_object(zend_object *obj) {
return (pdo_dbh_object_t *)((char*)(obj) - XtOffsetOf(pdo_dbh_object_t, std));
}
#define Z_PDO_DBH_P(zv) php_pdo_dbh_fetch_inner(Z_OBJ_P((zv)))
#define Z_PDO_OBJECT_P(zv) php_pdo_dbh_fetch_object(Z_OBJ_P((zv)))
/* describes a column */
struct pdo_column_data {
zend_string *name;
size_t maxlen;
zend_ulong precision;
};
/* describes a bound parameter */
struct pdo_bound_param_data {
zval parameter; /* the variable itself */
zval driver_params; /* optional parameter(s) for the driver */
zend_long paramno; /* if -1, then it has a name, and we don't know the index *yet* */
zend_string *name;
zend_long max_value_len; /* as a hint for pre-allocation */
void *driver_data;
pdo_stmt_t *stmt; /* for convenience in dtor */
enum pdo_param_type param_type; /* desired or suggested variable type */
int is_param; /* parameter or column ? */
};
/* represents a prepared statement */
struct _pdo_stmt_t {
/* driver specifics */
const struct pdo_stmt_methods *methods;
void *driver_data;
/* if true, we've already successfully executed this statement at least
* once */
unsigned executed:1;
/* if true, the statement supports placeholders and can implement
* bindParam() for its prepared statements, if false, PDO should
* emulate prepare and bind on its behalf */
unsigned supports_placeholders:2;
unsigned _reserved:29;
/* the number of columns in the result set; not valid until after
* the statement has been executed at least once. In some cases, might
* not be valid until fetch (at the driver level) has been called at least once.
* */
int column_count;
struct pdo_column_data *columns;
/* we want to keep the dbh alive while we live, so we own a reference */
zval database_object_handle;
pdo_dbh_t *dbh;
/* keep track of bound input parameters. Some drivers support
* input/output parameters, but you can't rely on that working */
HashTable *bound_params;
/* When rewriting from named to positional, this maps positions to names */
HashTable *bound_param_map;
/* keep track of PHP variables bound to named (or positional) columns
* in the result set */
HashTable *bound_columns;
/* not always meaningful */
zend_long row_count;
/* used to hold the statement's current query */
zend_string *query_string;
/* the copy of the query with expanded binds ONLY for emulated-prepare drivers */
zend_string *active_query_string;
/* the cursor specific error code. */
pdo_error_type error_code;
/* for lazy fetches, we always return the same lazy object handle.
* Let's keep it here. */
zval lazy_object_ref;
zend_ulong refcount;
/* defaults for fetches */
enum pdo_fetch_type default_fetch_type;
union {
int column;
struct {
zval ctor_args; /* freed */
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval retval;
zend_class_entry *ce;
} cls;
struct {
zval fetch_args; /* freed */
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval object;
zval function;
zval *values; /* freed */
} func;
zval into;
} fetch;
/* used by the query parser for driver specific
* parameter naming (see pgsql driver for example) */
const char *named_rewrite_template;
/* these items must appear in this order at the beginning of the
struct so that this can be cast as a zend_object. we need this
to allow the extending class to escape all the custom handlers
that PDO declares.
*/
zend_object std;
};
static inline pdo_stmt_t *php_pdo_stmt_fetch_object(zend_object *obj) {
return (pdo_stmt_t *)((char*)(obj) - XtOffsetOf(pdo_stmt_t, std));
}
#define Z_PDO_STMT_P(zv) php_pdo_stmt_fetch_object(Z_OBJ_P((zv)))
struct _pdo_row_t {
zend_object std;
pdo_stmt_t *stmt;
};
/* Call this in MINIT to register the PDO driver.
* Registering the driver might fail and should be reported accordingly in MINIT. */
PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver);
/* call this in MSHUTDOWN to unregister your PDO driver */
PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver);
/* For the convenience of drivers, this function will parse a data source
* string, of the form "name=value; name2=value2" and populate variables
* according to the data you pass in and array of pdo_data_src_parser structures */
struct pdo_data_src_parser {
const char *optname;
char *optval;
int freeme;
};
PDO_API int php_pdo_parse_data_source(const char *data_source,
zend_ulong data_source_len, struct pdo_data_src_parser *parsed,
int nparams);
PDO_API zend_class_entry *php_pdo_get_dbh_ce(void);
PDO_API zend_class_entry *php_pdo_get_exception(void);
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, zend_string *inquery, zend_string **outquery);
PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
pdo_error_type sqlstate, const char *supp);
PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh);
PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh);
PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt);
PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count);
/* Normalization for fetching long param for driver attributes */
PDO_API bool pdo_get_long_param(zend_long *lval, zval *value);
PDO_API bool pdo_get_bool_param(bool *bval, zval *value);
PDO_API void pdo_throw_exception(unsigned int driver_errcode, char *driver_errmsg, pdo_error_type *pdo_error);
#endif /* PHP_PDO_DRIVER_H */

View File

@ -0,0 +1,35 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PDO_ERROR_H
#define PHP_PDO_ERROR_H
#include "php_pdo_driver.h"
PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt);
#define PDO_DBH_CLEAR_ERR() do { \
strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
if (dbh->query_stmt) { \
dbh->query_stmt = NULL; \
zval_ptr_dtor(&dbh->query_stmt_zval); \
} \
} while (0)
#define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE)
#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL); }
#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt); }
#endif /* PHP_PDO_ERROR_H */

View File

@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| phar php single-file executable PHP extension |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Gregory Beaver <cellog@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PHAR_H
#define PHP_PHAR_H
#define PHP_PHAR_VERSION PHP_VERSION
#include "ext/standard/basic_functions.h"
extern zend_module_entry phar_module_entry;
#define phpext_phar_ptr &phar_module_entry
#ifdef PHP_WIN32
#define PHP_PHAR_API __declspec(dllexport)
#else
#define PHP_PHAR_API PHPAPI
#endif
PHP_PHAR_API int phar_resolve_alias(char *alias, size_t alias_len, char **filename, size_t *filename_len);
#endif /* PHP_PHAR_H */

View File

@ -0,0 +1,355 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Zeev Suraski <zeev@php.net> |
| Sascha Schumann <sascha@schumann.cx> |
| Pedro Melo <melo@ip.pt> |
| Sterling Hughes <sterling@php.net> |
| Sammy Kaye Powers <me@sammyk.me> |
| Go Kudo <zeriyoshi@php.net> |
| |
| Based on code from: Richard J. Wagner <rjwagner@writeme.com> |
| Makoto Matsumoto <matumoto@math.keio.ac.jp> |
| Takuji Nishimura |
| Shawn Cokus <Cokus@math.washington.edu> |
| David Blackman |
| Sebastiano Vigna <vigna@acm.org> |
| Melissa O'Neill <oneill@pcg-random.org> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_RANDOM_H
# define PHP_RANDOM_H
# include "php.h"
PHPAPI double php_combined_lcg(void);
/*
* A bit of tricky math here. We want to avoid using a modulus because
* that simply tosses the high-order bits and might skew the distribution
* of random values over the range. Instead we map the range directly.
*
* We need to map the range from 0...M evenly to the range a...b
* Let n = the random number and n' = the mapped random number
*
* Then we have: n' = a + n(b-a)/M
*
* We have a problem here in that only n==M will get mapped to b which
* means the chances of getting b is much much less than getting any of
* the other values in the range. We can fix this by increasing our range
* artificially and using:
*
* n' = a + n(b-a+1)/M
*
* Now we only have a problem if n==M which would cause us to produce a
* number of b+1 which would be bad. So we bump M up by one to make sure
* this will never happen, and the final algorithm looks like this:
*
* n' = a + n(b-a+1)/(M+1)
*
* -RL
*/
# define RAND_RANGE_BADSCALING(__n, __min, __max, __tmax) \
(__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
# ifdef PHP_WIN32
# define GENERATE_SEED() (((zend_long) ((zend_ulong) time(NULL) * (zend_ulong) GetCurrentProcessId())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
# else
# define GENERATE_SEED() (((zend_long) ((zend_ulong) time(NULL) * (zend_ulong) getpid())) ^ ((zend_long) (1000000.0 * php_combined_lcg())))
# endif
# define PHP_MT_RAND_MAX ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */
# define MT_RAND_MT19937 0
# define MT_RAND_PHP 1
# define MT_N (624)
#define PHP_RANDOM_RANGE_ATTEMPTS (50)
PHPAPI void php_mt_srand(uint32_t seed);
PHPAPI uint32_t php_mt_rand(void);
PHPAPI zend_long php_mt_rand_range(zend_long min, zend_long max);
PHPAPI zend_long php_mt_rand_common(zend_long min, zend_long max);
# ifndef RAND_MAX
# define RAND_MAX PHP_MT_RAND_MAX
# endif
# define PHP_RAND_MAX PHP_MT_RAND_MAX
PHPAPI void php_srand(zend_long seed);
PHPAPI zend_long php_rand(void);
# if !defined(__SIZEOF_INT128__) || defined(PHP_RANDOM_FORCE_EMULATE_128)
typedef struct _php_random_uint128_t {
uint64_t hi;
uint64_t lo;
} php_random_uint128_t;
static inline uint64_t php_random_uint128_hi(php_random_uint128_t num)
{
return num.hi;
}
static inline uint64_t php_random_uint128_lo(php_random_uint128_t num)
{
return num.lo;
}
static inline php_random_uint128_t php_random_uint128_constant(uint64_t hi, uint64_t lo)
{
php_random_uint128_t r;
r.hi = hi;
r.lo = lo;
return r;
}
static inline php_random_uint128_t php_random_uint128_add(php_random_uint128_t num1, php_random_uint128_t num2)
{
php_random_uint128_t r;
r.lo = (num1.lo + num2.lo);
r.hi = (num1.hi + num2.hi + (r.lo < num1.lo));
return r;
}
static inline php_random_uint128_t php_random_uint128_multiply(php_random_uint128_t num1, php_random_uint128_t num2)
{
php_random_uint128_t r;
const uint64_t
x0 = num1.lo & 0xffffffffULL,
x1 = num1.lo >> 32,
y0 = num2.lo & 0xffffffffULL,
y1 = num2.lo >> 32,
z0 = (((x1 * y0) + (x0 * y0 >> 32)) & 0xffffffffULL) + x0 * y1;
r.hi = num1.hi * num2.lo + num1.lo * num2.hi;
r.lo = num1.lo * num2.lo;
r.hi += x1 * y1 + ((x1 * y0 + (x0 * y0 >> 32)) >> 32) + (z0 >> 32);
return r;
}
static inline uint64_t php_random_pcgoneseq128xslrr64_rotr64(php_random_uint128_t num)
{
const uint64_t
v = (num.hi ^ num.lo),
s = num.hi >> 58U;
return (v >> s) | (v << ((-s) & 63));
}
# else
typedef __uint128_t php_random_uint128_t;
static inline uint64_t php_random_uint128_hi(php_random_uint128_t num)
{
return (uint64_t) (num >> 64);
}
static inline uint64_t php_random_uint128_lo(php_random_uint128_t num)
{
return (uint64_t) num;
}
static inline php_random_uint128_t php_random_uint128_constant(uint64_t hi, uint64_t lo)
{
php_random_uint128_t r;
r = ((php_random_uint128_t) hi << 64) + lo;
return r;
}
static inline php_random_uint128_t php_random_uint128_add(php_random_uint128_t num1, php_random_uint128_t num2)
{
return num1 + num2;
}
static inline php_random_uint128_t php_random_uint128_multiply(php_random_uint128_t num1, php_random_uint128_t num2)
{
return num1 * num2;
}
static inline uint64_t php_random_pcgoneseq128xslrr64_rotr64(php_random_uint128_t num)
{
const uint64_t
v = ((uint64_t) (num >> 64U)) ^ (uint64_t) num,
s = num >> 122U;
return (v >> s) | (v << ((-s) & 63));
}
# endif
PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw);
PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw);
static inline zend_result php_random_bytes_throw(void *bytes, size_t size)
{
return php_random_bytes(bytes, size, true);
}
static inline zend_result php_random_bytes_silent(void *bytes, size_t size)
{
return php_random_bytes(bytes, size, false);
}
static inline zend_result php_random_int_throw(zend_long min, zend_long max, zend_long *result)
{
return php_random_int(min, max, result, true);
}
static inline zend_result php_random_int_silent(zend_long min, zend_long max, zend_long *result)
{
return php_random_int(min, max, result, false);
}
typedef struct _php_random_status_ {
size_t last_generated_size;
void *state;
} php_random_status;
typedef struct _php_random_status_state_combinedlcg {
int32_t state[2];
} php_random_status_state_combinedlcg;
typedef struct _php_random_status_state_mt19937 {
uint32_t state[MT_N];
uint32_t count;
uint8_t mode;
} php_random_status_state_mt19937;
typedef struct _php_random_status_state_pcgoneseq128xslrr64 {
php_random_uint128_t state;
} php_random_status_state_pcgoneseq128xslrr64;
typedef struct _php_random_status_state_xoshiro256starstar {
uint64_t state[4];
} php_random_status_state_xoshiro256starstar;
typedef struct _php_random_status_state_user {
zend_object *object;
zend_function *generate_method;
} php_random_status_state_user;
typedef struct _php_random_algo {
const size_t generate_size;
const size_t state_size;
void (*seed)(php_random_status *status, uint64_t seed);
uint64_t (*generate)(php_random_status *status);
zend_long (*range)(php_random_status *status, zend_long min, zend_long max);
bool (*serialize)(php_random_status *status, HashTable *data);
bool (*unserialize)(php_random_status *status, HashTable *data);
} php_random_algo;
extern PHPAPI const php_random_algo php_random_algo_combinedlcg;
extern PHPAPI const php_random_algo php_random_algo_mt19937;
extern PHPAPI const php_random_algo php_random_algo_pcgoneseq128xslrr64;
extern PHPAPI const php_random_algo php_random_algo_xoshiro256starstar;
extern PHPAPI const php_random_algo php_random_algo_secure;
extern PHPAPI const php_random_algo php_random_algo_user;
typedef struct _php_random_engine {
const php_random_algo *algo;
php_random_status *status;
zend_object std;
} php_random_engine;
typedef struct _php_random_randomizer {
const php_random_algo *algo;
php_random_status *status;
bool is_userland_algo;
zend_object std;
} php_random_randomizer;
extern PHPAPI zend_class_entry *random_ce_Random_Engine;
extern PHPAPI zend_class_entry *random_ce_Random_CryptoSafeEngine;
extern PHPAPI zend_class_entry *random_ce_Random_RandomError;
extern PHPAPI zend_class_entry *random_ce_Random_BrokenRandomEngineError;
extern PHPAPI zend_class_entry *random_ce_Random_RandomException;
extern PHPAPI zend_class_entry *random_ce_Random_Engine_PcgOneseq128XslRr64;
extern PHPAPI zend_class_entry *random_ce_Random_Engine_Mt19937;
extern PHPAPI zend_class_entry *random_ce_Random_Engine_Xoshiro256StarStar;
extern PHPAPI zend_class_entry *random_ce_Random_Engine_Secure;
extern PHPAPI zend_class_entry *random_ce_Random_Randomizer;
extern PHPAPI zend_class_entry *random_ce_Random_IntervalBoundary;
static inline php_random_engine *php_random_engine_from_obj(zend_object *object) {
return (php_random_engine *)((char *)(object) - XtOffsetOf(php_random_engine, std));
}
static inline php_random_randomizer *php_random_randomizer_from_obj(zend_object *object) {
return (php_random_randomizer *)((char *)(object) - XtOffsetOf(php_random_randomizer, std));
}
# define Z_RANDOM_ENGINE_P(zval) php_random_engine_from_obj(Z_OBJ_P(zval))
# define Z_RANDOM_RANDOMIZER_P(zval) php_random_randomizer_from_obj(Z_OBJ_P(zval));
PHPAPI php_random_status *php_random_status_alloc(const php_random_algo *algo, const bool persistent);
PHPAPI php_random_status *php_random_status_copy(const php_random_algo *algo, php_random_status *old_status, php_random_status *new_status);
PHPAPI void php_random_status_free(php_random_status *status, const bool persistent);
PHPAPI php_random_engine *php_random_engine_common_init(zend_class_entry *ce, zend_object_handlers *handlers, const php_random_algo *algo);
PHPAPI void php_random_engine_common_free_object(zend_object *object);
PHPAPI zend_object *php_random_engine_common_clone_object(zend_object *object);
PHPAPI uint32_t php_random_range32(const php_random_algo *algo, php_random_status *status, uint32_t umax);
PHPAPI uint64_t php_random_range64(const php_random_algo *algo, php_random_status *status, uint64_t umax);
PHPAPI zend_long php_random_range(const php_random_algo *algo, php_random_status *status, zend_long min, zend_long max);
PHPAPI const php_random_algo *php_random_default_algo(void);
PHPAPI php_random_status *php_random_default_status(void);
PHPAPI zend_string *php_random_bin2hex_le(const void *ptr, const size_t len);
PHPAPI bool php_random_hex2bin_le(zend_string *hexstr, void *dest);
PHPAPI void php_random_combinedlcg_seed_default(php_random_status_state_combinedlcg *state);
PHPAPI void php_random_mt19937_seed_default(php_random_status_state_mt19937 *state);
PHPAPI void php_random_pcgoneseq128xslrr64_advance(php_random_status_state_pcgoneseq128xslrr64 *state, uint64_t advance);
PHPAPI void php_random_xoshiro256starstar_jump(php_random_status_state_xoshiro256starstar *state);
PHPAPI void php_random_xoshiro256starstar_jump_long(php_random_status_state_xoshiro256starstar *state);
PHPAPI double php_random_gammasection_closed_open(const php_random_algo *algo, php_random_status *status, double min, double max);
PHPAPI double php_random_gammasection_closed_closed(const php_random_algo *algo, php_random_status *status, double min, double max);
PHPAPI double php_random_gammasection_open_closed(const php_random_algo *algo, php_random_status *status, double min, double max);
PHPAPI double php_random_gammasection_open_open(const php_random_algo *algo, php_random_status *status, double min, double max);
extern zend_module_entry random_module_entry;
# define phpext_random_ptr &random_module_entry
PHP_MINIT_FUNCTION(random);
PHP_MSHUTDOWN_FUNCTION(random);
PHP_RINIT_FUNCTION(random);
ZEND_BEGIN_MODULE_GLOBALS(random)
php_random_status *combined_lcg;
bool combined_lcg_seeded;
php_random_status *mt19937;
bool mt19937_seeded;
int random_fd;
ZEND_END_MODULE_GLOBALS(random)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(random)
# define RANDOM_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(random, v)
#endif /* PHP_RANDOM_H */

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef MOD_FILES_H
#define MOD_FILES_H
extern const ps_module ps_mod_files;
#define ps_files_ptr &ps_mod_files
PS_FUNCS_UPDATE_TIMESTAMP(files);
#endif

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef MOD_USER_H
#define MOD_USER_H
extern const ps_module ps_mod_user;
#define ps_user_ptr &ps_mod_user
PS_FUNCS_UPDATE_TIMESTAMP(user);
#endif

View File

@ -0,0 +1,323 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SESSION_H
#define PHP_SESSION_H
#include "ext/standard/php_var.h"
#include "ext/hash/php_hash.h"
#define PHP_SESSION_API 20161017
#include "php_version.h"
#define PHP_SESSION_VERSION PHP_VERSION
/* save handler macros */
#define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name
#define PS_CLOSE_ARGS void **mod_data
#define PS_READ_ARGS void **mod_data, zend_string *key, zend_string **val, zend_long maxlifetime
#define PS_WRITE_ARGS void **mod_data, zend_string *key, zend_string *val, zend_long maxlifetime
#define PS_DESTROY_ARGS void **mod_data, zend_string *key
#define PS_GC_ARGS void **mod_data, zend_long maxlifetime, zend_long *nrdels
#define PS_CREATE_SID_ARGS void **mod_data
#define PS_VALIDATE_SID_ARGS void **mod_data, zend_string *key
#define PS_UPDATE_TIMESTAMP_ARGS void **mod_data, zend_string *key, zend_string *val, zend_long maxlifetime
typedef struct ps_module_struct {
const char *s_name;
zend_result (*s_open)(PS_OPEN_ARGS);
zend_result (*s_close)(PS_CLOSE_ARGS);
zend_result (*s_read)(PS_READ_ARGS);
zend_result (*s_write)(PS_WRITE_ARGS);
zend_result (*s_destroy)(PS_DESTROY_ARGS);
zend_long (*s_gc)(PS_GC_ARGS);
zend_string *(*s_create_sid)(PS_CREATE_SID_ARGS);
zend_result (*s_validate_sid)(PS_VALIDATE_SID_ARGS);
zend_result (*s_update_timestamp)(PS_UPDATE_TIMESTAMP_ARGS);
} ps_module;
#define PS_GET_MOD_DATA() *mod_data
#define PS_SET_MOD_DATA(a) *mod_data = (a)
#define PS_OPEN_FUNC(x) zend_result ps_open_##x(PS_OPEN_ARGS)
#define PS_CLOSE_FUNC(x) zend_result ps_close_##x(PS_CLOSE_ARGS)
#define PS_READ_FUNC(x) zend_result ps_read_##x(PS_READ_ARGS)
#define PS_WRITE_FUNC(x) zend_result ps_write_##x(PS_WRITE_ARGS)
#define PS_DESTROY_FUNC(x) zend_result ps_delete_##x(PS_DESTROY_ARGS)
#define PS_GC_FUNC(x) zend_long ps_gc_##x(PS_GC_ARGS)
#define PS_CREATE_SID_FUNC(x) zend_string *ps_create_sid_##x(PS_CREATE_SID_ARGS)
#define PS_VALIDATE_SID_FUNC(x) zend_result ps_validate_sid_##x(PS_VALIDATE_SID_ARGS)
#define PS_UPDATE_TIMESTAMP_FUNC(x) zend_result ps_update_timestamp_##x(PS_UPDATE_TIMESTAMP_ARGS)
/* Legacy save handler module definitions */
#define PS_FUNCS(x) \
PS_OPEN_FUNC(x); \
PS_CLOSE_FUNC(x); \
PS_READ_FUNC(x); \
PS_WRITE_FUNC(x); \
PS_DESTROY_FUNC(x); \
PS_GC_FUNC(x); \
PS_CREATE_SID_FUNC(x)
#define PS_MOD(x) \
#x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \
ps_delete_##x, ps_gc_##x, php_session_create_id, \
php_session_validate_sid, php_session_update_timestamp
/* Legacy SID creation enabled save handler module definitions */
#define PS_FUNCS_SID(x) \
PS_OPEN_FUNC(x); \
PS_CLOSE_FUNC(x); \
PS_READ_FUNC(x); \
PS_WRITE_FUNC(x); \
PS_DESTROY_FUNC(x); \
PS_GC_FUNC(x); \
PS_CREATE_SID_FUNC(x); \
PS_VALIDATE_SID_FUNC(x); \
PS_UPDATE_TIMESTAMP_FUNC(x);
#define PS_MOD_SID(x) \
#x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \
ps_delete_##x, ps_gc_##x, ps_create_sid_##x, \
php_session_validate_sid, php_session_update_timestamp
/* Update timestamp enabled save handler module definitions
New save handlers should use this API */
#define PS_FUNCS_UPDATE_TIMESTAMP(x) \
PS_OPEN_FUNC(x); \
PS_CLOSE_FUNC(x); \
PS_READ_FUNC(x); \
PS_WRITE_FUNC(x); \
PS_DESTROY_FUNC(x); \
PS_GC_FUNC(x); \
PS_CREATE_SID_FUNC(x); \
PS_VALIDATE_SID_FUNC(x); \
PS_UPDATE_TIMESTAMP_FUNC(x);
#define PS_MOD_UPDATE_TIMESTAMP(x) \
#x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \
ps_delete_##x, ps_gc_##x, ps_create_sid_##x, \
ps_validate_sid_##x, ps_update_timestamp_##x
typedef enum {
php_session_disabled,
php_session_none,
php_session_active
} php_session_status;
typedef struct _php_session_rfc1867_progress {
size_t sname_len;
zval sid;
smart_str key;
zend_long update_step;
zend_long next_update;
double next_update_time;
bool cancel_upload;
bool apply_trans_sid;
size_t content_length;
zval data; /* the array exported to session data */
zval *post_bytes_processed; /* data["bytes_processed"] */
zval files; /* data["files"] array */
zval current_file; /* array of currently uploading file */
zval *current_file_bytes_processed;
} php_session_rfc1867_progress;
typedef struct _php_ps_globals {
char *save_path;
char *session_name;
zend_string *id;
char *extern_referer_chk;
char *cache_limiter;
zend_long cookie_lifetime;
char *cookie_path;
char *cookie_domain;
bool cookie_secure;
bool cookie_httponly;
char *cookie_samesite;
const ps_module *mod;
const ps_module *default_mod;
void *mod_data;
php_session_status session_status;
zend_string *session_started_filename;
uint32_t session_started_lineno;
zend_long gc_probability;
zend_long gc_divisor;
zend_long gc_maxlifetime;
int module_number;
zend_long cache_expire;
struct {
zval ps_open;
zval ps_close;
zval ps_read;
zval ps_write;
zval ps_destroy;
zval ps_gc;
zval ps_create_sid;
zval ps_validate_sid;
zval ps_update_timestamp;
} mod_user_names;
bool mod_user_implemented;
bool mod_user_is_open;
zend_string *mod_user_class_name;
const struct ps_serializer_struct *serializer;
zval http_session_vars;
bool auto_start;
bool use_cookies;
bool use_only_cookies;
bool use_trans_sid; /* contains the INI value of whether to use trans-sid */
zend_long sid_length;
zend_long sid_bits_per_character;
bool send_cookie;
bool define_sid;
php_session_rfc1867_progress *rfc1867_progress;
bool rfc1867_enabled; /* session.upload_progress.enabled */
bool rfc1867_cleanup; /* session.upload_progress.cleanup */
char *rfc1867_prefix; /* session.upload_progress.prefix */
char *rfc1867_name; /* session.upload_progress.name */
zend_long rfc1867_freq; /* session.upload_progress.freq */
double rfc1867_min_freq; /* session.upload_progress.min_freq */
bool use_strict_mode; /* whether or not PHP accepts unknown session ids */
bool lazy_write; /* omit session write when it is possible */
bool in_save_handler; /* state if session is in save handler or not */
bool set_handler; /* state if session module i setting handler or not */
zend_string *session_vars; /* serialized original session data */
} php_ps_globals;
typedef php_ps_globals zend_ps_globals;
extern zend_module_entry session_module_entry;
#define phpext_session_ptr &session_module_entry
#ifdef ZTS
#define PS(v) ZEND_TSRMG(ps_globals_id, php_ps_globals *, v)
#ifdef COMPILE_DL_SESSION
ZEND_TSRMLS_CACHE_EXTERN()
#endif
#else
#define PS(v) (ps_globals.v)
#endif
#define PS_SERIALIZER_ENCODE_ARGS void
#define PS_SERIALIZER_DECODE_ARGS const char *val, size_t vallen
typedef struct ps_serializer_struct {
const char *name;
zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS);
zend_result (*decode)(PS_SERIALIZER_DECODE_ARGS);
} ps_serializer;
#define PS_SERIALIZER_ENCODE_NAME(x) ps_srlzr_encode_##x
#define PS_SERIALIZER_DECODE_NAME(x) ps_srlzr_decode_##x
#define PS_SERIALIZER_ENCODE_FUNC(x) \
zend_string *PS_SERIALIZER_ENCODE_NAME(x)(PS_SERIALIZER_ENCODE_ARGS)
#define PS_SERIALIZER_DECODE_FUNC(x) \
zend_result PS_SERIALIZER_DECODE_NAME(x)(PS_SERIALIZER_DECODE_ARGS)
#define PS_SERIALIZER_FUNCS(x) \
PS_SERIALIZER_ENCODE_FUNC(x); \
PS_SERIALIZER_DECODE_FUNC(x)
#define PS_SERIALIZER_ENTRY(x) \
{ #x, PS_SERIALIZER_ENCODE_NAME(x), PS_SERIALIZER_DECODE_NAME(x) }
/* default create id function */
PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS);
/* Dummy PS module functions */
PHPAPI zend_result php_session_validate_sid(PS_VALIDATE_SID_ARGS);
PHPAPI zend_result php_session_update_timestamp(PS_UPDATE_TIMESTAMP_ARGS);
PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len);
PHPAPI zend_result php_session_destroy(void);
PHPAPI void php_add_session_var(zend_string *name);
PHPAPI zval *php_set_session_var(zend_string *name, zval *state_val, php_unserialize_data_t *var_hash);
PHPAPI zval *php_get_session_var(zend_string *name);
PHPAPI zend_result php_session_register_module(const ps_module *);
PHPAPI zend_result php_session_register_serializer(const char *name,
zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS),
zend_result (*decode)(PS_SERIALIZER_DECODE_ARGS));
PHPAPI zend_result php_session_start(void);
PHPAPI zend_result php_session_flush(int write);
PHPAPI const ps_module *_php_find_ps_module(const char *name);
PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name);
PHPAPI zend_result php_session_valid_key(const char *key);
PHPAPI zend_result php_session_reset_id(void);
#define PS_ADD_VARL(name) do { \
php_add_session_var(name); \
} while (0)
#define PS_ADD_VAR(name) PS_ADD_VARL(name)
#define PS_DEL_VARL(name) do { \
if (!Z_ISNULL(PS(http_session_vars))) { \
zend_hash_del(Z_ARRVAL(PS(http_session_vars)), name); \
} \
} while (0)
#define PS_ENCODE_VARS \
zend_string *key; \
zend_ulong num_key; \
zval *struc;
#define PS_ENCODE_LOOP(code) do { \
HashTable *_ht = Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))); \
ZEND_HASH_FOREACH_KEY(_ht, num_key, key) { \
if (key == NULL) { \
php_error_docref(NULL, E_WARNING, \
"Skipping numeric key " ZEND_LONG_FMT, num_key);\
continue; \
} \
if ((struc = php_get_session_var(key))) { \
code; \
} \
} ZEND_HASH_FOREACH_END(); \
} while(0)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(ps)
void php_session_auto_start(void *data);
extern PHPAPI zend_class_entry *php_session_class_entry;
extern PHPAPI zend_class_entry *php_session_iface_entry;
extern PHPAPI zend_class_entry *php_session_id_iface_entry;
extern PHPAPI zend_class_entry *php_session_update_timestamp_iface_entry;
extern PHP_METHOD(SessionHandler, open);
extern PHP_METHOD(SessionHandler, close);
extern PHP_METHOD(SessionHandler, read);
extern PHP_METHOD(SessionHandler, write);
extern PHP_METHOD(SessionHandler, destroy);
extern PHP_METHOD(SessionHandler, gc);
extern PHP_METHOD(SessionHandler, create_sid);
#endif

View File

@ -0,0 +1,85 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SIMPLEXML_H
#define PHP_SIMPLEXML_H
extern zend_module_entry simplexml_module_entry;
#define phpext_simplexml_ptr &simplexml_module_entry
#include "php_version.h"
#define PHP_SIMPLEXML_VERSION PHP_VERSION
#ifdef ZTS
#include "TSRM.h"
#endif
#include "ext/libxml/php_libxml.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/tree.h>
#include <libxml/uri.h>
#include <libxml/xmlerror.h>
#include <libxml/xinclude.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/xpointer.h>
#include <libxml/xmlschemas.h>
PHP_MINIT_FUNCTION(simplexml);
PHP_MSHUTDOWN_FUNCTION(simplexml);
PHP_MINFO_FUNCTION(simplexml);
typedef enum {
SXE_ITER_NONE = 0,
SXE_ITER_ELEMENT = 1,
SXE_ITER_CHILD = 2,
SXE_ITER_ATTRLIST = 3
} SXE_ITER;
typedef struct {
php_libxml_node_ptr *node;
php_libxml_ref_obj *document;
HashTable *properties;
xmlXPathContextPtr xpath;
struct {
xmlChar *name;
xmlChar *nsprefix;
int isprefix;
SXE_ITER type;
zval data;
} iter;
zval tmp;
zend_function *fptr_count;
zend_object zo;
} php_sxe_object;
#ifdef PHP_WIN32
# ifdef PHP_SIMPLEXML_EXPORTS
# define PHP_SXE_API __declspec(dllexport)
# else
# define PHP_SXE_API __declspec(dllimport)
# endif
#else
# define PHP_SXE_API ZEND_API
#endif
extern PHP_SXE_API zend_class_entry *ce_SimpleXMLIterator;
extern PHP_SXE_API zend_class_entry *ce_SimpleXMLElement;
PHP_SXE_API zend_class_entry *sxe_get_element_class_entry(void);
#endif

View File

@ -0,0 +1,55 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sterling Hughes <sterling@php.net> |
| Marcus Boerger <helly@php.net> |
| Rob Richards <rrichards@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SIMPLEXML_EXPORTS_H
#define PHP_SIMPLEXML_EXPORTS_H
#include "php_simplexml.h"
#define SKIP_TEXT(__p) \
if ((__p)->type == XML_TEXT_NODE) { \
goto next_iter; \
}
#define GET_NODE(__s, __n) { \
if ((__s)->node && (__s)->node->node) { \
__n = (__s)->node->node; \
} else { \
__n = NULL; \
zend_throw_error(NULL, "SimpleXMLElement is not properly initialized"); \
} \
}
PHP_SXE_API zend_object *sxe_object_new(zend_class_entry *ce);
static inline php_sxe_object *php_sxe_fetch_object(zend_object *obj) /* {{{ */ {
return (php_sxe_object *)((char*)(obj) - XtOffsetOf(php_sxe_object, zo));
}
/* }}} */
#define Z_SXEOBJ_P(zv) php_sxe_fetch_object(Z_OBJ_P((zv)))
typedef struct {
zend_object_iterator intern;
php_sxe_object *sxe;
} php_sxe_iterator;
PHP_SXE_API void php_sxe_rewind_iterator(php_sxe_object *sxe);
PHP_SXE_API void php_sxe_move_forward_iterator(php_sxe_object *sxe);
#endif /* PHP_SIMPLEXML_EXPORTS_H */

View File

@ -0,0 +1,55 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SPL_H
#define PHP_SPL_H
#include "php.h"
#include <stdarg.h>
#define PHP_SPL_VERSION PHP_VERSION
extern zend_module_entry spl_module_entry;
#define phpext_spl_ptr &spl_module_entry
#ifdef PHP_WIN32
# ifdef SPL_EXPORTS
# define SPL_API __declspec(dllexport)
# elif defined(COMPILE_DL_SPL)
# define SPL_API __declspec(dllimport)
# else
# define SPL_API /* nothing */
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define SPL_API __attribute__ ((visibility("default")))
#else
# define SPL_API
#endif
#if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL)
#undef phpext_spl
#define phpext_spl NULL
#endif
PHP_MINIT_FUNCTION(spl);
PHP_MSHUTDOWN_FUNCTION(spl);
PHP_RINIT_FUNCTION(spl);
PHP_RSHUTDOWN_FUNCTION(spl);
PHP_MINFO_FUNCTION(spl);
PHPAPI zend_string *php_spl_object_hash(zend_object *obj);
#endif /* PHP_SPL_H */

View File

@ -0,0 +1,45 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_ARRAY_H
#define SPL_ARRAY_H
#include "php.h"
#include "php_spl.h"
#include "spl_iterators.h"
#define SPL_ARRAY_STD_PROP_LIST 0x00000001
#define SPL_ARRAY_ARRAY_AS_PROPS 0x00000002
#define SPL_ARRAY_CHILD_ARRAYS_ONLY 0x00000004
#define SPL_ARRAY_IS_SELF 0x01000000
#define SPL_ARRAY_USE_OTHER 0x02000000
#define SPL_ARRAY_INT_MASK 0xFFFF0000
#define SPL_ARRAY_CLONE_MASK 0x0100FFFF
#define SPL_ARRAY_METHOD_NO_ARG 0
#define SPL_ARRAY_METHOD_CALLBACK_ARG 1
#define SPL_ARRAY_METHOD_SORT_FLAGS_ARG 2
extern PHPAPI zend_class_entry *spl_ce_ArrayObject;
extern PHPAPI zend_class_entry *spl_ce_ArrayIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator;
PHP_MINIT_FUNCTION(spl_array);
extern void spl_array_iterator_append(zval *object, zval *append_value);
extern void spl_array_iterator_key(zval *object, zval *return_value);
#endif /* SPL_ARRAY_H */

View File

@ -0,0 +1,115 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_DIRECTORY_H
#define SPL_DIRECTORY_H
#include "php.h"
#include "php_spl.h"
extern PHPAPI zend_class_entry *spl_ce_SplFileInfo;
extern PHPAPI zend_class_entry *spl_ce_DirectoryIterator;
extern PHPAPI zend_class_entry *spl_ce_FilesystemIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator;
extern PHPAPI zend_class_entry *spl_ce_GlobIterator;
extern PHPAPI zend_class_entry *spl_ce_SplFileObject;
extern PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
PHP_MINIT_FUNCTION(spl_directory);
/* Internal objecte structure and helpers for Directory and File SPL objects */
typedef struct _spl_filesystem_object spl_filesystem_object;
typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object);
typedef void (*spl_foreign_clone_t)(spl_filesystem_object *src, spl_filesystem_object *dst);
PHPAPI zend_string *spl_filesystem_object_get_path(spl_filesystem_object *intern);
typedef struct _spl_other_handler {
spl_foreign_dtor_t dtor;
spl_foreign_clone_t clone;
} spl_other_handler;
typedef enum {
SPL_FS_INFO, /* must be 0 */
SPL_FS_DIR,
SPL_FS_FILE
} SPL_FS_OBJ_TYPE;
struct _spl_filesystem_object {
void *oth;
const spl_other_handler *oth_handler;
zend_string *path;
zend_string *orig_path;
zend_string *file_name;
SPL_FS_OBJ_TYPE type;
zend_long flags;
zend_class_entry *file_class;
zend_class_entry *info_class;
union {
struct {
php_stream *dirp;
zend_string *sub_path;
int index;
zend_function *func_rewind;
zend_function *func_next;
zend_function *func_valid;
php_stream_dirent entry;
} dir;
struct {
php_stream *stream;
php_stream_context *context;
zval *zcontext;
zend_string *open_mode;
zval current_zval;
char *current_line;
size_t current_line_len;
size_t max_line_len;
zend_long current_line_num;
zval zresource;
zend_function *func_getCurr;
char delimiter;
char enclosure;
int escape;
} file;
} u;
zend_object std;
};
#define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines */
#define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on rewind/next */
#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000004 /* skip empty lines */
#define SPL_FILE_OBJECT_READ_CSV 0x00000008 /* read via fgetcsv */
#define SPL_FILE_OBJECT_MASK 0x0000000F /* read via fgetcsv */
#define SPL_FILE_DIR_CURRENT_AS_FILEINFO 0x00000000 /* make RecursiveDirectoryTree::current() return SplFileInfo */
#define SPL_FILE_DIR_CURRENT_AS_SELF 0x00000010 /* make RecursiveDirectoryTree::current() return getSelf() */
#define SPL_FILE_DIR_CURRENT_AS_PATHNAME 0x00000020 /* make RecursiveDirectoryTree::current() return getPathname() */
#define SPL_FILE_DIR_CURRENT_MODE_MASK 0x000000F0 /* mask RecursiveDirectoryTree::current() */
#define SPL_FILE_DIR_CURRENT(intern,mode) ((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)
#define SPL_FILE_DIR_KEY_AS_PATHNAME 0x00000000 /* make RecursiveDirectoryTree::key() return getPathname() */
#define SPL_FILE_DIR_KEY_AS_FILENAME 0x00000100 /* make RecursiveDirectoryTree::key() return getFilename() */
#define SPL_FILE_DIR_KEY_MODE_MASK 0x00000F00 /* mask RecursiveDirectoryTree::key() */
#define SPL_FILE_NEW_CURRENT_AND_KEY SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO
#define SPL_FILE_DIR_KEY(intern,mode) ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
#define SPL_FILE_DIR_SKIPDOTS 0x00001000 /* Tells whether it should skip dots or not */
#define SPL_FILE_DIR_UNIXPATHS 0x00002000 /* Whether to unixify path separators */
#define SPL_FILE_DIR_FOLLOW_SYMLINKS 0x00004000 /* make RecursiveDirectoryTree::hasChildren() follow symlinks */
#define SPL_FILE_DIR_OTHERS_MASK 0x00007000 /* mask used for get/setFlags */
#endif /* SPL_DIRECTORY_H */

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Etienne Kneuss <colder@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_DLLIST_H
#define SPL_DLLIST_H
#include "php.h"
#include "php_spl.h"
#define SPL_DLLIST_IT_KEEP 0x00000000
#define SPL_DLLIST_IT_FIFO 0x00000000 /* FIFO flag makes the iterator traverse the structure as a FirstInFirstOut */
#define SPL_DLLIST_IT_DELETE 0x00000001 /* Delete flag makes the iterator delete the current element on next */
#define SPL_DLLIST_IT_LIFO 0x00000002 /* LIFO flag makes the iterator traverse the structure as a LastInFirstOut */
#define SPL_DLLIST_IT_MASK 0x00000003 /* Mask to isolate flags related to iterators */
#define SPL_DLLIST_IT_FIX 0x00000004 /* Backward/Forward bit is fixed */
extern PHPAPI zend_class_entry *spl_ce_SplDoublyLinkedList;
extern PHPAPI zend_class_entry *spl_ce_SplQueue;
extern PHPAPI zend_class_entry *spl_ce_SplStack;
PHP_MINIT_FUNCTION(spl_dllist);
#endif /* SPL_DLLIST_H */

View File

@ -0,0 +1,45 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_ENGINE_H
#define SPL_ENGINE_H
#include "php.h"
#include "php_spl.h"
#include "zend_interfaces.h"
static inline void spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
{
object_init_ex(retval, pce);
zend_call_known_instance_method_with_1_params(pce->constructor, Z_OBJ_P(retval), NULL, arg1);
}
static inline void spl_instantiate_arg_ex2(
zend_class_entry *pce, zval *retval, zval *arg1, zval *arg2)
{
object_init_ex(retval, pce);
zend_call_known_instance_method_with_2_params(
pce->constructor, Z_OBJ_P(retval), NULL, arg1, arg2);
}
static inline void spl_instantiate_arg_n(
zend_class_entry *pce, zval *retval, uint32_t argc, zval *argv)
{
object_init_ex(retval, pce);
zend_call_known_instance_method(pce->constructor, Z_OBJ_P(retval), NULL, argc, argv);
}
#endif /* SPL_ENGINE_H */

View File

@ -0,0 +1,40 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_EXCEPTIONS_H
#define SPL_EXCEPTIONS_H
#include "php.h"
#include "php_spl.h"
extern PHPAPI zend_class_entry *spl_ce_LogicException;
extern PHPAPI zend_class_entry *spl_ce_BadFunctionCallException;
extern PHPAPI zend_class_entry *spl_ce_BadMethodCallException;
extern PHPAPI zend_class_entry *spl_ce_DomainException;
extern PHPAPI zend_class_entry *spl_ce_InvalidArgumentException;
extern PHPAPI zend_class_entry *spl_ce_LengthException;
extern PHPAPI zend_class_entry *spl_ce_OutOfRangeException;
extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
extern PHPAPI zend_class_entry *spl_ce_OutOfBoundsException;
extern PHPAPI zend_class_entry *spl_ce_OverflowException;
extern PHPAPI zend_class_entry *spl_ce_RangeException;
extern PHPAPI zend_class_entry *spl_ce_UnderflowException;
extern PHPAPI zend_class_entry *spl_ce_UnexpectedValueException;
PHP_MINIT_FUNCTION(spl_exceptions);
#endif /* SPL_EXCEPTIONS_H */

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Antony Dovgal <tony@daylessday.org> |
| Etienne Kneuss <colder@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_FIXEDARRAY_H
#define SPL_FIXEDARRAY_H
extern PHPAPI zend_class_entry *spl_ce_SplFixedArray;
PHP_MINIT_FUNCTION(spl_fixedarray);
#endif /* SPL_FIXEDARRAY_H */

View File

@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_FUNCTIONS_H
#define PHP_FUNCTIONS_H
#include "php.h"
typedef zend_object* (*create_object_func_t)(zend_class_entry *class_type);
/* sub: whether to allow subclasses/interfaces
allow = 0: allow all classes and interfaces
allow > 0: allow all that match and mask ce_flags
allow < 0: disallow all that match and mask ce_flags
*/
void spl_add_class_name(zval * list, zend_class_entry * pce, int allow, int ce_flags);
void spl_add_interfaces(zval * list, zend_class_entry * pce, int allow, int ce_flags);
void spl_add_traits(zval * list, zend_class_entry * pce, int allow, int ce_flags);
void spl_add_classes(zend_class_entry *pce, zval *list, bool sub, int allow, int ce_flags);
/* caller must efree(return) */
zend_string *spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, size_t prop_len);
#endif /* PHP_FUNCTIONS_H */

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Etienne Kneuss <colder@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_HEAP_H
#define SPL_HEAP_H
#include "php.h"
#include "php_spl.h"
#define SPL_PQUEUE_EXTR_MASK 0x00000003
#define SPL_PQUEUE_EXTR_BOTH 0x00000003
#define SPL_PQUEUE_EXTR_DATA 0x00000001
#define SPL_PQUEUE_EXTR_PRIORITY 0x00000002
extern PHPAPI zend_class_entry *spl_ce_SplHeap;
extern PHPAPI zend_class_entry *spl_ce_SplMinHeap;
extern PHPAPI zend_class_entry *spl_ce_SplMaxHeap;
extern PHPAPI zend_class_entry *spl_ce_SplPriorityQueue;
PHP_MINIT_FUNCTION(spl_heap);
#endif /* SPL_HEAP_H */

View File

@ -0,0 +1,119 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_ITERATORS_H
#define SPL_ITERATORS_H
#include "php.h"
#include "php_spl.h"
extern PHPAPI zend_class_entry *spl_ce_AppendIterator;
extern PHPAPI zend_class_entry *spl_ce_CachingIterator;
extern PHPAPI zend_class_entry *spl_ce_CallbackFilterIterator;
extern PHPAPI zend_class_entry *spl_ce_EmptyIterator;
extern PHPAPI zend_class_entry *spl_ce_FilterIterator;
extern PHPAPI zend_class_entry *spl_ce_InfiniteIterator;
extern PHPAPI zend_class_entry *spl_ce_IteratorIterator;
extern PHPAPI zend_class_entry *spl_ce_LimitIterator;
extern PHPAPI zend_class_entry *spl_ce_NoRewindIterator;
extern PHPAPI zend_class_entry *spl_ce_OuterIterator;
extern PHPAPI zend_class_entry *spl_ce_ParentIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveCachingIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveCallbackFilterIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveFilterIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveIteratorIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveTreeIterator;
extern PHPAPI zend_class_entry *spl_ce_RegexIterator;
extern PHPAPI zend_class_entry *spl_ce_SeekableIterator;
PHP_MINIT_FUNCTION(spl_iterators);
typedef enum {
RIT_LEAVES_ONLY = 0,
RIT_SELF_FIRST = 1,
RIT_CHILD_FIRST = 2
} RecursiveIteratorMode;
#define RIT_CATCH_GET_CHILD CIT_CATCH_GET_CHILD
typedef enum {
RTIT_BYPASS_CURRENT = 4,
RTIT_BYPASS_KEY = 8
} RecursiveTreeIteratorFlags;
typedef enum {
DIT_Default = 0,
DIT_FilterIterator = DIT_Default,
DIT_RecursiveFilterIterator = DIT_Default,
DIT_ParentIterator = DIT_Default,
DIT_LimitIterator,
DIT_CachingIterator,
DIT_RecursiveCachingIterator,
DIT_IteratorIterator,
DIT_NoRewindIterator,
DIT_InfiniteIterator,
DIT_AppendIterator,
DIT_RegexIterator,
DIT_RecursiveRegexIterator,
DIT_CallbackFilterIterator,
DIT_RecursiveCallbackFilterIterator,
DIT_Unknown = ~0
} dual_it_type;
typedef enum {
RIT_Default = 0,
RIT_RecursiveIteratorIterator = RIT_Default,
RIT_RecursiveTreeIterator,
RIT_Unknow = ~0
} recursive_it_it_type;
enum {
/* public */
CIT_CALL_TOSTRING = 0x00000001,
CIT_TOSTRING_USE_KEY = 0x00000002,
CIT_TOSTRING_USE_CURRENT = 0x00000004,
CIT_TOSTRING_USE_INNER = 0x00000008,
CIT_CATCH_GET_CHILD = 0x00000010,
CIT_FULL_CACHE = 0x00000100,
CIT_PUBLIC = 0x0000FFFF,
/* private */
CIT_VALID = 0x00010000,
CIT_HAS_CHILDREN = 0x00020000
};
enum {
/* public */
REGIT_USE_KEY = 0x00000001,
REGIT_INVERTED = 0x00000002
};
typedef enum {
REGIT_MODE_MATCH,
REGIT_MODE_GET_MATCH,
REGIT_MODE_ALL_MATCHES,
REGIT_MODE_SPLIT,
REGIT_MODE_REPLACE,
REGIT_MODE_MAX
} regex_mode;
typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser);
PHPAPI zend_result spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);
#endif /* SPL_ITERATORS_H */

View File

@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPL_OBSERVER_H
#define SPL_OBSERVER_H
#include "php.h"
#include "php_spl.h"
typedef enum {
MIT_NEED_ANY = 0,
MIT_NEED_ALL = 1,
MIT_KEYS_NUMERIC = 0,
MIT_KEYS_ASSOC = 2
} MultipleIteratorFlags;
extern PHPAPI zend_class_entry *spl_ce_SplObserver;
extern PHPAPI zend_class_entry *spl_ce_SplSubject;
extern PHPAPI zend_class_entry *spl_ce_SplObjectStorage;
extern PHPAPI zend_class_entry *spl_ce_MultipleIterator;
PHP_MINIT_FUNCTION(spl_observer);
#endif /* SPL_OBSERVER_H */

View File

@ -0,0 +1,78 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jim Winstead <jimw@php.net> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef BASE64_H
#define BASE64_H
/*
* NEON and AVX512 implementation are based on https://github.com/WojciechMula/base64simd
* which is copyrighted to:
* Copyright (c) 2015-2018, Wojciech Mula
* All rights reserved.
*
* SSSE3 and AVX2 implementation are based on https://github.com/aklomp/base64
* which is copyrighted to:
*
* Copyright (c) 2005-2007, Nick Galbreath
* Copyright (c) 2013-2017, Alfred Klomp
* Copyright (c) 2015-2017, Wojciech Mula
* Copyright (c) 2016-2017, Matthieu Darbois
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if (ZEND_INTRIN_AVX2_FUNC_PTR || ZEND_INTRIN_SSSE3_FUNC_PTR || ZEND_INTRIN_AVX512_FUNC_PTR || ZEND_INTRIN_AVX512_VBMI_FUNC_PTR) && !ZEND_INTRIN_AVX2_NATIVE
PHP_MINIT_FUNCTION(base64_intrin);
#endif
PHPAPI extern zend_string *php_base64_encode(const unsigned char *, size_t);
PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, size_t, bool);
static inline zend_string *php_base64_encode_str(const zend_string *str) {
return php_base64_encode((const unsigned char*)(ZSTR_VAL(str)), ZSTR_LEN(str));
}
static inline zend_string *php_base64_decode(const unsigned char *str, size_t len) {
return php_base64_decode_ex(str, len, 0);
}
static inline zend_string *php_base64_decode_str(const zend_string *str) {
return php_base64_decode_ex((const unsigned char*)(ZSTR_VAL(str)), ZSTR_LEN(str), 0);
}
#endif /* BASE64_H */

View File

@ -0,0 +1,142 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef BASIC_FUNCTIONS_H
#define BASIC_FUNCTIONS_H
#include <sys/stat.h>
#include <wchar.h>
#include "php_filestat.h"
#include "zend_highlight.h"
#include "url_scanner_ex.h"
/* for MT_N */
#include "ext/random/php_random.h"
#if defined(_WIN32) && !defined(__clang__)
#include <intrin.h>
#endif
extern zend_module_entry basic_functions_module;
#define basic_functions_module_ptr &basic_functions_module
PHP_MINIT_FUNCTION(basic);
PHP_MSHUTDOWN_FUNCTION(basic);
PHP_RINIT_FUNCTION(basic);
PHP_RSHUTDOWN_FUNCTION(basic);
PHP_MINFO_FUNCTION(basic);
ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);
PHP_MINIT_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(browscap);
/* Left for BC (not binary safe!) */
PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers);
PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers);
PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, bool add_underscore);
/* Deprecated type aliases -- use the standard types instead */
typedef uint32_t php_uint32;
typedef int32_t php_int32;
typedef struct _php_basic_globals {
HashTable *user_shutdown_function_names;
HashTable putenv_ht;
zend_string *strtok_string;
zend_string *ctype_string; /* current LC_CTYPE locale (or NULL for 'C') */
bool locale_changed; /* locale was changed and has to be restored */
char *strtok_last;
char strtok_table[256];
size_t strtok_len;
zend_fcall_info user_compare_fci;
zend_fcall_info_cache user_compare_fci_cache;
zend_llist *user_tick_functions;
zval active_ini_file_section;
/* pageinfo.c */
zend_long page_uid;
zend_long page_gid;
zend_long page_inode;
time_t page_mtime;
/* filestat.c && main/streams/streams.c */
zend_string *CurrentStatFile, *CurrentLStatFile;
php_stream_statbuf ssb, lssb;
/* syslog.c */
char *syslog_device;
/* var.c */
unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */
struct {
struct php_serialize_data *data;
unsigned level;
} serialize;
struct {
struct php_unserialize_data *data;
unsigned level;
} unserialize;
/* url_scanner_ex.re */
url_adapt_state_ex_t url_adapt_session_ex;
HashTable url_adapt_session_hosts_ht;
url_adapt_state_ex_t url_adapt_output_ex;
HashTable url_adapt_output_hosts_ht;
HashTable *user_filter_map;
/* file.c */
#if defined(_REENTRANT)
mbstate_t mblen_state;
#endif
int umask;
zend_long unserialize_max_depth;
} php_basic_globals;
#ifdef ZTS
#define BG(v) ZEND_TSRMG(basic_globals_id, php_basic_globals *, v)
PHPAPI extern int basic_globals_id;
#else
#define BG(v) (basic_globals.v)
PHPAPI extern php_basic_globals basic_globals;
#endif
PHPAPI zend_string *php_getenv(const char *str, size_t str_len);
PHPAPI double php_get_nan(void);
PHPAPI double php_get_inf(void);
typedef struct _php_shutdown_function_entry {
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
} php_shutdown_function_entry;
PHPAPI extern bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
PHPAPI extern bool remove_user_shutdown_function(const char *function_name, size_t function_len);
PHPAPI extern bool append_user_shutdown_function(php_shutdown_function_entry *shutdown_function_entry);
PHPAPI void php_call_shutdown_functions(void);
PHPAPI void php_free_shutdown_functions(void);
#endif /* BASIC_FUNCTIONS_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,104 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
/*
* This code implements the AUTODIN II polynomial
* The variable corresponding to the macro argument "crc" should
* be an unsigned long.
* Original code by Spencer Garrett <srg@quick.com>
*/
#define CRC32(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff])
#define php_crc32_bulk_init() (0 ^ 0xffffffff)
#define php_crc32_bulk_end(c) ((c) ^ 0xffffffff)
PHPAPI uint32_t php_crc32_bulk_update(uint32_t crc, const char *p, size_t nr);
/* Return FAILURE if stream reading fail */
PHPAPI int php_crc32_stream_bulk_update(uint32_t *crc, php_stream *fp, size_t nr);
/* generated using the AUTODIN II polynomial
* x^32 + x^26 + x^23 + x^22 + x^16 +
* x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1
*/
static const unsigned int crc32tab[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
};

View File

@ -0,0 +1,52 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Frank Du <frank.du@intel.com> |
+----------------------------------------------------------------------+
*/
#ifndef _CRC32_X86_HEADER_H_
#define _CRC32_X86_HEADER_H_
#include "php.h"
typedef enum {
/* polynomial: 0x04C11DB7, used by bzip */
X86_CRC32 = 0,
/*
polynomial: 0x04C11DB7 with reversed ordering,
used by ethernet (IEEE 802.3), gzip, zip, png, etc
*/
X86_CRC32B,
/*
polynomial: 0x1EDC6F41 with reversed ordering,
used by iSCSI, SCTP, Btrfs, ext4, etc
*/
X86_CRC32C,
X86_CRC32_MAX,
} X86_CRC32_TYPE;
#if ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR
PHP_MINIT_FUNCTION(crc32_x86_intrin);
#endif
#if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
/* Return the size processed by SIMD routine */
size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr);
#else
static inline size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned char *p, size_t nr)
{
return 0;
}
#endif
#endif

View File

@ -0,0 +1,38 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef CREDITS_H
#define CREDITS_H
#ifndef HAVE_CREDITS_DEFS
#define HAVE_CREDITS_DEFS
#define PHP_CREDITS_GROUP (1<<0)
#define PHP_CREDITS_GENERAL (1<<1)
#define PHP_CREDITS_SAPI (1<<2)
#define PHP_CREDITS_MODULES (1<<3)
#define PHP_CREDITS_DOCS (1<<4)
#define PHP_CREDITS_FULLPAGE (1<<5)
#define PHP_CREDITS_QA (1<<6)
#define PHP_CREDITS_WEB (1<<7)
#define PHP_CREDITS_ALL 0xFFFFFFFF
#endif /* HAVE_CREDITS_DEFS */
PHPAPI void php_print_credits(int flag);
#endif

View File

@ -0,0 +1,81 @@
/*
DO NOT EDIT THIS FILE!
it has been automatically created by scripts/dev/credits from
the information found in the various ext/.../CREDITS and
sapi/.../CREDITS files
if you want to change an entry you have to edit the appropriate
CREDITS file instead
*/
CREDIT_LINE("BC Math", "Andi Gutmans");
CREDIT_LINE("Bzip2", "Sterling Hughes");
CREDIT_LINE("Calendar", "Shane Caraveo, Colin Viebrock, Hartmut Holzgraefe, Wez Furlong");
CREDIT_LINE("COM and .Net", "Wez Furlong");
CREDIT_LINE("ctype", "Hartmut Holzgraefe");
CREDIT_LINE("cURL", "Sterling Hughes");
CREDIT_LINE("Date/Time Support", "Derick Rethans");
CREDIT_LINE("DB-LIB (MS SQL, Sybase)", "Wez Furlong, Frank M. Kromann, Adam Baratz");
CREDIT_LINE("DBA", "Sascha Schumann, Marcus Boerger");
CREDIT_LINE("DOM", "Christian Stocker, Rob Richards, Marcus Boerger");
CREDIT_LINE("enchant", "Pierre-Alain Joye, Ilia Alshanetsky");
CREDIT_LINE("EXIF", "Rasmus Lerdorf, Marcus Boerger");
CREDIT_LINE("FFI", "Dmitry Stogov");
CREDIT_LINE("fileinfo", "Ilia Alshanetsky, Pierre Alain Joye, Scott MacVicar, Derick Rethans, Anatol Belski");
CREDIT_LINE("Firebird driver for PDO", "Ard Biesheuvel");
CREDIT_LINE("FTP", "Stefan Esser, Andrew Skalski");
CREDIT_LINE("GD imaging", "Rasmus Lerdorf, Stig Bakken, Jim Winstead, Jouni Ahto, Ilia Alshanetsky, Pierre-Alain Joye, Marcus Boerger, Mark Randall");
CREDIT_LINE("GetText", "Alex Plotnick");
CREDIT_LINE("GNU GMP support", "Stanislav Malyshev");
CREDIT_LINE("Iconv", "Rui Hirokawa, Stig Bakken, Moriyoshi Koizumi");
CREDIT_LINE("IMAP", "Rex Logan, Mark Musone, Brian Wang, Kaj-Michael Lang, Antoni Pamies Olive, Rasmus Lerdorf, Andrew Skalski, Chuck Hagenbuch, Daniel R Kalowsky");
CREDIT_LINE("Input Filter", "Rasmus Lerdorf, Derick Rethans, Pierre-Alain Joye, Ilia Alshanetsky");
CREDIT_LINE("Internationalization", "Ed Batutis, Vladimir Iordanov, Dmitry Lakhtyuk, Stanislav Malyshev, Vadim Savchuk, Kirti Velankar");
CREDIT_LINE("JSON", "Jakub Zelenka, Omar Kilani, Scott MacVicar");
CREDIT_LINE("LDAP", "Amitay Isaacs, Eric Warnke, Rasmus Lerdorf, Gerrit Thomson, Stig Venaas");
CREDIT_LINE("LIBXML", "Christian Stocker, Rob Richards, Marcus Boerger, Wez Furlong, Shane Caraveo");
CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa");
CREDIT_LINE("MySQL driver for PDO", "George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter");
CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel");
CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter, Johannes Schlüter");
CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong, Christopher Jones, Oracle Corporation");
CREDIT_LINE("ODBC driver for PDO", "Wez Furlong");
CREDIT_LINE("ODBC", "Stig Bakken, Andreas Karajannis, Frank M. Kromann, Daniel R. Kalowsky");
CREDIT_LINE("Opcache", "Andi Gutmans, Zeev Suraski, Stanislav Malyshev, Dmitry Stogov, Xinchen Hui");
CREDIT_LINE("OpenSSL", "Stig Venaas, Wez Furlong, Sascha Kettler, Scott MacVicar, Eliot Lear");
CREDIT_LINE("Oracle (OCI) driver for PDO", "Wez Furlong");
CREDIT_LINE("pcntl", "Jason Greene, Arnaud Le Blanc");
CREDIT_LINE("Perl Compatible Regexps", "Andrei Zmievski");
CREDIT_LINE("PHP Archive", "Gregory Beaver, Marcus Boerger");
CREDIT_LINE("PHP Data Objects", "Wez Furlong, Marcus Boerger, Sterling Hughes, George Schlossnagle, Ilia Alshanetsky");
CREDIT_LINE("PHP hash", "Sara Golemon, Rasmus Lerdorf, Stefan Esser, Michael Wallner, Scott MacVicar");
CREDIT_LINE("Posix", "Kristian Koehntopp");
CREDIT_LINE("PostgreSQL driver for PDO", "Edin Kadribasic, Ilia Alshanetsky");
CREDIT_LINE("PostgreSQL", "Jouni Ahto, Zeev Suraski, Yasuo Ohgaki, Chris Kings-Lynne");
CREDIT_LINE("Pspell", "Vlad Krupin");
CREDIT_LINE("random", "Go Kudo, Tim Düsterhus, Guilliam Xavier, Christoph M. Becker, Jakub Zelenka, Bob Weinand, Máté Kocsis, and Original RNG implementators");
CREDIT_LINE("Readline", "Thies C. Arntzen");
CREDIT_LINE("Reflection", "Marcus Boerger, Timm Friebe, George Schlossnagle, Andrei Zmievski, Johannes Schlueter");
CREDIT_LINE("Sessions", "Sascha Schumann, Andrei Zmievski");
CREDIT_LINE("Shared Memory Operations", "Slava Poliakov, Ilia Alshanetsky");
CREDIT_LINE("SimpleXML", "Sterling Hughes, Marcus Boerger, Rob Richards");
CREDIT_LINE("SNMP", "Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Lawrance, Johann Hanne, Boris Lytochkin");
CREDIT_LINE("SOAP", "Brad Lafountain, Shane Caraveo, Dmitry Stogov");
CREDIT_LINE("Sockets", "Chris Vandomelen, Sterling Hughes, Daniel Beulshausen, Jason Greene");
CREDIT_LINE("Sodium", "Frank Denis");
CREDIT_LINE("SPL", "Marcus Boerger, Etienne Kneuss");
CREDIT_LINE("SQLite 3.x driver for PDO", "Wez Furlong");
CREDIT_LINE("SQLite3", "Scott MacVicar, Ilia Alshanetsky, Brad Dewar");
CREDIT_LINE("System V Message based IPC", "Wez Furlong");
CREDIT_LINE("System V Semaphores", "Tom May");
CREDIT_LINE("System V Shared Memory", "Christian Cartus");
CREDIT_LINE("tidy", "John Coggeshall, Ilia Alshanetsky");
CREDIT_LINE("tokenizer", "Andrei Zmievski, Johannes Schlueter");
CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen, Sterling Hughes");
CREDIT_LINE("XMLReader", "Rob Richards");
CREDIT_LINE("XMLWriter", "Rob Richards, Pierre-Alain Joye");
CREDIT_LINE("XSL", "Christian Stocker, Rob Richards");
CREDIT_LINE("Zip", "Pierre-Alain Joye, Remi Collet");
CREDIT_LINE("Zlib", "Rasmus Lerdorf, Stefan Roehrich, Zeev Suraski, Jade Nicoletti, Michael Wallner");

View File

@ -0,0 +1,19 @@
/*
DO NOT EDIT THIS FILE!
it has been automatically created by scripts/dev/credits from
the information found in the various ext/.../CREDITS and
sapi/.../CREDITS files
if you want to change an entry you have to edit the appropriate
CREDITS file instead
*/
CREDIT_LINE("Apache 2.0 Handler", "Ian Holsman, Justin Erenkrantz (based on Apache 2.0 Filter code)");
CREDIT_LINE("CGI / FastCGI", "Rasmus Lerdorf, Stig Bakken, Shane Caraveo, Dmitry Stogov");
CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter, Moriyoshi Koizumi, Xinchen Hui");
CREDIT_LINE("Embed", "Edin Kadribasic");
CREDIT_LINE("FastCGI Process Manager", "Andrei Nigmatulin, dreamcat4, Antony Dovgal, Jerome Loyet");
CREDIT_LINE("litespeed", "George Wang");
CREDIT_LINE("phpdbg", "Felipe Pena, Joe Watkins, Bob Weinand");

View File

@ -0,0 +1,23 @@
/*
* Written by Solar Designer <solar at openwall.com> in 2000-2011.
* No copyright is claimed, and the software is hereby placed in the public
* domain. In case this attempt to disclaim copyright and place the software
* in the public domain is deemed null and void, then the software is
* Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
* general public under the following terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*
* See crypt_blowfish.c for more information.
*/
#ifndef _CRYPT_BLOWFISH_H
#define _CRYPT_BLOWFISH_H
extern char *php_crypt_blowfish_rn(const char *key, const char *setting,
char *output, int size);
#endif

View File

@ -0,0 +1,28 @@
#ifndef _CRYPT_FREESEC_H
#define _CRYPT_FREESEC_H
#include <stdint.h>
#define MD5_HASH_MAX_LEN 120
struct php_crypt_extended_data {
int initialized;
uint32_t saltbits;
uint32_t old_salt;
uint32_t en_keysl[16], en_keysr[16];
uint32_t de_keysl[16], de_keysr[16];
uint32_t old_rawkey0, old_rawkey1;
char output[21];
};
/*
* _crypt_extended_init() must be called explicitly before first use of
* _crypt_extended_r().
*/
void _crypt_extended_init(void);
char *_crypt_extended_r(const unsigned char *key, const char *setting,
struct php_crypt_extended_data *data);
#endif

View File

@ -0,0 +1,22 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Colin Viebrock <colin@viebrock.ca> |
+----------------------------------------------------------------------+
*/
#ifndef CSS_H
#define CSS_H
PHPAPI void php_info_print_css(void);
#endif

View File

@ -0,0 +1,23 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef DATETIME_H
#define DATETIME_H
PHPAPI char *php_std_date(time_t t);
#endif /* DATETIME_H */

View File

@ -0,0 +1,45 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: b3890e798e609e306027b4717ce0c5e782884087 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_Directory_rewind arginfo_class_Directory_close
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Directory_read, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_END_ARG_INFO()
ZEND_FUNCTION(closedir);
ZEND_FUNCTION(rewinddir);
ZEND_FUNCTION(readdir);
static const zend_function_entry class_Directory_methods[] = {
ZEND_ME_MAPPING(close, closedir, arginfo_class_Directory_close, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(rewind, rewinddir, arginfo_class_Directory_rewind, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(read, readdir, arginfo_class_Directory_read, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static zend_class_entry *register_class_Directory(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "Directory", class_Directory_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zval property_path_default_value;
ZVAL_UNDEF(&property_path_default_value);
zend_string *property_path_name = zend_string_init("path", sizeof("path") - 1, 1);
zend_declare_typed_property(class_entry, property_path_name, &property_path_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_path_name);
zval property_handle_default_value;
ZVAL_UNDEF(&property_handle_default_value);
zend_string *property_handle_name = zend_string_init("handle", sizeof("handle") - 1, 1);
zend_declare_typed_property(class_entry, property_handle_name, &property_handle_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY));
zend_string_release(property_handle_name);
return class_entry;
}

View File

@ -0,0 +1,31 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Brian Schaffner <brian@tool.net> |
| Shane Caraveo <shane@caraveo.com> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef DL_H
#define DL_H
PHPAPI int php_load_extension(const char *filename, int type, int start_now);
PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now);
PHPAPI void *php_load_shlib(const char *path, char **errp);
/* dynamic loading functions */
PHPAPI PHP_FUNCTION(dl);
PHP_MINFO_FUNCTION(dl);
#endif /* DL_H */

View File

@ -0,0 +1,6 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 7dac6edd98e3e17669ae4bf0be7db89678059ca0 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, extension_filename, IS_STRING, 0)
ZEND_END_ARG_INFO()

View File

@ -0,0 +1,27 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef EXEC_H
#define EXEC_H
PHP_MINIT_FUNCTION(proc_open);
PHP_MINIT_FUNCTION(exec);
PHPAPI zend_string *php_escape_shell_cmd(const char *str);
PHPAPI zend_string *php_escape_shell_arg(const char *str);
PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value);
#endif /* EXEC_H */

View File

@ -0,0 +1,116 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef FILE_H
#define FILE_H
#include "php_network.h"
PHP_MINIT_FUNCTION(file);
PHP_MSHUTDOWN_FUNCTION(file);
PHPAPI PHP_FUNCTION(fclose);
PHPAPI PHP_FUNCTION(feof);
PHPAPI PHP_FUNCTION(fread);
PHPAPI PHP_FUNCTION(fgetc);
PHPAPI PHP_FUNCTION(fgets);
PHPAPI PHP_FUNCTION(fwrite);
PHPAPI PHP_FUNCTION(fflush);
PHPAPI PHP_FUNCTION(rewind);
PHPAPI PHP_FUNCTION(ftell);
PHPAPI PHP_FUNCTION(fseek);
PHPAPI PHP_FUNCTION(fpassthru);
PHP_MINIT_FUNCTION(user_streams);
PHPAPI int php_le_stream_context(void);
PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
PHPAPI int php_copy_file(const char *src, const char *dest);
PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk);
PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx);
PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options);
PHPAPI int php_mkdir(const char *dir, zend_long mode);
PHPAPI void php_fstat(php_stream *stream, zval *return_value);
PHPAPI void php_flock_common(php_stream *stream, zend_long operation, uint32_t operation_arg_num,
zval *wouldblock, zval *return_value);
#define PHP_CSV_NO_ESCAPE EOF
PHPAPI HashTable *php_bc_fgetcsv_empty_line(void);
PHPAPI HashTable *php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int escape_char, size_t buf_len, char *buf);
PHPAPI ssize_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, int escape_char, zend_string *eol_str);
#define META_DEF_BUFSIZE 8192
#define PHP_FILE_USE_INCLUDE_PATH (1 << 0)
#define PHP_FILE_IGNORE_NEW_LINES (1 << 1)
#define PHP_FILE_SKIP_EMPTY_LINES (1 << 2)
#define PHP_FILE_APPEND (1 << 3)
#define PHP_FILE_NO_DEFAULT_CONTEXT (1 << 4)
typedef enum _php_meta_tags_token {
TOK_EOF = 0,
TOK_OPENTAG,
TOK_CLOSETAG,
TOK_SLASH,
TOK_EQUAL,
TOK_SPACE,
TOK_ID,
TOK_STRING,
TOK_OTHER
} php_meta_tags_token;
typedef struct _php_meta_tags_data {
php_stream *stream;
int ulc;
int lc;
char *input_buffer;
char *token_data;
int token_len;
int in_meta;
} php_meta_tags_data;
php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
typedef struct {
int pclose_ret;
size_t def_chunk_size;
bool auto_detect_line_endings;
zend_long default_socket_timeout;
char *user_agent; /* for the http wrapper */
char *from_address; /* for the ftp and http wrappers */
const char *user_stream_current_filename; /* for simple recursion protection */
php_stream_context *default_context;
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
HashTable *stream_filters; /* per-request copy of stream_filters_hash */
HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */
int pclose_wait;
#ifdef HAVE_GETHOSTBYNAME_R
struct hostent tmp_host_info;
char *tmp_host_buf;
size_t tmp_host_buf_len;
#endif
} php_file_globals;
#ifdef ZTS
#define FG(v) ZEND_TSRMG(file_globals_id, php_file_globals *, v)
extern PHPAPI int file_globals_id;
#else
#define FG(v) (file_globals.v)
extern PHPAPI php_file_globals file_globals;
#endif
#endif /* FILE_H */

View File

@ -0,0 +1,127 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e9a566d5ef96f781074027b1b3ff1824d0208b47 */
static void register_file_symbols(int module_number)
{
REGISTER_LONG_CONSTANT("SEEK_SET", SEEK_SET, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SEEK_CUR", SEEK_CUR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SEEK_END", SEEK_END, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOCK_SH", PHP_LOCK_SH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOCK_EX", PHP_LOCK_EX, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOCK_UN", PHP_LOCK_UN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LOCK_NB", PHP_LOCK_NB, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_CONNECT", PHP_STREAM_NOTIFY_CONNECT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_AUTH_REQUIRED", PHP_STREAM_NOTIFY_AUTH_REQUIRED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_AUTH_RESULT", PHP_STREAM_NOTIFY_AUTH_RESULT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_MIME_TYPE_IS", PHP_STREAM_NOTIFY_MIME_TYPE_IS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_FILE_SIZE_IS", PHP_STREAM_NOTIFY_FILE_SIZE_IS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_REDIRECTED", PHP_STREAM_NOTIFY_REDIRECTED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_PROGRESS", PHP_STREAM_NOTIFY_PROGRESS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_FAILURE", PHP_STREAM_NOTIFY_FAILURE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_COMPLETED", PHP_STREAM_NOTIFY_COMPLETED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_RESOLVE", PHP_STREAM_NOTIFY_RESOLVE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO", PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN", PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR", PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_FILTER_READ", PHP_STREAM_FILTER_READ, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_FILTER_WRITE", PHP_STREAM_FILTER_WRITE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_FILTER_ALL", PHP_STREAM_FILTER_ALL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CLIENT_PERSISTENT", PHP_STREAM_CLIENT_PERSISTENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CLIENT_ASYNC_CONNECT", PHP_STREAM_CLIENT_ASYNC_CONNECT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CLIENT_CONNECT", PHP_STREAM_CLIENT_CONNECT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_ANY_CLIENT", STREAM_CRYPTO_METHOD_ANY_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv2_CLIENT", STREAM_CRYPTO_METHOD_SSLv2_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv3_CLIENT", STREAM_CRYPTO_METHOD_SSLv3_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv23_CLIENT", STREAM_CRYPTO_METHOD_SSLv23_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLS_CLIENT", STREAM_CRYPTO_METHOD_TLS_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT", STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT", STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT", STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT", STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_ANY_SERVER", STREAM_CRYPTO_METHOD_ANY_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv2_SERVER", STREAM_CRYPTO_METHOD_SSLv2_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv3_SERVER", STREAM_CRYPTO_METHOD_SSLv3_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv23_SERVER", STREAM_CRYPTO_METHOD_SSLv23_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLS_SERVER", STREAM_CRYPTO_METHOD_TLS_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_0_SERVER", STREAM_CRYPTO_METHOD_TLSv1_0_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_1_SERVER", STREAM_CRYPTO_METHOD_TLSv1_1_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_2_SERVER", STREAM_CRYPTO_METHOD_TLSv1_2_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_3_SERVER", STREAM_CRYPTO_METHOD_TLSv1_3_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_PROTO_SSLv3", STREAM_CRYPTO_METHOD_SSLv3_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_PROTO_TLSv1_0", STREAM_CRYPTO_METHOD_TLSv1_0_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_PROTO_TLSv1_1", STREAM_CRYPTO_METHOD_TLSv1_1_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_PROTO_TLSv1_2", STREAM_CRYPTO_METHOD_TLSv1_2_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_PROTO_TLSv1_3", STREAM_CRYPTO_METHOD_TLSv1_3_SERVER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SHUT_RD", STREAM_SHUT_RD, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SHUT_WR", STREAM_SHUT_WR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SHUT_RDWR", STREAM_SHUT_RDWR, CONST_PERSISTENT);
#if defined(PF_INET)
REGISTER_LONG_CONSTANT("STREAM_PF_INET", PF_INET, CONST_PERSISTENT);
#endif
#if (!defined(PF_INET) && defined(AF_INET))
REGISTER_LONG_CONSTANT("STREAM_PF_INET", AF_INET, CONST_PERSISTENT);
#endif
#if defined(HAVE_IPV6) && defined(PF_INET6)
REGISTER_LONG_CONSTANT("STREAM_PF_INET6", PF_INET6, CONST_PERSISTENT);
#endif
#if defined(HAVE_IPV6) && (!defined(PF_INET6) && defined(AF_INET6))
REGISTER_LONG_CONSTANT("STREAM_PF_INET6", AF_INET6, CONST_PERSISTENT);
#endif
#if defined(PF_UNIX)
REGISTER_LONG_CONSTANT("STREAM_PF_UNIX", PF_UNIX, CONST_PERSISTENT);
#endif
#if (!defined(PF_UNIX) && defined(AF_UNIX))
REGISTER_LONG_CONSTANT("STREAM_PF_UNIX", AF_UNIX, CONST_PERSISTENT);
#endif
#if defined(IPPROTO_IP)
REGISTER_LONG_CONSTANT("STREAM_IPPROTO_IP", IPPROTO_IP, CONST_PERSISTENT);
#endif
#if (defined(IPPROTO_TCP) || defined(PHP_WIN32))
REGISTER_LONG_CONSTANT("STREAM_IPPROTO_TCP", IPPROTO_TCP, CONST_PERSISTENT);
#endif
#if (defined(IPPROTO_UDP) || defined(PHP_WIN32))
REGISTER_LONG_CONSTANT("STREAM_IPPROTO_UDP", IPPROTO_UDP, CONST_PERSISTENT);
#endif
#if (defined(IPPROTO_ICMP) || defined(PHP_WIN32))
REGISTER_LONG_CONSTANT("STREAM_IPPROTO_ICMP", IPPROTO_ICMP, CONST_PERSISTENT);
#endif
#if (defined(IPPROTO_RAW) || defined(PHP_WIN32))
REGISTER_LONG_CONSTANT("STREAM_IPPROTO_RAW", IPPROTO_RAW, CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("STREAM_SOCK_STREAM", SOCK_STREAM, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SOCK_DGRAM", SOCK_DGRAM, CONST_PERSISTENT);
#if defined(SOCK_RAW)
REGISTER_LONG_CONSTANT("STREAM_SOCK_RAW", SOCK_RAW, CONST_PERSISTENT);
#endif
#if defined(SOCK_SEQPACKET)
REGISTER_LONG_CONSTANT("STREAM_SOCK_SEQPACKET", SOCK_SEQPACKET, CONST_PERSISTENT);
#endif
#if defined(SOCK_RDM)
REGISTER_LONG_CONSTANT("STREAM_SOCK_RDM", SOCK_RDM, CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("STREAM_PEEK", STREAM_PEEK, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_OOB", STREAM_OOB, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SERVER_BIND", STREAM_XPORT_BIND, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SERVER_LISTEN", STREAM_XPORT_LISTEN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_USE_INCLUDE_PATH", PHP_FILE_USE_INCLUDE_PATH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_IGNORE_NEW_LINES", PHP_FILE_IGNORE_NEW_LINES, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_SKIP_EMPTY_LINES", PHP_FILE_SKIP_EMPTY_LINES, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_APPEND", PHP_FILE_APPEND, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_NO_DEFAULT_CONTEXT", PHP_FILE_NO_DEFAULT_CONTEXT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_TEXT", 0, CONST_PERSISTENT | CONST_DEPRECATED);
REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_PERSISTENT | CONST_DEPRECATED);
#if defined(HAVE_FNMATCH)
REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_PERSISTENT);
#endif
#if defined(HAVE_FNMATCH)
REGISTER_LONG_CONSTANT("FNM_PATHNAME", FNM_PATHNAME, CONST_PERSISTENT);
#endif
#if defined(HAVE_FNMATCH)
REGISTER_LONG_CONSTANT("FNM_PERIOD", FNM_PERIOD, CONST_PERSISTENT);
#endif
#if defined(HAVE_FNMATCH) && defined(FNM_CASEFOLD)
REGISTER_LONG_CONSTANT("FNM_CASEFOLD", FNM_CASEFOLD, CONST_PERSISTENT);
#endif
}

View File

@ -0,0 +1,72 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef FLOCK_COMPAT_H
#define FLOCK_COMPAT_H
#ifdef HAVE_STRUCT_FLOCK
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>
#endif
#ifdef PHP_WIN32
#include <io.h>
#include "config.w32.h"
#endif
/* php_flock internally uses fcntl whether or not flock is available
* This way our php_flock even works on NFS files.
* More info: /usr/src/linux/Documentation
*/
PHPAPI int php_flock(int fd, int operation);
#ifndef HAVE_FLOCK
# define LOCK_SH 1
# define LOCK_EX 2
# define LOCK_NB 4
# define LOCK_UN 8
PHPAPI int flock(int fd, int operation);
#endif
/* Userland LOCK_* constants */
#define PHP_LOCK_SH 1
#define PHP_LOCK_EX 2
#define PHP_LOCK_UN 3
#define PHP_LOCK_NB 4
#ifdef PHP_WIN32
# ifdef EWOULDBLOCK
# undef EWOULDBLOCK
# endif
# define EWOULDBLOCK WSAEWOULDBLOCK
# define fsync _commit
# define ftruncate(a, b) chsize(a, b)
#endif /* defined(PHP_WIN32) */
#ifndef HAVE_INET_ATON
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
# ifndef PHP_WIN32
extern int inet_aton(const char *, struct in_addr *);
# endif
#endif
#endif /* FLOCK_COMPAT_H */

View File

@ -0,0 +1,27 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Paul Panotzki - Bunyip Information Systems |
| Jim Winstead <jimw@php.net> |
| Wez Furlong |
+----------------------------------------------------------------------+
*/
#ifndef FSOCK_H
#define FSOCK_H
#include "file.h"
#include "php_network.h"
#endif /* FSOCK_H */

View File

@ -0,0 +1,35 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef HEAD_H
#define HEAD_H
#define COOKIE_EXPIRES "; expires="
#define COOKIE_MAX_AGE "; Max-Age="
#define COOKIE_DOMAIN "; domain="
#define COOKIE_PATH "; path="
#define COOKIE_SECURE "; secure"
#define COOKIE_HTTPONLY "; HttpOnly"
#define COOKIE_SAMESITE "; SameSite="
extern PHP_RINIT_FUNCTION(head);
PHPAPI int php_header(void);
PHPAPI zend_result php_setcookie(zend_string *name, zend_string *value, time_t expires,
zend_string *path, zend_string *domain, bool secure, bool httponly,
zend_string *samesite, bool url_encode);
#endif

View File

@ -0,0 +1,52 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef HTML_H
#define HTML_H
#define ENT_HTML_QUOTE_NONE 0
#define ENT_HTML_QUOTE_SINGLE 1
#define ENT_HTML_QUOTE_DOUBLE 2
#define ENT_HTML_IGNORE_ERRORS 4
#define ENT_HTML_SUBSTITUTE_ERRORS 8
#define ENT_HTML_DOC_TYPE_MASK (16|32)
#define ENT_HTML_DOC_HTML401 0
#define ENT_HTML_DOC_XML1 16
#define ENT_HTML_DOC_XHTML 32
#define ENT_HTML_DOC_HTML5 (16|32)
/* reserve bit 6 */
#define ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS 128
#define PHP_HTML_SPECIALCHARS 0
#define PHP_HTML_ENTITIES 1
#define ENT_COMPAT ENT_HTML_QUOTE_DOUBLE
#define ENT_QUOTES (ENT_HTML_QUOTE_DOUBLE | ENT_HTML_QUOTE_SINGLE)
#define ENT_NOQUOTES ENT_HTML_QUOTE_NONE
#define ENT_IGNORE ENT_HTML_IGNORE_ERRORS
#define ENT_SUBSTITUTE ENT_HTML_SUBSTITUTE_ERRORS
#define ENT_HTML401 0
#define ENT_XML1 16
#define ENT_XHTML 32
#define ENT_HTML5 (16|32)
#define ENT_DISALLOWED 128
PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset);
PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, bool double_encode, bool quiet);
PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset);
PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, zend_result *status);
#endif /* HTML_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,50 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Alexander Peslyak (Solar Designer) <solar at openwall.com> |
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef MD5_H
#define MD5_H
PHPAPI void make_digest(char *md5str, const unsigned char *digest);
PHPAPI void make_digest_ex(char *md5str, const unsigned char *digest, int len);
#include "ext/standard/basic_functions.h"
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security,
* Inc. MD5 Message-Digest Algorithm (RFC 1321).
*
* Written by Solar Designer <solar at openwall.com> in 2001, and placed
* in the public domain. There's absolutely no warranty.
*
* See md5.c for more information.
*/
/* MD5 context. */
typedef struct {
uint32_t lo, hi;
uint32_t a, b, c, d;
unsigned char buffer[64];
uint32_t block[16];
} PHP_MD5_CTX;
#define PHP_MD5_SPEC "llllllb64l16."
#define PHP_MD5Init(ctx) PHP_MD5InitArgs(ctx, NULL)
PHPAPI void PHP_MD5InitArgs(PHP_MD5_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args);
PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size);
PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx);
#endif

View File

@ -0,0 +1,22 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef PACK_H
#define PACK_H
PHP_MINIT_FUNCTION(pack);
#endif /* PACK_H */

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PAGEINFO_H
#define PAGEINFO_H
PHPAPI void php_statpage(void);
PHPAPI time_t php_getlastmod(void);
extern zend_long php_getuid(void);
extern zend_long php_getgid(void);
#endif

View File

@ -0,0 +1,72 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
| Rasmus Lerdorf <rasmus@php.net> |
| Andrei Zmievski <andrei@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_ARRAY_H
#define PHP_ARRAY_H
# include "ext/random/php_random.h"
PHP_MINIT_FUNCTION(array);
PHP_MSHUTDOWN_FUNCTION(array);
PHPAPI int php_array_merge(HashTable *dest, HashTable *src);
PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src);
PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src);
PHPAPI int php_multisort_compare(const void *a, const void *b);
PHPAPI zend_long php_count_recursive(HashTable *ht);
PHPAPI bool php_array_data_shuffle(const php_random_algo *algo, php_random_status *status, zval *array);
PHPAPI bool php_array_pick_keys(const php_random_algo *algo, php_random_status *status, zval *input, zend_long num_req, zval *retval, bool silent);
#define PHP_EXTR_OVERWRITE 0
#define PHP_EXTR_SKIP 1
#define PHP_EXTR_PREFIX_SAME 2
#define PHP_EXTR_PREFIX_ALL 3
#define PHP_EXTR_PREFIX_INVALID 4
#define PHP_EXTR_PREFIX_IF_EXISTS 5
#define PHP_EXTR_IF_EXISTS 6
#define PHP_EXTR_REFS 0x100
#define PHP_CASE_LOWER 0
#define PHP_CASE_UPPER 1
#define PHP_SORT_REGULAR 0
#define PHP_SORT_NUMERIC 1
#define PHP_SORT_STRING 2
#define PHP_SORT_DESC 3
#define PHP_SORT_ASC 4
#define PHP_SORT_LOCALE_STRING 5
#define PHP_SORT_NATURAL 6
#define PHP_SORT_FLAG_CASE 8
#define PHP_COUNT_NORMAL 0
#define PHP_COUNT_RECURSIVE 1
#define ARRAY_FILTER_USE_BOTH 1
#define ARRAY_FILTER_USE_KEY 2
ZEND_BEGIN_MODULE_GLOBALS(array)
bucket_compare_func_t *multisort_func;
bool compare_deprecation_thrown;
ZEND_END_MODULE_GLOBALS(array)
#define ARRAYG(v) ZEND_MODULE_GLOBALS_ACCESSOR(array, v)
#endif /* PHP_ARRAY_H */

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Thies C. Arntzen <thies@thieso.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_ASSERT_H
#define PHP_ASSERT_H
PHP_MINIT_FUNCTION(assert);
PHP_MSHUTDOWN_FUNCTION(assert);
PHP_RINIT_FUNCTION(assert);
PHP_RSHUTDOWN_FUNCTION(assert);
PHP_MINFO_FUNCTION(assert);
enum {
PHP_ASSERT_ACTIVE=1,
PHP_ASSERT_CALLBACK,
PHP_ASSERT_BAIL,
PHP_ASSERT_WARNING,
PHP_ASSERT_EXCEPTION
};
extern PHPAPI zend_class_entry *assertion_error_ce;
#endif /* PHP_ASSERT_H */

View File

@ -0,0 +1,23 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_BROWSCAP_H
#define PHP_BROWSCAP_H
PHP_MINIT_FUNCTION(browscap);
PHP_MSHUTDOWN_FUNCTION(browscap);
#endif /* PHP_BROWSCAP_H */

View File

@ -0,0 +1,30 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Stig Bakken <ssb@php.net> |
| Zeev Suraski <zeev@php.net> |
| Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_CRYPT_H
#define PHP_CRYPT_H
PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const char *salt, int salt_len, bool quiet);
PHP_MINIT_FUNCTION(crypt);
PHP_MSHUTDOWN_FUNCTION(crypt);
PHP_RINIT_FUNCTION(crypt);
/* sha512 crypt has the maximal salt length of 123 characters */
#define PHP_MAX_SALT_LEN 123
#endif

View File

@ -0,0 +1,39 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Pierre Alain Joye <pajoye@php.net |
+----------------------------------------------------------------------+
*/
#ifndef _CRYPT_WIHN32_H_
#define _CRYPT_WIHN32_H_
BEGIN_EXTERN_C()
#include "crypt_freesec.h"
void php_init_crypt_r(void);
void php_shutdown_crypt_r(void);
extern void _crypt_extended_init_r(void);
PHPAPI char *php_crypt_r (const char *__key, const char *__salt, struct php_crypt_extended_data * __data);
#define MD5_HASH_MAX_LEN 120
#include "crypt_blowfish.h"
extern char * php_md5_crypt_r(const char *pw, const char *salt, char *out);
extern char * php_sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
extern char * php_sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
END_EXTERN_C()
#endif /* _CRYPT_WIHN32_H_ */

View File

@ -0,0 +1,28 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Thies C. Arntzen <thies@thieso.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_DIR_H
#define PHP_DIR_H
/* directory functions */
PHP_MINIT_FUNCTION(dir);
PHP_RINIT_FUNCTION(dir);
#define PHP_SCANDIR_SORT_ASCENDING 0
#define PHP_SCANDIR_SORT_DESCENDING 1
#define PHP_SCANDIR_SORT_NONE 2
#endif /* PHP_DIR_H */

View File

@ -0,0 +1,94 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: The typical suspects |
| Marcus Boerger <helly@php.net> |
| Pollita <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_DNS_H
#define PHP_DNS_H
#if defined(HAVE_DNS_SEARCH)
#define php_dns_search(res, dname, class, type, answer, anslen) \
((int)dns_search(res, dname, class, type, (char *) answer, anslen, (struct sockaddr *)&from, &fromsize))
#define php_dns_free_handle(res) \
dns_free(res)
#define php_dns_errno(handle) h_errno
#elif defined(HAVE_RES_NSEARCH)
#define php_dns_search(res, dname, class, type, answer, anslen) \
res_nsearch(res, dname, class, type, answer, anslen);
#ifdef HAVE_RES_NDESTROY
#define php_dns_free_handle(res) \
res_ndestroy(res); \
php_dns_free_res(res)
#else
#define php_dns_free_handle(res) \
res_nclose(res); \
php_dns_free_res(res)
#endif
#define php_dns_errno(handle) handle->res_h_errno
#elif defined(HAVE_RES_SEARCH)
#define php_dns_search(res, dname, class, type, answer, anslen) \
res_search(dname, class, type, answer, anslen)
#define php_dns_free_handle(res) /* noop */
#define php_dns_errno(handle) h_errno
#endif
#if defined(HAVE_DNS_SEARCH) || defined(HAVE_RES_NSEARCH) || defined(HAVE_RES_SEARCH)
#define HAVE_DNS_SEARCH_FUNC 1
#endif
#if defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_DN_EXPAND) && defined(HAVE_DN_SKIPNAME)
#define HAVE_FULL_DNS_FUNCS 1
#endif
#if defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))
#define PHP_DNS_A 0x00000001
#define PHP_DNS_NS 0x00000002
#define PHP_DNS_CNAME 0x00000010
#define PHP_DNS_SOA 0x00000020
#define PHP_DNS_PTR 0x00000800
#define PHP_DNS_HINFO 0x00001000
#if !defined(PHP_WIN32)
# define PHP_DNS_CAA 0x00002000
#endif
#define PHP_DNS_MX 0x00004000
#define PHP_DNS_TXT 0x00008000
#define PHP_DNS_A6 0x01000000
#define PHP_DNS_SRV 0x02000000
#define PHP_DNS_NAPTR 0x04000000
#define PHP_DNS_AAAA 0x08000000
#define PHP_DNS_ANY 0x10000000
#if defined(PHP_WIN32)
# define PHP_DNS_NUM_TYPES 12 /* Number of DNS Types Supported by PHP currently */
# define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA)
#else
# define PHP_DNS_NUM_TYPES 13 /* Number of DNS Types Supported by PHP currently */
# define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_CAA|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA)
#endif
#endif
#ifndef INT16SZ
#define INT16SZ 2
#endif
#ifndef INT32SZ
#define INT32SZ 4
#endif
#endif /* PHP_DNS_H */

View File

@ -0,0 +1,29 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_EXT_SYSLOG_H
#define PHP_EXT_SYSLOG_H
#ifdef HAVE_SYSLOG_H
#include "php_syslog.h"
PHP_MINIT_FUNCTION(syslog);
PHP_RSHUTDOWN_FUNCTION(syslog);
#endif
#endif /* PHP_EXT_SYSLOG_H */

View File

@ -0,0 +1,67 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_FILESTAT_H
#define PHP_FILESTAT_H
PHP_RINIT_FUNCTION(filestat);
PHP_RSHUTDOWN_FUNCTION(filestat);
#ifdef PHP_WIN32
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
#define S_IXUSR S_IEXEC
#define S_IRGRP S_IREAD
#define S_IWGRP S_IWRITE
#define S_IXGRP S_IEXEC
#define S_IROTH S_IREAD
#define S_IWOTH S_IWRITE
#define S_IXOTH S_IEXEC
#undef getgid
#define getgroups(a, b) 0
#define getgid() 1
#define getuid() 1
#endif
/* Compatibility. */
typedef size_t php_stat_len;
PHPAPI void php_clear_stat_cache(bool clear_realpath_cache, const char *filename, size_t filename_len);
PHPAPI void php_stat(zend_string *filename, int type, zval *return_value);
/* Switches for various filestat functions: */
#define FS_PERMS 0
#define FS_INODE 1
#define FS_SIZE 2
#define FS_OWNER 3
#define FS_GROUP 4
#define FS_ATIME 5
#define FS_MTIME 6
#define FS_CTIME 7
#define FS_TYPE 8
#define FS_IS_W 9
#define FS_IS_R 10
#define FS_IS_X 11
#define FS_IS_FILE 12
#define FS_IS_DIR 13
#define FS_IS_LINK 14
#define FS_EXISTS 15
#define FS_LSTAT 16
#define FS_STAT 17
#define FS_LPERMS 18
#endif /* PHP_FILESTAT_H */

View File

@ -0,0 +1,29 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Jim Winstead <jimw@php.net> |
| Hartmut Holzgraefe <hholzgra@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_FOPEN_WRAPPERS_H
#define PHP_FOPEN_WRAPPERS_H
php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
extern PHPAPI const php_stream_wrapper php_stream_http_wrapper;
extern PHPAPI const php_stream_wrapper php_stream_ftp_wrapper;
extern PHPAPI const php_stream_wrapper php_stream_php_wrapper;
extern PHPAPI /*const*/ php_stream_wrapper php_plain_files_wrapper;
#endif

View File

@ -0,0 +1,29 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_HTTP_H
#define PHP_HTTP_H
#include "php.h"
#include "zend_types.h" /* for zend_string */
#include "zend_smart_str.h"
PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, size_t num_prefix_len,
const zend_string *key_prefix,
zval *type, const zend_string *arg_sep, int enc_type);
#endif

View File

@ -0,0 +1,58 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_IMAGE_H
#define PHP_IMAGE_H
/* {{{ enum image_filetype
This enum is used to have ext/standard/image.c and ext/exif/exif.c use
the same constants for file types.
*/
typedef enum
{ IMAGE_FILETYPE_UNKNOWN=0,
IMAGE_FILETYPE_GIF=1,
IMAGE_FILETYPE_JPEG,
IMAGE_FILETYPE_PNG,
IMAGE_FILETYPE_SWF,
IMAGE_FILETYPE_PSD,
IMAGE_FILETYPE_BMP,
IMAGE_FILETYPE_TIFF_II, /* intel */
IMAGE_FILETYPE_TIFF_MM, /* motorola */
IMAGE_FILETYPE_JPC,
IMAGE_FILETYPE_JP2,
IMAGE_FILETYPE_JPX,
IMAGE_FILETYPE_JB2,
IMAGE_FILETYPE_SWC,
IMAGE_FILETYPE_IFF,
IMAGE_FILETYPE_WBMP,
/* IMAGE_FILETYPE_JPEG2000 is a userland alias for IMAGE_FILETYPE_JPC */
IMAGE_FILETYPE_XBM,
IMAGE_FILETYPE_ICO,
IMAGE_FILETYPE_WEBP,
IMAGE_FILETYPE_AVIF,
/* WHEN EXTENDING: PLEASE ALSO REGISTER IN basic_function.stub.php */
IMAGE_FILETYPE_COUNT
} image_filetype;
/* }}} */
PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetype);
PHPAPI char * php_image_type_to_mime_type(int image_type);
PHPAPI bool php_is_image_avif(php_stream *stream);
#endif /* PHP_IMAGE_H */

View File

@ -0,0 +1,60 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_INCOMPLETE_CLASS_H
#define PHP_INCOMPLETE_CLASS_H
#include "ext/standard/basic_functions.h"
extern PHPAPI zend_class_entry *php_ce_incomplete_class;
#define PHP_IC_ENTRY php_ce_incomplete_class
#define PHP_SET_CLASS_ATTRIBUTES(struc) \
/* OBJECTS_FIXME: Fix for new object model */ \
if (Z_OBJCE_P(struc) == php_ce_incomplete_class) { \
class_name = php_lookup_class_name(Z_OBJ_P(struc)); \
if (!class_name) { \
class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
} \
incomplete_class = 1; \
} else { \
class_name = zend_string_copy(Z_OBJCE_P(struc)->name); \
}
#define PHP_CLEANUP_CLASS_ATTRIBUTES() \
zend_string_release_ex(class_name, 0)
#define PHP_CLASS_ATTRIBUTES \
zend_string *class_name; \
bool incomplete_class ZEND_ATTRIBUTE_UNUSED = 0
#define INCOMPLETE_CLASS "__PHP_Incomplete_Class"
#define MAGIC_MEMBER "__PHP_Incomplete_Class_Name"
#ifdef __cplusplus
extern "C" {
#endif
PHPAPI void php_register_incomplete_class_handlers(void);
PHPAPI zend_string *php_lookup_class_name(zend_object *object);
PHPAPI void php_store_class_name(zval *object, zend_string *name);
#ifdef __cplusplus
};
#endif
#endif

View File

@ -0,0 +1 @@
#include "ext/random/php_random.h"

View File

@ -0,0 +1,53 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_MAIL_H
#define PHP_MAIL_H
PHP_MINFO_FUNCTION(mail);
PHPAPI zend_string *php_mail_build_headers(HashTable *headers);
PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd);
#define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
do { \
if (Z_TYPE_P(val) == IS_STRING) { \
php_mail_build_headers_elem(&s, key, val); \
} else if (Z_TYPE_P(val) == IS_ARRAY) { \
if (zend_string_equals_literal_ci(key, target)) { \
zend_type_error("Header \"%s\" must be of type string, array given", target); \
break; \
} \
php_mail_build_headers_elems(&s, key, val); \
} else { \
zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_value_name(val)); \
} \
} while(0)
#define PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val) \
do { \
if (Z_TYPE_P(val) == IS_STRING) { \
php_mail_build_headers_elem(&s, key, val); \
} else if (Z_TYPE_P(val) == IS_ARRAY) { \
php_mail_build_headers_elems(&s, key, val); \
} else { \
zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_value_name(val)); \
} \
} while(0)
#endif /* PHP_MAIL_H */

View File

@ -0,0 +1,117 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Jim Winstead <jimw@php.net> |
| Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_MATH_H
#define PHP_MATH_H
PHPAPI double _php_math_round(double value, int places, int mode);
PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep);
PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
PHPAPI zend_string *_php_math_number_format_long(zend_long num, zend_long dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base);
PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);
PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);
#include <math.h>
#ifndef M_E
#define M_E 2.7182818284590452354 /* e */
#endif
#ifndef M_LOG2E
#define M_LOG2E 1.4426950408889634074 /* log_2 e */
#endif
#ifndef M_LOG10E
#define M_LOG10E 0.43429448190325182765 /* log_10 e */
#endif
#ifndef M_LN2
#define M_LN2 0.69314718055994530942 /* log_e 2 */
#endif
#ifndef M_LN10
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
#ifndef M_PI_4
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#endif
#ifndef M_1_PI
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#endif
#ifndef M_2_PI
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#endif
#ifndef M_SQRTPI
#define M_SQRTPI 1.77245385090551602729 /* sqrt(pi) */
#endif
#ifndef M_2_SQRTPI
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#endif
#ifndef M_LNPI
#define M_LNPI 1.14472988584940017414 /* ln(pi) */
#endif
#ifndef M_EULER
#define M_EULER 0.57721566490153286061 /* Euler constant */
#endif
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif
#ifndef M_SQRT3
#define M_SQRT3 1.73205080756887729352 /* sqrt(3) */
#endif
/* Define rounding modes (all are round-to-nearest) */
#ifndef PHP_ROUND_HALF_UP
#define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */
#endif
#ifndef PHP_ROUND_HALF_DOWN
#define PHP_ROUND_HALF_DOWN 0x02 /* Down == towards zero */
#endif
#ifndef PHP_ROUND_HALF_EVEN
#define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */
#endif
#ifndef PHP_ROUND_HALF_ODD
#define PHP_ROUND_HALF_ODD 0x04
#endif
#endif /* PHP_MATH_H */

View File

@ -0,0 +1 @@
#include "ext/random/php_random.h"

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_NET_H
#define PHP_NET_H
#include "php.h"
#include "php_network.h"
PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr);
#endif /* PHP_NET_H */

View File

@ -0,0 +1,64 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Anthony Ferrara <ircmaxell@php.net> |
| Charles R. Portwood II <charlesportwoodii@erianna.com> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PASSWORD_H
#define PHP_PASSWORD_H
PHP_MINIT_FUNCTION(password);
PHP_MSHUTDOWN_FUNCTION(password);
#define PHP_PASSWORD_DEFAULT PHP_PASSWORD_BCRYPT
#define PHP_PASSWORD_BCRYPT_COST 10
#ifdef HAVE_ARGON2LIB
/**
* When updating these values, synchronize ext/sodium/sodium_pwhash.c values.
* Note that libargon expresses memlimit in KB, while libsoidum uses bytes.
*/
#define PHP_PASSWORD_ARGON2_MEMORY_COST (64 << 10)
#define PHP_PASSWORD_ARGON2_TIME_COST 4
#define PHP_PASSWORD_ARGON2_THREADS 1
#endif
typedef struct _php_password_algo {
const char *name;
zend_string *(*hash)(const zend_string *password, zend_array *options);
bool (*verify)(const zend_string *password, const zend_string *hash);
bool (*needs_rehash)(const zend_string *password, zend_array *options);
int (*get_info)(zval *return_value, const zend_string *hash);
bool (*valid)(const zend_string *hash);
} php_password_algo;
extern const php_password_algo php_password_algo_bcrypt;
#ifdef HAVE_ARGON2LIB
extern const php_password_algo php_password_algo_argon2i;
extern const php_password_algo php_password_algo_argon2id;
#endif
PHPAPI int php_password_algo_register(const char*, const php_password_algo*);
PHPAPI void php_password_algo_unregister(const char*);
PHPAPI const php_password_algo* php_password_algo_default(void);
PHPAPI zend_string *php_password_algo_extract_ident(const zend_string*);
PHPAPI const php_password_algo* php_password_algo_find(const zend_string*);
PHPAPI const php_password_algo* php_password_algo_identify_ex(const zend_string*, const php_password_algo*);
static inline const php_password_algo* php_password_algo_identify(const zend_string *hash) {
return php_password_algo_identify_ex(hash, php_password_algo_default());
}
#endif

View File

@ -0,0 +1 @@
#include "ext/random/php_random.h"

View File

@ -0,0 +1 @@
#include "ext/random/php_random.h"

View File

@ -0,0 +1,19 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
/* Header moved to Zend. This file is retained for BC. */
#include "zend_smart_string.h"

View File

@ -0,0 +1,19 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
/* Header moved to Zend. This file is retained for BC. */
#include "zend_smart_string_public.h"

View File

@ -0,0 +1,55 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
#include "basic_functions.h"
#include "php_math.h"
#include "php_string.h"
#include "base64.h"
#include "php_dir.h"
#include "php_dns.h"
#include "php_mail.h"
#include "md5.h"
#include "sha1.h"
#include "html.h"
#include "exec.h"
#include "file.h"
#include "php_ext_syslog.h"
#include "php_filestat.h"
#include "php_browscap.h"
#include "pack.h"
#include "datetime.h"
#include "url.h"
#include "pageinfo.h"
#include "fsock.h"
#include "php_image.h"
#include "info.h"
#include "php_var.h"
#include "quot_print.h"
#include "dl.h"
#include "php_crypt.h"
#include "head.h"
#include "php_output.h"
#include "php_array.h"
#include "php_assert.h"
#include "php_versioning.h"
#include "php_password.h"
#include "php_version.h"
#define PHP_STANDARD_VERSION PHP_VERSION
#define phpext_standard_ptr basic_functions_module_ptr
PHP_MINIT_FUNCTION(standard_filters);
PHP_MSHUTDOWN_FUNCTION(standard_filters);

View File

@ -0,0 +1,90 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
| Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_STRING_H
#define PHP_STRING_H
# include "ext/random/php_random.h"
#ifdef ZTS
PHP_MINIT_FUNCTION(localeconv);
PHP_MSHUTDOWN_FUNCTION(localeconv);
#endif
#ifdef ZEND_INTRIN_SSE4_2_FUNC_PTR
PHP_MINIT_FUNCTION(string_intrin);
#endif
#define strnatcmp(a, b) \
strnatcmp_ex(a, strlen(a), b, strlen(b), 0)
#define strnatcasecmp(a, b) \
strnatcmp_ex(a, strlen(a), b, strlen(b), 1)
PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, bool is_case_insensitive);
PHPAPI struct lconv *localeconv_r(struct lconv *out);
PHPAPI char *php_strtoupper(char *s, size_t len);
PHPAPI char *php_strtolower(char *s, size_t len);
PHPAPI zend_string *php_string_toupper(zend_string *s);
PHPAPI zend_string *php_string_tolower(zend_string *s);
PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen);
PHPAPI zend_string *php_addslashes(zend_string *str);
PHPAPI void php_stripslashes(zend_string *str);
PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t what_len);
PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t what_len);
PHPAPI void php_stripcslashes(zend_string *str);
PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t sufflen);
PHPAPI size_t php_dirname(char *str, size_t len);
PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len);
PHPAPI zend_string *php_str_to_str(const char *haystack, size_t length, const char *needle,
size_t needle_len, const char *str, size_t str_len);
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode);
PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len);
PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, const char *allow, size_t allow_len, bool allow_tag_spaces);
PHPAPI void php_implode(const zend_string *delim, HashTable *arr, zval *return_value);
PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit);
PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, bool case_insensitive);
PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2);
PHPAPI int string_natural_case_compare_function(zval *result, zval *op1, zval *op2);
PHPAPI bool php_binary_string_shuffle(const php_random_algo *algo, php_random_status *status, char *str, zend_long len);
#ifdef _REENTRANT
# ifdef PHP_WIN32
# include <wchar.h>
# endif
# define php_mblen(ptr, len) ((int) mbrlen(ptr, len, &BG(mblen_state)))
# define php_mb_reset() memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)))
#else
# define php_mblen(ptr, len) mblen(ptr, len)
# define php_mb_reset() php_ignore_value(mblen(NULL, 0))
#endif
#define PHP_STR_PAD_LEFT 0
#define PHP_STR_PAD_RIGHT 1
#define PHP_STR_PAD_BOTH 2
#define PHP_PATHINFO_DIRNAME 1
#define PHP_PATHINFO_BASENAME 2
#define PHP_PATHINFO_EXTENSION 4
#define PHP_PATHINFO_FILENAME 8
#define PHP_PATHINFO_ALL (PHP_PATHINFO_DIRNAME | PHP_PATHINFO_BASENAME | PHP_PATHINFO_EXTENSION | PHP_PATHINFO_FILENAME)
#define PHP_STR_STRSPN 0
#define PHP_STR_STRCSPN 1
#endif /* PHP_STRING_H */

View File

@ -0,0 +1,23 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Ilia Alshanetsky <ilia@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_UUENCODE_H
#define PHP_UUENCODE_H
PHPAPI zend_string *php_uudecode(const char *src, size_t src_len);
PHPAPI zend_string *php_uuencode(const char *src, size_t src_len);
#endif /* PHP_UUENCODE_H */

View File

@ -0,0 +1,69 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jani Lehtimäki <jkl@njet.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_VAR_H
#define PHP_VAR_H
#include "ext/standard/basic_functions.h"
#include "zend_smart_str_public.h"
PHP_MINIT_FUNCTION(var);
PHPAPI void php_var_dump(zval *struc, int level);
PHPAPI void php_var_export(zval *struc, int level);
PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf);
PHPAPI void php_debug_zval_dump(zval *struc, int level);
typedef struct php_serialize_data *php_serialize_data_t;
typedef struct php_unserialize_data *php_unserialize_data_t;
PHPAPI void php_var_serialize(smart_str *buf, zval *struc, php_serialize_data_t *data);
PHPAPI int php_var_unserialize(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
PHPAPI int php_var_unserialize_ref(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
PHPAPI int php_var_unserialize_intern(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
PHPAPI php_serialize_data_t php_var_serialize_init(void);
PHPAPI void php_var_serialize_destroy(php_serialize_data_t d);
PHPAPI php_unserialize_data_t php_var_unserialize_init(void);
PHPAPI void php_var_unserialize_destroy(php_unserialize_data_t d);
PHPAPI HashTable *php_var_unserialize_get_allowed_classes(php_unserialize_data_t d);
PHPAPI void php_var_unserialize_set_allowed_classes(php_unserialize_data_t d, HashTable *classes);
PHPAPI void php_var_unserialize_set_max_depth(php_unserialize_data_t d, zend_long max_depth);
PHPAPI zend_long php_var_unserialize_get_max_depth(php_unserialize_data_t d);
PHPAPI void php_var_unserialize_set_cur_depth(php_unserialize_data_t d, zend_long cur_depth);
PHPAPI zend_long php_var_unserialize_get_cur_depth(php_unserialize_data_t d);
#define PHP_VAR_SERIALIZE_INIT(d) \
(d) = php_var_serialize_init()
#define PHP_VAR_SERIALIZE_DESTROY(d) \
php_var_serialize_destroy(d)
#define PHP_VAR_UNSERIALIZE_INIT(d) \
(d) = php_var_unserialize_init()
#define PHP_VAR_UNSERIALIZE_DESTROY(d) \
php_var_unserialize_destroy(d)
PHPAPI void php_unserialize_with_options(zval *return_value, const char *buf, const size_t buf_len, HashTable *options, const char* function_name);
PHPAPI void var_replace(php_unserialize_data_t *var_hash, zval *ozval, zval *nzval);
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hash, zval *val);
PHPAPI zval *var_tmp_var(php_unserialize_data_t *var_hashx);
PHPAPI void var_destroy(php_unserialize_data_t *var_hash);
#endif /* PHP_VAR_H */

View File

@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_VERSIONING_H
#define PHP_VERSIONING_H
#include "ext/standard/basic_functions.h"
PHPAPI char *php_canonicalize_version(const char *);
PHPAPI int php_version_compare(const char *, const char *);
#endif

View File

@ -0,0 +1,52 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
#ifdef PHP_WIN32
typedef HANDLE php_file_descriptor_t;
typedef DWORD php_process_id_t;
# define PHP_INVALID_FD INVALID_HANDLE_VALUE
#else
typedef int php_file_descriptor_t;
typedef pid_t php_process_id_t;
# define PHP_INVALID_FD (-1)
#endif
/* Environment block under Win32 is a NUL terminated sequence of NUL terminated
* name=value strings.
* Under Unix, it is an argv style array. */
typedef struct _php_process_env {
char *envp;
#ifndef PHP_WIN32
char **envarray;
#endif
} php_process_env;
typedef struct _php_process_handle {
php_process_id_t child;
#ifdef PHP_WIN32
HANDLE childHandle;
#endif
int npipes;
zend_resource **pipes;
zend_string *command;
php_process_env env;
#if HAVE_SYS_WAIT_H
/* We can only request the status once before it becomes unavailable.
* Cache the result so we can request it multiple times. */
int cached_exit_wait_status_value;
bool has_cached_exit_wait_status;
#endif
} php_process_handle;

View File

@ -0,0 +1,23 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Kirill Maximov (kir@rus.net) |
+----------------------------------------------------------------------+
*/
#ifndef QUOT_PRINT_H
#define QUOT_PRINT_H
PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t length, int replace_us_by_ws);
PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t length);
#endif /* QUOT_PRINT_H */

View File

@ -0,0 +1,42 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Clayton Collie <clcollie@mindspring.com> |
+----------------------------------------------------------------------+
*/
#ifndef SCANF_H
#define SCANF_H
#define SCAN_MAX_ARGS 0xFF /* Maximum number of variable which can be */
/* passed to (f|s)scanf. This is an artificial */
/* upper limit to keep resources in check and */
/* minimize the possibility of exploits */
#define SCAN_SUCCESS SUCCESS
#define SCAN_ERROR_EOF -1 /* indicates premature termination of scan */
/* can be caused by bad parameters or format*/
/* string. */
#define SCAN_ERROR_INVALID_FORMAT (SCAN_ERROR_EOF - 1)
#define SCAN_ERROR_WRONG_PARAM_COUNT (SCAN_ERROR_INVALID_FORMAT - 1)
/*
* The following are here solely for the benefit of the scanf type functions
* e.g. fscanf
*/
PHPAPI int ValidateFormat(char *format, int numVars, int *totalVars);
PHPAPI int php_sscanf_internal(char *string,char *format,int argCount,zval *args,
int varStart, zval *return_value);
#endif /* SCANF_H */

View File

@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SHA1_H
#define SHA1_H
#include "ext/standard/basic_functions.h"
/* SHA1 context. */
typedef struct {
uint32_t state[5]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_SHA1_CTX;
#define PHP_SHA1_SPEC "l5l2b64."
#define PHP_SHA1Init(ctx) PHP_SHA1InitArgs(ctx, NULL)
PHPAPI void PHP_SHA1InitArgs(PHP_SHA1_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, size_t);
PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest);
#endif

View File

@ -0,0 +1,20 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* Flags for stream_socket_client */
#define PHP_STREAM_CLIENT_PERSISTENT 1
#define PHP_STREAM_CLIENT_ASYNC_CONNECT 2
#define PHP_STREAM_CLIENT_CONNECT 4

View File

@ -0,0 +1,53 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef URL_H
#define URL_H
typedef struct php_url {
zend_string *scheme;
zend_string *user;
zend_string *pass;
zend_string *host;
unsigned short port;
zend_string *path;
zend_string *query;
zend_string *fragment;
} php_url;
PHPAPI void php_url_free(php_url *theurl);
PHPAPI php_url *php_url_parse(char const *str);
PHPAPI php_url *php_url_parse_ex(char const *str, size_t length);
PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port);
PHPAPI size_t php_url_decode(char *str, size_t len); /* return value: length of decoded string */
PHPAPI size_t php_raw_url_decode(char *str, size_t len); /* return value: length of decoded string */
PHPAPI zend_string *php_url_encode(char const *s, size_t len);
PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len);
PHPAPI char *php_replace_controlchars_ex(char *str, size_t len);
#define PHP_URL_SCHEME 0
#define PHP_URL_HOST 1
#define PHP_URL_PORT 2
#define PHP_URL_USER 3
#define PHP_URL_PASS 4
#define PHP_URL_PATH 5
#define PHP_URL_QUERY 6
#define PHP_URL_FRAGMENT 7
#define PHP_QUERY_RFC1738 1
#define PHP_QUERY_RFC3986 2
#endif /* URL_H */

View File

@ -0,0 +1,63 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef URL_SCANNER_EX_H
#define URL_SCANNER_EX_H
PHP_MINIT_FUNCTION(url_scanner_ex);
PHP_MSHUTDOWN_FUNCTION(url_scanner_ex);
PHP_RINIT_FUNCTION(url_scanner_ex);
PHP_RSHUTDOWN_FUNCTION(url_scanner_ex);
PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode);
PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_session_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_session_vars(void);
PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_vars(void);
#include "zend_smart_str_public.h"
typedef struct {
/* Used by the mainloop of the scanner */
smart_str tag; /* read only */
smart_str arg; /* read only */
smart_str val; /* read only */
smart_str buf;
/* The result buffer */
smart_str result;
/* The data which is appended to each relative URL/FORM */
smart_str form_app, url_app;
int active;
char *lookup_data;
int state;
int type;
smart_str attr_val;
int tag_type;
int attr_type;
/* Everything above is zeroed in RINIT */
HashTable *tags;
} url_adapt_state_ex_t;
#endif

View File

@ -0,0 +1,66 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 1c03251b4e0b22056da43bf86087d6996454d2a0 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_php_user_filter_filter, 0, 4, IS_LONG, 0)
ZEND_ARG_INFO(0, in)
ZEND_ARG_INFO(0, out)
ZEND_ARG_INFO(1, consumed)
ZEND_ARG_TYPE_INFO(0, closing, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_php_user_filter_onCreate, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_php_user_filter_onClose, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_METHOD(php_user_filter, filter);
ZEND_METHOD(php_user_filter, onCreate);
ZEND_METHOD(php_user_filter, onClose);
static const zend_function_entry class_php_user_filter_methods[] = {
ZEND_ME(php_user_filter, filter, arginfo_class_php_user_filter_filter, ZEND_ACC_PUBLIC)
ZEND_ME(php_user_filter, onCreate, arginfo_class_php_user_filter_onCreate, ZEND_ACC_PUBLIC)
ZEND_ME(php_user_filter, onClose, arginfo_class_php_user_filter_onClose, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static void register_user_filters_symbols(int module_number)
{
REGISTER_LONG_CONSTANT("PSFS_PASS_ON", PSFS_PASS_ON, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PSFS_FEED_ME", PSFS_FEED_ME, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PSFS_ERR_FATAL", PSFS_ERR_FATAL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PSFS_FLAG_NORMAL", PSFS_FLAG_NORMAL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PSFS_FLAG_FLUSH_INC", PSFS_FLAG_FLUSH_INC, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PSFS_FLAG_FLUSH_CLOSE", PSFS_FLAG_FLUSH_CLOSE, CONST_PERSISTENT);
}
static zend_class_entry *register_class_php_user_filter(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "php_user_filter", class_php_user_filter_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zval property_filtername_default_value;
ZVAL_EMPTY_STRING(&property_filtername_default_value);
zend_string *property_filtername_name = zend_string_init("filtername", sizeof("filtername") - 1, 1);
zend_declare_typed_property(class_entry, property_filtername_name, &property_filtername_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_filtername_name);
zval property_params_default_value;
ZVAL_EMPTY_STRING(&property_params_default_value);
zend_string *property_params_name = zend_string_init("params", sizeof("params") - 1, 1);
zend_declare_typed_property(class_entry, property_params_name, &property_params_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY));
zend_string_release(property_params_name);
zval property_stream_default_value;
ZVAL_NULL(&property_stream_default_value);
zend_string *property_stream_name = zend_string_init("stream", sizeof("stream") - 1, 1);
zend_declare_typed_property(class_entry, property_stream_name, &property_stream_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
zend_string_release(property_stream_name);
return class_entry;
}

View File

@ -0,0 +1,133 @@
#ifndef _PHP_WINVER_H
#define _PHP_WINVER_H
#ifndef SM_TABLETPC
#define SM_TABLETPC 86
#endif
#ifndef SM_MEDIACENTER
#define SM_MEDIACENTER 87
#endif
#ifndef SM_STARTER
#define SM_STARTER 88
#endif
#ifndef SM_SERVERR2
#define SM_SERVERR2 89
#endif
#ifndef VER_SUITE_WH_SERVER
#define VER_SUITE_WH_SERVER 0x8000
#endif
#ifndef PRODUCT_ULTIMATE
#define PRODUCT_UNDEFINED 0x00000000
#define PRODUCT_ULTIMATE 0x00000001
#define PRODUCT_HOME_BASIC 0x00000002
#define PRODUCT_HOME_PREMIUM 0x00000003
#define PRODUCT_ENTERPRISE 0x00000004
#define PRODUCT_HOME_BASIC_N 0x00000005
#define PRODUCT_BUSINESS 0x00000006
#define PRODUCT_STANDARD_SERVER 0x00000007
#define PRODUCT_DATACENTER_SERVER 0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
#define PRODUCT_ENTERPRISE_SERVER 0x0000000A
#define PRODUCT_STARTER 0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
#define PRODUCT_BUSINESS_N 0x00000010
#define PRODUCT_WEB_SERVER 0x00000011
#define PRODUCT_CLUSTER_SERVER 0x00000012
#define PRODUCT_HOME_SERVER 0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
#define PRODUCT_HOME_PREMIUM_N 0x0000001A
#define PRODUCT_ENTERPRISE_N 0x0000001B
#define PRODUCT_ULTIMATE_N 0x0000001C
#define PRODUCT_WEB_SERVER_CORE 0x0000001D
#define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
#define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
#define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
#define PRODUCT_SERVER_FOUNDATION 0x00000021
#define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
#define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
#define PRODUCT_STANDARD_SERVER_V 0x00000024
#define PRODUCT_DATACENTER_SERVER_V 0x00000025
#define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
#define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
#define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
#define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
#define PRODUCT_HYPERV 0x0000002A
#define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
#define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
#define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
#define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
#define PRODUCT_STARTER_N 0x0000002F
#define PRODUCT_PROFESSIONAL 0x00000030
#define PRODUCT_PROFESSIONAL_N 0x00000031
#define PRODUCT_SB_SOLUTION_SERVER 0x00000032
#define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
#define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
#define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
#define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
#define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
#define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
#define PRODUCT_CLUSTER_SERVER_V 0x00000040
#define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
#define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
#define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
#define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
#define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
#define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
#define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
#define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
#define PRODUCT_CORE_N 0x00000062
#define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
#define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
#define PRODUCT_CORE 0x00000065
#define PRODUCT_PROFESSIONAL_WMC 0x00000067
#endif
#ifndef VER_NT_WORKSTATION
#define VER_NT_WORKSTATION 0x0000001
#define VER_NT_DOMAIN_CONTROLLER 0x0000002
#define VER_NT_SERVER 0x0000003
#endif
#ifndef VER_SUITE_SMALLBUSINESS
#define VER_SUITE_SMALLBUSINESS 0x00000001
#define VER_SUITE_ENTERPRISE 0x00000002
#define VER_SUITE_BACKOFFICE 0x00000004
#define VER_SUITE_COMMUNICATIONS 0x00000008
#define VER_SUITE_TERMINAL 0x00000010
#define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
#define VER_SUITE_EMBEDDEDNT 0x00000040
#define VER_SUITE_DATACENTER 0x00000080
#define VER_SUITE_SINGLEUSERTS 0x00000100
#define VER_SUITE_PERSONAL 0x00000200
#define VER_SUITE_BLADE 0x00000400
#define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
#define VER_SUITE_SECURITY_APPLIANCE 0x00001000
#endif
#ifndef VER_SUITE_STORAGE_SERVER
# define VER_SUITE_STORAGE_SERVER 0x00002000
#endif
#ifndef VER_SUITE_COMPUTE_SERVER
# define VER_SUITE_COMPUTE_SERVER 0x00004000
#endif
#ifndef PROCESSOR_ARCHITECTURE_AMD64
#define PROCESSOR_ARCHITECTURE_AMD64 9
#endif
#endif

View File

@ -0,0 +1,157 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_EXPAT_COMPAT_H
#define PHP_EXPAT_COMPAT_H
#ifdef PHP_WIN32
#include "config.w32.h"
#else
#include <php_config.h>
#endif
#ifdef PHP_WIN32
# define PHP_XML_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_XML_API __attribute__ ((visibility("default")))
#else
# define PHP_XML_API
#endif
#if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML)
#define LIBXML_EXPAT_COMPAT 1
#include "php.h"
#include "php_compat.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/tree.h>
#include <libxml/hash.h>
/* For compatibility with the misspelled version. */
#define _ns_seperator _ns_separator
typedef xmlChar XML_Char;
typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **);
typedef void (*XML_EndElementHandler)(void *, const XML_Char *);
typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int);
typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *);
typedef void (*XML_CommentHandler)(void *, const XML_Char *);
typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int);
typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *);
typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *);
typedef struct _XML_Memory_Handling_Suite {
void *(*malloc_fcn)(size_t size);
void *(*realloc_fcn)(void *ptr, size_t size);
void (*free_fcn)(void *ptr);
} XML_Memory_Handling_Suite;
typedef struct _XML_Parser {
int use_namespace;
xmlChar *_ns_separator;
void *user;
xmlParserCtxtPtr parser;
XML_StartElementHandler h_start_element;
XML_EndElementHandler h_end_element;
XML_CharacterDataHandler h_cdata;
XML_ProcessingInstructionHandler h_pi;
XML_CommentHandler h_comment;
XML_DefaultHandler h_default;
XML_UnparsedEntityDeclHandler h_unparsed_entity_decl;
XML_NotationDeclHandler h_notation_decl;
XML_ExternalEntityRefHandler h_external_entity_ref;
XML_StartNamespaceDeclHandler h_start_ns;
XML_EndNamespaceDeclHandler h_end_ns;
} *XML_Parser;
enum XML_Error {
XML_ERROR_NONE,
XML_ERROR_NO_MEMORY,
XML_ERROR_SYNTAX,
XML_ERROR_NO_ELEMENTS,
XML_ERROR_INVALID_TOKEN,
XML_ERROR_UNCLOSED_TOKEN,
XML_ERROR_PARTIAL_CHAR,
XML_ERROR_TAG_MISMATCH,
XML_ERROR_DUPLICATE_ATTRIBUTE,
XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
XML_ERROR_PARAM_ENTITY_REF,
XML_ERROR_UNDEFINED_ENTITY,
XML_ERROR_RECURSIVE_ENTITY_REF,
XML_ERROR_ASYNC_ENTITY,
XML_ERROR_BAD_CHAR_REF,
XML_ERROR_BINARY_ENTITY_REF,
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
XML_ERROR_MISPLACED_XML_PI,
XML_ERROR_UNKNOWN_ENCODING,
XML_ERROR_INCORRECT_ENCODING,
XML_ERROR_UNCLOSED_CDATA_SECTION,
XML_ERROR_EXTERNAL_ENTITY_HANDLING,
XML_ERROR_NOT_STANDALONE,
XML_ERROR_UNEXPECTED_STATE,
XML_ERROR_ENTITY_DECLARED_IN_PE,
XML_ERROR_FEATURE_REQUIRES_XML_DTD,
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
};
enum XML_Content_Type {
XML_CTYPE_EMPTY = 1,
XML_CTYPE_ANY,
XML_CTYPE_MIXED,
XML_CTYPE_NAME,
XML_CTYPE_CHOICE,
XML_CTYPE_SEQ
};
PHP_XML_API XML_Parser XML_ParserCreate(const XML_Char *);
PHP_XML_API XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char);
PHP_XML_API XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *);
PHP_XML_API void XML_SetUserData(XML_Parser, void *);
PHP_XML_API void *XML_GetUserData(XML_Parser);
PHP_XML_API void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler);
PHP_XML_API void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler);
PHP_XML_API void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler);
PHP_XML_API void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler);
PHP_XML_API void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler);
PHP_XML_API void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler);
PHP_XML_API void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler);
PHP_XML_API void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler);
PHP_XML_API void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler);
PHP_XML_API int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final);
PHP_XML_API int XML_GetErrorCode(XML_Parser);
PHP_XML_API const XML_Char *XML_ErrorString(int);
PHP_XML_API int XML_GetCurrentLineNumber(XML_Parser);
PHP_XML_API int XML_GetCurrentColumnNumber(XML_Parser);
PHP_XML_API int XML_GetCurrentByteIndex(XML_Parser);
PHP_XML_API int XML_GetCurrentByteCount(XML_Parser);
PHP_XML_API const XML_Char *XML_ExpatVersion(void);
PHP_XML_API void XML_ParserFree(XML_Parser);
#elif defined(HAVE_LIBEXPAT)
#include "php.h"
#include <expat.h>
#endif /* HAVE_LIBEXPAT */
#endif /* PHP_EXPAT_COMPAT_H */

View File

@ -0,0 +1,55 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Stig Sæther Bakken <ssb@php.net> |
| Thies C. Arntzen <thies@thieso.net> |
| Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_XML_H
#define PHP_XML_H
#ifdef HAVE_XML
extern zend_module_entry xml_module_entry;
#define xml_module_ptr &xml_module_entry
#include "php_version.h"
#define PHP_XML_VERSION PHP_VERSION
#include "expat_compat.h"
#ifdef XML_UNICODE
#error "UTF-16 Unicode support not implemented!"
#endif
#else
#define xml_module_ptr NULL
#endif /* HAVE_XML */
#define phpext_xml_ptr xml_module_ptr
enum php_xml_option {
PHP_XML_OPTION_CASE_FOLDING = 1,
PHP_XML_OPTION_TARGET_ENCODING,
PHP_XML_OPTION_SKIP_TAGSTART,
PHP_XML_OPTION_SKIP_WHITE
};
#ifdef LIBXML_EXPAT_COMPAT
#define PHP_XML_SAX_IMPL "libxml"
#else
#define PHP_XML_SAX_IMPL "expat"
#endif
#endif /* PHP_XML_H */

View File

@ -0,0 +1,181 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: f87e295b35cd43db72a936ee5745297a45730090 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_xml_parser_create, 0, 0, XMLParser, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_xml_parser_create_ns, 0, 0, XMLParser, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, separator, IS_STRING, 0, "\":\"")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_set_object, 0, 2, IS_TRUE, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_set_element_handler, 0, 3, IS_TRUE, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_INFO(0, start_handler)
ZEND_ARG_INFO(0, end_handler)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_set_character_data_handler, 0, 2, IS_TRUE, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_INFO(0, handler)
ZEND_END_ARG_INFO()
#define arginfo_xml_set_processing_instruction_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_default_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_unparsed_entity_decl_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_notation_decl_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_external_entity_ref_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_start_namespace_decl_handler arginfo_xml_set_character_data_handler
#define arginfo_xml_set_end_namespace_decl_handler arginfo_xml_set_character_data_handler
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_parse, 0, 2, IS_LONG, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, is_final, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_xml_parse_into_struct, 0, 3, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_INFO(1, values)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, index, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_get_error_code, 0, 1, IS_LONG, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_error_string, 0, 1, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, error_code, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_xml_get_current_line_number arginfo_xml_get_error_code
#define arginfo_xml_get_current_column_number arginfo_xml_get_error_code
#define arginfo_xml_get_current_byte_index arginfo_xml_get_error_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_parser_free, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_xml_parser_set_option, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_xml_parser_get_option, 0, 2, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL)
ZEND_ARG_OBJ_INFO(0, parser, XMLParser, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_FUNCTION(xml_parser_create);
ZEND_FUNCTION(xml_parser_create_ns);
ZEND_FUNCTION(xml_set_object);
ZEND_FUNCTION(xml_set_element_handler);
ZEND_FUNCTION(xml_set_character_data_handler);
ZEND_FUNCTION(xml_set_processing_instruction_handler);
ZEND_FUNCTION(xml_set_default_handler);
ZEND_FUNCTION(xml_set_unparsed_entity_decl_handler);
ZEND_FUNCTION(xml_set_notation_decl_handler);
ZEND_FUNCTION(xml_set_external_entity_ref_handler);
ZEND_FUNCTION(xml_set_start_namespace_decl_handler);
ZEND_FUNCTION(xml_set_end_namespace_decl_handler);
ZEND_FUNCTION(xml_parse);
ZEND_FUNCTION(xml_parse_into_struct);
ZEND_FUNCTION(xml_get_error_code);
ZEND_FUNCTION(xml_error_string);
ZEND_FUNCTION(xml_get_current_line_number);
ZEND_FUNCTION(xml_get_current_column_number);
ZEND_FUNCTION(xml_get_current_byte_index);
ZEND_FUNCTION(xml_parser_free);
ZEND_FUNCTION(xml_parser_set_option);
ZEND_FUNCTION(xml_parser_get_option);
static const zend_function_entry ext_functions[] = {
ZEND_FE(xml_parser_create, arginfo_xml_parser_create)
ZEND_FE(xml_parser_create_ns, arginfo_xml_parser_create_ns)
ZEND_FE(xml_set_object, arginfo_xml_set_object)
ZEND_FE(xml_set_element_handler, arginfo_xml_set_element_handler)
ZEND_FE(xml_set_character_data_handler, arginfo_xml_set_character_data_handler)
ZEND_FE(xml_set_processing_instruction_handler, arginfo_xml_set_processing_instruction_handler)
ZEND_FE(xml_set_default_handler, arginfo_xml_set_default_handler)
ZEND_FE(xml_set_unparsed_entity_decl_handler, arginfo_xml_set_unparsed_entity_decl_handler)
ZEND_FE(xml_set_notation_decl_handler, arginfo_xml_set_notation_decl_handler)
ZEND_FE(xml_set_external_entity_ref_handler, arginfo_xml_set_external_entity_ref_handler)
ZEND_FE(xml_set_start_namespace_decl_handler, arginfo_xml_set_start_namespace_decl_handler)
ZEND_FE(xml_set_end_namespace_decl_handler, arginfo_xml_set_end_namespace_decl_handler)
ZEND_FE(xml_parse, arginfo_xml_parse)
ZEND_FE(xml_parse_into_struct, arginfo_xml_parse_into_struct)
ZEND_FE(xml_get_error_code, arginfo_xml_get_error_code)
ZEND_FE(xml_error_string, arginfo_xml_error_string)
ZEND_FE(xml_get_current_line_number, arginfo_xml_get_current_line_number)
ZEND_FE(xml_get_current_column_number, arginfo_xml_get_current_column_number)
ZEND_FE(xml_get_current_byte_index, arginfo_xml_get_current_byte_index)
ZEND_FE(xml_parser_free, arginfo_xml_parser_free)
ZEND_FE(xml_parser_set_option, arginfo_xml_parser_set_option)
ZEND_FE(xml_parser_get_option, arginfo_xml_parser_get_option)
ZEND_FE_END
};
static const zend_function_entry class_XMLParser_methods[] = {
ZEND_FE_END
};
static void register_xml_symbols(int module_number)
{
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_SYNTAX", XML_ERROR_SYNTAX, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_NO_ELEMENTS", XML_ERROR_NO_ELEMENTS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_INVALID_TOKEN", XML_ERROR_INVALID_TOKEN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_TOKEN", XML_ERROR_UNCLOSED_TOKEN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_PARTIAL_CHAR", XML_ERROR_PARTIAL_CHAR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_TAG_MISMATCH", XML_ERROR_TAG_MISMATCH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_DUPLICATE_ATTRIBUTE", XML_ERROR_DUPLICATE_ATTRIBUTE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_JUNK_AFTER_DOC_ELEMENT", XML_ERROR_JUNK_AFTER_DOC_ELEMENT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_PARAM_ENTITY_REF", XML_ERROR_PARAM_ENTITY_REF, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_UNDEFINED_ENTITY", XML_ERROR_UNDEFINED_ENTITY, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_RECURSIVE_ENTITY_REF", XML_ERROR_RECURSIVE_ENTITY_REF, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_ASYNC_ENTITY", XML_ERROR_ASYNC_ENTITY, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_BAD_CHAR_REF", XML_ERROR_BAD_CHAR_REF, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_BINARY_ENTITY_REF", XML_ERROR_BINARY_ENTITY_REF, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF", XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_MISPLACED_XML_PI", XML_ERROR_MISPLACED_XML_PI, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_UNKNOWN_ENCODING", XML_ERROR_UNKNOWN_ENCODING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_INCORRECT_ENCODING", XML_ERROR_INCORRECT_ENCODING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_CDATA_SECTION", XML_ERROR_UNCLOSED_CDATA_SECTION, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_EXTERNAL_ENTITY_HANDLING", XML_ERROR_EXTERNAL_ENTITY_HANDLING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_OPTION_CASE_FOLDING", PHP_XML_OPTION_CASE_FOLDING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_OPTION_TARGET_ENCODING", PHP_XML_OPTION_TARGET_ENCODING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_TAGSTART", PHP_XML_OPTION_SKIP_TAGSTART, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_WHITE", PHP_XML_OPTION_SKIP_WHITE, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("XML_SAX_IMPL", PHP_XML_SAX_IMPL, CONST_PERSISTENT);
}
static zend_class_entry *register_class_XMLParser(void)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "XMLParser", class_XMLParser_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE;
return class_entry;
}

320
include/php/main/SAPI.h Normal file
View File

@ -0,0 +1,320 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SAPI_H
#define SAPI_H
#include "php.h"
#include "zend.h"
#include "zend_API.h"
#include "zend_llist.h"
#include "zend_operators.h"
#include <sys/stat.h>
#define SAPI_OPTION_NO_CHDIR 1
#define SAPI_POST_BLOCK_SIZE 0x4000
#ifdef PHP_WIN32
# ifdef SAPI_EXPORTS
# define SAPI_API __declspec(dllexport)
# else
# define SAPI_API __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define SAPI_API __attribute__ ((visibility("default")))
#else
# define SAPI_API
#endif
#undef shutdown
typedef struct {
char *header;
size_t header_len;
} sapi_header_struct;
typedef struct {
zend_llist headers;
int http_response_code;
unsigned char send_default_content_type;
char *mimetype;
char *http_status_line;
} sapi_headers_struct;
typedef struct _sapi_post_entry sapi_post_entry;
typedef struct _sapi_module_struct sapi_module_struct;
BEGIN_EXTERN_C()
extern SAPI_API sapi_module_struct sapi_module; /* true global */
END_EXTERN_C()
/* Some values in this structure needs to be filled in before
* calling sapi_activate(). We WILL change the `char *' entries,
* so make sure that you allocate a separate buffer for them
* and that you free them after sapi_deactivate().
*/
typedef struct {
const char *request_method;
char *query_string;
char *cookie_data;
zend_long content_length;
char *path_translated;
char *request_uri;
/* Do not use request_body directly, but the php://input stream wrapper instead */
struct _php_stream *request_body;
const char *content_type;
bool headers_only;
bool no_headers;
bool headers_read;
sapi_post_entry *post_entry;
char *content_type_dup;
/* for HTTP authentication */
char *auth_user;
char *auth_password;
char *auth_digest;
/* this is necessary for the CGI SAPI module */
char *argv0;
char *current_user;
int current_user_length;
/* this is necessary for CLI module */
int argc;
char **argv;
int proto_num;
} sapi_request_info;
typedef struct _sapi_globals_struct {
void *server_context;
sapi_request_info request_info;
sapi_headers_struct sapi_headers;
int64_t read_post_bytes;
unsigned char post_read;
unsigned char headers_sent;
zend_stat_t global_stat;
char *default_mimetype;
char *default_charset;
HashTable *rfc1867_uploaded_files;
zend_long post_max_size;
int options;
bool sapi_started;
double global_request_time;
HashTable known_post_content_types;
zval callback_func;
zend_fcall_info_cache fci_cache;
} sapi_globals_struct;
BEGIN_EXTERN_C()
#ifdef ZTS
# define SG(v) ZEND_TSRMG_FAST(sapi_globals_offset, sapi_globals_struct *, v)
SAPI_API extern int sapi_globals_id;
SAPI_API extern size_t sapi_globals_offset;
#else
# define SG(v) (sapi_globals.v)
extern SAPI_API sapi_globals_struct sapi_globals;
#endif
SAPI_API void sapi_startup(sapi_module_struct *sf);
SAPI_API void sapi_shutdown(void);
SAPI_API void sapi_activate(void);
SAPI_API void sapi_deactivate_module(void);
SAPI_API void sapi_deactivate_destroy(void);
SAPI_API void sapi_deactivate(void);
SAPI_API void sapi_initialize_empty_request(void);
SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
END_EXTERN_C()
/*
* This is the preferred and maintained API for
* operating on HTTP headers.
*/
/*
* Always specify a sapi_header_line this way:
*
* sapi_header_line ctr = {0};
*/
typedef struct {
const char *line; /* If you allocated this, you need to free it yourself */
size_t line_len;
zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
typedef enum { /* Parameter: */
SAPI_HEADER_REPLACE, /* sapi_header_line* */
SAPI_HEADER_ADD, /* sapi_header_line* */
SAPI_HEADER_DELETE, /* sapi_header_line* */
SAPI_HEADER_DELETE_ALL, /* void */
SAPI_HEADER_SET_STATUS /* int */
} sapi_header_op_enum;
BEGIN_EXTERN_C()
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
/* Deprecated functions. Use sapi_header_op instead. */
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, bool duplicate, bool replace);
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
SAPI_API int sapi_send_headers(void);
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
SAPI_API void sapi_handle_post(void *arg);
SAPI_API size_t sapi_read_post_block(char *buffer, size_t buflen);
SAPI_API int sapi_register_post_entries(const sapi_post_entry *post_entry);
SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void));
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
SAPI_API int sapi_flush(void);
SAPI_API zend_stat_t *sapi_get_stat(void);
SAPI_API char *sapi_getenv(const char *name, size_t name_len);
SAPI_API char *sapi_get_default_content_type(void);
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header);
SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len);
SAPI_API void sapi_activate_headers_only(void);
SAPI_API int sapi_get_fd(int *fd);
SAPI_API int sapi_force_http_10(void);
SAPI_API int sapi_get_target_uid(uid_t *);
SAPI_API int sapi_get_target_gid(gid_t *);
SAPI_API double sapi_get_request_time(void);
SAPI_API void sapi_terminate_process(void);
END_EXTERN_C()
struct _sapi_module_struct {
char *name;
char *pretty_name;
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*activate)(void);
int (*deactivate)(void);
size_t (*ub_write)(const char *str, size_t str_length);
void (*flush)(void *server_context);
zend_stat_t *(*get_stat)(void);
char *(*getenv)(const char *name, size_t name_len);
void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
int (*header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers);
int (*send_headers)(sapi_headers_struct *sapi_headers);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
size_t (*read_post)(char *buffer, size_t count_bytes);
char *(*read_cookies)(void);
void (*register_server_variables)(zval *track_vars_array);
void (*log_message)(const char *message, int syslog_type_int);
zend_result (*get_request_time)(double *request_time);
void (*terminate_process)(void);
char *php_ini_path_override;
void (*default_post_reader)(void);
void (*treat_data)(int arg, char *str, zval *destArray);
char *executable_location;
int php_ini_ignore;
int php_ini_ignore_cwd; /* don't look for php.ini in the current directory */
int (*get_fd)(int *fd);
int (*force_http_10)(void);
int (*get_target_uid)(uid_t *);
int (*get_target_gid)(gid_t *);
unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
const char *ini_entries;
const zend_function_entry *additional_functions;
unsigned int (*input_filter_init)(void);
};
struct _sapi_post_entry {
char *content_type;
uint32_t content_type_len;
void (*post_reader)(void);
void (*post_handler)(char *content_type_dup, void *arg);
};
/* header_handler() constants */
#define SAPI_HEADER_ADD (1<<0)
#define SAPI_HEADER_SENT_SUCCESSFULLY 1
#define SAPI_HEADER_DO_SEND 2
#define SAPI_HEADER_SEND_FAILED 3
#define SAPI_DEFAULT_MIMETYPE "text/html"
#define SAPI_DEFAULT_CHARSET PHP_DEFAULT_CHARSET
#define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION
#define SAPI_POST_READER_FUNC(post_reader) void post_reader(void)
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data);
SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter);
END_EXTERN_C()
#define STANDARD_SAPI_MODULE_PROPERTIES \
NULL, /* php_ini_path_override */ \
NULL, /* default_post_reader */ \
NULL, /* treat_data */ \
NULL, /* executable_location */ \
0, /* php_ini_ignore */ \
0, /* php_ini_ignore_cwd */ \
NULL, /* get_fd */ \
NULL, /* force_http_10 */ \
NULL, /* get_target_uid */ \
NULL, /* get_target_gid */ \
NULL, /* input_filter */ \
NULL, /* ini_defaults */ \
0, /* phpinfo_as_text; */ \
NULL, /* ini_entries; */ \
NULL, /* additional_functions */ \
NULL /* input_filter_init */
#endif /* SAPI_H */

View File

@ -0,0 +1,39 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#define CONFIGURE_COMMAND " './configure' '--prefix=/home/wreng/php-8.3.3-linux/'"
#define PHP_ODBC_CFLAGS ""
#define PHP_ODBC_LFLAGS ""
#define PHP_ODBC_LIBS ""
#define PHP_ODBC_TYPE ""
#define PHP_OCI8_DIR ""
#define PHP_OCI8_ORACLE_VERSION ""
#define PHP_PROG_SENDMAIL "/usr/sbin/sendmail"
#define PEAR_INSTALLDIR ""
#define PHP_INCLUDE_PATH ".:"
#define PHP_EXTENSION_DIR "/home/wreng/php-8.3.3-linux/lib/php/extensions/no-debug-non-zts-20230831"
#define PHP_PREFIX "/home/wreng/php-8.3.3-linux"
#define PHP_BINDIR "/home/wreng/php-8.3.3-linux/bin"
#define PHP_SBINDIR "/home/wreng/php-8.3.3-linux/sbin"
#define PHP_MANDIR "/home/wreng/php-8.3.3-linux/php/man"
#define PHP_LIBDIR "/home/wreng/php-8.3.3-linux/lib/php"
#define PHP_DATADIR "/home/wreng/php-8.3.3-linux/share/php"
#define PHP_SYSCONFDIR "/home/wreng/php-8.3.3-linux/etc"
#define PHP_LOCALSTATEDIR "/home/wreng/php-8.3.3-linux/var"
#define PHP_CONFIG_FILE_PATH "/home/wreng/php-8.3.3-linux/lib"
#define PHP_CONFIG_FILE_SCAN_DIR ""
#define PHP_SHLIB_SUFFIX "so"
#define PHP_SHLIB_EXT_PREFIX ""

126
include/php/main/fastcgi.h Normal file
View File

@ -0,0 +1,126 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
/* FastCGI protocol */
#define FCGI_VERSION_1 1
#define FCGI_MAX_LENGTH 0xffff
#define FCGI_KEEP_CONN 1
/* this is near the perfect hash function for most useful FastCGI variables
* which combines efficiency and minimal hash collisions
*/
#define FCGI_HASH_FUNC(var, var_len) \
(UNEXPECTED(var_len < 3) ? (unsigned int)var_len : \
(((unsigned int)var[3]) << 2) + \
(((unsigned int)var[var_len-2]) << 4) + \
(((unsigned int)var[var_len-1]) << 2) + \
var_len)
#define FCGI_GETENV(request, name) \
fcgi_quick_getenv(request, name, sizeof(name)-1, FCGI_HASH_FUNC(name, sizeof(name)-1))
#define FCGI_PUTENV(request, name, value) \
fcgi_quick_putenv(request, name, sizeof(name)-1, FCGI_HASH_FUNC(name, sizeof(name)-1), value)
typedef enum _fcgi_role {
FCGI_RESPONDER = 1,
FCGI_AUTHORIZER = 2,
FCGI_FILTER = 3
} fcgi_role;
enum {
FCGI_DEBUG = 1,
FCGI_NOTICE = 2,
FCGI_WARNING = 3,
FCGI_ERROR = 4,
FCGI_ALERT = 5,
};
typedef enum _fcgi_request_type {
FCGI_BEGIN_REQUEST = 1, /* [in] */
FCGI_ABORT_REQUEST = 2, /* [in] (not supported) */
FCGI_END_REQUEST = 3, /* [out] */
FCGI_PARAMS = 4, /* [in] environment variables */
FCGI_STDIN = 5, /* [in] post data */
FCGI_STDOUT = 6, /* [out] response */
FCGI_STDERR = 7, /* [out] errors */
FCGI_DATA = 8, /* [in] filter data (not supported) */
FCGI_GET_VALUES = 9, /* [in] */
FCGI_GET_VALUES_RESULT = 10 /* [out] */
} fcgi_request_type;
typedef enum _fcgi_protocol_status {
FCGI_REQUEST_COMPLETE = 0,
FCGI_CANT_MPX_CONN = 1,
FCGI_OVERLOADED = 2,
FCGI_UNKNOWN_ROLE = 3
} dcgi_protocol_status;
/* FastCGI client API */
typedef void (*fcgi_apply_func)(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
#define FCGI_HASH_TABLE_SIZE 128
#define FCGI_HASH_TABLE_MASK (FCGI_HASH_TABLE_SIZE - 1)
#define FCGI_HASH_SEG_SIZE 4096
typedef struct _fcgi_request fcgi_request;
int fcgi_init(void);
void fcgi_shutdown(void);
int fcgi_is_fastcgi(void);
int fcgi_is_closed(fcgi_request *req);
void fcgi_close(fcgi_request *req, int force, int destroy);
int fcgi_in_shutdown(void);
void fcgi_terminate(void);
int fcgi_listen(const char *path, int backlog);
fcgi_request* fcgi_init_request(int listen_socket, void(*on_accept)(void), void(*on_read)(void), void(*on_close)(void));
void fcgi_destroy_request(fcgi_request *req);
void fcgi_set_allowed_clients(char *ip);
int fcgi_accept_request(fcgi_request *req);
int fcgi_finish_request(fcgi_request *req, int force_close);
const char *fcgi_get_last_client_ip(void);
void fcgi_set_in_shutdown(int new_value);
void fcgi_request_set_keep(fcgi_request *req, int new_value);
#ifndef HAVE_ATTRIBUTE_WEAK
typedef void (*fcgi_logger)(int type, const char *fmt, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
void fcgi_set_logger(fcgi_logger lg);
#endif
int fcgi_has_env(fcgi_request *req);
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value);
char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val);
void fcgi_loadenv(fcgi_request *req, fcgi_apply_func load_func, zval *array);
int fcgi_read(fcgi_request *req, char *str, int len);
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
int fcgi_flush(fcgi_request *req, int end);
int fcgi_end(fcgi_request *req);
#ifdef PHP_WIN32
void fcgi_impersonate(void);
#endif
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
void fcgi_free_mgmt_var_cb(zval *zv);

View File

@ -0,0 +1,47 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef FOPEN_WRAPPERS_H
#define FOPEN_WRAPPERS_H
BEGIN_EXTERN_C()
#include "php_globals.h"
#include "php_ini.h"
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle);
PHPAPI char *expand_filepath(const char *filepath, char *real_path);
PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len);
PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int use_realpath);
PHPAPI int php_check_open_basedir(const char *path);
PHPAPI int php_check_open_basedir_ex(const char *path, int warn);
PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path);
/* OPENBASEDIR_CHECKPATH(filename) to ease merge between 6.x and 5.x */
#define OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
PHPAPI int php_check_safe_mode_include_dir(const char *path);
PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_len, const char *path);
PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const char *path, zend_string **opened_path);
PHPAPI char *php_strip_url_passwd(char *path);
PHPAPI ZEND_INI_MH(OnUpdateBaseDir);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,80 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Andrea Faulds <ajf@ajf.me> |
+----------------------------------------------------------------------+
*/
#ifndef HTTP_STATUS_CODES_H
#define HTTP_STATUS_CODES_H
typedef struct _http_response_status_code_pair {
const int code;
const char *str;
} http_response_status_code_pair;
static const http_response_status_code_pair http_status_map[] = {
{ 100, "Continue" },
{ 101, "Switching Protocols" },
{ 200, "OK" },
{ 201, "Created" },
{ 202, "Accepted" },
{ 203, "Non-Authoritative Information" },
{ 204, "No Content" },
{ 205, "Reset Content" },
{ 206, "Partial Content" },
{ 300, "Multiple Choices" },
{ 301, "Moved Permanently" },
{ 302, "Found" },
{ 303, "See Other" },
{ 304, "Not Modified" },
{ 305, "Use Proxy" },
{ 307, "Temporary Redirect" },
{ 308, "Permanent Redirect" },
{ 400, "Bad Request" },
{ 401, "Unauthorized" },
{ 402, "Payment Required" },
{ 403, "Forbidden" },
{ 404, "Not Found" },
{ 405, "Method Not Allowed" },
{ 406, "Not Acceptable" },
{ 407, "Proxy Authentication Required" },
{ 408, "Request Timeout" },
{ 409, "Conflict" },
{ 410, "Gone" },
{ 411, "Length Required" },
{ 412, "Precondition Failed" },
{ 413, "Request Entity Too Large" },
{ 414, "Request-URI Too Long" },
{ 415, "Unsupported Media Type" },
{ 416, "Requested Range Not Satisfiable" },
{ 417, "Expectation Failed" },
{ 426, "Upgrade Required" },
{ 428, "Precondition Required" },
{ 429, "Too Many Requests" },
{ 431, "Request Header Fields Too Large" },
{ 451, "Unavailable For Legal Reasons"},
{ 500, "Internal Server Error" },
{ 501, "Not Implemented" },
{ 502, "Bad Gateway" },
{ 503, "Service Unavailable" },
{ 504, "Gateway Timeout" },
{ 505, "HTTP Version Not Supported" },
{ 506, "Variant Also Negotiates" },
{ 511, "Network Authentication Required" },
/* to allow search with while() loop */
{ 0, NULL }
};
static const size_t http_status_map_len = (sizeof(http_status_map) / sizeof(http_response_status_code_pair)) - 1;
#endif /* HTTP_STATUS_CODES_H */

View File

@ -0,0 +1,98 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 58c8b6ec69650d241919ebba4f957b4b141fb9f2 */
static void register_main_symbols(int module_number)
{
REGISTER_STRING_CONSTANT("PHP_VERSION", PHP_VERSION, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_MAJOR_VERSION", PHP_MAJOR_VERSION, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_MINOR_VERSION", PHP_MINOR_VERSION, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_ZTS", PHP_ZTS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_OS", PHP_OS_STR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_OS_FAMILY", PHP_OS_FAMILY, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PEAR_EXTENSION_DIR", PHP_EXTENSION_DIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_EXTENSION_DIR", PHP_EXTENSION_DIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_PREFIX", PHP_PREFIX, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_BINDIR", PHP_BINDIR, CONST_PERSISTENT);
#if !defined(PHP_WIN32)
REGISTER_STRING_CONSTANT("PHP_MANDIR", PHP_MANDIR, CONST_PERSISTENT);
#endif
REGISTER_STRING_CONSTANT("PHP_LIBDIR", PHP_LIBDIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_DATADIR", PHP_DATADIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_LOCALSTATEDIR", PHP_LOCALSTATEDIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("PHP_EOL", PHP_EOL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_INT_MAX", ZEND_LONG_MAX, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_INT_MIN", ZEND_LONG_MIN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_LONG, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_FD_SETSIZE", FD_SETSIZE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_FLOAT_DIG", DBL_DIG, CONST_PERSISTENT);
REGISTER_DOUBLE_CONSTANT("PHP_FLOAT_EPSILON", DBL_EPSILON, CONST_PERSISTENT);
REGISTER_DOUBLE_CONSTANT("PHP_FLOAT_MAX", DBL_MAX, CONST_PERSISTENT);
REGISTER_DOUBLE_CONSTANT("PHP_FLOAT_MIN", DBL_MIN, CONST_PERSISTENT);
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_MINOR", EG(windows_version_info).dwMinorVersion, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_BUILD", EG(windows_version_info).dwBuildNumber, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_PLATFORM", EG(windows_version_info).dwPlatformId, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MAJOR", EG(windows_version_info).wServicePackMajor, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MINOR", EG(windows_version_info).wServicePackMinor, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SUITEMASK", EG(windows_version_info).wSuiteMask, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_PRODUCTTYPE", EG(windows_version_info).wProductType, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_DOMAIN_CONTROLLER", VER_NT_DOMAIN_CONTROLLER, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_SERVER", VER_NT_SERVER, CONST_PERSISTENT);
#endif
#if defined(PHP_WIN32)
REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_WORKSTATION", VER_NT_WORKSTATION, CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_WRITE", PHP_OUTPUT_HANDLER_WRITE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FLUSH", PHP_OUTPUT_HANDLER_FLUSH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CLEAN", PHP_OUTPUT_HANDLER_CLEAN, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FINAL", PHP_OUTPUT_HANDLER_FINAL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CONT", PHP_OUTPUT_HANDLER_WRITE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_FINAL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CLEANABLE", PHP_OUTPUT_HANDLER_CLEANABLE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FLUSHABLE", PHP_OUTPUT_HANDLER_FLUSHABLE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_REMOVABLE", PHP_OUTPUT_HANDLER_REMOVABLE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STDFLAGS", PHP_OUTPUT_HANDLER_STDFLAGS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STARTED", PHP_OUTPUT_HANDLER_STARTED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_DISABLED", PHP_OUTPUT_HANDLER_DISABLED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_OK", PHP_UPLOAD_ERROR_OK, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_INI_SIZE", PHP_UPLOAD_ERROR_A, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_FORM_SIZE", PHP_UPLOAD_ERROR_B, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_PARTIAL", PHP_UPLOAD_ERROR_C, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_NO_FILE", PHP_UPLOAD_ERROR_D, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_NO_TMP_DIR", PHP_UPLOAD_ERROR_E, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_CANT_WRITE", PHP_UPLOAD_ERROR_F, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UPLOAD_ERR_EXTENSION", PHP_UPLOAD_ERROR_X, CONST_PERSISTENT);
}

443
include/php/main/php.h Normal file
View File

@ -0,0 +1,443 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_H
#define PHP_H
#ifdef HAVE_DMALLOC
#include <dmalloc.h>
#endif
#define PHP_API_VERSION 20230831
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
#include "php_version.h"
#include "zend.h"
#include "zend_sort.h"
#include "php_compat.h"
#include "zend_API.h"
#define php_sprintf sprintf
/* Operating system family definition */
#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__)
# define PHP_OS_FAMILY "Darwin"
#elif defined(__sun__)
# define PHP_OS_FAMILY "Solaris"
#elif defined(__linux__)
# define PHP_OS_FAMILY "Linux"
#else
# define PHP_OS_FAMILY "Unknown"
#endif
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
#undef PHP_DEBUG
#define PHP_DEBUG ZEND_DEBUG
#ifdef PHP_WIN32
# include "tsrm_win32.h"
# ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport)
# else
# define PHPAPI __declspec(dllimport)
# endif
# define PHP_DIR_SEPARATOR '\\'
# define PHP_EOL "\r\n"
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define PHPAPI __attribute__ ((visibility("default")))
# else
# define PHPAPI
# endif
# define PHP_DIR_SEPARATOR '/'
# define PHP_EOL "\n"
#endif
/* 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
#if PHP_DEBUG
#undef NDEBUG
#else
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <assert.h>
#ifdef HAVE_UNIX_H
#include <unix.h>
#endif
#if HAVE_ALLOCA_H
#include <alloca.h>
#endif
#if HAVE_BUILD_DEFS_H
#include <build-defs.h>
#endif
/*
* This is a fast version of strlcpy which should be used, if you
* know the size of the destination buffer and if you know
* the length of the source string.
*
* size is the allocated number of bytes of dst
* src_size is the number of bytes excluding the NUL of src
*/
#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'; \
}
#ifndef HAVE_STRLCPY
BEGIN_EXTERN_C()
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
END_EXTERN_C()
#undef strlcpy
#define strlcpy php_strlcpy
#define HAVE_STRLCPY 1
#define USE_STRLCPY_PHP_IMPL 1
#endif
#ifndef HAVE_STRLCAT
BEGIN_EXTERN_C()
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
END_EXTERN_C()
#undef strlcat
#define strlcat php_strlcat
#define HAVE_STRLCAT 1
#define USE_STRLCAT_PHP_IMPL 1
#endif
#ifndef HAVE_EXPLICIT_BZERO
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
BEGIN_EXTERN_C()
PHPAPI int php_safe_bcmp(const zend_string *a, const zend_string *b);
END_EXTERN_C()
#ifndef HAVE_STRTOK_R
BEGIN_EXTERN_C()
char *strtok_r(char *s, const char *delim, char **last);
END_EXTERN_C()
#endif
#ifndef HAVE_SOCKLEN_T
# ifdef PHP_WIN32
typedef int socklen_t;
# else
typedef unsigned int socklen_t;
# endif
#endif
#define CREATE_MUTEX(a, b)
#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
#include <stdarg.h>
#include "zend_hash.h"
#include "zend_alloc.h"
#include "zend_stack.h"
#include <string.h>
#if HAVE_PWD_H
# ifdef PHP_WIN32
#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
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN (- INT_MAX - 1)
#endif
#define PHP_DOUBLE_MAX_LENGTH ZEND_DOUBLE_MAX_LENGTH
#define PHP_GCC_VERSION ZEND_GCC_VERSION
#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
BEGIN_EXTERN_C()
#include "snprintf.h"
END_EXTERN_C()
#include "spprintf.h"
#define EXEC_INPUT_BUF 4096
#define PHP_MIME_TYPE "application/x-httpd-php"
/* macros */
#define STR_PRINT(str) ((str)?(str):"")
#ifndef MAXPATHLEN
# ifdef PHP_WIN32
# include "win32/ioutil.h"
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
# elif PATH_MAX
# define MAXPATHLEN PATH_MAX
# elif defined(MAX_PATH)
# define MAXPATHLEN MAX_PATH
# else
# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
# endif
#endif
#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
/* global variables */
#ifndef PHP_WIN32
#define php_sleep sleep
extern char **environ;
#endif /* ifndef PHP_WIN32 */
#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
BEGIN_EXTERN_C()
void phperror(char *error);
PHPAPI size_t php_write(void *buf, size_t size);
PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
PHPAPI size_t php_printf_unchecked(const char *format, ...);
PHPAPI bool php_during_module_startup(void);
PHPAPI bool php_during_module_shutdown(void);
PHPAPI bool php_get_module_initialized(void);
#ifdef HAVE_SYSLOG_H
#include "php_syslog.h"
#define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE)
#else
#define php_log_err(msg) php_log_err_with_severity(msg, 5)
#endif
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
int cfgparse(void);
END_EXTERN_C()
#define php_error zend_error
#define error_handling_t zend_error_handling_t
BEGIN_EXTERN_C()
static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class)
{
zend_replace_error_handling(error_handling, exception_class, NULL);
}
static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling(void) {}
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);
/* PHPAPI void php_error(int type, const char *format, ...); */
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 5, 6);
#ifdef PHP_WIN32
PHPAPI ZEND_COLD void php_win32_docref1_from_error(DWORD error, const char *param1);
PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
#endif
END_EXTERN_C()
#define zenderror phperror
#define zendlex phplex
#define phpparse zendparse
#define phprestart zendrestart
#define phpin zendin
#define php_memnstr zend_memnstr
#define php_memnistr zend_memnistr
/* functions */
BEGIN_EXTERN_C()
PHPAPI extern int (*php_register_internal_extensions_func)(void);
PHPAPI int php_register_internal_extensions(void);
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
PHPAPI void php_com_initialize(void);
PHPAPI char *php_get_current_user(void);
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);
END_EXTERN_C()
/* PHP-named Zend macro wrappers */
#define PHP_FN ZEND_FN
#define PHP_MN ZEND_MN
#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
#define PHP_FUNCTION ZEND_FUNCTION
#define PHP_METHOD ZEND_METHOD
#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
#define PHP_NAMED_FE ZEND_NAMED_FE
#define PHP_FE ZEND_FE
#define PHP_DEP_FE ZEND_DEP_FE
#define PHP_FALIAS ZEND_FALIAS
#define PHP_DEP_FALIAS ZEND_DEP_FALIAS
#define PHP_ME ZEND_ME
#define PHP_MALIAS ZEND_MALIAS
#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
#define PHP_ME_MAPPING ZEND_ME_MAPPING
#define PHP_FE_END ZEND_FE_END
#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
#define PHP_GINIT ZEND_GINIT
#define PHP_GSHUTDOWN ZEND_GSHUTDOWN
#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
#define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
#define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
#define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
/* Output support */
#include "main/php_output.h"
#include "php_streams.h"
#include "php_memory_streams.h"
#include "fopen_wrappers.h"
/* Virtual current working directory support */
#include "zend_virtual_cwd.h"
#include "zend_constants.h"
/* connection status states */
#define PHP_CONNECTION_NORMAL 0
#define PHP_CONNECTION_ABORTED 1
#define PHP_CONNECTION_TIMEOUT 2
#include "php_reentrancy.h"
/* 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;
#endif

View File

@ -0,0 +1,400 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
#ifndef PHP_COMPAT_H
#define PHP_COMPAT_H
#ifdef PHP_WIN32
#include "config.w32.h"
#else
#include <php_config.h>
#endif
#if defined(HAVE_BUNDLED_PCRE) || !defined(PHP_VERSION)
#define pcre2_jit_callback_8 php_pcre2_jit_callback
#define pcre2_callout_enumerate_8 php_pcre2_callout_enumerate
#define pcre2_code_copy_8 php_pcre2_code_copy
#define pcre2_code_copy_with_tables_8 php_pcre2_code_copy_with_tables
#define pcre2_code_free_8 php_pcre2_code_free
#define pcre2_compile_8 php_pcre2_compile
#define pcre2_compile_context_copy_8 php_pcre2_compile_context_copy
#define pcre2_compile_context_create_8 php_pcre2_compile_context_create
#define pcre2_compile_context_free_8 php_pcre2_compile_context_free
#define pcre2_config_8 php_pcre2_config
#define pcre2_convert_context_copy_8 php_pcre2_convert_context_copy
#define pcre2_convert_context_create_8 php_pcre2_convert_context_create
#define pcre2_convert_context_free_8 php_pcre2_convert_context_free
#define pcre2_dfa_match_8 php_pcre2_dfa_match
#define pcre2_general_context_copy_8 php_pcre2_general_context_copy
#define pcre2_general_context_create_8 php_pcre2_general_context_create
#define pcre2_general_context_free_8 php_pcre2_general_context_free
#define pcre2_get_error_message_8 php_pcre2_get_error_message
#define pcre2_get_mark_8 php_pcre2_get_mark
#define pcre2_get_ovector_pointer_8 php_pcre2_get_ovector_pointer
#define pcre2_get_ovector_count_8 php_pcre2_get_ovector_count
#define pcre2_get_startchar_8 php_pcre2_get_startchar
#define pcre2_jit_compile_8 php_pcre2_jit_compile
#define pcre2_jit_match_8 php_pcre2_jit_match
#define pcre2_jit_free_unused_memory_8 php_pcre2_jit_free_unused_memory
#define pcre2_jit_stack_assign_8 php_pcre2_jit_stack_assign
#define pcre2_jit_stack_create_8 php_pcre2_jit_stack_create
#define pcre2_jit_stack_free_8 php_pcre2_jit_stack_free
#define pcre2_maketables_8 php_pcre2_maketables
#define pcre2_match_8 php_pcre2_match
#define pcre2_match_context_copy_8 php_pcre2_match_context_copy
#define pcre2_match_context_create_8 php_pcre2_match_context_create
#define pcre2_match_context_free_8 php_pcre2_match_context_free
#define pcre2_match_data_create_8 php_pcre2_match_data_create
#define pcre2_match_data_create_from_pattern_8 php_pcre2_match_data_create_from_pattern
#define pcre2_match_data_free_8 php_pcre2_match_data_free
#define pcre2_pattern_info_8 php_pcre2_pattern_info
#define pcre2_serialize_decode_8 php_pcre2_serialize_decode
#define pcre2_serialize_encode_8 php_pcre2_serialize_encode
#define pcre2_serialize_free_8 php_pcre2_serialize_free
#define pcre2_serialize_get_number_of_codes_8 php_pcre2_serialize_get_number_of_codes
#define pcre2_set_bsr_8 php_pcre2_set_bsr
#define pcre2_set_callout_8 php_pcre2_set_callout
#define pcre2_set_character_tables_8 php_pcre2_set_character_tables
#define pcre2_set_compile_extra_options_8 php_pcre2_set_compile_extra_options
#define pcre2_set_compile_recursion_guard_8 php_pcre2_set_compile_recursion_guard
#define pcre2_set_depth_limit_8 php_pcre2_set_depth_limit
#define pcre2_set_glob_escape_8 php_pcre2_set_glob_escape
#define pcre2_set_glob_separator_8 php_pcre2_set_glob_separator
#define pcre2_set_heap_limit_8 php_pcre2_set_heap_limit
#define pcre2_set_match_limit_8 php_pcre2_set_match_limit
#define pcre2_set_max_pattern_length_8 php_pcre2_set_max_pattern_length
#define pcre2_set_newline_8 php_pcre2_set_newline
#define pcre2_set_parens_nest_limit_8 php_pcre2_set_parens_nest_limit
#define pcre2_set_offset_limit_8 php_pcre2_set_offset_limit
#define pcre2_substitute_8 php_pcre2_substitute
#define pcre2_substring_copy_byname_8 php_pcre2_substring_copy_byname
#define pcre2_substring_copy_bynumber_8 php_pcre2_substring_copy_bynumber
#define pcre2_substring_free_8 php_pcre2_substring_free
#define pcre2_substring_get_byname_8 php_pcre2_substring_get_byname
#define pcre2_substring_get_bynumber_8 php_pcre2_substring_get_bynumber
#define pcre2_substring_length_byname_8 php_pcre2_substring_length_byname
#define pcre2_substring_length_bynumber_8 php_pcre2_substring_length_bynumber
#define pcre2_substring_list_get_8 php_pcre2_substring_list_get
#define pcre2_substring_list_free_8 php_pcre2_substring_list_free
#define pcre2_substring_nametable_scan_8 php_pcre2_substring_nametable_scan
#define pcre2_substring_number_from_name_8 php_pcre2_substring_number_from_name
#define pcre2_set_recursion_limit_8 php_pcre2_set_recursion_limit
#define pcre2_set_recursion_memory_management_8 php_pcre2_set_recursion_memory_management
#endif
#define lookup php_lookup
#define hashTableInit php_hashTableInit
#define hashTableDestroy php_hashTableDestroy
#define hashTableIterInit php_hashTableIterInit
#define hashTableIterNext php_hashTableIterNext
#if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT)
#define XML_DefaultCurrent php_XML_DefaultCurrent
#define XML_ErrorString php_XML_ErrorString
#define XML_ExpatVersion php_XML_ExpatVersion
#define XML_ExpatVersionInfo php_XML_ExpatVersionInfo
#define XML_ExternalEntityParserCreate php_XML_ExternalEntityParserCreate
#define XML_GetBase php_XML_GetBase
#define XML_GetBuffer php_XML_GetBuffer
#define XML_GetCurrentByteCount php_XML_GetCurrentByteCount
#define XML_GetCurrentByteIndex php_XML_GetCurrentByteIndex
#define XML_GetCurrentColumnNumber php_XML_GetCurrentColumnNumber
#define XML_GetCurrentLineNumber php_XML_GetCurrentLineNumber
#define XML_GetErrorCode php_XML_GetErrorCode
#define XML_GetIdAttributeIndex php_XML_GetIdAttributeIndex
#define XML_GetInputContext php_XML_GetInputContext
#define XML_GetSpecifiedAttributeCount php_XML_GetSpecifiedAttributeCount
#define XmlGetUtf16InternalEncodingNS php_XmlGetUtf16InternalEncodingNS
#define XmlGetUtf16InternalEncoding php_XmlGetUtf16InternalEncoding
#define XmlGetUtf8InternalEncodingNS php_XmlGetUtf8InternalEncodingNS
#define XmlGetUtf8InternalEncoding php_XmlGetUtf8InternalEncoding
#define XmlInitEncoding php_XmlInitEncoding
#define XmlInitEncodingNS php_XmlInitEncodingNS
#define XmlInitUnknownEncoding php_XmlInitUnknownEncoding
#define XmlInitUnknownEncodingNS php_XmlInitUnknownEncodingNS
#define XML_ParseBuffer php_XML_ParseBuffer
#define XML_Parse php_XML_Parse
#define XML_ParserCreate_MM php_XML_ParserCreate_MM
#define XML_ParserCreateNS php_XML_ParserCreateNS
#define XML_ParserCreate php_XML_ParserCreate
#define XML_ParserFree php_XML_ParserFree
#define XmlParseXmlDecl php_XmlParseXmlDecl
#define XmlParseXmlDeclNS php_XmlParseXmlDeclNS
#define XmlPrologStateInitExternalEntity php_XmlPrologStateInitExternalEntity
#define XmlPrologStateInit php_XmlPrologStateInit
#define XML_SetAttlistDeclHandler php_XML_SetAttlistDeclHandler
#define XML_SetBase php_XML_SetBase
#define XML_SetCdataSectionHandler php_XML_SetCdataSectionHandler
#define XML_SetCharacterDataHandler php_XML_SetCharacterDataHandler
#define XML_SetCommentHandler php_XML_SetCommentHandler
#define XML_SetDefaultHandlerExpand php_XML_SetDefaultHandlerExpand
#define XML_SetDefaultHandler php_XML_SetDefaultHandler
#define XML_SetDoctypeDeclHandler php_XML_SetDoctypeDeclHandler
#define XML_SetElementDeclHandler php_XML_SetElementDeclHandler
#define XML_SetElementHandler php_XML_SetElementHandler
#define XML_SetEncoding php_XML_SetEncoding
#define XML_SetEndCdataSectionHandler php_XML_SetEndCdataSectionHandler
#define XML_SetEndDoctypeDeclHandler php_XML_SetEndDoctypeDeclHandler
#define XML_SetEndElementHandler php_XML_SetEndElementHandler
#define XML_SetEndNamespaceDeclHandler php_XML_SetEndNamespaceDeclHandler
#define XML_SetEntityDeclHandler php_XML_SetEntityDeclHandler
#define XML_SetExternalEntityRefHandlerArg php_XML_SetExternalEntityRefHandlerArg
#define XML_SetExternalEntityRefHandler php_XML_SetExternalEntityRefHandler
#define XML_SetNamespaceDeclHandler php_XML_SetNamespaceDeclHandler
#define XML_SetNotationDeclHandler php_XML_SetNotationDeclHandler
#define XML_SetNotStandaloneHandler php_XML_SetNotStandaloneHandler
#define XML_SetParamEntityParsing php_XML_SetParamEntityParsing
#define XML_SetProcessingInstructionHandler php_XML_SetProcessingInstructionHandler
#define XML_SetReturnNSTriplet php_XML_SetReturnNSTriplet
#define XML_SetStartCdataSectionHandler php_XML_SetStartCdataSectionHandler
#define XML_SetStartDoctypeDeclHandler php_XML_SetStartDoctypeDeclHandler
#define XML_SetStartElementHandler php_XML_SetStartElementHandler
#define XML_SetStartNamespaceDeclHandler php_XML_SetStartNamespaceDeclHandler
#define XML_SetUnknownEncodingHandler php_XML_SetUnknownEncodingHandler
#define XML_SetUnparsedEntityDeclHandler php_XML_SetUnparsedEntityDeclHandler
#define XML_SetUserData php_XML_SetUserData
#define XML_SetXmlDeclHandler php_XML_SetXmlDeclHandler
#define XmlSizeOfUnknownEncoding php_XmlSizeOfUnknownEncoding
#define XML_UseParserAsHandlerArg php_XML_UseParserAsHandlerArg
#define XmlUtf16Encode php_XmlUtf16Encode
#define XmlUtf8Encode php_XmlUtf8Encode
#define XML_FreeContentModel php_XML_FreeContentModel
#define XML_MemMalloc php_XML_MemMalloc
#define XML_MemRealloc php_XML_MemRealloc
#define XML_MemFree php_XML_MemFree
#define XML_UseForeignDTD php_XML_UseForeignDTD
#define XML_GetFeatureList php_XML_GetFeatureList
#define XML_ParserReset php_XML_ParserReset
#ifdef HAVE_GD_BUNDLED
#define any2eucjp php_gd_any2eucjp
#define createwbmp php_gd_createwbmp
#define empty_output_buffer php_gd_empty_output_buffer
#define fill_input_buffer php_gd_fill_input_buffer
#define freewbmp php_gd_freewbmp
#define gdAlphaBlend php_gd_gdAlphaBlend
#define gdCompareInt php_gd_gdCompareInt
#define gdCosT php_gd_gdCosT
#define gdCtxPrintf php_gd_gdCtxPrintf
#define gdDPExtractData php_gd_gdDPExtractData
#define gdFontGetGiant php_gd_gdFontGetGiant
#define gdFontGetLarge php_gd_gdFontGetLarge
#define gdFontGetMediumBold php_gd_gdFontGetMediumBold
#define gdFontGetSmall php_gd_gdFontGetSmall
#define gdFontGetTiny php_gd_gdFontGetTiny
#define gdFontGiant php_gd_gdFontGiant
#define gdFontGiantData php_gd_gdFontGiantData
#define gdFontGiantRep php_gd_gdFontGiantRep
#define gdFontLarge php_gd_gdFontLarge
#define gdFontLargeData php_gd_gdFontLargeData
#define gdFontLargeRep php_gd_gdFontLargeRep
#define gdFontMediumBold php_gd_gdFontMediumBold
#define gdFontMediumBoldData php_gd_gdFontMediumBoldData
#define gdFontMediumBoldRep php_gd_gdFontMediumBoldRep
#define gdFontSmall php_gd_gdFontSmall
#define gdFontSmallData php_gd_gdFontSmallData
#define gdFontSmallRep php_gd_gdFontSmallRep
#define gdFontTiny php_gd_gdFontTiny
#define gdFontTinyData php_gd_gdFontTinyData
#define gdFontTinyRep php_gd_gdFontTinyRep
#define gdGetBuf php_gd_gdGetBuf
#define gdGetByte php_gd_gdGetByte
#define gdGetC php_gd_gdGetC
#define _gdGetColors php_gd__gdGetColors
#define gd_getin php_gd_gd_getin
#define gdGetInt php_gd_gdGetInt
#define gdGetWord php_gd_gdGetWord
#define gdImageAABlend php_gd_gdImageAABlend
#define gdImageAALine php_gd_gdImageAALine
#define gdImageAlphaBlending php_gd_gdImageAlphaBlending
#define gdImageAntialias php_gd_gdImageAntialias
#define gdImageArc php_gd_gdImageArc
#define gdImageBrightness php_gd_gdImageBrightness
#define gdImageChar php_gd_gdImageChar
#define gdImageCharUp php_gd_gdImageCharUp
#define gdImageColor php_gd_gdImageColor
#define gdImageColorAllocate php_gd_gdImageColorAllocate
#define gdImageColorAllocateAlpha php_gd_gdImageColorAllocateAlpha
#define gdImageColorClosest php_gd_gdImageColorClosest
#define gdImageColorClosestAlpha php_gd_gdImageColorClosestAlpha
#define gdImageColorClosestHWB php_gd_gdImageColorClosestHWB
#define gdImageColorDeallocate php_gd_gdImageColorDeallocate
#define gdImageColorExact php_gd_gdImageColorExact
#define gdImageColorExactAlpha php_gd_gdImageColorExactAlpha
#define gdImageColorMatch php_gd_gdImageColorMatch
#define gdImageColorResolve php_gd_gdImageColorResolve
#define gdImageColorResolveAlpha php_gd_gdImageColorResolveAlpha
#define gdImageColorTransparent php_gd_gdImageColorTransparent
#define gdImageCompare php_gd_gdImageCompare
#define gdImageContrast php_gd_gdImageContrast
#define gdImageConvolution php_gd_gdImageConvolution
#define gdImageCopy php_gd_gdImageCopy
#define gdImageCopyMerge php_gd_gdImageCopyMerge
#define gdImageCopyMergeGray php_gd_gdImageCopyMergeGray
#define gdImageCopyResampled php_gd_gdImageCopyResampled
#define gdImageCopyResized php_gd_gdImageCopyResized
#define gdImageCreate php_gd_gdImageCreate
#define gdImageCreateFromGd php_gd_gdImageCreateFromGd
#define gdImageCreateFromGd2 php_gd_gdImageCreateFromGd2
#define gdImageCreateFromGd2Ctx php_gd_gdImageCreateFromGd2Ctx
#define gdImageCreateFromGd2Part php_gd_gdImageCreateFromGd2Part
#define gdImageCreateFromGd2PartCtx php_gd_gdImageCreateFromGd2PartCtx
#define gdImageCreateFromGd2PartPtr php_gd_gdImageCreateFromGd2PartPtr
#define gdImageCreateFromGd2Ptr php_gd_gdImageCreateFromGd2Ptr
#define gdImageCreateFromGdCtx php_gd_gdImageCreateFromGdCtx
#define gdImageCreateFromGdPtr php_gd_gdImageCreateFromGdPtr
#define gdImageCreateFromGif php_gd_gdImageCreateFromGif
#define gdImageCreateFromGifCtx php_gd_gdImageCreateFromGifCtx
#define gdImageCreateFromGifSource php_gd_gdImageCreateFromGifSource
#define gdImageCreateFromJpeg php_gd_gdImageCreateFromJpeg
#define gdImageCreateFromJpegCtx php_gd_gdImageCreateFromJpegCtx
#define gdImageCreateFromJpegPtr php_gd_gdImageCreateFromJpegPtr
#define gdImageCreateFromPng php_gd_gdImageCreateFromPng
#define gdImageCreateFromPngCtx php_gd_gdImageCreateFromPngCtx
#define gdImageCreateFromPngPtr php_gd_gdImageCreateFromPngPtr
#define gdImageCreateFromPngSource php_gd_gdImageCreateFromPngSource
#define gdImageCreateFromWBMP php_gd_gdImageCreateFromWBMP
#define gdImageCreateFromWBMPCtx php_gd_gdImageCreateFromWBMPCtx
#define gdImageCreateFromWBMPPtr php_gd_gdImageCreateFromWBMPPtr
#define gdImageCreateFromXbm php_gd_gdImageCreateFromXbm
#define gdImageCreatePaletteFromTrueColor php_gd_gdImageCreatePaletteFromTrueColor
#define gdImageCreateTrueColor php_gd_gdImageCreateTrueColor
#define gdImageDashedLine php_gd_gdImageDashedLine
#define gdImageDestroy php_gd_gdImageDestroy
#define gdImageEdgeDetectQuick php_gd_gdImageEdgeDetectQuick
#define gdImageEllipse php_gd_gdImageEllipse
#define gdImageEmboss php_gd_gdImageEmboss
#define gdImageFill php_gd_gdImageFill
#define gdImageFilledArc php_gd_gdImageFilledArc
#define gdImageFilledEllipse php_gd_gdImageFilledEllipse
#define gdImageFilledPolygon php_gd_gdImageFilledPolygon
#define gdImageFilledRectangle php_gd_gdImageFilledRectangle
#define _gdImageFillTiled php_gd__gdImageFillTiled
#define gdImageFillToBorder php_gd_gdImageFillToBorder
#define gdImageGaussianBlur php_gd_gdImageGaussianBlur
#define gdImageGd php_gd_gdImageGd
#define gdImageGd2 php_gd_gdImageGd2
#define gdImageGd2Ptr php_gd_gdImageGd2Ptr
#define gdImageGdPtr php_gd_gdImageGdPtr
#define gdImageGetClip php_gd_gdImageGetClip
#define gdImageGetPixel php_gd_gdImageGetPixel
#define gdImageGetTrueColorPixel php_gd_gdImageGetTrueColorPixel
#define gdImageGif php_gd_gdImageGif
#define gdImageGifCtx php_gd_gdImageGifCtx
#define gdImageGifPtr php_gd_gdImageGifPtr
#define gdImageGrayScale php_gd_gdImageGrayScale
#define gdImageInterlace php_gd_gdImageInterlace
#define gdImageJpeg php_gd_gdImageJpeg
#define gdImageJpegCtx php_gd_gdImageJpegCtx
#define gdImageJpegPtr php_gd_gdImageJpegPtr
#define gdImageLine php_gd_gdImageLine
#define gdImageMeanRemoval php_gd_gdImageMeanRemoval
#define gdImageNegate php_gd_gdImageNegate
#define gdImagePaletteCopy php_gd_gdImagePaletteCopy
#define gdImagePng php_gd_gdImagePng
#define gdImagePngCtx php_gd_gdImagePngCtx
#define gdImagePngCtxEx php_gd_gdImagePngCtxEx
#define gdImagePngEx php_gd_gdImagePngEx
#define gdImagePngPtr php_gd_gdImagePngPtr
#define gdImagePngPtrEx php_gd_gdImagePngPtrEx
#define gdImagePngToSink php_gd_gdImagePngToSink
#define gdImagePolygon php_gd_gdImagePolygon
#define gdImageRectangle php_gd_gdImageRectangle
#define gdImageRotate php_gd_gdImageRotate
#define gdImageRotate180 php_gd_gdImageRotate180
#define gdImageRotate270 php_gd_gdImageRotate270
#define gdImageRotate45 php_gd_gdImageRotate45
#define gdImageRotate90 php_gd_gdImageRotate90
#define gdImageSaveAlpha php_gd_gdImageSaveAlpha
#define gdImageSelectiveBlur php_gd_gdImageSelectiveBlur
#define gdImageSetAntiAliased php_gd_gdImageSetAntiAliased
#define gdImageSetAntiAliasedDontBlend php_gd_gdImageSetAntiAliasedDontBlend
#define gdImageSetBrush php_gd_gdImageSetBrush
#define gdImageSetClip php_gd_gdImageSetClip
#define gdImageSetPixel php_gd_gdImageSetPixel
#define gdImageSetStyle php_gd_gdImageSetStyle
#define gdImageSetThickness php_gd_gdImageSetThickness
#define gdImageSetTile php_gd_gdImageSetTile
#define gdImageSkewX php_gd_gdImageSkewX
#define gdImageSkewY php_gd_gdImageSkewY
#define gdImageSmooth php_gd_gdImageSmooth
#define gdImageString php_gd_gdImageString
#define gdImageString16 php_gd_gdImageString16
#define gdImageStringFT php_gd_gdImageStringFT
#define gdImageStringFTEx php_gd_gdImageStringFTEx
#define gdImageStringTTF php_gd_gdImageStringTTF
#define gdImageStringUp php_gd_gdImageStringUp
#define gdImageStringUp16 php_gd_gdImageStringUp16
#define gdImageTrueColorToPalette php_gd_gdImageTrueColorToPalette
#define gdImageWBMP php_gd_gdImageWBMP
#define gdImageWBMPCtx php_gd_gdImageWBMPCtx
#define gdImageWBMPPtr php_gd_gdImageWBMPPtr
#define gdImageXbmCtx php_gd_gdImageXbmCtx
#define gdNewDynamicCtx php_gd_gdNewDynamicCtx
#define gdNewDynamicCtxEx php_gd_gdNewDynamicCtxEx
#define gdNewFileCtx php_gd_gdNewFileCtx
#define gdNewSSCtx php_gd_gdNewSSCtx
#define gdPutBuf php_gd_gdPutBuf
#define gdPutC php_gd_gdPutC
#define _gdPutColors php_gd__gdPutColors
#define gdPutInt php_gd_gdPutInt
#define gd_putout php_gd_gd_putout
#define gdPutWord php_gd_gdPutWord
#define gdSeek php_gd_gdSeek
#define gdSinT php_gd_gdSinT
#define gd_strtok_r php_gd_gd_strtok_r
#define gdTell php_gd_gdTell
#define getmbi php_gd_getmbi
#define init_destination php_gd_init_destination
#define init_source php_gd_init_source
#define jpeg_gdIOCtx_dest php_gd_jpeg_gdIOCtx_dest
#define jpeg_gdIOCtx_src php_gd_jpeg_gdIOCtx_src
#define lsqrt php_gd_lsqrt
#define printwbmp php_gd_printwbmp
#define Putchar php_gd_Putchar
#define putmbi php_gd_putmbi
#define Putword php_gd_Putword
#define readwbmp php_gd_readwbmp
#define skipheader php_gd_skipheader
#define skip_input_data php_gd_skip_input_data
#define term_destination php_gd_term_destination
#define term_source php_gd_term_source
#define writewbmp php_gd_writewbmp
#define ZeroDataBlock php_gd_ZeroDataBlock
#define gdCacheCreate php_gd_gdCacheCreate
#define gdCacheDelete php_gd_gdCacheDelete
#define gdCacheGet php_gd_gdCacheGet
#define gdFontCacheSetup php_gd_gdFontCacheSetup
#define gdFontCacheShutdown php_gd_gdFontCacheShutdown
#define gdFreeFontCache php_gd_gdFreeFontCache
#endif /* HAVE_GD_BUNDLED */
/* Define to specify how much context to retain around the current parse
point. */
#define XML_CONTEXT_BYTES 1024
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD 1
/* Define to make XML Namespaces functionality available. */
#define XML_NS 1
#endif
#ifdef PHP_EXPORTS
#define PCRE_STATIC
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
#ifndef PHP_CONTENT_TYPES_H
#define PHP_CONTENT_TYPES_H
#define DEFAULT_POST_CONTENT_TYPE "application/x-www-form-urlencoded"
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler);
int php_startup_sapi_content_types(void);
int php_setup_sapi_content_types(void);
#endif /* PHP_CONTENT_TYPES_H */

View File

@ -0,0 +1,39 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_GETOPT_H
#define PHP_GETOPT_H
#include "php.h"
/* Define structure for one recognized option (both single char and long name).
* If short_open is '-' this is the last option. */
typedef struct _opt_struct {
char opt_char;
int need_param;
char * opt_name;
} opt_struct;
BEGIN_EXTERN_C()
/* holds the index of the latest fetched element from the opts array */
extern PHPAPI int php_optidx;
PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start);
END_EXTERN_C()
/* php_getopt will return this value if there is an error in arguments */
#define PHP_GETOPT_INVALID_ARG (-2)
#endif

View File

@ -0,0 +1,178 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_GLOBALS_H
#define PHP_GLOBALS_H
#include "zend_globals.h"
#include <stdint.h>
typedef struct _php_core_globals php_core_globals;
#ifdef ZTS
# define PG(v) ZEND_TSRMG_FAST(core_globals_offset, php_core_globals *, v)
extern PHPAPI int core_globals_id;
extern PHPAPI size_t core_globals_offset;
#else
# define PG(v) (core_globals.v)
extern ZEND_API struct _php_core_globals core_globals;
#endif
/* Error display modes */
#define PHP_DISPLAY_ERRORS_STDOUT 1
#define PHP_DISPLAY_ERRORS_STDERR 2
/* Track vars */
#define TRACK_VARS_POST 0
#define TRACK_VARS_GET 1
#define TRACK_VARS_COOKIE 2
#define TRACK_VARS_SERVER 3
#define TRACK_VARS_ENV 4
#define TRACK_VARS_FILES 5
#define TRACK_VARS_REQUEST 6
struct _php_tick_function_entry;
typedef struct _arg_separators {
char *output;
char *input;
} arg_separators;
struct _php_core_globals {
zend_long output_buffering;
bool implicit_flush;
bool enable_dl;
uint8_t display_errors;
bool display_startup_errors;
bool log_errors;
bool ignore_repeated_errors;
bool ignore_repeated_source;
bool report_memleaks;
char *output_handler;
char *unserialize_callback_func;
zend_long serialize_precision;
zend_long memory_limit;
zend_long max_input_time;
char *error_log;
char *doc_root;
char *user_dir;
char *include_path;
char *open_basedir;
bool open_basedir_modified;
char *extension_dir;
char *php_binary;
char *sys_temp_dir;
char *upload_tmp_dir;
zend_long upload_max_filesize;
char *error_append_string;
char *error_prepend_string;
char *auto_prepend_file;
char *auto_append_file;
char *input_encoding;
char *internal_encoding;
char *output_encoding;
arg_separators arg_separator;
char *variables_order;
HashTable rfc1867_protected_variables;
short connection_status;
bool ignore_user_abort;
unsigned char header_is_being_sent;
zend_llist tick_functions;
zval http_globals[6];
bool expose_php;
bool register_argc_argv;
bool auto_globals_jit;
bool html_errors;
bool xmlrpc_errors;
char *docref_root;
char *docref_ext;
zend_long xmlrpc_error_number;
bool activated_auto_globals[8];
bool modules_activated;
bool file_uploads;
bool during_request_startup;
bool allow_url_fopen;
bool enable_post_data_reading;
bool report_zend_debug;
int last_error_type;
int last_error_lineno;
zend_string *last_error_message;
zend_string *last_error_file;
char *php_sys_temp_dir;
char *disable_classes;
zend_long max_input_nesting_level;
zend_long max_input_vars;
char *user_ini_filename;
zend_long user_ini_cache_ttl;
char *request_order;
char *mail_log;
bool mail_x_header;
bool mail_mixed_lf_and_crlf;
bool in_error_log;
bool allow_url_include;
#ifdef PHP_WIN32
bool com_initialized;
#endif
bool in_user_include;
#ifdef PHP_WIN32
bool windows_show_crt_warning;
#endif
bool have_called_openlog;
zend_long syslog_facility;
char *syslog_ident;
zend_long syslog_filter;
zend_long error_log_mode;
};
#endif /* PHP_GLOBALS_H */

View File

@ -0,0 +1,87 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_INI_H
#define PHP_INI_H
#include "zend_ini.h"
BEGIN_EXTERN_C()
PHPAPI void config_zval_dtor(zval *zvalue);
int php_init_config(void);
int php_shutdown_config(void);
void php_ini_register_extensions(void);
PHPAPI zval *cfg_get_entry_ex(zend_string *name);
PHPAPI zval *cfg_get_entry(const char *name, size_t name_length);
PHPAPI int cfg_get_long(const char *varname, zend_long *result);
PHPAPI int cfg_get_double(const char *varname, double *result);
PHPAPI int cfg_get_string(const char *varname, char **result);
PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash);
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage);
PHPAPI int php_ini_has_per_dir_config(void);
PHPAPI int php_ini_has_per_host_config(void);
PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len);
PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len);
PHPAPI HashTable* php_ini_get_configuration_hash(void);
END_EXTERN_C()
#define PHP_INI_USER ZEND_INI_USER
#define PHP_INI_PERDIR ZEND_INI_PERDIR
#define PHP_INI_SYSTEM ZEND_INI_SYSTEM
#define PHP_INI_ALL ZEND_INI_ALL
#define php_ini_entry zend_ini_entry
#define PHP_INI_MH ZEND_INI_MH
#define PHP_INI_DISP ZEND_INI_DISP
#define PHP_INI_BEGIN ZEND_INI_BEGIN
#define PHP_INI_END ZEND_INI_END
#define PHP_INI_ENTRY3_EX ZEND_INI_ENTRY3_EX
#define PHP_INI_ENTRY3 ZEND_INI_ENTRY3
#define PHP_INI_ENTRY2_EX ZEND_INI_ENTRY2_EX
#define PHP_INI_ENTRY2 ZEND_INI_ENTRY2
#define PHP_INI_ENTRY1_EX ZEND_INI_ENTRY1_EX
#define PHP_INI_ENTRY1 ZEND_INI_ENTRY1
#define PHP_INI_ENTRY_EX ZEND_INI_ENTRY_EX
#define PHP_INI_ENTRY ZEND_INI_ENTRY
#define STD_PHP_INI_ENTRY STD_ZEND_INI_ENTRY
#define STD_PHP_INI_ENTRY_EX STD_ZEND_INI_ENTRY_EX
#define STD_PHP_INI_BOOLEAN STD_ZEND_INI_BOOLEAN
#define PHP_INI_DISPLAY_ORIG ZEND_INI_DISPLAY_ORIG
#define PHP_INI_DISPLAY_ACTIVE ZEND_INI_DISPLAY_ACTIVE
#define PHP_INI_STAGE_STARTUP ZEND_INI_STAGE_STARTUP
#define PHP_INI_STAGE_SHUTDOWN ZEND_INI_STAGE_SHUTDOWN
#define PHP_INI_STAGE_ACTIVATE ZEND_INI_STAGE_ACTIVATE
#define PHP_INI_STAGE_DEACTIVATE ZEND_INI_STAGE_DEACTIVATE
#define PHP_INI_STAGE_RUNTIME ZEND_INI_STAGE_RUNTIME
#define PHP_INI_STAGE_HTACCESS ZEND_INI_STAGE_HTACCESS
#define php_ini_boolean_displayer_cb zend_ini_boolean_displayer_cb
#define php_ini_color_displayer_cb zend_ini_color_displayer_cb
#define php_alter_ini_entry zend_alter_ini_entry
#define php_ini_long zend_ini_long
#define php_ini_double zend_ini_double
#define php_ini_string zend_ini_string
#endif /* PHP_INI_H */

View File

@ -0,0 +1,95 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Max Kellermann <max.kellermann@ionos.com> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_INI_BUILDER_H
#define PHP_INI_BUILDER_H
#include "php.h"
/**
* A class which helps with constructing INI entries from the command
* line.
*/
struct php_ini_builder {
char *value;
size_t length;
};
BEGIN_EXTERN_C()
static inline void php_ini_builder_init(struct php_ini_builder *b)
{
b->value = NULL;
b->length = 0;
}
static inline void php_ini_builder_deinit(struct php_ini_builder *b)
{
free(b->value);
}
/**
* Null-terminate the buffer and return it.
*/
static inline char *php_ini_builder_finish(struct php_ini_builder *b)
{
if (b->value != NULL) {
/* null-terminate the string */
b->value[b->length] = '\0';
}
return b->value;
}
/**
* Make room for more data.
*
* @param delta the number of bytes to be appended
*/
static inline void php_ini_builder_realloc(struct php_ini_builder *b, size_t delta)
{
/* reserve enough space for the null terminator */
b->value = realloc(b->value, b->length + delta + 1);
}
/**
* Prepend a string.
*
* @param src the source string
* @param length the size of the source string
*/
PHPAPI void php_ini_builder_prepend(struct php_ini_builder *b, const char *src, size_t length);
#define php_ini_builder_prepend_literal(b, l) php_ini_builder_prepend(b, l, strlen(l))
/**
* Append an unquoted name/value pair.
*/
PHPAPI void php_ini_builder_unquoted(struct php_ini_builder *b, const char *name, size_t name_length, const char *value, size_t value_length);
/**
* Append a quoted name/value pair.
*/
PHPAPI void php_ini_builder_quoted(struct php_ini_builder *b, const char *name, size_t name_length, const char *value, size_t value_length);
/**
* Parse an INI entry from the command-line option "--define".
*/
PHPAPI void php_ini_builder_define(struct php_ini_builder *b, const char *arg);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,79 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_MAIN_H
#define PHP_MAIN_H
#include "zend_globals.h"
#include "php_globals.h"
#include "SAPI.h"
BEGIN_EXTERN_C()
/* Returns the PHP version the engine was built with. This is useful for
* extensions which want to know the version of PHP at run-time, rather than
* the version they were built with at compile-time.
*/
PHPAPI const char *php_version(void);
/* Returns the PHP version id the engine was built with. This is useful for
* extensions which want to know the version of PHP at run-time, rather than
* the version they were built with at compile-time.
*/
PHPAPI unsigned int php_version_id(void);
PHPAPI zend_result php_request_startup(void);
PHPAPI void php_request_shutdown(void *dummy);
PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module);
PHPAPI void php_module_shutdown(void);
PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
PHPAPI zend_result php_register_extensions(zend_module_entry * const * ptr, int count);
PHPAPI bool php_execute_script(zend_file_handle *primary_file);
PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret);
PHPAPI zend_result php_lint_script(zend_file_handle *file);
PHPAPI void php_handle_aborted_connection(void);
PHPAPI int php_handle_auth_data(const char *auth);
PHPAPI void php_html_puts(const char *str, size_t siz);
PHPAPI zend_result php_stream_open_for_zend_ex(zend_file_handle *handle, int mode);
/* environment module */
extern int php_init_environ(void);
extern int php_shutdown_environ(void);
#ifdef ZTS
PHPAPI void php_reserve_tsrm_memory(void);
PHPAPI bool php_tsrm_startup_ex(int expected_threads);
PHPAPI bool php_tsrm_startup(void);
#define PHP_ZTS 1
#else
#define PHP_ZTS 0
#endif
#ifdef PHP_WIN32
#define PHP_OS_STR "WINNT"
#else
#define PHP_OS_STR PHP_OS
#endif
END_EXTERN_C()
#endif

View File

@ -0,0 +1,63 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_MEMORY_STREAM_H
#define PHP_MEMORY_STREAM_H
#include "php_streams.h"
#define PHP_STREAM_MAX_MEM 2 * 1024 * 1024
#define TEMP_STREAM_DEFAULT 0x0
#define TEMP_STREAM_READONLY 0x1
#define TEMP_STREAM_TAKE_BUFFER 0x2
#define TEMP_STREAM_APPEND 0x4
#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC)
#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC)
#define php_stream_memory_open(mode, str) _php_stream_memory_open((mode), (str) STREAMS_CC)
#define php_stream_memory_get_buffer(stream) _php_stream_memory_get_buffer((stream) STREAMS_CC)
#define php_stream_temp_new() php_stream_temp_create(TEMP_STREAM_DEFAULT, PHP_STREAM_MAX_MEM)
#define php_stream_temp_create(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_CC)
#define php_stream_temp_create_ex(mode, max_memory_usage, tmpdir) _php_stream_temp_create_ex((mode), (max_memory_usage), (tmpdir) STREAMS_CC)
#define php_stream_temp_create_rel(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_REL_CC)
#define php_stream_temp_open(mode, max_memory_usage, buf, length) _php_stream_temp_open((mode), (max_memory_usage), (buf), (length) STREAMS_CC)
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC);
PHPAPI php_stream *_php_stream_memory_open(int mode, zend_string *buf STREAMS_DC);
PHPAPI zend_string *_php_stream_memory_get_buffer(php_stream *stream STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC);
PHPAPI int php_stream_mode_from_str(const char *mode);
PHPAPI const char *_php_stream_mode_to_str(int mode);
END_EXTERN_C()
extern PHPAPI const php_stream_ops php_stream_memory_ops;
extern PHPAPI const php_stream_ops php_stream_temp_ops;
extern PHPAPI const php_stream_ops php_stream_rfc2397_ops;
extern PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper;
#define PHP_STREAM_IS_MEMORY &php_stream_memory_ops
#define PHP_STREAM_IS_TEMP &php_stream_temp_ops
#endif

View File

@ -0,0 +1,363 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Venaas <venaas@uninett.no> |
+----------------------------------------------------------------------+
*/
#ifndef _PHP_NETWORK_H
#define _PHP_NETWORK_H
#include <php.h>
#ifdef PHP_WIN32
# include "win32/inet.h"
#else
# undef closesocket
# define closesocket close
# include <netinet/tcp.h>
#endif
#ifndef HAVE_SHUTDOWN
#undef shutdown
#define shutdown(s,n) /* nothing */
#endif
#ifdef PHP_WIN32
# ifdef EWOULDBLOCK
# undef EWOULDBLOCK
# endif
# ifdef EINPROGRESS
# undef EINPROGRESS
# endif
# define EWOULDBLOCK WSAEWOULDBLOCK
# define EINPROGRESS WSAEWOULDBLOCK
# define fsync _commit
# define ftruncate(a, b) chsize(a, b)
#endif /* defined(PHP_WIN32) */
#ifndef EWOULDBLOCK
# define EWOULDBLOCK EAGAIN
#endif
/* This is a workaround for GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 */
#if EAGAIN != EWOULDBLOCK
# define PHP_IS_TRANSIENT_ERROR(err) (err == EAGAIN || err == EWOULDBLOCK)
#else
# define PHP_IS_TRANSIENT_ERROR(err) (err == EAGAIN)
#endif
#ifdef PHP_WIN32
#define php_socket_errno() WSAGetLastError()
#else
#define php_socket_errno() errno
#endif
/* like strerror, but caller must efree the returned string,
* unless buf is not NULL.
* Also works sensibly for win32 */
BEGIN_EXTERN_C()
PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize);
PHPAPI zend_string *php_socket_error_str(long err);
END_EXTERN_C()
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_GETHOSTBYNAME_R
#include <netdb.h>
#endif
/* These are here, rather than with the win32 counterparts above,
* since <sys/socket.h> defines them. */
#ifndef SHUT_RD
# define SHUT_RD 0
# define SHUT_WR 1
# define SHUT_RDWR 2
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <stddef.h>
#ifdef PHP_WIN32
typedef SOCKET php_socket_t;
#else
typedef int php_socket_t;
#endif
#ifdef PHP_WIN32
# define SOCK_ERR INVALID_SOCKET
# define SOCK_CONN_ERR SOCKET_ERROR
# define SOCK_RECV_ERR SOCKET_ERROR
#else
# define SOCK_ERR -1
# define SOCK_CONN_ERR -1
# define SOCK_RECV_ERR -1
#endif
#define STREAM_SOCKOP_NONE (1 << 0)
#define STREAM_SOCKOP_SO_REUSEPORT (1 << 1)
#define STREAM_SOCKOP_SO_BROADCAST (1 << 2)
#define STREAM_SOCKOP_IPV6_V6ONLY (1 << 3)
#define STREAM_SOCKOP_IPV6_V6ONLY_ENABLED (1 << 4)
#define STREAM_SOCKOP_TCP_NODELAY (1 << 5)
/* uncomment this to debug poll(2) emulation on systems that have poll(2) */
/* #define PHP_USE_POLL_2_EMULATION 1 */
#if defined(HAVE_POLL)
# if defined(HAVE_POLL_H)
# include <poll.h>
# elif defined(HAVE_SYS_POLL_H)
# include <sys/poll.h>
# endif
typedef struct pollfd php_pollfd;
#else
typedef struct _php_pollfd {
php_socket_t fd;
short events;
short revents;
} php_pollfd;
PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout);
#ifndef POLLIN
# define POLLIN 0x0001 /* There is data to read */
# define POLLPRI 0x0002 /* There is urgent data to read */
# define POLLOUT 0x0004 /* Writing now will not block */
# define POLLERR 0x0008 /* Error condition */
# define POLLHUP 0x0010 /* Hung up */
# define POLLNVAL 0x0020 /* Invalid request: fd not open */
#endif
# ifndef PHP_USE_POLL_2_EMULATION
# define PHP_USE_POLL_2_EMULATION 1
# endif
#endif
#define PHP_POLLREADABLE (POLLIN|POLLERR|POLLHUP)
#ifndef PHP_USE_POLL_2_EMULATION
# define php_poll2(ufds, nfds, timeout) poll(ufds, nfds, timeout)
#endif
/* timeval-to-timeout (for poll(2)) */
static inline int php_tvtoto(struct timeval *timeouttv)
{
if (timeouttv) {
return (timeouttv->tv_sec * 1000) + (timeouttv->tv_usec / 1000);
}
return -1;
}
/* hybrid select(2)/poll(2) for a single descriptor.
* timeouttv follows same rules as select(2), but is reduced to millisecond accuracy.
* Returns 0 on timeout, -1 on error, or the event mask (ala poll(2)).
*/
static inline int php_pollfd_for(php_socket_t fd, int events, struct timeval *timeouttv)
{
php_pollfd p;
int n;
p.fd = fd;
p.events = events;
p.revents = 0;
n = php_poll2(&p, 1, php_tvtoto(timeouttv));
if (n > 0) {
return p.revents;
}
return n;
}
static inline int php_pollfd_for_ms(php_socket_t fd, int events, int timeout)
{
php_pollfd p;
int n;
p.fd = fd;
p.events = events;
p.revents = 0;
n = php_poll2(&p, 1, timeout);
if (n > 0) {
return p.revents;
}
return n;
}
/* emit warning and suggestion for unsafe select(2) usage */
PHPAPI void _php_emit_fd_setsize_warning(int max_fd);
static inline bool _php_check_fd_setsize(php_socket_t *max_fd, int setsize)
{
#ifdef PHP_WIN32
(void)(max_fd); // Unused
if (setsize + 1 >= FD_SETSIZE) {
_php_emit_fd_setsize_warning(setsize);
return false;
}
#else
(void)(setsize); // Unused
if (*max_fd >= FD_SETSIZE) {
_php_emit_fd_setsize_warning(*max_fd);
*max_fd = FD_SETSIZE - 1;
return false;
}
#endif
return true;
}
#ifdef PHP_WIN32
/* it is safe to FD_SET too many fd's under win32; the macro will simply ignore
* descriptors that go beyond the default FD_SETSIZE */
# define PHP_SAFE_FD_SET(fd, set) FD_SET(fd, set)
# define PHP_SAFE_FD_CLR(fd, set) FD_CLR(fd, set)
# define PHP_SAFE_FD_ISSET(fd, set) FD_ISSET(fd, set)
# define PHP_SAFE_MAX_FD(m, n) _php_check_fd_setsize(&m, n)
#else
# define PHP_SAFE_FD_SET(fd, set) do { if (fd < FD_SETSIZE) FD_SET(fd, set); } while(0)
# define PHP_SAFE_FD_CLR(fd, set) do { if (fd < FD_SETSIZE) FD_CLR(fd, set); } while(0)
# define PHP_SAFE_FD_ISSET(fd, set) ((fd < FD_SETSIZE) && FD_ISSET(fd, set))
# define PHP_SAFE_MAX_FD(m, n) _php_check_fd_setsize(&m, n)
#endif
#define PHP_SOCK_CHUNK_SIZE 8192
#ifdef HAVE_SOCKADDR_STORAGE
typedef struct sockaddr_storage php_sockaddr_storage;
#else
typedef struct {
#ifdef HAVE_SOCKADDR_SA_LEN
unsigned char ss_len;
unsigned char ss_family;
#else
unsigned short ss_family;
#endif
char info[126];
} php_sockaddr_storage;
#endif
BEGIN_EXTERN_C()
PHPAPI int php_network_getaddresses(const char *host, int socktype, struct sockaddr ***sal, zend_string **error_string);
PHPAPI void php_network_freeaddresses(struct sockaddr **sal);
PHPAPI php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
int *error_code, const char *bindto, unsigned short bindport, long sockopts
);
PHPAPI int php_network_connect_socket(php_socket_t sockfd,
const struct sockaddr *addr,
socklen_t addrlen,
int asynchronous,
struct timeval *timeout,
zend_string **error_string,
int *error_code);
#define php_connect_nonb(sock, addr, addrlen, timeout) \
php_network_connect_socket((sock), (addr), (addrlen), 0, (timeout), NULL, NULL)
PHPAPI php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned port,
int socktype, long sockopts, zend_string **error_string, int *error_code
);
PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
zend_string **textaddr,
struct sockaddr **addr,
socklen_t *addrlen,
struct timeval *timeout,
zend_string **error_string,
int *error_code,
int tcp_nodelay
);
PHPAPI int php_network_get_sock_name(php_socket_t sock,
zend_string **textaddr,
struct sockaddr **addr,
socklen_t *addrlen
);
PHPAPI int php_network_get_peer_name(php_socket_t sock,
zend_string **textaddr,
struct sockaddr **addr,
socklen_t *addrlen
);
PHPAPI void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port);
PHPAPI int php_sockaddr_size(php_sockaddr_storage *addr);
END_EXTERN_C()
struct _php_netstream_data_t {
php_socket_t socket;
char is_blocked;
struct timeval timeout;
char timeout_event;
size_t ownsize;
};
typedef struct _php_netstream_data_t php_netstream_data_t;
PHPAPI extern const php_stream_ops php_stream_socket_ops;
extern const php_stream_ops php_stream_generic_socket_ops;
#define PHP_STREAM_IS_SOCKET (&php_stream_socket_ops)
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_sock_open_from_socket(php_socket_t socket, const char *persistent_id STREAMS_DC );
/* open a connection to a host using php_hostconnect and return a stream */
PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port,
int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC);
PHPAPI void php_network_populate_name_from_sockaddr(
/* input address */
struct sockaddr *sa, socklen_t sl,
/* output readable address */
zend_string **textaddr,
/* output address */
struct sockaddr **addr,
socklen_t *addrlen
);
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
zend_long addrlen, struct sockaddr *sa, socklen_t *sl);
PHPAPI struct hostent* php_network_gethostbyname(const char *name);
PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
END_EXTERN_C()
#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC)
#define php_stream_sock_open_host(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_CC)
/* {{{ memory debug */
#define php_stream_sock_open_from_socket_rel(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_REL_CC)
#define php_stream_sock_open_host_rel(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_REL_CC)
#define php_stream_sock_open_unix_rel(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_REL_CC)
/* }}} */
#ifndef MAXFQDNLEN
#define MAXFQDNLEN 255
#endif
#endif /* _PHP_NETWORK_H */

View File

@ -0,0 +1,22 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Calvin Buckley <calvin@cmpct.info> |
+----------------------------------------------------------------------+
*/
#include "php.h"
PHPAPI bool php_odbc_connstr_is_quoted(const char *str);
PHPAPI bool php_odbc_connstr_should_quote(const char *str);
PHPAPI size_t php_odbc_connstr_estimate_quote_length(const char *in_str);
PHPAPI size_t php_odbc_connstr_quote(char *out_str, const char *in_str, size_t out_str_size);

View File

@ -0,0 +1,38 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_OPEN_TEMPORARY_FILE_H
#define PHP_OPEN_TEMPORARY_FILE_H
#define PHP_TMP_FILE_DEFAULT 0
#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_FALLBACK (1<<0)
#define PHP_TMP_FILE_SILENT (1<<1)
#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_EXPLICIT_DIR (1<<2)
#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ALWAYS \
(PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_FALLBACK | PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_EXPLICIT_DIR)
/* for compatibility purpose */
#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_FALLBACK
BEGIN_EXTERN_C()
PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, zend_string **opened_path_p);
PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, uint32_t flags);
PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, zend_string **opened_path_p);
PHPAPI const char *php_get_temporary_directory(void);
END_EXTERN_C()
#endif /* PHP_OPEN_TEMPORARY_FILE_H */

View File

@ -0,0 +1,242 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Michael Wallner <mike@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_OUTPUT_H
#define PHP_OUTPUT_H
#define PHP_OUTPUT_NEWAPI 1
/* handler ops */
#define PHP_OUTPUT_HANDLER_WRITE 0x00 /* standard passthru */
#define PHP_OUTPUT_HANDLER_START 0x01 /* start */
#define PHP_OUTPUT_HANDLER_CLEAN 0x02 /* restart */
#define PHP_OUTPUT_HANDLER_FLUSH 0x04 /* pass along as much as possible */
#define PHP_OUTPUT_HANDLER_FINAL 0x08 /* finalize */
#define PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_WRITE
#define PHP_OUTPUT_HANDLER_END PHP_OUTPUT_HANDLER_FINAL
/* handler types */
#define PHP_OUTPUT_HANDLER_INTERNAL 0x0000
#define PHP_OUTPUT_HANDLER_USER 0x0001
/* handler ability flags */
#define PHP_OUTPUT_HANDLER_CLEANABLE 0x0010
#define PHP_OUTPUT_HANDLER_FLUSHABLE 0x0020
#define PHP_OUTPUT_HANDLER_REMOVABLE 0x0040
#define PHP_OUTPUT_HANDLER_STDFLAGS 0x0070
/* handler status flags */
#define PHP_OUTPUT_HANDLER_STARTED 0x1000
#define PHP_OUTPUT_HANDLER_DISABLED 0x2000
#define PHP_OUTPUT_HANDLER_PROCESSED 0x4000
/* handler op return values */
typedef enum _php_output_handler_status_t {
PHP_OUTPUT_HANDLER_FAILURE,
PHP_OUTPUT_HANDLER_SUCCESS,
PHP_OUTPUT_HANDLER_NO_DATA
} php_output_handler_status_t;
/* php_output_stack_pop() flags */
#define PHP_OUTPUT_POP_TRY 0x000
#define PHP_OUTPUT_POP_FORCE 0x001
#define PHP_OUTPUT_POP_DISCARD 0x010
#define PHP_OUTPUT_POP_SILENT 0x100
/* real global flags */
#define PHP_OUTPUT_IMPLICITFLUSH 0x01
#define PHP_OUTPUT_DISABLED 0x02
#define PHP_OUTPUT_WRITTEN 0x04
#define PHP_OUTPUT_SENT 0x08
/* supplementary flags for php_output_get_status() */
#define PHP_OUTPUT_ACTIVE 0x10
#define PHP_OUTPUT_LOCKED 0x20
/* output layer is ready to use */
#define PHP_OUTPUT_ACTIVATED 0x100000
/* handler hooks */
typedef enum _php_output_handler_hook_t {
PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ,
PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS,
PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL,
PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE,
PHP_OUTPUT_HANDLER_HOOK_DISABLE,
/* unused */
PHP_OUTPUT_HANDLER_HOOK_LAST
} php_output_handler_hook_t;
#define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \
( ((s) > 1) ? \
(s) + PHP_OUTPUT_HANDLER_ALIGNTO_SIZE - ((s) % (PHP_OUTPUT_HANDLER_ALIGNTO_SIZE)) : \
PHP_OUTPUT_HANDLER_DEFAULT_SIZE \
)
#define PHP_OUTPUT_HANDLER_ALIGNTO_SIZE 0x1000
#define PHP_OUTPUT_HANDLER_DEFAULT_SIZE 0x4000
typedef struct _php_output_buffer {
char *data;
size_t size;
size_t used;
uint32_t free:1;
uint32_t _reserved:31;
} php_output_buffer;
typedef struct _php_output_context {
int op;
php_output_buffer in;
php_output_buffer out;
} php_output_context;
/* old-style, stateless callback */
typedef void (*php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode);
/* new-style, opaque context callback */
typedef int (*php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context);
/* output handler context dtor */
typedef void (*php_output_handler_context_dtor_t)(void *opaq);
/* conflict check callback */
typedef int (*php_output_handler_conflict_check_t)(const char *handler_name, size_t handler_name_len);
/* ctor for aliases */
typedef struct _php_output_handler *(*php_output_handler_alias_ctor_t)(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags);
typedef struct _php_output_handler_user_func_t {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval zoh;
} php_output_handler_user_func_t;
typedef struct _php_output_handler {
zend_string *name;
int flags;
int level;
size_t size;
php_output_buffer buffer;
void *opaq;
void (*dtor)(void *opaq);
union {
php_output_handler_user_func_t *user;
php_output_handler_context_func_t internal;
} func;
} php_output_handler;
ZEND_BEGIN_MODULE_GLOBALS(output)
zend_stack handlers;
php_output_handler *active;
php_output_handler *running;
zend_string *output_start_filename;
int output_start_lineno;
int flags;
ZEND_END_MODULE_GLOBALS(output)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(output)
/* there should not be a need to use OG() from outside of output.c */
#ifdef ZTS
# define OG(v) ZEND_TSRMG(output_globals_id, zend_output_globals *, v)
#else
# define OG(v) (output_globals.v)
#endif
/* convenience macros */
#define PHPWRITE(str, str_len) php_output_write((str), (str_len))
#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len))
#define PUTC(c) php_output_write((const char *) &(c), 1)
#define PUTC_H(c) php_output_write_unbuffered((const char *) &(c), 1)
#define PUTS(str) do { \
const char *__str = (str); \
php_output_write(__str, strlen(__str)); \
} while (0)
#define PUTS_H(str) do { \
const char *__str = (str); \
php_output_write_unbuffered(__str, strlen(__str)); \
} while (0)
BEGIN_EXTERN_C()
extern const char php_output_default_handler_name[sizeof("default output handler")];
extern const char php_output_devnull_handler_name[sizeof("null output handler")];
#define php_output_tearup() \
php_output_startup(); \
php_output_activate()
#define php_output_teardown() \
php_output_end_all(); \
php_output_deactivate(); \
php_output_shutdown()
/* MINIT */
PHPAPI void php_output_startup(void);
/* MSHUTDOWN */
PHPAPI void php_output_shutdown(void);
/* RINIT */
PHPAPI int php_output_activate(void);
/* RSHUTDOWN */
PHPAPI void php_output_deactivate(void);
PHPAPI void php_output_set_status(int status);
PHPAPI int php_output_get_status(void);
PHPAPI void php_output_set_implicit_flush(int flush);
PHPAPI const char *php_output_get_start_filename(void);
PHPAPI int php_output_get_start_lineno(void);
PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len);
PHPAPI size_t php_output_write(const char *str, size_t len);
PHPAPI int php_output_flush(void);
PHPAPI void php_output_flush_all(void);
PHPAPI int php_output_clean(void);
PHPAPI void php_output_clean_all(void);
PHPAPI int php_output_end(void);
PHPAPI void php_output_end_all(void);
PHPAPI int php_output_discard(void);
PHPAPI void php_output_discard_all(void);
PHPAPI int php_output_get_contents(zval *p);
PHPAPI int php_output_get_length(zval *p);
PHPAPI int php_output_get_level(void);
PHPAPI php_output_handler* php_output_get_active_handler(void);
PHPAPI int php_output_start_default(void);
PHPAPI int php_output_start_devnull(void);
PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int flags);
PHPAPI int php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags);
PHPAPI php_output_handler *php_output_handler_create_user(zval *handler, size_t chunk_size, int flags);
PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t handler, size_t chunk_size, int flags);
PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void (*dtor)(void*));
PHPAPI int php_output_handler_start(php_output_handler *handler);
PHPAPI int php_output_handler_started(const char *name, size_t name_len);
PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg);
PHPAPI void php_output_handler_dtor(php_output_handler *handler);
PHPAPI void php_output_handler_free(php_output_handler **handler);
PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len);
PHPAPI int php_output_handler_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func);
PHPAPI int php_output_handler_reverse_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func);
PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *handler_name, size_t handler_name_len);
PHPAPI int php_output_handler_alias_register(const char *handler_name, size_t handler_name_len, php_output_handler_alias_ctor_t func);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,116 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_REENTRANCY_H
#define PHP_REENTRANCY_H
#include "php.h"
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#include <time.h>
/* currently, PHP does not check for these functions, but assumes
that they are available on all systems. */
#define HAVE_LOCALTIME 1
#define HAVE_GMTIME 1
#define HAVE_ASCTIME 1
#define HAVE_CTIME 1
#if defined(PHP_IRIX_TIME_R)
#undef HAVE_ASCTIME_R
#undef HAVE_CTIME_R
#endif
#if defined(PHP_HPUX_TIME_R)
#undef HAVE_LOCALTIME_R
#undef HAVE_ASCTIME_R
#undef HAVE_CTIME_R
#undef HAVE_GMTIME_R
#endif
BEGIN_EXTERN_C()
#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
#define PHP_NEED_REENTRANCY 1
PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
#else
#define php_localtime_r localtime_r
#ifdef MISSING_LOCALTIME_R_DECL
struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
#endif
#endif
#if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
#define PHP_NEED_REENTRANCY 1
PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
#else
#define php_ctime_r ctime_r
#ifdef MISSING_CTIME_R_DECL
char *ctime_r(const time_t *clock, char *buf);
#endif
#endif
#if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
#define PHP_NEED_REENTRANCY 1
PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
#else
#define php_asctime_r asctime_r
#ifdef MISSING_ASCTIME_R_DECL
char *asctime_r(const struct tm *tm, char *buf);
#endif
#endif
#if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
#define PHP_NEED_REENTRANCY 1
PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
#else
#define php_gmtime_r gmtime_r
#ifdef MISSING_GMTIME_R_DECL
struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
#endif
#endif
#if !defined(HAVE_STRTOK_R)
PHPAPI char *php_strtok_r(char *s, const char *delim, char **last);
#else
#define php_strtok_r strtok_r
#ifdef MISSING_STRTOK_R_DECL
char *strtok_r(char *s, const char *delim, char **last);
#endif
#endif
END_EXTERN_C()
#if !defined(ZTS)
#undef PHP_NEED_REENTRANCY
#endif
#if defined(PHP_NEED_REENTRANCY)
void reentrancy_startup(void);
void reentrancy_shutdown(void);
#else
#define reentrancy_startup()
#define reentrancy_shutdown()
#endif
#endif

View File

@ -0,0 +1,46 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Shane Caraveo <shane@caraveo.com> |
| Ilia Alshanetsky <ilia@prohost.org> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SCANDIR_H
#define PHP_SCANDIR_H
#include <sys/types.h>
#ifdef PHP_WIN32
#include "config.w32.h"
#include "win32/readdir.h"
#else
#include <php_config.h>
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_SCANDIR
#define php_scandir scandir
#else
PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b));
#endif
#ifdef HAVE_ALPHASORT
#define php_alphasort alphasort
#else
PHPAPI int php_alphasort(const struct dirent **a, const struct dirent **b);
#endif
#endif /* PHP_SCANDIR_H */

View File

@ -0,0 +1,653 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong (wez@thebrainroom.com) |
+----------------------------------------------------------------------+
*/
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "zend.h"
#include "zend_stream.h"
BEGIN_EXTERN_C()
PHPAPI int php_file_le_stream(void);
PHPAPI int php_file_le_pstream(void);
PHPAPI int php_file_le_stream_filter(void);
END_EXTERN_C()
/* {{{ Streams memory debugging stuff */
#if ZEND_DEBUG
/* these have more of a dependency on the definitions of the zend macros than
* I would prefer, but doing it this way saves loads of idefs :-/ */
# define STREAMS_D int __php_stream_call_depth ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
# define STREAMS_C 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC
# define STREAMS_REL_C __php_stream_call_depth + 1 ZEND_FILE_LINE_CC, \
__php_stream_call_depth ? __zend_orig_filename : __zend_filename, \
__php_stream_call_depth ? __zend_orig_lineno : __zend_lineno
# define STREAMS_DC , STREAMS_D
# define STREAMS_CC , STREAMS_C
# define STREAMS_REL_CC , STREAMS_REL_C
#else
# define STREAMS_D
# define STREAMS_C
# define STREAMS_REL_C
# define STREAMS_DC
# define STREAMS_CC
# define STREAMS_REL_CC
#endif
/* these functions relay the file/line number information. They are depth aware, so they will pass
* the ultimate ancestor, which is useful, because there can be several layers of calls */
#define php_stream_alloc_rel(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_REL_CC)
#define php_stream_copy_to_mem_rel(src, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_REL_CC)
#define php_stream_fopen_rel(filename, mode, opened, options) _php_stream_fopen((filename), (mode), (opened), (options) STREAMS_REL_CC)
#define php_stream_fopen_with_path_rel(filename, mode, path, opened, options) _php_stream_fopen_with_path((filename), (mode), (path), (opened), (options) STREAMS_REL_CC)
#define php_stream_fopen_from_fd_rel(fd, mode, persistent_id, zero_position) _php_stream_fopen_from_fd((fd), (mode), (persistent_id), (zero_position) STREAMS_REL_CC)
#define php_stream_fopen_from_file_rel(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_REL_CC)
#define php_stream_fopen_from_pipe_rel(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_REL_CC)
#define php_stream_fopen_tmpfile_rel() _php_stream_fopen_tmpfile(0 STREAMS_REL_CC)
#define php_stream_fopen_temporary_file_rel(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_REL_CC)
#define php_stream_open_wrapper_rel(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_REL_CC)
#define php_stream_open_wrapper_ex_rel(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_REL_CC)
#define php_stream_make_seekable_rel(origstream, newstream, flags) _php_stream_make_seekable((origstream), (newstream), (flags) STREAMS_REL_CC)
/* }}} */
/* The contents of the php_stream_ops and php_stream should only be accessed
* using the functions/macros in this header.
* If you need to get at something that doesn't have an API,
* drop me a line <wez@thebrainroom.com> and we can sort out a way to do
* it properly.
*
* The only exceptions to this rule are that stream implementations can use
* the php_stream->abstract pointer to hold their context, and streams
* opened via stream_open_wrappers can use the zval ptr in
* php_stream->wrapperdata to hold metadata for php scripts to
* retrieve using file_get_wrapper_data(). */
typedef struct _php_stream php_stream;
typedef struct _php_stream_wrapper php_stream_wrapper;
typedef struct _php_stream_context php_stream_context;
typedef struct _php_stream_filter php_stream_filter;
#include "streams/php_stream_context.h"
#include "streams/php_stream_filter_api.h"
typedef struct _php_stream_statbuf {
zend_stat_t sb; /* regular info */
/* extended info to go here some day: content-type etc. etc. */
} php_stream_statbuf;
typedef struct _php_stream_dirent {
#ifdef NAME_MAX
char d_name[NAME_MAX + 1];
#else
char d_name[MAXPATHLEN];
#endif
unsigned char d_type;
} php_stream_dirent;
/* operations on streams that are file-handles */
typedef struct _php_stream_ops {
/* stdio like functions - these are mandatory! */
ssize_t (*write)(php_stream *stream, const char *buf, size_t count);
ssize_t (*read)(php_stream *stream, char *buf, size_t count);
int (*close)(php_stream *stream, int close_handle);
int (*flush)(php_stream *stream);
const char *label; /* label for this ops structure */
/* these are optional */
int (*seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset);
int (*cast)(php_stream *stream, int castas, void **ret);
int (*stat)(php_stream *stream, php_stream_statbuf *ssb);
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam);
} php_stream_ops;
typedef struct _php_stream_wrapper_ops {
/* open/create a wrapped stream */
php_stream *(*stream_opener)(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
/* close/destroy a wrapped stream */
int (*stream_closer)(php_stream_wrapper *wrapper, php_stream *stream);
/* stat a wrapped stream */
int (*stream_stat)(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb);
/* stat a URL */
int (*url_stat)(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context);
/* open a "directory" stream */
php_stream *(*dir_opener)(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
const char *label;
/* delete a file */
int (*unlink)(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context);
/* rename a file */
int (*rename)(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context);
/* Create/Remove directory */
int (*stream_mkdir)(php_stream_wrapper *wrapper, const char *url, int mode, int options, php_stream_context *context);
int (*stream_rmdir)(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context);
/* Metadata handling */
int (*stream_metadata)(php_stream_wrapper *wrapper, const char *url, int options, void *value, php_stream_context *context);
} php_stream_wrapper_ops;
struct _php_stream_wrapper {
const php_stream_wrapper_ops *wops; /* operations the wrapper can perform */
void *abstract; /* context for the wrapper */
int is_url; /* so that PG(allow_url_fopen) can be respected */
};
#define PHP_STREAM_FLAG_NO_SEEK 0x1
#define PHP_STREAM_FLAG_NO_BUFFER 0x2
#define PHP_STREAM_FLAG_EOL_UNIX 0x0 /* also includes DOS */
#define PHP_STREAM_FLAG_DETECT_EOL 0x4
#define PHP_STREAM_FLAG_EOL_MAC 0x8
/* set this when the stream might represent "interactive" data.
* When set, the read buffer will avoid certain operations that
* might otherwise cause the read to block for much longer than
* is strictly required. */
#define PHP_STREAM_FLAG_AVOID_BLOCKING 0x10
#define PHP_STREAM_FLAG_NO_CLOSE 0x20
#define PHP_STREAM_FLAG_IS_DIR 0x40
#define PHP_STREAM_FLAG_NO_FCLOSE 0x80
/* Suppress generation of PHP warnings on stream read/write errors.
* Currently, for internal use only. */
#define PHP_STREAM_FLAG_SUPPRESS_ERRORS 0x100
/* Do not close handle except it is explicitly closed by user (e.g. fclose) */
#define PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE 0x200
#define PHP_STREAM_FLAG_NO_IO 0x400
#define PHP_STREAM_FLAG_WAS_WRITTEN 0x80000000
struct _php_stream {
const php_stream_ops *ops;
void *abstract; /* convenience pointer for abstraction */
php_stream_filter_chain readfilters, writefilters;
php_stream_wrapper *wrapper; /* which wrapper was used to open the stream */
void *wrapperthis; /* convenience pointer for an instance of a wrapper */
zval wrapperdata; /* fgetwrapperdata retrieves this */
uint16_t is_persistent:1;
uint16_t in_free:2; /* to prevent recursion during free */
uint16_t eof:1;
uint16_t __exposed:1; /* non-zero if exposed as a zval somewhere */
/* so we know how to clean it up correctly. This should be set to
* PHP_STREAM_FCLOSE_XXX as appropriate */
uint16_t fclose_stdiocast:2;
/* flag to mark whether the stream has buffered data */
uint16_t has_buffered_data:1;
/* whether stdio cast flushing is in progress */
uint16_t fclose_stdiocast_flush_in_progress:1;
char mode[16]; /* "rwb" etc. ala stdio */
uint32_t flags; /* PHP_STREAM_FLAG_XXX */
zend_resource *res; /* used for auto-cleanup */
FILE *stdiocast; /* cache this, otherwise we might leak! */
char *orig_path;
zend_resource *ctx;
/* buffer */
zend_off_t position; /* of underlying stream */
unsigned char *readbuf;
size_t readbuflen;
zend_off_t readpos;
zend_off_t writepos;
/* how much data to read when filling buffer */
size_t chunk_size;
#if ZEND_DEBUG
const char *open_filename;
uint32_t open_lineno;
#endif
struct _php_stream *enclosing_stream; /* this is a private stream owned by enclosing_stream */
}; /* php_stream */
#define PHP_STREAM_CONTEXT(stream) \
((php_stream_context*) ((stream)->ctx ? ((stream)->ctx->ptr) : NULL))
/* state definitions when closing down; these are private to streams.c */
#define PHP_STREAM_FCLOSE_NONE 0
#define PHP_STREAM_FCLOSE_FDOPEN 1
#define PHP_STREAM_FCLOSE_FOPENCOOKIE 2
/* allocate a new stream for a particular ops */
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_alloc(const php_stream_ops *ops, void *abstract,
const char *persistent_id, const char *mode STREAMS_DC);
END_EXTERN_C()
#define php_stream_alloc(ops, thisptr, persistent_id, mode) _php_stream_alloc((ops), (thisptr), (persistent_id), (mode) STREAMS_CC)
#define php_stream_get_resource_id(stream) ((php_stream *)(stream))->res->handle
/* use this to tell the stream that it is OK if we don't explicitly close it */
#define php_stream_auto_cleanup(stream) { (stream)->__exposed = 1; }
/* use this to assign the stream to a zval and tell the stream that is
* has been exported to the engine; it will expect to be closed automatically
* when the resources are auto-destructed */
#define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); (stream)->__exposed = 1; }
#define php_stream_from_zval(xstr, pzval) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
return; \
} \
} while (0)
#define php_stream_from_res(xstr, res) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2((res), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
return; \
} \
} while (0)
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2((res), "stream", php_file_le_stream(), php_file_le_pstream())
#define php_stream_from_zval_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), "stream", php_file_le_stream(), php_file_le_pstream())
BEGIN_EXTERN_C()
PHPAPI php_stream *php_stream_encloses(php_stream *enclosing, php_stream *enclosed);
#define php_stream_free_enclosed(stream_enclosed, close_options) _php_stream_free_enclosed((stream_enclosed), (close_options))
PHPAPI int _php_stream_free_enclosed(php_stream *stream_enclosed, int close_options);
PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream **stream);
#define PHP_STREAM_PERSISTENT_SUCCESS 0 /* id exists */
#define PHP_STREAM_PERSISTENT_FAILURE 1 /* id exists but is not a stream! */
#define PHP_STREAM_PERSISTENT_NOT_EXIST 2 /* id does not exist */
#define PHP_STREAM_FREE_CALL_DTOR 1 /* call ops->close */
#define PHP_STREAM_FREE_RELEASE_STREAM 2 /* pefree(stream) */
#define PHP_STREAM_FREE_PRESERVE_HANDLE 4 /* tell ops->close to not close its underlying handle */
#define PHP_STREAM_FREE_RSRC_DTOR 8 /* called from the resource list dtor */
#define PHP_STREAM_FREE_PERSISTENT 16 /* manually freeing a persistent connection */
#define PHP_STREAM_FREE_IGNORE_ENCLOSING 32 /* don't close the enclosing stream instead */
#define PHP_STREAM_FREE_KEEP_RSRC 64 /* keep associated zend_resource */
#define PHP_STREAM_FREE_CLOSE (PHP_STREAM_FREE_CALL_DTOR | PHP_STREAM_FREE_RELEASE_STREAM)
#define PHP_STREAM_FREE_CLOSE_CASTED (PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_PRESERVE_HANDLE)
#define PHP_STREAM_FREE_CLOSE_PERSISTENT (PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_PERSISTENT)
PHPAPI int _php_stream_free(php_stream *stream, int close_options);
#define php_stream_free(stream, close_options) _php_stream_free((stream), (close_options))
#define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE)
#define php_stream_pclose(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE_PERSISTENT)
PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence);
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET)
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence))
PHPAPI zend_off_t _php_stream_tell(php_stream *stream);
#define php_stream_tell(stream) _php_stream_tell((stream))
PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t count);
#define php_stream_read(stream, buf, count) _php_stream_read((stream), (buf), (count))
PHPAPI zend_string *php_stream_read_to_str(php_stream *stream, size_t len);
PHPAPI ssize_t _php_stream_write(php_stream *stream, const char *buf, size_t count);
#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str))
#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count))
PHPAPI zend_result _php_stream_fill_read_buffer(php_stream *stream, size_t size);
#define php_stream_fill_read_buffer(stream, size) _php_stream_fill_read_buffer((stream), (size))
PHPAPI ssize_t _php_stream_printf(php_stream *stream, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
/* php_stream_printf macro & function require */
#define php_stream_printf _php_stream_printf
PHPAPI bool _php_stream_eof(php_stream *stream);
#define php_stream_eof(stream) _php_stream_eof((stream))
PHPAPI int _php_stream_getc(php_stream *stream);
#define php_stream_getc(stream) _php_stream_getc((stream))
PHPAPI int _php_stream_putc(php_stream *stream, int c);
#define php_stream_putc(stream, c) _php_stream_putc((stream), (c))
PHPAPI int _php_stream_flush(php_stream *stream, int closing);
#define php_stream_flush(stream) _php_stream_flush((stream), 0)
PHPAPI int _php_stream_sync(php_stream *stream, bool data_only);
#define php_stream_sync(stream, d) _php_stream_sync((stream), (d))
PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, size_t *returned_len);
#define php_stream_gets(stream, buf, maxlen) _php_stream_get_line((stream), (buf), (maxlen), NULL)
#define php_stream_get_line(stream, buf, maxlen, retlen) _php_stream_get_line((stream), (buf), (maxlen), (retlen))
PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, const char *delim, size_t delim_len);
/* Returns true if buffer has been appended, false on error */
PHPAPI bool _php_stream_puts(php_stream *stream, const char *buf);
#define php_stream_puts(stream, buf) _php_stream_puts((stream), (buf))
PHPAPI int _php_stream_stat(php_stream *stream, php_stream_statbuf *ssb);
#define php_stream_stat(stream, ssb) _php_stream_stat((stream), (ssb))
PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf *ssb, php_stream_context *context);
#define php_stream_stat_path(path, ssb) _php_stream_stat_path((path), 0, (ssb), NULL)
#define php_stream_stat_path_ex(path, flags, ssb, context) _php_stream_stat_path((path), (flags), (ssb), (context))
PHPAPI int _php_stream_mkdir(const char *path, int mode, int options, php_stream_context *context);
#define php_stream_mkdir(path, mode, options, context) _php_stream_mkdir(path, mode, options, context)
PHPAPI int _php_stream_rmdir(const char *path, int options, php_stream_context *context);
#define php_stream_rmdir(path, options, context) _php_stream_rmdir(path, options, context)
PHPAPI php_stream *_php_stream_opendir(const char *path, int options, php_stream_context *context STREAMS_DC);
#define php_stream_opendir(path, options, context) _php_stream_opendir((path), (options), (context) STREAMS_CC)
PHPAPI php_stream_dirent *_php_stream_readdir(php_stream *dirstream, php_stream_dirent *ent);
#define php_stream_readdir(dirstream, dirent) _php_stream_readdir((dirstream), (dirent))
#define php_stream_closedir(dirstream) php_stream_close((dirstream))
#define php_stream_rewinddir(dirstream) php_stream_rewind((dirstream))
PHPAPI int php_stream_dirent_alphasort(const zend_string **a, const zend_string **b);
PHPAPI int php_stream_dirent_alphasortr(const zend_string **a, const zend_string **b);
PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], int flags, php_stream_context *context,
int (*compare) (const zend_string **a, const zend_string **b));
#define php_stream_scandir(dirname, namelist, context, compare) _php_stream_scandir((dirname), (namelist), 0, (context), (compare))
PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam);
#define php_stream_set_option(stream, option, value, ptrvalue) _php_stream_set_option((stream), (option), (value), (ptrvalue))
#define php_stream_set_chunk_size(stream, size) _php_stream_set_option((stream), PHP_STREAM_OPTION_SET_CHUNK_SIZE, (size), NULL)
END_EXTERN_C()
/* Flags for mkdir method in wrapper ops */
#define PHP_STREAM_MKDIR_RECURSIVE 1
/* define REPORT ERRORS 8 (below) */
/* Flags for rmdir method in wrapper ops */
/* define REPORT_ERRORS 8 (below) */
/* Flags for url_stat method in wrapper ops */
#define PHP_STREAM_URL_STAT_LINK 1
#define PHP_STREAM_URL_STAT_QUIET 2
#define PHP_STREAM_URL_STAT_IGNORE_OPEN_BASEDIR 4
/* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */
#define PHP_STREAM_OPTION_BLOCKING 1
/* change the buffering mode of stream. value is a PHP_STREAM_BUFFER_XXXX value, ptrparam is a ptr to a size_t holding
* the required buffer size */
#define PHP_STREAM_OPTION_READ_BUFFER 2
#define PHP_STREAM_OPTION_WRITE_BUFFER 3
#define PHP_STREAM_BUFFER_NONE 0 /* unbuffered */
#define PHP_STREAM_BUFFER_LINE 1 /* line buffered */
#define PHP_STREAM_BUFFER_FULL 2 /* fully buffered */
/* set the timeout duration for reads on the stream. ptrparam is a pointer to a struct timeval * */
#define PHP_STREAM_OPTION_READ_TIMEOUT 4
#define PHP_STREAM_OPTION_SET_CHUNK_SIZE 5
/* set or release lock on a stream */
#define PHP_STREAM_OPTION_LOCKING 6
/* whether or not locking is supported */
#define PHP_STREAM_LOCK_SUPPORTED 1
#define php_stream_supports_lock(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_LOCKING, 0, (void *) PHP_STREAM_LOCK_SUPPORTED) == 0 ? 1 : 0)
#define php_stream_lock(stream, mode) _php_stream_set_option((stream), PHP_STREAM_OPTION_LOCKING, (mode), (void *) NULL)
/* option code used by the php_stream_xport_XXX api */
#define PHP_STREAM_OPTION_XPORT_API 7 /* see php_stream_transport.h */
#define PHP_STREAM_OPTION_CRYPTO_API 8 /* see php_stream_transport.h */
#define PHP_STREAM_OPTION_MMAP_API 9 /* see php_stream_mmap.h */
#define PHP_STREAM_OPTION_TRUNCATE_API 10
#define PHP_STREAM_TRUNCATE_SUPPORTED 0
#define PHP_STREAM_TRUNCATE_SET_SIZE 1 /* ptrparam is a pointer to a size_t */
#define php_stream_truncate_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_TRUNCATE_API, PHP_STREAM_TRUNCATE_SUPPORTED, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
BEGIN_EXTERN_C()
PHPAPI int _php_stream_truncate_set_size(php_stream *stream, size_t newsize);
#define php_stream_truncate_set_size(stream, size) _php_stream_truncate_set_size((stream), (size))
END_EXTERN_C()
#define PHP_STREAM_OPTION_META_DATA_API 11 /* ptrparam is a zval* to which to add metadata information */
#define php_stream_populate_meta_data(stream, zv) (_php_stream_set_option((stream), PHP_STREAM_OPTION_META_DATA_API, 0, zv) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
/* Check if the stream is still "live"; for sockets/pipes this means the socket
* is still connected; for files, this does not really have meaning */
#define PHP_STREAM_OPTION_CHECK_LIVENESS 12 /* no parameters */
/* Enable/disable blocking reads on anonymous pipes on Windows. */
#define PHP_STREAM_OPTION_PIPE_BLOCKING 13
/* Stream can support fsync operation */
#define PHP_STREAM_OPTION_SYNC_API 14
#define PHP_STREAM_SYNC_SUPPORTED 0
#define PHP_STREAM_SYNC_FSYNC 1
#define PHP_STREAM_SYNC_FDSYNC 2
#define php_stream_sync_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_SYNC_API, PHP_STREAM_SYNC_SUPPORTED, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
#define PHP_STREAM_OPTION_RETURN_OK 0 /* option set OK */
#define PHP_STREAM_OPTION_RETURN_ERR -1 /* problem setting option */
#define PHP_STREAM_OPTION_RETURN_NOTIMPL -2 /* underlying stream does not implement; streams can handle it instead */
/* copy up to maxlen bytes from src to dest. If maxlen is PHP_STREAM_COPY_ALL,
* copy until eof(src). */
#define PHP_STREAM_COPY_ALL ((size_t)-1)
BEGIN_EXTERN_C()
ZEND_ATTRIBUTE_DEPRECATED
PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC);
#define php_stream_copy_to_stream(src, dest, maxlen) _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC)
PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC);
#define php_stream_copy_to_stream_ex(src, dest, maxlen, len) _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC)
/* read all data from stream and put into a buffer. Caller must free buffer
* when done. */
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int persistent STREAMS_DC);
#define php_stream_copy_to_mem(src, maxlen, persistent) _php_stream_copy_to_mem((src), (maxlen), (persistent) STREAMS_CC)
/* output all data from a stream */
PHPAPI ssize_t _php_stream_passthru(php_stream * src STREAMS_DC);
#define php_stream_passthru(stream) _php_stream_passthru((stream) STREAMS_CC)
END_EXTERN_C()
#include "streams/php_stream_transport.h"
#include "streams/php_stream_plain_wrapper.h"
#include "streams/php_stream_glob_wrapper.h"
#include "streams/php_stream_userspace.h"
#include "streams/php_stream_mmap.h"
/* coerce the stream into some other form */
/* cast as a stdio FILE * */
#define PHP_STREAM_AS_STDIO 0
/* cast as a POSIX fd or socketd */
#define PHP_STREAM_AS_FD 1
/* cast as a socketd */
#define PHP_STREAM_AS_SOCKETD 2
/* cast as fd/socket for select purposes */
#define PHP_STREAM_AS_FD_FOR_SELECT 3
/* try really, really hard to make sure the cast happens (avoid using this flag if possible) */
#define PHP_STREAM_CAST_TRY_HARD 0x80000000
#define PHP_STREAM_CAST_RELEASE 0x40000000 /* stream becomes invalid on success */
#define PHP_STREAM_CAST_INTERNAL 0x20000000 /* stream cast for internal use */
#define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL)
BEGIN_EXTERN_C()
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err);
END_EXTERN_C()
/* use this to check if a stream can be cast into another form */
#define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0)
#define php_stream_cast(stream, as, ret, show_err) _php_stream_cast((stream), (as), (ret), (show_err))
/* use this to check if a stream is of a particular type:
* PHPAPI int php_stream_is(php_stream *stream, php_stream_ops *ops); */
#define php_stream_is(stream, anops) ((stream)->ops == anops)
#define PHP_STREAM_IS_STDIO &php_stream_stdio_ops
#define php_stream_is_persistent(stream) (stream)->is_persistent
/* Wrappers support */
#define IGNORE_PATH 0x00000000
#define USE_PATH 0x00000001
#define IGNORE_URL 0x00000002
#define REPORT_ERRORS 0x00000008
/* If you don't need to write to the stream, but really need to
* be able to seek, use this flag in your options. */
#define STREAM_MUST_SEEK 0x00000010
/* If you are going to end up casting the stream into a FILE* or
* a socket, pass this flag and the streams/wrappers will not use
* buffering mechanisms while reading the headers, so that HTTP
* wrapped streams will work consistently.
* If you omit this flag, streams will use buffering and should end
* up working more optimally.
* */
#define STREAM_WILL_CAST 0x00000020
/* this flag applies to php_stream_locate_url_wrapper */
#define STREAM_LOCATE_WRAPPERS_ONLY 0x00000040
/* this flag is only used by include/require functions */
#define STREAM_OPEN_FOR_INCLUDE 0x00000080
/* this flag tells streams to ONLY open urls */
#define STREAM_USE_URL 0x00000100
/* this flag is used when only the headers from HTTP request are to be fetched */
#define STREAM_ONLY_GET_HEADERS 0x00000200
/* don't apply open_basedir checks */
#define STREAM_DISABLE_OPEN_BASEDIR 0x00000400
/* get (or create) a persistent version of the stream */
#define STREAM_OPEN_PERSISTENT 0x00000800
/* use glob stream for directory open in plain files stream */
#define STREAM_USE_GLOB_DIR_OPEN 0x00001000
/* don't check allow_url_fopen and allow_url_include */
#define STREAM_DISABLE_URL_PROTECTION 0x00002000
/* assume the path passed in exists and is fully expanded, avoiding syscalls */
#define STREAM_ASSUME_REALPATH 0x00004000
/* Allow blocking reads on anonymous pipes on Windows. */
#define STREAM_USE_BLOCKING_PIPE 0x00008000
/* this flag is only used by include/require functions */
#define STREAM_OPEN_FOR_ZEND_STREAM 0x00010000
int php_init_stream_wrappers(int module_number);
void php_shutdown_stream_wrappers(int module_number);
void php_shutdown_stream_hashes(void);
PHP_RSHUTDOWN_FUNCTION(streams);
BEGIN_EXTERN_C()
PHPAPI zend_result php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper);
PHPAPI zend_result php_unregister_url_stream_wrapper(const char *protocol);
PHPAPI zend_result php_register_url_stream_wrapper_volatile(zend_string *protocol, php_stream_wrapper *wrapper);
PHPAPI zend_result php_unregister_url_stream_wrapper_volatile(zend_string *protocol);
PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const char **path_for_open, int options);
PHPAPI const char *php_stream_locate_eol(php_stream *stream, zend_string *buf);
#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC)
#define php_stream_open_wrapper_ex(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_CC)
/* pushes an error message onto the stack for a wrapper instance */
PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int options, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
#define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */
#define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */
#define PHP_STREAM_FAILED 2 /* an error occurred while attempting conversion */
#define PHP_STREAM_CRITICAL 3 /* an error occurred; origstream is in an unknown state; you should close origstream */
#define PHP_STREAM_NO_PREFERENCE 0
#define PHP_STREAM_PREFER_STDIO 1
#define PHP_STREAM_FORCE_CONVERSION 2
/* DO NOT call this on streams that are referenced by resources! */
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC);
#define php_stream_make_seekable(origstream, newstream, flags) _php_stream_make_seekable((origstream), (newstream), (flags) STREAMS_CC)
/* Give other modules access to the url_stream_wrappers_hash and stream_filters_hash */
PHPAPI HashTable *_php_stream_get_url_stream_wrappers_hash(void);
#define php_stream_get_url_stream_wrappers_hash() _php_stream_get_url_stream_wrappers_hash()
PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash_global(void);
PHPAPI HashTable *_php_get_stream_filters_hash(void);
#define php_get_stream_filters_hash() _php_get_stream_filters_hash()
PHPAPI HashTable *php_get_stream_filters_hash_global(void);
extern const php_stream_wrapper_ops *php_stream_user_wrapper_ops;
static inline bool php_is_stream_path(const char *filename)
{
const char *p;
for (p = filename;
(*p >= 'a' && *p <= 'z') ||
(*p >= 'A' && *p <= 'Z') ||
(*p >= '0' && *p <= '9') ||
*p == '+' || *p == '-' || *p == '.';
p++);
return ((p != filename) && (p[0] == ':') && (p[1] == '/') && (p[2] == '/'));
}
END_EXTERN_C()
#endif
/* Definitions for user streams */
#define PHP_STREAM_IS_URL 1
/* Stream metadata definitions */
/* Create if referred resource does not exist */
#define PHP_STREAM_META_TOUCH 1
#define PHP_STREAM_META_OWNER_NAME 2
#define PHP_STREAM_META_OWNER 3
#define PHP_STREAM_META_GROUP_NAME 4
#define PHP_STREAM_META_GROUP 5
#define PHP_STREAM_META_ACCESS 6

View File

@ -0,0 +1,44 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SYSLOG_H
#define PHP_SYSLOG_H
#include "php.h"
#ifdef PHP_WIN32
#include "win32/syslog.h"
#else
#include <php_config.h>
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#endif
/* Syslog filters */
#define PHP_SYSLOG_FILTER_ALL 0
#define PHP_SYSLOG_FILTER_NO_CTRL 1
#define PHP_SYSLOG_FILTER_ASCII 2
#define PHP_SYSLOG_FILTER_RAW 3
BEGIN_EXTERN_C()
PHPAPI void php_syslog_str(int priority, const zend_string* message);
PHPAPI void php_syslog(int, const char *format, ...);
PHPAPI void php_openlog(const char *, int, int);
PHPAPI void php_closelog(void);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,30 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_TICKS_H
#define PHP_TICKS_H
int php_startup_ticks(void);
void php_deactivate_ticks(void);
void php_shutdown_ticks(php_core_globals *core_globals);
void php_run_ticks(int count);
BEGIN_EXTERN_C()
PHPAPI void php_add_tick_function(void (*func)(int, void *), void *arg);
PHPAPI void php_remove_tick_function(void (*func)(int, void *), void * arg);
END_EXTERN_C()
#endif

View File

@ -0,0 +1,47 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_VARIABLES_H
#define PHP_VARIABLES_H
#include "php.h"
#include "SAPI.h"
#define PARSE_POST 0
#define PARSE_GET 1
#define PARSE_COOKIE 2
#define PARSE_STRING 3
#define PARSE_ENV 4
#define PARSE_SERVER 5
#define PARSE_SESSION 6
BEGIN_EXTERN_C()
void php_startup_auto_globals(void);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr);
PHPAPI void php_register_variable(const char *var, const char *val, zval *track_vars_array);
/* binary-safe version */
PHPAPI void php_register_variable_safe(const char *var, const char *val, size_t val_len, zval *track_vars_array);
PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_vars_array);
PHPAPI void php_register_known_variable(const char *var, size_t var_len, zval *value, zval *track_vars_array);
PHPAPI void php_build_argv(const char *s, zval *track_vars_array);
PHPAPI int php_hash_environment(void);
END_EXTERN_C()
#define NUM_TRACK_VARS 6
#endif /* PHP_VARIABLES_H */

View File

@ -0,0 +1,8 @@
/* automatically generated by configure */
/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION 8
#define PHP_MINOR_VERSION 3
#define PHP_RELEASE_VERSION 3
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "8.3.3-dev"
#define PHP_VERSION_ID 80303

View File

@ -0,0 +1,96 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
#ifndef RFC1867_H
#define RFC1867_H
#include "SAPI.h"
#define MULTIPART_CONTENT_TYPE "multipart/form-data"
#define MULTIPART_EVENT_START 0
#define MULTIPART_EVENT_FORMDATA 1
#define MULTIPART_EVENT_FILE_START 2
#define MULTIPART_EVENT_FILE_DATA 3
#define MULTIPART_EVENT_FILE_END 4
#define MULTIPART_EVENT_END 5
/* Errors */
#define PHP_UPLOAD_ERROR_OK 0 /* File upload successful */
#define PHP_UPLOAD_ERROR_A 1 /* Uploaded file exceeded upload_max_filesize */
#define PHP_UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
#define PHP_UPLOAD_ERROR_C 3 /* Partially uploaded */
#define PHP_UPLOAD_ERROR_D 4 /* No file uploaded */
#define PHP_UPLOAD_ERROR_E 6 /* Missing /tmp or similar directory */
#define PHP_UPLOAD_ERROR_F 7 /* Failed to write file to disk */
#define PHP_UPLOAD_ERROR_X 8 /* File upload stopped by extension */
typedef struct _multipart_event_start {
size_t content_length;
} multipart_event_start;
typedef struct _multipart_event_formdata {
size_t post_bytes_processed;
char *name;
char **value;
size_t length;
size_t *newlength;
} multipart_event_formdata;
typedef struct _multipart_event_file_start {
size_t post_bytes_processed;
char *name;
char **filename;
} multipart_event_file_start;
typedef struct _multipart_event_file_data {
size_t post_bytes_processed;
zend_off_t offset;
char *data;
size_t length;
size_t *newlength;
} multipart_event_file_data;
typedef struct _multipart_event_file_end {
size_t post_bytes_processed;
char *temp_filename;
int cancel_upload;
} multipart_event_file_end;
typedef struct _multipart_event_end {
size_t post_bytes_processed;
} multipart_event_end;
typedef int (*php_rfc1867_encoding_translation_t)(void);
typedef void (*php_rfc1867_get_detect_order_t)(const zend_encoding ***list, size_t *list_size);
typedef void (*php_rfc1867_set_input_encoding_t)(const zend_encoding *encoding);
typedef char* (*php_rfc1867_getword_t)(const zend_encoding *encoding, char **line, char stop);
typedef char* (*php_rfc1867_getword_conf_t)(const zend_encoding *encoding, char *str);
typedef char* (*php_rfc1867_basename_t)(const zend_encoding *encoding, char *str);
SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
PHPAPI void destroy_uploaded_files_hash(void);
extern PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra);
SAPI_API void php_rfc1867_set_multibyte_callbacks(
php_rfc1867_encoding_translation_t encoding_translation,
php_rfc1867_get_detect_order_t get_detect_order,
php_rfc1867_set_input_encoding_t set_input_encoding,
php_rfc1867_getword_t getword,
php_rfc1867_getword_conf_t getword_conf,
php_rfc1867_basename_t basename);
#endif /* RFC1867_H */

136
include/php/main/snprintf.h Normal file
View File

@ -0,0 +1,136 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Stig Sæther Bakken <ssb@php.net> |
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
/*
Comparing: sprintf, snprintf, slprintf, spprintf
sprintf offers the ability to make a lot of failures since it does not know
the size of the buffer it uses. Therefore usage of sprintf often
results in possible entries for buffer overrun attacks. So please
use this version only if you are sure the call is safe. sprintf
always terminates the buffer it writes to.
snprintf knows the buffers size and will not write behind it. But you will
have to use either a static buffer or allocate a dynamic buffer
before being able to call the function. In other words you must
be sure that you really know the maximum size of the buffer required.
A bad thing is having a big maximum while in most cases you would
only need a small buffer. If the size of the resulting string is
longer or equal to the buffer size than the buffer is not terminated.
The function also returns the number of chars not including the
terminating \0 that were needed to fully comply to the print request.
slprintf same as snprintf with the difference that it actually returns the
length printed not including the terminating \0.
spprintf is the dynamical version of snprintf. It allocates the buffer in size
as needed and allows a maximum setting as snprintf (turn this feature
off by setting max_len to 0). spprintf is a little bit slower than
snprintf and offers possible memory leaks if you miss freeing the
buffer allocated by the function. Therefore this function should be
used where either no maximum is known or the maximum is much bigger
than normal size required. spprintf always terminates the buffer.
Example:
#define MAX 1024 | #define MAX 1024 | #define MAX 1024
char buffer[MAX] | char buffer[MAX] | char *buffer;
| |
| | // No need to initialize buffer:
| | // spprintf ignores value of buffer
sprintf(buffer, "test"); | snprintf(buffer, MAX, "test"); | spprintf(&buffer, MAX, "text");
| | if (!buffer)
| | return OUT_OF_MEMORY
// sprintf always terminates | // manual termination of | // spprintf allays terminates buffer
// buffer | // buffer *IS* required |
| buffer[MAX-1] = 0; |
action_with_buffer(buffer); | action_with_buffer(buffer); | action_with_buffer(buffer);
| | efree(buffer);
*/
#ifndef SNPRINTF_H
#define SNPRINTF_H
#include <stdbool.h>
BEGIN_EXTERN_C()
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list ap);
PHPAPI int ap_php_snprintf(char *, size_t, const char *, ...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap);
PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_conv_fp(char format, double num,
bool add_dp, int precision, char dec_point, bool * is_negative, char *buf, size_t *len);
END_EXTERN_C()
#define php_gcvt zend_gcvt
#ifdef slprintf
#undef slprintf
#endif
#define slprintf ap_php_slprintf
#ifdef vslprintf
#undef vslprintf
#endif
#define vslprintf ap_php_vslprintf
#ifdef snprintf
#undef snprintf
#endif
#define snprintf ap_php_snprintf
#ifdef vsnprintf
#undef vsnprintf
#endif
#define vsnprintf ap_php_vsnprintf
#ifndef HAVE_VASPRINTF
#define vasprintf ap_php_vasprintf
#endif
#ifndef HAVE_ASPRINTF
#define asprintf ap_php_asprintf
#endif
typedef enum {
LM_STD = 0,
#if SIZEOF_INTMAX_T
LM_INTMAX_T,
#endif
#if SIZEOF_PTRDIFF_T
LM_PTRDIFF_T,
#endif
#if SIZEOF_LONG_LONG
LM_LONG_LONG,
#endif
LM_SIZE_T,
LM_LONG,
LM_LONG_DOUBLE,
} length_modifier_e;
PHPAPI char * ap_php_conv_10(int64_t num, bool is_unsigned,
bool * is_negative, char *buf_end, size_t *len);
PHPAPI char * ap_php_conv_p2(uint64_t num, int nbits,
char format, char *buf_end, size_t *len);
#endif /* SNPRINTF_H */

View File

@ -0,0 +1,34 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef SPPRINTF_H
#define SPPRINTF_H
#include "snprintf.h"
#include "zend_smart_str_public.h"
#include "zend_smart_string_public.h"
BEGIN_EXTERN_C()
PHPAPI void php_printf_to_smart_string(smart_string *buf, const char *format, va_list ap);
PHPAPI void php_printf_to_smart_str(smart_str *buf, const char *format, va_list ap);
END_EXTERN_C()
#define spprintf zend_spprintf
#define strpprintf zend_strpprintf
#define vspprintf zend_vspprintf
#define vstrpprintf zend_vstrpprintf
#endif /* SPPRINTF_H */

View File

@ -0,0 +1,118 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* Stream context and status notification related definitions */
/* callback for status notifications */
typedef void (*php_stream_notification_func)(php_stream_context *context,
int notifycode, int severity,
char *xmsg, int xcode,
size_t bytes_sofar, size_t bytes_max,
void * ptr);
#define PHP_STREAM_NOTIFIER_PROGRESS 1
/* Attempt to fetch context from the zval passed,
If no context was passed, use the default context
The default context has not yet been created, do it now. */
#define php_stream_context_from_zval(zcontext, nocontext) ( \
(zcontext) ? zend_fetch_resource_ex(zcontext, "Stream-Context", php_le_stream_context()) : \
(nocontext) ? NULL : \
FG(default_context) ? FG(default_context) : \
(FG(default_context) = php_stream_context_alloc()) )
#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); GC_ADDREF((context)->res); }
typedef struct _php_stream_notifier php_stream_notifier;
struct _php_stream_notifier {
php_stream_notification_func func;
void (*dtor)(php_stream_notifier *notifier);
zval ptr;
int mask;
size_t progress, progress_max; /* position for progress notification */
};
struct _php_stream_context {
php_stream_notifier *notifier;
zval options; /* hash keyed by wrapper family or specific wrapper */
zend_resource *res; /* used for auto-cleanup */
};
BEGIN_EXTERN_C()
PHPAPI void php_stream_context_free(php_stream_context *context);
PHPAPI php_stream_context *php_stream_context_alloc(void);
PHPAPI zval *php_stream_context_get_option(php_stream_context *context,
const char *wrappername, const char *optionname);
PHPAPI void php_stream_context_set_option(php_stream_context *context,
const char *wrappername, const char *optionname, zval *optionvalue);
PHPAPI php_stream_notifier *php_stream_notification_alloc(void);
PHPAPI void php_stream_notification_free(php_stream_notifier *notifier);
END_EXTERN_C()
/* not all notification codes are implemented */
#define PHP_STREAM_NOTIFY_RESOLVE 1
#define PHP_STREAM_NOTIFY_CONNECT 2
#define PHP_STREAM_NOTIFY_AUTH_REQUIRED 3
#define PHP_STREAM_NOTIFY_MIME_TYPE_IS 4
#define PHP_STREAM_NOTIFY_FILE_SIZE_IS 5
#define PHP_STREAM_NOTIFY_REDIRECTED 6
#define PHP_STREAM_NOTIFY_PROGRESS 7
#define PHP_STREAM_NOTIFY_COMPLETED 8
#define PHP_STREAM_NOTIFY_FAILURE 9
#define PHP_STREAM_NOTIFY_AUTH_RESULT 10
#define PHP_STREAM_NOTIFY_SEVERITY_INFO 0
#define PHP_STREAM_NOTIFY_SEVERITY_WARN 1
#define PHP_STREAM_NOTIFY_SEVERITY_ERR 2
BEGIN_EXTERN_C()
PHPAPI void php_stream_notification_notify(php_stream_context *context, int notifycode, int severity,
char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr);
PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context);
END_EXTERN_C()
#define php_stream_notify_info(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) { \
php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_INFO, \
(xmsg), (xcode), 0, 0, NULL); } } while (0)
#define php_stream_notify_progress(context, bsofar, bmax) do { if ((context) && (context)->notifier) { \
php_stream_notification_notify((context), PHP_STREAM_NOTIFY_PROGRESS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
NULL, 0, (bsofar), (bmax), NULL); } } while(0)
#define php_stream_notify_completed(context) do { if ((context) && (context)->notifier) { \
php_stream_notification_notify((context), PHP_STREAM_NOTIFY_COMPLETED, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
NULL, 0, (context)->notifier->progress, (context)->notifier->progress_max, NULL); } } while(0)
#define php_stream_notify_progress_init(context, sofar, bmax) do { if ((context) && (context)->notifier) { \
(context)->notifier->progress = (sofar); \
(context)->notifier->progress_max = (bmax); \
(context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && ((context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS)) { \
(context)->notifier->progress += (dsofar); \
(context)->notifier->progress_max += (dmax); \
php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
#define php_stream_notify_file_size(context, file_size, xmsg, xcode) do { if ((context) && (context)->notifier) { \
php_stream_notification_notify((context), PHP_STREAM_NOTIFY_FILE_SIZE_IS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
(xmsg), (xcode), 0, (file_size), NULL); } } while(0)
#define php_stream_notify_error(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) {\
php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
(xmsg), (xcode), 0, 0, NULL); } } while(0)

View File

@ -0,0 +1,149 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
| With suggestions from: |
| Moriyoshi Koizumi <moriyoshi@at.wakwak.com> |
| Sara Golemon <pollita@php.net> |
+----------------------------------------------------------------------+
*/
/* The filter API works on the principle of "Bucket-Brigades". This is
* partially inspired by the Apache 2 method of doing things, although
* it is intentionally a light-weight implementation.
*
* Each stream can have a chain of filters for reading and another for writing.
*
* When data is written to the stream, it is placed into a bucket and placed at
* the start of the input brigade.
*
* The first filter in the chain is invoked on the brigade and (depending on
* it's return value), the next filter is invoked and so on.
* */
#define PHP_STREAM_FILTER_READ 0x0001
#define PHP_STREAM_FILTER_WRITE 0x0002
#define PHP_STREAM_FILTER_ALL (PHP_STREAM_FILTER_READ | PHP_STREAM_FILTER_WRITE)
typedef struct _php_stream_bucket php_stream_bucket;
typedef struct _php_stream_bucket_brigade php_stream_bucket_brigade;
struct _php_stream_bucket {
php_stream_bucket *next, *prev;
php_stream_bucket_brigade *brigade;
char *buf;
size_t buflen;
/* if non-zero, buf should be pefreed when the bucket is destroyed */
uint8_t own_buf;
uint8_t is_persistent;
/* destroy this struct when refcount falls to zero */
int refcount;
};
struct _php_stream_bucket_brigade {
php_stream_bucket *head, *tail;
};
typedef enum {
PSFS_ERR_FATAL, /* error in data stream */
PSFS_FEED_ME, /* filter needs more data; stop processing chain until more is available */
PSFS_PASS_ON /* filter generated output buckets; pass them on to next in chain */
} php_stream_filter_status_t;
/* Buckets API. */
BEGIN_EXTERN_C()
PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent);
PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length);
PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket);
#define php_stream_bucket_addref(bucket) (bucket)->refcount++
PHPAPI void php_stream_bucket_prepend(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket);
PHPAPI void php_stream_bucket_append(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket);
PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket);
PHPAPI php_stream_bucket *php_stream_bucket_make_writeable(php_stream_bucket *bucket);
END_EXTERN_C()
#define PSFS_FLAG_NORMAL 0 /* regular read/write */
#define PSFS_FLAG_FLUSH_INC 1 /* an incremental flush */
#define PSFS_FLAG_FLUSH_CLOSE 2 /* final flush prior to closing */
typedef struct _php_stream_filter_ops {
php_stream_filter_status_t (*filter)(
php_stream *stream,
php_stream_filter *thisfilter,
php_stream_bucket_brigade *buckets_in,
php_stream_bucket_brigade *buckets_out,
size_t *bytes_consumed,
int flags
);
void (*dtor)(php_stream_filter *thisfilter);
const char *label;
} php_stream_filter_ops;
typedef struct _php_stream_filter_chain {
php_stream_filter *head, *tail;
/* Owning stream */
php_stream *stream;
} php_stream_filter_chain;
struct _php_stream_filter {
const php_stream_filter_ops *fops;
zval abstract; /* for use by filter implementation */
php_stream_filter *next;
php_stream_filter *prev;
int is_persistent;
/* link into stream and chain */
php_stream_filter_chain *chain;
/* buffered buckets */
php_stream_bucket_brigade buffer;
/* filters are auto_registered when they're applied */
zend_resource *res;
};
/* stack filter onto a stream */
BEGIN_EXTERN_C()
PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter);
PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter);
PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish);
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor);
PHPAPI void php_stream_filter_free(php_stream_filter *filter);
PHPAPI php_stream_filter *_php_stream_filter_alloc(const php_stream_filter_ops *fops, void *abstract, uint8_t persistent STREAMS_DC);
END_EXTERN_C()
#define php_stream_filter_alloc(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_CC)
#define php_stream_filter_alloc_rel(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_REL_CC)
#define php_stream_filter_prepend(chain, filter) _php_stream_filter_prepend((chain), (filter))
#define php_stream_filter_append(chain, filter) _php_stream_filter_append((chain), (filter))
#define php_stream_filter_flush(filter, finish) _php_stream_filter_flush((filter), (finish))
#define php_stream_is_filtered(stream) ((stream)->readfilters.head || (stream)->writefilters.head)
typedef struct _php_stream_filter_factory {
php_stream_filter *(*create_filter)(const char *filtername, zval *filterparams, uint8_t persistent);
} php_stream_filter_factory;
BEGIN_EXTERN_C()
PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory);
PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern);
PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory);
PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent);
END_EXTERN_C()

View File

@ -0,0 +1,31 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
PHPAPI extern const php_stream_wrapper php_glob_stream_wrapper;
PHPAPI extern const php_stream_ops php_glob_stream_ops;
BEGIN_EXTERN_C()
PHPAPI char* _php_glob_stream_get_path(php_stream *stream, size_t *plen STREAMS_DC);
#define php_glob_stream_get_path(stream, plen) _php_glob_stream_get_path((stream), (plen) STREAMS_CC)
PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, size_t *plen STREAMS_DC);
#define php_glob_stream_get_pattern(stream, plen) _php_glob_stream_get_pattern((stream), (plen) STREAMS_CC)
PHPAPI int _php_glob_stream_get_count(php_stream *stream, int *pflags STREAMS_DC);
#define php_glob_stream_get_count(stream, pflags) _php_glob_stream_get_count((stream), (pflags) STREAMS_CC)
END_EXTERN_C()

View File

@ -0,0 +1,77 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* Memory Mapping interface for streams.
* The intention is to provide a uniform interface over the most common
* operations that are used within PHP itself, rather than a complete
* API for all memory mapping needs.
*
* ATM, we support only mmap(), but win32 memory mapping support will
* follow soon.
* */
typedef enum {
/* Does the stream support mmap ? */
PHP_STREAM_MMAP_SUPPORTED,
/* Request a range and offset to be mapped;
* while mapped, you MUST NOT use any read/write functions
* on the stream (win9x compatibility) */
PHP_STREAM_MMAP_MAP_RANGE,
/* Unmap the last range that was mapped for the stream */
PHP_STREAM_MMAP_UNMAP
} php_stream_mmap_operation_t;
typedef enum {
PHP_STREAM_MAP_MODE_READONLY,
PHP_STREAM_MAP_MODE_READWRITE,
PHP_STREAM_MAP_MODE_SHARED_READONLY,
PHP_STREAM_MAP_MODE_SHARED_READWRITE
} php_stream_mmap_access_t;
typedef struct {
/* requested offset and length.
* If length is 0, the whole file is mapped */
size_t offset;
size_t length;
php_stream_mmap_access_t mode;
/* returned mapped address */
char *mapped;
} php_stream_mmap_range;
#define PHP_STREAM_MMAP_ALL 0
#define PHP_STREAM_MMAP_MAX (512 * 1024 * 1024)
#define php_stream_mmap_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_SUPPORTED, NULL) == 0 ? 1 : 0)
/* Returns 1 if the stream in its current state can be memory mapped,
* 0 otherwise */
#define php_stream_mmap_possible(stream) (!php_stream_is_filtered((stream)) && php_stream_mmap_supported((stream)))
BEGIN_EXTERN_C()
PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_access_t mode, size_t *mapped_len);
#define php_stream_mmap_range(stream, offset, length, mode, mapped_len) _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len))
/* un-maps the last mapped range */
PHPAPI int _php_stream_mmap_unmap(php_stream *stream);
#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream))
PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden);
#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden))
END_EXTERN_C()

View File

@ -0,0 +1,56 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* definitions for the plain files wrapper */
/* operations for a plain file; use the php_stream_fopen_XXX funcs below */
PHPAPI extern php_stream_ops php_stream_stdio_ops;
PHPAPI extern /*const*/ php_stream_wrapper php_plain_files_wrapper;
BEGIN_EXTERN_C()
/* like fopen, but returns a stream */
PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zend_string **opened_path, int options STREAMS_DC);
#define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened), 0 STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const char *mode, const char *path, zend_string **opened_path, int options STREAMS_DC);
#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened), 0 STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC);
#define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const char *persistent_id, bool zero_position STREAMS_DC);
#define php_stream_fopen_from_fd(fd, mode, persistent_id) _php_stream_fopen_from_fd((fd), (mode), (persistent_id), false STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC);
#define php_stream_fopen_from_pipe(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC);
#define php_stream_fopen_tmpfile() _php_stream_fopen_tmpfile(0 STREAMS_CC)
PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, zend_string **opened_path STREAMS_DC);
#define php_stream_fopen_temporary_file(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_CC)
/* This is a utility API for extensions that are opening a stream, converting it
* to a FILE* and then closing it again. Be warned that fileno() on the result
* will most likely fail on systems with fopencookie. */
PHPAPI FILE * _php_stream_open_wrapper_as_file(char * path, char * mode, int options, zend_string **opened_path STREAMS_DC);
#define php_stream_open_wrapper_as_file(path, mode, options, opened_path) _php_stream_open_wrapper_as_file((path), (mode), (options), (opened_path) STREAMS_CC)
/* parse standard "fopen" modes into open() flags */
PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags);
END_EXTERN_C()

View File

@ -0,0 +1,216 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
#ifdef PHP_WIN32
#include "config.w32.h"
#include <Ws2tcpip.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
typedef php_stream *(php_stream_transport_factory_func)(const char *proto, size_t protolen,
const char *resourcename, size_t resourcenamelen,
const char *persistent_id, int options, int flags,
struct timeval *timeout,
php_stream_context *context STREAMS_DC);
typedef php_stream_transport_factory_func *php_stream_transport_factory;
BEGIN_EXTERN_C()
PHPAPI int php_stream_xport_register(const char *protocol, php_stream_transport_factory factory);
PHPAPI int php_stream_xport_unregister(const char *protocol);
#define STREAM_XPORT_CLIENT 0
#define STREAM_XPORT_SERVER 1
#define STREAM_XPORT_CONNECT 2
#define STREAM_XPORT_BIND 4
#define STREAM_XPORT_LISTEN 8
#define STREAM_XPORT_CONNECT_ASYNC 16
/* Open a client or server socket connection */
PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, int options,
int flags, const char *persistent_id,
struct timeval *timeout,
php_stream_context *context,
zend_string **error_string,
int *error_code
STREAMS_DC);
#define php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode) \
_php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode STREAMS_CC)
/* Bind the stream to a local address */
PHPAPI int php_stream_xport_bind(php_stream *stream,
const char *name, size_t namelen,
zend_string **error_text
);
/* Connect to a remote address */
PHPAPI int php_stream_xport_connect(php_stream *stream,
const char *name, size_t namelen,
int asynchronous,
struct timeval *timeout,
zend_string **error_text,
int *error_code
);
/* Prepare to listen */
PHPAPI int php_stream_xport_listen(php_stream *stream,
int backlog,
zend_string **error_text
);
/* Get the next client and their address as a string, or the underlying address
* structure. You must efree either of these if you request them */
PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client,
zend_string **textaddr,
void **addr, socklen_t *addrlen,
struct timeval *timeout,
zend_string **error_text
);
/* Get the name of either the socket or it's peer */
PHPAPI int php_stream_xport_get_name(php_stream *stream, int want_peer,
zend_string **textaddr,
void **addr, socklen_t *addrlen
);
enum php_stream_xport_send_recv_flags {
STREAM_OOB = 1,
STREAM_PEEK = 2
};
/* Similar to recv() system call; read data from the stream, optionally
* peeking, optionally retrieving OOB data */
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen,
int flags, void **addr, socklen_t *addrlen,
zend_string **textaddr);
/* Similar to send() system call; send data to the stream, optionally
* sending it as OOB data */
PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen,
int flags, void *addr, socklen_t addrlen);
typedef enum {
STREAM_SHUT_RD,
STREAM_SHUT_WR,
STREAM_SHUT_RDWR
} stream_shutdown_t;
/* Similar to shutdown() system call; shut down part of a full-duplex
* connection */
PHPAPI int php_stream_xport_shutdown(php_stream *stream, stream_shutdown_t how);
END_EXTERN_C()
/* Structure definition for the set_option interface that the above functions wrap */
typedef struct _php_stream_xport_param {
enum {
STREAM_XPORT_OP_BIND, STREAM_XPORT_OP_CONNECT,
STREAM_XPORT_OP_LISTEN, STREAM_XPORT_OP_ACCEPT,
STREAM_XPORT_OP_CONNECT_ASYNC,
STREAM_XPORT_OP_GET_NAME,
STREAM_XPORT_OP_GET_PEER_NAME,
STREAM_XPORT_OP_RECV,
STREAM_XPORT_OP_SEND,
STREAM_XPORT_OP_SHUTDOWN
} op;
unsigned int want_addr:1;
unsigned int want_textaddr:1;
unsigned int want_errortext:1;
unsigned int how:2;
struct {
char *name;
size_t namelen;
struct timeval *timeout;
struct sockaddr *addr;
char *buf;
size_t buflen;
socklen_t addrlen;
int backlog;
int flags;
} inputs;
struct {
php_stream *client;
struct sockaddr *addr;
socklen_t addrlen;
zend_string *textaddr;
zend_string *error_text;
int returncode;
int error_code;
} outputs;
} php_stream_xport_param;
/* Because both client and server streams use the same mechanisms
for encryption we use the LSB to denote clients.
*/
typedef enum {
STREAM_CRYPTO_METHOD_SSLv2_CLIENT = (1 << 1 | 1),
STREAM_CRYPTO_METHOD_SSLv3_CLIENT = (1 << 2 | 1),
/* v23 no longer negotiates SSL2 or SSL3 */
STREAM_CRYPTO_METHOD_SSLv23_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT = (1 << 3 | 1),
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT = (1 << 4 | 1),
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT = (1 << 5 | 1),
STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT = (1 << 6 | 1),
/* TLS equates to TLS_ANY as of PHP 7.2 */
STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
STREAM_CRYPTO_METHOD_SSLv2_SERVER = (1 << 1),
STREAM_CRYPTO_METHOD_SSLv3_SERVER = (1 << 2),
/* v23 no longer negotiates SSL2 or SSL3 */
STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
STREAM_CRYPTO_METHOD_TLSv1_0_SERVER = (1 << 3),
STREAM_CRYPTO_METHOD_TLSv1_1_SERVER = (1 << 4),
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER = (1 << 5),
STREAM_CRYPTO_METHOD_TLSv1_3_SERVER = (1 << 6),
/* TLS equates to TLS_ANY as of PHP 7.2 */
STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
STREAM_CRYPTO_METHOD_TLS_ANY_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6))
} php_stream_xport_crypt_method_t;
/* These functions provide crypto support on the underlying transport */
BEGIN_EXTERN_C()
PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream);
PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate);
END_EXTERN_C()
typedef struct _php_stream_xport_crypto_param {
struct {
php_stream *session;
int activate;
php_stream_xport_crypt_method_t method;
} inputs;
struct {
int returncode;
} outputs;
enum {
STREAM_XPORT_CRYPTO_OP_SETUP,
STREAM_XPORT_CRYPTO_OP_ENABLE
} op;
} php_stream_xport_crypto_param;
BEGIN_EXTERN_C()
PHPAPI HashTable *php_stream_xport_get_hash(void);
PHPAPI php_stream_transport_factory_func php_stream_generic_socket_factory;
END_EXTERN_C()

View File

@ -0,0 +1,21 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* for user-space streams */
PHPAPI extern const php_stream_ops php_stream_userspace_ops;
PHPAPI extern const php_stream_ops php_stream_userspace_dir_ops;
#define PHP_STREAM_IS_USERSPACE &php_stream_userspace_ops
#define PHP_STREAM_IS_USERSPACE_DIR &php_stream_userspace_dir_ops

View File

@ -0,0 +1,62 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
#if ZEND_DEBUG
#define emalloc_rel_orig(size) \
( __php_stream_call_depth == 0 \
? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
: _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
#define erealloc_rel_orig(ptr, size) \
( __php_stream_call_depth == 0 \
? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
: _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
#define pemalloc_rel_orig(size, persistent) ((persistent) ? malloc((size)) : emalloc_rel_orig((size)))
#define perealloc_rel_orig(ptr, size, persistent) ((persistent) ? realloc((ptr), (size)) : erealloc_rel_orig((ptr), (size)))
#else
# define pemalloc_rel_orig(size, persistent) pemalloc((size), (persistent))
# define perealloc_rel_orig(ptr, size, persistent) perealloc((ptr), (size), (persistent))
# define emalloc_rel_orig(size) emalloc((size))
#endif
#define STREAM_DEBUG 0
#define STREAM_WRAPPER_PLAIN_FILES ((php_stream_wrapper*)-1)
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif
#define CHUNK_SIZE 8192
#ifdef PHP_WIN32
# ifdef EWOULDBLOCK
# undef EWOULDBLOCK
# endif
# define EWOULDBLOCK WSAEWOULDBLOCK
# ifdef EMSGSIZE
# undef EMSGSIZE
# endif
# define EMSGSIZE WSAEMSGSIZE
#endif
/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
* and strips any subsequent chars except '+' and 'b'.
* Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or
* any other function that expects standard modes and you allow non-standard
* ones. result should be a char[5]. */
void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result);

View File

@ -0,0 +1,31 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 9198095c858c95fcb31252ddfa24fe04787d0460 */
static void register_userspace_symbols(int module_number)
{
REGISTER_LONG_CONSTANT("STREAM_USE_PATH", USE_PATH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_IGNORE_URL", IGNORE_URL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_REPORT_ERRORS", REPORT_ERRORS, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_MUST_SEEK", STREAM_MUST_SEEK, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_URL_STAT_LINK", PHP_STREAM_URL_STAT_LINK, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_URL_STAT_QUIET", PHP_STREAM_URL_STAT_QUIET, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_MKDIR_RECURSIVE", PHP_STREAM_MKDIR_RECURSIVE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_IS_URL", PHP_STREAM_IS_URL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_OPTION_BLOCKING", PHP_STREAM_OPTION_BLOCKING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_OPTION_READ_TIMEOUT", PHP_STREAM_OPTION_READ_TIMEOUT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_OPTION_READ_BUFFER", PHP_STREAM_OPTION_READ_BUFFER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_OPTION_WRITE_BUFFER", PHP_STREAM_OPTION_WRITE_BUFFER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_BUFFER_NONE", PHP_STREAM_BUFFER_NONE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_BUFFER_LINE", PHP_STREAM_BUFFER_LINE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_BUFFER_FULL", PHP_STREAM_BUFFER_FULL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CAST_AS_STREAM", PHP_STREAM_AS_STDIO, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CAST_FOR_SELECT", PHP_STREAM_AS_FD_FOR_SELECT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_TOUCH", PHP_STREAM_META_TOUCH, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_OWNER", PHP_STREAM_META_OWNER, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_OWNER_NAME", PHP_STREAM_META_OWNER_NAME, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_GROUP", PHP_STREAM_META_GROUP, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_GROUP_NAME", PHP_STREAM_META_GROUP_NAME, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_META_ACCESS", PHP_STREAM_META_ACCESS, CONST_PERSISTENT);
}

View File

@ -0,0 +1,39 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| 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. |
+----------------------------------------------------------------------+
| Author: Johannes Schlueter <johannes@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef CLI_H
#define CLI_H
#ifdef PHP_WIN32
# define PHP_CLI_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_CLI_API __attribute__ ((visibility("default")))
#else
# define PHP_CLI_API
#endif
extern PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length);
typedef struct {
size_t (*cli_shell_write)(const char *str, size_t str_length);
size_t (*cli_shell_ub_write)(const char *str, size_t str_length);
int (*cli_shell_run)(void);
} cli_shell_callbacks_t;
extern PHP_CLI_API cli_shell_callbacks_t *php_cli_get_shell_callbacks(void);
#endif /* CLI_H */

View File

@ -0,0 +1,163 @@
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
all: $(all_targets)
@echo
@echo "Build complete."
@echo "Don't forget to run 'make test'."
@echo
build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
build-binaries: $(PHP_BINARIES)
libphp.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --tag=CC --mode=link $(CC) $(LIBPHP_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --tag=CC --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
libs/libphp.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp.so
install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
@$(INSTALL_IT)
install-binaries: build-binaries $(install_binary_targets)
install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
@echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
@rm -f modules/*.la >/dev/null 2>&1
@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
install-headers:
-@if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
src=$$i; \
fi; \
if test -f "$(top_srcdir)/$$src"; then \
$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
elif test -f "$(top_builddir)/$$src"; then \
$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
else \
(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
fi \
done; \
fi
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
PHP_TEST_SHARED_EXTENSIONS = ` \
if test "x$(PHP_MODULES)" != "x"; then \
for i in $(PHP_MODULES)""; do \
. $$i; \
if test "x$$dlname" != "xdl_test.so"; then \
$(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
fi; \
done; \
fi; \
if test "x$(PHP_ZEND_EX)" != "x"; then \
for i in $(PHP_ZEND_EX)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d zend_extension=$(top_builddir)/modules/$$dlname"; \
done; \
fi`
PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
test: all
@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
TEST_RESULT_EXIT_CODE=$$?; \
rm $(top_builddir)/tmp-php.ini; \
exit $$TEST_RESULT_EXIT_CODE; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
clean:
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o -o -name \*.dep | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
rm -f ext/opcache/jit/zend_jit_x86.c
rm -f ext/opcache/jit/zend_jit_arm64.c
rm -f ext/opcache/minilua
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h
rm -f main/build-defs.h scripts/phpize
rm -f ext/date/lib/timelib_config.h ext/mbstring/libmbfl/config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/phar/phar.phar ext/phar/phar.php
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
prof-gen:
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-generate all
find . -name \*.gcda | xargs rm -f
prof-clean:
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
prof-use:
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
%_arginfo.h: %.stub.php
@if test -e "$(top_srcdir)/build/gen_stub.php"; then \
if test ! -z "$(PHP)"; then \
echo Parse $< to generate $@;\
$(PHP) $(top_srcdir)/build/gen_stub.php $<; \
elif test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
echo Parse $< to generate $@;\
$(PHP_EXECUTABLE) $(top_srcdir)/build/gen_stub.php $<; \
fi; \
fi;
.PHONY: all clean install distclean test prof-gen prof-clean prof-use
.NOEXPORT:

View File

@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View File

@ -0,0 +1,241 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
#
# DESCRIPTION
#
# This macro checks if the compiler supports one of GCC's function
# attributes; many other compilers also provide function attributes with
# the same syntax. Compiler warnings are used to detect supported
# attributes as unsupported ones are ignored by default so quieting
# warnings when using this macro will yield false positives.
#
# The ATTRIBUTE parameter holds the name of the attribute to be checked.
#
# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
#
# The macro caches its result in the ax_cv_have_func_attribute_<attribute>
# variable.
#
# The macro currently supports the following function attributes:
#
# alias
# aligned
# alloc_size
# always_inline
# artificial
# cold
# const
# constructor
# constructor_priority for constructor attribute with priority
# deprecated
# destructor
# dllexport
# dllimport
# error
# externally_visible
# fallthrough
# flatten
# format
# format_arg
# gnu_inline
# hot
# ifunc
# leaf
# malloc
# noclone
# noinline
# nonnull
# noreturn
# nothrow
# optimize
# pure
# sentinel
# sentinel_position
# unused
# used
# visibility
# warning
# warn_unused_result
# weak
# weakref
#
# Unsupported function attributes will be tested with a prototype
# returning an int and not accepting any arguments and the result of the
# check might be wrong or meaningless so use with care.
#
# LICENSE
#
# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 9
AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
m4_case([$1],
[alias], [
int foo( void ) { return 0; }
int bar( void ) __attribute__(($1("foo")));
],
[aligned], [
int foo( void ) __attribute__(($1(32)));
],
[alloc_size], [
void *foo(int a) __attribute__(($1(1)));
],
[always_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[artificial], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[cold], [
int foo( void ) __attribute__(($1));
],
[const], [
int foo( void ) __attribute__(($1));
],
[constructor_priority], [
int foo( void ) __attribute__((__constructor__(65535/2)));
],
[constructor], [
int foo( void ) __attribute__(($1));
],
[deprecated], [
int foo( void ) __attribute__(($1("")));
],
[destructor], [
int foo( void ) __attribute__(($1));
],
[dllexport], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[dllimport], [
int foo( void ) __attribute__(($1));
],
[error], [
int foo( void ) __attribute__(($1("")));
],
[externally_visible], [
int foo( void ) __attribute__(($1));
],
[fallthrough], [
int foo( void ) {switch (0) { case 1: __attribute__(($1)); case 2: break ; }};
],
[flatten], [
int foo( void ) __attribute__(($1));
],
[format], [
int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
],
[format_arg], [
char *foo(const char *p) __attribute__(($1(1)));
],
[gnu_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[hot], [
int foo( void ) __attribute__(($1));
],
[ifunc], [
int my_foo( void ) { return 0; }
static int (*resolve_foo(void))(void) { return my_foo; }
int foo( void ) __attribute__(($1("resolve_foo")));
],
[leaf], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[malloc], [
void *foo( void ) __attribute__(($1));
],
[noclone], [
int foo( void ) __attribute__(($1));
],
[noinline], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[nonnull], [
int foo(char *p) __attribute__(($1(1)));
],
[noreturn], [
void foo( void ) __attribute__(($1));
],
[nothrow], [
int foo( void ) __attribute__(($1));
],
[optimize], [
__attribute__(($1(3))) int foo( void ) { return 0; }
],
[pure], [
int foo( void ) __attribute__(($1));
],
[sentinel], [
int foo(void *p, ...) __attribute__(($1));
],
[sentinel_position], [
int foo(void *p, ...) __attribute__(($1(1)));
],
[returns_nonnull], [
void *foo( void ) __attribute__(($1));
],
[unused], [
int foo( void ) __attribute__(($1));
],
[used], [
int foo( void ) __attribute__(($1));
],
[visibility], [
int foo_def( void ) __attribute__(($1("default")));
int foo_hid( void ) __attribute__(($1("hidden")));
int foo_int( void ) __attribute__(($1("internal")));
int foo_pro( void ) __attribute__(($1("protected")));
],
[warning], [
int foo( void ) __attribute__(($1("")));
],
[warn_unused_result], [
int foo( void ) __attribute__(($1));
],
[weak], [
int foo( void ) __attribute__(($1));
],
[weakref], [
static int foo( void ) { return 0; }
static int bar( void ) __attribute__(($1("foo")));
],
[target], [
static int bar( void ) __attribute__(($1("sse2")));
],
[
m4_warn([syntax], [Unsupported attribute $1, the test may fail])
int foo( void ) __attribute__(($1));
]
)], [])
],
dnl GCC doesn't exit with an error if an unknown attribute is
dnl provided but only outputs a warning, so accept the attribute
dnl only if no warning were issued.
[AS_IF([test -s conftest.err],
[AS_VAR_SET([ac_var], [no])],
[AS_VAR_SET([ac_var], [yes])])],
[AS_VAR_SET([ac_var], [no])])
])
AS_IF([test yes = AS_VAR_GET([ac_var])],
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
[Define to 1 if the system has the `$1' function attribute])], [])
AS_VAR_POPDEF([ac_var])
])

1774
lib/php/build/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1914
lib/php/build/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

5179
lib/php/build/gen_stub.php Normal file

File diff suppressed because it is too large Load Diff

6370
lib/php/build/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

6970
lib/php/build/ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

2864
lib/php/build/php.m4 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,956 @@
dnl
dnl Based on https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
dnl Author: Anatol Belski <ab@php.net>
dnl
dnl PHP_CXX_COMPILE_STDCXX(version, mandatory|optional, var_name_to_put_switch_in)
dnl
dnl ARGUMENTS
dnl
dnl first arg - version as 11, 14, 17 or 20
dnl second arg - if mandatory, the configure will fail when no features found.
dnl Optional will make configure silently continue
dnl third arg - a variable name where the corresponding switch would be put. If
dnl the variable is already defined, its contents will be overwritten.
dnl
dnl EXAMPLE
dnl
dnl PHP_CXX_COMPILE_STDCXX(14, mandatory, MY_STDCXX_SWiTCH)
dnl echo $MY_STDCXX_SWITCH
dnl
dnl
dnl PHP specific implementation start.
dnl
AC_DEFUN([PHP_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20"],
[m4_fatal([invalid first argument `$1' to PHP_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx$1_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$2], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$2' to PHP_CXX_COMPILE_STDCXX])])dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
eval AS_TR_SH([$3])="$switch"
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
AC_MSG_NOTICE([No compiler with C++$1 support was found])
fi
AC_SUBST(HAVE_CXX$1)
])
dnl
dnl PHP specific implementation end.
dnl The relevant part of the unchanged original implementation is below.
dnl
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
# Copyright (c) 2020 Jason Merrill <jason@redhat.com>
# Copyright (c) 2021 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
dnl Test body for checking C++17 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Test body for checking C++20 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
virtual ~Derived() override {}
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L
#error "This is not a C++17 compiler"
#else
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
namespace test_constexpr_lambdas
{
constexpr int foo = [](){return 42;}();
}
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
namespace test_template_argument_deduction_for_class_templates
{
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
namespace test_structured_bindings
{
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
namespace test_exception_spec_type_system
{
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus < 201703L
]])
dnl Tests for new features in C++20
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 202002L
#error "This is not a C++20 compiler"
#else
#include <version>
namespace cxx20
{
// As C++20 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.
} // namespace cxx20
#endif // __cplusplus < 202002L
]])

224
lib/php/build/phpize.m4 Normal file
View File

@ -0,0 +1,224 @@
dnl This file becomes configure.ac for self-contained extensions.
dnl Include external macro definitions before the AC_INIT to also remove
dnl comments starting with # and empty newlines from the included files.
m4_include([build/ax_check_compile_flag.m4])
m4_include([build/ax_gcc_func_attribute.m4])
m4_include([build/libtool.m4])
m4_include([build/php_cxx_compile_stdcxx.m4])
m4_include([build/php.m4])
m4_include([build/pkg.m4])
AC_PREREQ([2.68])
AC_INIT
AC_CONFIG_SRCDIR([config.m4])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER
PHP_CONFIG_NICE(config.nice)
AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
AC_DEFUN([PHP_EXT_DIR],[""])dnl
AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
AC_DEFUN([PHP_ALWAYS_SHARED],[
ext_output="yes, shared"
ext_shared=yes
test "[$]$1" = "no" && $1=yes
])dnl
test -z "$CFLAGS" && auto_cflags=1
abs_srcdir=`(cd $srcdir && pwd)`
abs_builddir=`pwd`
PKG_PROG_PKG_CONFIG
AC_PROG_CC([cc gcc])
PHP_DETECT_ICC
PHP_DETECT_SUNCC
dnl Support systems with system libraries in e.g. /usr/lib64.
PHP_ARG_WITH([libdir],
[for system library directory],
[AS_HELP_STRING([--with-libdir=NAME],
[Look for libraries in .../NAME rather than .../lib])],
[lib],
[no])
PHP_RUNPATH_SWITCH
PHP_SHLIB_SUFFIX_NAMES
dnl Find php-config script.
PHP_ARG_WITH([php-config],,
[AS_HELP_STRING([--with-php-config=PATH],
[Path to php-config [php-config]])],
[php-config],
[no])
dnl For BC.
PHP_CONFIG=$PHP_PHP_CONFIG
prefix=`$PHP_CONFIG --prefix 2>/dev/null`
phpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null`
INCLUDES=`$PHP_CONFIG --includes 2>/dev/null`
EXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null`
PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null`
if test -z "$prefix"; then
AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])
fi
php_shtool=$srcdir/build/shtool
PHP_INIT_BUILD_SYSTEM
AC_MSG_CHECKING([for PHP prefix])
AC_MSG_RESULT([$prefix])
AC_MSG_CHECKING([for PHP includes])
AC_MSG_RESULT([$INCLUDES])
AC_MSG_CHECKING([for PHP extension directory])
AC_MSG_RESULT([$EXTENSION_DIR])
AC_MSG_CHECKING([for PHP installed headers prefix])
AC_MSG_RESULT([$phpincludedir])
dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS.
AC_MSG_CHECKING([if debug is enabled])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP(php_debug_is_enabled,[
#include <main/php_config.h>
#if ZEND_DEBUG
php_debug_is_enabled
#endif
],[
PHP_DEBUG=yes
],[
PHP_DEBUG=no
])
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_DEBUG])
AC_MSG_CHECKING([if zts is enabled])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP(php_zts_is_enabled,[
#include <main/php_config.h>
#if ZTS
php_zts_is_enabled
#endif
],[
PHP_THREAD_SAFETY=yes
],[
PHP_THREAD_SAFETY=no
])
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_THREAD_SAFETY])
dnl Discard optimization flags when debugging is enabled.
if test "$PHP_DEBUG" = "yes"; then
PHP_DEBUG=1
ZEND_DEBUG=yes
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
changequote([,])
dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0"
CXXFLAGS="$CXXFLAGS -g -O0"
fi
if test "$SUNCC" = "yes"; then
if test -n "$auto_cflags"; then
CFLAGS="-g"
CXXFLAGS="-g"
else
CFLAGS="$CFLAGS -g"
CXXFLAGS="$CFLAGS -g"
fi
fi
else
PHP_DEBUG=0
ZEND_DEBUG=no
fi
dnl Always shared.
PHP_BUILD_SHARED
dnl Required programs.
PHP_PROG_AWK
sinclude(config.m4)
enable_static=no
enable_shared=yes
dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by
dnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++
dnl compiler.
AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
undefine([AC_PROG_CXX])
AC_DEFUN([AC_PROG_CXX], [])
undefine([AC_PROG_CXXCPP])
AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
])
AC_PROG_LIBTOOL
all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
install_targets="install-modules install-headers"
phplibdir="`pwd`/modules"
CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
CFLAGS_CLEAN='$(CFLAGS) -D_GNU_SOURCE'
CXXFLAGS_CLEAN='$(CXXFLAGS)'
test "$prefix" = "NONE" && prefix="/usr/local"
test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
if test "$cross_compiling" = yes ; then
AC_MSG_CHECKING(for native build C compiler)
AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)
AC_MSG_RESULT($BUILD_CC)
else
BUILD_CC=$CC
fi
PHP_SUBST(PHP_MODULES)
PHP_SUBST(PHP_ZEND_EX)
PHP_SUBST(all_targets)
PHP_SUBST(install_targets)
PHP_SUBST(prefix)
PHP_SUBST(exec_prefix)
PHP_SUBST(libdir)
PHP_SUBST(prefix)
PHP_SUBST(phplibdir)
PHP_SUBST(phpincludedir)
PHP_SUBST(CC)
PHP_SUBST(CFLAGS)
PHP_SUBST(CFLAGS_CLEAN)
PHP_SUBST(CPP)
PHP_SUBST(CPPFLAGS)
PHP_SUBST(CXX)
PHP_SUBST(CXXFLAGS)
PHP_SUBST(CXXFLAGS_CLEAN)
PHP_SUBST(EXTENSION_DIR)
PHP_SUBST(PHP_EXECUTABLE)
PHP_SUBST(EXTRA_LDFLAGS)
PHP_SUBST(EXTRA_LIBS)
PHP_SUBST(INCLUDES)
PHP_SUBST(LFLAGS)
PHP_SUBST(LDFLAGS)
PHP_SUBST(SHARED_LIBTOOL)
PHP_SUBST(LIBTOOL)
PHP_SUBST(SHELL)
PHP_SUBST(INSTALL_HEADERS)
PHP_SUBST(BUILD_CC)
PHP_GEN_BUILD_DIRS
PHP_GEN_GLOBAL_MAKEFILE
test -d modules || $php_shtool mkdir modules
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])])
AC_OUTPUT

275
lib/php/build/pkg.m4 Normal file
View File

@ -0,0 +1,275 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301, USA.
dnl
dnl As a special exception to the GNU General Public License, if you
dnl distribute this file as part of a program that contains a
dnl configuration script generated by Autoconf, you may include it under
dnl the same distribution terms that you use for the rest of that
dnl program.
dnl PKG_PREREQ(MIN-VERSION)
dnl -----------------------
dnl Since: 0.29
dnl
dnl Verify that the version of the pkg-config macros are at least
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
dnl installed version of pkg-config, this checks the developer's version
dnl of pkg.m4 when generating configure.
dnl
dnl To ensure that this macro is defined, also add:
dnl m4_ifndef([PKG_PREREQ],
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
dnl ----------------------------------
dnl Since: 0.16
dnl
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
dnl first found in the path. Checks that the version of pkg-config found
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
dnl used since that's the first version where most current features of
dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])dnl PKG_PROG_PKG_CONFIG
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------------------------------
dnl Since: 0.18
dnl
dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurrence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you
dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
dnl ---------------------------------------------
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])dnl _PKG_CONFIG
dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl ---------------------------
dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Since: 0.4.0
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])dnl PKG_CHECK_MODULES
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl ---------------------------------------------------------------------
dnl Since: 0.29
dnl
dnl Checks for existence of MODULES and gathers its build flags with
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
dnl and VARIABLE-PREFIX_LIBS from --libs.
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
dnl configure.ac.
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
_save_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES($@)
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
])dnl PKG_CHECK_MODULES_STATIC
dnl PKG_INSTALLDIR([DIRECTORY])
dnl -------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable pkgconfigdir as the location where a module
dnl should install pkg-config .pc files. By default the directory is
dnl $libdir/pkgconfig, but the default can be changed by passing
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
[with_pkgconfigdir=]pkg_default)
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_INSTALLDIR
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
dnl --------------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
dnl module should install arch-independent pkg-config .pc files. By
dnl default the directory is $datadir/pkgconfig, but the default can be
dnl changed by passing DIRECTORY. The user can override through the
dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([noarch-pkgconfigdir],
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
[with_noarch_pkgconfigdir=]pkg_default)
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_NOARCH_INSTALLDIR
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------
dnl Since: 0.28
dnl
dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR

4266
lib/php/build/run-tests.php Normal file

File diff suppressed because it is too large Load Diff

1814
lib/php/build/shtool Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.

531
php/man/man1/phar.1 Normal file
View File

@ -0,0 +1,531 @@
.TH PHAR 1 "2024" "The PHP Group" "User Commands"
.SH NAME
phar, phar.phar \- PHAR (PHP archive) command line tool
.SH SYNOPSIS
.B phar
<command> [options] ...
.LP
.SH DESCRIPTION
The \fBPHAR\fP file format provides a way to put entire PHP applications into a single
file called a "phar" (PHP Archive) for easy distribution and installation.
.P
With the \fBphar\fP command you can create, update or extract PHP archives.
.P
Commands:
add compress delete extract help help-list info list meta-del
meta-get meta-set pack sign stub-get stub-set tree version
.SH add command
Add entries to a PHAR package.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B ...
Any number of input files and directories. If -i is in
use then ONLY files and matching the given regular
expression are being packed. If -x is given then files
matching that regular expression are NOT being packed.
.P
Optional arguments:
.TP 15
.PD
.B \-a \fIalias\fP
Provide an \fIalias\fP name for the phar file.
.TP
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-l \fIlevel\fP
Number of preceding subdirectories to strip from file entries
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.SH compress command
Compress or uncompress all files or a selected entry.
.P
Required arguments:
.TP 15
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.SH delete command
Delete entry from a PHAR archive
.P
Required arguments:
.TP 15
.PD
.B \-e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.SH extract command
Extract a PHAR package to a directory.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B -x \fIregex\fP
Regular expression for input files to exclude.
.TP
.PD
.B ...
Directory to extract to (defaults to '.').
.SH help command
This help or help for a selected command.
.P
Optional arguments:
.TP 15
.PD
.B ...
Optional command to retrieve help for.
.SH help-list command
Lists available commands.
.SH info command
Get information about a PHAR package.
.P
By using -k it is possible to return a single value.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH list command
List contents of a PHAR archive.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B -x \fIregex\fP
Regular expression for input files to exclude.
.SH meta-del command
Delete meta information of a PHAR entry or a PHAR package.
.P
If -k is given then the metadata is expected to be an array and the
given index is being deleted.
.P
If something was deleted the return value is 0 otherwise it is 1.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH meta-get command
Get meta information of a PHAR entry or a PHAR package in serialized from. If
no output file is specified for meta data then stdout is being used.
You can also specify a particular index using -k. In that case the
metadata is expected to be an array and the value of the given index
is returned using echo rather than using serialize. If that index does
not exist or no meta data is present then the return value is 1.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH meta-set command
Set meta data of a PHAR entry or a PHAR package using serialized input. If no
input file is specified for meta data then stdin is being used. You can
also specify a particular index using -k. In that case the metadata is
expected to be an array and the value of the given index is being set.
If the metadata is not present or empty a new array will be created.
If the metadata is present and a flat value then the return value is
1. Also using -k the input is been taken directly rather then being
serialized.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B -m \fImeta\fP
Meta data to store with entry (serialized php data).
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH pack command
Pack files into a PHAR archive.
.P
When using -s <stub>, then the stub file is being excluded from the
list of input files/dirs.To create an archive that contains PEAR class
PHP_Archive then point -p argument to PHP/Archive.php.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B ...
Any number of input files and directories. If -i is in
use then ONLY files and matching the given regular
expression are being packed. If -x is given then files
matching that regular expression are NOT being packed.
.P
Optional arguments:
.TP 15
.PD
.B \-a \fIalias\fP
Provide an \fIalias\fP name for the phar file.
.TP
.PD
.B \-b \fIbang\fP
Hash-bang line to start the archive (e.g. #!/usr/bin/php).
The hash mark itself '#!' and the newline character are optional.
.TP
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B \-h \fIhash\fP
Selects the \fIhash\fP algorithm (see
.SM
.B HASH
)
.TP
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-l \fIlevel\fP
Number of preceding subdirectories to strip from file entries
.TP
.PD
.B \-p \fIloader\fP
Location of PHP_Archive class file (pear list-files
PHP_Archive).You can use '0' or '1' to locate it
automatically using the mentioned pear command. When
using '0' the command does not error out when the class
file cannot be located. This switch also adds some code
around the stub so that class PHP_Archive gets
registered as phar:// stream wrapper if necessary. And
finally this switch will add the file phar.inc from
this package and load it to ensure class Phar is
present.
.TP
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.TP
.PD
.B \-y \fIkey\fP
Private \fIkey\fP for OpenSSL signing.
.SH sign command
Set signature hash algorithm.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B \-h \fIhash\fP
Selects the \fIhash\fP algorithm (see
.SM
.B HASH
)
.P
Optional arguments:
.TP 15
.PD
.B \-y \fIkey\fP
Private \fIkey\fP for OpenSSL signing.
.SH stub-get command
Get the stub of a PHAR file. If no output file is specified as stub then stdout
is being used.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.SH stub-set command
Set the stub of a PHAR file. If no input file is specified as stub then stdin
is being used.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-b \fIbang\fP
Hash-bang line to start the archive (e.g. #!/usr/bin/php).
The hash mark itself '#!' and the newline character are optional.
.TP
.PD
.B \-p \fIloader\fP
Location of PHP_Archive class file (pear list-files
PHP_Archive).You can use '0' or '1' to locate it
automatically using the mentioned pear command. When
using '0' the command does not error out when the class
file cannot be located. This switch also adds some code
around the stub so that class PHP_Archive gets
registered as phar:// stream wrapper if necessary. And
finally this switch will add the file phar.inc from
this package and load it to ensure class Phar is
present.
.TP
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.SH tree command
Get a directory tree for a PHAR archive.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.SH version command
Get information about the PHAR environment and the tool version.
.SH COMPRESSION
Algorithms:
.TP 15
.PD
.B 0
No compression
.TP
.PD
.B none
No compression
.TP
.PD
.B auto
Automatically select compression algorithm
.TP
.PD
.B gz
GZip compression
.TP
.PD
.B gzip
GZip compression
.TP
.PD
.B bz2
BZip2 compression
.TP
.PD
.B bzip2
BZip2 compression
.SH HASH
Algorithms:
.TP 15
.PD
.TP
.PD
.B md5
MD5
.TP
.PD
.B sha1
SHA1
.TP
.PD
.B sha256
SHA256
.TP
.PD
.B sha512
SHA512
.TP
.PD
.B openssl
OpenSSL using SHA-1
.TP
.PD
.B openssl_sha256
OpenSSL using SHA-256
.TP
.PD
.B openssl_sha512
OpenSSL using SHA-512
.SH SEE ALSO
For a more or less complete description of PHAR look here:
.PD 0
.P
.B http://php.net/phar
.PD 1
.P
.SH BUGS
You can view the list of known bugs or report any new bug you
found at:
.PD 0
.P
.B https://github.com/php/php-src/issues
.PD 1
.SH AUTHORS
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
.P
Work for the PHP archive was done by Gregory Beaver, Marcus Boerger.
.P
A List of active developers can be found here:
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphar\fP, version 8.3.3-dev.
.SH COPYRIGHT
Copyright \(co The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available through the world-wide-web at the following url:
.PD 0
.P
.B https://www.php.net/license/3_01.txt
.PD 1
.P
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
.B license@php.net
so we can mail you a copy immediately.

1
php/man/man1/phar.phar.1 Normal file
View File

@ -0,0 +1 @@
.so man1/phar.1

1
php/man/man1/php-cgi.1 Normal file
View File

@ -0,0 +1 @@
.so man1/php.1

81
php/man/man1/php-config.1 Normal file
View File

@ -0,0 +1,81 @@
.TH php\-config 1 "2024" "The PHP Group" "Scripting Language"
.SH NAME
php\-config \- get information about PHP configuration and compile options
.SH SYNOPSIS
.B php\-config
[options]
.LP
.SH DESCRIPTION
.B php\-config
is a simple shell script for obtaining information about installed PHP configuration.
.SH OPTIONS
.TP 15
.PD 0
.B \-\-prefix
Directory prefix where PHP is installed, e.g. /usr/local
.TP
.PD 0
.B \-\-includes
List of \-I options with all include files
.TP
.PD 0
.B \-\-ldflags
LD Flags which PHP was compiled with
.TP
.PD 0
.B \-\-libs
Extra libraries which PHP was compiled with
.TP
.PD 0
.B \-\-man-dir
The directory prefix where the manpages is installed
.TP
.PD 0
.B \-\-extension-dir
Directory where extensions are searched by default
.TP
.PD 0
.B \-\-include-dir
Directory prefix where header files are installed by default
.TP
.PD 0
.B \-\-php-binary
Full path to php CLI or CGI binary
.TP
.PD 0
.B \-\-php-sapis
Show all SAPI modules available
.TP
.PD 0
.B \-\-configure-options
Configure options to recreate configuration of current PHP installation
.TP
.PD 0
.B \-\-version
PHP version
.TP
.PD 0
.B \-\-vernum
PHP version as integer
.RS
.PD 1
.P
.SH SEE ALSO
.BR php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 8.3.3-dev.
.SH COPYRIGHT
Copyright \(co The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available through the world-wide-web at the following url:
.PD 0
.P
.B https://www.php.net/license/3_01.txt
.PD 1
.P
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
.B license@php.net
so we can mail you a copy immediately.

479
php/man/man1/php.1 Normal file
View File

@ -0,0 +1,479 @@
.TH php 1 "2024" "The PHP Group" "Scripting Language"
.SH NAME
php \- PHP Command Line Interface 'CLI'
.P
php-cgi \- PHP Common Gateway Interface 'CGI' command
.SH SYNOPSIS
.B php
[options] [
.B \-f\fP ]
.IR file
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options]
.B \-r
.IR code
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] [\-B
.IR begin_code ]
.B \-R
.IR code
[\-E
.IR end_code ]
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] [\-B
.IR begin_code ]
.B \-F
.IR file
[\-E
.IR end_code ]
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] \-\- [
.IR args.\|.\|. ]
.LP
\fBphp \fP[options] \fB\-a\fP
.LP
.B php
[options] \-S
.IR addr:port
[\-t
.IR docroot ]
.LP
.SH DESCRIPTION
\fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for
Web development and can be embedded into HTML. This is the command line interface
that enables you to do the following:
.P
You can parse and execute files by using parameter \-f followed by the name of the
.IR file
to be executed.
.LP
Using parameter \-r you can directly execute PHP
.IR code
simply as you would do inside a
.B \.php
file when using the
.B eval()
function.
.LP
It is also possible to process the standard input line by line using either
the parameter \-R or \-F. In this mode each separate input line causes the
.IR code
specified by \-R or the
.IR file
specified by \-F to be executed.
You can access the input line by \fB$argn\fP. While processing the input lines
.B $argi
contains the number of the actual line being processed. Further more
the parameters \-B and \-E can be used to execute
.IR code
(see \-r) before and
after all input lines have been processed respectively. Notice that the
input is read from
.B STDIN
and therefore reading from
.B STDIN
explicitly changes the next input line or skips input lines.
.LP
PHP also contains an built-in web server for application development purpose. By using the \-S option where
.B addr:port
point to a local address and port PHP will listen to HTTP requests on that address and port and serve files from the current working directory or the
.B docroot
passed by the \-t option.
.LP
If a PHP file is provided to the command line when the
built-in web server is used, it will be used as the router script. This script
will be started at each HTTP request. The script output is returned to the
browser, unless the router script returns the
.B false
value. If so, the built-in server falls back to the default behaviour, returning
the requested resource as-is by looking up the files relative to the document
root specified by the \-t option, if provided.
.LP
If none of \-r \-f \-B \-R \-F \-E or \-S is present but a single parameter is given
then this parameter is taken as the filename to parse and execute (same as
with \-f). If no parameter is present then the standard input is read and
executed.
.SH OPTIONS
.TP 15
.PD 0
.B \-\-interactive
.TP
.PD 1
.B \-a
Run PHP interactively. This lets you enter snippets of PHP code that directly
get executed. When readline support is enabled you can edit the lines and also
have history support.
.TP
.PD 0
.B \-\-bindpath \fIaddress:port\fP|\fIport\fP
.TP
.PD 1
.B \-b \fIaddress:port\fP|\fIport\fP
Bind Path for external FASTCGI Server mode (CGI only).
.TP
.PD 0
.B \-\-no\-chdir
.TP
.PD 1
.B \-C
Do not chdir to the script's directory (CGI only).
.TP
.PD 0
.B \-\-no\-header
.TP
.PD 1
.B \-q
Quiet-mode. Suppress HTTP header output (CGI only).
.TP
.PD 0
.B \-\-timing \fIcount\fP
.TP
.PD 1
.B \-T \fIcount\fP
Measure execution time of script repeated count times (CGI only).
.TP
.PD 0
.B \-\-php\-ini \fIpath\fP|\fIfile\fP
.TP
.PD 1
.B \-c \fIpath\fP|\fIfile\fP
Look for
.B php.ini
file in the directory
.IR path
or use the specified
.IR file
.TP
.PD 0
.B \-\-no\-php\-ini
.TP
.PD 1
.B \-n
No
.B php.ini
file will be used
.TP
.PD 0
.B \-\-define \fIfoo\fP[=\fIbar\fP]
.TP
.PD 1
.B \-d \fIfoo\fP[=\fIbar\fP]
Define INI entry
.IR foo
with value
.IR bar
.TP
.B \-e
Generate extended information for debugger/profiler
.TP
.PD 0
.B \-\-file \fIfile\fP
.TP
.PD 1
.B \-f \fIfile\fP
Parse and execute
.IR file
.TP
.PD 0
.B \-\-help
.TP
.PD 1
.B \-h
This help
.TP
.PD 0
.B \-\-hide\-args
.TP
.PD 1
.B \-H
Hide script name (\fIfile\fP) and parameters (\fIargs\.\.\.\fP) from external
tools. For example you may want to use this when a php script is started as
a daemon and the command line contains sensitive data such as passwords.
.TP
.PD 0
.B \-\-info
.TP
.PD 1
.B \-i
PHP information and configuration
.TP
.PD 0
.B \-\-syntax\-check
.TP
.PD 1
.B \-l
Syntax check only (lint)
.TP
.PD 0
.B \-\-modules
.TP
.PD 1
.B \-m
Show compiled in modules
.TP
.PD 0
.B \-\-run \fIcode\fP
.TP
.PD 1
.B \-r \fIcode\fP
Run PHP
.IR code
without using script tags
.B '<?..?>'
.TP
.PD 0
.B \-\-process\-begin \fIcode\fP
.TP
.PD 1
.B \-B \fIbegin_code\fP
Run PHP
.IR begin_code
before processing input lines
.TP
.PD 0
.B \-\-process\-code \fIcode\fP
.TP
.PD 1
.B \-R \fIcode\fP
Run PHP
.IR code
for every input line
.TP
.PD 0
.B \-\-process\-file \fIfile\fP
.TP
.PD 1
.B \-F \fIfile\fP
Parse and execute
.IR file
for every input line
.TP
.PD 0
.B \-\-process\-end \fIcode\fP
.TP
.PD 1
.B \-E \fIend_code\fP
Run PHP
.IR end_code
after processing all input lines
.TP
.PD 0
.B \-\-syntax\-highlight
.TP
.PD 1
.B \-s
Output HTML syntax highlighted source
.TP
.PD 0
.B \-\-server \fIaddr:port\fP
.TP
.PD 1
.B \-S \fIaddr:port\fP
Start built-in web server on the given local address and port
.TP
.PD 0
.B \-\-docroot \fIdocroot\fP
.TP
.PD 1
.B \-t \fIdocroot\fP
Specify the document root to be used by the built-in web server
.TP
.PD 0
.B \-\-version
.TP
.PD 1
.B \-v
Version number
.TP
.PD 0
.B \-\-strip
.TP
.PD 1
.B \-w
Output source with stripped comments and whitespace
.TP
.PD 0
.B \-\-zend\-extension \fIfile\fP
.TP
.PD 1
.B \-z \fIfile\fP
Load Zend extension
.IR file
.TP
.IR args.\|.\|.
Arguments passed to script. Use
.B '\-\-'
.IR args
when first argument starts with
.B '\-'
or script is read from stdin
.TP
.PD 0
.B \-\-rfunction
.IR name
.TP
.PD 1
.B \-\-rf
.IR name
Shows information about function
.B name
.TP
.PD 0
.B \-\-rclass
.IR name
.TP
.PD 1
.B \-\-rc
.IR name
Shows information about class
.B name
.TP
.PD 0
.B \-\-rextension
.IR name
.TP
.PD 1
.B \-\-re
.IR name
Shows information about extension
.B name
.TP
.PD 0
.B \-\-rzendextension
.IR name
.TP
.PD 1
.B \-\-rz
.IR name
Shows information about Zend extension
.B name
.TP
.PD 0
.B \-\-rextinfo
.IR name
.TP
.PD 1
.B \-\-ri
.IR name
Shows configuration for extension
.B name
.TP
.B \-\-ini
Show configuration file names
.SH FILES
.TP 15
.B php\-cli.ini
The configuration file for the CLI version of PHP.
.TP
.B php.ini
The standard configuration file will only be used when
.B php\-cli.ini
cannot be found.
.SH EXAMPLES
.TP 5
\fIphp \-r 'echo "Hello World\\n";'\fP
This command simply writes the text "Hello World" to standard out.
.TP
\fIphp \-r 'print_r(gd_info());'\fP
This shows the configuration of your gd extension. You can use this
to easily check which image formats you can use. If you have any
dynamic modules you may want to use the same ini file that php uses
when executed from your webserver. There are more extensions which
have such a function. For dba use:
.RS
\fIphp \-r 'print_r(dba_handlers(1));'\fP
.RE
.TP
\fIphp \-R 'echo strip_tags($argn)."\\n";'\fP
This PHP command strips off the HTML tags line by line and outputs the
result. To see how it works you can first look at the following PHP command
\'\fIphp \-d html_errors=1 \-i\fP\' which uses PHP to output HTML formatted
configuration information. If you then combine those two
\'\fIphp \.\.\.|php \.\.\.\fP\' you'll see what happens.
.TP
\fIphp \-E 'echo "Lines: $argi\\n";'\fP
Using this PHP command you can count the lines being input.
.TP
\fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
In this example PHP expects each input line being a file. It counts all lines
of the files specified by each input line and shows the summarized result.
You may combine this with tools like find and change the php scriptlet.
.TP
\fIphp \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
Since you have access to STDIN from within \-B \-R \-F and \-E you can skip
certain input lines with your code. But note that in such cases $argi only
counts the lines being processed by php itself. Having read this you will
guess what the above program does: skipping every second input line.
.SH TIPS
You can use a shebang line to automatically invoke php
from scripts. Only the CLI version of PHP will ignore
such a first line as shown below:
.P
.PD 0
.RS
#!/bin/php
.P
<?php
.P
// your script
.P
?>
.RE
.PD 1
.P
.SH SEE ALSO
For a more or less complete description of PHP look here:
.PD 0
.P
.B http://www.php.net/manual/
.PD 1
.P
.SH BUGS
You can view the list of known bugs or report any new bug you
found at:
.PD 0
.P
.B https://github.com/php/php-src/issues
.PD 1
.SH AUTHORS
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
.P
Additional work for the CLI sapi was done by Edin Kadribasic, Marcus Boerger and Johannes Schlueter.
.P
A List of active developers can be found here:
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 8.3.3-dev.
.SH COPYRIGHT
Copyright \(co The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available through the world-wide-web at the following url:
.PD 0
.P
.B https://www.php.net/license/3_01.txt
.PD 1
.P
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
.B license@php.net
so we can mail you a copy immediately.

137
php/man/man1/phpdbg.1 Normal file
View File

@ -0,0 +1,137 @@
.TH phpdbg 1 "2024" "The PHP Group" "Scripting Language"
.SH NAME
phpdbg \- The interactive PHP debugger
.SH SYNOPSIS
.B phpdbg
[options]
[\fIfile\fP]
[\fIargs...\fP]
.SH DESCRIPTION
.B phpdbg
is a lightweight, powerful, easy to use debugging platform for PHP.
.SH OPTIONS
.TP 15
.B \-c \fIpath\fB|\fIfile\fR
Look for
.B php.ini
file in the directory
.IR path
or use the specified
.IR file
.TP
.B \-d \fIfoo\fP[=\fIbar\fP]
Define INI entry
.IR foo
with value
.IR bar
.TP
.B \-n
No
.B php.ini
file will be used
.TP
.B \-z \fIfile\fR
Load Zend extension
.IR file
.TP
.BR \-q
Do not print banner on startup
.TP
.B \-v
Enable oplog output
.TP
.B \-b
Disables use of color on the console
.TP
.B \-i \fIpath\fB|\fIfile\fR
Override .phpgdbinit location (implies -I)
.TP
.B \-I
Ignore .phpdbginit (default init file)
.TP
.B \-r
Jump straight to run
.TP
.B -e
Generate extended information for debugger/profiler
.TP
.B \-E
Enable step through eval()
.TP
.B \-s \fIdelimiter\fP
Read code to execute from stdin with an optional
.IR delimiter
.TP
.B \-S \fIsapi_name\fP
Override SAPI name
.TP
.B \-p \fIopcode\fP
Output opcodes and quit
.TP
.B \-h
Print the help overview
.TP
.B \-V
Version number
.TP
.IR args.\|.\|.
Arguments passed to script. Use
.B '\-\-'
.IR args
when first argument starts with
.B '\-'
or script is read from stdin
.SH NOTES
Passing
.B \-rr
will cause
.B phpdbg
to quit after execution, rather than returning to the console
.SH FILES
.TP 15
.B php.ini
The standard configuration file
.TP
.B .phpdbginit
The init file
.SH SEE ALSO
The online manual can be found at
.PD 0
.P
.B http://php.net/manual/book.phpdbg.php
.PD 1
.SH BUGS
You can view the list of known bugs or report any new bug you
found at
.PD 0
.P
.B https://github.com/php/php-src/issues
.PD 1
.SH AUTHORS
Written by Felipe Pena, Joe Watkins and Bob Weinand, formatted by Ondřej Surý for Debian project.
.P
A List of active developers can be found at
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphpdbg\fP, for PHP version 8.3.3-dev.
.SH COPYRIGHT
Copyright \(co The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available through the world-wide-web at the following url:
.PD 0
.P
.B https://www.php.net/license/3_01.txt
.PD 1
.P
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
.B license@php.net
so we can mail you a copy immediately.

48
php/man/man1/phpize.1 Normal file
View File

@ -0,0 +1,48 @@
.TH phpize 1 "2024" "The PHP Group" "Scripting Language"
.SH NAME
phpize \- prepare a PHP extension for compiling
.SH SYNOPSIS
.B phpize
[options]
.LP
.SH DESCRIPTION
.B phpize
is a shell script to prepare PHP extension for compiling.
.SH OPTIONS
.TP 15
.PD 0
.B \-\-clean
Remove all created files
.TP
.PD 0
.B \-\-help
Prints usage information
.TP
.PD 0
.B \-\-version
.TP
.PD 1
.B \-v
Prints API version information
.RS
.PD 1
.P
.SH SEE ALSO
.BR php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 8.3.3-dev.
.SH COPYRIGHT
Copyright \(co The PHP Group
.LP
This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
available through the world-wide-web at the following url:
.PD 0
.P
.B https://www.php.net/license/3_01.txt
.PD 1
.P
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
.B license@php.net
so we can mail you a copy immediately.