summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-14 19:57:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:44:44 -0500
commit8a58b806e90b177107cb6a21ab43a88ff8516ec8 (patch)
treee5e27d4e82d843392aeb1a52396ee9c1e2d154e8 /source4/pidl/lib/Parse
parent6f3caf73e13f32e5482d09b3fd2fbcf61ac88bc1 (diff)
downloadsamba-8a58b806e90b177107cb6a21ab43a88ff8516ec8.tar.gz
samba-8a58b806e90b177107cb6a21ab43a88ff8516ec8.tar.bz2
samba-8a58b806e90b177107cb6a21ab43a88ff8516ec8.zip
r11067: Support for [string] in the Ethereal parser generator
(This used to be commit 1d5db487bb4afffac13b0d0904aea6b8664b75a8)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm39
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm13
2 files changed, 42 insertions, 10 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
index 8a4c0ed60c..be2e48a686 100644
--- a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
@@ -19,13 +19,19 @@ package Parse::Pidl::Ethereal::NDR;
use strict;
use Parse::Pidl::Typelist qw(getType);
use Parse::Pidl::Util qw(has_property ParseExpr property_matches make_str);
-use Parse::Pidl::NDR;
+use Parse::Pidl::NDR qw(ContainsString GetNextLevel);
use Parse::Pidl::Dump qw(DumpTypedef DumpFunction);
use Parse::Pidl::Ethereal::Conformance qw(ReadConformance);
use vars qw($VERSION);
$VERSION = '0.01';
+sub error($$)
+{
+ my ($e,$t) = @_;
+ print "$e->{FILE}:$e->{LINE}: $t\n";
+}
+
my @ett;
my %hf_used = ();
@@ -243,21 +249,26 @@ sub ElementLevel($$$$$)
}
pidl_code "offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME})) . " ($e->{TYPE})\",$hf);";
} elsif ($l->{TYPE} eq "ARRAY") {
-
if ($l->{IS_INLINE}) {
- warn ("Inline arrays not supported");
- pidl_code "/* FIXME: Handle inline array */";
+ error($e->{ORIGINAL}, "Inline arrays not supported");
} elsif ($l->{IS_FIXED}) {
pidl_code "int i;";
pidl_code "for (i = 0; i < $l->{SIZE_IS}; i++)";
pidl_code "\toffset = $myname\_(tvb, offset, pinfo, tree, drep);";
} else {
- my $af = "";
- ($af = "ucarray") if ($l->{IS_CONFORMANT});
- ($af = "uvarray") if ($l->{IS_VARYING});
- ($af = "ucvarray") if ($l->{IS_CONFORMANT} and $l->{IS_VARYING});
+ my $type = "";
+ $type .= "c" if ($l->{IS_CONFORMANT});
+ $type .= "v" if ($l->{IS_VARYING});
- pidl_code "offset = dissect_ndr_$af(tvb, offset, pinfo, tree, drep, $myname\_);";
+ unless ($l->{IS_ZERO_TERMINATED}) {
+ pidl_code "offset = dissect_ndr_u" . $type . "array(tvb, offset, pinfo, tree, drep, $myname\_);";
+ } else {
+ my $nl = GetNextLevel($e,$l);
+ pidl_code "char *data;";
+ pidl_code "";
+ pidl_code "offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);";
+ pidl_code "proto_item_append_text(tree, \": %s\", data);";
+ }
}
} elsif ($l->{TYPE} eq "DATA") {
if ($l->{DATA_TYPE} eq "string") {
@@ -332,6 +343,15 @@ sub Element($$$)
};
}
+ if (ContainsString($e)) {
+ $type = {
+ MASK => 0,
+ VALSSTRING => "NULL",
+ FT_TYPE => "FT_STRING",
+ BASE_TYPE => "BASE_DEC"
+ };
+ }
+
my $hf = register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", field2name($e->{NAME}), "$ifname.$pn.$e->{NAME}", $type->{FT_TYPE}, $type->{BASE_TYPE}, $type->{VALSSTRING}, $type->{MASK}, "");
$hf_used{$hf} = 1;
@@ -357,6 +377,7 @@ sub Element($$$)
deindent;
pidl_code "}\n";
$add.="_";
+ last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED});
}
return $call_code;
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index f975e07b15..73104758dd 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -31,7 +31,7 @@ require Exporter;
use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
-@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred);
+@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
use strict;
use Parse::Pidl::Typelist qw(hasType getType);
@@ -654,6 +654,17 @@ sub GetPrevLevel($$)
return undef;
}
+sub ContainsString($)
+{
+ my ($e) = @_;
+
+ foreach my $l (@{$e->{LEVELS}}) {
+ return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
+ }
+
+ return 0;
+}
+
sub ContainsDeferred($$)
{
my ($e,$l) = @_;