Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 671 lines (594 sloc) 18.761 kB
651e232 @zsuraski Testing 123
zsuraski authored
1 /*
2 +----------------------------------------------------------------------+
dbeb415 @andigutmans - A belated happy holidays and PHP 5
andigutmans authored
3 | PHP Version 5 |
651e232 @zsuraski Testing 123
zsuraski authored
4 +----------------------------------------------------------------------+
4223aa4 MFH: Bump year.
Sebastian Bergmann authored
5 | Copyright (c) 1997-2007 The PHP Group |
651e232 @zsuraski Testing 123
zsuraski authored
6 +----------------------------------------------------------------------+
5bd9322 bump year and license version
foobar authored
7 | This source file is subject to version 3.01 of the PHP license, |
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff updating license information in the headers.
James Cox authored
9 | available through the world-wide-web at the following url: |
5bd9322 bump year and license version
foobar authored
10 | http://www.php.net/license/3_01.txt |
c5724cb @zsuraski License update
zsuraski authored
11 | If you did not receive a copy of the PHP license and are unable to |
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
651e232 @zsuraski Testing 123
zsuraski authored
14 +----------------------------------------------------------------------+
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
15 | Author: Zeev Suraski <zeev@zend.com> |
651e232 @zsuraski Testing 123
zsuraski authored
16 +----------------------------------------------------------------------+
17 */
18
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
19 /* $Id$ */
651e232 @zsuraski Testing 123
zsuraski authored
20
aceaabc @zsuraski PHP 4.0
zsuraski authored
21 #include "php.h"
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
22 #include "ext/standard/info.h"
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
23 #include "zend_ini.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
24 #include "php_ini.h"
25 #include "ext/standard/dl.h"
26 #include "zend_extensions.h"
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
27 #include "zend_highlight.h"
ab25640 Removed CWD from php_ini_search_path when using CLI SAPI.
Edin Kadribasic authored
28 #include "SAPI.h"
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
29 #include "php_main.h"
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
30 #include "php_scandir.h"
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
31 #ifdef PHP_WIN32
32 #include "win32/php_registry.h"
33 #endif
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
34
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
35 #if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
36 #include <dirent.h>
82f6cef Fix broken build by adding scandir and alphasort for win32
Shane Caraveo authored
37 #endif
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
38
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
39 #ifndef S_ISREG
40 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
41 #endif
42
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
43 typedef struct _php_extension_lists {
42c82bb Revert the last patches.
foobar authored
44 zend_llist engine;
45 zend_llist functions;
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
46 } php_extension_lists;
58e24ac @zsuraski - Add PHP Modules workspace
zsuraski authored
47
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
48
49 /* True globals */
50 static HashTable configuration_hash;
51 PHPAPI char *php_ini_opened_path=NULL;
52 static php_extension_lists extension_lists;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
53 PHPAPI char *php_ini_scanned_files=NULL;
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
54
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
55 /* {{{ php_ini_displayer_cb
56 */
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
57 static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
58 {
42c82bb Revert the last patches.
foobar authored
59 if (ini_entry->displayer) {
60 ini_entry->displayer(ini_entry, type);
61 } else {
62 char *display_string;
63 uint display_string_length, esc_html=0;
64 TSRMLS_FETCH();
65
7e3b508 ws/style fixes
foobar authored
66 if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
42c82bb Revert the last patches.
foobar authored
67 if (ini_entry->orig_value && ini_entry->orig_value[0]) {
68 display_string = ini_entry->orig_value;
69 display_string_length = ini_entry->orig_value_length;
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
70 esc_html = !sapi_module.phpinfo_as_text;
42c82bb Revert the last patches.
foobar authored
71 } else {
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
72 if (!sapi_module.phpinfo_as_text) {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
73 display_string = "<i>no value</i>";
7e3b508 ws/style fixes
foobar authored
74 display_string_length = sizeof("<i>no value</i>") - 1;
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
75 } else {
76 display_string = "no value";
7e3b508 ws/style fixes
foobar authored
77 display_string_length = sizeof("no value") - 1;
9be89ed MFH: ws fixes
Jani Taskinen authored
78 }
42c82bb Revert the last patches.
foobar authored
79 }
80 } else if (ini_entry->value && ini_entry->value[0]) {
81 display_string = ini_entry->value;
82 display_string_length = ini_entry->value_length;
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
83 esc_html = !sapi_module.phpinfo_as_text;
42c82bb Revert the last patches.
foobar authored
84 } else {
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
85 if (!sapi_module.phpinfo_as_text) {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
86 display_string = "<i>no value</i>";
7e3b508 ws/style fixes
foobar authored
87 display_string_length = sizeof("<i>no value</i>") - 1;
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
88 } else {
89 display_string = "no value";
7e3b508 ws/style fixes
foobar authored
90 display_string_length = sizeof("no value") - 1;
9be89ed MFH: ws fixes
Jani Taskinen authored
91 }
42c82bb Revert the last patches.
foobar authored
92 }
7e3b508 ws/style fixes
foobar authored
93
94 if (esc_html) {
a769454 reenable php_html_puts
Sascha Schumann authored
95 php_html_puts(display_string, display_string_length TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
96 } else {
97 PHPWRITE(display_string, display_string_length);
98 }
99 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
100 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
101 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
102
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
103 /* {{{ php_ini_displayer
104 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
105 static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS_DC)
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
106 {
42c82bb Revert the last patches.
foobar authored
107 if (ini_entry->module_number != module_number) {
108 return 0;
109 }
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
110 if (!sapi_module.phpinfo_as_text) {
14a6cc8 Change phpinfo() to use CSS styling instead of HTML code.
Colin Viebrock authored
111 PUTS("<tr>");
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
112 PUTS("<td class=\"e\">");
7e3b508 ws/style fixes
foobar authored
113 PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
114 PUTS("</td><td class=\"v\">");
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
115 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
116 PUTS("</td><td class=\"v\">");
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
117 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
118 PUTS("</td></tr>\n");
119 } else {
7e3b508 ws/style fixes
foobar authored
120 PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
121 PUTS(" => ");
122 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
123 PUTS(" => ");
124 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
125 PUTS("\n");
9be89ed MFH: ws fixes
Jani Taskinen authored
126 }
42c82bb Revert the last patches.
foobar authored
127 return 0;
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
128 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
129 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
130
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
131 /* {{{ display_ini_entries
132 */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
133 PHPAPI void display_ini_entries(zend_module_entry *module)
134 {
42c82bb Revert the last patches.
foobar authored
135 int module_number;
136 TSRMLS_FETCH();
137
138 if (module) {
139 module_number = module->module_number;
9be89ed MFH: ws fixes
Jani Taskinen authored
140 } else {
42c82bb Revert the last patches.
foobar authored
141 module_number = 0;
142 }
143 php_info_print_table_start();
144 php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
e1814f0 WIN64 support
Dmitry Stogov authored
145 zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (zend_intptr_t) module_number TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
146 php_info_print_table_end();
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
147 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
148 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
149
150 /* php.ini support */
151
152 #ifdef ZTS
153 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
154 # define ZEND_EXTENSION_TOKEN "zend_extension_debug_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
155 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
156 # define ZEND_EXTENSION_TOKEN "zend_extension_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
157 # endif
158 #else
159 # if (ZEND_DEBUG)
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
160 # define ZEND_EXTENSION_TOKEN "zend_extension_debug"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
161 # else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
162 # define ZEND_EXTENSION_TOKEN "zend_extension"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
163 # endif
164 #endif
165
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
166 /* {{{ php_config_ini_parser_cb
167 */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
168 static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
169 {
42c82bb Revert the last patches.
foobar authored
170 switch (callback_type) {
171 case ZEND_INI_PARSER_ENTRY: {
172 zval *entry;
173
174 if (!arg2) {
175 break;
176 }
177 if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
178 zval copy;
9be89ed MFH: ws fixes
Jani Taskinen authored
179
42c82bb Revert the last patches.
foobar authored
180 copy = *arg2;
181 zval_copy_ctor(&copy);
182 copy.refcount = 0;
9be89ed MFH: ws fixes
Jani Taskinen authored
183 zend_llist_add_element(&extension_lists.functions, &copy);
42c82bb Revert the last patches.
foobar authored
184 } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
185 char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
9be89ed MFH: ws fixes
Jani Taskinen authored
186
42c82bb Revert the last patches.
foobar authored
187 zend_llist_add_element(&extension_lists.engine, &extension_name);
188 } else {
7e3b508 ws/style fixes
foobar authored
189 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, arg2, sizeof(zval), (void **) &entry);
42c82bb Revert the last patches.
foobar authored
190 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
191 }
192 }
193 break;
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
194
195 case ZEND_INI_PARSER_POP_ENTRY: {
196 zval *hash;
197 zval **find_hash;
198 zval *element;
199
200 if (!arg2) {
201 /* bare string - nothing to do */
202 break;
203 }
204
7e3b508 ws/style fixes
foobar authored
205 if (zend_hash_find(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void **) &find_hash) == FAILURE) {
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
206 ALLOC_ZVAL(hash);
207 array_init(hash);
208
7e3b508 ws/style fixes
foobar authored
209 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, &hash, sizeof(zval *), NULL);
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
210 } else {
211 hash = *find_hash;
212 }
213
214 ALLOC_ZVAL(element);
215 *element = *arg2;
216 zval_copy_ctor(element);
217 INIT_PZVAL(element);
9be89ed MFH: ws fixes
Jani Taskinen authored
218 add_next_index_zval(hash, element);
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
219 }
220 break;
221
42c82bb Revert the last patches.
foobar authored
222 case ZEND_INI_PARSER_SECTION:
223 break;
224 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
225 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
226 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
227
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
228 /* {{{ php_load_function_extension_cb
229 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
230 static void php_load_function_extension_cb(void *arg TSRMLS_DC)
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
231 {
42c82bb Revert the last patches.
foobar authored
232 zval *extension = (zval *) arg;
233 zval zval;
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
234
000a9e3 - Fixed problem with -dextension=foobar.so not having it's MINIT run.
foobar authored
235 php_dl(extension, MODULE_PERSISTENT, &zval, 0 TSRMLS_CC);
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
236 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
237 /* }}} */
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
238
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
239 /* {{{ php_load_zend_extension_cb
240 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
241 static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
242 {
42c82bb Revert the last patches.
foobar authored
243 zend_load_extension(*((char **) arg));
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
244 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
245 /* }}} */
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
246
64cfbf5 MFH: - Fixed bug #34307 (OnUpdateStringUnempty INI options can be set…
foobar authored
247 /* {{{ pvalue_config_destructor
248 */
249 static void pvalue_config_destructor(zval *pvalue)
9be89ed MFH: ws fixes
Jani Taskinen authored
250 {
64cfbf5 MFH: - Fixed bug #34307 (OnUpdateStringUnempty INI options can be set…
foobar authored
251 if (Z_TYPE_P(pvalue) == IS_STRING) {
252 free(Z_STRVAL_P(pvalue));
253 }
254 }
255 /* }}} */
256
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
257 /* {{{ php_init_config
258 */
64cfbf5 MFH: - Fixed bug #34307 (OnUpdateStringUnempty INI options can be set…
foobar authored
259 int php_init_config(TSRMLS_D)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
260 {
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
261 char *php_ini_file_name = NULL;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
262 char *php_ini_search_path = NULL;
42c82bb Revert the last patches.
foobar authored
263 int safe_mode_state;
264 char *open_basedir;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
265 int free_ini_search_path = 0;
42c82bb Revert the last patches.
foobar authored
266 zend_file_handle fh;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
267 struct stat sb;
268 char ini_file[MAXPATHLEN];
269 char *p;
270 zend_llist scanned_ini_list;
271 int l, total_l=0;
272 zend_llist_element *element;
42c82bb Revert the last patches.
foobar authored
273
1890173 Revert
foobar authored
274 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1) == FAILURE) {
275 return FAILURE;
276 }
277
63739c7 give sapi modules the possibility to overwrite default ini settings
Marcus Boerger authored
278 if (sapi_module.ini_defaults) {
279 sapi_module.ini_defaults(&configuration_hash);
280 }
281
42c82bb Revert the last patches.
foobar authored
282 zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
9be89ed MFH: ws fixes
Jani Taskinen authored
283 zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
284 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
9be89ed MFH: ws fixes
Jani Taskinen authored
285
42c82bb Revert the last patches.
foobar authored
286 safe_mode_state = PG(safe_mode);
287 open_basedir = PG(open_basedir);
288
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
289 if (sapi_module.php_ini_path_override) {
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
290 php_ini_file_name = sapi_module.php_ini_path_override;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
291 php_ini_search_path = sapi_module.php_ini_path_override;
292 free_ini_search_path = 0;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
293 } else if (!sapi_module.php_ini_ignore) {
112462d @tony2001 MFH
tony2001 authored
294 int search_path_size;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
295 char *default_location;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
296 char *env_location;
297 char *binary_location;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
298 static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
2479384 Fixed unused variable warning on *nix.
Ilia Alshanetsky authored
299 #ifdef PHP_WIN32
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
300 char *reg_location;
2479384 Fixed unused variable warning on *nix.
Ilia Alshanetsky authored
301 #endif
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
302
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
303 env_location = getenv("PHPRC");
304 if (!env_location) {
305 env_location = "";
306 }
307
308 /*
309 * Prepare search path
310 */
311
112462d @tony2001 MFH
tony2001 authored
312 search_path_size = MAXPATHLEN * 4 + strlen(env_location) + 3 + 1;
313 php_ini_search_path = (char *) emalloc(search_path_size);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
314 free_ini_search_path = 1;
315 php_ini_search_path[0] = 0;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
316
acb1e07 Changed priority of PHPRC environment variable on win32 to be higher …
Dmitry Stogov authored
317 /* Add environment location */
318 if (env_location[0]) {
319 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
320 strlcat(php_ini_search_path, paths_separator, search_path_size);
acb1e07 Changed priority of PHPRC environment variable on win32 to be higher …
Dmitry Stogov authored
321 }
112462d @tony2001 MFH
tony2001 authored
322 strlcat(php_ini_search_path, env_location, search_path_size);
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
323 php_ini_file_name = env_location;
acb1e07 Changed priority of PHPRC environment variable on win32 to be higher …
Dmitry Stogov authored
324 }
325
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
326 #ifdef PHP_WIN32
327 /* Add registry location */
328 reg_location = GetIniPathFromRegistry();
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
329 if (reg_location != NULL) {
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
330 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
331 strlcat(php_ini_search_path, paths_separator, search_path_size);
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
332 }
112462d @tony2001 MFH
tony2001 authored
333 strlcat(php_ini_search_path, reg_location, search_path_size);
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
334 efree(reg_location);
335 }
336 #endif
42c82bb Revert the last patches.
foobar authored
337
ef058cd Search for php.ini in CWD in all sapi's *but* CLI.
Edin Kadribasic authored
338 /* Add cwd (not with CLI) */
339 if (strcmp(sapi_module.name, "cli") != 0) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
340 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
341 strlcat(php_ini_search_path, paths_separator, search_path_size);
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
342 }
112462d @tony2001 MFH
tony2001 authored
343 strlcat(php_ini_search_path, ".", search_path_size);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
344 }
42c82bb Revert the last patches.
foobar authored
345
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
346 /* Add binary directory */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
347 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
348 binary_location = (char *) emalloc(MAXPATHLEN);
7e3b508 ws/style fixes
foobar authored
349 if (GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
350 efree(binary_location);
351 binary_location = NULL;
42c82bb Revert the last patches.
foobar authored
352 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
353 #else
354 if (sapi_module.executable_location) {
0db4f06 @tony2001 MFH
tony2001 authored
355 binary_location = (char *)emalloc(MAXPATHLEN);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
356 if (!strchr(sapi_module.executable_location, '/')) {
9098946 @bjori MFH: bug#41361 (shell_exec() does not find binaries)
bjori authored
357 char *envpath, *path;
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
358 int found = 0;
359
9098946 @bjori MFH: bug#41361 (shell_exec() does not find binaries)
bjori authored
360 if ((envpath = getenv("PATH")) != NULL) {
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
361 char *search_dir, search_path[MAXPATHLEN];
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
362 char *last;
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
363
d85fc29 @tony2001 MFH
tony2001 authored
364 path = estrdup(envpath);
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
365 search_dir = php_strtok_r(path, ":", &last);
d85fc29 @tony2001 MFH
tony2001 authored
366
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
367 while (search_dir) {
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
368 snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
369 if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
370 found = 1;
371 break;
372 }
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
373 search_dir = php_strtok_r(NULL, ":", &last);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
374 }
d85fc29 @tony2001 MFH
tony2001 authored
375 efree(path);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
376 }
377 if (!found) {
378 efree(binary_location);
379 binary_location = NULL;
380 }
381 } else if (!VCWD_REALPATH(sapi_module.executable_location, binary_location) || VCWD_ACCESS(binary_location, X_OK)) {
7e071d9 php.ini search logic needs to use the absolute path of the running bi…
Hartmut Holzgraefe authored
382 efree(binary_location);
9be89ed MFH: ws fixes
Jani Taskinen authored
383 binary_location = NULL;
98694f9 @tony2001 ws fix
tony2001 authored
384 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
385 } else {
386 binary_location = NULL;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
387 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
388 #endif
389 if (binary_location) {
390 char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
9be89ed MFH: ws fixes
Jani Taskinen authored
391
882cb20 edge case: do not remove trailing slash for root directory (Bug #33882)
Hartmut Holzgraefe authored
392 if (separator_location && separator_location != binary_location) {
7e071d9 php.ini search logic needs to use the absolute path of the running bi…
Hartmut Holzgraefe authored
393 *(separator_location) = 0;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
394 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
395 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
396 strlcat(php_ini_search_path, paths_separator, search_path_size);
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
397 }
112462d @tony2001 MFH
tony2001 authored
398 strlcat(php_ini_search_path, binary_location, search_path_size);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
399 efree(binary_location);
400 }
401
402 /* Add default location */
403 #ifdef PHP_WIN32
7e3b508 ws/style fixes
foobar authored
404 default_location = (char *) emalloc(MAXPATHLEN + 1);
9be89ed MFH: ws fixes
Jani Taskinen authored
405
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
406 if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
407 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
408 strlcat(php_ini_search_path, paths_separator, search_path_size);
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
409 }
112462d @tony2001 MFH
tony2001 authored
410 strlcat(php_ini_search_path, default_location, search_path_size);
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
411 }
412 efree(default_location);
fcdda2e @wez Fix a problem resolving the php.ini path under win32 terminal service…
wez authored
413
414 {
415 /* For people running under terminal services, GetWindowsDirectory will
416 * return their personal Windows directory, so lets add the system
417 * windows directory too */
418 typedef UINT (WINAPI *get_system_windows_directory_func)(char *buffer, UINT size);
419 static get_system_windows_directory_func get_system_windows_directory = NULL;
420 HMODULE kern;
421
422 if (get_system_windows_directory == NULL) {
423 kern = LoadLibrary("kernel32.dll");
424 if (kern) {
425 get_system_windows_directory = (get_system_windows_directory_func)GetProcAddress(kern, "GetSystemWindowsDirectoryA");
426 }
427 }
428 if (get_system_windows_directory != NULL) {
429 default_location = (char *) emalloc(MAXPATHLEN + 1);
430 if (0 < get_system_windows_directory(default_location, MAXPATHLEN)) {
431 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
432 strlcat(php_ini_search_path, paths_separator, search_path_size);
fcdda2e @wez Fix a problem resolving the php.ini path under win32 terminal service…
wez authored
433 }
112462d @tony2001 MFH
tony2001 authored
434 strlcat(php_ini_search_path, default_location, search_path_size);
fcdda2e @wez Fix a problem resolving the php.ini path under win32 terminal service…
wez authored
435 }
436 efree(default_location);
437 }
438 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
439 #else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
440 default_location = PHP_CONFIG_FILE_PATH;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
441 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
442 strlcat(php_ini_search_path, paths_separator, search_path_size);
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
443 }
112462d @tony2001 MFH
tony2001 authored
444 strlcat(php_ini_search_path, default_location, search_path_size);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
445 #endif
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
446 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
447
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
448 PG(safe_mode) = 0;
449 PG(open_basedir) = NULL;
450
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored
451 memset(&fh, 0, sizeof(fh));
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
452 /* Check if php_ini_path_override is a file */
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
453 if (!sapi_module.php_ini_ignore) {
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
454 if (php_ini_file_name && php_ini_file_name[0]) {
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
455 struct stat statbuf;
9be89ed MFH: ws fixes
Jani Taskinen authored
456
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
457 if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
458 if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
459 fh.handle.fp = VCWD_FOPEN(php_ini_file_name, "r");
460 if (fh.handle.fp) {
461 fh.filename = php_ini_opened_path = expand_filepath(php_ini_file_name, NULL TSRMLS_CC);
462 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
463 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
464 }
465 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
466 /* Search php-%sapi-module-name%.ini file in search path */
467 if (!fh.handle.fp) {
468 const char *fmt = "php-%s.ini";
50ea267 - Avoid sprintf, even when checked copy'n'paste or changes lead to er…
Marcus Boerger authored
469 char *ini_fname;
470 spprintf(&ini_fname, 0, fmt, sapi_module.name);
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
471 fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
472 efree(ini_fname);
473 if (fh.handle.fp) {
474 fh.filename = php_ini_opened_path;
475 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
476 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
477 /* Search php.ini file in search path */
478 if (!fh.handle.fp) {
479 fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
480 if (fh.handle.fp) {
481 fh.filename = php_ini_opened_path;
482 }
8f94a8a First try to open php-SAPI.ini and if it fails fall back to regular
Edin Kadribasic authored
483 }
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
484 }
7e3b508 ws/style fixes
foobar authored
485
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
486 if (free_ini_search_path) {
487 efree(php_ini_search_path);
488 }
7e3b508 ws/style fixes
foobar authored
489
42c82bb Revert the last patches.
foobar authored
490 PG(safe_mode) = safe_mode_state;
491 PG(open_basedir) = open_basedir;
492
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
493 if (fh.handle.fp) {
494 fh.type = ZEND_HANDLE_FP;
42c82bb Revert the last patches.
foobar authored
495
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
496 zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
9be89ed MFH: ws fixes
Jani Taskinen authored
497
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
498 {
499 zval tmp;
9be89ed MFH: ws fixes
Jani Taskinen authored
500
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
501 Z_STRLEN(tmp) = strlen(fh.filename);
502 Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
503 Z_TYPE(tmp) = IS_STRING;
504 zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
7e3b508 ws/style fixes
foobar authored
505 if (php_ini_opened_path) {
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
506 efree(php_ini_opened_path);
7e3b508 ws/style fixes
foobar authored
507 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
508 php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
509 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
510 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
511
512 /* If the config_file_scan_dir is set at compile-time, go and scan this directory and
513 * parse any .ini files found in this directory. */
173b949 Fixed bug: #22011 (-n must ignore all ini files)
foobar authored
514 if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
515 struct dirent **namelist;
516 int ndir, i;
517
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
518 if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) {
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
519 for (i = 0; i < ndir; i++) {
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
520 /* check for a .ini extension */
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
521 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
522 free(namelist[i]);
d454bec - Whitespace
Derick Rethans authored
523 continue;
524 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
525 snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
526 if (VCWD_STAT(ini_file, &sb) == 0) {
527 if (S_ISREG(sb.st_mode)) {
528 if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
529 fh.filename = ini_file;
1ad304c @rlerdorf MFB config-file-scan-dir crash fix
rlerdorf authored
530 fh.type = ZEND_HANDLE_FP;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
531 zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
532 /* Here, add it to the list of ini files read */
533 l = strlen(ini_file);
7e3b508 ws/style fixes
foobar authored
534 total_l += l + 2;
9be89ed MFH: ws fixes
Jani Taskinen authored
535 p = estrndup(ini_file, l);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
536 zend_llist_add_element(&scanned_ini_list, &p);
537 }
538 }
539 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
540 free(namelist[i]);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
541 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
542 free(namelist);
543
9be89ed MFH: ws fixes
Jani Taskinen authored
544 /*
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
545 * Don't need an extra byte for the \0 in this malloc as the last
546 * element will not get a trailing , which gives us the byte for the \0
547 */
3781af5 - Fixed zero bytes memory allocation when no extra ini files are foun…
Derick Rethans authored
548 if (total_l) {
549 php_ini_scanned_files = (char *) malloc(total_l);
550 *php_ini_scanned_files = '\0';
551 for (element = scanned_ini_list.head; element; element = element->next) {
112462d @tony2001 MFH
tony2001 authored
552 strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
553 strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
9be89ed MFH: ws fixes
Jani Taskinen authored
554 }
3781af5 - Fixed zero bytes memory allocation when no extra ini files are foun…
Derick Rethans authored
555 }
ac9f4cc - We always need to destroy the llist though.
Derick Rethans authored
556 zend_llist_destroy(&scanned_ini_list);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
557 }
42c82bb Revert the last patches.
foobar authored
558 }
7d14dad MFH: Fixed mess with CGI/CLI -d command line option (now it works wit…
Dmitry Stogov authored
559
560 if (sapi_module.ini_entries) {
561 zend_parse_ini_string(sapi_module.ini_entries, 1, php_config_ini_parser_cb, &extension_lists);
562 }
563
42c82bb Revert the last patches.
foobar authored
564 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
565 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
566 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
567
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
568 /* {{{ php_shutdown_config
569 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
570 int php_shutdown_config(void)
571 {
42c82bb Revert the last patches.
foobar authored
572 zend_hash_destroy(&configuration_hash);
573 if (php_ini_opened_path) {
574 free(php_ini_opened_path);
2a2d49b Fixed bug #30050 (Possible crash inside php_shutdown_config()).
Ilia Alshanetsky authored
575 php_ini_opened_path = NULL;
42c82bb Revert the last patches.
foobar authored
576 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
577 if (php_ini_scanned_files) {
578 free(php_ini_scanned_files);
2a2d49b Fixed bug #30050 (Possible crash inside php_shutdown_config()).
Ilia Alshanetsky authored
579 php_ini_scanned_files = NULL;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
580 }
42c82bb Revert the last patches.
foobar authored
581 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
582 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
583 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
584
f47c784 Improved PHP extension loading mechanism with support for module depe…
Dmitry Stogov authored
585 /* {{{ php_ini_register_extensions
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
586 */
f47c784 Improved PHP extension loading mechanism with support for module depe…
Dmitry Stogov authored
587 void php_ini_register_extensions(TSRMLS_D)
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
588 {
42c82bb Revert the last patches.
foobar authored
589 zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
590 zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb TSRMLS_CC);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
591
42c82bb Revert the last patches.
foobar authored
592 zend_llist_destroy(&extension_lists.engine);
593 zend_llist_destroy(&extension_lists.functions);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
594 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
595 /* }}} */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
596
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
597 /* {{{ cfg_get_entry
598 */
b9ddb5c MFH
Jani Taskinen authored
599 PHPAPI zval *cfg_get_entry(char *name, uint name_length)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
600 {
42c82bb Revert the last patches.
foobar authored
601 zval *tmp;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
602
7e3b508 ws/style fixes
foobar authored
603 if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp) == SUCCESS) {
42c82bb Revert the last patches.
foobar authored
604 return tmp;
605 } else {
606 return NULL;
607 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
608 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
609 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
610
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
611 /* {{{ cfg_get_long
612 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
613 PHPAPI int cfg_get_long(char *varname, long *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
614 {
42c82bb Revert the last patches.
foobar authored
615 zval *tmp, var;
b9ddb5c MFH
Jani Taskinen authored
616
7e3b508 ws/style fixes
foobar authored
617 if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
e1814f0 WIN64 support
Dmitry Stogov authored
618 *result = 0;
42c82bb Revert the last patches.
foobar authored
619 return FAILURE;
620 }
621 var = *tmp;
622 zval_copy_ctor(&var);
623 convert_to_long(&var);
624 *result = Z_LVAL(var);
625 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
626 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
627 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
628
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
629 /* {{{ cfg_get_double
630 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
631 PHPAPI int cfg_get_double(char *varname, double *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
632 {
42c82bb Revert the last patches.
foobar authored
633 zval *tmp, var;
b9ddb5c MFH
Jani Taskinen authored
634
7e3b508 ws/style fixes
foobar authored
635 if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
636 *result = (double) 0;
42c82bb Revert the last patches.
foobar authored
637 return FAILURE;
638 }
639 var = *tmp;
640 zval_copy_ctor(&var);
641 convert_to_double(&var);
642 *result = Z_DVAL(var);
643 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
644 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
645 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
646
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
647 /* {{{ cfg_get_string
648 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
649 PHPAPI int cfg_get_string(char *varname, char **result)
650 {
42c82bb Revert the last patches.
foobar authored
651 zval *tmp;
652
7e3b508 ws/style fixes
foobar authored
653 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp) == FAILURE) {
654 *result = NULL;
42c82bb Revert the last patches.
foobar authored
655 return FAILURE;
656 }
657 *result = Z_STRVAL_P(tmp);
658 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
659 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
660 /* }}} */
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
661
662 /*
663 * Local variables:
664 * tab-width: 4
665 * c-basic-offset: 4
666 * indent-tabs-mode: t
667 * End:
78747bd - Don't wrap lines... this is annoying while coding.
Derick Rethans authored
668 * vim600: sw=4 ts=4 fdm=marker
669 * vim<600: sw=4 ts=4
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
670 */
Something went wrong with that request. Please try again.