summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-08-21 14:06:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:02:22 -0500
commitedb4fefeb74cd7a2390cbf962048c320d21b7d8c (patch)
tree4520341b57085a0b76d81d2bc299da103afdda3d /source4/pidl/lib/Parse/Pidl
parent02467edf5cc3dbaac8bec15deff4fb606ab76f75 (diff)
downloadsamba-edb4fefeb74cd7a2390cbf962048c320d21b7d8c.tar.gz
samba-edb4fefeb74cd7a2390cbf962048c320d21b7d8c.tar.bz2
samba-edb4fefeb74cd7a2390cbf962048c320d21b7d8c.zip
r24596: - talloc request structure for the samba3 server bindings
and make that the primary context for the request which the implementations can also use. - go via functions pointers in the ndr_interface_table instead of calling functions directly. metze (This used to be commit fa577a12940d2df9d5ea9e3e0fed40021d59647d)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm57
1 files changed, 33 insertions, 24 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
index f7acddc7c4..b3aa98ee0a 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
@@ -72,7 +72,7 @@ sub AllocOutVar($$$$)
}
pidl "if ($name == NULL) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free($mem_ctx);";
pidl "\treturn False;";
pidl "}";
pidl "";
@@ -82,62 +82,71 @@ sub ParseFunction($$)
{
my ($if,$fn) = @_;
+ my $op = "NDR_".uc($fn->{NAME});
+
pidl "static BOOL api_$fn->{NAME}(pipes_struct *p)";
pidl "{";
indent;
+ pidl "const struct ndr_interface_call *call;";
pidl "struct ndr_pull *pull;";
pidl "struct ndr_push *push;";
pidl "NTSTATUS status;";
pidl "DATA_BLOB blob;";
- pidl "struct $fn->{NAME} r;";
- pidl "TALLOC_CTX *mem_ctx = talloc_init(\"api_$fn->{NAME}\");";
+ pidl "struct $fn->{NAME} *r;";
+ pidl "";
+ pidl "call = &ndr_table_$if->{NAME}.calls[$op];";
+ pidl "";
+ pidl "r = talloc(NULL, struct $fn->{NAME});";
+ pidl "if (r == NULL) {";
+ pidl "\treturn False;";
+ pidl "}";
pidl "";
- pidl "if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "if (!prs_data_blob(&p->in_data.data, &blob, r)) {";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
- pidl "pull = ndr_pull_init_blob(&blob, mem_ctx);";
+ pidl "pull = ndr_pull_init_blob(&blob, r);";
pidl "if (pull == NULL) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;";
- pidl "status = ndr_pull_$fn->{NAME}(pull, NDR_IN, &r);";
+ pidl "status = call->ndr_pull(pull, NDR_IN, r);";
pidl "if (NT_STATUS_IS_ERR(status)) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
pidl "if (DEBUGLEVEL >= 10)";
- pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, &r);";
+ pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, r);";
pidl "";
- my $env = GenerateFunctionOutEnv($fn, "r.");
+ my $env = GenerateFunctionOutEnv($fn);
my $hasout = 0;
foreach (@{$fn->{ELEMENTS}}) {
if (grep(/out/, @{$_->{DIRECTION}})) { $hasout = 1; }
}
- pidl "ZERO_STRUCT(r.out);" if ($hasout);
+ pidl "ZERO_STRUCT(r->out);" if ($hasout);
my $proto = "_$fn->{NAME}(pipes_struct *p, struct $fn->{NAME} *r";
- my $ret = "_$fn->{NAME}(p, &r";
+ my $ret = "_$fn->{NAME}(p, r";
foreach (@{$fn->{ELEMENTS}}) {
my @dir = @{$_->{DIRECTION}};
if (grep(/in/, @dir) and grep(/out/, @dir)) {
- pidl "r.out.$_->{NAME} = r.in.$_->{NAME};";
+ pidl "r->out.$_->{NAME} = r->in.$_->{NAME};";
} elsif (grep(/out/, @dir) and not
has_property($_, "represent_as")) {
- AllocOutVar($_, "mem_ctx", "r.out.$_->{NAME}", $env);
+ AllocOutVar($_, "r", "r->out.$_->{NAME}", $env);
}
}
$ret .= ")";
$proto .= ");";
if ($fn->{RETURN_TYPE}) {
- $ret = "r.out.result = $ret";
+ $ret = "r->out.result = $ret";
$proto = "$fn->{RETURN_TYPE} $proto";
} else {
$proto = "void $proto";
@@ -148,33 +157,33 @@ sub ParseFunction($$)
pidl "";
pidl "if (p->rng_fault_state) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\t/* Return True here, srv_pipe_hnd.c will take care */";
pidl "\treturn True;";
pidl "}";
pidl "";
pidl "if (DEBUGLEVEL >= 10)";
- pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, &r);";
+ pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
pidl "";
- pidl "push = ndr_push_init_ctx(mem_ctx);";
+ pidl "push = ndr_push_init_ctx(r);";
pidl "if (push == NULL) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
- pidl "status = ndr_push_$fn->{NAME}(push, NDR_OUT, &r);";
+ pidl "status = call->ndr_push(push, NDR_OUT, r);";
pidl "if (NT_STATUS_IS_ERR(status)) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
pidl "blob = ndr_push_blob(push);";
pidl "if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {";
- pidl "\ttalloc_free(mem_ctx);";
+ pidl "\ttalloc_free(r);";
pidl "\treturn False;";
pidl "}";
pidl "";
- pidl "talloc_free(mem_ctx);";
+ pidl "talloc_free(r);";
pidl "";
pidl "return True;";
deindent;