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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [uIP_Demo_Rowley_ARM7/] [uip/] [makefsdata] - Blame information for rev 831

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

Line No. Rev Author Line
1 583 jeremybenn
#!/usr/bin/perl
2
 
3
open(OUTPUT, "> fsdata.c");
4
 
5
chdir("fs");
6
open(FILES, "find . -type f |");
7
 
8
while($file = ) {
9
 
10
    # Do not include files in CVS directories nor backup files.
11
    if($file =~ /(CVS|~)/) {
12
        next;
13
    }
14
 
15
    chop($file);
16
 
17
    open(HEADER, "> /tmp/header") || die $!;
18
    if($file =~ /404.html/) {
19
      print(HEADER "HTTP/1.0 404 File not found\r\n");
20
    } else {
21
      print(HEADER "HTTP/1.0 200 OK\r\n");
22
    }
23
    print(HEADER "Server: uIP/0.9 (http://dunkels.com/adam/uip/)\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
    } else {
33
        print(HEADER "Content-type: text/plain\r\n");
34
    }
35
    print(HEADER "\r\n");
36
    close(HEADER);
37
 
38
    unless($file =~ /\.plain$/ || $file =~ /cgi/) {
39
        system("cat /tmp/header $file > /tmp/file");
40
    } else {
41
        system("cp $file /tmp/file");
42
    }
43
 
44
    open(FILE, "/tmp/file");
45
    unlink("/tmp/file");
46
    unlink("/tmp/header");
47
 
48
    $file =~ s/\.//;
49
    $fvar = $file;
50
    $fvar =~ s-/-_-g;
51
    $fvar =~ s-\.-_-g;
52
    print(OUTPUT "static const char data".$fvar."[] = {\n");
53
    print(OUTPUT "\t/* $file */\n\t");
54
    for($j = 0; $j < length($file); $j++) {
55
        printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
56
    }
57
    printf(OUTPUT "0,\n");
58
 
59
 
60
    $i = 0;
61
    while(read(FILE, $data, 1)) {
62
        if($i == 0) {
63
            print(OUTPUT "\t");
64
        }
65
        printf(OUTPUT "%#02x, ", unpack("C", $data));
66
        $i++;
67
        if($i == 10) {
68
            print(OUTPUT "\n");
69
            $i = 0;
70
        }
71
    }
72
    print(OUTPUT "};\n\n");
73
    close(FILE);
74
    push(@fvars, $fvar);
75
    push(@files, $file);
76
}
77
 
78
for($i = 0; $i < @fvars; $i++) {
79
    $file = $files[$i];
80
    $fvar = $fvars[$i];
81
 
82
    if($i == 0) {
83
        $prevfile = "NULL";
84
    } else {
85
        $prevfile = "file" . $fvars[$i - 1];
86
    }
87
    print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
88
    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
89
    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
90
}
91
 
92
print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
93
print(OUTPUT "#define FS_NUMFILES $i");

powered by: WebSVN 2.1.0

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