cvs: php4 /ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h
| From: | Derick Rethans | Date: | Wed, 13 Sep 2000 22:00:31 +0000 |
| Subject: | cvs: php4 /ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1754@lists.php.net to get a copy of this message | ||
derick Wed Sep 13 15:00:31 2000 EDT
Modified files:
/php4/ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h
Log:
- Added ftp_exec to the ftp functions (thanks to <jhennebicq@i-d.net>)
@ Added ftp_exec to the ftp functions (thanks to <jhennebicq@i-d.net>)
@ (Derick)
Index: php4/ext/ftp/ftp.c
diff -u php4/ext/ftp/ftp.c:1.24 php4/ext/ftp/ftp.c:1.25
--- php4/ext/ftp/ftp.c:1.24 Thu Aug 10 14:13:08 2000
+++ php4/ext/ftp/ftp.c Wed Sep 13 15:00:31 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.c,v 1.24 2000/08/10 21:13:08 sniper Exp $ */
+/* $Id: ftp.c,v 1.25 2000/09/13 22:00:31 derick Exp $ */
#include "php.h"
@@ -311,6 +311,20 @@
*end = '"';
return ftp->pwd;
+}
+
+
+int
+ftp_exec(ftpbuf_t *ftp, const char *cmd)
+{
+ if (ftp == NULL)
+ return 0;
+ if (!ftp_putcmd(ftp, "SITE EXEC", cmd))
+ return 0;
+ if (!ftp_getresp(ftp) || ftp->resp != 200)
+ return 0;
+
+ return 1;
}
Index: php4/ext/ftp/ftp.h
diff -u php4/ext/ftp/ftp.h:1.13 php4/ext/ftp/ftp.h:1.14
--- php4/ext/ftp/ftp.h:1.13 Sun Jul 2 16:46:41 2000
+++ php4/ext/ftp/ftp.h Wed Sep 13 15:00:31 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.h,v 1.13 2000/07/02 23:46:41 sas Exp $ */
+/* $Id: ftp.h,v 1.14 2000/09/13 22:00:31 derick Exp $ */
#ifndef FTP_H
#define FTP_H
@@ -99,6 +99,9 @@
/* returns the present working directory (NULL on error) */
const char* ftp_pwd(ftpbuf_t *ftp);
+
+/* exec a command [special features], return true on success, false on error */
+int ftp_exec(ftpbuf_t *ftp, const char *cmd);
/* changes directories, return true on success, false on error */
int ftp_chdir(ftpbuf_t *ftp, const char *dir);
Index: php4/ext/ftp/php_ftp.c
diff -u php4/ext/ftp/php_ftp.c:1.26 php4/ext/ftp/php_ftp.c:1.27
--- php4/ext/ftp/php_ftp.c:1.26 Tue Aug 8 13:28:18 2000
+++ php4/ext/ftp/php_ftp.c Wed Sep 13 15:00:31 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ftp.c,v 1.26 2000/08/08 20:28:18 eschmid Exp $ */
+/* $Id: php_ftp.c,v 1.27 2000/09/13 22:00:31 derick Exp $ */
#include "php.h"
@@ -48,6 +48,7 @@
PHP_FE(ftp_pwd, NULL)
PHP_FE(ftp_cdup, NULL)
PHP_FE(ftp_chdir, NULL)
+ PHP_FE(ftp_exec, NULL)
PHP_FE(ftp_mkdir, NULL)
PHP_FE(ftp_rmdir, NULL)
PHP_FE(ftp_nlist, NULL)
@@ -272,6 +273,36 @@
/* change directories */
if (!ftp_chdir(ftp, arg2->value.str.val)) {
php_error(E_WARNING, "ftp_chdir: %s", ftp->inbuf);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int ftp_exec(int stream, string command)
+ Changes directories */
+PHP_FUNCTION(ftp_exec)
+{
+ pval *arg1, *arg2;
+ ftpbuf_t *ftp;
+
+ /* arg1 - ftp
+ * arg2 - command
+ */
+ if (ARG_COUNT(ht) != 2 ||
+ getParameters(ht, 2, &arg1, &arg2) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(arg2);
+
+ FTPBUF(ftp, arg1);
+
+ /* change directories */
+ if (!ftp_exec(ftp, arg2->value.str.val)) {
+ php_error(E_WARNING, "ftp_exec: %s", ftp->inbuf);
RETURN_FALSE;
}
Index: php4/ext/ftp/php_ftp.h
diff -u php4/ext/ftp/php_ftp.h:1.10 php4/ext/ftp/php_ftp.h:1.11
--- php4/ext/ftp/php_ftp.h:1.10 Sat Jun 10 01:47:56 2000
+++ php4/ext/ftp/php_ftp.h Wed Sep 13 15:00:31 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ftp.h,v 1.10 2000/06/10 08:47:56 andi Exp $ */
+/* $Id: php_ftp.h,v 1.11 2000/09/13 22:00:31 derick Exp $ */
#ifndef _INCLUDED_FTP_H
#define _INCLUDED_FTP_H
@@ -45,6 +45,7 @@
PHP_FUNCTION(ftp_pwd);
PHP_FUNCTION(ftp_cdup);
PHP_FUNCTION(ftp_chdir);
+PHP_FUNCTION(ftp_exec);
PHP_FUNCTION(ftp_mkdir);
PHP_FUNCTION(ftp_rmdir);
PHP_FUNCTION(ftp_nlist);