diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/NDR.pm | 28 | ||||
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm | 17 | ||||
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/Samba4.pm | 29 | ||||
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 6 | ||||
-rwxr-xr-x | tools/pidl/pidl | 8 | ||||
-rw-r--r-- | tools/pidl/tests/Util.pm | 5 | ||||
-rwxr-xr-x | tools/pidl/tests/ndr_align.pl | 6 | ||||
-rw-r--r-- | tools/pidl/tests/ndr_represent.pl | 2 | ||||
-rwxr-xr-x | tools/pidl/tests/ndr_string.pl | 2 |
9 files changed, 64 insertions, 39 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/NDR.pm b/tools/pidl/lib/Parse/Pidl/NDR.pm index a80bb954c1..9670e05744 100644 --- a/tools/pidl/lib/Parse/Pidl/NDR.pm +++ b/tools/pidl/lib/Parse/Pidl/NDR.pm @@ -70,8 +70,6 @@ my $scalar_alignment = { 'ipv4address' => 4 }; - - sub nonfatal($$) { my ($e,$s) = @_; @@ -135,8 +133,7 @@ sub GetElementLevelTable($) $is_string = 1; delete($e->{PROPERTIES}->{string}); } else { - print "$e->{FILE}:$e->{LINE}: Must specify size_is() for conformant array!\n"; - exit 1; + fatal($e, "Must specify size_is() for conformant array!") } if (($length = shift @length_is) or $is_string) { @@ -184,6 +181,11 @@ sub GetElementLevelTable($) LEVEL => $level }); + nonfatal($e, "top-level \[out\] pointer `$e->{NAME}' is not a \[ref\] pointer") + if ($i == 1 and pointer_type($e) ne "ref" and + $e->{PARENT}->{TYPE} eq "FUNCTION" and + not has_property($e, "in")); + $pointer_idx++; # everything that follows will be deferred @@ -307,7 +309,7 @@ sub pointer_type($) return undef unless $e->{POINTERS}; return "ref" if (has_property($e, "ref")); - return "ptr" if (has_property($e, "ptr")); + return "full" if (has_property($e, "ptr")); return "sptr" if (has_property($e, "sptr")); return "unique" if (has_property($e, "unique")); return "relative" if (has_property($e, "relative")); @@ -605,6 +607,8 @@ sub ParseInterface($) if (not has_property($idl, "pointer_default_top")) { $idl->{PROPERTIES}->{pointer_default_top} = "ref"; + } else { + nonfatal($idl, "pointer_default_top() is a pidl extension and should not be used"); } foreach my $d (@{$idl->{DATA}}) { @@ -785,7 +789,6 @@ my %property_list = ( # pointer "ref" => ["ELEMENT"], "ptr" => ["ELEMENT"], - "sptr" => ["ELEMENT"], "unique" => ["ELEMENT"], "ignore" => ["ELEMENT"], "relative" => ["ELEMENT"], @@ -881,10 +884,6 @@ sub ValidElement($) ValidProperties($e,"ELEMENT"); - if (has_property($e, "ptr")) { - fatal($e, el_name($e) . " : pidl does not support full NDR pointers yet\n"); - } - # Check whether switches are used correctly. if (my $switch = has_property($e, "switch_is")) { my $e2 = find_sibling($e, $switch); @@ -942,7 +941,6 @@ sub ValidElement($) if (!$e->{POINTERS} && ( has_property($e, "ptr") or - has_property($e, "sptr") or has_property($e, "unique") or has_property($e, "relative") or has_property($e, "ref"))) { @@ -1050,9 +1048,11 @@ sub ValidInterface($) ValidProperties($interface,"INTERFACE"); - if (has_property($interface, "pointer_default") && - $interface->{PROPERTIES}->{pointer_default} eq "ptr") { - fatal $interface, "Full pointers are not supported yet\n"; + if (has_property($interface, "pointer_default")) { + if (not grep (/$interface->{PROPERTIES}->{pointer_default}/, + ("ref", "unique", "ptr"))) { + fatal $interface, "Unknown default pointer type `$interface->{PROPERTIES}->{pointer_default}'"; + } } if (has_property($interface, "object")) { diff --git a/tools/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/tools/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index c939feb1b9..6cfab753e9 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -10,7 +10,7 @@ use strict; use Parse::Pidl::Typelist qw(hasType getType mapType scalar_is_reference); use Parse::Pidl::Util qw(has_property ParseExpr is_constant); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); -use Parse::Pidl::Samba4 qw(DeclLong); +use Parse::Pidl::Samba4 qw(DeclLong_cli IsUniqueOut); use vars qw($VERSION); $VERSION = '0.01'; @@ -36,7 +36,7 @@ sub ParseFunction($$) my $ufn = "DCERPC_".uc($fn->{NAME}); foreach (@{$fn->{ELEMENTS}}) { - $defargs .= ", " . DeclLong($_); + $defargs .= ", " . DeclLong_cli($_); } fn_declare "NTSTATUS rpccli_$fn->{NAME}(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx$defargs)"; pidl "{"; @@ -48,7 +48,12 @@ sub ParseFunction($$) foreach (@{$fn->{ELEMENTS}}) { if (grep(/in/, @{$_->{DIRECTION}})) { + if ( IsUniqueOut($_) ) { + pidl "r.in.$_->{NAME} = *$_->{NAME};"; + } + else { pidl "r.in.$_->{NAME} = $_->{NAME};"; + } } } @@ -79,12 +84,8 @@ sub ParseFunction($$) fatal($e, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY"); - if ( ($e->{LEVELS}[0]->{TYPE} eq "POINTER") && ($e->{LEVELS}[0]->{POINTER_TYPE} eq "unique") ) { - pidl "if ( $e->{NAME} ) {"; - indent; - pidl "*$e->{NAME} = *r.out.$e->{NAME};"; - deindent; - pidl "}"; + if ( IsUniqueOut($e) ) { + pidl "*$e->{NAME} = r.out.$e->{NAME};"; } else { pidl "*$e->{NAME} = *r.out.$e->{NAME};"; } diff --git a/tools/pidl/lib/Parse/Pidl/Samba4.pm b/tools/pidl/lib/Parse/Pidl/Samba4.pm index 4ef2daa591..e11bd6a5ff 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4.pm @@ -7,7 +7,7 @@ package Parse::Pidl::Samba4; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(is_intree choose_header DeclLong); +@EXPORT = qw(is_intree choose_header DeclLong DeclLong_cli IsUniqueOut); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::Typelist qw(mapType scalar_is_reference); @@ -32,9 +32,19 @@ sub choose_header($$) return "#include <$out>"; } -sub DeclLong($) +sub IsUniqueOut($) { - my($element) = shift; + my ($e) = shift; + + return grep(/out/, @{$e->{DIRECTION}}) && + ((($e->{LEVELS}[0]->{TYPE} eq "POINTER") && + ($e->{LEVELS}[0]->{POINTER_TYPE} eq "unique")) || + ($e->{LEVELS}[0]->{TYPE} eq "ARRAY")); +} + +sub DeclLong_int($$) +{ + my($element,$cli) = @_; my $ret = ""; if (has_property($element, "represent_as")) { @@ -57,6 +67,9 @@ sub DeclLong($) not has_property($element, "charset"); $numstar++; } + if ($cli && IsUniqueOut($element)) { + $numstar++; + } $ret.="*" foreach (1..$numstar); } $ret.=$element->{NAME}; @@ -68,4 +81,14 @@ sub DeclLong($) return $ret; } +sub DeclLong($) +{ + return DeclLong_int($_, 0); +} + +sub DeclLong_cli($) +{ + return DeclLong_int($_, 1); +} + 1; diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index d871ed38bb..f104ffbad8 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -669,8 +669,8 @@ sub ParsePtrPush($$$) pidl "NDR_CHECK(ndr_push_relative_ptr1(ndr, $var_name));"; } elsif ($l->{POINTER_TYPE} eq "unique") { pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_name));"; - } elsif ($l->{POINTER_TYPE} eq "sptr") { - pidl "NDR_CHECK(ndr_push_sptr_ptr(ndr, $var_name));"; + } elsif ($l->{POINTER_TYPE} eq "full") { + pidl "NDR_CHECK(ndr_push_full_ptr(ndr, $var_name));"; } else { die("Unhandled pointer type $l->{POINTER_TYPE}"); } @@ -1085,7 +1085,7 @@ sub ParsePtrPull($$$$) return; } elsif (($l->{POINTER_TYPE} eq "unique") or ($l->{POINTER_TYPE} eq "relative") or - ($l->{POINTER_TYPE} eq "sptr")) { + ($l->{POINTER_TYPE} eq "full")) { pidl "NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));"; pidl "if (_ptr_$e->{NAME}) {"; indent; diff --git a/tools/pidl/pidl b/tools/pidl/pidl index 397378e443..8084213e5d 100755 --- a/tools/pidl/pidl +++ b/tools/pidl/pidl @@ -268,12 +268,12 @@ Datagram support (ncadg_*) =back -=head2 Supported attributes +=head2 Supported attributes and statements in, out, ref, length_is, switch_is, size_is, uuid, case, default, string, unique, ptr, pointer_default, v1_enum, object, helpstring, range, local, call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as, -transmit_as. +transmit_as, import, include. =head2 PIDL Specific properties @@ -342,13 +342,13 @@ to the host format. Commonly used values are UCS2, DOS and UTF8. =back -=head2 Unsupported MIDL properties +=head2 Unsupported MIDL properties or statements aggregatable, appobject, async_uuid, bindable, control, cpp_quote, defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface, displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext, helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib, -import, include, includelib, last_is, lcid, licensed, max_is, module, +includelib, last_is, lcid, licensed, max_is, module, ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl, oleautomation, optional, pragma, propget, propputref, propput, readonly, requestedit, restricted, retval, source, uidefault, diff --git a/tools/pidl/tests/Util.pm b/tools/pidl/tests/Util.pm index ccac1a6d7e..83651e6073 100644 --- a/tools/pidl/tests/Util.pm +++ b/tools/pidl/tests/Util.pm @@ -35,7 +35,7 @@ sub test_samba4_ndr SKIP: { skip "no samba environment available, skipping compilation", 3 - if (system("pkg-config --exists dcerpc ndr") != 0); + if (system("pkg-config --exists ndr") != 0); my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; @@ -46,7 +46,7 @@ SKIP: { $outfile = "test-$name"; } - my $cflags = `pkg-config --libs --cflags dcerpc ndr`; + my $cflags = `pkg-config --libs --cflags ndr`; open CC, "|cc -x c - -o $outfile $cflags"; print CC "#define uint_t unsigned int\n"; @@ -56,6 +56,7 @@ SKIP: { print CC "#include <stdio.h>\n"; print CC "#include <stdbool.h>\n"; print CC "#include <stdarg.h>\n"; + print CC "#include <core.h>\n"; print CC $header; print CC $ndrheader; print CC $extra if ($extra); diff --git a/tools/pidl/tests/ndr_align.pl b/tools/pidl/tests/ndr_align.pl index c05f6383ed..26f41377e7 100755 --- a/tools/pidl/tests/ndr_align.pl +++ b/tools/pidl/tests/ndr_align.pl @@ -119,11 +119,11 @@ test_samba4_ndr('align-blob-align2', uint8 x; [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; uint8 y; - } bla; + } blie; ', ' struct ndr_push *ndr = ndr_push_init(); - struct bla r; + struct blie r; uint8_t data[] = { 0x01, 0x02 }; uint8_t expected[] = { 0x0D, 0x00, 0x0E }; DATA_BLOB expected_blob = { expected, 3 }; @@ -134,7 +134,7 @@ test_samba4_ndr('align-blob-align2', r.data.data = data; r.data.length = 2; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (NT_STATUS_IS_ERR(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); diff --git a/tools/pidl/tests/ndr_represent.pl b/tools/pidl/tests/ndr_represent.pl index 3c6b8cf6ab..93764451cf 100644 --- a/tools/pidl/tests/ndr_represent.pl +++ b/tools/pidl/tests/ndr_represent.pl @@ -26,7 +26,7 @@ test_samba4_ndr('represent_as-simple', return 2; ', ' -#include <core/nterr.h> +#include <libcli/util/nterr.h> NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { diff --git a/tools/pidl/tests/ndr_string.pl b/tools/pidl/tests/ndr_string.pl index 00ccbb31bb..9a09261996 100755 --- a/tools/pidl/tests/ndr_string.pl +++ b/tools/pidl/tests/ndr_string.pl @@ -79,6 +79,6 @@ test_samba4_ndr("string-out", if (strncmp(r.out.data, "foo", 3) != 0) return 3; - if (r.in.data[4] != 0) + if (r.out.data[4] != 0) return 4; '); |