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 "
perl DCE / RPC interface table generator
Copyright ( C ) tridge \ @ samba . org
Usage: tables . pl [ options ] <idlfile>
Options:
- - output OUTNAME put output in OUTNAME . *
\ 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> ) {
if ( $ line =~ /extern const struct dcerpc_interface_table (\w+);/ ) {
$ found = 1 ;
2005-12-31 03:02:41 +03:00
$ init_fns . = "\tstatus = librpc_register_interface(&$1);\n" ;
$ init_fns . = "\tif (NT_STATUS_IS_ERR(status)) return status;\n\n" ;
2005-12-29 19:04:34 +03:00
}
}
if ( $ found ) {
print TABLEC "#include \"$filename\"\n" ;
}
close ( FILE ) ;
}
print "Creating $opt_output\n" ;
open ( TABLEC , ">$opt_output" ) || die "failed to open $opt_output\n" ;
print TABLEC << EOF ;
/* Automatically generated by tables.pl. DO NOT EDIT */
#include "includes.h"
2006-03-18 18:42:57 +03:00
#include "librpc/rpc/dcerpc.h"
2005-12-31 02:18:27 +03:00
#include "librpc/rpc/dcerpc_table.h"
2005-12-29 19:04:34 +03:00
EOF
process_file ( $ _ ) foreach ( @ ARGV ) ;
print TABLEC << EOF ;
2005-12-31 03:02:41 +03:00
NTSTATUS dcerpc_register_builtin_interfaces ( 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
close ( TABLEC ) ;