Use new param API in standard

This commit is contained in:
Sara Golemon 2016-12-30 18:03:33 -08:00
parent 2ea5b64d9a
commit 07959c1cae
11 changed files with 125 additions and 94 deletions

View file

@ -457,9 +457,11 @@ PHP_FUNCTION(get_browser)
bdata = &global_bdata;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!b", &agent_name, &agent_name_len, &return_array) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
Z_PARAM_STRING_EX(agent_name, agent_name_len, 1, 0)
Z_PARAM_BOOL(return_array)
ZEND_PARSE_PARAMETERS_END();
if (agent_name == NULL) {
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&

View file

@ -274,9 +274,11 @@ PHP_FUNCTION(convert_cyr_string)
size_t input_len, fr_cs_len, to_cs_len;
zend_string *str;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &input, &input_len, &fr_cs, &fr_cs_len, &to_cs, &to_cs_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_STRING(input, input_len)
Z_PARAM_STRING(fr_cs, fr_cs_len)
Z_PARAM_STRING(to_cs, to_cs_len)
ZEND_PARSE_PARAMETERS_END();
str = zend_string_init(input, input_len, 0);

View file

@ -92,9 +92,10 @@ PHP_FUNCTION(strptime)
struct tm parsed_time;
char *unparsed_part;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &ts, &ts_length, &format, &format_length) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(ts, ts_length)
Z_PARAM_STRING(format, format_length)
ZEND_PARSE_PARAMETERS_END();
memset(&parsed_time, 0, sizeof(parsed_time));

View file

@ -53,9 +53,9 @@ PHPAPI PHP_FUNCTION(dl)
char *filename;
size_t filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(filename, filename_len)
ZEND_PARSE_PARAMETERS_END();
if (!PG(enable_dl)) {
php_error_docref(NULL, E_WARNING, "Dynamically loaded extensions aren't enabled");

View file

@ -151,9 +151,9 @@ PHP_FUNCTION(gethostbyaddr)
size_t addr_len;
zend_string *hostname;
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();
hostname = php_gethostbyaddr(addr);
@ -212,9 +212,9 @@ PHP_FUNCTION(gethostbyname)
char *hostname;
size_t hostname_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hostname, &hostname_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(hostname, hostname_len)
ZEND_PARSE_PARAMETERS_END();
if(hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
@ -236,9 +236,9 @@ PHP_FUNCTION(gethostbynamel)
struct in_addr in;
int i;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hostname, &hostname_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(hostname, hostname_len)
ZEND_PARSE_PARAMETERS_END();
if(hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
@ -363,9 +363,11 @@ PHP_FUNCTION(dns_check_record)
struct __res_state *handle = &state;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &hostname, &hostname_len, &rectype, &rectype_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(hostname, hostname_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(rectype, rectype_len)
ZEND_PARSE_PARAMETERS_END();
if (hostname_len == 0) {
php_error_docref(NULL, E_WARNING, "Host cannot be empty");
@ -780,10 +782,14 @@ PHP_FUNCTION(dns_get_record)
int type, first_query = 1, store_results = 1;
zend_bool raw = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz/!z/!b",
&hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 5)
Z_PARAM_STRING(hostname, hostname_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(type_param)
Z_PARAM_ZVAL_DEREF_EX(authns, 1, 1)
Z_PARAM_ZVAL_DEREF_EX(addtl, 1, 1)
Z_PARAM_BOOL(raw)
ZEND_PARSE_PARAMETERS_END();
if (authns) {
zval_dtor(authns);
@ -1008,9 +1014,12 @@ PHP_FUNCTION(dns_get_mx)
struct __res_state *handle = &state;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz/|z/", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STRING(hostname, hostname_len)
Z_PARAM_ZVAL_DEREF_EX(mx_list, 0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL_DEREF_EX(weight_list, 0, 1)
ZEND_PARSE_PARAMETERS_END();
zval_dtor(mx_list);
array_init(mx_list);

View file

@ -51,9 +51,14 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETVAL_FALSE;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz/z/d", &host, &host_len, &port, &zerrno, &zerrstr, &timeout) == FAILURE) {
RETURN_FALSE;
}
ZEND_PARSE_PARAMETERS_START(1, 5)
Z_PARAM_STRING(host, host_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(port)
Z_PARAM_ZVAL_DEREF_EX(zerrno, 0, 1)
Z_PARAM_ZVAL_DEREF_EX(zerrstr, 0, 1)
Z_PARAM_DOUBLE(timeout)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (persistent) {
spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_LONG_FMT, host, port);

View file

@ -35,9 +35,11 @@ PHP_FUNCTION(metaphone)
zend_string *result = NULL;
zend_long phones = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &str, &phones) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(phones)
ZEND_PARSE_PARAMETERS_END();
if (metaphone((unsigned char *)ZSTR_VAL(str), ZSTR_LEN(str), phones, &result, 1) == 0) {
RETVAL_STR(result);

View file

@ -27,9 +27,9 @@ PHP_FUNCTION(gettype)
{
zval *arg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(arg)
ZEND_PARSE_PARAMETERS_END();
switch (Z_TYPE_P(arg)) {
case IS_NULL:
@ -87,11 +87,11 @@ PHP_FUNCTION(settype)
char *type;
size_t type_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &var, &type, &type_len) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL_DEREF(var)
Z_PARAM_STRING(type, type_len)
ZEND_PARSE_PARAMETERS_END();
ZVAL_DEREF(var);
if (!strcasecmp(type, "integer")) {
convert_to_long(var);
} else if (!strcasecmp(type, "int")) {
@ -153,9 +153,9 @@ PHP_FUNCTION(floatval)
{
zval *num;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &num) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(num)
ZEND_PARSE_PARAMETERS_END();
RETURN_DOUBLE(zval_get_double(num));
}
@ -167,9 +167,9 @@ PHP_FUNCTION(boolval)
{
zval *val;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(val)
ZEND_PARSE_PARAMETERS_END();
RETURN_BOOL(zend_is_true(val));
}
@ -236,11 +236,10 @@ PHP_FUNCTION(is_bool)
{
zval *arg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
RETURN_FALSE;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(arg)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
ZVAL_DEREF(arg);
RETURN_BOOL(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE);
}
/* }}} */
@ -358,10 +357,12 @@ PHP_FUNCTION(is_callable)
zend_bool syntax_only = 0;
int check_flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|bz/", &var,
&syntax_only, &callable_name) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_ZVAL_DEREF(var)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(syntax_only)
Z_PARAM_ZVAL_DEREF_EX(callable_name, 0, 1)
ZEND_PARSE_PARAMETERS_END();
if (syntax_only) {
check_flags |= IS_CALLABLE_CHECK_SYNTAX_ONLY;
@ -393,10 +394,10 @@ PHP_FUNCTION(is_callable)
PHP_FUNCTION(is_iterable)
{
zval *var;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &var) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(var)
ZEND_PARSE_PARAMETERS_END();
RETURN_BOOL(zend_is_iterable(var));
}

View file

@ -54,10 +54,11 @@ PHP_FUNCTION(uniqid)
size_t prefix_len = 0;
struct timeval tv;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sb", &prefix, &prefix_len,
&more_entropy)) {
return;
}
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_BOOL(more_entropy)
ZEND_PARSE_PARAMETERS_END();
#if HAVE_USLEEP && !defined(PHP_WIN32)
if (!more_entropy) {

View file

@ -202,9 +202,9 @@ PHP_FUNCTION(var_dump)
int argc;
int i;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, -1)
Z_PARAM_VARIADIC('+', args, argc)
ZEND_PARSE_PARAMETERS_END();
for (i = 0; i < argc; i++) {
php_var_dump(&args[i], 1);
@ -366,9 +366,9 @@ PHP_FUNCTION(debug_zval_dump)
int argc;
int i;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, -1)
Z_PARAM_VARIADIC('+', args, argc)
ZEND_PARSE_PARAMETERS_END();
for (i = 0; i < argc; i++) {
php_debug_zval_dump(&args[i], 1);
@ -572,9 +572,11 @@ PHP_FUNCTION(var_export)
zend_bool return_output = 0;
smart_str buf = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &var, &return_output) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL_DEREF(var)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(return_output)
ZEND_PARSE_PARAMETERS_END();
php_var_export_ex(var, 1, &buf);
smart_str_0 (&buf);
@ -1035,9 +1037,9 @@ PHP_FUNCTION(serialize)
php_serialize_data_t var_hash;
smart_str buf = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &struc) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL_DEREF(struc)
ZEND_PARSE_PARAMETERS_END();
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, struc, &var_hash);
@ -1068,9 +1070,11 @@ PHP_FUNCTION(unserialize)
zval *retval;
HashTable *class_hash = NULL, *prev_class_hash;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|a", &buf, &buf_len, &options) == FAILURE) {
RETURN_FALSE;
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(buf, buf_len)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY(options)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (buf_len == 0) {
RETURN_FALSE;
@ -1134,9 +1138,10 @@ PHP_FUNCTION(unserialize)
PHP_FUNCTION(memory_get_usage) {
zend_bool real_usage = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &real_usage) == FAILURE) {
RETURN_FALSE;
}
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(real_usage)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
RETURN_LONG(zend_memory_usage(real_usage));
}
@ -1147,9 +1152,10 @@ PHP_FUNCTION(memory_get_usage) {
PHP_FUNCTION(memory_get_peak_usage) {
zend_bool real_usage = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &real_usage) == FAILURE) {
RETURN_FALSE;
}
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(real_usage)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
RETURN_LONG(zend_memory_peak_usage(real_usage));
}

View file

@ -212,15 +212,17 @@ PHP_FUNCTION(version_compare)
{
char *v1, *v2, *op = NULL;
size_t v1_len, v2_len, op_len = 0;
int compare, argc;
int compare;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STRING(v1, v1_len)
Z_PARAM_STRING(v2, v2_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(op, op_len)
ZEND_PARSE_PARAMETERS_END();
argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc, "ss|s", &v1, &v1_len, &v2,
&v2_len, &op, &op_len) == FAILURE) {
return;
}
compare = php_version_compare(v1, v2);
if (argc == 2) {
if (!op) {
RETURN_LONG(compare);
}
if (!strncmp(op, "<", op_len) || !strncmp(op, "lt", op_len)) {