summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-05-09 22:35:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:52 -0500
commit005eb6b502ac53815487d1c3feaaf00bc428608f (patch)
treebc0f5fdf5bef4b149fdc6d54b0541d114730021c /source4/build/pidl
parent16f7b35a0acfe3e9f9b907bac462221a9165825f (diff)
downloadsamba-005eb6b502ac53815487d1c3feaaf00bc428608f.tar.gz
samba-005eb6b502ac53815487d1c3feaaf00bc428608f.tar.bz2
samba-005eb6b502ac53815487d1c3feaaf00bc428608f.zip
r617: Sync some minor updates with repository:
- start handing idl string types - comments - generate field types - code to select field types and bases (This used to be commit 3d4148c07c46d5d99bd91e1985540cc4e59db2bc)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/eparser.pm88
1 files changed, 81 insertions, 7 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm
index f7d383d297..797c6abeec 100644
--- a/source4/build/pidl/eparser.pm
+++ b/source4/build/pidl/eparser.pm
@@ -12,6 +12,9 @@ use Data::Dumper;
my($name);
+#####################################################################
+# handlers for parsing ndr argument types
+
sub ParamSimpleNdrType($)
{
my($p) = shift;
@@ -32,10 +35,21 @@ sub ParamPolicyHandle($)
return $res;
}
+sub ParamString($)
+{
+ my($p) = shift;
+ my($res);
+
+ $res .= "\toffset = dissect_ndr_pointer_cb(tvb, offset, pinfo, tree, drep, dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE, \"$p->{NAME}\", hf_$p->{NAME}, cb_wstr_postprocess, GINT_TO_POINTER(1));\n";
+
+ return $res;
+}
+
my %param_handlers = (
'uint16' => \&ParamSimpleNdrType,
'uint32' => \&ParamSimpleNdrType,
'policy_handle' => \&ParamPolicyHandle,
+ 'string' => \&ParamString,
);
#####################################################################
@@ -78,7 +92,7 @@ sub ParseFunction($)
$res .= ParseParameter($d), if defined($d->{PROPERTIES}{in});
}
- $res .= "\treturn offset;\n";
+ $res .= "\n\treturn offset;\n";
$res .= "}\n\n";
# Response function
@@ -91,7 +105,8 @@ sub ParseFunction($)
$res .= ParseParameter($d), if defined($d->{PROPERTIES}{out});
}
- $res .= "\n";
+ $res .= "\n\toffset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf_samr_rc, NULL);\n\n";
+
$res .= "\treturn offset;\n";
$res .= "}\n\n";
@@ -116,6 +131,8 @@ sub Pass2Interface($)
#####################################################################
# Pass 1: Stuff required before structs and functions
+my %hf_info = (); # Field info - remember for trailing stuff
+
sub Pass1ModuleHeader($)
{
my($d) = shift;
@@ -156,6 +173,29 @@ EOF
return $res;
}
+# Convert an idl type to an ethereal FT_* type
+
+sub type2ft($)
+{
+ my($t) = shift;
+
+ return "FT_UINT32", if ($t eq "uint32");
+ return "FT_UINT16", if ($t eq "uint16");
+
+ return "FT_BYTES";
+}
+
+# Select an ethereal BASE_* type for an idl type
+
+sub type2base($)
+{
+ my($t) = shift;
+
+ return "BASE_DEC", if ($t eq "uint32") or ($t eq "uint16");
+
+ return "BASE_NONE";
+}
+
sub Pass1Interface($)
{
my($interface) = shift;
@@ -172,15 +212,20 @@ 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;
+
+ next, if defined $hf_info{$params->{NAME}};
+
+ # Make a note about new field
+
+ $res .= "static int hf_$params->{NAME} = -1;\n";
+ $hf_info{$params->{NAME}} = {
+ 'ft' => type2ft($params->{TYPE}),
+ 'base' => type2base($params->{TYPE})
+ };
}
}
}
@@ -254,8 +299,37 @@ sub Parse($)
$res .= Pass3Interface($d), if $d->{TYPE} eq "INTERFACE";
}
+ my $hf_register_info = "";
+
+ foreach my $hf (keys(%hf_info)) {
+ $hf_register_info .= "\t{ &hf_$hf,\n";
+ $hf_register_info .= "\t { \"$hf\", \"$hf\", $hf_info{$hf}{ft}, $hf_info{$hf}{base},\n";
+ $hf_register_info .= "\t NULL, 0, \"$hf\", HFILL }},\n";
+ }
+
+ my $ett_info = "/* spotty */";
+
$res .= << "EOF";
void
+proto_register_dcerpc_${name}(void)
+{
+ static hf_register_info hf[] = {
+$hf_register_info
+ };
+
+ static gint *ett[] = {
+ &ett_dcerpc_$name,
+$ett_info
+ };
+
+ proto_dcerpc_$name = proto_register_protocol("$name", "$name", "$name");
+
+ proto_register_field_array (proto_dcerpc_${name}, hf, array_length (hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+}
+
+void
proto_reg_handoff_dcerpc_$name(void)
{
dcerpc_init_uuid(proto_dcerpc_$name, ett_dcerpc_$name,