1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 08:58:28 +02:00

added ftp_pwd() ftp_cdup() ftp_mkdir() and ftp_rmdir()

This commit is contained in:
Andrew Skalski
1999-09-16 19:03:27 +00:00
parent 93313c576c
commit 13a74e6979
2 changed files with 136 additions and 0 deletions
+132
View File
@@ -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;
}
+4
View File
@@ -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);