From a2fd2488c79902dfe1de764bea4f619ec6107fed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Nov 2004 13:46:39 +0000 Subject: r3484: - add support for conformant string arrays at the end of a struct - add support for strings where the length excludes the NULLTERM metze (This used to be commit 8251d8b3e5af351972aa41aed63f7a7d2640910e) --- source4/build/pidl/parser.pm | 16 ++++++++++++++-- source4/build/pidl/util.pm | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'source4/build') diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index c52be637ec..34f9df197f 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -705,7 +705,6 @@ sub ParseElementPullBuffer($$$) sub ParseStructPush($) { my($struct) = shift; - my $conform_e; if (! defined $struct->{ELEMENTS}) { return; @@ -722,10 +721,14 @@ sub ParseStructPush($) if (defined $e->{ARRAY_LEN} && $e->{ARRAY_LEN} eq "*") { my $size = find_size_var($e, util::array_size($e), "r->"); $e->{CONFORMANT_SIZE} = $size; - $conform_e = $e; pidl "\tNDR_CHECK(ndr_push_uint32(ndr, $size));\n"; } + if (defined $e->{TYPE} && $e->{TYPE} eq "string" + && util::property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) { + pidl "\tNDR_CHECK(ndr_push_uint32(ndr, ndr_string_array_size(ndr, r->$e->{NAME})));\n"; + } + pidl "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; pidl "\tNDR_CHECK(ndr_push_struct_start(ndr));\n"; @@ -790,6 +793,15 @@ sub ParseStructPull($) my $e = $struct->{ELEMENTS}[-1]; if (defined $e->{ARRAY_LEN} && $e->{ARRAY_LEN} eq "*") { $conform_e = $e; + } + + if (defined $e->{TYPE} && $e->{TYPE} eq "string" + && util::property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) { + $conform_e = $e; + } + + if (defined $conform_e) { + $conform_e = $e; pidl "\tuint32_t _conformant_size;\n"; $conform_e->{CONFORMANT_SIZE} = "_conformant_size"; } diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm index c49e956e50..bddce57740 100644 --- a/source4/build/pidl/util.pm +++ b/source4/build/pidl/util.pm @@ -181,6 +181,24 @@ sub has_property($$) return $e->{PROPERTIES}->{$p}; } +##################################################################### +# see if a pidl property matches a value +sub property_matches($$$) +{ + my($e) = shift; + my($p) = shift; + my($v) = shift; + + if (!defined has_property($e, $p)) { + return undef; + } + + if ($e->{PROPERTIES}->{$p} =~ /$v/) { + return 1; + } + + return undef; +} sub is_scalar_type($) { -- cgit