From e0905c30908b4d621030689d33de28a13c04a690 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 20 Oct 2008 13:19:39 +0200 Subject: Use tables in Samba 3 ndrdump. --- librpc/tables.pl | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 librpc/tables.pl (limited to 'librpc/tables.pl') diff --git a/librpc/tables.pl b/librpc/tables.pl new file mode 100644 index 0000000000..04764f5fa0 --- /dev/null +++ b/librpc/tables.pl @@ -0,0 +1,89 @@ +#!/usr/bin/perl -w + +################################################### +# package to produce a table of all idl parsers +# Copyright tridge@samba.org 2003 +# Copyright jelmer@samba.org 2005 +# released under the GNU GPL + +use strict; + +use Getopt::Long; +use File::Basename; + +my $opt_output = 'librpc/gen_ndr/tables.c'; +my $opt_help = 0; + + +######################################### +# display help text +sub ShowHelp() +{ + print " + perl NDR interface table generator + Copyright (C) tridge\@samba.org + + Usage: tables.pl [options] + + \n"; + exit(0); +} + +# main program +GetOptions ( + 'help|h|?' => \$opt_help, + 'output=s' => \$opt_output, + ); + +if ($opt_help) { + ShowHelp(); + exit(0); +} + +my $init_fns = ""; + +################################### +# extract table entries from 1 file +sub process_file($) +{ + my $filename = shift; + open(FILE, $filename) || die "unable to open $filename\n"; + my $found = 0; + + while (my $line = ) { + if ($line =~ /extern const struct ndr_interface_table (\w+);/) { + $found = 1; + $init_fns.="\tstatus = ndr_table_register(&$1);\n"; + $init_fns.="\tif (NT_STATUS_IS_ERR(status)) return status;\n\n"; + } + } + + if ($found) { + print "#include \"$filename\"\n"; + } + + close(FILE); +} + +print <