From eb356fbafc4b6e0d94b1ba75c6c466262e3221e5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 02:12:33 +0100 Subject: Hide the registry backend from libnet_smbconf_getparm(). Return a formatted string of the value instead. Michael (This used to be commit 7d0ec5bae155cda6620db04dcb7bd43db59241aa) --- source3/libnet/libnet_conf.c | 21 ++++++++++++++++++--- source3/utils/net_conf.c | 6 +++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index dfea724497..1e9e033205 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -359,12 +359,17 @@ done: WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, const char *service, const char *param, - struct registry_value **value) + char **valstr) { - WERROR werr; + WERROR werr = WERR_OK; struct registry_key *key = NULL; struct registry_value *value = NULL; + if (valstr == NULL) { + werr = WERR_INVALID_PARAM; + goto done; + } + if (!libnet_smbconf_key_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; @@ -381,10 +386,20 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - werr = reg_queryvalue(mem_ctx, key, param, value); + werr = reg_queryvalue(mem_ctx, key, param, &value); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + *valstr = libnet_smbconf_format_registry_value(mem_ctx, value); + + if (*valstr == NULL) { + werr = WERR_NOMEM; + } done: TALLOC_FREE(key); + TALLOC_FREE(value); return werr; } diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index fb6cb58840..e607d099dc 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -769,7 +769,7 @@ static int net_conf_getparm(int argc, const char **argv) WERROR werr = WERR_OK; char *service = NULL; char *param = NULL; - struct registry_value *value = NULL; + char *valstr = NULL; TALLOC_CTX *ctx; ctx = talloc_init("getparm"); @@ -781,7 +781,7 @@ static int net_conf_getparm(int argc, const char **argv) service = strdup_lower(argv[0]); param = strdup_lower(argv[1]); - werr = libnet_smbconf_getparm(ctx, service, param, &value); + werr = libnet_smbconf_getparm(ctx, service, param, &valstr); if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) { d_fprintf(stderr, @@ -799,7 +799,7 @@ static int net_conf_getparm(int argc, const char **argv) goto done; } - d_printf("%s\n", libnet_smbconf_format_registry_value(ctx, value)); + d_printf("%s\n", valstr); ret = 0; done: -- cgit