mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use new param API in standard
This commit is contained in:
parent
331dcf08df
commit
a23f08a33c
9 changed files with 99 additions and 68 deletions
|
@ -1267,9 +1267,10 @@ PHP_FUNCTION(phpinfo)
|
|||
{
|
||||
zend_long flag = PHP_INFO_ALL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(0, 1)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG(flag)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
/* Andale! Andale! Yee-Hah! */
|
||||
php_output_start_default();
|
||||
|
@ -1288,9 +1289,10 @@ PHP_FUNCTION(phpversion)
|
|||
char *ext_name = NULL;
|
||||
size_t ext_name_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext_name, &ext_name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(0, 1)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_STRING(ext_name, ext_name_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!ext_name) {
|
||||
RETURN_STRING(PHP_VERSION);
|
||||
|
@ -1311,9 +1313,10 @@ PHP_FUNCTION(phpcredits)
|
|||
{
|
||||
zend_long flag = PHP_CREDITS_ALL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(0, 1)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG(flag)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
php_print_credits((int)flag);
|
||||
RETURN_TRUE;
|
||||
|
@ -1344,9 +1347,11 @@ PHP_FUNCTION(php_uname)
|
|||
char *mode = "a";
|
||||
size_t modelen = sizeof("a")-1;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &mode, &modelen) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(0, 1)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_STRING(mode, modelen)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
RETURN_STR(php_get_uname(*mode));
|
||||
}
|
||||
|
||||
|
|
|
@ -197,9 +197,12 @@ PHP_FUNCTION(iptcembed)
|
|||
zend_stat_t sb;
|
||||
zend_bool written = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sp|l", &iptcdata, &iptcdata_len, &jpeg_file, &jpeg_file_len, &spool) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 3)
|
||||
Z_PARAM_STRING(iptcdata, iptcdata_len)
|
||||
Z_PARAM_PATH(jpeg_file, jpeg_file_len)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG(spool)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (php_check_open_basedir(jpeg_file)) {
|
||||
RETURN_FALSE;
|
||||
|
@ -321,9 +324,9 @@ PHP_FUNCTION(iptcparse)
|
|||
size_t str_len;
|
||||
zval values, *element;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STRING(str, str_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
buffer = (unsigned char *)str;
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@ PHP_FUNCTION(readlink)
|
|||
char buff[MAXPATHLEN];
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_PATH(link, link_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (php_check_open_basedir(link)) {
|
||||
RETURN_FALSE;
|
||||
|
@ -90,9 +90,9 @@ PHP_FUNCTION(linkinfo)
|
|||
zend_stat_t sb;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_PATH(link, link_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
dirname = estrndup(link, link_len);
|
||||
php_dirname(dirname, link_len);
|
||||
|
@ -126,9 +126,10 @@ PHP_FUNCTION(symlink)
|
|||
char dirname[MAXPATHLEN];
|
||||
size_t len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 2)
|
||||
Z_PARAM_PATH(topath, topath_len)
|
||||
Z_PARAM_PATH(frompath, frompath_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!expand_filepath(frompath, source_p)) {
|
||||
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||
|
@ -182,9 +183,10 @@ PHP_FUNCTION(link)
|
|||
char source_p[MAXPATHLEN];
|
||||
char dest_p[MAXPATHLEN];
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 2)
|
||||
Z_PARAM_PATH(topath, topath_len)
|
||||
Z_PARAM_PATH(frompath, frompath_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!expand_filepath(frompath, source_p) || !expand_filepath(topath, dest_p)) {
|
||||
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||
|
|
|
@ -78,9 +78,9 @@ PHP_FUNCTION(ezmlm_hash)
|
|||
unsigned int h = 5381;
|
||||
size_t j, str_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STRING(str, str_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
for (j = 0; j < str_len; j++) {
|
||||
h = (h + (h << 5)) ^ (zend_ulong) (unsigned char) tolower(str[j]);
|
||||
|
@ -295,9 +295,14 @@ PHP_FUNCTION(mail)
|
|||
char *to_r, *subject_r;
|
||||
char *p, *e;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|zS", &to, &to_len, &subject, &subject_len, &message, &message_len, &headers, &extra_cmd) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(3, 5)
|
||||
Z_PARAM_STRING(to, to_len)
|
||||
Z_PARAM_STRING(subject, subject_len)
|
||||
Z_PARAM_STRING(message, message_len)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_ZVAL_DEREF(headers)
|
||||
Z_PARAM_STR(extra_cmd)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK(to, to_len);
|
||||
|
|
|
@ -191,8 +191,11 @@ PHP_FUNCTION(mt_srand)
|
|||
zend_long seed = 0;
|
||||
zend_long mode = MT_RAND_MT19937;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &seed, &mode) == FAILURE)
|
||||
return;
|
||||
ZEND_PARSE_PARAMETERS_START(0, 2)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG(seed)
|
||||
Z_PARAM_LONG(mode)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (ZEND_NUM_ARGS() == 0)
|
||||
seed = GENERATE_SEED();
|
||||
|
@ -288,9 +291,10 @@ PHP_FUNCTION(mt_rand)
|
|||
RETURN_LONG(php_mt_rand() >> 1);
|
||||
}
|
||||
|
||||
if (zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 2)
|
||||
Z_PARAM_LONG(min)
|
||||
Z_PARAM_LONG(max)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (UNEXPECTED(max < min)) {
|
||||
php_error_docref(NULL, E_WARNING, "max(" ZEND_LONG_FMT ") is smaller than min(" ZEND_LONG_FMT ")", max, min);
|
||||
|
|
|
@ -116,9 +116,10 @@ PHP_FUNCTION(pack)
|
|||
int outputpos = 0, outputsize = 0;
|
||||
zend_string *output;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s*", &format, &formatlen, &argv, &num_args) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, -1)
|
||||
Z_PARAM_STRING(format, formatlen)
|
||||
Z_PARAM_VARIADIC('*', argv, num_args)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
/* We have a maximum of <formatlen> format codes to deal with */
|
||||
formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
|
||||
|
@ -547,10 +548,12 @@ PHP_FUNCTION(unpack)
|
|||
int i;
|
||||
zend_long offset = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &formatarg,
|
||||
&inputarg, &offset) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 3)
|
||||
Z_PARAM_STR(formatarg)
|
||||
Z_PARAM_STR(inputarg)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG(offset)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
format = ZSTR_VAL(formatarg);
|
||||
formatlen = ZSTR_LEN(formatarg);
|
||||
|
|
|
@ -173,9 +173,9 @@ PHP_FUNCTION(password_get_info)
|
|||
char *hash, *algo_name;
|
||||
zval options;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hash, &hash_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STRING(hash, hash_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
array_init(&options);
|
||||
|
||||
|
@ -229,9 +229,12 @@ PHP_FUNCTION(password_needs_rehash)
|
|||
HashTable *options = 0;
|
||||
zval *option_buffer;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 3)
|
||||
Z_PARAM_STRING(hash, hash_len)
|
||||
Z_PARAM_LONG(new_algo)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_ARRAY_OR_OBJECT_HT(options)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
algo = php_password_determine_algo(hash, (size_t) hash_len);
|
||||
|
||||
|
@ -300,9 +303,10 @@ PHP_FUNCTION(password_verify)
|
|||
zend_string *ret;
|
||||
php_password_algo algo;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &password, &password_len, &hash, &hash_len) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 2)
|
||||
Z_PARAM_STRING(password, password_len)
|
||||
Z_PARAM_STRING(hash, hash_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||
|
||||
algo = php_password_determine_algo(hash, (size_t) hash_len);
|
||||
|
||||
|
@ -372,9 +376,12 @@ PHP_FUNCTION(password_hash)
|
|||
argon2_type type = Argon2_i;
|
||||
#endif
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &password, &password_len, &algo, &options) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(2, 3)
|
||||
Z_PARAM_STRING(password, password_len)
|
||||
Z_PARAM_LONG(algo)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_ARRAY_OR_OBJECT_HT(options)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
switch (algo) {
|
||||
case PHP_PASSWORD_BCRYPT:
|
||||
|
|
|
@ -4981,7 +4981,7 @@ PHP_FUNCTION(str_repeat)
|
|||
|
||||
ZEND_PARSE_PARAMETERS_START(2, 2)
|
||||
Z_PARAM_STR(input_str)
|
||||
Z_PARMA_LONG(mult)
|
||||
Z_PARAM_LONG(mult)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (mult < 0) {
|
||||
|
@ -5038,7 +5038,7 @@ PHP_FUNCTION(count_chars)
|
|||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_STR(input)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARMA_LONG(mymode)
|
||||
Z_PARAM_LONG(mymode)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (mymode < 0 || mymode > 4) {
|
||||
|
|
|
@ -204,9 +204,10 @@ PHP_FUNCTION(convert_uuencode)
|
|||
{
|
||||
zend_string *src;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STR(src)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||
if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
|
||||
|
||||
RETURN_STR(php_uuencode(ZSTR_VAL(src), ZSTR_LEN(src)));
|
||||
}
|
||||
|
@ -219,9 +220,10 @@ PHP_FUNCTION(convert_uudecode)
|
|||
zend_string *src;
|
||||
zend_string *dest;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STR(src)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
|
||||
if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
|
||||
|
||||
if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "The given parameter is not a valid uuencoded string");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue