summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c280
1 files changed, 146 insertions, 134 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index a00b05d44d..5bcd3d3386 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -99,7 +99,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef INADDR_NONE
-#define INADDR_NONE ((php_uint_t) -1)
+#define INADDR_NONE ((zend_ulong) -1)
#endif
#include "zend_globals.h"
@@ -3545,28 +3545,29 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
BG(incomplete_class) = incomplete_class_entry = php_create_incomplete_class(TSRMLS_C);
- REGISTER_INT_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("CONNECTION_TIMEOUT", PHP_CONNECTION_TIMEOUT, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_INT_CONSTANT("INI_USER", ZEND_INI_USER, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("INI_PERDIR", ZEND_INI_PERDIR, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("INI_SYSTEM", ZEND_INI_SYSTEM, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("INI_ALL", ZEND_INI_ALL, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_INT_CONSTANT("INI_SCANNER_NORMAL", ZEND_INI_SCANNER_NORMAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("INI_SCANNER_RAW", ZEND_INI_SCANNER_RAW, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_INT_CONSTANT("PHP_URL_SCHEME", PHP_URL_SCHEME, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_HOST", PHP_URL_HOST, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_PORT", PHP_URL_PORT, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_USER", PHP_URL_USER, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_PASS", PHP_URL_PASS, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_PATH", PHP_URL_PATH, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_QUERY", PHP_URL_QUERY, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_URL_FRAGMENT", PHP_URL_FRAGMENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_QUERY_RFC1738", PHP_QUERY_RFC1738, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_QUERY_RFC3986", PHP_QUERY_RFC3986, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CONNECTION_TIMEOUT", PHP_CONNECTION_TIMEOUT, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("INI_USER", ZEND_INI_USER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_PERDIR", ZEND_INI_PERDIR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SYSTEM", ZEND_INI_SYSTEM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_ALL", ZEND_INI_ALL, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("INI_SCANNER_NORMAL", ZEND_INI_SCANNER_NORMAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SCANNER_RAW", ZEND_INI_SCANNER_RAW, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SCANNER_TYPED", ZEND_INI_SCANNER_TYPED, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("PHP_URL_SCHEME", PHP_URL_SCHEME, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_HOST", PHP_URL_HOST, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_PORT", PHP_URL_PORT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_USER", PHP_URL_USER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_PASS", PHP_URL_PASS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_PATH", PHP_URL_PATH, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_QUERY", PHP_URL_QUERY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_URL_FRAGMENT", PHP_URL_FRAGMENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_QUERY_RFC1738", PHP_QUERY_RFC1738, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_QUERY_RFC3986", PHP_QUERY_RFC3986, CONST_CS | CONST_PERSISTENT);
#define REGISTER_MATH_CONSTANT(x) REGISTER_DOUBLE_CONSTANT(#x, x, CONST_CS | CONST_PERSISTENT)
REGISTER_MATH_CONSTANT(M_E);
@@ -3589,10 +3590,10 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
REGISTER_DOUBLE_CONSTANT("INF", php_get_inf(), CONST_CS | CONST_PERSISTENT);
REGISTER_DOUBLE_CONSTANT("NAN", php_get_nan(), CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_ROUND_HALF_UP", PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_ROUND_HALF_DOWN", PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_ROUND_HALF_EVEN", PHP_ROUND_HALF_EVEN, CONST_CS | CONST_PERSISTENT);
- REGISTER_INT_CONSTANT("PHP_ROUND_HALF_ODD", PHP_ROUND_HALF_ODD, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_UP", PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_DOWN", PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_EVEN", PHP_ROUND_HALF_EVEN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_ODD", PHP_ROUND_HALF_ODD, CONST_CS | CONST_PERSISTENT);
#if ENABLE_TEST_CLASS
test_class_startup();
@@ -3840,7 +3841,8 @@ PHP_FUNCTION(constant)
PHP_NAMED_FUNCTION(php_inet_ntop)
{
char *address;
- int address_len, af = AF_INET;
+ size_t address_len;
+ int af = AF_INET;
char buffer[40];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &address, &address_len) == FAILURE) {
@@ -3874,7 +3876,7 @@ PHP_NAMED_FUNCTION(php_inet_pton)
{
int ret, af = AF_INET;
char *address;
- int address_len;
+ size_t address_len;
char buffer[17];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &address, &address_len) == FAILURE) {
@@ -3910,11 +3912,11 @@ PHP_NAMED_FUNCTION(php_inet_pton)
PHP_FUNCTION(ip2long)
{
char *addr;
- int addr_len;
+ size_t addr_len;
#ifdef HAVE_INET_PTON
struct in_addr ip;
#else
- php_uint_t ip;
+ zend_ulong ip;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) {
@@ -3925,7 +3927,7 @@ PHP_FUNCTION(ip2long)
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
RETURN_FALSE;
}
- RETURN_INT(ntohl(ip.s_addr));
+ RETURN_LONG(ntohl(ip.s_addr));
#else
if (addr_len == 0 || (ip = inet_addr(addr)) == INADDR_NONE) {
/* The only special case when we should return -1 ourselves,
@@ -3934,11 +3936,11 @@ PHP_FUNCTION(ip2long)
if (addr_len == sizeof("255.255.255.255") - 1 &&
!memcmp(addr, "255.255.255.255", sizeof("255.255.255.255") - 1)
) {
- RETURN_INT(0xFFFFFFFF);
+ RETURN_LONG(0xFFFFFFFF);
}
RETURN_FALSE;
}
- RETURN_INT(ntohl(ip));
+ RETURN_LONG(ntohl(ip));
#endif
}
/* }}} */
@@ -3949,8 +3951,8 @@ PHP_FUNCTION(long2ip)
{
/* "It's a long but it's not, PHP ints are signed */
char *ip;
- int ip_len;
- php_uint_t n;
+ size_t ip_len;
+ zend_ulong n;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
@@ -3984,7 +3986,7 @@ PHP_FUNCTION(long2ip)
PHP_FUNCTION(getenv)
{
char *ptr, *str;
- int str_len;
+ size_t str_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
RETURN_FALSE;
@@ -4047,7 +4049,7 @@ PHP_FUNCTION(getenv)
PHP_FUNCTION(putenv)
{
char *setting;
- int setting_len;
+ size_t setting_len;
char *p, **env;
putenv_entry pe;
#ifdef PHP_WIN32
@@ -4176,8 +4178,9 @@ static int parse_opts(char * opts, opt_struct ** result)
{
opt_struct * paras = NULL;
unsigned int i, count = 0;
+ unsigned int opts_len = (unsigned int)strlen(opts);
- for (i = 0; i < strlen(opts); i++) {
+ for (i = 0; i < opts_len; i++) {
if ((opts[i] >= 48 && opts[i] <= 57) ||
(opts[i] >= 65 && opts[i] <= 90) ||
(opts[i] >= 97 && opts[i] <= 122)
@@ -4216,7 +4219,8 @@ PHP_FUNCTION(getopt)
char *options = NULL, **argv = NULL;
char opt[2] = { '\0' };
char *optname;
- int argc = 0, options_len = 0, len, o;
+ int argc = 0, len, o;
+ size_t options_len = 0;
char *php_optarg = NULL;
int php_optind = 1;
zval val, *args = NULL, *p_longopts = NULL;
@@ -4252,7 +4256,7 @@ PHP_FUNCTION(getopt)
argv[pos++] = estrdup(arg_str->val);
- STR_RELEASE(arg_str);
+ zend_string_release(arg_str);
} ZEND_HASH_FOREACH_END();
/* The C Standard requires argv[argc] to be NULL - this might
@@ -4297,7 +4301,7 @@ PHP_FUNCTION(getopt)
opts->opt_char = 0;
opts++;
- STR_RELEASE(arg_str);
+ zend_string_release(arg_str);
} ZEND_HASH_FOREACH_END();
} else {
opts = (opt_struct*) erealloc(opts, sizeof(opt_struct) * (len + 1));
@@ -4342,7 +4346,7 @@ PHP_FUNCTION(getopt)
/* Add this option / argument pair to the result hash. */
optname_len = strlen(optname);
- if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_INT) {
+ if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_LONG) {
/* numeric string */
int optname_int = atoi(optname);
if ((args = zend_hash_index_find(HASH_OF(return_value), optname_int)) != NULL) {
@@ -4386,9 +4390,9 @@ PHP_FUNCTION(flush)
Delay for a given number of seconds */
PHP_FUNCTION(sleep)
{
- php_int_t num;
+ zend_long num;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
RETURN_FALSE;
}
if (num < 0) {
@@ -4396,7 +4400,7 @@ PHP_FUNCTION(sleep)
RETURN_FALSE;
}
#ifdef PHP_SLEEP_NON_VOID
- RETURN_INT(php_sleep(num));
+ RETURN_LONG(php_sleep(num));
#else
php_sleep(num);
#endif
@@ -4409,9 +4413,9 @@ PHP_FUNCTION(sleep)
PHP_FUNCTION(usleep)
{
#if HAVE_USLEEP
- php_int_t num;
+ zend_long num;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
return;
}
if (num < 0) {
@@ -4428,10 +4432,10 @@ PHP_FUNCTION(usleep)
Delay for a number of seconds and nano seconds */
PHP_FUNCTION(time_nanosleep)
{
- php_int_t tv_sec, tv_nsec;
+ zend_long tv_sec, tv_nsec;
struct timespec php_req, php_rem;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &tv_sec, &tv_nsec) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &tv_sec, &tv_nsec) == FAILURE) {
return;
}
@@ -4450,8 +4454,8 @@ PHP_FUNCTION(time_nanosleep)
RETURN_TRUE;
} else if (errno == EINTR) {
array_init(return_value);
- add_assoc_int_ex(return_value, "seconds", sizeof("seconds"), php_rem.tv_sec);
- add_assoc_int_ex(return_value, "nanoseconds", sizeof("nanoseconds"), php_rem.tv_nsec);
+ add_assoc_long_ex(return_value, "seconds", sizeof("seconds"), php_rem.tv_sec);
+ add_assoc_long_ex(return_value, "nanoseconds", sizeof("nanoseconds"), php_rem.tv_nsec);
return;
} else if (errno == EINVAL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "nanoseconds was not in the range 0 to 999 999 999 or seconds was negative");
@@ -4525,9 +4529,9 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
if (Z_TYPE_P(entry) == IS_STRING) {
if (hash_key->key) {
- add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, STR_COPY(Z_STR_P(entry)));
+ add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, zend_string_copy(Z_STR_P(entry)));
} else {
- add_index_str(retval, hash_key->h, STR_COPY(Z_STR_P(entry)));
+ add_index_str(retval, hash_key->h, zend_string_copy(Z_STR_P(entry)));
}
} else if (Z_TYPE_P(entry) == IS_ARRAY) {
array_init(&tmp);
@@ -4543,7 +4547,7 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
PHP_FUNCTION(get_cfg_var)
{
char *varname;
- int varname_len;
+ size_t varname_len;
zval *retval;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &varname, &varname_len) == FAILURE) {
@@ -4624,11 +4628,11 @@ error options:
PHP_FUNCTION(error_log)
{
char *message, *opt = NULL, *headers = NULL;
- int message_len, opt_len = 0, headers_len = 0;
+ size_t message_len, opt_len = 0, headers_len = 0;
int opt_err = 0, argc = ZEND_NUM_ARGS();
- php_int_t erropt = 0;
+ zend_long erropt = 0;
- if (zend_parse_parameters(argc TSRMLS_CC, "s|ips", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|lps", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) {
return;
}
@@ -4703,16 +4707,17 @@ PHP_FUNCTION(error_get_last)
if (PG(last_error_message)) {
array_init(return_value);
- add_assoc_int_ex(return_value, "type", sizeof("type")-1, PG(last_error_type));
+ add_assoc_long_ex(return_value, "type", sizeof("type")-1, PG(last_error_type));
add_assoc_string_ex(return_value, "message", sizeof("message")-1, PG(last_error_message));
add_assoc_string_ex(return_value, "file", sizeof("file")-1, PG(last_error_file)?PG(last_error_file):"-");
- add_assoc_int_ex(return_value, "line", sizeof("line")-1, PG(last_error_lineno));
+ add_assoc_long_ex(return_value, "line", sizeof("line")-1, PG(last_error_lineno));
}
}
/* }}} */
/* {{{ proto mixed call_user_func(mixed function_name [, mixed parmeter] [, mixed ...])
- Call a user function which is the first parameter */
+ Call a user function which is the first parameter
+ Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
PHP_FUNCTION(call_user_func)
{
zval retval;
@@ -4739,7 +4744,8 @@ PHP_FUNCTION(call_user_func)
/* }}} */
/* {{{ proto mixed call_user_func_array(string function_name, array parameters)
- Call a user function which is the first parameter with the arguments contained in array */
+ Call a user function which is the first parameter with the arguments contained in array
+ Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
PHP_FUNCTION(call_user_func_array)
{
zval *params, retval;
@@ -4780,15 +4786,15 @@ PHP_FUNCTION(forward_static_call)
return;
}
- if (!EG(current_execute_data)->prev_execute_data->func->common.scope) {
+ if (!EX(prev_execute_data)->func->common.scope) {
zend_error(E_ERROR, "Cannot call forward_static_call() when no class scope is active");
}
fci.retval = &retval;
- if (EG(current_execute_data)->called_scope &&
- instanceof_function(EG(current_execute_data)->called_scope, fci_cache.calling_scope TSRMLS_CC)) {
- fci_cache.called_scope = EG(current_execute_data)->called_scope;
+ if (EX(called_scope) &&
+ instanceof_function(EX(called_scope), fci_cache.calling_scope TSRMLS_CC)) {
+ fci_cache.called_scope = EX(called_scope);
}
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@@ -4812,9 +4818,9 @@ PHP_FUNCTION(forward_static_call_array)
zend_fcall_info_args(&fci, params TSRMLS_CC);
fci.retval = &retval;
- if (EG(current_execute_data)->called_scope &&
- instanceof_function(EG(current_execute_data)->called_scope, fci_cache.calling_scope TSRMLS_CC)) {
- fci_cache.called_scope = EG(current_execute_data)->called_scope;
+ if (EX(called_scope) &&
+ instanceof_function(EX(called_scope), fci_cache.calling_scope TSRMLS_CC)) {
+ fci_cache.called_scope = EX(called_scope);
}
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@@ -4856,14 +4862,16 @@ static int user_shutdown_function_call(zval *zv TSRMLS_DC) /* {{{ */
zend_string *function_name;
if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, &function_name TSRMLS_CC)) {
- php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name->val);
if (function_name) {
- STR_RELEASE(function_name);
+ php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name->val);
+ zend_string_release(function_name);
+ } else {
+ php_error(E_WARNING, "(Registered shutdown functions) Unable to call - function does not exist");
}
return 0;
}
if (function_name) {
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
}
if (call_user_function(EG(function_table), NULL,
@@ -4937,11 +4945,11 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_
} else if (Z_TYPE_P(func1) == IS_ARRAY && Z_TYPE_P(func2) == IS_ARRAY) {
zval result;
zend_compare_arrays(&result, func1, func2 TSRMLS_CC);
- ret = (Z_IVAL(result) == 0);
+ ret = (Z_LVAL(result) == 0);
} else if (Z_TYPE_P(func1) == IS_OBJECT && Z_TYPE_P(func2) == IS_OBJECT) {
zval result;
zend_compare_objects(&result, func1, func2 TSRMLS_CC);
- ret = (Z_IVAL(result) == 0);
+ ret = (Z_LVAL(result) == 0);
} else {
ret = 0;
}
@@ -5004,7 +5012,11 @@ PHP_FUNCTION(register_shutdown_function)
/* Prevent entering of anything but valid callback (syntax check only!) */
if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, &callback_name TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name->val);
+ if (callback_name) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name->val);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback passed");
+ }
efree(shutdown_function_entry.arguments);
RETVAL_FALSE;
} else {
@@ -5019,7 +5031,7 @@ PHP_FUNCTION(register_shutdown_function)
zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry));
}
if (callback_name) {
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
}
}
/* }}} */
@@ -5071,7 +5083,7 @@ ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highl
PHP_FUNCTION(highlight_file)
{
char *filename;
- int filename_len, ret;
+ size_t filename_len, ret;
zend_syntax_highlighter_ini syntax_highlighter_ini;
zend_bool i = 0;
@@ -5112,9 +5124,9 @@ PHP_FUNCTION(highlight_file)
PHP_FUNCTION(php_strip_whitespace)
{
char *filename;
- int filename_len;
+ size_t filename_len;
zend_lex_state original_lex_state;
- zend_file_handle file_handle = {0};
+ zend_file_handle file_handle = {{0}};
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
RETURN_FALSE;
@@ -5194,7 +5206,7 @@ PHP_FUNCTION(highlight_string)
PHP_FUNCTION(ini_get)
{
char *varname, *str;
- int varname_len;
+ size_t varname_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &varname, &varname_len) == FAILURE) {
return;
@@ -5229,27 +5241,30 @@ static int php_ini_get_option(zval *zv TSRMLS_DC, int num_args, va_list args, ze
array_init(&option);
if (ini_entry->orig_value) {
- add_assoc_stringl(&option, "global_value", ini_entry->orig_value, ini_entry->orig_value_length);
+ add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->orig_value));
} else if (ini_entry->value) {
- add_assoc_stringl(&option, "global_value", ini_entry->value, ini_entry->value_length);
+ add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->value));
} else {
add_assoc_null(&option, "global_value");
}
if (ini_entry->value) {
- add_assoc_stringl(&option, "local_value", ini_entry->value, ini_entry->value_length);
+ add_assoc_str(&option, "local_value", zend_string_copy(ini_entry->value));
} else {
add_assoc_null(&option, "local_value");
}
- add_assoc_int(&option, "access", ini_entry->modifiable);
+ add_assoc_long(&option, "access", ini_entry->modifiable);
- add_assoc_zval_ex(ini_array, ini_entry->name, ini_entry->name_length, &option);
+ zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &option);
} else {
if (ini_entry->value) {
- add_assoc_stringl(ini_array, ini_entry->name, ini_entry->value, ini_entry->value_length);
+ zval zv;
+
+ ZVAL_STR_COPY(&zv, ini_entry->value);
+ zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &zv);
} else {
- add_assoc_null(ini_array, ini_entry->name);
+ zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &EG(uninitialized_zval));
}
}
}
@@ -5262,7 +5277,7 @@ static int php_ini_get_option(zval *zv TSRMLS_DC, int num_args, va_list args, ze
PHP_FUNCTION(ini_get_all)
{
char *extname = NULL;
- int extname_len = 0, extnumber = 0;
+ size_t extname_len = 0, extnumber = 0;
zend_module_entry *module;
zend_bool details = 1;
@@ -5300,11 +5315,10 @@ static int php_ini_check_path(char *option_name, int option_len, char *new_optio
PHP_FUNCTION(ini_set)
{
zend_string *varname;
- char *new_value;
- int new_value_len;
+ zend_string *new_value;
char *old_value;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss", &varname, &new_value, &new_value_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &varname, &new_value) == FAILURE) {
return;
}
@@ -5326,14 +5340,14 @@ PHP_FUNCTION(ini_set)
_CHECK_PATH(varname->val, varname->len, "mail.log") ||
_CHECK_PATH(varname->val, varname->len, "java.library.path") ||
_CHECK_PATH(varname->val, varname->len, "vpopmail.directory")) {
- if (php_check_open_basedir(new_value TSRMLS_CC)) {
+ if (php_check_open_basedir(new_value->val TSRMLS_CC)) {
zval_dtor(return_value);
RETURN_FALSE;
}
}
}
- if (zend_alter_ini_entry_ex(varname, new_value, new_value_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
+ if (zend_alter_ini_entry_ex(varname, new_value, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
@@ -5358,12 +5372,11 @@ PHP_FUNCTION(ini_restore)
Sets the include_path configuration option */
PHP_FUNCTION(set_include_path)
{
- char *new_value;
- int new_value_len;
+ zend_string *new_value;
char *old_value;
zend_string *key;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &new_value, &new_value_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &new_value) == FAILURE) {
return;
}
@@ -5375,13 +5388,13 @@ PHP_FUNCTION(set_include_path)
RETVAL_FALSE;
}
- key = STR_INIT("include_path", sizeof("include_path") - 1, 0);
- if (zend_alter_ini_entry_ex(key, new_value, new_value_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
- STR_RELEASE(key);
+ key = zend_string_init("include_path", sizeof("include_path") - 1, 0);
+ if (zend_alter_ini_entry_ex(key, new_value, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
+ zend_string_release(key);
zval_dtor(return_value);
RETURN_FALSE;
}
- STR_RELEASE(key);
+ zend_string_release(key);
}
/* }}} */
@@ -5414,9 +5427,9 @@ PHP_FUNCTION(restore_include_path)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- key = STR_INIT("include_path", sizeof("include_path")-1, 0);
+ key = zend_string_init("include_path", sizeof("include_path")-1, 0);
zend_restore_ini_entry(key, PHP_INI_STAGE_RUNTIME);
- STR_FREE(key);
+ zend_string_free(key);
}
/* }}} */
@@ -5450,7 +5463,7 @@ PHP_FUNCTION(print_r)
Returns true if client disconnected */
PHP_FUNCTION(connection_aborted)
{
- RETURN_INT(PG(connection_status) & PHP_CONNECTION_ABORTED);
+ RETURN_LONG(PG(connection_status) & PHP_CONNECTION_ABORTED);
}
/* }}} */
@@ -5458,7 +5471,7 @@ PHP_FUNCTION(connection_aborted)
Returns the connection status bitfield */
PHP_FUNCTION(connection_status)
{
- RETURN_INT(PG(connection_status));
+ RETURN_LONG(PG(connection_status));
}
/* }}} */
@@ -5466,23 +5479,22 @@ PHP_FUNCTION(connection_status)
Set whether we want to ignore a user abort event or not */
PHP_FUNCTION(ignore_user_abort)
{
- char *arg = NULL;
- int arg_len = 0;
+ zend_string *arg = NULL;
int old_setting;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &arg) == FAILURE) {
return;
}
old_setting = PG(ignore_user_abort);
if (arg) {
- zend_string *key = STR_INIT("ignore_user_abort", sizeof("ignore_user_abort"), 0);
- zend_alter_ini_entry_ex(key, arg, arg_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string *key = zend_string_init("ignore_user_abort", sizeof("ignore_user_abort"), 0);
+ zend_alter_ini_entry_ex(key, arg, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ zend_string_release(key);
}
- RETURN_INT(old_setting);
+ RETURN_LONG(old_setting);
}
/* }}} */
@@ -5492,7 +5504,7 @@ PHP_FUNCTION(ignore_user_abort)
PHP_FUNCTION(getservbyname)
{
char *name, *proto;
- int name_len, proto_len;
+ size_t name_len, proto_len;
struct servent *serv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &proto, &proto_len) == FAILURE) {
@@ -5514,7 +5526,7 @@ PHP_FUNCTION(getservbyname)
RETURN_FALSE;
}
- RETURN_INT(ntohs(serv->s_port));
+ RETURN_LONG(ntohs(serv->s_port));
}
/* }}} */
#endif
@@ -5525,11 +5537,11 @@ PHP_FUNCTION(getservbyname)
PHP_FUNCTION(getservbyport)
{
char *proto;
- int proto_len;
- php_int_t port;
+ size_t proto_len;
+ zend_long port;
struct servent *serv;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "is", &port, &proto, &proto_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &port, &proto, &proto_len) == FAILURE) {
return;
}
@@ -5550,7 +5562,7 @@ PHP_FUNCTION(getservbyport)
PHP_FUNCTION(getprotobyname)
{
char *name;
- int name_len;
+ size_t name_len;
struct protoent *ent;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
@@ -5563,7 +5575,7 @@ PHP_FUNCTION(getprotobyname)
RETURN_FALSE;
}
- RETURN_INT(ent->p_proto);
+ RETURN_LONG(ent->p_proto);
}
/* }}} */
#endif
@@ -5573,10 +5585,10 @@ PHP_FUNCTION(getprotobyname)
Returns protocol name associated with protocol number proto */
PHP_FUNCTION(getprotobynumber)
{
- php_int_t proto;
+ zend_long proto;
struct protoent *ent;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &proto) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &proto) == FAILURE) {
return;
}
@@ -5616,10 +5628,10 @@ PHP_FUNCTION(register_tick_function)
if (!zend_is_callable(&tick_fe.arguments[0], 0, &function_name TSRMLS_CC)) {
efree(tick_fe.arguments);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid tick callback '%s' passed", function_name->val);
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
RETURN_FALSE;
} else if (function_name) {
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
}
if (Z_TYPE(tick_fe.arguments[0]) != IS_ARRAY && Z_TYPE(tick_fe.arguments[0]) != IS_OBJECT) {
@@ -5678,7 +5690,7 @@ PHP_FUNCTION(unregister_tick_function)
PHP_FUNCTION(is_uploaded_file)
{
char *path;
- int path_len;
+ size_t path_len;
if (!SG(rfc1867_uploaded_files)) {
RETURN_FALSE;
@@ -5701,7 +5713,7 @@ PHP_FUNCTION(is_uploaded_file)
PHP_FUNCTION(move_uploaded_file)
{
char *path, *new_path;
- int path_len, new_path_len;
+ size_t path_len, new_path_len;
zend_bool successful = 0;
#ifndef PHP_WIN32
@@ -5777,8 +5789,8 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
break;
}
- if (!(Z_STRSIZE_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRSIZE_P(arg1), NULL, NULL, 0) == IS_INT) {
- php_uint_t key = (php_uint_t) zend_atol(Z_STRVAL_P(arg1), Z_STRSIZE_P(arg1));
+ if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
+ zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
array_init(&hash);
find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
@@ -5797,7 +5809,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
ZVAL_DUP(&element, arg2);
- if (arg3 && Z_STRSIZE_P(arg3) > 0) {
+ if (arg3 && Z_STRLEN_P(arg3) > 0) {
zend_symtable_update(Z_ARRVAL_P(find_hash), Z_STR_P(arg3), &element);
} else {
add_next_index_zval(find_hash, &element);
@@ -5837,13 +5849,13 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, zval *arg3,
PHP_FUNCTION(parse_ini_file)
{
char *filename = NULL;
- int filename_len = 0;
+ size_t filename_len = 0;
zend_bool process_sections = 0;
- php_int_t scanner_mode = ZEND_INI_SCANNER_NORMAL;
+ zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_file_handle fh;
zend_ini_parser_cb_t ini_parser_cb;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|bi", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|bl", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) {
RETURN_FALSE;
}
@@ -5878,12 +5890,12 @@ PHP_FUNCTION(parse_ini_file)
PHP_FUNCTION(parse_ini_string)
{
char *string = NULL, *str = NULL;
- int str_len = 0;
+ size_t str_len = 0;
zend_bool process_sections = 0;
- php_int_t scanner_mode = ZEND_INI_SCANNER_NORMAL;
+ zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_ini_parser_cb_t ini_parser_cb;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bi", &str, &str_len, &process_sections, &scanner_mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &str, &str_len, &process_sections, &scanner_mode) == FAILURE) {
RETURN_FALSE;
}