summaryrefslogtreecommitdiff
path: root/source4/build/pidl/server.pm
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-05-30 09:07:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:16 -0500
commit2a20e42c2637a6d53d74f3c68a4f420f8cb77a27 (patch)
treecec1b76d704f47c085b4a1f645350b0e6848e7f2 /source4/build/pidl/server.pm
parent9ab8ed3bab065afb0ba98277b7e4728b24caabe0 (diff)
downloadsamba-2a20e42c2637a6d53d74f3c68a4f420f8cb77a27.tar.gz
samba-2a20e42c2637a6d53d74f3c68a4f420f8cb77a27.tar.bz2
samba-2a20e42c2637a6d53d74f3c68a4f420f8cb77a27.zip
r7098: - make use of the NDR table instead of the IDL table in the client and server generation
- add 'noid' property to allow functions to be not present in the function table, and not generate client and server functions for them - print out a warning about [id()] not being correctly supported yet metze (This used to be commit 189730d1430e7f728d62dd5dc52f2a90c1a556d7)
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;