mirror of
https://github.com/php/php-src.git
synced 2025-08-19 17:04:47 +02:00
- add EG(windows_version_info), set at init time once per instance
contains a OSVERSIONINFOEX struct. It lets us determine easily on which windows version is used (for example) - add the ability to disable a function when the windows function does not support a feature (for example symlink) - symlink, hardlink & co support (1/2)
This commit is contained in:
parent
fc6c8f5440
commit
2f61ad9b98
2 changed files with 72 additions and 4 deletions
51
main/main.c
51
main/main.c
|
@ -99,6 +99,33 @@ php_core_globals core_globals;
|
||||||
PHPAPI int core_globals_id;
|
PHPAPI int core_globals_id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
#include "win32_internal_function_disabled.h"
|
||||||
|
|
||||||
|
static php_win32_disable_functions() {
|
||||||
|
int i;
|
||||||
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
|
if (EG(windows_version_info).dwMajorVersion < 5) {
|
||||||
|
for (i = 0; i < function_name_cnt_5; i++) {
|
||||||
|
if (zend_hash_del(CG(function_table), function_name_5[i], strlen(function_name_5[i]) + 1)==FAILURE) {
|
||||||
|
php_printf("Unable to disable function '%s'\n", function_name_5[i]);
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EG(windows_version_info).dwMajorVersion < 6) {
|
||||||
|
for (i = 0; i < function_name_cnt_6; i++) {
|
||||||
|
if (zend_hash_del(CG(function_table), function_name_6[i], strlen(function_name_6[i]) + 1)==FAILURE) {
|
||||||
|
php_printf("Unable to disable function '%s'\n", function_name_6[i]);
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SAFE_FILENAME(f) ((f)?(f):"-")
|
#define SAFE_FILENAME(f) ((f)?(f):"-")
|
||||||
|
|
||||||
/* {{{ PHP_INI_MH
|
/* {{{ PHP_INI_MH
|
||||||
|
@ -1677,6 +1704,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
zend_executor_globals *executor_globals;
|
zend_executor_globals *executor_globals;
|
||||||
void ***tsrm_ls;
|
void ***tsrm_ls;
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
DWORD dwVersion = GetVersion();
|
||||||
|
#endif
|
||||||
|
|
||||||
php_core_globals *core_globals;
|
php_core_globals *core_globals;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1685,16 +1715,12 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
{
|
|
||||||
DWORD dwVersion = GetVersion();
|
|
||||||
|
|
||||||
/* Get build numbers for Windows NT or Win95 */
|
/* Get build numbers for Windows NT or Win95 */
|
||||||
if (dwVersion < 0x80000000){
|
if (dwVersion < 0x80000000){
|
||||||
php_os="WINNT";
|
php_os="WINNT";
|
||||||
} else {
|
} else {
|
||||||
php_os="WIN32";
|
php_os="WIN32";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
old_invalid_parameter_handler =
|
old_invalid_parameter_handler =
|
||||||
_set_invalid_parameter_handler(dummy_invalid_parameter_handler);
|
_set_invalid_parameter_handler(dummy_invalid_parameter_handler);
|
||||||
|
@ -1752,6 +1778,18 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
||||||
#endif
|
#endif
|
||||||
gc_globals_ctor(TSRMLS_C);
|
gc_globals_ctor(TSRMLS_C);
|
||||||
|
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEX *osvi = &EG(windows_version_info);
|
||||||
|
|
||||||
|
ZeroMemory(osvi, sizeof(OSVERSIONINFOEX));
|
||||||
|
osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||||
|
if( !GetVersionEx((OSVERSIONINFO *) osvi)) {
|
||||||
|
php_printf("\nGetVersionEx unusable. %d\n", GetLastError());
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
EG(bailout) = NULL;
|
EG(bailout) = NULL;
|
||||||
EG(error_reporting) = E_ALL & ~E_NOTICE;
|
EG(error_reporting) = E_ALL & ~E_NOTICE;
|
||||||
|
|
||||||
|
@ -1927,6 +1965,11 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
||||||
module->info_func = PHP_MINFO(php_core);
|
module->info_func = PHP_MINFO(php_core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
/* Disable incompatible functions for the running platform */
|
||||||
|
php_win32_disable_functions();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
zend_post_startup(TSRMLS_C);
|
zend_post_startup(TSRMLS_C);
|
||||||
#endif
|
#endif
|
||||||
|
|
25
main/win32_internal_function_disabled.h
Normal file
25
main/win32_internal_function_disabled.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
| 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: Pierre A. Joye <pierre@php.net> |
|
||||||
|
+----------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/* 5 means the min version is 5 (XP/2000), 6 (2k8/vista), etc. */
|
||||||
|
static const char *function_name_5[] = {"link", NULL};
|
||||||
|
const int function_name_cnt_5 = 1;
|
||||||
|
static const char *function_name_6[] = {"readlink", "symlink", NULL};
|
||||||
|
const int function_name_cnt_6 = 2;
|
Loading…
Add table
Add a link
Reference in a new issue