+
+static BlueSkyStoreImplementation memstore_impl = {
+ .create = memstore_create,
+ .destroy = memstore_destroy,
+ .get = memstore_get,
+ .put = memstore_put,
+};
+
+/* Store implementation which writes data as files to disk. */
+static gpointer filestore_create()
+{
+ return GINT_TO_POINTER(1);
+}
+
+static void filestore_destroy()
+{
+}
+
+static BlueSkyRCStr *filestore_get(gpointer s, const gchar *key)
+{
+ gchar *contents = NULL;
+ gsize length;
+ GError *error = NULL;
+
+ g_file_get_contents(key, &contents, &length, &error);
+ if (contents == NULL)
+ return NULL;
+
+ return bluesky_string_new(contents, length);
+}
+
+static void filestore_put(gpointer s, const gchar *key, BlueSkyRCStr *val)
+{
+ g_file_set_contents(key, val->data, val->len, NULL);
+}
+
+static BlueSkyStoreImplementation filestore_impl = {
+ .create = filestore_create,
+ .destroy = filestore_destroy,
+ .get = filestore_get,
+ .put = filestore_put,
+};
+
+void bluesky_store_init()
+{
+ store_implementations = g_hash_table_new(g_str_hash, g_str_equal);
+ bluesky_store_register(&memstore_impl, "mem");
+ bluesky_store_register(&filestore_impl, "file");
+}