summaryrefslogtreecommitdiff
path: root/source4/build/pidl/eparser.pm
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-05-09 10:03:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:50 -0500
commit0221717a625b384801f08600046c738aecb56275 (patch)
treea5a578fd249ccf26b12e77b0f80249b843e4b0f8 /source4/build/pidl/eparser.pm
parent54a695f7edf7c40a92391aa94ddbbd2db8b11ec3 (diff)
downloadsamba-0221717a625b384801f08600046c738aecb56275.tar.gz
samba-0221717a625b384801f08600046c738aecb56275.tar.bz2
samba-0221717a625b384801f08600046c738aecb56275.zip
r602: Autogenerated packet-dcerpc-samr.c now compiles!
(This used to be commit 0c1069b56e7c80e2b428f6a6b550eacd5ac3d762)
Diffstat (limited to 'source4/build/pidl/eparser.pm')
-rw-r--r--source4/build/pidl/eparser.pm154
1 files changed, 147 insertions, 7 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm
index f32e1b9842..f7d383d297 100644
--- a/source4/build/pidl/eparser.pm
+++ b/source4/build/pidl/eparser.pm
@@ -10,6 +10,8 @@ use strict;
use dump;
use Data::Dumper;
+my($name);
+
sub ParamSimpleNdrType($)
{
my($p) = shift;
@@ -25,7 +27,7 @@ sub ParamPolicyHandle($)
my($p) = shift;
my($res);
- $res .= "\toffset = dissect_nt_policy_handle(tvb, offset, pinfo, tree, drep, hf_policy_hnd, NULL, NULL, FALSE, FALSE);\n";
+ $res .= "\toffset = dissect_nt_policy_hnd(tvb, offset, pinfo, tree, drep, hf_policy_hnd, NULL, NULL, FALSE, FALSE);\n";
return $res;
}
@@ -89,7 +91,7 @@ sub ParseFunction($)
$res .= ParseParameter($d), if defined($d->{PROPERTIES}{out});
}
-
+ $res .= "\n";
$res .= "\treturn offset;\n";
$res .= "}\n\n";
@@ -98,7 +100,7 @@ sub ParseFunction($)
#####################################################################
# parse the interface definitions
-sub ParseInterface($)
+sub Pass2Interface($)
{
my($interface) = shift;
my($data) = $interface->{DATA};
@@ -111,19 +113,157 @@ sub ParseInterface($)
return $res;
}
+#####################################################################
+# Pass 1: Stuff required before structs and functions
+
+sub Pass1ModuleHeader($)
+{
+ my($d) = shift;
+ my($res) = "";
+
+ $res .= << "EOF";
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "packet-dcerpc.h"
+#include "packet-dcerpc-nt.h"
+
+EOF
+
+ # UUID
+
+ if ($d->{TYPE} eq "MODULEHEADER" and defined($d->{PROPERTIES}->{uuid})) {
+ my $uuid = $d->{PROPERTIES}->{uuid};
+ $res .= "static e_uuid_t uuid_dcerpc_$name = {\n";
+ $res .= "\t0x" . substr($uuid, 0, 8);
+ $res .= ", 0x" . substr($uuid, 9, 4);
+ $res .= ", 0x" . substr($uuid, 14, 4) . ",\n";
+ $res .= "\t{ 0x" . substr($uuid, 19, 2);
+ $res .= ", 0x" . substr($uuid, 21, 2);
+ $res .= ", 0x" . substr($uuid, 24, 2);
+ $res .= ", 0x" . substr($uuid, 26, 2);
+ $res .= ", 0x" . substr($uuid, 28, 2);
+ $res .= ", 0x" . substr($uuid, 30, 2);
+ $res .= ", 0x" . substr($uuid, 32, 2);
+ $res .= ", 0x" . substr($uuid, 34, 2) . " }\n";
+ $res .= "};\n\n";
+
+ $res .= "static guint16 ver_dcerpc_samr = " .
+ $d->{PROPERTIES}->{version} . ";\n\n";
+ }
+
+ return $res;
+}
+
+sub Pass1Interface($)
+{
+ my($interface) = shift;
+ my($res) = "";
+
+ $res .= << "EOF";
+static int proto_dcerpc_$name = -1;
+
+static int hf_${name}_opnum = -1;
+static int hf_${name}_rc = -1;
+static int hf_policy_hnd = -1;
+
+static gint ett_dcerpc_$name = -1;
+
+EOF
+
+ my %p = ();
+
+ foreach my $fn (@{$interface->{DATA}}) {
+ next, if $fn->{TYPE} ne "FUNCTION";
+ foreach my $args ($fn->{DATA}) {
+ foreach my $params (@{$args}) {
+ $res .= "static int hf_$params->{NAME} = -1;\n",
+ if not defined $p{$params->{NAME}};
+ $p{$params->{NAME}} = 1;
+ }
+ }
+ }
+
+ $res .= "\n";
+
+ return $res;
+}
+
+#####################################################################
+# Pass 3: trailing stuff
+
+sub Pass3Interface($)
+{
+ my($interface) = shift;
+ my($res) = "";
+
+ $res .= "static dcerpc_sub_dissector dcerpc_${name}_dissectors[] = {\n";
+
+ my $num = 0;
+
+ foreach my $d (@{$interface->{DATA}}) {
+ if ($d->{TYPE} eq "FUNCTION") {
+ # Strip module name from function name, if present
+ my $n = $d->{NAME};
+ $n = substr($d->{NAME}, length($name) + 1),
+ if $name eq substr($d->{NAME}, 0, length($name));
+
+ $res .= "\t{ $num, \"$n\",\n";
+ $res .= "\t\t$d->{NAME}_rqst,\n";
+ $res .= "\t\t$d->{NAME}_resp },\n";
+ $num++;
+ }
+ }
+
+ $res .= "};\n\n";
+
+ return $res;
+}
#####################################################################
# parse a parsed IDL structure back into an IDL file
sub Parse($)
{
my($idl) = shift;
- my($res);
+ my($res) = "/* parser auto-generated by pidl */\n\n";
+ my($d);
+
+ # Pass 0: set module name
+
+ foreach $d (@{$idl}) {
+ $name = $d->{NAME}, if ($d->{TYPE} eq "INTERFACE");
+ }
+
+ # Pass 1: header stuff
+
+ foreach $d (@{$idl}) {
+ $res .= Pass1ModuleHeader($d), if $d->{TYPE} eq "MODULEHEADER";
+ $res .= Pass1Interface($d), if $d->{TYPE} eq "INTERFACE";
+ }
- $res = "/* parser auto-generated by pidl */\n\n";
- foreach my $d (@{$idl}) {
- $res .= ParseInterface($d), if $d->{TYPE} eq "INTERFACE";
+ # Pass 2: typedefs and functions
+
+ foreach $d (@{$idl}) {
+ $res .= Pass2Interface($d), if $d->{TYPE} eq "INTERFACE";
+ }
+
+ # Pass 3: trailing stuff
+
+ foreach $d (@{$idl}) {
+ $res .= Pass3Interface($d), if $d->{TYPE} eq "INTERFACE";
}
+ $res .= << "EOF";
+void
+proto_reg_handoff_dcerpc_$name(void)
+{
+ dcerpc_init_uuid(proto_dcerpc_$name, ett_dcerpc_$name,
+ &uuid_dcerpc_$name, ver_dcerpc_$name,
+ dcerpc_${name}_dissectors, hf_${name}_opnum);
+}
+EOF
+
return $res;
}