summaryrefslogtreecommitdiff
path: root/source4/build/pidl/server.pm
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/pidl/server.pm')
-rw-r--r--source4/build/pidl/server.pm74
1 files changed, 41 insertions, 33 deletions
diff --git a/source4/build/pidl/server.pm b/source4/build/pidl/server.pm
index 46dada7c7f..29745686fe 100644
--- a/source4/build/pidl/server.pm
+++ b/source4/build/pidl/server.pm
@@ -4,7 +4,7 @@
# Copyright metze@samba.org 2004
# released under the GNU GPL
-package IdlServer;
+package NdrServer;
use strict;
@@ -20,27 +20,25 @@ sub pidl($)
# generate the switch statement for function dispatch
sub gen_dispatch_switch($)
{
- my $data = shift;
+ my $interface = shift;
- my $count = 0;
- foreach my $d (@{$data}) {
- next if ($d->{TYPE} ne "FUNCTION");
+ foreach my $fn (@{$interface->{FUNCTIONS}}) {
+ next if not defined($fn->{OPNUM});
- pidl "\tcase $count: {\n";
- pidl "\t\tstruct $d->{NAME} *r2 = r;\n";
+ pidl "\tcase $fn->{OPNUM}: {\n";
+ pidl "\t\tstruct $fn->{NAME} *r2 = r;\n";
pidl "\t\tif (DEBUGLEVEL > 10) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_IN, r2);\n";
+ pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r2);\n";
pidl "\t\t}\n";
- if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") {
- pidl "\t\tr2->out.result = $d->{NAME}(dce_call, mem_ctx, r2);\n";
+ if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
+ pidl "\t\tr2->out.result = $fn->{NAME}(dce_call, mem_ctx, r2);\n";
} else {
- pidl "\t\t$d->{NAME}(dce_call, mem_ctx, r2);\n";
+ pidl "\t\t$fn->{NAME}(dce_call, mem_ctx, r2);\n";
}
pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} will reply async\\n\"));\n";
+ pidl "\t\t\tDEBUG(5,(\"function $fn->{NAME} will reply async\\n\"));\n";
pidl "\t\t}\n";
pidl "\t\tbreak;\n\t}\n";
- $count++;
}
}
@@ -48,25 +46,23 @@ sub gen_dispatch_switch($)
# generate the switch statement for function reply
sub gen_reply_switch($)
{
- my $data = shift;
+ my $interface = shift;
- my $count = 0;
- foreach my $d (@{$data}) {
- next if ($d->{TYPE} ne "FUNCTION");
+ foreach my $fn (@{$interface->{FUNCTIONS}}) {
+ next if not defined($fn->{OPNUM});
- pidl "\tcase $count: {\n";
- pidl "\t\tstruct $d->{NAME} *r2 = r;\n";
+ pidl "\tcase $fn->{OPNUM}: {\n";
+ pidl "\t\tstruct $fn->{NAME} *r2 = r;\n";
pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} replied async\\n\"));\n";
+ pidl "\t\t\tDEBUG(5,(\"function $fn->{NAME} replied async\\n\"));\n";
pidl "\t\t}\n";
pidl "\t\tif (DEBUGLEVEL > 10 && dce_call->fault_code == 0) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n";
+ pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n";
pidl "\t\t}\n";
pidl "\t\tif (dce_call->fault_code != 0) {\n";
- pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $d->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n";
+ pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $fn->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n";
pidl "\t\t}\n";
pidl "\t\tbreak;\n\t}\n";
- $count++;
}
}
@@ -75,8 +71,7 @@ sub gen_reply_switch($)
sub Boilerplate_Iface($)
{
my($interface) = shift;
- my($data) = $interface->{DATA};
- my $name = $interface->{NAME};
+ my $name = $interface->{NAME};
my $uname = uc $name;
my $uuid = util::make_str($interface->{PROPERTIES}->{uuid});
my $if_version = $interface->{PROPERTIES}->{version};
@@ -133,7 +128,7 @@ static NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_C
switch (opnum) {
";
- gen_dispatch_switch($data);
+ gen_dispatch_switch($interface);
pidl "
default:
@@ -156,7 +151,7 @@ static NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX
switch (opnum) {
";
- gen_reply_switch($data);
+ gen_reply_switch($interface);
pidl "
default:
@@ -283,11 +278,8 @@ NTSTATUS dcerpc_server_$name\_init(void)
sub ParseInterface($)
{
my($interface) = shift;
- my($data) = $interface->{DATA};
my $count = 0;
- $res = "";
-
if (!defined $interface->{PROPERTIES}->{uuid}) {
return $res;
}
@@ -296,19 +288,35 @@ sub ParseInterface($)
$interface->{PROPERTIES}->{version} = "0.0";
}
- foreach my $d (@{$data}) {
- if ($d->{TYPE} eq "FUNCTION") { $count++; }
+ foreach my $fn (@{$interface->{FUNCTIONS}}) {
+ if (defined($fn->{OPNUM})) { $count++; }
}
if ($count == 0) {
return $res;
}
- $res = "/* dcerpc server boilerplate generated by pidl */\n\n";
+ $res .= "/* $interface->{NAME} - dcerpc server boilerplate generated by pidl */\n\n";
Boilerplate_Iface($interface);
Boilerplate_Ep_Server($interface);
return $res;
}
+sub Parse($$)
+{
+ my($ndr) = shift;
+ my($filename) = shift;
+
+ $res = "";
+ $res .= "/* server functions auto-generated by pidl */\n";
+ $res .= "\n";
+
+ foreach my $x (@{$ndr}) {
+ ParseInterface($x) if ($x->{TYPE} eq "INTERFACE" and not defined($x->{PROPERTIES}{object}));
+ }
+
+ return $res;
+}
+
1;