w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 4e65e6dd3b56d51336d879f607ecbea2e568cedc
parent e2e9336edf325fbefbbcd953ce6e8a00939c7ee4
Author: ukai <ukai>
Date:   Fri, 10 Jan 2003 17:06:17 +0000

[w3m-dev 03632] cleanup (don't close connection of news server)
* file.c (loadSomething): remove UFclose nntp:,news:
	(loadFile): UFclose
	(loadGeneralFile): always UFclose
* html.h (UFclose): only reset when ISclose ==0
* istream.c (ISclose): return int
	(ISfileno): flag IST_UNCLOSE
* istream.h (ISclose): return int
	(IST_UNCLOSE): added
* news.c (news_close): reset IST_UNCLOSE
	(news_open): set IST_UNCLOSE
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 14++++++++++++++
Mfile.c | 16+++++++---------
Mhtml.h | 2+-
Mistream.c | 10++++++----
Mistream.h | 3++-
Mnews.c | 2++
6 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,19 @@ 2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03632] cleanup (don't close connection of news server) + * file.c (loadSomething): remove UFclose nntp:,news: + (loadFile): UFclose + (loadGeneralFile): always UFclose + * html.h (UFclose): only reset when ISclose ==0 + * istream.c (ISclose): return int + (ISfileno): flag IST_UNCLOSE + * istream.h (ISclose): return int + (IST_UNCLOSE): added + * news.c (news_close): reset IST_UNCLOSE + (news_open): set IST_UNCLOSE + +2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03631] display current form item * form.c (form2str): rewrite * istream.c (ssl_get_certificate): fix typo diff --git a/file.c b/file.c @@ -225,8 +225,6 @@ loadSomething(URLFile *f, buf->real_scheme = f->scheme; if (f->scheme == SCM_LOCAL && buf->sourcefile == NULL) buf->sourcefile = path; - if (f->scheme != SCM_NNTP && f->scheme != SCM_NEWS) - UFclose(f); return buf; } @@ -485,7 +483,9 @@ loadFile(char *path) #ifdef JP_CHARSET content_charset = '\0'; #endif - return loadSomething(&uf, path, loadBuffer, buf); + buf = loadSomething(&uf, path, loadBuffer, buf); + UFclose(&uf); + return buf; } int @@ -1942,7 +1942,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, doFileSave(f, file); if (f.scheme == SCM_FTP) FTPhalfclose(f.stream); - else if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) + else UFclose(&f); return NO_BUFFER; } @@ -2004,8 +2004,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (b->currentURL.host == NULL && b->currentURL.file == NULL) copyParsedURL(&b->currentURL, &pu); } - if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) - UFclose(&f); + UFclose(&f); if (fmInitialized) term_raw(); signal(SIGINT, prevtrap); @@ -2027,7 +2026,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, doFileSave(f, guess_save_name(t_buf, pu.file)); if (f.scheme == SCM_FTP) FTPhalfclose(f.stream); - else if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) + else UFclose(&f); } return NO_BUFFER; @@ -2045,9 +2044,8 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, #endif frame_source = flag & RG_FRAME_SRC; b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf); + UFclose(&f); frame_source = 0; - if (f.scheme != SCM_NNTP && f.scheme != SCM_NEWS) - UFclose(&f); if (b) { b->real_scheme = f.scheme; b->real_type = real_type; diff --git a/html.h b/html.h @@ -14,7 +14,7 @@ #define UFgetc(f) ISgetc((f)->stream) #define UFundogetc(f) ISundogetc((f)->stream) #define UFread(f,buf,len) ISread((f)->stream,buf,len) -#define UFclose(f) (ISclose((f)->stream), (f)->stream = NULL) +#define UFclose(f) (ISclose((f)->stream) == 0 && ((f)->stream = NULL)) struct cmdtable { char *cmdname; diff --git a/istream.c b/istream.c @@ -176,15 +176,17 @@ newEncodedStream(InputStream is, char encoding) return stream; } -void +int ISclose(InputStream stream) { MySignalHandler(*prevtrap) (); - if (stream == NULL || stream->base.close == NULL) - return; + if (stream == NULL || stream->base.close == NULL || + stream->base.type & IST_UNCLOSE) + return -1; prevtrap = signal(SIGINT, SIG_IGN); stream->base.close(stream->base.handle); signal(SIGINT, prevtrap); + return 0; } int @@ -336,7 +338,7 @@ ISfileno(InputStream stream) { if (stream == NULL) return -1; - switch (IStype(stream)) { + switch (IStype(stream) & ~IST_UNCLOSE) { case IST_BASIC: return *(int *)stream->base.handle; case IST_FILE: diff --git a/istream.h b/istream.h @@ -116,7 +116,7 @@ extern InputStream newStrStream(Str s); extern InputStream newSSLStream(SSL * ssl, int sock); #endif extern InputStream newEncodedStream(InputStream is, char encoding); -extern void ISclose(InputStream stream); +extern int ISclose(InputStream stream); extern int ISgetc(InputStream stream); extern int ISundogetc(InputStream stream); extern Str StrISgets(InputStream stream); @@ -134,6 +134,7 @@ extern Str ssl_get_certificate(SSL *ssl, char *hostname); #define IST_STR 2 #define IST_SSL 3 #define IST_ENCODED 4 +#define IST_UNCLOSE 0x10 #define IStype(stream) ((stream)->base.type) #define is_eos(stream) ISeos(stream) diff --git a/news.c b/news.c @@ -58,6 +58,7 @@ news_close(News * news) if (!news->host) return; if (news->rf) { + IStype(news->rf) &= ~IST_UNCLOSE; ISclose(news->rf); news->rf = NULL; } @@ -80,6 +81,7 @@ news_open(News * news) news->wf = fdopen(dup(sock), "wb"); if (!news->rf || !news->wf) goto open_err; + IStype(news->rf) |= IST_UNCLOSE; news_command(news, NULL, &status); if (status != 200 && status != 201) goto open_err;