cvs: php4 /ext/ftp ftp.c ftp.h php_ftp.c
| From: | Jani Taskinen | Date: | Thu, 04 Jul 2002 13:48:49 +0000 |
| Subject: | cvs: php4 /ext/ftp ftp.c ftp.h php_ftp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12711@lists.php.net to get a copy of this message | ||
sniper Thu Jul 4 09:48:49 2002 EDT
Modified files:
/php4/ext/ftp ftp.c ftp.h php_ftp.c
Log:
@- 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..)
Index: php4/ext/ftp/ftp.c
diff -u php4/ext/ftp/ftp.c:1.49 php4/ext/ftp/ftp.c:1.50
--- php4/ext/ftp/ftp.c:1.49 Mon Mar 18 17:26:32 2002
+++ php4/ext/ftp/ftp.c Thu Jul 4 09:48:48 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.c,v 1.49 2002/03/18 22:26:32 vlad Exp $ */
+/* $Id: ftp.c,v 1.50 2002/07/04 13:48:48 sniper Exp $ */
#include "php.h"
@@ -412,9 +412,9 @@
/* {{{ 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 @@
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 @@
if (!ftp_getresp(ftp) || ftp->resp != 200)
return 0;
- Z_TYPE_P(ftp) = type;
+ ftp->type = type;
return 1;
}
@@ -1042,7 +1042,7 @@
}
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 */
Index: php4/ext/ftp/ftp.h
diff -u php4/ext/ftp/ftp.h:1.23 php4/ext/ftp/ftp.h:1.24
--- php4/ext/ftp/ftp.h:1.23 Fri Mar 15 20:20:57 2002
+++ php4/ext/ftp/ftp.h Thu Jul 4 09:48:48 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.h,v 1.23 2002/03/16 01:20:57 wez Exp $ */
+/* $Id: ftp.h,v 1.24 2002/07/04 13:48:48 sniper Exp $ */
#ifndef FTP_H
#define FTP_H
@@ -120,7 +120,7 @@
* 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
Index: php4/ext/ftp/php_ftp.c
diff -u php4/ext/ftp/php_ftp.c:1.59 php4/ext/ftp/php_ftp.c:1.60
--- php4/ext/ftp/php_ftp.c:1.59 Thu Jun 27 02:49:02 2002
+++ php4/ext/ftp/php_ftp.c Thu Jul 4 09:48:48 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ftp.c,v 1.59 2002/06/27 06:49:02 derick Exp $ */
+/* $Id: php_ftp.c,v 1.60 2002/07/04 13:48:48 sniper Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -342,7 +342,7 @@
}
/* }}} */
-/* {{{ 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 @@
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;
}