]> granicus.if.org Git - php/commitdiff
@- Modified the registry INI entry reader (Win32) to work with drive letters. For
authorZeev Suraski <zeev@php.net>
Sat, 25 Mar 2000 01:32:47 +0000 (01:32 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 25 Mar 2000 01:32:47 +0000 (01:32 +0000)
@  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)

win32/registry.c

index 66ce5380d504f000128da985ddca2ec544f19764..71f1922b5eab6126af5ff30f32c7946cee1570fa 100644 (file)
@@ -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);
                }