1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-04 08:23:50 +03:00
Files
samba-mirror/source/build/pidl/eth_header.pm
Jelmer Vernooij 2b08c4b92b r7059: Use namespaces for pidl and the build system, so we can later on
call out to the build system to compile the various pidl tests
(without having to rely on shared library support).

Initial work on an ndr_array test.
2007-10-10 13:17:10 -05:00

102 lines
2.1 KiB
Perl

###################################################
# create C header files for an IDL structure
# Copyright tridge@samba.org 2000
# Copyright jelmer@samba.org 2005
# released under the GNU GPL
package EthHeader;
use strict;
my($res);
my($tab_depth);
sub pidl ($)
{
$res .= shift;
}
sub tabs()
{
for (my($i)=0; $i < $tab_depth; $i++) {
pidl "\t";
}
}
#####################################################################
# prototype a typedef
sub HeaderTypedefProto($)
{
my($d) = shift;
my $tf = EthParser::get_typefamily($d->{DATA}{TYPE});
return unless util::has_property($d, "public");
unless (util::has_property($d, "nopull")) {
pidl "dcerpc_dissect_fnct_t $d->{NAME};\n";
}
}
#####################################################################
# parse a const
sub HeaderConst($)
{
my($const) = shift;
if (!defined($const->{ARRAY_LEN}[0])) {
pidl "#define $const->{NAME}\t( $const->{VALUE} )\n";
} else {
pidl "#define $const->{NAME}\t $const->{VALUE}\n";
}
}
my %headerstructs = ();
#####################################################################
# parse the interface definitions
sub HeaderInterface($)
{
my($interface) = shift;
my $count = 0;
pidl "#ifndef _HEADER_NDR_$interface->{NAME}\n";
pidl "#define _HEADER_NDR_$interface->{NAME}\n\n";
if (defined $interface->{PROPERTIES}->{depends}) {
my @d = split / /, $interface->{PROPERTIES}->{depends};
foreach my $i (@d) {
pidl "#include \"packet-dcerpc-$i\.h\"\n";
}
}
foreach my $d (@{$interface->{CONSTS}}) {
HeaderConst($d);
}
foreach my $d (@{$interface->{TYPEDEFS}}) {
HeaderTypedefProto($d);
}
pidl "#endif /* _HEADER_NDR_$interface->{NAME} */\n";
}
#####################################################################
# parse a parsed IDL into a C header
sub Parse($)
{
my($idl) = shift;
$tab_depth = 0;
$res = "";
pidl "/* header auto-generated by pidl */\n\n";
foreach my $x (@{$idl}) {
if ($x->{TYPE} eq "INTERFACE") {
HeaderInterface($x);
}
}
return $res;
}
1;