blob: 4f119b6a0b87f4bd2d688333bbb8a0d63aa398f4 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 | #!/usr/bin/perl
if ($#ARGV != 0) {
	die "Usage: bin2c <name>";
}
# Slurp all the input
undef $/;
# Create an array of unsigned chars from input
@chars = unpack "C*", <STDIN>;
print "unsigned char $ARGV[0]\[\] = {\n  ";
foreach $char (@chars) {
	printf "0x%02x", $char;
	last if $i == $#chars;
	print ((++$i % 13) ? ", " : ",\n  ");
}
print "};\n";
 |