summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2016-12-30 16:06:20 -0800
committerSara Golemon <pollita@php.net>2016-12-30 16:13:14 -0800
commit5c919ee30b7f3a6e345535f52934ac26d714d6a5 (patch)
treea4d25505071a72916292332734c3f451f1e02f0d /ext/standard/basic_functions.c
parentb71b12843c08dafea897f105d791741f2c098827 (diff)
downloadphp-git-5c919ee30b7f3a6e345535f52934ac26d714d6a5.tar.gz
Use new param API in standard/basic_functions
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c251
1 files changed, 144 insertions, 107 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index fa635b1aea..7446a21d1c 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -3868,9 +3868,9 @@ PHP_FUNCTION(constant)
zval *c;
zend_class_entry *scope;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &const_name) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(const_name)
+ ZEND_PARSE_PARAMETERS_END();
scope = zend_get_executed_scope();
c = zend_get_constant_ex(const_name, scope, ZEND_FETCH_CLASS_SILENT);
@@ -3900,9 +3900,9 @@ PHP_NAMED_FUNCTION(php_inet_ntop)
int af = AF_INET;
char buffer[40];
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &address, &address_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(address, address_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
#ifdef HAVE_IPV6
if (address_len == 16) {
@@ -3934,9 +3934,9 @@ PHP_NAMED_FUNCTION(php_inet_pton)
size_t address_len;
char buffer[17];
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &address, &address_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(address, address_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
memset(buffer, 0, sizeof(buffer));
@@ -3974,9 +3974,9 @@ PHP_FUNCTION(ip2long)
zend_ulong ip;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &addr, &addr_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(addr, addr_len)
+ ZEND_PARSE_PARAMETERS_END();
#ifdef HAVE_INET_PTON
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
@@ -4005,14 +4005,18 @@ PHP_FUNCTION(ip2long)
PHP_FUNCTION(long2ip)
{
zend_ulong ip;
+ zend_long sip;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ip) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_LONG(sip)
+ ZEND_PARSE_PARAMETERS_END();
+
+ /* autoboxes on 32bit platforms, but that's expected */
+ ip = (zend_ulong)sip;
myaddr.s_addr = htonl(ip);
#ifdef HAVE_INET_PTON
@@ -4040,9 +4044,11 @@ PHP_FUNCTION(getenv)
size_t str_len;
zend_bool local_only = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sb", &str, &str_len, &local_only) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(str, str_len)
+ Z_PARAM_BOOL(local_only)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (!str) {
array_init(return_value);
@@ -4118,9 +4124,9 @@ PHP_FUNCTION(putenv)
int error_code;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &setting, &setting_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(setting, setting_len)
+ ZEND_PARSE_PARAMETERS_END();
if(setting_len == 0 || setting[0] == '=') {
php_error_docref(NULL, E_WARNING, "Invalid parameter syntax");
@@ -4292,9 +4298,12 @@ PHP_FUNCTION(getopt)
int optname_len = 0;
opt_struct *opts, *orig_opts;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|az/", &options, &options_len, &p_longopts, &zoptind) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_STRING(options, options_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ARRAY(p_longopts)
+ Z_PARAM_ZVAL_DEREF_EX(zoptind, 0, 1)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
/* Init zoptind to 1 */
if (zoptind) {
@@ -4472,9 +4481,10 @@ PHP_FUNCTION(sleep)
{
zend_long num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &num) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_LONG(num)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
if (num < 0) {
php_error_docref(NULL, E_WARNING, "Number of seconds must be greater than or equal to 0");
RETURN_FALSE;
@@ -4495,9 +4505,10 @@ PHP_FUNCTION(usleep)
#if HAVE_USLEEP
zend_long num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &num) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_LONG(num)
+ ZEND_PARSE_PARAMETERS_END();
+
if (num < 0) {
php_error_docref(NULL, E_WARNING, "Number of microseconds must be greater than or equal to 0");
RETURN_FALSE;
@@ -4515,9 +4526,10 @@ PHP_FUNCTION(time_nanosleep)
zend_long tv_sec, tv_nsec;
struct timespec php_req, php_rem;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &tv_sec, &tv_nsec) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_LONG(tv_sec)
+ Z_PARAM_LONG(tv_nsec)
+ ZEND_PARSE_PARAMETERS_END();
if (tv_sec < 0) {
php_error_docref(NULL, E_WARNING, "The seconds value must be greater than 0");
@@ -4553,9 +4565,9 @@ PHP_FUNCTION(time_sleep_until)
struct timeval tm;
struct timespec php_req, php_rem;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &d_ts) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_DOUBLE(d_ts)
+ ZEND_PARSE_PARAMETERS_END();
if (gettimeofday((struct timeval *) &tm, NULL) != 0) {
RETURN_FALSE;
@@ -4630,9 +4642,9 @@ PHP_FUNCTION(get_cfg_var)
size_t varname_len;
zval *retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &varname, &varname_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(varname, varname_len)
+ ZEND_PARSE_PARAMETERS_END();
retval = cfg_get_entry(varname, (uint32_t)varname_len);
@@ -4695,9 +4707,13 @@ PHP_FUNCTION(error_log)
int opt_err = 0, argc = ZEND_NUM_ARGS();
zend_long erropt = 0;
- if (zend_parse_parameters(argc, "s|lps", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 4)
+ Z_PARAM_STRING(message, message_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(erropt)
+ Z_PARAM_PATH(opt, opt_len)
+ Z_PARAM_STRING(headers, headers_len)
+ ZEND_PARSE_PARAMETERS_END();
if (argc > 1) {
opt_err = (int)erropt;
@@ -4863,9 +4879,10 @@ PHP_FUNCTION(forward_static_call)
zend_fcall_info_cache fci_cache;
zend_class_entry *called_scope;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "f*", &fci, &fci_cache, &fci.params, &fci.param_count) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, -1)
+ Z_PARAM_FUNC(fci, fci_cache)
+ Z_PARAM_VARIADIC('*', fci.params, fci.param_count)
+ ZEND_PARSE_PARAMETERS_END();
if (!EX(prev_execute_data)->func->common.scope) {
zend_throw_error(NULL, "Cannot call forward_static_call() when no class scope is active");
@@ -4898,9 +4915,10 @@ PHP_FUNCTION(forward_static_call_array)
zend_fcall_info_cache fci_cache;
zend_class_entry *called_scope;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "fa/", &fci, &fci_cache, &params) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_FUNC(fci, fci_cache)
+ Z_PARAM_ARRAY_EX(params, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
zend_fcall_info_args(&fci, params);
fci.retval = &retval;
@@ -5170,9 +5188,11 @@ PHP_FUNCTION(highlight_file)
zend_syntax_highlighter_ini syntax_highlighter_ini;
zend_bool i = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &filename, &filename_len, &i) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(i)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (php_check_open_basedir(filename)) {
RETURN_FALSE;
@@ -5211,9 +5231,9 @@ PHP_FUNCTION(php_strip_whitespace)
zend_lex_state original_lex_state;
zend_file_handle file_handle;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH(filename, filename_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
php_output_start_default();
@@ -5249,9 +5269,11 @@ PHP_FUNCTION(highlight_string)
zend_bool i = 0;
int old_error_reporting = EG(error_reporting);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &expr, &i) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_ZVAL_DEREF(expr)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(i)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
convert_to_string_ex(expr);
if (i) {
@@ -5292,9 +5314,9 @@ PHP_FUNCTION(ini_get)
char *varname, *str;
size_t varname_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &varname, &varname_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(varname, varname_len)
+ ZEND_PARSE_PARAMETERS_END();
str = zend_ini_string(varname, (uint32_t)varname_len, 0);
@@ -5365,9 +5387,11 @@ PHP_FUNCTION(ini_get_all)
zend_module_entry *module;
zend_bool details = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!b", &extname, &extname_len, &details) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING_EX(extname, extname_len, 1, 0)
+ Z_PARAM_BOOL(details)
+ ZEND_PARSE_PARAMETERS_END();
zend_ini_sort_entries();
@@ -5402,9 +5426,10 @@ PHP_FUNCTION(ini_set)
zend_string *new_value;
char *old_value;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &varname, &new_value) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STR(varname)
+ Z_PARAM_STR(new_value)
+ ZEND_PARSE_PARAMETERS_END();
old_value = zend_ini_string(ZSTR_VAL(varname), (int)ZSTR_LEN(varname), 0);
@@ -5444,9 +5469,9 @@ PHP_FUNCTION(ini_restore)
{
zend_string *varname;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &varname) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(varname)
+ ZEND_PARSE_PARAMETERS_END();
zend_restore_ini_entry(varname, PHP_INI_STAGE_RUNTIME);
}
@@ -5460,9 +5485,9 @@ PHP_FUNCTION(set_include_path)
char *old_value;
zend_string *key;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "P", &new_value) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH_STR(new_value)
+ ZEND_PARSE_PARAMETERS_END();
old_value = zend_ini_string("include_path", sizeof("include_path") - 1, 0);
/* copy to return here, because alter might free it! */
@@ -5488,7 +5513,7 @@ PHP_FUNCTION(get_include_path)
{
char *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE) {
return;
}
@@ -5508,7 +5533,7 @@ PHP_FUNCTION(restore_include_path)
{
zend_string *key;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) {
+ if (zend_parse_parameters_none() == FAILURE) {
return;
}
key = zend_string_init("include_path", sizeof("include_path")-1, 0);
@@ -5524,9 +5549,11 @@ PHP_FUNCTION(print_r)
zval *var;
zend_bool do_return = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &var, &do_return) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_ZVAL_DEREF(var)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(do_return)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (do_return) {
RETURN_STR(zend_print_zval_r_to_str(var, 0));
@@ -5560,9 +5587,10 @@ PHP_FUNCTION(ignore_user_abort)
zend_bool arg = 0;
int old_setting;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &arg) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(arg)
+ ZEND_PARSE_PARAMETERS_END();
old_setting = (unsigned short)PG(ignore_user_abort);
@@ -5585,9 +5613,10 @@ PHP_FUNCTION(getservbyname)
size_t name_len, proto_len;
struct servent *serv;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &proto, &proto_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(name, name_len)
+ Z_PARAM_STRING(proto, proto_len)
+ ZEND_PARSE_PARAMETERS_END();
/* empty string behaves like NULL on windows implementation of
@@ -5619,9 +5648,10 @@ PHP_FUNCTION(getservbyport)
zend_long port;
struct servent *serv;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &port, &proto, &proto_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_LONG(port)
+ Z_PARAM_STRING(proto, proto_len)
+ ZEND_PARSE_PARAMETERS_END();
serv = getservbyport(htons((unsigned short) port), proto);
@@ -5643,9 +5673,9 @@ PHP_FUNCTION(getprotobyname)
size_t name_len;
struct protoent *ent;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(name, name_len)
+ ZEND_PARSE_PARAMETERS_END();
ent = getprotobyname(name);
@@ -5666,9 +5696,9 @@ PHP_FUNCTION(getprotobynumber)
zend_long proto;
struct protoent *ent;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &proto) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_LONG(proto)
+ ZEND_PARSE_PARAMETERS_END();
ent = getprotobynumber((int)proto);
@@ -5743,9 +5773,9 @@ PHP_FUNCTION(unregister_tick_function)
zval *function;
user_tick_function_entry tick_fe;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &function) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_ZVAL_DEREF_EX(function, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
if (!BG(user_tick_functions)) {
return;
@@ -5774,9 +5804,9 @@ PHP_FUNCTION(is_uploaded_file)
RETURN_FALSE;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(path, path_len)
+ ZEND_PARSE_PARAMETERS_END();
if (zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) {
RETURN_TRUE;
@@ -5802,9 +5832,10 @@ PHP_FUNCTION(move_uploaded_file)
RETURN_FALSE;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sp", &path, &path_len, &new_path, &new_path_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(path, path_len)
+ Z_PARAM_PATH(new_path, new_path_len)
+ ZEND_PARSE_PARAMETERS_END();
if (!zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) {
RETURN_FALSE;
@@ -5930,9 +5961,12 @@ PHP_FUNCTION(parse_ini_file)
zend_file_handle fh;
zend_ini_parser_cb_t ini_parser_cb;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|bl", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(process_sections)
+ Z_PARAM_LONG(scanner_mode)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (filename_len == 0) {
php_error_docref(NULL, E_WARNING, "Filename cannot be empty!");
@@ -5970,9 +6004,12 @@ PHP_FUNCTION(parse_ini_string)
zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_ini_parser_cb_t ini_parser_cb;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|bl", &str, &str_len, &process_sections, &scanner_mode) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_STRING(str, str_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(process_sections)
+ Z_PARAM_LONG(scanner_mode)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (INT_MAX - str_len < ZEND_MMAP_AHEAD) {
RETVAL_FALSE;