/usr/lib/crossfire/crossfire/mktable.script is in crossfire-server 1.71.0+dfsg1-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #!/usr/bin/perl
# mktable - generate:
# 1. struct <def-file>_type
# 2. table <def-file>_table
# 3. table size <def-file>_size
# 3. enum-list <def-file>_enum, enumerator from given names
# from one definition file
#
# definition file:
# ^# hashes are allowed as comments in begining of line
# ^# first line declares type-member pairs separated by slash
# ^# typenames have to be in one part eg. "struct type" don't
# ^# work, typedef these instead.
# ^ type1/member1 type2/memeber2
# ^
# ^# in data lines, exist first name of row and then members
# ^# of struct in order. The name may not enclose in "'s althought
# ^# its type is char *.
# ^ name member1 member2
# ^ name ... ...
# ^ ...
#
if( ! $ARGV[0] ) {
print "Usage: mktable definition-file\n";
exit(2);
} else {
$def = $ARGV[0];
}
open(DEF,$def) || die("Can't open ".$def);
$line = 0;
$elems = 0;
%table;
print "/* should not be modified */\n\n";
&loop;
sub loop {
while(<DEF>) {
chop;
next if /^$/;
next if /^[\t ]*#/;
$line++;
@tuple = split;
shift @tuple if $tuple[0] eq "";
if($line == 1) {
print "typedef struct {\n";
print "\tchar\t*key;\n";
foreach $field (@tuple) {
# print "\"$field\"\n";
last if $field eq "empty";
($type,$mem) = split(/\//,$field);
print "\t$type\t$mem;\n";
}
print "} ".$def."_type;\n\n";
} else {
$elems++;
$key = shift(@tuple);
$val = join(":",@tuple);
$table{$key} = $val;
}
}
# size
print "#define\t".$def."_size\t$elems\n\n";
# table
print "/* sorted */\n";
print $def."_type ".$def."_table[] = {\n";
foreach $key (sort(keys(%table))) {
print "\t\"$key\",\t";
foreach $mem (split(/:/,$table{$key})) {
print "$mem,\t";
}
print "\n";
}
print "}; /* ".$def."_table */\n\n";
# enum
print "typedef enum {\n";
foreach $key (sort(keys(%table))) {
print "\tinput_".$key.",\n";
}
print "} "."$def"."_enum;\n\n";
}
|