[w3m-dev 03631] display current form item

* form.c (form2str): rewrite
* istream.c (ssl_get_certificate): fix typo
* map.c (follow_map_panel): valign=top
	(append_map_info): valign=top
	(append_link_info): valign=top
	(append_frame_info): <pre_int>
			html_quote ssl_certificate
	(page_info_panel): rewrite, html_quote
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-01-10 16:58:30 +00:00
parent ce8abe2b7c
commit c5ec364d23
4 changed files with 86 additions and 83 deletions
+13 -1
View File
@@ -1,3 +1,15 @@
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
* map.c (follow_map_panel): valign=top
(append_map_info): valign=top
(append_link_info): valign=top
(append_frame_info): <pre_int>
html_quote ssl_certificate
(page_info_panel): rewrite, html_quote
2003-01-11 Fumitoshi UKAI <ukai@debian.or.jp> 2003-01-11 Fumitoshi UKAI <ukai@debian.or.jp>
* doc/README.pre_form: update * doc/README.pre_form: update
@@ -6323,4 +6335,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.669 2003/01/10 16:51:08 ukai Exp $ $Id: ChangeLog,v 1.670 2003/01/10 16:58:30 ukai Exp $
+16 -13
View File
@@ -1,4 +1,4 @@
/* $Id: form.c,v 1.26 2003/01/10 16:48:49 ukai Exp $ */ /* $Id: form.c,v 1.27 2003/01/10 16:58:31 ukai Exp $ */
/* /*
* HTML forms * HTML forms
*/ */
@@ -160,8 +160,8 @@ formList_addInput(struct form_list *fl, struct parsed_tag *tag)
} }
static char *_formtypetbl[] = { static char *_formtypetbl[] = {
"text", "password", "checkbox", "radio", "submit", "text", "password", "checkbox", "radio", "submit", "reset", "hidden",
"reset", "hidden", "image", "select", "textarea", "button", "file", 0, "image", "select", "textarea", "button", "file", NULL
}; };
static char *_formmethodtbl[] = { static char *_formmethodtbl[] = {
@@ -171,16 +171,19 @@ static char *_formmethodtbl[] = {
char * char *
form2str(FormItemList *fi) form2str(FormItemList *fi)
{ {
Str tmp; Str tmp = Strnew();
if (fi->type == FORM_INPUT_SUBMIT ||
fi->type == FORM_INPUT_IMAGE || fi->type == FORM_INPUT_BUTTON) { if (fi->type != FORM_SELECT && fi->type != FORM_TEXTAREA)
tmp = Strnew_charp(_formmethodtbl[fi->parent->method]); Strcat_charp(tmp, "input type=");
Strcat_char(tmp, ' '); Strcat_charp(tmp, _formtypetbl[fi->type]);
Strcat(tmp, fi->parent->action); if (fi->name && fi->name->length)
return tmp->ptr; Strcat_m_charp(tmp, " name=\"", fi->name->ptr, "\"", NULL);
} if ((fi->type == FORM_INPUT_RADIO || fi->type == FORM_INPUT_CHECKBOX ||
else fi->type == FORM_SELECT) && fi->value)
return _formtypetbl[fi->type]; Strcat_m_charp(tmp, " value=\"", fi->value->ptr, "\"", NULL);
Strcat_m_charp(tmp, " (", _formmethodtbl[fi->parent->method], " ",
fi->parent->action->ptr, ")", NULL);
return tmp->ptr;
} }
int int
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: istream.c,v 1.16 2002/12/24 17:20:47 ukai Exp $ */ /* $Id: istream.c,v 1.17 2003/01/10 16:58:31 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include "myctype.h" #include "myctype.h"
#include "istream.h" #include "istream.h"
@@ -578,7 +578,7 @@ ssl_get_certificate(SSL * ssl, char *hostname)
Strcat_m_charp(s, " subject=", buf, NULL); Strcat_m_charp(s, " subject=", buf, NULL);
xn = X509_get_issuer_name(x); xn = X509_get_issuer_name(x);
if (X509_NAME_get_text_by_NID(xn, NID_commonName, buf, sizeof(buf)) == -1) if (X509_NAME_get_text_by_NID(xn, NID_commonName, buf, sizeof(buf)) == -1)
Strcat_charp(s, ": issuer=<unnown>"); Strcat_charp(s, ": issuer=<unknown>");
else else
Strcat_m_charp(s, ": issuer=", buf, NULL); Strcat_m_charp(s, ": issuer=", buf, NULL);
Strcat_charp(s, "\n\n"); Strcat_charp(s, "\n\n");
+55 -67
View File
@@ -1,4 +1,4 @@
/* $Id: map.c,v 1.22 2002/12/13 02:19:01 ukai Exp $ */ /* $Id: map.c,v 1.23 2003/01/10 16:58:31 ukai Exp $ */
/* /*
* client-side image maps * client-side image maps
*/ */
@@ -271,7 +271,7 @@ follow_map_panel(Buffer *buf, char *name)
continue; continue;
parseURL2(a->url, &pu, baseURL(buf)); parseURL2(a->url, &pu, baseURL(buf));
url = html_quote(parsedURL2Str(&pu)->ptr); url = html_quote(parsedURL2Str(&pu)->ptr);
Strcat_m_charp(mappage, "<tr><td><a href=\"", url, "\">", Strcat_m_charp(mappage, "<tr valign=top><td><a href=\"", url, "\">",
html_quote(*a->alt ? a->alt : mybasename(a->url)), html_quote(*a->alt ? a->alt : mybasename(a->url)),
"</a><td>", url, NULL); "</a><td>", url, NULL);
} }
@@ -392,15 +392,17 @@ append_map_info(Buffer *buf, Str tmp, FormItemList *fi)
if (ml == NULL) if (ml == NULL)
return; return;
Strcat_charp(tmp, "<tr><td colspan=2>Links of current image map"); Strcat_m_charp(tmp,
Strcat_charp(tmp, "<tr><td colspan=2><table>"); "<tr valign=top><td colspan=2>Links of current image map",
"<tr valign=top><td colspan=2><table>", NULL);
for (al = ml->area->first; al != NULL; al = al->next) { for (al = ml->area->first; al != NULL; al = al->next) {
a = (MapArea *) al->ptr; a = (MapArea *) al->ptr;
if (!a) if (!a)
continue; continue;
parseURL2(a->url, &pu, baseURL(buf)); parseURL2(a->url, &pu, baseURL(buf));
url = html_quote(parsedURL2Str(&pu)->ptr); url = html_quote(parsedURL2Str(&pu)->ptr);
Strcat_m_charp(tmp, "<tr><td>&nbsp;&nbsp;<td><a href=\"", url, "\">", Strcat_m_charp(tmp, "<tr valign=top><td>&nbsp;&nbsp;<td><a href=\"",
url, "\">",
html_quote(*a->alt ? a->alt : mybasename(a->url)), html_quote(*a->alt ? a->alt : mybasename(a->url)),
"</a><td>", html_quote(a->url), "\n", NULL); "</a><td>", html_quote(a->url), "\n", NULL);
} }
@@ -418,8 +420,7 @@ append_link_info(Buffer *buf, Str html, LinkList * link)
if (!link) if (!link)
return; return;
Strcat_charp(html, "<hr width=50%><h1>Link information</h1>"); Strcat_charp(html, "<hr width=50%><h1>Link information</h1><table>\n");
Strcat_charp(html, "<TABLE>\n");
for (l = link; l; l = l->next) { for (l = link; l; l = l->next) {
if (l->url) { if (l->url) {
parseURL2(l->url, &pu, baseURL(buf)); parseURL2(l->url, &pu, baseURL(buf));
@@ -427,20 +428,20 @@ append_link_info(Buffer *buf, Str html, LinkList * link)
} }
else else
url = "(empty)"; url = "(empty)";
Strcat_m_charp(html, "<TR><TD><A HREF=\"", url, "\">", Strcat_m_charp(html, "<tr valign=top><td><a href=\"", url, "\">",
l->title ? html_quote(l->title) : "(empty)", "</A><TD>", l->title ? html_quote(l->title) : "(empty)", "</a><td>",
NULL); NULL);
if (l->type == LINK_TYPE_REL) if (l->type == LINK_TYPE_REL)
Strcat_charp(html, "[Rel]"); Strcat_charp(html, "[Rel]");
else if (l->type == LINK_TYPE_REV) else if (l->type == LINK_TYPE_REV)
Strcat_charp(html, "[Rev]"); Strcat_charp(html, "[Rev]");
Strcat_m_charp(html, "<TD>", l->url ? html_quote(l->url) : "(empty)", Strcat_m_charp(html, "<td>", l->url ? html_quote(l->url) : "(empty)",
NULL); NULL);
if (l->ctype) if (l->ctype)
Strcat_m_charp(html, " (", html_quote(l->ctype), ")", NULL); Strcat_m_charp(html, " (", html_quote(l->ctype), ")", NULL);
Strcat_charp(html, "\n"); Strcat_charp(html, "\n");
} }
Strcat_charp(html, "</TABLE>\n"); Strcat_charp(html, "</table>\n");
} }
/* append frame URL */ /* append frame URL */
@@ -461,12 +462,11 @@ append_frame_info(Buffer *buf, Str html, struct frameset *set, int level)
case F_BODY: case F_BODY:
if (frame.body->url == NULL) if (frame.body->url == NULL)
break; break;
Strcat_charp(html, "<pre_int>");
for (j = 0; j < level; j++) for (j = 0; j < level; j++)
Strcat_charp(html, " "); Strcat_charp(html, " ");
q = html_quote(frame.body->url); q = html_quote(frame.body->url);
Strcat_charp(html, "<a href=\""); Strcat_m_charp(html, "<a href=\"", q, "\">", NULL);
Strcat_charp(html, q);
Strcat_charp(html, "\">");
if (frame.body->name) { if (frame.body->name) {
p = file_unquote(frame.body->name); p = file_unquote(frame.body->name);
#ifdef JP_CHARSET #ifdef JP_CHARSET
@@ -475,13 +475,11 @@ append_frame_info(Buffer *buf, Str html, struct frameset *set, int level)
p = html_quote(p); p = html_quote(p);
Strcat_charp(html, p); Strcat_charp(html, p);
} }
Strcat_charp(html, " "); Strcat_m_charp(html, " ", q, "</a></pre_int><br>\n", NULL);
Strcat_charp(html, q);
Strcat_charp(html, "</a>\n");
#ifdef USE_SSL #ifdef USE_SSL
if (frame.body->ssl_certificate) if (frame.body->ssl_certificate)
Strcat_m_charp(html, "<blockquote><pre>\n", Strcat_m_charp(html, "<blockquote><h2>SSL certificate</h2><pre>\n",
frame.body->ssl_certificate, html_quote(frame.body->ssl_certificate),
"</pre></blockquote>\n", NULL); "</pre></blockquote>\n", NULL);
#endif #endif
break; break;
@@ -507,34 +505,33 @@ page_info_panel(Buffer *buf)
struct frameset *f_set = NULL; struct frameset *f_set = NULL;
int all; int all;
Strcat_charp(tmp, Strcat_charp(tmp, "<html><head>\
"<html><head><title>Information about current page</title></head><body>"); <title>Information about current page</title>\
Strcat_charp(tmp, </head><body>\
"<h1>Information about current page</h1><table cellpadding=0>"); <h1>Information about current page</h1>\n");
if (buf == NULL) if (buf == NULL)
goto end; goto end;
Strcat_charp(tmp, "<tr><td nowrap>Title<td>");
Strcat_charp(tmp, html_quote(buf->buffername));
Strcat_charp(tmp, "<tr><td nowrap>Current URL<td>");
Strcat_charp(tmp, html_quote(parsedURL2Str(&buf->currentURL)->ptr));
Strcat_charp(tmp, "<tr><td nowrap>Document Type<td>");
if (buf->real_type)
Strcat_charp(tmp, buf->real_type);
else
Strcat_charp(tmp, "unknown");
Strcat_charp(tmp, "<tr><td nowrap>Last Modified<td>");
Strcat_charp(tmp, html_quote(last_modified(buf)));
#ifdef JP_CHARSET
Strcat_charp(tmp, "<tr><td nowrap>Document Code<td>");
Strcat_charp(tmp, code_to_str(buf->document_code));
#endif /* JP_CHARSET */
Strcat_charp(tmp, "<tr><td nowrap>Number of lines<td>");
all = buf->allLine; all = buf->allLine;
if (all == 0 && buf->lastLine) if (all == 0 && buf->lastLine)
all = buf->lastLine->linenumber; all = buf->lastLine->linenumber;
Strcat(tmp, Sprintf("%d", all)); Strcat_m_charp(tmp, "<table cellpadding=0>",
Strcat_charp(tmp, "<tr><td nowrap>Transferred bytes<td>"); "<tr valign=top><td nowrap>Title<td>",
Strcat(tmp, Sprintf("%d", buf->trbyte)); html_quote(buf->buffername),
"<tr valign=top><td nowrap>Current URL<td>",
html_quote(parsedURL2Str(&buf->currentURL)->ptr),
"<tr valign=top><td nowrap>Document Type<td>",
buf->real_type ? html_quote(buf->real_type) : "unknown",
"<tr valign=top><td nowrap>Last Modified<td>",
html_quote(last_modified(buf)),
#ifdef JP_CHARSET
"<tr valign=top><td nowrap>Document Code<td>",
code_to_str(buf->document_code),
#endif /* JP_CHARSET */
"<tr valign=top><td nowrap>Number of lines<td>",
Sprintf("%d", all)->ptr,
"<tr valign=top><td nowrap>Transferred bytes<td>",
Sprintf("%d", buf->trbyte)->ptr,
NULL);
a = retrieveCurrentAnchor(buf); a = retrieveCurrentAnchor(buf);
if (a != NULL) { if (a != NULL) {
@@ -542,26 +539,22 @@ page_info_panel(Buffer *buf)
parseURL2(a->url, &pu, baseURL(buf)); parseURL2(a->url, &pu, baseURL(buf));
s = parsedURL2Str(&pu); s = parsedURL2Str(&pu);
aurl = html_quote(s->ptr); aurl = html_quote(s->ptr);
Strcat_charp(tmp, "<tr><td nowrap>URL of current anchor<td>"); Strcat_m_charp(tmp, "<tr valign=top><td nowrap>URL of current anchor<td><a href=\"",
Strcat_m_charp(tmp, "<a href=\"", aurl, "\">", aurl, "</a>", NULL); aurl, "\">", aurl, "</a>", NULL);
} }
a = retrieveCurrentImg(buf); a = retrieveCurrentImg(buf);
if (a != NULL) { if (a != NULL) {
parseURL2(a->url, &pu, baseURL(buf)); parseURL2(a->url, &pu, baseURL(buf));
s = parsedURL2Str(&pu); s = parsedURL2Str(&pu);
Strcat_charp(tmp, "<tr><td nowrap>URL of current image<td>"); Strcat_m_charp(tmp, "<tr valign=top><td nowrap>URL of current image<td><a href=\"",
Strcat_charp(tmp, "<a href=\""); html_quote(s->ptr), "\">", html_quote(s->ptr),
Strcat_charp(tmp, html_quote(s->ptr)); "</a>", NULL);
Strcat_charp(tmp, "\">");
Strcat_charp(tmp, html_quote(s->ptr));
Strcat_charp(tmp, "</a>");
} }
a = retrieveCurrentForm(buf); a = retrieveCurrentForm(buf);
if (a != NULL) { if (a != NULL) {
FormItemList *fi = (FormItemList *)a->url; FormItemList *fi = (FormItemList *)a->url;
s = Strnew_charp(form2str(fi)); Strcat_m_charp(tmp, "<tr valign=top><td nowrap>Method/type of current form&nbsp;<td>",
Strcat_charp(tmp, "<tr><td nowrap>Method/type of current form<td>"); html_quote(form2str(fi)), NULL);
Strcat_charp(tmp, html_quote(s->ptr));
if (fi->parent->method == FORM_METHOD_INTERNAL && if (fi->parent->method == FORM_METHOD_INTERNAL &&
!Strcmp_charp(fi->parent->action, "map")) !Strcmp_charp(fi->parent->action, "map"))
append_map_info(buf, tmp, fi->parent->item); append_map_info(buf, tmp, fi->parent->item);
@@ -571,12 +564,11 @@ page_info_panel(Buffer *buf)
append_link_info(buf, tmp, buf->linklist); append_link_info(buf, tmp, buf->linklist);
if (buf->document_header != NULL) { if (buf->document_header != NULL) {
Strcat_charp(tmp, "<hr width=50%>\n"); Strcat_charp(tmp, "<hr width=50%><h1>Header information</h1><pre>\n");
Strcat_charp(tmp, "<h1>Header information</h1>\n"); for (ti = buf->document_header->first; ti != NULL; ti = ti->next)
for (ti = buf->document_header->first; ti != NULL; ti = ti->next) { Strcat_m_charp(tmp, "<pre_int>", html_quote(ti->ptr),
Strcat_charp(tmp, html_quote(ti->ptr)); "</pre_int>\n", NULL);
Strcat_charp(tmp, "<br>"); Strcat_charp(tmp, "</pre>\n");
}
} }
if (buf->frameset != NULL) if (buf->frameset != NULL)
@@ -586,17 +578,13 @@ page_info_panel(Buffer *buf)
f_set = buf->nextBuffer->frameset; f_set = buf->nextBuffer->frameset;
if (f_set) { if (f_set) {
Strcat_charp(tmp, "<hr width=50%><h1>Frame information</h1><pre>"); Strcat_charp(tmp, "<hr width=50%><h1>Frame information</h1>\n");
append_frame_info(buf, tmp, f_set, 0); append_frame_info(buf, tmp, f_set, 0);
Strcat_charp(tmp, "</pre>");
} }
#ifdef USE_SSL #ifdef USE_SSL
if (buf->ssl_certificate == NULL) if (buf->ssl_certificate)
goto end; Strcat_m_charp(tmp, "<h1>SSL certificate</h1><pre>\n",
Strcat_charp(tmp, "<h1>SSL certificate</h1>\n"); html_quote(buf->ssl_certificate), "</pre>\n", NULL);
Strcat_charp(tmp, "<pre>\n");
Strcat_charp(tmp, buf->ssl_certificate);
Strcat_charp(tmp, "</pre>\n");
#endif #endif
end: end:
Strcat_charp(tmp, "</body></html>"); Strcat_charp(tmp, "</body></html>");