pollita Thu Jan 30 23:54:58 2003 EDT Modified files: /php4/ext/ftp ftp.c ftp.h php_ftp.c php_ftp.h Log: Add ftp_raw() to send raw command strings to an FTP server. Index: php4/ext/ftp/ftp.c diff -u php4/ext/ftp/ftp.c:1.75 php4/ext/ftp/ftp.c:1.76 --- php4/ext/ftp/ftp.c:1.75 Mon Jan 27 14:51:50 2003 +++ php4/ext/ftp/ftp.c Thu Jan 30 23:54:57 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.c,v 1.75 2003/01/27 19:51:50 pollita Exp $ */ +/* $Id: ftp.c,v 1.76 2003/01/31 04:54:57 pollita Exp $ */ #include "php.h" @@ -440,6 +440,27 @@ } return 1; +} +/* }}} */ + +/* {{{ ftp_raw + */ +void +ftp_raw(ftpbuf_t *ftp, const char *cmd, zval *return_value) +{ + if (ftp == NULL || cmd == NULL) { + RETURN_NULL(); + } + if (!ftp_putcmd(ftp, cmd, NULL)) { + RETURN_NULL(); + } + array_init(return_value); + while (ftp_readline(ftp)) { + add_next_index_string(return_value, ftp->inbuf, 1); + if (isdigit(ftp->inbuf[0]) && isdigit(ftp->inbuf[1]) && +isdigit(ftp->inbuf[2]) && ftp->inbuf[3] == ' ') { + return; + } + } } /* }}} */ Index: php4/ext/ftp/ftp.h diff -u php4/ext/ftp/ftp.h:1.35 php4/ext/ftp/ftp.h:1.36 --- php4/ext/ftp/ftp.h:1.35 Mon Jan 27 14:51:50 2003 +++ php4/ext/ftp/ftp.h Thu Jan 30 23:54:57 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftp.h,v 1.35 2003/01/27 19:51:50 pollita Exp $ */ +/* $Id: ftp.h,v 1.36 2003/01/31 04:54:57 pollita Exp $ */ #ifndef FTP_H #define FTP_H @@ -120,6 +120,9 @@ /* exec a command [special features], return true on success, false on error */ int ftp_exec(ftpbuf_t *ftp, const char *cmd); + +/* send a raw ftp command, return response as a hashtable, NULL on error */ +void ftp_raw(ftpbuf_t *ftp, const char *cmd, zval *return_value); /* 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.81 php4/ext/ftp/php_ftp.c:1.82 --- php4/ext/ftp/php_ftp.c:1.81 Mon Jan 27 14:51:50 2003 +++ php4/ext/ftp/php_ftp.c Thu Jan 30 23:54:57 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.c,v 1.81 2003/01/27 19:51:50 pollita Exp $ */ +/* $Id: php_ftp.c,v 1.82 2003/01/31 04:54:57 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -56,6 +56,7 @@ PHP_FE(ftp_cdup, NULL) PHP_FE(ftp_chdir, NULL) PHP_FE(ftp_exec, NULL) + PHP_FE(ftp_raw, NULL) PHP_FE(ftp_mkdir, NULL) PHP_FE(ftp_rmdir, NULL) PHP_FE(ftp_chmod, NULL) @@ -328,6 +329,26 @@ } RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto array ftp_raw(resource stream, string command) + Sends a literal command to the FTP server */ +PHP_FUNCTION(ftp_raw) +{ + zval *z_ftp; + ftpbuf_t *ftp; + char *cmd; + int cmd_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &cmd, +&cmd_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); + + /* execute arbitrary ftp command */ + ftp_raw(ftp, cmd, return_value); } /* }}} */ Index: php4/ext/ftp/php_ftp.h diff -u php4/ext/ftp/php_ftp.h:1.23 php4/ext/ftp/php_ftp.h:1.24 --- php4/ext/ftp/php_ftp.h:1.23 Sun Jan 26 21:54:12 2003 +++ php4/ext/ftp/php_ftp.h Thu Jan 30 23:54:57 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.h,v 1.23 2003/01/27 02:54:12 pollita Exp $ */ +/* $Id: php_ftp.h,v 1.24 2003/01/31 04:54:57 pollita Exp $ */ #ifndef _INCLUDED_FTP_H #define _INCLUDED_FTP_H @@ -43,6 +43,7 @@ PHP_FUNCTION(ftp_cdup); PHP_FUNCTION(ftp_chdir); PHP_FUNCTION(ftp_exec); +PHP_FUNCTION(ftp_raw); PHP_FUNCTION(ftp_mkdir); PHP_FUNCTION(ftp_rmdir); PHP_FUNCTION(ftp_chmod);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php