summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba3
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-09-13 15:45:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:35 -0500
commit6a2b54149723d283878e3295bfe3a48d67e2d495 (patch)
tree4034994f2e27881eae60955e904c8db60ccfc092 /source4/pidl/lib/Parse/Pidl/Samba3
parent2fb4ecebc11152d770d07370b996b878338bcf46 (diff)
downloadsamba-6a2b54149723d283878e3295bfe3a48d67e2d495.tar.gz
samba-6a2b54149723d283878e3295bfe3a48d67e2d495.tar.bz2
samba-6a2b54149723d283878e3295bfe3a48d67e2d495.zip
r18477: Finish server code generator for Samba 3.
(This used to be commit 4e2f20042448721ba1df5bbbb77710e155f23953)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba3')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
index 327aea2f0e..7fba856617 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
@@ -33,7 +33,75 @@ sub ParseFunction($$)
pidl "static BOOL api_$fn->{NAME}(pipes_struct *p)";
pidl "{";
indent;
+ pidl "struct ndr_pull *pull;";
+ pidl "struct ndr_push *push;";
+ pidl "DATA_BLOB blob;";
+ pidl "struct $fn->{NAME} r;";
+ pidl "TALLOC_CTX *mem_ctx = talloc_init(\"api_$fn->{NAME}\");";
+ pidl "";
+ pidl "if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+ pidl "pull = ndr_pull_init_blob(&blob, mem_ctx);";
+ pidl "if (pull == NULL)";
+ pidl "\treturn False;";
+ pidl "";
+ pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;";
+ pidl "status = ndr_pull_$fn->{NAME}(pull, NDR_IN, &r);";
+ pidl "if (NT_STATUS_IS_ERR(status)) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+ my $proto = "_$fn->{NAME}(pipes_struct *p";
+ my $ret = "_$fn->{NAME}(p";
+ foreach (@{$fn->{ELEMENTS}}) {
+ my @dir = @{$_->{DIRECTION}};
+ if (grep(@dir, /in/) and grep(@dir, /out/)) {
+ pidl "r.out.$_->{NAME} = r.in.$_->{NAME};";
+ }
+ if (grep(@dir, /in/)) { $ret .= ", r.in.$_->{NAME}"; }
+ else { $ret .= ", r.out.$_->{NAME}"; }
+
+ $proto .= ", " . DeclLong($_);
+ }
+ $ret .= ")";
+ $proto .= ");";
+
+ if ($fn->{RETURN_TYPE}) {
+ $ret = "r.out.result = $ret";
+ $proto = "$fn->{RETURN_TYPE} $proto";
+ } else {
+ $proto = "void $proto";
+ }
+
+ pidl_hdr "$proto";
+ pidl "$ret;";
+ pidl "";
+ pidl "push = ndr_push_init_ctx(mem_ctx);";
+ pidl "if (push == NULL) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+ pidl "status = ndr_push_$fn->{NAME}(push, NDR_OUT, &r);";
+ pidl "if (NT_STATUS_IS_ERR(status)) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+ pidl "blob = ndr_push_blob(push);";
+ pidl "if (!prs_init_data_blob(&p->in_data.rdata, &blob, p->mem_ctx)) {";
+ pidl "\ttalloc_free(mem_ctx);";
+ pidl "\treturn False;";
+ pidl "}";
+ pidl "";
+ pidl "talloc_free(mem_ctx);";
+ pidl "";
+ pidl "return True;";
deindent;
pidl "}";
pidl "";