cvs: /php4/ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h
| From: | Andrew Skalski | Date: | Tue, 22 Feb 2000 20:50:00 +0000 |
| Subject: | cvs: /php4/ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10667@lists.php.net to get a copy of this message | ||
askalski Tue Feb 22 12:50:00 2000 EDT
Modified files:
/php4/ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h
Log:
added the ftp_site() function
Index: php4/ext/ftp/ftp.c
diff -u php4/ext/ftp/ftp.c:1.14 php4/ext/ftp/ftp.c:1.15
--- php4/ext/ftp/ftp.c:1.14 Wed Feb 16 08:07:27 2000
+++ php4/ext/ftp/ftp.c Tue Feb 22 12:50:00 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.c,v 1.14 2000/02/16 16:07:27 askalski Exp $ */
+/* $Id: ftp.c,v 1.15 2000/02/22 20:50:00 askalski Exp $ */
#include "php.h"
@@ -167,7 +167,7 @@
{
if (ftp == NULL)
return NULL;
- if (ftp->fd)
+ if (ftp->fd != -1)
close(ftp->fd);
ftp_gc(ftp);
free(ftp);
@@ -677,6 +677,21 @@
if (!ftp_putcmd(ftp, "RNTO", dest))
return 0;
if (!ftp_getresp(ftp) || ftp->resp != 250)
+ return 0;
+
+ return 1;
+}
+
+
+int
+ftp_site(ftpbuf_t *ftp, const char *cmd)
+{
+ if (ftp == NULL)
+ return 0;
+
+ if (!ftp_putcmd(ftp, "SITE", cmd))
+ return 0;
+ if (!ftp_getresp(ftp) || ftp->resp < 200 || ftp->resp >= 300)
return 0;
return 1;
Index: php4/ext/ftp/ftp.h
diff -u php4/ext/ftp/ftp.h:1.8 php4/ext/ftp/ftp.h:1.9
--- php4/ext/ftp/ftp.h:1.8 Thu Nov 18 12:29:32 1999
+++ php4/ext/ftp/ftp.h Tue Feb 22 12:50:00 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.h,v 1.8 1999/11/18 20:29:32 askalski Exp $ */
+/* $Id: ftp.h,v 1.9 2000/02/22 20:50:00 askalski Exp $ */
#ifndef _FTP_H
#define _FTP_H
@@ -154,5 +154,8 @@
/* deletes the file from the server */
int ftp_delete(ftpbuf_t *ftp, const char *path);
+
+/* sends a SITE command to the server */
+int ftp_site(ftpbuf_t *ftp, const char *cmd);
#endif
Index: php4/ext/ftp/php_ftp.c
diff -u php4/ext/ftp/php_ftp.c:1.13 php4/ext/ftp/php_ftp.c:1.14
--- php4/ext/ftp/php_ftp.c:1.13 Fri Dec 17 13:34:26 1999
+++ php4/ext/ftp/php_ftp.c Tue Feb 22 12:50:00 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ftp.c,v 1.13 1999/12/17 21:34:26 zeev Exp $ */
+/* $Id: php_ftp.c,v 1.14 2000/02/22 20:50:00 askalski Exp $ */
#include "php.h"
@@ -62,6 +62,7 @@
PHP_FE(ftp_mdtm, NULL)
PHP_FE(ftp_rename, NULL)
PHP_FE(ftp_delete, NULL)
+ PHP_FE(ftp_site, NULL)
PHP_FE(ftp_quit, NULL)
{NULL, NULL, NULL}
};
@@ -751,6 +752,35 @@
/* delete the file */
if (!ftp_delete(ftp, arg2->value.str.val)) {
php_error(E_WARNING, "ftp_delete: %s", ftp->inbuf);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int ftp_site(int stream, string cmd)
+ Sends a SITE command to the server */
+PHP_FUNCTION(ftp_site)
+{
+ pval *arg1, *arg2;
+ ftpbuf_t *ftp;
+
+ /* arg1 - ftp
+ * arg2 - cmd
+ */
+ if ( ARG_COUNT(ht) != 2 ||
+ getParameters(ht, 2, &arg1, &arg2) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ FTPBUF(ftp, arg1);
+ convert_to_string(arg2);
+
+ /* send the site command */
+ if (!ftp_site(ftp, arg2->value.str.val)) {
+ php_error(E_WARNING, "ftp_site: %s", ftp->inbuf);
RETURN_FALSE;
}
Index: php4/ext/ftp/php_ftp.h
diff -u php4/ext/ftp/php_ftp.h:1.8 php4/ext/ftp/php_ftp.h:1.9
--- php4/ext/ftp/php_ftp.h:1.8 Fri Dec 17 13:34:26 1999
+++ php4/ext/ftp/php_ftp.h Tue Feb 22 12:50:00 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ftp.h,v 1.8 1999/12/17 21:34:26 zeev Exp $ */
+/* $Id: php_ftp.h,v 1.9 2000/02/22 20:50:00 askalski Exp $ */
#ifndef _INCLUDED_FTP_H
#define _INCLUDED_FTP_H
@@ -64,6 +64,7 @@
PHP_FUNCTION(ftp_mdtm);
PHP_FUNCTION(ftp_rename);
PHP_FUNCTION(ftp_delete);
+PHP_FUNCTION(ftp_site);
PHP_FUNCTION(ftp_quit);
#define phpext_ftp_ptr php_ftp_module_ptr