summaryrefslogtreecommitdiff
path: root/main/php_ini.c
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2014-10-16 21:28:40 -0700
committerRasmus Lerdorf <rasmus@php.net>2014-10-16 21:28:40 -0700
commita9d6556971a435f71eabf142d8fb814382f3b6ac (patch)
tree4fecce88bbc1bc3259856eb0314d780184de85eb /main/php_ini.c
parent86674b5837bffe4486714f9661620020ee498f3b (diff)
parent176b8d7ca3aef3a172d8e429627c98e0328d02d8 (diff)
downloadphp-git-a9d6556971a435f71eabf142d8fb814382f3b6ac.tar.gz
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: (1132 commits) Micro optimizations for isset/empty Micro optimization for zend_hash_next_index_insert_new() Fix array_keys() on $GLOBALS Fix procedural finfo calls in methods Fix allocator for 64bit zend_long with 32bit long Use intptr_t for zend_intptr_t typedef Fix format strings in zend_alloc Drop zend_long64 in favor of int64_t Removed deprecated fields NEWS cleanup NEWS removing the NEWS entry as we had to revert this fix for now Revert "Merge branch 'PHP-5.5' into PHP-5.6" Revert "fix TS build" Revert "Merge branch 'PHP-5.4' into PHP-5.5" Revert "Bug #67965: Fix blocking behavior in non-blocking crypto streams" Revert "Bug #41631: Fix regression from first attempt (6569db8)" NEWS Fixed Bug #65171 imagescale() fails Fixed bug #68234 ...
Diffstat (limited to 'main/php_ini.c')
-rw-r--r--main/php_ini.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/main/php_ini.c b/main/php_ini.c
index 54944483d2..c90dc9f29f 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -83,9 +83,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
uint display_string_length, 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 && ini_entry->orig_value->val[0]) {
+ display_string = ini_entry->orig_value->val;
+ display_string_length = ini_entry->orig_value->len;
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -96,9 +96,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 && ini_entry->value->val[0]) {
+ display_string = ini_entry->value->val;
+ display_string_length = ini_entry->value->len;
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -132,14 +132,14 @@ static int php_ini_displayer(zval *el, void *arg TSRMLS_DC)
if (!sapi_module.phpinfo_as_text) {
PUTS("<tr>");
PUTS("<td class=\"e\">");
- PHPWRITE(ini_entry->name, ini_entry->name_length);
+ PHPWRITE(ini_entry->name->val, ini_entry->name->len);
PUTS("</td><td class=\"v\">");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
PUTS("</td><td class=\"v\">");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
PUTS("</td></tr>\n");
} else {
- PHPWRITE(ini_entry->name, ini_entry->name_length);
+ PHPWRITE(ini_entry->name->val, ini_entry->name->len);
PUTS(" => ");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
PUTS(" => ");
@@ -200,7 +200,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
zend_hash_destroy(Z_ARRVAL_P(zvalue));
free(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* Reset / free active_ini_sectin global */
@@ -233,17 +233,17 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
/* PHP and Zend extensions are not added into configuration hash! */
if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */
- extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2));
+ extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
zend_llist_add_element(&extension_lists.functions, &extension_name);
} else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
- extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2));
+ extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
zend_llist_add_element(&extension_lists.engine, &extension_name);
/* All other entries are added into either configuration_hash or active ini section array */
} else {
/* Store in active hash */
entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2);
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
}
break;
@@ -267,12 +267,12 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
}
/* arg3 is possible option offset name */
- if (arg3 && Z_STRSIZE_P(arg3) > 0) {
+ if (arg3 && Z_STRLEN_P(arg3) > 0) {
entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2);
} else {
entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2);
}
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
break;
@@ -287,7 +287,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) {
key = Z_STRVAL_P(arg1);
key = key + sizeof("PATH") - 1;
- key_len = Z_STRSIZE_P(arg1) - sizeof("PATH") + 1;
+ key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1;
is_special_section = 1;
has_per_dir_config = 1;
@@ -298,7 +298,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
} else if (!strncasecmp(Z_STRVAL_P(arg1), "HOST", sizeof("HOST") - 1)) {
key = Z_STRVAL_P(arg1);
key = key + sizeof("HOST") - 1;
- key_len = Z_STRSIZE_P(arg1) - sizeof("HOST") + 1;
+ key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1;
is_special_section = 1;
has_per_host_config = 1;
zend_str_tolower(key, key_len); /* host names are case-insensitive. */
@@ -545,7 +545,7 @@ 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]) {
- php_stat_t statbuf;
+ zend_stat_t statbuf;
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
@@ -593,12 +593,12 @@ int php_init_config(TSRMLS_D)
{
zval tmp;
- ZVAL_NEW_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1));
+ 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 (php_ini_opened_path) {
efree(php_ini_opened_path);
}
- php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRSIZE(tmp));
+ php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
}
}
@@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D)
if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
struct dirent **namelist;
int ndir, i;
- php_stat_t sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
char *p;
zend_file_handle fh2;
@@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D)
*/
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC)
{
- php_stat_t sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
zend_file_handle fh;
@@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
{
zend_string *str;
zval *data;
- zend_uint_t num_index;
+ zend_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);
@@ -786,7 +786,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
zend_hash_move_forward(source_hash)
) {
data = zend_hash_get_current_data(source_hash);
- zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRSIZE_P(data), modify_type, stage, 0 TSRMLS_CC);
+ zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0 TSRMLS_CC);
}
}
/* }}} */
@@ -867,15 +867,23 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR
/* {{{ cfg_get_entry
*/
+PHPAPI zval *cfg_get_entry_ex(zend_string *name)
+{
+ return zend_hash_find(&configuration_hash, name);
+}
+/* }}} */
+
+/* {{{ cfg_get_entry
+ */
PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
{
return zend_hash_str_find(&configuration_hash, name, name_length);
}
/* }}} */
-/* {{{ cfg_get_int
+/* {{{ cfg_get_long
*/
-PHPAPI int cfg_get_int(const char *varname, zend_int_t *result)
+PHPAPI int cfg_get_long(const char *varname, zend_long *result)
{
zval *tmp, var;
@@ -884,8 +892,8 @@ PHPAPI int cfg_get_int(const char *varname, zend_int_t *result)
return FAILURE;
}
ZVAL_DUP(&var, tmp);
- convert_to_int(&var);
- *result = Z_IVAL(var);
+ convert_to_long(&var);
+ *result = Z_LVAL(var);
return SUCCESS;
}
/* }}} */