aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pidl
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2006-11-04 16:57:21 +0000
committerJörg Mayer <jmayer@loplof.de>2006-11-04 16:57:21 +0000
commit24dbbfe6080704a4c058854d528d975036812f3b (patch)
treef2c5b347a146bf96ad19d55a8a46d86bab74dab8 /tools/pidl
parente15d91a592f122d4a17b9f324281abe634bb7e06 (diff)
Update from samba tree revision 19540 to 19553
============================ Samba log start ============ ------------------------------------------------------------------------ r19541 | jelmer | 2006-11-03 20:55:17 +0100 (Fri, 03 Nov 2006) | 3 lines Explicitly segfault when the API is being used incorrectly. Previously this would've caused a silent premature return. ------------------------------------------------------------------------ r19544 | jelmer | 2006-11-04 00:08:33 +0100 (Sat, 04 Nov 2006) | 2 lines Fix case of 'warning'. ------------------------------------------------------------------------ r19545 | jelmer | 2006-11-04 02:53:29 +0100 (Sat, 04 Nov 2006) | 2 lines Allow enums as return types in code generated for wireshark. Originally based on a patch by Julien Kerihuel. ------------------------------------------------------------------------ r19546 | jelmer | 2006-11-04 03:51:03 +0100 (Sat, 04 Nov 2006) | 3 lines fix number of bytes pushed when using switch_type() set to enum types. die() on invalid used of enum_type_fn() ------------------------------------------------------------------------ r19547 | jelmer | 2006-11-04 03:54:24 +0100 (Sat, 04 Nov 2006) | 2 lines Fix use of v1_enum on enums used in return types. ------------------------------------------------------------------------ r19553 | jelmer | 2006-11-04 16:40:05 +0100 (Sat, 04 Nov 2006) | 2 lines Add check for correct API usage. ------------------------------------------------------------------------ ============================ Samba log end ============== svn path=/trunk/; revision=19793
Diffstat (limited to 'tools/pidl')
-rw-r--r--tools/pidl/lib/Parse/Pidl/NDR.pm2
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm15
-rw-r--r--tools/pidl/lib/Parse/Pidl/Typelist.pm3
-rw-r--r--tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm2
-rw-r--r--tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm56
5 files changed, 45 insertions, 33 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/NDR.pm b/tools/pidl/lib/Parse/Pidl/NDR.pm
index cd8aa214ff..6a3698a920 100644
--- a/tools/pidl/lib/Parse/Pidl/NDR.pm
+++ b/tools/pidl/lib/Parse/Pidl/NDR.pm
@@ -75,7 +75,7 @@ my $scalar_alignment = {
sub nonfatal($$)
{
my ($e,$s) = @_;
- warn ("$e->{FILE}:$e->{LINE}: Warning: $s\n");
+ warn ("$e->{FILE}:$e->{LINE}: warning: $s\n");
}
#####################################################################
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 6124935e67..1bb277fd0e 100644
--- a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -188,18 +188,6 @@ sub check_null_pointer_deferred($)
}
#####################################################################
-# check that a variable we get from ParseExpr isn't a null pointer
-# void return varient
-sub check_null_pointer_void($)
-{
- my $size = shift;
- if ($size =~ /^\*/) {
- my $size2 = substr($size, 1);
- pidl "if ($size2 == NULL) return;";
- }
-}
-
-#####################################################################
# declare a function public or static, depending on its attributes
sub fn_declare($$$)
{
@@ -757,7 +745,6 @@ sub ParseElementPrint($$$)
pidl "ndr_print_$l->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name);";
} elsif ($l->{TYPE} eq "SWITCH") {
my $switch_var = ParseExpr($l->{SWITCH_IS}, $env);
- check_null_pointer_void($switch_var);
pidl "ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);";
}
}
@@ -1707,7 +1694,7 @@ sub ParseUnionPull($$)
pidl "int level;";
if (defined($switch_type)) {
if (Parse::Pidl::Typelist::typeIs($switch_type, "ENUM")) {
- $switch_type = Parse::Pidl::Typelist::enum_type_fn(getType($switch_type));
+ $switch_type = Parse::Pidl::Typelist::enum_type_fn(getType($switch_type)->{DATA});
}
pidl mapType($switch_type) . " _level;";
}
diff --git a/tools/pidl/lib/Parse/Pidl/Typelist.pm b/tools/pidl/lib/Parse/Pidl/Typelist.pm
index 66d5e59e7c..88f896632d 100644
--- a/tools/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/tools/pidl/lib/Parse/Pidl/Typelist.pm
@@ -153,6 +153,7 @@ sub RegisterScalars()
sub enum_type_fn($)
{
my $enum = shift;
+ $enum->{TYPE} eq "ENUM" or die("not an enum");
if (has_property($enum->{PARENT}, "enum8bit")) {
return "uint8";
} elsif (has_property($enum->{PARENT}, "v1_enum")) {
@@ -165,6 +166,8 @@ sub bitmap_type_fn($)
{
my $bitmap = shift;
+ $bitmap->{TYPE} eq "BITMAP" or die("not an enum");
+
if (has_property($bitmap, "bitmap8bit")) {
return "uint8";
} elsif (has_property($bitmap, "bitmap16bit")) {
diff --git a/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index 93927f8f54..163b3053f4 100644
--- a/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ b/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
@@ -347,7 +347,7 @@ sub ReadConformance($$)
shift @fields;
if (not defined($field_handlers{$cmd})) {
- print "$f:$ln: Warning: Unknown command `$cmd'\n";
+ print "$f:$ln: warning: Unknown command `$cmd'\n";
next;
}
diff --git a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index b91ba10e98..8793dd5774 100644
--- a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -36,6 +36,7 @@ sub error($$)
my @ett;
my %hf_used = ();
+my %return_types = ();
my %dissector_used = ();
my $conformance = undef;
@@ -146,7 +147,7 @@ sub Enum($$$)
}
pidl_hdr "extern const value_string $valsstring\[];";
- pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);";
+ pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 *param);";
pidl_def "const value_string ".$valsstring."[] = {";
foreach (@{$e->{ELEMENTS}}) {
@@ -159,10 +160,10 @@ sub Enum($$$)
pidl_fn_start $dissectorname;
pidl_code "int";
- pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)";
+ pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 *param)";
pidl_code "{";
indent;
- pidl_code "offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, NULL);";
+ pidl_code "offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, param);";
pidl_code "return offset;";
deindent;
pidl_code "}\n";
@@ -434,7 +435,20 @@ sub Function($$$)
pidl_code "$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)";
pidl_code "{";
indent;
- pidl_code "guint32 status;\n";
+ if ( not defined($fn->{RETURN_TYPE})) {
+ } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS" or $fn->{RETURN_TYPE} eq "WERROR")
+ {
+ pidl_code "guint32 status;\n";
+ } elsif (my $type = getType($fn->{RETURN_TYPE})) {
+ if ($type->{DATA}->{TYPE} eq "ENUM") {
+ pidl_code "g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA}) . " status;\n";
+ } else {
+ print "$fn->{FILE}:$fn->{LINE}: error: return type `$fn->{RETURN_TYPE}' not yet supported\n";
+ }
+ } else {
+ print "$fn->{FILE}:$fn->{LINE}: error: unknown return type `$fn->{RETURN_TYPE}'\n";
+ }
+
foreach (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$_->{DIRECTION}})) {
pidl_code "$dissectornames{$_->{NAME}}";
@@ -448,15 +462,23 @@ sub Function($$$)
pidl_code "offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf\_$ifname\_status, &status);\n";
pidl_code "if (status != 0 && check_col(pinfo->cinfo, COL_INFO))";
pidl_code "\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, NT_errors, \"Unknown NT status 0x%08x\"));\n";
- $hf_used{"hf\_$ifname\_status"} = 1;
+ $return_types{$ifname}->{"status"} = ["NTSTATUS", "Windows Error"];
} elsif ($fn->{RETURN_TYPE} eq "WERROR") {
pidl_code "offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf\_$ifname\_werror, &status);\n";
pidl_code "if (status != 0 && check_col(pinfo->cinfo, COL_INFO))";
pidl_code "\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, WERR_errors, \"Unknown DOS error 0x%08x\"));\n";
- $hf_used{"hf\_$ifname\_werror"} = 1;
- } else {
- print "$fn->{FILE}:$fn->{LINE}: error: return type `$fn->{RETURN_TYPE}' not yet supported\n";
+ $return_types{$ifname}->{"werror"} = ["WERROR", "Windows Error"];
+ } elsif (my $type = getType($fn->{RETURN_TYPE})) {
+ if ($type->{DATA}->{TYPE} eq "ENUM") {
+ my $return_type = "g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
+ my $return_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
+
+ pidl_code "offset = $return_dissect(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);";
+ pidl_code "if (status != 0 && check_col(pinfo->cinfo, COL_INFO))";
+ pidl_code "\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %s\", val_to_str(status, $ifname\_$fn->{RETURN_TYPE}\_vals, \"Unknown " . $fn->{RETURN_TYPE} . " error 0x%08x\"));\n";
+ $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
+ }
}
@@ -556,8 +578,8 @@ sub Union($$$)
my $switch_dissect;
my $switch_dt = getType($e->{SWITCH_TYPE});
if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
- $switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt);
- $switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt);
+ $switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
+ $switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
} elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
$switch_type = "g$e->{SWITCH_TYPE}";
$switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
@@ -739,17 +761,17 @@ sub ProcessInterface($)
pidl_def "";
}
+ $return_types{$x->{NAME}} = {};
+
Interface($x);
pidl_code "\n".DumpFunctionTable($x);
- # Only register these two return types if they were actually used
- if (defined($hf_used{"hf_$x->{NAME}_status"})) {
- register_hf_field("hf_$x->{NAME}_status", "Status", "$x->{NAME}.status", "FT_UINT32", "BASE_HEX", "VALS(NT_errors)", 0, "");
- }
-
- if (defined($hf_used{"hf_$x->{NAME}_werror"})) {
- register_hf_field("hf_$x->{NAME}_werror", "Windows Error", "$x->{NAME}.werror", "FT_UINT32", "BASE_HEX", "VALS(WERR_errors)", 0, "");
+ foreach (keys %{$return_types{$x->{NAME}}}) {
+ my ($type, $desc) = @{$return_types{$x->{NAME}}->{$_}};
+ my $dt = find_type($type);
+ register_hf_field("hf_$x->{NAME}_$_", $desc, "$x->{NAME}.$_", $dt->{FT_TYPE}, "BASE_HEX", $dt->{VALSSTRING}, 0, "");
+ $hf_used{"hf_$x->{NAME}_$_"} = 1;
}
RegisterInterface($x);