File: deftoheader.pl

package info (click to toggle)
crossfire-client 1.7.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,696 kB
  • ctags: 2,206
  • sloc: ansic: 24,397; sh: 3,743; makefile: 113; perl: 48
file content (28 lines) | stat: -rw-r--r-- 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);