]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 16:54:55 +0000 (08:54 -0800)
committerSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 17:12:17 +0000 (09:12 -0800)
ext/standard/base64.c
ext/standard/filestat.c
ext/standard/formatted_print.c
ext/standard/quot_print.c
ext/standard/syslog.c

index cd6bac0b3d8a4de069edb77e2f936cfc00420288..62698077e559f9ffd16706538f9fdf112fc32271 100644 (file)
@@ -213,9 +213,10 @@ PHP_FUNCTION(base64_encode)
        size_t str_len;
        zend_string *result;
 
-       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();
+
        result = php_base64_encode((unsigned char*)str, str_len);
        if (result != NULL) {
                RETURN_STR(result);
@@ -234,9 +235,12 @@ PHP_FUNCTION(base64_decode)
        size_t str_len;
        zend_string *result;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &str, &str_len, &strict) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(str, str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(strict)
+       ZEND_PARSE_PARAMETERS_END();
+
        result = php_base64_decode_ex((unsigned char*)str, str_len, strict);
        if (result != NULL) {
                RETURN_STR(result);
index 47e7d63738e53d417287ebeaf401c0fea91fd1a5..05df8011216264a6bf4a671fdfa54bfd14ff649d 100644 (file)
@@ -186,9 +186,9 @@ PHP_FUNCTION(disk_total_space)
        char *path;
        size_t path_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &path, &path_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_PATH(path, path_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (php_check_open_basedir(path)) {
                RETURN_FALSE;
@@ -279,9 +279,9 @@ PHP_FUNCTION(disk_free_space)
        char *path;
        size_t path_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &path, &path_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_PATH(path, path_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (php_check_open_basedir(path)) {
                RETURN_FALSE;
@@ -337,9 +337,10 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
 #endif
        php_stream_wrapper *wrapper;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz/", &filename, &filename_len, &group) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(filename, filename_len)
+               Z_PARAM_ZVAL_DEREF_EX(group, 0, 1)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
        if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -472,9 +473,10 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
 #endif
        php_stream_wrapper *wrapper;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz/", &filename, &filename_len, &user) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(filename, filename_len)
+               Z_PARAM_ZVAL_DEREF_EX(user, 0, 1)
+       ZEND_PARSE_PARAMETERS_END();
 
        wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
        if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -578,9 +580,10 @@ PHP_FUNCTION(chmod)
        mode_t imode;
        php_stream_wrapper *wrapper;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "pl", &filename, &filename_len, &mode) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(filename, filename_len)
+               Z_PARAM_LONG(mode)
+       ZEND_PARSE_PARAMETERS_END();
 
        wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
        if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -626,9 +629,12 @@ PHP_FUNCTION(touch)
        struct utimbuf *newtime = &newtimebuf;
        php_stream_wrapper *wrapper;
 
-       if (zend_parse_parameters(argc, "p|ll", &filename, &filename_len, &filetime, &fileatime) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 3)
+               Z_PARAM_PATH(filename, filename_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(filetime)
+               Z_PARAM_LONG(fileatime)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!filename_len) {
                RETURN_FALSE;
@@ -736,9 +742,11 @@ PHP_FUNCTION(clearstatcache)
        char      *filename             = NULL;
        size_t     filename_len         = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|bp", &clear_realpath_cache, &filename, &filename_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(clear_realpath_cache)
+               Z_PARAM_PATH(filename, filename_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        php_clear_stat_cache(clear_realpath_cache, filename, filename_len);
 }
index 3e3d59ca1533ba557b6baf5b30eafa6e611d5624..9058f316fa4579727f3a8eb4a5c7e38b3ecf8624 100644 (file)
@@ -727,9 +727,10 @@ PHP_FUNCTION(fprintf)
                WRONG_PARAM_COUNT;
        }
 
-       if (zend_parse_parameters(1, "r", &arg1) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, -1)
+               Z_PARAM_RESOURCE(arg1)
+               /* php_formatted_print does its own zpp for extra args */
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_stream_from_zval(stream, arg1);
 
@@ -756,9 +757,10 @@ PHP_FUNCTION(vfprintf)
                WRONG_PARAM_COUNT;
        }
 
-       if (zend_parse_parameters(1, "r", &arg1) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, -1)
+               Z_PARAM_RESOURCE(arg1)
+               /* php_formatted_print does its own zpp for extra args */
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_stream_from_zval(stream, arg1);
 
index be352cbf806cdb3e67363212c4fb422de9e63b1a..909470fff14ccb4d0c81d8545650103b30d43575 100644 (file)
@@ -206,9 +206,9 @@ PHP_FUNCTION(quoted_printable_decode)
        zend_string *str_out;
        size_t i = 0, j = 0, k;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &arg1) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(arg1)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (ZSTR_LEN(arg1) == 0) {
                /* shortcut */
@@ -267,9 +267,9 @@ PHP_FUNCTION(quoted_printable_encode)
        zend_string *str;
        zend_string *new_str;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) != SUCCESS) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(str)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!ZSTR_LEN(str)) {
                RETURN_EMPTY_STRING();
index 38605eb03dbdfa635748fcf7a50b4fb26fedb6f4..91162d303d0a6a16252eee22e8b42074141c6c62 100644 (file)
@@ -138,10 +138,12 @@ PHP_FUNCTION(openlog)
        zend_long option, facility;
        size_t ident_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll", &ident,
-                                                         &ident_len, &option, &facility) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 3)
+               Z_PARAM_STRING(ident, ident_len)
+               Z_PARAM_LONG(option)
+               Z_PARAM_LONG(facility)
+       ZEND_PARSE_PARAMETERS_END();
+
        if (BG(syslog_device)) {
                free(BG(syslog_device));
        }
@@ -179,10 +181,10 @@ PHP_FUNCTION(syslog)
        char *message;
        size_t message_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &priority,
-                                                         &message, &message_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_LONG(priority)
+               Z_PARAM_STRING(message, message_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        php_syslog(priority, "%s", message);
        RETURN_TRUE;