summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-12-23 15:07:20 +0100
committerMichael Adam <obnox@samba.org>2007-12-24 00:18:35 +0100
commit8f163d5c5ae48a3ff1974e936b9316781eceff8a (patch)
treef467b48f72c2d3f034abf7d5a50b7fb6e0a9ccfc /source3
parent4e53afccb1470b8d889f7300ad77a497f38ed418 (diff)
downloadsamba-8f163d5c5ae48a3ff1974e936b9316781eceff8a.tar.gz
samba-8f163d5c5ae48a3ff1974e936b9316781eceff8a.tar.bz2
samba-8f163d5c5ae48a3ff1974e936b9316781eceff8a.zip
Move logic of net_conf_getparm() to libnet_conf.c.
Michael (This used to be commit d3a20c4d5a8109334cd3ed665ba60cfcc4425059)
Diffstat (limited to 'source3')
-rw-r--r--source3/libnet/libnet_conf.c24
-rw-r--r--source3/utils/net_conf.c22
2 files changed, 34 insertions, 12 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index 69a105f8f5..121ec35468 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -271,6 +271,30 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx,
return werr;
}
+WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx,
+ const char *service,
+ const char *param,
+ struct registry_value **value)
+{
+ WERROR werr;
+ struct registry_key *key = NULL;
+
+ if (!libnet_smbconf_key_exists(mem_ctx, service)) {
+ return WERR_NO_SUCH_SERVICE;
+ }
+
+ werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key);
+ W_ERROR_NOT_OK_RETURN(werr);
+
+ if (!libnet_smbconf_value_exists(mem_ctx, key, param)) {
+ return WERR_INVALID_PARAM;
+ }
+
+ werr = reg_queryvalue(mem_ctx, key, param, value);
+
+ return werr;
+}
+
WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx,
const char *service,
const char *param)
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 673d373177..f3f2321643 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -869,7 +869,6 @@ static int net_conf_getparm(int argc, const char **argv)
{
int ret = -1;
WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
char *service = NULL;
char *param = NULL;
struct registry_value *value = NULL;
@@ -884,21 +883,20 @@ static int net_conf_getparm(int argc, const char **argv)
service = strdup_lower(argv[0]);
param = strdup_lower(argv[1]);
- if (!libnet_smbconf_key_exists(ctx, service)) {
+ werr = libnet_smbconf_getparm(ctx, service, param, &value);
+
+ if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
- "ERROR: given service '%s' does not exist.\n",
+ "Error: given service '%s' does not exist.\n",
service);
goto done;
- }
-
- werr = libnet_smbconf_open_path(ctx, service, REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
+ d_fprintf(stderr,
+ "Error: given parameter '%s' is not set.\n",
+ param);
goto done;
- }
-
- werr = reg_queryvalue(ctx, key, param, &value);
- if (!W_ERROR_IS_OK(werr)) {
- d_fprintf(stderr, "Error querying value '%s': %s.\n",
+ } else if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, "Error getting value '%s': %s.\n",
param, dos_errstr(werr));
goto done;
}