From b0ed560c95a560690786bd4e9a1b5b6f8725cda3 Mon Sep 17 00:00:00 2001 From: foobar Date: Thu, 4 Jul 2002 13:48:48 +0000 Subject: [PATCH] @- Added optional 3rd parameter 'recursive' to ftp_rawlist() which will @ do 'LIST -R' instead of 'LIST'. (Jani) # tested too..and it even works. :) # (removed that Z_TYPE_P() pollution also..) --- ext/ftp/ftp.c | 10 +++++----- ext/ftp/ftp.h | 2 +- ext/ftp/php_ftp.c | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index d7d7d8a8f1..575cb40f45 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -412,9 +412,9 @@ ftp_nlist(ftpbuf_t *ftp, const char *path) /* {{{ ftp_list */ char** -ftp_list(ftpbuf_t *ftp, const char *path) +ftp_list(ftpbuf_t *ftp, const char *path, int recursive) { - return ftp_genlist(ftp, "LIST", path); + return ftp_genlist(ftp, ((recursive) ? "LIST -R" : "LIST"), path); } /* }}} */ @@ -428,7 +428,7 @@ ftp_type(ftpbuf_t *ftp, ftptype_t type) if (ftp == NULL) return 0; - if (type == Z_TYPE_P(ftp)) + if (type == ftp->type) return 1; if (type == FTPTYPE_ASCII) @@ -443,7 +443,7 @@ ftp_type(ftpbuf_t *ftp, ftptype_t type) if (!ftp_getresp(ftp) || ftp->resp != 200) return 0; - Z_TYPE_P(ftp) = type; + ftp->type = type; return 1; } @@ -1042,7 +1042,7 @@ ftp_getdata(ftpbuf_t *ftp) } data->listener = -1; data->fd = -1; - Z_TYPE_P(data) = Z_TYPE_P(ftp); + data->type = ftp->type; sa = (struct sockaddr *) &ftp->localaddr; /* bind/listen */ diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h index b201045f9b..f980a8c757 100644 --- a/ext/ftp/ftp.h +++ b/ext/ftp/ftp.h @@ -120,7 +120,7 @@ char** ftp_nlist(ftpbuf_t *ftp, const char *path); * array must be freed (but don't * free the array elements) */ -char** ftp_list(ftpbuf_t *ftp, const char *path); +char** ftp_list(ftpbuf_t *ftp, const char *path, int recursive); /* switches passive mode on or off * returns true on success, false on error diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 2b91ed94cd..7a8b665b18 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -342,7 +342,7 @@ PHP_FUNCTION(ftp_nlist) } /* }}} */ -/* {{{ proto array ftp_rawlist(resource stream, string directory) +/* {{{ proto array ftp_rawlist(resource stream, string directory [, bool recursive]) Returns a detailed listing of a directory as an array of output lines */ PHP_FUNCTION(ftp_rawlist) { @@ -350,15 +350,16 @@ PHP_FUNCTION(ftp_rawlist) ftpbuf_t *ftp; char **llist, **ptr, *dir; int dir_len; + zend_bool recursive; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &dir, &dir_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|b", &z_ftp, &dir, &dir_len, &recursive) == FAILURE) { return; } ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); /* get raw directory listing */ - if (NULL == (llist = ftp_list(ftp, dir))) { + if (NULL == (llist = ftp_list(ftp, dir, recursive))) { RETURN_FALSE; } -- 2.40.0