w3m

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

commit 5fbb78b7c69561eec3992336eb0691e1646f1dab
parent b270e605dbbcb607b29b84b399363dc0526b7cdf
Author: ukai <ukai>
Date:   Sun,  3 Feb 2002 06:12:41 +0000

[w3m-dev 02964] Print data of forms when halfdump option is set
* backend.c (print_headers): print w3m-current-url and w3m-base-url
* backend.c (print_formlist): deleted
* backend.c (internal_get): remove "if (buf->formlist) {}"
* file.c (print_internal_information): added
* file.c (loadHTMLstream): if halfdump, print_internal_information
			if w3m_backend, print_internal_information
* fm.h (DUMP_HALFEXTRA): added
* main.c (-halfdump_extra): added
From: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>

Diffstat:
MChangeLog | 12++++++++++++
Mbackend.c | 34+++-------------------------------
Mfile.c | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mfm.h | 1+
Mmain.c | 2++
5 files changed, 85 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,15 @@ +2002-02-03 TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp> + + * [w3m-dev 02964] Print data of forms when halfdump option is set + * backend.c (print_headers): print w3m-current-url and w3m-base-url + * backend.c (print_formlist): deleted + * backend.c (internal_get): remove "if (buf->formlist) {}" + * file.c (print_internal_information): added + * file.c (loadHTMLstream): if halfdump, print_internal_information + if w3m_backend, print_internal_information + * fm.h (DUMP_HALFEXTRA): added + * main.c (-halfdump_extra): added + 2002-02-01 Dai Sato <satodai@dog.intcul.tohoku.ac.jp> * [w3m-dev 02972] #include "config.h" diff --git a/backend.c b/backend.c @@ -97,6 +97,9 @@ print_headers(Buffer *buf, int len) for (tp = buf->document_header->first; tp; tp = tp->next) printf("%s\n", tp->ptr); } + printf("w3m-current-url: %s\n", parsedURL2Str(&buf->currentURL)->ptr); + if (buf->baseURL) + printf("w3m-base-url: %s\n", parsedURL2Str(buf->baseURL)->ptr); printf("w3m-content-type: %s\n", buf->type); #ifdef JP_CHARSET if (buf->document_code) @@ -109,29 +112,6 @@ print_headers(Buffer *buf, int len) static void -print_formlist(int fid, FormList *fp) -{ - Str s = - Sprintf("w3m-form: (formlist (fid %d) (action \"%s\") (method \"%s\")", - fid, - 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)); - if (fp->charset) - Strcat(s, - Sprintf(" (charset '%s)", get_mime_charset_name(fp->charset))); - if (fp->enctype == FORM_ENCTYPE_MULTIPART) - Strcat_charp(s, " (enctype \"multipart/form-data\")"); - if (fp->boundary) - Strcat(s, Sprintf(" (boundary \"%s\")", fp->boundary)); - Strcat_charp(s, ")\n"); - Strfputs(s, stdout); -} - - -static void internal_get(char *url, int flag, FormList *request) { Buffer *buf; @@ -151,14 +131,6 @@ internal_get(char *url, int flag, FormList *request) last = Strnew_m_charp("</pre><title>", html_quote(buf->buffername), "</title>\n", NULL); print_headers(buf, len + first->length + last->length); - if (buf->formlist) { - FormList *fp; - int fid = 0; - for (fp = buf->formlist; fp; fp = fp->next) - fid++; - for (fp = buf->formlist; fp; fp = fp->next) - print_formlist(--fid, fp); - } printf("\n"); printf("%s", first->ptr); for (p = backend_halfdump_buf->first; p; p = p->next) diff --git a/file.c b/file.c @@ -5714,6 +5714,66 @@ 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)); + if (fp->charset) + Strcat(s, Sprintf(" accept-charset=\"%s\"", code_to_str(fp->charset))); + if (fp->enctype == FORM_ENCTYPE_MULTIPART) + Strcat_charp(s, " enctype=multipart/form-data"); + if (fp->boundary) + Strcat_m_charp(s, " boundary=\"", html_quote(fp->boundary), "\"", NULL); + 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) + printf("%s\n", p->ptr->line->ptr); + } +} + void loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) { @@ -5850,6 +5910,13 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) 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; return; } phase2: @@ -5864,8 +5931,6 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) #ifdef USE_IMAGE newBuf->image_flag = image_flag; #endif - if (w3m_backend) - backend_halfdump_buf = htmlenv1.buf; HTMLlineproc2(newBuf, htmlenv1.buf); } diff --git a/fm.h b/fm.h @@ -772,6 +772,7 @@ extern char *w3m_version; #define DUMP_EXTRA 0x08 #define DUMP_HALFDUMP 0x10 #define DUMP_FRAME 0x20 +#define DUMP_HALFEXTRA 0x40 global int w3m_debug; global int w3m_dump init(0); #define w3m_halfdump (w3m_dump & DUMP_HALFDUMP) diff --git a/main.c b/main.c @@ -562,6 +562,8 @@ MAIN(int argc, char **argv, char **envp) w3m_dump = (DUMP_HEAD | DUMP_SOURCE | DUMP_EXTRA); else if (!strcmp("-halfdump", argv[i])) w3m_dump = DUMP_HALFDUMP; + else if (!strcmp("-halfdump_extra", argv[i])) + w3m_dump = DUMP_HALFDUMP | DUMP_HALFEXTRA; else if (!strcmp("-halfload", argv[i])) { w3m_dump = 0; w3m_halfload = TRUE;