From 63dffdd551989100dc3ad845b1f5a2126a59be6e Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Sun, 3 Feb 2002 06:12:41 +0000 Subject: [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 --- file.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index eae0724..48b9b8f 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.58 2002/02/01 05:01:47 ukai Exp $ */ +/* $Id: file.c,v 1.59 2002/02/03 06:12:41 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -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("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("%s", + 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("%s", + 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); } -- cgit v1.2.3