3 open(OUTPUT, "> httpd-fsdata.c");
\r
8 @files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
\r
11 foreach $file (@files) {
\r
13 if(-d $file && $file !~ /^\./) {
\r
14 print "Processing directory $file\n";
\r
15 opendir(DIR, $file);
\r
16 @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
\r
18 printf "Adding files @newfiles\n";
\r
19 @files = (@files, map { $_ = "$file/$_" } @newfiles);
\r
24 foreach $file (@files) {
\r
27 print "Adding file $file\n";
\r
29 open(FILE, $file) || die "Could not open file $file\n";
\r
35 # for AVR, add PROGMEM here
\r
36 print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
\r
37 print(OUTPUT "\t/* $file */\n\t");
\r
38 for($j = 0; $j < length($file); $j++) {
\r
39 printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
\r
41 printf(OUTPUT "0,\n");
\r
45 while(read(FILE, $data, 1)) {
\r
49 printf(OUTPUT "%#02x, ", unpack("C", $data));
\r
56 print(OUTPUT "0};\n\n");
\r
58 push(@fvars, $fvar);
\r
59 push(@pfiles, $file);
\r
63 for($i = 0; $i < @fvars; $i++) {
\r
64 $file = $pfiles[$i];
\r
70 $prevfile = "file" . $fvars[$i - 1];
\r
72 print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
\r
73 print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
\r
74 print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
\r
77 print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
\r
78 print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");
\r