Signed-off-by: Alex Nelson <ajnelson(a)cs.ucsc.edu>
---
xml/hivexml.c | 42 ++++++++++++++++++++++++++++++++++--------
1 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/xml/hivexml.c b/xml/hivexml.c
index d38e9d4..1a75593 100644
--- a/xml/hivexml.c
+++ b/xml/hivexml.c
@@ -247,6 +247,32 @@ node_end (hive_h *h, void *writer_v, hive_node_h node, const char
*name)
return 0;
}
+/*
+ * Hive type names retrieved from:
+ *
https://secure.wikimedia.org/wikipedia/en/wiki/Windows_Registry#Keys_and_...
+ * (Retrieved 2011-10-09)
+ * Caller should not free return value.
+ */
+static char *
+value_type_windows_string (hive_type t)
+{
+ switch (t) {
+ case 0: return "REG_NONE"; break;
+ case 1: return "REG_SZ"; break;
+ case 2: return "REG_EXPAND_SZ"; break;
+ case 3: return "REG_BINARY"; break;
+ case 4: return "REG_DWORD_LITTLE_ENDIAN"; break;
+ case 5: return "REG_DWORD_BIG_ENDIAN"; break;
+ case 6: return "REG_LINK"; break;
+ case 7: return "REG_MULTI_SZ"; break;
+ case 8: return "REG_RESOURCE_LIST"; break;
+ case 9: return "REG_FULL_RESOURCE_DESCRIPTOR"; break;
+ case 10: return "REG_RESOURCE_REQUIREMENTS_LIST"; break;
+ case 11: return "REG_QWORD"; break;
+ default: return "unknown"; break;
+ }
+}
+
static void
start_value (xmlTextWriterPtr writer,
const char *key, const char *type, const char *encoding)
@@ -294,7 +320,7 @@ value_string (hive_h *h, void *writer_v, hive_node_h node,
hive_value_h value,
type = "unknown";
}
- start_value (writer, key, type, NULL);
+ start_value (writer, key, value_type_windows_string (t), NULL);
XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST "value"));
XML_CHECK (xmlTextWriterWriteString, (writer, BAD_CAST str));
XML_CHECK (xmlTextWriterEndAttribute, (writer));
@@ -308,7 +334,7 @@ value_multiple_strings (hive_h *h, void *writer_v, hive_node_h node,
const char *key, char **argv)
{
xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
- start_value (writer, key, "string-list", NULL);
+ start_value (writer, key, value_type_windows_string (t), NULL);
size_t i;
for (i = 0; argv[i] != NULL; ++i) {
@@ -350,7 +376,7 @@ value_string_invalid_utf16 (hive_h *h, void *writer_v, hive_node_h
node,
type = "unknown";
}
- start_value (writer, key, type, "base64");
+ start_value (writer, key, value_type_windows_string (t), "base64");
XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST "value"));
XML_CHECK (xmlTextWriterWriteBase64, (writer, str, 0, len));
XML_CHECK (xmlTextWriterEndAttribute, (writer));
@@ -364,7 +390,7 @@ value_dword (hive_h *h, void *writer_v, hive_node_h node, hive_value_h
value,
hive_type t, size_t len, const char *key, int32_t v)
{
xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
- start_value (writer, key, "int32", NULL);
+ start_value (writer, key, value_type_windows_string (t), NULL);
XML_CHECK (xmlTextWriterWriteFormatAttribute, (writer, BAD_CAST "value",
"%" PRIi32, v));
end_value (writer);
return 0;
@@ -375,7 +401,7 @@ value_qword (hive_h *h, void *writer_v, hive_node_h node, hive_value_h
value,
hive_type t, size_t len, const char *key, int64_t v)
{
xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
- start_value (writer, key, "int64", NULL);
+ start_value (writer, key, value_type_windows_string (t), NULL);
XML_CHECK (xmlTextWriterWriteFormatAttribute, (writer, BAD_CAST "value",
"%" PRIi64, v));
end_value (writer);
return 0;
@@ -386,7 +412,7 @@ value_binary (hive_h *h, void *writer_v, hive_node_h node,
hive_value_h value,
hive_type t, size_t len, const char *key, const char *v)
{
xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
- start_value (writer, key, "binary", "base64");
+ start_value (writer, key, value_type_windows_string (t), "base64");
XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST "value"));
XML_CHECK (xmlTextWriterWriteBase64, (writer, v, 0, len));
XML_CHECK (xmlTextWriterEndAttribute, (writer));
@@ -399,7 +425,7 @@ value_none (hive_h *h, void *writer_v, hive_node_h node, hive_value_h
value,
hive_type t, size_t len, const char *key, const char *v)
{
xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
- start_value (writer, key, "none", "base64");
+ start_value (writer, key, value_type_windows_string (t), "base64");
if (len > 0) {
XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST "value"));
XML_CHECK (xmlTextWriterWriteBase64, (writer, v, 0, len));
@@ -436,7 +462,7 @@ value_other (hive_h *h, void *writer_v, hive_node_h node, hive_value_h
value,
type = "unknown";
}
- start_value (writer, key, type, "base64");
+ start_value (writer, key, value_type_windows_string (t), "base64");
if (len > 0) {
XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST "value"));
XML_CHECK (xmlTextWriterWriteBase64, (writer, v, 0, len));
--
1.7.6.4