diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/ndr_parser.pm | 16 | ||||
-rw-r--r-- | source4/librpc/ndr/libndr.h | 2 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 30 |
3 files changed, 24 insertions, 24 deletions
diff --git a/source4/build/pidl/ndr_parser.pm b/source4/build/pidl/ndr_parser.pm index 0ec24b3526..5bb064c963 100644 --- a/source4/build/pidl/ndr_parser.pm +++ b/source4/build/pidl/ndr_parser.pm @@ -670,12 +670,14 @@ sub ParseElementPrint($$) if (util::array_size($e)) { ParseArrayPrint($e, $var_prefix) - } elsif (my $switch = util::has_property($e, "switch_is")) { - my $switch_var = ParseExpr($e, $switch, $var_prefix); - check_null_pointer_void($switch_var); - - pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $switch_var, $cprefix$var_prefix$e->{NAME});"; } else { + if (my $switch = util::has_property($e, "switch_is")) { + my $switch_var = ParseExpr($e, $switch, $var_prefix); + check_null_pointer_void($switch_var); + + pidl "ndr_print_set_switch_value(ndr, $cprefix$var_prefix$e->{NAME}, $switch_var);"; + } + pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $cprefix$var_prefix$e->{NAME});"; } @@ -1406,6 +1408,8 @@ sub ParseUnionPrint($) my $have_default = 0; my($name) = $e->{PARENT}->{NAME}; + pidl "int level = ndr_print_get_switch_value(ndr, r);"; + pidl "ndr_print_union(ndr, name, level, \"$name\");"; start_flags($e); @@ -1535,7 +1539,7 @@ sub ArgsUnionPush($) sub ArgsUnionPrint($) { my $e = shift; - return "struct ndr_print *ndr, const char *name, int level, union $e->{NAME} *r"; + return "struct ndr_print *ndr, const char *name, union $e->{NAME} *r"; } sub ArgsUnionPull($) diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 15ac1b2d4c..dd775d62ad 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -86,6 +86,7 @@ struct ndr_push_save { struct ndr_print { uint32_t flags; /* LIBNDR_FLAG_* */ uint32_t depth; + struct ndr_token_list *switch_list; void (*print)(struct ndr_print *, const char *, ...); void *private; }; @@ -248,5 +249,4 @@ typedef NTSTATUS (*ndr_push_const_fn_t)(struct ndr_push *, int ndr_flags, const typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *); typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, void *); typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, void *); -typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint32_t, void *); diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index de8a01f5d5..de87f0850a 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -324,23 +324,6 @@ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr) talloc_free(ndr); } - -/* - a useful helper function for printing idl unions via DEBUG() -*/ -void ndr_print_union_debug(ndr_print_union_fn_t fn, const char *name, uint32_t level, void *ptr) -{ - struct ndr_print *ndr; - - ndr = talloc(NULL, struct ndr_print); - if (!ndr) return; - ndr->print = ndr_print_debug_helper; - ndr->depth = 1; - ndr->flags = 0; - fn(ndr, name, level, ptr); - talloc_free(ndr); -} - /* a useful helper function for printing idl function calls via DEBUG() */ @@ -690,6 +673,19 @@ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p) return ndr_token_peek(&ndr->switch_list, p); } +NTSTATUS ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val) +{ + return ndr_token_store(ndr, &ndr->switch_list, p, val); +} + +/* + retrieve a switch value + */ +uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p) +{ + return ndr_token_peek(&ndr->switch_list, p); +} + /* pull a relative object - stage1 called during SCALARS processing |