s3-util: add push_reg_sz() and push_reg_multi_sz() convenience functions.
authorGünther Deschner <gd@samba.org>
Wed, 23 Sep 2009 18:42:20 +0000 (20:42 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 30 Nov 2009 15:09:36 +0000 (16:09 +0100)
Guenther
(cherry picked from commit fcee9d2c97a673347baf58f749f35785a896e468)

source3/include/proto.h
source3/lib/util_reg.c

index 0265d42c004ddeaf26d8d3d1c510d052b0eb9c5d..259c8908865d108bac30c9e696788b7f8b2b6b12 100644 (file)
@@ -1253,6 +1253,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  */
 
index 6570bb072d4ffd4629ad69a9ded7d034579f1ed5..39a42e981043e29c3a7e5dff61dadf823d555cef 100644 (file)
@@ -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);
+}