Made cfs-based webserver example compatible with 8.3 file systems.

This commit is contained in:
oliverschmidt 2010-09-28 20:40:52 +00:00
parent 8631ae8515
commit cd24e920b6
9 changed files with 38 additions and 33 deletions

View file

@ -10,6 +10,7 @@ http_texthtml "text/html"
http_location "location: " http_location "location: "
http_host "host: " http_host "host: "
http_crnl "\r\n" http_crnl "\r\n"
http_index_htm "/index.htm"
http_index_html "/index.html" http_index_html "/index.html"
http_404_html "/404.html" http_404_html "/404.html"
http_referer "Referer:" http_referer "Referer:"

View file

@ -34,6 +34,9 @@ const char http_host[7] =
const char http_crnl[3] = const char http_crnl[3] =
/* "\r\n" */ /* "\r\n" */
{0xd, 0xa, }; {0xd, 0xa, };
const char http_index_htm[11] =
/* "/index.htm" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, };
const char http_index_html[12] = const char http_index_html[12] =
/* "/index.html" */ /* "/index.html" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; {0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };

View file

@ -10,6 +10,7 @@ extern const char http_texthtml[10];
extern const char http_location[11]; extern const char http_location[11];
extern const char http_host[7]; extern const char http_host[7];
extern const char http_crnl[3]; extern const char http_crnl[3];
extern const char http_index_htm[11];
extern const char http_index_html[12]; extern const char http_index_html[12];
extern const char http_404_html[10]; extern const char http_404_html[10];
extern const char http_referer[9]; extern const char http_referer[9];

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: httpd-cfs.c,v 1.23 2010/08/30 19:44:38 oliverschmidt Exp $ * $Id: httpd-cfs.c,v 1.24 2010/09/28 20:40:52 oliverschmidt Exp $
*/ */
#include <stdio.h> #include <stdio.h>
@ -141,7 +141,7 @@ PT_THREAD(handle_output(struct httpd_state *s))
s->fd = cfs_open(&s->filename[1], CFS_READ); s->fd = cfs_open(&s->filename[1], CFS_READ);
petsciiconv_toascii(s->filename, sizeof(s->filename)); petsciiconv_toascii(s->filename, sizeof(s->filename));
if(s->fd < 0) { if(s->fd < 0) {
strcpy(s->filename, "/notfound.html"); strcpy(s->filename, "/notfound.htm");
s->fd = cfs_open(&s->filename[1], CFS_READ); s->fd = cfs_open(&s->filename[1], CFS_READ);
petsciiconv_toascii(s->filename, sizeof(s->filename)); petsciiconv_toascii(s->filename, sizeof(s->filename));
PT_WAIT_THREAD(&s->outputpt, PT_WAIT_THREAD(&s->outputpt,
@ -150,10 +150,10 @@ PT_THREAD(handle_output(struct httpd_state *s))
PT_WAIT_THREAD(&s->outputpt, PT_WAIT_THREAD(&s->outputpt,
send_string(s, "not found")); send_string(s, "not found"));
uip_close(); uip_close();
webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.html)"); webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.htm)");
PT_EXIT(&s->outputpt); PT_EXIT(&s->outputpt);
} }
webserver_log_file(&uip_conn->ripaddr, "404 - notfound.html"); webserver_log_file(&uip_conn->ripaddr, "404 - notfound.htm");
} else { } else {
PT_WAIT_THREAD(&s->outputpt, PT_WAIT_THREAD(&s->outputpt,
send_headers(s, http_header_200)); send_headers(s, http_header_200));
@ -186,7 +186,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename)); urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename));
#else /* URLCONV */ #else /* URLCONV */
if(s->inputbuf[1] == ISO_space) { if(s->inputbuf[1] == ISO_space) {
strncpy(s->filename, http_index_html, sizeof(s->filename)); strncpy(s->filename, http_index_htm, sizeof(s->filename));
} else { } else {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
strncpy(s->filename, s->inputbuf, sizeof(s->filename)); strncpy(s->filename, s->inputbuf, sizeof(s->filename));

View file

@ -30,7 +30,7 @@
* *
* Author: Kajtar Zsolt <soci@c64.rulez.org> * Author: Kajtar Zsolt <soci@c64.rulez.org>
* *
* $Id: urlconv.c,v 1.2 2010/08/30 19:44:38 oliverschmidt Exp $ * $Id: urlconv.c,v 1.3 2010/09/28 20:40:52 oliverschmidt Exp $
*/ */
#include <string.h> #include <string.h>
@ -140,7 +140,7 @@ urlconv_tofilename(char *dest, char *source, unsigned char maxlen)
} }
} while(c); } while(c);
if(*to == ISO_slash && (len + sizeof(http_index_html) - 3) < maxlen) { if(*to == ISO_slash && (len + sizeof(http_index_html) - 3) < maxlen) {
strcpy(to, http_index_html); // add index.html strcpy(to, http_index_htm); // add index.htm
} else { } else {
++to; ++to;
*to = 0; *to = 0;

View file

@ -30,7 +30,7 @@
# #
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
# $Id: Makefile.apple2enh,v 1.17 2010/09/28 19:36:16 oliverschmidt Exp $ # $Id: Makefile.apple2enh,v 1.18 2010/09/28 20:40:52 oliverschmidt Exp $
# #
CONTIKI_SOURCEFILES += pfs.S CONTIKI_SOURCEFILES += pfs.S
@ -66,8 +66,8 @@ ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE)
java -jar $(AC) -p contiki.dsk a2e.stdmou.mou rel 0 < $(CC65_HOME)/mou/a2e.stdmou.mou java -jar $(AC) -p contiki.dsk a2e.stdmou.mou rel 0 < $(CC65_HOME)/mou/a2e.stdmou.mou
endif endif
ifeq ($(HTTPD-CFS),1) ifeq ($(HTTPD-CFS),1)
java -jar $(AC) -p contiki.dsk index.html bin 0 < httpd-cfs/index.html java -jar $(AC) -p contiki.dsk index.htm bin 0 < httpd-cfs/index.htm
java -jar $(AC) -p contiki.dsk backgrnd.gif bin 0 < httpd-cfs/backgrnd.gif java -jar $(AC) -p contiki.dsk backgrnd.gif bin 0 < httpd-cfs/backgrnd.gif
java -jar $(AC) -p contiki.dsk contiki.gif bin 0 < httpd-cfs/contiki.gif java -jar $(AC) -p contiki.dsk contiki.gif bin 0 < httpd-cfs/contiki.gif
java -jar $(AC) -p contiki.dsk notfound.html bin 0 < httpd-cfs/notfound.html java -jar $(AC) -p contiki.dsk notfound.htm bin 0 < httpd-cfs/notfound.htm
endif endif

View file

@ -30,7 +30,7 @@
# #
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
# $Id: Makefile.c128,v 1.12 2010/09/28 19:36:16 oliverschmidt Exp $ # $Id: Makefile.c128,v 1.13 2010/09/28 20:40:53 oliverschmidt Exp $
# #
CONTIKI_SOURCEFILES += pfs.S pfs_write.S CONTIKI_SOURCEFILES += pfs.S pfs_write.S
@ -57,8 +57,8 @@ ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE)
$(C1541) -attach contiki.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u $(C1541) -attach contiki.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u
endif endif
ifeq ($(HTTPD-CFS),1) ifeq ($(HTTPD-CFS),1)
$(C1541) -attach contiki.d71 -write httpd-cfs/index.html index.html,u $(C1541) -attach contiki.d71 -write httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki.d71 -write httpd-cfs/backgrnd.gif backgrnd.gif,u $(C1541) -attach contiki.d71 -write httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki.d71 -write httpd-cfs/contiki.gif contiki.gif,u $(C1541) -attach contiki.d71 -write httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki.d71 -write httpd-cfs/notfound.html notfound.html,u $(C1541) -attach contiki.d71 -write httpd-cfs/notfound.htm notfound.htm,u
endif endif

View file

@ -30,7 +30,7 @@
# #
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
# $Id: Makefile.c64,v 1.14 2010/09/28 19:36:16 oliverschmidt Exp $ # $Id: Makefile.c64,v 1.15 2010/09/28 20:40:53 oliverschmidt Exp $
# #
CONTIKI_SOURCEFILES += pfs.S pfs_write.S CONTIKI_SOURCEFILES += pfs.S pfs_write.S
@ -57,8 +57,8 @@ ifeq ($(findstring WITH_MOUSE,$(DEFINES)),WITH_MOUSE)
$(C1541) -attach contiki.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u $(C1541) -attach contiki.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u
endif endif
ifeq ($(HTTPD-CFS),1) ifeq ($(HTTPD-CFS),1)
$(C1541) -attach contiki.d64 -write httpd-cfs/index.html index.html,u $(C1541) -attach contiki.d64 -write httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki.d64 -write httpd-cfs/backgrnd.gif backgrnd.gif,u $(C1541) -attach contiki.d64 -write httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki.d64 -write httpd-cfs/contiki.gif contiki.gif,u $(C1541) -attach contiki.d64 -write httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki.d64 -write httpd-cfs/notfound.html notfound.html,u $(C1541) -attach contiki.d64 -write httpd-cfs/notfound.htm notfound.htm,u
endif endif

View file

@ -30,7 +30,7 @@
# #
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
# $Id: Makefile,v 1.6 2010/09/28 19:43:50 oliverschmidt Exp $ # $Id: Makefile,v 1.7 2010/09/28 20:40:52 oliverschmidt Exp $
# #
ifndef CC65_HOME ifndef CC65_HOME
@ -60,10 +60,10 @@ apple2enh-1-disk:
java -jar $(AC) -p contiki-1.dsk cs8900a.eth rel 0 < ../../cpu/6502/dhcp/cs8900a.eth java -jar $(AC) -p contiki-1.dsk cs8900a.eth rel 0 < ../../cpu/6502/dhcp/cs8900a.eth
java -jar $(AC) -p contiki-1.dsk lan91c96.eth rel 0 < ../../cpu/6502/dhcp/lan91c96.eth java -jar $(AC) -p contiki-1.dsk lan91c96.eth rel 0 < ../../cpu/6502/dhcp/lan91c96.eth
java -jar $(AC) -p contiki-1.dsk a2e.stdmou.mou rel 0 < $(CC65_HOME)/mou/a2e.stdmou.mou java -jar $(AC) -p contiki-1.dsk a2e.stdmou.mou rel 0 < $(CC65_HOME)/mou/a2e.stdmou.mou
java -jar $(AC) -p contiki-1.dsk index.html bin 0 < ../../examples/webserver/httpd-cfs/index.html java -jar $(AC) -p contiki-1.dsk index.htm bin 0 < ../../examples/webserver/httpd-cfs/index.htm
java -jar $(AC) -p contiki-1.dsk backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif java -jar $(AC) -p contiki-1.dsk backgrnd.gif bin 0 < ../../examples/webserver/httpd-cfs/backgrnd.gif
java -jar $(AC) -p contiki-1.dsk contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif java -jar $(AC) -p contiki-1.dsk contiki.gif bin 0 < ../../examples/webserver/httpd-cfs/contiki.gif
java -jar $(AC) -p contiki-1.dsk notfound.html bin 0 < ../../examples/webserver/httpd-cfs/notfound.html java -jar $(AC) -p contiki-1.dsk notfound.htm bin 0 < ../../examples/webserver/httpd-cfs/notfound.htm
apple2enh-2-disk: apple2enh-2-disk:
cp ../apple2enh/prodos.dsk contiki-2.dsk cp ../apple2enh/prodos.dsk contiki-2.dsk
@ -103,10 +103,10 @@ c64-1-disk:
$(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u $(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u $(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-1.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u $(C1541) -attach contiki-1.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u
$(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/index.html index.html,u $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/notfound.html notfound.html,u $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/notfound.htm notfound.htm,u
c64-2-disk: c64-2-disk:
$(C1541) -format contiki,00 d64 contiki-2.d64 $(C1541) -format contiki,00 d64 contiki-2.d64
@ -132,7 +132,7 @@ c128-1-disk:
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u $(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u $(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-1.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u $(C1541) -attach contiki-1.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/index.html index.html,u $(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u $(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u $(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/notfound.html notfound.html,u $(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/notfound.htm notfound.htm,u