PDOS

[uia] / trunk / uia / vxa / bin2c.pl  

View of /trunk/uia/vxa/bin2c.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2005 - (download) (as text) (annotate)
Wed Apr 4 19:58:39 2007 UTC (2 years, 7 months ago) by baford
File size: 688 byte(s)
Moved vx32/vxa trees into correct locations
#!/usr/bin/perl
#
# Copyright 2005 Bryan Ford
# Distributed under the GNU General Public License.
#
# Usage: bin2c <name>
#
# This script reads an arbitrary binary file from standard input
# and writes it to standard output as a global array in C source code,
# so that the binary file can be linked into a program as static data.
# The array has the name <name>.
#

if ($#ARGV != 0) {
	die "Usage: bin2c <name>";
}

print "unsigned char $ARGV[0]_data[] = {\n";

$len = 0;
while (($n = read STDIN, $str, 10) > 0) {

	print "\t";
	foreach $i (0 .. $n-1) {
		print ord(substr($str, $i, 1)), ", ";
	}
	print "\n";

	$len += $n;
}

print "};\n";
print "const int $ARGV[0]_length = $len;\n";


Maintained by PDOS
ViewVC Help
Powered by ViewVC 1.0.3