summaryrefslogtreecommitdiff
path: root/win32/registry.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-03-25 01:32:47 +0000
committerZeev Suraski <zeev@php.net>2000-03-25 01:32:47 +0000
commit1239651126c005981a1e3cabcf389a678e1d8b66 (patch)
tree16bf904ead831663c32c2b9f5f095e0c307d1ced /win32/registry.c
parent5bdd53972fe77fc920635c9593f0d9ddb4cc1d5e (diff)
downloadphp-git-1239651126c005981a1e3cabcf389a678e1d8b66.tar.gz
@- 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)
Diffstat (limited to 'win32/registry.c')
-rw-r--r--win32/registry.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/win32/registry.c b/win32/registry.c
index 66ce5380d5..71f1922b5e 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -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 @@ void UpdateIniFromRegistry(char *path)
/* 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 @@ void UpdateIniFromRegistry(char *path)
}
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 @@ void UpdateIniFromRegistry(char *path)
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);
}