21#define PHP_REGISTRY_KEY "SOFTWARE\\PHP"
23#define PHP_VER1(V1) #V1
24#define PHP_VER2(V1,V2) #V1"."#V2
25#define PHP_VER3(V1,V2,V3) #V1"."#V2"."#V3
27#define PHP_REGISTRY_KEYV(VER) PHP_REGISTRY_KEY"\\"VER
28#define PHP_REGISTRY_KEY1(V1) PHP_REGISTRY_KEY"\\"PHP_VER1(V1)
29#define PHP_REGISTRY_KEY2(V1,V2) PHP_REGISTRY_KEY"\\"PHP_VER2(V1,V2)
30#define PHP_REGISTRY_KEY3(V1,V2,V3) PHP_REGISTRY_KEY"\\"PHP_VER3(V1,V2,V3)
32static const char* registry_keys[] = {
41static int OpenPhpRegistryKey(
char* sub_key, HKEY *hKey)
43 const char **key_name = registry_keys;
47 size_t sub_key_len =
strlen(sub_key);
53 main_key_len =
strlen(*key_name);
54 reg_key =
emalloc(main_key_len + sub_key_len + 1);
55 memcpy(reg_key, *key_name, main_key_len);
56 memcpy(reg_key + main_key_len, sub_key, sub_key_len + 1);
57 ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ, hKey);
60 if (
ret == ERROR_SUCCESS) {
67 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, *key_name, 0, KEY_READ, hKey) == ERROR_SUCCESS) {
76static int LoadDirectory(
HashTable *directories, HKEY
key,
char *path,
int path_len,
HashTable *parent_ht)
78 DWORD keys, values, max_key, max_name, max_value;
82 if (RegQueryInfoKey(
key,
NULL,
NULL,
NULL, &keys, &max_key,
NULL, &values, &max_name, &max_value,
NULL,
NULL) == ERROR_SUCCESS) {
90 for (i = 0; i < values; i++) {
91 name_len = max_name+1;
92 value_len = max_value+1;
98 if ((
type == REG_SZ) || (
type == REG_EXPAND_SZ)) {
123 zend_hash_str_update_mem(directories, path, path_len,
ht,
sizeof(
HashTable));
138 char *new_path = (
char*)
emalloc(path_len+max_key+2);
143 for (i = 0; i < keys; i++) {
144 name_len = max_key+1;
146 if (RegOpenKeyEx(
key,
name, 0, KEY_READ, &subkey) == ERROR_SUCCESS) {
148 memcpy(new_path, path, path_len);
149 new_path[path_len] =
'/';
150 memcpy(new_path+path_len+1,
name, name_len+1);
152 name_len += path_len+1;
157 if (LoadDirectory(directories, subkey, new_path, name_len,
ht)) {
171static void delete_internal_hashtable(
zval *
zv)
178#define RegNotifyFlags (REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET)
189 if (!
PW32G(registry_directories)) {
191 if (!
PW32G(registry_directories)) {
195 if (!OpenPhpRegistryKey(
"\\Per Directory Values", &
PW32G(registry_key))) {
200 if (
PW32G(registry_event)) {
203 if (!LoadDirectory(
PW32G(registry_directories),
PW32G(registry_key),
"", 0,
NULL)) {
206 }
else if (
PW32G(registry_event) && WaitForSingleObject(
PW32G(registry_event), 0) == WAIT_OBJECT_0) {
209 if (!LoadDirectory(
PW32G(registry_directories),
PW32G(registry_key),
"", 0,
NULL)) {
212 }
else if (zend_hash_num_elements(
PW32G(registry_directories)) == 0) {
216 orig_path = path =
estrdup(path);
224 if (path[0] !=
'\\' && path[0] !=
'/') {
238 drive_letter = tmp_buf[0];
241 while (*
cwd ==
'\\' || *
cwd ==
'/') {
244 spprintf(&path, 0,
"%c\\%s\\%s", drive_letter,
cwd, orig_path);
251 while (path[path_len] != 0) {
252 if (path[path_len] ==
'\\') {
253 path[path_len] =
'/';
259 while (path_len > 0) {
273 }
while (path_len > 0 && path[path_len] !=
'/');
280#define PHPRC_REGISTRY_NAME "IniFilePath"
284 char *reg_location =
NULL;
287 if (OpenPhpRegistryKey(
NULL, &hKey)) {
strchr(string $haystack, string $needle, bool $before_needle=false)
memset(ptr, 0, type->size)
#define PHP_INI_STAGE_ACTIVATE
unsigned char key[REFLECTION_KEY_LEN]
#define PHP_MINOR_VERSION
#define PHP_RELEASE_VERSION
#define PHP_MAJOR_VERSION
#define PHPRC_REGISTRY_NAME
#define PHP_REGISTRY_KEYV(VER)
char * GetIniPathFromRegistry()
#define PHP_REGISTRY_KEY2(V1, V2)
#define PHP_REGISTRY_KEY3(V1, V2, V3)
void UpdateIniFromRegistry(char *path)
#define PHP_REGISTRY_KEY1(V1)
#define ZVAL_PSTRINGL(z, s, l)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_MAP_FOREACH_KEY_VAL(ht, _h, _key, _val)
#define ZEND_HASH_FOREACH_END()
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage)
struct _zend_string zend_string
ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length)
struct _zend_array HashTable
#define ZVAL_INTERNAL_PTR_DTOR
#define VCWD_GETCWD(buff, size)