1 --- php5.2-200710301730/main/php_ini.c 2007-08-31 11:31:28.000000000 +0300
2 +++ php5.2-200710301730-sapi-ini-file/main/php_ini.c 2007-10-30 21:28:48.493329368 +0200
7 + /* Search (global) php.ini file in search path */
9 + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
11 + fh.filename = php_ini_opened_path;
12 + PG(safe_mode) = safe_mode_state;
13 + PG(open_basedir) = open_basedir;
14 + fh.type = ZEND_HANDLE_FP;
15 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
16 + safe_mode_state = PG(safe_mode);
17 + open_basedir = PG(open_basedir);
19 + PG(open_basedir) = NULL;
20 + fh.handle.fp = NULL;
21 + efree(php_ini_opened_path);
22 + fh.filename = php_ini_opened_path = NULL;
25 /* Search php-%sapi-module-name%.ini file in search path */
27 const char *fmt = "php-%s.ini";
29 fh.filename = php_ini_opened_path;
32 - /* Search php.ini file in search path */
33 - if (!fh.handle.fp) {
34 - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
36 - fh.filename = php_ini_opened_path;
41 if (free_ini_search_path) {
43 * parse any .ini files found in this directory. */
44 if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
45 struct dirent **namelist;
47 + int ndir, i, found = 0;
48 + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
49 + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
50 + sprintf(sapi_scan_dir, fmt, sapi_module.name);
52 if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) {
54 for (i = 0; i < ndir; i++) {
55 /* check for a .ini extension */
56 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
58 /* Here, add it to the list of ini files read */
61 + p = estrndup(ini_file, l);
62 + zend_llist_add_element(&scanned_ini_list, &p);
71 + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
74 + for (i = 0; i < ndir; i++) {
75 + /* check for a .ini extension */
76 + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
80 + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
81 + if (VCWD_STAT(ini_file, &sb) == 0) {
82 + if (S_ISREG(sb.st_mode)) {
83 + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
84 + fh.filename = ini_file;
85 + fh.type = ZEND_HANDLE_FP;
86 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
87 + /* Here, add it to the list of ini files read */
88 + l = strlen(ini_file);
90 p = estrndup(ini_file, l);
91 zend_llist_add_element(&scanned_ini_list, &p);
98 + efree(sapi_scan_dir);
103 * Don't need an extra byte for the \0 in this malloc as the last
104 * element will not get a trailing , which gives us the byte for the \0