OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_LPC2368_Rowley/] [webserver/] [makefsdata] - Blame information for rev 866

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
#!/usr/bin/perl
2
 
3
open(OUTPUT, "> httpd-fsdata.c");
4
 
5
chdir("httpd-fs");
6
 
7
opendir(DIR, ".");
8
@files =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
9
closedir(DIR);
10
 
11
foreach $file (@files) {
12
 
13
    if(-d $file && $file !~ /^\./) {
14
        print "Processing directory $file\n";
15
        opendir(DIR, $file);
16
        @newfiles =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
17
        closedir(DIR);
18
        printf "Adding files @newfiles\n";
19
        @files = (@files, map { $_ = "$file/$_" } @newfiles);
20
        next;
21
    }
22
}
23
 
24
foreach $file (@files) {
25
    if(-f $file) {
26
 
27
        print "Adding file $file\n";
28
 
29
        open(FILE, $file) || die "Could not open file $file\n";
30
 
31
        $file =~ s-^-/-;
32
        $fvar = $file;
33
        $fvar =~ s-/-_-g;
34
        $fvar =~ s-\.-_-g;
35
        # for AVR, add PROGMEM here
36
        print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
37
        print(OUTPUT "\t/* $file */\n\t");
38
        for($j = 0; $j < length($file); $j++) {
39
            printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
40
        }
41
        printf(OUTPUT "0,\n");
42
 
43
 
44
        $i = 0;
45
        while(read(FILE, $data, 1)) {
46
            if($i == 0) {
47
                print(OUTPUT "\t");
48
            }
49
            printf(OUTPUT "%#02x, ", unpack("C", $data));
50
            $i++;
51
            if($i == 10) {
52
                print(OUTPUT "\n");
53
                $i = 0;
54
            }
55
        }
56
        print(OUTPUT "0};\n\n");
57
        close(FILE);
58
        push(@fvars, $fvar);
59
        push(@pfiles, $file);
60
    }
61
}
62
 
63
for($i = 0; $i < @fvars; $i++) {
64
    $file = $pfiles[$i];
65
    $fvar = $fvars[$i];
66
 
67
    if($i == 0) {
68
        $prevfile = "NULL";
69
    } else {
70
        $prevfile = "file" . $fvars[$i - 1];
71
    }
72
    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
73
    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
74
    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
75
}
76
 
77
print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
78
print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.