Merge pull request #151 from oliverschmidt/master

Reorganized web page attribute data handling.
This commit is contained in:
Oliver Schmidt 2013-03-06 07:34:07 -08:00
commit 8e05c80d96
12 changed files with 313 additions and 461 deletions

View file

@ -1,5 +1,4 @@
html_slasha "/a\0" html_slasha "/a\0"
html_slashcenter "/center\0"
html_slashdiv "/div\0" html_slashdiv "/div\0"
html_slashform "/form\0" html_slashform "/form\0"
html_slashh "/h\0" html_slashh "/h\0"
@ -9,7 +8,6 @@ html_slashstyle "/style\0"
html_a "a\0" html_a "a\0"
html_body "body\0" html_body "body\0"
html_br "br\0" html_br "br\0"
html_center "center\0"
html_form "form\0" html_form "form\0"
html_frame "frame\0" html_frame "frame\0"
html_h1 "h1\0" html_h1 "h1\0"

View file

@ -1,9 +1,6 @@
const char html_slasha[4] = const char html_slasha[4] =
/* "/a\0" */ /* "/a\0" */
{0x2f, 0x61, 00, }; {0x2f, 0x61, 00, };
const char html_slashcenter[9] =
/* "/center\0" */
{0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
const char html_slashdiv[6] = const char html_slashdiv[6] =
/* "/div\0" */ /* "/div\0" */
{0x2f, 0x64, 0x69, 0x76, 00, }; {0x2f, 0x64, 0x69, 0x76, 00, };
@ -31,9 +28,6 @@ const char html_body[6] =
const char html_br[4] = const char html_br[4] =
/* "br\0" */ /* "br\0" */
{0x62, 0x72, 00, }; {0x62, 0x72, 00, };
const char html_center[8] =
/* "center\0" */
{0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
const char html_form[6] = const char html_form[6] =
/* "form\0" */ /* "form\0" */
{0x66, 0x6f, 0x72, 0x6d, 00, }; {0x66, 0x6f, 0x72, 0x6d, 00, };

View file

@ -1,5 +1,4 @@
extern const char html_slasha[4]; extern const char html_slasha[4];
extern const char html_slashcenter[9];
extern const char html_slashdiv[6]; extern const char html_slashdiv[6];
extern const char html_slashform[7]; extern const char html_slashform[7];
extern const char html_slashh[4]; extern const char html_slashh[4];
@ -9,7 +8,6 @@ extern const char html_slashstyle[8];
extern const char html_a[3]; extern const char html_a[3];
extern const char html_body[6]; extern const char html_body[6];
extern const char html_br[4]; extern const char html_br[4];
extern const char html_center[8];
extern const char html_form[6]; extern const char html_form[6];
extern const char html_frame[7]; extern const char html_frame[7];
extern const char html_h1[4]; extern const char html_h1[4];

View file

@ -160,7 +160,6 @@ struct htmlparser_state {
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
char formaction[WWW_CONF_MAX_FORMACTIONLEN]; char formaction[WWW_CONF_MAX_FORMACTIONLEN];
char formname[WWW_CONF_MAX_FORMNAMELEN];
unsigned char inputtype; unsigned char inputtype;
char inputname[WWW_CONF_MAX_INPUTNAMELEN]; char inputname[WWW_CONF_MAX_INPUTNAMELEN];
char inputvalue[WWW_CONF_MAX_INPUTVALUELEN]; char inputvalue[WWW_CONF_MAX_INPUTVALUELEN];
@ -177,57 +176,53 @@ static const char *tags[] = {
#define TAG_FIRST 0 #define TAG_FIRST 0
#define TAG_SLASHA 0 #define TAG_SLASHA 0
html_slasha, html_slasha,
#define TAG_SLASHCENTER 1 #define TAG_SLASHDIV 1
html_slashcenter,
#define TAG_SLASHDIV 2
html_slashdiv, html_slashdiv,
#define TAG_SLASHFORM 3 #define TAG_SLASHFORM 2
html_slashform, html_slashform,
#define TAG_SLASHH 4 #define TAG_SLASHH 3
html_slashh, html_slashh,
#define TAG_SLASHSCRIPT 5 #define TAG_SLASHSCRIPT 4
html_slashscript, html_slashscript,
#define TAG_SLASHSELECT 6 #define TAG_SLASHSELECT 5
html_slashselect, html_slashselect,
#define TAG_SLASHSTYLE 7 #define TAG_SLASHSTYLE 6
html_slashstyle, html_slashstyle,
#define TAG_A 8 #define TAG_A 7
html_a, html_a,
#define TAG_BODY 9 #define TAG_BODY 8
html_body, html_body,
#define TAG_BR 10 #define TAG_BR 9
html_br, html_br,
#define TAG_CENTER 11 #define TAG_FORM 10
html_center,
#define TAG_FORM 12
html_form, html_form,
#define TAG_FRAME 13 #define TAG_FRAME 11
html_frame, html_frame,
#define TAG_H1 14 #define TAG_H1 12
html_h1, html_h1,
#define TAG_H2 15 #define TAG_H2 13
html_h2, html_h2,
#define TAG_H3 16 #define TAG_H3 14
html_h3, html_h3,
#define TAG_H4 17 #define TAG_H4 15
html_h4, html_h4,
#define TAG_IMG 18 #define TAG_IMG 16
html_img, html_img,
#define TAG_INPUT 19 #define TAG_INPUT 17
html_input, html_input,
#define TAG_LI 20 #define TAG_LI 18
html_li, html_li,
#define TAG_P 21 #define TAG_P 19
html_p, html_p,
#define TAG_SCRIPT 22 #define TAG_SCRIPT 20
html_script, html_script,
#define TAG_SELECT 23 #define TAG_SELECT 21
html_select, html_select,
#define TAG_STYLE 24 #define TAG_STYLE 22
html_style, html_style,
#define TAG_TR 25 #define TAG_TR 23
html_tr, html_tr,
#define TAG_LAST 26 #define TAG_LAST 24
last, last,
}; };
@ -258,7 +253,7 @@ htmlparser_init(void)
s.minorstate = MINORSTATE_TEXT; s.minorstate = MINORSTATE_TEXT;
s.lastchar = 0; s.lastchar = 0;
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
s.formaction[0] = s.formname[0] = 0; s.formaction[0] = 0;
#endif /* WWW_CONF_FORMS */ #endif /* WWW_CONF_FORMS */
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -340,23 +335,20 @@ find_tag(char *tag)
do { do {
tagc = tag[i]; tagc = tag[i];
if((tagc == 0 || tagc == ISO_slash) && if((tagc == 0 || tagc == ISO_slash) && tags[first][i] == 0) {
tags[first][i] == 0) {
return first; return first;
} }
tabi = first; tabi = first;
/* First, find first matching tag from table. */ /* First, find first matching tag from table. */
while(tagc > (tags[tabi])[i] && while(tagc > (tags[tabi])[i] && tabi < last) {
tabi < last) {
++tabi; ++tabi;
} }
first = tabi; first = tabi;
/* Second, find last matching tag from table. */ /* Second, find last matching tag from table. */
while(tagc == (tags[tabi])[i] && while(tagc == (tags[tabi])[i] && tabi < last) {
tabi < last) {
++tabi; ++tabi;
} }
last = tabi; last = tabi;
@ -377,8 +369,7 @@ parse_tag(void)
static char dummy; static char dummy;
PRINTF(("Parsing tag '%s' '%s' '%s'\n", PRINTF(("Parsing tag '%s' '%s' '%s'\n", s.tag, s.tagattr, s.tagattrparam));
s.tag, s.tagattr, s.tagattrparam));
switch(find_tag(s.tag)) { switch(find_tag(s.tag)) {
case TAG_P: case TAG_P:
@ -386,14 +377,12 @@ parse_tag(void)
case TAG_H2: case TAG_H2:
case TAG_H3: case TAG_H3:
case TAG_H4: case TAG_H4:
/* parse_char(ISO_nl);*/
newline(); newline();
/* FALLTHROUGH */ /* FALLTHROUGH */
case TAG_BR: case TAG_BR:
case TAG_TR: case TAG_TR:
case TAG_SLASHDIV: case TAG_SLASHDIV:
case TAG_SLASHH: case TAG_SLASHH:
/* parse_char(ISO_nl);*/
dummy = 0; dummy = 0;
newline(); newline();
break; break;
@ -417,8 +406,7 @@ parse_tag(void)
s.majorstate = s.lastmajorstate = MAJORSTATE_BODY; s.majorstate = s.lastmajorstate = MAJORSTATE_BODY;
break; break;
case TAG_FRAME: case TAG_FRAME:
if(strncmp(s.tagattr, html_src, sizeof(html_src)) == 0 && if(strncmp(s.tagattr, html_src, sizeof(html_src)) == 0 && s.tagattrparam[0] != 0) {
s.tagattrparam[0] != 0) {
switch_majorstate(MAJORSTATE_BODY); switch_majorstate(MAJORSTATE_BODY);
newline(); newline();
add_char(ISO_rbrack); add_char(ISO_rbrack);
@ -430,25 +418,20 @@ parse_tag(void)
} }
break; break;
case TAG_IMG: case TAG_IMG:
if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 && if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 && s.tagattrparam[0] != 0) {
s.tagattrparam[0] != 0) {
/* parse_char(ISO_lt);*/
add_char(ISO_lt); add_char(ISO_lt);
tagattrparam = &s.tagattrparam[0]; tagattrparam = &s.tagattrparam[0];
while(*tagattrparam) { while(*tagattrparam) {
/* parse_char(*tagattrparam);*/
add_char(*tagattrparam); add_char(*tagattrparam);
++tagattrparam; ++tagattrparam;
} }
/* parse_char(ISO_gt);*/
add_char(ISO_gt); add_char(ISO_gt);
do_word(); do_word();
} }
break; break;
case TAG_A: case TAG_A:
PRINTF(("A %s %s\n", s.tagattr, s.tagattrparam)); PRINTF(("A %s %s\n", s.tagattr, s.tagattrparam));
if(strncmp(s.tagattr, html_href, sizeof(html_href)) == 0 && if(strncmp(s.tagattr, html_href, sizeof(html_href)) == 0 && s.tagattrparam[0] != 0) {
s.tagattrparam[0] != 0) {
strcpy(s.linkurl, s.tagattrparam); strcpy(s.linkurl, s.tagattrparam);
do_word(); do_word();
switch_majorstate(MAJORSTATE_LINK); switch_majorstate(MAJORSTATE_LINK);
@ -464,72 +447,62 @@ parse_tag(void)
break; break;
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
case TAG_FORM: case TAG_FORM:
/* First check if we are called at the end of a form tag. If
so, we should propagate the form action. */
if(s.tagattr[0] == 0 && s.formaction[0] != 0) {
htmlparser_form(s.formaction);
init_input();
} else {
PRINTF(("Form tag\n")); PRINTF(("Form tag\n"));
switch_majorstate(MAJORSTATE_FORM); switch_majorstate(MAJORSTATE_FORM);
if(strncmp(s.tagattr, html_action, sizeof(html_action)) == 0) { if(strncmp(s.tagattr, html_action, sizeof(html_action)) == 0) {
PRINTF(("Form action '%s'\n", s.tagattrparam)); PRINTF(("Form action '%s'\n", s.tagattrparam));
strncpy(s.formaction, s.tagattrparam, WWW_CONF_MAX_FORMACTIONLEN - 1); strncpy(s.formaction, s.tagattrparam, WWW_CONF_MAX_FORMACTIONLEN - 1);
} else if(strncmp(s.tagattr, html_name, sizeof(html_name)) == 0) {
PRINTF(("Form name '%s'\n", s.tagattrparam));
strncpy(s.formname, s.tagattrparam, WWW_CONF_MAX_FORMNAMELEN - 1);
} }
init_input(); }
break; break;
case TAG_SLASHFORM: case TAG_SLASHFORM:
switch_majorstate(MAJORSTATE_BODY); switch_majorstate(MAJORSTATE_BODY);
s.formaction[0] = s.formname[0] = 0; s.formaction[0] = 0;
break; break;
case TAG_INPUT: case TAG_INPUT:
if(s.majorstate == MAJORSTATE_FORM) { if(s.majorstate == MAJORSTATE_FORM) {
/* First check if we are called at the end of an input tag. If /* First check if we are called at the end of an input tag. If
so, we should render the input widget. */ so, we should render the input widget. */
if(s.tagattr[0] == 0 && if(s.tagattr[0] == 0 && s.inputname[0] != 0) {
s.inputname[0] != 0) {
PRINTF(("Render input type %d\n", s.inputtype)); PRINTF(("Render input type %d\n", s.inputtype));
switch(s.inputtype) { switch(s.inputtype) {
case HTMLPARSER_INPUTTYPE_NONE: case HTMLPARSER_INPUTTYPE_NONE:
case HTMLPARSER_INPUTTYPE_TEXT: case HTMLPARSER_INPUTTYPE_TEXT:
s.inputvalue[s.inputvaluesize] = 0; s.inputvalue[s.inputvaluesize] = 0;
htmlparser_inputfield(s.inputvaluesize, s.inputvalue, s.inputname, htmlparser_inputfield(s.inputvaluesize, s.inputvalue, s.inputname);
s.formname, s.formaction);
break; break;
case HTMLPARSER_INPUTTYPE_SUBMIT: case HTMLPARSER_INPUTTYPE_SUBMIT:
case HTMLPARSER_INPUTTYPE_IMAGE: case HTMLPARSER_INPUTTYPE_IMAGE:
htmlparser_submitbutton(s.inputvalue, s.inputname, htmlparser_submitbutton(s.inputvalue, s.inputname);
s.formname, s.formaction);
break; break;
} }
init_input(); init_input();
} else { } else {
PRINTF(("Input '%s' '%s'\n", s.tagattr, s.tagattrparam)); PRINTF(("Input '%s' '%s'\n", s.tagattr, s.tagattrparam));
if(strncmp(s.tagattr, html_type, sizeof(html_type)) == 0) { if(strncmp(s.tagattr, html_type, sizeof(html_type)) == 0) {
if(strncmp(s.tagattrparam, html_submit, if(strncmp(s.tagattrparam, html_submit, sizeof(html_submit)) == 0) {
sizeof(html_submit)) == 0) {
s.inputtype = HTMLPARSER_INPUTTYPE_SUBMIT; s.inputtype = HTMLPARSER_INPUTTYPE_SUBMIT;
} else if(strncmp(s.tagattrparam, html_image, } else if(strncmp(s.tagattrparam, html_image, sizeof(html_image)) == 0) {
sizeof(html_image)) == 0) {
s.inputtype = HTMLPARSER_INPUTTYPE_IMAGE; s.inputtype = HTMLPARSER_INPUTTYPE_IMAGE;
} else if(strncmp(s.tagattrparam, html_text, } else if(strncmp(s.tagattrparam, html_text, sizeof(html_text)) == 0) {
sizeof(html_text)) == 0) {
s.inputtype = HTMLPARSER_INPUTTYPE_TEXT; s.inputtype = HTMLPARSER_INPUTTYPE_TEXT;
} else { } else {
s.inputtype = HTMLPARSER_INPUTTYPE_OTHER; s.inputtype = HTMLPARSER_INPUTTYPE_OTHER;
} }
} else if(strncmp(s.tagattr, html_name, } else if(strncmp(s.tagattr, html_name, sizeof(html_name)) == 0) {
sizeof(html_name)) == 0) { strncpy(s.inputname, s.tagattrparam, WWW_CONF_MAX_INPUTNAMELEN);
strncpy(s.inputname, s.tagattrparam, } else if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 &&
WWW_CONF_MAX_INPUTNAMELEN);
} else if(strncmp(s.tagattr, html_alt,
sizeof(html_alt)) == 0 &&
s.inputtype == HTMLPARSER_INPUTTYPE_IMAGE) { s.inputtype == HTMLPARSER_INPUTTYPE_IMAGE) {
strncpy(s.inputvalue, s.tagattrparam, strncpy(s.inputvalue, s.tagattrparam, WWW_CONF_MAX_INPUTVALUELEN);
WWW_CONF_MAX_INPUTVALUELEN); } else if(strncmp(s.tagattr, html_value, sizeof(html_value)) == 0) {
} else if(strncmp(s.tagattr, html_value, strncpy(s.inputvalue, s.tagattrparam, WWW_CONF_MAX_INPUTVALUELEN);
sizeof(html_value)) == 0) { } else if(strncmp(s.tagattr, html_size, sizeof(html_size)) == 0) {
strncpy(s.inputvalue, s.tagattrparam,
WWW_CONF_MAX_INPUTVALUELEN);
} else if(strncmp(s.tagattr, html_size,
sizeof(html_size)) == 0) {
size = 0; size = 0;
if(s.tagattrparam[0] >= '0' && if(s.tagattrparam[0] >= '0' &&
s.tagattrparam[0] <= '9') { s.tagattrparam[0] <= '9') {
@ -543,32 +516,15 @@ parse_tag(void)
size = WWW_CONF_MAX_INPUTVALUELEN - 1; size = WWW_CONF_MAX_INPUTVALUELEN - 1;
} }
s.inputvaluesize = size; s.inputvaluesize = size;
/* strncpy(s.inputvalue, s.tagattrparam,
WWW_CONF_MAX_INPUTVALUELEN);*/
} }
} }
} }
break; break;
#endif /* WWW_CONF_FORMS */ #endif /* WWW_CONF_FORMS */
#if WWW_CONF_RENDERSTATE
case TAG_CENTER:
/* parse_char(ISO_nl); */
newline();
htmlparser_renderstate(HTMLPARSER_RENDERSTATE_BEGIN |
HTMLPARSER_RENDERSTATE_CENTER);
break;
case TAG_SLASHCENTER:
/* parse_char(ISO_nl);*/
newline();
htmlparser_renderstate(HTMLPARSER_RENDERSTATE_END |
HTMLPARSER_RENDERSTATE_CENTER);
break;
#endif /* WWW_CONF_RENDERSTATE */
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static uint16_t static uint16_t CC_FASTCALL
parse_word(char *data, uint8_t dlen) parse_word(char *data, uint8_t dlen)
{ {
static uint8_t i; static uint8_t i;
@ -586,7 +542,6 @@ parse_word(char *data, uint8_t dlen)
} else if(c == ISO_lt) { } else if(c == ISO_lt) {
s.minorstate = MINORSTATE_TAG; s.minorstate = MINORSTATE_TAG;
s.tagptr = 0; s.tagptr = 0;
/* do_word();*/
break; break;
} else if(c == ISO_ampersand) { } else if(c == ISO_ampersand) {
s.minorstate = MINORSTATE_EXTCHAR; s.minorstate = MINORSTATE_EXTCHAR;
@ -635,7 +590,6 @@ parse_word(char *data, uint8_t dlen)
} else { } else {
/* Keep track of the name of the tag, but convert it to /* Keep track of the name of the tag, but convert it to
lower case. */ lower case. */
s.tag[s.tagptr] = lowercase(c); s.tag[s.tagptr] = lowercase(c);
++s.tagptr; ++s.tagptr;
/* Check if the ->tag field is full. If so, we just eat up /* Check if the ->tag field is full. If so, we just eat up
@ -684,8 +638,6 @@ parse_word(char *data, uint8_t dlen)
parse_tag(); parse_tag();
s.minorstate = MINORSTATE_TAGATTRSPACE; s.minorstate = MINORSTATE_TAGATTRSPACE;
break; break;
/* s.tagattrptr = 0;
endtagfound();*/
} }
} else if(c == ISO_eq) { } else if(c == ISO_eq) {
s.minorstate = MINORSTATE_TAGATTRPARAMNQ; s.minorstate = MINORSTATE_TAGATTRPARAMNQ;
@ -739,19 +691,16 @@ parse_word(char *data, uint8_t dlen)
s.tagptr = 0; s.tagptr = 0;
endtagfound(); endtagfound();
break; break;
} else if(iswhitespace(c) && } else if(iswhitespace(c) && s.tagattrparamptr == 0) {
s.tagattrparamptr == 0) {
/* Discard leading spaces. */ /* Discard leading spaces. */
} else if((c == ISO_citation || } else if((c == ISO_citation ||
c == ISO_citation2) && c == ISO_citation2) && s.tagattrparamptr == 0) {
s.tagattrparamptr == 0) {
s.minorstate = MINORSTATE_TAGATTRPARAM; s.minorstate = MINORSTATE_TAGATTRPARAM;
s.quotechar = c; s.quotechar = c;
PRINTF(("tag attr param q found\n")); PRINTF(("tag attr param q found\n"));
break; break;
} else if(iswhitespace(c)) { } else if(iswhitespace(c)) {
PRINTF(("Non-leading space found at %d\n", PRINTF(("Non-leading space found at %d\n", s.tagattrparamptr));
s.tagattrparamptr));
/* Stop parsing if a non-leading space was found */ /* Stop parsing if a non-leading space was found */
endtagfound(); endtagfound();
parse_tag(); parse_tag();

View file

@ -38,29 +38,15 @@
/* Callbacks. */ /* Callbacks. */
void htmlparser_link(char *text, unsigned char textlen, char *url); void htmlparser_link(char *text, unsigned char textlen, char *url);
void htmlparser_form(char *action);
void htmlparser_submitbutton(char *value, void htmlparser_submitbutton(char *value,
char *name, char *name);
char *formname,
char *formaction);
void htmlparser_inputfield(unsigned char size, void htmlparser_inputfield(unsigned char size,
char *value, char *value,
char *name, char *name);
char *formname,
char *formaction);
void htmlparser_newline(void); void htmlparser_newline(void);
void htmlparser_word(char *word, unsigned char wordlen); void htmlparser_word(char *word, unsigned char wordlen);
void htmlparser_renderstate(unsigned char state);
#define HTMLPARSER_RENDERSTATE_STATUSMASK 0x80
#define HTMLPARSER_RENDERSTATE_BEGIN 0x00
#define HTMLPARSER_RENDERSTATE_END 0x80
#define HTMLPARSER_RENDERSTATE_NONE 0x00
#define HTMLPARSER_RENDERSTATE_CENTER 0x01
#define HTMLPARSER_RENDERSTATE_TABLE 0x02
#define HTMLPARSER_RENDERSTATE_TR 0x04
#define HTMLPARSER_RENDERSTATE_TD 0x08
#define HTMLPARSER_INPUTTYPE_NONE 0 #define HTMLPARSER_INPUTTYPE_NONE 0
#define HTMLPARSER_INPUTTYPE_TEXT 1 #define HTMLPARSER_INPUTTYPE_TEXT 1

View file

@ -33,6 +33,7 @@
*/ */
#include <string.h> #include <string.h>
#include <stddef.h>
#include "ctk/ctk.h" #include "ctk/ctk.h"
#include "lib/ctk-textentry-cmdline.h" #include "lib/ctk-textentry-cmdline.h"
@ -59,13 +60,11 @@
/* The array that holds the current URL. */ /* The array that holds the current URL. */
static char url[WWW_CONF_MAX_URLLEN + 1]; static char url[WWW_CONF_MAX_URLLEN + 1];
static char tmpurl[WWW_CONF_MAX_URLLEN + 1];
/* The array that holds the web page text. */ /* The array that holds the web page text. */
static char webpage[WWW_CONF_WEBPAGE_WIDTH * static char webpage[WWW_CONF_WEBPAGE_WIDTH *
WWW_CONF_WEBPAGE_HEIGHT + 1]; WWW_CONF_WEBPAGE_HEIGHT + 1];
/* The CTK widgets for the main window. */ /* The CTK widgets for the main window. */
static struct ctk_window mainwindow; static struct ctk_window mainwindow;
@ -120,31 +119,45 @@ static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
static char history_last; static char history_last;
#endif /* WWW_CONF_HISTORY_SIZE > 0 */ #endif /* WWW_CONF_HISTORY_SIZE > 0 */
/* The CTK widget definitions for the hyperlinks and the char arrays struct linkattrib {
that hold the link URLs. */ struct ctk_hyperlink hyperlink;
struct formattribs { char url[1];
char formaction[WWW_CONF_MAX_FORMACTIONLEN];
char formname[WWW_CONF_MAX_FORMNAMELEN];
#define FORMINPUTTYPE_SUBMITBUTTON 1
#define FORMINPUTTYPE_INPUTFIELD 2
unsigned char inputtype;
char inputname[WWW_CONF_MAX_INPUTNAMELEN];
char *inputvalue;
}; };
union pagewidgetattrib { struct inputattrib;
char url[WWW_CONF_MAX_URLLEN];
struct formattrib {
struct inputattrib *nextptr;
char action[1];
};
struct inputattrib {
struct inputattrib *nextptr;
struct formattrib *formptr;
struct ctk_widget widget;
};
struct textattrib {
struct inputattrib *nextptr;
struct formattrib *formptr;
struct ctk_textentry textentry;
char name[1];
};
struct submitattrib {
struct inputattrib *nextptr;
struct formattrib *formptr;
struct ctk_button button;
char name[1];
};
static char pageattribs[WWW_CONF_PAGEATTRIB_SIZE];
static char *pageattribptr;
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
struct formattribs form; static struct formattrib *formptr;
static struct inputattrib *currptr;
#endif /* WWW_CONF_FORMS */ #endif /* WWW_CONF_FORMS */
};
static struct ctk_widget pagewidgets[WWW_CONF_MAX_NUMPAGEWIDGETS];
static union pagewidgetattrib pagewidgetattribs[WWW_CONF_MAX_NUMPAGEWIDGETS];
static unsigned char pagewidgetptr;
#if WWW_CONF_RENDERSTATE
static unsigned char renderstate;
#endif /* WWW_CONF_RENDERSTATE */
#define ISO_nl 0x0a #define ISO_nl 0x0a
#define ISO_space 0x20 #define ISO_space 0x20
@ -172,7 +185,7 @@ PROCESS(www_process, "Web browser");
AUTOSTART_PROCESSES(&www_process); AUTOSTART_PROCESSES(&www_process);
static void formsubmit(struct formattribs *attribs); static void CC_FASTCALL formsubmit(struct formattrib *form);
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* make_window() /* make_window()
@ -195,7 +208,7 @@ make_window(void)
CTK_WIDGET_ADD(&mainwindow, &sep2); CTK_WIDGET_ADD(&mainwindow, &sep2);
CTK_WIDGET_ADD(&mainwindow, &statustext); CTK_WIDGET_ADD(&mainwindow, &statustext);
pagewidgetptr = 0; pageattribptr = pageattribs;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* redraw_window(): /* redraw_window():
@ -208,6 +221,29 @@ redraw_window(void)
ctk_window_redraw(&mainwindow); ctk_window_redraw(&mainwindow);
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static char * CC_FASTCALL
add_pageattrib(unsigned size)
{
char *ptr;
if(pageattribptr + size > pageattribs + sizeof(pageattribs)) {
return NULL;
}
ptr = pageattribptr;
pageattribptr += size;
return ptr;
}
/*-----------------------------------------------------------------------------------*/
#if WWW_CONF_FORMS
static void CC_FASTCALL
add_forminput(struct inputattrib *inputptr)
{
inputptr->nextptr = NULL;
currptr->nextptr = inputptr;
currptr = inputptr;
}
#endif /* WWW_CONF_FORMS */
/*-----------------------------------------------------------------------------------*/
static void static void
clear_page(void) clear_page(void)
{ {
@ -237,7 +273,7 @@ start_loading(void)
clear_page(); clear_page();
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void static void CC_FASTCALL
show_statustext(char *text) show_statustext(char *text)
{ {
ctk_label_set_text(&statustext, text); ctk_label_set_text(&statustext, text);
@ -332,15 +368,15 @@ open_url(void)
redraw_window(); redraw_window();
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* open_link(link): /* set_link(link):
* *
* Will format a link from the current web pages so that it suits the * Will format a link from the current web pages so that it suits the
* open_url() function and finally call it to open the requested URL. * open_url() function.
*/ */
static void static void CC_FASTCALL
open_link(char *link) set_link(char *link)
{ {
char *urlptr; register char *urlptr;
if(strncmp(link, http_http, 7) == 0) { if(strncmp(link, http_http, 7) == 0) {
/* The link starts with http://. We just copy the contents of the /* The link starts with http://. We just copy the contents of the
@ -373,12 +409,6 @@ open_link(char *link)
++urlptr; ++urlptr;
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url)); strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
} }
/* Open the URL. */
show_url();
open_url();
start_loading();
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
#if WWW_CONF_HISTORY_SIZE > 0 #if WWW_CONF_HISTORY_SIZE > 0
@ -497,18 +527,10 @@ PROCESS_THREAD(www_process, ev, data)
#endif /* WWW_CONF_WITH_WGET */ #endif /* WWW_CONF_WITH_WGET */
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
} else { } else {
/* Check form buttons */ /* Assume form widget. */
for(i = 0; i < pagewidgetptr; ++i) { struct inputattrib *input = (struct inputattrib *)
if(&pagewidgets[i] == w) { (((char *)w) - offsetof(struct inputattrib, widget));
formsubmit(&pagewidgetattribs[i].form); formsubmit(input->formptr);
/* show_statustext(pagewidgetattribs[i].form.formaction);*/
/* PRINTF(("Formaction %s formname %s inputname %s\n",
pagewidgetattribs[i].form.formaction,
pagewidgetattribs[i].form.formname,
pagewidgetattribs[i].form.inputname));*/
break;
}
}
#endif /* WWW_CONF_FORMS */ #endif /* WWW_CONF_FORMS */
} }
} else if(ev == ctk_signal_hyperlink_activate) { } else if(ev == ctk_signal_hyperlink_activate) {
@ -516,12 +538,13 @@ PROCESS_THREAD(www_process, ev, data)
#if WWW_CONF_HISTORY_SIZE > 0 #if WWW_CONF_HISTORY_SIZE > 0
log_back(); log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */ #endif /* WWW_CONF_HISTORY_SIZE > 0 */
open_link(w->widget.hyperlink.url); set_link(w->widget.hyperlink.url);
show_url();
open_url();
start_loading();
CTK_WIDGET_FOCUS(&mainwindow, &stopbutton); CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
/* ctk_window_open(&mainwindow);*/
} else if(ev == ctk_signal_hyperlink_hover) { } else if(ev == ctk_signal_hyperlink_hover) {
if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) {
CTK_WIDGET_HYPERLINK) {
strncpy(statustexturl, w->widget.hyperlink.url, strncpy(statustexturl, w->widget.hyperlink.url,
sizeof(statustexturl)); sizeof(statustexturl));
petsciiconv_topetscii(statustexturl, sizeof(statustexturl)); petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
@ -530,8 +553,7 @@ PROCESS_THREAD(www_process, ev, data)
#if UIP_UDP #if UIP_UDP
} else if(ev == resolv_event_found) { } else if(ev == resolv_event_found) {
/* Either found a hostname, or not. */ /* Either found a hostname, or not. */
if((char *)data != NULL && if((char *)data != NULL && resolv_lookup((char *)data) != NULL) {
resolv_lookup((char *)data) != NULL) {
open_url(); open_url();
} else { } else {
show_statustext("Host not found"); show_statustext("Host not found");
@ -551,7 +573,7 @@ PROCESS_THREAD(www_process, ev, data)
* "url" variable and the visible "editurl" (which is shown in the URL * "url" variable and the visible "editurl" (which is shown in the URL
* text entry widget in the browser window). * text entry widget in the browser window).
*/ */
static void static void CC_FASTCALL
set_url(char *host, uint16_t port, char *file) set_url(char *host, uint16_t port, char *file)
{ {
char *urlptr; char *urlptr;
@ -623,9 +645,6 @@ webclient_connected(void)
show_statustext("Request sent..."); show_statustext("Request sent...");
set_url(webclient_hostname(), webclient_port(), webclient_filename()); set_url(webclient_hostname(), webclient_port(), webclient_filename());
#if WWW_CONF_RENDERSTATE
renderstate = HTMLPARSER_RENDERSTATE_NONE;
#endif /* WWW_CONF_RENDERSTATE */
htmlparser_init(); htmlparser_init();
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -664,21 +683,19 @@ webclient_datahandler(char *data, uint16_t len)
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void * static void CC_FASTCALL
add_pagewidget(char *text, unsigned char len, unsigned char type, add_pagewidget(char *text, unsigned char textlen, char *attrib, unsigned char type,
unsigned char border) unsigned char border)
{ {
register struct ctk_widget *lptr; char *wptr;
register char *wptr;
static unsigned char maxwidth; static unsigned char maxwidth;
static void *dataptr;
if(!loading) { if(!loading) {
return NULL; return;
} }
if(len + border == 0) { if(textlen + border == 0) {
return NULL; return;
} }
maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border); maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border);
@ -686,10 +703,10 @@ add_pagewidget(char *text, unsigned char len, unsigned char type,
/* If the text of the link is too long so that it does not fit into /* If the text of the link is too long so that it does not fit into
the width of the current window, counting from the current x the width of the current window, counting from the current x
coordinate, we first try to jump to the next line. */ coordinate, we first try to jump to the next line. */
if(len + x > maxwidth) { if(textlen + x > maxwidth) {
htmlparser_newline(); htmlparser_newline();
if(!loading) { if(!loading) {
return NULL; return;
} }
} }
@ -697,103 +714,84 @@ add_pagewidget(char *text, unsigned char len, unsigned char type,
XXX: this is not really the right thing to do, we should probably XXX: this is not really the right thing to do, we should probably
either make a link into a multiline link, or add multiple either make a link into a multiline link, or add multiple
buttons. But this will do for now. */ buttons. But this will do for now. */
if(len > maxwidth) { if(textlen > maxwidth) {
text[maxwidth] = 0; text[maxwidth] = 0;
len = maxwidth; textlen = maxwidth;
} }
dataptr = NULL;
if(firsty == pagey) { if(firsty == pagey) {
unsigned char attriblen = strlen(attrib);
wptr = webpageptr; wptr = webpageptr;
/* To save memory, we'll copy the widget text to the web page /* To save memory, we'll copy the widget text to the web page
drawing area and reference it from there. */ drawing area and reference it from there. */
wptr[0] = 0; wptr[0] = 0;
wptr += border; wptr += border;
memcpy(wptr, text, len); memcpy(wptr, text, textlen);
wptr[len] = 0; wptr[textlen] = 0;
wptr[len + border] = ' '; wptr[textlen + border] = ' ';
if(pagewidgetptr < WWW_CONF_MAX_NUMPAGEWIDGETS) {
dataptr = &pagewidgetattribs[pagewidgetptr];
lptr = &pagewidgets[pagewidgetptr];
switch(type) { switch(type) {
case CTK_WIDGET_HYPERLINK: case CTK_WIDGET_HYPERLINK: {
CTK_HYPERLINK_NEW((struct ctk_hyperlink *)lptr, x, struct linkattrib *linkptr;
y + 3, len,
wptr, dataptr); linkptr = (struct linkattrib *)add_pageattrib(sizeof(struct linkattrib) /* incl 1 attrib char */ + attriblen);
break; if(linkptr != NULL) {
case CTK_WIDGET_BUTTON: CTK_HYPERLINK_NEW(&linkptr->hyperlink, x, y + 3, textlen, wptr, linkptr->url);
CTK_BUTTON_NEW((struct ctk_button *)lptr, x, strcpy(linkptr->url, attrib);
y + 3, len, CTK_WIDGET_SET_FLAG(&linkptr->hyperlink, CTK_WIDGET_FLAG_MONOSPACE);
wptr); CTK_WIDGET_ADD(&mainwindow, &linkptr->hyperlink);
((struct formattribs *)dataptr)->inputvalue = wptr; }
break;
case CTK_WIDGET_TEXTENTRY:
CTK_TEXTENTRY_NEW((struct ctk_textentry *)lptr, x,
y + 3, len, 1,
wptr, len);
((struct formattribs *)dataptr)->inputvalue = wptr;
break; break;
} }
CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE); #if WWW_CONF_FORMS
CTK_WIDGET_ADD(&mainwindow, lptr); case CTK_WIDGET_BUTTON: {
struct submitattrib *submitptr;
++pagewidgetptr; submitptr = (struct submitattrib *)add_pageattrib(sizeof(struct submitattrib) /* incl 1 attrib char */ + attriblen);
if(submitptr != NULL) {
CTK_BUTTON_NEW((struct ctk_button *)&submitptr->button, x, y + 3, textlen, wptr);
add_forminput((struct inputattrib *)submitptr);
submitptr->formptr = formptr;
strcpy(submitptr->name, attrib);
CTK_WIDGET_SET_FLAG(&submitptr->button, CTK_WIDGET_FLAG_MONOSPACE);
CTK_WIDGET_ADD(&mainwindow, &submitptr->button);
}
break;
}
case CTK_WIDGET_TEXTENTRY: {
struct textattrib *textptr;
textptr = (struct textattrib *)add_pageattrib(sizeof(struct textattrib) /* incl 1 attrib char */ + attriblen + WWW_CONF_MAX_INPUTVALUELEN);
if(textptr != NULL) {
CTK_TEXTENTRY_NEW((struct ctk_textentry *)&textptr->textentry, x, y + 3, textlen, 1,
textptr->name + attriblen + 1, WWW_CONF_MAX_INPUTVALUELEN);
add_forminput((struct inputattrib *)textptr);
textptr->formptr = formptr;
strcpy(textptr->textentry.text, text);
strcpy(textptr->name, attrib);
CTK_WIDGET_SET_FLAG(&textptr->textentry, CTK_WIDGET_FLAG_MONOSPACE);
CTK_WIDGET_ADD(&mainwindow, &textptr->textentry);
}
break;
}
#endif /* WWW_CONF_FORMS */
} }
} }
/* Increase the x coordinate with the length of the link text plus /* Increase the x coordinate with the length of the link text plus
the extra space behind it and the CTK button markers. */ the extra space behind it and the CTK button markers. */
len = len + 1 + 2 * border; textlen = textlen + 1 + 2 * border;
x += len; x += textlen;
if(firsty == pagey) { if(firsty == pagey) {
webpageptr += len; webpageptr += textlen;
} }
if(x == WWW_CONF_WEBPAGE_WIDTH) { if(x == WWW_CONF_WEBPAGE_WIDTH) {
htmlparser_newline(); htmlparser_newline();
} }
return dataptr;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
#if WWW_CONF_RENDERSTATE
static void
centerline(char *wptr)
{
unsigned char spaces, i;
char *cptr;
register struct ctk_widget *linksptr;
cptr = wptr + WWW_CONF_WEBPAGE_WIDTH;
for(spaces = 0; spaces < WWW_CONF_WEBPAGE_WIDTH; ++spaces) {
if(*--cptr != 0) {
break;
}
}
spaces /= 2;
while(cptr >= wptr) {
*(cptr + spaces) = *cptr;
--cptr;
}
memset(wptr, ' ', spaces);
linksptr = pagewidgets;
for(i = 0; i < pagewidgetptr; ++i) {
if(CTK_WIDGET_YPOS(linksptr) == y + 2) {
linksptr->x += spaces;
linksptr->widget.hyperlink.text += spaces;
}
++linksptr;
}
}
#endif /* WWW_CONF_RENDERSTATE */
/*-----------------------------------------------------------------------------------*/
void void
htmlparser_newline(void) htmlparser_newline(void)
{ {
@ -814,13 +812,7 @@ htmlparser_newline(void)
x = 0; x = 0;
wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH; wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH;
petsciiconv_topetscii(wptr, petsciiconv_topetscii(wptr, WWW_CONF_WEBPAGE_WIDTH);
WWW_CONF_WEBPAGE_WIDTH);
#if WWW_CONF_RENDERSTATE
if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
centerline(wptr);
}
#endif /* WWW_CONF_RENDERSTATE */
if(y == WWW_CONF_WEBPAGE_HEIGHT) { if(y == WWW_CONF_WEBPAGE_HEIGHT) {
loading = 0; loading = 0;
@ -831,7 +823,6 @@ htmlparser_newline(void)
void void
htmlparser_word(char *word, unsigned char wordlen) htmlparser_word(char *word, unsigned char wordlen)
{ {
if(loading) { if(loading) {
if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) { if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) {
htmlparser_newline(); htmlparser_newline();
@ -855,127 +846,93 @@ htmlparser_word(char *word, unsigned char wordlen)
void void
htmlparser_link(char *text, unsigned char textlen, char *url) htmlparser_link(char *text, unsigned char textlen, char *url)
{ {
static char *linkurlptr; add_pagewidget(text, textlen, url, CTK_WIDGET_HYPERLINK, 0);
linkurlptr = add_pagewidget(text, textlen, CTK_WIDGET_HYPERLINK, 0);
if(linkurlptr != NULL &&
strlen(url) < WWW_CONF_MAX_URLLEN) {
strcpy(linkurlptr, url);
} }
}
/*-----------------------------------------------------------------------------------*/
#if WWW_CONF_RENDERSTATE
void
htmlparser_renderstate(unsigned char s)
{
if((s & HTMLPARSER_RENDERSTATE_STATUSMASK) ==
HTMLPARSER_RENDERSTATE_BEGIN) {
renderstate |= s & ~HTMLPARSER_RENDERSTATE_STATUSMASK;
} else {
renderstate &= ~(s & ~HTMLPARSER_RENDERSTATE_STATUSMASK);
}
}
#endif /* WWW_CONF_RENDERSTATE */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
#if WWW_CONF_FORMS #if WWW_CONF_FORMS
void void
htmlparser_submitbutton(char *text, char *name, htmlparser_form(char *action)
char *formname, char *formaction)
{ {
register struct formattribs *form; formptr = (struct formattrib *)add_pageattrib(sizeof(struct formattrib) + strlen(action));
if(formptr != NULL) {
form = add_pagewidget(text, (unsigned char)strlen(text), CTK_WIDGET_BUTTON, 1); formptr->nextptr = NULL;
if(form != NULL) { currptr = (struct inputattrib *)formptr;
strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN); strcpy(formptr->action, action);
strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
form->inputtype = FORMINPUTTYPE_SUBMITBUTTON;
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
htmlparser_inputfield(unsigned char size, char *text, char *name, htmlparser_submitbutton(char *text, char *name)
char *formname, char *formaction)
{ {
register struct formattribs *form; add_pagewidget(text, (unsigned char)strlen(text), name, CTK_WIDGET_BUTTON, 1);
form = add_pagewidget(text, size, CTK_WIDGET_TEXTENTRY, 1);
if(form != NULL) {
strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN);
strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
form->inputtype = FORMINPUTTYPE_INPUTFIELD;
}
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void void
formsubmit(struct formattribs *attribs) htmlparser_inputfield(unsigned char size, char *text, char *name)
{ {
unsigned char i, j; add_pagewidget(text, size, name, CTK_WIDGET_TEXTENTRY, 1);
register char *urlptr, *valueptr; }
register struct formattribs *faptr; /*-----------------------------------------------------------------------------------*/
static void CC_FASTCALL
add_query(char delimiter, char *string)
{
static char *query;
unsigned char length;
urlptr = &tmpurl[0]; if(delimiter == ISO_questionmark) {
query = url + strlen(url);
strncpy(urlptr, attribs->formaction, WWW_CONF_MAX_URLLEN);
tmpurl[WWW_CONF_MAX_URLLEN] = 0;
urlptr += strlen(urlptr);
*urlptr = ISO_questionmark;
++urlptr;
/* Construct an URL by finding all input field forms with the same
formname as the current submit button, and add the submit button
URL stuff as well. */
for(i = 0; i < pagewidgetptr; ++i) {
if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
break;
} }
faptr = &pagewidgetattribs[i].form; length = strlen(string);
if(query - url + WWW_CONF_MAX_URLLEN - 1 /* delimiter */ < length) {
if(strcmp(attribs->formaction, faptr->formaction) == 0 && return;
strcmp(attribs->formname, faptr->formname) == 0 &&
(faptr->inputtype == FORMINPUTTYPE_INPUTFIELD ||
faptr == attribs)) {
/* Copy the name of the input field into the URL and append a
questionmark. */
strncpy(urlptr, faptr->inputname, WWW_CONF_MAX_URLLEN - strlen(tmpurl));
tmpurl[WWW_CONF_MAX_URLLEN] = 0;
urlptr += strlen(urlptr);
*urlptr = ISO_eq;
++urlptr;
/* Convert and copy the contents of the input field to the URL
and append an ampersand. */
valueptr = pagewidgets[i].widget.textentry.text;
petsciiconv_toascii(valueptr, WWW_CONF_MAX_INPUTVALUELEN);
for(j = 0; j < WWW_CONF_MAX_INPUTVALUELEN; ++j) {
if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
break;
}
*urlptr = *valueptr;
if(*urlptr == ISO_space) {
*urlptr = ISO_plus;
}
if(*urlptr == 0) {
break;
}
++urlptr;
++valueptr;
} }
*urlptr = ISO_ampersand; *query++ = delimiter;
++urlptr; strcpy(query, string);
if(delimiter == ISO_eq) {
char *space = query;
petsciiconv_toascii(query, length);
while((space = strchr(space, ISO_space)) != NULL) {
*space = ISO_plus;
} }
} }
--urlptr; query += length;
*urlptr = 0; }
/*-----------------------------------------------------------------------------------*/
static void CC_FASTCALL
formsubmit(struct formattrib *form)
{
struct inputattrib *inputptr;
char delimiter = ISO_questionmark;
set_link(form->action);
for(inputptr = form->nextptr; inputptr != NULL; inputptr = inputptr->nextptr) {
char *name;
char *value;
if(inputptr->widget.type == CTK_WIDGET_BUTTON) {
name = ((struct submitattrib *)inputptr)->name;
value = ((struct submitattrib *)inputptr)->button.text;
} else {
name = ((struct textattrib *)inputptr)->name;
value = ((struct textattrib *)inputptr)->textentry.text;
}
add_query(delimiter, name);
add_query(ISO_eq, value);
delimiter = ISO_ampersand;
}
#if WWW_CONF_HISTORY_SIZE > 0 #if WWW_CONF_HISTORY_SIZE > 0
log_back(); log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */ #endif /* WWW_CONF_HISTORY_SIZE > 0 */
open_link(tmpurl);
show_url();
open_url();
start_loading();
} }
#endif /* WWW_CONF_FORMS */ #endif /* WWW_CONF_FORMS */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View file

@ -41,31 +41,25 @@
#define WWW_CONF_WEBPAGE_HEIGHT 20 #define WWW_CONF_WEBPAGE_HEIGHT 20
#endif #endif
#ifndef WWW_CONF_HISTORY_SIZE #ifndef WWW_CONF_HISTORY_SIZE
#define WWW_CONF_HISTORY_SIZE 40 #define WWW_CONF_HISTORY_SIZE 10
#endif #endif
#ifndef WWW_CONF_MAX_URLLEN #ifndef WWW_CONF_MAX_URLLEN
#define WWW_CONF_MAX_URLLEN 200 #define WWW_CONF_MAX_URLLEN 300
#endif #endif
#ifndef WWW_CONF_MAX_NUMPAGEWIDGETS #ifndef WWW_CONF_PAGEATTRIB_SIZE
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20 #define WWW_CONF_PAGEATTRIB_SIZE 2000
#endif
#ifndef WWW_CONF_RENDERSTATE
#define WWW_CONF_RENDERSTATE 1
#endif #endif
#ifndef WWW_CONF_FORMS #ifndef WWW_CONF_FORMS
#define WWW_CONF_FORMS 1 #define WWW_CONF_FORMS 1
#endif #endif
#ifndef WWW_CONF_MAX_FORMACTIONLEN #ifndef WWW_CONF_MAX_FORMACTIONLEN
#define WWW_CONF_MAX_FORMACTIONLEN 200 #define WWW_CONF_MAX_FORMACTIONLEN 150
#endif
#ifndef WWW_CONF_MAX_FORMNAMELEN
#define WWW_CONF_MAX_FORMNAMELEN 200
#endif #endif
#ifndef WWW_CONF_MAX_INPUTNAMELEN #ifndef WWW_CONF_MAX_INPUTNAMELEN
#define WWW_CONF_MAX_INPUTNAMELEN 200 #define WWW_CONF_MAX_INPUTNAMELEN 50
#endif #endif
#ifndef WWW_CONF_MAX_INPUTVALUELEN #ifndef WWW_CONF_MAX_INPUTVALUELEN
#define WWW_CONF_MAX_INPUTVALUELEN 200 #define WWW_CONF_MAX_INPUTVALUELEN 100
#endif #endif
PROCESS_NAME(www_process); PROCESS_NAME(www_process);

View file

@ -60,10 +60,8 @@
#define WWW_CONF_HISTORY_SIZE 4 #define WWW_CONF_HISTORY_SIZE 4
#define WWW_CONF_MAX_URLLEN 78 #define WWW_CONF_MAX_URLLEN 78
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20 #define WWW_CONF_MAX_NUMPAGEWIDGETS 20
#define WWW_CONF_RENDERSTATE 1
#define WWW_CONF_FORMS 1 #define WWW_CONF_FORMS 1
#define WWW_CONF_MAX_FORMACTIONLEN 20 #define WWW_CONF_MAX_FORMACTIONLEN 20
#define WWW_CONF_MAX_FORMNAMELEN 20
#define WWW_CONF_MAX_INPUTNAMELEN 20 #define WWW_CONF_MAX_INPUTNAMELEN 20
#define WWW_CONF_MAX_INPUTVALUELEN 20 #define WWW_CONF_MAX_INPUTVALUELEN 20

View file

@ -62,11 +62,6 @@
#define WWW_CONF_HISTORY_SIZE 0 #define WWW_CONF_HISTORY_SIZE 0
#define WWW_CONF_MAX_URLLEN 80 #define WWW_CONF_MAX_URLLEN 80
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20 #define WWW_CONF_MAX_NUMPAGEWIDGETS 20
#define WWW_CONF_RENDERSTATE 0
#define WWW_CONF_FORMS 0 #define WWW_CONF_FORMS 0
#define WWW_CONF_MAX_FORMACTIONLEN 20
#define WWW_CONF_MAX_FORMNAMELEN 20
#define WWW_CONF_MAX_INPUTNAMELEN 20
#define WWW_CONF_MAX_INPUTVALUELEN 20
#endif /* __CONTIKI_CONF_H__ */ #endif /* __CONTIKI_CONF_H__ */

View file

@ -70,11 +70,6 @@
#define WWW_CONF_HISTORY_SIZE 0 #define WWW_CONF_HISTORY_SIZE 0
#define WWW_CONF_MAX_URLLEN 78 #define WWW_CONF_MAX_URLLEN 78
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20 #define WWW_CONF_MAX_NUMPAGEWIDGETS 20
#define WWW_CONF_RENDERSTATE 0
#define WWW_CONF_FORMS 0 #define WWW_CONF_FORMS 0
#define WWW_CONF_MAX_FORMACTIONLEN 20
#define WWW_CONF_MAX_FORMNAMELEN 20
#define WWW_CONF_MAX_INPUTNAMELEN 20
#define WWW_CONF_MAX_INPUTVALUELEN 20
#endif /* __CONTIKI_CONF_H__ */ #endif /* __CONTIKI_CONF_H__ */

View file

@ -70,10 +70,8 @@
#define WWW_CONF_HISTORY_SIZE 4 #define WWW_CONF_HISTORY_SIZE 4
#define WWW_CONF_MAX_URLLEN 80 #define WWW_CONF_MAX_URLLEN 80
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20 #define WWW_CONF_MAX_NUMPAGEWIDGETS 20
#define WWW_CONF_RENDERSTATE 1
#define WWW_CONF_FORMS 1 #define WWW_CONF_FORMS 1
#define WWW_CONF_MAX_FORMACTIONLEN 20 #define WWW_CONF_MAX_FORMACTIONLEN 20
#define WWW_CONF_MAX_FORMNAMELEN 20
#define WWW_CONF_MAX_INPUTNAMELEN 20 #define WWW_CONF_MAX_INPUTNAMELEN 20
#define WWW_CONF_MAX_INPUTVALUELEN 20 #define WWW_CONF_MAX_INPUTVALUELEN 20

View file

@ -175,15 +175,5 @@ typedef unsigned long clock_time_t;
#define WWW_CONF_WEBPAGE_WIDTH 76 #define WWW_CONF_WEBPAGE_WIDTH 76
#define WWW_CONF_WEBPAGE_HEIGHT 30 #define WWW_CONF_WEBPAGE_HEIGHT 30
#define WWW_CONF_HISTORY_SIZE 40
#define WWW_CONF_MAX_URLLEN 200
#define WWW_CONF_MAX_NUMPAGEWIDGETS 80
#define WWW_CONF_RENDERSTATE 1
#define WWW_CONF_FORMS 1
#define WWW_CONF_MAX_FORMACTIONLEN 200
#define WWW_CONF_MAX_FORMNAMELEN 200
#define WWW_CONF_MAX_INPUTNAMELEN 200
#define WWW_CONF_MAX_INPUTVALUELEN 240
#define WWW_CONF_PAGEVIEW 1
#endif /* __CONTIKI_CONF_H__ */ #endif /* __CONTIKI_CONF_H__ */