summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-12-31 04:29:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:10 -0500
commitff5c9a127335a35d5625c500d5cd6b5971fd1e13 (patch)
tree99fc1a1901f5120f4e52f8c98d390938551347e8 /source4/librpc/ndr
parente4b7e8cdf1590d8ed9b1f190cad9ee6734ffe4de (diff)
downloadsamba-ff5c9a127335a35d5625c500d5cd6b5971fd1e13.tar.gz
samba-ff5c9a127335a35d5625c500d5cd6b5971fd1e13.tar.bz2
samba-ff5c9a127335a35d5625c500d5cd6b5971fd1e13.zip
r12634: make the [validate] binding string switch also check to see if the
string form of the structure we receive matches the generated form. This has the effect of checking things like value() attributes. (This used to be commit f2e68ec649658976e5bf4887713a92c14850c277)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/ndr.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 260d445870..26190b199e 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -199,6 +199,21 @@ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRI
free(s);
}
+static void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
+{
+ va_list ap;
+ int i;
+
+ for (i=0;i<ndr->depth;i++) {
+ ndr->private = talloc_asprintf_append(ndr->private, " ");
+ }
+
+ va_start(ap, format);
+ ndr->private = talloc_vasprintf_append(ndr->private, format, ap);
+ va_end(ap);
+ ndr->private = talloc_asprintf_append(ndr->private, "\n");
+}
+
/*
a useful helper function for printing idl structures via DEBUG()
*/
@@ -248,6 +263,27 @@ void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int fla
talloc_free(ndr);
}
+
+/*
+ a useful helper function for printing idl function calls to a string
+*/
+char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
+ ndr_print_function_t fn, const char *name,
+ int flags, void *ptr)
+{
+ struct ndr_print *ndr;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_print);
+ if (!ndr) return NULL;
+ ndr->private = talloc_strdup(mem_ctx, "");
+ ndr->print = ndr_print_string_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ fn(ndr, name, flags, ptr);
+ talloc_free(ndr);
+ return ndr->private;
+}
+
void ndr_set_flags(uint32_t *pflags, uint32_t new_flags)
{
/* the big/little endian flags are inter-dependent */