From 79f476a1126cc1426eb7f42d9d2b1f63051e69b1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 9 Sep 2005 10:30:19 +0000 Subject: r10110: Add some more warnings, implement FIELD_DESCRIPTION (This used to be commit 1caeb3238dac6321bde8e254a8efaf090b4d56b0) --- .../pidl/lib/Parse/Pidl/Ethereal/Conformance.pm | 106 +++++++++++++++++---- source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm | 6 ++ source4/pidl/pidl.1.xml | 4 +- 3 files changed, 93 insertions(+), 23 deletions(-) (limited to 'source4/pidl') diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm index 7ba6af3815..9e6147b166 100644 --- a/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm +++ b/source4/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm @@ -14,12 +14,31 @@ use strict; use Parse::Pidl::Util qw(has_property); -sub handle_type($$$$$$$$) +sub handle_type($$$$$$$$$$) { - my ($data,$name,$dissectorname,$ft_type,$base_type,$mask,$valsstring,$alignment) = @_; + my ($pos,$data,$name,$dissectorname,$ft_type,$base_type,$mask,$valsstring,$alignment) = @_; + + unless(defined($alignment)) { + print "$pos: error incomplete TYPE command\n"; + return; + } + + unless ($dissectorname =~ /.*dissect_.*/) { + print "$pos: warning: dissector name does not contain `dissect'\n"; + } + + unless(valid_ft_type($ft_type)) { + print "$pos: warning: invalid FT_TYPE `$ft_type'\n"; + } + + unless(alid_base_type($base_type)) { + print "$pos: warning: invalid BASE_TYPE `$base_type'\n"; + } $data->{types}->{$name} = { NAME => $name, + POS => $pos, + USED => 0, DISSECTOR_NAME => $dissectorname, FT_TYPE => $ft_type, BASE_TYPE => $base_type, @@ -29,25 +48,65 @@ sub handle_type($$$$$$$$) }; } -sub handle_hf_rename($$$) +sub handle_hf_rename($$$$) { - my ($data,$old,$new) = @_; - $data->{hf_renames}{$old} = $new; + my ($pos,$data,$old,$new) = @_; + + unless(defined($new)) { + print "$pos: error incomplete HF_RENAME command\n"; + return; + } + + $data->{hf_renames}->{$old} = $new; } -sub handle_param_value($$$) +sub handle_param_value($$$$) { - my ($data,$dissector_name,$value) = @_; + my ($pos,$data,$dissector_name,$value) = @_; + + unless(defined($value)) { + print "$pos: error: incomplete PARAM_VALUE command\n"; + return; + } $data->{dissectorparams}->{$dissector_name} = $value; } -sub handle_hf_field($$$$$$$$$) +sub valid_base_type($) +{ + my $t = shift; + return 0 unless($t =~ /^BASE_.*/); + return 1; +} + +sub valid_ft_type($) { - my ($data,$index,$name,$filter,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_; + my $t = shift; + return 0 unless($t =~ /^FT_.*/); + return 1; +} + +sub handle_hf_field($$$$$$$$$$) +{ + my ($pos,$data,$index,$name,$filter,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_; + + unless(defined($blurb)) { + print "$pos: error: incomplete HF_FIELD command\n"; + return; + } + + unless(valid_ft_type($ft_type)) { + print "$pos: warning: invalid FT_TYPE `$ft_type'\n"; + } + + unless(valid_base_type($base_type)) { + print "$pos: warning: invalid BASE_TYPE `$base_type'\n"; + } $data->{header_fields}->{$index} = { INDEX => $index, + POS => $pos, + USED => 0, NAME => $name, FILTER => $filter, FT_TYPE => $ft_type, @@ -58,16 +117,16 @@ sub handle_hf_field($$$$$$$$$) }; } -sub handle_strip_prefix($$) +sub handle_strip_prefix($$$) { - my ($data,$x) = @_; + my ($pos,$data,$x) = @_; push (@{$data->{strip_prefixes}}, $x); } -sub handle_noemit($$) +sub handle_noemit($$$) { - my ($data) = shift; + my ($pos,$data) = @_; my $type; $type = shift if ($#_ == 1); @@ -79,9 +138,9 @@ sub handle_noemit($$) } } -sub handle_protocol($$$$$) +sub handle_protocol($$$$$$) { - my ($data, $name, $longname, $shortname, $filtername) = @_; + my ($pos, $data, $name, $longname, $shortname, $filtername) = @_; $data->{protocols}->{$name} = { LONGNAME => $longname, @@ -90,18 +149,24 @@ sub handle_protocol($$$$$) }; } -sub handle_fielddescription($$$) +sub handle_fielddescription($$$$) { - my ($data,$field,$desc) = @_; + my ($pos,$data,$field,$desc) = @_; $data->{fielddescription}->{$field} = $desc; } sub handle_import { + my $pos = shift @_; my $data = shift @_; my $dissectorname = shift @_; + unless(defined($dissectorname)) { + print "$pos: error: no dissectorname specified\n"; + return; + } + $data->{imports}->{$dissectorname} = join(' ', @_); } @@ -147,11 +212,10 @@ sub ReadConformance($$) next; } - my @fields = split(/([^ ]+|"[^"]+")/); + my @fields = /([^ "]+|"[^"]+")/g; - my $cmd = $fields[1]; + my $cmd = $fields[0]; - shift @fields; shift @fields; if (not defined($field_handlers{$cmd})) { @@ -159,7 +223,7 @@ sub ReadConformance($$) next; } - $field_handlers{$cmd}($data, @fields); + $field_handlers{$cmd}("$f:$ln", $data, @fields); } close(IN); diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm index 315c31a6f6..119dc46707 100644 --- a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm @@ -826,6 +826,12 @@ sub register_hf_field($$$$$$$$) BLURB => $blurb }; + if ((not defined($blurb) or $blurb eq "") and + defined($conformance->{fielddescription}->{$index})) { + $conformance->{header_fields}->{$index}->{BLURB} = + $conformance->{fielddescription}->{$index}; + } + return $index; } diff --git a/source4/pidl/pidl.1.xml b/source4/pidl/pidl.1.xml index 8641d17e68..a379dced1f 100644 --- a/source4/pidl/pidl.1.xml +++ b/source4/pidl/pidl.1.xml @@ -541,8 +541,8 @@ The following commands are currently supported: FIELD_DESCRIPTION field desc - Change description for the specified header field. - Not implemented yet. + Change description for the specified header field. `field' is the hf name of the field. + -- cgit