Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 402 lines (351 sloc) 11.049 kb
651e232 @zsuraski Testing 123
zsuraski authored
1 /*
2 +----------------------------------------------------------------------+
3893351 Update headers.
Sebastian Bergmann authored
3 | PHP Version 4 |
651e232 @zsuraski Testing 123
zsuraski authored
4 +----------------------------------------------------------------------+
3893351 Update headers.
Sebastian Bergmann authored
5 | Copyright (c) 1997-2002 The PHP Group |
651e232 @zsuraski Testing 123
zsuraski authored
6 +----------------------------------------------------------------------+
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
7 | This source file is subject to version 2.02 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
10 | http://www.php.net/license/2_02.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"
0be5cca @fmk Fix build on WIn32
fmk authored
22 #ifndef PHP_WIN32
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
23 #include "build-defs.h"
0be5cca @fmk Fix build on WIn32
fmk authored
24 #endif
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
25 #include "ext/standard/info.h"
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
26 #include "zend_ini.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
27 #include "php_ini.h"
28 #include "ext/standard/dl.h"
29 #include "zend_extensions.h"
9d1817e Fix bug: #10323. Every value outputted is now escaped.
foobar authored
30 #include "zend_highlight.h"
ab25640 Removed CWD from php_ini_search_path when using CLI SAPI.
Edin Kadribasic authored
31 #include "SAPI.h"
46a7b0c @fmk Killing compiler warning on Win32
fmk authored
32 #include "php_main.h"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
33
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
34 typedef struct _php_extension_lists {
42c82bb Revert the last patches.
foobar authored
35 zend_llist engine;
36 zend_llist functions;
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
37 } php_extension_lists;
58e24ac @zsuraski - Add PHP Modules workspace
zsuraski authored
38
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_ini.c...
zsuraski authored
39
40 /* True globals */
41 static HashTable configuration_hash;
42 PHPAPI char *php_ini_opened_path=NULL;
43 static php_extension_lists extension_lists;
44
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
45 /* {{{ php_ini_displayer_cb
46 */
1fd0913 @zsuraski Initial steps to move the INI mechanism to the Zend engine
zsuraski authored
47 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 ot...
zsuraski authored
48 {
42c82bb Revert the last patches.
foobar authored
49 if (ini_entry->displayer) {
50 ini_entry->displayer(ini_entry, type);
51 } else {
52 char *display_string;
53 uint display_string_length, esc_html=0;
54 TSRMLS_FETCH();
55
56 if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
57 if (ini_entry->orig_value && ini_entry->orig_value[0]) {
58 display_string = ini_entry->orig_value;
59 display_string_length = ini_entry->orig_value_length;
60 esc_html=1;
61 } else {
62 display_string = "<i>no value</i>";
63 display_string_length = sizeof("<i>no value</i>")-1;
64 }
65 } else if (ini_entry->value && ini_entry->value[0]) {
66 display_string = ini_entry->value;
67 display_string_length = ini_entry->value_length;
68 esc_html=1;
69 } else {
70 display_string = "<i>no value</i>";
71 display_string_length = sizeof("<i>no value</i>")-1;
72 }
73 if(esc_html) {
74 php_html_puts(display_string, display_string_length TSRMLS_CC);
75 } else {
76 PHPWRITE(display_string, display_string_length);
77 }
78 }
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
79 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
80 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
81
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
82 /* {{{ php_ini_displayer
83 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
84 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 ot...
zsuraski authored
85 {
42c82bb Revert the last patches.
foobar authored
86 if (ini_entry->module_number != module_number) {
87 return 0;
88 }
89
90 PUTS("<tr valign=\"baseline\" bgcolor=\"" PHP_CONTENTS_COLOR "\">");
91 PUTS("<td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>");
92 PHPWRITE(ini_entry->name, ini_entry->name_length-1);
93 PUTS("</b><br /></td><td align=\"center\">");
94 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
95 PUTS("</td><td align=\"center\">");
96 php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
97 PUTS("</td></tr>\n");
98 return 0;
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
99 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
100 /* }}} */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
101
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
102 /* {{{ display_ini_entries
103 */
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
104 PHPAPI void display_ini_entries(zend_module_entry *module)
105 {
42c82bb Revert the last patches.
foobar authored
106 int module_number;
107 TSRMLS_FETCH();
108
109 if (module) {
110 module_number = module->module_number;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
111 } else {
42c82bb Revert the last patches.
foobar authored
112 module_number = 0;
113 }
114 php_info_print_table_start();
115 php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
116 zend_hash_apply_with_argument(&EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (long) module_number TSRMLS_CC);
117 php_info_print_table_end();
bc415d5 @zsuraski * Finalizing the PHP version of SAPI. Support POST and cookies among ot...
zsuraski authored
118 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
119 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
120
121 /* php.ini support */
122
123 #ifdef ZTS
124 # if (ZEND_DEBUG)
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
125 # define ZEND_EXTENSION_TOKEN "zend_extension_debug_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
126 # else
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
127 # define ZEND_EXTENSION_TOKEN "zend_extension_ts"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
128 # endif
129 #else
130 # if (ZEND_DEBUG)
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
131 # define ZEND_EXTENSION_TOKEN "zend_extension_debug"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
132 # else
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
133 # define ZEND_EXTENSION_TOKEN "zend_extension"
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
134 # endif
135 #endif
136
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
137 /* {{{ pvalue_config_destructor
138 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
139 static void pvalue_config_destructor(zval *pvalue)
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
140 {
141 if (Z_TYPE_P(pvalue) == IS_STRING && Z_STRVAL_P(pvalue) != empty_string) {
142 free(Z_STRVAL_P(pvalue));
143 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
144 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
145 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
146
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
147 /* {{{ php_config_ini_parser_cb
148 */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_ini.c...
zsuraski authored
149 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, peop...
zsuraski authored
150 {
42c82bb Revert the last patches.
foobar authored
151 switch (callback_type) {
152 case ZEND_INI_PARSER_ENTRY: {
153 zval *entry;
154
155 if (!arg2) {
156 break;
157 }
158 if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
159 zval copy;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
160
42c82bb Revert the last patches.
foobar authored
161 copy = *arg2;
162 zval_copy_ctor(&copy);
163 copy.refcount = 0;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
164 zend_llist_add_element(&extension_lists.functions, &copy);
42c82bb Revert the last patches.
foobar authored
165 } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
166 char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
167
42c82bb Revert the last patches.
foobar authored
168 zend_llist_add_element(&extension_lists.engine, &extension_name);
169 } else {
170 zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
171 Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
172 }
173 }
174 break;
175 case ZEND_INI_PARSER_SECTION:
176 break;
177 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
178 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
179 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
180
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
181 /* {{{ php_load_function_extension_cb
182 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
183 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
184 {
42c82bb Revert the last patches.
foobar authored
185 zval *extension = (zval *) arg;
186 zval zval;
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
187
42c82bb Revert the last patches.
foobar authored
188 php_dl(extension, MODULE_PERSISTENT, &zval TSRMLS_CC);
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
189 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
190 /* }}} */
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
191
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
192 /* {{{ php_load_zend_extension_cb
193 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
194 static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
d294f46 @zsuraski - Remove the ini_extension_list global
zsuraski authored
195 {
42c82bb Revert the last patches.
foobar authored
196 zend_load_extension(*((char **) arg));
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
197 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
198 /* }}} */
db0b8bc Defer loading of extensions until all configuration entries have been
Sascha Schumann authored
199
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
200 /* {{{ php_init_config
201 */
bd0ac7f @zsuraski Many patches. I hope I remember them all:
zsuraski authored
202 int php_init_config(char *php_ini_path_override)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
203 {
42c82bb Revert the last patches.
foobar authored
204 int safe_mode_state;
205 char *open_basedir;
206 zend_file_handle fh;
207 TSRMLS_FETCH();
208
209 if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
210 return FAILURE;
211 }
212
213 zend_llist_init(&extension_lists.engine, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
214 zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
215
42c82bb Revert the last patches.
foobar authored
216 safe_mode_state = PG(safe_mode);
217 open_basedir = PG(open_basedir);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
218 PG(safe_mode) = 0;
219 PG(open_basedir) = NULL;
42c82bb Revert the last patches.
foobar authored
220
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
221 fh.handle.fp = NULL;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
222
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
223 /* If no override given (usually from the command line) then check the environment. */
224 if (!php_ini_path_override) {
225 php_ini_path_override = getenv("PHPRC");
226 }
227 if (php_ini_path_override && *php_ini_path_override) {
228
229 /* Try to open php_ini_path_override if not a directory. */
230 struct stat st;
231 if ((0 == VCWD_STAT(php_ini_path_override, &st)) && (S_IFDIR != (st.st_mode & S_IFMT))) {
232 fh.handle.fp = VCWD_FOPEN(php_ini_path_override, "r");
233 if (fh.handle.fp) {
234 php_ini_opened_path = estrdup(php_ini_path_override);
42c82bb Revert the last patches.
foobar authored
235 }
236 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
237
238 /* If we did not manage to open php_ini_path_override then search it as a directory. */
239 if (!fh.handle.fp) {
240 fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_path_override, &php_ini_opened_path TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
241 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
242
42c82bb Revert the last patches.
foobar authored
243 }
244
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
245 #define INI_CHECK_CWD
246 #ifdef INI_CHECK_CWD
247 if (!fh.handle.fp && (0 != strcmp(sapi_module.name, "cli"))) {
248 /* Search the current directory - possible security risk? */
249 fh.handle.fp = php_fopen_with_path("php.ini", "r", ".", &php_ini_opened_path TSRMLS_CC);
250 }
251 #endif
42c82bb Revert the last patches.
foobar authored
252
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
253 #ifdef PHP_WIN32
254 if (!fh.handle.fp) {
255 /* Search for php.ini in the same directory as the executable. */
256 char search_path[MAX_PATH];
257 if (GetModuleFileName(0,search_path,sizeof(search_path))) {
258 char* p = strrchr(search_path,'\\');
259 if (p) *++p = 0;
260 fh.handle.fp = php_fopen_with_path("php.ini", "r", search_path, &php_ini_opened_path TSRMLS_CC);
42c82bb Revert the last patches.
foobar authored
261 }
262 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
263 if (!fh.handle.fp) {
264 /* Search for php.ini in the Windows base directory. */
265 char search_path[MAX_PATH];
266 if (GetWindowsDirectory(search_path,sizeof(search_path))) {
267 fh.handle.fp = php_fopen_with_path("php.ini", "r", search_path, &php_ini_opened_path TSRMLS_CC);
268 }
42c82bb Revert the last patches.
foobar authored
269 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
270 #else
271 if (!fh.handle.fp) {
272 /* Search for php.ini in the (platform-specific) default places. */
273 fh.handle.fp = php_fopen_with_path("php.ini", "r", PHP_CONFIG_FILE_PATH, &php_ini_opened_path TSRMLS_CC);
274 }
275 #endif
276
42c82bb Revert the last patches.
foobar authored
277 PG(safe_mode) = safe_mode_state;
278 PG(open_basedir) = open_basedir;
279
280 if (!fh.handle.fp) {
281 return SUCCESS; /* having no configuration file is ok */
282 }
283 fh.type = ZEND_HANDLE_FP;
284 fh.filename = php_ini_opened_path;
285
286 zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
287
288 /* If we succeeded in opening an INI file, preserve the name of the file opened. */
42c82bb Revert the last patches.
foobar authored
289 if (php_ini_opened_path) {
290 zval tmp;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
291
42c82bb Revert the last patches.
foobar authored
292 Z_STRLEN(tmp) = strlen(php_ini_opened_path);
293 Z_STRVAL(tmp) = zend_strndup(php_ini_opened_path, Z_STRLEN(tmp));
294 Z_TYPE(tmp) = IS_STRING;
295 zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
296 efree(php_ini_opened_path);
297 php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
298 }
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
299
42c82bb Revert the last patches.
foobar authored
300 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
301 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
302 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
303
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
304 /* {{{ php_shutdown_config
305 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
306 int php_shutdown_config(void)
307 {
42c82bb Revert the last patches.
foobar authored
308 zend_hash_destroy(&configuration_hash);
309 if (php_ini_opened_path) {
310 free(php_ini_opened_path);
311 }
312 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
313 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
314 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
315
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
316 /* {{{ php_ini_delayed_modules_startup
317 */
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
318 void php_ini_delayed_modules_startup(TSRMLS_D)
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_ini.c...
zsuraski authored
319 {
42c82bb Revert the last patches.
foobar authored
320 zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
321 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_ini.c...
zsuraski authored
322
42c82bb Revert the last patches.
foobar authored
323 zend_llist_destroy(&extension_lists.engine);
324 zend_llist_destroy(&extension_lists.functions);
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_ini.c...
zsuraski authored
325 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
326 /* }}} */
9db5589 @zsuraski Recode delayed loading in a much simpler way (switched back to php_ini.c...
zsuraski authored
327
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
328 /* {{{ cfg_get_entry
329 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
330 zval *cfg_get_entry(char *name, uint name_length)
331 {
42c82bb Revert the last patches.
foobar authored
332 zval *tmp;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
333
42c82bb Revert the last patches.
foobar authored
334 if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) {
335 return tmp;
336 } else {
337 return NULL;
338 }
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
339 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
340 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
341
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
342 /* {{{ cfg_get_long
343 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
344 PHPAPI int cfg_get_long(char *varname, long *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
345 {
42c82bb Revert the last patches.
foobar authored
346 zval *tmp, var;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
347
42c82bb Revert the last patches.
foobar authored
348 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
349 *result=(long)NULL;
350 return FAILURE;
351 }
352 var = *tmp;
353 zval_copy_ctor(&var);
354 convert_to_long(&var);
355 *result = Z_LVAL(var);
356 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
357 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
358 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
359
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
360 /* {{{ cfg_get_double
361 */
1159c84 @zsuraski - TSRMLS_FETCH work
zsuraski authored
362 PHPAPI int cfg_get_double(char *varname, double *result)
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
363 {
42c82bb Revert the last patches.
foobar authored
364 zval *tmp, var;
6de4f3a Add check for php.ini in same directory as php.exe (or equivalent execut...
Preston L. Bannister authored
365
42c82bb Revert the last patches.
foobar authored
366 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
367 *result=(double)0;
368 return FAILURE;
369 }
370 var = *tmp;
371 zval_copy_ctor(&var);
372 convert_to_double(&var);
373 *result = Z_DVAL(var);
374 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
375 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
376 /* }}} */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
377
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
378 /* {{{ cfg_get_string
379 */
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
380 PHPAPI int cfg_get_string(char *varname, char **result)
381 {
42c82bb Revert the last patches.
foobar authored
382 zval *tmp;
383
384 if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) {
385 *result=NULL;
386 return FAILURE;
387 }
388 *result = Z_STRVAL_P(tmp);
389 return SUCCESS;
78194a4 @zsuraski - Complete the move to the new INI parser. (Side effect: at last, peop...
zsuraski authored
390 }
81e2cf0 @rlerdorf Fix folding and clean up some extensions
rlerdorf authored
391 /* }}} */
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
392
393 /*
394 * Local variables:
395 * tab-width: 4
396 * c-basic-offset: 4
397 * indent-tabs-mode: t
398 * End:
78747bd - Don't wrap lines... this is annoying while coding.
Derick Rethans authored
399 * vim600: sw=4 ts=4 fdm=marker
400 * vim<600: sw=4 ts=4
2cf1b8d * expanded the following constants and made them available in PHP:
Stig Bakken authored
401 */
Something went wrong with that request. Please try again.