summaryrefslogtreecommitdiff
path: root/source4/build/pidl/server.pm
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-14 13:22:12 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-14 13:22:12 +0000
commitf6eb8342cba87c7c8f17471ed9783b567d36b0ed (patch)
tree40484486513e10f1fb4764ce62f7fdc3f8df17ff /source4/build/pidl/server.pm
parent4cd6b8a64b5d995190a28b2a8308e688847df49c (diff)
downloadsamba-f6eb8342cba87c7c8f17471ed9783b567d36b0ed.tar.gz
samba-f6eb8342cba87c7c8f17471ed9783b567d36b0ed.tar.bz2
samba-f6eb8342cba87c7c8f17471ed9783b567d36b0ed.zip
added auto-generation of the server side boilerplate code for each
pipe. The server side code gets generated as librpc/gen_ndr/ndr_NAME_s.c and gets included in the pipe module (This used to be commit bd3dcfe5820489a838e19b244266bd9126af5eb4)
Diffstat (limited to 'source4/build/pidl/server.pm')
-rw-r--r--source4/build/pidl/server.pm108
1 files changed, 108 insertions, 0 deletions
diff --git a/source4/build/pidl/server.pm b/source4/build/pidl/server.pm
new file mode 100644
index 0000000000..e6d996b95d
--- /dev/null
+++ b/source4/build/pidl/server.pm
@@ -0,0 +1,108 @@
+
+
+###################################################
+# server boilerplate generator
+# Copyright tridge@samba.org 2003
+# released under the GNU GPL
+
+package IdlServer;
+
+use strict;
+use Data::Dumper;
+
+my($res);
+
+sub pidl($)
+{
+ $res .= shift;
+}
+
+#####################################################################
+# produce boilerplate code for a interface
+sub Boilerplate($)
+{
+ my($interface) = shift;
+ my($data) = $interface->{DATA};
+ my $count = 0;
+ my $name = $interface->{NAME};
+ my $uname = uc $name;
+
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") { $count++; }
+ }
+
+ if ($count == 0) {
+ return;
+ }
+
+ pidl "static const dcesrv_dispatch_fn_t dispatch_table[] = {\n";
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") {
+ pidl "\t(dcesrv_dispatch_fn_t)$d->{NAME},\n";
+ }
+ }
+ pidl "\tNULL};\n\n";
+
+ pidl "
+static BOOL op_query_endpoint(const struct dcesrv_endpoint *ep)
+{
+ return dcesrv_table_query(&dcerpc_table_$name, ep);
+}
+
+static BOOL op_set_interface(struct dcesrv_state *dce,
+ const char *uuid, uint32 if_version)
+{
+ return dcesrv_set_interface(dce, uuid, if_version,
+ &dcerpc_table_$name, dispatch_table);
+}
+
+static NTSTATUS op_connect(struct dcesrv_state *dce)
+{
+ return NT_STATUS_OK;
+}
+
+static void op_disconnect(struct dcesrv_state *dce)
+{
+ /* nothing to do */
+}
+
+static int op_lookup_endpoints(TALLOC_CTX *mem_ctx, struct dcesrv_ep_iface **e)
+{
+ return dcesrv_lookup_endpoints(&dcerpc_table_$name, mem_ctx, e);
+}
+
+static const struct dcesrv_endpoint_ops $name\_ops = {
+ op_query_endpoint,
+ op_set_interface,
+ op_connect,
+ op_disconnect,
+ op_lookup_endpoints
+};
+
+void rpc_$name\_init(void *v)
+{
+ struct dcesrv_context *dce = v;
+ if (!dcesrv_endpoint_register(dce, &$name\_ops,
+ &dcerpc_table_$name)) {
+ DEBUG(1,(\"Failed to register rpcecho endpoint\\n\"));
+ }
+}
+";
+}
+
+
+#####################################################################
+# parse a parsed IDL structure back into an IDL file
+sub Parse($)
+{
+ my($idl) = shift;
+ $res = "/* dcerpc server boilerplate generated by pidl */\n\n";
+ foreach my $x (@{$idl}) {
+ ($x->{TYPE} eq "INTERFACE") &&
+ Boilerplate($x);
+ }
+ return $res;
+}
+
+1;
+