]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 21:21:11 +0000 (13:21 -0800)
committerSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 21:36:51 +0000 (13:36 -0800)
ext/standard/dir.c
ext/standard/head.c
ext/standard/http.c
ext/standard/rand.c
ext/standard/user_filters.c

index 9e7adfccfb1dacd9423d9c48a39f888435fac589..096381f5320c00d49e65f715b2755511fe82019d 100644 (file)
@@ -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");
index b440b19226607ff0e4f7bd9d3e71937a305b5f36..fc8e0692da92e8214de7b463611e5159946df207 100644 (file)
@@ -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)
        {
index 4d173e57a1307a4fa9d64bbb1b7898907ac1dee2..25bc7bfee708061f9b81f0fbd35ff8f182a8d521 100644 (file)
@@ -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");
index e97e0b46f03ceb0f5869ca5613986475fe015fed..9e83111f5867e5930436b18d6dddc735957c5e38 100644 (file)
@@ -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));
index a2ca8cc7d78bd017bd0a1a3a8920e8b7404261a0..31a5d75bc949fec6b76f39dba6ef601e20cb5f59 100644 (file)
@@ -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;