svn commit: samba r15624 - in branches/SAMBA_4_0/source/librpc/ndr: .

metze at samba.org metze at samba.org
Mon May 15 14:38:04 GMT 2006


Author: metze
Date: 2006-05-15 14:38:04 +0000 (Mon, 15 May 2006)
New Revision: 15624

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15624

Log:
add some useful helper functions

metze
Modified:
   branches/SAMBA_4_0/source/librpc/ndr/ndr.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr.c	2006-05-15 13:14:26 UTC (rev 15623)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr.c	2006-05-15 14:38:04 UTC (rev 15624)
@@ -265,8 +265,56 @@
 	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
 */
 _PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,



More information about the samba-cvs mailing list