cvs: /php4/ext/ftp ftp.c ftp.h

From: Date: Thu, 16 Sep 1999 19:03:28 +0000
Subject: cvs: /php4/ext/ftp ftp.c ftp.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-4533@lists.php.net to get a copy of this message
askalski Thu Sep 16 15:03:28 1999 EDT Modified files: /php4/ext/ftp ftp.c ftp.h Log: added ftp_pwd() ftp_cdup() ftp_mkdir() and ftp_rmdir() Index: php4/ext/ftp/ftp.c diff -u php4/ext/ftp/ftp.c:1.2 php4/ext/ftp/ftp.c:1.3 --- php4/ext/ftp/ftp.c:1.2 Thu Sep 16 14:38:11 1999 +++ php4/ext/ftp/ftp.c Thu Sep 16 15:03:27 1999 @@ -43,7 +43,11 @@ function_entry php3_ftp_functions[] = { PHP_FE(ftp_connect, NULL) PHP_FE(ftp_login, NULL) + PHP_FE(ftp_pwd, NULL) + PHP_FE(ftp_cdup, NULL) PHP_FE(ftp_chdir, NULL) + PHP_FE(ftp_mkdir, NULL) + PHP_FE(ftp_rmdir, NULL) PHP_FE(ftp_nlist, NULL) PHP_FE(ftp_listraw, NULL) PHP_FE(ftp_systype, NULL) @@ -141,6 +145,65 @@ RETURN_TRUE; } +PHP_FUNCTION(ftp_pwd) +{ + pval *arg1; + int id, type; + netbuf *net; + char buf[512]; + + /* arg1 - netbuf + */ + if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + + id = arg1->value.lval; + net = php3_list_find(id, &type); + if (!net || type != le_netbuf) { + php_error(E_WARNING, "Unable to find netbuf %d", id); + RETURN_FALSE; + } + + if (!FtpPwd(buf, sizeof(buf), net)) { + php_error(E_WARNING, "FtpPwd: %s", FtpLastResponse(net)); + RETURN_FALSE; + } + + RETURN_STRING(buf, 1); +} + +PHP_FUNCTION(ftp_cdup) +{ + pval *arg1; + int id, type; + netbuf *net; + + /* arg1 - netbuf + */ + if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + + id = arg1->value.lval; + net = php3_list_find(id, &type); + if (!net || type != le_netbuf) { + php_error(E_WARNING, "Unable to find netbuf %d", id); + RETURN_FALSE; + } + + if (!FtpCDUp(net)) { + php_error(E_WARNING, "FtpCdup: %s", FtpLastResponse(net)); + RETURN_FALSE; + } + + RETURN_TRUE; +} + PHP_FUNCTION(ftp_chdir) { pval *arg1, *arg2; @@ -175,6 +238,74 @@ RETURN_TRUE; } +PHP_FUNCTION(ftp_mkdir) +{ + pval *arg1, *arg2; + int id, type; + netbuf *net; + + /* arg1 - netbuf + * arg2 - directory + */ + if ( ARG_COUNT(ht) != 2 || + getParameters(ht, 2, &arg1, &arg2) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + + id = arg1->value.lval; + net = php3_list_find(id, &type); + if (!net || type != le_netbuf) { + php_error(E_WARNING, "Unable to find netbuf %d", id); + RETURN_FALSE; + } + + /* change directories */ + if (!FtpMkdir(arg2->value.str.val, net)) { + php_error(E_WARNING, "FtpMkdir: %s", FtpLastResponse(net)); + RETURN_FALSE; + } + + RETURN_TRUE; +} + +PHP_FUNCTION(ftp_rmdir) +{ + pval *arg1, *arg2; + int id, type; + netbuf *net; + + /* arg1 - netbuf + * arg2 - directory + */ + if ( ARG_COUNT(ht) != 2 || + getParameters(ht, 2, &arg1, &arg2) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + + id = arg1->value.lval; + net = php3_list_find(id, &type); + if (!net || type != le_netbuf) { + php_error(E_WARNING, "Unable to find netbuf %d", id); + RETURN_FALSE; + } + + /* change directories */ + if (!FtpRmdir(arg2->value.str.val, net)) { + php_error(E_WARNING, "FtpRmdir: %s", FtpLastResponse(net)); + RETURN_FALSE; + } + + RETURN_TRUE; +} + PHP_FUNCTION(ftp_nlist) { pval *arg1, *arg2; @@ -356,6 +487,7 @@ } if (!FtpSysType(buf, sizeof(buf), net)) { + php_error(E_WARNING, "FtpSysType: %s", FtpLastResponse(net)); RETURN_FALSE; } Index: php4/ext/ftp/ftp.h diff -u php4/ext/ftp/ftp.h:1.2 php4/ext/ftp/ftp.h:1.3 --- php4/ext/ftp/ftp.h:1.2 Thu Sep 16 14:38:11 1999 +++ php4/ext/ftp/ftp.h Thu Sep 16 15:03:27 1999 @@ -1,4 +1,4 @@ -/* $Id: ftp.h,v 1.2 1999/09/16 18:38:11 askalski Exp $ */ +/* $Id: ftp.h,v 1.3 1999/09/16 19:03:27 askalski Exp $ */ #ifndef _INCLUDED_FTP_H #define _INCLUDED_FTP_H @@ -17,7 +17,11 @@ PHP_FUNCTION(ftp_connect); PHP_FUNCTION(ftp_login); +PHP_FUNCTION(ftp_pwd); +PHP_FUNCTION(ftp_cdup); PHP_FUNCTION(ftp_chdir); +PHP_FUNCTION(ftp_mkdir); +PHP_FUNCTION(ftp_rmdir); PHP_FUNCTION(ftp_nlist); PHP_FUNCTION(ftp_listraw); PHP_FUNCTION(ftp_systype);

« previous php.version4 (#4533) next »