Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 947 lines (831 sloc) 27.954 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 +----------------------------------------------------------------------+
9ba1e81 sed -i "s#1997-2009#1997-2010#g" **/*.c **/*.h **/*.php
Sebastian Bergmann authored
5 | Copyright (c) 1997-2010 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"
09b6f37 MFH:
Jani Taskinen authored
24 #include "zend_ini_scanner.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
25 #include "php_ini.h"
26 #include "ext/standard/dl.h"
27 #include "zend_extensions.h"
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
28 #include "zend_highlight.h"
ab25640 Removed CWD from php_ini_search_path when using CLI SAPI.
Edin Kadribasic authored
29 #include "SAPI.h"
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
30 #include "php_main.h"
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
31 #include "php_scandir.h"
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
32 #ifdef PHP_WIN32
33 #include "win32/php_registry.h"
34 #endif
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
35
ec11fe0 Fix the possible conflicts with other libs (like libc-client)
foobar authored
36 #if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
37 #include <dirent.h>
82f6cef Fix broken build by adding scandir and alphasort for win32
Shane Caraveo authored
38 #endif
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
39
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
40 #ifndef S_ISREG
41 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
42 #endif
43
8e5a00e - changed ini file directives [PATH=](on Win32) and [HOST=](on all) t…
Garrett Serack authored
44 #ifdef PHP_WIN32
4d63bd1 @pierrejoye - #48779, don't loop twice over the path chars
pierrejoye authored
45 #define TRANSLATE_SLASHES_LOWER(path) \
8e5a00e - changed ini file directives [PATH=](on Win32) and [HOST=](on all) t…
Garrett Serack authored
46 { \
47 char *tmp = path; \
48 while (*tmp) { \
49 if (*tmp == '\\') *tmp = '/'; \
e5d4b01 @pierrejoye - #48779, improve fix, drop usage of _tolower and use zend_strtolower
pierrejoye authored
50 else *tmp = tolower(*tmp); \
4d63bd1 @pierrejoye - #48779, don't loop twice over the path chars
pierrejoye authored
51 tmp++; \
8e5a00e - changed ini file directives [PATH=](on Win32) and [HOST=](on all) t…
Garrett Serack authored
52 } \
53 }
54 #else
4d63bd1 @pierrejoye - #48779, don't loop twice over the path chars
pierrejoye authored
55 #define TRANSLATE_SLASHES_LOWER(path)
8e5a00e - changed ini file directives [PATH=](on Win32) and [HOST=](on all) t…
Garrett Serack authored
56 #endif
57
58
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
59 typedef struct _php_extension_lists {
42c82bb Revert the last patches.
foobar authored
60 zend_llist engine;
61 zend_llist functions;
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
62 } php_extension_lists;
58e24ac @zsuraski - Add PHP Modules workspace
zsuraski authored
63
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
64 /* True globals */
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
65 static int is_special_section = 0;
09b6f37 MFH:
Jani Taskinen authored
66 static HashTable *active_ini_hash;
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
67 static HashTable configuration_hash;
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
68 static int has_per_dir_config = 0;
69 static int has_per_host_config = 0;
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
70 PHPAPI char *php_ini_opened_path=NULL;
71 static php_extension_lists extension_lists;
e5e6f55 MFH
Jani Taskinen authored
72 PHPAPI char *php_ini_scanned_path=NULL;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
73 PHPAPI char *php_ini_scanned_files=NULL;
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
74
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
75 /* {{{ php_ini_displayer_cb
76 */
09b6f37 MFH:
Jani Taskinen authored
77 static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
78 {
42c82bb Revert the last patches.
foobar authored
79 if (ini_entry->displayer) {
80 ini_entry->displayer(ini_entry, type);
81 } else {
82 char *display_string;
83 uint display_string_length, esc_html=0;
84
7e3b508 ws/style fixes
foobar authored
85 if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
42c82bb Revert the last patches.
foobar authored
86 if (ini_entry->orig_value && ini_entry->orig_value[0]) {
87 display_string = ini_entry->orig_value;
88 display_string_length = ini_entry->orig_value_length;
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
89 esc_html = !sapi_module.phpinfo_as_text;
42c82bb Revert the last patches.
foobar authored
90 } else {
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
91 if (!sapi_module.phpinfo_as_text) {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
92 display_string = "<i>no value</i>";
7e3b508 ws/style fixes
foobar authored
93 display_string_length = sizeof("<i>no value</i>") - 1;
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
94 } else {
95 display_string = "no value";
7e3b508 ws/style fixes
foobar authored
96 display_string_length = sizeof("no value") - 1;
9be89ed MFH: ws fixes
Jani Taskinen authored
97 }
42c82bb Revert the last patches.
foobar authored
98 }
99 } else if (ini_entry->value && ini_entry->value[0]) {
100 display_string = ini_entry->value;
101 display_string_length = ini_entry->value_length;
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
102 esc_html = !sapi_module.phpinfo_as_text;
42c82bb Revert the last patches.
foobar authored
103 } else {
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
104 if (!sapi_module.phpinfo_as_text) {
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
105 display_string = "<i>no value</i>";
7e3b508 ws/style fixes
foobar authored
106 display_string_length = sizeof("<i>no value</i>") - 1;
d6497fc - reenable "no value" output. thanks to sebastian for pointing that …
Jan Lehnardt authored
107 } else {
108 display_string = "no value";
7e3b508 ws/style fixes
foobar authored
109 display_string_length = sizeof("no value") - 1;
9be89ed MFH: ws fixes
Jani Taskinen authored
110 }
42c82bb Revert the last patches.
foobar authored
111 }
7e3b508 ws/style fixes
foobar authored
112
113 if (esc_html) {
a769454 reenable php_html_puts
Sascha Schumann authored
114 php_html_puts(display_string, display_string_length TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
115 } else {
116 PHPWRITE(display_string, display_string_length);
117 }
118 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
119 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
120 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
121
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
122 /* {{{ php_ini_displayer
123 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
124 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
125 {
42c82bb Revert the last patches.
foobar authored
126 if (ini_entry->module_number != module_number) {
127 return 0;
128 }
b5c97d8 fix phpinfo() & php -i
Marcus Boerger authored
129 if (!sapi_module.phpinfo_as_text) {
14a6cc8 Change phpinfo() to use CSS styling instead of HTML code.
Colin Viebrock authored
130 PUTS("<tr>");
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
131 PUTS("<td class=\"e\">");
7e3b508 ws/style fixes
foobar authored
132 PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
133 PUTS("</td><td class=\"v\">");
09b6f37 MFH:
Jani Taskinen authored
134 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
c7c275b fix phpinfo() output for better browser BC
Colin Viebrock authored
135 PUTS("</td><td class=\"v\">");
09b6f37 MFH:
Jani Taskinen authored
136 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
137 PUTS("</td></tr>\n");
138 } else {
7e3b508 ws/style fixes
foobar authored
139 PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
140 PUTS(" => ");
09b6f37 MFH:
Jani Taskinen authored
141 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
142 PUTS(" => ");
09b6f37 MFH:
Jani Taskinen authored
143 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
6676617 - add phpinfo() support for CLI.
Jan Lehnardt authored
144 PUTS("\n");
9be89ed MFH: ws fixes
Jani Taskinen authored
145 }
42c82bb Revert the last patches.
foobar authored
146 return 0;
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 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
149
d6d4121 - MFH Do not show empty ini directive tables for modules without ini …
Marcus Boerger authored
150 /* {{{ php_ini_available
151 */
152 static int php_ini_available(zend_ini_entry *ini_entry, int *module_number_available TSRMLS_DC)
153 {
154 if (ini_entry->module_number == *module_number_available) {
155 *module_number_available = -1;
156 return ZEND_HASH_APPLY_STOP;
157 } else {
158 return ZEND_HASH_APPLY_KEEP;
159 }
160 }
161 /* }}} */
162
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
163 /* {{{ display_ini_entries
164 */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
165 PHPAPI void display_ini_entries(zend_module_entry *module)
166 {
d6d4121 - MFH Do not show empty ini directive tables for modules without ini …
Marcus Boerger authored
167 int module_number, module_number_available;
42c82bb Revert the last patches.
foobar authored
168 TSRMLS_FETCH();
169
170 if (module) {
171 module_number = module->module_number;
9be89ed MFH: ws fixes
Jani Taskinen authored
172 } else {
42c82bb Revert the last patches.
foobar authored
173 module_number = 0;
174 }
d6d4121 - MFH Do not show empty ini directive tables for modules without ini …
Marcus Boerger authored
175 module_number_available = module_number;
176 zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_available, &module_number_available TSRMLS_CC);
177 if (module_number_available == -1) {
178 php_info_print_table_start();
179 php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
180 zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (zend_intptr_t) module_number TSRMLS_CC);
181 php_info_print_table_end();
182 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among…
zsuraski authored
183 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
184 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
185
186 /* php.ini support */
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
187 #define PHP_EXTENSION_TOKEN "extension"
d29d244 - MFH: Get rid of the four different versions of zend_extension* and …
Derick Rethans authored
188 #define ZEND_EXTENSION_TOKEN "zend_extension"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
189
09b6f37 MFH:
Jani Taskinen authored
190 /* {{{ config_zval_dtor
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
191 */
1674976 MFH: Fixed win32 build.
Jani Taskinen authored
192 PHPAPI void config_zval_dtor(zval *zvalue)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
193 {
09b6f37 MFH:
Jani Taskinen authored
194 if (Z_TYPE_P(zvalue) == IS_ARRAY) {
195 zend_hash_destroy(Z_ARRVAL_P(zvalue));
196 free(Z_ARRVAL_P(zvalue));
197 } else if (Z_TYPE_P(zvalue) == IS_STRING) {
198 free(Z_STRVAL_P(zvalue));
199 }
200 }
201 /* Reset / free active_ini_sectin global */
202 #define RESET_ACTIVE_INI_HASH() do { \
203 active_ini_hash = NULL; \
02b2a28 @LawnGnome Fix bug #52786 (PHP should reset section to [PHP] after ini sections)…
LawnGnome authored
204 is_special_section = 0; \
09b6f37 MFH:
Jani Taskinen authored
205 } while (0)
206 /* }}} */
207
208 /* {{{ php_ini_parser_cb
209 */
210 static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, HashTable *target_hash)
211 {
212 zval *entry;
213 HashTable *active_hash;
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
214 char *extension_name;
09b6f37 MFH:
Jani Taskinen authored
215
216 if (active_ini_hash) {
217 active_hash = active_ini_hash;
218 } else {
219 active_hash = target_hash;
220 }
221
42c82bb Revert the last patches.
foobar authored
222 switch (callback_type) {
223 case ZEND_INI_PARSER_ENTRY: {
224 if (!arg2) {
09b6f37 MFH:
Jani Taskinen authored
225 /* bare string - nothing to do */
42c82bb Revert the last patches.
foobar authored
226 break;
227 }
09b6f37 MFH:
Jani Taskinen authored
228
229 /* PHP and Zend extensions are not added into configuration hash! */
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
230 if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */
231 extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
232 zend_llist_add_element(&extension_lists.functions, &extension_name);
233 } else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
234 extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
42c82bb Revert the last patches.
foobar authored
235 zend_llist_add_element(&extension_lists.engine, &extension_name);
09b6f37 MFH:
Jani Taskinen authored
236
237 /* All other entries are added into either configuration_hash or active ini section array */
42c82bb Revert the last patches.
foobar authored
238 } else {
09b6f37 MFH:
Jani Taskinen authored
239 /* Store in active hash */
240 zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, arg2, sizeof(zval), (void **) &entry);
42c82bb Revert the last patches.
foobar authored
241 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
242 }
243 }
244 break;
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
245
246 case ZEND_INI_PARSER_POP_ENTRY: {
09b6f37 MFH:
Jani Taskinen authored
247 zval *option_arr;
248 zval *find_arr;
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
249
250 if (!arg2) {
251 /* bare string - nothing to do */
252 break;
253 }
254
09b6f37 MFH:
Jani Taskinen authored
255 /* fprintf(stdout, "ZEND_INI_PARSER_POP_ENTRY: %s[%s] = %s\n",Z_STRVAL_P(arg1), Z_STRVAL_P(arg3), Z_STRVAL_P(arg2)); */
256
257 /* If option not found in hash or is not an array -> create array, otherwise add to existing array */
258 if (zend_hash_find(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void **) &find_arr) == FAILURE || Z_TYPE_P(find_arr) != IS_ARRAY) {
259 option_arr = (zval *) pemalloc(sizeof(zval), 1);
260 INIT_PZVAL(option_arr);
261 Z_TYPE_P(option_arr) = IS_ARRAY;
262 Z_ARRVAL_P(option_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1);
263 zend_hash_init(Z_ARRVAL_P(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
264 zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, option_arr, sizeof(zval), (void **) &find_arr);
265 free(option_arr);
266 }
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
267
09b6f37 MFH:
Jani Taskinen authored
268 /* arg3 is possible option offset name */
269 if (arg3 && Z_STRLEN_P(arg3) > 0) {
270 zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, arg2, sizeof(zval), (void **) &entry);
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
271 } else {
09b6f37 MFH:
Jani Taskinen authored
272 zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2, sizeof(zval), (void **) &entry);
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
273 }
09b6f37 MFH:
Jani Taskinen authored
274 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
b51b6f0 ini patch to allow 'entry[] = value' entries
Harald Radi authored
275 }
276 break;
277
09b6f37 MFH:
Jani Taskinen authored
278 case ZEND_INI_PARSER_SECTION: { /* Create an array of entries of each section */
279
280 /* fprintf(stdout, "ZEND_INI_PARSER_SECTION: %s\n",Z_STRVAL_P(arg1)); */
281
282 char *key = NULL;
283 uint key_len;
284
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
285 /* PATH sections */
09b6f37 MFH:
Jani Taskinen authored
286 if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) {
287 key = Z_STRVAL_P(arg1);
288 key = key + sizeof("PATH") - 1;
289 key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1;
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
290 is_special_section = 1;
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
291 has_per_dir_config = 1;
8e5a00e - changed ini file directives [PATH=](on Win32) and [HOST=](on all) t…
Garrett Serack authored
292
4d63bd1 @pierrejoye - #48779, don't loop twice over the path chars
pierrejoye authored
293 /* make the path lowercase on Windows, for case insensitivty. Does nothign for other platforms */
294 TRANSLATE_SLASHES_LOWER(key);
09b6f37 MFH:
Jani Taskinen authored
295
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
296 /* HOST sections */
09b6f37 MFH:
Jani Taskinen authored
297 } else if (!strncasecmp(Z_STRVAL_P(arg1), "HOST", sizeof("HOST") - 1)) {
298 key = Z_STRVAL_P(arg1);
299 key = key + sizeof("HOST") - 1;
300 key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1;
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
301 is_special_section = 1;
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
302 has_per_host_config = 1;
994307d @felipensp - Fixed build and comment-style
felipensp authored
303 zend_str_tolower(key, key_len); /* host names are case-insensitive. */
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
304
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
305 } else {
306 is_special_section = 0;
09b6f37 MFH:
Jani Taskinen authored
307 }
308
309 if (key && key_len > 0) {
310 /* Strip any trailing slashes */
311 while (key_len > 0 && (key[key_len - 1] == '/' || key[key_len - 1] == '\\')) {
312 key_len--;
313 key[key_len] = 0;
314 }
315
316 /* Strip any leading whitespace and '=' */
317 while (*key && (
318 *key == '=' ||
319 *key == ' ' ||
320 *key == '\t'
321 )) {
322 key++;
323 key_len--;
324 }
325
326 /* Search for existing entry and if it does not exist create one */
327 if (zend_hash_find(target_hash, key, key_len + 1, (void **) &entry) == FAILURE) {
328 zval *section_arr;
329
330 section_arr = (zval *) pemalloc(sizeof(zval), 1);
331 INIT_PZVAL(section_arr);
332 Z_TYPE_P(section_arr) = IS_ARRAY;
333 Z_ARRVAL_P(section_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1);
334 zend_hash_init(Z_ARRVAL_P(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
335 zend_hash_update(target_hash, key, key_len + 1, section_arr, sizeof(zval), (void **) &entry);
336 free(section_arr);
337 }
338 active_ini_hash = Z_ARRVAL_P(entry);
339 }
340 }
42c82bb Revert the last patches.
foobar authored
341 break;
342 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
343 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
344 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
345
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
346 /* {{{ php_load_php_extension_cb
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
347 */
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
348 static void php_load_php_extension_cb(void *arg TSRMLS_DC)
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
349 {
01f828e @tony2001 fix bug #51276 (php_load_extension() is missing when HAVE_LIBDL is un…
tony2001 authored
350 #ifdef HAVE_LIBDL
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
351 php_load_extension(*((char **) arg), MODULE_PERSISTENT, 0 TSRMLS_CC);
01f828e @tony2001 fix bug #51276 (php_load_extension() is missing when HAVE_LIBDL is un…
tony2001 authored
352 #endif
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
353 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
354 /* }}} */
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
355
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
356 /* {{{ php_load_zend_extension_cb
357 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
358 static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
359 {
42c82bb Revert the last patches.
foobar authored
360 zend_load_extension(*((char **) arg));
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
361 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
362 /* }}} */
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
363
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
364 /* {{{ php_init_config
365 */
64cfbf5 MFH: - Fixed bug #34307 (OnUpdateStringUnempty INI options can be set…
foobar authored
366 int php_init_config(TSRMLS_D)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
367 {
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
368 char *php_ini_file_name = NULL;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
369 char *php_ini_search_path = NULL;
1463a82 @pierrejoye - move declaration on top and fix build error
pierrejoye authored
370 int php_ini_scanned_path_len;
42c82bb Revert the last patches.
foobar authored
371 char *open_basedir;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
372 int free_ini_search_path = 0;
42c82bb Revert the last patches.
foobar authored
373 zend_file_handle fh;
374
09b6f37 MFH:
Jani Taskinen authored
375 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) {
1890173 Revert
foobar authored
376 return FAILURE;
377 }
378
63739c7 give sapi modules the possibility to overwrite default ini settings
Marcus Boerger authored
379 if (sapi_module.ini_defaults) {
380 sapi_module.ini_defaults(&configuration_hash);
381 }
382
42c82bb Revert the last patches.
foobar authored
383 zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
c75b887 MFH: No zval is stored here
Jani Taskinen authored
384 zend_llist_init(&extension_lists.functions, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
9be89ed MFH: ws fixes
Jani Taskinen authored
385
42c82bb Revert the last patches.
foobar authored
386 open_basedir = PG(open_basedir);
387
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
388 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
389 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
390 php_ini_search_path = sapi_module.php_ini_path_override;
391 free_ini_search_path = 0;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
392 } else if (!sapi_module.php_ini_ignore) {
112462d @tony2001 MFH
tony2001 authored
393 int search_path_size;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
394 char *default_location;
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
395 char *env_location;
396 char *binary_location;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
397 static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
2479384 Fixed unused variable warning on *nix.
Ilia Alshanetsky authored
398 #ifdef PHP_WIN32
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
399 char *reg_location;
2721bbf @pierrejoye - fix possible leak and error while fetching PHPRC
pierrejoye authored
400 char phprc_path[MAXPATHLEN];
2479384 Fixed unused variable warning on *nix.
Ilia Alshanetsky authored
401 #endif
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
402
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
403 env_location = getenv("PHPRC");
2721bbf @pierrejoye - fix possible leak and error while fetching PHPRC
pierrejoye authored
404
405 #ifdef PHP_WIN32
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
406 if (!env_location) {
2721bbf @pierrejoye - fix possible leak and error while fetching PHPRC
pierrejoye authored
407 char dummybuf;
408 int size;
409
410 SetLastError(0);
411
412 /*If the given bugger is not large enough to hold the data, the return value is
413 the buffer size, in characters, required to hold the string and its terminating
414 null character. We use this return value to alloc the final buffer. */
415 size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
416 if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
417 /* The environment variable doesn't exist. */
418 env_location = "";
419 } else {
420 if (size == 0) {
421 env_location = "";
422 } else {
423 size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
424 env_location = phprc_path;
425 }
426 }
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
427 }
1fc65cb @felipensp - Fixed crash on non-Windows build
felipensp authored
428 #else
429 if (!env_location) {
430 env_location = "";
431 }
2721bbf @pierrejoye - fix possible leak and error while fetching PHPRC
pierrejoye authored
432 #endif
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
433 /*
434 * Prepare search path
435 */
436
112462d @tony2001 MFH
tony2001 authored
437 search_path_size = MAXPATHLEN * 4 + strlen(env_location) + 3 + 1;
438 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
439 free_ini_search_path = 1;
440 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
441
acb1e07 Changed priority of PHPRC environment variable on win32 to be higher …
Dmitry Stogov authored
442 /* Add environment location */
443 if (env_location[0]) {
444 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
445 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
446 }
112462d @tony2001 MFH
tony2001 authored
447 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
448 php_ini_file_name = env_location;
acb1e07 Changed priority of PHPRC environment variable on win32 to be higher …
Dmitry Stogov authored
449 }
450
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
451 #ifdef PHP_WIN32
452 /* Add registry location */
453 reg_location = GetIniPathFromRegistry();
f66d5f0 - Fixed few logic errors in php*.ini search path creation as document…
foobar authored
454 if (reg_location != NULL) {
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
455 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
456 strlcat(php_ini_search_path, paths_separator, search_path_size);
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
457 }
112462d @tony2001 MFH
tony2001 authored
458 strlcat(php_ini_search_path, reg_location, search_path_size);
06aae4b @smalyshev Enable setting php.ini path via the registry
smalyshev authored
459 efree(reg_location);
460 }
461 #endif
42c82bb Revert the last patches.
foobar authored
462
ef058cd Search for php.ini in CWD in all sapi's *but* CLI.
Edin Kadribasic authored
463 /* Add cwd (not with CLI) */
464 if (strcmp(sapi_module.name, "cli") != 0) {
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
465 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
466 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
467 }
112462d @tony2001 MFH
tony2001 authored
468 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
469 }
42c82bb Revert the last patches.
foobar authored
470
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
471 /* Add binary directory */
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
472 #ifdef PHP_WIN32
b9fd107 @zsuraski Use portable #define
zsuraski authored
473 binary_location = (char *) emalloc(MAXPATHLEN);
7e3b508 ws/style fixes
foobar authored
474 if (GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) {
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
475 efree(binary_location);
476 binary_location = NULL;
42c82bb Revert the last patches.
foobar authored
477 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
478 #else
479 if (sapi_module.executable_location) {
0db4f06 @tony2001 MFH
tony2001 authored
480 binary_location = (char *)emalloc(MAXPATHLEN);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
481 if (!strchr(sapi_module.executable_location, '/')) {
9098946 @bjori MFH: bug#41361 (shell_exec() does not find binaries)
bjori authored
482 char *envpath, *path;
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
483 int found = 0;
484
9098946 @bjori MFH: bug#41361 (shell_exec() does not find binaries)
bjori authored
485 if ((envpath = getenv("PATH")) != NULL) {
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
486 char *search_dir, search_path[MAXPATHLEN];
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
487 char *last;
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
488
d85fc29 @tony2001 MFH
tony2001 authored
489 path = estrdup(envpath);
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
490 search_dir = php_strtok_r(path, ":", &last);
d85fc29 @tony2001 MFH
tony2001 authored
491
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
492 while (search_dir) {
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
493 snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
494 if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
495 found = 1;
496 break;
497 }
63c1173 @bjori use php_strtok_r() rather than strsep()
bjori authored
498 search_dir = php_strtok_r(NULL, ":", &last);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
499 }
d85fc29 @tony2001 MFH
tony2001 authored
500 efree(path);
448dbac @bjori MFH: Fixed PHP CLI to use the php.ini from the binary location
bjori authored
501 }
502 if (!found) {
503 efree(binary_location);
504 binary_location = NULL;
505 }
506 } 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
507 efree(binary_location);
9be89ed MFH: ws fixes
Jani Taskinen authored
508 binary_location = NULL;
98694f9 @tony2001 ws fix
tony2001 authored
509 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
510 } else {
511 binary_location = NULL;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
512 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
513 #endif
514 if (binary_location) {
515 char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
9be89ed MFH: ws fixes
Jani Taskinen authored
516
882cb20 edge case: do not remove trailing slash for root directory (Bug #33882)
Hartmut Holzgraefe authored
517 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
518 *(separator_location) = 0;
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
519 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
520 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
521 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
522 }
112462d @tony2001 MFH
tony2001 authored
523 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
524 efree(binary_location);
525 }
526
527 /* Add default location */
528 #ifdef PHP_WIN32
7e3b508 ws/style fixes
foobar authored
529 default_location = (char *) emalloc(MAXPATHLEN + 1);
9be89ed MFH: ws fixes
Jani Taskinen authored
530
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
531 if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
532 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
533 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
534 }
112462d @tony2001 MFH
tony2001 authored
535 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
536 }
fcdda2e @wez Fix a problem resolving the php.ini path under win32 terminal service…
wez authored
537
112379b @pierrejoye - fix possible issue in TS environment (we don't have to do that anym…
pierrejoye authored
538 /* For people running under terminal services, GetWindowsDirectory will
539 * return their personal Windows directory, so lets add the system
540 * windows directory too */
541 if (0 < GetSystemWindowsDirectory(default_location, MAXPATHLEN)) {
542 if (*php_ini_search_path) {
543 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
544 }
112379b @pierrejoye - fix possible issue in TS environment (we don't have to do that anym…
pierrejoye authored
545 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
546 }
112379b @pierrejoye - fix possible issue in TS environment (we don't have to do that anym…
pierrejoye authored
547 efree(default_location);
548
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
549 #else
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
550 default_location = PHP_CONFIG_FILE_PATH;
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
551 if (*php_ini_search_path) {
112462d @tony2001 MFH
tony2001 authored
552 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
553 }
112462d @tony2001 MFH
tony2001 authored
554 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
555 #endif
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
556 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent exe…
Preston L. Bannister authored
557
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
558 PG(open_basedir) = NULL;
559
e5e6f55 MFH
Jani Taskinen authored
560 /*
561 * Find and open actual ini file
562 */
563
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored
564 memset(&fh, 0, sizeof(fh));
e5e6f55 MFH
Jani Taskinen authored
565
566 /* If SAPI does not want to ignore all ini files OR an overriding file/path is given.
567 * This allows disabling scanning for ini files in the PHP_CONFIG_FILE_SCAN_DIR but still
568 * load an optional ini file. */
569 if (!sapi_module.php_ini_ignore || sapi_module.php_ini_path_override) {
570
571 /* Check if php_ini_file_name is a file and can be opened */
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
572 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
573 struct stat statbuf;
9be89ed MFH: ws fixes
Jani Taskinen authored
574
c946b4d In addtion to path to php.ini, PHPRC now may specify full file name
Dmitry Stogov authored
575 if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
576 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
577 fh.handle.fp = VCWD_FOPEN(php_ini_file_name, "r");
578 if (fh.handle.fp) {
579 fh.filename = php_ini_opened_path = expand_filepath(php_ini_file_name, NULL TSRMLS_CC);
580 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
581 }
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
582 }
583 }
e5e6f55 MFH
Jani Taskinen authored
584
585 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
586 if (!fh.handle.fp) {
587 const char *fmt = "php-%s.ini";
50ea267 - Avoid sprintf, even when checked copy'n'paste or changes lead to er…
Marcus Boerger authored
588 char *ini_fname;
589 spprintf(&ini_fname, 0, fmt, sapi_module.name);
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
590 fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
591 efree(ini_fname);
592 if (fh.handle.fp) {
593 fh.filename = php_ini_opened_path;
594 }
e1658ed Minor cleanups to path building and php*.ini search logic.
Preston L. Bannister authored
595 }
e5e6f55 MFH
Jani Taskinen authored
596
597 /* If still no ini file found, search for php.ini file in search path */
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
598 if (!fh.handle.fp) {
599 fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
600 if (fh.handle.fp) {
601 fh.filename = php_ini_opened_path;
602 }
8f94a8a First try to open php-SAPI.ini and if it fails fall back to regular
Edin Kadribasic authored
603 }
751cd67 get_cfg_var("get_file_path") didn't work correctly when an alternative
Sander Roobol authored
604 }
7e3b508 ws/style fixes
foobar authored
605
5af649e @zsuraski Revert to the old php_ini.c, and reimplement the binary-path searching.
zsuraski authored
606 if (free_ini_search_path) {
607 efree(php_ini_search_path);
608 }
7e3b508 ws/style fixes
foobar authored
609
42c82bb Revert the last patches.
foobar authored
610 PG(open_basedir) = open_basedir;
611
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
612 if (fh.handle.fp) {
613 fh.type = ZEND_HANDLE_FP;
09b6f37 MFH:
Jani Taskinen authored
614 RESET_ACTIVE_INI_HASH();
42c82bb Revert the last patches.
foobar authored
615
09b6f37 MFH:
Jani Taskinen authored
616 zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
9be89ed MFH: ws fixes
Jani Taskinen authored
617
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
618 {
619 zval tmp;
9be89ed MFH: ws fixes
Jani Taskinen authored
620
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
621 Z_STRLEN(tmp) = strlen(fh.filename);
622 Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
623 Z_TYPE(tmp) = IS_STRING;
4b4d634 MFH: Added macros for managing zval refcounts and is_ref statuses
Yiduo (David) Wang authored
624 Z_SET_REFCOUNT(tmp, 0);
09b6f37 MFH:
Jani Taskinen authored
625
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
626 zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
7e3b508 ws/style fixes
foobar authored
627 if (php_ini_opened_path) {
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
628 efree(php_ini_opened_path);
7e3b508 ws/style fixes
foobar authored
629 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
630 php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
631 }
cecb9df Implemented -n switch to skip parsing ini at startup as suggested by …
Marcus Boerger authored
632 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
633
e5e6f55 MFH
Jani Taskinen authored
634 /* Check for PHP_INI_SCAN_DIR environment variable to override/set config file scan directory */
635 php_ini_scanned_path = getenv("PHP_INI_SCAN_DIR");
636 if (!php_ini_scanned_path) {
637 /* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */
638 php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR;
639 }
1463a82 @pierrejoye - move declaration on top and fix build error
pierrejoye authored
640 php_ini_scanned_path_len = strlen(php_ini_scanned_path);
e5e6f55 MFH
Jani Taskinen authored
641
642 /* Scan and parse any .ini files found in scan path if path not empty. */
643 if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
644 struct dirent **namelist;
645 int ndir, i;
09b6f37 MFH:
Jani Taskinen authored
646 struct stat sb;
647 char ini_file[MAXPATHLEN];
648 char *p;
649 zend_file_handle fh;
650 zend_llist scanned_ini_list;
651 zend_llist_element *element;
652 int l, total_l = 0;
653
e5e6f55 MFH
Jani Taskinen authored
654 if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
09b6f37 MFH:
Jani Taskinen authored
655 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
656 memset(&fh, 0, sizeof(fh));
657
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
658 for (i = 0; i < ndir; i++) {
09b6f37 MFH:
Jani Taskinen authored
659
660 /* check for any file with .ini extension */
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
661 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
662 free(namelist[i]);
d454bec - Whitespace
Derick Rethans authored
663 continue;
664 }
02b2a28 @LawnGnome Fix bug #52786 (PHP should reset section to [PHP] after ini sections)…
LawnGnome authored
665 /* Reset active ini section */
666 RESET_ACTIVE_INI_HASH();
667
e5e6f55 MFH
Jani Taskinen authored
668 if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) {
669 snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name);
670 } else {
671 snprintf(ini_file, MAXPATHLEN, "%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name);
672 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
673 if (VCWD_STAT(ini_file, &sb) == 0) {
674 if (S_ISREG(sb.st_mode)) {
675 if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
676 fh.filename = ini_file;
1ad304c @rlerdorf MFB config-file-scan-dir crash fix
rlerdorf authored
677 fh.type = ZEND_HANDLE_FP;
09b6f37 MFH:
Jani Taskinen authored
678
679 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) {
680 /* Here, add it to the list of ini files read */
681 l = strlen(ini_file);
682 total_l += l + 2;
683 p = estrndup(ini_file, l);
684 zend_llist_add_element(&scanned_ini_list, &p);
685 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
686 }
687 }
688 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
689 free(namelist[i]);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
690 }
8d352d2 Fixed bug #21625 (When scanning a directory for ini files, do so in
Ilia Alshanetsky authored
691 free(namelist);
692
3781af5 - Fixed zero bytes memory allocation when no extra ini files are foun…
Derick Rethans authored
693 if (total_l) {
09b6f37 MFH:
Jani Taskinen authored
694 int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
695 php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
696 if (!php_ini_scanned_files_len) {
697 *php_ini_scanned_files = '\0';
698 }
699 total_l += php_ini_scanned_files_len;
3781af5 - Fixed zero bytes memory allocation when no extra ini files are foun…
Derick Rethans authored
700 for (element = scanned_ini_list.head; element; element = element->next) {
09b6f37 MFH:
Jani Taskinen authored
701 if (php_ini_scanned_files_len) {
702 strlcat(php_ini_scanned_files, ",\n", total_l);
703 }
112462d @tony2001 MFH
tony2001 authored
704 strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
705 strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
9be89ed MFH: ws fixes
Jani Taskinen authored
706 }
3781af5 - Fixed zero bytes memory allocation when no extra ini files are foun…
Derick Rethans authored
707 }
ac9f4cc - We always need to destroy the llist though.
Derick Rethans authored
708 zend_llist_destroy(&scanned_ini_list);
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
709 }
e5e6f55 MFH
Jani Taskinen authored
710 } else {
711 /* Make sure an empty php_ini_scanned_path ends up as NULL */
712 php_ini_scanned_path = NULL;
42c82bb Revert the last patches.
foobar authored
713 }
7d14dad MFH: Fixed mess with CGI/CLI -d command line option (now it works wit…
Dmitry Stogov authored
714
715 if (sapi_module.ini_entries) {
09b6f37 MFH:
Jani Taskinen authored
716 /* Reset active ini section */
717 RESET_ACTIVE_INI_HASH();
718 zend_parse_ini_string(sapi_module.ini_entries, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
7d14dad MFH: Fixed mess with CGI/CLI -d command line option (now it works wit…
Dmitry Stogov authored
719 }
720
42c82bb Revert the last patches.
foobar authored
721 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
722 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
723 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
724
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
725 /* {{{ php_shutdown_config
726 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
727 int php_shutdown_config(void)
728 {
42c82bb Revert the last patches.
foobar authored
729 zend_hash_destroy(&configuration_hash);
730 if (php_ini_opened_path) {
731 free(php_ini_opened_path);
2a2d49b Fixed bug #30050 (Possible crash inside php_shutdown_config()).
Ilia Alshanetsky authored
732 php_ini_opened_path = NULL;
42c82bb Revert the last patches.
foobar authored
733 }
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
734 if (php_ini_scanned_files) {
735 free(php_ini_scanned_files);
2a2d49b Fixed bug #30050 (Possible crash inside php_shutdown_config()).
Ilia Alshanetsky authored
736 php_ini_scanned_files = NULL;
989a61e @rlerdorf As discussed, add --with-config-file-scan-dir compile-time switch def…
rlerdorf authored
737 }
42c82bb Revert the last patches.
foobar authored
738 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
739 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
740 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
741
f47c784 Improved PHP extension loading mechanism with support for module depe…
Dmitry Stogov authored
742 /* {{{ php_ini_register_extensions
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
743 */
f47c784 Improved PHP extension loading mechanism with support for module depe…
Dmitry Stogov authored
744 void php_ini_register_extensions(TSRMLS_D)
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
745 {
42c82bb Revert the last patches.
foobar authored
746 zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
747 zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb TSRMLS_CC);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
748
42c82bb Revert the last patches.
foobar authored
749 zend_llist_destroy(&extension_lists.engine);
750 zend_llist_destroy(&extension_lists.functions);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
751 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
752 /* }}} */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_in…
zsuraski authored
753
09b6f37 MFH:
Jani Taskinen authored
754 /* {{{ php_parse_user_ini_file
755 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
756 PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC)
09b6f37 MFH:
Jani Taskinen authored
757 {
758 struct stat sb;
759 char ini_file[MAXPATHLEN];
760 zend_file_handle fh;
761
762 snprintf(ini_file, MAXPATHLEN, "%s%c%s", dirname, DEFAULT_SLASH, ini_filename);
763
764 if (VCWD_STAT(ini_file, &sb) == 0) {
765 if (S_ISREG(sb.st_mode)) {
766 memset(&fh, 0, sizeof(fh));
767 if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
768 fh.filename = ini_file;
769 fh.type = ZEND_HANDLE_FP;
770
771 /* Reset active ini section */
772 RESET_ACTIVE_INI_HASH();
773
774 if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash TSRMLS_CC) == SUCCESS) {
775 /* FIXME: Add parsed file to the list of user files read? */
776 return SUCCESS;
777 }
778 return FAILURE;
779 }
780 }
781 }
782 return FAILURE;
783 }
784 /* }}} */
785
786 /* {{{ php_ini_activate_config
787 */
788 PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC)
789 {
790 char *str;
791 zval *data;
792 uint str_len;
793 ulong num_index;
794
795 /* Walk through config hash and alter matching ini entries using the values found in the hash */
796 for (zend_hash_internal_pointer_reset(source_hash);
797 zend_hash_get_current_key_ex(source_hash, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING;
798 zend_hash_move_forward(source_hash)
799 ) {
800 zend_hash_get_current_data(source_hash, (void **) &data);
801 zend_alter_ini_entry_ex(str, str_len, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC);
802 }
803 }
804 /* }}} */
805
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
806 /* {{{ php_ini_has_per_dir_config
807 */
808 PHPAPI int php_ini_has_per_dir_config(void)
809 {
810 return has_per_dir_config;
811 }
812 /* }}} */
813
09b6f37 MFH:
Jani Taskinen authored
814 /* {{{ php_ini_activate_per_dir_config
815 */
816 PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC)
817 {
818 zval *tmp;
819 char *ptr;
820
e4adfe4 @pierrejoye - #48779, fix another use case where / usage may differ
pierrejoye authored
821 #if PHP_WIN32
822 char path_bak[MAXPATHLEN];
823 memcpy(path_bak, path, path_len);
824 path_bak[path_len] = 0;
825 TRANSLATE_SLASHES_LOWER(path_bak);
826 path = path_bak;
827 #endif
828
09b6f37 MFH:
Jani Taskinen authored
829 /* Walk through each directory in path and apply any found per-dir-system-configuration from configuration_hash */
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
830 if (has_per_dir_config && path && path_len) {
09b6f37 MFH:
Jani Taskinen authored
831 ptr = path + 1;
e4adfe4 @pierrejoye - #48779, fix another use case where / usage may differ
pierrejoye authored
832 while ((ptr = strchr(ptr, '/')) != NULL) {
09b6f37 MFH:
Jani Taskinen authored
833 *ptr = 0;
834 /* Search for source array matching the path from configuration_hash */
e421bee - Fixed bug #48811 (Directives in PATH section do not get applied to …
Jani Taskinen authored
835 if (zend_hash_find(&configuration_hash, path, strlen(path) + 1, (void **) &tmp) == SUCCESS) {
09b6f37 MFH:
Jani Taskinen authored
836 php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
837 }
838 *ptr = '/';
839 ptr++;
840 }
841 }
842 }
843 /* }}} */
844
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
845 /* {{{ php_ini_has_per_host_config
846 */
847 PHPAPI int php_ini_has_per_host_config(void)
848 {
849 return has_per_host_config;
850 }
851 /* }}} */
852
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
853 /* {{{ php_ini_activate_per_host_config
854 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
855 PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSRMLS_DC)
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
856 {
857 zval *tmp;
858
ba8e317 Optimized request startup sequence for php.ini without per dir and pe…
Dmitry Stogov authored
859 if (has_per_host_config && host && host_len) {
02d966c MFH:- Added support for [HOST=www.example.com] special sections
Jani Taskinen authored
860 /* Search for source array matching the host from configuration_hash */
861 if (zend_hash_find(&configuration_hash, host, host_len, (void **) &tmp) == SUCCESS) {
862 php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
863 }
864 }
865 }
866 /* }}} */
867
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
868 /* {{{ cfg_get_entry
869 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
870 PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
871 {
42c82bb Revert the last patches.
foobar authored
872 zval *tmp;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
873
7e3b508 ws/style fixes
foobar authored
874 if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp) == SUCCESS) {
42c82bb Revert the last patches.
foobar authored
875 return tmp;
876 } else {
877 return NULL;
878 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
879 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
880 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
881
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
882 /* {{{ cfg_get_long
883 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
884 PHPAPI int cfg_get_long(const char *varname, long *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
885 {
42c82bb Revert the last patches.
foobar authored
886 zval *tmp, var;
b9ddb5c MFH
Jani Taskinen authored
887
7e3b508 ws/style fixes
foobar authored
888 if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
e1814f0 WIN64 support
Dmitry Stogov authored
889 *result = 0;
42c82bb Revert the last patches.
foobar authored
890 return FAILURE;
891 }
892 var = *tmp;
893 zval_copy_ctor(&var);
894 convert_to_long(&var);
895 *result = Z_LVAL(var);
896 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
897 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
898 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
899
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
900 /* {{{ cfg_get_double
901 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
902 PHPAPI int cfg_get_double(const char *varname, double *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
903 {
42c82bb Revert the last patches.
foobar authored
904 zval *tmp, var;
b9ddb5c MFH
Jani Taskinen authored
905
7e3b508 ws/style fixes
foobar authored
906 if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
907 *result = (double) 0;
42c82bb Revert the last patches.
foobar authored
908 return FAILURE;
909 }
910 var = *tmp;
911 zval_copy_ctor(&var);
912 convert_to_double(&var);
913 *result = Z_DVAL(var);
914 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
915 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
916 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
917
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
918 /* {{{ cfg_get_string
919 */
cf7384a @felipensp - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
920 PHPAPI int cfg_get_string(const char *varname, char **result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
921 {
42c82bb Revert the last patches.
foobar authored
922 zval *tmp;
923
7e3b508 ws/style fixes
foobar authored
924 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp) == FAILURE) {
925 *result = NULL;
42c82bb Revert the last patches.
foobar authored
926 return FAILURE;
927 }
928 *result = Z_STRVAL_P(tmp);
929 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, p…
zsuraski authored
930 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
931 /* }}} */
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
932
fa94dab - MFH Rename dump_config_hash() to get_config_hash() as it doesn't dump
Marcus Boerger authored
933 PHPAPI HashTable* php_ini_get_configuration_hash(void) /* {{{ */
09b6f37 MFH:
Jani Taskinen authored
934 {
fa94dab - MFH Rename dump_config_hash() to get_config_hash() as it doesn't dump
Marcus Boerger authored
935 return &configuration_hash;
936 } /* }}} */
09b6f37 MFH:
Jani Taskinen authored
937
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
938 /*
939 * Local variables:
940 * tab-width: 4
941 * c-basic-offset: 4
942 * indent-tabs-mode: t
943 * End:
78747bd - Don't wrap lines... this is annoying while coding.
Derick Rethans authored
944 * vim600: sw=4 ts=4 fdm=marker
945 * vim<600: sw=4 ts=4
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
946 */
Something went wrong with that request. Please try again.