]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 21:05:51 +0000 (13:05 -0800)
committerSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 21:17:52 +0000 (13:17 -0800)
ext/standard/ftok.c
ext/standard/image.c
ext/standard/md5.c
ext/standard/microtime.c
ext/standard/proc_open.c
ext/standard/sha1.c
ext/standard/url.c

index 02cf61daf61634b5da5d7e4523af560af4c9f992..f19f16fe573af2dd53e10eacd351e2a0700d00f2 100644 (file)
@@ -39,9 +39,10 @@ PHP_FUNCTION(ftok)
        size_t pathname_len, proj_len;
        key_t k;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &pathname, &pathname_len, &proj, &proj_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(pathname, pathname_len)
+               Z_PARAM_STRING(proj, proj_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (pathname_len == 0){
                php_error_docref(NULL, E_WARNING, "Pathname is invalid");
index 4fb8298f7607cae2c377571b70f69c57eb87b516..61cafe5e802a319f6a3ecc0e3eaf3f2f81508376 100644 (file)
@@ -1217,9 +1217,9 @@ PHP_FUNCTION(image_type_to_mime_type)
 {
        zend_long p_image_type;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &p_image_type) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_LONG(p_image_type)
+       ZEND_PARSE_PARAMETERS_END();
 
        ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(p_image_type));
 }
@@ -1232,9 +1232,11 @@ PHP_FUNCTION(image_type_to_extension)
        zend_long image_type;
        zend_bool inc_dot=1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &image_type, &inc_dot) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_LONG(image_type)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(inc_dot)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        switch (image_type) {
                case IMAGE_FILETYPE_GIF:
@@ -1470,9 +1472,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
        size_t input_len;
        const int argc = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(argc, "s|z/", &input, &input_len, &info) == FAILURE) {
-                       return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(input, input_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ZVAL_DEREF_EX(info, 0, 1)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (argc == 2) {
                zval_dtor(info);
index 825df21c69733c87e0205be6eb93aff1bc1dd864..cb43e674412319fe441c739c05c0f7fb343c118e 100644 (file)
@@ -52,9 +52,11 @@ PHP_NAMED_FUNCTION(php_if_md5)
        PHP_MD5_CTX context;
        unsigned char digest[16];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &arg, &raw_output) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(arg)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(raw_output)
+       ZEND_PARSE_PARAMETERS_END();
 
        md5str[0] = '\0';
        PHP_MD5Init(&context);
@@ -84,9 +86,11 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
        size_t           n;
        php_stream    *stream;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &arg, &arg_len, &raw_output) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_PATH(arg, arg_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(raw_output)
+       ZEND_PARSE_PARAMETERS_END();
 
        stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS, NULL);
        if (!stream) {
index 9a75038fa85727dda088487da2c55b02fa4fb99d..196d8cf1a65dd5fd4175ed4638659a6cec2fe6dc 100644 (file)
@@ -53,9 +53,10 @@ static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode)
        zend_bool get_as_float = 0;
        struct timeval tp = {0};
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &get_as_float) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(get_as_float)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (gettimeofday(&tp, NULL)) {
                RETURN_FALSE;
@@ -112,9 +113,10 @@ PHP_FUNCTION(getrusage)
        zend_long pwho = 0;
        int who = RUSAGE_SELF;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &pwho) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(pwho)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (pwho == 1) {
                who = RUSAGE_CHILDREN;
index b8294ed0e9487ccb806992fd559269819ac87334..5675a69028fd3abc0568ef4a7ae29fb4850ccc70 100644 (file)
@@ -247,9 +247,11 @@ PHP_FUNCTION(proc_terminate)
        struct php_process_handle *proc;
        zend_long sig_no = SIGTERM;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zproc, &sig_no) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_RESOURCE(zproc)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(sig_no)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
                RETURN_FALSE;
@@ -278,9 +280,9 @@ PHP_FUNCTION(proc_close)
        zval *zproc;
        struct php_process_handle *proc;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zproc) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_RESOURCE(zproc)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
                RETURN_FALSE;
@@ -308,9 +310,9 @@ PHP_FUNCTION(proc_get_status)
        int running = 1, signaled = 0, stopped = 0;
        int exitcode = -1, termsig = 0, stopsig = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zproc) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_RESOURCE(zproc)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if ((proc = (struct php_process_handle *)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open)) == NULL) {
                RETURN_FALSE;
@@ -443,11 +445,15 @@ PHP_FUNCTION(proc_open)
        php_file_descriptor_t slave_pty = -1;
 #endif
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "saz/|s!a!a!", &command,
-                               &command_len, &descriptorspec, &pipes, &cwd, &cwd_len, &environment,
-                               &other_options) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 6)
+               Z_PARAM_STRING(command, command_len)
+               Z_PARAM_ARRAY(descriptorspec)
+               Z_PARAM_ZVAL_DEREF_EX(pipes, 0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING_EX(cwd, cwd_len, 1, 0)
+               Z_PARAM_ARRAY_EX(environment, 1, 0)
+               Z_PARAM_ARRAY_EX(other_options, 1, 0)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        command = pestrdup(command, is_persistent);
 
index c4bed51abcb5f240fa7444e44c1d61e0cc6503a4..cb7e3645b78b79698b1b2471b52423e36c2e675c 100644 (file)
@@ -40,9 +40,11 @@ PHP_FUNCTION(sha1)
        PHP_SHA1_CTX context;
        unsigned char digest[20];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &arg, &raw_output) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(arg)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(raw_output)
+       ZEND_PARSE_PARAMETERS_END();
 
        sha1str[0] = '\0';
        PHP_SHA1Init(&context);
@@ -74,9 +76,11 @@ PHP_FUNCTION(sha1_file)
        size_t         n;
        php_stream    *stream;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &arg, &arg_len, &raw_output) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_PATH(arg, arg_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(raw_output)
+       ZEND_PARSE_PARAMETERS_END();
 
        stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS, NULL);
        if (!stream) {
index 915db481ba35c738877ad00542d900a55bf6b824..e8eb2add76d6e73d0e7a70d251792274df95a4a2 100644 (file)
@@ -336,9 +336,11 @@ PHP_FUNCTION(parse_url)
        php_url *resource;
        zend_long key = -1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &key) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(str, str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(key)
+       ZEND_PARSE_PARAMETERS_END();
 
        resource = php_url_parse_ex(str, str_len);
        if (resource == NULL) {
@@ -655,9 +657,12 @@ PHP_FUNCTION(get_headers)
        zval *zcontext = NULL;
        php_stream_context *context;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lr!", &url, &url_len, &format, &zcontext) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 3)
+               Z_PARAM_STRING(url, url_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(format)
+               Z_PARAM_RESOURCE_EX(zcontext, 1, 0)
+       ZEND_PARSE_PARAMETERS_END();
 
        context = php_stream_context_from_zval(zcontext, 0);