summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/lib/util_reg.c30
2 files changed, 32 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d664a26949..328145b8f7 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1259,6 +1259,8 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
const char *reg_type_lookup(enum winreg_Type type);
WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
uint32 *num_values, char ***values);
+bool push_reg_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *s);
+bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a);
/* The following definitions come from lib/util_reg_api.c */
diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c
index 1e1bcfeb10..ef8c245479 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);
+}