summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba3
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-15 00:45:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:44:44 -0500
commit5a937a0f6f62de25ce7721413a4bbf3b9b31ea59 (patch)
treeebca84c6499a31c333d7815f0d3cbdce4f62cc1c /source4/pidl/lib/Parse/Pidl/Samba3
parent5de65d5801f77838dc5cc9f856290ac95c1b8660 (diff)
downloadsamba-5a937a0f6f62de25ce7721413a4bbf3b9b31ea59.tar.gz
samba-5a937a0f6f62de25ce7721413a4bbf3b9b31ea59.tar.bz2
samba-5a937a0f6f62de25ce7721413a4bbf3b9b31ea59.zip
r11077: Fix [string] for Samba3
(This used to be commit 2f76e2a6bf8ff99ac2f9b61669d09d76a2fe920a)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba3')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm10
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Types.pm9
2 files changed, 12 insertions, 7 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
index d582305326..9ef8f09dc4 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
@@ -27,7 +27,7 @@ sub fatal($$) { my ($e,$s) = @_; die("$e->{FILE}:$e->{LINE}: $s\n"); }
#TODO:
# - Add some security checks (array sizes, memory alloc == NULL, etc)
# - Don't add seperate _p and _d functions if there is no deferred data
-# - [string] with non-varying arrays
+# - [string] with non-varying arrays and "surrounding" strings
# - subcontext()
# - DATA_BLOB
@@ -90,11 +90,13 @@ sub ParseElementLevelArray($$$$$$$)
my ($e,$l,$nl,$env,$varname,$what,$align) = @_;
if ($l->{IS_ZERO_TERMINATED}) {
+ return if ($what == DEFERRED);
+
my ($t,$f) = StringType($e,$l);
- pidl "if (!prs_io_$t(\"$e->{VARNAME}\", ps, depth, $varname))";
+ Align($align, 4);
+ pidl "if (!smb_io_$t(\"$e->{NAME}\", &$varname, 1, ps, depth))";
pidl "\treturn False;";
- pidl "";
$$align = 0;
return;
@@ -246,7 +248,7 @@ sub InitLevel($$$$)
}
} elsif ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED}) {
my ($t,$f) = StringType($e,$l);
- pidl "init_$t(" . ParseExpr($e->{NAME}, $env) . ", $varname, $f);";
+ pidl "init_$t(&" . ParseExpr($e->{NAME}, $env) . ", ".substr($varname, 1) . ", $f);";
} elsif ($l->{TYPE} eq "ARRAY") {
pidl ParseExpr($e->{NAME}, $env) . " = $varname;";
} elsif ($l->{TYPE} eq "DATA") {
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
index db20372bba..3f7e8ae134 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
@@ -11,7 +11,7 @@ require Exporter;
use strict;
use Parse::Pidl::Util qw(has_property ParseExpr property_matches);
-use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
+use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
use vars qw($VERSION);
$VERSION = '0.01';
@@ -110,7 +110,7 @@ sub StringType($$)
my $nl = GetNextLevel($e,$l);
if ($l->{IS_VARYING} and $l->{IS_CONFORMANT} and $nl->{DATA_TYPE} eq "uint16") {
- return ("unistr2", 0);
+ return ("unistr2", "UNI_FLAGS_NONE");
} elsif ($l->{IS_CONFORMANT} and $l->{IS_VARYING} and $nl->{DATA_TYPE} eq "uint8") {
return ("string2", 0);
} else {
@@ -282,7 +282,10 @@ sub DeclLong($)
my $suffixes = "";
foreach my $l (@{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "ARRAY" and not $l->{IS_FIXED}) {
+ if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED}) {
+ $p = "const char";
+ last;
+ } elsif ($l->{TYPE} eq "ARRAY" and not $l->{IS_FIXED}) {
$prefixes = "*$prefixes";
} elsif ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED}) {
$suffixes.="[$l->{SIZE_IS}]";