]> git.pld-linux.org Git - packages/php.git/blame - php-config-file-scan-dir.patch
- build litespeed API (disabled with bcond by now)
[packages/php.git] / php-config-file-scan-dir.patch
CommitLineData
bf52cc5d
AM
1--- php-src/main/php_ini.c 2009/05/18 21:28:42 1.173
2+++ php-src/main/php_ini.c 2009/06/27 15:22:06 1.174
3@@ -349,7 +349,8 @@
4 char *open_basedir;
5 int free_ini_search_path = 0;
6 zend_file_handle fh;
7-
8+ static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
9+
10 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) {
11 return FAILURE;
12 }
13@@ -372,7 +373,6 @@
14 char *default_location;
15 char *env_location;
16 char *binary_location;
17- static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
18 #ifdef PHP_WIN32
19 char *reg_location;
20 #endif
21@@ -608,72 +608,83 @@
22
23 /* Scan and parse any .ini files found in scan path if path not empty. */
24 if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
25- struct dirent **namelist;
26 int ndir, i;
27 struct stat sb;
28 char ini_file[MAXPATHLEN];
29- char *p;
30+ char *p, *last, *path_copy, *ini_path = NULL;
31 zend_file_handle fh;
32 zend_llist scanned_ini_list;
33 zend_llist_element *element;
34 int l, total_l = 0;
35
36- /* Reset active ini section */
37- RESET_ACTIVE_INI_HASH();
38-
39- if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
40- zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
41- memset(&fh, 0, sizeof(fh));
42-
43- for (i = 0; i < ndir; i++) {
44-
45- /* check for any file with .ini extension */
46- if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
47- free(namelist[i]);
48- continue;
49- }
50- if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) {
51- snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name);
52- } else {
53- snprintf(ini_file, MAXPATHLEN, "%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name);
54- }
55- if (VCWD_STAT(ini_file, &sb) == 0) {
56- if (S_ISREG(sb.st_mode)) {
57- if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
58- fh.filename = ini_file;
59- fh.type = ZEND_HANDLE_FP;
60-
61- if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) {
62- /* Here, add it to the list of ini files read */
63- l = strlen(ini_file);
64- total_l += l + 2;
65- p = estrndup(ini_file, l);
66- zend_llist_add_element(&scanned_ini_list, &p);
67+ /* List of found ini files */
68+ zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
69+
70+ /* Split by paths_separator and load ini-files from all paths */
71+ path_copy = estrdup(php_ini_scanned_path);
72+ ini_path = php_strtok_r(path_copy, paths_separator, &last);
73+
74+ while (ini_path != NULL) {
75+ struct dirent **namelist;
76+ int ini_path_len = strlen(ini_path);
77+
78+ if ((ndir = php_scandir(ini_path, &namelist, 0, php_alphasort)) > 0) {
79+ memset(&fh, 0, sizeof(fh));
80+
81+ for (i = 0; i < ndir; i++) {
82+ /* check for any file with .ini extension */
83+ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
84+ free(namelist[i]);
85+ continue;
86+ }
87+ if (IS_SLASH(ini_path[ini_path_len - 1])) {
88+ snprintf(ini_file, MAXPATHLEN, "%s%s", ini_path, namelist[i]->d_name);
89+ } else {
90+ snprintf(ini_file, MAXPATHLEN, "%s%c%s", ini_path, DEFAULT_SLASH, namelist[i]->d_name);
91+ }
92+ if (VCWD_STAT(ini_file, &sb) == 0) {
93+ if (S_ISREG(sb.st_mode)) {
94+ if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
95+ fh.filename = ini_file;
96+ fh.type = ZEND_HANDLE_FP;
97+
98+ /* Reset active ini section */
99+ RESET_ACTIVE_INI_HASH();
100+
101+ if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) {
102+ /* Here, add it to the list of ini files read */
103+ l = strlen(ini_file);
104+ total_l += l + 2;
105+ p = estrndup(ini_file, l);
106+ zend_llist_add_element(&scanned_ini_list, &p);
107+ }
108 }
109 }
110 }
111+ free(namelist[i]);
112 }
113- free(namelist[i]);
114+ free(namelist);
115 }
116- free(namelist);
117-
118- if (total_l) {
119- int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
120- php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
121- if (!php_ini_scanned_files_len) {
122- *php_ini_scanned_files = '\0';
123- }
124- total_l += php_ini_scanned_files_len;
125- for (element = scanned_ini_list.head; element; element = element->next) {
126- if (php_ini_scanned_files_len) {
127- strlcat(php_ini_scanned_files, ",\n", total_l);
128- }
129- strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
130- strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
131+ ini_path = php_strtok_r(NULL, paths_separator, &last);
132+ }
133+
134+ if (total_l) {
135+ int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
136+ php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
137+ if (!php_ini_scanned_files_len) {
138+ *php_ini_scanned_files = '\0';
139+ }
140+ total_l += php_ini_scanned_files_len;
141+ for (element = scanned_ini_list.head; element; element = element->next) {
142+ if (php_ini_scanned_files_len) {
143+ strlcat(php_ini_scanned_files, ",\n", total_l);
144 }
145+ strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
146+ strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
147 }
148- zend_llist_destroy(&scanned_ini_list);
149 }
150+ efree(path_copy);
151+ zend_llist_destroy(&scanned_ini_list);
152 } else {
153 /* Make sure an empty php_ini_scanned_path ends up as NULL */
154 php_ini_scanned_path = NULL;
This page took 0.055091 seconds and 4 git commands to generate.