summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-15 10:57:17 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-15 10:57:17 +0000
commit54ccb9c6a2510c3e76603459f09d911c1dc3354e (patch)
tree69fbb8c5a695643ae31b102d79d8a150ac2684d9 /source4/build
parent42a25ebb75f29c9d67232312c99ecbd5555e50b2 (diff)
downloadsamba-54ccb9c6a2510c3e76603459f09d911c1dc3354e.tar.gz
samba-54ccb9c6a2510c3e76603459f09d911c1dc3354e.tar.bz2
samba-54ccb9c6a2510c3e76603459f09d911c1dc3354e.zip
added support for varying conformant arrays (needed for samr
userinfo3) (This used to be commit f5b577a2b9d8084c8ee3f5b646b059c3297695b4)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/parser.pm28
-rw-r--r--source4/build/pidl/util.pm11
2 files changed, 34 insertions, 5 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 60fdd38379..99f3fdf4bb 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -86,11 +86,18 @@ sub ParseArrayPush($$$)
if (defined $e->{CONFORMANT_SIZE}) {
# the conformant size has already been pushed
- } elsif (!util::is_constant($size)) {
+ } elsif (!util::is_fixed_array($e)) {
# we need to emit the array size
$res .= "\t\tNDR_CHECK(ndr_push_uint32(ndr, $size));\n";
}
+ if (my $length = util::has_property($e, "length_is")) {
+ $length = find_size_var($e, $length);
+ $res .= "\t\tNDR_CHECK(ndr_push_uint32(ndr, 0));\n";
+ $res .= "\t\tNDR_CHECK(ndr_push_uint32(ndr, $length));\n";
+ $size = $length;
+ }
+
if (util::is_scalar_type($e->{TYPE})) {
$res .= "\t\tNDR_CHECK(ndr_push_array_$e->{TYPE}(ndr, $var_prefix$e->{NAME}, $size));\n";
} else {
@@ -105,6 +112,11 @@ sub ParseArrayPrint($$)
my $e = shift;
my $var_prefix = shift;
my $size = find_size_var($e, util::array_size($e));
+ my $length = util::has_property($e, "length_is");
+
+ if (defined $length) {
+ $size = find_size_var($e, $length);
+ }
if (util::is_scalar_type($e->{TYPE})) {
$res .= "\t\tndr_print_array_$e->{TYPE}(ndr, \"$e->{NAME}\", $var_prefix$e->{NAME}, $size);\n";
@@ -132,7 +144,7 @@ sub ParseArrayPull($$$)
$res .= "\tif ($size > $alloc_size) {\n";
$res .= "\t\treturn ndr_pull_error(ndr, NDR_ERR_CONFORMANT_SIZE, \"Bad conformant size %u should be %u\", $alloc_size, $size);\n";
$res .= "\t}\n";
- } elsif (!util::is_constant($size)) {
+ } elsif (!util::is_fixed_array($e)) {
# non fixed arrays encode the size just before the array
$res .= "\t{\n";
$res .= "\t\tuint32 _array_size;\n";
@@ -143,12 +155,18 @@ sub ParseArrayPull($$$)
$res .= "\t}\n";
}
- if (util::need_alloc($e) && !util::is_constant($size)) {
+ if (util::need_alloc($e) && !util::is_fixed_array($e)) {
$res .= "\t\tNDR_ALLOC_N_SIZE(ndr, $var_prefix$e->{NAME}, $alloc_size, sizeof($var_prefix$e->{NAME}\[0]));\n";
}
- if (util::has_property($e, "length_is")) {
- die "we don't handle varying arrays yet";
+ if (my $length = util::has_property($e, "length_is")) {
+ $length = find_size_var($e, $length);
+ $res .= "\t\tuint32 _offset, _length;\n";
+ $res .= "\t\tNDR_CHECK(ndr_pull_uint32(ndr, &_offset));\n";
+ $res .= "\t\tNDR_CHECK(ndr_pull_uint32(ndr, &_length));\n";
+ $res .= "\t\tif (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, \"Bad array offset 0x%08x\", _offset);\n";
+ $res .= "\t\tif (_length > $size || _length != $length) return ndr_pull_error(ndr, NDR_ERR_LENGTH, \"Bad array length 0x%08x > size 0x%08x\", _offset, $size);\n";
+ $size = "_length";
}
if (util::is_scalar_type($e->{TYPE})) {
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 341502e551..383bcdfd07 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -353,6 +353,17 @@ sub is_constant($)
return 0;
}
+# return 1 if this is a fixed array
+sub is_fixed_array($)
+{
+ my $e = shift;
+ my $len = $e->{"ARRAY_LEN"};
+ if (defined $len && is_constant($len)) {
+ return 1;
+ }
+ return 0;
+}
+
sub dump($)
{
print Dumper shift;