X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fstore.c;h=d83fe037717ea1778c51bc64dc4022b3b7d49567;hb=d3949cc58f81fc5c84231f79720250ded9e8f143;hp=785372b4d961452e855d1f9142323bb31a93389c;hpb=d4f612098ea5541a81adf302f58239aa9d3e8227;p=bluesky.git diff --git a/bluesky/store.c b/bluesky/store.c index 785372b..d83fe03 100644 --- a/bluesky/store.c +++ b/bluesky/store.c @@ -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; } @@ -88,6 +101,11 @@ BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store) return async; } +gpointer bluesky_store_async_get_handle(BlueSkyStoreAsync *async) +{ + return async->store->handle; +} + void bluesky_store_async_ref(BlueSkyStoreAsync *async) { if (async == NULL) @@ -296,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(); @@ -362,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); }