summaryrefslogtreecommitdiff
path: root/main/php_ini.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/php_ini.c')
-rw-r--r--main/php_ini.c248
1 files changed, 116 insertions, 132 deletions
diff --git a/main/php_ini.c b/main/php_ini.c
index 7d27582f4f..5f9eb61907 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
@@ -37,10 +37,6 @@
#include <dirent.h>
#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-
#ifdef PHP_WIN32
#define TRANSLATE_SLASHES_LOWER(path) \
{ \
@@ -74,18 +70,19 @@ PHPAPI char *php_ini_scanned_files=NULL;
/* {{{ php_ini_displayer_cb
*/
-static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
+static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
{
if (ini_entry->displayer) {
ini_entry->displayer(ini_entry, type);
} else {
char *display_string;
- uint display_string_length, esc_html=0;
+ size_t display_string_length;
+ int esc_html=0;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- if (ini_entry->orig_value && ini_entry->orig_value[0]) {
- display_string = ini_entry->orig_value;
- display_string_length = ini_entry->orig_value_length;
+ if (ini_entry->orig_value && ZSTR_VAL(ini_entry->orig_value)[0]) {
+ display_string = ZSTR_VAL(ini_entry->orig_value);
+ display_string_length = ZSTR_LEN(ini_entry->orig_value);
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -96,9 +93,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
display_string_length = sizeof("no value") - 1;
}
}
- } else if (ini_entry->value && ini_entry->value[0]) {
- display_string = ini_entry->value;
- display_string_length = ini_entry->value_length;
+ } else if (ini_entry->value && ZSTR_VAL(ini_entry->value)[0]) {
+ display_string = ZSTR_VAL(ini_entry->value);
+ display_string_length = ZSTR_LEN(ini_entry->value);
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -111,7 +108,7 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
}
if (esc_html) {
- php_html_puts(display_string, display_string_length TSRMLS_CC);
+ php_html_puts(display_string, display_string_length);
} else {
PHPWRITE(display_string, display_string_length);
}
@@ -121,26 +118,29 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
/* {{{ php_ini_displayer
*/
-static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS_DC)
+static int php_ini_displayer(zval *el, void *arg)
{
+ zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el);
+ int module_number = *(int *)arg;
+
if (ini_entry->module_number != module_number) {
return 0;
}
if (!sapi_module.phpinfo_as_text) {
PUTS("<tr>");
PUTS("<td class=\"e\">");
- PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
PUTS("</td></tr>\n");
} else {
- PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
PUTS("\n");
}
return 0;
@@ -149,10 +149,12 @@ static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS
/* {{{ php_ini_available
*/
-static int php_ini_available(zend_ini_entry *ini_entry, int *module_number_available TSRMLS_DC)
+static int php_ini_available(zval *el, void *arg)
{
- if (ini_entry->module_number == *module_number_available) {
- *module_number_available = -1;
+ zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
+ int *module_number_available = (int *)arg;
+ if (ini_entry->module_number == *(int *)module_number_available) {
+ *(int *)module_number_available = -1;
return ZEND_HASH_APPLY_STOP;
} else {
return ZEND_HASH_APPLY_KEEP;
@@ -165,7 +167,6 @@ static int php_ini_available(zend_ini_entry *ini_entry, int *module_number_avail
PHPAPI void display_ini_entries(zend_module_entry *module)
{
int module_number, module_number_available;
- TSRMLS_FETCH();
if (module) {
module_number = module->module_number;
@@ -173,11 +174,11 @@ PHPAPI void display_ini_entries(zend_module_entry *module)
module_number = 0;
}
module_number_available = module_number;
- zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_available, &module_number_available TSRMLS_CC);
+ zend_hash_apply_with_argument(EG(ini_directives), php_ini_available, &module_number_available);
if (module_number_available == -1) {
php_info_print_table_start();
php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
- zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (zend_intptr_t) module_number TSRMLS_CC);
+ zend_hash_apply_with_argument(EG(ini_directives), php_ini_displayer, (void *)&module_number);
php_info_print_table_end();
}
}
@@ -193,9 +194,9 @@ PHPAPI void config_zval_dtor(zval *zvalue)
{
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
zend_hash_destroy(Z_ARRVAL_P(zvalue));
- free(Z_ARRVAL_P(zvalue));
+ free(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- free(Z_STRVAL_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* Reset / free active_ini_sectin global */
@@ -237,14 +238,14 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
/* All other entries are added into either configuration_hash or active ini section array */
} else {
/* Store in active hash */
- zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, arg2, sizeof(zval), (void **) &entry);
- Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
+ entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
}
break;
case ZEND_INI_PARSER_POP_ENTRY: {
- zval *option_arr;
+ zval option_arr;
zval *find_arr;
if (!arg2) {
@@ -255,23 +256,19 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
/* fprintf(stdout, "ZEND_INI_PARSER_POP_ENTRY: %s[%s] = %s\n",Z_STRVAL_P(arg1), Z_STRVAL_P(arg3), Z_STRVAL_P(arg2)); */
/* If option not found in hash or is not an array -> create array, otherwise add to existing array */
- 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) {
- option_arr = (zval *) pemalloc(sizeof(zval), 1);
- INIT_PZVAL(option_arr);
- Z_TYPE_P(option_arr) = IS_ARRAY;
- Z_ARRVAL_P(option_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1);
- zend_hash_init(Z_ARRVAL_P(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
- zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, option_arr, sizeof(zval), (void **) &find_arr);
- free(option_arr);
+ if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) {
+ ZVAL_NEW_PERSISTENT_ARR(&option_arr);
+ zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, config_zval_dtor, 1);
+ find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr);
}
/* arg3 is possible option offset name */
if (arg3 && Z_STRLEN_P(arg3) > 0) {
- zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, arg2, sizeof(zval), (void **) &entry);
+ entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2);
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2, sizeof(zval), (void **) &entry);
+ entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2);
}
- Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
break;
@@ -280,7 +277,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
/* fprintf(stdout, "ZEND_INI_PARSER_SECTION: %s\n",Z_STRVAL_P(arg1)); */
char *key = NULL;
- uint key_len;
+ size_t key_len;
/* PATH sections */
if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) {
@@ -324,16 +321,12 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
}
/* Search for existing entry and if it does not exist create one */
- if (zend_hash_find(target_hash, key, key_len + 1, (void **) &entry) == FAILURE) {
- zval *section_arr;
-
- section_arr = (zval *) pemalloc(sizeof(zval), 1);
- INIT_PZVAL(section_arr);
- Z_TYPE_P(section_arr) = IS_ARRAY;
- Z_ARRVAL_P(section_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1);
- zend_hash_init(Z_ARRVAL_P(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
- zend_hash_update(target_hash, key, key_len + 1, section_arr, sizeof(zval), (void **) &entry);
- free(section_arr);
+ if ((entry = zend_hash_str_find(target_hash, key, key_len)) == NULL) {
+ zval section_arr;
+
+ ZVAL_NEW_PERSISTENT_ARR(&section_arr);
+ zend_hash_init(Z_ARRVAL(section_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1);
+ entry = zend_hash_str_update(target_hash, key, key_len, &section_arr);
}
active_ini_hash = Z_ARRVAL_P(entry);
}
@@ -345,27 +338,31 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
/* {{{ php_load_php_extension_cb
*/
-static void php_load_php_extension_cb(void *arg TSRMLS_DC)
+static void php_load_php_extension_cb(void *arg)
{
#ifdef HAVE_LIBDL
- php_load_extension(*((char **) arg), MODULE_PERSISTENT, 0 TSRMLS_CC);
+ php_load_extension(*((char **) arg), MODULE_PERSISTENT, 0);
#endif
}
/* }}} */
/* {{{ php_load_zend_extension_cb
*/
-static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
+static void php_load_zend_extension_cb(void *arg)
{
char *filename = *((char **) arg);
- int length = strlen(filename);
+ const int length = (int)strlen(filename);
+
+#ifndef PHP_WIN32
+ (void) length;
+#endif
if (IS_ABSOLUTE_PATH(filename, length)) {
zend_load_extension(filename);
} else {
char *libpath;
char *extension_dir = INI_STR("extension_dir");
- int extension_dir_len = strlen(extension_dir);
+ int extension_dir_len = (int)strlen(extension_dir);
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
spprintf(&libpath, 0, "%s%s", extension_dir, filename);
@@ -380,7 +377,7 @@ static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
/* {{{ php_init_config
*/
-int php_init_config(TSRMLS_D)
+int php_init_config(void)
{
char *php_ini_file_name = NULL;
char *php_ini_search_path = NULL;
@@ -388,10 +385,9 @@ int php_init_config(TSRMLS_D)
char *open_basedir;
int free_ini_search_path = 0;
zend_file_handle fh;
+ zend_string *opened_path = NULL;
- if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) {
- return FAILURE;
- }
+ zend_hash_init(&configuration_hash, 8, NULL, config_zval_dtor, 1);
if (sapi_module.ini_defaults) {
sapi_module.ini_defaults(&configuration_hash);
@@ -425,8 +421,8 @@ int php_init_config(TSRMLS_D)
SetLastError(0);
- /*If the given bugger is not large enough to hold the data, the return value is
- the buffer size, in characters, required to hold the string and its terminating
+ /*If the given buffer is not large enough to hold the data, the return value is
+ the buffer size, in characters, required to hold the string and its terminating
null character. We use this return value to alloc the final buffer. */
size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
@@ -454,7 +450,7 @@ int php_init_config(TSRMLS_D)
* Prepare search path
*/
- search_path_size = MAXPATHLEN * 4 + strlen(env_location) + 3 + 1;
+ search_path_size = MAXPATHLEN * 4 + (int)strlen(env_location) + 3 + 1;
php_ini_search_path = (char *) emalloc(search_path_size);
free_ini_search_path = 1;
php_ini_search_path[0] = 0;
@@ -550,13 +546,13 @@ int php_init_config(TSRMLS_D)
/* Check if php_ini_file_name is a file and can be opened */
if (php_ini_file_name && php_ini_file_name[0]) {
- struct stat statbuf;
+ zend_stat_t statbuf;
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
fh.handle.fp = VCWD_FOPEN(php_ini_file_name, "r");
if (fh.handle.fp) {
- fh.filename = php_ini_opened_path = expand_filepath(php_ini_file_name, NULL TSRMLS_CC);
+ fh.filename = expand_filepath(php_ini_file_name, NULL);
}
}
}
@@ -567,18 +563,18 @@ int php_init_config(TSRMLS_D)
const char *fmt = "php-%s.ini";
char *ini_fname;
spprintf(&ini_fname, 0, fmt, sapi_module.name);
- fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
+ fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &opened_path);
efree(ini_fname);
if (fh.handle.fp) {
- fh.filename = php_ini_opened_path;
+ fh.filename = ZSTR_VAL(opened_path);
}
}
/* If still no ini file found, search for php.ini file in search path */
if (!fh.handle.fp) {
- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
+ fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
if (fh.handle.fp) {
- fh.filename = php_ini_opened_path;
+ fh.filename = ZSTR_VAL(opened_path);
}
}
}
@@ -593,19 +589,17 @@ int php_init_config(TSRMLS_D)
fh.type = ZEND_HANDLE_FP;
RESET_ACTIVE_INI_HASH();
- zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
+ zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash);
{
zval tmp;
- Z_STRLEN(tmp) = strlen(fh.filename);
- Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
- Z_TYPE(tmp) = IS_STRING;
- Z_SET_REFCOUNT(tmp, 0);
-
- zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
- if (php_ini_opened_path) {
- efree(php_ini_opened_path);
+ ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
+ zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
+ if (opened_path) {
+ zend_string_release(opened_path);
+ } else {
+ efree((char *)fh.filename);
}
php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
}
@@ -617,13 +611,13 @@ int php_init_config(TSRMLS_D)
/* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */
php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR;
}
- php_ini_scanned_path_len = strlen(php_ini_scanned_path);
+ php_ini_scanned_path_len = (int)strlen(php_ini_scanned_path);
/* Scan and parse any .ini files found in scan path if path not empty. */
if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
struct dirent **namelist;
int ndir, i;
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
char *p;
zend_file_handle fh2;
@@ -647,7 +641,7 @@ int php_init_config(TSRMLS_D)
to allow "/foo/phd.d:" or ":/foo/php.d" */
debpath = PHP_CONFIG_FILE_SCAN_DIR;
}
- lenpath = strlen(debpath);
+ lenpath = (int)strlen(debpath);
if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) {
@@ -672,9 +666,9 @@ int php_init_config(TSRMLS_D)
fh2.filename = ini_file;
fh2.type = ZEND_HANDLE_FP;
- if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) {
+ if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash) == SUCCESS) {
/* Here, add it to the list of ini files read */
- l = strlen(ini_file);
+ l = (int)strlen(ini_file);
total_l += l + 2;
p = estrndup(ini_file, l);
zend_llist_add_element(&scanned_ini_list, &p);
@@ -690,7 +684,7 @@ int php_init_config(TSRMLS_D)
efree(bufpath);
if (total_l) {
- int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
+ int php_ini_scanned_files_len = (php_ini_scanned_files) ? (int)strlen(php_ini_scanned_files) + 1 : 0;
php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
if (!php_ini_scanned_files_len) {
*php_ini_scanned_files = '\0';
@@ -713,7 +707,7 @@ int php_init_config(TSRMLS_D)
if (sapi_module.ini_entries) {
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();
- 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);
+ zend_parse_ini_string(sapi_module.ini_entries, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash);
}
return SUCCESS;
@@ -739,10 +733,10 @@ int php_shutdown_config(void)
/* {{{ php_ini_register_extensions
*/
-void php_ini_register_extensions(TSRMLS_D)
+void php_ini_register_extensions(void)
{
- zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
- zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb TSRMLS_CC);
+ zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
+ zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb);
zend_llist_destroy(&extension_lists.engine);
zend_llist_destroy(&extension_lists.functions);
@@ -751,9 +745,9 @@ void php_ini_register_extensions(TSRMLS_D)
/* {{{ php_parse_user_ini_file
*/
-PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC)
+PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash)
{
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
zend_file_handle fh;
@@ -769,7 +763,7 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();
- 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) {
+ if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash) == SUCCESS) {
/* FIXME: Add parsed file to the list of user files read? */
return SUCCESS;
}
@@ -783,21 +777,15 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash
/* {{{ php_ini_activate_config
*/
-PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC)
+PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage)
{
- char *str;
+ zend_string *str;
zval *data;
- uint str_len;
- ulong num_index;
/* Walk through config hash and alter matching ini entries using the values found in the hash */
- for (zend_hash_internal_pointer_reset(source_hash);
- zend_hash_get_current_key_ex(source_hash, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(source_hash)
- ) {
- zend_hash_get_current_data(source_hash, (void **) &data);
- zend_alter_ini_entry_ex(str, str_len, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC);
- }
+ ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
+ zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0);
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
@@ -811,7 +799,7 @@ PHPAPI int php_ini_has_per_dir_config(void)
/* {{{ php_ini_activate_per_dir_config
*/
-PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC)
+PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len)
{
zval *tmp2;
char *ptr;
@@ -842,8 +830,8 @@ PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC)
while ((ptr = strchr(ptr, '/')) != NULL) {
*ptr = 0;
/* Search for source array matching the path from configuration_hash */
- if (zend_hash_find(&configuration_hash, path, strlen(path) + 1, (void **) &tmp2) == SUCCESS) {
- php_ini_activate_config(Z_ARRVAL_P(tmp2), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
+ if ((tmp2 = zend_hash_str_find(&configuration_hash, path, strlen(path))) != NULL) {
+ php_ini_activate_config(Z_ARRVAL_P(tmp2), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
}
*ptr = '/';
ptr++;
@@ -862,14 +850,14 @@ PHPAPI int php_ini_has_per_host_config(void)
/* {{{ php_ini_activate_per_host_config
*/
-PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSRMLS_DC)
+PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len)
{
zval *tmp;
if (has_per_host_config && host && host_len) {
/* Search for source array matching the host from configuration_hash */
- if (zend_hash_find(&configuration_hash, host, host_len, (void **) &tmp) == SUCCESS) {
- php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
+ if ((tmp = zend_hash_str_find(&configuration_hash, host, host_len)) != NULL) {
+ php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
}
}
}
@@ -877,32 +865,31 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR
/* {{{ cfg_get_entry
*/
-PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
+PHPAPI zval *cfg_get_entry_ex(zend_string *name)
{
- zval *tmp;
+ return zend_hash_find(&configuration_hash, name);
+}
+/* }}} */
- if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp) == SUCCESS) {
- return tmp;
- } else {
- return NULL;
- }
+/* {{{ cfg_get_entry
+ */
+PHPAPI zval *cfg_get_entry(const char *name, size_t name_length)
+{
+ return zend_hash_str_find(&configuration_hash, name, name_length);
}
/* }}} */
/* {{{ cfg_get_long
*/
-PHPAPI int cfg_get_long(const char *varname, long *result)
+PHPAPI int cfg_get_long(const char *varname, zend_long *result)
{
- zval *tmp, var;
+ zval *tmp;
- if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
+ if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
*result = 0;
return FAILURE;
}
- var = *tmp;
- zval_copy_ctor(&var);
- convert_to_long(&var);
- *result = Z_LVAL(var);
+ *result = zval_get_long(tmp);
return SUCCESS;
}
/* }}} */
@@ -911,16 +898,13 @@ PHPAPI int cfg_get_long(const char *varname, long *result)
*/
PHPAPI int cfg_get_double(const char *varname, double *result)
{
- zval *tmp, var;
+ zval *tmp;
- if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) {
+ if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
*result = (double) 0;
return FAILURE;
}
- var = *tmp;
- zval_copy_ctor(&var);
- convert_to_double(&var);
- *result = Z_DVAL(var);
+ *result = zval_get_double(tmp);
return SUCCESS;
}
/* }}} */
@@ -931,7 +915,7 @@ PHPAPI int cfg_get_string(const char *varname, char **result)
{
zval *tmp;
- if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp) == FAILURE) {
+ if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) {
*result = NULL;
return FAILURE;
}