Store backends now consist of a type followed by extra information.
[bluesky.git] / bluesky / store.c
index 8cf9f0e..d83fe03 100644 (file)
@@ -45,13 +45,25 @@ BlueSkyStore *bluesky_store_new(const gchar *type)
 {
     const BlueSkyStoreImplementation *impl;
 
-    impl = g_hash_table_lookup(store_implementations, type);
-    if (impl == NULL)
+    gchar *scheme, *path;
+    scheme = g_strdup(type);
+    path = strchr(scheme, ':');
+    if (path != NULL) {
+        *path = '\0';
+        path++;
+    }
+
+    impl = g_hash_table_lookup(store_implementations, scheme);
+    if (impl == NULL) {
+        g_free(scheme);
         return NULL;
+    }
 
-    gpointer handle = impl->create();
-    if (handle == NULL)
+    gpointer handle = impl->create(path);
+    if (handle == NULL) {
+        g_free(scheme);
         return NULL;
+    }
 
     BlueSkyStore *store = g_new(BlueSkyStore, 1);
     store->impl = impl;
@@ -59,6 +71,7 @@ BlueSkyStore *bluesky_store_new(const gchar *type)
     store->lock = g_mutex_new();
     store->cond_idle = g_cond_new();
     store->pending = 0;
+    g_free(scheme);
     return store;
 }
 
@@ -301,7 +314,7 @@ typedef struct {
     GHashTable *store;
 } MemStore;
 
-static gpointer memstore_create()
+static gpointer memstore_create(const gchar *path)
 {
     MemStore *store = g_new(MemStore, 1);
     store->lock = g_mutex_new();
@@ -367,7 +380,7 @@ static BlueSkyStoreImplementation memstore_impl = {
 };
 
 /* Store implementation which writes data as files to disk. */
-static gpointer filestore_create()
+static gpointer filestore_create(const gchar *path)
 {
     return GINT_TO_POINTER(1);
 }