summaryrefslogtreecommitdiff
path: root/source4/lib/registry/common
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-03 17:17:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:36:28 -0500
commit02b3abec25ed0b303906c5dae9dd527171762d9a (patch)
tree04bc902d7b1557e4038d34ccbced7e7ffab8109b /source4/lib/registry/common
parent0eea337a6f11c3a86414fbd31b065fc59a481435 (diff)
downloadsamba-02b3abec25ed0b303906c5dae9dd527171762d9a.tar.gz
samba-02b3abec25ed0b303906c5dae9dd527171762d9a.tar.bz2
samba-02b3abec25ed0b303906c5dae9dd527171762d9a.zip
r10007: Merge data_blk and data_len member of registry_value into a DATA_BLOB.
Fix handling of REG_DWORD in the LDB backend. Fix a couple of warnings (This used to be commit 709fdc7ebf5a77cfb50359fad978884777decc3b)
Diffstat (limited to 'source4/lib/registry/common')
-rw-r--r--source4/lib/registry/common/reg_interface.c10
-rw-r--r--source4/lib/registry/common/reg_util.c34
2 files changed, 17 insertions, 27 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index 2abe90f2d1..7f745143e6 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -252,7 +252,7 @@ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx, struct registry_key *key,
return WERR_OK;
}
-WERROR reg_key_num_subkeys(struct registry_key *key, int *count)
+WERROR reg_key_num_subkeys(struct registry_key *key, uint32_t *count)
{
if(!key) return WERR_INVALID_PARAM;
@@ -277,7 +277,7 @@ WERROR reg_key_num_subkeys(struct registry_key *key, int *count)
return WERR_NOT_SUPPORTED;
}
-WERROR reg_key_num_values(struct registry_key *key, int *count)
+WERROR reg_key_num_values(struct registry_key *key, uint32_t *count)
{
if(!key) return WERR_INVALID_PARAM;
@@ -416,11 +416,11 @@ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, struct registry_key *parent, const
return WERR_OK;
}
-WERROR reg_val_set(struct registry_key *key, const char *value, uint32_t type, void *data, int len)
+WERROR reg_val_set(struct registry_key *key, const char *value, uint32_t type, DATA_BLOB data)
{
/* A 'real' set function has preference */
if (key->hive->functions->set_value)
- return key->hive->functions->set_value(key, value, type, data, len);
+ return key->hive->functions->set_value(key, value, type, data);
DEBUG(1, ("Backend '%s' doesn't support method set_value\n", key->hive->functions->name));
return WERR_NOT_SUPPORTED;
@@ -501,7 +501,7 @@ WERROR reg_key_valuesizes(struct registry_key *key, uint32_t *max_valnamelen, ui
if (value->name) {
*max_valnamelen = MAX(*max_valnamelen, strlen(value->name));
}
- *max_valbufsize = MAX(*max_valbufsize, value->data_len);
+ *max_valbufsize = MAX(*max_valbufsize, value->data.length);
}
i++;
diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c
index 65f1167832..a0d4db6f57 100644
--- a/source4/lib/registry/common/reg_util.c
+++ b/source4/lib/registry/common/reg_util.c
@@ -48,35 +48,25 @@ const char *str_regtype(int type)
char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
{
- char *asciip;
char *ret = NULL;
- int i;
- if(v->data_len == 0) return talloc_strdup(mem_ctx, "");
+ if(v->data.length == 0) return talloc_strdup(mem_ctx, "");
switch (v->data_type) {
case REG_EXPAND_SZ:
case REG_SZ:
- convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data_blk, v->data_len, (void **)&ret);
+ convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data.data, v->data.length, (void **)&ret);
return ret;
case REG_BINARY:
- ret = talloc_array_size(mem_ctx, 3, v->data_len+1);
- asciip = ret;
- for (i=0; i<v->data_len; i++) {
- int str_rem = v->data_len * 3 - (asciip - ret);
- asciip += snprintf(asciip, str_rem, "%02x", *(uint8_t *)(((char *)v->data_blk)+i));
- if (i < v->data_len && str_rem > 0)
- *asciip = ' '; asciip++;
- }
- *asciip = '\0';
+ ret = data_blob_hex_string(mem_ctx, &v->data);
return ret;
case REG_DWORD:
- if (*(int *)v->data_blk == 0)
+ if (*(int *)v->data.data == 0)
return talloc_strdup(mem_ctx, "0");
- return talloc_asprintf(mem_ctx, "0x%x", *(int *)v->data_blk);
+ return talloc_asprintf(mem_ctx, "0x%x", *(int *)v->data.data);
case REG_MULTI_SZ:
/* FIXME */
@@ -117,17 +107,17 @@ BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *da
{
case REG_SZ:
case REG_EXPAND_SZ:
- (*value)->data_len = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), &(*value)->data_blk);
+ (*value)->data.length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&(*value)->data.data);
break;
- case REG_DWORD:
- (*value)->data_len = sizeof(uint32_t);
- (*value)->data_blk = talloc(mem_ctx, uint32_t);
- *((uint32_t *)(*value)->data_blk) = strtol(data_str, NULL, 0);
+
+ case REG_DWORD: {
+ uint32_t tmp = strtol(data_str, NULL, 0);
+ (*value)->data = data_blob_talloc(mem_ctx, &tmp, 4);
+ }
break;
case REG_NONE:
- (*value)->data_len = 0;
- (*value)->data_blk = NULL;
+ ZERO_STRUCT((*value)->data);
break;
default: