summaryrefslogtreecommitdiff
path: root/source4/build
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
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')
-rwxr-xr-xsource4/build/pidl/pidl.pl8
-rw-r--r--source4/build/pidl/server.pm2
-rw-r--r--source4/build/pidl/template.pm88
3 files changed, 96 insertions, 2 deletions
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl
index ce8250826a..9b870d7263 100755
--- a/source4/build/pidl/pidl.pl
+++ b/source4/build/pidl/pidl.pl
@@ -21,12 +21,14 @@ use parser;
use eparser;
use validator;
use util;
+use template;
my($opt_help) = 0;
my($opt_parse) = 0;
my($opt_dump) = 0;
my($opt_diff) = 0;
my($opt_header) = 0;
+my($opt_template) = 0;
my($opt_server) = 0;
my($opt_parser) = 0;
my($opt_eparser) = 0;
@@ -64,6 +66,7 @@ sub ShowHelp()
--header create a C header file
--parser create a C parser
--server create server boilterplate
+ --template print a template for a pipe
--eparser create an ethereal parser
--diff run diff on the idl and dumped output
--keep keep the .pidl file
@@ -79,6 +82,7 @@ GetOptions (
'dump' => \$opt_dump,
'header' => \$opt_header,
'server' => \$opt_server,
+ 'template' => \$opt_template,
'parser' => \$opt_parser,
'eparser' => \$opt_eparser,
'diff' => \$opt_diff,
@@ -149,6 +153,10 @@ sub process_file($)
system("diff -wu $idl_file $tempfile");
unlink($tempfile);
}
+
+ if ($opt_template) {
+ print IdlTemplate::Parse($pidl);
+ }
}
diff --git a/source4/build/pidl/server.pm b/source4/build/pidl/server.pm
index e87a6a00be..f5256d18a6 100644
--- a/source4/build/pidl/server.pm
+++ b/source4/build/pidl/server.pm
@@ -1,5 +1,3 @@
-
-
###################################################
# server boilerplate generator
# Copyright tridge@samba.org 2003
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;
+