summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Wireshark
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-08 23:54:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:54 -0500
commit45db1030651e69896fdb9e78aa2e2495a7ce7ff5 (patch)
tree86734e4199b036ac8ade8c39cd7b10cd112c4b73 /source4/pidl/lib/Parse/Pidl/Wireshark
parent57a68c93178ee9e0159366a8b02af01a86e601f5 (diff)
downloadsamba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.tar.gz
samba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.tar.bz2
samba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.zip
r21253: Merge some pidl fixes:
* Add tests for wireshark dissector generator * Add tests for the header code * Some cleanups * Fix handling of elements without [in] or [out] (This used to be commit 1aecba7100685ed291ea13b0ae47fb0cf9e6a6c8)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Wireshark')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm48
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm6
2 files changed, 44 insertions, 10 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index 4ad60319a6..9798c7c552 100644
--- a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
@@ -96,7 +96,7 @@ use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
-@EXPORT_OK = qw(ReadConformance);
+@EXPORT_OK = qw(ReadConformance ReadConformanceFH);
use strict;
@@ -157,7 +157,7 @@ sub handle_hf_rename($$$$)
my ($pos,$data,$old,$new) = @_;
unless(defined($new)) {
- error($pos, "incomplete HF_RENAME command");
+ warning($pos, "incomplete HF_RENAME command");
return;
}
@@ -253,6 +253,11 @@ sub handle_manual($$$)
{
my ($pos,$data,$fn) = @_;
+ unless(defined($fn)) {
+ warning($pos, "incomplete MANUAL command");
+ return;
+ }
+
$data->{manual}->{$fn} = 1;
}
@@ -271,6 +276,11 @@ sub handle_fielddescription($$$$)
{
my ($pos,$data,$field,$desc) = @_;
+ unless(defined($desc)) {
+ warning($pos, "incomplete FIELD_DESCRIPTION command");
+ return;
+ }
+
$data->{fielddescription}->{$field} = {
DESCRIPTION => $desc,
POS => $pos,
@@ -314,16 +324,26 @@ my %field_handlers = (
sub ReadConformance($$)
{
my ($f,$data) = @_;
+ my $ret;
- $data->{override} = "";
+ open(IN,"<$f") or return undef;
- my $incodeblock = 0;
+ $ret = ReadConformanceFH(*IN, $data, $f);
- open(IN,"<$f") or return undef;
+ close(IN);
+
+ return $ret;
+}
+
+sub ReadConformanceFH($$$)
+{
+ my ($fh,$data,$f) = @_;
+
+ my $incodeblock = 0;
my $ln = 0;
- foreach (<IN>) {
+ foreach (<$fh>) {
$ln++;
next if (/^#.*$/);
next if (/^$/);
@@ -337,7 +357,11 @@ sub ReadConformance($$)
$incodeblock = 0;
next;
} elsif ($incodeblock) {
- $data->{override}.="$_\n";
+ if (exists $data->{override}) {
+ $data->{override}.="$_\n";
+ } else {
+ $data->{override} = "$_\n";
+ }
next;
}
@@ -349,6 +373,8 @@ sub ReadConformance($$)
my $pos = { FILE => $f, LINE => $ln };
+ next unless(defined($cmd));
+
if (not defined($field_handlers{$cmd})) {
warning($pos, "Unknown command `$cmd'");
next;
@@ -357,7 +383,13 @@ sub ReadConformance($$)
$field_handlers{$cmd}($pos, $data, @fields);
}
- close(IN);
+ if ($incodeblock) {
+ warning({ FILE => $f, LINE => $ln },
+ "Expecting CODE END");
+ return undef;
+ }
+
+ return 1;
}
1;
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 9415c16652..646f5fdabc 100644
--- a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -2,7 +2,7 @@
# Samba4 NDR parser generator for IDL structures
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001,2005
-# Copyright jelmer@samba.org 2004-2005
+# Copyright jelmer@samba.org 2004-2007
# Portions based on idl2eth.c by Ronnie Sahlberg
# released under the GNU GPL
@@ -918,7 +918,9 @@ sub Parse($$$$)
$parser.=$res{ett};
$parser.=$res{hf};
$parser.=$res{def};
- $parser.=$conformance->{override};
+ if (exists ($conformance->{override})) {
+ $parser.=$conformance->{override};
+ }
$parser.=$res{code};
my $header = "/* autogenerated by pidl */\n\n";