aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-02-04 16:26:27 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-02-04 16:26:27 +0000
commit8fdd83b62ac34041dc3d73376a093197166bf640 (patch)
tree4387ee67a5fc538163ed232dea19fbd1ab44b3d2 /file.c
parent[w3m-dev 02984] inline image improvements and cleanups (diff)
downloadw3m-release-0-2-5-1.tar.gz
w3m-release-0-2-5-1.zip
w3m 0.2.5.1 - backport from w3m/0.2.5+cvs-1.299release-0-2-5-1branch-0-2-5
Diffstat (limited to '')
-rw-r--r--file.c728
1 files changed, 127 insertions, 601 deletions
diff --git a/file.c b/file.c
index 3ce3b46..f2c6ba1 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.63 2002/02/04 15:26:44 ukai Exp $ */
+/* $Id: file.c,v 1.54.2.1 2002/02/04 16:26:28 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -25,9 +25,6 @@
#define min(a,b) ((a) > (b) ? (b) : (a))
#endif /* not min */
-static int frame_source = 0;
-
-static int _MoveFile(char *path1, char *path2);
static void uncompress_stream(URLFile *uf);
static FILE *lessopen_stream(char *path);
static Buffer *loadcmdout(char *cmd,
@@ -50,13 +47,6 @@ static JMP_BUF AbortLoading;
static struct table *tables[MAX_TABLE];
static struct table_mode table_mode[MAX_TABLE];
-#ifdef USE_IMAGE
-static ParsedURL *cur_baseURL = NULL;
-#ifdef JP_CHARSET
-static char cur_document_code;
-#endif
-#endif
-
static Str cur_select;
static Str select_str;
static int select_is_multiple;
@@ -123,9 +113,6 @@ static int form_sp = 0;
static int current_content_length;
static int cur_hseq;
-#ifdef USE_IMAGE
-static int cur_iseq;
-#endif
#define MAX_UL_LEVEL 9
#ifdef KANJI_SYMBOLS
@@ -1436,10 +1423,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
/* openURL failure: it means either (1) the requested URL is a directory name
* on an FTP server, or (2) is a local directory name.
*/
- if (fmInitialized)
+ if (fmInitialized && prevtrap) {
term_raw();
- if (prevtrap)
signal(SIGINT, prevtrap);
+ }
switch (f.scheme) {
case SCM_FTPDIR:
{
@@ -1514,9 +1501,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
/* openURL() succeeded */
if (SETJMP(AbortLoading) != 0) {
/* transfer interrupted */
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
if (b)
discardBuffer(b);
UFclose(&f);
@@ -1531,9 +1519,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
}
if (header_string)
header_string = NULL;
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
+ if (fmInitialized) {
+ prevtrap = signal(SIGINT, KeyAbort);
term_cbreak();
+ }
if (pu.scheme == SCM_HTTP ||
#ifdef USE_SSL
pu.scheme == SCM_HTTPS ||
@@ -1766,17 +1755,14 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
if (real_type == NULL)
real_type = t;
proc = loadBuffer;
-#ifdef USE_IMAGE
- cur_baseURL = New(ParsedURL);
- copyParsedURL(cur_baseURL, &pu);
-#endif
if (do_download) {
/* download only */
char *file;
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
if (DecodeCTE && IStype(f.stream) != IST_ENCODED)
f.stream = newEncodedStream(f.stream, f.encoding);
if (pu.scheme == SCM_LOCAL)
@@ -1800,33 +1786,11 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
f.compression = CMP_NOCOMPRESS;
}
}
-#ifdef USE_IMAGE
- if (image_source) {
- Buffer *b = NULL;
- if (IStype(f.stream) != IST_ENCODED)
- f.stream = newEncodedStream(f.stream, f.encoding);
- if (save2tmp(f, image_source) == 0) {
- b = newBuffer(INIT_BUFFER_WIDTH);
- b->sourcefile = image_source;
- b->real_type = t;
- }
- if (fmInitialized)
- term_raw();
- signal(SIGINT, prevtrap);
- UFclose(&f);
- return b;
- }
-#endif
if (!strcasecmp(t, "text/html"))
proc = loadHTMLBuffer;
else if (is_plain_text_type(t))
proc = loadBuffer;
-#ifdef USE_IMAGE
- else if (activeImage && displayImage && !useExtImageViewer &&
- !w3m_dump && !strncasecmp(t, "image/", 6))
- proc = loadImageBuffer;
-#endif
#ifdef USE_GOPHER
else if (!strcasecmp(t, "gopher:directory")) {
proc = loadGopherDir;
@@ -1844,15 +1808,17 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
copyParsedURL(&b->currentURL, &pu);
}
UFclose(&f);
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
return b;
}
else {
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
if (pu.scheme == SCM_LOCAL) {
UFclose(&f);
doFileCopy(pu.real_file,
@@ -1886,9 +1852,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
t_buf->ssl_certificate = s->ptr;
}
#endif
- frame_source = flag & RG_FRAME_SRC;
b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf);
- frame_source = 0;
UFclose(&f);
if (b) {
b->real_scheme = f.scheme;
@@ -1902,10 +1866,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
Str s = Strnew_charp(t);
b->type = s->ptr;
}
-#ifdef USE_IMAGE
- else if (proc == loadImageBuffer)
- b->type = b->real_type;
-#endif
else
b->type = "text/plain";
if (pu.label) {
@@ -1940,9 +1900,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
}
if (header_string)
header_string = NULL;
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
return b;
}
@@ -2504,7 +2465,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
h_env->maxlimit = lbuf->pos;
if (buf)
pushTextLine(buf, lbuf);
- else if (f) {
+ else {
Strfputs(lbuf->line, f);
fputc('\n', f);
}
@@ -2520,16 +2481,15 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
#define APPEND(str) \
if (buf) \
appendTextLine(buf,(str),0); \
- else if (f) \
+ else \
Strfputs((str),f)
while (*p) {
q = p;
if (sloppy_parse_line(&p)) {
Strcat_charp_n(tmp, q, p - q);
- if (force == 2) {
+ if (force == 2)
APPEND(tmp);
- }
else
Strcat(tmp2, tmp);
Strclear(tmp);
@@ -2625,7 +2585,9 @@ void
do_blankline(struct html_feed_environ *h_env, struct readbuffer *obuf,
int indent, int indent_incr, int width)
{
- if (h_env->blank_lines == 0)
+ if (h_env->buf && h_env->blank_lines == 0)
+ flushline(h_env, obuf, indent, 1, width);
+ else if (h_env->f)
flushline(h_env, obuf, indent, 1, width);
}
@@ -2750,18 +2712,12 @@ restore_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf)
push_tag(obuf, "<u>", HTML_U);
}
+
Str
-process_img(struct parsed_tag *tag, int width)
+process_img(struct parsed_tag *tag)
{
- char *p, *q, *r, *r2 = NULL, *s;
-#ifdef USE_IMAGE
- int w, i, nw, ni = 1, n, w0 = -1, i0 = -1;
- int align, xoffset, yoffset, top, bottom, ismap = 0;
- int use_image = activeImage && displayImage;
-#else
- int w, i, nw, n;
-#endif
- int pre_int = FALSE;
+ char *p, *q, *r, *r2, *s;
+ int w, i;
Str tmp = Strnew();
if (!parsedtag_get_value(tag, ATTR_SRC, &p))
@@ -2769,237 +2725,69 @@ process_img(struct parsed_tag *tag, int width)
q = NULL;
parsedtag_get_value(tag, ATTR_ALT, &q);
w = -1;
- if (parsedtag_get_value(tag, ATTR_WIDTH, &w)) {
- if (w < 0) {
- if (width > 0)
- w = (int)(-width * pixel_per_char * w / 100 + 0.5);
- else
- w = -1;
- }
-#ifdef USE_IMAGE
- if (use_image) {
- if (w > 0) {
- w = (int)(w * image_scale / 100 + 0.5);
- if (w == 0)
- w = 1;
- }
- }
-#endif
- }
-#ifdef USE_IMAGE
- if (use_image) {
- i = -1;
- if (parsedtag_get_value(tag, ATTR_HEIGHT, &i)) {
- if (i > 0) {
- i = (int)(i * image_scale / 100 + 0.5);
- if (i == 0)
- i = 1;
- }
- else {
- i = -1;
- }
- }
- align = -1;
- parsedtag_get_value(tag, ATTR_ALIGN, &align);
- ismap = 0;
- if (parsedtag_exists(tag, ATTR_ISMAP))
- ismap = 1;
- }
- else
-#endif
- parsedtag_get_value(tag, ATTR_HEIGHT, &i);
+ parsedtag_get_value(tag, ATTR_WIDTH, &w);
+ i = -1;
+ parsedtag_get_value(tag, ATTR_HEIGHT, &i);
r = NULL;
parsedtag_get_value(tag, ATTR_USEMAP, &r);
tmp = Strnew_size(128);
-#ifdef USE_IMAGE
- if (use_image) {
- switch (align) {
- case ALIGN_LEFT:
- Strcat_charp(tmp, "<div align=left>");
- break;
- case ALIGN_CENTER:
- Strcat_charp(tmp, "<div align=center>");
- break;
- case ALIGN_RIGHT:
- Strcat_charp(tmp, "<div align=right>");
- break;
- }
- }
-#endif
if (r) {
r2 = strchr(r, '#');
s = "<form_int method=internal action=map>";
process_form(parse_tag(&s, TRUE));
- Strcat(tmp, Sprintf("<input_alt fid=\"%d\" "
+ Strcat(tmp, Sprintf("<pre_int><input_alt fid=\"%d\" "
"type=hidden name=link value=\"", cur_form_id));
Strcat_charp(tmp, html_quote((r2) ? r2 + 1 : r));
Strcat(tmp, Sprintf("\"><input_alt hseq=\"%d\" fid=\"%d\" "
"type=submit no_effect=true>",
cur_hseq++, cur_form_id));
}
-#ifdef USE_IMAGE
- if (use_image) {
- w0 = w;
- i0 = i;
- if (w < 0 || i < 0) {
- Image image;
- ParsedURL u;
-
-#ifdef JP_CHARSET
- parseURL2(conv(p, InnerCode, cur_document_code)->ptr, &u,
- cur_baseURL);
-#else
- parseURL2(p, &u, cur_baseURL);
-#endif
- image.url = parsedURL2Str(&u)->ptr;
- image.ext = filename_extension(u.file, TRUE);
- image.cache = NULL;
- image.width = w;
- image.height = i;
-
- image.cache = getImage(&image, cur_baseURL, IMG_FLAG_SKIP);
- if (image.cache && image.cache->width > 0 &&
- image.cache->height > 0) {
- w = w0 = image.cache->width;
- i = i0 = image.cache->height;
- }
- if (w < 0)
- w = 8 * pixel_per_char;
- if (i < 0)
- i = pixel_per_line;
- }
- nw = (w > 3) ? (int)((w - 3) / pixel_per_char + 1) : 1;
- ni = (i > 3) ? (int)((i - 3) / pixel_per_line + 1) : 1;
- Strcat(tmp,
- Sprintf("<pre_int><img_alt hseq=\"%d\" src=\"", cur_iseq++));
- pre_int = TRUE;
- }
- else
-#endif
- {
- if (w < 0)
- w = 12 * pixel_per_char;
- nw = w ? (int)((w - 1) / pixel_per_char + 1) : 1;
- if (r) {
- Strcat_charp(tmp, "<pre_int>");
- pre_int = TRUE;
- }
- Strcat_charp(tmp, "<img_alt src=\"");
- }
- Strcat_charp(tmp, html_quote(p));
- Strcat_charp(tmp, "\"");
-#ifdef USE_IMAGE
- if (use_image) {
- if (w0 >= 0)
- Strcat(tmp, Sprintf(" width=%d", w0));
- if (i0 >= 0)
- Strcat(tmp, Sprintf(" height=%d", i0));
- switch (align) {
- case ALIGN_TOP:
- top = 0;
- bottom = ni - 1;
- yoffset = 0;
- break;
- case ALIGN_MIDDLE:
- top = ni / 2;
- bottom = top;
- if (top * 2 == ni)
- yoffset = (int)(((ni + 1) * pixel_per_line - i) / 2);
- else
- yoffset = (int)((ni * pixel_per_line - i) / 2);
- break;
- case ALIGN_BOTTOM:
- top = ni - 1;
- bottom = 0;
- yoffset = (int)(ni * pixel_per_line - i);
- break;
- default:
- top = ni - 1;
- bottom = 0;
- if (ni == 1 && ni * pixel_per_line > i)
- yoffset = 0;
- else {
- yoffset = (int)(ni * pixel_per_line - i);
- if (yoffset <= -2)
- yoffset++;
- }
- break;
- }
- xoffset = (int)((nw * pixel_per_char - w) / 2);
- if (xoffset)
- Strcat(tmp, Sprintf(" xoffset=%d", xoffset));
- if (yoffset)
- Strcat(tmp, Sprintf(" yoffset=%d", yoffset));
- if (top)
- Strcat(tmp, Sprintf(" top_margin=%d", top));
- if (bottom)
- Strcat(tmp, Sprintf(" bottom_margin=%d", bottom));
- if (r) {
- Strcat_charp(tmp, " usemap=\"");
- Strcat_charp(tmp, html_quote((r2) ? r2 + 1 : r));
- Strcat_charp(tmp, "\"");
- }
- if (ismap)
- Strcat_charp(tmp, " ismap");
- }
-#endif
- Strcat_charp(tmp, ">");
if (q != NULL && *q == '\0' && ignore_null_img_alt)
q = NULL;
+ if (q != NULL || r != NULL)
+ Strcat_charp(tmp, "<img_alt src=\"");
+ else
+ Strcat_charp(tmp, "<nobr><img_alt src=\"");
+ Strcat_charp(tmp, html_quote(p));
+ Strcat_charp(tmp, "\">");
if (q != NULL) {
- n = strlen(q);
-#ifdef USE_IMAGE
- if (use_image) {
- if (n > nw) {
- n = nw;
- Strcat_charp(tmp, html_quote(Strnew_charp_n(q, nw)->ptr));
- }
- else
- Strcat_charp(tmp, q);
- }
- else
-#endif
- Strcat_charp(tmp, q);
- goto img_end;
+ Strcat_charp(tmp, html_quote(q));
+ Strcat_charp(tmp, "</img_alt> ");
+ goto img_end2;
}
if (w > 0 && i > 0) {
/* guess what the image is! */
if (w < 32 && i < 48) {
/* must be an icon or space */
- n = 1;
if (strcasestr(p, "space") || strcasestr(p, "blank"))
- Strcat_charp(tmp, "_");
+ Strcat_charp(tmp, "_</img_alt>");
else {
if (w * i < 8 * 16)
- Strcat_charp(tmp, "*");
+ Strcat_charp(tmp, "*</img_alt>");
else {
#ifdef KANJI_SYMBOLS
- Strcat_charp(tmp, "¡ü");
- n = 2;
+ Strcat_charp(tmp, "¡ü</img_alt>");
#else /* not KANJI_SYMBOLS */
- Strcat_charp(tmp, "#");
+ Strcat_charp(tmp, "#</img_alt>");
#endif /* not KANJI_SYMBOLS */
}
}
- goto img_end;
+ goto img_end1;
}
if (w > 200 && i < 13) {
/* must be a horizontal line */
- if (!pre_int) {
- Strcat_charp(tmp, "<pre_int>");
- pre_int = TRUE;
- }
#ifndef KANJI_SYMBOLS
Strcat_charp(tmp, "<_RULE TYPE=10>");
#endif /* not KANJI_SYMBOLS */
- for (i = 0; i < nw - (HR_RULE_WIDTH - 1); i += HR_RULE_WIDTH)
+ w /= pixel_per_char;
+ for (i = 0; i < w - (HR_RULE_WIDTH - 1); i += HR_RULE_WIDTH)
Strcat_charp(tmp, HR_RULE);
#ifndef KANJI_SYMBOLS
Strcat_charp(tmp, "</_RULE>");
#endif /* not KANJI_SYMBOLS */
- n = i;
- goto img_end;
+ Strcat_charp(tmp, "</img_alt>");
+ goto img_end1;
}
}
for (q = p; *q; q++) ;
@@ -3008,44 +2796,27 @@ process_img(struct parsed_tag *tag, int width)
if (*q == '/')
q++;
Strcat_char(tmp, '[');
- n = 1;
p = q;
for (; *q; q++) {
if (!IS_ALNUM(*q) && *q != '_' && *q != '-') {
break;
}
- Strcat_char(tmp, *q);
- n++;
- if (n + 1 >= nw)
+ else if (w > 0 && !IS_ALNUM(*q)
+ && q - p + 2 > (int)(w / pixel_per_char)) {
+ Strcat_charp(tmp, "..");
break;
+ }
+ Strcat_char(tmp, *q);
}
- Strcat_char(tmp, ']');
- n++;
- img_end:
-#ifdef USE_IMAGE
- if (use_image) {
- for (; n < nw; n++)
- Strcat_char(tmp, ' ');
- }
-#endif
- Strcat_charp(tmp, "</img_alt>");
- if (pre_int)
- Strcat_charp(tmp, "</pre_int>");
+ Strcat_charp(tmp, "]</img_alt>");
+ img_end1:
+ if (r == NULL)
+ Strcat_charp(tmp, "</nobr>");
+ img_end2:
if (r) {
- Strcat_charp(tmp, "</input_alt>");
+ Strcat_charp(tmp, "</input_alt></pre_int>");
process_n_form();
}
-#ifdef USE_IMAGE
- if (use_image) {
- switch (align) {
- case ALIGN_RIGHT:
- case ALIGN_CENTER:
- case ALIGN_LEFT:
- Strcat_charp(tmp, "</div>");
- break;
- }
- }
-#endif
return tmp;
}
@@ -3067,7 +2838,8 @@ Str
process_input(struct parsed_tag *tag)
{
int i, w, v, x, y, z, iw, ih;
- char *q, *p, *r, *p2, *s;
+ char *q, *p, *r, *p2;
+ char *pi = NULL;
Str tmp;
char *qq = "";
int qlen = 0;
@@ -3156,20 +2928,6 @@ process_input(struct parsed_tag *tag)
Strcat_charp(tmp, "<u>");
break;
case FORM_INPUT_IMAGE:
- s = NULL;
- parsedtag_get_value(tag, ATTR_SRC, &s);
- if (s) {
- Strcat(tmp, Sprintf("<img src=\"%s\"", html_quote(s)));
- if (p2)
- Strcat(tmp, Sprintf(" alt=\"%s\"", html_quote(p2)));
- if (parsedtag_get_value(tag, ATTR_WIDTH, &iw))
- Strcat(tmp, Sprintf(" width=\"%d\"", iw));
- if (parsedtag_get_value(tag, ATTR_HEIGHT, &ih))
- Strcat(tmp, Sprintf(" height=\"%d\"", ih));
- Strcat_charp(tmp, ">");
- Strcat_charp(tmp, "</input_alt></pre_int>");
- return tmp;
- }
case FORM_INPUT_SUBMIT:
case FORM_INPUT_BUTTON:
case FORM_INPUT_RESET:
@@ -3195,6 +2953,23 @@ process_input(struct parsed_tag *tag)
Strcat_char(tmp, ' ');
}
break;
+ case FORM_INPUT_IMAGE:
+ parsedtag_get_value(tag, ATTR_SRC, &pi);
+ if (pi) {
+ Strcat(tmp, Sprintf("<img_alt src=\"%s\"", html_quote(pi)));
+ if (parsedtag_get_value(tag, ATTR_WIDTH, &iw))
+ Strcat(tmp, Sprintf(" width=\"%d\"", iw));
+ if (parsedtag_get_value(tag, ATTR_HEIGHT, &ih))
+ Strcat(tmp, Sprintf(" height=\"%d\"", ih));
+ Strcat_charp(tmp, ">");
+ if (p2)
+ Strcat_charp(tmp, html_quote(p2));
+ else
+ Strcat_charp(tmp, qq);
+ Strcat_charp(tmp, "</img_alt>");
+ break;
+ }
+ /* FALL THROUGH */
case FORM_INPUT_SUBMIT:
case FORM_INPUT_BUTTON:
if (p2)
@@ -4191,24 +3966,12 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
close_anchor(h_env, obuf);
return 1;
case HTML_IMG:
- tmp = process_img(tag, h_env->limit);
+ tmp = process_img(tag);
HTMLlineproc1(tmp->ptr, h_env);
return 1;
case HTML_IMG_ALT:
if (parsedtag_get_value(tag, ATTR_SRC, &p))
obuf->img_alt = Strnew_charp(p);
-#ifdef USE_IMAGE
- i = 0;
- if (parsedtag_get_value(tag, ATTR_TOP_MARGIN, &i)) {
- if (i > obuf->top_margin)
- obuf->top_margin = i;
- }
- i = 0;
- if (parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &i)) {
- if (i > obuf->bottom_margin)
- obuf->bottom_margin = i;
- }
-#endif
return 0;
case HTML_N_IMG_ALT:
if (obuf->img_alt) {
@@ -4440,14 +4203,6 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
}
return 1;
case HTML_BASE:
-#ifdef USE_IMAGE
- p = NULL;
- if (parsedtag_get_value(tag, ATTR_HREF, &p)) {
- if (!cur_baseURL)
- cur_baseURL = New(ParsedURL);
- parseURL(p, cur_baseURL, NULL);
- }
-#endif
case HTML_MAP:
case HTML_N_MAP:
case HTML_AREA:
@@ -4539,7 +4294,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
{
Anchor *a_href = NULL, *a_img = NULL, *a_form = NULL;
char outc[LINELEN];
- char *p, *q, *r, *s, *str;
+ char *p, *q, *r, *str;
Lineprop outp[LINELEN], mode, effect;
int pos;
int nlines;
@@ -4695,67 +4450,9 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
break;
case HTML_IMG_ALT:
if (parsedtag_get_value(tag, ATTR_SRC, &p)) {
-#ifdef USE_IMAGE
- int w = -1, h = -1, iseq = 0, ismap = 0;
- int xoffset = 0, yoffset = 0, top = 0, bottom = 0;
- parsedtag_get_value(tag, ATTR_HSEQ, &iseq);
- parsedtag_get_value(tag, ATTR_WIDTH, &w);
- parsedtag_get_value(tag, ATTR_HEIGHT, &h);
- parsedtag_get_value(tag, ATTR_XOFFSET, &xoffset);
- parsedtag_get_value(tag, ATTR_YOFFSET, &yoffset);
- parsedtag_get_value(tag, ATTR_TOP_MARGIN, &top);
- parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &bottom);
- if (parsedtag_exists(tag, ATTR_ISMAP))
- ismap = 1;
- q = NULL;
- parsedtag_get_value(tag, ATTR_USEMAP, &q);
- if (iseq > 0) {
- buf->imarklist = putHmarker(buf->imarklist,
- currentLn(buf), pos,
- iseq - 1);
- }
-#endif
p = remove_space(p);
p = url_quote_conv(p, buf->document_code);
a_img = registerImg(buf, p, currentLn(buf), pos);
-#ifdef USE_IMAGE
- a_img->hseq = iseq;
- a_img->image = NULL;
- if (iseq > 0) {
- ParsedURL u;
- Image *image;
-
- parseURL2(a_img->url, &u, cur_baseURL);
- a_img->image = image = New(Image);
- image->url = parsedURL2Str(&u)->ptr;
- image->ext = filename_extension(u.file, TRUE);
- image->cache = NULL;
- image->width = w;
- image->height = h;
- image->xoffset = xoffset;
- image->yoffset = yoffset;
- image->y = currentLn(buf) - top;
- if (image->xoffset < 0 && pos == 0)
- image->xoffset = 0;
- if (image->yoffset < 0 && image->y == 1)
- image->yoffset = 0;
- image->rows = 1 + top + bottom;
- image->map = q;
- image->ismap = ismap;
- image->touch = 0;
- image->cache = getImage(image, cur_baseURL,
- IMG_FLAG_SKIP);
- }
- else if (iseq < 0) {
- BufferPoint *po = buf->imarklist->marks - iseq - 1;
- Anchor *a = retrieveAnchor(buf->img,
- po->line, po->pos);
- if (a) {
- a_img->url = a->url;
- a_img->image = a->image;
- }
- }
-#endif
}
effect |= PE_IMAGE;
break;
@@ -4817,8 +4514,9 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
if (parsedtag_get_value(tag, ATTR_NAME, &p)) {
MapList *m = New(MapList);
m->name = Strnew_charp(p);
- m->area = newGeneralList();
m->next = buf->maplist;
+ m->urls = newTextList();
+ m->alts = newTextList();
buf->maplist = m;
}
break;
@@ -4829,19 +4527,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
if (buf->maplist == NULL) /* outside of <map>..</map> */
break;
if (parsedtag_get_value(tag, ATTR_HREF, &p)) {
- MapArea *a;
p = remove_space(p);
p = url_quote_conv(p, buf->document_code);
- q = "";
- parsedtag_get_value(tag, ATTR_ALT, &q);
- r = NULL;
- s = NULL;
-#ifdef USE_IMAGE
- parsedtag_get_value(tag, ATTR_SHAPE, &r);
- parsedtag_get_value(tag, ATTR_COORDS, &s);
-#endif
- a = newMapArea(p, q, r, s);
- pushValue(buf->maplist->area, (void *)a);
+ pushText(buf->maplist->urls, p);
+ if (parsedtag_get_value(tag, ATTR_ALT, &q))
+ pushText(buf->maplist->alts, q);
+ else
+ pushText(buf->maplist->alts, "");
}
break;
case HTML_FRAMESET:
@@ -4942,9 +4634,6 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
fclose(debug);
if (n_textarea)
addMultirowsForm(buf, buf->formitem);
-#ifdef USE_IMAGE
- addMultirowsImg(buf, buf->img);
-#endif
}
void
@@ -5716,69 +5405,6 @@ completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf)
}
}
-static void
-print_internal_information(struct html_feed_environ *henv)
-{
- int i;
- Str s;
- TextLineList *tl = newTextLineList();
-
- if (form_max >= 0) {
- FormList *fp;
- for (i = 0; i <= form_max; i++) {
- fp = forms[i];
- s = Sprintf("<form_int fid=\"%d\" action=\"%s\" method=\"%s\"",
- i, fp->action->ptr,
- (fp->method == FORM_METHOD_POST) ? "post"
- : ((fp->method ==
- FORM_METHOD_INTERNAL) ? "internal" : "get"));
- if (fp->target)
- Strcat(s, Sprintf(" target=\"%s\"", fp->target));
-#ifdef JP_CHARSET
- if (fp->charset)
- Strcat(s,
- Sprintf(" accept-charset=\"%s\"",
- code_to_str(fp->charset)));
-#endif
- if (fp->enctype == FORM_ENCTYPE_MULTIPART)
- Strcat_charp(s, " enctype=multipart/form-data");
- Strcat_charp(s, ">");
- pushTextLine(tl, newTextLine(s, 0));
- }
- }
-#ifdef MENU_SELECT
- if (n_select > 0) {
- FormSelectOptionItem *ip;
- for (i = 0; i < n_select; i++) {
- for (ip = select_option[i].first; ip; ip = ip->next) {
- s = Sprintf("<option_int selectnumber=%d"
- " value=\"%s\"%s>%s</option_int>",
- i,
- html_quote(ip->value ? ip->value->ptr : ip->label->
- ptr), ip->checked ? " selected" : "",
- ip->label->ptr);
- pushTextLine(tl, newTextLine(s, 0));
- }
- }
- }
-#endif /* MENU_SELECT */
- if (n_textarea > 0) {
- for (i = 0; i < n_textarea; i++) {
- s = Sprintf("<textarea_int textareanumber=%d>%s</textarea_int>",
- i, textarea_str[i]->ptr);
- pushTextLine(tl, newTextLine(s, 0));
- }
- }
-
- if (henv->buf)
- appendTextLineList(henv->buf, tl);
- else if (henv->f) {
- TextLineListItem *p;
- for (p = tl->first; p; p = p->next)
- fprintf(henv->f, "%s\n", p->ptr->line->ptr);
- }
-}
-
void
loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
{
@@ -5789,9 +5415,6 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
char code;
struct html_feed_environ htmlenv1;
struct readbuffer obuf;
-#ifdef USE_IMAGE
- int volatile image_flag;
-#endif
MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
n_textarea = 0;
@@ -5809,17 +5432,6 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
forms_size = 0;
forms = NULL;
cur_hseq = 1;
-#ifdef USE_IMAGE
- cur_iseq = 1;
- if (newBuf->image_flag)
- image_flag = newBuf->image_flag;
- else if (activeImage && displayImage && autoImage)
- image_flag = IMG_FLAG_AUTO;
- else
- image_flag = IMG_FLAG_SKIP;
- if (newBuf->currentURL.file)
- cur_baseURL = baseURL(newBuf);
-#endif
if (w3m_halfload) {
newBuf->buffername = "---";
@@ -5828,9 +5440,10 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
#endif /* JP_CHARSET */
HTMLlineproc3(newBuf, f->stream);
w3m_halfload = FALSE;
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
return;
}
@@ -5845,9 +5458,10 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1);
goto phase2;
}
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
+ if (fmInitialized) {
+ prevtrap = signal(SIGINT, KeyAbort);
term_cbreak();
+ }
#ifdef JP_CHARSET
if (newBuf != NULL && newBuf->document_code != '\0')
@@ -5868,32 +5482,16 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
if (src)
Strfputs(lineBuf2, src);
linelen += lineBuf2->length;
- if (w3m_dump & DUMP_SOURCE)
- continue;
showProgress(&linelen, &trbyte);
- /*
- * if (frame_source)
- * continue;
- */
#ifdef JP_CHARSET
if (meta_charset != '\0') { /* <META> */
- if (content_charset == '\0' && UseContentCharset) {
+ if (content_charset == '\0' && UseContentCharset)
code = meta_charset;
-#ifdef USE_IMAGE
- cur_document_code = code;
-#endif
- }
meta_charset = '\0';
}
#endif
- if (!internal) {
+ if (!internal)
lineBuf2 = convertLine(f, lineBuf2, &code, HTML_MODE);
-#ifdef JP_CHARSET
-#ifdef USE_IMAGE
- cur_document_code = code;
-#endif
-#endif
- }
#ifdef USE_NNTP
if (f->scheme == SCM_NEWS) {
if (Str_news_endline(lineBuf2)) {
@@ -5912,30 +5510,24 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
if (htmlenv1.title)
newBuf->buffername = htmlenv1.title;
if (w3m_halfdump) {
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
- if (w3m_dump & DUMP_HALFEXTRA)
- print_internal_information(&htmlenv1);
- return;
- }
- if (w3m_backend) {
- print_internal_information(&htmlenv1);
- backend_halfdump_buf = htmlenv1.buf;
+ signal(SIGINT, prevtrap);
+ }
return;
}
phase2:
newBuf->trbyte = trbyte + linelen;
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
#ifdef JP_CHARSET
newBuf->document_code = code;
content_charset = '\0';
#endif /* JP_CHARSET */
-#ifdef USE_IMAGE
- newBuf->image_flag = image_flag;
-#endif
+ if (w3m_backend)
+ backend_halfdump_buf = htmlenv1.buf;
HTMLlineproc2(newBuf, htmlenv1.buf);
}
@@ -5953,18 +5545,15 @@ loadHTMLString(Str page)
newBuf = newBuffer(INIT_BUFFER_WIDTH);
if (SETJMP(AbortLoading) != 0) {
- if (fmInitialized)
- term_raw();
- signal(SIGINT, prevtrap);
discardBuffer(newBuf);
return NULL;
}
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
- term_cbreak();
-
init_stream(&f, SCM_LOCAL, newStrStream(page));
+ if (fmInitialized) {
+ prevtrap = signal(SIGINT, KeyAbort);
+ term_cbreak();
+ }
if (w3m_dump & DUMP_FRAME) {
tmp = tmpfname(TMPF_SRC, ".html");
pushText(fileToDelete, tmp->ptr);
@@ -5975,9 +5564,10 @@ loadHTMLString(Str page)
loadHTMLstream(&f, newBuf, src, TRUE);
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
newBuf->topLine = newBuf->firstLine;
newBuf->lastLine = newBuf->currentLine;
newBuf->currentLine = newBuf->firstLine;
@@ -6021,9 +5611,6 @@ loadGopherDir(URLFile *uf, Buffer *newBuf)
code = content_charset;
else
code = DocumentCode;
-#ifdef USE_IMAGE
- cur_document_code = code;
-#endif
content_charset = '\0';
#endif
while (1) {
@@ -6127,9 +5714,10 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
if (SETJMP(AbortLoading) != 0) {
goto _end;
}
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
+ if (fmInitialized) {
+ prevtrap = signal(SIGINT, KeyAbort);
term_cbreak();
+ }
if (newBuf->sourcefile == NULL &&
(uf->scheme != SCM_LOCAL || newBuf->mailcap)) {
@@ -6155,11 +5743,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
if (src)
Strfputs(lineBuf2, src);
linelen += lineBuf2->length;
- if (w3m_dump & DUMP_SOURCE)
- continue;
showProgress(&linelen, &trbyte);
- if (frame_source)
- continue;
lineBuf2 = convertLine(uf, lineBuf2, &code, PAGER_MODE);
if (squeezeBlankLine) {
if (lineBuf2->ptr[0] == '\n' && pre_lbuf == '\n') {
@@ -6190,9 +5774,10 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
lineBuf2->length, nlines);
}
_end:
- if (fmInitialized)
+ if (fmInitialized) {
+ signal(SIGINT, prevtrap);
term_raw();
- signal(SIGINT, prevtrap);
+ }
newBuf->topLine = newBuf->firstLine;
newBuf->lastLine = newBuf->currentLine;
newBuf->currentLine = newBuf->firstLine;
@@ -6206,67 +5791,6 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
return newBuf;
}
-#ifdef USE_IMAGE
-Buffer *
-loadImageBuffer(URLFile *uf, Buffer *newBuf)
-{
- Image *image;
- ImageCache *cache;
- Str tmp, tmpf;
- FILE *src = NULL;
- URLFile f;
- MySignalHandler(*prevtrap) ();
-
- loadImage(IMG_FLAG_STOP);
- image = New(Image);
- image->url = parsedURL2Str(cur_baseURL)->ptr;
- image->ext = filename_extension(cur_baseURL->file, 1);
- image->width = -1;
- image->height = -1;
- cache = getImage(image, cur_baseURL, IMG_FLAG_AUTO);
- if (!cur_baseURL->is_nocache && cache->loaded == IMG_FLAG_LOADED)
- goto image_buffer;
-
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
- term_cbreak();
- if (IStype(uf->stream) != IST_ENCODED)
- uf->stream = newEncodedStream(uf->stream, uf->encoding);
- if (save2tmp(*uf, cache->file) < 0) {
- if (fmInitialized)
- term_raw();
- signal(SIGINT, prevtrap);
- return NULL;
- }
- if (fmInitialized)
- term_raw();
- signal(SIGINT, prevtrap);
-
- cache->loaded = IMG_FLAG_LOADED;
- getImageSize(cache);
-
- image_buffer:
- tmp = Sprintf("<img src=\"%s\"><br><br>", html_quote(image->url));
- if (newBuf == NULL)
- newBuf = newBuffer(INIT_BUFFER_WIDTH);
- if (frame_source) {
- tmpf = tmpfname(TMPF_SRC, ".html");
- src = fopen(tmpf->ptr, "w");
- newBuf->sourcefile = tmpf->ptr;
- pushText(fileToDelete, tmpf->ptr);
- }
- init_stream(&f, SCM_LOCAL, newStrStream(tmp));
- loadHTMLstream(&f, newBuf, src, TRUE);
- if (src)
- fclose(src);
-
- newBuf->topLine = newBuf->firstLine;
- newBuf->lastLine = newBuf->currentLine;
- newBuf->currentLine = newBuf->firstLine;
- return newBuf;
-}
-#endif
-
/*
* saveBuffer: write buffer to file
*/
@@ -6641,9 +6165,10 @@ save2tmp(URLFile uf, char *tmpf)
if (SETJMP(AbortLoading) != 0) {
goto _end;
}
- prevtrap = signal(SIGINT, KeyAbort);
- if (fmInitialized)
+ if (fmInitialized) {
+ prevtrap = signal(SIGINT, KeyAbort);
term_cbreak();
+ }
check = 0;
current_content_length = 0;
#ifdef USE_NNTP
@@ -6679,9 +6204,10 @@ save2tmp(URLFile uf, char *tmpf)
}
_end:
bcopy(env_bak, AbortLoading, sizeof(JMP_BUF));
- if (fmInitialized)
+ if (fmInitialized) {
term_raw();
- signal(SIGINT, prevtrap);
+ signal(SIGINT, prevtrap);
+ }
fclose(ff);
if (uf.scheme == SCM_FTP)
FTPhalfclose(uf.stream);