summaryrefslogtreecommitdiff
path: root/ext/ftp
diff options
context:
space:
mode:
authorAndrew Skalski <askalski@php.net>1999-09-16 19:03:27 +0000
committerAndrew Skalski <askalski@php.net>1999-09-16 19:03:27 +0000
commit13a74e697959ea110e9daf54946bd417872feee4 (patch)
tree3d9c7484f79ef079782a4174306dd210b5e06bdd /ext/ftp
parent93313c576c1a98779d3e5e11e239e6cf8eb760b7 (diff)
downloadphp-git-13a74e697959ea110e9daf54946bd417872feee4.tar.gz
added ftp_pwd() ftp_cdup() ftp_mkdir() and ftp_rmdir()
Diffstat (limited to 'ext/ftp')
-rw-r--r--ext/ftp/ftp.c132
-rw-r--r--ext/ftp/ftp.h4
2 files changed, 136 insertions, 0 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 8eaadd682e..c90bfea020 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -43,7 +43,11 @@ static int le_netbuf;
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 @@ PHP_FUNCTION(ftp_login)
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 @@ PHP_FUNCTION(ftp_chdir)
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 @@ PHP_FUNCTION(ftp_systype)
}
if (!FtpSysType(buf, sizeof(buf), net)) {
+ php_error(E_WARNING, "FtpSysType: %s", FtpLastResponse(net));
RETURN_FALSE;
}
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
index e23b659ae5..1a71ba70a1 100644
--- a/ext/ftp/ftp.h
+++ b/ext/ftp/ftp.h
@@ -17,7 +17,11 @@ extern PHP_MINIT_FUNCTION(ftp);
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);