]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mk-string-arrays.pl
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / mk-string-arrays.pl
CommitLineData
bbc27441
AJ
1#
2## Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3##
4## Squid software is distributed under GPLv2+ license and includes
5## contributions from numerous individuals and organizations.
6## Please see the COPYING and CONTRIBUTORS files for details.
7##
8
c0ba22d5 9#******************************************************************************
c0ba22d5 10# File: mk-strs.pl
11#
12# Author: Max Okumoto <okumoto@ucsd.edu>
13#
14# Abstract: This perl script parses enums and builds an array of
15# printable strings.
16#
17# Warning: The parser is very simplistic, and will prob not work for
18# things other than squid.
19#******************************************************************************
20
21$pat{'err_type'} = "err_type_str";
22$pat{'icp_opcode'} = "icp_opcode_str";
d9b6855b 23$pat{'swap_log_op'} = "swap_log_op_str";
74fd842e 24$pat{'lookup_t'} = "lookup_t_str";
c0ba22d5 25
26$state = 0; # start state
27while (<>) {
28 if ($state == 0) {
29 # Looking for start of typedef
30 if (/^typedef enum /) {
31 $count = 0; # enum index
32 $state = 1;
33 }
34 next;
35
36 } elsif ($state == 1) {
37 # Looking for end of typedef
38 if (/^} /) {
39 ($b, $t) = split(/[ \t;]/, $_);
40 if (defined($pat{$t})) {
29ca60c9 41 print "const char *$pat{$t}\[\] = \n";
c0ba22d5 42 print "{\n";
43 for ($i = 0; $i < $count; $i++) {
44 printf "\t\"%s\"%s\n",
45 $ea[$i],
46 $i == $count - 1 ? '' : ',';
47 }
48 print "};\n";
49 print "\n";
50 }
51 $state = 0;
52 } else {
53 ($e) = split(' ', $_);
54 $e =~ s/,//;
55 $ea[$count] = $e;
56 $count++;
57 }
58 next;
59 }
60}
61
62exit 0;