[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-940-g80e7340
Michael Adam
obnox at samba.org
Sat Dec 29 01:19:54 GMT 2007
The branch, v3-2-test has been updated
via 80e73407ea326cc68cd8728845c7a1c0907e2201 (commit)
via d7aaec713e17f93eed5177f0c3468deb625402a8 (commit)
via 7d0ec5bae155cda6620db04dcb7bd43db59241aa (commit)
via 95d5dd9bb0546181cd499e6deabff562166412e3 (commit)
via 3422a5048ad4b7f789ec233356885d78dbdacf9a (commit)
from fada689893314bed2fc78588b3fd9b144f4c808a (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 80e73407ea326cc68cd8728845c7a1c0907e2201
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 02:18:44 2007 +0100
Add a comment header for libnet_smbconf_format_registry_value().
Michael
commit d7aaec713e17f93eed5177f0c3468deb625402a8
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 02:16:38 2007 +0100
Handle NULL talloc context in libnet_smbconf_format_registry_value().
Maybe we should generate a new context instead of returning NULL?
Michael
commit 7d0ec5bae155cda6620db04dcb7bd43db59241aa
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 02:12:33 2007 +0100
Hide the registry backend from libnet_smbconf_getparm().
Return a formatted string of the value instead.
Michael
commit 95d5dd9bb0546181cd499e6deabff562166412e3
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 01:17:39 2007 +0100
Rename format_value() to libnet_smbconf_format_registry_value().
Michael
commit 3422a5048ad4b7f789ec233356885d78dbdacf9a
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 00:05:23 2007 +0100
Move format_value() to libnet_conf.c.
Michael
-----------------------------------------------------------------------
Summary of changes:
source/libnet/libnet_conf.c | 67 +++++++++++++++++++++++++++++++++++++++++--
source/utils/net_conf.c | 42 +++-----------------------
2 files changed, 69 insertions(+), 40 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/libnet/libnet_conf.c b/source/libnet/libnet_conf.c
index 93e1300..6603de0 100644
--- a/source/libnet/libnet_conf.c
+++ b/source/libnet/libnet_conf.c
@@ -222,6 +222,51 @@ done:
return werr;
}
+/**
+ * format a registry_value into a string.
+ *
+ * This is intended to be used for smbconf registry values,
+ * which are ar stored as REG_SZ values, so the incomplete
+ * handling should be ok.
+ */
+char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
+ struct registry_value *value)
+{
+ char *result = NULL;
+
+ /* alternatively, create a new talloc context? */
+ if (mem_ctx == NULL) {
+ return result;
+ }
+
+ switch (value->type) {
+ case REG_DWORD:
+ result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
+ break;
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
+ break;
+ case REG_MULTI_SZ: {
+ uint32 j;
+ for (j = 0; j < value->v.multi_sz.num_strings; j++) {
+ result = talloc_asprintf(mem_ctx, "\"%s\" ",
+ value->v.multi_sz.strings[j]);
+ }
+ break;
+ }
+ case REG_BINARY:
+ result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
+ (int)value->v.binary.length);
+ break;
+ default:
+ result = talloc_asprintf(mem_ctx, "<unprintable>");
+ break;
+ }
+ return result;
+}
+
+
/**********************************************************************
*
* The actual net conf api functions, that are exported.
@@ -324,10 +369,16 @@ 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;
@@ -345,10 +396,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/source/utils/net_conf.c b/source/utils/net_conf.c
index 8b89f2f..e607d09 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -110,39 +110,6 @@ static int net_conf_delparm_usage(int argc, const char **argv)
* Helper functions
*/
-static char *format_value(TALLOC_CTX *mem_ctx, struct registry_value *value)
-{
- char *result = NULL;
-
- /* what if mem_ctx = NULL? */
-
- switch (value->type) {
- case REG_DWORD:
- result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
- break;
- case REG_SZ:
- case REG_EXPAND_SZ:
- result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
- break;
- case REG_MULTI_SZ: {
- uint32 j;
- for (j = 0; j < value->v.multi_sz.num_strings; j++) {
- result = talloc_asprintf(mem_ctx, "\"%s\" ",
- value->v.multi_sz.strings[j]);
- }
- break;
- }
- case REG_BINARY:
- result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
- (int)value->v.binary.length);
- break;
- default:
- result = talloc_asprintf(mem_ctx, "<unprintable>");
- break;
- }
- return result;
-}
-
static WERROR list_values(TALLOC_CTX *ctx, struct registry_key *key)
{
WERROR werr = WERR_OK;
@@ -155,7 +122,8 @@ static WERROR list_values(TALLOC_CTX *ctx, struct registry_key *key)
&valvalue));
idx++)
{
- d_printf("\t%s = %s\n", valname, format_value(ctx, valvalue));
+ d_printf("\t%s = %s\n", valname,
+ libnet_smbconf_format_registry_value(ctx, valvalue));
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
d_fprintf(stderr, "Error enumerating values: %s\n",
@@ -801,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");
@@ -813,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,
@@ -831,7 +799,7 @@ static int net_conf_getparm(int argc, const char **argv)
goto done;
}
- d_printf("%s\n", format_value(ctx, value));
+ d_printf("%s\n", valstr);
ret = 0;
done:
--
Samba Shared Repository
More information about the samba-cvs
mailing list