summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-09-23 20:42:20 +0200
committerKarolin Seeger <kseeger@samba.org>2009-12-23 12:07:48 +0100
commit2e2a33853bd191fc6624806a3b28faae828028c8 (patch)
tree45989e353bff38e027234424b359c9c8a49a5203 /source3/lib
parent0be27d4f5ab7e69e3704b94d49f0d7fc45c2fab7 (diff)
downloadsamba-2e2a33853bd191fc6624806a3b28faae828028c8.tar.gz
s3-util: add push_reg_sz() and push_reg_multi_sz() convenience functions.
Guenther (cherry picked from commit fcee9d2c97a673347baf58f749f35785a896e468) (cherry picked from commit 20b43200885d7e4cef5e26ad249c9a4c6529dca5)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_reg.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c
index 6570bb072d4..39a42e98104 100644
--- a/source3/lib/util_reg.c
+++ b/source3/lib/util_reg.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "../librpc/gen_ndr/ndr_winreg.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
@@ -110,3 +111,32 @@ WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
return WERR_OK;
}
+
+/*******************************************************************
+ push a string in unix charset into a REG_SZ UCS2 null terminated blob
+ ********************************************************************/
+
+bool push_reg_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *s)
+{
+ union winreg_Data data;
+ enum ndr_err_code ndr_err;
+ data.string = s;
+ ndr_err = ndr_push_union_blob(blob, mem_ctx, NULL, &data, REG_SZ,
+ (ndr_push_flags_fn_t)ndr_push_winreg_Data);
+ return NDR_ERR_CODE_IS_SUCCESS(ndr_err);
+}
+
+/*******************************************************************
+ push a string_array in unix charset into a REG_MULTI_SZ UCS2 double-null
+ terminated blob
+ ********************************************************************/
+
+bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a)
+{
+ union winreg_Data data;
+ enum ndr_err_code ndr_err;
+ data.string_array = a;
+ ndr_err = ndr_push_union_blob(blob, mem_ctx, NULL, &data, REG_MULTI_SZ,
+ (ndr_push_flags_fn_t)ndr_push_winreg_Data);
+ return NDR_ERR_CODE_IS_SUCCESS(ndr_err);
+}