lib: Add a few required includes
[samba4-gss.git] / librpc / tables.pl
blobb7ac6e004505c06ea120c0d2ac2fa55c17cee3db
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_help = 0;
17 #########################################
18 # display help text
19 sub ShowHelp()
21 print "
22 perl NDR interface table generator
23 Copyright (C) tridge\@samba.org
25 Usage: tables.pl [options] <idlfile>
27 \n";
28 exit(0);
31 # main program
32 GetOptions (
33 'help|h|?' => \$opt_help,
36 if ($opt_help) {
37 ShowHelp();
38 exit(0);
41 my $init_fns = "";
43 ###################################
44 # extract table entries from 1 file
45 sub process_file($)
47 my $filename = shift;
48 open(FILE, $filename) || die "unable to open $filename\n";
49 my $found = 0;
51 while (my $line = <FILE>) {
52 if ($line =~ /extern const struct ndr_interface_table (\w+);/) {
53 $found = 1;
54 $init_fns.="\tstatus = ndr_table_register(&$1);\n";
55 $init_fns.="\tif (NT_STATUS_IS_ERR(status)) return status;\n\n";
59 if ($found) {
60 print "#include \"$filename\"\n";
63 close(FILE);
66 print <<EOF;
68 /* Automatically generated by tables.pl. DO NOT EDIT */
70 #include "includes.h"
71 #include "librpc/ndr/libndr.h"
72 #include "librpc/ndr/ndr_table.h"
73 EOF
75 process_file($_) foreach (@ARGV);
77 print <<EOF;
79 NTSTATUS ndr_table_register_builtin_tables(void)
81 NTSTATUS status;
83 $init_fns
85 return NT_STATUS_OK;
87 EOF