3 open(OUTPUT, "> fsdata.c");
6 open(FILES, "find . -type f |");
8 while($file = <FILES>) {
10 # Do not include files in CVS directories nor backup files.
11 if($file =~ /(CVS|~)/) {
17 open(HEADER, "> /tmp/header") || die $!;
19 print(HEADER "HTTP/1.0 404 File not found\r\n");
21 print(HEADER "HTTP/1.0 200 OK\r\n");
23 print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n");
24 if($file =~ /\.html$/) {
25 print(HEADER "Content-type: text/html\r\n");
26 } elsif($file =~ /\.gif$/) {
27 print(HEADER "Content-type: image/gif\r\n");
28 } elsif($file =~ /\.png$/) {
29 print(HEADER "Content-type: image/png\r\n");
30 } elsif($file =~ /\.jpg$/) {
31 print(HEADER "Content-type: image/jpeg\r\n");
32 } elsif($file =~ /\.class$/) {
33 print(HEADER "Content-type: application/octet-stream\r\n");
34 } elsif($file =~ /\.ram$/) {
35 print(HEADER "Content-type: audio/x-pn-realaudio\r\n");
37 print(HEADER "Content-type: text/plain\r\n");
42 unless($file =~ /\.plain$/ || $file =~ /cgi/) {
43 system("cat /tmp/header $file > /tmp/file");
45 system("cp $file /tmp/file");
48 open(FILE, "/tmp/file");
50 unlink("/tmp/header");
56 print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
57 print(OUTPUT "\t/* $file */\n\t");
58 for($j = 0; $j < length($file); $j++) {
59 printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
61 printf(OUTPUT "0,\n");
65 while(read(FILE, $data, 1)) {
69 printf(OUTPUT "%#02x, ", unpack("C", $data));
76 print(OUTPUT "};\n\n");
82 for($i = 0; $i < @fvars; $i++) {
89 $prevfile = "file" . $fvars[$i - 1];
91 print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
92 print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
93 print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
96 print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
97 print(OUTPUT "#define FS_NUMFILES $i\n");