stas Tue Mar 16 13:27:58 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src/win32 php_registry.h registry.c
Log:
MFH registry fixes:
fix off-by-one in registry per-dir values
add IniFilePath value for setting php.ini path via registry
http://cvs.php.net/diff.php/php-src/win32/php_registry.h?r1=1.3&r2=1.3.10.1&ty=u
Index: php-src/win32/php_registry.h
diff -u php-src/win32/php_registry.h:1.3 php-src/win32/php_registry.h:1.3.10.1
--- php-src/win32/php_registry.h:1.3 Sat Aug 4 21:42:48 2001
+++ php-src/win32/php_registry.h Tue Mar 16 13:27:55 2004
@@ -3,5 +3,6 @@
void UpdateIniFromRegistry(char *path TSRMLS_DC);
+char *GetIniPathFromRegistry();
#endif /* PHP_REGISTRY_H */
http://cvs.php.net/diff.php/php-src/win32/registry.c?r1=1.12&r2=1.12.2.1&ty=u
Index: php-src/win32/registry.c
diff -u php-src/win32/registry.c:1.12 php-src/win32/registry.c:1.12.2.1
--- php-src/win32/registry.c:1.12 Mon Oct 14 08:05:09 2002
+++ php-src/win32/registry.c Tue Mar 16 13:27:55 2004
@@ -1,13 +1,15 @@
#include "php.h"
#include "php_ini.h"
+#define PHP_REGISTRY_KEY "SOFTWARE\\PHP"
+
void UpdateIniFromRegistry(char *path TSRMLS_DC)
{
char *p, *orig_path;
HKEY MainKey;
char *strtok_buf = NULL;
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\PHP\\Per Directory Values", 0,
KEY_READ, &MainKey)!=ERROR_SUCCESS) {
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY "\\Per Directory
Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) {
return;
}
@@ -70,7 +72,8 @@
RegEnumValue(hKey, i, namebuf, &namebuf_len, NULL,
&lType, valuebuf, &valuebuf_len);
if ((lType == REG_SZ) || (lType == REG_EXPAND_SZ)) {
- zend_alter_ini_entry(namebuf, namebuf_len + 1,
valuebuf, valuebuf_len, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
+ /* valuebuf_len includes terminating 0 */
+ zend_alter_ini_entry(namebuf, namebuf_len + 1,
valuebuf, valuebuf_len?valuebuf_len-1:0, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
}
i++;
@@ -86,3 +89,23 @@
RegCloseKey(MainKey);
efree(orig_path);
}
+
+#define PHPRC_REGISTRY_NAME "IniFilePath"
+
+char *GetIniPathFromRegistry()
+{
+ char *reg_location = NULL;
+ HKEY hKey;
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY, 0, KEY_READ, &hKey) ==
ERROR_SUCCESS) {
+ DWORD buflen = MAXPATHLEN;
+ reg_location = emalloc(MAXPATHLEN+1);
+ if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location,
&buflen) != ERROR_SUCCESS) {
+ efree(reg_location);
+ reg_location = NULL;
+ return reg_location;
+ }
+ RegCloseKey(hKey);
+ }
+ return reg_location;
+}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php