r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / librpc / tables.pl
blob9ad0675cb23a8c77428a7d39176980698474417b
1 #!/usr/bin/perl -w
3 ###################################################
4 # package to produce a table of all idl parsers
5 # Copyright tridge@samba.org 2003
6 # Copyright jelmer@samba.org 2005
7 # released under the GNU GPL
9 use strict;
11 use Getopt::Long;
12 use File::Basename;
14 my $opt_output = 'librpc/gen_ndr/tables.c';
15 my $opt_help = 0;
18 #########################################
19 # display help text
20 sub ShowHelp()
22 print "
23 perl DCE/RPC interface table generator
24 Copyright (C) tridge\@samba.org
26 Usage: tables.pl [options] <idlfile>
28 \n";
29 exit(0);
32 # main program
33 GetOptions (
34 'help|h|?' => \$opt_help,
35 'output=s' => \$opt_output,
38 if ($opt_help) {
39 ShowHelp();
40 exit(0);
43 my $init_fns = "";
45 ###################################
46 # extract table entries from 1 file
47 sub process_file($)
49 my $filename = shift;
50 open(FILE, $filename) || die "unable to open $filename\n";
51 my $found = 0;
53 while (my $line = <FILE>) {
54 if ($line =~ /extern const struct dcerpc_interface_table (\w+);/) {
55 $found = 1;
56 $init_fns.="\tstatus = librpc_register_interface(&$1);\n";
57 $init_fns.="\tif (NT_STATUS_IS_ERR(status)) return status;\n\n";
61 if ($found) {
62 print "#include \"$filename\"\n";
65 close(FILE);
68 print <<EOF;
70 /* Automatically generated by tables.pl. DO NOT EDIT */
72 #include "includes.h"
73 #include "librpc/rpc/dcerpc.h"
74 #include "librpc/rpc/dcerpc_table.h"
75 EOF
77 process_file($_) foreach (@ARGV);
79 print <<EOF;
81 NTSTATUS dcerpc_register_builtin_interfaces(void)
83 NTSTATUS status;
85 $init_fns
87 return NT_STATUS_OK;
89 EOF