[w3m-dev 03444] download from ftp.

* file.c (FTPhalfclose: static
	(loadGeneralFile): UFclose
			FTPhalfclose for SCM_FTP
			UFclose before signal back
	(loadImageBuffer): UFclose before signal back
	(openGeneralPagerBuffer): UFclose
* ftp.c (ftp_fclose): added
	(Ftpfclose): dont read response(), but ftp_fclose()
	(FtpBye): ftp_fclose()
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-11-18 18:10:35 +00:00
parent f551e984ec
commit 4f37c0a28c
3 changed files with 54 additions and 25 deletions

43
ftp.c
View File

@@ -1,4 +1,4 @@
/* $Id: ftp.c,v 1.13 2002/10/30 17:21:42 ukai Exp $ */
/* $Id: ftp.c,v 1.14 2002/11/18 18:12:35 ukai Exp $ */
#include <stdio.h>
#include <pwd.h>
#include <Str.h>
@@ -249,6 +249,27 @@ ftp_pasv(FTP ftp)
return 0;
}
static int
ftp_fclose(FTP ftp)
{
int control_closed = 0;
if (ftp->rcontrol != NULL) {
fclose(ftp->rcontrol);
ftp->rcontrol = NULL;
control_closed = 1;
}
if (ftp->wcontrol != NULL) {
fclose(ftp->wcontrol);
ftp->wcontrol = NULL;
control_closed = 1;
}
if (control_closed && ftp->data != NULL) {
fclose(ftp->data);
ftp->data = NULL;
}
}
int
FtpCwd(FTP ftp, char *path)
{
@@ -298,7 +319,7 @@ Ftpfclose(FILE * f)
fclose(f);
if (f == current_ftp->data)
current_ftp->data = NULL;
read_response(current_ftp);
ftp_fclose(current_ftp);
return 0;
}
@@ -346,7 +367,7 @@ int
FtpBye(FTP ftp)
{
Str tmp;
int ret_val, control_closed;
int ret_val;
fwrite("QUIT\r\n", 6, sizeof(char), ftp->wcontrol);
fflush(ftp->wcontrol);
@@ -355,21 +376,7 @@ FtpBye(FTP ftp)
ret_val = -1;
else
ret_val = 0;
control_closed = 0;
if (ftp->rcontrol != NULL) {
fclose(ftp->rcontrol);
ftp->rcontrol = NULL;
control_closed = 1;
}
if (ftp->wcontrol != NULL) {
fclose(ftp->wcontrol);
ftp->wcontrol = NULL;
control_closed = 1;
}
if (control_closed && ftp->data != NULL) {
fclose(ftp->data);
ftp->data = NULL;
}
ftp_fclose(ftp);
return ret_val;
}