Skip to content

Commit 4263efc

Browse files
committed
ext/ftp: Use new php_streams fast ZPP specifier
1 parent f4f0162 commit 4263efc

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

ext/ftp/php_ftp.c

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -566,19 +566,24 @@ PHP_FUNCTION(ftp_systype)
566566
/* {{{ Retrieves a file from the FTP server and writes it to an open file */
567567
PHP_FUNCTION(ftp_fget)
568568
{
569-
zval *z_ftp, *z_file;
569+
zval *z_ftp;
570570
ftpbuf_t *ftp;
571571
ftptype_t xtype;
572572
php_stream *stream;
573573
char *file;
574574
size_t file_len;
575575
zend_long mode=FTPTYPE_IMAGE, resumepos=0;
576576

577-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
578-
RETURN_THROWS();
579-
}
577+
ZEND_PARSE_PARAMETERS_START(3, 5)
578+
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
579+
PHP_Z_PARAM_STREAM(stream)
580+
Z_PARAM_STRING(file, file_len)
581+
Z_PARAM_OPTIONAL
582+
Z_PARAM_LONG(mode)
583+
Z_PARAM_LONG(resumepos)
584+
ZEND_PARSE_PARAMETERS_END();
585+
580586
GET_FTPBUF(ftp, z_ftp);
581-
php_stream_from_res(stream, Z_RES_P(z_file));
582587
XTYPE(xtype, mode);
583588

584589
/* ignore autoresume if autoseek is switched off */
@@ -610,19 +615,24 @@ PHP_FUNCTION(ftp_fget)
610615
/* {{{ Retrieves a file from the FTP server asynchronly and writes it to an open file */
611616
PHP_FUNCTION(ftp_nb_fget)
612617
{
613-
zval *z_ftp, *z_file;
618+
zval *z_ftp;
614619
ftpbuf_t *ftp;
615620
ftptype_t xtype;
616621
php_stream *stream;
617622
char *file;
618623
size_t file_len;
619624
zend_long mode=FTPTYPE_IMAGE, resumepos=0, ret;
620625

621-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
622-
RETURN_THROWS();
623-
}
626+
ZEND_PARSE_PARAMETERS_START(3, 5)
627+
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
628+
PHP_Z_PARAM_STREAM(stream)
629+
Z_PARAM_STRING(file, file_len)
630+
Z_PARAM_OPTIONAL
631+
Z_PARAM_LONG(mode)
632+
Z_PARAM_LONG(resumepos)
633+
ZEND_PARSE_PARAMETERS_END();
634+
624635
GET_FTPBUF(ftp, z_ftp);
625-
php_stream_from_res(stream, Z_RES_P(z_file));
626636
XTYPE(xtype, mode);
627637

628638
/* ignore autoresume if autoseek is switched off */
@@ -848,19 +858,24 @@ PHP_FUNCTION(ftp_nb_continue)
848858
/* {{{ Stores a file from an open file to the FTP server */
849859
PHP_FUNCTION(ftp_fput)
850860
{
851-
zval *z_ftp, *z_file;
861+
zval *z_ftp;
852862
ftpbuf_t *ftp;
853863
ftptype_t xtype;
854864
size_t remote_len;
855865
zend_long mode=FTPTYPE_IMAGE, startpos=0;
856866
php_stream *stream;
857867
char *remote;
858868

859-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
860-
RETURN_THROWS();
861-
}
869+
ZEND_PARSE_PARAMETERS_START(3, 5)
870+
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
871+
Z_PARAM_STRING(remote, remote_len)
872+
PHP_Z_PARAM_STREAM(stream)
873+
Z_PARAM_OPTIONAL
874+
Z_PARAM_LONG(mode)
875+
Z_PARAM_LONG(startpos)
876+
ZEND_PARSE_PARAMETERS_END();
877+
862878
GET_FTPBUF(ftp, z_ftp);
863-
php_stream_from_zval(stream, z_file);
864879
XTYPE(xtype, mode);
865880

866881
/* ignore autoresume if autoseek is switched off */
@@ -895,7 +910,7 @@ PHP_FUNCTION(ftp_fput)
895910
/* {{{ Stores a file from an open file to the FTP server nbronly */
896911
PHP_FUNCTION(ftp_nb_fput)
897912
{
898-
zval *z_ftp, *z_file;
913+
zval *z_ftp;
899914
ftpbuf_t *ftp;
900915
ftptype_t xtype;
901916
size_t remote_len;
@@ -904,11 +919,16 @@ PHP_FUNCTION(ftp_nb_fput)
904919
php_stream *stream;
905920
char *remote;
906921

907-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
908-
RETURN_THROWS();
909-
}
922+
ZEND_PARSE_PARAMETERS_START(3, 5)
923+
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
924+
Z_PARAM_STRING(remote, remote_len)
925+
PHP_Z_PARAM_STREAM(stream)
926+
Z_PARAM_OPTIONAL
927+
Z_PARAM_LONG(mode)
928+
Z_PARAM_LONG(startpos)
929+
ZEND_PARSE_PARAMETERS_END();
930+
910931
GET_FTPBUF(ftp, z_ftp);
911-
php_stream_from_res(stream, Z_RES_P(z_file));
912932
XTYPE(xtype, mode);
913933

914934
/* ignore autoresume if autoseek is switched off */

0 commit comments

Comments
 (0)