Implement byteswapping in the reader

This commit is contained in:
Ryan Lortie 2010-06-10 15:27:46 -04:00
parent 9a8cba9eb5
commit afea703422

View File

@ -438,11 +438,23 @@ gvdb_table_get_value (GvdbTable *file,
const gchar *key) const gchar *key)
{ {
const struct gvdb_hash_item *item; const struct gvdb_hash_item *item;
GVariant *value;
if ((item = gvdb_table_lookup (file, key, 'v')) == NULL) if ((item = gvdb_table_lookup (file, key, 'v')) == NULL)
return NULL; return NULL;
return gvdb_table_value_from_item (file, item); value = gvdb_table_value_from_item (file, item);
if (value && file->byteswapped)
{
GVariant *tmp;
tmp = g_variant_byteswap (value);
g_variant_unref (value);
value = tmp;
}
return value;
} }
/** /**
@ -579,6 +591,15 @@ gvdb_table_walk (GvdbTable *table,
if (value != NULL) if (value != NULL)
{ {
if (table->byteswapped)
{
GVariant *tmp;
tmp = g_variant_byteswap (value);
g_variant_unref (value);
value = tmp;
}
value_func (name, name_len, value, user_data); value_func (name, name_len, value, user_data);
g_variant_unref (value); g_variant_unref (value);
} }