From cd24e920b641fbbae9e686cfe3296554fe1614ca Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Tue, 28 Sep 2010 20:40:52 +0000 Subject: [PATCH] Made cfs-based webserver example compatible with 8.3 file systems. --- apps/webserver/http-strings | 1 + apps/webserver/http-strings.c | 3 +++ apps/webserver/http-strings.h | 1 + apps/webserver/httpd-cfs.c | 10 ++++---- apps/webserver/urlconv.c | 4 ++-- platform/apple2enh/Makefile.apple2enh | 6 ++--- platform/c128/Makefile.c128 | 6 ++--- platform/c64/Makefile.c64 | 6 ++--- tools/6502/Makefile | 34 +++++++++++++-------------- 9 files changed, 38 insertions(+), 33 deletions(-) diff --git a/apps/webserver/http-strings b/apps/webserver/http-strings index edbd49d37..ff4626d98 100644 --- a/apps/webserver/http-strings +++ b/apps/webserver/http-strings @@ -10,6 +10,7 @@ http_texthtml "text/html" http_location "location: " http_host "host: " http_crnl "\r\n" +http_index_htm "/index.htm" http_index_html "/index.html" http_404_html "/404.html" http_referer "Referer:" diff --git a/apps/webserver/http-strings.c b/apps/webserver/http-strings.c index 3f889ed98..41342bdfc 100644 --- a/apps/webserver/http-strings.c +++ b/apps/webserver/http-strings.c @@ -34,6 +34,9 @@ const char http_host[7] = const char http_crnl[3] = /* "\r\n" */ {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] = /* "/index.html" */ {0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; diff --git a/apps/webserver/http-strings.h b/apps/webserver/http-strings.h index 0c6405f2e..079cbb149 100644 --- a/apps/webserver/http-strings.h +++ b/apps/webserver/http-strings.h @@ -10,6 +10,7 @@ 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_htm[11]; extern const char http_index_html[12]; extern const char http_404_html[10]; extern const char http_referer[9]; diff --git a/apps/webserver/httpd-cfs.c b/apps/webserver/httpd-cfs.c index f4021a0a8..fd6e85776 100644 --- a/apps/webserver/httpd-cfs.c +++ b/apps/webserver/httpd-cfs.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -141,7 +141,7 @@ PT_THREAD(handle_output(struct httpd_state *s)) s->fd = cfs_open(&s->filename[1], CFS_READ); petsciiconv_toascii(s->filename, sizeof(s->filename)); if(s->fd < 0) { - strcpy(s->filename, "/notfound.html"); + strcpy(s->filename, "/notfound.htm"); s->fd = cfs_open(&s->filename[1], CFS_READ); petsciiconv_toascii(s->filename, sizeof(s->filename)); PT_WAIT_THREAD(&s->outputpt, @@ -150,10 +150,10 @@ PT_THREAD(handle_output(struct httpd_state *s)) PT_WAIT_THREAD(&s->outputpt, send_string(s, "not found")); 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); } - webserver_log_file(&uip_conn->ripaddr, "404 - notfound.html"); + webserver_log_file(&uip_conn->ripaddr, "404 - notfound.htm"); } else { PT_WAIT_THREAD(&s->outputpt, 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)); #else /* URLCONV */ 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 { s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; strncpy(s->filename, s->inputbuf, sizeof(s->filename)); diff --git a/apps/webserver/urlconv.c b/apps/webserver/urlconv.c index 3693ce178..55f05a252 100644 --- a/apps/webserver/urlconv.c +++ b/apps/webserver/urlconv.c @@ -30,7 +30,7 @@ * * Author: Kajtar Zsolt * - * $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 @@ -140,7 +140,7 @@ urlconv_tofilename(char *dest, char *source, unsigned char maxlen) } } while(c); 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 { ++to; *to = 0; diff --git a/platform/apple2enh/Makefile.apple2enh b/platform/apple2enh/Makefile.apple2enh index b587c2b93..e4fa4d1df 100644 --- a/platform/apple2enh/Makefile.apple2enh +++ b/platform/apple2enh/Makefile.apple2enh @@ -30,7 +30,7 @@ # # Author: Oliver Schmidt # -# $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 @@ -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 endif 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 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 diff --git a/platform/c128/Makefile.c128 b/platform/c128/Makefile.c128 index dcc1772a8..9794625b1 100644 --- a/platform/c128/Makefile.c128 +++ b/platform/c128/Makefile.c128 @@ -30,7 +30,7 @@ # # Author: Oliver Schmidt # -# $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 @@ -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 endif 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/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 diff --git a/platform/c64/Makefile.c64 b/platform/c64/Makefile.c64 index b229ae525..d85dc294d 100644 --- a/platform/c64/Makefile.c64 +++ b/platform/c64/Makefile.c64 @@ -30,7 +30,7 @@ # # Author: Oliver Schmidt # -# $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 @@ -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 endif 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/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 diff --git a/tools/6502/Makefile b/tools/6502/Makefile index 0688e21f9..170d63b45 100644 --- a/tools/6502/Makefile +++ b/tools/6502/Makefile @@ -30,7 +30,7 @@ # # Author: Oliver Schmidt # -# $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 @@ -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 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 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 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: cp ../apple2enh/prodos.dsk contiki-2.dsk @@ -95,18 +95,18 @@ apple2enh-3-disk: c64-1-disk: $(C1541) -format contiki,00 d64 contiki-1.d64 - $(C1541) -attach contiki-1.d64 -write dummy.cfg contiki.cfg,u - $(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/dhcp-client.c64 dhcp,p - $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/webserver-example.c64 webserver,p - $(C1541) -attach contiki-1.d64 -write ../../examples/webbrowser/webbrowser.c64 webbrowser,p - $(C1541) -attach contiki-1.d64 -write ../../examples/wget/wget.c64 wget,p - $(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 $(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/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/notfound.html notfound.html,u + $(C1541) -attach contiki-1.d64 -write dummy.cfg contiki.cfg,u + $(C1541) -attach contiki-1.d64 -write ../../cpu/6502/dhcp/dhcp-client.c64 dhcp,p + $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/webserver-example.c64 webserver,p + $(C1541) -attach contiki-1.d64 -write ../../examples/webbrowser/webbrowser.c64 webbrowser,p + $(C1541) -attach contiki-1.d64 -write ../../examples/wget/wget.c64 wget,p + $(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 $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,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/contiki.gif contiki.gif,u + $(C1541) -attach contiki-1.d64 -write ../../examples/webserver/httpd-cfs/notfound.htm notfound.htm,u c64-2-disk: $(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/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 ../../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/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