FIX bytes highlight ?
[wireshark-wip.git] / doc / eproto2sgml
blobc8c832fa832d1c806cec136e98911d7ba2dc0eef
1 #!/usr/bin/perl
3 # Reads the display filter keyword dump produced by 'wireshark -G' and
4 # formats it as an SGML bulleted list of protocols.
6 # STDIN is the wireshark glossary
7 # arg1 is the pod template file. The =insert_dfilter_table token
8 # will be replaced by the pod-formatted glossary
9 # STDOUT is the output
11 # $Id$
13 # Read all the data into memory
14 while (<STDIN>) {
15 next unless (/^([PF])/);
17 $record_type = $1;
18 chomp($_);
20 # Store protocol information
21 if ($record_type eq 'P') {
22 ($junk, $name, $abbrev) = split(/\t+/, $_);
23 $proto_abbrev{$name} = $abbrev;
25 # Store header field information
26 else {
27 ($junk, $name, $abbrev, $type, $parent) =
28 split(/\t+/, $_);
29 push(@{$field_abbrev{$parent}}, $abbrev);
30 $field_info{$abbrev} = [ $name, $type ];
34 # if there was no input on stdin, bail out
35 if ($record_type ne 'P' and $record_type ne 'F') {
36 exit;
39 $template = shift(@ARGV);
41 open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";
43 while (<TEMPLATE>) {
44 if (/=insert_dfilter_table/) {
45 &create_dfilter_table;
47 else {
48 print;
52 close(TEMPLATE) || die "Can't close $template: $!\n";
54 sub create_dfilter_table {
56 print "<itemizedlist id=\"WiresharkListOfProtos\">\n";
58 # Print each protocol
59 for $proto_name (sort keys %proto_abbrev) {
61 print " <listitem><para>$proto_name</></>\n";
66 print "</itemizedlist>\n";