package Parse::Pidl::Samba3::ClientNDR;
use strict;
-use Parse::Pidl::Typelist qw(hasType getType mapType);
-use Parse::Pidl::Util qw(has_property ParseExpr);
+use Parse::Pidl::Typelist qw(hasType getType mapType scalar_is_reference);
+use Parse::Pidl::Util qw(has_property ParseExpr is_constant);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
-use Parse::Pidl::Samba3::Types qw(DeclLong);
+use Parse::Pidl::Samba4 qw(DeclLong);
use vars qw($VERSION);
$VERSION = '0.01';
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 CopyLevel($$$$)
-{
- sub CopyLevel($$$$);
- my ($e,$l,$argument,$member) = @_;
-
- if ($l->{TYPE} eq "DATA") {
- pidl "*$argument = *$member;";
- } elsif ($l->{TYPE} eq "POINTER") {
- pidl "if (r.ptr$l->{POINTER_INDEX}_$e->{NAME}) {";
- indent;
- pidl "*$argument = talloc_size(mem_ctx, sizeof(void *));";
- CopyLevel($e,GetNextLevel($e,$l),"*$argument", $member);
- deindent;
- pidl "}";
- } elsif ($l->{TYPE} eq "SWITCH") {
- CopyLevel($e,GetNextLevel($e,$l),$argument,$member);
- } elsif ($l->{TYPE} eq "ARRAY") {
- pidl "*$argument = $member;";
- }
-}
-
sub ParseFunction($$)
{
my ($if,$fn) = @_;
}
}
- pidl "status = cli_do_rpc_ndr(cli, mem_ctx, PI_$uif, $ufn, &r, ndr_pull_$fn->{NAME}, ndr_push_$fn->{NAME});";
+ pidl "";
+ pidl "if (DEBUGLEVEL >= 10)";
+ pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, &r);";
+ pidl "";
+ pidl "status = cli_do_rpc_ndr(cli, mem_ctx, PI_$uif, $ufn, &r, (ndr_pull_flags_fn_t)ndr_pull_$fn->{NAME}, (ndr_push_flags_fn_t)ndr_push_$fn->{NAME});";
+ pidl "";
+
+ pidl "if ( !NT_STATUS_IS_OK(status) ) {";
+ indent;
+ pidl "return status;";
+ deindent;
+ pidl "}";
+
+ pidl "";
+ pidl "if (DEBUGLEVEL >= 10)";
+ pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, &r);";
+ pidl "";
pidl "if (NT_STATUS_IS_ERR(status)) {";
pidl "\treturn status;";
pidl "}";
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));
- fatal($e, "[out] argument is not a pointer") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER");
-
- CopyLevel($e, $e->{LEVELS}[1], $e->{NAME}, "r.out.$e->{NAME}");
+ fatal($e, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
+
+ if ( ($e->{LEVELS}[0]->{TYPE} eq "POINTER") && ($e->{LEVELS}[0]->{POINTER_TYPE} eq "unique") ) {
+ pidl "if ( $e->{NAME} ) {";
+ indent;
+ pidl "*$e->{NAME} = *r.out.$e->{NAME};";
+ deindent;
+ pidl "}";
+ } else {
+ pidl "*$e->{NAME} = *r.out.$e->{NAME};";
+ }
+
}
pidl"";
if (not $fn->{RETURN_TYPE}) {
pidl "return NT_STATUS_OK;";
} elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
- pidl "return r.status;";
+ pidl "return r.out.result;";
} elsif ($fn->{RETURN_TYPE} eq "WERROR") {
- pidl "return werror_to_ntstatus(r.status);";
+ pidl "return werror_to_ntstatus(r.out.result);";
} else {
pidl "/* Sorry, don't know how to convert $fn->{RETURN_TYPE} to NTSTATUS */";
pidl "return NT_STATUS_OK;";
pidl_hdr "#endif /* __CLI_$uif\__ */";
}
-sub Parse($$)
+sub Parse($$$)
{
- my($ndr,$filename) = @_;
+ my($ndr,$header,$ndr_header) = @_;
$res = "";
$res_hdr = "";
pidl " */";
pidl "";
pidl "#include \"includes.h\"";
+ pidl "#include \"$header\"";
+ pidl_hdr "#include \"$ndr_header\"";
pidl "";
foreach (@$ndr) {