r9168: Fix subcontext handling
authorJelmer Vernooij <jelmer@samba.org>
Sat, 6 Aug 2005 23:41:18 +0000 (23:41 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:31:27 +0000 (13:31 -0500)
Support fixed-size arrays
Give some more nicer warnings for not-supported IDL constructions such as inline arrays
Fix signed int-handling
(This used to be commit 2f1fcf3bc7a29e3089f1edafd45c70488f3cd565)

source4/build/pidl/Parse/Pidl/Ethereal/Conformance.pm
source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm

index 19c8ff2563944767ca429d25fc9e31f3139e3e57..45654fe6aade402b16eda5e344040ff71844162c 100644 (file)
@@ -91,6 +91,14 @@ sub handle_fielddescription($$$)
        $data->{fielddescription}->{$field} = $desc;
 }
 
+sub handle_import
+{
+       my $data = shift @_;
+       my $dissectorname = shift @_;
+
+       $data->{imports}->{$dissectorname} = join(' ', @_);
+}
+
 my %field_handlers = (
        TYPE => \&handle_type,
        NOEMIT => \&handle_noemit, 
@@ -99,7 +107,8 @@ my %field_handlers = (
        HF_RENAME => \&handle_hf_rename, 
        STRIP_PREFIX => \&handle_strip_prefix,
        PROTOCOL => \&handle_protocol,
-       FIELD_DESCRIPTION => \&handle_fielddescription
+       FIELD_DESCRIPTION => \&handle_fielddescription,
+       IMPORT => \&handle_import
 );
 
 sub ReadConformance($$)
index 41c243f47ac8f6bbc1b189d57f500caad6412284..070297fb0464042031cecfa6511906f3a7658f59 100644 (file)
@@ -6,10 +6,6 @@
 # Portions based on idl2eth.c by Ronnie Sahlberg
 # released under the GNU GPL
 
-# TODO:
-#  - more built-in types:
-#    sec_desc_buf -> lsa_dissect_sec_desc_buf
-
 package Parse::Pidl::Ethereal::NDR;
 
 use strict;
@@ -21,7 +17,7 @@ use Parse::Pidl::Ethereal::Conformance qw(ReadConformance);
 
 my %types;
 
-my $conformance = {};
+my $conformance = {imports=>{}};
 
 my %ptrtype_mappings = (
        "unique" => "NDR_POINTER_UNIQUE",
@@ -221,6 +217,12 @@ sub ElementLevel($$$$$)
 {
        my ($e,$l,$hf,$myname,$pn) = @_;
 
+       my $param = 0;
+
+       if (defined($conformance->{dissectorparams}->{$myname})) {
+               $param = $conformance->{dissectorparams}->{$myname};
+       }
+
        if ($l->{TYPE} eq "POINTER") {
                my $type;
                if ($l->{LEVEL} eq "TOP") {
@@ -248,29 +250,39 @@ sub ElementLevel($$$$$)
                }
        } elsif ($l->{TYPE} eq "DATA") {
                if ($l->{DATA_TYPE} eq "string") {
-                       my $bs = 2;
+                       my $bs = 2; # Byte size defaults to that of UCS2
 
-                       if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_ASCII.*")) {
-                               $bs = 1;
-                       }
+
+                       ($bs = 1) if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_ASCII.*"));
                        
                        if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) {
                                pidl_code "offset=dissect_ndr_cvstring(tvb,offset,pinfo,tree,drep,$bs,$hf,FALSE,NULL);";
-                       } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_LEN4.*")) {
+                       } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) {
                                pidl_code "offset=dissect_ndr_vstring(tvb,offset,pinfo,tree,drep,$bs,$hf,FALSE,NULL);";
+                       } else {
+                               warn("Unable to handle string with flags $e->{PROPERTIES}->{flags}");
                        }
-               } elsif (defined($types{$l->{DATA_TYPE}})) {
-                       my $param = 0;
-                       if (defined($conformance->{dissectorparams}->{$myname})) {
-                               $param = $conformance->{dissectorparams}->{$myname};
-                       }
-                       my $x = $types{$l->{DATA_TYPE}}->{CALL};
-                       $x =~ s/\@HF\@/$hf/g;
-                       $x =~ s/\@PARAM\@/$param/g;
-                       pidl_code "$x";
                } else {
-                       warn("Unknown data type `$l->{DATA_TYPE}'");
-                       pidl_code "/* FIXME: Handle unknown data type $l->{DATA_TYPE} */";
+                       my $call;
+
+                       if (defined($types{$l->{DATA_TYPE}})) {
+                               $call= $types{$l->{DATA_TYPE}}->{CALL};
+                       } elsif ($conformance->{imports}->{$l->{DATA_TYPE}}) {
+                               $call = $conformance->{imports}->{$l->{DATA_TYPE}};     
+                       } else {
+                               warn("Unknown data type `$l->{DATA_TYPE}'");
+                               pidl_code "/* FIXME: Handle unknown data type $l->{DATA_TYPE} */";
+                               if ($l->{DATA_TYPE} =~ /^([a-z]+)\_(.*)$/)
+                               {
+                                       pidl_code "offset=$1_dissect_$2(tvb,offset,pinfo,tree,drep,$hf,$param);";
+                               }
+
+                               return;
+                       }
+
+                       $call =~ s/\@HF\@/$hf/g;
+                       $call =~ s/\@PARAM\@/$param/g;
+                       pidl_code "$call";
                }
        } elsif ($_->{TYPE} eq "SUBCONTEXT") {
                my $num_bits = ($l->{HEADER_SIZE}*8);