summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-23 13:44:19 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-23 13:44:19 +0000
commit3d0e6b3835379d545189563ce25ffe37ed340703 (patch)
tree6941a15bff5d7132879907999bdd4ce5938c5b2a /source4/build/pidl
parent66694c571f2fbefda4cb70d944497bd9a9d45a7c (diff)
downloadsamba-3d0e6b3835379d545189563ce25ffe37ed340703.tar.gz
samba-3d0e6b3835379d545189563ce25ffe37ed340703.tar.bz2
samba-3d0e6b3835379d545189563ce25ffe37ed340703.zip
added a tool called 'ndrdump' that allows you to dump NDR data
according to the current IDL taking the data from a file. In combination with a little hack to ethereal to extract data this is a quite powerful IDL development tool. (This used to be commit 229a325c3cf0d4dc1e910ed32e1d7391040aeba1)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/header.pm2
-rw-r--r--source4/build/pidl/parser.pm42
2 files changed, 42 insertions, 2 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index d6584a05ad..5a75e4c9b4 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -240,6 +240,8 @@ sub HeaderInterface($)
$res .= "#define DCERPC_$name\_NAME \"$interface->{NAME}\"\n\n";
}
+ $res .= "extern struct dcerpc_interface_table dcerpc_table_$interface->{NAME};\n\n";
+
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "FUNCTION") {
my $u_name = uc $d->{NAME};
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 59ff73b8e6..b92729a80a 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -406,7 +406,12 @@ sub ParseElementPullSwitch($$$$)
pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n";
pidl "\t\t $e2->{TYPE} _level;\n";
pidl "\t\tNDR_CHECK(ndr_pull_$e2->{TYPE}(ndr, &_level));\n";
- pidl "\t\tif (_level != $switch_var) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\n";
+ if ($switch_var =~ /r->in/) {
+ pidl "\t\tif (!(ndr->flags & LIBNDR_FLAG_REF_ALLOC) && _level != $switch_var) {\n";
+ } else {
+ pidl "\t\tif (_level != $switch_var) {\n";
+ }
+ pidl "\t\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\t\t} else { $switch_var = _level; }\n";
pidl "\t}\n";
}
@@ -1211,6 +1216,37 @@ sub ParseFunctionPull($)
}
#####################################################################
+# produce a function call table
+sub FunctionTable($)
+{
+ my($interface) = shift;
+ my($data) = $interface->{DATA};
+ my $count = 0;
+
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") { $count++; }
+ }
+
+
+ pidl "static const struct dcerpc_interface_call calls[] = {\n";
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") {
+ pidl "\t{\n";
+ pidl "\t\t\"$d->{NAME}\",\n";
+ pidl "\t\tsizeof(struct $d->{NAME}),\n";
+ pidl "\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},\n";
+ pidl "\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},\n";
+ pidl "\t\t(ndr_print_function_t) ndr_print_$d->{NAME}\n";
+ pidl "\t},\n";
+ }
+ }
+ pidl "\t{ NULL, 0, NULL, NULL }\n};\n\n";
+
+ pidl "\nstruct dcerpc_interface_table dcerpc_table_$interface->{NAME} = {\"$interface->{NAME}\", $count,calls};\n\n";
+}
+
+
+#####################################################################
# parse the interface definitions
sub ParseInterface($)
{
@@ -1247,6 +1283,9 @@ sub ParseInterface($)
ParseFunctionPrint($d);
}
}
+
+ FunctionTable($interface);
+
}
sub NeededFunction($)
@@ -1310,7 +1349,6 @@ sub BuildNeeded($)
}
}
-
#####################################################################
# parse a parsed IDL structure back into an IDL file
sub Parse($$)