cvs: /php4/win32 registry.c
| From: | Zeev Suraski | Date: | Sat, 25 Mar 2000 01:33:17 +0000 |
| Subject: | cvs: /php4/win32 registry.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12583@lists.php.net to get a copy of this message | ||
zeev Fri Mar 24 17:33:17 2000 EDT
Modified files:
/php4/win32 registry.c
Log:
@- Modified the registry INI entry reader (Win32) to work with drive letters. For
@ example, if you wish to wish to specify INI entries for C:\foo\bar, you should
@ create HKLM\PHP\Per Directory Values\C\foo\bar in the registry, and add
@ string values for each directive you want to override in this directory (Zeev)
Index: php4/win32/registry.c
diff -u php4/win32/registry.c:1.3 php4/win32/registry.c:1.4
--- php4/win32/registry.c:1.3 Sat Feb 26 07:36:23 2000
+++ php4/win32/registry.c Fri Mar 24 17:32:47 2000
@@ -2,6 +2,9 @@
#include "php_ini.h"
#include "php_registry.h"
+#define MAX_NAMEBUF_LEN 512
+#define MAX_VALUE_LEN 512
+
void UpdateIniFromRegistry(char *path)
{
char *p, *orig_path;
@@ -18,10 +21,12 @@
/* Get rid of C:, if exists */
p = strchr(path, ':');
if (p) {
- path = p+1;
+ *p = path[0]; /* replace the colon with the drive letter */
+ path = p; /* make path point to the drive letter */
} else {
if (path[0] != '\\' && path[0] != '/') {
char tmp_buf[MAXPATHLEN], *cwd;
+ char drive_letter;
/* get current working directory and prepend it to the path */
if (!getcwd(tmp_buf, MAXPATHLEN)) {
@@ -30,30 +35,31 @@
}
cwd = strchr(tmp_buf, ':');
if (!cwd) {
+ drive_letter = 'C';
cwd = tmp_buf;
} else {
+ drive_letter = tmp_buf[0];
cwd++;
}
- path = (char *) emalloc(strlen(cwd)+1+strlen(orig_path)+1);
- sprintf(path, "%s\\%s", cwd, orig_path);
+ path = (char *) emalloc(2+strlen(cwd)+1+strlen(orig_path)+1);
+ sprintf(path, "%c\\%s\\%s", drive_letter, cwd, orig_path);
efree(orig_path);
orig_path = path;
}
}
- path++; /* step over the first / */
path = p = strtok_r(path, "\\/", &strtok_buf);
while (p) {
HKEY hKey;
- char namebuf[256], valuebuf[256];
+ char namebuf[MAX_NAMEBUF_LEN], valuebuf[MAX_VALUE_LEN];
DWORD lType;
- DWORD namebuf_length=256, valuebuf_length=256;
+ DWORD namebuf_length=MAX_NAMEBUF_LEN, valuebuf_length=MAX_VALUE_LEN;
DWORD i=0;
if (p>path) {
- *(p-1) = '\\';
+ *(p-1) = '\\'; /* restore the slash */
}
if (RegOpenKeyEx(MainKey, path, 0, KEY_READ, &hKey)!=ERROR_SUCCESS) {
break;
@@ -62,7 +68,7 @@
if (lType != REG_SZ) {
continue;
}
- printf("%s -> %s\n", namebuf, valuebuf);
+ /*printf("%s -> %s\n", namebuf, valuebuf);*/
php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR,
PHP_INI_STAGE_ACTIVATE);
}