summaryrefslogtreecommitdiff
path: root/source4/build/pidl/template.pm
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-15 10:55:10 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-15 10:55:10 +0000
commit43e52cc177a6e2b112cd233f71a53c54bcb97265 (patch)
tree8bf0ae021ff45af766ac3581dee415ea7437a44e /source4/build/pidl/template.pm
parent5b0359652912baee3767d14d394eb951301c0e8f (diff)
downloadsamba-43e52cc177a6e2b112cd233f71a53c54bcb97265.tar.gz
samba-43e52cc177a6e2b112cd233f71a53c54bcb97265.tar.bz2
samba-43e52cc177a6e2b112cd233f71a53c54bcb97265.zip
added "pidl.pl --template" to dump a rough template to save typing
when starting a pipe. Thanks to metze for a script that gave the idea. do something like this to use it: pidl.pl --parse --template librpc/idl/XXX.idl > rpc_server/XXX/rpc_XXX.c then fill in the functions in rpc_XXX.c (This used to be commit 68e71d7497ddc7b8239fc4bd7cb3e780a1f53a39)
Diffstat (limited to 'source4/build/pidl/template.pm')
-rw-r--r--source4/build/pidl/template.pm88
1 files changed, 88 insertions, 0 deletions
diff --git a/source4/build/pidl/template.pm b/source4/build/pidl/template.pm
new file mode 100644
index 0000000000..f9f9897ce2
--- /dev/null
+++ b/source4/build/pidl/template.pm
@@ -0,0 +1,88 @@
+###################################################
+# server template function generator
+# Copyright tridge@samba.org 2003
+# released under the GNU GPL
+
+package IdlTemplate;
+
+use strict;
+
+my($res);
+
+#####################################################################
+# produce boilerplate code for a interface
+sub Template($)
+{
+ my($interface) = shift;
+ my($data) = $interface->{DATA};
+ my $name = $interface->{NAME};
+
+ $res .=
+"
+/*
+ Unix SMB/CIFS implementation.
+
+ endpoint server for the $name pipe
+
+ Copyright (C) YOUR NAME HERE XXXX
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include \"includes.h\"
+
+";
+
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") {
+ my $fname = $d->{NAME};
+ $res .=
+"
+/*
+ $fname
+*/
+static NTSTATUS $fname(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx,
+ struct $fname *r)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+";
+ }
+ }
+
+ $res .=
+"
+/* include the generated boilerplate */
+#include \"librpc/gen_ndr/ndr_$name\_s.c\"
+"
+}
+
+
+#####################################################################
+# parse a parsed IDL structure back into an IDL file
+sub Parse($)
+{
+ my($idl) = shift;
+ $res = "";
+ foreach my $x (@{$idl}) {
+ ($x->{TYPE} eq "INTERFACE") &&
+ Template($x);
+ }
+ return $res;
+}
+
+1;
+