summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
index dea3a32607..4d3dba2e0e 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
@@ -26,6 +26,30 @@ sub fatal($$) { my ($e,$s) = @_; die("$e->{ORIGINAL}->{FILE}:$e->{ORIGINAL}->{LI
sub warning($$) { my ($e,$s) = @_; warn("$e->{ORIGINAL}->{FILE}:$e->{ORIGINAL}->{LINE}: $s\n"); }
sub fn_declare($) { my ($n) = @_; pidl $n; pidl_hdr "$n;"; }
+sub AllocOutVar($$$$)
+{
+ my ($e, $mem_ctx, $name, $env) = @_;
+
+ my $l = $e->{LEVELS}[0];
+
+ if ($l->{TYPE} eq "POINTER") {
+ $l = GetNextLevel($e, $l);
+ }
+
+ if ($l->{TYPE} eq "ARRAY") {
+ my $size = ParseExpr($l->{SIZE_IS}, $env);
+ pidl "$name = talloc_array_size($mem_ctx, sizeof(*$name), $size);";
+ } else {
+ pidl "$name = talloc_size($mem_ctx, sizeof(*$name));";
+ }
+
+ pidl "if ($name == NULL) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+}
+
sub ParseFunction($$)
{
my ($if,$fn) = @_;
@@ -56,12 +80,21 @@ sub ParseFunction($$)
pidl "\treturn False;";
pidl "}";
pidl "";
+
+ my %env = ();
+ foreach (@{$fn->{ELEMENTS}}) {
+ next unless (grep (/in/, @{$_->{DIRECTION}}));
+ $env{$_->{NAME}} = "r.in.$_->{NAME}";
+ }
+
my $proto = "_$fn->{NAME}(pipes_struct *p";
my $ret = "_$fn->{NAME}(p";
foreach (@{$fn->{ELEMENTS}}) {
my @dir = @{$_->{DIRECTION}};
if (grep(/in/, @dir) and grep(/out/, @dir)) {
pidl "r.out.$_->{NAME} = r.in.$_->{NAME};";
+ } elsif (grep(/out/, @dir)) {
+ AllocOutVar($_, "mem_ctx", "r.out.$_->{NAME}", \%env);
}
if (grep(/in/, @dir)) { $ret .= ", r.in.$_->{NAME}"; }
else { $ret .= ", r.out.$_->{NAME}"; }