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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [RX600_RX62N-RDK_GNURX/] [RTOSDemo/] [webserver/] [makefsdata] - Blame information for rev 664

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

Line No. Rev Author Line
1 585 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
        binmode FILE;
31
 
32
        $file =~ s-^-/-;
33
        $fvar = $file;
34
        $fvar =~ s-/-_-g;
35
        $fvar =~ s-\.-_-g;
36
        # for AVR, add PROGMEM here
37
        print(OUTPUT "static const char data".$fvar."[] = {\n");
38
        print(OUTPUT "\t/* $file */\n\t");
39
        for($j = 0; $j < length($file); $j++) {
40
            printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
41
        }
42
        printf(OUTPUT "0,\n");
43
 
44
 
45
        $i = 0;
46
        while(read(FILE, $data, 1)) {
47
            if($i == 0) {
48
                print(OUTPUT "\t");
49
            }
50
            printf(OUTPUT "%#02x, ", unpack("C", $data));
51
            $i++;
52
            if($i == 10) {
53
                print(OUTPUT "\n");
54
                $i = 0;
55
            }
56
        }
57
        print(OUTPUT "0};\n\n");
58
        close(FILE);
59
        push(@fvars, $fvar);
60
        push(@pfiles, $file);
61
    }
62
}
63
 
64
for($i = 0; $i < @fvars; $i++) {
65
    $file = $pfiles[$i];
66
    $fvar = $fvars[$i];
67
 
68
    if($i == 0) {
69
        $prevfile = "NULL";
70
    } else {
71
        $prevfile = "file" . $fvars[$i - 1];
72
    }
73
    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
74
    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
75
    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
76
}
77
 
78
print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
79
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.