summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2016-12-30 13:21:11 -0800
committerSara Golemon <pollita@php.net>2016-12-30 13:36:51 -0800
commitb71b12843c08dafea897f105d791741f2c098827 (patch)
tree884faece3796fed177ff06460d4ccfab73e3d4d4 /ext/standard
parent625304fa7666ce0e3445c5f92ecb689a48ed9d8e (diff)
downloadphp-git-b71b12843c08dafea897f105d791741f2c098827.tar.gz
Use new param API in standard
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/dir.c44
-rw-r--r--ext/standard/head.c57
-rw-r--r--ext/standard/http.c10
-rw-r--r--ext/standard/rand.c7
-rw-r--r--ext/standard/user_filters.c27
5 files changed, 90 insertions, 55 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 9e7adfccfb..096381f532 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -66,9 +66,10 @@ php_dir_globals dir_globals;
static zend_class_entry *dir_class_entry_ptr;
#define FETCH_DIRP() \
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &id) == FAILURE) { \
- return; \
- } \
+ ZEND_PARSE_PARAMETERS_START(0, 1) \
+ Z_PARAM_OPTIONAL \
+ Z_PARAM_RESOURCE(id) \
+ ZEND_PARSE_PARAMETERS_END(); \
if (ZEND_NUM_ARGS() == 0) { \
myself = getThis(); \
if (myself) { \
@@ -215,9 +216,11 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
php_stream_context *context = NULL;
php_stream *dirp;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
- RETURN_NULL();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_PATH(dirname, dir_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_RESOURCE(zcontext)
+ ZEND_PARSE_PARAMETERS_END();
context = php_stream_context_from_zval(zcontext, 0);
@@ -291,9 +294,9 @@ PHP_FUNCTION(chroot)
int ret;
size_t str_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &str, &str_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH(str, str_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
ret = chroot(str);
if (ret != 0) {
@@ -323,9 +326,9 @@ PHP_FUNCTION(chdir)
int ret;
size_t str_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &str, &str_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH(str, str_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (php_check_open_basedir(str)) {
RETURN_FALSE;
@@ -434,9 +437,11 @@ PHP_FUNCTION(glob)
int ret;
zend_bool basedir_limit = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &pattern, &pattern_len, &flags) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_PATH(pattern, pattern_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(flags)
+ ZEND_PARSE_PARAMETERS_END();
if (pattern_len >= MAXPATHLEN) {
php_error_docref(NULL, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
@@ -557,9 +562,12 @@ PHP_FUNCTION(scandir)
zval *zcontext = NULL;
php_stream_context *context = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|lr", &dirn, &dirn_len, &flags, &zcontext) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_PATH(dirn, dirn_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(flags)
+ Z_PARAM_RESOURCE(zcontext)
+ ZEND_PARSE_PARAMETERS_END();
if (dirn_len < 1) {
php_error_docref(NULL, E_WARNING, "Directory name cannot be empty");
diff --git a/ext/standard/head.c b/ext/standard/head.c
index b440b19226..fc8e0692da 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -42,9 +42,12 @@ PHP_FUNCTION(header)
sapi_header_line ctr = {0};
size_t len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|bl", &ctr.line,
- &len, &rep, &ctr.response_code) == FAILURE)
- return;
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_STRING(ctr.line, len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(rep)
+ Z_PARAM_LONG(ctr.response_code)
+ ZEND_PARSE_PARAMETERS_END();
ctr.line_len = (uint32_t)len;
sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr);
@@ -58,9 +61,9 @@ PHP_FUNCTION(header_remove)
sapi_header_line ctr = {0};
size_t len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ctr.line,
- &len) == FAILURE)
- return;
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_STRING(ctr.line, len)
+ ZEND_PARSE_PARAMETERS_END();
ctr.line_len = (uint32_t)len;
sapi_header_op(ZEND_NUM_ARGS() == 0 ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr);
@@ -191,10 +194,16 @@ PHP_FUNCTION(setcookie)
zend_long expires = 0;
zend_bool secure = 0, httponly = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|SlSSbb",
- &name, &value, &expires, &path, &domain, &secure, &httponly) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 7)
+ Z_PARAM_STR(name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR(value)
+ Z_PARAM_LONG(expires)
+ Z_PARAM_STR(path)
+ Z_PARAM_STR(domain)
+ Z_PARAM_BOOL(secure)
+ Z_PARAM_BOOL(httponly)
+ ZEND_PARSE_PARAMETERS_END();
if (php_setcookie(name, value, expires, path, domain, secure, 1, httponly) == SUCCESS) {
RETVAL_TRUE;
@@ -212,10 +221,16 @@ PHP_FUNCTION(setrawcookie)
zend_long expires = 0;
zend_bool secure = 0, httponly = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|SlSSbb",
- &name, &value, &expires, &path, &domain, &secure, &httponly) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 7)
+ Z_PARAM_STR(name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR(value)
+ Z_PARAM_LONG(expires)
+ Z_PARAM_STR(path)
+ Z_PARAM_STR(domain)
+ Z_PARAM_BOOL(secure)
+ Z_PARAM_BOOL(httponly)
+ ZEND_PARSE_PARAMETERS_END();
if (php_setcookie(name, value, expires, path, domain, secure, 0, httponly) == SUCCESS) {
RETVAL_TRUE;
@@ -234,8 +249,11 @@ PHP_FUNCTION(headers_sent)
const char *file="";
int line=0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z/z/", &arg1, &arg2) == FAILURE)
- return;
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL_DEREF_EX(arg1, 0, 1)
+ Z_PARAM_ZVAL_DEREF_EX(arg2, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
if (SG(headers_sent)) {
line = php_output_get_start_lineno();
@@ -294,9 +312,10 @@ PHP_FUNCTION(http_response_code)
{
zend_long response_code = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &response_code) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(response_code)
+ ZEND_PARSE_PARAMETERS_END();
if (response_code)
{
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 4d173e57a1..25bc7bfee7 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -232,9 +232,13 @@ PHP_FUNCTION(http_build_query)
smart_str formstr = {0};
zend_long enc_type = PHP_QUERY_RFC1738;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ssl", &formdata, &prefix, &prefix_len, &arg_sep, &arg_sep_len, &enc_type) != SUCCESS) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 4)
+ Z_PARAM_ZVAL_DEREF(formdata)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(prefix, prefix_len)
+ Z_PARAM_STRING(arg_sep, arg_sep_len)
+ Z_PARAM_LONG(enc_type)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given");
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index e97e0b46f0..9e83111f58 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -57,9 +57,10 @@ PHP_FUNCTION(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 (max < min) {
RETURN_LONG(php_mt_rand_common(max, min));
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index a2ca8cc7d7..31a5d75bc9 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -399,9 +399,9 @@ PHP_FUNCTION(stream_bucket_make_writeable)
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zbrigade) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_RESOURCE(zbrigade)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if ((brigade = (php_stream_bucket_brigade*)zend_fetch_resource(
Z_RES_P(zbrigade), PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade)) == NULL) {
@@ -430,9 +430,10 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ro", &zbrigade, &zobject) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_RESOURCE(zbrigade)
+ Z_PARAM_OBJECT(zobject)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
php_error_docref(NULL, E_WARNING, "Object has no bucket property");
@@ -500,9 +501,10 @@ PHP_FUNCTION(stream_bucket_new)
size_t buffer_len;
php_stream_bucket *bucket;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &zstream, &buffer, &buffer_len) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_ZVAL_DEREF(zstream)
+ Z_PARAM_STRING(buffer, buffer_len)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
php_stream_from_zval(stream, zstream);
@@ -561,9 +563,10 @@ PHP_FUNCTION(stream_filter_register)
zend_string *filtername, *classname;
struct php_user_filter_data *fdat;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &filtername, &classname) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STR(filtername)
+ Z_PARAM_STR(classname)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
RETVAL_FALSE;