From 560b7a45ff8257b7d9994199218edfa3ea4e8dae Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Fri, 25 Sep 2009 00:56:17 +0200 Subject: [PATCH] s3-util: add pull_reg_sz() and pull_reg_multi_sz() convenience functions. Guenther (cherry picked from commit f8016cfee922cba97b70f56c752827e4584da6c6) --- source3/include/proto.h | 2 ++ source3/lib/util_reg.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 259c8908865..d2ae62cbd88 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1255,6 +1255,8 @@ 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); +bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s); +bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const 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 39a42e98104..3f8033befe1 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; +} -- 2.11.4.GIT