summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-03-17 19:21:05 -0400
committerColin Walters <walters@verbum.org>2014-03-19 09:49:55 -0400
commit606918e76339b6c62a06b04c6e8647345a24c692 (patch)
tree675b242d0c982b66e24dd97ed6e8e3efb7e17d7b
parent24b1e9c0acd6778e156b667348f4cf922aac013c (diff)
downloadostree-606918e76339b6c62a06b04c6e8647345a24c692.tar.gz
libostree: Add ostree_bootconfig_parser_clone()
This will be necessary to fix ostree_deployment_clone(), but is potentially useful on its own for other consumers.
-rw-r--r--src/libostree/ostree-bootconfig-parser.c24
-rw-r--r--src/libostree/ostree-bootconfig-parser.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/libostree/ostree-bootconfig-parser.c b/src/libostree/ostree-bootconfig-parser.c
index e6606858..f002a188 100644
--- a/src/libostree/ostree-bootconfig-parser.c
+++ b/src/libostree/ostree-bootconfig-parser.c
@@ -38,6 +38,30 @@ typedef GObjectClass OstreeBootconfigParserClass;
G_DEFINE_TYPE (OstreeBootconfigParser, ostree_bootconfig_parser, G_TYPE_OBJECT)
+/**
+ * ostree_bootconfig_parser_clone:
+ * @self: Bootconfig to clone
+ *
+ * Returns: (transfer full): Copy of @self
+ */
+OstreeBootconfigParser *
+ostree_bootconfig_parser_clone (OstreeBootconfigParser *self)
+{
+ OstreeBootconfigParser *parser = ostree_bootconfig_parser_new ();
+ guint i;
+ GHashTableIter hashiter;
+ gpointer k, v;
+
+ for (i = 0; i < self->lines->len; i++)
+ g_ptr_array_add (parser->lines, g_variant_ref (self->lines->pdata[i]));
+
+ g_hash_table_iter_init (&hashiter, self->options);
+ while (g_hash_table_iter_next (&hashiter, &k, &v))
+ g_hash_table_replace (parser->options, g_strdup (k), g_strdup (v));
+
+ return parser;
+}
+
gboolean
ostree_bootconfig_parser_parse (OstreeBootconfigParser *self,
GFile *path,
diff --git a/src/libostree/ostree-bootconfig-parser.h b/src/libostree/ostree-bootconfig-parser.h
index 07610169..629d1718 100644
--- a/src/libostree/ostree-bootconfig-parser.h
+++ b/src/libostree/ostree-bootconfig-parser.h
@@ -34,6 +34,8 @@ GType ostree_bootconfig_parser_get_type (void) G_GNUC_CONST;
OstreeBootconfigParser * ostree_bootconfig_parser_new (void);
+OstreeBootconfigParser * ostree_bootconfig_parser_clone (OstreeBootconfigParser *self);
+
gboolean ostree_bootconfig_parser_parse (OstreeBootconfigParser *self,
GFile *path,
GCancellable *cancellable,