From c9d23c96d6ed75bfa39ad0925d8d3fbe8be1075d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 3 Mar 2025 15:38:14 +0000 Subject: [PATCH] ext/ftp: Use new php_streams fast ZPP specifier --- ext/ftp/php_ftp.c | 60 +++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 0336f9e9537..17dc94b728e 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -566,7 +566,7 @@ PHP_FUNCTION(ftp_systype) /* {{{ Retrieves a file from the FTP server and writes it to an open file */ PHP_FUNCTION(ftp_fget) { - zval *z_ftp, *z_file; + zval *z_ftp; ftpbuf_t *ftp; ftptype_t xtype; php_stream *stream; @@ -574,11 +574,16 @@ PHP_FUNCTION(ftp_fget) size_t file_len; zend_long mode=FTPTYPE_IMAGE, resumepos=0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce) + PHP_Z_PARAM_STREAM(stream) + Z_PARAM_STRING(file, file_len) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + Z_PARAM_LONG(resumepos) + ZEND_PARSE_PARAMETERS_END(); + GET_FTPBUF(ftp, z_ftp); - php_stream_from_res(stream, Z_RES_P(z_file)); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ @@ -610,7 +615,7 @@ PHP_FUNCTION(ftp_fget) /* {{{ Retrieves a file from the FTP server asynchronly and writes it to an open file */ PHP_FUNCTION(ftp_nb_fget) { - zval *z_ftp, *z_file; + zval *z_ftp; ftpbuf_t *ftp; ftptype_t xtype; php_stream *stream; @@ -618,11 +623,16 @@ PHP_FUNCTION(ftp_nb_fget) size_t file_len; zend_long mode=FTPTYPE_IMAGE, resumepos=0, ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce) + PHP_Z_PARAM_STREAM(stream) + Z_PARAM_STRING(file, file_len) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + Z_PARAM_LONG(resumepos) + ZEND_PARSE_PARAMETERS_END(); + GET_FTPBUF(ftp, z_ftp); - php_stream_from_res(stream, Z_RES_P(z_file)); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ @@ -848,7 +858,7 @@ PHP_FUNCTION(ftp_nb_continue) /* {{{ Stores a file from an open file to the FTP server */ PHP_FUNCTION(ftp_fput) { - zval *z_ftp, *z_file; + zval *z_ftp; ftpbuf_t *ftp; ftptype_t xtype; size_t remote_len; @@ -856,11 +866,16 @@ PHP_FUNCTION(ftp_fput) php_stream *stream; char *remote; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce) + Z_PARAM_STRING(remote, remote_len) + PHP_Z_PARAM_STREAM(stream) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + Z_PARAM_LONG(startpos) + ZEND_PARSE_PARAMETERS_END(); + GET_FTPBUF(ftp, z_ftp); - php_stream_from_zval(stream, z_file); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */ @@ -895,7 +910,7 @@ PHP_FUNCTION(ftp_fput) /* {{{ Stores a file from an open file to the FTP server nbronly */ PHP_FUNCTION(ftp_nb_fput) { - zval *z_ftp, *z_file; + zval *z_ftp; ftpbuf_t *ftp; ftptype_t xtype; size_t remote_len; @@ -904,11 +919,16 @@ PHP_FUNCTION(ftp_nb_fput) php_stream *stream; char *remote; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce) + Z_PARAM_STRING(remote, remote_len) + PHP_Z_PARAM_STREAM(stream) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + Z_PARAM_LONG(startpos) + ZEND_PARSE_PARAMETERS_END(); + GET_FTPBUF(ftp, z_ftp); - php_stream_from_res(stream, Z_RES_P(z_file)); XTYPE(xtype, mode); /* ignore autoresume if autoseek is switched off */