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 # Instructions for using this script are in epan/dissectors/README.X11
9 # 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 # SPDX-License-Identifier: GPL-2.0-or-later
21 die "'$srcdir' is not a directory" unless -d
$srcdir;
23 open(DECL
, "> $srcdir/x11-declarations.h") || die;
24 open(REG
, "> $srcdir/x11-register-info.h") || die;
26 my $script_name = File
::Spec
->abs2rel ($0, $srcdir);
28 sub add_generated_header
{
32 /* Do not modify this file. */
33 /* It was automatically generated by $script_name. */
40 * Copyright 2000, Christophe Tronche <ch.tronche[AT]computer.org>
42 * Wireshark - Network traffic analyzer
43 * By Gerald Combs <gerald[AT]wireshark.org>
44 * Copyright 1998 Gerald Combs
46 * SPDX-License-Identifier: GPL-2.0-or-later
53 add_generated_header
(DECL
);
54 add_generated_header
(REG
);
57 $subfieldStringLength = 0;
65 if (length $subfield != $subfieldStringLength) {
66 if (!length $subfield) {
68 } elsif (length $subfield > $subfieldStringLength) {
69 $prefix .= "$lastAbbrev.";
71 $prefix =~ s/^(.*)\.[^\.]+\.$/$1./o;
73 $subfieldStringLength = length $subfield;
76 @fields = split /\s+/o ;
77 if ($fields[0] eq '#') {
79 # If the line begins with "#", treat it as a comment, by
82 # (We don't support comments at the end of a line; that would
83 # require some more pain in our simple parser.)
87 $abbrev = shift @fields;
88 $type = shift @fields;
89 $lastAbbrev = $abbrev;
91 $field = $prefix.$abbrev;
93 if ($fields[0] =~ /^\d+$/o) {
95 # This is presumably a Boolean bitfield, and this is the number
96 # of bits in the parent field.
98 $fieldDisplay = shift @fields;
101 # The next token is the base for the field.
103 $fieldDisplay = "BASE_".shift @fields;
106 if ($fields[0] eq 'VALS') {
108 # It's an enumerated field, with the value_string table having a
109 # name based on the field's name.
112 $fieldStrings = "VALS(${abbrev}_vals)";
113 $fieldStrings =~ s/-/_/go;
114 } elsif ($fields[0] =~ /^VALS\(/o) {
116 # It's an enumerated field, with a specified name for the
117 # value_string table.
119 $fieldStrings = shift @fields;
120 $fieldStrings =~ s/\)/_vals\)/o;
123 # It's not an enumerated field.
125 $fieldStrings = 'NULL';
128 if ($fields[0] =~ /^0x/) {
130 # The next token looks like a bitmask for a bitfield.
132 $mask = shift @fields;
137 $rest = join(' ', @fields);
138 $longName = uc $name;
139 $longName = $rest if ($rest);
140 # Don't allow empty blurbs
141 $longName = $longName eq "" ?
"NULL" : "\"$longName\"";
144 $variable =~ s/-/_/go;
145 $variable =~ s/\./_/go;
147 print DECL
"static int hf_x11_$variable;\n";
150 { &hf_x11_$variable, { "$abbrev", "x11.$field", FT_$type, $fieldDisplay, $fieldStrings, $mask, $longName, HFILL }},
160 # indent-tabs-mode: nil
163 # ex: set shiftwidth=4 tabstop=8 expandtab:
164 # :indentSize=4:tabSize=8:noTabs=true: