r6746: added ndr_push_union_blob() for pushing IDL unions into a DATA_BLOB
authorAndrew Tridgell <tridge@samba.org>
Thu, 12 May 2005 08:27:04 +0000 (08:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:16:40 +0000 (13:16 -0500)
source/librpc/ndr/ndr.c

index 7beb64942a29424b6e95922f88f0da373ffb7d53..b86cf0dd66a6e001ded216ddda8b694556eab134 100644 (file)
@@ -841,6 +841,29 @@ NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
        return NT_STATUS_OK;
 }
 
+/*
+  push a union to a blob using NDR
+*/
+NTSTATUS ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+                            uint32_t level, ndr_push_flags_fn_t fn)
+{
+       NTSTATUS status;
+       struct ndr_push *ndr;
+       ndr = ndr_push_init_ctx(mem_ctx);
+       if (!ndr) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       ndr_push_set_switch_value(ndr, p, level);
+       status = fn(ndr, NDR_SCALARS|NDR_BUFFERS, p);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       *blob = ndr_push_blob(ndr);
+
+       return NT_STATUS_OK;
+}
+
 /*
   generic ndr_size_*() handler for structures
 */