diff options
author | Ryan Lortie <desrt@desrt.ca> | 2010-06-10 16:37:19 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2010-06-10 16:37:19 -0400 |
commit | c81c09ea027e7dbc45ae202137ea2281e7295ed8 (patch) | |
tree | 7a462535eb6e18d1a338c86cb108412917e478f4 /gvdb | |
parent | 4e0a2bc4f98c18ff03a594d92fe65dfcfc5e2f80 (diff) | |
parent | afea703422001cbbe8bbd2e13842008a482cd9ae (diff) | |
download | dconf-c81c09ea027e7dbc45ae202137ea2281e7295ed8.tar.gz |
Merge remote branch 'gvdb/master'
Diffstat (limited to 'gvdb')
-rw-r--r-- | gvdb/gvdb-builder.c | 41 | ||||
-rw-r--r-- | gvdb/gvdb-builder.h | 3 | ||||
-rw-r--r-- | gvdb/gvdb-format.h | 2 | ||||
-rw-r--r-- | gvdb/gvdb-reader.c | 37 | ||||
-rw-r--r-- | gvdb/gvdb-reader.h | 3 |
5 files changed, 16 insertions, 70 deletions
diff --git a/gvdb/gvdb-builder.c b/gvdb/gvdb-builder.c index 5a71970..fdd0ef4 100644 --- a/gvdb/gvdb-builder.c +++ b/gvdb/gvdb-builder.c @@ -36,7 +36,6 @@ struct _GvdbItem GvdbItem *parent; GvdbItem *sibling; GvdbItem *next; - GVariant *options; /* one of: * this: @@ -60,9 +59,6 @@ gvdb_item_free (gpointer data) if (item->value) g_variant_unref (item->value); - if (item->options) - g_variant_unref (item->options); - if (item->table) g_hash_table_unref (item->table); @@ -136,15 +132,6 @@ gvdb_item_set_value (GvdbItem *item, } void -gvdb_item_set_options (GvdbItem *item, - GVariant *options) -{ - g_return_if_fail (!item->options); - - item->options = g_variant_ref_sink (options); -} - -void gvdb_item_set_hash_table (GvdbItem *item, GHashTable *table) { @@ -282,33 +269,6 @@ file_builder_add_value (FileBuilder *fb, } static void -file_builder_add_options (FileBuilder *fb, - GVariant *options, - struct gvdb_pointer *pointer) -{ - GVariant *normal; - gpointer data; - gsize size; - - if (options) - { - if (fb->byteswap) - { - options = g_variant_byteswap (options); - normal = g_variant_get_normal_form (options); - g_variant_unref (options); - } - else - normal = g_variant_get_normal_form (options); - - size = g_variant_get_size (normal); - data = file_builder_allocate (fb, 8, size, pointer); - g_variant_store (normal, data); - g_variant_unref (normal); - } -} - -static void file_builder_add_string (FileBuilder *fb, const gchar *string, guint32_le *start, @@ -424,7 +384,6 @@ file_builder_add_hash (FileBuilder *fb, g_assert (item->child == NULL && item->table == NULL); file_builder_add_value (fb, item->value, &entry->value.pointer); - file_builder_add_options (fb, item->options, &entry->options); entry->type = 'v'; } diff --git a/gvdb/gvdb-builder.h b/gvdb/gvdb-builder.h index c0d3b30..797626e 100644 --- a/gvdb/gvdb-builder.h +++ b/gvdb/gvdb-builder.h @@ -42,9 +42,6 @@ G_GNUC_INTERNAL void gvdb_item_set_value (GvdbItem *item, GVariant *value); G_GNUC_INTERNAL -void gvdb_item_set_options (GvdbItem *item, - GVariant *options); -G_GNUC_INTERNAL void gvdb_item_set_hash_table (GvdbItem *item, GHashTable *table); G_GNUC_INTERNAL diff --git a/gvdb/gvdb-format.h b/gvdb/gvdb-format.h index f11a033..886aa56 100644 --- a/gvdb/gvdb-format.h +++ b/gvdb/gvdb-format.h @@ -51,8 +51,6 @@ struct gvdb_hash_item { struct gvdb_pointer pointer; gchar direct[8]; } value; - - struct gvdb_pointer options; }; struct gvdb_header { diff --git a/gvdb/gvdb-reader.c b/gvdb/gvdb-reader.c index 54bad9d..a043060 100644 --- a/gvdb/gvdb-reader.c +++ b/gvdb/gvdb-reader.c @@ -422,7 +422,6 @@ gvdb_table_value_from_item (GvdbTable *table, * gvdb_table_get_value: * @file: a #GvdbTable * @key: a string - * @options: a pointer to a #GVariant, or %NULL * @returns: a #GVariant, or %NULL * * Looks up a value named @key in @file. @@ -431,17 +430,12 @@ gvdb_table_value_from_item (GvdbTable *table, * #GVariant instance is returned. The #GVariant does not depend on the * continued existence of @file. * - * If @options is non-%NULL then it will be set either to %NULL in the - * case of no options or a #GVariant containing a dictionary mapping - * strings to variants. - * * You should call g_variant_unref() on the return result when you no * longer require it. **/ GVariant * gvdb_table_get_value (GvdbTable *file, - const gchar *key, - GVariant **options) + const gchar *key) { const struct gvdb_hash_item *item; GVariant *value; @@ -451,23 +445,13 @@ gvdb_table_get_value (GvdbTable *file, value = gvdb_table_value_from_item (file, item); - if (options != NULL) + if (value && file->byteswapped) { - gconstpointer data; - gsize size; + GVariant *tmp; - data = gvdb_table_dereference (file, &item->options, 8, &size); - - if (data != NULL && size > 0) - { - *options = g_variant_new_from_data (G_VARIANT_TYPE ("a{sv}"), - data, size, file->trusted, - (GDestroyNotify) g_mapped_file_unref, - g_mapped_file_ref (file->mapped)); - g_variant_ref_sink (*options); - } - else - *options = NULL; + tmp = g_variant_byteswap (value); + g_variant_unref (value); + value = tmp; } return value; @@ -607,6 +591,15 @@ gvdb_table_walk (GvdbTable *table, 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); g_variant_unref (value); } diff --git a/gvdb/gvdb-reader.h b/gvdb/gvdb-reader.h index 2698e6c..a29c16e 100644 --- a/gvdb/gvdb-reader.h +++ b/gvdb/gvdb-reader.h @@ -43,8 +43,7 @@ GvdbTable * gvdb_table_get_table (GvdbTab const gchar *key); G_GNUC_INTERNAL GVariant * gvdb_table_get_value (GvdbTable *table, - const gchar *key, - GVariant **options); + const gchar *key); G_GNUC_INTERNAL gboolean gvdb_table_has_value (GvdbTable *table, |