Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Committer:
Michael J. Spencer
Date:
Fri Feb 28 18:52:52 2014 -0800
Revision:
2:1df0b61d3b5a
Update to latest Smoothie.

Who changed what in which revision?

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