From d01df43a0cc0726dc97f11c497615e969d9400ab Mon Sep 17 00:00:00 2001 From: David Kopf Date: Sat, 10 Sep 2011 13:04:21 -0400 Subject: [PATCH] Drop unneded null byte at end of httpd-fsdata files. --- apps/webserver-nano/httpd-fs.c | 5 +-- apps/webserver-nano/httpd-fsdata.c | 24 ++++++------- apps/webserver/Makefile.webserver | 10 ++++++ apps/webserver/httpd-fsdata.c | 20 +++++------ .../webserver-ipv6-raven/Makefile.webserver | 6 ++-- tools/makefsdata | 34 +++++++++++-------- 6 files changed, 57 insertions(+), 42 deletions(-) diff --git a/apps/webserver-nano/httpd-fs.c b/apps/webserver-nano/httpd-fs.c index b87b13d9a..c408c1294 100644 --- a/apps/webserver-nano/httpd-fs.c +++ b/apps/webserver-nano/httpd-fs.c @@ -74,11 +74,12 @@ httpd_fs_open(const char *name, struct httpd_fs_file *file) httpd_memcpy(&fram,f,sizeof(fram)); /*Compare name passed in RAM with name in whatever flash the file is in */ - /*makefsdata adds an extra zero byte at the end of the file */ + /*makefsdata no longer adds an extra zero byte at the end of the file */ if(httpd_fs_strcmp((char *)name, fram.name) == 0) { if (file) { file->data = fram.data; - file->len = fram.len-1; + // file->len = fram.len-1; + file->len = fram.len; #if WEBSERVER_CONF_FILESTATS==2 //increment count in linked list field if it is in RAM f->count++; } diff --git a/apps/webserver-nano/httpd-fsdata.c b/apps/webserver-nano/httpd-fsdata.c index 58cef3c1c..8f211b437 100644 --- a/apps/webserver-nano/httpd-fsdata.c +++ b/apps/webserver-nano/httpd-fsdata.c @@ -1,7 +1,7 @@ -/*********Generated by contiki/tools/makefsdata on 2011-07-23*********/ +/*********Generated by contiki/tools/makefsdata on 2011-09-10*********/ -const char data_404_html[87] HTTPD_STRING_ATTR = { +const char data_404_html[86] HTTPD_STRING_ATTR = { /* /404.html */ 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64, @@ -11,9 +11,9 @@ const char data_404_html[87] HTTPD_STRING_ATTR = { 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, - 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x00}; + 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e}; -const char data_files_shtml[169] HTTPD_STRING_ATTR = { +const char data_files_shtml[168] HTTPD_STRING_ATTR = { /* /files.shtml */ 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x25, 0x21, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, @@ -31,9 +31,9 @@ const char data_files_shtml[169] HTTPD_STRING_ATTR = { 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2a, 0x0a, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, - 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x00}; + 0x74, 0x6d, 0x6c, 0x3e, 0x0a}; -const char data_index_shtml[121] HTTPD_STRING_ATTR = { +const char data_index_shtml[120] HTTPD_STRING_ATTR = { /* /index.shtml */ 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x25, 0x21, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, @@ -46,9 +46,9 @@ const char data_index_shtml[121] HTTPD_STRING_ATTR = { 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x6e, 0x61, 0x6e, 0x6f, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x0a, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, - 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e, 0x00}; + 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e}; -const char data_status_shtml[159] HTTPD_STRING_ATTR = { +const char data_status_shtml[158] HTTPD_STRING_ATTR = { /* /status.shtml */ 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x25, 0x21, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, @@ -65,9 +65,9 @@ const char data_status_shtml[159] HTTPD_STRING_ATTR = { 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e, 0x0a, 0x25, 0x21, 0x20, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0a, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, - 0x73, 0x20, 0x2e, 0x0a, 0x00}; + 0x73, 0x20, 0x2e, 0x0a}; -const char data_tcp_shtml[228] HTTPD_STRING_ATTR = { +const char data_tcp_shtml[227] HTTPD_STRING_ATTR = { /* /tcp.shtml */ 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x25, 0x21, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, @@ -91,7 +91,7 @@ const char data_tcp_shtml[228] HTTPD_STRING_ATTR = { 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0a, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e, 0x00}; + 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e}; /* Structure of linked list (all offsets relative to start of section): @@ -113,4 +113,4 @@ const struct httpd_fsdata_file file_tcp_shtml[] HTTPD_STRING_ATTR ={{ fi #define HTTPD_FS_ROOT file_tcp_shtml #define HTTPD_FS_NUMFILES 5 -#define HTTPD_FS_SIZE 764 +#define HTTPD_FS_SIZE 759 diff --git a/apps/webserver/Makefile.webserver b/apps/webserver/Makefile.webserver index fb39f3545..1961da250 100644 --- a/apps/webserver/Makefile.webserver +++ b/apps/webserver/Makefile.webserver @@ -2,5 +2,15 @@ webserver_src = webserver-nogui.c httpd.c http-strings.c psock.c memb.c \ httpd-fs.c httpd-cgi.c webserver_dsc = webserver-dsc.c +#Run makefsdata to regenerate httpd-fsdata.c when web content has been edited. This requires PERL. +# Note: Deleting files or transferring pages from makefsdata.ignore will not trigger this rule +# when there is no change in modification dates. +$(CONTIKI)/apps/webserver/httpd-fsdata.c : $(CONTIKI)/apps/webserver/httpd-fs/*.* + $(CONTIKI)/tools/makefsdata -d $(CONTIKI)/apps/webserver/httpd-fs -o $(CONTIKI)/apps/webserver/httpd-fsdata.c + +#Rebuild httpd-fs.c when makefsdata has changed httpd-fsdata.c +$(CONTIKI)/apps/webserver/httpd-fs.c: $(CONTIKI)/apps/webserver/httpd-fsdata.c + touch $(CONTIKI)/apps/webserver/httpd-fs.c + #$(CONTIKI)/apps/webserver/http-strings.c: $(CONTIKI)/apps/webserver/http-strings # cd $(CONTIKI)/apps/webserver/; $(CONTIKI)/tools/makestrings $< diff --git a/apps/webserver/httpd-fsdata.c b/apps/webserver/httpd-fsdata.c index 02596adf1..83f75855b 100644 --- a/apps/webserver/httpd-fsdata.c +++ b/apps/webserver/httpd-fsdata.c @@ -17,7 +17,7 @@ static const char data_processes_shtml[] = { 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, - 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0}; + 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa}; static const char data_404_html[] = { /* /404.html */ @@ -37,8 +37,7 @@ static const char data_404_html[] = { 0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, - 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, -0}; + 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e}; static const char data_files_shtml[] = { /* /files.shtml */ @@ -119,13 +118,13 @@ static const char data_files_shtml[] = { 0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, - 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0}; + 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c}; static const char data_footer_html[] = { /* /footer.html */ 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, - 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0}; + 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e}; static const char data_header_html[] = { /* /header.html */ @@ -204,8 +203,7 @@ static const char data_header_html[] = { 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0xa, 0x20, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x21, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, -0}; + 0x72, 0x21, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa}; static const char data_index_html[] = { /* /index.html */ @@ -307,7 +305,7 @@ static const char data_index_html[] = { 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0xa, 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, - 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0}; + 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa}; static const char data_style_css[] = { /* /style.css */ @@ -567,8 +565,7 @@ static const char data_style_css[] = { 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x63, 0x62, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, - 0x3b, 0xa, 0xa, 0x7d, 0x20, 0xa, 0xa, 0xa, 0xa, 0xa, -0}; + 0x3b, 0xa, 0xa, 0x7d, 0x20, 0xa, 0xa, 0xa, 0xa, 0xa}; static const char data_tcp_shtml[] = { /* /tcp.shtml */ @@ -593,8 +590,7 @@ static const char data_tcp_shtml[] = { 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63, 0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, - 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, -0}; + 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c}; const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}}; diff --git a/examples/webserver-ipv6-raven/Makefile.webserver b/examples/webserver-ipv6-raven/Makefile.webserver index fb7f12964..24fc0853a 100644 --- a/examples/webserver-ipv6-raven/Makefile.webserver +++ b/examples/webserver-ipv6-raven/Makefile.webserver @@ -7,8 +7,10 @@ UIP_CONF_IPV6=1 #WITH_RPL=1 //RPL is not yet the default. #RF230BB=1 //Use radio driver that communicates with the core MAC layer. Now the default. -#COFFEE_FILES=1 //Use coffee file system in EEPROM -#COFFEE_FILES=2 //Use coffee file system in program flash +#COFFEE_FILES=1 //Static coffee file system in EEPROM +#COFFEE_FILES=2 //Dynamic coffee file system in EEPROM +#COFFEE_FILES=3 //Static coffee file system in program flash +#COFFEE_FILES=4 //Dynamic coffee file system in program flash #COFFEE_ADDRESS=0xnnnn //Override default coffee file system starting address CONTIKI = ../.. diff --git a/tools/makefsdata b/tools/makefsdata index 893bb79d2..4d721b6a5 100755 --- a/tools/makefsdata +++ b/tools/makefsdata @@ -203,7 +203,7 @@ foreach $file (@files) {if ($file eq $includefile) { #--------------------Process data files------------------- $n=0;$coffeesize=0;$coffeesectors=0; foreach $file (@files) {if(-f $file) { - if (length($file)>($coffee_name_length-1)) {die "Aborted: File name $file is too long";} + if (length($file)>=($coffee_name_length-1)) {die "Aborted: File name $file is too long";} if (abs_path("$file") eq abs_path("$outputfile")) { print "Skipping output file $outputfile - recursive input NOT allowed\n"; next; @@ -224,7 +224,7 @@ foreach $file (@files) {if(-f $file) { # $coffee_sectors=sprintf("%.0f",($coffee_header_length+$file_length+$coffee_sector_size-1)/$coffee_sector_size)-1; $coffee_length=$coffee_sectors*$coffee_sector_size; } else { - $coffee_length=$file_length+length($file)+2; + $coffee_length=$file_length+length($file)+1; } $flen[$n]=$file_length; $clen[$n]=$coffee_length; @@ -275,34 +275,40 @@ foreach $file (@files) {if(-f $file) { printf(OUTPUT " %#02.2x,", $temp); } if ($coffee) { - for(; $j < $coffee_name_length; $j++) {printf(OUTPUT " $null,");} + for(; $j < $coffee_name_length-1; $j++) {printf(OUTPUT " $null,");} + {print(OUTPUT " $null");} } else { - {printf(OUTPUT " $null,");} + {printf(OUTPUT " $null");} } - print(OUTPUT "\n$tab"); #------------------File Data--------------------------- $coffee_length-=$coffee_header_length; - $i = 0; + $i = 10; while(read(FILE, $data, 1)) { $temp=unpack("C", $data); if ($complement) {$temp=$temp^0xff;} - printf(OUTPUT " 0x%2.2x,", $temp); - $i++;$coffee_length--; if($i == 10) { - print(OUTPUT "\n$tab"); + printf(OUTPUT ",\n$tab 0x%2.2x", $temp); $i = 0; + } else { + printf(OUTPUT ", 0x%2.2x", $temp) } + $i++;$coffee_length--; } + if ($coffee) { - while (--$coffee_length>1) { - print (OUTPUT " $null,"); - if($i++ == 9) { - print(OUTPUT "\n$tab"); + print (OUTPUT ","); + while (--$coffee_length) { + if($i==9) { + print(OUTPUT " $null,\n$tab"); $i = 0; + } else { + print (OUTPUT " $null,"); + $i++; } } + print (OUTPUT " $null"); } - print (OUTPUT " $null};\n"); + print (OUTPUT "};\n"); close(FILE); push(@fvars, $fvar); push(@pfiles, $file);