Author: jelmer
Date: 2005-09-09 10:30:19 +0000 (Fri, 09 Sep 2005)
New Revision: 10110

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10110

Log:
Add some more warnings, implement FIELD_DESCRIPTION

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
   branches/SAMBA_4_0/source/pidl/pidl.1.xml


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm       
2005-09-09 10:29:12 UTC (rev 10109)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/Conformance.pm       
2005-09-09 10:30:19 UTC (rev 10110)
@@ -14,12 +14,31 @@
 
 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_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 
($data,$index,$name,$filter,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_;
+       my $t = shift;
+       return 0 unless($t =~ /^BASE_.*/);
+       return 1;
+}
 
+sub valid_ft_type($)
+{
+       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_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_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_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,19 +212,18 @@
                        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})) {
                        print "$f:$ln: Warning: Unknown command `$cmd'\n";
                        next;
                }
                
-               $field_handlers{$cmd}($data, @fields);
+               $field_handlers{$cmd}("$f:$ln", $data, @fields);
        }
 
        close(IN);

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm       
2005-09-09 10:29:12 UTC (rev 10109)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm       
2005-09-09 10:30:19 UTC (rev 10110)
@@ -826,6 +826,12 @@
                BLURB => $blurb
        };
 
+       if ((not defined($blurb) or $blurb eq "") and 
+                       defined($conformance->{fielddescription}->{$index})) {
+               $conformance->{header_fields}->{$index}->{BLURB} = 
+                       $conformance->{fielddescription}->{$index};
+       }
+
        return $index;
 }
 

Modified: branches/SAMBA_4_0/source/pidl/pidl.1.xml
===================================================================
--- branches/SAMBA_4_0/source/pidl/pidl.1.xml   2005-09-09 10:29:12 UTC (rev 
10109)
+++ branches/SAMBA_4_0/source/pidl/pidl.1.xml   2005-09-09 10:30:19 UTC (rev 
10110)
@@ -541,8 +541,8 @@
 
 <varlistentry>
        <term>FIELD_DESCRIPTION field desc</term>
-       <listitem><para>Change description for the specified header field. 
-       Not implemented yet.</para></listitem>
+       <listitem><para>Change description for the specified header field. 
`field' is the hf name of the field.
+       </para></listitem>
 </varlistentry>
 
 <varlistentry>

Reply via email to