summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-04-18 15:54:18 +0000
committerZeev Suraski <zeev@php.net>1999-04-18 15:54:18 +0000
commitf432c05c3f2fdfc51b8799f908eb213717a15500 (patch)
treeaea0ef725359c326239967fc49c67a9309108e2e
parent342c6e0b2328db952709dd5a35c113e2b17c1e3d (diff)
downloadphp-git-f432c05c3f2fdfc51b8799f908eb213717a15500.tar.gz
Forgot to add these - Win32 registry support
-rw-r--r--win32/php_registry.h7
-rw-r--r--win32/registry.c74
2 files changed, 81 insertions, 0 deletions
diff --git a/win32/php_registry.h b/win32/php_registry.h
new file mode 100644
index 0000000000..ad722a5607
--- /dev/null
+++ b/win32/php_registry.h
@@ -0,0 +1,7 @@
+#ifndef _PHP_REGISTRY_H
+#define _PHP_REGISTRY_H
+
+
+void UpdateIniFromRegistry(char *path);
+
+#endif /* _PHP_REGISTRY_H */ \ No newline at end of file
diff --git a/win32/registry.c b/win32/registry.c
new file mode 100644
index 0000000000..ec43b30596
--- /dev/null
+++ b/win32/registry.c
@@ -0,0 +1,74 @@
+#include "php.h"
+#include "php_ini.h"
+#include "php_registry.h"
+
+void UpdateIniFromRegistry(char *path)
+{
+ char *p, *orig_path;
+ HKEY MainKey;
+
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\PHP\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) {
+ return;
+ }
+
+
+ orig_path = path = estrdup(path);
+
+ /* Get rid of C:, if exists */
+ p = strchr(path, ':');
+ if (p) {
+ path = p+1;
+ } else {
+ if (path[0] != '\\' && path[0] != '/') {
+ char tmp_buf[MAXPATHLEN], *cwd;
+
+ /* get current working directory and prepend it to the path */
+ if (!getcwd(tmp_buf, MAXPATHLEN)) {
+ efree(orig_path);
+ return;
+ }
+ cwd = strchr(tmp_buf, ':');
+ if (!cwd) {
+ cwd = tmp_buf;
+ } else {
+ cwd++;
+ }
+ path = (char *) emalloc(strlen(cwd)+1+strlen(orig_path)+1);
+ sprintf(path, "%s\\%s", cwd, orig_path);
+ efree(orig_path);
+ orig_path = path;
+ }
+ }
+
+
+ path++; /* step over the first / */
+ path = p = strtok(path, "\\/");
+
+ while (p) {
+ HKEY hKey;
+ char namebuf[256], valuebuf[256];
+ DWORD lType;
+ DWORD namebuf_length=256, valuebuf_length=256;
+ DWORD i=0;
+
+ if (p>path) {
+ *(p-1) = '\\';
+ }
+ if (RegOpenKeyEx(MainKey, path, 0, KEY_READ, &hKey)!=ERROR_SUCCESS) {
+ break;
+ }
+ while (RegEnumValue(hKey, i++, namebuf, &namebuf_length, NULL, &lType, valuebuf, &valuebuf_length)==ERROR_SUCCESS) {
+ if (lType != REG_SZ) {
+ continue;
+ }
+ printf("%s -> %s\n", namebuf, valuebuf);
+ php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR);
+ }
+
+ RegCloseKey(hKey);
+ p = strtok(NULL, "\\/");
+ }
+ RegCloseKey(MainKey);
+ efree(orig_path);
+}