aboutsummaryrefslogtreecommitdiffstats
path: root/process-x11-fields.pl
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-04-20 04:16:19 +0000
committerGuy Harris <guy@alum.mit.edu>2001-04-20 04:16:19 +0000
commit986bd7f26198ca2a5973e5b11c4477c2717cc64f (patch)
tree94b73cee3d42afba183c66edf640d0e69553d9d1 /process-x11-fields.pl
parentc16aaa518b8752b511a44884a9b73102c7d7cf09 (diff)
Check in the file used to define fields for the X11 dissector, and the
Perl script that generates them, so that if we have to change those fields we can do so more conveniently. Remove the generated header files from CVS, and arrange that we generate them when we do a build. svn path=/trunk/; revision=3341
Diffstat (limited to 'process-x11-fields.pl')
-rw-r--r--process-x11-fields.pl65
1 files changed, 65 insertions, 0 deletions
diff --git a/process-x11-fields.pl b/process-x11-fields.pl
new file mode 100644
index 0000000000..219ca5ee7e
--- /dev/null
+++ b/process-x11-fields.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+
+open(DECL, ">x11-declarations.h") || die;
+open(REG, ">x11-register-info.h") || die;
+
+$prefix = '';
+$subfieldStringLength = 0;
+
+while(<>) {
+ s/#.*$//go;
+ next if /^\s*$/o;
+ s/^(\s*)//o;
+ $subfield = $1;
+
+ if (length $subfield != $subfieldStringLength) {
+ if (!length $subfield) {
+ $prefix = '';
+ } elsif (length $subfield > $subfieldStringLength) {
+ $prefix .= "$lastAbbrev.";
+ } else {
+ $prefix =~ s/^(.*)\.[^\.]+\.$/$1./o;
+ }
+ $subfieldStringLength = length $subfield;
+ }
+
+ ($abbrev, $type, $presentation, $field4) = split /\s+/o;
+ $lastAbbrev = $abbrev;
+
+ $field = $prefix.$abbrev;
+
+ if ($presentation =~ /^VALS/) {
+ $fieldBase = 'BASE_NONE';
+ } elsif ($presentation =~ /^\d+$/o) {
+ $fieldBase = $presentation;
+ } else {
+ $fieldBase = "BASE_$presentation";
+ }
+
+ if ($presentation eq 'VALS') {
+ $fieldConvert = "VALS(${abbrev}_vals)";
+ $fieldConvert =~ s/-/_/go;
+ } elsif ($presentation =~ /^VALS\(/o) {
+ $fieldConvert = $presentation;
+ $fieldConvert =~ s/\)/_vals\)/o;
+ } else {
+ $fieldConvert = 'NULL';
+ }
+
+ $mask = 0;
+ $mask = $field4 if $subfield;
+ $mask = 0 unless $mask =~ /\d+/o;
+
+ $longName = uc $name;
+ $longName = $field4 if ($field4 && !$subfield);
+
+ $variable = $field;
+ $variable =~ s/-/_/go;
+ $variable =~ s/\./_/go;
+
+ print DECL "static int hf_x11_$variable = -1;\n";
+
+ print REG <<END;
+{ &hf_x11_$variable, { "$abbrev", "x11.$field", FT_$type, $fieldBase, $fieldConvert, $mask, "$longName" } },
+END
+}