diff options
author | Richard Hughes <richard@hughsie.com> | 2016-01-13 11:47:29 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-01-13 11:47:35 +0000 |
commit | d114e05c4a4260cc0f963017e52bfe7861d1e39a (patch) | |
tree | a4d006bd562691f590f05a9c1ccc6153ebf8ca1f | |
parent | 53fa7cbc4fa846217e9b0f647d2837bab6f11790 (diff) | |
download | appstream-glib-d114e05c4a4260cc0f963017e52bfe7861d1e39a.tar.gz |
Automatically add missing .inf types as required
Some .inf files miss the vital [Strings] section, which I think is actually
required for MS HWQL.
-rw-r--r-- | libappstream-glib/as-inf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c index d4bebea..41e2a41 100644 --- a/libappstream-glib/as-inf.c +++ b/libappstream-glib/as-inf.c @@ -159,6 +159,17 @@ as_inf_get_dict (AsInfHelper *helper, GError **error) g_autofree gchar *lower = NULL; g_autoptr(GHashTable) dict_tmp = NULL; g_auto(GStrv) keys = NULL; + struct { + const gchar *search; + const gchar *replace; + } types[] = { + { "REG_SZ", "0x00000000" }, + { "REG_BINARY", "0x00000001" }, + { "REG_MULTI_SZ", "0x00010000" }, + { "REG_EXPAND_SZ", "0x00020000" }, + { "REG_DWORD", "0x00010001" }, + { "REG_NONE", "0x00020001" }, + { NULL, NULL } }; dict_tmp = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); lower = as_inf_make_case_insensitive (helper, "Strings"); @@ -169,6 +180,16 @@ as_inf_get_dict (AsInfHelper *helper, GError **error) goto out; g_hash_table_insert (dict_tmp, g_strdup (keys[i]), val); } + + /* verify that commonly missed types are present */ + for (i = 0; types[i].search != NULL; i++) { + if (g_hash_table_lookup (dict_tmp, types[i].search) == NULL) { + g_hash_table_insert (dict_tmp, + g_strdup (types[i].search), + g_strdup (types[i].replace)); + } + } + dict = g_hash_table_ref (dict_tmp); out: return dict; |