From a833be0c4e44135e4f45b3d460586762da04cf32 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 27 Apr 2010 16:37:56 +0200 Subject: s4: use shared registry functions. Guenther --- source4/lib/registry/config.mk | 3 ++- source4/lib/registry/registry.h | 9 +++++++ source4/lib/registry/util.c | 48 +------------------------------------- source4/lib/registry/wscript_build | 2 +- 4 files changed, 13 insertions(+), 49 deletions(-) (limited to 'source4/lib/registry') diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index adf26b275f..9ff917f75a 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -30,7 +30,8 @@ registry_SOVERSION = 0 registry_OBJ_FILES = $(addprefix $(libregistrysrcdir)/, interface.o util.o samba.o \ patchfile_dotreg.o patchfile_preg.o patchfile.o regf.o \ - hive.o local.o ldb.o dir.o rpc.o) + hive.o local.o ldb.o dir.o rpc.o) \ + ../libcli/registry/util_reg.o PUBLIC_HEADERS += $(libregistrysrcdir)/registry.h diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index 3ac50d517d..e43b0b054c 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -453,6 +453,15 @@ WERROR reg_create_key(TALLOC_CTX *mem_ctx, /* Utility functions */ const char *str_regtype(int type); +bool push_reg_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic, + DATA_BLOB *blob, const char *s); +bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic, + DATA_BLOB *blob, const char **a); +bool pull_reg_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic, + const DATA_BLOB *blob, const char **s); +bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic, + const DATA_BLOB *blob, const char ***a); +int regtype_by_string(const char *str); char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t type, const DATA_BLOB data); char *reg_val_description(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const char *name, uint32_t type, const DATA_BLOB data); diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index 0620748efa..62a94dfcc7 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -21,43 +21,6 @@ #include "lib/registry/registry.h" #include "librpc/gen_ndr/winreg.h" -/** - * @file - * @brief Registry utility functions - */ - -static const struct { - uint32_t id; - const char *name; -} reg_value_types[] = { - { REG_NONE, "REG_NONE" }, - { REG_SZ, "REG_SZ" }, - { REG_EXPAND_SZ, "REG_EXPAND_SZ" }, - { REG_BINARY, "REG_BINARY" }, - { REG_DWORD, "REG_DWORD" }, - { REG_DWORD_BIG_ENDIAN, "REG_DWORD_BIG_ENDIAN" }, - { REG_LINK, "REG_LINK" }, - { REG_MULTI_SZ, "REG_MULTI_SZ" }, - { REG_RESOURCE_LIST, "REG_RESOURCE_LIST" }, - { REG_FULL_RESOURCE_DESCRIPTOR, "REG_FULL_RESOURCE_DESCRIPTOR" }, - { REG_RESOURCE_REQUIREMENTS_LIST, "REG_RESOURCE_REQUIREMENTS_LIST" }, - { REG_QWORD, "REG_QWORD" }, - - { 0, NULL } -}; - -/** Return string description of registry value type */ -_PUBLIC_ const char *str_regtype(int type) -{ - unsigned int i; - for (i = 0; reg_value_types[i].name; i++) { - if (reg_value_types[i].id == type) - return reg_value_types[i].name; - } - - return "Unknown"; -} - _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t type, @@ -126,16 +89,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *data_str, uint32_t *type, DATA_BLOB *data) { - unsigned int i; - *type = -1; - - /* Find the correct type */ - for (i = 0; reg_value_types[i].name; i++) { - if (!strcmp(reg_value_types[i].name, type_str)) { - *type = reg_value_types[i].id; - break; - } - } + *type = regtype_by_string(type_str); if (*type == -1) return false; diff --git a/source4/lib/registry/wscript_build b/source4/lib/registry/wscript_build index 1b34f7963f..2e07757a4f 100644 --- a/source4/lib/registry/wscript_build +++ b/source4/lib/registry/wscript_build @@ -11,7 +11,7 @@ bld.SAMBA_SUBSYSTEM('TDR_REGF', bld.SAMBA_LIBRARY('registry', - source='interface.c util.c samba.c patchfile_dotreg.c patchfile_preg.c patchfile.c regf.c hive.c local.c ldb.c dir.c rpc.c', + source='interface.c ../libcli/registry/util_reg.c util.c samba.c patchfile_dotreg.c patchfile_preg.c patchfile.c regf.c hive.c local.c ldb.c dir.c rpc.c', pc_files='registry.pc', public_deps='LIBSAMBA-UTIL CHARSET TDR_REGF ldb RPC_NDR_WINREG LDB_WRAP', public_headers='registry.h', -- cgit