cvs: /php3/functions ftp.c ftp.h php_ftp.c php_ftp.h

From: Date: Tue, 22 Feb 2000 20:51:06 +0000
Subject: cvs: /php3/functions ftp.c ftp.h php_ftp.c php_ftp.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-15805@lists.php.net to get a copy of this message
askalski Tue Feb 22 12:51:06 2000 EDT Modified files: /php3/functions ftp.c ftp.h php_ftp.c php_ftp.h Log: added ftp_site() to the ftp module Index: php3/functions/ftp.c diff -u php3/functions/ftp.c:1.15 php3/functions/ftp.c:1.16 --- php3/functions/ftp.c:1.15 Wed Feb 16 08:05:49 2000 +++ php3/functions/ftp.c Tue Feb 22 12:51:05 2000 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.c,v 1.15 2000/02/16 16:05:49 askalski Exp $ */ +/* $Id: ftp.c,v 1.16 2000/02/22 20:51:05 askalski Exp $ */ #include "php.h" @@ -171,7 +171,7 @@ { if (ftp == NULL) return NULL; - if (ftp->fd) + if (ftp->fd != -1) close(ftp->fd); ftp_gc(ftp); free(ftp); @@ -681,6 +681,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: php3/functions/ftp.h diff -u php3/functions/ftp.h:1.9 php3/functions/ftp.h:1.10 --- php3/functions/ftp.h:1.9 Sun Jan 9 03:06:00 2000 +++ php3/functions/ftp.h Tue Feb 22 12:51:05 2000 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.h,v 1.9 2000/01/09 11:06:00 fmk Exp $ */ +/* $Id: ftp.h,v 1.10 2000/02/22 20:51:05 askalski Exp $ */ #ifndef _FTP_H #define _FTP_H @@ -160,5 +160,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: php3/functions/php_ftp.c diff -u php3/functions/php_ftp.c:1.8 php3/functions/php_ftp.c:1.9 --- php3/functions/php_ftp.c:1.8 Sun Jan 9 03:06:00 2000 +++ php3/functions/php_ftp.c Tue Feb 22 12:51:05 2000 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.c,v 1.8 2000/01/09 11:06:00 fmk Exp $ */ +/* $Id: php_ftp.c,v 1.9 2000/02/22 20:51:05 askalski Exp $ */ #include "php.h" @@ -66,6 +66,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} }; @@ -773,6 +774,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: php3/functions/php_ftp.h diff -u php3/functions/php_ftp.h:1.7 php3/functions/php_ftp.h:1.8 --- php3/functions/php_ftp.h:1.7 Sun Jan 9 03:06:00 2000 +++ php3/functions/php_ftp.h Tue Feb 22 12:51:05 2000 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.h,v 1.7 2000/01/09 11:06:00 fmk Exp $ */ +/* $Id: php_ftp.h,v 1.8 2000/02/22 20:51:05 askalski Exp $ */ #ifndef _INCLUDED_FTP_H #define _INCLUDED_FTP_H @@ -69,6 +69,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 php3_ftp_module_ptr

« previous php.dev (#15805) next »