summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/build/Makefile6
-rw-r--r--win32/build/buildconf.js2
-rw-r--r--win32/build/config.w3225
-rw-r--r--win32/build/config.w32.h.in40
-rw-r--r--win32/build/confutils.js218
-rw-r--r--win32/build/deplister.c11
-rw-r--r--win32/build/mkdist.php801
-rw-r--r--win32/build/phpize.js.in2
-rwxr-xr-xwin32/build/registersyslog.php26
-rw-r--r--win32/build/template.rc2
-rw-r--r--[-rwxr-xr-x]win32/build/wsyslog.mc0
-rw-r--r--win32/builddef.bat6
-rw-r--r--win32/codepage.c60
-rw-r--r--win32/codepage.h11
-rw-r--r--win32/console.c17
-rw-r--r--win32/console.h14
-rw-r--r--win32/cp_enc_map_gen.c9
-rw-r--r--win32/dllmain.c11
-rw-r--r--win32/fnmatch.c9
-rw-r--r--win32/fnmatch.h9
-rw-r--r--win32/ftok.c12
-rw-r--r--win32/getrusage.c11
-rw-r--r--win32/getrusage.h11
-rw-r--r--win32/glob.c9
-rw-r--r--win32/glob.h9
-rw-r--r--win32/globals.c11
-rw-r--r--win32/grp.h11
-rw-r--r--win32/inet.c11
-rw-r--r--win32/inet.h11
-rw-r--r--win32/ioutil.c404
-rw-r--r--win32/ioutil.h186
-rw-r--r--win32/ipc.h11
-rw-r--r--win32/nice.c11
-rw-r--r--win32/nice.h11
-rw-r--r--win32/param.h9
-rw-r--r--win32/php7dllts.rc126
-rw-r--r--win32/php7dllts.rc261
-rw-r--r--win32/php7ts.rc126
-rw-r--r--win32/php7ts.rc261
-rw-r--r--win32/php7ts_cli.rc126
-rw-r--r--win32/php7ts_cli.rc261
-rw-r--r--win32/php_inttypes.h9
-rw-r--r--win32/php_registry.h11
-rw-r--r--win32/php_stdbool.h20
-rw-r--r--win32/php_stdint.h9
-rw-r--r--win32/php_win32_globals.h11
-rw-r--r--win32/readdir.c49
-rw-r--r--win32/readdir.h12
-rw-r--r--win32/registry.c11
-rw-r--r--win32/resource.h29
-rw-r--r--win32/select.c13
-rw-r--r--win32/select.h11
-rw-r--r--win32/sendmail.c16
-rw-r--r--win32/sendmail.h9
-rw-r--r--win32/signal.c164
-rw-r--r--win32/signal.h14
-rw-r--r--win32/sockets.c11
-rw-r--r--win32/sockets.h11
-rw-r--r--win32/syslog.h11
-rw-r--r--win32/syslog.reg5
-rw-r--r--win32/time.c9
-rw-r--r--win32/time.h9
-rw-r--r--win32/unistd.h9
-rw-r--r--win32/winutil.c100
-rw-r--r--win32/winutil.h16
-rw-r--r--win32/wsyslog.c8
66 files changed, 1455 insertions, 1690 deletions
diff --git a/win32/build/Makefile b/win32/build/Makefile
index d52f3ef5b0..9435df5c46 100644
--- a/win32/build/Makefile
+++ b/win32/build/Makefile
@@ -1,7 +1,7 @@
# +----------------------------------------------------------------------+
# | PHP Version 7 |
# +----------------------------------------------------------------------+
-# | Copyright (c) 1997-2018 The PHP Group |
+# | 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 |
@@ -193,7 +193,7 @@ run: set-tmp-env
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" $(ARGS)
!else
test: set-tmp-env
- $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) -d open_basedir= -d output_buffering=0 -d memory_limit=-1 run-tests.php -p "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(TESTS)
+ $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -d open_basedir= -d output_buffering=0 -d memory_limit=-1 run-tests.php -p "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(TESTS)
run: set-tmp-env
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(ARGS)
@@ -229,7 +229,6 @@ snap: build-snap build-devel build-dist
$(BUILD_DIR)\deplister.exe: win32\build\deplister.c
$(CC) /nologo /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
-# need to redirect, since INSTALL is a file in the root...
install: really-install install-sdk
build-lib: build-ext-libs
@@ -265,3 +264,4 @@ really-install:
@echo Registering event source with syslog (requires admin rights)
@echo It's okay for this step to fail:
-$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL)
+ -regedit /s win32\syslog.reg
diff --git a/win32/build/buildconf.js b/win32/build/buildconf.js
index d928023994..5a45e481fc 100644
--- a/win32/build/buildconf.js
+++ b/win32/build/buildconf.js
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index 6ea1c57540..fcb98704f4 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -232,14 +232,17 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
zend_llist.c zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c \
zend_stack.c zend_variables.c zend.c zend_API.c zend_extensions.c \
zend_hash.c zend_list.c zend_builtin_functions.c \
- zend_sprintf.c zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \
+ zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \
zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \
zend_object_handlers.c zend_objects_API.c \
- zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \
+ zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c zend_weakrefs.c \
zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \
zend_inheritance.c zend_smart_str.c zend_cpuinfo.c");
ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+if (VS_TOOLSET && VCVERS >= 1914) {
+ ADD_FLAG("CFLAGS_BD_ZEND", "/d2FuncCache1");
+}
/* XXX inspect this for other toolsets */
//AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
@@ -247,22 +250,31 @@ ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
- php_open_temporary_file.c output.c internal_functions.c php_sprintf.c \
+ php_open_temporary_file.c output.c internal_functions.c \
php_syslog.c");
ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+if (VS_TOOLSET && VCVERS >= 1914) {
+ ADD_FLAG("CFLAGS_BD_MAIN", "/d2FuncCache1");
+}
AC_DEFINE('HAVE_STRNLEN', 1);
ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \
userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c");
ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+if (VS_TOOLSET && VCVERS >= 1914) {
+ ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/d2FuncCache1");
+}
ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
getrusage.c ftok.c ioutil.c codepage.c nice.c \
- inet.c fnmatch.c sockets.c console.c");
+ inet.c fnmatch.c sockets.c console.c signal.c");
ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+if (VS_TOOLSET && VCVERS >= 1914) {
+ ADD_FLAG("CFLAGS_BD_WIN32", "/d2FuncCache1");
+}
PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/");
@@ -288,9 +300,6 @@ AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
-AC_DEFINE('HAVE_USLEEP', 1);
-AC_DEFINE('HAVE_STRCOLL', 1);
-
/* For snapshot builders, where can we find the additional
* files that make up the snapshot template? */
ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");
@@ -319,7 +328,7 @@ if (CLANG_TOOLSET) {
"-Wno-unused-command-line-argument -Wno-unused-function -Wno-ignored-pragma-optimize");
}
- ARG_ENABLE("sanitizer", "Enable address sanitizer extension", "no");
+ ARG_ENABLE("sanitizer", "Enable ASan and UBSan extensions", "no");
if (PHP_SANITIZER == "yes") {
if (COMPILER_NUMERIC_VERSION < 500) {
ERROR("Clang at least 5.0.0 required for sanitation plugins");
diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in
index 0cf8a11959..5c093f5f86 100644
--- a/win32/build/config.w32.h.in
+++ b/win32/build/config.w32.h.in
@@ -28,7 +28,6 @@
/* Platform-Specific Configuration. Should not be changed. */
#define PHP_SIGCHILD 0
-#define HAVE_LIBBIND 1
#define HAVE_GETSERVBYNAME 1
#define HAVE_GETSERVBYPORT 1
#define HAVE_GETPROTOBYNAME 1
@@ -40,7 +39,6 @@
#define HAVE_ERRMSG_H 0
#undef HAVE_ADABAS
#undef HAVE_SOLID
-#undef HAVE_LINK
#undef HAVE_SYMLINK
/* its in win32/time.c */
@@ -48,9 +46,7 @@
#define HAVE_NANOSLEEP 1
#define PHP_SLEEP_NON_VOID 1
-#define HAVE_GETHOSTNAME 1
#define HAVE_GETCWD 1
-#define HAVE_POSIX_READDIR_R 1
#define NEED_ISBLANK 1
#define DISCARD_PATH 0
#undef HAVE_SETITIMER
@@ -59,69 +55,42 @@
#define HAVE_LIBDL 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_PUTENV 1
-#define HAVE_LIMITS_H 1
#define HAVE_TZSET 1
-#define HAVE_TZNAME 1
#undef HAVE_FLOCK
#define HAVE_ALLOCA 1
#undef HAVE_SYS_TIME_H
-#define HAVE_SIGNAL_H 1
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
-#undef HAVE_ST_BLOCKS
+#undef HAVE_STRUCT_STAT_ST_BLOCKS
#define HAVE_STRUCT_STAT_ST_RDEV 1
-#define HAVE_UTIME_NULL 1
-#define HAVE_VPRINTF 1
-#define STDC_HEADERS 1
#define REGEX 1
#define HSREGEX 1
-#define HAVE_GCVT 1
#define HAVE_GETLOGIN 1
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
-#define HAVE_PUTENV 1
#define HAVE_REGCOMP 1
-#define HAVE_SETLOCALE 1
-#define HAVE_LOCALECONV 1
#define HAVE_LOCALE_H 1
-#ifndef HAVE_LIBBIND
-# define HAVE_SETVBUF 1
-#endif
#define HAVE_SHUTDOWN 1
-#define HAVE_SNPRINTF 1
-#define HAVE_VSNPRINTF 1
#define HAVE_STRCASECMP 1
-#define HAVE_STRDUP 1
-#define HAVE_STRERROR 1
-#define HAVE_STRSTR 1
-#define HAVE_TEMPNAM 1
#define HAVE_UTIME 1
#undef HAVE_DIRENT_H
-#define HAVE_ASSERT_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GRP_H 0
#undef HAVE_PWD_H
-#define HAVE_STRING_H 1
#undef HAVE_SYS_FILE_H
#undef HAVE_SYS_SOCKET_H
#undef HAVE_SYS_WAIT_H
#define HAVE_SYSLOG_H 1
#undef HAVE_UNISTD_H
#define HAVE_SYS_TYPES_H 1
-#define HAVE_STDARG_H 1
#undef HAVE_ALLOCA_H
#undef HAVE_KILL
#define HAVE_GETPID 1
#define HAVE_LIBM 1
-#define HAVE_CUSERID 0
#undef HAVE_RINT
-#define HAVE_STRFTIME 1
#define SIZEOF_SHORT 2
-/* int and long are stll 32bit in 64bit compiles */
+/* int and long are still 32bit in 64bit compiles */
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
/* MSVC.6/NET don't allow 'long long' or know 'intmax_t' */
-#define SIZEOF_LONG_LONG_INT 0
#define SIZEOF_LONG_LONG 8 /* defined as __int64 */
#define SIZEOF_INTMAX_T 0
#define ssize_t SSIZE_T
@@ -132,15 +101,13 @@
# define SIZEOF_SIZE_T 4
# define SIZEOF_PTRDIFF_T 4
#endif
+#define SIZEOF_OFF_T 4
#define HAVE_FNMATCH
#define HAVE_GLOB
#define PHP_SHLIB_SUFFIX "dll"
#define PHP_SHLIB_EXT_PREFIX "php_"
#define HAVE_SQLDATASOURCES
-/* Win32 supports strcoll */
-#define HAVE_STRCOLL 1
-
/* Win32 supports socketpair by the emulation in win32/sockets.c */
#define HAVE_SOCKETPAIR 1
#define HAVE_SOCKLEN_T 1
@@ -164,7 +131,6 @@
#ifndef _WIN64
# define _USE_32BIT_TIME_T 1
#endif
-#define HAVE_STDLIB_H 1
#define _REENTRANT 1
#define HAVE_MBRLEN 1
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index 96d9b887b6..2fe2039afe 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -3,7 +3,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -35,7 +35,8 @@ var VCVERS = -1;
var CLANGVERS = -1;
var INTELVERS = -1;
var COMPILER_NUMERIC_VERSION = -1;
-var COMPILER_NAME = "unknown";
+var COMPILER_NAME_LONG = "unknown";
+var COMPILER_NAME_SHORT = "unknown";
var PHP_OBJECT_OUT_DIR = "";
var PHP_CONFIG_PROFILE = "no";
var PHP_SANITIZER = "no";
@@ -71,31 +72,6 @@ var headers_install = new Array();
/* Store unknown configure options */
var INVALID_CONFIG_ARGS = new Array();
-/* Mapping CL version > human readable name */
-var VC_VERSIONS = new Array();
-VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)';
-VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)';
-VC_VERSIONS[1900] = 'MSVC14 (Visual C++ 2015)';
-VC_VERSIONS[1910] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1911] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1912] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1913] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1914] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1915] = 'MSVC15 (Visual C++ 2017)';
-VC_VERSIONS[1916] = 'MSVC15 (Visual C++ 2017)';
-
-var VC_VERSIONS_SHORT = new Array();
-VC_VERSIONS_SHORT[1700] = 'VC11';
-VC_VERSIONS_SHORT[1800] = 'VC12';
-VC_VERSIONS_SHORT[1900] = 'VC14';
-VC_VERSIONS_SHORT[1910] = 'VC15';
-VC_VERSIONS_SHORT[1911] = 'VC15';
-VC_VERSIONS_SHORT[1912] = 'VC15';
-VC_VERSIONS_SHORT[1913] = 'VC15';
-VC_VERSIONS_SHORT[1914] = 'VC15';
-VC_VERSIONS_SHORT[1915] = 'VC15';
-VC_VERSIONS_SHORT[1916] = 'VC15';
-
if (PROGRAM_FILES == null) {
PROGRAM_FILES = "C:\\Program Files";
}
@@ -106,7 +82,7 @@ if (MODE_PHPIZE) {
WScript.Quit(10);
}
} else {
- if (!FSO.FileExists("README.GIT-RULES")) {
+ if (!FSO.FileExists("main\\php_version.h")) {
STDERR.WriteLine("Must be run from the root of the php source");
WScript.Quit(10);
}
@@ -115,38 +91,31 @@ if (MODE_PHPIZE) {
var CWD = WshShell.CurrentDirectory;
if (typeof(CWD) == "undefined") {
- CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.GIT-RULES"));
+ CWD = FSO.GetParentFolderName(FSO.GetParentFolderName(FSO.GetAbsolutePathName("main\\php_version.h")));
}
/* defaults; we pick up the precise versions from configure.ac */
var PHP_VERSION = 7;
-var PHP_MINOR_VERSION = 3;
+var PHP_MINOR_VERSION = 4;
var PHP_RELEASE_VERSION = 0;
var PHP_EXTRA_VERSION = "";
-var PHP_VERSION_STRING = "7.3.0";
+var PHP_VERSION_STRING = "7.4.0";
/* Get version numbers and DEFINE as a string */
function get_version_numbers()
{
var cin = file_get_contents("configure.ac");
+ var regex = /AC_INIT.+(\d+)\.(\d+)\.(\d+)([^\,^\]]*).+/g;
- if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) {
+ if (cin.match(new RegExp(regex))) {
PHP_VERSION = RegExp.$1;
+ PHP_MINOR_VERSION = RegExp.$2;
+ PHP_RELEASE_VERSION = RegExp.$3;
+ PHP_EXTRA_VERSION = RegExp.$4;
}
- if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) {
- PHP_MINOR_VERSION = RegExp.$1;
- }
- if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) {
- PHP_RELEASE_VERSION = RegExp.$1;
- }
- PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION;
- if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) {
- PHP_EXTRA_VERSION = RegExp.$1;
- if (PHP_EXTRA_VERSION.length) {
- PHP_VERSION_STRING += PHP_EXTRA_VERSION;
- }
- }
+ PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION + PHP_EXTRA_VERSION;
+
DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING);
}
@@ -462,6 +431,10 @@ can be built that way. \
}
STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext));
}
+ STDOUT.WriteBlankLines(1);
+ STDOUT.WriteLine("Some influential environment variables:");
+ STDOUT.WriteLine(" CFLAGS C compiler flags");
+ STDOUT.WriteLine(" LDFLAGS linker flags");
WScript.Quit(1);
}
@@ -1264,10 +1237,16 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /GENPROFILE");
+ if (VCVERS >= 1914) {
+ ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
+ }
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG /USEPROFILE");
+ if (VCVERS >= 1914) {
+ ADD_FLAG('LDFLAGS_' + SAPI, "/d2:-FuncCache1");
+ }
}
ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
@@ -1470,9 +1449,15 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /GENPROFILE");
+ if (VCVERS >= 1914) {
+ ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
+ }
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('LDFLAGS_' + EXT, "/LTCG /USEPROFILE");
+ if (VCVERS >= 1914) {
+ ADD_FLAG('LDFLAGS_' + EXT, "/d2:-FuncCache1");
+ }
}
ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");
@@ -1963,7 +1948,7 @@ function write_summary()
}
ar[k++] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"];
ar[k++] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"];
- ar[k++] = ['Compiler', COMPILER_NAME];
+ ar[k++] = ['Compiler', COMPILER_NAME_LONG];
ar[k++] = ['Architecture', X64 ? 'x64' : 'x86'];
if (PHP_PGO == "yes") {
ar[k++] = ['Optimization', "PGO"];
@@ -2037,6 +2022,19 @@ function generate_tmp_php_ini()
if (!is_on_exclude_list_for_test_ini(ext_list, ext_name)) {
INI.WriteLine(directive + "=php_" + ext_name + ".dll");
+
+ if ("opcache" == ext_name) {
+ var dir = get_define("BUILD_DIR") + "\\" + "test_file_cache";
+ if (FSO.FolderExists(dir)) {
+ STDOUT.Write(execute("powershell -Command Remove-Item -path \"\\\\?\\" + dir + "\" -recurse"));
+ }
+ FSO.CreateFolder(dir);
+
+ /* Fallback is implied, if filecache is enabled. */
+ INI.WriteLine("opcache.file_cache=" + dir);
+ INI.WriteLine("opcache.enable=1");
+ INI.WriteLine("opcache.enable_cli=1");
+ }
}
}
@@ -2931,56 +2929,41 @@ function toolset_setup_compiler()
}
COMPILER_NUMERIC_VERSION = toolset_get_compiler_version();
- COMPILER_NAME = toolset_get_compiler_name();
+ COMPILER_NAME_LONG = toolset_get_compiler_name();
+ COMPILER_NAME_SHORT = toolset_get_compiler_name(true);
if (VS_TOOLSET) {
- /* For the record here: */
- // 1200 is VC6
- // 1300 is vs.net 2002
- // 1310 is vs.net 2003
- // 1400 is vs.net 2005
- // 1500 is vs.net 2008
- // 1600 is vs.net 2010
- // 1700 is vs.net 2011
- // 1800 is vs.net 2012
- // 1900 is vs.net 2015
- // 1910 is vs.net 2017
- // Which version of the compiler do we have?
VCVERS = COMPILER_NUMERIC_VERSION;
- if (VCVERS < 1700) {
- ERROR("Unsupported MS C++ Compiler, VC11 (2011) minimum is required");
- }
-
- if (undefined == COMPILER_NAME) {
+ if ("unknown" == COMPILER_NAME_LONG) {
var tmp = probe_binary(PHP_CL);
- COMPILER_NAME = "MSVC " + tmp + ", untested";
+ COMPILER_NAME_LONG = COMPILER_NAME_SHORT = "MSVC " + tmp + ", untested";
WARNING("Using unknown MSVC version " + tmp);
- AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+ AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", tmp);
AC_DEFINE('PHP_COMPILER_ID', tmp, "Compiler compatibility ID");
} else {
- AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
- DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
- AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
+ AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
+ DEFINE("PHP_COMPILER_SHORT", COMPILER_NAME_SHORT.toLowerCase());
+ AC_DEFINE('PHP_COMPILER_ID', COMPILER_NAME_SHORT.toUpperCase(), "Compiler compatibility ID");
}
} else if (CLANG_TOOLSET) {
CLANGVERS = COMPILER_NUMERIC_VERSION;
- AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+ AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "clang");
AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */
} else if (ICC_TOOLSET) {
INTELVERS = COMPILER_NUMERIC_VERSION;
- AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
+ AC_DEFINE('COMPILER', COMPILER_NAME_LONG, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "icc");
AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */
}
- STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME);
+ STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME_LONG);
}
function toolset_setup_project_tools()
@@ -3017,7 +3000,7 @@ function toolset_setup_project_tools()
ERROR('sed is required')
}
- RE2C = PATH_PROG('re2c');
+ var RE2C = PATH_PROG('re2c');
if (RE2C) {
var RE2CVERS = probe_binary(RE2C, "version");
STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
@@ -3105,17 +3088,32 @@ function toolset_get_compiler_version()
}
/* Get compiler name if the toolset is supported */
-function toolset_get_compiler_name()
+function toolset_get_compiler_name(short)
{
var version;
+ short = !!short;
if (VS_TOOLSET) {
- var name = undefined;
+ var name = "unknown";
version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
- if (undefined != VC_VERSIONS[version]) {
- name = VC_VERSIONS[version];
+ if (version >= 1930) {
+ return name;
+ } if (version >= 1920) {
+ /* NOTE - VS is intentional. Due to changes in recent Visual Studio
+ versioning scheme refering to the exact VC++ version is
+ hardly predictable. From this version on, it refers to
+ Visual Studio version and implies the default toolset.
+ When new versions are introduced, adapt also checks in
+ php_win32_image_compatible(), if needed. */
+ name = short ? "VS16" : "Visual C++ 2019";
+ } else if (version >= 1910) {
+ name = short ? "VC15" : "Visual C++ 2017";
+ } else if (version >= 1900) {
+ name = short ? "VC14" : "Visual C++ 2015";
+ } else {
+ ERROR("Unsupported Visual C++ compiler " + version);
}
return name;
@@ -3186,20 +3184,35 @@ function toolset_setup_codegen_arch()
function toolset_setup_linker()
{
+ var lnk = false;
if (VS_TOOLSET) {
- return PATH_PROG('link', null);
+ lnk = PATH_PROG('link', null);
} else if (CLANG_TOOLSET) {
//return PATH_PROG('lld', WshShell.Environment("Process").Item("PATH"), "LINK");
- return PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
+ lnk = PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
} else if (ICC_TOOLSET) {
- return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK");
+ lnk = PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK");
}
- ERROR("Unsupported toolset");
+ if (!lnk) {
+ ERROR("Unsupported toolset");
+ }
+
+ var ver = probe_binary(lnk);
+
+ var major = ver.substr(0, 2);
+ var minor = ver.substr(3, 2);
+
+ AC_DEFINE('PHP_LINKER_MAJOR', major, "Linker major version", false);
+ AC_DEFINE('PHP_LINKER_MINOR', minor, "Linker minor version", false);
+
+ return lnk;
}
function toolset_setup_common_cflags()
{
+ var envCFLAGS = WshShell.Environment("PROCESS").Item("CFLAGS");
+
// CFLAGS for building the PHP dll
DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \
/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER);
@@ -3211,6 +3224,10 @@ function toolset_setup_common_cflags()
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 \
/D _USE_MATH_DEFINES");
+ if (envCFLAGS) {
+ ADD_FLAG("CFLAGS", envCFLAGS);
+ }
+
if (VS_TOOLSET) {
ADD_FLAG("CFLAGS", " /FD ");
@@ -3265,6 +3282,12 @@ function toolset_setup_common_cflags()
/* This is only in effect for CXX sources, __cplusplus is not defined in C sources. */
ADD_FLAG("CFLAGS", "/Zc:__cplusplus");
}
+
+ if (VCVERS >= 1914) {
+ ADD_FLAG("CFLAGS", "/d2FuncCache1");
+ }
+
+ ADD_FLAG("CFLAGS", "/Zc:wchar_t");
} else if (CLANG_TOOLSET) {
if (X64) {
ADD_FLAG('CFLAGS', '-m64');
@@ -3355,6 +3378,8 @@ function toolset_setup_intrinsic_cflags()
function toolset_setup_common_ldlags()
{
+ var envLDFLAGS = WshShell.Environment("PROCESS").Item("LDFLAGS");
+
// General DLL link flags
DEFINE("DLL_LDFLAGS", "/dll ");
@@ -3363,6 +3388,10 @@ function toolset_setup_common_ldlags()
DEFINE("LDFLAGS", "/nologo ");
+ if (envLDFLAGS) {
+ ADD_FLAG("LDFLAGS", envLDFLAGS);
+ }
+
// we want msvcrt in the PHP DLL
ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt");
@@ -3378,7 +3407,7 @@ function toolset_setup_common_ldlags()
function toolset_setup_common_libs()
{
// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
- DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib");
+ DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib psapi.lib bcrypt.lib imagehlp.lib");
}
function toolset_setup_build_mode()
@@ -3396,8 +3425,13 @@ function toolset_setup_build_mode()
ADD_FLAG("CFLAGS", "/Zi");
ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf");
}
- // Equivalent to Release_TSInline build -> best optimization
- ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
+ ADD_FLAG("CFLAGS", "/LD /MD /W3");
+ if (PHP_SANITIZER == "yes" && CLANG_TOOLSET) {
+ ADD_FLAG("CFLAGS", "/Od /D NDebug /D NDEBUG /D ZEND_WIN32_NEVER_INLINE /D ZEND_DEBUG=0");
+ } else {
+ // Equivalent to Release_TSInline build -> best optimization
+ ADD_FLAG("CFLAGS", "/Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
+ }
// if you have VS.Net /GS hardens the binary against buffer overruns
// ADD_FLAG("CFLAGS", "/GS");
@@ -3598,6 +3632,15 @@ function SETUP_OPENSSL(target, path_to_check, common_name, use_env, add_dir_part
return ret;
}
+function SETUP_SQLITE3(target, path_to_check, shared) {
+ var cflags_var = "CFLAGS_" + target.toUpperCase();
+ var libs = (shared ? "libsqlite3.lib;libsqlite3_a.lib" : "libsqlite3_a.lib;libsqlite3.lib");
+
+ return CHECK_LIB(libs, target, path_to_check) &&
+ CHECK_HEADER_ADD_INCLUDE("sqlite3.h", cflags_var) &&
+ CHECK_HEADER_ADD_INCLUDE("sqlite3ext.h", cflags_var);
+}
+
function check_binary_tools_sdk()
{
var BIN_TOOLS_SDK_VER_MAJOR = 0;
@@ -3623,7 +3666,7 @@ function get_clang_lib_dir()
var ret = null;
var ver = null;
- if (COMPILER_NAME.match(/clang version ([\d\.]+) \((.*)\)/)) {
+ if (COMPILER_NAME_LONG.match(/clang version ([\d\.]+) \((.*)\)/)) {
ver = RegExp.$1;
} else {
ERROR("Faled to determine clang lib path");
@@ -3656,15 +3699,14 @@ function add_asan_opts(cflags_name, libs_name, ldflags_name)
var ver = null;
- if (COMPILER_NAME.match(/clang version ([\d\.]+) \((.*)\)/)) {
+ if (COMPILER_NAME_LONG.match(/clang version ([\d\.]+) \((.*)\)/)) {
ver = RegExp.$1;
} else {
ERROR("Faled to determine clang lib path");
}
if (!!cflags_name) {
- ADD_FLAG(cflags_name, "-fsanitize=address");
- ADD_FLAG(cflags_name, "-fsanitize-address-use-after-scope");
+ ADD_FLAG(cflags_name, "-fsanitize=address,undefined");
}
if (!!libs_name) {
if (X64) {
diff --git a/win32/build/deplister.c b/win32/build/deplister.c
index 19966b195e..b5dd059c98 100644
--- a/win32/build/deplister.c
+++ b/win32/build/deplister.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -48,12 +48,3 @@ int main(int argc, char *argv[])
return BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES,
argv[1], NULL, argv[2], StatusRoutine);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php
index 00d626a0db..84b69970a4 100644
--- a/win32/build/mkdist.php
+++ b/win32/build/mkdist.php
@@ -31,136 +31,136 @@ $pecl_dll_deps = array();
function get_depends($module)
{
- static $no_dist = array(
- /* windows system dlls that should not be bundled */
- 'advapi32.dll', 'comdlg32.dll', 'crypt32.dll', 'gdi32.dll', 'kernel32.dll', 'ntdll.dll',
- 'odbc32.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll',
- 'shell32.dll', 'shlwapi.dll', 'user32.dll', 'ws2_32.dll', 'ws2help.dll',
- 'comctl32.dll', 'winmm.dll', 'wsock32.dll', 'winspool.drv', 'msasn1.dll',
- 'secur32.dll', 'netapi32.dll', 'dnsapi.dll', 'psapi.dll', 'normaliz.dll',
- 'iphlpapi.dll', 'bcrypt.dll',
-
- /* apache */
- 'apachecore.dll',
-
- /* apache 2 */
- 'libhttpd.dll', 'libapr.dll', 'libaprutil.dll','libapr-1.dll', 'libaprutil-1.dll',
-
- /* oracle */
- 'oci.dll', 'ociw32.dll',
-
- /* sybase */
- 'libcs.dll', 'libct.dll',
-
- /* firebird */
- 'fbclient.dll',
-
- /* visual C++; mscvrt.dll is present on everyones system,
- * but the debug version (msvcrtd.dll) and those from visual studio.net
- * (msvcrt7x.dll) are not */
- 'msvcrt.dll',
- 'msvcr90.dll',
- 'wldap32.dll',
- 'vcruntime140.dll',
- 'msvcp140.dll',
- );
- static $no_dist_re = array(
- "api-ms-win-crt-.+\.dll",
- );
- global $build_dir, $extra_dll_deps, $ext_targets, $sapi_targets, $pecl_targets, $phpdll, $per_module_deps, $pecl_dll_deps;
-
- $bd = strtolower(realpath($build_dir));
-
- $is_pecl = in_array($module, $pecl_targets);
-
- $cmd = "$GLOBALS[build_dir]\\deplister.exe \"$module\" \"$GLOBALS[build_dir]\"";
- $proc = proc_open($cmd,
- array(1 => array("pipe", "w")),
- $pipes);
-
- $n = 0;
- while (($line = fgetcsv($pipes[1]))) {
- $n++;
-
- $dep = strtolower($line[0]);
- $depbase = basename($dep);
- /* ignore stuff in our build dir, but only if it is
- * one of our targets */
- if (((in_array($depbase, $sapi_targets) ||
- in_array($depbase, $ext_targets) || in_array($depbase, $pecl_targets)) ||
- $depbase == $phpdll) && file_exists($GLOBALS['build_dir'] . "/$depbase")) {
- continue;
- }
- /* ignore some well-known system dlls */
- if (in_array(basename($dep), $no_dist)) {
- continue;
- } else {
- $skip = false;
- foreach ($no_dist_re as $re) {
- if (preg_match(",$re,", basename($dep)) > 0) {
- $skip = true;
- break;
- }
- }
- if ($skip) {
- continue;
- }
- }
-
- if ($is_pecl) {
- if (!in_array($dep, $pecl_dll_deps)) {
- $pecl_dll_deps[] = $dep;
- }
- } else {
- if (!in_array($dep, $extra_dll_deps)) {
- $extra_dll_deps[] = $dep;
- }
- }
-
- if (!isset($per_module_deps[basename($module)]) || !in_array($dep, $per_module_deps[basename($module)])) {
- $per_module_deps[basename($module)][] = $dep;
- //recursively check dll dependencies
- get_depends($dep);
- }
- }
- fclose($pipes[1]);
- proc_close($proc);
+ static $no_dist = array(
+ /* windows system dlls that should not be bundled */
+ 'advapi32.dll', 'comdlg32.dll', 'crypt32.dll', 'gdi32.dll', 'kernel32.dll', 'ntdll.dll',
+ 'odbc32.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll',
+ 'shell32.dll', 'shlwapi.dll', 'user32.dll', 'ws2_32.dll', 'ws2help.dll',
+ 'comctl32.dll', 'winmm.dll', 'wsock32.dll', 'winspool.drv', 'msasn1.dll',
+ 'secur32.dll', 'netapi32.dll', 'dnsapi.dll', 'psapi.dll', 'normaliz.dll',
+ 'iphlpapi.dll', 'bcrypt.dll',
+
+ /* apache */
+ 'apachecore.dll',
+
+ /* apache 2 */
+ 'libhttpd.dll', 'libapr.dll', 'libaprutil.dll','libapr-1.dll', 'libaprutil-1.dll',
+
+ /* oracle */
+ 'oci.dll', 'ociw32.dll',
+
+ /* sybase */
+ 'libcs.dll', 'libct.dll',
+
+ /* firebird */
+ 'fbclient.dll',
+
+ /* visual C++; mscvrt.dll is present on everyones system,
+ * but the debug version (msvcrtd.dll) and those from visual studio.net
+ * (msvcrt7x.dll) are not */
+ 'msvcrt.dll',
+ 'msvcr90.dll',
+ 'wldap32.dll',
+ 'vcruntime140.dll',
+ 'msvcp140.dll',
+ );
+ static $no_dist_re = array(
+ "api-ms-win-crt-.+\.dll",
+ );
+ global $build_dir, $extra_dll_deps, $ext_targets, $sapi_targets, $pecl_targets, $phpdll, $per_module_deps, $pecl_dll_deps;
+
+ $bd = strtolower(realpath($build_dir));
+
+ $is_pecl = in_array($module, $pecl_targets);
+
+ $cmd = "$GLOBALS[build_dir]\\deplister.exe \"$module\" \"$GLOBALS[build_dir]\"";
+ $proc = proc_open($cmd,
+ array(1 => array("pipe", "w")),
+ $pipes);
+
+ $n = 0;
+ while (($line = fgetcsv($pipes[1]))) {
+ $n++;
+
+ $dep = strtolower($line[0]);
+ $depbase = basename($dep);
+ /* ignore stuff in our build dir, but only if it is
+ * one of our targets */
+ if (((in_array($depbase, $sapi_targets) ||
+ in_array($depbase, $ext_targets) || in_array($depbase, $pecl_targets)) ||
+ $depbase == $phpdll) && file_exists($GLOBALS['build_dir'] . "/$depbase")) {
+ continue;
+ }
+ /* ignore some well-known system dlls */
+ if (in_array(basename($dep), $no_dist)) {
+ continue;
+ } else {
+ $skip = false;
+ foreach ($no_dist_re as $re) {
+ if (preg_match(",$re,", basename($dep)) > 0) {
+ $skip = true;
+ break;
+ }
+ }
+ if ($skip) {
+ continue;
+ }
+ }
+
+ if ($is_pecl) {
+ if (!in_array($dep, $pecl_dll_deps)) {
+ $pecl_dll_deps[] = $dep;
+ }
+ } else {
+ if (!in_array($dep, $extra_dll_deps)) {
+ $extra_dll_deps[] = $dep;
+ }
+ }
+
+ if (!isset($per_module_deps[basename($module)]) || !in_array($dep, $per_module_deps[basename($module)])) {
+ $per_module_deps[basename($module)][] = $dep;
+ //recursively check dll dependencies
+ get_depends($dep);
+ }
+ }
+ fclose($pipes[1]);
+ proc_close($proc);
//echo "Module $module [$n lines]\n";
}
function copy_file_list($source_dir, $dest_dir, $list)
{
- global $is_debug, $dist_dir;
-
- foreach ($list as $item) {
- if (empty($item)) {
- continue;
- } elseif (!is_file($source_dir . DIRECTORY_SEPARATOR . $item)) {
- echo "WARNING: $item not found\n";
- continue;
- }
-
- echo "Copying $item from $source_dir to $dest_dir\n";
- copy($source_dir . DIRECTORY_SEPARATOR . $item, $dest_dir . DIRECTORY_SEPARATOR . $item);
- if ($is_debug) {
- $itemdb = preg_replace("/\.(exe|dll|lib)$/i", ".pdb", $item);
- if (file_exists("$source_dir/$itemdb")) {
- copy("$source_dir/$itemdb", "$dist_dir/dev/$itemdb");
- }
- }
- if (preg_match("/\.(exe|dll)$/i", $item)) {
- get_depends($source_dir . '/' . $item);
- }
- }
+ global $is_debug, $dist_dir;
+
+ foreach ($list as $item) {
+ if (empty($item)) {
+ continue;
+ } elseif (!is_file($source_dir . DIRECTORY_SEPARATOR . $item)) {
+ echo "WARNING: $item not found\n";
+ continue;
+ }
+
+ echo "Copying $item from $source_dir to $dest_dir\n";
+ copy($source_dir . DIRECTORY_SEPARATOR . $item, $dest_dir . DIRECTORY_SEPARATOR . $item);
+ if ($is_debug) {
+ $itemdb = preg_replace("/\.(exe|dll|lib)$/i", ".pdb", $item);
+ if (file_exists("$source_dir/$itemdb")) {
+ copy("$source_dir/$itemdb", "$dist_dir/dev/$itemdb");
+ }
+ }
+ if (preg_match("/\.(exe|dll)$/i", $item)) {
+ get_depends($source_dir . '/' . $item);
+ }
+ }
}
function copy_text_file($source, $dest)
{
- $text = file_get_contents($source);
- $text = preg_replace("/(\r\n?)|\n/", "\r\n", $text);
- $fp = fopen($dest, "w");
- fwrite($fp, $text);
- fclose($fp);
+ $text = file_get_contents($source);
+ $text = preg_replace("/(\r\n?)|\n/", "\r\n", $text);
+ $fp = fopen($dest, "w");
+ fwrite($fp, $text);
+ fclose($fp);
}
/* very light-weight function to extract a single named file from
@@ -168,57 +168,57 @@ function copy_text_file($source, $dest)
* based on the PEAR info set in $packages. */
function extract_file_from_tarball($pkg, $filename, $dest_dir) /* {{{ */
{
- global $packages;
-
- $name = $pkg . '-' . $packages[$pkg];
- $tarball = $dest_dir . "/" . $name . '.tgz';
- $filename = $name . '/' . $filename;
- $destfilename = $dest_dir . "/" . basename($filename);
-
- $fp = gzopen($tarball, 'rb');
-
- $done = false;
- do {
- /* read the header */
- $hdr_data = gzread($fp, 512);
- if (strlen($hdr_data) == 0)
- break;
- $checksum = 0;
- for ($i = 0; $i < 148; $i++)
- $checksum += ord($hdr_data[$i]);
- for ($i = 148; $i < 156; $i++)
- $checksum += 32;
- for ($i = 156; $i < 512; $i++)
- $checksum += ord($hdr_data[$i]);
-
- $hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data);
-
- $hdr['checksum'] = octdec(trim($hdr['checksum']));
-
- if ($hdr['checksum'] != $checksum) {
- echo "Checksum for $tarball $hdr[filename] is invalid\n";
- print_r($hdr);
- return;
- }
-
- $hdr['size'] = octdec(trim($hdr['size']));
- echo "File: $hdr[filename] $hdr[size]\n";
-
- if ($filename == $hdr['filename']) {
- echo "Found the file we want\n";
- $dest = fopen($destfilename, 'wb');
- $x = stream_copy_to_stream($fp, $dest, $hdr['size']);
- fclose($dest);
- echo "Wrote $x bytes into $destfilename\n";
- break;
- }
-
- /* skip body of the file */
- $size = 512 * ceil((int)$hdr['size'] / 512);
- echo "Skipping $size bytes\n";
- gzseek($fp, gztell($fp) + $size);
-
- } while (!$done);
+ global $packages;
+
+ $name = $pkg . '-' . $packages[$pkg];
+ $tarball = $dest_dir . "/" . $name . '.tgz';
+ $filename = $name . '/' . $filename;
+ $destfilename = $dest_dir . "/" . basename($filename);
+
+ $fp = gzopen($tarball, 'rb');
+
+ $done = false;
+ do {
+ /* read the header */
+ $hdr_data = gzread($fp, 512);
+ if (strlen($hdr_data) == 0)
+ break;
+ $checksum = 0;
+ for ($i = 0; $i < 148; $i++)
+ $checksum += ord($hdr_data[$i]);
+ for ($i = 148; $i < 156; $i++)
+ $checksum += 32;
+ for ($i = 156; $i < 512; $i++)
+ $checksum += ord($hdr_data[$i]);
+
+ $hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data);
+
+ $hdr['checksum'] = octdec(trim($hdr['checksum']));
+
+ if ($hdr['checksum'] != $checksum) {
+ echo "Checksum for $tarball $hdr[filename] is invalid\n";
+ print_r($hdr);
+ return;
+ }
+
+ $hdr['size'] = octdec(trim($hdr['size']));
+ echo "File: $hdr[filename] $hdr[size]\n";
+
+ if ($filename == $hdr['filename']) {
+ echo "Found the file we want\n";
+ $dest = fopen($destfilename, 'wb');
+ $x = stream_copy_to_stream($fp, $dest, $hdr['size']);
+ fclose($dest);
+ echo "Wrote $x bytes into $destfilename\n";
+ break;
+ }
+
+ /* skip body of the file */
+ $size = 512 * ceil((int)$hdr['size'] / 512);
+ echo "Skipping $size bytes\n";
+ gzseek($fp, gztell($fp) + $size);
+
+ } while (!$done);
} /* }}} */
@@ -233,8 +233,8 @@ $phplib = str_replace(".dll", ".lib", $phpdll);
copy("$build_dir/$phplib", "$dist_dir/dev/$phplib");
/* debug builds; copy the symbols too */
if ($is_debug) {
- $phppdb = str_replace(".dll", ".pdb", $phpdll);
- copy("$build_dir/$phppdb", "$dist_dir/dev/$phppdb");
+ $phppdb = str_replace(".dll", ".pdb", $phpdll);
+ copy("$build_dir/$phppdb", "$dist_dir/dev/$phppdb");
}
/* copy the sapi */
copy_file_list($build_dir, "$dist_dir", $sapi_targets);
@@ -244,31 +244,30 @@ copy_file_list($build_dir, "$dist_dir/ext", $ext_targets);
/* pecl sapi and extensions */
if(sizeof($pecl_targets)) {
- copy_file_list($build_dir, $pecl_dir, $pecl_targets);
+ copy_file_list($build_dir, $pecl_dir, $pecl_targets);
}
/* populate reading material */
$text_files = array(
- "LICENSE" => "license.txt",
- "NEWS" => "news.txt",
- "INSTALL" => "install.txt",
- "README.REDIST.BINS" => "readme-redist-bins.txt",
- "php.ini-development" => "php.ini-development",
- "php.ini-production" => "php.ini-production"
+ "LICENSE" => "license.txt",
+ "NEWS" => "news.txt",
+ "README.md" => "README.md",
+ "README.REDIST.BINS" => "readme-redist-bins.txt",
+ "php.ini-development" => "php.ini-development",
+ "php.ini-production" => "php.ini-production"
);
foreach ($text_files as $src => $dest) {
- copy_text_file($src, $dist_dir . '/' . $dest);
+ copy_text_file($src, $dist_dir . '/' . $dest);
}
/* general other files */
$general_files = array(
- "php.gif" => "php.gif",
- "$GLOBALS[build_dir]\\deplister.exe" => "deplister.exe",
+ "$GLOBALS[build_dir]\\deplister.exe" => "deplister.exe",
);
foreach ($general_files as $src => $dest) {
- copy($src, $dist_dir . '/' . $dest);
+ copy($src, $dist_dir . '/' . $dest);
}
/* include a snapshot identifier */
@@ -290,40 +289,40 @@ $exts = get_loaded_extensions();
fprintf($fp, "\r\nBuilt-in Extensions\r\n");
fwrite($fp, "===========================\r\n");
foreach ($exts as $ext) {
- fprintf($fp, "%s\r\n", $ext);
+ fprintf($fp, "%s\r\n", $ext);
}
fwrite($fp, "\r\n\r\n");
/* list dependencies */
fprintf($fp, "Dependency information:\r\n");
foreach ($per_module_deps as $modulename => $deps) {
- if (in_array($modulename, $pecl_targets))
- continue;
-
- fprintf($fp, "Module: %s\r\n", $modulename);
- fwrite($fp, "===========================\r\n");
- foreach ($deps as $dll) {
- fprintf($fp, "\t%s\r\n", basename($dll));
- }
- fwrite($fp, "\r\n");
+ if (in_array($modulename, $pecl_targets))
+ continue;
+
+ fprintf($fp, "Module: %s\r\n", $modulename);
+ fwrite($fp, "===========================\r\n");
+ foreach ($deps as $dll) {
+ fprintf($fp, "\t%s\r\n", basename($dll));
+ }
+ fwrite($fp, "\r\n");
}
fclose($fp);
/* Now add those dependencies */
foreach ($extra_dll_deps as $dll) {
- if (!file_exists($dll)) {
- /* try template dir */
- $tdll = $snapshot_template . "/dlls/" . basename($dll);
- if (!file_exists($tdll)) {
- $tdll = $php_build_dir . '/bin/' . basename($dll);
- if (!file_exists($tdll)) {
- echo "WARNING: distro depends on $dll, but could not find it on your system\n";
- continue;
- }
- }
- $dll = $tdll;
- }
- copy($dll, "$dist_dir/" . basename($dll));
+ if (!file_exists($dll)) {
+ /* try template dir */
+ $tdll = $snapshot_template . "/dlls/" . basename($dll);
+ if (!file_exists($tdll)) {
+ $tdll = $php_build_dir . '/bin/' . basename($dll);
+ if (!file_exists($tdll)) {
+ echo "WARNING: distro depends on $dll, but could not find it on your system\n";
+ continue;
+ }
+ }
+ $dll = $tdll;
+ }
+ copy($dll, "$dist_dir/" . basename($dll));
}
/* TODO:
@@ -334,168 +333,168 @@ deps. For example, libenchant.dll loads libenchant_myspell.dll or
libenchant_ispell.dll
*/
$ENCHANT_DLLS = array(
- array('', 'glib-2.dll'),
- array('', 'gmodule-2.dll'),
- array('lib/enchant', 'libenchant_myspell.dll'),
- array('lib/enchant', 'libenchant_ispell.dll'),
+ array('', 'glib-2.dll'),
+ array('', 'gmodule-2.dll'),
+ array('lib/enchant', 'libenchant_myspell.dll'),
+ array('lib/enchant', 'libenchant_ispell.dll'),
);
foreach ($ENCHANT_DLLS as $dll) {
- $dest = "$dist_dir/$dll[0]";
- $filename = $dll[1];
-
- if (!file_exists("$dest") || !is_dir("$dest")) {
- if (!mkdir("$dest", 0777, true)) {
- echo "WARNING: couldn't create '$dest' for enchant plugins ";
- }
- }
-
- if (!copy($php_build_dir . '/bin/' . $filename, "$dest/" . basename($filename))) {
- echo "WARNING: couldn't copy $filename into the dist dir";
- }
+ $dest = "$dist_dir/$dll[0]";
+ $filename = $dll[1];
+
+ if (!file_exists("$dest") || !is_dir("$dest")) {
+ if (!mkdir("$dest", 0777, true)) {
+ echo "WARNING: couldn't create '$dest' for enchant plugins ";
+ }
+ }
+
+ if (!copy($php_build_dir . '/bin/' . $filename, "$dest/" . basename($filename))) {
+ echo "WARNING: couldn't copy $filename into the dist dir";
+ }
}
$SASL_DLLS = $php_build_dir . "/bin/sasl2/sasl*.dll";
$fls = glob($SASL_DLLS);
if (!empty($fls)) {
- $sasl_dest_dir = "$dist_dir/sasl2";
- if (!file_exists($sasl_dest_dir) || !is_dir($sasl_dest_dir)) {
- if (!mkdir("$sasl_dest_dir", 0777, true)) {
- echo "WARNING: couldn't create '$sasl_dest_dir' for SASL2 auth plugins ";
- }
- }
- foreach ($fls as $fl) {
- if (!copy($fl, "$sasl_dest_dir/" . basename($fl))) {
- echo "WARNING: couldn't copy $fl into the $sasl_dest_dir";
- }
- }
+ $sasl_dest_dir = "$dist_dir/sasl2";
+ if (!file_exists($sasl_dest_dir) || !is_dir($sasl_dest_dir)) {
+ if (!mkdir("$sasl_dest_dir", 0777, true)) {
+ echo "WARNING: couldn't create '$sasl_dest_dir' for SASL2 auth plugins ";
+ }
+ }
+ foreach ($fls as $fl) {
+ if (!copy($fl, "$sasl_dest_dir/" . basename($fl))) {
+ echo "WARNING: couldn't copy $fl into the $sasl_dest_dir";
+ }
+ }
}
/* and those for pecl */
foreach ($pecl_dll_deps as $dll) {
- if (in_array($dll, $extra_dll_deps)) {
- /* already in main distro */
- continue;
- }
- if (!file_exists($dll)) {
- /* try template dir */
- $tdll = $snapshot_template . "/dlls/" . basename($dll);
- if (!file_exists($tdll)) {
- echo "WARNING: distro depends on $dll, but could not find it on your system\n";
- continue;
- }
- $dll = $tdll;
- }
- copy($dll, "$pecl_dir/" . basename($dll));
+ if (in_array($dll, $extra_dll_deps)) {
+ /* already in main distro */
+ continue;
+ }
+ if (!file_exists($dll)) {
+ /* try template dir */
+ $tdll = $snapshot_template . "/dlls/" . basename($dll);
+ if (!file_exists($tdll)) {
+ echo "WARNING: distro depends on $dll, but could not find it on your system\n";
+ continue;
+ }
+ $dll = $tdll;
+ }
+ copy($dll, "$pecl_dir/" . basename($dll));
}
function copy_dir($source, $dest)
{
- if (!is_dir($dest)) {
- if (!mkdir($dest)) {
- return false;
- }
- }
-
- $d = opendir($source);
- while (($f = readdir($d)) !== false) {
- if ($f == '.' || $f == '..' || $f == '.svn') {
- continue;
- }
- $fs = $source . '/' . $f;
- $fd = $dest . '/' . $f;
- if (is_dir($fs)) {
- copy_dir($fs, $fd);
- } else {
- copy($fs, $fd);
- }
- }
- closedir($d);
+ if (!is_dir($dest)) {
+ if (!mkdir($dest)) {
+ return false;
+ }
+ }
+
+ $d = opendir($source);
+ while (($f = readdir($d)) !== false) {
+ if ($f == '.' || $f == '..' || $f == '.svn') {
+ continue;
+ }
+ $fs = $source . '/' . $f;
+ $fd = $dest . '/' . $f;
+ if (is_dir($fs)) {
+ copy_dir($fs, $fd);
+ } else {
+ copy($fs, $fd);
+ }
+ }
+ closedir($d);
}
function copy_test_dir($directory, $dest)
{
- if(substr($directory,-1) == '/') {
- $directory = substr($directory,0,-1);
- }
-
- if ($directory == 'tests' || $directory == 'examples') {
- if (!is_dir($dest . '/tests')) {
- mkdir($dest . '/tests', 0775, true);
- }
- copy_dir($directory, $dest . '/tests/');
-
- return false;
- }
-
- if(!file_exists($directory) || !is_dir($directory)) {
- echo "failed... $directory\n";
- return FALSE;
- }
-
- $directory_list = opendir($directory);
-
- while (FALSE !== ($file = readdir($directory_list))) {
- $full_path = $directory . '/' . $file;
- if($file != '.' && $file != '..' && $file != '.svn' && is_dir($full_path)) {
- if ($file == 'tests' || $file == 'examples') {
- if (!is_dir($dest . '/' . $full_path)) {
- mkdir($dest . '/' . $full_path , 0775, true);
- }
- copy_dir($full_path, $dest . '/' . $full_path . '/');
- continue;
- } else {
- copy_test_dir($full_path, $dest);
- }
- }
- }
-
- closedir($directory_list);
+ if(substr($directory,-1) == '/') {
+ $directory = substr($directory,0,-1);
+ }
+
+ if ($directory == 'tests' || $directory == 'examples') {
+ if (!is_dir($dest . '/tests')) {
+ mkdir($dest . '/tests', 0775, true);
+ }
+ copy_dir($directory, $dest . '/tests/');
+
+ return false;
+ }
+
+ if(!file_exists($directory) || !is_dir($directory)) {
+ echo "failed... $directory\n";
+ return FALSE;
+ }
+
+ $directory_list = opendir($directory);
+
+ while (FALSE !== ($file = readdir($directory_list))) {
+ $full_path = $directory . '/' . $file;
+ if($file != '.' && $file != '..' && $file != '.svn' && is_dir($full_path)) {
+ if ($file == 'tests' || $file == 'examples') {
+ if (!is_dir($dest . '/' . $full_path)) {
+ mkdir($dest . '/' . $full_path , 0775, true);
+ }
+ copy_dir($full_path, $dest . '/' . $full_path . '/');
+ continue;
+ } else {
+ copy_test_dir($full_path, $dest);
+ }
+ }
+ }
+
+ closedir($directory_list);
}
function make_phar_dot_phar($dist_dir)
{
- if (!extension_loaded('phar')) {
- return;
- }
+ if (!extension_loaded('phar')) {
+ return;
+ }
- $path_to_phar = realpath(__DIR__ . '/../../ext/phar');
+ $path_to_phar = realpath(__DIR__ . '/../../ext/phar');
- echo "Generating pharcommand.phar\n";
- $phar = new Phar($dist_dir . '/pharcommand.phar', 0, 'pharcommand');
+ echo "Generating pharcommand.phar\n";
+ $phar = new Phar($dist_dir . '/pharcommand.phar', 0, 'pharcommand');
- foreach (new DirectoryIterator($path_to_phar . '/phar') as $file) {
- if ($file->isDir() || $file == 'phar.php') {
- continue;
- }
+ foreach (new DirectoryIterator($path_to_phar . '/phar') as $file) {
+ if ($file->isDir() || $file == 'phar.php') {
+ continue;
+ }
- echo 'adding ', $file, "\n";
- $phar[(string) $file] = file_get_contents($path_to_phar. '/phar/' . $file);
- }
+ echo 'adding ', $file, "\n";
+ $phar[(string) $file] = file_get_contents($path_to_phar. '/phar/' . $file);
+ }
- $phar->setSignatureAlgorithm(Phar::SHA1);
- $stub = file($path_to_phar . '/phar/phar.php');
+ $phar->setSignatureAlgorithm(Phar::SHA1);
+ $stub = file($path_to_phar . '/phar/phar.php');
- unset($stub[0]); // remove hashbang
- $phar->setStub(implode('', $stub));
+ unset($stub[0]); // remove hashbang
+ $phar->setStub(implode('', $stub));
- echo "Creating phar.phar.bat\n";
- file_put_contents($dist_dir . '/phar.phar.bat', "\"%~dp0php.exe\" \"%~dp0pharcommand.phar\" %*\r\n");
+ echo "Creating phar.phar.bat\n";
+ file_put_contents($dist_dir . '/phar.phar.bat', "\"%~dp0php.exe\" \"%~dp0pharcommand.phar\" %*\r\n");
}
if (!is_dir($test_dir)) {
- mkdir($test_dir);
+ mkdir($test_dir);
}
$dirs = array(
- 'ext',
- 'Sapi',
- 'Zend',
- 'tests'
+ 'ext',
+ 'Sapi',
+ 'Zend',
+ 'tests'
);
foreach ($dirs as $dir) {
- copy_test_dir($dir, $test_dir);
+ copy_test_dir($dir, $test_dir);
}
copy('run-tests.php', $test_dir . '/run-test.php');
@@ -504,82 +503,82 @@ copy('run-tests.php', $test_dir . '/run-test.php');
$use_pear_template = true;
if (!$use_pear_template) {
- /* Let's do a PEAR-less pear setup */
- mkdir("$dist_dir/PEAR");
- mkdir("$dist_dir/PEAR/go-pear-bundle");
-
- /* grab the bootstrap script */
- echo "Downloading go-pear\n";
- copy("https://pear.php.net/go-pear.phar", "$dist_dir/PEAR/go-pear.php");
-
- /* import the package list -- sets $packages variable */
- include "pear/go-pear-list.php";
-
- /* download the packages into the destination */
- echo "Fetching packages\n";
-
- foreach ($packages as $name => $version) {
- $filename = "$name-$version.tgz";
- $destfilename = "$dist_dir/PEAR/go-pear-bundle/$filename";
- if (file_exists($destfilename))
- continue;
- $url = "http://pear.php.net/get/$filename";
- echo "Downloading $name from $url\n";
- flush();
- copy($url, $destfilename);
- }
-
- echo "Download complete. Extracting bootstrap files\n";
-
- /* Now, we want PEAR.php, Getopt.php (Console_Getopt) and Tar.php (Archive_Tar)
- * broken out of the tarballs */
- extract_file_from_tarball('PEAR', 'PEAR.php', "$dist_dir/PEAR/go-pear-bundle");
- extract_file_from_tarball('Archive_Tar', 'Archive/Tar.php', "$dist_dir/PEAR/go-pear-bundle");
- extract_file_from_tarball('Console_Getopt', 'Console/Getopt.php', "$dist_dir/PEAR/go-pear-bundle");
+ /* Let's do a PEAR-less pear setup */
+ mkdir("$dist_dir/PEAR");
+ mkdir("$dist_dir/PEAR/go-pear-bundle");
+
+ /* grab the bootstrap script */
+ echo "Downloading go-pear\n";
+ copy("https://pear.php.net/go-pear.phar", "$dist_dir/PEAR/go-pear.php");
+
+ /* import the package list -- sets $packages variable */
+ include "pear/go-pear-list.php";
+
+ /* download the packages into the destination */
+ echo "Fetching packages\n";
+
+ foreach ($packages as $name => $version) {
+ $filename = "$name-$version.tgz";
+ $destfilename = "$dist_dir/PEAR/go-pear-bundle/$filename";
+ if (file_exists($destfilename))
+ continue;
+ $url = "http://pear.php.net/get/$filename";
+ echo "Downloading $name from $url\n";
+ flush();
+ copy($url, $destfilename);
+ }
+
+ echo "Download complete. Extracting bootstrap files\n";
+
+ /* Now, we want PEAR.php, Getopt.php (Console_Getopt) and Tar.php (Archive_Tar)
+ * broken out of the tarballs */
+ extract_file_from_tarball('PEAR', 'PEAR.php', "$dist_dir/PEAR/go-pear-bundle");
+ extract_file_from_tarball('Archive_Tar', 'Archive/Tar.php', "$dist_dir/PEAR/go-pear-bundle");
+ extract_file_from_tarball('Console_Getopt', 'Console/Getopt.php', "$dist_dir/PEAR/go-pear-bundle");
}
/* add extras from the template dir */
if (file_exists($snapshot_template)) {
- $items = glob("$snapshot_template/*");
- print_r($items);
-
- foreach ($items as $item) {
- $bi = basename($item);
- if (is_dir($item)) {
- if ($bi == 'dlls' || $bi == 'symbols') {
- continue;
- } else if ($bi == 'PEAR') {
- if ($use_pear_template) {
- /* copy to top level */
- copy_dir($item, "$dist_dir/$bi");
- }
- } else {
- /* copy that dir into extras */
- copy_dir($item, "$dist_dir/extras/$bi");
- }
- } else {
- if ($bi == 'go-pear.bat') {
- /* copy to top level */
- copy($item, "$dist_dir/$bi");
- } else {
- /* copy to extras */
- copy($item, "$dist_dir/extras/$bi");
- }
- }
- }
-
- /* copy c++ runtime */
- $items = glob("$snapshot_template/dlls/*.CRT");
-
- foreach ($items as $item) {
- $bi = basename($item);
- if (is_dir($item)) {
- copy_dir($item, "$dist_dir/$bi");
- copy_dir($item, "$dist_dir/ext/$bi");
- }
- }
+ $items = glob("$snapshot_template/*");
+ print_r($items);
+
+ foreach ($items as $item) {
+ $bi = basename($item);
+ if (is_dir($item)) {
+ if ($bi == 'dlls' || $bi == 'symbols') {
+ continue;
+ } else if ($bi == 'PEAR') {
+ if ($use_pear_template) {
+ /* copy to top level */
+ copy_dir($item, "$dist_dir/$bi");
+ }
+ } else {
+ /* copy that dir into extras */
+ copy_dir($item, "$dist_dir/extras/$bi");
+ }
+ } else {
+ if ($bi == 'go-pear.bat') {
+ /* copy to top level */
+ copy($item, "$dist_dir/$bi");
+ } else {
+ /* copy to extras */
+ copy($item, "$dist_dir/extras/$bi");
+ }
+ }
+ }
+
+ /* copy c++ runtime */
+ $items = glob("$snapshot_template/dlls/*.CRT");
+
+ foreach ($items as $item) {
+ $bi = basename($item);
+ if (is_dir($item)) {
+ copy_dir($item, "$dist_dir/$bi");
+ copy_dir($item, "$dist_dir/ext/$bi");
+ }
+ }
} else {
- echo "WARNING: you don't have a snapshot template, your dist will not be complete\n";
+ echo "WARNING: you don't have a snapshot template, your dist will not be complete\n";
}
make_phar_dot_phar($dist_dir);
diff --git a/win32/build/phpize.js.in b/win32/build/phpize.js.in
index b64f32c71d..5a4a973e19 100644
--- a/win32/build/phpize.js.in
+++ b/win32/build/phpize.js.in
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
diff --git a/win32/build/registersyslog.php b/win32/build/registersyslog.php
index ce28cbf420..fa8503a4b8 100755
--- a/win32/build/registersyslog.php
+++ b/win32/build/registersyslog.php
@@ -1,33 +1,10 @@
<?php
-/* This script sets up an event source for use by the php syslog() function. */
-
-if (!extension_loaded("win32std")) {
- @dl("php_win32std.dll");
-}
+/* This script generates the .reg file to set up an event source for use by the php syslog() function. */
$PATH = "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\PHP-" . phpversion();
$dll = $argv[1];
-
-if (extension_loaded("win32std")) {
- $key = @reg_create_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
-
- if (!$key)
- $key = reg_open_key(HKEY_LOCAL_MACHINE, $PATH, KEY_ALL_ACCESS);
-
- if ($key) {
- reg_set_value($key, "TypesSupported", REG_DWORD, 7) or die("Types");
- reg_set_value($key, "EventMessageFile", REG_SZ, $dll) or die("EventMessageFile");
-
- syslog(LOG_NOTICE, "Registered PHP Event source");
- } else {
- echo "Could not register event source\n";
- }
-}
-
-/* let's also generate/update the bundled .reg file */
-
$dll = addslashes($dll);
file_put_contents("win32/syslog.reg", <<<REG
@@ -40,5 +17,4 @@ REGEDIT4
REG
);
-
?>
diff --git a/win32/build/template.rc b/win32/build/template.rc
index f26c98009d..15813d4ab9 100644
--- a/win32/build/template.rc
+++ b/win32/build/template.rc
@@ -64,7 +64,7 @@ BEGIN
#endif
VALUE "FileVersion", EXT_VERSION
VALUE "InternalName", INTERNAL_NAME
- VALUE "LegalCopyright", "Copyright © 1997-2018 The PHP Group"
+ VALUE "LegalCopyright", "Copyright © The PHP Group"
VALUE "LegalTrademarks", "PHP"
VALUE "OriginalFilename", FILE_NAME
VALUE "ProductName", "PHP"
diff --git a/win32/build/wsyslog.mc b/win32/build/wsyslog.mc
index f326abf7d9..f326abf7d9 100755..100644
--- a/win32/build/wsyslog.mc
+++ b/win32/build/wsyslog.mc
diff --git a/win32/builddef.bat b/win32/builddef.bat
deleted file mode 100644
index 8688754da8..0000000000
--- a/win32/builddef.bat
+++ /dev/null
@@ -1,6 +0,0 @@
-@echo off
-rem Generate phpts.def file, which exports symbols from our dll that
-rem are present in some of the libraries which are compiled statically
-rem into PHP
-type ..\ext\sqlite\php_sqlite.def
-type ..\ext\libxml\php_libxml2.def
diff --git a/win32/codepage.c b/win32/codepage.c
index b84909c10c..0543a057a5 100644
--- a/win32/codepage.c
+++ b/win32/codepage.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -22,6 +22,8 @@
#include "SAPI.h"
#include <emmintrin.h>
+#include "win32/console.h"
+
ZEND_TLS const struct php_win32_cp *cur_cp = NULL;
ZEND_TLS const struct php_win32_cp *orig_cp = NULL;
ZEND_TLS const struct php_win32_cp *cur_out_cp = NULL;
@@ -103,10 +105,12 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size
{/*{{{*/
wchar_t *ret, *ret_idx;
const char *idx = in, *end;
+ char ch_err = 0;
+
#if PHP_DEBUG
size_t save_in_len = in_len;
#endif
-
+
assert(in && in_len ? in[in_len] == '\0' : 1);
if (!in) {
@@ -124,29 +128,33 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size
/* Process unaligned chunk. */
while (idx < aidx) {
- if (!__isascii(*idx) && '\0' != *idx) {
- ASCII_FAIL_RETURN()
- }
+ ch_err |= *idx;
idx++;
}
+ if (ch_err & 0x80) {
+ ASCII_FAIL_RETURN()
+ }
/* Process aligned chunk. */
+ __m128i vec_err = _mm_setzero_si128();
while (end - idx > 15) {
const __m128i block = _mm_load_si128((__m128i *)idx);
- if (_mm_movemask_epi8(block)) {
- ASCII_FAIL_RETURN()
- }
+ vec_err = _mm_or_si128(vec_err, block);
idx += 16;
}
+ if (_mm_movemask_epi8(vec_err)) {
+ ASCII_FAIL_RETURN()
+ }
}
/* Process the trailing part, or otherwise process string < 16 bytes. */
while (idx < end) {
- if (!__isascii(*idx) && '\0' != *idx) {
- ASCII_FAIL_RETURN()
- }
+ ch_err |= *idx;
idx++;
}
+ if (ch_err & 0x80) {
+ ASCII_FAIL_RETURN()
+ }
ret = malloc((in_len+1)*sizeof(wchar_t));
if (!ret) {
@@ -157,9 +165,6 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size
ret_idx = ret;
idx = in;
- /* Check and conversion could be merged. This however would
- be more expencive, if a non ASCII string was passed.
- TODO check whether the impact is acceptable. */
if (in_len > 15) {
const char *aidx = (const char *)ZEND_SLIDE_TO_ALIGNED16(in);
@@ -292,11 +297,6 @@ __forceinline static char *php_win32_cp_get_enc(void)
return enc;
}/*}}}*/
-__forceinline static BOOL php_win32_cp_is_cli_sapi()
-{/*{{{*/
- return strlen(sapi_module.name) >= sizeof("cli") - 1 && !strncmp(sapi_module.name, "cli", sizeof("cli") - 1);
-}/*}}}*/
-
PW32CP const struct php_win32_cp *php_win32_cp_get_current(void)
{/*{{{*/
return cur_cp;
@@ -476,7 +476,7 @@ PW32CP const struct php_win32_cp *php_win32_cp_do_setup(const char *enc)
if (!orig_cp) {
orig_cp = php_win32_cp_get_by_id(GetACP());
}
- if (php_win32_cp_is_cli_sapi()) {
+ if (php_win32_console_is_cli_sapi()) {
if (!orig_in_cp) {
orig_in_cp = php_win32_cp_get_by_id(GetConsoleCP());
if (!orig_in_cp) {
@@ -502,7 +502,7 @@ PW32CP const struct php_win32_cp *php_win32_cp_do_update(const char *enc)
}
cur_cp = php_win32_cp_get_by_enc(enc);
- if (php_win32_cp_is_cli_sapi()) {
+ if (php_win32_console_is_cli_sapi()) {
php_win32_cp_cli_do_setup(cur_cp->id);
}
@@ -577,7 +577,7 @@ PHP_FUNCTION(sapi_windows_cp_set)
RETURN_FALSE;
}
- if (php_win32_cp_is_cli_sapi()) {
+ if (php_win32_console_is_cli_sapi()) {
cp = php_win32_cp_cli_do_setup((DWORD)id);
} else {
cp = php_win32_cp_set_by_id((DWORD)id);
@@ -657,7 +657,9 @@ PHP_FUNCTION(sapi_windows_cp_conv)
RETURN_NULL();
}
} else {
- convert_to_string(z_in_cp);
+ if (!try_convert_to_string(z_in_cp)) {
+ return;
+ }
in_cp = php_win32_cp_get_by_enc(Z_STRVAL_P(z_in_cp));
if (!in_cp) {
@@ -678,7 +680,9 @@ PHP_FUNCTION(sapi_windows_cp_conv)
RETURN_NULL();
}
} else {
- convert_to_string(z_out_cp);
+ if (!try_convert_to_string(z_out_cp)) {
+ return;
+ }
out_cp = php_win32_cp_get_by_enc(Z_STRVAL_P(z_out_cp));
if (!out_cp) {
@@ -708,11 +712,3 @@ PHP_FUNCTION(sapi_windows_cp_conv)
/* }}} */
/* }}} */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/codepage.h b/win32/codepage.h
index 7929ea7509..0dd72562b6 100644
--- a/win32/codepage.h
+++ b/win32/codepage.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -151,12 +151,3 @@ __forceinline static char *php_win32_cp_conv_w_to_any(const wchar_t* in, size_t
#endif
#endif /* PHP_WIN32_CODEPAGE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/console.c b/win32/console.c
index c7c9f11968..0b1bb0eff9 100644
--- a/win32/console.c
+++ b/win32/console.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -16,6 +16,8 @@
+----------------------------------------------------------------------+
*/
+#include "php.h"
+#include "SAPI.h"
#include "win32/console.h"
@@ -109,11 +111,8 @@ PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
return FALSE;
}/*}}}*/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+PHP_WINUTIL_API BOOL php_win32_console_is_cli_sapi(void)
+{/*{{{*/
+ return strlen(sapi_module.name) >= sizeof("cli") - 1 && !strncmp(sapi_module.name, "cli", sizeof("cli") - 1);
+}/*}}}*/
+
diff --git a/win32/console.h b/win32/console.h
index 93fa4ced2b..2d36d85508 100644
--- a/win32/console.h
+++ b/win32/console.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -59,13 +59,7 @@ PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL e
http://support.microsoft.com/kb/99115 */
PHP_WINUTIL_API BOOL php_win32_console_is_own(void);
-#endif
+/* Check whether the current SAPI is run on console. */
+PHP_WINUTIL_API BOOL php_win32_console_is_cli_sapi(void);
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+#endif
diff --git a/win32/cp_enc_map_gen.c b/win32/cp_enc_map_gen.c
index 34861d148b..bd2f108287 100644
--- a/win32/cp_enc_map_gen.c
+++ b/win32/cp_enc_map_gen.c
@@ -246,12 +246,3 @@ main(int argc, char **argv)
return 0;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/dllmain.c b/win32/dllmain.c
index 1c5ed48c97..4743f732e9 100644
--- a/win32/dllmain.c
+++ b/win32/dllmain.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -86,12 +86,3 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
return ret;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/fnmatch.c b/win32/fnmatch.c
index 9017b3e19c..296a1a5ca1 100644
--- a/win32/fnmatch.c
+++ b/win32/fnmatch.c
@@ -195,12 +195,3 @@ rangematch(const char *pattern, char test, int flags)
}
return (ok == negate ? NULL : pattern);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/fnmatch.h b/win32/fnmatch.h
index c149e89402..03a828d054 100644
--- a/win32/fnmatch.h
+++ b/win32/fnmatch.h
@@ -51,12 +51,3 @@
PHPAPI int fnmatch(const char *pattern, const char *string, int flags);
#endif /* !_FNMATCH_H_ */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/ftok.c b/win32/ftok.c
index 469f2df59a..db789f8b70 100644
--- a/win32/ftok.c
+++ b/win32/ftok.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -16,6 +16,7 @@
+----------------------------------------------------------------------+
*/
+#include "php.h"
#include "ipc.h"
#include <windows.h>
@@ -59,12 +60,3 @@ ftok(const char *pathname, int proj_id)
return ret;
}/*}}}*/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/getrusage.c b/win32/getrusage.c
index 4d5b8faf8d..de67f7f8d2 100644
--- a/win32/getrusage.c
+++ b/win32/getrusage.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -73,12 +73,3 @@ PHPAPI int getrusage(int who, struct rusage *usage)
return -1;
}
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/getrusage.h b/win32/getrusage.h
index 0bed8ba6f6..c41c026aa2 100644
--- a/win32/getrusage.h
+++ b/win32/getrusage.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -114,12 +114,3 @@ struct rusage
PHPAPI int getrusage(int who, struct rusage *usage);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/glob.c b/win32/glob.c
index a0845e803d..578284cb3d 100644
--- a/win32/glob.c
+++ b/win32/glob.c
@@ -923,12 +923,3 @@ qprintf(str, s)
(void)printf("\n");
}
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/glob.h b/win32/glob.h
index 946c2ecae8..42cf2f9d71 100644
--- a/win32/glob.h
+++ b/win32/glob.h
@@ -100,12 +100,3 @@ PHPAPI int glob(const char *, int, int (*)(const char *, int), glob_t *);
PHPAPI void globfree(glob_t *);
END_EXTERN_C()
#endif /* !_GLOB_H_ */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/globals.c b/win32/globals.c
index b872c33c88..9bb392f42a 100644
--- a/win32/globals.c
+++ b/win32/globals.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -67,12 +67,3 @@ PHP_RSHUTDOWN_FUNCTION(win32_core_globals)
return SUCCESS;
}/*}}}*/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/grp.h b/win32/grp.h
index 3da4fa194a..301babed4e 100644
--- a/win32/grp.h
+++ b/win32/grp.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -27,12 +27,3 @@ struct group {
};
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/inet.c b/win32/inet.c
index 7e52b581a0..7361b89bc2 100644
--- a/win32/inet.c
+++ b/win32/inet.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -27,12 +27,3 @@ int inet_aton(const char *cp, struct in_addr *inp) {
return 1;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/inet.h b/win32/inet.h
index 4d6140e44c..b57d78903d 100644
--- a/win32/inet.h
+++ b/win32/inet.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -25,12 +25,3 @@
PHPAPI int inet_aton(const char *cp, struct in_addr *inp);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/ioutil.c b/win32/ioutil.c
index 6fbfdb52e4..48e65d918f 100644
--- a/win32/ioutil.c
+++ b/win32/ioutil.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -60,6 +60,8 @@
#include "main/streams/php_stream_plain_wrapper.h"
#include <pathcch.h>
+#include <winioctl.h>
+#include <winnt.h>
/*
#undef NONLS
@@ -817,11 +819,395 @@ PW32IO char *realpath(const char *path, char *resolved)
return php_win32_ioutil_realpath(path, resolved);
}/*}}}*/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+PW32IO int php_win32_ioutil_symlink_w(const wchar_t *target, const wchar_t *link)
+{/*{{{*/
+ DWORD attr;
+ BOOLEAN res;
+
+ if ((attr = GetFileAttributesW(target)) == INVALID_FILE_ATTRIBUTES) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ res = CreateSymbolicLinkW(link, target, (attr & FILE_ATTRIBUTE_DIRECTORY ? 1 : 0));
+ if (!res) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ return 0;
+}/*}}}*/
+
+PW32IO int php_win32_ioutil_link_w(const wchar_t *target, const wchar_t *link)
+{/*{{{*/
+ BOOL res;
+
+ res = CreateHardLinkW(link, target, NULL);
+ if (!res) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ return 0;
+}/*}}}*/
+
+#define FILETIME_TO_UINT(filetime) \
+ (*((uint64_t*) &(filetime)) - 116444736000000000ULL)
+
+#define FILETIME_TO_TIME_T(filetime) \
+ (time_t)(FILETIME_TO_UINT(filetime) / 10000000ULL)
+
+static int php_win32_ioutil_fstat_int(HANDLE h, php_win32_ioutil_stat_t *buf, const wchar_t *pathw, size_t pathw_len, PBY_HANDLE_FILE_INFORMATION dp)
+{/*{{{*/
+ BY_HANDLE_FILE_INFORMATION d;
+ PBY_HANDLE_FILE_INFORMATION data;
+ LARGE_INTEGER t;
+ wchar_t mypath[MAXPATHLEN];
+ uint8_t is_dir;
+
+ data = !dp ? &d : dp;
+
+ if(!GetFileInformationByHandle(h, data)) {
+ if (INVALID_HANDLE_VALUE != h) {
+ /* Perhaps it's a fileless stream like stdio, reuse the normal stat info. */
+ struct __stat64 _buf;
+ if (_fstat64(_open_osfhandle((intptr_t)h, 0), &_buf)) {
+ return -1;
+ }
+ buf->st_dev = _buf.st_dev;
+ buf->st_ino = _buf.st_ino;
+ buf->st_mode = _buf.st_mode;
+ buf->st_nlink = _buf.st_nlink;
+ buf->st_uid = _buf.st_uid;
+ buf->st_gid = _buf.st_gid;
+ buf->st_rdev = _buf.st_rdev;
+ buf->st_size = _buf.st_size;
+ buf->st_atime = _buf.st_atime;
+ buf->st_mtime = _buf.st_mtime;
+ buf->st_ctime = _buf.st_ctime;
+ return 0;
+ } else if(h == INVALID_HANDLE_VALUE && pathw_len > 0) {
+ /* An abnormal situation it is. For example, the user is the file
+ owner, but the file has an empty DACL. In that case, it is
+ possible CreateFile would fail, but the attributes still can
+ be read. Some info is still going to be missing. */
+ WIN32_FILE_ATTRIBUTE_DATA _data;
+ if (!GetFileAttributesExW(pathw, GetFileExInfoStandard, &_data)) {
+ DWORD err = GetLastError();
+ SET_ERRNO_FROM_WIN32_CODE(err);
+ return -1;
+ }
+ data->dwFileAttributes = _data.dwFileAttributes;
+ data->ftCreationTime = _data.ftCreationTime;
+ data->ftLastAccessTime = _data.ftLastAccessTime;
+ data->ftLastWriteTime = _data.ftLastWriteTime;
+ data->nFileSizeHigh = _data.nFileSizeHigh;
+ data->nFileSizeLow = _data.nFileSizeLow;
+ data->dwVolumeSerialNumber = 0;
+ data->nNumberOfLinks = 1;
+ data->nFileIndexHigh = 0;
+ data->nFileIndexLow = 0;
+ } else {
+ DWORD err = GetLastError();
+ SET_ERRNO_FROM_WIN32_CODE(err);
+ return -1;
+ }
+ }
+
+ is_dir = (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
+
+ buf->st_dev = data->dwVolumeSerialNumber;
+
+ buf->st_rdev = buf->st_uid = buf->st_gid = 0;
+
+ buf->st_ino = (((uint64_t)data->nFileIndexHigh) << 32) + data->nFileIndexLow;
+
+ buf->st_mode = 0;
+
+ if (!is_dir) {
+ if (pathw_len >= 4 &&
+ pathw[pathw_len-4] == L'.') {
+ if (_wcsnicmp(pathw+pathw_len-3, L"exe", 3) == 0 ||
+ _wcsnicmp(pathw+pathw_len-3, L"com", 3) == 0) {
+ DWORD type;
+ if (GetBinaryTypeW(pathw, &type)) {
+ buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
+ }
+ /* The below is actually incorrect, but keep for BC. */
+ } else if (_wcsnicmp(pathw+pathw_len-3, L"bat", 3) == 0 ||
+ _wcsnicmp(pathw+pathw_len-3, L"cmd", 3) == 0) {
+ buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
+ }
+ }
+ }
+
+ if ((data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
+ if (is_dir) {
+ buf->st_mode |= (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
+ } else {
+ switch (GetFileType(h)) {
+ case FILE_TYPE_CHAR:
+ buf->st_mode |= S_IFCHR;
+ break;
+ case FILE_TYPE_PIPE:
+ buf->st_mode |= S_IFIFO;
+ break;
+ default:
+ buf->st_mode |= S_IFREG;
+ }
+ }
+ buf->st_mode |= (data->dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
+ }
+
+ buf->st_nlink = data->nNumberOfLinks;
+ t.HighPart = data->nFileSizeHigh;
+ t.LowPart = data->nFileSizeLow;
+ /* It's an overflow on 32 bit, however it won't fix as long
+ as zend_long is 32 bit. */
+ buf->st_size = (zend_long)t.QuadPart;
+ buf->st_atime = FILETIME_TO_TIME_T(data->ftLastAccessTime);
+ buf->st_ctime = FILETIME_TO_TIME_T(data->ftCreationTime);
+ buf->st_mtime = FILETIME_TO_TIME_T(data->ftLastWriteTime);
+
+ return 0;
+}/*}}}*/
+
+PW32IO int php_win32_ioutil_stat_ex_w(const wchar_t *path, size_t path_len, php_win32_ioutil_stat_t *buf, int lstat)
+{/*{{{*/
+ BY_HANDLE_FILE_INFORMATION data;
+ HANDLE hLink = NULL;
+ DWORD flags_and_attrs = lstat ? FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT : FILE_FLAG_BACKUP_SEMANTICS;
+ int ret;
+ ALLOCA_FLAG(use_heap_large)
+
+ hLink = CreateFileW(path,
+ FILE_READ_ATTRIBUTES,
+ PHP_WIN32_IOUTIL_DEFAULT_SHARE_MODE,
+ NULL,
+ OPEN_EXISTING,
+ flags_and_attrs,
+ NULL
+ );
+
+ ret = php_win32_ioutil_fstat_int(hLink, buf, path, path_len, &data);
+
+ if (lstat && data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+ /* File is a reparse point. Get the target */
+ PHP_WIN32_IOUTIL_REPARSE_DATA_BUFFER * pbuffer;
+ DWORD retlength = 0;
+
+ pbuffer = (PHP_WIN32_IOUTIL_REPARSE_DATA_BUFFER *)do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large);
+ if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
+ free_alloca(pbuffer, use_heap_large);
+ CloseHandle(hLink);
+ return -1;
+ }
+
+ if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+ buf->st_mode = S_IFLNK;
+ buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
+ }
+
+#if 0 /* Not used yet */
+ else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
+ buf->st_mode |=;
+ }
+#endif
+ free_alloca(pbuffer, use_heap_large);
+ }
+
+ CloseHandle(hLink);
+
+ return ret;
+
+}/*}}}*/
+
+PW32IO int php_win32_ioutil_fstat(int fd, php_win32_ioutil_stat_t *buf)
+{/*{{{*/
+ return php_win32_ioutil_fstat_int((HANDLE)_get_osfhandle(fd), buf, NULL, 0, NULL);
+}/*}}}*/
+
+static ssize_t php_win32_ioutil_readlink_int(HANDLE h, wchar_t *buf, size_t buf_len)
+{/*{{{*/
+ char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+ PHP_WIN32_IOUTIL_REPARSE_DATA_BUFFER *reparse_data = (PHP_WIN32_IOUTIL_REPARSE_DATA_BUFFER*) buffer;
+ wchar_t* reparse_target;
+ DWORD reparse_target_len;
+ DWORD bytes;
+
+ if (!DeviceIoControl(h,
+ FSCTL_GET_REPARSE_POINT,
+ NULL,
+ 0,
+ buffer,
+ sizeof buffer,
+ &bytes,
+ NULL)) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ if (reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+ /* Real symlink */
+
+ /* BC - relative links are shown as absolute */
+ if (reparse_data->SymbolicLinkReparseBuffer.Flags & SYMLINK_FLAG_RELATIVE) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+
+ reparse_target = reparse_data->SymbolicLinkReparseBuffer.ReparseTarget +
+ (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset /
+ sizeof(wchar_t));
+ reparse_target_len =
+ reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength /
+ sizeof(wchar_t);
+
+ /* Real symlinks can contain pretty much everything, but the only thing we
+ * really care about is undoing the implicit conversion to an NT namespaced
+ * path that CreateSymbolicLink will perform on absolute paths. If the path
+ * is win32-namespaced then the user must have explicitly made it so, and
+ * we better just return the unmodified reparse data. */
+ if (reparse_target_len >= 4 &&
+ reparse_target[0] == L'\\' &&
+ reparse_target[1] == L'?' &&
+ reparse_target[2] == L'?' &&
+ reparse_target[3] == L'\\') {
+ /* Starts with \??\ */
+ if (reparse_target_len >= 6 &&
+ ((reparse_target[4] >= L'A' && reparse_target[4] <= L'Z') ||
+ (reparse_target[4] >= L'a' && reparse_target[4] <= L'z')) &&
+ reparse_target[5] == L':' &&
+ (reparse_target_len == 6 || reparse_target[6] == L'\\')) {
+ /* \??\<drive>:\ */
+ reparse_target += 4;
+ reparse_target_len -= 4;
+
+ } else if (reparse_target_len >= 8 &&
+ (reparse_target[4] == L'U' || reparse_target[4] == L'u') &&
+ (reparse_target[5] == L'N' || reparse_target[5] == L'n') &&
+ (reparse_target[6] == L'C' || reparse_target[6] == L'c') &&
+ reparse_target[7] == L'\\') {
+ /* \??\UNC\<server>\<share>\ - make sure the final path looks like
+ * \\<server>\<share>\ */
+ reparse_target += 6;
+ reparse_target[0] = L'\\';
+ reparse_target_len -= 6;
+ }
+ }
+
+ } else if (reparse_data->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
+ /* Junction. */
+ reparse_target = reparse_data->MountPointReparseBuffer.ReparseTarget +
+ (reparse_data->MountPointReparseBuffer.SubstituteNameOffset /
+ sizeof(wchar_t));
+ reparse_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
+
+ /* Only treat junctions that look like \??\<drive>:\ as symlink. Junctions
+ * can also be used as mount points, like \??\Volume{<guid>}, but that's
+ * confusing for programs since they wouldn't be able to actually
+ * understand such a path when returned by uv_readlink(). UNC paths are
+ * never valid for junctions so we don't care about them. */
+ if (!(reparse_target_len >= 6 &&
+ reparse_target[0] == L'\\' &&
+ reparse_target[1] == L'?' &&
+ reparse_target[2] == L'?' &&
+ reparse_target[3] == L'\\' &&
+ ((reparse_target[4] >= L'A' && reparse_target[4] <= L'Z') ||
+ (reparse_target[4] >= L'a' && reparse_target[4] <= L'z')) &&
+ reparse_target[5] == L':' &&
+ (reparse_target_len == 6 || reparse_target[6] == L'\\'))) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+
+ /* Remove leading \??\ */
+ reparse_target += 4;
+ reparse_target_len -= 4;
+
+ } else {
+ /* Reparse tag does not indicate a symlink. */
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+
+ if (reparse_target_len >= buf_len) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_NOT_ENOUGH_MEMORY);
+ return -1;
+ }
+
+ memcpy(buf, reparse_target, reparse_target_len*sizeof(wchar_t));
+ buf[reparse_target_len] = L'\0';
+
+ return reparse_target_len;
+}/*}}}*/
+
+PW32IO ssize_t php_win32_ioutil_readlink_w(const wchar_t *path, wchar_t *buf, size_t buf_len)
+{/*{{{*/
+ HANDLE h;
+ ssize_t ret;
+
+ /* Get a handle to the symbolic link (if path is a symbolic link) */
+ h = CreateFileW(path,
+ 0,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ ret = php_win32_ioutil_readlink_int(h, buf, buf_len);
+
+ if (ret < 0) {
+ wchar_t target[PHP_WIN32_IOUTIL_MAXPATHLEN];
+ size_t target_len;
+ size_t offset = 0;
+
+ /* BC - get a handle to the target (if path is a symbolic link) */
+ CloseHandle(h);
+ h = CreateFileW(path,
+ 0,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ SET_ERRNO_FROM_WIN32_CODE(GetLastError());
+ return -1;
+ }
+
+ target_len = GetFinalPathNameByHandleW(h, target, PHP_WIN32_IOUTIL_MAXPATHLEN, VOLUME_NAME_DOS);
+
+ if(target_len >= buf_len || target_len >= PHP_WIN32_IOUTIL_MAXPATHLEN || target_len == 0) {
+ CloseHandle(h);
+ return -1;
+ }
+
+ if(target_len > 4) {
+ /* Skip first 4 characters if they are "\\?\" */
+ if(target[0] == L'\\' && target[1] == L'\\' && target[2] == L'?' && target[3] == L'\\') {
+ offset = 4;
+
+ /* \\?\UNC\ */
+ if (target_len > 7 && target[4] == L'U' && target[5] == L'N' && target[6] == L'C') {
+ offset += 2;
+ target[offset] = L'\\';
+ }
+ }
+ }
+
+ ret = target_len - offset;
+ memcpy(buf, target + offset, (ret + 1)*sizeof(wchar_t));
+ }
+
+ CloseHandle(h);
+
+ return ret;
+}/*}}}*/
diff --git a/win32/ioutil.h b/win32/ioutil.h
index 82ed6b4e63..05ed3621d2 100644
--- a/win32/ioutil.h
+++ b/win32/ioutil.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -88,6 +88,11 @@ typedef unsigned short mode_t;
#define F_OK 0x00
#endif
+/* from ntifs.h */
+#ifndef SYMLINK_FLAG_RELATIVE
+#define SYMLINK_FLAG_RELATIVE 0x01
+#endif
+
typedef struct {
DWORD access;
DWORD share;
@@ -269,6 +274,8 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode);
PW32IO FILE *php_win32_ioutil_fopen_w(const wchar_t *path, const wchar_t *mode);
PW32IO wchar_t *php_win32_ioutil_realpath_w(const wchar_t *path, wchar_t *resolved);
PW32IO wchar_t *php_win32_ioutil_realpath_w_ex0(const wchar_t *path, wchar_t *resolved, PBY_HANDLE_FILE_INFORMATION info);
+PW32IO int php_win32_ioutil_symlink_w(const wchar_t *target, const wchar_t *link);
+PW32IO int php_win32_ioutil_link_w(const wchar_t *target, const wchar_t *link);
__forceinline static int php_win32_ioutil_access(const char *path, mode_t mode)
{/*{{{*/
@@ -574,6 +581,57 @@ __forceinline static int php_win32_ioutil_mkdir(const char *path, mode_t mode)
return ret;
}/*}}}*/
+__forceinline static int php_win32_ioutil_symlink(const char *target, const char *link)
+{/*{{{*/
+ wchar_t *targetw, *linkw;
+ int ret;
+
+ targetw = php_win32_ioutil_any_to_w(target);
+ if (!targetw) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ linkw = php_win32_ioutil_any_to_w(link);
+ if (!linkw) {
+ free(targetw);
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ ret = php_win32_ioutil_symlink_w(targetw, linkw);
+
+ free(targetw);
+ free(linkw);
+
+ return ret;
+}/*}}}*/
+
+__forceinline static int php_win32_ioutil_link(const char *target, const char *link)
+{/*{{{*/
+ wchar_t *targetw, *linkw;
+ int ret;
+
+ targetw = php_win32_ioutil_any_to_w(target);
+ if (!targetw) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+ linkw = php_win32_ioutil_any_to_w(link);
+ if (!linkw) {
+ free(targetw);
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ ret = php_win32_ioutil_link_w(targetw, linkw);
+
+ free(targetw);
+ free(linkw);
+
+ return ret;
+}/*}}}*/
+
#define HAVE_REALPATH 1
PW32IO char *realpath(const char *path, char *resolved);
@@ -627,17 +685,125 @@ __forceinline static char *php_win32_ioutil_realpath(const char *path, char *res
return php_win32_ioutil_realpath_ex0(path, resolved, NULL);
}/*}}}*/
+#include <sys/stat.h>
+#if _WIN64
+typedef unsigned __int64 php_win32_ioutil_dev_t;
+typedef unsigned __int64 php_win32_ioutil_ino_t;
+typedef __time64_t php_win32_ioutil_time_t;
+typedef __int64 php_win32_ioutil_size_t;
+#else
+typedef unsigned __int32 php_win32_ioutil_dev_t;
+typedef unsigned __int32 php_win32_ioutil_ino_t;
+typedef __time32_t php_win32_ioutil_time_t;
+typedef __int32 php_win32_ioutil_size_t;
+#endif
+typedef struct {
+ php_win32_ioutil_dev_t st_dev;
+ php_win32_ioutil_ino_t st_ino;
+ unsigned __int32 st_mode;
+ unsigned __int32 st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ php_win32_ioutil_dev_t st_rdev;
+ php_win32_ioutil_size_t st_size;
+#if 0
+ __int32 st_blksize;
+ __int32 st_blocks;
+#endif
+ php_win32_ioutil_time_t st_atime;
+ php_win32_ioutil_time_t st_mtime;
+ php_win32_ioutil_time_t st_ctime;
+} php_win32_ioutil_stat_t;
+
+typedef struct {
+ unsigned long ReparseTag;
+ unsigned short ReparseDataLength;
+ unsigned short Reserved;
+ union {
+ struct {
+ unsigned short SubstituteNameOffset;
+ unsigned short SubstituteNameLength;
+ unsigned short PrintNameOffset;
+ unsigned short PrintNameLength;
+ unsigned long Flags;
+ wchar_t ReparseTarget[1];
+ } SymbolicLinkReparseBuffer;
+ struct {
+ unsigned short SubstituteNameOffset;
+ unsigned short SubstituteNameLength;
+ unsigned short PrintNameOffset;
+ unsigned short PrintNameLength;
+ wchar_t ReparseTarget[1];
+ } MountPointReparseBuffer;
+ struct {
+ unsigned char ReparseTarget[1];
+ } GenericReparseBuffer;
+ };
+} PHP_WIN32_IOUTIL_REPARSE_DATA_BUFFER, *PHP_WIN32_IOUTIL_PREPARSE_DATA_BUFFER;
+
+PW32IO int php_win32_ioutil_stat_ex_w(const wchar_t *path, size_t path_len, php_win32_ioutil_stat_t *buf, int lstat);
+PW32IO int php_win32_ioutil_fstat(int fd, php_win32_ioutil_stat_t *buf);
+
+__forceinline static int php_win32_ioutil_stat_ex(const char *path, php_win32_ioutil_stat_t *buf, int lstat)
+{/*{{{*/
+ size_t pathw_len;
+ wchar_t *pathw = php_win32_ioutil_conv_any_to_w(path, PHP_WIN32_CP_IGNORE_LEN, &pathw_len);
+ int ret;
+
+ if (!pathw) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ ret = php_win32_ioutil_stat_ex_w(pathw, pathw_len, buf, lstat);
+
+ free(pathw);
+
+ return ret;
+}/*}}}*/
+#define php_win32_ioutil_stat(path, buf) php_win32_ioutil_stat_ex(path, buf, 0)
+#define php_win32_ioutil_lstat(path, buf) php_win32_ioutil_stat_ex(path, buf, 1)
+
+PW32IO ssize_t php_win32_ioutil_readlink_w(const wchar_t *path, wchar_t *buf, size_t buf_len);
+
+__forceinline static ssize_t php_win32_ioutil_readlink(const char *path, char *buf, size_t buf_len)
+{/*{{{*/
+ size_t pathw_len, ret_buf_len;
+ wchar_t *pathw = php_win32_ioutil_conv_any_to_w(path, PHP_WIN32_CP_IGNORE_LEN, &pathw_len);
+ wchar_t retw[PHP_WIN32_IOUTIL_MAXPATHLEN];
+ char *ret_buf;
+ ssize_t ret;
+
+ if (!pathw) {
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ ret = php_win32_ioutil_readlink_w(pathw, retw, sizeof(retw)-1);
+ if (ret < 0) {
+ DWORD _err = GetLastError();
+ free(pathw);
+ SET_ERRNO_FROM_WIN32_CODE(_err);
+ return ret;
+ }
+
+ ret_buf = php_win32_ioutil_conv_w_to_any(retw, ret, &ret_buf_len);
+ if (!ret_buf || ret_buf_len >= buf_len || ret_buf_len >= MAXPATHLEN) {
+ free(ret_buf);
+ free(pathw);
+ SET_ERRNO_FROM_WIN32_CODE(ERROR_BAD_PATHNAME);
+ return -1;
+ }
+ memcpy(buf, ret_buf, ret_buf_len + 1);
+
+ free(ret_buf);
+ free(pathw);
+
+ return ret_buf_len;
+}/*}}}*/
+
#ifdef __cplusplus
}
#endif
#endif /* PHP_WIN32_IOUTIL_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/ipc.h b/win32/ipc.h
index 1be7a7d050..c7cb476353 100644
--- a/win32/ipc.h
+++ b/win32/ipc.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -31,12 +31,3 @@ PHP_WIN32_IPC_API key_t ftok(const char *path, int id);
#endif /* PHP_WIN32_IPC_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/nice.c b/win32/nice.c
index 993df0a041..05aae465ed 100644
--- a/win32/nice.c
+++ b/win32/nice.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -81,12 +81,3 @@ PHPAPI int nice(zend_long p)
return 0;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/nice.h b/win32/nice.h
index ad3833c8b2..385855c2ea 100644
--- a/win32/nice.h
+++ b/win32/nice.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -22,12 +22,3 @@
PHPAPI int nice(zend_long);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/param.h b/win32/param.h
index 552323c5b1..b40d966d7f 100644
--- a/win32/param.h
+++ b/win32/param.h
@@ -19,12 +19,3 @@
#define roundup(x,y) ((((x)+((y)-1))/(y))*(y))
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/php7dllts.rc b/win32/php7dllts.rc
deleted file mode 100644
index 27ec635e25..0000000000
--- a/win32/php7dllts.rc
+++ /dev/null
@@ -1,126 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-
-//
-
-#include "resource.h"
-
-
-
-#define APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 2 resource.
-
-//
-
-#include "winres.h"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#undef APSTUDIO_READONLY_SYMBOLS
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-// English (U.S.) resources
-
-
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-
-#ifdef _WIN32
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-#pragma code_page(1252)
-
-#endif //_WIN32
-
-
-
-#ifdef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// TEXTINCLUDE
-
-//
-
-
-
-1 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "resource.h\0"
-
-END
-
-
-
-2 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "#include ""php7dllts.rc2""\r\n"
-
- "\0"
-
-END
-
-
-
-3 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "\r\n"
-
- "\0"
-
-END
-
-
-
-#endif // APSTUDIO_INVOKED
-
-
-
-#endif // English (U.S.) resources
-
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-#ifndef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 3 resource.
-
-//
-
-#include "php7dllts.rc2"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#endif // not APSTUDIO_INVOKED
-
-
-
diff --git a/win32/php7dllts.rc2 b/win32/php7dllts.rc2
deleted file mode 100644
index 6bcc652a72..0000000000
--- a/win32/php7dllts.rc2
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// php7dllts.RC2 - resources Microsoft Visual C++ does not edit directly
-//
-
-#ifdef APSTUDIO_INVOKED
- #error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-#include "../main/php_version.h"
-
-#define XSTRVER4(maj, min, rel, build) #maj "." #min "." #rel "." #build
-#define XSTRVER3(maj, min, rel) #maj "." #min "." #rel
-#define STRVER4(maj, min, rel, build) XSTRVER4(maj, min, rel, build)
-#define STRVER3(maj, min, rel) XSTRVER3(maj, min, rel)
-
-#ifndef _MAC
-//Version
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_RELEASE_VERSION
- PRODUCTVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", "\0"
- VALUE "CompanyName", "The PHP Group\0"
- VALUE "FileDescription", "PHP Script Interpreter\0"
- VALUE "FileVersion", STRVER4(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_RELEASE_VERSION)
- VALUE "InternalName", "php\0"
- VALUE "LegalCopyright", "Copyright © 1997-2007 The PHP Group\0"
- VALUE "LegalTrademarks", "php\0"
- VALUE "OriginalFilename", "php7ts.dll\0"
- VALUE "PrivateBuild", "\0"
- VALUE "ProductName", "PHP Thread Safe\0"
- VALUE "ProductVersion", STRVER3(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
- VALUE "SpecialBuild", PHP_EXTRA_VERSION "\0"
- VALUE "URL", "http://www.php.net"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-#endif // !_MAC
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/win32/php7ts.rc b/win32/php7ts.rc
deleted file mode 100644
index b725155809..0000000000
--- a/win32/php7ts.rc
+++ /dev/null
@@ -1,126 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-
-//
-
-#include "resource.h"
-
-
-
-#define APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 2 resource.
-
-//
-
-#include "winres.h"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#undef APSTUDIO_READONLY_SYMBOLS
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-// English (U.S.) resources
-
-
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-
-#ifdef _WIN32
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-#pragma code_page(1252)
-
-#endif //_WIN32
-
-
-
-#ifdef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// TEXTINCLUDE
-
-//
-
-
-
-1 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "resource.h\0"
-
-END
-
-
-
-2 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "#include ""php7ts.rc2""\r\n"
-
- "\0"
-
-END
-
-
-
-3 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "\r\n"
-
- "\0"
-
-END
-
-
-
-#endif // APSTUDIO_INVOKED
-
-
-
-#endif // English (U.S.) resources
-
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-#ifndef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 3 resource.
-
-//
-
-#include "php7ts.rc2"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#endif // not APSTUDIO_INVOKED
-
-
-
diff --git a/win32/php7ts.rc2 b/win32/php7ts.rc2
deleted file mode 100644
index 6c813de23c..0000000000
--- a/win32/php7ts.rc2
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// php7dllts.RC2 - resources Microsoft Visual C++ does not edit directly
-//
-
-#ifdef APSTUDIO_INVOKED
- #error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-#include "../main/php_version.h"
-
-#define XSTRVER4(maj, min, rel, build) #maj "." #min "." #rel "." #build
-#define XSTRVER3(maj, min, rel) #maj "." #min "." #rel
-#define STRVER4(maj, min, rel, build) XSTRVER4(maj, min, rel, build)
-#define STRVER3(maj, min, rel) XSTRVER3(maj, min, rel)
-
-#ifndef _MAC
-//Version
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_RELEASE_VERSION
- PRODUCTVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_APP
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", "\0"
- VALUE "CompanyName", "The PHP Group\0"
- VALUE "FileDescription", "PHP Script Interpreter\0"
- VALUE "FileVersion", STRVER4(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_RELEASE_VERSION)
- VALUE "InternalName", "php-cgi\0"
- VALUE "LegalCopyright", "Copyright © 1997-2007 The PHP Group\0"
- VALUE "LegalTrademarks", "php\0"
- VALUE "OriginalFilename", "php.exe\0"
- VALUE "PrivateBuild", "\0"
- VALUE "ProductName", "PHP Thread Safe CGI\0"
- VALUE "ProductVersion", STRVER3(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
- VALUE "SpecialBuild", PHP_EXTRA_VERSION "\0"
- VALUE "URL", "http://www.php.net"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-#endif // !_MAC
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/win32/php7ts_cli.rc b/win32/php7ts_cli.rc
deleted file mode 100644
index 3478b94bd7..0000000000
--- a/win32/php7ts_cli.rc
+++ /dev/null
@@ -1,126 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-
-//
-
-#include "resource.h"
-
-
-
-#define APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 2 resource.
-
-//
-
-#include "winres.h"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#undef APSTUDIO_READONLY_SYMBOLS
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-// English (U.S.) resources
-
-
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-
-#ifdef _WIN32
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-#pragma code_page(1252)
-
-#endif //_WIN32
-
-
-
-#ifdef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// TEXTINCLUDE
-
-//
-
-
-
-1 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "resource.h\0"
-
-END
-
-
-
-2 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "#include ""php7ts_cli.rc2""\r\n"
-
- "\0"
-
-END
-
-
-
-3 TEXTINCLUDE DISCARDABLE
-
-BEGIN
-
- "\r\n"
-
- "\0"
-
-END
-
-
-
-#endif // APSTUDIO_INVOKED
-
-
-
-#endif // English (U.S.) resources
-
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-#ifndef APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-
-//
-
-// Generated from the TEXTINCLUDE 3 resource.
-
-//
-
-#include "php7ts_cli.rc2"
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-#endif // not APSTUDIO_INVOKED
-
-
-
diff --git a/win32/php7ts_cli.rc2 b/win32/php7ts_cli.rc2
deleted file mode 100644
index 004808c16b..0000000000
--- a/win32/php7ts_cli.rc2
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// php7dllts.RC2 - resources Microsoft Visual C++ does not edit directly
-//
-
-#ifdef APSTUDIO_INVOKED
- #error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-#include "../main/php_version.h"
-
-#define XSTRVER4(maj, min, rel, build) #maj "." #min "." #rel "." #build
-#define XSTRVER3(maj, min, rel) #maj "." #min "." #rel
-#define STRVER4(maj, min, rel, build) XSTRVER4(maj, min, rel, build)
-#define STRVER3(maj, min, rel) XSTRVER3(maj, min, rel)
-
-#ifndef _MAC
-//Version
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_RELEASE_VERSION
- PRODUCTVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_APP
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", "\0"
- VALUE "CompanyName", "The PHP Group\0"
- VALUE "FileDescription", "PHP Script Interpreter\0"
- VALUE "FileVersion", STRVER4(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_RELEASE_VERSION)
- VALUE "InternalName", "php-cli\0"
- VALUE "LegalCopyright", "Copyright © 1997-2006 The PHP Group\0"
- VALUE "LegalTrademarks", "php\0"
- VALUE "OriginalFilename", "php.exe\0"
- VALUE "PrivateBuild", "\0"
- VALUE "ProductName", "PHP Thread Safe Command Line Interface\0"
- VALUE "ProductVersion", STRVER3(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
- VALUE "SpecialBuild", PHP_EXTRA_VERSION "\0"
- VALUE "URL", "http://www.php.net"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-#endif // !_MAC
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/win32/php_inttypes.h b/win32/php_inttypes.h
index 878d13fffb..20e9c9b775 100644
--- a/win32/php_inttypes.h
+++ b/win32/php_inttypes.h
@@ -311,12 +311,3 @@ imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
#else
#include <inttypes.h>
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/php_registry.h b/win32/php_registry.h
index a55a057628..f46c482085 100644
--- a/win32/php_registry.h
+++ b/win32/php_registry.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -24,12 +24,3 @@ void UpdateIniFromRegistry(char *path);
char *GetIniPathFromRegistry();
#endif /* PHP_REGISTRY_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/php_stdbool.h b/win32/php_stdbool.h
deleted file mode 100644
index 5b73d985ae..0000000000
--- a/win32/php_stdbool.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _STDBOOL_H
-#define _STDBOOL_H
-#if !defined(__BOOL_DEFINED)
-# define bool short
-
-/* The other macros must be usable in preprocessor directives. */
-# define false 0
-# define true 1
-# define __bool_true_false_are_defined 1
-# endif
-#endif /* _STDBOOL_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/php_stdint.h b/win32/php_stdint.h
index bc936bf111..e7615f1479 100644
--- a/win32/php_stdint.h
+++ b/win32/php_stdint.h
@@ -263,12 +263,3 @@ static __inline int64_t llabs(int64_t i)
#ifndef u_char
typedef unsigned __int8 u_char;
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/php_win32_globals.h b/win32/php_win32_globals.h
index 642acbf9bf..bb91f08c50 100644
--- a/win32/php_win32_globals.h
+++ b/win32/php_win32_globals.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -53,12 +53,3 @@ void php_win32_core_globals_dtor(void *vg);
PHP_RSHUTDOWN_FUNCTION(win32_core_globals);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/readdir.c b/win32/readdir.c
index 9071a61b10..c172f16fc2 100644
--- a/win32/readdir.c
+++ b/win32/readdir.c
@@ -127,46 +127,6 @@ struct dirent *readdir(DIR *dp)
return &(dp->dent);
}/*}}}*/
-int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result)
-{/*{{{*/
- char *_tmp;
- size_t reclen;
-
- if (!dp || dp->finished) {
- *result = NULL;
- return 0;
- }
-
- if (dp->offset != 0) {
- if (FindNextFileW(dp->handle, &(dp->fileinfo)) == 0) {
- dp->finished = 1;
- *result = NULL;
- return 0;
- }
- }
-
- _tmp = php_win32_cp_conv_w_to_any(dp->fileinfo.cFileName, PHP_WIN32_CP_IGNORE_LEN, &reclen);
- if (!_tmp) {
- /* wide to utf8 failed, should never happen. */
- result = NULL;
- return 0;
- }
- memmove(dp->dent.d_name, _tmp, reclen + 1);
- free(_tmp);
- dp->dent.d_reclen = (unsigned short)reclen;
-
- dp->offset++;
-
- dp->dent.d_ino = 1;
- dp->dent.d_off = dp->offset;
-
- memcpy(entry, &dp->dent, sizeof(*entry));
-
- *result = &dp->dent;
-
- return 0;
-}/*}}}*/
-
int closedir(DIR *dp)
{/*{{{*/
if (!dp)
@@ -239,12 +199,3 @@ int rewinddir(DIR *dp)
#ifdef __cplusplus
}
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/readdir.h b/win32/readdir.h
index 8e26cbadb6..61876f3dc1 100644
--- a/win32/readdir.h
+++ b/win32/readdir.h
@@ -15,8 +15,6 @@ extern "C" {
#include "ioutil.h"
-#define php_readdir_r readdir_r
-
/* struct dirent - same as Unix */
struct dirent {
long d_ino; /* inode (always 1 in WIN32) */
@@ -39,7 +37,6 @@ typedef struct DIR_W32 DIR;
/* Function prototypes */
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
-int readdir_r(DIR *, struct dirent *, struct dirent **);
int closedir(DIR *);
int rewinddir(DIR *);
@@ -48,12 +45,3 @@ int rewinddir(DIR *);
#endif
#endif /* READDIR_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/registry.c b/win32/registry.c
index eddfa78ede..99c3ce365f 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -299,12 +299,3 @@ char *GetIniPathFromRegistry()
}
return reg_location;
}/*}}}*/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/resource.h b/win32/resource.h
deleted file mode 100644
index 05e3111512..0000000000
--- a/win32/resource.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by php7dllts.rc
-//
-
-#ifndef PHP_WIN32_RESOURCE_H
-#define PHP_WIN32_RESOURCE_H
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/select.c b/win32/select.c
index 04d46ec679..b02766e4f3 100644
--- a/win32/select.c
+++ b/win32/select.c
@@ -1,8 +1,8 @@
-/*
+/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -164,12 +164,3 @@ PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *e
return retcode;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/win32/select.h b/win32/select.h
index 8e948f7d80..c23eb87ddb 100644
--- a/win32/select.h
+++ b/win32/select.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -24,12 +24,3 @@
PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/win32/sendmail.c b/win32/sendmail.c
index 273a3737c6..9e31028d58 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -1,11 +1,11 @@
-/*
+/*
* PHP Sendmail for Windows.
*
* This file is rewritten specificly for PHPFI. Some functionality
* has been removed (MIME and file attachments). This code was
* modified from code based on code written by Jarle Aase.
*
- * This class is based on the original code by Jarle Aase, see bellow:
+ * This class is based on the original code by Jarle Aase, see below:
* wSendmail.cpp It has been striped of some functionality to match
* the requirements of phpfi.
*
@@ -26,7 +26,6 @@
#include <string.h>
#include <math.h>
#include <malloc.h>
-#include <memory.h>
#include <winbase.h>
#include "sendmail.h"
#include "php_ini.h"
@@ -48,7 +47,7 @@
/* '*error_message' has to be passed around from php_mail() */
#define SMTP_ERROR_RESPONSE_SPEC "SMTP server response: %s"
-/* Convinient way to handle error messages from the SMTP server.
+/* Convenient way to handle error messages from the SMTP server.
response is ecalloc()d in Ack() itself and efree()d here
because the content is in *error_message now */
#define SMTP_ERROR_RESPONSE(response) { \
@@ -980,12 +979,3 @@ static int FormatEmailAddress(char* Buf, char* EmailAddress, char* FormatString)
}
return snprintf(Buf, MAIL_BUFFER_SIZE , FormatString , EmailAddress );
} /* end FormatEmailAddress() */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/sendmail.h b/win32/sendmail.h
index 47c89231cb..bb502cb7dd 100644
--- a/win32/sendmail.h
+++ b/win32/sendmail.h
@@ -47,12 +47,3 @@ static int Ack(char **server_response);
static unsigned long GetAddr(LPSTR szHost);
static int FormatEmailAddress(char* Buf, char* EmailAddress, char* FormatString);
#endif /* sendmail_h */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/signal.c b/win32/signal.c
new file mode 100644
index 0000000000..bdfd7033f3
--- /dev/null
+++ b/win32/signal.c
@@ -0,0 +1,164 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | 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: |
+ | http://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> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "php.h"
+#include "SAPI.h"
+
+#include "win32/console.h"
+
+/* true globals; only used from main thread and from kernel callback */
+static zval ctrl_handler;
+static DWORD ctrl_evt = (DWORD)-1;
+static zend_bool *vm_interrupt_flag = NULL;
+
+static void (*orig_interrupt_function)(zend_execute_data *execute_data);
+
+static void php_win32_signal_ctrl_interrupt_function(zend_execute_data *execute_data)
+{/*{{{*/
+ if (IS_UNDEF != Z_TYPE(ctrl_handler)) {
+ zval retval, params[1];
+
+ ZVAL_LONG(&params[0], ctrl_evt);
+
+ /* If the function returns, */
+ call_user_function(NULL, NULL, &ctrl_handler, &retval, 1, params);
+ zval_ptr_dtor(&retval);
+ }
+
+ if (orig_interrupt_function) {
+ orig_interrupt_function(execute_data);
+ }
+}/*}}}*/
+
+PHP_WINUTIL_API void php_win32_signal_ctrl_handler_init(void)
+{/*{{{*/
+ /* We are in the main thread! */
+ if (!php_win32_console_is_cli_sapi()) {
+ return;
+ }
+
+ orig_interrupt_function = zend_interrupt_function;
+ zend_interrupt_function = php_win32_signal_ctrl_interrupt_function;
+ vm_interrupt_flag = &EG(vm_interrupt);
+ ZVAL_UNDEF(&ctrl_handler);
+
+ REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_EVENT_CTRL_C", CTRL_C_EVENT, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_EVENT_CTRL_BREAK", CTRL_BREAK_EVENT, CONST_PERSISTENT | CONST_CS);
+}/*}}}*/
+
+PHP_WINUTIL_API void php_win32_signal_ctrl_handler_shutdown(void)
+{/*{{{*/
+ if (!php_win32_console_is_cli_sapi()) {
+ return;
+ }
+
+ zend_interrupt_function = orig_interrupt_function;
+ orig_interrupt_function = NULL;
+ vm_interrupt_flag = NULL;
+ ZVAL_UNDEF(&ctrl_handler);
+}/*}}}*/
+
+static BOOL WINAPI php_win32_signal_system_ctrl_handler(DWORD evt)
+{/*{{{*/
+ if (CTRL_C_EVENT != evt && CTRL_BREAK_EVENT != evt) {
+ return FALSE;
+ }
+
+ (void)InterlockedExchange8(vm_interrupt_flag, 1);
+
+ ctrl_evt = evt;
+
+ return TRUE;
+}/*}}}*/
+
+/* {{{ proto bool sapi_windows_set_ctrl_handler(callable handler, [, bool add = true])
+ Assigns a CTRL signal handler to a PHP function */
+PHP_FUNCTION(sapi_windows_set_ctrl_handler)
+{
+ zval *handler = NULL;
+ zend_bool add = 1;
+
+#if ZTS
+ if (!tsrm_is_main_thread()) {
+ php_error_docref(NULL, E_WARNING, "CTRL events can only be received on the main thread");
+ return;
+ }
+#endif
+
+ if (!php_win32_console_is_cli_sapi()) {
+ php_error_docref(NULL, E_WARNING, "CTRL events trapping is only supported on console");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &handler, &add) == FAILURE) {
+ return;
+ }
+
+ if (IS_NULL == Z_TYPE_P(handler)) {
+ zval_dtor(&ctrl_handler);
+ ZVAL_UNDEF(&ctrl_handler);
+ if (!SetConsoleCtrlHandler(NULL, add)) {
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ }
+
+ if (!zend_is_callable(handler, 0, NULL)) {
+ zend_string *func_name = zend_get_callable_name(handler);
+ php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", ZSTR_VAL(func_name));
+ zend_string_release_ex(func_name, 0);
+ RETURN_FALSE;
+ }
+
+ if (!SetConsoleCtrlHandler(NULL, FALSE) || !SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, add)) {
+ zend_string *func_name = zend_get_callable_name(handler);
+ php_error_docref(NULL, E_WARNING, "Unable to attach %s as a CTRL handler", ZSTR_VAL(func_name));
+ zend_string_release_ex(func_name, 0);
+ RETURN_FALSE;
+ }
+
+ zval_dtor(&ctrl_handler);
+ ZVAL_COPY(&ctrl_handler, handler);
+
+ RETURN_TRUE;
+}/*}}}*/
+
+PHP_FUNCTION(sapi_windows_generate_ctrl_event)
+{/*{{{*/
+ zend_long evt, pid = 0;
+ zend_bool ret = 0;
+
+ if (!php_win32_console_is_cli_sapi()) {
+ php_error_docref(NULL, E_WARNING, "CTRL events trapping is only supported on console");
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &evt, &pid) == FAILURE) {
+ return;
+ }
+
+ SetConsoleCtrlHandler(NULL, TRUE);
+
+ ret = (GenerateConsoleCtrlEvent(evt, pid) != 0);
+
+ if (IS_UNDEF != Z_TYPE(ctrl_handler)) {
+ ret = ret && SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, TRUE);
+ }
+
+ RETURN_BOOL(ret);
+}/*}}}*/
diff --git a/win32/signal.h b/win32/signal.h
index dd8c1091cc..2058dd873b 100644
--- a/win32/signal.h
+++ b/win32/signal.h
@@ -3,17 +3,13 @@
#include <signal.h>
+#include "win32/winutil.h"
+
#define SIGALRM 13
#define SIGVTALRM 26 /* virtual time alarm */
#define SIGPROF 27 /* profiling time alarm */
-#endif /* PHP_WIN32_SIGNAL_H */
+PHP_WINUTIL_API void php_win32_signal_ctrl_handler_init(void);
+PHP_WINUTIL_API void php_win32_signal_ctrl_handler_shutdown(void);
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+#endif /* PHP_WIN32_SIGNAL_H */
diff --git a/win32/sockets.c b/win32/sockets.c
index 588e5d9a05..461ce69888 100644
--- a/win32/sockets.c
+++ b/win32/sockets.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -88,12 +88,3 @@ error:
WSASetLastError(WSAECONNABORTED);
return -1;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/sockets.h b/win32/sockets.h
index cdd85f3c18..2e693f8840 100644
--- a/win32/sockets.h
+++ b/win32/sockets.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -27,12 +27,3 @@
PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2]);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/syslog.h b/win32/syslog.h
index d6a749d266..5ea75d8486 100644
--- a/win32/syslog.h
+++ b/win32/syslog.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -75,12 +75,3 @@ extern void vsyslog(int, const char *, va_list ap);
#endif /* SYSLOG_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/syslog.reg b/win32/syslog.reg
deleted file mode 100644
index a817b52faf..0000000000
--- a/win32/syslog.reg
+++ /dev/null
@@ -1,5 +0,0 @@
-REGEDIT4
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\PHP-7.3.0-dev]
-"TypesSupported"=dword:00000007
-"EventMessageFile"="g:\\test\\srctrunkinstall\\php7ts.dll"
diff --git a/win32/time.c b/win32/time.c
index cd5a7affdf..d1fe51458e 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -117,12 +117,3 @@ PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp )
}
return usleep( rqtp->tv_sec * 1000000 + rqtp->tv_nsec / 1000 );
}/*}}}*/
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/time.h b/win32/time.h
index 07afae487a..51090ccfd8 100644
--- a/win32/time.h
+++ b/win32/time.h
@@ -61,12 +61,3 @@ void php_win32_init_gettimeofday(void);
#endif
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/unistd.h b/win32/unistd.h
index 3d95ea06c7..0b9446149c 100644
--- a/win32/unistd.h
+++ b/win32/unistd.h
@@ -2,12 +2,3 @@
#define _PHP_WIN32_UNISTD_H
PHPAPI int usleep(unsigned int useconds);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/win32/winutil.c b/win32/winutil.c
index 78b5af6d7c..8cf5cdc1e7 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -19,19 +19,38 @@
#include "php.h"
#include "winutil.h"
+#include "codepage.h"
#include <bcrypt.h>
#include <lmcons.h>
+#include <imagehlp.h>
+
PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
{/*{{{*/
- char *buf = NULL;
+ wchar_t *bufw = NULL;
+ char *buf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, 0, NULL
+ DWORD ret = FormatMessageW(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&bufw, 0, NULL
);
- return (buf ? (char *) buf : "");
+ if (!ret || !bufw) {
+ return "";
+ }
+
+ buf = php_win32_cp_conv_w_to_any(bufw, ret, PHP_WIN32_CP_IGNORE_LEN_P);
+
+ LocalFree(bufw);
+
+ return (buf ? buf : "");
+}/*}}}*/
+
+PHP_WINUTIL_API void php_win32_error_msg_free(char *msg)
+{/*{{{*/
+ if (msg && msg[0]) {
+ free(msg);
+ }
}/*}}}*/
int php_win32_check_trailing_space(const char * path, const size_t path_len)
@@ -378,8 +397,11 @@ PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err)
/* 1113 */ , { ERROR_NO_UNICODE_TRANSLATION , EINVAL }
/* 1168 */ , { ERROR_NOT_FOUND , ENOENT }
/* 1224 */ , { ERROR_USER_MAPPED_FILE , EACCES }
+ /* 1314 */ , { ERROR_PRIVILEGE_NOT_HELD , EACCES }
/* 1816 */ , { ERROR_NOT_ENOUGH_QUOTA , ENOMEM }
, { ERROR_ABANDONED_WAIT_0 , EIO }
+ /* 1464 */ , { ERROR_SYMLINK_NOT_SUPPORTED , EINVAL }
+ /* 4390 */ , { ERROR_NOT_A_REPARSE_POINT , EINVAL }
};
for(i = 0; i < sizeof(errmap)/sizeof(struct code_to_errno_map); ++i)
@@ -416,11 +438,61 @@ PHP_WINUTIL_API char *php_win32_get_username(void)
return uname;
}/*}}}*/
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+static zend_always_inline BOOL is_compatible(const char *name, BOOL is_smaller, char *format, char **err)
+{/*{{{*/
+ /* work around ImageLoad() issue */
+ char *name_stripped = name;
+ if (name[0] == '.' && IS_SLASH(name[1])) {
+ name_stripped += 2;
+ }
+
+ PLOADED_IMAGE img = ImageLoad(name_stripped, NULL);
+
+ if (!img) {
+ DWORD _err = GetLastError();
+ char *err_txt = php_win32_error_to_msg(_err);
+ spprintf(err, 0, "Failed to load %s, %s", name, err_txt);
+ free(err_txt);
+ return FALSE;
+ }
+
+ DWORD major = img->FileHeader->OptionalHeader.MajorLinkerVersion;
+ DWORD minor = img->FileHeader->OptionalHeader.MinorLinkerVersion;
+
+#if PHP_LINKER_MAJOR == 14
+ /* VS 2015, 2017 and 2019 are binary compatible, but only forward compatible.
+ It should be fine, if we load a module linked with an older one into
+ the core linked with the newer one, but not the otherway round.
+ Analogously, it should be fine, if a PHP build linked with an older version
+ is used with a newer CRT, but not the other way round.
+ Otherwise, if the linker major version is not same, it is an error, as
+ per the current knowledge.
+
+ This check is to be extended as new VS versions come out. */
+ DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10);
+ DWORD comp_minor = (DWORD)(minor/10);
+ if (14 == major && (is_smaller ? core_minor < comp_minor : core_minor > comp_minor) || PHP_LINKER_MAJOR != major)
+#else
+ if (PHP_LINKER_MAJOR != major)
+#endif
+ {
+ spprintf(err, 0, format, name, major, minor, PHP_LINKER_MAJOR, PHP_LINKER_MINOR);
+ ImageUnload(img);
+ return FALSE;
+ }
+ ImageUnload(img);
+
+ return TRUE;
+}/*}}}*/
+
+PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *name, char **err)
+{/*{{{*/
+ return is_compatible(name, TRUE, "Can't load module '%s' as it's linked with %u.%u, but the core is linked with %d.%d", err);
+}/*}}}*/
+
+/* Expect a CRT name DLL. */
+PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *name, char **err)
+{/*{{{*/
+ return is_compatible(name, FALSE, "'%s' %u.%u is not compatible with this PHP build linked with %d.%d", err);
+}/*}}}*/
+
diff --git a/win32/winutil.h b/win32/winutil.h
index c08ab5e27e..f2faa95fa8 100644
--- a/win32/winutil.h
+++ b/win32/winutil.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | 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 |
@@ -26,8 +26,10 @@
#endif
PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
+PHP_WINUTIL_API void php_win32_error_msg_free(char *msg);
#define php_win_err() php_win32_error_to_msg(GetLastError())
+#define php_win_err_free(err) php_win32_error_msg_free(err)
int php_win32_check_trailing_space(const char * path, const size_t path_len);
PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
#ifdef PHP_EXPORTS
@@ -53,13 +55,7 @@ PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
PHP_WINUTIL_API char *php_win32_get_username(void);
-#endif
+PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *img, char **err);
+PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *img, char **err);
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+#endif
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
index 9050b40381..b4e58b1562 100644
--- a/win32/wsyslog.c
+++ b/win32/wsyslog.c
@@ -154,11 +154,3 @@ void openlog(const char *ident, int logopt, int facility)
PW32G(log_header) = malloc(header_len*sizeof(char));
sprintf_s(PW32G(log_header), header_len, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
}
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */