File: deftoheader.pl

package info (click to toggle)
crossfire-client 0.95.4-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,028 kB
  • ctags: 1,144
  • sloc: ansic: 11,408; sh: 1,885; makefile: 237; perl: 48
file content (28 lines) | stat: -rwxr-xr-x 682 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/local/bin/perl
#
# This program takes some file and encapsulates it into a header file
# as a giant string.
#
# It takes three options <infile> <outfile> <enscapsulation string>.
# the encapsulation string is what string the script uses to encapsulate
# the data.
#

if ($#ARGV!=2) {
	print "Usage: $0 <infile> <outfile> <enscapsulation>\n";
	exit;
}

open(INFILE, "<$ARGV[0]") || die("can not open $ARGV[0]\n");
open(OUTFILE, ">$ARGV[1]") || die("can not open $ARGV[1]\n");

print OUTFILE "char *$ARGV[2]\[\] = {\n";
while (<INFILE>) {
	chomp;
	s/\"/\\\"/g;
	print OUTFILE "\"$_\\n\",\n";
}
print OUTFILE "};\n";
print "$. lines processed\n";
close(INFILE);
close(OUTFILE);