aboutsummaryrefslogtreecommitdiffstats
path: root/doc/eproto2sgml
blob: 4ffa52a28560b46b0c33775e75b3f438d3386cc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
#
# Reads the display filter keyword dump produced by 'wireshark -G' and
# formats it as an SGML bulleted list of protocols.
#
# STDIN is the wireshark glossary
# arg1 is the pod template file. The =insert_dfilter_table token
#	will be replaced by the pod-formatted glossary
# STDOUT is the output

# Read all the data into memory
while (<STDIN>) {
	next unless (/^([PF])/);

	$record_type = $1;
	chomp($_);

	# Store protocol information
	if ($record_type eq 'P') {
		($junk, $name, $abbrev) = split(/\t+/, $_);
		$proto_abbrev{$name} = $abbrev;
	}
	# Store header field information
	else {
		($junk, $name, $abbrev, $type, $parent) =
			split(/\t+/, $_);
		push(@{$field_abbrev{$parent}}, $abbrev);
		$field_info{$abbrev} = [ $name, $type ];
	}
}

# if there was no input on stdin, bail out
if ($record_type ne 'P' and $record_type ne 'F') {
	exit;
}

$template = shift(@ARGV);

open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";

while (<TEMPLATE>) {
	if (/=insert_dfilter_table/) {
		&create_dfilter_table;
	}
	else {
		print;
	}
}

close(TEMPLATE) || die "Can't close $template: $!\n";

sub create_dfilter_table {

        print "<itemizedlist id=\"WiresharkListOfProtos\">\n";

	# Print each protocol
	for $proto_name (sort keys %proto_abbrev) {

		print "   <listitem><para>$proto_name</></>\n";
	
	
	    }

	print "</itemizedlist>\n";

}