blob: 2e0397df37a95933ee1201f9baa3e761a46d013f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
###################################################
# 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;
use typelist;
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;
|