commit 3312e155c2f31de5cc473cc84314f7a33149b4d3
parent 31c1cc10665e99d87a1b213c0ecc72850b73b34b
Author: ukai <ukai>
Date: Mon, 18 Nov 2002 18:10:35 +0000
[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>
Diffstat:
M | ChangeLog | | | 13 | +++++++++++++ |
M | file.c | | | 19 | ++++++++++++++----- |
M | ftp.c | | | 41 | ++++++++++++++++++++++++----------------- |
3 files changed, 51 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,4 +1,17 @@
2002-11-19 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
+ * [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()
+
+2002-11-19 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03449] Add DOWNLOAD_LIST to doc*/README.func and scripts/w3mhelp.cgi.in
* doc-jp/README.func (DOWNLOAD_LIST): added
diff --git a/file.c b/file.c
@@ -27,6 +27,7 @@
static int frame_source = 0;
+static void FTPhalfclose(InputStream stream);
static int _MoveFile(char *path1, char *path2);
static void uncompress_stream(URLFile *uf);
static FILE *lessopen_stream(char *path);
@@ -1805,6 +1806,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
if (save2tmp(f, tmpf) < 0)
UFclose(&f);
else {
+ UFclose(&f);
if (fmInitialized)
term_raw();
signal(SIGINT, prevtrap);
@@ -1873,7 +1875,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
else
file = guess_save_name(t_buf, pu.file);
doFileSave(f, file);
- UFclose(&f);
+ if (f.scheme == SCM_FTP)
+ FTPhalfclose(f.stream);
+ else
+ UFclose(&f);
return NO_BUFFER;
}
@@ -1899,10 +1904,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
b->sourcefile = image_source;
b->real_type = t;
}
+ UFclose(&f);
if (fmInitialized)
term_raw();
signal(SIGINT, prevtrap);
- UFclose(&f);
return b;
}
#endif
@@ -1952,7 +1957,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
if (DecodeCTE && IStype(f.stream) != IST_ENCODED)
f.stream = newEncodedStream(f.stream, f.encoding);
doFileSave(f, guess_save_name(t_buf, pu.file));
- UFclose(&f);
+ if (f.scheme == SCM_FTP)
+ FTPhalfclose(f.stream);
+ else
+ UFclose(&f);
}
return NO_BUFFER;
}
@@ -6594,11 +6602,13 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf)
if (IStype(uf->stream) != IST_ENCODED)
uf->stream = newEncodedStream(uf->stream, uf->encoding);
if (save2tmp(*uf, cache->file) < 0) {
+ UFclose(uf);
if (fmInitialized)
term_raw();
signal(SIGINT, prevtrap);
return NULL;
}
+ UFclose(uf);
if (fmInitialized)
term_raw();
signal(SIGINT, prevtrap);
@@ -6829,6 +6839,7 @@ openGeneralPagerBuffer(InputStream stream)
#endif
else {
if (doExternal(uf, "-", t, &buf, t_buf)) {
+ UFclose(&uf);
if (buf == NULL || buf == NO_BUFFER)
return buf;
}
@@ -7049,8 +7060,6 @@ save2tmp(URLFile uf, char *tmpf)
term_raw();
signal(SIGINT, prevtrap);
fclose(ff);
- if (uf.scheme == SCM_FTP)
- FTPhalfclose(uf.stream);
current_content_length = 0;
return 0;
}
diff --git a/ftp.c b/ftp.c
@@ -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;
}