summaryrefslogtreecommitdiff
path: root/source4/build/pidl/tables.pl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-28 00:48:05 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-28 00:48:05 +0000
commitdf5949efb425668f8e7ae38c0c858bd90529255a (patch)
tree6fc93659cff35e9a4a9a433d0a7cc4eb5e383f42 /source4/build/pidl/tables.pl
parentabff8aac56b2481de2223bf43ae2098cc7ab2391 (diff)
downloadsamba-df5949efb425668f8e7ae38c0c858bd90529255a.tar.gz
samba-df5949efb425668f8e7ae38c0c858bd90529255a.tar.bz2
samba-df5949efb425668f8e7ae38c0c858bd90529255a.zip
added auto-generation of the IDL interface tables. This makes two less
places that need to be edited when someone adds a new IDL file. (This used to be commit ccd9ddeed679baa6cbb05ac728b381b50420e00f)
Diffstat (limited to 'source4/build/pidl/tables.pl')
-rwxr-xr-xsource4/build/pidl/tables.pl97
1 files changed, 97 insertions, 0 deletions
diff --git a/source4/build/pidl/tables.pl b/source4/build/pidl/tables.pl
new file mode 100755
index 0000000000..fa53af1c09
--- /dev/null
+++ b/source4/build/pidl/tables.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+
+###################################################
+# package to produce a table of all idl parsers
+# Copyright tridge@samba.org 2003
+# released under the GNU GPL
+
+use strict;
+
+use Getopt::Long;
+use File::Basename;
+
+my($opt_output);
+my($opt_help) = 0;
+
+
+#########################################
+# display help text
+sub ShowHelp()
+{
+ print "
+ perl IDL table generator
+ Copyright (C) tridge\@samba.org
+
+ Usage: tables.pl [options] <idlfile>
+
+ Options:
+ --output OUTNAME put output in OUTNAME.*
+ \n";
+ exit(0);
+}
+
+# main program
+GetOptions (
+ 'help|h|?' => \$opt_help,
+ 'output=s' => \$opt_output,
+ );
+
+if ($opt_help) {
+ ShowHelp();
+ exit(0);
+}
+
+
+###################################
+# extract table entries from 1 file
+sub process_file($)
+{
+ my $filename = shift;
+ open(FILE, $filename) || die "unable to open $filename\n";
+
+ print TABLEH "#include \"$filename\"\n";
+
+ while (my $line = <FILE>) {
+ if ($line =~ /extern const struct dcerpc_interface_table (\w+);/) {
+ print TABLEC "\t&$1,\n";
+ }
+ }
+
+ close(FILE);
+}
+
+
+open(TABLEH, ">$opt_output.h") || die "failed to open $opt_output.h\n";
+open(TABLEC, ">$opt_output.c") || die "failed to open $opt_output.c\n";
+
+#include "includes.h"
+
+#define NDR_BASE_MARSHALL_SIZE 1024
+
+print TABLEC "
+#include \"includes.h\"
+
+/*
+ generated by pidl IDL table generator
+*/
+const struct dcerpc_interface_table *dcerpc_pipes[] = {
+";
+
+print TABLEH "
+/*
+ table headers generated by pidl IDL table generator
+*/
+
+extern const struct dcerpc_interface_table *dcerpc_pipes[];
+
+";
+
+foreach my $filename (@ARGV) {
+ process_file($filename);
+}
+
+
+print TABLEC "\tNULL\n};\n";
+
+close(TABLEH);
+close(TABLEC);