]> git.samba.org - gd/samba-autobuild/.git/blob - librpc/tables.pl
s4:torture/smb2: add smb2.getinfo.normalized test
[gd/samba-autobuild/.git] / librpc / tables.pl
1 #!/usr/bin/perl -w
2
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
8
9 use strict;
10
11 use Getopt::Long;
12 use File::Basename;
13
14 my $opt_help  = 0;
15
16
17 #########################################
18 # display help text
19 sub ShowHelp()
20 {
21     print "
22            perl NDR interface table generator
23            Copyright (C) tridge\@samba.org
24
25            Usage: tables.pl [options] <idlfile>
26
27            \n";
28     exit(0);
29 }
30
31 # main program
32 GetOptions (
33             'help|h|?' => \$opt_help, 
34             );
35
36 if ($opt_help) {
37     ShowHelp();
38     exit(0);
39 }
40
41 my $init_fns = "";
42
43 ###################################
44 # extract table entries from 1 file
45 sub process_file($)
46 {
47         my $filename = shift;
48         open(FILE, $filename) || die "unable to open $filename\n";
49         my $found = 0;
50
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";
56                 }
57         }
58
59         if ($found) {
60                 print "#include \"$filename\"\n";
61         }
62
63         close(FILE);
64 }
65
66 print <<EOF;
67
68 /* Automatically generated by tables.pl. DO NOT EDIT */
69
70 #include "includes.h"
71 #include "librpc/ndr/libndr.h"
72 #include "librpc/ndr/ndr_table.h"
73 EOF
74
75 process_file($_) foreach (@ARGV);
76
77 print <<EOF;
78
79 NTSTATUS ndr_table_register_builtin_tables(void)
80 {
81         NTSTATUS status;
82
83 $init_fns
84         
85         return NT_STATUS_OK;
86 }
87 EOF