summaryrefslogtreecommitdiff
path: root/source4/lib/registry/common/reg_util.c
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/reg_util.c
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/reg_util.c')
-rw-r--r--source4/lib/registry/common/reg_util.c34
1 files changed, 12 insertions, 22 deletions
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: