1
#******************************************************************************
2
# $Id: mk-string-arrays.pl,v 1.5 2003/01/23 00:37:23 robertc Exp $
6
# Author: Max Okumoto <okumoto@ucsd.edu>
8
# Abstract: This perl script parses enums and builds an array of
11
# Warning: The parser is very simplistic, and will prob not work for
12
# things other than squid.
13
#******************************************************************************
15
$pat{'err_type'} = "err_type_str";
16
$pat{'icp_opcode'} = "icp_opcode_str";
17
$pat{'swap_log_op'} = "swap_log_op_str";
18
$pat{'lookup_t'} = "lookup_t_str";
20
$state = 0; # start state
23
# Looking for start of typedef
24
if (/^typedef enum /) {
25
$count = 0; # enum index
30
} elsif ($state == 1) {
31
# Looking for end of typedef
33
($b, $t) = split(/[ \t;]/, $_);
34
if (defined($pat{$t})) {
35
print "const char *$pat{$t}\[\] = \n";
37
for ($i = 0; $i < $count; $i++) {
38
printf "\t\"%s\"%s\n",
40
$i == $count - 1 ? '' : ',';
47
($e) = split(' ', $_);