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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [ethernet/] [uIP/] [uip-1.0/] [apps/] [webserver/] [makestrings] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
#!/usr/bin/perl
2
 
3
 
4
sub stringify {
5
  my $name = shift(@_);
6
  open(OUTPUTC, "> $name.c");
7
  open(OUTPUTH, "> $name.h");
8
 
9
  open(FILE, "$name");
10
 
11
  while() {
12
    if(/(.+) "(.+)"/) {
13
      $var = $1;
14
      $data = $2;
15
 
16
      $datan = $data;
17
      $datan =~ s/\\r/\r/g;
18
      $datan =~ s/\\n/\n/g;
19
      $datan =~ s/\\01/\01/g;
20
      $datan =~ s/\\0/\0/g;
21
 
22
      printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
23
      printf(OUTPUTC "/* \"$data\" */\n");
24
      printf(OUTPUTC "{");
25
      for($j = 0; $j < length($datan); $j++) {
26
        printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
27
      }
28
      printf(OUTPUTC "};\n");
29
 
30
      printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
31
 
32
    }
33
  }
34
  close(OUTPUTC);
35
  close(OUTPUTH);
36
}
37
stringify("http-strings");
38
 
39
exit 0;
40
 

powered by: WebSVN 2.1.0

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