From 6821b67124604da690c5e9276d5370d679c63ac8 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Wed, 25 Mar 2009 19:39:21 -0400 Subject: Imported Upstream version 5.3.0RC1 --- win32/build/DSP.README | 37 +++ win32/build/Makefile | 59 ++-- win32/build/block.template.dsw | 15 + win32/build/buildconf.js | 27 +- win32/build/config.w32 | 201 +++++++------ win32/build/config.w32.h.in | 20 +- win32/build/configure.bat | 2 +- win32/build/configure.tail | 7 +- win32/build/confutils.js | 357 ++++++++++++++++++++--- win32/build/cvsclean.js | 4 +- win32/build/deplister.c | 2 +- win32/build/mkdist.php | 82 +++++- win32/build/projectgen.js | 625 +++++++++++++++++++++++++++++++++++++++++ win32/build/registersyslog.php | 89 +++--- win32/build/template.dsp | 81 ++++++ win32/build/template.dsw | 63 +++++ win32/build/template.rc | 64 +++-- win32/crypt_win32.c | 562 ------------------------------------ win32/crypt_win32.h | 33 --- win32/fnmatch.c | 198 +++++++++++++ win32/fnmatch.h | 54 ++++ win32/glob.c | 6 +- win32/glob.h | 15 +- win32/globals.c | 2 +- win32/grp.h | 2 +- win32/inet.c | 88 ++++++ win32/inet.h | 10 + win32/install.txt | 359 +++++------------------ win32/md5crypt.c | 163 ----------- win32/md5crypt.h | 37 --- win32/php5dll.dsp | 4 - win32/php5dllts.dsp | 4 - win32/php5ts_cli.rc2 | 2 +- win32/php_stdint.h | 244 ++++++++++++++++ win32/php_strtoi64.h | 7 + win32/php_win32_globals.h | 2 +- win32/readdir.h | 2 +- win32/registry.c | 2 +- win32/select.c | 2 +- win32/select.h | 2 +- win32/sockets.c | 71 +++++ win32/sockets.h | 26 ++ win32/strtoi64.c | 122 ++++++++ win32/syslog.h | 2 +- win32/time.c | 19 +- win32/time.h | 10 + win32/unistd.h | 2 +- win32/wfile.c | 2 +- win32/wfile.h | 2 +- win32/winutil.c | 2 +- 50 files changed, 2433 insertions(+), 1360 deletions(-) create mode 100644 win32/build/DSP.README create mode 100644 win32/build/block.template.dsw create mode 100644 win32/build/projectgen.js create mode 100644 win32/build/template.dsp create mode 100644 win32/build/template.dsw delete mode 100644 win32/crypt_win32.c delete mode 100644 win32/crypt_win32.h create mode 100644 win32/fnmatch.c create mode 100644 win32/fnmatch.h create mode 100644 win32/inet.c create mode 100644 win32/inet.h delete mode 100644 win32/md5crypt.c delete mode 100644 win32/md5crypt.h create mode 100644 win32/php_stdint.h create mode 100644 win32/php_strtoi64.h create mode 100644 win32/sockets.c create mode 100644 win32/sockets.h create mode 100644 win32/strtoi64.c (limited to 'win32') diff --git a/win32/build/DSP.README b/win32/build/DSP.README new file mode 100644 index 000000000..c6736578c --- /dev/null +++ b/win32/build/DSP.README @@ -0,0 +1,37 @@ +MSVC++ project file generation +============================== + +These files are only intended for use in debugging and profiling, +but can be used to create working binaries. However, they are very +unlikely to match the official PHP distributed binaries. + +With this in mind, the script will only generate basic .dsp files +for the modules that are currently configured. + +The switch for project file generation is a buildconf switch and +not a configure switch: + +> buildconf --add-project-files +> configure ... + +The resulting workspace files should appear at /win32/phpdll[ts].dsw +and (if any shared modules are configured) at /win32/php_modules.dsw, +after configure is run. + +If the .dsw files haven't generated in a sane way, the most likely reason +will be that the template files have become corrupted. They need DOS +line endings (CR/LF) in order to function. The affected files are: + +/win32/build/block.template.dsw +/win32/build/template.dsp +/win32/build/template.dsw + +Simply save them with DOS line endings, and bug it to me if basic +project file generation still fails (as in, you ran the command and +configure again after saving, and you have a working copy of MSVS +installed, but clicking on the workspace(s) doesn't give you anything). + +- Steph +sfox@php.net + +July 2008 diff --git a/win32/build/Makefile b/win32/build/Makefile index e4fe5ea18..f17aae31f 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -1,7 +1,7 @@ # +----------------------------------------------------------------------+ # | PHP Version 5 | # +----------------------------------------------------------------------+ -# | Copyright (c) 1997-2007 The PHP Group | +# | Copyright (c) 1997-2008 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 | @@ -14,13 +14,15 @@ # | Author: Wez Furlong | # +----------------------------------------------------------------------+ # -# $Id: Makefile,v 1.35.2.1.2.7 2008/10/10 23:38:14 pajoye Exp $ +# $Id: Makefile,v 1.35.2.1.2.6.2.10 2008/11/21 14:18:27 pajoye Exp $ # This is the makefile template for the win32 build CC="$(CL)" LD="$(LINK)" MC="$(MC)" MT="$(MT)" +RE2C="$(RE2C)" +PHP_BUILD=$(PHP_BUILD) MCFILE=$(BUILD_DIR)\wsyslog.rc @@ -28,10 +30,16 @@ all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS) build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) +!if $(RE2C) == "" +generated_files: build_dirs Zend\zend_ini_parser.c \ + Zend\zend_language_parser.c \ + $(PHPDEF) $(MCFILE) +!else generated_files: build_dirs Zend\zend_ini_parser.c \ Zend\zend_language_parser.c Zend\zend_ini_scanner.c \ Zend\zend_language_scanner.c \ $(PHPDEF) $(MCFILE) +!endif $(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES) type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def @@ -42,11 +50,13 @@ Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y $(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y -Zend\zend_ini_scanner.c: Zend\flex.skl Zend\zend_ini_scanner.l - $(FLEX) -B -i -SZend/flex.skl -Pini_ -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l +!if $(RE2C) != "" +Zend\zend_ini_scanner.c: Zend\zend_ini_scanner.l + $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l -Zend\zend_language_scanner.c: Zend\flex.skl Zend\zend_language_scanner.l - $(FLEX) -i -SZend/flex.skl -Pzend -oZend/zend_language_scanner.c Zend/zend_language_scanner.l +Zend\zend_language_scanner.c: Zend\zend_language_scanner.l + $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l +!endif PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res @@ -67,14 +77,14 @@ $(PHPDLL_RES): win32\build\template.rc $(RC) /fo $(PHPDLL_RES) /d FILE_DESCRIPTION="\"PHP Script Interpreter\"" \ /d FILE_NAME="\"$(PHPDLL)\"" /d PRODUCT_NAME="\"PHP Script Interpreter\"" \ /I$(BUILD_DIR) /d MC_INCLUDE="\"$(MCFILE)\"" \ - win32\build\template.rc + win32\build\template.rc $(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE) @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) -@$(_VC_MANIFEST_EMBED_DLL) - + $(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) - + $(BUILD_DIR) $(BUILD_DIRS_SUB): @echo Recreating build dirs @if not exist $(BUILD_DIR) mkdir $(BUILD_DIR) @@ -88,14 +98,19 @@ clean-sapi: -@del /F /Q $(BUILD_DIR)\$(PHPDLL) clean: clean-sapi - @echo Cleaning build dirs + @echo Cleaning distribution build dirs @for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @del /F /Q %D\*.* > NUL -@del /F /Q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp $(PHPDEF) $(BUILD_DIR)\php-$(PHP_VERSION_STRING)-Win32.zip $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)-Win32.zip > NUL - -rmdir /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) + -rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) clean-pecl: @echo Cleaning PECL targets only - -rmdir /s /q $(BUILD_DIR)\pecl + -rd /s /q $(BUILD_DIR)\pecl + +clean-all: + @echo Cleaning standard build dirs + @for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @rd /s /q %D + -@del /f /q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp $(PHPDEF) $(BUILD_DIR)\*.rc $(BUILD_DIR)\*.dbg $(BUILD_DIR)\*.bin $(BUILD_DIR)\php*.dll $(BUILD_DIR)\php*.exe > NUL test: < + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name php5ts + End Project Dependency +}}} + +############################################################################### diff --git a/win32/build/buildconf.js b/win32/build/buildconf.js index b329e78a5..6efe3d708 100644 --- a/win32/build/buildconf.js +++ b/win32/build/buildconf.js @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 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,12 +16,14 @@ +----------------------------------------------------------------------+ */ -/* $Id: buildconf.js,v 1.13.2.2.2.2 2009/01/03 03:27:47 kalle Exp $ */ +/* $Id: buildconf.js,v 1.13.2.2.2.1.2.5 2009/01/02 12:18:21 kalle Exp $ */ // This generates a configure script for win32 build WScript.StdOut.WriteLine("Rebuilding configure.js"); var FSO = WScript.CreateObject("Scripting.FileSystemObject"); var C = FSO.CreateTextFile("configure.js", true); +var B = FSO.CreateTextFile("configure.bat", true); +var DSP = false; var modules = ""; var MODULES = WScript.CreateObject("Scripting.Dictionary"); @@ -54,7 +56,7 @@ function find_config_w32(dirname) var fc = new Enumerator(f.SubFolders); var c, i, ok, n; var item = null; - var re_dep_line = new RegExp("ADD_EXTENSION_DEP\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\);", "gm"); + var re_dep_line = new RegExp("ADD_EXTENSION_DEP\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\)", "gm"); for (; !fc.atEnd(); fc.moveNext()) { @@ -72,7 +74,6 @@ function find_config_w32(dirname) continue; } - c = FSO.BuildPath(fc.item(), "config.w32"); if (FSO.FileExists(c)) { // WScript.StdOut.WriteLine(c); @@ -90,6 +91,7 @@ function find_config_w32(dirname) if (calls[i].match(re_dep_line)) { // WScript.StdOut.WriteLine("n depends on " + RegExp.$1); deps[deps.length] = RegExp.$1; + } } } @@ -202,6 +204,11 @@ function buildconf_process_args() WScript.StdOut.WriteLine("Adding " + argval + " to the module search path"); module_dirs[module_dirs.length] = argval; } + + if (argname == '--add-project-files') { + WScript.StdOut.WriteLine("Adding dsp templates into the mix"); + DSP = true; + } } } @@ -211,6 +218,16 @@ buildconf_process_args(); C.WriteLine("/* This file automatically generated from win32/build/confutils.js */"); C.Write(file_get_contents("win32/build/confutils.js")); +// If project files were requested, pull in the code to generate them +if (DSP == true) { + C.WriteLine('PHP_DSP="yes"'); + C.WriteBlankLines(1); + C.Write(file_get_contents("win32/build/projectgen.js")); +} else { + C.WriteLine('PHP_DSP="no"'); + C.WriteBlankLines(1); +} + // Pull in code from sapi and extensions modules = file_get_contents("win32/build/config.w32"); @@ -259,3 +276,5 @@ C.Write(modules); C.WriteBlankLines(1); C.Write(file_get_contents("win32/build/configure.tail")); +B.WriteLine("@echo off"); +B.WriteLine("cscript /nologo configure.js %*"); diff --git a/win32/build/config.w32 b/win32/build/config.w32 index a50c33502..f95d39a9b 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -1,57 +1,40 @@ // vim:ft=javascript -// $Id: config.w32,v 1.40.2.8.2.11 2008/10/10 23:38:14 pajoye Exp $ +// $Id: config.w32,v 1.40.2.8.2.10.2.45 2009/03/18 10:18:10 dmitry Exp $ // "Master" config file; think of it as a configure.in // equivalent. ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); -PATH_PROG('cl'); CL = PATH_PROG('cl'); if (!CL) { ERROR("MS C++ compiler is required"); } -// Which version of the compiler do we have ? -function probe_msvc_compiler_version(CL) -{ - // tricky escapes to get stderr redirection to work - var banner = execute('cmd /c ""' + CL + '" 2>&1"'); - if (banner.match(/(\d+)\.(\d+)\.(\d+)(\.(\d+))?/)) { - return RegExp.$1; - } - return 0; -} -VCVERS = probe_msvc_compiler_version(CL); -STDOUT.WriteLine("Detected MS compiler version " + VCVERS); +/* 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 +// Which version of the compiler do we have? +VCVERS = probe_binary(CL).substr(0, 5).replace('.', ''); +STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]); +AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version"); +DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); +AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); -// 12 is VC6 -// 13 is vs.net 2003 -// 14 is vs.net 2005 - // do we use x64 or 80x86 version of compiler? -function probe_msvc_compiler_x64(CL) -{ - // tricky escapes to get stderr redirection to work - var banner = execute('cmd /c ""' + CL + '" 2>&1"'); - if (banner.match(/x64/)) { - return 1; - } - return 0; -} - -X64 = probe_msvc_compiler_x64(CL); +X64 = probe_binary(CL, 64); if (X64) { - STDOUT.WriteLine("Detected 64-bit compiler"); + STDOUT.WriteLine(" Detected 64-bit compiler"); } else { - STDOUT.WriteLine("Detected 32-bit compiler"); + STDOUT.WriteLine(" Detected 32-bit compiler"); } - AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); // cygwin now ships with link.exe. Avoid searching the cygwin path // for this, as we want the MS linker, not the fileutil PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); - PATH_PROG('nmake'); // we don't want to define LIB, as that will override the default library path @@ -60,10 +43,31 @@ PATH_PROG('lib', null, 'MAKE_LIB'); if (!PATH_PROG('bison')) { ERROR('bison is required') } -if (!PATH_PROG('flex')) { - ERROR('flex is required') + +// There's a minimum requirement for re2c.. +MINRE2C = "0.13.4"; + +RE2C = PATH_PROG('re2c'); +if (RE2C) { + var intvers, intmin; + var pattern = /\./g; + + RE2CVERS = probe_binary(RE2C, "version"); + STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); + + intvers = RE2CVERS.replace(pattern, '') - 0; + intmin = MINRE2C.replace(pattern, '') - 0; + + if (intvers < intmin) { + STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); + STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); + DEFINE('RE2C', ''); + } else { + DEFINE('RE2C_FLAGS', ''); + } +} else { + STDOUT.WriteLine('Parsers will not be regenerated'); } -PATH_PROG('re2c'); PATH_PROG('zip'); PATH_PROG('lemon'); @@ -71,7 +75,9 @@ PATH_PROG('lemon'); PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); // Try locating manifest tool -PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); +if (VCVERS > 1200) { + PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); +} // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); @@ -102,7 +108,7 @@ if (PHP_PREFIX == '') { } DEFINE('PHP_PREFIX', PHP_PREFIX); -DEFINE("BASE_INCLUDES", "/I . /I main /I regex /I Zend /I TSRM /I ext "); +DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext "); // CFLAGS for building the PHP dll DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS \ @@ -114,7 +120,7 @@ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS"); -if (VCVERS < 14) { +if (VCVERS < 1400) { // Enable automatic precompiled headers ADD_FLAG('CFLAGS', ' /YX '); @@ -124,7 +130,7 @@ if (VCVERS < 14) { } } -if (VCVERS >= 14) { +if (VCVERS >= 1400) { // fun stuff: MS deprecated ANSI stdio and similar functions // disable annoying warnings. In addition, time_t defaults // to 64-bit. Ask for 32-bit. @@ -140,6 +146,10 @@ if (VCVERS >= 14) { } } +if (VCVERS >= 1500) { + ADD_FLAG('CFLAGS', ' /MP '); +} + // General link flags DEFINE("LDFLAGS", "/nologo /version:" + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); @@ -151,8 +161,8 @@ DEFINE("DLL_LDFLAGS", "/dll "); DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); // General 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"); +// 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"); // Set some debug/release specific options if (PHP_DEBUG == "yes") { @@ -169,8 +179,8 @@ if (PHP_DEBUG == "yes") { 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 /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"); } @@ -178,7 +188,7 @@ if (PHP_DEBUG == "yes") { if (PHP_ZTS == "yes") { ADD_FLAG("CFLAGS", "/D ZTS=1"); } - + DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts"); @@ -188,51 +198,59 @@ ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); // set up the build dir and DLL name if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS"); - DEFINE("PHPDLL", "php5ts_debug.dll"); - DEFINE("PHPLIB", "php5ts_debug.lib"); + DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib"); } else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug"); - DEFINE("PHPDLL", "php5_debug.dll"); - DEFINE("PHPLIB", "php5_debug.lib"); + DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib"); } else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS"); - DEFINE("PHPDLL", "php5ts.dll"); - DEFINE("PHPLIB", "php5ts.lib"); + DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib"); } else if (PHP_DEBUG == "no" && PHP_ZTS == "no") { DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release"); - DEFINE("PHPDLL", "php5.dll"); - DEFINE("PHPLIB", "php5.lib"); + DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll"); + DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib"); } // Find the php_build dir - it contains headers and libraries // that we need -ARG_WITH('php-build', 'Path to where you extracted http://www.php.net/extra/win32build.zip. Assumes that it is a sibling of this source dir (..\\php_build) if not specified', 'no'); +ARG_WITH('php-build', 'Path to where you extracted the development libraries (http://wiki.php.net/internals/windows/libs). Assumes that it is a sibling of this source dir (..\\deps) if not specified', 'no'); if (PHP_PHP_BUILD == 'no') { - if (FSO.FolderExists("..\\php_build")) { - PHP_PHP_BUILD = "..\\php_build"; + if (FSO.FolderExists("..\\deps")) { + PHP_PHP_BUILD = "..\\deps"; } else { - if (X64) { - if (FSO.FolderExists("..\\win64build")) { - PHP_PHP_BUILD = "..\\win64build"; - } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win64-dev\\php_build"; - } + if (FSO.FolderExists("..\\php_build")) { + PHP_PHP_BUILD = "..\\php_build"; } else { - if (FSO.FolderExists("..\\win32build")) { - PHP_PHP_BUILD = "..\\win32build"; - } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { - PHP_PHP_BUILD = "..\\php-win32-dev\\php_build"; + if (X64) { + if (FSO.FolderExists("..\\win64build")) { + PHP_PHP_BUILD = "..\\win64build"; + } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) { + PHP_PHP_BUILD = "..\\php-win64-dev\\php_build"; + } + } else { + if (FSO.FolderExists("..\\win32build")) { + PHP_PHP_BUILD = "..\\win32build"; + } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) { + PHP_PHP_BUILD = "..\\php-win32-dev\\php_build"; + } } } } } +DEFINE("PHP_BUILD", PHP_PHP_BUILD); ARG_WITH('extra-includes', 'Extra include path to use when building everything', ''); ARG_WITH('extra-libs', 'Extra library path to use when linking everything', ''); -var php_usual_include_suspects = PHP_PHP_BUILD+"\\include;..\\bindlib_w32"; -var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib;..\\bindlib_w32"; +var php_usual_include_suspects = PHP_PHP_BUILD+"\\include"; +var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib"; + +ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" '); +ADD_FLAG("LDFLAGS", '/libpath:"\\"' + php_usual_lib_suspects + '\\"" '); // Poke around for some headers function probe_basic_headers() @@ -243,17 +261,6 @@ function probe_basic_headers() php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include"; php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib"; } - - p = CHECK_HEADER_ADD_INCLUDE("arpa\\nameser.h", "CFLAGS", php_usual_include_suspects); - - // hack to catch common location of libs - if (typeof(p) == "string") { - p = p.replace(new RegExp("include$"), "lib"); - ADD_FLAG("LDFLAGS", '/libpath:"' + p + '" '); - php_usual_lib_suspects += ";" + p; - } else if (!p) { - ERROR("We really need that arpa\\nameser.h file - it is part of the win32build package"); - } } function add_extra_dirs() @@ -274,7 +281,7 @@ function add_extra_dirs() for (i = 0; i < path.length; i++) { f = FSO.GetAbsolutePathName(path[i]); if (FSO.FolderExists(f)) { - if (VCVERS <= 12 && f.indexOf(" ") >= 0) { + if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); } else { ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); @@ -287,7 +294,6 @@ function add_extra_dirs() probe_basic_headers(); add_extra_dirs(); -CHECK_LIB("resolv.lib"); //DEFINE("PHP_BUILD", PHP_PHP_BUILD); @@ -305,21 +311,29 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_sprintf.c zend_ini.c zend_qsort.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_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \ + zend_float.c"); -ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.c fopen_wrappers.c \ +ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.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 php_logos.c output.c internal_functions.c php_sprintf.c"); +ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); + +// Newer versions have it +if (VCVERS <= 1300) { + ADD_SOURCES("win32", "strtoi64.c"); +} +if (VCVERS >= 1400) { + 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"); + userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c"); -ADD_SOURCES("win32", "crypt_win32.c glob.c md5crypt.c readdir.c \ +ADD_SOURCES("win32", "glob.c readdir.c \ registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c globals.c"); -ADD_SOURCES("regex", "regcomp.c regerror.c regexec.c regfree.c"); - STDOUT.WriteBlankLines(1); /* Can we build with IPv6 support? */ @@ -343,10 +357,10 @@ ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE)); ARG_ENABLE("zend-multibyte", "Enable Zend multibyte encoding support", "no"); if (PHP_ZEND_MULTIBYTE == "yes") { - STDOUT.WriteLine("Enabling Zend multibyte encoding support"); - AC_DEFINE('ZEND_MULTIBYTE', 1); + STDOUT.WriteLine("Enabling Zend multibyte encoding support"); + AC_DEFINE('ZEND_MULTIBYTE', 1); } - + AC_DEFINE('HAVE_USLEEP', 1); AC_DEFINE('HAVE_STRCOLL', 1); @@ -364,3 +378,10 @@ if (PHP_SNAPSHOT_TEMPLATE == "no") { } DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE); + +if (PHP_DSP != "no") { + if (FSO.FolderExists("tmp")) { + FSO.DeleteFolder("tmp"); + } + FSO.CreateFolder("tmp"); +} diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in index ca37f22d6..05a9615ac 100644 --- a/win32/build/config.w32.h.in +++ b/win32/build/config.w32.h.in @@ -1,8 +1,12 @@ /* Build Configuration Template for Win32. - $Id: config.w32.h.in,v 1.7.2.4.2.3 2007/07/11 17:36:56 johannes Exp $ + $Id: config.w32.h.in,v 1.7.2.4.2.3.2.11 2009/02/02 09:40:55 pajoye Exp $ */ +/* Define the minimum supported version */ +#define _WIN32_WINNT 0x500 +#define NTDDI_VERSION _WIN32_WIN2K + /* Default PHP / PEAR directories */ #define PHP_CONFIG_FILE_PATH (getenv("SystemRoot"))?getenv("SystemRoot"):"" #define CONFIGURATION_FILE_PATH "php.ini" @@ -19,9 +23,9 @@ /* Enable / Disable crypt() function (default: enabled) */ #define HAVE_CRYPT 1 #define PHP_STD_DES_CRYPT 1 -#define PHP_EXT_DES_CRYPT 0 +#define PHP_EXT_DES_CRYPT 1 #define PHP_MD5_CRYPT 1 -#define PHP_BLOWFISH_CRYPT 0 +#define PHP_BLOWFISH_CRYPT 1 /* PHP Runtime Configuration */ #define PHP_URL_FOPEN 1 @@ -37,6 +41,7 @@ #define HAVE_GETSERVBYPORT 1 #define HAVE_GETPROTOBYNAME 1 #define HAVE_GETPROTOBYNUMBER 1 +#define HAVE_GETHOSTNAME 1 #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 @@ -48,12 +53,15 @@ /* its in win32/time.c */ #define HAVE_USLEEP 1 +#define HAVE_NANOSLEEP 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 +#undef HAVE_SIGSETJMP #undef HAVE_IODBC #define HAVE_LIBDL 1 #define HAVE_GETTIMEOFDAY 1 @@ -131,6 +139,7 @@ # define SIZEOF_SIZE_T 4 # define SIZEOF_PTRDIFF_T 4 #endif +#define HAVE_FNMATCH #define HAVE_GLOB #define PHP_SHLIB_SUFFIX "dll" #define HAVE_SQLDATASOURCES @@ -138,6 +147,10 @@ /* 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 + /* Win32 support proc_open */ #define PHP_CAN_SUPPORT_PROC_OPEN 1 @@ -154,4 +167,3 @@ # define _USE_32BIT_TIME_T 1 #endif #define HAVE_STDLIB_H 1 - diff --git a/win32/build/configure.bat b/win32/build/configure.bat index df63cd46d..45d273dc6 100644 --- a/win32/build/configure.bat +++ b/win32/build/configure.bat @@ -1,2 +1,2 @@ @echo off -cscript /nologo configure.js %* \ No newline at end of file +cscript /nologo configure.js %* diff --git a/win32/build/configure.tail b/win32/build/configure.tail index 49e537825..ad81c3349 100644 --- a/win32/build/configure.tail +++ b/win32/build/configure.tail @@ -1,6 +1,11 @@ // vim:ft=javascript -// $Id: configure.tail,v 1.1 2003/12/02 23:17:04 wez Exp $ +// $Id: configure.tail,v 1.1.8.1 2008/12/25 00:09:49 pajoye Exp $ // tail end of configure +if (sapi_enabled.length < 1) { + MESSAGE(""); + ERROR("No SAPI selected, please enable at least one SAPI."); +} + generate_files(); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 5f7cb0674..15ff54b9c 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3,7 +3,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -// $Id: confutils.js,v 1.60.2.1.2.10 2008/01/17 21:17:29 cellog Exp $ +// $Id: confutils.js,v 1.60.2.1.2.8.2.32 2008/12/25 00:08:51 pajoye Exp $ var STDOUT = WScript.StdOut; var STDERR = WScript.StdErr; @@ -26,6 +26,28 @@ var FSO = WScript.CreateObject("Scripting.FileSystemObject"); var MFO = null; var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive"); var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles"); +var DSP_FLAGS = new Array(); + +/* Store the enabled extensions (summary + QA check) */ +var extensions_enabled = new Array(); + +/* Store the SAPI enabled (summary + QA check) */ +var sapi_enabled = new Array(); + +/* Mapping CL version > human readable name */ +var VC_VERSIONS = new Array(); +VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)'; +VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)'; +VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)'; +VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)'; +VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; + +var VC_VERSIONS_SHORT = new Array(); +VC_VERSIONS_SHORT[1200] = 'VC6'; +VC_VERSIONS_SHORT[1300] = 'VC7'; +VC_VERSIONS_SHORT[1310] = 'VC7.1'; +VC_VERSIONS_SHORT[1400] = 'VC8'; +VC_VERSIONS_SHORT[1500] = 'VC9'; if (PROGRAM_FILES == null) { PROGRAM_FILES = "C:\\Program Files"; @@ -98,6 +120,27 @@ function execute(command_line) return ret; } +function probe_binary(EXE, what) +{ + // tricky escapes to get stderr redirection to work + var command = 'cmd /c ""' + EXE; + if (what == "version") { + command = command + '" -v"'; + } + var version = execute(command + '" 2>&1"'); + + if (what == "64") { + if (version.match(/x64/)) { + return 1; + } + } else { + if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) { + return RegExp.$1; + } + } + return 0; +} + function condense_path(path) { path = FSO.GetAbsolutePathName(path); @@ -347,7 +390,7 @@ can be built that way. \ var snapshot_build_exclusions = new Array( 'debug', 'crt-debug', 'lzf-better-compression', - 'php-build', 'snapshot-template', + 'php-build', 'snapshot-template', 'ereg', 'pcre-regex', 'fastcgi', 'force-cgi-redirect', 'path-info-check', 'zts', 'ipv6', 'memory-limit', 'zend-multibyte', 'fd-setsize', 'memory-manager', 't1lib' @@ -416,7 +459,11 @@ can be built that way. \ } } if (force) { - argval = "no"; + if (arg.defval == '') { + argval = ''; + } else { + argval = "no"; + } shared = false; } } @@ -432,7 +479,7 @@ can be built that way. \ nicefile.WriteLine(nice + " %*"); nicefile.Close(); - AC_DEFINE('CONFIGURE_COMMAND', nice); + AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line"); } function DEFINE(name, value) @@ -501,6 +548,7 @@ function PATH_PROG(progname, additional_paths, symbol) var exe; var place; var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin"; + var php_build_bin_path = PHP_PHP_BUILD + "\\bin" exe = progname + ".exe"; @@ -510,6 +558,8 @@ function PATH_PROG(progname, additional_paths, symbol) additional_paths += ";" + cyg_path; } + additional_paths = additional_paths + ";" + php_build_bin_path; + place = search_paths(exe, additional_paths, "PATH"); if (place == true) { @@ -583,6 +633,17 @@ function CHECK_LIB(libnames, target, path_to_check, common_name) // libnames can be ; separated list of accepted library names libnames = libnames.split(';'); + // for debug builds, lib may have _debug appended, we want that first + if (PHP_DEBUG == "yes") { + var length = libnames.length; + for (var i = 0; i < length; i++) { + var name = new String(libnames[i]); + rExp = /.lib$/i; + name = name.replace(rExp,"_debug.lib"); + libnames.unshift(name); + } + } + var i, j, k, libname; var location = false; var path = path_to_check.split(';'); @@ -832,14 +893,24 @@ function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env /* emits rule to generate version info for a SAPI * or extension. Returns the name of the .res file * that will be generated */ -function generate_version_info_resource(makefiletarget, creditspath) +function generate_version_info_resource(makefiletarget, basename, creditspath, sapi) { var resname = makefiletarget + ".res"; - var res_desc = "PHP " + makefiletarget; - var res_prod_name = res_desc; + var res_desc = makefiletarget; + var res_prod_name = "PHP " + makefiletarget; var credits; var thanks = ""; var logo = ""; + var debug = ""; + var project_url = "http://www.php.net"; + var project_header = creditspath + "/php_" + basename + ".h"; + var versioning = ""; + + if (sapi) { + var internal_name = basename.toUpperCase() + " SAPI"; + } else { + var internal_name = basename.toUpperCase() + " extension"; + } if (FSO.FileExists(creditspath + '/CREDITS')) { credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1); @@ -857,8 +928,34 @@ function generate_version_info_resource(makefiletarget, creditspath) credits.Close(); } + if (creditspath.match(new RegExp("pecl"))) { + /* PECL project url - this will eventually work correctly for all */ + project_url = "http://pecl.php.net/" + basename; + + /* keep independent versioning PECL-specific for now */ + if (FSO.FileExists(project_header)) { + if (header = FSO.OpenTextFile(project_header, 1)) { + contents = header.ReadAll(); + /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */ + if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) { + project_version = RegExp.$2; + file_version = RegExp.$3.split('.'); + if (!file_version[2]) { + file_version[2] = 0; + } + versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version; + } + header.Close(); + } + } + } + if (makefiletarget.match(new RegExp("\\.exe$"))) { - logo = " /D WANT_LOGO "; + logo = " /d WANT_LOGO "; + } + + if (PHP_DEBUG != "no") { + debug = " /d _DEBUG"; } /** @@ -866,20 +963,21 @@ function generate_version_info_resource(makefiletarget, creditspath) */ if (FSO.FileExists(creditspath + '\\template.rc')) { MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc"); - MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + - ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + makefiletarget + - '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + '\\"" /d THANKS_GUYS="\\"' + - thanks + '\\"" ' + creditspath + '\\template.rc'); + MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + + versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' + + creditspath + '\\template.rc'); return resname; } MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc"); - MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + - ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + makefiletarget + - '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + '\\"" /d THANKS_GUYS="\\"' + - thanks + '\\"" win32\\build\\template.rc'); + MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d URL="\\"' + project_url + + '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc'); MFO.WriteBlankLines(1); - return resname; } @@ -913,7 +1011,7 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) MFO.WriteBlankLines(1); /* generate a .res file containing version information */ - resname = generate_version_info_resource(makefiletarget, configure_module_dirname); + resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true); MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete"); @@ -949,7 +1047,12 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) ADD_FLAG("SAPI_TARGETS", makefiletarget); } + if (PHP_DSP != "no") { + generate_dsp_file(sapiname, configure_module_dirname, file_list, false); + } + MFO.WriteBlankLines(1); + sapi_enabled[sapi_enabled.length] = [sapiname]; } function ADD_DIST_FILE(filename) @@ -986,15 +1089,24 @@ function ADD_EXTENSION_DEP(extname, dependson, optional) try { dep_present = eval("PHP_" + DEP); - dep_shared = eval("PHP_" + DEP + "_SHARED"); + + if (dep_present != "no") { + try { + dep_shared = eval("PHP_" + DEP + "_SHARED"); + } catch (e) { + dep_shared = false; + } + } + } catch (e) { dep_present = "no"; - dep_shared = false; } - + if (optional) { - if (dep_present == "no") - return; + if (dep_present == "no") { + MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled"); + return false; + } } var ext_shared = eval("PHP_" + EXT + "_SHARED"); @@ -1002,22 +1114,37 @@ function ADD_EXTENSION_DEP(extname, dependson, optional) if (dep_shared) { if (!ext_shared) { if (optional) { - return; + MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled"); + return false; } ERROR("static " + extname + " cannot depend on shared " + dependson); } + ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)"); ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib"); ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib"); + } else { + if (dep_present == "no") { if (ext_shared) { - WARNING(extname + " has a missing dependency: " + dependson); - } else { - ERROR("Cannot build " + extname + "; " + dependson + " not enabled"); + WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found"); + + var dllname = ' php_' + extname + '.dll'; + + if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) { + REMOVE_TARGET(dllname, 'PECL_TARGETS'); + } + + return false; + } + + ERROR("Cannot build " + extname + "; " + dependson + " not enabled"); + return false; } - } + } // dependency is statically built-in to PHP + return true; } function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) @@ -1025,10 +1152,13 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) var objs = null; var EXT = extname.toUpperCase(); var extname_for_printing; - + if (shared == null) { eval("shared = PHP_" + EXT + "_SHARED;"); + } else { + eval("PHP_" + EXT + "_SHARED = shared;"); } + if (cflags == null) { cflags = ""; } @@ -1062,7 +1192,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) } var libname = dllname.substring(0, dllname.length-4) + ".lib"; - var resname = generate_version_info_resource(dllname, configure_module_dirname); + var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false); var ld = "@$(CC)"; MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname); @@ -1109,6 +1239,12 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')'); } ADD_FLAG("CFLAGS_" + EXT, cflags); + + if (PHP_DSP != "no") { + generate_dsp_file(extname, configure_module_dirname, file_list, shared); + } + + extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static']; } function ADD_SOURCES(dir, file_list, target, obj_dir) @@ -1198,6 +1334,30 @@ function ADD_SOURCES(dir, file_list, target, obj_dir) DEFINE(sym, tv); } +function REMOVE_TARGET(dllname, flag) +{ + var dllname = dllname.replace(/\s/g, ""); + var EXT = dllname.replace(/php_(\S+)\.dll/, "$1").toUpperCase(); + var php_flags = configure_subst.Item("CFLAGS_PHP"); + + if (configure_subst.Exists(flag)) { + var targets = configure_subst.Item(flag); + + if (targets.match(dllname)) { + configure_subst.Remove(flag); + targets = targets.replace(dllname, ""); + targets = targets.replace(/\s+/, " "); + targets = targets.replace(/\s$/, ""); + configure_subst.Add(flag, targets); + configure_hdr.Add("HAVE_" + EXT, new Array(0, "")); + configure_subst.Item("CFLAGS_PHP") = php_flags.replace(" /D COMPILE_DL_" + EXT, ""); + extensions_enabled.pop(); + return true; + } + } + return false; +} + function generate_internal_functions() { var infile, outfile; @@ -1226,6 +1386,107 @@ function generate_internal_functions() outfile.Close(); } +function output_as_table(header, ar_out) +{ + var l = header.length; + var cols = 80; + var fixedlenght = ""; + var t = 0; + var i,j,k,m; + var out = "| "; + var min = new Array(l); + var max = new Array(l); + + if (l != ar_out[0].length) { + STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length ); + return; + } + + for (j=0; j < l; j++) { + var tmax, tmin; + + /*Figure out the max length per column */ + tmin = 0; + tmax = 0; + for (k = 0; k < ar_out.length; k++) { + var t = ar_out[k][j].length; + if (t > tmax) tmax = t; + else if (t < tmin) tmin = t; + } + if (tmax > header[j].length) { + max[j] = tmax; + } else { + max[j] = header[j].length; + } + if (tmin < header[j].length) { + min[j] = header[j].length; + } + } + + sep = ""; + k = 0; + for (i = 0; i < l; i++) { + k += max[i] + 3; + } + k++; + + for (j=0; j < k; j++) { + sep += "-"; + } + + STDOUT.WriteLine(sep); + out = "|"; + for (j=0; j < l; j++) { + out += " " + header[j]; + for (var i = 0; i < (max[j] - header[j].length); i++){ + out += " "; + } + out += " |"; + } + STDOUT.WriteLine(out); + + STDOUT.WriteLine(sep); + + out = "|"; + for (i=0; i < ar_out.length; i++) { + line = ar_out[i]; + for (j=0; j < l; j++) { + out += " " + line[j]; + for (var k = 0; k < (max[j] - line[j].length); k++){ + out += " "; + } + out += " |"; + } + STDOUT.WriteLine(out); + out = "|"; + } + + STDOUT.WriteLine(sep); +} + +function write_summary() +{ + var ar = new Array(); + + STDOUT.WriteBlankLines(2); + + STDOUT.WriteLine("Enabled extensions:"); + output_as_table(["Extension", "Mode"], extensions_enabled.sort()); + STDOUT.WriteBlankLines(2); + + STDOUT.WriteLine("Enabled SAPI:"); + output_as_table(["Sapi Name"], sapi_enabled); + STDOUT.WriteBlankLines(2); + + ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"]; + ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"]; + ar[2] = ['Compiler', VC_VERSIONS[VCVERS]]; + ar[3] = ['Architecture', X64 ? 'x64' : 'x86']; + + output_as_table(["",""], ar); + STDOUT.WriteBlankLines(2); +} + function generate_files() { var i, dir, bd, last; @@ -1239,7 +1500,7 @@ function generate_files() if (!FSO.FolderExists(dir)) { FSO.CreateFolder(dir); } - + for (i = 0; i < build_dirs.length; i++) { bd = FSO.BuildPath(dir, build_dirs[i]); if (bd == last) { @@ -1251,15 +1512,25 @@ function generate_files() FSO.CreateFolder(bd); } } - + + if (PHP_DSP != "no") { + generate_dsp_file("TSRM", "TSRM", null, false); + generate_dsp_file("Zend", "Zend", null, false); + generate_dsp_file("win32", "win32", null, false); + generate_dsp_file("main", "main", null, false); + generate_dsp_file("streams", "main\\streams", null, false); + copy_dsp_files(); + } + STDOUT.WriteLine("Generating files..."); generate_makefile(); generate_internal_functions(); generate_config_h(); - STDOUT.WriteLine("Done."); STDOUT.WriteBlankLines(1); + write_summary(); + if (PHP_SNAPSHOT_BUILD != "no") { STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot"); } else { @@ -1380,11 +1651,20 @@ function ADD_FLAG(name, flags, target) configure_subst.Remove(name); } configure_subst.Add(name, flags); + + if (PHP_DSP != "no") { + if (flags && (name.substr(name.length-3) != "PHP") && (name.substr(0, 7) == "CFLAGS_")) { + DSP_FLAGS[DSP_FLAGS.length] = new Array(name, flags); + } + } } function get_define(name) { - return configure_subst.Item(name); + if (configure_subst.Exists(name)) { + return configure_subst.Item(name); + } + return ""; } // Add a .def to the core to export symbols @@ -1410,12 +1690,17 @@ function AC_DEFINE(name, value, comment, quote) var item = new Array(value, comment); if (configure_hdr.Exists(name)) { var orig_item = configure_hdr.Item(name); - STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + item[0]); + STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]); } else { configure_hdr.Add(name, item); } } +function MESSAGE(msg) +{ + STDOUT.WriteLine("" + msg); +} + function ERROR(msg) { STDERR.WriteLine("ERROR: " + msg); diff --git a/win32/build/cvsclean.js b/win32/build/cvsclean.js index 7109cae55..c654bbc6a 100644 --- a/win32/build/cvsclean.js +++ b/win32/build/cvsclean.js @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 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,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cvsclean.js,v 1.5.2.1.2.1 2007/01/01 19:32:09 iliaa Exp $ */ +/* $Id: cvsclean.js,v 1.5.2.1.2.1.2.1 2008/07/20 02:20:31 sfox Exp $ */ // Cleans up files that do not belong in CVS var FSO = WScript.CreateObject("Scripting.FileSystemObject"); diff --git a/win32/build/deplister.c b/win32/build/deplister.c index f6a8c2acc..6d90aa49c 100644 --- a/win32/build/deplister.c +++ b/win32/build/deplister.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: deplister.c,v 1.3.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: deplister.c,v 1.3.2.1.2.1.2.2 2008/12/31 11:15:49 sebastian Exp $ */ /* This little application will list the DLL dependencies for a PE * module to it's stdout for use by distro/installer building tools */ diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php index a529b2940..39a28d17d 100644 --- a/win32/build/mkdist.php +++ b/win32/build/mkdist.php @@ -1,4 +1,4 @@ - 1) { + if (arr[i].match('alloca.c') || + arr[i].match(/internal_functions_(nw|win32)\.c/) || + arr[i].match(/flock\.(c|h)/) || + arr[i].match(/zend_static_allocator\.(c|h)/) || + arr[i].match(/zend_(ini|language)_scanner_defs\.h/)) { + continue; + } + + libpath = arr[i].substr(2, arr[i].lastIndexOf("\\") - 2); + if (libpath) { + libpath = "\\" + libpath; + } + + src.WriteLine("# Begin Source File"); + src.WriteLine("SOURCE=" + arr[i]); + src.WriteLine('# PROP Intermediate_Dir "' + intpath + out + '\\' + path + libpath + '"'); + src.WriteLine("# End Source File"); + src.WriteBlankLines(1); + } + } + + src.Close(); + return; +} + +/* generate list of text files */ +function generate_text_filelist(ext, ext_dir) +{ + var txtdir = FSO.GetFolder(ext_dir); + + block = '# Begin Group "Text Files"\r\n\# PROP Default_Filter ""\r\n\r\n'; + txt = new Enumerator(txtdir.Files); + + for (; !txt.atEnd(); txt.moveNext()) { + fname = FSO.GetFileName(txt.item()); + munged = fname.replace(ext, ""); /* TSRM...! */ + + if (munged.match(/[A-Z]{4}/)){ + block += "# Begin Source File\r\n"; + block += "SOURCE=./" + fname + "\r\n"; + block += "# End Source File\r\n\r\n"; + } + } + + block += "# End Group\r\n"; + return block; +} + +/* generate list of resource files */ +function generate_resource_filelist(ext, ext_dir) +{ + var resdir = FSO.GetFolder(ext_dir); + res = new Enumerator(resdir.Files); + block = ""; + + for (; !res.atEnd(); res.moveNext()) { + fname = FSO.GetFileName(res.item()); + + if (fname.match(/\.(ico|rc)/)) { + block += "# Begin Source File\r\n"; + block += "SOURCE=./" + fname + "\r\n"; + block += "# End Source File\r\n\r\n"; + } + } + + return block; +} + +/* generate parser and scanner files for Zend */ +function generate_parsers_or_scanners(arr, type) +{ + var filter = (type.match("Parsers") ? "y" : "l"); + + ret = '# Begin Group "' + type + '"\r\n# PROP Default_Filter "' + filter + '"\r\n\r\n'; + + for (i = 0; i < arr.length; i++) { + + fl = "zend_" + arr[i] + "_" + type.toLowerCase().substr(0, type.length - 1); + ret += "# Begin Source File\r\n"; + ret += "SOURCE=.\\" + fl + "." + filter + "\r\n\r\n"; + ret += '# Begin Custom Build\r\n\r\n'; + + if (type.match("Parsers")) { + pre = (arr[i].match(/ini/) ? "ini_ " : "zend "); + ret += fl + ".c " + fl + ".h: " + fl + ".y\r\n"; + ret += "\tbison --output=" + fl + ".c -v -d -p " + pre + fl + ".y\r\n\r\n"; + } else { + ret += fl + ".c: " + fl + ".l\r\n"; + ret += "\tre2c --case-inverted -cbdFt " + fl + "_defs.h -o" + fl + ".c " + fl + ".l\r\n\r\n"; + } + + ret += "# End Custom Build\r\n"; + ret += "# End Source File\r\n"; + } + + ret += "# End Group\r\n\r\n"; + return ret; +} + +/* generate .defs file for php5[ts].dll */ +function generate_php_defs() +{ + var defs = get_define("PHP_DLL_DEF_SOURCES").split(" "); + var bdir = get_define("BUILD_DIR") + "\\"; + var file = get_define("PHPLIB").replace("lib", "def"); + var path = "..\\" + bdir + file; + var deps = "USERDEP__PHP5TS="; + var cmds = "BuildCmds= \\\r\n"; + var cmd = '$(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n\t$(BuildCmds)\r\n'; + + for (i = 0; i < defs.length; i++) { + deps += '"..\\' + defs[i] + '" '; + cmds += "\ttype ..\\" + defs[i] + (i == 0 ? " > " : " >> ") + path + " \\\r\n"; + } + + ret = '# Begin Group "Defs Files"\r\n\r\n'; + ret += "# Begin Source File\r\nSOURCE=" + path + "\r\n\r\n"; + ret += deps.substr(0, deps.length-1) + "\r\n# Begin Custom Build - "; + ret += "Generating $(InputPath)\r\nInputPath=" + path + "\r\n\r\n"; + ret += cmds + '\r\n\"' + path + '" : ' + cmd + "\r\n"; + ret += "# End Custom Build\r\n# End Source File\r\n\r\n"; + ret += "# End Group\r\n"; + return ret; +} + +/* generate win32\wsyslog.h for php5[ts].dll */ +function generate_wsyslog() +{ + var path = ".\\build\\wsyslog.mc\r\n\r\n"; + var intdir = "..\\" + get_define("BUILD_DIR"); + + ret = "# Begin Source File\r\nSOURCE=" + path; + ret += "# Begin Custom Build\r\nInputDir=.\\build\r\n"; + ret += "IntDir=" + intdir + "\r\nInputPath=" + path; + ret += '"wsyslog.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n'; + ret += "\tmc -h $(InputDir)/.. -r $(InputDir) -x $(IntDir) $(InputPath)\r\n\r\n"; + ret += "# End Custom Build\r\n# End Source File\r\n"; + return ret; +} + +/* generate ext\date\lib\timelib_config.h for php5[ts].dll */ +function generate_timelib_conf(headers) +{ + var file = "timelib_config.h"; + var path = "..\\ext\\date\\lib\\timelib_config.h"; + var pos = headers.search(file); + var entry = headers.slice(pos, pos + 64); + + replace = entry.replace(file, file + ".win32"); + replace += "\r\n\r\n# Begin Custom Build\r\nInputDir=..\\ext\\date\\lib\r\n"; + replace += "InputPath=" + path + ".win32\r\n\r\n"; + replace += '"' + path + '" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n'; + replace += "\tcopy $(InputPath) $(InputDir)\\" + file + "\r\n\r\n"; + replace += "# End Custom Build"; + + headers = headers.replace(entry, replace); + return headers; +} + +/* generate php5[ts].dsp */ +function generate_core_dsp(core_headers, core_sources, headers, sources, cflags, ldflags, libs) +{ + var ts = (PHP_ZTS != "no" ? "ts" : ""); + var extname = "php5" + ts; + var tmpl = generate_dsp_file(extname, ".", false, false); + + cflags += get_define("CFLAGS_PHP").replace("/D _USRDLL", ""); + cflags = cflags.replace(/\/(I|D)(\S)/g, "/$1 $2"); + ldflags += get_define("LDFLAGS_PHP"); + libs += get_define("LIBS_PHP"); + + tmpl = tmpl.replace(/LOCALCPP/, cflags.replace(/\"ext/g, '"../ext') + " /c"); + tmpl = tmpl.replace(/LOCALLIBS/, libs); + tmpl = tmpl.replace(/LOCALLDFLAGS/, ldflags); + tmpl = tmpl.replace(extname + ".dll", get_define("PHPDLL")); + + wsyslog = (core_headers.match("wsyslog.h") ? "" : generate_wsyslog(core_headers)); + core_sources = '# Begin Group "CORE"\r\n' + core_sources + "# End Group\r\n"; + tmpl = tmpl.replace(/CORESOURCES/, core_sources); + core_headers = '# Begin Group "CORE "\r\n' + core_headers + "# End Group\r\n"; + tmpl = tmpl.replace(/COREHEADERS/, core_headers + wsyslog); + + headers = generate_timelib_conf(headers); + tmpl = tmpl.replace(/SOURCEFILES/, sources); + tmpl = tmpl.replace(/HEADERFILES/, headers); + + defs = generate_php_defs(); + tmpl = tmpl.replace(/DEFS/, defs); + + dsp = FSO.CreateTextFile("win32\\php5" + ts + ".dsp", true); + STDOUT.WriteLine("\tGenerating win32\\php5" + ts + ".dsp"); + dsp.Write(tmpl); + dsp.Close(); + + return; +} + +/* generate .dsw files */ +function generate_dsw_files(sblocks, mblocks) +{ + var stmpl = file_get_contents("win32\\build\\template.dsw"); + var mtmpl = file_get_contents("win32\\build\\template.dsw"); + var ts = (PHP_ZTS != "no" ? "ts" : ""); + + /* push all the sapi blocks to the same tag */ + stmpl = stmpl.replace("INSERT", sblocks); + stmpl = (PHP_ZTS != "no" ? stmpl : stmpl.replace(/dllts/g, "dll")); + sdsw = FSO.CreateTextFile("win32\\php5" + ts + ".dsw", true); + STDOUT.WriteLine("\tGenerating win32\\php5" + ts + ".dsw"); + sdsw.Write(stmpl); + sdsw.Close(); + + /* same for shared modules - except that nothing else goes in here */ + garbage = mtmpl.slice(200, mtmpl.search("INSERT")); + mtmpl = mtmpl.replace(garbage, "\r\n"); + mtmpl = mtmpl.replace("INSERT", mblocks); + mtmpl = (PHP_ZTS != "no" ? mtmpl : mtmpl.replace(/dllts/g, "dll")); + mdsw = FSO.CreateTextFile("win32\\php_modules.dsw", true); + STDOUT.WriteLine("\tGenerating win32\\php_modules.dsw"); + mdsw.Write(mtmpl); + mdsw.Close(); + + return; +} + +/* finalize .dsp files and copy to final destination */ +function copy_dsp_files() +{ + var tmp = FSO.GetFolder("tmp"); + var CORE_HEADERS = ""; + var CORE_SOURCES = ""; + var EXT_HEADERS = ""; + var EXT_SOURCES = ""; + var EXT_CFLAGS = ""; + var EXT_LDFLAGS = ""; + var EXT_LIBS = ""; + var sblocks = ""; /* for sapis */ + var mblocks = ""; /* for modules */ + + f = new Enumerator(tmp.Files); + + for (; !f.atEnd(); f.moveNext()) { + /* retrieve the path */ + contents = file_get_contents(f.item()); + address = contents.slice(0, contents.indexOf("#")); + contents = contents.slice(contents.indexOf("#")+1); + shared = contents.slice(0, contents.indexOf("#")); + contents = contents.slice(contents.indexOf("#")); + + /* pick up module name and path */ + path = address.slice(0, address.lastIndexOf("\\")+1); + ext = address.slice(address.lastIndexOf("\\")+1, address.length-4); + EXT = ext.toUpperCase(); + + if (path.match(/(sapi|ext)/)) { + rel = "..\\..\\"; + } else { + rel = "..\\"; + } + + /* pick up local flags and libs */ + cflags = get_define("CFLAGS_" + EXT); + cflags += (ext.match(/(TSRM|Zend)/) ? "/D TSRM_EXPORTS " : ""); + cflags += (ext.match(/Zend/) ? "/D LIBZEND_EXPORTS " : ""); + libs = get_define("LIBS_" + EXT); + ldflags = get_define("LDFLAGS_" + EXT); + ldflags = ldflags.replace(/(\.\.\\)/g, rel + "$1"); + contents = contents.replace(/LOCALCPP/, cflags + " /c"); + contents = contents.replace(/LOCALLIBS/, libs); + contents = contents.replace(/LOCALLDFLAGS/, ldflags); + + if (ext.match("Zend")) { + arr = new Array("ini", "language"); + parsers = generate_parsers_or_scanners(arr, "Parsers"); + scanners = generate_parsers_or_scanners(arr, "Scanners"); + contents = contents.replace(/DEFS/, parsers + scanners); + } + + /* none of these are core... */ + contents = contents.replace(/\r\n(CORESOURCES|COREHEADERS|EXTSOURCES|EXTHEADERS|DEFS)\r\n/g, ""); + + if (address.match("sapi")) { + /* most sapis are .dlls, just not cgi, cli, embed */ + + if (ext == "cli") { + + /* change of address: php.dsp */ + newext = "cli"; + address = "win32\\php.dsp"; + srcpath = "..\\" + path; + contents = contents.replace(/cli\.exe/g, "php.exe"); + + } else if (ext == "cgi") { + + /* change of address: php-cgi.dsp */ + newext = "cgi"; + address = "win32\\php-cgi.dsp"; + srcpath = "..\\" + path; + contents = contents.replace(/cgi\.exe/g, "php-cgi.exe"); + + } else { + + /* there's always one... most sapis just get a 'php5' prefix */ + newext = (ext.match(/apache2handler/) ? "php5apache2" : "php5" + ext); + address = address.replace(ext + ".dsp", newext + ".dsp"); + srcpath = ".\\"; + oldext = new RegExp(('[^=\\\\]'+ext), "g"); + contents = contents.replace(oldext, newext); + contents = contents.replace(ext + ".dll", newext + ".dll"); + contents = contents.replace("CFG=" + ext, "CFG=" + newext); + } + + contents = read_src_files(ext, contents, (srcpath ? srcpath : false)); + dsp = FSO.CreateTextFile(address, true); + STDOUT.WriteLine("\tGenerating " + address); + dsp.Write(contents); + dsp.Close(); + + /* add all configured sapis to the list in php5ts.dsw */ + sblocks += file_get_contents("win32\\build\\block.template.dsw"); + sblocks = sblocks.replace("ADDRESS", address); + sblocks = sblocks.replace("EXTNAME", newext); + + } else if (address.match("ext") && shared == "true") { + + /* independent modules with their own .dsp */ + contents = read_src_files(ext, contents, false); + dsp = FSO.CreateTextFile(address, true); + STDOUT.WriteLine("\tGenerating " + address); + dsp.Write(contents); + dsp.Close(); + + mblocks += file_get_contents("win32\\build\\block.template.dsw"); + mblocks = mblocks.replace("ADDRESS", address); + mblocks = mblocks.replace("EXTNAME", ext); + + } else if (ext.match(/(TSRM|Zend)/)) { + + contents = read_src_files(ext, contents, false); + dsp = FSO.CreateTextFile(address, true); + STDOUT.WriteLine("\tGenerating " + address); + dsp.Write(contents); + dsp.Close(); + + } else { + + /* bound for php5[ts].dsp */ + cflags = get_define("CFLAGS_" + EXT); + cflags = cflags ? cflags.replace(/-(I|D)/g, " /$1") : ""; + cflags = cflags? cflags.replace(/\/(I|D)\s+/g, "/$1") : ""; + cflags = cflags ? cflags.replace(/\/I(?!\")(\S+)/g, '/I"$1"') : ""; + + EXT_CFLAGS = check_duplicates(cflags, EXT_CFLAGS); + EXT_LDFLAGS = check_duplicates(ldflags, EXT_LDFLAGS); + EXT_LIBS = check_duplicates(libs, EXT_LIBS); + + beginh = '# Begin Group "' + ext + ' "\r\n'; + begins = '# Begin Group "' + ext + '"\r\n'; + + hdr = file_get_contents("tmp\\src\\" + ext + ".headers.tmp"); + hdr = hdr.replace(/\.\//g, "..\\" + path); + hdr = hdr.replace(/\.\.\\\.\.\\/g, "..\\"); + + src = file_get_contents("tmp\\src\\" + ext + ".sources.tmp"); + src = src.replace(/\.\//g, "..\\" + path); + src = src.replace(/\.\.\\\.\.\\/g, "..\\"); + + if (ext.match(/(main|standard|streams|win32)/)) { + CORE_HEADERS += beginh + hdr + "# End Group\r\n"; + CORE_SOURCES += begins + src + "# End Group\r\n"; + } else { + EXT_HEADERS += beginh + hdr + "# End Group\r\n"; + EXT_SOURCES += begins + src + "# End Group\r\n"; + } + + FSO.DeleteFile("tmp\\src\\" + ext + ".headers.tmp"); + FSO.DeleteFile("tmp\\src\\" + ext + ".sources.tmp"); + } + + FSO.DeleteFile(f.item()); + } + + generate_core_dsp(CORE_HEADERS, CORE_SOURCES, EXT_HEADERS, EXT_SOURCES, EXT_CFLAGS, EXT_LDFLAGS, EXT_LIBS); + generate_dsw_files(sblocks, mblocks); + + /* goodnight vienna */ + FSO.DeleteFolder("tmp\\src"); + FSO.DeleteFolder("tmp"); +} + +/* generate source and header entries for .dsp files */ +function generate_dsp_filelist(ext, ext_dir, files, intpath) +{ + var EXT = ext.toUpperCase(); + var tabs = new RegExp("[\t\r\n\'\"]", "gm"); + var ws = new RegExp("\\s+", "g"); + var dir = FSO.GetFolder(ext_dir); + var configfile = FSO.BuildPath(ext_dir, "config.w32"); + var headers = ""; + var path = ""; + + if (!files) { + /* module either lacks a config.w32 or is core + * either way, we know nothing about its sources + */ + files = ""; + f = new Enumerator(dir.Files); + + for (; !f.atEnd(); f.moveNext()) { + name = FSO.GetFileName(f.item()); + + if (name.substr(name.length-2) == ".c") { + files += " ./" + name; + } + } + } else { + files = files.replace(tabs, ""); + files = "./" + files.replace(/ /g, " ./"); + } + + DSP_SOURCES = files.split(" "); + + /* pick up headers (all modules) */ + f = new Enumerator(dir.Files); + + for (; !f.atEnd(); f.moveNext()) { + name = FSO.GetFileName(f.item()); + + if (name.substr(name.length-2) == ".h") { + headers += " ./" + name; + } + } + + DSP_HEADERS = headers.split(" "); + + /* check for bundled library paths and sourcefiles */ + if (FSO.FileExists(configfile)) { + config = file_get_contents(configfile); + + if (config.match("ADD_SOURCES")) { + sources = new RegExp("ADD_SOURCES\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\)", "gm"); + arr = config.match(sources); + line = arr[0].replace(tabs, ""); + line = line.replace(/ADD_SOURCES\((.+)\)/, "$1"); + newarr = line.split(','); + orig_path = newarr[0].replace(/\//g, "\\"); + orig_path = orig_path.replace(/configure_module_dirname(\s?\+\s?)?/, ext_dir); + path = orig_path.replace(ext_dir + '\\', ""); + + if (path.length > 0 && path != ext_dir) { + subdir = FSO.GetFolder(orig_path); + lib = new Enumerator(subdir.Files); + libheaders = ""; + + for (; !lib.atEnd(); lib.moveNext()) { + name = FSO.GetFileName(lib.item()); + + if (name.substr(name.length-2) == ".h") { + libheaders += " ./" + path + "\\" + name; + } + } + + DSP_HEADERS = DSP_HEADERS.concat(libheaders.split(" ")); + + } else { + path = ""; + } + + sources = newarr[1].replace(/\\/g, ""); /* continuation lines */ + sources = sources.replace(ws, " "); + sources = sources.replace(/\s/g, (path ? " ./" + path + "\\" : " ./")); + sources = check_duplicates(DSP_SOURCES.join(" "), sources); + DSP_SOURCES = sources.split(" "); + } + } + + /* store the array contents in temp files for now */ + write_src_file(ext + ".headers.tmp", ext_dir, intpath, DSP_HEADERS); + write_src_file(ext + ".sources.tmp", ext_dir, intpath, DSP_SOURCES); + + return; +} + +/* entry point. Called from EXTENSION(), SAPI() and generate_files() (confutils.js) */ +function generate_dsp_file(ext, ext_dir, files, shared) +{ + var dsp = FSO.CreateTextFile("tmp\\" + ext + ".dsp", true); + var tmpl = file_get_contents("win32\\build\\template.dsp"); + var ts = (PHP_ZTS != "no" ? "ts" : ""); + var debug = (PHP_DEBUG != "no" ? " /debug" : ""); + var ld = (debug ? "/LDd" : "/LD"); + var status = (PHP_DEBUG == "no" ? 'Release' : 'Debug'); + var statusts = status + (ts ? "_" + ts.toUpperCase() : ""); + var baseflags = ""; + + /* store the final path and value of shared in the tmp file */ + if (!ext.match("php5")) { + tmpl = ext_dir + "\\" + ext + ".dsp#" + shared + tmpl; + } + + tmpl = tmpl.replace(/extname/g, ext); + tmpl = tmpl.replace(/Status_TS/g, statusts); + + if (debug) { + tmpl = tmpl.replace(/Use_Debug_Libraries 0/g, "Use_Debug_Libraries 1"); + tmpl = tmpl.replace(/NDEBUG/g, "_DEBUG"); + } + + if (ext == "cli" || ext == "cgi") { + tmpl = tmpl.replace(/Dynamic-Link Library/g, "Console Application"); + tmpl = tmpl.replace(/0x0102/, "0x0103"); + path = "..\\"; + type = ".exe"; + } else if (ext == "embed" || ext == "TSRM" || ext == "Zend") { + tmpl = tmpl.replace(/Dynamic-Link/g, "Static"); + tmpl = tmpl.replace(/0x0102/, "0x0104"); + tmpl = tmpl.replace(/LINK32/g, "LIB32"); + tmpl = tmpl.replace("link.exe", "link.exe -lib"); + tmpl = tmpl.replace(/BASELIBS/g, "/nologo"); + tmpl = tmpl.replace(/\s(LOCALLIBS|BASELDFLAGS|LOCALLDFLAGS|OUTPATH)/g, ""); + path = "..\\"; + if (ext == "embed") { + path += "..\\"; + } + type = ".lib"; + } else if (ext.match("php5")) { + path = "..\\"; + type = ".dll"; + } else { + path = "..\\..\\"; + type = ".dll"; + } + + outpath = path + get_define("BUILD_DIR"); + tmpl = tmpl.replace(/OUTPUTDIR/g, outpath); + + /* populate the baseline CFLAGS and libs */ + cflags = get_define("CFLAGS").replace(/\s+/g, " "); + cflags = cflags.replace('/I "..\\bindlib_w32" ', ""); + bcflags = (cflags.replace(/\/([A-Z])\s/g, "/$1")).split(" "); + + for (i= 0; i < bcflags.length; i++) { + baseflags += (bcflags[i].match(/(PHP|ZEND|ZTS|BASE|FD|WINDOWS)/) ? "" : bcflags[i]); + } + + baseflags = baseflags.replace(/\//g, " /"); + baseflags = baseflags.substr(1).replace(/(\/D)/g, "$1 ") + " /c"; + tmpl = tmpl.replace(/BASECPP/, (type == ".dll" ? baseflags : baseflags.replace(ld + " ", ""))); + + tmpl = tmpl.replace(/BASELIBS/, "/nologo " + get_define("LIBS").replace(/\sresolv.lib/, "")); + + /* now populate the bases in the 'local' lines */ + incs = get_define("BASE_INCLUDES").replace(/\/I (\S+)/g, '/I "' + path + '$1"'); + incs = incs.replace('"' + path + '."', '".."'); + lcflags = cflags.replace(/\$\(BASE_INCLUDES\)/, incs + (type == ".exe" ? '/I "..\\sapi" ' : "") + '/I "' + path + '..\\bindlib_w32"'); + tmpl = tmpl.replace(/BASECPP/, (type == ".dll" ? lcflags : lcflags.replace(ld + " ", ""))); + tmpl = tmpl.replace(/BASELIBS/, "/nologo " + get_define("LIBS") + " " + (ext.match("php5") ? "" : get_define("PHPLIB"))); + ldflags = get_define("LDFLAGS").replace(/\s?(\/nologo|\/libpath:\S+)\s?/g, ""); + tmpl = tmpl.replace(/BASELDFLAGS/, ldflags + (type == ".dll" ? " " + get_define("DLL_LDFLAGS") : "") + (debug ? ' /nodefaultlib:"msvcrt"' : "")); + out = '/out:"' + outpath + "\\" + ext + type + '"' + ' /libpath:"' + outpath + '"' + ' /libpath:"..\\' + path + 'bindlib_w32\\' + status + '"'; + tmpl = tmpl.replace(/OUTPATH/, out); + + txt = generate_text_filelist(ext, ext_dir); + res = generate_resource_filelist(ext, ext_dir); + + tmpl = tmpl.replace(/TEXTFILES/, txt); + tmpl = tmpl.replace(/RESOURCEFILES/, res); + + if (ext.match("php5")) { + return tmpl; + } + + /* generate source and header blocks for .dsp */ + generate_dsp_filelist(ext, ext_dir, files, path); + + dsp.Write(tmpl); + dsp.Close(); + + return; +} diff --git a/win32/build/registersyslog.php b/win32/build/registersyslog.php index 73fef50f0..e5aa1d92c 100755 --- a/win32/build/registersyslog.php +++ b/win32/build/registersyslog.php @@ -1,45 +1,44 @@ - + diff --git a/win32/build/template.dsp b/win32/build/template.dsp new file mode 100644 index 000000000..ce1b070d5 --- /dev/null +++ b/win32/build/template.dsp @@ -0,0 +1,81 @@ +# Microsoft Developer Studio Project File - Name="extname" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=extname - Win32 Status_TS +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "extname.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "extname.mak" CFG="extname - Win32 Status_TS" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "extname - Win32 Status_TS" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe +RE2C=re2c.exe + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "OUTPUTDIR" +# PROP BASE Intermediate_Dir "OUTPUTDIR" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "OUTPUTDIR" +# PROP Intermediate_Dir "OUTPUTDIR" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP BASECPP +# ADD CPP BASECPP LOCALCPP +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 BASELIBS +# ADD LINK32 BASELIBS LOCALLIBS BASELDFLAGS LOCALLDFLAGS OUTPATH + +# Begin Target +# Name "extname - Win32 Status_TS" + +# Begin Group "Source Files" +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + +CORESOURCES +SOURCEFILES +# End Group + +# Begin Group "Header Files" +# PROP Default_Filter "h;hpp;hxx;hm;inl" + +COREHEADERS +HEADERFILES +# End Group + +DEFS + +TEXTFILES + +# Begin Group "Resource Files" +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + +RESOURCEFILES +# End Group +# End Target +# End Project diff --git a/win32/build/template.dsw b/win32/build/template.dsw new file mode 100644 index 000000000..a627d028d --- /dev/null +++ b/win32/build/template.dsw @@ -0,0 +1,63 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "TSRM"=..\TSRM\TSRM.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "Zend"=..\Zend\Zend.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name TSRM + End Project Dependency +}}} + +############################################################################### + +Project: "php5ts"=..\win32\php5ts.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name TSRM + End Project Dependency + Begin Project Dependency + Project_Dep_Name Zend + End Project Dependency +}}} + +############################################################################### +INSERT + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/win32/build/template.rc b/win32/build/template.rc index d10905fe2..8ee8f1c4c 100644 --- a/win32/build/template.rc +++ b/win32/build/template.rc @@ -1,5 +1,5 @@ /* This is a template RC file. - * $Id: template.rc,v 1.7.2.2.2.2 2008/11/03 19:28:23 auroraeosrose Exp $ + * $Id: template.rc,v 1.7.2.2.2.1.2.2 2008/11/03 19:25:42 auroraeosrose Exp $ * Do not edit with MSVC */ #ifdef APSTUDIO_INVOKED # error dont edit with MSVC @@ -19,18 +19,32 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 0 ICON win32\build\php.ico #endif -#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 INTERNAL_NAME /* e.g. 'PHAR extension', 'CGI SAPI' */ +# ifdef FILE_DESCRIPTION +#define INTERNAL_NAME FILE_DESCRIPTION /* e.g. 'PHP Script Interpreter', 'GD imaging' */ +# else +#define INTERNAL_NAME FILE_NAME /* e.g. 'php5ts.dll', 'php_bz2.dll' */ +# endif +#endif + +#ifndef URL +#define URL "http://www.php.net" +#endif + +#ifndef EXT_VERSION +#define EXT_VERSION PHP_VERSION +#endif + +#ifndef EXT_FILE_VERSION +#define EXT_FILE_VERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION +#endif -//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 + FILEVERSION EXT_FILE_VERSION + PRODUCTVERSION PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION FILEFLAGSMASK 0x3fL #ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG + FILEFLAGS (VS_FF_DEBUG|VS_FF_SPECIALBUILD) #else FILEFLAGS 0x0L #endif @@ -42,19 +56,24 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", THANKS_GUYS "\0" - VALUE "CompanyName", "The PHP Group\0" - VALUE "FileDescription", FILE_DESCRIPTION "\0" - VALUE "FileVersion", STRVER4(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_RELEASE_VERSION) - VALUE "InternalName", FILE_NAME "\0" - VALUE "LegalCopyright", "Copyright © 1997-2007 The PHP Group\0" - VALUE "LegalTrademarks", "PHP\0" - VALUE "OriginalFilename", FILE_NAME "\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", PRODUCT_NAME "\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" + VALUE "Comments", THANKS_GUYS + VALUE "CompanyName", "The PHP Group" +#ifdef _DEBUG + VALUE "FileDescription", FILE_DESCRIPTION " (DEBUG)" +#else + VALUE "FileDescription", FILE_DESCRIPTION +#endif + VALUE "FileVersion", EXT_VERSION + VALUE "InternalName", INTERNAL_NAME + VALUE "LegalCopyright", "Copyright © 1997-2008 The PHP Group" + VALUE "LegalTrademarks", "PHP" + VALUE "OriginalFilename", FILE_NAME + VALUE "ProductName", "PHP" + VALUE "ProductVersion", PHP_VERSION +#ifdef _DEBUG + VALUE "SpecialBuild", "Debug build" +#endif + VALUE "URL", URL END END BLOCK "VarFileInfo" @@ -66,4 +85,3 @@ END #ifdef MC_INCLUDE #include MC_INCLUDE #endif - diff --git a/win32/crypt_win32.c b/win32/crypt_win32.c deleted file mode 100644 index 1e5d2e422..000000000 --- a/win32/crypt_win32.c +++ /dev/null @@ -1,562 +0,0 @@ -/* - * UFC-crypt: ultra fast crypt(3) implementation - * - * Copyright (C) 1991, Michael Glad, email: glad@daimi.aau.dk - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * @(#)crypt.c 2.2 10/04/91 - * - * Semiportable C version - * - */ - -#include - -#define bzero(addr, cnt) memset(addr, 0, cnt) -#define bcopy(from, to, len) memcpy(to, from, len) - -/* Permutation done once on the 56 bit - key derived from the original 8 byte ASCII key. -*/ -static unsigned long pc1[56] = - { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, - 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, - 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, - 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 - }; - -/* How much to rotate each 28 bit half of the pc1 permutated - 56 bit key before using pc2 to give the i' key -*/ -static unsigned long totrot[16] = - { 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 }; - -/* Permutation giving the key of the i' DES round */ -static unsigned long pc2[48] = - { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 - }; - -/* Reference copy of the expansion table which selects - bits from the 32 bit intermediate result. -*/ -static unsigned long eref[48] = - { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, - 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, - 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, - 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 - }; -static unsigned long disturbed_e[48]; -static unsigned long e_inverse[64]; - -/* Permutation done on the result of sbox lookups */ -static unsigned long perm32[32] = - { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, - 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 - }; - -/* The sboxes */ -static unsigned long sbox[8][4][16]= - { { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, - { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, - { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, - { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } - }, - - { { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }, - { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, - { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, - { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } - }, - - { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, - { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, - { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, - { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } - }, - - { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, - { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, - { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, - { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } - }, - - { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, - { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, - { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, - { 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 } - }, - - { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, - { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, - { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, - { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } - }, - - { { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, - { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, - { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, - { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 } - }, - - { { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, - { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 }, - { 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, - { 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } - } - }; - -#ifdef notdef - -/* This is the initial permutation matrix -- we have no - use for it, but it is needed if you will develop - this module into a general DES package. -*/ -static unsigned char inital_perm[64] = - { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 - }; - -#endif - -/* Final permutation matrix -- not used directly */ -static unsigned char final_perm[64] = - { 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 - }; - -/* The 16 DES keys in BITMASK format */ -unsigned long keytab[16][2]; - -#define ascii_to_bin(c) ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.') -#define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') - -/* Macro to set a bit (0..23) */ -#define BITMASK(i) ( (1<<(11-(i)%12+3)) << ((i)<12?16:0) ) - -/* sb arrays: - - Workhorses of the inner loop of the DES implementation. - They do sbox lookup, shifting of this value, 32 bit - permutation and E permutation for the next round. - - Kept in 'BITMASK' format. - -*/ - -unsigned long sb0[8192],sb1[8192],sb2[8192],sb3[8192]; -static unsigned long *sb[4] = {sb0,sb1,sb2,sb3}; - -/* eperm32tab: do 32 bit permutation and E selection - - The first index is the byte number in the 32 bit value to be permuted - - second - is the value of this byte - - third - selects the two 32 bit values - - The table is used and generated internally in init_des to speed it up - -*/ -static unsigned long eperm32tab[4][256][2]; - -/* mk_keytab_table: fast way of generating keytab from ASCII key - - The first index is the byte number in the 8 byte ASCII key - - second - - - current DES round i.e. the key number - - third - distinguishes between the two 24 bit halfs of - the selected key - - fourth - selects the 7 bits actually used of each byte - - The table is kept in the format generated by the BITMASK macro - -*/ -static unsigned long mk_keytab_table[8][16][2][128]; - - -/* efp: undo an extra e selection and do final - permutation giving the DES result. - - Invoked 6 bit a time on two 48 bit values - giving two 32 bit longs. -*/ -static unsigned long efp[16][64][2]; - - -static unsigned char bytemask[8] = - { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; - - -static unsigned long longmask[32] = - { 0x80000000, 0x40000000, 0x20000000, 0x10000000, - 0x08000000, 0x04000000, 0x02000000, 0x01000000, - 0x00800000, 0x00400000, 0x00200000, 0x00100000, - 0x00080000, 0x00040000, 0x00020000, 0x00010000, - 0x00008000, 0x00004000, 0x00002000, 0x00001000, - 0x00000800, 0x00000400, 0x00000200, 0x00000100, - 0x00000080, 0x00000040, 0x00000020, 0x00000010, - 0x00000008, 0x00000004, 0x00000002, 0x00000001 - }; - -static unsigned long initialized = 0; - -/* lookup a 6 bit value in sbox */ - -#define s_lookup(i,s) sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf]; - -/* Generate the mk_keytab_table once in a program execution */ - -void init_des() - { unsigned long tbl_long,bit_within_long,comes_from_bit; - unsigned long bit,sg,j; - unsigned long bit_within_byte,key_byte,byte_value; - unsigned long round,mask; - - bzero((char*)mk_keytab_table,sizeof mk_keytab_table); - - for(round=0; round<16; round++) - for(bit=0; bit<48; bit++) - { tbl_long = bit / 24; - bit_within_long = bit % 24; - - /* from which bit in the key halves does it origin? */ - comes_from_bit = pc2[bit] - 1; - - /* undo the rotation done before pc2 */ - if(comes_from_bit>=28) - comes_from_bit = 28 + (comes_from_bit + totrot[round]) % 28; - else - comes_from_bit = (comes_from_bit + totrot[round]) % 28; - - /* undo the initial key half forming permutation */ - comes_from_bit = pc1[comes_from_bit] - 1; - - /* Now 'comes_from_bit' is the correct number (0..55) - of the keybit from which the bit being traced - in key 'round' comes from - */ - - key_byte = comes_from_bit / 8; - bit_within_byte = (comes_from_bit % 8)+1; - - mask = bytemask[bit_within_byte]; - - for(byte_value=0; byte_value<128; byte_value++) - if(byte_value & mask) - mk_keytab_table[key_byte][round][tbl_long][byte_value] |= - BITMASK(bit_within_long); - } - - /* Now generate the table used to do an combined - 32 bit permutation and e expansion - - We use it because we have to permute 16384 32 bit - longs into 48 bit in order to initialize sb. - - Looping 48 rounds per permutation becomes - just too slow... - - */ - - bzero((char*)eperm32tab,sizeof eperm32tab); - for(bit=0; bit<48; bit++) - { unsigned long mask1,comes_from; - - comes_from = perm32[eref[bit]-1]-1; - mask1 = bytemask[comes_from % 8]; - - for(j=256; j--;) - if(j & mask1) - eperm32tab[comes_from/8][j][bit/24] |= BITMASK(bit % 24); - } - - /* Create the sb tables: - - For each 12 bit segment of an 48 bit intermediate - result, the sb table precomputes the two 4 bit - values of the sbox lookups done with the two 6 - bit halves, shifts them to their proper place, - sends them through perm32 and finally E expands - them so that they are ready for the next - DES round. - - The value looked up is to be xored onto the - two 48 bit right halves. - */ - - for(sg=0; sg<4; sg++) - { unsigned long j1,j2; - unsigned long s1,s2; - - for(j1=0; j1<64; j1++) - { s1 = s_lookup(2*sg,j1); - for(j2=0; j2<64; j2++) - { unsigned long to_permute,inx; - - s2 = s_lookup(2*sg+1,j2); - to_permute = ((s1<<4) | s2) << (24-8*sg); - inx = ((j1<<6) | j2) << 1; - - sb[sg][inx ] = eperm32tab[0][(to_permute >> 24) & 0xff][0]; - sb[sg][inx+1] = eperm32tab[0][(to_permute >> 24) & 0xff][1]; - - sb[sg][inx ] |= eperm32tab[1][(to_permute >> 16) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[1][(to_permute >> 16) & 0xff][1]; - - sb[sg][inx ] |= eperm32tab[2][(to_permute >> 8) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[2][(to_permute >> 8) & 0xff][1]; - - sb[sg][inx ] |= eperm32tab[3][(to_permute) & 0xff][0]; - sb[sg][inx+1] |= eperm32tab[3][(to_permute) & 0xff][1]; - } - } - } - initialized++; - } - -/* Process the elements of the sb table permuting the - bits swapped in the expansion by the current salt. -*/ - -void shuffle_sb(k, saltbits) - unsigned long *k, saltbits; - { int j, x; - for(j=4096; j--;) { - x = (k[0] ^ k[1]) & saltbits; - *k++ ^= x; - *k++ ^= x; - } - } - -/* Setup the unit for a new salt - Hopefully we'll not see a new salt in each crypt call. -*/ - -static unsigned char current_salt[3]="&&"; /* invalid value */ -static unsigned long oldsaltbits = 0; - -void setup_salt(s) - char *s; - { unsigned long i,j,saltbits; - - if(!initialized) - init_des(); - - if(s[0]==current_salt[0] && s[1]==current_salt[1]) - return; - current_salt[0]=s[0]; current_salt[1]=s[1]; - - /* This is the only crypt change to DES: - entries are swapped in the expansion table - according to the bits set in the salt. - */ - - saltbits=0; - bcopy((char*)eref,(char*)disturbed_e,sizeof eref); - for(i=0; i<2; i++) - { long c=ascii_to_bin(s[i]); - if(c<0 || c>63) - c=0; - for(j=0; j<6; j++) - if((c>>j) & 0x1) - { disturbed_e[6*i+j ]=eref[6*i+j+24]; - disturbed_e[6*i+j+24]=eref[6*i+j ]; - saltbits |= BITMASK(6*i+j); - } - } - - /* Permute the sb table values - to reflect the changed e - selection table - */ - - shuffle_sb(sb0, oldsaltbits ^ saltbits); - shuffle_sb(sb1, oldsaltbits ^ saltbits); - shuffle_sb(sb2, oldsaltbits ^ saltbits); - shuffle_sb(sb3, oldsaltbits ^ saltbits); - - oldsaltbits = saltbits; - - /* Create an inverse matrix for disturbed_e telling - where to plug out bits if undoing disturbed_e - */ - - for(i=48; i--;) - { e_inverse[disturbed_e[i]-1 ] = i; - e_inverse[disturbed_e[i]-1+32] = i+48; - } - - /* create efp: the matrix used to - undo the E expansion and effect final permutation - */ - - bzero((char*)efp,sizeof efp); - for(i=0; i<64; i++) - { unsigned long o_bit,o_long; - unsigned long word_value,mask1,mask2,comes_from_f_bit,comes_from_e_bit; - unsigned long comes_from_word,bit_within_word; - - /* See where bit i belongs in the two 32 bit long's */ - o_long = i / 32; /* 0..1 */ - o_bit = i % 32; /* 0..31 */ - - /* And find a bit in the e permutated value setting this bit. - - Note: the e selection may have selected the same bit several - times. By the initialization of e_inverse, we only look - for one specific instance. - */ - comes_from_f_bit = final_perm[i]-1; /* 0..63 */ - comes_from_e_bit = e_inverse[comes_from_f_bit]; /* 0..95 */ - comes_from_word = comes_from_e_bit / 6; /* 0..15 */ - bit_within_word = comes_from_e_bit % 6; /* 0..5 */ - - mask1 = longmask[bit_within_word+26]; - mask2 = longmask[o_bit]; - - for(word_value=64; word_value--;) - if(word_value & mask1) - efp[comes_from_word][word_value][o_long] |= mask2; - - } - - } - -/* Generate the key table before running the 25 DES rounds */ - -void mk_keytab(key) - char *key; - { unsigned long i,j; - unsigned long *k,*mkt; - char t; - - bzero((char*)keytab, sizeof keytab); - mkt = &mk_keytab_table[0][0][0][0]; - - for(i=0; (t=(*key++) & 0x7f) && i<8; i++) - for(j=0,k = &keytab[0][0]; j<16; j++) - { *k++ |= mkt[t]; mkt += 128; - *k++ |= mkt[t]; mkt += 128; - } - for(; i<8; i++) - for(j=0,k = &keytab[0][0]; j<16; j++) - { *k++ |= mkt[0]; mkt += 128; - *k++ |= mkt[0]; mkt += 128; - } - } - -/* Do final permutations and convert to ASCII */ - -char *output_conversion(l1,l2,r1,r2,salt) - unsigned long l1,l2,r1,r2; - char *salt; - { static char outbuf[14]; - unsigned long i; - unsigned long s,v1,v2; - - /* Unfortunately we've done an extra E - expansion -- undo it at the same time. - */ - - v1=v2=0; l1 >>= 3; l2 >>= 3; r1 >>= 3; r2 >>= 3; - - v1 |= efp[ 3][ l1 & 0x3f][0]; v2 |= efp[ 3][ l1 & 0x3f][1]; - v1 |= efp[ 2][(l1>>=6) & 0x3f][0]; v2 |= efp[ 2][ l1 & 0x3f][1]; - v1 |= efp[ 1][(l1>>=10) & 0x3f][0]; v2 |= efp[ 1][ l1 & 0x3f][1]; - v1 |= efp[ 0][(l1>>=6) & 0x3f][0]; v2 |= efp[ 0][ l1 & 0x3f][1]; - - v1 |= efp[ 7][ l2 & 0x3f][0]; v2 |= efp[ 7][ l2 & 0x3f][1]; - v1 |= efp[ 6][(l2>>=6) & 0x3f][0]; v2 |= efp[ 6][ l2 & 0x3f][1]; - v1 |= efp[ 5][(l2>>=10) & 0x3f][0]; v2 |= efp[ 5][ l2 & 0x3f][1]; - v1 |= efp[ 4][(l2>>=6) & 0x3f][0]; v2 |= efp[ 4][ l2 & 0x3f][1]; - - v1 |= efp[11][ r1 & 0x3f][0]; v2 |= efp[11][ r1 & 0x3f][1]; - v1 |= efp[10][(r1>>=6) & 0x3f][0]; v2 |= efp[10][ r1 & 0x3f][1]; - v1 |= efp[ 9][(r1>>=10) & 0x3f][0]; v2 |= efp[ 9][ r1 & 0x3f][1]; - v1 |= efp[ 8][(r1>>=6) & 0x3f][0]; v2 |= efp[ 8][ r1 & 0x3f][1]; - - v1 |= efp[15][ r2 & 0x3f][0]; v2 |= efp[15][ r2 & 0x3f][1]; - v1 |= efp[14][(r2>>=6) & 0x3f][0]; v2 |= efp[14][ r2 & 0x3f][1]; - v1 |= efp[13][(r2>>=10) & 0x3f][0]; v2 |= efp[13][ r2 & 0x3f][1]; - v1 |= efp[12][(r2>>=6) & 0x3f][0]; v2 |= efp[12][ r2 & 0x3f][1]; - - outbuf[0] = salt[0]; - outbuf[1] = salt[1] ? salt[1] : salt[0]; - - for(i=0; i<5; i++) - outbuf[i+2] = bin_to_ascii((v1>>(26-6*i)) & 0x3f); - - s = (v2 & 0xf) << 2; /* Save the rightmost 4 bit a moment */ - v2 = (v2>>2) | ((v1 & 0x3)<<30); /* Shift two bits of v1 onto v2 */ - - for(i=5; i<10; i++) - outbuf[i+2] = bin_to_ascii((v2>>(56-6*i)) & 0x3f); - - outbuf[12] = bin_to_ascii(s); - outbuf[13] = 0; - - return outbuf; - } - -#define SBA(sb, v) (*(unsigned long*)((char*)(sb)+(v))) - -#define F(I, O1, O2, SBX, SBY) \ - s = *k++ ^ I; \ - O1 ^= SBA(SBX, (s & 0xffff)); O2 ^= SBA(SBX, ((s & 0xffff) + 4)); \ - O1 ^= SBA(SBY, (s >>= 16)); O2 ^= SBA(SBY, ((s) + 4)); - -#define G(I1, I2, O1, O2) \ - F(I1, O1, O2, sb1, sb0) F(I2, O1, O2, sb3, sb2) - -#define H G(r1, r2, l1, l2) ; G(l1, l2, r1, r2) - -char *des_crypt(key, salt) - char *key; - char *salt; - { unsigned long l1, l2, r1, r2, i, j, s, *k; - - setup_salt(salt); - mk_keytab(key); - - l1=l2=r1=r2=0; - - for(j=0; j<25; j++) { - k = &keytab[0][0]; - for(i=8; i--; ) { - H; - } - s=l1; l1=r1; r1=s; s=l2; l2=r2; r2=s; - } - - return output_conversion(l1, l2, r1, r2, salt); - } - -#include "php.h" -#include "md5crypt.h" - -PHPAPI char * -crypt (const char *pw, const char *salt) -{ - if (strlen(salt)>MD5_MAGIC_LEN && strncmp(salt, MD5_MAGIC, MD5_MAGIC_LEN)==0) { - return md5_crypt(pw, salt); - } else { - return des_crypt(pw, salt); - } -} diff --git a/win32/crypt_win32.h b/win32/crypt_win32.h deleted file mode 100644 index 272ca7653..000000000 --- a/win32/crypt_win32.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 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: | - +----------------------------------------------------------------------+ - */ - -#ifndef _CRYPT_WIHN32_H_ -#define _CRYPT_WIHN32_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -PHPAPI char* crypt(const char *key, const char *salt); - -#ifdef __cplusplus -} -#endif - -#endif /* _CRYPT_WIHN32_H_ */ diff --git a/win32/fnmatch.c b/win32/fnmatch.c new file mode 100644 index 000000000..4d3bc3486 --- /dev/null +++ b/win32/fnmatch.c @@ -0,0 +1,198 @@ +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * From FreeBSD fnmatch.c 1.11 + * $Id: fnmatch.c,v 1.1.2.2 2009/01/20 01:37:48 pajoye Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. + */ + +#include +#include +#include + +#include "fnmatch.h" + +#define EOS '\0' + +static const char *rangematch(const char *, char, int); + +PHPAPI int fnmatch(const char *pattern, const char *string, int flags) +{ + const char *stringstart; + char c, test; + + for (stringstart = string;;) + switch (c = *pattern++) { + case EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return (0); + return (*string == EOS ? 0 : FNM_NOMATCH); + case '?': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + ++string; + break; + case '*': + c = *pattern; + /* Collapse multiple stars. */ + while (c == '*') + c = *++pattern; + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + /* Optimize for pattern with * at end or before /. */ + if (c == EOS) + if (flags & FNM_PATHNAME) + return ((flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH); + else + return (0); + else if (c == '/' && flags & FNM_PATHNAME) { + if ((string = strchr(string, '/')) == NULL) + return (FNM_NOMATCH); + break; + } + + /* General case, use recursion. */ + while ((test = *string) != EOS) { + if (!fnmatch(pattern, string, flags & ~FNM_PERIOD)) + return (0); + if (test == '/' && flags & FNM_PATHNAME) + break; + ++string; + } + return (FNM_NOMATCH); + case '[': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && flags & FNM_PATHNAME) + return (FNM_NOMATCH); + if ((pattern = + rangematch(pattern, *string, flags)) == NULL) + return (FNM_NOMATCH); + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + if ((c = *pattern++) == EOS) { + c = '\\'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + if (c == *string) + ; + else if ((flags & FNM_CASEFOLD) && + (tolower((unsigned char)c) == + tolower((unsigned char)*string))) + ; + else if ((flags & FNM_PREFIX_DIRS) && *string == EOS && + (c == '/' && string != stringstart || + string == stringstart+1 && *stringstart == '/') ) + return (0); + else + return (FNM_NOMATCH); + string++; + break; + } + /* NOTREACHED */ +} + +static const char * +rangematch(const char *pattern, char test, int flags) +{ + int negate, ok; + char c, c2; + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + if ( (negate = (*pattern == '!' || *pattern == '^')) ) + ++pattern; + + if (flags & FNM_CASEFOLD) + test = tolower((unsigned char)test); + + for (ok = 0; (c = *pattern++) != ']';) { + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = *pattern++; + if (c == EOS) + return (NULL); + + if (flags & FNM_CASEFOLD) + c = tolower((unsigned char)c); + + if (*pattern == '-' + && (c2 = *(pattern+1)) != EOS && c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = *pattern++; + if (c2 == EOS) + return (NULL); + + if (flags & FNM_CASEFOLD) + c2 = tolower((unsigned char)c2); + + if ((unsigned char)c <= (unsigned char)test && + (unsigned char)test <= (unsigned char)c2) + ok = 1; + } else if (c == test) + ok = 1; + } + return (ok == negate ? NULL : pattern); +} diff --git a/win32/fnmatch.h b/win32/fnmatch.h new file mode 100644 index 000000000..1e13c3b49 --- /dev/null +++ b/win32/fnmatch.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + * + * From FreeBSD fnmatch.h 1.7 + * $Id: fnmatch.h,v 1.1.2.2 2009/01/20 01:37:48 pajoye Exp $ + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ +#include "php.h" + +#define FNM_NOMATCH 1 /* Match failed. */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ +#define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ +#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ +#define FNM_PREFIX_DIRS 0x20 /* Directory prefixes of pattern match too. */ + +PHPAPI int fnmatch(const char *pattern, const char *string, int flags); + +#endif /* !_FNMATCH_H_ */ diff --git a/win32/glob.c b/win32/glob.c index 744b37263..f4c469990 100644 --- a/win32/glob.c +++ b/win32/glob.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -/* $Id: glob.c,v 1.6.6.1 2006/11/10 09:56:16 dmitry Exp $ */ +/* $Id: glob.c,v 1.6.6.1.2.1 2009/01/01 12:32:48 pajoye Exp $ */ /* * glob(3) -- a superset of the one defined in POSIX 1003.2. @@ -159,7 +159,7 @@ static int match(Char *, Char *, Char *); static void qprintf(const char *, Char *); #endif -int +PHPAPI int glob(pattern, flags, errfunc, pglob) const char *pattern; int flags, (*errfunc)(const char *, int); @@ -811,7 +811,7 @@ match(name, pat, patend) } /* Free allocated data belonging to a glob_t structure. */ -void +PHPAPI void globfree(pglob) glob_t *pglob; { diff --git a/win32/glob.h b/win32/glob.h index 67f4fc112..8dc146470 100644 --- a/win32/glob.h +++ b/win32/glob.h @@ -1,4 +1,4 @@ -/* $Id: glob.h,v 1.1 2002/05/19 14:32:24 edink Exp $ */ +/* $Id: glob.h,v 1.1.24.2 2009/01/01 12:32:49 pajoye Exp $ */ /* OpenBSD: glob.h,v 1.7 2002/02/17 19:42:21 millert Exp */ /* NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp */ @@ -43,7 +43,9 @@ #ifndef _GLOB_H_ #define _GLOB_H_ -#include +#ifndef PHP_WIN32 +# include +#endif struct stat; typedef struct { @@ -93,9 +95,8 @@ typedef struct { #define GLOB_NOSYS (-4) /* Function not supported. */ #define GLOB_ABEND GLOB_ABORTED -__BEGIN_DECLS -int glob(const char *, int, int (*)(const char *, int), glob_t *); -void globfree(glob_t *); -__END_DECLS - +BEGIN_EXTERN_C() +PHPAPI int glob(const char *, int, int (*)(const char *, int), glob_t *); +PHPAPI void globfree(glob_t *); +END_EXTERN_C() #endif /* !_GLOB_H_ */ diff --git a/win32/globals.c b/win32/globals.c index 1bdc27980..741d7ed41 100755 --- a/win32/globals.c +++ b/win32/globals.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: globals.c,v 1.5.2.1.2.5 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: globals.c,v 1.5.2.1.2.3.2.2 2008/12/31 11:15:49 sebastian Exp $ */ #include "php.h" #include "php_win32_globals.h" diff --git a/win32/grp.h b/win32/grp.h index 45e5c848c..520a5b536 100644 --- a/win32/grp.h +++ b/win32/grp.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: grp.h,v 1.7.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: grp.h,v 1.7.2.1.2.1.2.2 2008/12/31 11:15:49 sebastian Exp $ */ struct group { char *gr_name; diff --git a/win32/inet.c b/win32/inet.c new file mode 100644 index 000000000..b794bcaeb --- /dev/null +++ b/win32/inet.c @@ -0,0 +1,88 @@ +#include "config.w32.h" +#if (_WIN32_WINNT < 0x0600) /* Vista/2k8 have these functions */ +#include "php.h" +#include +#include +#include + +#include "inet.h" + +PHPAPI int inet_pton(int af, const char* src, void* dst) +{ + int address_length; + struct sockaddr_storage sa; + struct sockaddr_in *sin = (struct sockaddr_in *)&sa; + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa; + + switch (af) { + case AF_INET: + address_length = sizeof (struct sockaddr_in); + break; + + case AF_INET6: + address_length = sizeof (struct sockaddr_in6); + break; + + default: + return -1; + } + + if (WSAStringToAddress ((LPTSTR) src, af, NULL, (LPSOCKADDR) &sa, &address_length) == 0) { + switch (af) { + case AF_INET: + memcpy (dst, &sin->sin_addr, sizeof (struct in_addr)); + break; + + case AF_INET6: + memcpy (dst, &sin6->sin6_addr, sizeof (struct in6_addr)); + break; + } + return 1; + } + + return 0; +} + +PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size) +{ + int address_length; + DWORD string_length = size; + struct sockaddr_storage sa; + struct sockaddr_in *sin = (struct sockaddr_in *)&sa; + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa; + + memset (&sa, 0, sizeof (sa)); + switch (af) { + case AF_INET: + address_length = sizeof (struct sockaddr_in); + sin->sin_family = af; + memcpy (&sin->sin_addr, src, sizeof (struct in_addr)); + break; + + case AF_INET6: + address_length = sizeof (struct sockaddr_in6); + sin6->sin6_family = af; + memcpy (&sin6->sin6_addr, src, sizeof (struct in6_addr)); + break; + + default: + return NULL; + } + + if (WSAAddressToString ((LPSOCKADDR) &sa, address_length, NULL, dst, &string_length) == 0) { + return dst; + } + + return NULL; +} + +int inet_aton(const char *cp, struct in_addr *inp) { + inp->s_addr = inet_addr(cp); + + if (inp->s_addr == INADDR_NONE) { + return 0; + } + + return 1; +} +#endif diff --git a/win32/inet.h b/win32/inet.h new file mode 100644 index 000000000..7b3821c71 --- /dev/null +++ b/win32/inet.h @@ -0,0 +1,10 @@ +#if _MSC_VER >= 1500 +# include +#endif +#include + +#if (_WIN32_WINNT <= 0x500) +PHPAPI int inet_pton(int af, const char* src, void* dst); +PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size); +PHPAPI int inet_aton(const char *cp, struct in_addr *inp); +#endif diff --git a/win32/install.txt b/win32/install.txt index 198d7f7dc..d77e4f186 100644 --- a/win32/install.txt +++ b/win32/install.txt @@ -6,8 +6,7 @@ Installing PHP 1. General Installation Considerations 2. Installation on Windows systems - Windows Installer (PHP 5.2 and later) - Windows Installer (PHP 5.1.0 and earlier) + Windows Installer Manual Installation Steps ActiveScript Microsoft IIS / PWS @@ -292,64 +291,6 @@ Manual Installation Steps The directory structure extracted from the zip is different for PHP versions 4 and 5 and look like as follows: - Example 2-1. PHP 4 package structure -c:\php - | - +--cli - | | - | |-php.exe -- CLI executable - ONLY for command line scripting - | - +--dlls -- support DLLs required by some extensions - | | - | |-expat.dll - | | - | |-fdftk.dll - | | - | |-... - | - +--extensions -- extension DLLs for PHP - | | - | |-php_bz2.dll - | | - | |-php_cpdf.dll - | | - | |-.. - | - +--mibs -- support files for SNMP - | - +--openssl -- support files for Openssl - | - +--pdf-related -- support files for PDF - | - +--sapi -- SAPI (server module support) DLLs - | | - | |-php4apache.dll - | | - | |-php4apache2.dll - | | - | |-.. - | - +--PEAR -- initial copy of PEAR - | - | - |-go-pear.bat -- PEAR setup script - | - |-.. - | - |-php.exe -- CGI executable - | - |-.. - | - |-php.ini-dist -- default php.ini settings - | - |-php.ini-recommended -- recommended php.ini settings - | - |-php4ts.dll -- core PHP DLL - | - |-... - - Or: - Example 2-2. PHP 5 package structure c:\php | @@ -392,9 +333,9 @@ c:\php | |-.. | - |-php.ini-dist -- default php.ini settings + |-php.ini-development -- development php.ini settings | - |-php.ini-recommended -- recommended php.ini settings + |-php.ini-production -- recommended php.ini settings for production | |-php5activescript.dll | @@ -419,24 +360,23 @@ c:\php Note: In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g. C:\php). - Here is a list of server modules shipped with PHP 4 and PHP 5: + Here is a list of server modules shipped with PHP 5: - * sapi/php4activescript.dll (php5activescript.dll) - ActiveScript - engine, allowing you to embed PHP in your Windows applications. - * sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module. - * sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module. * sapi/php5apache2_2.dll - Apache 2.2.x module. - * sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI - compliant web servers like IIS 4.0/PWS 4.0 or newer. - * sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server - module. - * sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server + * sapi/php5apache.dll (php5apache.dll) - Apache 1.x module + * sapi/php5apache2.dll (php5apache2.dll) - - Apache 2.0.x module. + * sapi/php5isapi.dll - ISAPI Module for ISAPI compliant web servers + like IIS 5.0 or newer. However the FCGI SAPI is recommended with + IIS + * sapi/php5nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server module. Server modules provide significantly better performance and additional - functionality compared to the CGI binary. The CLI version is designed - to let you use PHP for command line scripting. More information about - CLI is available in the chapter about using PHP from the command line. + functionality compared to the CGI binary. The FastCGI is significantly + more stable and can be faster than the ISAPI module with IIS. + The CLI version is designed to let you use PHP for command line + scripting. More information about CLI is available in the chapter + about using PHP from the command line. Warning @@ -445,7 +385,7 @@ c:\php other server modules failing, such as ASP. The CGI and CLI binaries, and the web server modules all require the - php4ts.dll (php5ts.dll) file to be available to them. You have to make + php5ts.dll file to be available to them. You have to make sure that this file can be found by your PHP installation. The search order for this DLL is as follows: @@ -454,7 +394,7 @@ c:\php Files\Apache Group\Apache2\bin). * Any directory in your Windows PATH environment variable. - To make php4ts.dll / php5ts.dll available you have three options: copy + To make php5ts.dll available you have three options: copy the file to the Windows system directory, copy the file to the web server's directory, or add your PHP directory, C:\php to the PATH. For better maintenance, we advise you to follow the last option, add C:\php @@ -464,12 +404,12 @@ c:\php - logoff isn't enough). The next step is to set up a valid configuration file for PHP, php.ini. - There are two ini files distributed in the zip file, php.ini-dist and - php.ini-recommended. We advise you to use php.ini-recommended, because - we optimized the default settings in this file for performance, and - security. Read this well documented file carefully because it has - changes from php.ini-dist that will drastically affect your setup. Some - examples are display_errors being off and magic_quotes_gpc being off. + There are two ini files distributed in the zip file, php.ini-development + and php.ini-production. We advise you to use php.ini-production, + because we optimized the default settings in this file for performance, + and security. Read this well documented file carefully because it has + changes from php.ini-production that will drastically affect your setup. + Some examples are display_errors being off and magic_quotes_gpc being off. In addition to reading these, study the ini settings and set every element manually yourself. If you would like to achieve the best security, then this is the way for you, although PHP works fine with @@ -639,7 +579,7 @@ Windows NT/200x/XP and IIS 4 or newer * If you don't want to perform HTTP Authentication using PHP, you can (and should) skip this step. Under ISAPI Filters, add a new ISAPI filter. Use PHP as the filter name, and supply a path to the - php4isapi.dll / php5isapi.dll. + php5isapi.dll. * Under 'Home Directory', 'Virtual Directory', or 'Directory', do the following: * Change the Execute Permissions to 'Scripts only' @@ -655,7 +595,7 @@ Windows NT/200x/XP and IIS 4 or newer With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service Extensions, choose "Add a new Web service extension", enter in a name such as PHP, choose the Add button and for the value browse to either - the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or + the ISAPI file (php5isapi.dll) or CGI (php.exe or php-cgi.exe) then check "Set extension status to Allowed" and click OK. In order to use index.php as a default content page, do the following: @@ -671,82 +611,9 @@ Windows NT/200x/XP and IIS 4 or newer setting Cache ISAPI Application. __________________________________________________________________ -Windows and PWS 4 - - PWS 4 does not support ISAPI, only PHP CGI should be used. - - * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look into - the SAPI folder for PHP 4, or in the main folder for PHP 5) to - reflect the location of your php.exe / php-cgi.exe. Backslashes - should be escaped, for example: - [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\paramet - ers\Script Map] ".php"="C:\\php\\php.exe" (change to - C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this - registery file into your system; you may do this by double-clicking - it. - * In the PWS Manager, right click on a given directory you want to - add PHP support to, and select Properties. Check the 'Execute' - checkbox, and confirm. - __________________________________________________________________ - -Windows and PWS/IIS 3 - - The recommended method for configuring these servers is to use the REG - file included with the distribution (pws-php4cgi.reg in the SAPI folder - for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5). You may - want to edit this file and make sure the extensions and PHP install - directories match your configuration. Or you can follow the steps below - to do it manually. +Windows and IIS - Warning - - These steps involve working directly with the Windows registry. One - error here can leave your system in an unstable state. We highly - recommend that you back up your registry first. The PHP Development - team will not be held responsible if you damage your registry. - - * Run Regedit. - * Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet - /Services /W3Svc /Parameters /ScriptMap. - * On the edit menu select: New->String Value. - * Type in the extension you wish to use for your php scripts. For - example .php - * Double click on the new string value and enter the path to php.exe - in the value data field. ex: C:\php\php.exe "%s" %s for PHP 4, or - C:\php\php-cgi.exe "%s" %s for PHP 5. - * Repeat these steps for each extension you wish to associate with - PHP scripts. - - The following steps do not affect the web server installation and only - apply if you want your PHP scripts to be executed when they are run - from the command line (ex. run C:\myscripts\test.php) or by double - clicking on them in a directory viewer window. You may wish to skip - these steps as you might prefer the PHP files to load into a text - editor when you double click on them. - - * Navigate to: HKEY_CLASSES_ROOT - * On the edit menu select: New->Key. - * Name the key to the extension you setup in the previous section. - ex: .php - * Highlight the new key and in the right side pane, double click the - "default value" and enter phpfile. - * Repeat the last step for each extension you set up in the previous - section. - * Now create another New->Key under HKEY_CLASSES_ROOT and name it - phpfile. - * Highlight the new key phpfile and in the right side pane, double - click the "default value" and enter PHP Script. - * Right click on the phpfile key and select New->Key, name it Shell. - * Right click on the Shell key and select New->Key, name it open. - * Right click on the open key and select New->Key, name it command. - * Highlight the new key command and in the right side pane, double - click the "default value" and enter the path to php.exe. ex: - c:\php\php.exe -q %1. (don't forget the %1). - * Exit Regedit. - * If using PWS on Windows, reboot to reload the registry. - - PWS and IIS 3 users now have a fully operational system. IIS 3 users - can use a nifty tool from Steven Genusa to configure their script maps. +See http://www.php.net/install.windows __________________________________________________________________ Apache 1.3.x on Microsoft Windows @@ -791,14 +658,6 @@ Installing as an Apache module This assumes PHP is installed to c:\php. Adjust the path if this is not the case. - For PHP 4: -# Add to the end of the LoadModule section -# Don't forget to copy this file from the sapi directory! -LoadModule php4_module "C:/php/php4apache.dll" - -# Add to the end of the AddModule section -AddModule mod_php4.c - For PHP 5: # Add to the end of the LoadModule section LoadModule php5_module "C:/php/php5apache.dll" @@ -944,10 +803,6 @@ Installing as an Apache module configuration file to set up the PHP module for Apache 2.0: Example 2-6. PHP and Apache 2.0 as Module -# For PHP 4 do something like this: -LoadModule php4_module "c:/php/php4apache2.dll" -# Don't forget to copy the php4apache2.dll file from the sapi directory! -AddType application/x-httpd-php .php # For PHP 5 do something like this: LoadModule php5_module "c:/php/php5apache2.dll" @@ -957,10 +812,9 @@ AddType application/x-httpd-php .php PHPIniDir "C:/php" Note: Remember to substitute your actual path to PHP for the c:/php/ - in the above examples. Take care to use either php4apache2.dll or - php5apache2.dll in your LoadModule directive and not php4apache.dll - or php5apache.dll as the latter ones are designed to run with Apache - 1.3.x. + in the above examples. Take care to use either + php5apache2.dll in your LoadModule directive and not php5apache.dll + as the latter ones are designed to run with Apache 1.3.x. Note: If you want to use content negotiation, read related FAQ. @@ -987,7 +841,7 @@ CGI setup on Sun, iPlanet and Netscape servers To install PHP as a CGI handler, do the following: - * Copy php4ts.dll to your systemroot (the directory where you + * Copy php5ts.dll to your systemroot (the directory where you installed Windows) * Make a file association from the command line. Type the following two lines: @@ -1012,7 +866,7 @@ NSAPI setup on Sun, iPlanet and Netscape servers To install PHP with NSAPI, do the following: - * Copy php4ts.dll to your systemroot (the directory where you + * Copy php5ts.dll to your systemroot (the directory where you installed Windows) * Make a file association from the command line. Type the following two lines: @@ -1027,24 +881,24 @@ ftype PHPScript=c:\php\php.exe %1 %* and add the following: You should place the lines after mime types init. -Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/ -php/sapi/php4nsapi.dll" -Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ +Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="c:/ +php/sapi/php5nsapi.dll" +Init fn="php5_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ ini="c:/path/to/php.ini"] - (PHP >= 4.3.3) The php_ini parameter is optional but with it you + The php_ini parameter is optional but with it you can place your php.ini in your web server configuration directory. * Configure the default object in obj.conf (for virtual server classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the section, place this line necessarily after all 'ObjectType' and before all 'AddLog' lines: -Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inike +Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value inike y=value ...] - (PHP >= 4.3.3) As additional parameters you can add some special + As additional parameters you can add some special php.ini-values, for example you can set a - docroot="/path/to/docroot" specific to the context php4_execute is + docroot="/path/to/docroot" specific to the context php5_execute is called. For boolean ini-keys please use 0/1 as value, not "On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On" @@ -1053,7 +907,7 @@ y=value ...] ObjectType fn="force-type" type="magnus-internal/x-httpd-php" -Service fn=php4_execute [inikey=value inikey=value ...] +Service fn=php5_execute [inikey=value inikey=value ...] After that you can configure a directory in the Administration @@ -1095,7 +949,7 @@ CGI environment and recommended modifications in php.ini CGI-like environment variables. Simply change your scripts to get CGI variables in the correct way for - PHP 4.x by using the superglobal $_SERVER. If you have older scripts + PHP 5.x by using the superglobal $_SERVER. If you have older scripts which use $HTTP_HOST, etc., you should turn on register_globals in php.ini and change the variable order too (important: remove "E" from it, because you do not need the environment here): @@ -1108,7 +962,7 @@ Special use for error pages or self-made directory listings (PHP >= 4.3.3) You can use PHP to generate the error pages for "404 Not Found" or similar. Add the following line to the object in obj.conf for every error page you want to overwrite: -Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inik +Error fn="php5_execute" code=XXX script="/path/to/script.php" [inikey=value inik ey=value...] where XXX is the HTTP error code. Please delete any other Error @@ -1120,7 +974,7 @@ ey=value...] create a PHP script which displays a directory listing and replace the corresponding default Service line for type="magnus-internal/directory" in obj.conf with the following: -Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scri +Service fn="php5_execute" type="magnus-internal/directory" script="/path/to/scri pt.php" [inikey=value inikey=value...] For both error and directory listing pages the original URI and @@ -1145,8 +999,8 @@ Note about nsapi_virtual() and subrequests (PHP >= 4.3.3) server is used, the detection fails and nsapi_virtual() is disabled. If this is the case, try the following: Add the following parameter to - php4_init in magnus.conf/obj.conf: - Init fn=php4_init ... server_lib="ns-httpdXX.dll" + php5_init in magnus.conf/obj.conf: + Init fn=php5_init ... server_lib="ns-httpdXX.dll" where XX is the correct DLL version number. To get it, look in the server-root for the correct DLL name. The DLL with the biggest filesize @@ -1190,46 +1044,6 @@ OmniHTTPd Server Repeat steps 2 - 6 for each extension you want to associate with PHP. - Note: Some OmniHTTPd packages come with built in PHP support. You - can choose at setup time to do a custom setup, and uncheck the PHP - component. We recommend you to use the latest PHP binaries. Some - OmniHTTPd servers come with PHP 4 beta distributions, so you should - choose not to set up the built in support, but install your own. If - the server is already on your machine, use the Replace button in - Step 4 and 5 to set the new, correct information. - __________________________________________________________________ - -Sambar Server on Microsoft Windows - - This section contains notes and hints specific to the Sambar Server for - Windows. - - Note: You should read the manual installation steps first! - - This list describes how to set up the ISAPI module to work with the - Sambar server on Windows. - - * Find the file called mappings.ini (in the config directory) in the - Sambar install directory. - * Open mappings.ini and add the following line under [ISAPI]: - - Example 2-7. ISAPI configuration of Sambar -#for PHP 4 -*.php = c:\php\php4isapi.dll - -#for PHP 5 -*.php = c:\php\php5isapi.dll - - (This line assumes that PHP was installed in c:\php.) - * Now restart the Sambar server for the changes to take effect. - - Note: If you intend to use PHP to communicate with resources which - are held on a different computer on your network, then you will need - to alter the account used by the Sambar Server Service. The default - account used for the Sambar Server Service is LocalSystem which will - not have access to remote resources. The account can be amended by - using the Services option from within the Windows Control Panel - Administation Tools. __________________________________________________________________ Xitami on Microsoft Windows @@ -1258,8 +1072,7 @@ Xitami on Microsoft Windows * Navigate to the Filters, and put the extension which PHP should parse (i.e. .php) into the field File extensions (.xxx). * In Filter command or script put the path and name of your PHP CGI - executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe for - PHP 5. + executable i.e. C:\php\php-cgi.exe. * Press the 'Save' icon. * Restart the server to reflect changes. __________________________________________________________________ @@ -1280,16 +1093,13 @@ Installation of extensions on Windows that require, or used to require, additional PHP DLL files. Here's a list of built in extensions: - In PHP 4 (updated PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP, MySQL, - ODBC, Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib - In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in: DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are no longer built in: MySQL and Overload. - The default location PHP searches for extensions is C:\php4\extensions - in PHP 4 and C:\php5 in PHP 5. To change this setting to reflect your - setup of PHP edit your php.ini file: + The default location PHP searches for extensions is C:\php5 in PHP 5. + To change this setting to reflect your setup of PHP edit your php.ini + file: * You will need to change the extension_dir setting to point to the directory where your extensions lives, or where you have placed @@ -1309,13 +1119,9 @@ extension_dir = C:\php\extensions extension=php_bz2.dll * Some of the extensions need extra DLLs to work. Couple of them can - be found in the distribution package, in the C:\php\dlls\ folder in - PHP 4 or in the main folder in PHP 5, but some, for example Oracle - (php_oci8.dll) require DLLs which are not bundled with the - distribution package. If you are installing PHP 4, copy the bundled - DLLs from C:\php\dlls folder to the main C:\php folder. Don't - forget to include C:\php in the system PATH (this process is - explained in a separate FAQ entry). + be found in the distribution package, in in the main folder in PHP 5, + but some, for example Oracle (php_oci8.dll) require DLLs which are + not bundled with the distribution package. * Some of these DLLs are not bundled with the PHP distribution. See each extensions documentation page for details. Also, read the manual section titled Installation of PECL extensions for details @@ -1331,48 +1137,31 @@ extension=php_bz2.dll Table 2-1. PHP Extensions Extension Description Notes php_bz2.dll bzip2 compression functions None - php_calendar.dll Calendar conversion functions Built in since PHP 4.0.3 + php_calendar.dll Calendar conversion functions php_cpdf.dll ClibPDF functions None php_crack.dll Crack functions None - php_ctype.dll ctype family functions Built in since PHP 4.3.0 + php_ctype.dll ctype family functions php_curl.dll CURL, Client URL library functions Requires: libeay32.dll, ssleay32.dll (bundled) - php_cybercash.dll Cybercash payment functions PHP <= 4.2.0 php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll) php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None php_dbase.dll dBase functions None php_dbx.dll dbx functions - php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll - (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled) - php_dotnet.dll .NET functions PHP <= 4.1.1 php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must be loaded after php_mbstring.dll in php.ini. - php_fbsql.dll FrontBase functions PHP <= 4.2.0 php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll (bundled) php_filepro.dll filePro functions Read-only access - php_ftp.dll FTP functions Built-in since PHP 4.0.3 - php_gd.dll GD library image functions Removed in PHP 4.3.2. Also note - that truecolor functions are not available in GD1, instead, use - php_gd2.dll. + php_ftp.dll FTP functions php_gd2.dll GD library image functions GD2 - php_gettext.dll Gettext functions PHP <= 4.2.0 requires gnu_gettext.dll - (bundled), PHP >= 4.2.3 requires libintl-1.dll, iconv.dll (bundled). - php_hyperwave.dll HyperWave functions None - php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll - (bundled), PHP >=4.2.1 iconv.dll - php_ifx.dll Informix functions Requires: Informix libraries - php_iisfunc.dll IIS management functions None + php_gettext.dll Gettext functions, requires libintl-1.dll, + iconv.dll (bundled). + php_iconv.dll ICONV characterset conversion Requires: iconv.dll php_imap.dll IMAP POP3 and NNTP functions None - php_ingres.dll Ingres II functions Requires: Ingres II libraries php_interbase.dll InterBase functions Requires: gds32.dll (bundled) - php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled) - php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll - (bundled), PHP >= 4.3.0 requires libeay32.dll, ssleay32.dll (bundled) + php_ldap.dll LDAP functions requires libeay32.dll, ssleay32.dll (bundled) php_mbstring.dll Multi-Byte String functions None php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll - php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll - (bundled) php_mime_magic.dll Mimetype functions Requires: magic.mime (bundled) php_ming.dll Ming functions for Flash None php_msql.dll mSQL functions Requires: msql.dll (bundled) @@ -1384,8 +1173,6 @@ extension=php_bz2.dll php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled) php_oracle.dll Oracle functions Requires: Oracle 7 client libraries - php_overload.dll Object overloading functions Built in since PHP 4.3.0 - php_pdf.dll PDF functions None php_pgsql.dll PostgreSQL functions None php_printer.dll Printer functions None php_shmop.dll Shared Memory functions None @@ -1395,15 +1182,11 @@ extension=php_bz2.dll php_sybase_ct.dll Sybase functions Requires: Sybase client libraries php_tidy.dll Tidy functions PHP >= 5.0.0 php_tokenizer.dll Tokenizer functions Built in since PHP 4.3.0 - php_w32api.dll W32api functions None php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll (bundled) - php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll, expat.dll - (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll, iconv.dll - (bundled). - php_yaz.dll YAZ functions Requires: yaz.dll (bundled) - php_zip.dll Zip File functions Read only access - php_zlib.dll ZLib compression functions Built in since PHP 4.3.0 + php_xslt.dll XSLT requires libxslt.dll, iconv.dll (bundled). + php_zip.dll Zip File functions + php_zlib.dll ZLib compression functions __________________________________________________________________ Chapter 3. Installation of PECL extensions @@ -1717,14 +1500,6 @@ Running PHP as an Apache module php_value include_path ".:/usr/local/lib/php" php_admin_flag safe_mode on - - php_value include_path ".:/usr/local/lib/php" - php_admin_flag safe_mode on - - - php3_include_path ".:/usr/local/lib/php" - php3_safe_mode on - Caution @@ -1798,7 +1573,7 @@ Chapter 6. Installation FAQ 9. Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors: -[mybox:user /src/php4] root# apachectl configtest +[mybox:user /src/php5] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress @@ -1858,7 +1633,7 @@ cgi error: example, set it with something like: --with-config-file-path=/etc - And then you would copy php.ini-dist from the distribution to + And then you would copy php.ini-production from the distribution to /etc/php.ini and edit it to make any local changes you want. --with-config-file-scan-dir=PATH @@ -1909,8 +1684,6 @@ AddModule mod_perl.c # Extra Modules LoadModule php_module modules/mod_php.so -LoadModule php3_module modules/libphp3.so # for PHP 3 -LoadModule php4_module modules/libphp4.so # for PHP 4 LoadModule perl_module modules/libperl.so And add: @@ -2011,7 +1784,7 @@ rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm 9. Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors: -[mybox:user /src/php4] root# apachectl configtest +[mybox:user /src/php5] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress @@ -2039,7 +1812,7 @@ cgi error: the browser again. If it still fails then it could be one of the following: - * File permissions on your PHP script, php.exe, php4ts.dll, php.ini + * File permissions on your PHP script, php.exe, php5ts.dll, php.ini or any PHP extensions you are trying to load are such that the anonymous internet user ISUR_ cannot access them. * The script file does not exist (or possibly isn't where you think diff --git a/win32/md5crypt.c b/win32/md5crypt.c deleted file mode 100644 index c5f7dad3c..000000000 --- a/win32/md5crypt.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 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: Edin Kadribasic | - +----------------------------------------------------------------------+ - */ - -/* $Id: md5crypt.c,v 1.6.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ - -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * from FreeBSD: crypt.c,v 1.5 1996/10/14 08:34:02 phk Exp - * via OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp - * via NetBSD: md5crypt.c,v 1.4.2.1 2002/01/22 19:31:59 he Exp - * - */ - -#include "php.h" -#include "ext/standard/md5.h" -#include "md5crypt.h" - -static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -static void to64(char *, php_uint32, int); - -static void -to64(char *s, php_uint32 v, int n) -{ - - while (--n >= 0) { - *s++ = itoa64[v & 0x3f]; - v >>= 6; - } -} - -/* - * MD5 password encryption. - */ -char * -md5_crypt(const char *pw, const char *salt) -{ - static char passwd[120], *p; - const char *sp, *ep; - unsigned char final[16]; - unsigned int i, sl, pwl; - PHP_MD5_CTX ctx, ctx1; - php_uint32 l; - int pl; - - pwl = strlen(pw); - - /* Refine the salt first */ - sp = salt; - - /* If it starts with the magic string, then skip that */ - if (strncmp(sp, MD5_MAGIC, MD5_MAGIC_LEN) == 0) - sp += MD5_MAGIC_LEN; - - /* It stops at the first '$', max 8 chars */ - for (ep = sp; *ep != '\0' && *ep != '$' && ep < (sp + 8); ep++) - continue; - - /* get the length of the true salt */ - sl = ep - sp; - - PHP_MD5Init(&ctx); - - /* The password first, since that is what is most unknown */ - PHP_MD5Update(&ctx, (const unsigned char *)pw, pwl); - - /* Then our magic string */ - PHP_MD5Update(&ctx, (const unsigned char *)MD5_MAGIC, MD5_MAGIC_LEN); - - /* Then the raw salt */ - PHP_MD5Update(&ctx, (const unsigned char *)sp, sl); - - /* Then just as many characters of the MD5(pw,salt,pw) */ - PHP_MD5Init(&ctx1); - PHP_MD5Update(&ctx1, (const unsigned char *)pw, pwl); - PHP_MD5Update(&ctx1, (const unsigned char *)sp, sl); - PHP_MD5Update(&ctx1, (const unsigned char *)pw, pwl); - PHP_MD5Final(final, &ctx1); - - for (pl = pwl; pl > 0; pl -= 16) - PHP_MD5Update(&ctx, final, (unsigned int)(pl > 16 ? 16 : pl)); - - /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); - - /* Then something really weird... */ - for (i = pwl; i != 0; i >>= 1) - if ((i & 1) != 0) - PHP_MD5Update(&ctx, final, 1); - else - PHP_MD5Update(&ctx, (const unsigned char *)pw, 1); - - /* Now make the output string */ - memcpy(passwd, MD5_MAGIC, MD5_MAGIC_LEN); - strlcpy(passwd + MD5_MAGIC_LEN, sp, sl + 1); - strcat(passwd, "$"); - - PHP_MD5Final(final, &ctx); - - /* - * And now, just to make sure things don't run too fast. On a 60 MHz - * Pentium this takes 34 msec, so you would need 30 seconds to build - * a 1000 entry dictionary... - */ - for (i = 0; i < 1000; i++) { - PHP_MD5Init(&ctx1); - - if ((i & 1) != 0) - PHP_MD5Update(&ctx1, (const unsigned char *)pw, pwl); - else - PHP_MD5Update(&ctx1, final, 16); - - if ((i % 3) != 0) - PHP_MD5Update(&ctx1, (const unsigned char *)sp, sl); - - if ((i % 7) != 0) - PHP_MD5Update(&ctx1, (const unsigned char *)pw, pwl); - - if ((i & 1) != 0) - PHP_MD5Update(&ctx1, final, 16); - else - PHP_MD5Update(&ctx1, (const unsigned char *)pw, pwl); - - PHP_MD5Final(final, &ctx1); - } - - p = passwd + sl + MD5_MAGIC_LEN + 1; - - l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4; - l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4; - l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4; - l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4; - l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4; - l = final[11] ; to64(p,l,2); p += 2; - *p = '\0'; - - /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); - return (passwd); -} - diff --git a/win32/md5crypt.h b/win32/md5crypt.h deleted file mode 100644 index 52c999c72..000000000 --- a/win32/md5crypt.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 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: Edin Kadribasic | - +----------------------------------------------------------------------+ - */ - -/* $Id: md5crypt.h,v 1.5.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ -#ifndef _MD5CRYPT_H_ -#define _MD5CRYPT_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define MD5_MAGIC "$1$" -#define MD5_MAGIC_LEN 3 - -char *md5_crypt(const char *pw, const char *salt); - -#ifdef __cplusplus -} -#endif - -#endif /* _MD5CRYPT_H_ */ \ No newline at end of file diff --git a/win32/php5dll.dsp b/win32/php5dll.dsp index 24e4227a0..b0a26bcfc 100644 --- a/win32/php5dll.dsp +++ b/win32/php5dll.dsp @@ -1576,10 +1576,6 @@ SOURCE=..\win32\wfile.c # End Source File # Begin Source File -SOURCE=..\ext\snmp\winsnmp.c -# End Source File -# Begin Source File - SOURCE=..\win32\winutil.c # End Source File # Begin Source File diff --git a/win32/php5dllts.dsp b/win32/php5dllts.dsp index d9bf1882a..0faddf954 100644 --- a/win32/php5dllts.dsp +++ b/win32/php5dllts.dsp @@ -2415,10 +2415,6 @@ SOURCE=..\win32\wfile.c # End Source File # Begin Source File -SOURCE=..\ext\snmp\winsnmp.c -# End Source File -# Begin Source File - SOURCE=..\win32\winutil.c # End Source File # Begin Source File diff --git a/win32/php5ts_cli.rc2 b/win32/php5ts_cli.rc2 index 41554c64f..130759ab6 100644 --- a/win32/php5ts_cli.rc2 +++ b/win32/php5ts_cli.rc2 @@ -40,7 +40,7 @@ BEGIN 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-2007 The PHP Group\0" + VALUE "LegalCopyright", "Copyright © 1997-2006 The PHP Group\0" VALUE "LegalTrademarks", "php\0" VALUE "OriginalFilename", "php.exe\0" VALUE "PrivateBuild", "\0" diff --git a/win32/php_stdint.h b/win32/php_stdint.h new file mode 100644 index 000000000..70909f063 --- /dev/null +++ b/win32/php_stdint.h @@ -0,0 +1,244 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2009 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#if (_MSC_VER < 1300) && defined(__cplusplus) + extern "C++" { +#endif +# include +#if (_MSC_VER < 1300) && defined(__cplusplus) + } +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types +typedef __int8 int8_t; +typedef __int16 int16_t; +#ifndef int32_t +typedef __int32 int32_t; +#endif +#ifndef int64_t +typedef __int64 int64_t; +#endif +#ifndef uint8_t +typedef unsigned __int8 uint8_t; +#endif +#ifndef u_char +typedef unsigned __int8 u_char; +#endif +typedef unsigned __int16 uint16_t; +#ifndef uint32_t +typedef unsigned __int32 uint32_t; +#endif +typedef unsigned __int64 uint64_t; + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint32_t u_int32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/win32/php_strtoi64.h b/win32/php_strtoi64.h new file mode 100644 index 000000000..633ecb105 --- /dev/null +++ b/win32/php_strtoi64.h @@ -0,0 +1,7 @@ +#if _MSC_VERS <= 1300 +#include "php.h" +#include "php_stdint.h" + +PHPAPI int64_t _strtoi64(const char *nptr, char **endptr, int base); +#define _strtoui64 _strtoi64 +#endif diff --git a/win32/php_win32_globals.h b/win32/php_win32_globals.h index 2b45476b0..a7cb068f5 100755 --- a/win32/php_win32_globals.h +++ b/win32/php_win32_globals.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_win32_globals.h,v 1.4.2.1.2.5 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: php_win32_globals.h,v 1.4.2.1.2.3.2.2 2008/12/31 11:15:49 sebastian Exp $ */ #ifndef PHP_WIN32_GLOBALS_H #define PHP_WIN32_GLOBALS_H diff --git a/win32/readdir.h b/win32/readdir.h index f2a0191b7..f1fb3a736 100644 --- a/win32/readdir.h +++ b/win32/readdir.h @@ -7,7 +7,7 @@ * on Windows 95/NT. */ -#define _WIN32_WINNT 0x0400 +#include #include diff --git a/win32/registry.c b/win32/registry.c index cdeb85f21..d5f84af59 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -102,7 +102,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_ zend_hash_get_current_key_ex(parent_ht, &index, &index_len, &num, 0, &pos) == HASH_KEY_IS_STRING; zend_hash_move_forward_ex(parent_ht, &pos)) { if (zend_hash_add(ht, index, index_len, data, sizeof(zval*), NULL) == SUCCESS) { - (*data)->refcount++; + Z_ADDREF_PP(data); } } } diff --git a/win32/select.c b/win32/select.c index fb49bff05..073e1b0ce 100644 --- a/win32/select.c +++ b/win32/select.c @@ -21,7 +21,7 @@ #ifdef PHP_WIN32 -/* $Id: select.c,v 1.10.2.2.2.4 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: select.c,v 1.10.2.2.2.2.2.2 2008/12/31 11:15:49 sebastian Exp $ */ /* Win32 select() will only work with sockets, so we roll our own implementation here. * - If you supply only sockets, this simply passes through to winsock select(). diff --git a/win32/select.h b/win32/select.h index f1830f501..b6d632d1a 100644 --- a/win32/select.h +++ b/win32/select.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: select.h,v 1.4.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: select.h,v 1.4.2.1.2.1.2.2 2008/12/31 11:15:49 sebastian Exp $ */ PHPAPI int php_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv); diff --git a/win32/sockets.c b/win32/sockets.c new file mode 100644 index 000000000..003f25baf --- /dev/null +++ b/win32/sockets.c @@ -0,0 +1,71 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 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. | + +----------------------------------------------------------------------+ + | Authors: Chris Vandomelen | + | Sterling Hughes | + | | + | WinSock: Daniel Beulshausen | + +----------------------------------------------------------------------+ + */ + +/* $Id: sockets.c,v 1.1.2.2 2009/01/23 15:49:49 kalle Exp $ */ + +/* Code originally from ext/sockets */ + +#include +#include + +#include "php.h" + +PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2]) +{ + struct sockaddr_in address; + SOCKET redirect; + int size = sizeof(address); + + if(domain != AF_INET) { + WSASetLastError(WSAENOPROTOOPT); + return -1; + } + + + sock[0] = socket(domain, type, protocol); + address.sin_addr.s_addr = INADDR_ANY; + address.sin_family = AF_INET; + address.sin_port = 0; + + bind(sock[0], (struct sockaddr*)&address, sizeof(address)); + + if(getsockname(sock[0], (struct sockaddr *)&address, &size) != 0) { + } + + listen(sock[0], 2); + sock[1] = socket(domain, type, protocol); + address.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + connect(sock[1], (struct sockaddr*)&address, sizeof(address)); + redirect = accept(sock[0],(struct sockaddr*)&address, &size); + + closesocket(sock[0]); + sock[0] = redirect; + + if(sock[0] == INVALID_SOCKET ) { + closesocket(sock[0]); + closesocket(sock[1]); + WSASetLastError(WSAECONNABORTED); + return -1; + } + + return 0; +} diff --git a/win32/sockets.h b/win32/sockets.h new file mode 100644 index 000000000..8614614f3 --- /dev/null +++ b/win32/sockets.h @@ -0,0 +1,26 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 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. | + +----------------------------------------------------------------------+ + | Authors: Chris Vandomelen | + | Sterling Hughes | + | | + | WinSock: Daniel Beulshausen | + +----------------------------------------------------------------------+ + */ + +/* $Id: sockets.h,v 1.1.2.2 2009/01/23 15:49:49 kalle Exp $ */ + +/* Code originally from ext/sockets */ + +PHPAPI int socketpair(int domain, int type, int protocol, SOCKET sock[2]); \ No newline at end of file diff --git a/win32/strtoi64.c b/win32/strtoi64.c new file mode 100644 index 000000000..689cc0984 --- /dev/null +++ b/win32/strtoi64.c @@ -0,0 +1,122 @@ +#if _MSC_VERS <= 1300 +#include "php_strtoi64.h" +/* + From APR, apr_strings.c + See http://www.apache.org/licenses/LICENSE-2.0 +*/ + +PHPAPI int64_t _strtoi64(const char *nptr, char **endptr, int base) +{ + const char *s; + int64_t acc; + int64_t val; + int neg, any; + char c; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace((unsigned char)c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') { + c = *s++; + } + } + + if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) { + base = c == '0' ? 8 : 10; + } + acc = any = 0; + if (base < 2 || base > 36) { + errno = EINVAL; + if (endptr != NULL) { + *endptr = (char *)(any ? s - 1 : nptr); + } + return acc; + } + + /* The classic bsd implementation requires div/mod operators + * to compute a cutoff. Benchmarking proves that iss very, very + * evil to some 32 bit processors. Instead, look for underflow + * in both the mult and add/sub operation. Unlike the bsd impl, + * we also work strictly in a signed int64 word as we haven't + * implemented the unsigned type in win32. + * + * Set 'any' if any `digits' consumed; make it negative to indicate + * overflow. + */ + val = 0; + for ( ; ; c = *s++) { + if (c >= '0' && c <= '9') + c -= '0'; + +#if (('Z' - 'A') == 25) + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; +#elif APR_CHARSET_EBCDIC + else if (c >= 'A' && c <= 'I') + c -= 'A' - 10; + else if (c >= 'J' && c <= 'R') + c -= 'J' - 19; + else if (c >= 'S' && c <= 'Z') + c -= 'S' - 28; + else if (c >= 'a' && c <= 'i') + c -= 'a' - 10; + else if (c >= 'j' && c <= 'r') + c -= 'j' - 19; + else if (c >= 's' && c <= 'z') + c -= 'z' - 28; +#else +# error "CANNOT COMPILE apr_strtoi64(), only ASCII and EBCDIC supported" +#endif + else { + break; + } + + if (c >= base) { + break; + } + + val *= base; + if ( (any < 0) /* already noted an over/under flow - short circuit */ + || (neg && (val > acc || (val -= c) > acc)) /* underflow */ + || (val < acc || (val += c) < acc)) { /* overflow */ + any = -1; /* once noted, over/underflows never go away */ +#ifdef APR_STRTOI64_OVERFLOW_IS_BAD_CHAR + break; +#endif + } else { + acc = val; + any = 1; + } + } + + if (any < 0) { + acc = neg ? INT64_MIN : INT64_MAX; + errno = ERANGE; + } else if (!any) { + errno = EINVAL; + } + + if (endptr != NULL) { + *endptr = (char *)(any ? s - 1 : nptr); + } + return (acc); +} +#endif diff --git a/win32/syslog.h b/win32/syslog.h index 43fd1be5d..05ef02f41 100644 --- a/win32/syslog.h +++ b/win32/syslog.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: syslog.h,v 1.10.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: syslog.h,v 1.10.2.1.2.1.2.2 2008/12/31 11:15:49 sebastian Exp $ */ #ifndef SYSLOG_H #define SYSLOG_H diff --git a/win32/time.c b/win32/time.c index 115353294..b89064e03 100644 --- a/win32/time.c +++ b/win32/time.c @@ -11,7 +11,7 @@ * *****************************************************************************/ -/* $Id: time.c,v 1.10 2004/07/29 02:59:43 wez Exp $ */ +/* $Id: time.c,v 1.10.6.3 2009/01/19 02:35:21 pajoye Exp $ */ /** * @@ -22,9 +22,7 @@ /* Include stuff ************************************************************ */ -/* this allows the use of the WaitableTimer functions. - * For win98 and later */ -#define _WIN32_WINNT 0x400 +#include #include "time.h" #include "unistd.h" @@ -129,7 +127,7 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf return 0; } -void usleep(unsigned int useconds) +PHPAPI int usleep(unsigned int useconds) { HANDLE timer; LARGE_INTEGER due; @@ -140,6 +138,17 @@ void usleep(unsigned int useconds) SetWaitableTimer(timer, &due, 0, NULL, NULL, 0); WaitForSingleObject(timer, INFINITE); CloseHandle(timer); + return 0; +} + +PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ) +{ + if (rqtp->tv_nsec > 999999999) { + /* The time interval specified 1,000,000 or more microseconds. */ + errno = EINVAL; + return -1; + } + return usleep( rqtp->tv_sec * 1000000 + rqtp->tv_nsec / 1000 ); } #if 0 /* looks pretty ropey in here */ diff --git a/win32/time.h b/win32/time.h index 5c52e7837..f841a2b60 100644 --- a/win32/time.h +++ b/win32/time.h @@ -28,6 +28,14 @@ struct itimerval { struct timeval it_value; /* current value */ }; +#ifndef timespec +struct timespec +{ + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +#endif + #define ITIMER_REAL 0 /*generates sigalrm */ #define ITIMER_VIRTUAL 1 /*generates sigvtalrm */ #define ITIMER_VIRT 1 /*generates sigvtalrm */ @@ -40,4 +48,6 @@ PHPAPI extern int gettimeofday(struct timeval *time_Info, struct timezone *timez PHPAPI extern int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue); +PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ); + #endif diff --git a/win32/unistd.h b/win32/unistd.h index 96e0aedc1..0b9446149 100644 --- a/win32/unistd.h +++ b/win32/unistd.h @@ -1,4 +1,4 @@ #ifndef _PHP_WIN32_UNISTD_H #define _PHP_WIN32_UNISTD_H -void usleep(unsigned int useconds); +PHPAPI int usleep(unsigned int useconds); #endif diff --git a/win32/wfile.c b/win32/wfile.c index 1407d6a32..3a5118e03 100644 --- a/win32/wfile.c +++ b/win32/wfile.c @@ -6,7 +6,7 @@ int readlink(char *file_Name, char *buf_Mem, int buf_Size) { /* See if the file exists */ - if (access(file_Name, X_OK) == -1) { + if (access(file_Name, WFILE_EXISTS) == -1) { errno = ENOENT; } else { errno = EINVAL; diff --git a/win32/wfile.h b/win32/wfile.h index 2e7940647..0105e76ee 100644 --- a/win32/wfile.h +++ b/win32/wfile.h @@ -4,7 +4,7 @@ #include #define access _access -#define X_OK 0 +#define WFILE_EXISTS 0 #ifndef ENOENT #define ENOENT 136 #endif diff --git a/win32/winutil.c b/win32/winutil.c index 84a2cff22..ee1e700ce 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: winutil.c,v 1.16.2.1.2.3 2008/12/31 11:17:49 sebastian Exp $ */ +/* $Id: winutil.c,v 1.16.2.1.2.1.2.2 2008/12/31 11:15:49 sebastian Exp $ */ #include "php.h" -- cgit v1.2.3