summaryrefslogtreecommitdiff
path: root/source4/lib/registry/common
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-29 11:51:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:11 -0500
commit5e7a0fb5349422cfb782c0348f98505011d27391 (patch)
tree18f04740785403e0566ce3675178543b83ef9737 /source4/lib/registry/common
parent0e90afb4e7737d60d902aee1df4cbeb85a7b693d (diff)
downloadsamba-5e7a0fb5349422cfb782c0348f98505011d27391.tar.gz
samba-5e7a0fb5349422cfb782c0348f98505011d27391.tar.bz2
samba-5e7a0fb5349422cfb782c0348f98505011d27391.zip
r10604: Put in the new registry "patchfile" code (similar to ldif
for LDB); not finished yet. (This used to be commit b405b27ba4bf4ddbaff9ca58926d94d1b2fd09f6)
Diffstat (limited to 'source4/lib/registry/common')
-rw-r--r--source4/lib/registry/common/reg_util.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c
index ae30839cca..75f9d3cf00 100644
--- a/source4/lib/registry/common/reg_util.c
+++ b/source4/lib/registry/common/reg_util.c
@@ -46,27 +46,27 @@ const char *str_regtype(int type)
return "Unknown";
}
-char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
+char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, DATA_BLOB *data)
{
char *ret = NULL;
- if(v->data.length == 0) return talloc_strdup(mem_ctx, "");
+ if(data->length == 0) return talloc_strdup(mem_ctx, "");
- switch (v->data_type) {
+ switch (type) {
case REG_EXPAND_SZ:
case REG_SZ:
- convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data.data, v->data.length, (void **)&ret);
+ convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, data->data, data->length, (void **)&ret);
return ret;
case REG_BINARY:
- ret = data_blob_hex_string(mem_ctx, &v->data);
+ ret = data_blob_hex_string(mem_ctx, data);
return ret;
case REG_DWORD:
- if (*(int *)v->data.data == 0)
+ if (*(int *)data->data == 0)
return talloc_strdup(mem_ctx, "0");
- return talloc_asprintf(mem_ctx, "0x%x", *(int *)v->data.data);
+ return talloc_asprintf(mem_ctx, "0x%x", *(int *)data->data);
case REG_MULTI_SZ:
/* FIXME */
@@ -81,47 +81,51 @@ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
char *reg_val_description(TALLOC_CTX *mem_ctx, struct registry_value *val)
{
- return talloc_asprintf(mem_ctx, "%s = %s : %s", val->name?val->name:"<No Name>", str_regtype(val->data_type), reg_val_data_string(mem_ctx, val));
+ return talloc_asprintf(mem_ctx, "%s = %s : %s", val->name?val->name:"<No Name>", str_regtype(val->data_type), reg_val_data_string(mem_ctx, val->data_type, &val->data));
}
-BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, struct registry_value **value)
+BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data)
{
int i;
- *value = talloc(mem_ctx, struct registry_value);
- (*value)->data_type = -1;
+ *type = -1;
/* Find the correct type */
for (i = 0; reg_value_types[i].name; i++) {
if (!strcmp(reg_value_types[i].name, type_str)) {
- (*value)->data_type = reg_value_types[i].id;
+ *type = reg_value_types[i].id;
break;
}
}
- if ((*value)->data_type == -1)
+ if (*type == -1)
return False;
/* Convert data appropriately */
- switch ((*value)->data_type)
+ switch (*type)
{
case REG_SZ:
case REG_EXPAND_SZ:
- (*value)->data.length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&(*value)->data.data);
+ data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&data->data);
break;
case REG_DWORD: {
uint32_t tmp = strtol(data_str, NULL, 0);
- (*value)->data = data_blob_talloc(mem_ctx, &tmp, 4);
+ *data = data_blob_talloc(mem_ctx, &tmp, 4);
}
break;
case REG_NONE:
- ZERO_STRUCT((*value)->data);
+ ZERO_STRUCT(data);
break;
+ case REG_BINARY:
+ *data = strhex_to_data_blob(data_str);
+ talloc_steal(mem_ctx, data->data);
+ break;
+
default:
- case REG_BINARY: /* FIXME */
+ /* FIXME */
return False;
}
return True;