From e8558986debb4f4fc64ae678f2a36059f11e9beb Mon Sep 17 00:00:00 2001 From: jmayer Date: Tue, 25 Apr 2006 13:40:04 +0000 Subject: Update from samba tree revision 14805 to 15243 ============================ Samba log start ============ svn: When specifying working copy paths, only one target may be given ============================ Samba log end ============== git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17994 f5534014-38df-0310-8fa8-9805f1628bb7 --- tools/pidl/lib/Parse/Pidl/Samba4.pm | 32 +++++++++++++++++++ tools/pidl/lib/Parse/Pidl/Samba4/EJS.pm | 12 +++++-- tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 1 + tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 1 + tools/pidl/lib/Parse/Pidl/Samba4/TDR.pm | 1 + tools/pidl/tests/Util.pm | 1 + tools/pidl/tests/ndr_represent.pl | 43 ++++++++++++++++++++++++++ tools/pidl/tests/ndr_tagtype.pl | 38 +++++++++++++++++++++++ 8 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 tools/pidl/lib/Parse/Pidl/Samba4.pm create mode 100644 tools/pidl/tests/ndr_represent.pl create mode 100755 tools/pidl/tests/ndr_tagtype.pl (limited to 'tools/pidl') diff --git a/tools/pidl/lib/Parse/Pidl/Samba4.pm b/tools/pidl/lib/Parse/Pidl/Samba4.pm new file mode 100644 index 0000000000..0a284aa85b --- /dev/null +++ b/tools/pidl/lib/Parse/Pidl/Samba4.pm @@ -0,0 +1,32 @@ +################################################### +# Common Samba4 functions +# Copyright jelmer@samba.org 2006 +# released under the GNU GPL + +package Parse::Pidl::Samba4; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(is_intree choose_header); + +use Parse::Pidl::Util qw(has_property); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +sub is_intree() +{ + return -f "include/smb.h"; +} + +# Return an #include line depending on whether this build is an in-tree +# build or not. +sub choose_header($$) +{ + my ($in,$out) = @_; + return "#include \"$in\"" if (is_intree()); + return "#include <$out>"; +} + +1; diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/EJS.pm b/tools/pidl/lib/Parse/Pidl/Samba4/EJS.pm index 41ea1e8eaa..550499a5f3 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/EJS.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/EJS.pm @@ -154,7 +154,11 @@ sub EjsPullPointer($$$$$) my ($e, $l, $var, $name, $env) = @_; pidl "if (ejs_pull_null(ejs, v, $name)) {"; indent; - pidl "$var = NULL;"; + if ($l->{POINTER_TYPE} eq "ref") { + pidl "return NT_STATUS_INVALID_PARAMETER_MIX;"; + } else { + pidl "$var = NULL;"; + } deindent; pidl "} else {"; indent; @@ -450,7 +454,11 @@ sub EjsPushPointer($$$$$) my ($e, $l, $var, $name, $env) = @_; pidl "if (NULL == $var) {"; indent; - pidl "NDR_CHECK(ejs_push_null(ejs, v, $name));"; + if ($l->{POINTER_TYPE} eq "ref") { + pidl "return NT_STATUS_INVALID_PARAMETER_MIX;"; + } else { + pidl "NDR_CHECK(ejs_push_null(ejs, v, $name));"; + } deindent; pidl "} else {"; indent; diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index ace1e79672..3b12c8f173 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -105,6 +105,7 @@ sub Parse($$$$) } else { $res .= "#define _GNU_SOURCE\n"; $res .= "#include \n"; + $res .= "#include \n"; $res .= "#include \n"; $res .= "#include \n"; $res .= "#include \n"; diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 07128568bd..38e3268356 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -2356,6 +2356,7 @@ sub Parse($$$) pidl "#include "; pidl "#include "; pidl "#include "; + pidl "#include "; pidl "#include "; pidl "#include "; } diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/tools/pidl/lib/Parse/Pidl/Samba4/TDR.pm index 7e597dfb34..592961dee2 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/TDR.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/TDR.pm @@ -242,6 +242,7 @@ sub Parser($$$) pidl "#include \"includes.h\""; } else { pidl "#include "; + pidl "#include "; pidl "#include "; pidl "#include "; pidl "#include "; diff --git a/tools/pidl/tests/Util.pm b/tools/pidl/tests/Util.pm index fde92c2a77..ccac1a6d7e 100644 --- a/tools/pidl/tests/Util.pm +++ b/tools/pidl/tests/Util.pm @@ -54,6 +54,7 @@ SKIP: { print CC "#include \n"; print CC "#include \n"; print CC "#include \n"; + print CC "#include \n"; print CC "#include \n"; print CC $header; print CC $ndrheader; diff --git a/tools/pidl/tests/ndr_represent.pl b/tools/pidl/tests/ndr_represent.pl new file mode 100644 index 0000000000..3c6b8cf6ab --- /dev/null +++ b/tools/pidl/tests/ndr_represent.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# NDR represent_as() / transmit_as() tests +# (C) 2006 Jelmer Vernooij. Published under the GNU GPL +use strict; + +use Test::More tests => 1 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +test_samba4_ndr('represent_as-simple', +' + void bla([in,represent_as(uint32)] uint8 x); +', +' + uint8_t expected[] = { 0x0D }; + DATA_BLOB in_blob = { expected, 1 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct bla r; + + if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + if (r.in.x != 13) + return 2; +', +' +#include + +NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) +{ + *to = from; + return NT_STATUS_OK; +} + +NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) +{ + *to = from; + return NT_STATUS_OK; +} +' +); diff --git a/tools/pidl/tests/ndr_tagtype.pl b/tools/pidl/tests/ndr_tagtype.pl new file mode 100755 index 0000000000..dcdbc22494 --- /dev/null +++ b/tools/pidl/tests/ndr_tagtype.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# Support for tagged types +# (C) 2005 Jelmer Vernooij. Published under the GNU GPL +use strict; + +use Test::More tests => 1 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +SKIP: { + skip "Tagged types without typedef are not supported yet", 8; + +test_samba4_ndr('struct-notypedef', +' + struct bla { + uint8 x; + }; +', +' + struct ndr_push *ndr = ndr_push_init(); + struct bla r; + uint8_t expected[] = { 0x0D }; + DATA_BLOB expected_blob = { expected, 1 }; + DATA_BLOB result_blob; + r.x = 13; + + if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (!data_blob_equal(&result_blob, &expected_blob)) + return 2; +'); + +} -- cgit v1.2.3