source: branches/samba-3.5.x/librpc/tables.pl

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 1.6 KB
Line 
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
9use strict;
10
11use Getopt::Long;
12use File::Basename;
13
14my $opt_output = 'librpc/gen_ndr/tables.c';
15my $opt_help = 0;
16
17
18#########################################
19# display help text
20sub ShowHelp()
21{
22 print "
23 perl NDR interface table generator
24 Copyright (C) tridge\@samba.org
25
26 Usage: tables.pl [options] <idlfile>
27
28 \n";
29 exit(0);
30}
31
32# main program
33GetOptions (
34 'help|h|?' => \$opt_help,
35 'output=s' => \$opt_output,
36 );
37
38if ($opt_help) {
39 ShowHelp();
40 exit(0);
41}
42
43my $init_fns = "";
44
45###################################
46# extract table entries from 1 file
47sub process_file($)
48{
49 my $filename = shift;
50 open(FILE, $filename) || die "unable to open $filename\n";
51 my $found = 0;
52
53 while (my $line = <FILE>) {
54 if ($line =~ /extern const struct ndr_interface_table (\w+);/) {
55 $found = 1;
56 $init_fns.="\tstatus = ndr_table_register(&$1);\n";
57 $init_fns.="\tif (NT_STATUS_IS_ERR(status)) return status;\n\n";
58 }
59 }
60
61 if ($found) {
62 print "#include \"$filename\"\n";
63 }
64
65 close(FILE);
66}
67
68print <<EOF;
69
70/* Automatically generated by tables.pl. DO NOT EDIT */
71
72#include "includes.h"
73#include "librpc/ndr/libndr.h"
74#include "librpc/ndr/ndr_table.h"
75EOF
76
77process_file($_) foreach (@ARGV);
78
79print <<EOF;
80
81NTSTATUS ndr_table_register_builtin_tables(void)
82{
83 NTSTATUS status;
84
85$init_fns
86
87 return NT_STATUS_OK;
88}
89EOF
Note: See TracBrowser for help on using the repository browser.