2005-12-29 19:04:34 +03:00
#!/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 "
2007-08-21 23:35:43 +04:00
perl NDR interface table generator
2005-12-29 19:04:34 +03:00
Copyright ( C ) tridge \ @ samba . org
Usage: tables . pl [ options ] <idlfile>
\ 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 = <FILE> ) {
2007-08-20 00:46:45 +04:00
if ( $ line =~ /extern const struct ndr_interface_table (\w+);/ ) {
2005-12-29 19:04:34 +03:00
$ found = 1 ;
2007-08-21 23:35:43 +04:00
$ init_fns . = "\tstatus = ndr_table_register(&$1);\n" ;
2005-12-31 03:02:41 +03:00
$ init_fns . = "\tif (NT_STATUS_IS_ERR(status)) return status;\n\n" ;
2005-12-29 19:04:34 +03:00
}
}
if ( $ found ) {
2006-04-04 18:38:05 +04:00
print "#include \"$filename\"\n" ;
2005-12-29 19:04:34 +03:00
}
close ( FILE ) ;
}
2006-04-04 18:38:05 +04:00
print << EOF ;
2005-12-29 19:04:34 +03:00
/* Automatically generated by tables.pl. DO NOT EDIT */
#include "includes.h"
2007-08-21 23:35:43 +04:00
#include "librpc/ndr/libndr.h"
#include "librpc/ndr/ndr_table.h"
2005-12-29 19:04:34 +03:00
EOF
process_file ( $ _ ) foreach ( @ ARGV ) ;
2006-04-04 18:38:05 +04:00
print << EOF ;
2005-12-29 19:04:34 +03:00
2007-08-21 23:35:43 +04:00
NTSTATUS ndr_table_register_builtin_tables ( void )
2005-12-29 19:04:34 +03:00
{
2005-12-31 03:02:41 +03:00
NTSTATUS status ;
2005-12-31 01:46:16 +03:00
2005-12-29 19:04:34 +03:00
$ init_fns
return NT_STATUS_OK ;
}
EOF