From b0a661730f022b85ef0dfd6244a7cef05357856d Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 29 Jan 2003 17:10:17 +0000 Subject: [w3m-dev 03708] Re: Don't stop loading image when moving to next page. * config.h.dist (lstat): define ifndef HAVE_LSTAT * configure (config.h) ditto * display.c (fmTerm): new loadImage (save_current_buf): only ifdef USE_BUFINFO (displayBuffer): new loadImage * etc.c (setup_child): TrapSignal * file.c (loadGeneralFile): TRAP_OFF, TRAP_ON (loadHTMLstream): ditto (loadGopherDir): ditto (loadBuffer): ditto (loadImageBuffer): ditto (getNextPage): ditto (save2tmp): ditto * fm.h (TrapSignal): added (TRAP_ON): added (TRAP_OFF): added * form.c (HAVE_LSTAT): deleted * frame.c (createFrameFile): TRAP_OFF, TRAP_ON * image.c (image_buffer): added (deleteImage): new loadImage (getAllImage): initialize image_buffer (loadImage): rewrite * main.c (main): new loadImage (checkDownloadList): remove ifdef HAVE_LSTAT * news.c (loadNwesgroup): TRAP_ON, TRAP_OFF * proto.h (loadImage): add buf arg * url.c (openSocket): TRAP_ON, TRAP_OFF (check_no_proxy): TRAP_ON, TRAP_OFF From: Hironori SAKAMOTO --- ChangeLog | 38 +++++++++++++++-- config.h.dist | 4 ++ configure | 6 ++- display.c | 18 +++----- etc.c | 3 +- file.c | 132 +++++++++++++++------------------------------------------- fm.h | 14 ++++++- form.c | 9 +--- frame.c | 15 ++----- image.c | 124 +++++++++++++++++++++++++++--------------------------- main.c | 12 +----- news.c | 12 ++---- proto.h | 4 +- url.c | 27 ++++-------- 14 files changed, 182 insertions(+), 236 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a86c01..1f89fb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,43 @@ -2003-01-29 NAKAJIMA Mikio +2003-01-30 Hironori SAKAMOTO + + * [w3m-dev 03708] Re: Don't stop loading image when moving to next page. + * config.h.dist (lstat): define ifndef HAVE_LSTAT + * configure (config.h) ditto + * display.c (fmTerm): new loadImage + (save_current_buf): only ifdef USE_BUFINFO + (displayBuffer): new loadImage + * etc.c (setup_child): TrapSignal + * file.c (loadGeneralFile): TRAP_OFF, TRAP_ON + (loadHTMLstream): ditto + (loadGopherDir): ditto + (loadBuffer): ditto + (loadImageBuffer): ditto + (getNextPage): ditto + (save2tmp): ditto + * fm.h (TrapSignal): added + (TRAP_ON): added + (TRAP_OFF): added + * form.c (HAVE_LSTAT): deleted + * frame.c (createFrameFile): TRAP_OFF, TRAP_ON + * image.c (image_buffer): added + (deleteImage): new loadImage + (getAllImage): initialize image_buffer + (loadImage): rewrite + * main.c (main): new loadImage + (checkDownloadList): remove ifdef HAVE_LSTAT + * news.c (loadNwesgroup): TRAP_ON, TRAP_OFF + * proto.h (loadImage): add buf arg + * url.c (openSocket): TRAP_ON, TRAP_OFF + (check_no_proxy): TRAP_ON, TRAP_OFF + +2003-01-29 Hironori SAKAMOTO * [w3m-dev 03707] Don't stop loading image when moving to next page. * display.c (save_current_buf): required when defined USE_IMAGE (displayBuffer): stop only buffer changed * image.c (loadImage): IMG_FLAG_START load from maxLoadImage -2003-01-29 NAKAJIMA Mikio +2003-01-29 Hironori SAKAMOTO * [w3m-dev 03706] X-Image-URL: support, bug fix of reshapeBuffer() * buffer.c (reshapeBuffer): rewrite @@ -6899,4 +6931,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.722 2003/01/28 16:45:15 ukai Exp $ +$Id: ChangeLog,v 1.723 2003/01/29 17:10:17 ukai Exp $ diff --git a/config.h.dist b/config.h.dist index 58a60da..fbe8d22 100644 --- a/config.h.dist +++ b/config.h.dist @@ -238,6 +238,10 @@ typedef void MySignalHandler; #endif /* HAVE_SRANDOM */ #endif +#ifndef HAVE_LSTAT +#define lstat stat +#endif + #if defined( __CYGWIN32__ ) && !defined( __CYGWIN__ ) #define __CYGWIN__ #endif diff --git a/configure b/configure index 1f347c3..65e94c4 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.95 2003/01/22 16:36:11 ukai Exp $ +# $Id: configure,v 1.96 2003/01/29 17:10:25 ukai Exp $ # Configuration. # @@ -2504,6 +2504,10 @@ $def_ipv6_ss_family #endif /* HAVE_SRANDOM */ #endif +#ifndef HAVE_LSTAT +#define lstat stat +#endif + #if defined( __CYGWIN32__ ) && !defined( __CYGWIN__ ) #define __CYGWIN__ #endif diff --git a/display.c b/display.c index 9f9d028..27cf475 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.58 2003/01/28 16:45:18 ukai Exp $ */ +/* $Id: display.c,v 1.59 2003/01/29 17:10:27 ukai Exp $ */ #include #include "fm.h" @@ -164,7 +164,7 @@ fmTerm(void) refresh(); #ifdef USE_IMAGE if (activeImage) - loadImage(IMG_FLAG_STOP); + loadImage(NULL, IMG_FLAG_STOP); #endif #ifdef USE_MOUSE if (use_mouse) @@ -210,7 +210,7 @@ static int graph_mode = 0; static Linecolor color_mode = 0; #endif -#if defined(USE_BUFINFO) || defined(USE_IMAGE) +#ifdef USE_BUFINFO static Buffer *save_current_buf = NULL; #endif @@ -431,10 +431,7 @@ displayBuffer(Buffer *buf, int mode) if (draw_image_flag) clear(); clearImage(); - if (buf != save_current_buf) - loadImage(IMG_FLAG_STOP); - else - loadImage(IMG_FLAG_START); + loadImage(buf, IMG_FLAG_STOP); image_touch++; draw_image_flag = FALSE; } @@ -472,17 +469,12 @@ displayBuffer(Buffer *buf, int mode) refresh(); #ifdef USE_IMAGE if (activeImage && displayImage && buf->img) { - /* - * loadImage(IMG_FLAG_START); - */ drawImage(); } #endif -#if defined(USE_BUFINFO) || defined(USE_IMAGE) - if (buf != save_current_buf) { #ifdef USE_BUFINFO + if (buf != save_current_buf) { saveBufferInfo(); -#endif save_current_buf = buf; } #endif diff --git a/etc.c b/etc.c index 62b8f25..13adf25 100644 --- a/etc.c +++ b/etc.c @@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.60 2003/01/25 17:42:17 ukai Exp $ */ +/* $Id: etc.c,v 1.61 2003/01/29 17:10:30 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -1367,6 +1367,7 @@ setup_child(int child, int i, int f) close_all_fds_except(i, f); QuietMessage = TRUE; fmInitialized = FALSE; + TrapSignal = FALSE; } pid_t diff --git a/file.c b/file.c index ccc1566..6625b28 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.210 2003/01/28 16:41:05 ukai Exp $ */ +/* $Id: file.c,v 1.211 2003/01/29 17:10:32 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -1583,10 +1583,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, checkRedirection(NULL); load_doc: - if (fmInitialized) - term_raw(); - if (prevtrap) - signal(SIGINT, prevtrap); + TRAP_OFF; url_option.referer = referer; url_option.flag = flag; f = openURL(tpath, &pu, current, &url_option, request, extra_header, of, @@ -1654,10 +1651,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } if (status == HTST_MISSING) { - if (fmInitialized) - term_raw(); - if (prevtrap) - signal(SIGINT, prevtrap); + TRAP_OFF; UFclose(&f); return NULL; } @@ -1665,9 +1659,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, /* openURL() succeeded */ if (SETJMP(AbortLoading) != 0) { /* transfer interrupted */ - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (b) discardBuffer(b); UFclose(&f); @@ -1682,9 +1674,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } if (header_string) header_string = NULL; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (pu.scheme == SCM_HTTP || #ifdef USE_SSL pu.scheme == SCM_HTTPS || @@ -1754,9 +1744,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (ss == NULL) { /* abort */ UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return NULL; } UFclose(&f); @@ -1778,9 +1766,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (ss == NULL) { /* abort */ UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return NULL; } UFclose(&f); @@ -1818,9 +1804,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, case 'm': page = loadGopherDir(&f, &pu, &code); t = "gopher:directory"; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; goto page_loaded; case 's': t = "audio/basic"; @@ -1865,9 +1849,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, UFclose(&f); else { UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; doFileMove(tmpf, guess_save_name(t_buf, pu.file)); } return NO_BUFFER; @@ -1971,9 +1953,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (do_download) { /* download only */ char *file; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (DecodeCTE && IStype(f.stream) != IST_ENCODED) f.stream = newEncodedStream(f.stream, f.encoding); if (pu.scheme == SCM_LOCAL) { @@ -2016,9 +1996,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, b->real_type = t; } UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } #endif @@ -2044,15 +2022,11 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, copyParsedURL(&b->currentURL, &pu); } UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } else { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (pu.scheme == SCM_LOCAL) { UFclose(&f); _doFileCopy(pu.real_file, @@ -2140,9 +2114,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, reAnchorNewsheader(b); #endif preFormUpdateBuffer(b); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } @@ -6572,9 +6544,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) HTMLlineproc1("
Transfer Interrupted!
", &htmlenv1); goto phase2; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; #ifdef JP_CHARSET if (newBuf != NULL && newBuf->document_code != '\0') @@ -6645,25 +6615,19 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) if (htmlenv1.title) newBuf->buffername = htmlenv1.title; if (w3m_halfdump) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; print_internal_information(&htmlenv1); return; } if (w3m_backend) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; print_internal_information(&htmlenv1); backend_halfdump_buf = htmlenv1.buf; return; } phase2: newBuf->trbyte = trbyte + linelen; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; #ifdef JP_CHARSET newBuf->document_code = code; content_charset = '\0'; @@ -6686,22 +6650,16 @@ loadHTMLString(Str page) newBuf = newBuffer(INIT_BUFFER_WIDTH); if (SETJMP(AbortLoading) != 0) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; discardBuffer(newBuf); return NULL; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; init_stream(&f, SCM_LOCAL, newStrStream(page)); loadHTMLstream(&f, newBuf, NULL, TRUE); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; newBuf->topLine = newBuf->firstLine; newBuf->lastLine = newBuf->currentLine; newBuf->currentLine = newBuf->firstLine; @@ -6740,9 +6698,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, char *code) if (SETJMP(AbortLoading) != 0) goto gopher_end; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; #ifdef JP_CHARSET *code = DocumentCode; @@ -6804,9 +6760,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, char *code) } gopher_end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; Strcat_charp(tmp, "\n\n\n"); return tmp; @@ -6839,9 +6793,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf) if (SETJMP(AbortLoading) != 0) { goto _end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (newBuf->sourcefile == NULL && (uf->scheme != SCM_LOCAL || newBuf->mailcap)) { @@ -6906,9 +6858,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf) lineBuf2->length, FOLD_BUFFER_WIDTH, nlines); } _end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; newBuf->topLine = newBuf->firstLine; newBuf->lastLine = newBuf->currentLine; newBuf->currentLine = newBuf->firstLine; @@ -6931,10 +6881,10 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) Str tmp, tmpf; FILE *src = NULL; URLFile f; - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; struct stat st; - loadImage(IMG_FLAG_STOP); + loadImage(newBuf, IMG_FLAG_STOP); image.url = uf->url; image.ext = uf->ext; image.width = -1; @@ -6945,22 +6895,16 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) !stat(cache->file, &st)) goto image_buffer; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; 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); + TRAP_OFF; return NULL; } UFclose(uf); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; cache->loaded = IMG_FLAG_LOADED; cache->index = 0; @@ -7242,9 +7186,7 @@ getNextPage(Buffer *buf, int plen) if (SETJMP(AbortLoading) != 0) { goto pager_end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; init_stream(&uf, SCM_UNKNOWN, NULL); for (i = 0; i < plen; i++) { @@ -7307,9 +7249,7 @@ getNextPage(Buffer *buf, int plen) } } pager_end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; buf->trbyte = trbyte + linelen; #ifdef JP_CHARSET @@ -7342,9 +7282,7 @@ save2tmp(URLFile uf, char *tmpf) if (SETJMP(AbortLoading) != 0) { goto _end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; check = 0; #ifdef USE_NNTP if (uf.scheme == SCM_NEWS) { @@ -7379,9 +7317,7 @@ save2tmp(URLFile uf, char *tmpf) } _end: bcopy(env_bak, AbortLoading, sizeof(JMP_BUF)); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; fclose(ff); current_content_length = 0; return 0; diff --git a/fm.h b/fm.h index 30fd5ab..04a683d 100644 --- a/fm.h +++ b/fm.h @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.109 2003/01/27 16:18:52 ukai Exp $ */ +/* $Id: fm.h,v 1.110 2003/01/29 17:10:37 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -778,6 +778,18 @@ global char MetaRefresh init(FALSE); global char fmInitialized init(FALSE); global char QuietMessage init(FALSE); +global char TrapSignal init(TRUE); +#define TRAP_ON if (TrapSignal) { \ + prevtrap = signal(SIGINT, KeyAbort); \ + if (fmInitialized) \ + term_cbreak(); \ +} +#define TRAP_OFF if (TrapSignal) { \ + if (fmInitialized) \ + term_raw(); \ + if (prevtrap) \ + signal(SIGINT, prevtrap); \ +} extern unsigned char GlobalKeymap[]; extern unsigned char EscKeymap[]; diff --git a/form.c b/form.c index d04f732..29a0992 100644 --- a/form.c +++ b/form.c @@ -1,4 +1,4 @@ -/* $Id: form.c,v 1.29 2003/01/20 15:22:59 ukai Exp $ */ +/* $Id: form.c,v 1.30 2003/01/29 17:10:38 ukai Exp $ */ /* * HTML forms */ @@ -9,13 +9,6 @@ #include "local.h" #include "regex.h" -#ifndef HAVE_LSTAT -/* lstat is identical to stat, only the link itself is statted, not the file - * that is obtained by tracing the links. But on OS/2 systems, there is no - * differences. */ -#define lstat stat -#endif /* not HAVE_LSTAT */ - extern Str *textarea_str; #ifdef MENU_SELECT extern FormSelectOption *select_option; diff --git a/frame.c b/frame.c index 11b863b..ae8e83b 100644 --- a/frame.c +++ b/frame.c @@ -1,4 +1,4 @@ -/* $Id: frame.c,v 1.30 2003/01/20 15:30:20 ukai Exp $ */ +/* $Id: frame.c,v 1.31 2003/01/29 17:10:39 ukai Exp $ */ #include "fm.h" #include "parsetagx.h" #include "myctype.h" @@ -424,15 +424,10 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, if (level == 0) { if (SETJMP(AbortLoading) != 0) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return -1; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); - + TRAP_ON; f->name = "_top"; } @@ -852,9 +847,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, fputs("\n", f1); if (level == 0) { fputs("\n", f1); - signal(SIGINT, prevtrap); - if (fmInitialized) - term_raw(); + TRAP_OFF; } return 0; } diff --git a/image.c b/image.c index aa8942d..7f2847c 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.28 2003/01/28 16:45:19 ukai Exp $ */ +/* $Id: image.c,v 1.30 2003/01/29 17:10:40 ukai Exp $ */ #include "fm.h" #include @@ -243,6 +243,7 @@ static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; static ImageCache **image_cache = NULL; +static Buffer *image_buffer = NULL; void deleteImage(Buffer *buf) @@ -263,7 +264,7 @@ deleteImage(Buffer *buf) a->image->cache->index < 0) unlink(a->image->cache->file); } - loadImage(IMG_FLAG_STOP); + loadImage(NULL, IMG_FLAG_STOP); } void @@ -274,6 +275,7 @@ getAllImage(Buffer *buf) ParsedURL *current; int i; + image_buffer = buf; if (!buf) return; buf->image_loaded = TRUE; @@ -318,11 +320,11 @@ showImageProgress(Buffer *buf) } void -loadImage(int flag) +loadImage(Buffer *buf, int flag) { ImageCache *cache; struct stat st; - int wait_st, i; + int wait_st, i, draw = FALSE; if (maxLoadImage > MAX_LOAD_IMAGE) maxLoadImage = MAX_LOAD_IMAGE; @@ -334,74 +336,71 @@ loadImage(int flag) image_cache = New_N(ImageCache *, MAX_LOAD_IMAGE); bzero(image_cache, sizeof(ImageCache *) * MAX_LOAD_IMAGE); } - - if (flag == IMG_FLAG_STOP || flag == IMG_FLAG_START) { - if (flag == IMG_FLAG_STOP) - i = 0; - else - i = maxLoadImage; - for ( ; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = 0; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (lstat(cache->touch, &st)) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; +*/ + cache->pid = 0; + } + if (!stat(cache->file, &st)) { + cache->loaded = IMG_FLAG_LOADED; + if (getImageSize(cache)) { + if (image_buffer) + image_buffer->need_reshape = TRUE; } - unlink(cache->touch); - image_cache[i] = NULL; + draw = TRUE; } - image_list = NULL; - image_file = NULL; - n_load_image = maxLoadImage; - return; + else + cache->loaded = IMG_FLAG_ERROR; + unlink(cache->touch); + image_cache[i] = NULL; } - { - int draw = FALSE; - for (i = 0; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; -#ifdef HAVE_LSTAT - if (lstat(cache->touch, &st)) -#else - if (stat(cache->touch, &st)) -#endif - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = (buf != image_buffer) ? 0 : maxLoadImage; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; - } - if (!stat(cache->file, &st)) { - cache->loaded = IMG_FLAG_LOADED; - if (getImageSize(cache)) { - if (CurrentTab && Currentbuf) - Currentbuf->need_reshape = TRUE; - } - draw = TRUE; - } - else - cache->loaded = IMG_FLAG_ERROR; - unlink(cache->touch); - image_cache[i] = NULL; - } - if (draw && CurrentTab && Currentbuf) { - drawImage(); - showImageProgress(Currentbuf); +*/ + cache->pid = 0; } + unlink(cache->touch); + image_cache[i] = NULL; } + if (flag == IMG_FLAG_STOP) { + image_list = NULL; + image_file = NULL; + n_load_image = maxLoadImage; + image_buffer = NULL; + return; + } + + if (draw && image_buffer) { + drawImage(); + showImageProgress(image_buffer); + } + + image_buffer = buf; + if (!image_list) return; for (i = 0; i < n_load_image; i++) { @@ -416,8 +415,8 @@ loadImage(int flag) } image_list = NULL; image_file = NULL; - if (CurrentTab && Currentbuf) - displayBuffer(Currentbuf, B_NORMAL); + if (image_buffer) + displayBuffer(image_buffer, B_NORMAL); return; } if (cache->loaded == IMG_FLAG_UNLOADED) @@ -428,7 +427,10 @@ loadImage(int flag) flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; +/* setup_child(TRUE, 0, -1); +*/ + setup_child(FALSE, 0, -1); image_source = cache->file; b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL); if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6)) diff --git a/main.c b/main.c index d76105d..7bf596f 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.202 2003/01/28 16:34:25 ukai Exp $ */ +/* $Id: main.c,v 1.203 2003/01/29 17:10:41 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include @@ -1039,7 +1039,7 @@ main(int argc, char **argv, char **envp) if (activeImage && displayImage && Currentbuf->img && !Currentbuf->image_loaded) { do { - loadImage(IMG_FLAG_NEXT); + loadImage(Currentbuf, IMG_FLAG_NEXT); } while (sleep_till_anykey(1, 0) <= 0); } #endif @@ -6089,11 +6089,7 @@ checkDownloadList(void) if (!FirstDL) return FALSE; for (d = FirstDL; d != NULL; d = d->next) { -#ifdef HAVE_LSTAT if (!d->ok && !lstat(d->lock, &st)) -#else - if (!d->ok && !stat(d->lock, &st)) -#endif return TRUE; } return FALSE; @@ -6131,11 +6127,7 @@ DownloadListBuffer(void) DOWNLOAD_LIST_TITLE "\n" "

\n"); for (d = LastDL; d != NULL; d = d->prev) { -#ifdef HAVE_LSTAT if (lstat(d->lock, &st)) -#else - if (stat(d->lock, &st)) -#endif d->ok = TRUE; Strcat_charp(src, "
\n");
 	Strcat(src, Sprintf("%s\n  --> %s\n  ", html_quote(d->url),
diff --git a/news.c b/news.c
index 840bbd1..40cd983 100644
--- a/news.c
+++ b/news.c
@@ -1,4 +1,4 @@
-/* $Id: news.c,v 1.14 2003/01/15 16:24:25 ukai Exp $ */
+/* $Id: news.c,v 1.15 2003/01/29 17:10:49 ukai Exp $ */
 #include "fm.h"
 #include "myctype.h"
 #include 
@@ -314,7 +314,7 @@ loadNewsgroup(ParsedURL *pu, char *code)
     char *volatile scheme, *volatile group, *volatile list;
     int status, i, first, last;
     volatile int flag = 0, start = 0, end = 0;
-    MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL;
+    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
 
     if (current_news.host == NULL || !pu->file || *pu->file == '\0')
 	return NULL;
@@ -346,9 +346,7 @@ loadNewsgroup(ParsedURL *pu, char *code)
 	Strcat_charp(page, "\n

Transfer Interrupted!\n"); goto news_end; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; tmp = news_command(¤t_news, "GROUP", group, &status); if (status != 211) @@ -489,9 +487,7 @@ loadNewsgroup(ParsedURL *pu, char *code) news_end: Strcat_charp(page, "\n\n"); - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return page; } diff --git a/proto.h b/proto.h index ad77328..a343587 100644 --- a/proto.h +++ b/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.84 2003/01/23 18:37:21 ukai Exp $ */ +/* $Id: proto.h,v 1.85 2003/01/29 17:10:51 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -184,7 +184,7 @@ extern void restore_fonteffect(struct html_feed_environ *h_env, #ifdef USE_IMAGE extern void deleteImage(Buffer *buf); extern void getAllImage(Buffer *buf); -extern void loadImage(int flag); +extern void loadImage(Buffer *buf, int flag); extern ImageCache *getImage(Image * image, ParsedURL *current, int flag); extern int getImageSize(ImageCache * cache); #endif diff --git a/url.c b/url.c index 489c6a0..52030c8 100644 --- a/url.c +++ b/url.c @@ -1,4 +1,4 @@ -/* $Id: url.c,v 1.69 2003/01/17 17:06:06 ukai Exp $ */ +/* $Id: url.c,v 1.70 2003/01/29 17:10:53 ukai Exp $ */ #include "fm.h" #include #include @@ -457,7 +457,7 @@ openSocket(char *const hostname, int a1, a2, a3, a4; unsigned long adr; #endif /* not INET6 */ - MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (fmInitialized) { message(Sprintf("Opening socket...")->ptr, 0, 0); @@ -471,9 +471,7 @@ openSocket(char *const hostname, close(sock); goto error; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (hostname == NULL) { #ifdef SOCK_DEBUG sock_log("openSocket() failed. reason: Bad hostname \"%s\"\n", @@ -618,15 +616,10 @@ openSocket(char *const hostname, } #endif /* not INET6 */ - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return sock; error: - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); - + TRAP_OFF; return -1; } @@ -1955,7 +1948,7 @@ check_no_proxy(char *domain) { TextListItem *tl; volatile int ret = 0; - MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (NO_proxy_domains == NULL || NO_proxy_domains->nitem == 0 || domain == NULL) @@ -1974,9 +1967,7 @@ check_no_proxy(char *domain) ret = 0; goto end; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; { #ifndef INET6 struct hostent *he; @@ -2053,9 +2044,7 @@ check_no_proxy(char *domain) #endif /* INET6 */ } end: - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return ret; } -- cgit v1.2.3