3 # Script to convert "x11-fields" file, listing fields for
4 # X11 dissector, into header files declaring field-index
5 # values and field definitions for those fields.
7 # Copyright 2000, Christophe Tronche <ch.tronche[AT]computer.org>
11 # Wireshark - Network traffic analyzer
12 # By Gerald Combs <gerald@wireshark.org>
13 # Copyright 1998 Gerald Combs
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 open(DECL
, ">x11-declarations.h") || die;
31 open(REG
, ">x11-register-info.h") || die;
33 sub add_generated_header
{
37 /* Do not modify this file. */
38 /* It was automatically generated by $0. */
41 # Since this file is checked in, add its SVN revision
42 print $out "/* \$"."Id"."\$ */\n\n";
47 * Copyright 2000, Christophe Tronche <ch.tronche[AT]computer.org>
49 * Wireshark - Network traffic analyzer
50 * By Gerald Combs <gerald[AT]wireshark.org>
51 * Copyright 1998 Gerald Combs
53 * This program is free software; you can redistribute it and/or modify
54 * it under the terms of the GNU General Public License as published by
55 * the Free Software Foundation; either version 2 of the License, or
56 * (at your option) any later version.
58 * This program is distributed in the hope that it will be useful,
59 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 * GNU General Public License for more details.
63 * You should have received a copy of the GNU General Public License along
64 * with this program; if not, write to the Free Software Foundation, Inc.,
65 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
72 add_generated_header
(DECL
);
73 add_generated_header
(REG
);
76 $subfieldStringLength = 0;
84 if (length $subfield != $subfieldStringLength) {
85 if (!length $subfield) {
87 } elsif (length $subfield > $subfieldStringLength) {
88 $prefix .= "$lastAbbrev.";
90 $prefix =~ s/^(.*)\.[^\.]+\.$/$1./o;
92 $subfieldStringLength = length $subfield;
95 @fields = split /\s+/o ;
96 if ($fields[0] eq '#') {
98 # If the line begins with "#", treat it as a comment, by
101 # (We don't support comments at the end of a line; that would
102 # require some more pain in our simple parser.)
106 $abbrev = shift @fields;
107 $type = shift @fields;
108 $lastAbbrev = $abbrev;
110 $field = $prefix.$abbrev;
112 if ($fields[0] =~ /^\d+$/o) {
114 # This is presumably a Boolean bitfield, and this is the number
115 # of bits in the parent field.
117 $fieldDisplay = shift @fields;
120 # The next token is the base for the field.
122 $fieldDisplay = "BASE_".shift @fields;
125 if ($fields[0] eq 'VALS') {
127 # It's an enumerated field, with the value_string table having a
128 # name based on the field's name.
131 $fieldStrings = "VALS(${abbrev}_vals)";
132 $fieldStrings =~ s/-/_/go;
133 } elsif ($fields[0] =~ /^VALS\(/o) {
135 # It's an enumerated field, with a specified name for the
136 # value_string table.
138 $fieldStrings = shift @fields;
139 $fieldStrings =~ s/\)/_vals\)/o;
142 # It's not an enumerated field.
144 $fieldStrings = 'NULL';
147 if ($fields[0] =~ /^0x/) {
149 # The next token looks like a bitmask for a bitfield.
151 $mask = shift @fields;
156 $rest = join(' ', @fields);
157 $longName = uc $name;
158 $longName = $rest if ($rest);
159 # Don't allow empty blurbs
160 $longName = $longName eq "" ?
"NULL" : "\"$longName\"";
163 $variable =~ s/-/_/go;
164 $variable =~ s/\./_/go;
166 print DECL
"static int hf_x11_$variable = -1;\n";
169 { &hf_x11_$variable, { "$abbrev", "x11.$field", FT_$type, $fieldDisplay, $fieldStrings, $mask, $longName, HFILL }},