3 open(OUTPUT
, "> httpd-fsdata.c");
8 @files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR
);
11 foreach $file (@files) {
13 if(-d
$file && $file !~ /^\./) {
14 print "Processing directory $file\n";
16 @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR
);
18 printf "Adding files @newfiles\n";
19 @files = (@files, map { $_ = "$file/$_" } @newfiles);
24 foreach $file (@files) {
27 print "Adding file $file\n";
29 open(FILE
, $file) || die "Could not open file $file\n";
30 if (grep /.png/,$file) {binmode FILE
;}
31 if (grep /.jpg/,$file) {binmode FILE
;}
32 if (grep /.gif/,$file) {binmode FILE
;}
38 # for AVR, add PROGMEM here
39 print(OUTPUT
"static const char data".$fvar."[] PROGMEM = {\n");
40 print(OUTPUT
"\t/* $file */\n\t");
41 for($j = 0; $j < length($file); $j++) {
42 printf(OUTPUT
"%#02x, ", unpack("C", substr($file, $j, 1)));
44 printf(OUTPUT
"0,\n");
48 while(read(FILE
, $data, 1)) {
52 printf(OUTPUT
"%#02x, ", unpack("C", $data));
59 print(OUTPUT
"0};\n\n");
66 for($i = 0; $i < @fvars; $i++) {
73 $prevfile = "file" . $fvars[$i - 1];
75 # for AVR, add PROGMEM here
76 print(OUTPUT
"const struct httpd_fsdata_file file".$fvar."[] PROGMEM = {{$prevfile, data$fvar, ");
77 print(OUTPUT
"data$fvar + ". (length($file) + 1) .", ");
78 print(OUTPUT
"sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
81 print(OUTPUT
"#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
82 print(OUTPUT
"#define HTTPD_FS_NUMFILES $i\n");