summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-05-15 14:38:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:07:24 -0500
commit6506e27cb26dd05671a2a001d02536955101dae1 (patch)
treeec271670d81261ede0eab91fdd32af33ee2a312a /source4/librpc
parent235b3dd9f81d211ec1fff08f4302209229430d54 (diff)
downloadsamba-6506e27cb26dd05671a2a001d02536955101dae1.tar.gz
samba-6506e27cb26dd05671a2a001d02536955101dae1.tar.bz2
samba-6506e27cb26dd05671a2a001d02536955101dae1.zip
r15624: add some useful helper functions
metze (This used to be commit 8fa6059100d1f6e235bacc722a83a961e460ebb2)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/ndr/ndr.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 74d966a9d9..c03cf6a588 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -265,6 +265,54 @@ _PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name
talloc_free(ndr);
}
+/*
+ a useful helper function for printing idl structures to a string
+*/
+_PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr)
+{
+ struct ndr_print *ndr;
+ char *ret = NULL;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_print);
+ if (!ndr) return NULL;
+ ndr->private_data = talloc_strdup(ndr, "");
+ if (!ndr->private_data) {
+ goto failed;
+ }
+ ndr->print = ndr_print_string_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ fn(ndr, name, ptr);
+ ret = talloc_steal(mem_ctx, ndr->private_data);
+failed:
+ talloc_free(ndr);
+ return ret;
+}
+
+/*
+ a useful helper function for printing idl unions to a string
+*/
+_PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr)
+{
+ struct ndr_print *ndr;
+ char *ret = NULL;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_print);
+ if (!ndr) return NULL;
+ ndr->private_data = talloc_strdup(ndr, "");
+ if (!ndr->private_data) {
+ goto failed;
+ }
+ ndr->print = ndr_print_string_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ ndr_print_set_switch_value(ndr, ptr, level);
+ fn(ndr, name, ptr);
+ ret = talloc_steal(mem_ctx, ndr->private_data);
+failed:
+ talloc_free(ndr);
+ return ret;
+}
/*
a useful helper function for printing idl function calls to a string