Merge branch 'master' of https://github.com/contiki-os/contiki
This commit is contained in:
commit
23e56e57b0
@ -1,7 +1,7 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
ifndef CONTIKI
|
||||
${error CONTIKI not defined! You must specify where CONTIKI resides}
|
||||
${error CONTIKI not defined! You must specify where Contiki resides}
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),)
|
||||
|
@ -1,5 +1,5 @@
|
||||
html_slasha "/a\0"
|
||||
html_slashcenter "/center\0"
|
||||
html_slashdiv "/div\0"
|
||||
html_slashform "/form\0"
|
||||
html_slashh "/h\0"
|
||||
html_slashscript "/script\0"
|
||||
@ -8,7 +8,6 @@ html_slashstyle "/style\0"
|
||||
html_a "a\0"
|
||||
html_body "body\0"
|
||||
html_br "br\0"
|
||||
html_center "center\0"
|
||||
html_form "form\0"
|
||||
html_frame "frame\0"
|
||||
html_h1 "h1\0"
|
||||
|
@ -1,9 +1,9 @@
|
||||
const char html_slasha[4] =
|
||||
/* "/a\0" */
|
||||
{0x2f, 0x61, 00, };
|
||||
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, };
|
||||
@ -28,9 +28,6 @@ const char html_body[6] =
|
||||
const char html_br[4] =
|
||||
/* "br\0" */
|
||||
{0x62, 0x72, 00, };
|
||||
const char html_center[8] =
|
||||
/* "center\0" */
|
||||
{0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
|
||||
const char html_form[6] =
|
||||
/* "form\0" */
|
||||
{0x66, 0x6f, 0x72, 0x6d, 00, };
|
||||
|
@ -1,5 +1,5 @@
|
||||
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];
|
||||
@ -8,7 +8,6 @@ extern const char html_slashstyle[8];
|
||||
extern const char html_a[3];
|
||||
extern const char html_body[6];
|
||||
extern const char html_br[4];
|
||||
extern const char html_center[8];
|
||||
extern const char html_form[6];
|
||||
extern const char html_frame[7];
|
||||
extern const char html_h1[4];
|
||||
|
@ -160,7 +160,6 @@ struct htmlparser_state {
|
||||
|
||||
#if WWW_CONF_FORMS
|
||||
char formaction[WWW_CONF_MAX_FORMACTIONLEN];
|
||||
char formname[WWW_CONF_MAX_FORMNAMELEN];
|
||||
unsigned char inputtype;
|
||||
char inputname[WWW_CONF_MAX_INPUTNAMELEN];
|
||||
char inputvalue[WWW_CONF_MAX_INPUTVALUELEN];
|
||||
@ -177,8 +176,8 @@ static const char *tags[] = {
|
||||
#define TAG_FIRST 0
|
||||
#define TAG_SLASHA 0
|
||||
html_slasha,
|
||||
#define TAG_SLASHCENTER 1
|
||||
html_slashcenter,
|
||||
#define TAG_SLASHDIV 1
|
||||
html_slashdiv,
|
||||
#define TAG_SLASHFORM 2
|
||||
html_slashform,
|
||||
#define TAG_SLASHH 3
|
||||
@ -195,37 +194,35 @@ static const char *tags[] = {
|
||||
html_body,
|
||||
#define TAG_BR 9
|
||||
html_br,
|
||||
#define TAG_CENTER 10
|
||||
html_center,
|
||||
#define TAG_FORM 11
|
||||
#define TAG_FORM 10
|
||||
html_form,
|
||||
#define TAG_FRAME 12
|
||||
#define TAG_FRAME 11
|
||||
html_frame,
|
||||
#define TAG_H1 13
|
||||
#define TAG_H1 12
|
||||
html_h1,
|
||||
#define TAG_H2 14
|
||||
#define TAG_H2 13
|
||||
html_h2,
|
||||
#define TAG_H3 15
|
||||
#define TAG_H3 14
|
||||
html_h3,
|
||||
#define TAG_H4 16
|
||||
#define TAG_H4 15
|
||||
html_h4,
|
||||
#define TAG_IMG 17
|
||||
#define TAG_IMG 16
|
||||
html_img,
|
||||
#define TAG_INPUT 18
|
||||
#define TAG_INPUT 17
|
||||
html_input,
|
||||
#define TAG_LI 19
|
||||
#define TAG_LI 18
|
||||
html_li,
|
||||
#define TAG_P 20
|
||||
#define TAG_P 19
|
||||
html_p,
|
||||
#define TAG_SCRIPT 21
|
||||
#define TAG_SCRIPT 20
|
||||
html_script,
|
||||
#define TAG_SELECT 22
|
||||
#define TAG_SELECT 21
|
||||
html_select,
|
||||
#define TAG_STYLE 23
|
||||
#define TAG_STYLE 22
|
||||
html_style,
|
||||
#define TAG_TR 24
|
||||
#define TAG_TR 23
|
||||
html_tr,
|
||||
#define TAG_LAST 25
|
||||
#define TAG_LAST 24
|
||||
last,
|
||||
};
|
||||
|
||||
@ -239,12 +236,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] = 0;
|
||||
#endif /* WWW_CONF_FORMS */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static char CC_FASTCALL
|
||||
@ -325,23 +335,20 @@ find_tag(char *tag)
|
||||
do {
|
||||
tagc = tag[i];
|
||||
|
||||
if(tagc == 0 &&
|
||||
tags[first][i] == 0) {
|
||||
if((tagc == 0 || tagc == ISO_slash) && tags[first][i] == 0) {
|
||||
return first;
|
||||
}
|
||||
|
||||
tabi = first;
|
||||
|
||||
/* First, find first matching tag from table. */
|
||||
while(tagc > (tags[tabi])[i] &&
|
||||
tabi < last) {
|
||||
while(tagc > (tags[tabi])[i] && tabi < last) {
|
||||
++tabi;
|
||||
}
|
||||
first = tabi;
|
||||
|
||||
/* Second, find last matching tag from table. */
|
||||
while(tagc == (tags[tabi])[i] &&
|
||||
tabi < last) {
|
||||
while(tagc == (tags[tabi])[i] && tabi < last) {
|
||||
++tabi;
|
||||
}
|
||||
last = tabi;
|
||||
@ -362,8 +369,7 @@ parse_tag(void)
|
||||
|
||||
static char dummy;
|
||||
|
||||
PRINTF(("Parsing tag '%s' '%s' '%s'\n",
|
||||
s.tag, s.tagattr, s.tagattrparam));
|
||||
PRINTF(("Parsing tag '%s' '%s' '%s'\n", s.tag, s.tagattr, s.tagattrparam));
|
||||
|
||||
switch(find_tag(s.tag)) {
|
||||
case TAG_P:
|
||||
@ -371,13 +377,12 @@ parse_tag(void)
|
||||
case TAG_H2:
|
||||
case TAG_H3:
|
||||
case TAG_H4:
|
||||
/* parse_char(ISO_nl);*/
|
||||
newline();
|
||||
/* FALLTHROUGH */
|
||||
case TAG_BR:
|
||||
case TAG_TR:
|
||||
case TAG_SLASHDIV:
|
||||
case TAG_SLASHH:
|
||||
/* parse_char(ISO_nl);*/
|
||||
dummy = 0;
|
||||
newline();
|
||||
break;
|
||||
@ -401,8 +406,7 @@ parse_tag(void)
|
||||
s.majorstate = s.lastmajorstate = MAJORSTATE_BODY;
|
||||
break;
|
||||
case TAG_FRAME:
|
||||
if(strncmp(s.tagattr, html_src, sizeof(html_src)) == 0 &&
|
||||
s.tagattrparam[0] != 0) {
|
||||
if(strncmp(s.tagattr, html_src, sizeof(html_src)) == 0 && s.tagattrparam[0] != 0) {
|
||||
switch_majorstate(MAJORSTATE_BODY);
|
||||
newline();
|
||||
add_char(ISO_rbrack);
|
||||
@ -414,25 +418,20 @@ parse_tag(void)
|
||||
}
|
||||
break;
|
||||
case TAG_IMG:
|
||||
if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 &&
|
||||
s.tagattrparam[0] != 0) {
|
||||
/* parse_char(ISO_lt);*/
|
||||
if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 && s.tagattrparam[0] != 0) {
|
||||
add_char(ISO_lt);
|
||||
tagattrparam = &s.tagattrparam[0];
|
||||
while(*tagattrparam) {
|
||||
/* parse_char(*tagattrparam);*/
|
||||
add_char(*tagattrparam);
|
||||
++tagattrparam;
|
||||
}
|
||||
/* parse_char(ISO_gt);*/
|
||||
add_char(ISO_gt);
|
||||
do_word();
|
||||
}
|
||||
break;
|
||||
case TAG_A:
|
||||
PRINTF(("A %s %s\n", s.tagattr, s.tagattrparam));
|
||||
if(strncmp(s.tagattr, html_href, sizeof(html_href)) == 0 &&
|
||||
s.tagattrparam[0] != 0) {
|
||||
if(strncmp(s.tagattr, html_href, sizeof(html_href)) == 0 && s.tagattrparam[0] != 0) {
|
||||
strcpy(s.linkurl, s.tagattrparam);
|
||||
do_word();
|
||||
switch_majorstate(MAJORSTATE_LINK);
|
||||
@ -448,72 +447,62 @@ parse_tag(void)
|
||||
break;
|
||||
#if WWW_CONF_FORMS
|
||||
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"));
|
||||
switch_majorstate(MAJORSTATE_FORM);
|
||||
if(strncmp(s.tagattr, html_action, sizeof(html_action)) == 0) {
|
||||
PRINTF(("Form action '%s'\n", s.tagattrparam));
|
||||
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);
|
||||
}
|
||||
s.inputname[0] = s.inputvalue[0] = 0;
|
||||
}
|
||||
break;
|
||||
case TAG_SLASHFORM:
|
||||
switch_majorstate(MAJORSTATE_BODY);
|
||||
s.formaction[0] = s.formname[0] = 0;
|
||||
s.formaction[0] = 0;
|
||||
break;
|
||||
case TAG_INPUT:
|
||||
if(s.majorstate == MAJORSTATE_FORM) {
|
||||
/* First check if we are called at the end of an input tag. If
|
||||
so, we should render the input widget. */
|
||||
if(s.tagattr[0] == 0 &&
|
||||
s.inputname[0] != 0) {
|
||||
if(s.tagattr[0] == 0 && s.inputname[0] != 0) {
|
||||
PRINTF(("Render input type %d\n", s.inputtype));
|
||||
switch(s.inputtype) {
|
||||
case HTMLPARSER_INPUTTYPE_NONE:
|
||||
case HTMLPARSER_INPUTTYPE_TEXT:
|
||||
s.inputvalue[s.inputvaluesize] = 0;
|
||||
htmlparser_inputfield(s.inputvaluesize, s.inputvalue, s.inputname,
|
||||
s.formname, s.formaction);
|
||||
htmlparser_inputfield(s.inputvaluesize, s.inputvalue, s.inputname);
|
||||
break;
|
||||
case HTMLPARSER_INPUTTYPE_SUBMIT:
|
||||
case HTMLPARSER_INPUTTYPE_IMAGE:
|
||||
htmlparser_submitbutton(s.inputvalue, s.inputname,
|
||||
s.formname, s.formaction);
|
||||
htmlparser_submitbutton(s.inputvalue, s.inputname);
|
||||
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) {
|
||||
if(strncmp(s.tagattrparam, html_submit,
|
||||
sizeof(html_submit)) == 0) {
|
||||
if(strncmp(s.tagattrparam, html_submit, sizeof(html_submit)) == 0) {
|
||||
s.inputtype = HTMLPARSER_INPUTTYPE_SUBMIT;
|
||||
} else if(strncmp(s.tagattrparam, html_image,
|
||||
sizeof(html_image)) == 0) {
|
||||
} else if(strncmp(s.tagattrparam, html_image, sizeof(html_image)) == 0) {
|
||||
s.inputtype = HTMLPARSER_INPUTTYPE_IMAGE;
|
||||
} else if(strncmp(s.tagattrparam, html_text,
|
||||
sizeof(html_text)) == 0) {
|
||||
} else if(strncmp(s.tagattrparam, html_text, sizeof(html_text)) == 0) {
|
||||
s.inputtype = HTMLPARSER_INPUTTYPE_TEXT;
|
||||
} else {
|
||||
s.inputtype = HTMLPARSER_INPUTTYPE_OTHER;
|
||||
}
|
||||
} else if(strncmp(s.tagattr, html_name,
|
||||
sizeof(html_name)) == 0) {
|
||||
strncpy(s.inputname, s.tagattrparam,
|
||||
WWW_CONF_MAX_INPUTNAMELEN);
|
||||
} else if(strncmp(s.tagattr, html_alt,
|
||||
sizeof(html_alt)) == 0 &&
|
||||
} else if(strncmp(s.tagattr, html_name, sizeof(html_name)) == 0) {
|
||||
strncpy(s.inputname, s.tagattrparam, WWW_CONF_MAX_INPUTNAMELEN);
|
||||
} else if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 &&
|
||||
s.inputtype == HTMLPARSER_INPUTTYPE_IMAGE) {
|
||||
strncpy(s.inputvalue, s.tagattrparam,
|
||||
WWW_CONF_MAX_INPUTVALUELEN);
|
||||
} else if(strncmp(s.tagattr, html_value,
|
||||
sizeof(html_value)) == 0) {
|
||||
strncpy(s.inputvalue, s.tagattrparam,
|
||||
WWW_CONF_MAX_INPUTVALUELEN);
|
||||
} 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_value, sizeof(html_value)) == 0) {
|
||||
strncpy(s.inputvalue, s.tagattrparam, WWW_CONF_MAX_INPUTVALUELEN);
|
||||
} else if(strncmp(s.tagattr, html_size, sizeof(html_size)) == 0) {
|
||||
size = 0;
|
||||
if(s.tagattrparam[0] >= '0' &&
|
||||
s.tagattrparam[0] <= '9') {
|
||||
@ -527,32 +516,15 @@ parse_tag(void)
|
||||
size = WWW_CONF_MAX_INPUTVALUELEN - 1;
|
||||
}
|
||||
s.inputvaluesize = size;
|
||||
/* strncpy(s.inputvalue, s.tagattrparam,
|
||||
WWW_CONF_MAX_INPUTVALUELEN);*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
#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)
|
||||
{
|
||||
static uint8_t i;
|
||||
@ -570,7 +542,6 @@ parse_word(char *data, uint8_t dlen)
|
||||
} else if(c == ISO_lt) {
|
||||
s.minorstate = MINORSTATE_TAG;
|
||||
s.tagptr = 0;
|
||||
/* do_word();*/
|
||||
break;
|
||||
} else if(c == ISO_ampersand) {
|
||||
s.minorstate = MINORSTATE_EXTCHAR;
|
||||
@ -619,7 +590,6 @@ parse_word(char *data, uint8_t dlen)
|
||||
} else {
|
||||
/* Keep track of the name of the tag, but convert it to
|
||||
lower case. */
|
||||
|
||||
s.tag[s.tagptr] = lowercase(c);
|
||||
++s.tagptr;
|
||||
/* Check if the ->tag field is full. If so, we just eat up
|
||||
@ -668,8 +638,6 @@ parse_word(char *data, uint8_t dlen)
|
||||
parse_tag();
|
||||
s.minorstate = MINORSTATE_TAGATTRSPACE;
|
||||
break;
|
||||
/* s.tagattrptr = 0;
|
||||
endtagfound();*/
|
||||
}
|
||||
} else if(c == ISO_eq) {
|
||||
s.minorstate = MINORSTATE_TAGATTRPARAMNQ;
|
||||
@ -723,19 +691,16 @@ parse_word(char *data, uint8_t dlen)
|
||||
s.tagptr = 0;
|
||||
endtagfound();
|
||||
break;
|
||||
} else if(iswhitespace(c) &&
|
||||
s.tagattrparamptr == 0) {
|
||||
} else if(iswhitespace(c) && s.tagattrparamptr == 0) {
|
||||
/* Discard leading spaces. */
|
||||
} else if((c == ISO_citation ||
|
||||
c == ISO_citation2) &&
|
||||
s.tagattrparamptr == 0) {
|
||||
c == ISO_citation2) && s.tagattrparamptr == 0) {
|
||||
s.minorstate = MINORSTATE_TAGATTRPARAM;
|
||||
s.quotechar = c;
|
||||
PRINTF(("tag attr param q found\n"));
|
||||
break;
|
||||
} else if(iswhitespace(c)) {
|
||||
PRINTF(("Non-leading space found at %d\n",
|
||||
s.tagattrparamptr));
|
||||
PRINTF(("Non-leading space found at %d\n", s.tagattrparamptr));
|
||||
/* Stop parsing if a non-leading space was found */
|
||||
endtagfound();
|
||||
parse_tag();
|
||||
|
@ -38,29 +38,15 @@
|
||||
|
||||
/* Callbacks. */
|
||||
void htmlparser_link(char *text, unsigned char textlen, char *url);
|
||||
void htmlparser_form(char *action);
|
||||
void htmlparser_submitbutton(char *value,
|
||||
char *name,
|
||||
char *formname,
|
||||
char *formaction);
|
||||
char *name);
|
||||
void htmlparser_inputfield(unsigned char size,
|
||||
char *value,
|
||||
char *name,
|
||||
char *formname,
|
||||
char *formaction);
|
||||
char *name);
|
||||
void htmlparser_newline(void);
|
||||
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_TEXT 1
|
||||
|
@ -6,29 +6,7 @@ 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"
|
||||
http_referer "Referer:"
|
||||
http_header_200 "HTTP/1.0 200 OK\r\nServer: Contiki/2.6 http://www.contiki-os.org/\r\nConnection: close\r\n"
|
||||
http_header_404 "HTTP/1.0 404 Not found\r\nServer: Contiki/2.6 http://www.contiki-os.org/\r\nConnection: close\r\n"
|
||||
http_content_type_plain "Content-type: text/plain\r\n\r\n"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_html ".html"
|
||||
http_htm ".htm"
|
||||
http_css ".css"
|
||||
http_png ".png"
|
||||
http_gif ".gif"
|
||||
http_jpg ".jpg"
|
||||
http_text ".text"
|
||||
http_txt ".txt"
|
||||
|
||||
|
@ -22,78 +22,15 @@ 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, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[85] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: Contiki/2.6 http://www.contiki-os.org/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x36, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[92] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: Contiki/2.6 http://www.contiki-os.org/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x36, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[6] =
|
||||
/* ".text" */
|
||||
{0x2e, 0x74, 0x65, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
|
@ -6,28 +6,7 @@ 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];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
extern const char http_header_200[85];
|
||||
extern const char http_header_404[92];
|
||||
extern const char http_content_type_plain[29];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[6];
|
||||
extern const char http_txt[5];
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ctk/ctk.h"
|
||||
#include "lib/ctk-textentry-cmdline.h"
|
||||
@ -59,13 +60,11 @@
|
||||
|
||||
/* The array that holds the current URL. */
|
||||
static char url[WWW_CONF_MAX_URLLEN + 1];
|
||||
static char tmpurl[WWW_CONF_MAX_URLLEN + 1];
|
||||
|
||||
/* The array that holds the web page text. */
|
||||
static char webpage[WWW_CONF_WEBPAGE_WIDTH *
|
||||
WWW_CONF_WEBPAGE_HEIGHT + 1];
|
||||
|
||||
|
||||
/* The CTK widgets for the main window. */
|
||||
static struct ctk_window mainwindow;
|
||||
|
||||
@ -120,31 +119,45 @@ static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
|
||||
static char history_last;
|
||||
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
|
||||
|
||||
/* The CTK widget definitions for the hyperlinks and the char arrays
|
||||
that hold the link URLs. */
|
||||
struct formattribs {
|
||||
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;
|
||||
struct linkattrib {
|
||||
struct ctk_hyperlink hyperlink;
|
||||
char url[1];
|
||||
};
|
||||
|
||||
union pagewidgetattrib {
|
||||
char url[WWW_CONF_MAX_URLLEN];
|
||||
struct inputattrib;
|
||||
|
||||
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
|
||||
struct formattribs form;
|
||||
static struct formattrib *formptr;
|
||||
static struct inputattrib *currptr;
|
||||
#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_space 0x20
|
||||
@ -172,7 +185,7 @@ PROCESS(www_process, "Web browser");
|
||||
|
||||
AUTOSTART_PROCESSES(&www_process);
|
||||
|
||||
static void formsubmit(struct formattribs *attribs);
|
||||
static void CC_FASTCALL formsubmit(struct formattrib *form);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* make_window()
|
||||
@ -195,7 +208,7 @@ make_window(void)
|
||||
CTK_WIDGET_ADD(&mainwindow, &sep2);
|
||||
CTK_WIDGET_ADD(&mainwindow, &statustext);
|
||||
|
||||
pagewidgetptr = 0;
|
||||
pageattribptr = pageattribs;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* redraw_window():
|
||||
@ -208,6 +221,29 @@ redraw_window(void)
|
||||
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
|
||||
clear_page(void)
|
||||
{
|
||||
@ -237,7 +273,7 @@ start_loading(void)
|
||||
clear_page();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
static void CC_FASTCALL
|
||||
show_statustext(char *text)
|
||||
{
|
||||
ctk_label_set_text(&statustext, text);
|
||||
@ -325,22 +361,22 @@ 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...");
|
||||
}
|
||||
redraw_window();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* open_link(link):
|
||||
/* set_link(link):
|
||||
*
|
||||
* 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
|
||||
open_link(char *link)
|
||||
static void CC_FASTCALL
|
||||
set_link(char *link)
|
||||
{
|
||||
char *urlptr;
|
||||
register char *urlptr;
|
||||
|
||||
if(strncmp(link, http_http, 7) == 0) {
|
||||
/* The link starts with http://. We just copy the contents of the
|
||||
@ -373,12 +409,6 @@ open_link(char *link)
|
||||
++urlptr;
|
||||
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
|
||||
}
|
||||
|
||||
/* Open the URL. */
|
||||
show_url();
|
||||
open_url();
|
||||
|
||||
start_loading();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if WWW_CONF_HISTORY_SIZE > 0
|
||||
@ -497,18 +527,10 @@ PROCESS_THREAD(www_process, ev, data)
|
||||
#endif /* WWW_CONF_WITH_WGET */
|
||||
#if WWW_CONF_FORMS
|
||||
} else {
|
||||
/* Check form buttons */
|
||||
for(i = 0; i < pagewidgetptr; ++i) {
|
||||
if(&pagewidgets[i] == w) {
|
||||
formsubmit(&pagewidgetattribs[i].form);
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
/* Assume form widget. */
|
||||
struct inputattrib *input = (struct inputattrib *)
|
||||
(((char *)w) - offsetof(struct inputattrib, widget));
|
||||
formsubmit(input->formptr);
|
||||
#endif /* WWW_CONF_FORMS */
|
||||
}
|
||||
} else if(ev == ctk_signal_hyperlink_activate) {
|
||||
@ -516,12 +538,13 @@ PROCESS_THREAD(www_process, ev, data)
|
||||
#if WWW_CONF_HISTORY_SIZE > 0
|
||||
log_back();
|
||||
#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_window_open(&mainwindow);*/
|
||||
} else if(ev == ctk_signal_hyperlink_hover) {
|
||||
if(CTK_WIDGET_TYPE((struct ctk_widget *)data) ==
|
||||
CTK_WIDGET_HYPERLINK) {
|
||||
if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) {
|
||||
strncpy(statustexturl, w->widget.hyperlink.url,
|
||||
sizeof(statustexturl));
|
||||
petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
|
||||
@ -530,11 +553,10 @@ PROCESS_THREAD(www_process, ev, data)
|
||||
#if UIP_UDP
|
||||
} else if(ev == resolv_event_found) {
|
||||
/* Either found a hostname, or not. */
|
||||
if((char *)data != NULL &&
|
||||
resolv_lookup((char *)data) != NULL) {
|
||||
if((char *)data != NULL && 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 ||
|
||||
@ -551,7 +573,7 @@ PROCESS_THREAD(www_process, ev, data)
|
||||
* "url" variable and the visible "editurl" (which is shown in the URL
|
||||
* text entry widget in the browser window).
|
||||
*/
|
||||
static void
|
||||
static void CC_FASTCALL
|
||||
set_url(char *host, uint16_t port, char *file)
|
||||
{
|
||||
char *urlptr;
|
||||
@ -602,7 +624,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();
|
||||
@ -623,9 +645,6 @@ webclient_connected(void)
|
||||
show_statustext("Request sent...");
|
||||
set_url(webclient_hostname(), webclient_port(), webclient_filename());
|
||||
|
||||
#if WWW_CONF_RENDERSTATE
|
||||
renderstate = HTMLPARSER_RENDERSTATE_NONE;
|
||||
#endif /* WWW_CONF_RENDERSTATE */
|
||||
htmlparser_init();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -638,12 +657,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,28 +676,26 @@ 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();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void *
|
||||
add_pagewidget(char *text, unsigned char len, unsigned char type,
|
||||
static void CC_FASTCALL
|
||||
add_pagewidget(char *text, unsigned char textlen, char *attrib, unsigned char type,
|
||||
unsigned char border)
|
||||
{
|
||||
register struct ctk_widget *lptr;
|
||||
register char *wptr;
|
||||
char *wptr;
|
||||
static unsigned char maxwidth;
|
||||
static void *dataptr;
|
||||
|
||||
if(!loading) {
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if(len + border == 0) {
|
||||
return NULL;
|
||||
if(textlen + border == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border);
|
||||
@ -685,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
|
||||
the width of the current window, counting from the current x
|
||||
coordinate, we first try to jump to the next line. */
|
||||
if(len + x > maxwidth) {
|
||||
if(textlen + x > maxwidth) {
|
||||
htmlparser_newline();
|
||||
if(!loading) {
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,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
|
||||
either make a link into a multiline link, or add multiple
|
||||
buttons. But this will do for now. */
|
||||
if(len > maxwidth) {
|
||||
if(textlen > maxwidth) {
|
||||
text[maxwidth] = 0;
|
||||
len = maxwidth;
|
||||
textlen = maxwidth;
|
||||
}
|
||||
|
||||
dataptr = NULL;
|
||||
|
||||
if(firsty == pagey) {
|
||||
unsigned char attriblen = strlen(attrib);
|
||||
|
||||
wptr = webpageptr;
|
||||
/* To save memory, we'll copy the widget text to the web page
|
||||
drawing area and reference it from there. */
|
||||
wptr[0] = 0;
|
||||
wptr += border;
|
||||
memcpy(wptr, text, len);
|
||||
wptr[len] = 0;
|
||||
wptr[len + border] = ' ';
|
||||
if(pagewidgetptr < WWW_CONF_MAX_NUMPAGEWIDGETS) {
|
||||
dataptr = &pagewidgetattribs[pagewidgetptr];
|
||||
lptr = &pagewidgets[pagewidgetptr];
|
||||
memcpy(wptr, text, textlen);
|
||||
wptr[textlen] = 0;
|
||||
wptr[textlen + border] = ' ';
|
||||
|
||||
switch(type) {
|
||||
case CTK_WIDGET_HYPERLINK:
|
||||
CTK_HYPERLINK_NEW((struct ctk_hyperlink *)lptr, x,
|
||||
y + 3, len,
|
||||
wptr, dataptr);
|
||||
break;
|
||||
case CTK_WIDGET_BUTTON:
|
||||
CTK_BUTTON_NEW((struct ctk_button *)lptr, x,
|
||||
y + 3, len,
|
||||
wptr);
|
||||
((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;
|
||||
case CTK_WIDGET_HYPERLINK: {
|
||||
struct linkattrib *linkptr;
|
||||
|
||||
linkptr = (struct linkattrib *)add_pageattrib(sizeof(struct linkattrib) /* incl 1 attrib char */ + attriblen);
|
||||
if(linkptr != NULL) {
|
||||
CTK_HYPERLINK_NEW(&linkptr->hyperlink, x, y + 3, textlen, wptr, linkptr->url);
|
||||
strcpy(linkptr->url, attrib);
|
||||
CTK_WIDGET_SET_FLAG(&linkptr->hyperlink, CTK_WIDGET_FLAG_MONOSPACE);
|
||||
CTK_WIDGET_ADD(&mainwindow, &linkptr->hyperlink);
|
||||
}
|
||||
break;
|
||||
}
|
||||
CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE);
|
||||
CTK_WIDGET_ADD(&mainwindow, lptr);
|
||||
#if WWW_CONF_FORMS
|
||||
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
|
||||
the extra space behind it and the CTK button markers. */
|
||||
len = len + 1 + 2 * border;
|
||||
x += len;
|
||||
textlen = textlen + 1 + 2 * border;
|
||||
x += textlen;
|
||||
|
||||
if(firsty == pagey) {
|
||||
webpageptr += len;
|
||||
webpageptr += textlen;
|
||||
}
|
||||
|
||||
if(x == WWW_CONF_WEBPAGE_WIDTH) {
|
||||
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
|
||||
htmlparser_newline(void)
|
||||
{
|
||||
@ -813,13 +812,7 @@ htmlparser_newline(void)
|
||||
x = 0;
|
||||
|
||||
wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH;
|
||||
petsciiconv_topetscii(wptr,
|
||||
WWW_CONF_WEBPAGE_WIDTH);
|
||||
#if WWW_CONF_RENDERSTATE
|
||||
if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
|
||||
centerline(wptr);
|
||||
}
|
||||
#endif /* WWW_CONF_RENDERSTATE */
|
||||
petsciiconv_topetscii(wptr, WWW_CONF_WEBPAGE_WIDTH);
|
||||
|
||||
if(y == WWW_CONF_WEBPAGE_HEIGHT) {
|
||||
loading = 0;
|
||||
@ -830,7 +823,6 @@ htmlparser_newline(void)
|
||||
void
|
||||
htmlparser_word(char *word, unsigned char wordlen)
|
||||
{
|
||||
|
||||
if(loading) {
|
||||
if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) {
|
||||
htmlparser_newline();
|
||||
@ -854,127 +846,93 @@ htmlparser_word(char *word, unsigned char wordlen)
|
||||
void
|
||||
htmlparser_link(char *text, unsigned char textlen, char *url)
|
||||
{
|
||||
static char *linkurlptr;
|
||||
|
||||
linkurlptr = add_pagewidget(text, textlen, CTK_WIDGET_HYPERLINK, 0);
|
||||
if(linkurlptr != NULL &&
|
||||
strlen(url) < WWW_CONF_MAX_URLLEN) {
|
||||
strcpy(linkurlptr, url);
|
||||
add_pagewidget(text, textlen, url, CTK_WIDGET_HYPERLINK, 0);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#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
|
||||
void
|
||||
htmlparser_submitbutton(char *text, char *name,
|
||||
char *formname, char *formaction)
|
||||
htmlparser_form(char *action)
|
||||
{
|
||||
register struct formattribs *form;
|
||||
|
||||
form = add_pagewidget(text, (unsigned char)strlen(text), CTK_WIDGET_BUTTON, 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_SUBMITBUTTON;
|
||||
formptr = (struct formattrib *)add_pageattrib(sizeof(struct formattrib) + strlen(action));
|
||||
if(formptr != NULL) {
|
||||
formptr->nextptr = NULL;
|
||||
currptr = (struct inputattrib *)formptr;
|
||||
strcpy(formptr->action, action);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
htmlparser_inputfield(unsigned char size, char *text, char *name,
|
||||
char *formname, char *formaction)
|
||||
htmlparser_submitbutton(char *text, char *name)
|
||||
{
|
||||
register struct formattribs *form;
|
||||
|
||||
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;
|
||||
}
|
||||
add_pagewidget(text, (unsigned char)strlen(text), name, CTK_WIDGET_BUTTON, 1);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
formsubmit(struct formattribs *attribs)
|
||||
void
|
||||
htmlparser_inputfield(unsigned char size, char *text, char *name)
|
||||
{
|
||||
unsigned char i, j;
|
||||
register char *urlptr, *valueptr;
|
||||
register struct formattribs *faptr;
|
||||
add_pagewidget(text, size, name, CTK_WIDGET_TEXTENTRY, 1);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void CC_FASTCALL
|
||||
add_query(char delimiter, char *string)
|
||||
{
|
||||
static char *query;
|
||||
unsigned char length;
|
||||
|
||||
urlptr = &tmpurl[0];
|
||||
|
||||
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;
|
||||
if(delimiter == ISO_questionmark) {
|
||||
query = url + strlen(url);
|
||||
}
|
||||
|
||||
faptr = &pagewidgetattribs[i].form;
|
||||
|
||||
if(strcmp(attribs->formaction, faptr->formaction) == 0 &&
|
||||
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;
|
||||
length = strlen(string);
|
||||
if(query - url + WWW_CONF_MAX_URLLEN - 1 /* delimiter */ < length) {
|
||||
return;
|
||||
}
|
||||
|
||||
*urlptr = ISO_ampersand;
|
||||
++urlptr;
|
||||
*query++ = delimiter;
|
||||
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;
|
||||
*urlptr = 0;
|
||||
query += length;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
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
|
||||
log_back();
|
||||
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
|
||||
open_link(tmpurl);
|
||||
|
||||
show_url();
|
||||
open_url();
|
||||
start_loading();
|
||||
}
|
||||
#endif /* WWW_CONF_FORMS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -41,31 +41,25 @@
|
||||
#define WWW_CONF_WEBPAGE_HEIGHT 20
|
||||
#endif
|
||||
#ifndef WWW_CONF_HISTORY_SIZE
|
||||
#define WWW_CONF_HISTORY_SIZE 40
|
||||
#define WWW_CONF_HISTORY_SIZE 10
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_URLLEN
|
||||
#define WWW_CONF_MAX_URLLEN 200
|
||||
#define WWW_CONF_MAX_URLLEN 300
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_NUMPAGEWIDGETS
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
|
||||
#endif
|
||||
#ifndef WWW_CONF_RENDERSTATE
|
||||
#define WWW_CONF_RENDERSTATE 1
|
||||
#ifndef WWW_CONF_PAGEATTRIB_SIZE
|
||||
#define WWW_CONF_PAGEATTRIB_SIZE 2000
|
||||
#endif
|
||||
#ifndef WWW_CONF_FORMS
|
||||
#define WWW_CONF_FORMS 1
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_FORMACTIONLEN
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 200
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_FORMNAMELEN
|
||||
#define WWW_CONF_MAX_FORMNAMELEN 200
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 150
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_INPUTNAMELEN
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 200
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 50
|
||||
#endif
|
||||
#ifndef WWW_CONF_MAX_INPUTVALUELEN
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 200
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 100
|
||||
#endif
|
||||
|
||||
PROCESS_NAME(www_process);
|
||||
|
@ -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"
|
||||
|
@ -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, };
|
||||
|
@ -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];
|
||||
|
@ -66,11 +66,11 @@ cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
return -1;
|
||||
}
|
||||
strncpy(e->name, res->d_name, sizeof(e->name));
|
||||
#if defined(__APPLE2__) || defined(__APPLE2ENH__)
|
||||
#if defined(__APPLE2__) || defined(__APPLE2ENH__) || defined(__CBM__)
|
||||
e->size = res->d_blocks;
|
||||
#else /* __APPLE2__ || __APPLE2ENH__ */
|
||||
#else /* __APPLE2__ || __APPLE2ENH__ || __CBM__ */
|
||||
e->size = 0;
|
||||
#endif /* __APPLE2__ || __APPLE2ENH__ */
|
||||
#endif /* __APPLE2__ || __APPLE2ENH__ || __CBM__ */
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -124,16 +124,6 @@ buf_bufto(CC_REGISTER_ARG struct psock_buf *buf, uint8_t endmarker,
|
||||
return BUF_NOT_FOUND;
|
||||
}
|
||||
|
||||
while(*datalen > 0) {
|
||||
c = **dataptr;
|
||||
--*datalen;
|
||||
++*dataptr;
|
||||
|
||||
if(c == endmarker) {
|
||||
return BUF_FOUND | BUF_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
return BUF_FULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -274,9 +264,9 @@ PT_THREAD(psock_readto(CC_REGISTER_ARG struct psock *psock, unsigned char c))
|
||||
psock->readptr = (uint8_t *)uip_appdata;
|
||||
psock->readlen = uip_datalen();
|
||||
}
|
||||
} while((buf_bufto(&psock->buf, c,
|
||||
} while(buf_bufto(&psock->buf, c,
|
||||
&psock->readptr,
|
||||
&psock->readlen) & BUF_FOUND) == 0);
|
||||
&psock->readlen) == BUF_NOT_FOUND);
|
||||
|
||||
if(psock_datalen(psock) == 0) {
|
||||
psock->state = STATE_NONE;
|
||||
|
@ -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. */
|
||||
|
@ -39,7 +39,7 @@ endif
|
||||
|
||||
all: cs8900a.eth lan91c96.eth
|
||||
|
||||
CONTIKI_TARGET_DIRS = . lib sys cfs
|
||||
CONTIKI_TARGET_DIRS = . lib sys
|
||||
CONTIKI_CPU_DIRS = . lib sys ctk net
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-main.c
|
||||
@ -47,11 +47,9 @@ CONTIKI_CPU_SOURCEFILES += log.c error.c unload.c config.c ctk-mouse.c \
|
||||
clock.c mtarch.c mtarch-asm.S lc-asm.S \
|
||||
uip_arch.c ethernet-drv.c ethernet.c
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CTK) ctk-conio.c petsciiconv.c \
|
||||
CONTIKI_SOURCEFILES += $(CTK) ctk-conio.c petsciiconv.c cfs-posix-dir.c \
|
||||
$(CONTIKI_TARGET_SOURCEFILES) $(CONTIKI_CPU_SOURCEFILES)
|
||||
|
||||
TARGET_LIBFILES = $(TARGET).lib
|
||||
|
||||
ifdef ETHERNET
|
||||
CONTIKI_SOURCEFILES += $(ETHERNET)-eth.S
|
||||
CFLAGS += -DETHERNET=$(ETHERNET)
|
||||
@ -60,7 +58,7 @@ endif
|
||||
### Compiler definitions
|
||||
|
||||
AS = ca65
|
||||
CC = cc65
|
||||
CC = cl65
|
||||
LD = ld65
|
||||
AR = ar65
|
||||
|
||||
@ -69,35 +67,29 @@ AR = ar65
|
||||
|
||||
ASFLAGS = -t $(TARGET)
|
||||
CFLAGS += -t $(TARGET) -Or
|
||||
LDFLAGS = -D __STACKSIZE__=0x200 -u _main -m contiki-$(TARGET).map
|
||||
LDFLAGS = $(STARTADDR_FLAG) -t $(TARGET) -m contiki-$(TARGET).map -D __STACKSIZE__=0x200
|
||||
AROPTS = a
|
||||
|
||||
### Compilation rules
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
CMD.EXE := $(shell echo)
|
||||
|
||||
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
||||
$(OBJECTDIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) --create-dep $< -o $(@:.o=.s)
|
||||
@$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
|
||||
@sed -e "s!.s:!.o:!" -e "s!\t! !" < $(@:.o=.u) > $(@:.o=.d)
|
||||
@rm -f $(@:.o=.s) $(@:.o=.u)
|
||||
ifndef CMD.EXE
|
||||
@$(FINALIZE_DEPENDENCY)
|
||||
endif
|
||||
$(CC) -c -o $@ $(CFLAGS) --create-dep $(@:.o=.d) $<
|
||||
|
||||
CUSTOM_RULE_C_TO_CO = 1
|
||||
%.co: %.c
|
||||
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $(@:.co=.s)
|
||||
@$(AS) $(ASFLAGS) $(@:.co=.s) -o $@
|
||||
@rm -f $(@:.co=.s)
|
||||
$(CC) -c -o $@ $(CFLAGS) -DAUTOSTART_ENABLE --create-dep $(@:.o=.d) $<
|
||||
|
||||
CUSTOM_RULE_LINK = 1
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
$(LD) -o $@ $(LDFLAGS) -u _main $^ $(TARGET).lib
|
||||
|
||||
%.eth: $(OBJECTDIR)/%.o
|
||||
$(LD) -t module -m $@.map $< -o $@
|
||||
$(LD) -o $@ -t module -m $@.map $<
|
||||
|
||||
ifdef ETHERNET
|
||||
$(ETHERNET)-eth.S: $(ETHERNET).eth
|
||||
co65 --code-label _$(ETHERNET) -o $@ $<
|
||||
co65 -o $@ --code-label _$(ETHERNET) $<
|
||||
endif
|
||||
|
@ -106,6 +106,15 @@ endif
|
||||
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
|
||||
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
|
||||
|
||||
SMALL ?= 1
|
||||
|
||||
### These flags help significantly reduce the code size
|
||||
ifeq ($(SMALL),1)
|
||||
CFLAGS += -ffunction-sections
|
||||
CFLAGS += -fdata-sections
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
endif # SMALL
|
||||
|
||||
### Setup directory search path for source files
|
||||
|
||||
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
||||
|
@ -292,7 +292,7 @@
|
||||
#else
|
||||
#define RADIO_VECT TIMER1_CAPT_vect
|
||||
// Raven and Jackdaw
|
||||
#define HAL_ENABLE_RADIO_INTERRUPT( ) ( TIMSK1 |= ( 1 << ICIE1 ) )
|
||||
#define HAL_ENABLE_RADIO_INTERRUPT( ) { TCCR1B = ( 1 << ICES1 ) | ( 1 << CS10 ); TIFR1 |= (1 << ICF1); TIMSK1 |= ( 1 << ICIE1 ) ; }
|
||||
#define HAL_DISABLE_RADIO_INTERRUPT( ) ( TIMSK1 &= ~( 1 << ICIE1 ) )
|
||||
#endif
|
||||
|
||||
|
@ -114,7 +114,7 @@ uart0_init(unsigned long ubr)
|
||||
UCA0CTL1 |= UCSWRST; /* Hold peripheral in reset state */
|
||||
UCA0CTL1 |= UCSSEL_2; /* CLK = SMCLK */
|
||||
|
||||
UCA0BR0 = 0x45; /* 8MHz/115200 = 69 = 0x45 */
|
||||
UCA0BR0 = ubr; /* 8MHz/115200 = 69 = 0x45 */
|
||||
UCA0BR1 = 0x00;
|
||||
UCA0MCTL = UCBRS_3; /* Modulation UCBRSx = 3 */
|
||||
|
||||
|
@ -1 +1 @@
|
||||
DEFINES = WITH_CLIENT,WITH_DNS,WITH_GUI,WITH_PFS
|
||||
DEFINES = WITH_CLIENT,WITH_DNS,WITH_GUI
|
||||
|
@ -1 +1 @@
|
||||
DEFINES = WITH_CLIENT,WITH_DNS,WITH_GUI,MTU_SIZE=900
|
||||
DEFINES = WITH_CLIENT,WITH_DNS,WITH_GUI,MTU_SIZE=1000
|
||||
|
@ -1 +1 @@
|
||||
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS
|
||||
DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS
|
||||
|
@ -142,6 +142,8 @@ app_quit(void)
|
||||
if(file != -1) {
|
||||
cfs_close(file);
|
||||
}
|
||||
puts("Press any key to continue...");
|
||||
getchar();
|
||||
process_exit(&wget_process);
|
||||
LOADER_UNLOAD();
|
||||
}
|
||||
|
@ -33,22 +33,21 @@
|
||||
# $Id: Makefile.apple2enh,v 1.19 2010/10/23 08:17:45 oliverschmidt Exp $
|
||||
#
|
||||
|
||||
CONTIKI_SOURCEFILES += cfs-posix-dir.c
|
||||
CONTIKI_TARGET_SOURCEFILES += pfs.S
|
||||
|
||||
CONTIKI_CPU = $(CONTIKI)/cpu/6502
|
||||
include $(CONTIKI_CPU)/Makefile.6502
|
||||
|
||||
LDFLAGS += -D __HIMEM__=0xBF00
|
||||
LC_SOURCEFILES = process.c tcpip.c
|
||||
|
||||
ifeq ($(findstring WITH_REBOOT,$(DEFINES)),WITH_REBOOT)
|
||||
HIGHCODE_SOURCEFILES = process.c etimer.c uip_arp.c
|
||||
LDFLAGS += -C apple2enh-reboot.cfg
|
||||
else
|
||||
HIGHCODE_SOURCEFILES = process.c etimer.c ethernet.c
|
||||
LDFLAGS += -C apple2enh-loader.cfg
|
||||
LDFLAGS += -D __LCADDR__=0xD000 -D __LCSIZE__=0x1000
|
||||
LC_SOURCEFILES += etimer.c
|
||||
endif
|
||||
|
||||
# Set a target-specific variable value
|
||||
${addprefix $(OBJECTDIR)/,${call oname, $(HIGHCODE_SOURCEFILES)}}: CFLAGS += --code-name HIGHCODE
|
||||
${addprefix $(OBJECTDIR)/,${call oname, $(LC_SOURCEFILES)}}: CFLAGS += --code-name LC
|
||||
|
||||
ifeq ($(MAKECMDGOALS),disk)
|
||||
ifndef AC
|
||||
@ -58,7 +57,7 @@ endif
|
||||
|
||||
disk: all
|
||||
cp $(CONTIKI)/tools/$(TARGET)/prodos.dsk contiki.dsk
|
||||
java -jar $(AC) -p contiki.dsk contiki.system sys 0 < $(CONTIKI)/tools/$(TARGET)/loader.system
|
||||
java -jar $(AC) -p contiki.dsk contiki.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 contiki.dsk contiki bin < $(CONTIKI_PROJECT).$(TARGET)
|
||||
java -jar $(AC) -p contiki.dsk contiki.cfg bin 0 < $(CONTIKI)/tools/$(TARGET)/sample.cfg
|
||||
java -jar $(AC) -p contiki.dsk cs8900a.eth rel 0 < cs8900a.eth
|
||||
|
@ -60,10 +60,8 @@
|
||||
#define WWW_CONF_HISTORY_SIZE 4
|
||||
#define WWW_CONF_MAX_URLLEN 78
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
|
||||
#define WWW_CONF_RENDERSTATE 1
|
||||
#define WWW_CONF_FORMS 1
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 20
|
||||
#define WWW_CONF_MAX_FORMNAMELEN 20
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 20
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 20
|
||||
|
||||
|
@ -35,13 +35,10 @@
|
||||
|
||||
ETHERNET = cs8900a
|
||||
|
||||
CONTIKI_SOURCEFILES += cfs-posix-dir.c
|
||||
CONTIKI_TARGET_SOURCEFILES += posixdirent.S
|
||||
|
||||
CONTIKI_CPU = $(CONTIKI)/cpu/6502
|
||||
include $(CONTIKI_CPU)/Makefile.6502
|
||||
|
||||
LDFLAGS += -C $(CONTIKI)/platform/$(TARGET)/$(TARGET).cfg -S 0x2000
|
||||
STARTADDR_FLAG = -S 0x2000
|
||||
|
||||
ifeq ($(MAKECMDGOALS),disk)
|
||||
ifndef DIR2ATR
|
||||
@ -51,8 +48,8 @@ endif
|
||||
|
||||
disk: all
|
||||
mkdir atr
|
||||
cp $(CONTIKI)/tools/$(TARGET)/dos.sys atr/dos.sys
|
||||
cp $(CONTIKI)/tools/$(TARGET)/dup.sys atr/dup.sys
|
||||
cp $(CONTIKI)/tools/$(TARGET)/dos25/dos.sys atr/dos.sys
|
||||
cp $(CONTIKI)/tools/$(TARGET)/dos25/dup.sys atr/dup.sys
|
||||
cp $(CONTIKI_PROJECT).$(TARGET) atr/autorun.sys
|
||||
cp $(CONTIKI)/tools/$(TARGET)/sample.cfg atr/contiki.cfg
|
||||
ifeq ($(HTTPD-CFS),1)
|
||||
|
@ -62,11 +62,6 @@
|
||||
#define WWW_CONF_HISTORY_SIZE 0
|
||||
#define WWW_CONF_MAX_URLLEN 80
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
|
||||
#define WWW_CONF_RENDERSTATE 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__ */
|
||||
|
@ -1,159 +0,0 @@
|
||||
; Native: Shawn Jefferson, December 2005
|
||||
; POSIX: Stefan Haubenthal, April 2008
|
||||
|
||||
.include "atari.inc"
|
||||
.export _opendir, _readdir, _closedir
|
||||
.import findfreeiocb, clriocb
|
||||
.import __oserror, return0, __do_oserror
|
||||
.importzp ptr1, tmp1
|
||||
.ifdef DEFAULT_DEVICE
|
||||
.import __defdev
|
||||
.endif
|
||||
|
||||
|
||||
.proc _opendir
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
jsr findfreeiocb
|
||||
beq @iocbok
|
||||
bne cioerr
|
||||
@iocbok: stx diriocb
|
||||
jsr clriocb
|
||||
ldx diriocb
|
||||
ldy #0 ; '.' -> "D:*.*"
|
||||
lda (ptr1),y
|
||||
cmp #'.'
|
||||
bne @use_parm
|
||||
|
||||
; "." was given as parameter, use default device/dir
|
||||
|
||||
.ifdef DEFAULT_DEVICE
|
||||
; construct a "Dn:*.*" like string from the default drive
|
||||
lda __defdev+1
|
||||
sta dddefdev+1 ; copy drive number (overwrite 2nd 'D')
|
||||
lda #<dddefdev
|
||||
sta ICBAL,x
|
||||
lda #>dddefdev
|
||||
sta ICBAH,x
|
||||
bne @cont
|
||||
.else
|
||||
lda #<defdev
|
||||
sta ICBAL,x
|
||||
lda #>defdev
|
||||
sta ICBAH,x
|
||||
bne @cont
|
||||
.endif
|
||||
|
||||
@use_parm: lda ptr1
|
||||
sta ICBAL,x
|
||||
lda ptr1+1
|
||||
sta ICBAH,x
|
||||
|
||||
@cont: lda #OPEN
|
||||
sta ICCOM,x
|
||||
lda #OPNIN|DIRECT
|
||||
sta ICAX1,x
|
||||
jsr CIOV
|
||||
bmi cioerr
|
||||
lda #0
|
||||
sta __oserror
|
||||
tax
|
||||
lda diriocb
|
||||
rts
|
||||
.endproc
|
||||
|
||||
cioerr: sty __oserror
|
||||
jmp return0
|
||||
|
||||
.proc _readdir
|
||||
tax
|
||||
lda #GETREC
|
||||
sta ICCOM,x
|
||||
lda #<entry
|
||||
sta ICBAL,x
|
||||
sta ptr1
|
||||
lda #>entry
|
||||
sta ICBAH,x
|
||||
sta ptr1+1
|
||||
lda #DSCTSZ
|
||||
sta ICBLL,x
|
||||
lda #0
|
||||
sta ICBLH,x
|
||||
jsr CIOV
|
||||
bmi cioerr
|
||||
ldy #0 ; FREE SECTORS
|
||||
lda (ptr1),y
|
||||
cmp #'0'
|
||||
bcs cioerr
|
||||
dey
|
||||
@next: iny ; remove trailing spaces
|
||||
iny
|
||||
iny
|
||||
lda (ptr1),y
|
||||
dey
|
||||
dey
|
||||
sta (ptr1),y
|
||||
cpy #9
|
||||
bcs @break
|
||||
cmp #' '
|
||||
bne @next
|
||||
|
||||
@break: lda #'.' ; extension dot
|
||||
sta (ptr1),y
|
||||
iny ; copy extension
|
||||
sty tmp1
|
||||
ldy #10
|
||||
lda (ptr1),y
|
||||
cmp #' '
|
||||
bne @hasext
|
||||
|
||||
; no extension present: remove the trailing dot and be done
|
||||
ldy tmp1
|
||||
dey
|
||||
bne @done
|
||||
|
||||
@hasext: jsr copychar
|
||||
ldy #11
|
||||
jsr copychar
|
||||
ldy #12
|
||||
jsr copychar
|
||||
|
||||
@done: lda #0 ; end of string
|
||||
sta (ptr1),y
|
||||
lda ptr1
|
||||
ldx ptr1+1
|
||||
rts
|
||||
|
||||
|
||||
copychar: lda (ptr1),y ; src=y dest=tmp1
|
||||
ldy tmp1
|
||||
cmp #' '
|
||||
beq @break
|
||||
sta (ptr1),y
|
||||
iny
|
||||
sty tmp1
|
||||
@break: rts
|
||||
.endproc
|
||||
|
||||
.proc _closedir
|
||||
tax
|
||||
lda #CLOSE
|
||||
sta ICCOM,x
|
||||
jsr CIOV
|
||||
bmi @cioerr
|
||||
ldx #0
|
||||
stx __oserror ; clear system specific error code
|
||||
txa
|
||||
rts
|
||||
@cioerr: jmp __do_oserror
|
||||
.endproc
|
||||
|
||||
.data
|
||||
.ifdef DEFAULT_DEVICE
|
||||
dddefdev: .byte "D"
|
||||
.endif
|
||||
defdev: .asciiz "D:*.*"
|
||||
|
||||
.bss
|
||||
diriocb: .res 1
|
||||
entry: .res DSCTSZ
|
@ -33,13 +33,12 @@
|
||||
# $Id: Makefile.c128,v 1.15 2010/10/23 13:48:06 oliverschmidt Exp $
|
||||
#
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += cfs-cbm-dir.c pfs.S pfs_write.S
|
||||
CONTIKI_TARGET_SOURCEFILES += pfs.S pfs_write.S
|
||||
|
||||
CONTIKI_CPU = $(CONTIKI)/cpu/6502
|
||||
include $(CONTIKI_CPU)/Makefile.6502
|
||||
|
||||
CFLAGS += -DWITH_PETSCII
|
||||
LDFLAGS += -t $(TARGET)
|
||||
|
||||
ifeq ($(MAKECMDGOALS),disk)
|
||||
ifndef C1541
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cbm.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_opendir(struct cfs_dir *p, const char *n)
|
||||
{
|
||||
return cbm_opendir(12, _curunit);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
{
|
||||
struct cbm_dirent dirent;
|
||||
|
||||
do {
|
||||
if(cbm_readdir(12, &dirent)) {
|
||||
return -1;
|
||||
}
|
||||
} while(dirent.type == CBM_T_HEADER);
|
||||
strcpy(e->name, dirent.name);
|
||||
e->size = dirent.size;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
cfs_closedir(struct cfs_dir *p)
|
||||
{
|
||||
cbm_closedir(12);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
@ -70,11 +70,6 @@
|
||||
#define WWW_CONF_HISTORY_SIZE 0
|
||||
#define WWW_CONF_MAX_URLLEN 78
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
|
||||
#define WWW_CONF_RENDERSTATE 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__ */
|
||||
|
@ -36,7 +36,7 @@
|
||||
.constructor init_pfs
|
||||
.destructor done_pfs
|
||||
.importzp ptr1, ptr2, ptr3, sp
|
||||
.import __curunit, __filetype, popax, addysp, subysp
|
||||
.import curunit, __filetype, popax, addysp, subysp
|
||||
.export pfs_rwcommon, pfs_rwsetflags, pfs_rwcommonend
|
||||
.if F_IDE64
|
||||
.export ide64_rwprepare, ide64_rwfinish
|
||||
@ -178,7 +178,7 @@ next: inc ptr2 ;next file number
|
||||
stx ptr2+1
|
||||
nextsa: inc ptr2+1 ;next channel
|
||||
retr: lda ptr2 ;file number
|
||||
ldx __curunit
|
||||
ldx curunit
|
||||
ldy ptr2+1 ;secondary address
|
||||
jsr SETLFS
|
||||
jsr OPEN ;open
|
||||
|
@ -33,13 +33,12 @@
|
||||
# $Id: Makefile.c64,v 1.17 2010/10/23 13:48:06 oliverschmidt Exp $
|
||||
#
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += cfs-cbm-dir.c pfs.S pfs_write.S
|
||||
CONTIKI_TARGET_SOURCEFILES += pfs.S pfs_write.S
|
||||
|
||||
CONTIKI_CPU = $(CONTIKI)/cpu/6502
|
||||
include $(CONTIKI_CPU)/Makefile.6502
|
||||
|
||||
CFLAGS += -DWITH_PETSCII
|
||||
LDFLAGS += -t $(TARGET)
|
||||
|
||||
ifeq ($(MAKECMDGOALS),disk)
|
||||
ifndef C1541
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cbm.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_opendir(struct cfs_dir *p, const char *n)
|
||||
{
|
||||
return cbm_opendir(12, _curunit);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
{
|
||||
struct cbm_dirent dirent;
|
||||
|
||||
do {
|
||||
if(cbm_readdir(12, &dirent)) {
|
||||
return -1;
|
||||
}
|
||||
} while(dirent.type == CBM_T_HEADER);
|
||||
strcpy(e->name, dirent.name);
|
||||
e->size = dirent.size;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
cfs_closedir(struct cfs_dir *p)
|
||||
{
|
||||
cbm_closedir(12);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
@ -70,10 +70,8 @@
|
||||
#define WWW_CONF_HISTORY_SIZE 4
|
||||
#define WWW_CONF_MAX_URLLEN 80
|
||||
#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
|
||||
#define WWW_CONF_RENDERSTATE 1
|
||||
#define WWW_CONF_FORMS 1
|
||||
#define WWW_CONF_MAX_FORMACTIONLEN 20
|
||||
#define WWW_CONF_MAX_FORMNAMELEN 20
|
||||
#define WWW_CONF_MAX_INPUTNAMELEN 20
|
||||
#define WWW_CONF_MAX_INPUTVALUELEN 20
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
.constructor init_pfs
|
||||
.destructor done_pfs
|
||||
.importzp ptr1, ptr2, ptr3, sp
|
||||
.import __curunit, __filetype, popax, addysp, subysp
|
||||
.import curunit, __filetype, popax, addysp, subysp
|
||||
.export pfs_rwcommon, pfs_rwsetflags, pfs_rwcommonend
|
||||
.if F_IDE64
|
||||
.export ide64_rwprepare, ide64_rwfinish
|
||||
@ -178,7 +178,7 @@ next: inc ptr2 ;next file number
|
||||
stx ptr2+1
|
||||
nextsa: inc ptr2+1 ;next channel
|
||||
retr: lda ptr2 ;file number
|
||||
ldx __curunit
|
||||
ldx curunit
|
||||
ldy ptr2+1 ;secondary address
|
||||
jsr SETLFS
|
||||
jsr OPEN ;open
|
||||
|
@ -175,15 +175,5 @@ typedef unsigned long clock_time_t;
|
||||
|
||||
#define WWW_CONF_WEBPAGE_WIDTH 76
|
||||
#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__ */
|
||||
|
@ -97,7 +97,7 @@ else
|
||||
ifdef MOTEIDS
|
||||
MOTES = $(foreach MOTEID, $(MOTEIDS), $(shell $(MOTELIST) 2>&- | grep $(MOTEID) | \
|
||||
cut -f 4 -d \ | \
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/[\w+\.\-]+)-);')
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/[\w+\.\-]+)-);'))
|
||||
else
|
||||
MOTES = $(shell $(MOTELIST) 2>&- | grep USB | \
|
||||
cut -f 4 -d \ | \
|
||||
|
@ -1,5 +1,3 @@
|
||||
# $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $
|
||||
|
||||
ifdef GCC
|
||||
CFLAGS+=-Os -g
|
||||
endif
|
||||
@ -53,7 +51,19 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
|
||||
NUMPAR=20
|
||||
IHEXFILE=tmpimage.ihex
|
||||
|
||||
# If we are not running under Windows, we assume Linux
|
||||
ifeq ($(HOST_OS),Darwin)
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1-macos
|
||||
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1
|
||||
BSL_FILETYPE = -I
|
||||
MOTES = $(shell $(MOTELIST) -c 2>&- | \
|
||||
cut -f 2 -d ,)
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
else
|
||||
# If we are not running under Mac, we assume Linux
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
@ -65,6 +75,9 @@ ifndef MOTELIST
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
motelist: z1-motelist
|
||||
|
||||
|
@ -226,17 +226,14 @@ ISR(USCIAB1TX, i2c_tx_interrupt)
|
||||
// RX Part
|
||||
#if I2C_RX_WITH_INTERRUPT
|
||||
else if (UC1IFG & UCB1RXIFG){ // RX int. condition
|
||||
if (rx_byte_ctr == 0){
|
||||
rx_buf_ptr[rx_byte_tot - rx_byte_ctr] = UCB1RXBUF;
|
||||
rx_byte_ctr--;
|
||||
if (rx_byte_ctr == 1){ //stop condition should be set before receiving last byte
|
||||
// Only for 1-byte transmissions, STOP is handled in receive_n_int
|
||||
if (rx_byte_tot != 1)
|
||||
UCB1CTL1 |= UCTXSTP; // I2C stop condition
|
||||
|
||||
UC1IFG &= ~UCB1RXIFG; // Clear USCI_B1 RX int flag. XXX Just in case, check if necessary
|
||||
}
|
||||
else {
|
||||
rx_buf_ptr[rx_byte_tot - rx_byte_ctr] = UCB1RXBUF;
|
||||
rx_byte_ctr--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -76,11 +76,11 @@ contiki-apple2-1.dsk: apple2enh-makes
|
||||
cp ../apple2enh/prodos.dsk $@
|
||||
java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg
|
||||
java -jar $(AC) -p $@ menu.system sys 0 < ../apple2enh/menu.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ipconfig bin 0 < ../../cpu/6502/ipconfig/ipconfig.apple2enh
|
||||
java -jar $(AC) -p $@ webbrows.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ webbrows.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser/webbrowser.apple2enh
|
||||
java -jar $(AC) -p $@ wget.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ wget.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh
|
||||
java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ipconfig/cs8900a.eth
|
||||
java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ipconfig/lan91c96.eth
|
||||
@ -90,11 +90,11 @@ contiki-apple2-2.dsk: apple2enh-makes
|
||||
cp ../apple2enh/prodos.dsk $@
|
||||
java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg
|
||||
java -jar $(AC) -p $@ menu.system sys 0 < ../apple2enh/menu.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ipconfig bin 0 < ../../cpu/6502/ipconfig/ipconfig.apple2enh
|
||||
java -jar $(AC) -p $@ irc.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ irc.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc/irc-client.apple2enh
|
||||
java -jar $(AC) -p $@ breadbox.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ breadbox.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ breadbox bin < ../../../contikiprojects/vandenbrande.com/twitter/platform/apple2enh/breadbox64.apple2enh
|
||||
java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ipconfig/cs8900a.eth
|
||||
java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ipconfig/lan91c96.eth
|
||||
@ -104,11 +104,11 @@ contiki-apple2-3.dsk: apple2enh-makes
|
||||
cp ../apple2enh/prodos.dsk $@
|
||||
java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg
|
||||
java -jar $(AC) -p $@ menu.system sys 0 < ../apple2enh/menu.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ipconfig bin 0 < ../../cpu/6502/ipconfig/ipconfig.apple2enh
|
||||
java -jar $(AC) -p $@ email.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ email.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ email bin < ../../examples/email/email-client.apple2enh
|
||||
java -jar $(AC) -p $@ ftp.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ftp.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ftp bin < ../../examples/ftp/ftp-client.apple2enh
|
||||
java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ipconfig/cs8900a.eth
|
||||
java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ipconfig/lan91c96.eth
|
||||
@ -118,11 +118,11 @@ contiki-apple2-4.dsk: apple2enh-makes
|
||||
cp ../apple2enh/prodos.dsk $@
|
||||
java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg
|
||||
java -jar $(AC) -p $@ menu.system sys 0 < ../apple2enh/menu.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ipconfig bin 0 < ../../cpu/6502/ipconfig/ipconfig.apple2enh
|
||||
java -jar $(AC) -p $@ webserv.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ webserv.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh
|
||||
java -jar $(AC) -p $@ telnetd.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ telnetd.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh
|
||||
java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ipconfig/cs8900a.eth
|
||||
java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ipconfig/lan91c96.eth
|
||||
@ -136,23 +136,23 @@ contiki-apple2.2mg: apple2enh-makes
|
||||
cp ../apple2enh/prodos.2mg $@
|
||||
java -jar $(AC) -p $@ contiki.cfg bin 0 < ../apple2enh/default.cfg
|
||||
java -jar $(AC) -p $@ menu.system sys 0 < ../apple2enh/menu.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ipconfig.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ipconfig bin 0 < ../../cpu/6502/ipconfig/ipconfig.apple2enh
|
||||
java -jar $(AC) -p $@ webbrows.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ webbrows.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ webbrows bin < ../../examples/webbrowser/webbrowser.apple2enh
|
||||
java -jar $(AC) -p $@ wget.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ wget.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ wget bin < ../../examples/wget/wget.apple2enh
|
||||
java -jar $(AC) -p $@ irc.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ irc.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ irc bin < ../../examples/irc/irc-client.apple2enh
|
||||
java -jar $(AC) -p $@ breadbox.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ breadbox.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ breadbox bin < ../../../contikiprojects/vandenbrande.com/twitter/platform/apple2enh/breadbox64.apple2enh
|
||||
java -jar $(AC) -p $@ email.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ email.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ email bin < ../../examples/email/email-client.apple2enh
|
||||
java -jar $(AC) -p $@ ftp.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ ftp.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ ftp bin < ../../examples/ftp/ftp-client.apple2enh
|
||||
java -jar $(AC) -p $@ webserv.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ webserv.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ webserv bin < ../../examples/webserver/webserver-example.apple2enh
|
||||
java -jar $(AC) -p $@ telnetd.system sys 0 < ../apple2enh/loader.system
|
||||
java -jar $(AC) -p $@ telnetd.system sys 0 < $(CC65_HOME)/targetutil/loader.system
|
||||
java -jar $(AC) -cc65 $@ telnetd bin < ../../examples/telnet-server/telnet-server.apple2enh
|
||||
java -jar $(AC) -p $@ cs8900a.eth rel 0 < ../../cpu/6502/ipconfig/cs8900a.eth
|
||||
java -jar $(AC) -p $@ lan91c96.eth rel 0 < ../../cpu/6502/ipconfig/lan91c96.eth
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
75
tools/z1/motelist-z1-macos
Executable file
75
tools/z1/motelist-z1-macos
Executable file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
|
||||
my $help = <<'EOF';
|
||||
usage: motelist [options]
|
||||
|
||||
options:
|
||||
-h display this help
|
||||
-c compact format, not pretty but easier for parsing
|
||||
EOF
|
||||
|
||||
my %Opt = (
|
||||
compact => 0,
|
||||
dev_prefix => [ "/dev/tty.SLAB" ],
|
||||
);
|
||||
|
||||
while (@ARGV) {
|
||||
last unless $ARGV[0] =~ /^-/;
|
||||
my $opt = shift @ARGV;
|
||||
if( $opt eq "-h" ) { print "$help\n"; exit 0; }
|
||||
elsif( $opt eq "-c" ) { $Opt{compact} = 1; }
|
||||
else { print STDERR "$help\nerror, unknown command line option $opt\n"; exit 1; }
|
||||
}
|
||||
|
||||
print_motelist( scan_dev() );
|
||||
|
||||
#
|
||||
# Scan /dev for tty.SLAB*
|
||||
#
|
||||
sub scan_dev {
|
||||
my @devs;
|
||||
foreach (`ls /dev/tty.SLAB* 2>&1`) {
|
||||
my($dev, $serial) = /(\/dev\/tty.SLAB(\S+))/;
|
||||
if ($serial ne "*:") {
|
||||
my $d;
|
||||
$d->{"InfoSerial"} = $serial;
|
||||
$d->{"SerialDevName"} = $dev;
|
||||
push(@devs, $d);
|
||||
}
|
||||
}
|
||||
return @devs;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Print motelist
|
||||
#
|
||||
sub print_motelist {
|
||||
my @devs = @_;
|
||||
|
||||
# If none were found, quit
|
||||
if( @devs == 0 ) {
|
||||
#print "No devices found.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
# Print a header
|
||||
if( !$Opt{compact} ) {
|
||||
print << "EOF" unless $Opt{compact};
|
||||
Reference Device Description
|
||||
---------- --------------------------- ---------------------------------------
|
||||
EOF
|
||||
}
|
||||
|
||||
# Print the usb information
|
||||
for my $dev (@devs) {
|
||||
my $desc = "(none)";
|
||||
my @output = ( $dev->{"InfoSerial"}, $dev->{"SerialDevName"}, $desc );
|
||||
if( $Opt{compact} ) {
|
||||
print join(",",@output) . "\n";
|
||||
} else {
|
||||
printf( "%-10s %-27s %s\n", @output );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user