Merge pull request #147 from oliverschmidt/master

Added several Web Browser changes and removed some 'register' keywords.
This commit is contained in:
Oliver Schmidt 2013-03-06 05:45:02 -08:00
commit 5ab48453cf
12 changed files with 66 additions and 54 deletions

View file

@ -1,5 +1,6 @@
html_slasha "/a\0"
html_slashcenter "/center\0"
html_slashdiv "/div\0"
html_slashform "/form\0"
html_slashh "/h\0"
html_slashscript "/script\0"

View file

@ -4,6 +4,9 @@ const char html_slasha[4] =
const char html_slashcenter[9] =
/* "/center\0" */
{0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
const char html_slashdiv[6] =
/* "/div\0" */
{0x2f, 0x64, 0x69, 0x76, 00, };
const char html_slashform[7] =
/* "/form\0" */
{0x2f, 0x66, 0x6f, 0x72, 0x6d, 00, };

View file

@ -1,5 +1,6 @@
extern const char html_slasha[4];
extern const char html_slashcenter[9];
extern const char html_slashdiv[6];
extern const char html_slashform[7];
extern const char html_slashh[4];
extern const char html_slashscript[9];

View file

@ -179,53 +179,55 @@ static const char *tags[] = {
html_slasha,
#define TAG_SLASHCENTER 1
html_slashcenter,
#define TAG_SLASHFORM 2
#define TAG_SLASHDIV 2
html_slashdiv,
#define TAG_SLASHFORM 3
html_slashform,
#define TAG_SLASHH 3
#define TAG_SLASHH 4
html_slashh,
#define TAG_SLASHSCRIPT 4
#define TAG_SLASHSCRIPT 5
html_slashscript,
#define TAG_SLASHSELECT 5
#define TAG_SLASHSELECT 6
html_slashselect,
#define TAG_SLASHSTYLE 6
#define TAG_SLASHSTYLE 7
html_slashstyle,
#define TAG_A 7
#define TAG_A 8
html_a,
#define TAG_BODY 8
#define TAG_BODY 9
html_body,
#define TAG_BR 9
#define TAG_BR 10
html_br,
#define TAG_CENTER 10
#define TAG_CENTER 11
html_center,
#define TAG_FORM 11
#define TAG_FORM 12
html_form,
#define TAG_FRAME 12
#define TAG_FRAME 13
html_frame,
#define TAG_H1 13
#define TAG_H1 14
html_h1,
#define TAG_H2 14
#define TAG_H2 15
html_h2,
#define TAG_H3 15
#define TAG_H3 16
html_h3,
#define TAG_H4 16
#define TAG_H4 17
html_h4,
#define TAG_IMG 17
#define TAG_IMG 18
html_img,
#define TAG_INPUT 18
#define TAG_INPUT 19
html_input,
#define TAG_LI 19
#define TAG_LI 20
html_li,
#define TAG_P 20
#define TAG_P 21
html_p,
#define TAG_SCRIPT 21
#define TAG_SCRIPT 22
html_script,
#define TAG_SELECT 22
#define TAG_SELECT 23
html_select,
#define TAG_STYLE 23
#define TAG_STYLE 24
html_style,
#define TAG_TR 24
#define TAG_TR 25
html_tr,
#define TAG_LAST 25
#define TAG_LAST 26
last,
};
@ -239,12 +241,25 @@ iswhitespace(char c)
c == ISO_ht);
}
/*-----------------------------------------------------------------------------------*/
#if WWW_CONF_FORMS
static void
init_input(void)
{
s.inputtype = HTMLPARSER_INPUTTYPE_NONE;
s.inputname[0] = s.inputvalue[0] = 0;
s.inputvaluesize = 20; /* De facto default size */
}
#endif /* WWW_CONF_FORMS */
/*-----------------------------------------------------------------------------------*/
void
htmlparser_init(void)
{
s.majorstate = s.lastmajorstate = MAJORSTATE_DISCARD;
s.minorstate = MINORSTATE_TEXT;
s.lastchar = 0;
#if WWW_CONF_FORMS
s.formaction[0] = s.formname[0] = 0;
#endif /* WWW_CONF_FORMS */
}
/*-----------------------------------------------------------------------------------*/
static char CC_FASTCALL
@ -325,7 +340,7 @@ find_tag(char *tag)
do {
tagc = tag[i];
if(tagc == 0 &&
if((tagc == 0 || tagc == ISO_slash) &&
tags[first][i] == 0) {
return first;
}
@ -376,6 +391,7 @@ parse_tag(void)
/* FALLTHROUGH */
case TAG_BR:
case TAG_TR:
case TAG_SLASHDIV:
case TAG_SLASHH:
/* parse_char(ISO_nl);*/
dummy = 0;
@ -457,7 +473,7 @@ parse_tag(void)
PRINTF(("Form name '%s'\n", s.tagattrparam));
strncpy(s.formname, s.tagattrparam, WWW_CONF_MAX_FORMNAMELEN - 1);
}
s.inputname[0] = s.inputvalue[0] = 0;
init_input();
break;
case TAG_SLASHFORM:
switch_majorstate(MAJORSTATE_BODY);
@ -483,7 +499,7 @@ parse_tag(void)
s.formname, s.formaction);
break;
}
s.inputtype = HTMLPARSER_INPUTTYPE_NONE;
init_input();
} else {
PRINTF(("Input '%s' '%s'\n", s.tagattr, s.tagattrparam));
if(strncmp(s.tagattr, html_type, sizeof(html_type)) == 0) {

View file

@ -6,9 +6,8 @@ http_get "GET "
http_10 "HTTP/1.0"
http_11 "HTTP/1.1"
http_content_type "content-type: "
http_texthtml "text/html"
http_location "location: "
http_host "host: "
http_host "Host: "
http_crnl "\r\n"
http_index_html "/index.html"
http_404_html "/404.html"

View file

@ -22,15 +22,12 @@ const char http_11[9] =
const char http_content_type[15] =
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
const char http_texthtml[10] =
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
const char http_location[11] =
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
const char http_host[7] =
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
/* "Host: " */
{0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
const char http_crnl[3] =
/* "\r\n" */
{0xd, 0xa, };

View file

@ -6,7 +6,6 @@ extern const char http_get[5];
extern const char http_10[9];
extern const char http_11[9];
extern const char http_content_type[15];
extern const char http_texthtml[10];
extern const char http_location[11];
extern const char http_host[7];
extern const char http_crnl[3];

View file

@ -325,7 +325,7 @@ open_url(void)
/* The hostname we present in the hostname table, so we send out the
initial GET request. */
if(webclient_get(host, 80, file) == 0) {
show_statustext("Out of memory error.");
show_statustext("Out of memory error");
} else {
show_statustext("Connecting...");
}
@ -534,7 +534,7 @@ PROCESS_THREAD(www_process, ev, data)
resolv_lookup((char *)data) != NULL) {
open_url();
} else {
show_statustext("Host not found.");
show_statustext("Host not found");
}
#endif /* UIP_UDP */
} else if(ev == ctk_signal_window_close ||
@ -602,7 +602,7 @@ webclient_timedout(void)
void
webclient_closed(void)
{
show_statustext("Stopped.");
show_statustext("Stopped");
petsciiconv_topetscii(webpageptr - x, x);
CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
redraw_window();
@ -638,12 +638,13 @@ void
webclient_datahandler(char *data, uint16_t len)
{
if(len > 0) {
if(strcmp(webclient_mimetype(), http_texthtml) == 0) {
if(strstr(webclient_mimetype(), http_html + 1) != 0) {
count = (count + 1) & 3;
show_statustext(receivingmsgs[count]);
htmlparser_parse(data, len);
redraw_window();
} else {
show_statustext("Cannot display web page");
uip_abort();
#if WWW_CONF_WITH_WGET
ctk_dialog_open(&wgetdialog);
@ -656,7 +657,7 @@ webclient_datahandler(char *data, uint16_t len)
if(data == NULL) {
loading = 0;
show_statustext("Done.");
show_statustext("Done");
petsciiconv_topetscii(webpageptr - x, x);
CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
redraw_window();

View file

@ -6,9 +6,8 @@ http_get "GET "
http_10 "HTTP/1.0"
http_11 "HTTP/1.1"
http_content_type "content-type: "
http_texthtml "text/html"
http_location "location: "
http_host "host: "
http_host "Host: "
http_crnl "\r\n"
http_index_htm "/index.htm"
http_index_html "/index.html"

View file

@ -22,15 +22,12 @@ const char http_11[9] =
const char http_content_type[15] =
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
const char http_texthtml[10] =
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
const char http_location[11] =
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
const char http_host[7] =
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
/* "Host: " */
{0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
const char http_crnl[3] =
/* "\r\n" */
{0xd, 0xa, };

View file

@ -6,7 +6,6 @@ extern const char http_get[5];
extern const char http_10[9];
extern const char http_11[9];
extern const char http_content_type[15];
extern const char http_texthtml[10];
extern const char http_location[11];
extern const char http_host[7];
extern const char http_crnl[3];

View file

@ -284,7 +284,7 @@ void
tcp_attach(struct uip_conn *conn,
void *appstate)
{
register uip_tcp_appstate_t *s;
uip_tcp_appstate_t *s;
s = &conn->appstate;
s->p = PROCESS_CURRENT();
@ -298,7 +298,7 @@ void
udp_attach(struct uip_udp_conn *conn,
void *appstate)
{
register uip_udp_appstate_t *s;
uip_udp_appstate_t *s;
s = &conn->appstate;
s->p = PROCESS_CURRENT();
@ -394,7 +394,7 @@ eventhandler(process_event_t ev, process_data_t data)
}
{
register struct uip_conn *cptr;
struct uip_conn *cptr;
for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) {
if(cptr->appstate.p == p) {
@ -406,7 +406,7 @@ eventhandler(process_event_t ev, process_data_t data)
#endif /* UIP_TCP */
#if UIP_UDP
{
register struct uip_udp_conn *cptr;
struct uip_udp_conn *cptr;
for(cptr = &uip_udp_conns[0];
cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) {
@ -697,7 +697,7 @@ tcpip_poll_tcp(struct uip_conn *conn)
void
tcpip_uipcall(void)
{
register uip_udp_appstate_t *ts;
uip_udp_appstate_t *ts;
#if UIP_UDP
if(uip_conn != NULL) {
@ -712,7 +712,7 @@ tcpip_uipcall(void)
#if UIP_TCP
{
static unsigned char i;
register struct listenport *l;
struct listenport *l;
/* If this is a connection request for a listening port, we must
mark the connection with the right process ID. */