pidl: fix an error message typo
[obnox/samba/samba-obnox.git] / pidl / lib / Parse / Pidl / Samba4 / NDR / Parser.pm
index e2c901253de2352159515b81026fae9b0eb47e17..3deab2ec953435d8d47fdb49230ecb78e5e2ef11 100644 (file)
@@ -198,6 +198,12 @@ sub ParseArrayPushHeader($$$$$$)
                } else {
                        $size = $length = "ndr_string_length($var_name, sizeof(*$var_name))";
                }
+               if (defined($l->{SIZE_IS})) {
+                       $size = ParseExpr($l->{SIZE_IS}, $env, $e);
+               }
+               if (defined($l->{LENGTH_IS})) {
+                       $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
+               }
        } else {
                $size = ParseExpr($l->{SIZE_IS}, $env, $e);
                $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
@@ -255,7 +261,7 @@ sub check_fully_dereferenced($$)
                                $nump = $_->{POINTER_INDEX}+1;
                        }
                }
-               warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr));
+               warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully dereferenced variable") if ($nump > length($ptr));
                return ($origvar);
        }
 }      
@@ -315,44 +321,104 @@ sub check_null_pointer($$$$)
        }
 }
 
-#####################################################################
-# parse an array - pull side
-sub ParseArrayPullHeader($$$$$$)
+sub ParseArrayPullGetSize($$$$$$)
 {
        my ($self,$e,$l,$ndr,$var_name,$env) = @_;
 
-       my $length;
        my $size;
 
        if ($l->{IS_CONFORMANT}) {
-               $length = $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
+               $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
        } elsif ($l->{IS_ZERO_TERMINATED} and $l->{SIZE_IS} == 0 and $l->{LENGTH_IS} == 0) { # Noheader arrays
-               $length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
+               $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
        } else {
-               $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
+               $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
                        check_null_pointer($e, $env, sub { $self->pidl(shift); },
                                           "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
                        check_fully_dereferenced($e, $env));
        }
 
+       $self->pidl("size_$e->{NAME}_$l->{LEVEL_INDEX} = $size;");
+       my $array_size = "size_$e->{NAME}_$l->{LEVEL_INDEX}";
+
+       if (my $range = has_property($e, "range")) {
+               my ($low, $high) = split(/,/, $range, 2);
+               if ($low < 0) {
+                       warning(0, "$low is invalid for the range of an array size");
+               }
+               if ($low == 0) {
+                       $self->pidl("if ($array_size > $high) {");
+               } else {
+                       $self->pidl("if ($array_size < $low || $array_size > $high) {");
+               }
+               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
+               $self->pidl("}");
+       }
+
+       return $array_size;
+}
+
+#####################################################################
+# parse an array - pull side
+sub ParseArrayPullGetLength($$$$$$;$)
+{
+       my ($self,$e,$l,$ndr,$var_name,$env,$array_size) = @_;
+
+       if (not defined($array_size)) {
+               $array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
+       }
+
+       if (not $l->{IS_VARYING}) {
+               return $array_size;
+       }
+
+       my $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
+       $self->pidl("length_$e->{NAME}_$l->{LEVEL_INDEX} = $length;");
+       my $array_length = "length_$e->{NAME}_$l->{LEVEL_INDEX}";
+
+       if (my $range = has_property($e, "range")) {
+               my ($low, $high) = split(/,/, $range, 2);
+               if ($low < 0) {
+                       warning(0, "$low is invalid for the range of an array size");
+               }
+               if ($low == 0) {
+                       $self->pidl("if ($array_length > $high) {");
+               } else {
+                       $self->pidl("if ($array_length < $low || $array_length > $high) {");
+               }
+               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
+               $self->pidl("}");
+       }
+
+       return $array_length;
+}
+
+#####################################################################
+# parse an array - pull side
+sub ParseArrayPullHeader($$$$$$)
+{
+       my ($self,$e,$l,$ndr,$var_name,$env) = @_;
+
        if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
                $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));");
        }
 
        if ($l->{IS_VARYING}) {
                $self->pidl("NDR_CHECK(ndr_pull_array_length($ndr, " . get_pointer_to($var_name) . "));");
-               $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
        }
 
-       if ($length ne $size) {
-               $self->pidl("if ($length > $size) {");
+       my $array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
+       my $array_length = $self->ParseArrayPullGetLength($e, $l, $ndr, $var_name, $env, $array_size);
+
+       if ($array_length ne $array_size) {
+               $self->pidl("if ($array_length > $array_size) {");
                $self->indent;
-               $self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $size, $length);");
+               $self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $array_size, $array_length);");
                $self->deindent;
                $self->pidl("}");
        }
 
-       if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
+       if ($l->{IS_CONFORMANT} and (defined($l->{SIZE_IS}) or not $l->{IS_ZERO_TERMINATED})) {
                $self->defer("if ($var_name) {");
                $self->defer_indent;
                my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
@@ -364,7 +430,7 @@ sub ParseArrayPullHeader($$$$$$)
                $self->defer("}");
        }
 
-       if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
+       if ($l->{IS_VARYING} and (defined($l->{LENGTH_IS}) or not $l->{IS_ZERO_TERMINATED})) {
                $self->defer("if ($var_name) {");
                $self->defer_indent;
                my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, 
@@ -377,10 +443,10 @@ sub ParseArrayPullHeader($$$$$$)
        }
 
        if (ArrayDynamicallyAllocated($e,$l) and not is_charset_array($e,$l)) {
-               $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size);
+               $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$array_size);
        }
 
-       return $length;
+       return $array_length;
 }
 
 sub compression_alg($$)
@@ -566,7 +632,9 @@ sub ParseElementPushLevel
                }
        }
 
-       if ($l->{TYPE} eq "POINTER" and $deferred) {
+       if ($l->{TYPE} eq "POINTER" and $l->{POINTER_TYPE} eq "ignore") {
+               $self->pidl("/* [ignore] '$e->{NAME}' */");
+       } elsif ($l->{TYPE} eq "POINTER" and $deferred) {
                my $rel_var_name = $var_name;
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->pidl("if ($var_name) {");
@@ -747,6 +815,8 @@ sub ParseElementPrint($$$$$)
        my($self, $e, $ndr, $var_name, $env) = @_;
 
        return if (has_property($e, "noprint"));
+       my $cur_depth = 0;
+       my $ignore_depth = 0xFFFF;
 
        if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
                $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}($ndr, \"$e->{NAME}\", $var_name);");
@@ -760,8 +830,19 @@ sub ParseElementPrint($$$$$)
        }
 
        foreach my $l (@{$e->{LEVELS}}) {
+               $cur_depth += 1;
+
+               if ($cur_depth > $ignore_depth) {
+                       next;
+               }
+
                if ($l->{TYPE} eq "POINTER") {
                        $self->pidl("ndr_print_ptr($ndr, \"$e->{NAME}\", $var_name);");
+                       if ($l->{POINTER_TYPE} eq "ignore") {
+                               $self->pidl("/* [ignore] '$e->{NAME}' */");
+                               $ignore_depth = $cur_depth;
+                               last;
+                       }
                        $self->pidl("$ndr->depth++;");
                        if ($l->{POINTER_TYPE} ne "ref") {
                                $self->pidl("if ($var_name) {");
@@ -775,7 +856,7 @@ sub ParseElementPrint($$$$$)
                                $var_name = get_pointer_to($var_name); 
                        }
                        
-                       if ($l->{IS_ZERO_TERMINATED}) {
+                       if ($l->{IS_ZERO_TERMINATED} and not defined($l->{LENGTH_IS})) {
                                $length = "ndr_string_length($var_name, sizeof(*$var_name))";
                        } else {
                                $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, 
@@ -809,7 +890,17 @@ sub ParseElementPrint($$$$$)
        }
 
        foreach my $l (reverse @{$e->{LEVELS}}) {
+               $cur_depth -= 1;
+
+               if ($cur_depth > $ignore_depth) {
+                       next;
+               }
+
                if ($l->{TYPE} eq "POINTER") {
+                       if ($l->{POINTER_TYPE} eq "ignore") {
+                               next;
+                       }
+
                        if ($l->{POINTER_TYPE} ne "ref") {
                                $self->deindent;
                                $self->pidl("}");
@@ -867,7 +958,11 @@ sub ParseDataPull($$$$$$$)
 
                $var_name = get_pointer_to($var_name);
 
-               $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
+               if (has_property($e, "skip")) {
+                       $self->pidl("/* [skip] '$var_name' */");
+               } else {
+                       $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
+               }
 
                my $pl = GetPrevLevel($e, $l);
 
@@ -905,7 +1000,11 @@ sub ParseDataPush($$$$$$$)
                        $var_name = get_pointer_to($var_name);
                }
 
-               $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
+               if (has_property($e, "skip")) {
+                       $self->pidl("/* [skip] '$var_name' */");
+               } else {
+                       $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
+               }
        } else {
                $self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
        }
@@ -941,6 +1040,7 @@ sub ParseMemCtxPullFlags($$$$)
        my ($self, $e, $l) = @_;
 
        return undef unless ($l->{TYPE} eq "POINTER" or $l->{TYPE} eq "ARRAY");
+       return undef if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ignore"));
 
        return undef unless ($l->{TYPE} ne "ARRAY" or ArrayDynamicallyAllocated($e,$l));
        return undef if has_fast_array($e, $l);
@@ -1002,6 +1102,7 @@ sub ParseElementPullLevel
        my($self,$e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_;
 
        my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
+       my $array_length = undef;
 
        if ($l->{TYPE} eq "ARRAY" and ($l->{IS_VARYING} or $l->{IS_CONFORMANT})) {
                $var_name = get_pointer_to($var_name);
@@ -1015,20 +1116,7 @@ sub ParseElementPullLevel
                        $self->ParseSubcontextPullEnd($e, $l, $ndr, $env);
                } elsif ($l->{TYPE} eq "ARRAY") {
                        my $length = $self->ParseArrayPullHeader($e, $l, $ndr, $var_name, $env);
-
-                       if (my $range = has_property($e, "range")) {
-                               my ($low, $high) = split(/,/, $range, 2);
-                               if ($low < 0) {
-                                       warning(0, "$low is invalid for the range of an array size");
-                               }
-                               if ($low == 0) {
-                                       $self->pidl("if ($length > $high) {");
-                               } else {
-                                       $self->pidl("if ($length < $low || $length > $high) {");
-                               }
-                               $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
-                               $self->pidl("}");
-                       }
+                       $array_length = $length;
 
                        my $nl = GetNextLevel($e, $l);
 
@@ -1036,7 +1124,11 @@ sub ParseElementPullLevel
                                if ($l->{IS_ZERO_TERMINATED}) {
                                        $self->CheckStringTerminator($ndr, $e, $l, $length);
                                }
-                               $self->pidl("NDR_CHECK(ndr_pull_charset($ndr, $ndr_flags, ".get_pointer_to($var_name).", $length, sizeof(" . mapTypeName($nl->{DATA_TYPE}) . "), CH_$e->{PROPERTIES}->{charset}));");
+                               if ($l->{IS_TO_NULL}) {
+                                       $self->pidl("NDR_CHECK(ndr_pull_charset_to_null($ndr, $ndr_flags, ".get_pointer_to($var_name).", $length, sizeof(" . mapTypeName($nl->{DATA_TYPE}) . "), CH_$e->{PROPERTIES}->{charset}));");
+                               } else {
+                                       $self->pidl("NDR_CHECK(ndr_pull_charset($ndr, $ndr_flags, ".get_pointer_to($var_name).", $length, sizeof(" . mapTypeName($nl->{DATA_TYPE}) . "), CH_$e->{PROPERTIES}->{charset}));");
+                               }
                                return;
                        } elsif (has_fast_array($e, $l)) {
                                if ($l->{IS_ZERO_TERMINATED}) {
@@ -1057,7 +1149,9 @@ sub ParseElementPullLevel
        }
 
        # add additional constructions
-       if ($l->{TYPE} eq "POINTER" and $deferred) {
+       if ($l->{TYPE} eq "POINTER" and $l->{POINTER_TYPE} eq "ignore") {
+               $self->pidl("/* [ignore] '$e->{NAME}' */");
+       } elsif ($l->{TYPE} eq "POINTER" and $deferred) {
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->pidl("if ($var_name) {");
                        $self->indent;
@@ -1077,7 +1171,7 @@ sub ParseElementPullLevel
                $self->ParseMemCtxPullEnd($e, $l, $ndr);
 
                if ($l->{POINTER_TYPE} ne "ref") {
-                       if ($l->{POINTER_TYPE} eq "relative") {
+                       if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
                                $self->pidl("if ($ndr->offset > $ndr->relative_highest_offset) {");
                                $self->indent;
                                $self->pidl("$ndr->relative_highest_offset = $ndr->offset;");
@@ -1090,26 +1184,12 @@ sub ParseElementPullLevel
                }
        } elsif ($l->{TYPE} eq "ARRAY" and 
                        not has_fast_array($e,$l) and not is_charset_array($e, $l)) {
-               my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
+               my $length = $array_length;
                my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
                my $array_name = $var_name;
 
-               if ($l->{IS_VARYING}) {
-                       $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
-               }
-
-               if (my $range = has_property($e, "range")) {
-                       my ($low, $high) = split(/,/, $range, 2);
-                       if ($low < 0) {
-                               warning(0, "$low is invalid for the range of an array size");
-                       }
-                       if ($low == 0) {
-                               $self->pidl("if ($length > $high) {");
-                       } else {
-                               $self->pidl("if ($length < $low || $length > $high) {");
-                       }
-                       $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
-                       $self->pidl("}");
+               if (not defined($length)) {
+                       $length = $self->ParseArrayPullGetLength($e, $l, $ndr, $var_name, $env);
                }
 
                $var_name = get_array_element($var_name, $counter);
@@ -1215,7 +1295,7 @@ sub ParsePtrPull($$$$$)
        } elsif ($l->{POINTER_TYPE} eq "ignore") {
                 #We want to consume the pointer bytes, but ignore the pointer value
                $self->pidl("NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &_ptr_$e->{NAME}));");
-               $self->pidl("_ptr_$e->{NAME} = NULL;");
+               $self->pidl("_ptr_$e->{NAME} = 0;");
        } else {
                die("Unhandled pointer type $l->{POINTER_TYPE}");
        }
@@ -1273,6 +1353,9 @@ sub ParseStructPushPrimitives($$$$$)
                                } else {
                                        $size = "ndr_string_length($varname->$e->{NAME}, sizeof(*$varname->$e->{NAME}))";
                                }
+                               if (defined($e->{LEVELS}[0]->{SIZE_IS})) {
+                                       $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
+                               }
                        } else {
                                $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
                        }
@@ -1323,6 +1406,7 @@ sub ParseStructPush($$$$)
 
        $self->start_flags($struct, $ndr);
 
+       $self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
        $self->indent;
        $self->ParseStructPushPrimitives($struct, $ndr, $varname, $env);
@@ -1536,16 +1620,21 @@ sub DeclarePtrVariables($$)
        }
 }
 
-sub DeclareArrayVariables($$)
+sub DeclareArrayVariables($$;$)
 {
-       my ($self,$e) = @_;
+       my ($self,$e,$pull) = @_;
 
        foreach my $l (@{$e->{LEVELS}}) {
+               next if ($l->{TYPE} ne "ARRAY");
+               if (defined($pull)) {
+                       $self->pidl("uint32_t size_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
+                       if ($l->{IS_VARYING}) {
+                               $self->pidl("uint32_t length_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
+                       }
+               }
                next if has_fast_array($e,$l);
                next if is_charset_array($e,$l);
-               if ($l->{TYPE} eq "ARRAY") {
-                       $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
-               }
+               $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
        }
 }
 
@@ -1554,15 +1643,14 @@ sub DeclareArrayVariablesNoZero($$$)
        my ($self,$e,$env) = @_;
 
        foreach my $l (@{$e->{LEVELS}}) {
+               next if ($l->{TYPE} ne "ARRAY");
                next if has_fast_array($e,$l);
                next if is_charset_array($e,$l);
-               if ($l->{TYPE} eq "ARRAY") {
-                   my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
-                   if ($length eq "0") {
+               my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
+               if ($length eq "0") {
                        warning($e->{ORIGINAL}, "pointless array cntr: 'cntr_$e->{NAME}_$l->{LEVEL_INDEX}': length=$length");
-                   } else {
+               } else {
                        $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
-                   }
                }
        }
 }
@@ -1572,6 +1660,11 @@ sub DeclareMemCtxVariables($$)
        my ($self,$e) = @_;
        foreach my $l (@{$e->{LEVELS}}) {
                my $mem_flags = $self->ParseMemCtxPullFlags($e, $l);
+
+               if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ignore")) {
+                       last;
+               }
+
                if (defined($mem_flags)) {
                        $self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX};");
                }
@@ -1628,7 +1721,7 @@ sub ParseStructPull($$$$)
        # declare any internal pointers we need
        foreach my $e (@{$struct->{ELEMENTS}}) {
                $self->DeclarePtrVariables($e);
-               $self->DeclareArrayVariables($e);
+               $self->DeclareArrayVariables($e, "pull");
                $self->DeclareMemCtxVariables($e);
        }
 
@@ -1636,6 +1729,7 @@ sub ParseStructPull($$$$)
 
        my $env = GenerateStructEnv($struct, $varname);
 
+       $self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
        $self->indent;
        $self->ParseStructPullPrimitives($struct,$ndr,$varname,$env);
@@ -1799,6 +1893,7 @@ sub ParseUnionPush($$$$)
 
        $self->start_flags($e, $ndr);
 
+       $self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
        $self->indent;
        $self->ParseUnionPushPrimitives($e, $ndr, $varname);
@@ -1891,8 +1986,6 @@ sub ParseUnionPullPrimitives($$$$$)
 
                if ($el->{TYPE} ne "EMPTY") {
                        $self->indent;
-                       $self->DeclarePtrVariables($el);
-                       $self->DeclareArrayVariables($el);
                        if (defined($e->{PROPERTIES}{relative_base})) {
                                $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $el->{ALIGN}));");
                                # set the current offset as base for relative pointers
@@ -1969,6 +2062,8 @@ sub ParseUnionPull($$$$)
                next if ($el->{TYPE} eq "EMPTY");
                next if ($double_cases{"$el->{NAME}"});
                $self->DeclareMemCtxVariables($el);
+               $self->DeclarePtrVariables($el);
+               $self->DeclareArrayVariables($el, "pull");
                $double_cases{"$el->{NAME}"} = 1;
        }
 
@@ -1976,6 +2071,7 @@ sub ParseUnionPull($$$$)
 
        $self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
 
+       $self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
        $self->indent;
        $self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
@@ -2258,6 +2354,8 @@ sub ParseFunctionPush($$)
                $self->DeclareArrayVariables($e);
        }
 
+       $self->pidl("NDR_PUSH_CHECK_FN_FLAGS(ndr, flags);");
+
        $self->pidl("if (flags & NDR_IN) {");
        $self->indent;
 
@@ -2334,7 +2432,7 @@ sub ParseFunctionPull($$)
        # declare any internal pointers we need
        foreach my $e (@{$fn->{ELEMENTS}}) { 
                $self->DeclarePtrVariables($e);
-               $self->DeclareArrayVariables($e);
+               $self->DeclareArrayVariables($e, "pull");
        }
 
        my %double_cases = ();
@@ -2345,6 +2443,8 @@ sub ParseFunctionPull($$)
                $double_cases{"$e->{NAME}"} = 1;
        }
 
+       $self->pidl("NDR_PULL_CHECK_FN_FLAGS(ndr, flags);");
+
        $self->pidl("if (flags & NDR_IN) {");
        $self->indent;
 
@@ -2666,10 +2766,9 @@ sub HeaderInterface($$$)
        if (defined $interface->{PROPERTIES}->{uuid}) {
                my $name = uc $interface->{NAME};
                $self->pidl_hdr("#define NDR_$name\_UUID " . 
-               Parse::Pidl::Util::make_str(lc($interface->{PROPERTIES}->{uuid})));
+               Parse::Pidl::Util::make_str(lc($interface->{UUID})));
 
-               if(!defined $interface->{PROPERTIES}->{version}) { $interface->{PROPERTIES}->{version} = "0.0"; }
-               $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{PROPERTIES}->{version}");
+               $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{VERSION}");
 
                $self->pidl_hdr("#define NDR_$name\_NAME \"$interface->{NAME}\"");