summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-09-25 00:56:17 +0200
committerGünther Deschner <gd@samba.org>2009-09-30 00:30:47 +0200
commitf8016cfee922cba97b70f56c752827e4584da6c6 (patch)
tree1e6e2706e8d4442e6cbb8cf62038ec305b3ed765 /source3/lib
parent2d6e5e160b9fd1a21bbbe699f6786c570daa0467 (diff)
downloadsamba-f8016cfee922cba97b70f56c752827e4584da6c6.tar.gz
samba-f8016cfee922cba97b70f56c752827e4584da6c6.tar.bz2
samba-f8016cfee922cba97b70f56c752827e4584da6c6.zip
s3-util: add pull_reg_sz() and pull_reg_multi_sz() convenience functions.
Guenther
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_reg.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c
index ef8c245479..eccd26dc34 100644
--- a/source3/lib/util_reg.c
+++ b/source3/lib/util_reg.c
@@ -140,3 +140,38 @@ bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a)
(ndr_push_flags_fn_t)ndr_push_winreg_Data);
return NDR_ERR_CODE_IS_SUCCESS(ndr_err);
}
+
+/*******************************************************************
+ pull a string in unix charset out of a REG_SZ UCS2 null terminated blob
+ ********************************************************************/
+
+bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s)
+{
+ union winreg_Data data;
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_pull_union_blob(blob, mem_ctx, NULL, &data, REG_SZ,
+ (ndr_pull_flags_fn_t)ndr_pull_winreg_Data);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return false;
+ }
+ *s = data.string;
+ return true;
+}
+
+/*******************************************************************
+ pull a string_array in unix charset out of a REG_MULTI_SZ UCS2 double-null
+ terminated blob
+ ********************************************************************/
+
+bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char ***a)
+{
+ union winreg_Data data;
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_pull_union_blob(blob, mem_ctx, NULL, &data, REG_MULTI_SZ,
+ (ndr_pull_flags_fn_t)ndr_pull_winreg_Data);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return false;
+ }
+ *a = data.string_array;
+ return true;
+}