Back to index

php5  5.3.10
Functions
php_registry.h File Reference

Go to the source code of this file.

Functions

void UpdateIniFromRegistry (char *path TSRMLS_DC)
char * GetIniPathFromRegistry ()

Function Documentation

Definition at line 271 of file registry.c.

{
       char *reg_location = NULL;
       HKEY hKey;
       
       if (OpenPhpRegistryKey(NULL, &hKey)) {
              DWORD buflen = MAXPATHLEN;
              reg_location = emalloc(MAXPATHLEN+1);
              if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location, &buflen) != ERROR_SUCCESS) {
                     efree(reg_location);
                     reg_location = NULL;
                     return reg_location;
              }
              RegCloseKey(hKey);
       }
       return reg_location;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void UpdateIniFromRegistry ( char *path  TSRMLS_DC)

Definition at line 165 of file registry.c.

{
       char *p, *orig_path;
       int path_len;
       HashTable **pht;

       if(!path) {
              return;
       }

       if (!PW32G(registry_directories)) {
              PW32G(registry_directories) = (HashTable*)malloc(sizeof(HashTable));
              zend_hash_init(PW32G(registry_directories), 0, NULL, delete_internal_hashtable, 1);
              if (!OpenPhpRegistryKey("\\Per Directory Values", &PW32G(registry_key))) {
                     PW32G(registry_key) = NULL;
                     return;
              }
              PW32G(registry_event) = CreateEvent(NULL, TRUE, FALSE, NULL);
              if (PW32G(registry_event)) {
                     RegNotifyChangeKeyValue(PW32G(registry_key), TRUE, RegNotifyFlags, PW32G(registry_event), TRUE);
              }
              if (!LoadDirectory(PW32G(registry_directories), PW32G(registry_key), "", 0, NULL)) {
                     return;
              }
       } else if (PW32G(registry_event) && WaitForSingleObject(PW32G(registry_event), 0) == WAIT_OBJECT_0) {
              RegNotifyChangeKeyValue(PW32G(registry_key), TRUE, RegNotifyFlags, PW32G(registry_event), TRUE);
              zend_hash_clean(PW32G(registry_directories));
              if (!LoadDirectory(PW32G(registry_directories), PW32G(registry_key), "", 0, NULL)) {
                     return;
              }
       } else if (zend_hash_num_elements(PW32G(registry_directories)) == 0) {
              return;
       }

       orig_path = path = estrdup(path);

       /* Get rid of C:, if exists */
       p = strchr(path, ':');
       if (p) {
              *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 (!VCWD_GETCWD(tmp_buf, MAXPATHLEN)) {
                            efree(orig_path);
                            return;
                     }
                     cwd = strchr(tmp_buf, ':');
                     if (!cwd) {
                            drive_letter = 'C';
                            cwd = tmp_buf;
                     } else {
                            drive_letter = tmp_buf[0];
                            cwd++;
                     }
                     while (*cwd == '\\' || *cwd == '/') {
                            cwd++;
                     }
                     spprintf(&path, 0, "%c\\%s\\%s", drive_letter, cwd, orig_path);
                     efree(orig_path);
                     orig_path = path;
              }
       }

       path_len = 0;
       while (path[path_len] != 0) {
              if (path[path_len] == '\\') {
                     path[path_len] = '/';
              }
              path_len++;
       }
       zend_str_tolower(path, path_len);
       while (path_len >= 0) {
              if (zend_hash_find(PW32G(registry_directories), path, path_len+1, (void**)&pht) == SUCCESS) {
                     HashTable *ht = *pht;
                     HashPosition pos;
                     char *index;
                     uint index_len;
                     ulong num;
                     zval **data;

                     for (zend_hash_internal_pointer_reset_ex(ht, &pos);
                          zend_hash_get_current_data_ex(ht, (void**)&data, &pos) == SUCCESS &&
                          zend_hash_get_current_key_ex(ht, &index, &index_len, &num, 0, &pos) == HASH_KEY_IS_STRING;
                          zend_hash_move_forward_ex(ht, &pos)) {
                            zend_alter_ini_entry(index, index_len, Z_STRVAL_PP(data), Z_STRLEN_PP(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
                     }
                     break;
              }
              if (--path_len > 0) {
                     while (path_len > 0 && path[path_len] != '/') {
                            path_len--;
                     }
              }
              path[path_len] = 0;
       }

       efree(orig_path);
}

Here is the call graph for this function:

Here is the caller graph for this function: