summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJusung Son <jusung07.son@samsung.com>2020-06-15 15:26:55 +0900
committerJusung Son <jusung07.son@samsung.com>2020-06-15 15:26:55 +0900
commitc1e2f68fbcbd03da1faad4607441396c50e91ba3 (patch)
tree53cc1d3b16b2234059a6dc2ca3c8f8dd249e7dbc
parentbac55e2ae6583a850c4cd1e96f21c9b04f89d3cc (diff)
downloadbuxton2-c1e2f68fbcbd03da1faad4607441396c50e91ba3.tar.gz
buxton2-c1e2f68fbcbd03da1faad4607441396c50e91ba3.tar.bz2
buxton2-c1e2f68fbcbd03da1faad4607441396c50e91ba3.zip
Remove unused backend
Change-Id: Ifeefb46d4c27c800009608f545ce08ad395facdc Signed-off-by: Jusung Son <jusung07.son@samsung.com>
-rw-r--r--backend/CMakeLists.txt11
-rw-r--r--backend/gdbm.c351
-rw-r--r--packaging/buxton2.spec1
3 files changed, 0 insertions, 363 deletions
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index 06f53cb..92fea53 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -1,14 +1,3 @@
-# gdbm.so build
-SET(TARGET gdbm)
-SET(SRC gdbm.c)
-ADD_LIBRARY(${TARGET} SHARED ${SRC})
-SET_TARGET_PROPERTIES(${TARGET} PROPERTIES
- PREFIX ""
- COMPILE_FLAGS "-fvisibility=hidden"
-)
-TARGET_LINK_LIBRARIES(${TARGET} ${PKGS_LDFLAGS} -lgdbm)
-INSTALL(TARGETS ${TARGET} DESTINATION ${MODULE_DIR} COMPONENT RuntimeLibraries)
-
SET(TARGET sqlite)
SET(SRC sqlite.c)
ADD_LIBRARY(${TARGET} SHARED ${SRC})
diff --git a/backend/gdbm.c b/backend/gdbm.c
deleted file mode 100644
index 920444d..0000000
--- a/backend/gdbm.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Buxton
- *
- * Copyright (C) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <gdbm.h>
-
-#include "backend.h"
-#include "log.h"
-#include "buxton_error.h"
-
-static GHashTable *dbs;
-
-static void free_db(GDBM_FILE db)
-{
- if (!db)
- return;
-
- gdbm_close(db);
-}
-
-static int open_gdbm(const char *dbpath, bool readonly, GDBM_FILE *db)
-{
- GDBM_FILE tmp_db;
- char *nm;
- int cache_size;
- int r;
-
- if (!dbpath || !db) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- if (!dbs) {
- bxt_err("dbs is not initilized.");
- return BUXTON_ERROR_INVALID_OPERATION;
- }
-
- tmp_db = g_hash_table_lookup(dbs, dbpath);
- if (tmp_db) {
- *db = tmp_db;
- return BUXTON_ERROR_NONE;
- }
-
- nm = strdup(dbpath);
- if (!nm) {
- bxt_err("out of memory");
- return BUXTON_ERROR_OUT_OF_MEMORY;
- }
-
- tmp_db = gdbm_open(nm, 0, readonly ? GDBM_READER : GDBM_WRCREAT,
- S_IRUSR | S_IWUSR, NULL);
- if (!tmp_db) {
- bxt_err("Open '%s' failed: %s", dbpath,
- gdbm_strerror(gdbm_errno));
- free(nm);
- return BUXTON_ERROR_IO_ERROR;
- }
-
- cache_size = 50;
- r = gdbm_setopt(tmp_db, GDBM_CACHESIZE, &cache_size, sizeof(cache_size));
- if (r == -1)
- bxt_err("Set option failed: %s", gdbm_strerror(gdbm_errno));
-
- g_hash_table_insert(dbs, nm, tmp_db);
-
- bxt_dbg("Open '%s'", dbpath);
-
- *db = tmp_db;
- return BUXTON_ERROR_NONE;
-}
-
-static int open_db(const char *dbpath, bool readonly)
-{
- GDBM_FILE db;
-
- if (!dbpath || !*dbpath) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- return open_gdbm(dbpath, readonly, &db);
-}
-
-static int close_db(const char *dbpath)
-{
- GDBM_FILE db;
-
- if (!dbpath || !*dbpath) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- if (!dbs) {
- bxt_err("dbs is not initilized.");
- return BUXTON_ERROR_INVALID_OPERATION;
- }
-
- db = g_hash_table_lookup(dbs, dbpath);
-
- if (!db)
- return BUXTON_ERROR_NONE;
-
- g_hash_table_remove(dbs, dbpath);
-
- bxt_info("close '%s'", dbpath);
-
- return BUXTON_ERROR_NONE;
-}
-
-static int remove_db(const char *dbpath)
-{
- GDBM_FILE db;
- int r;
-
- if (!dbpath || !*dbpath) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- if (!dbs) {
- bxt_err("dbs is not initilized.");
- return BUXTON_ERROR_INVALID_OPERATION;
- }
-
- db = g_hash_table_lookup(dbs, dbpath);
- if (db)
- g_hash_table_remove(dbs, dbpath);
-
- r = unlink(dbpath);
- if (r == -1) {
- bxt_err("Remove '%s' failed: %d", dbpath, errno);
- return BUXTON_ERROR_IO_ERROR;
- }
-
- bxt_dbg("Remove '%s'", dbpath);
-
- return BUXTON_ERROR_NONE;
-}
-
-static int set_value(const char *dbpath, const char *key, const void *data,
- int dlen)
-{
- GDBM_FILE db;
- int r;
- datum d_key;
- datum d_data;
-
- if (!dbpath || !*dbpath || !key || !*key || !data || dlen <= 0) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- r = open_gdbm(dbpath, false, &db);
- if (r != BUXTON_ERROR_NONE)
- return r;
-
- d_key.dptr = (char *)key;
- d_key.dsize = strlen(key) + 1;
-
- d_data.dptr = (char *)data;
- d_data.dsize = dlen;
-
- r = gdbm_store(db, d_key, d_data, GDBM_REPLACE);
- if (r) {
- bxt_err("Set '%s' failed: %s", key, gdbm_strerror(gdbm_errno));
- return BUXTON_ERROR_IO_ERROR;
- }
-
- gdbm_sync(db);
-
- bxt_dbg("Set '%s' Key '%s'", dbpath, key);
-
- return BUXTON_ERROR_NONE;
-}
-
-static int get_value(const char *dbpath, const char *key, void **data,
- int *dlen, bool readonly)
-{
- GDBM_FILE db;
- datum d_key;
- datum d_data;
- int r;
-
- if (!dbpath || !*dbpath || !key || !*key || !data || !dlen) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- r = open_gdbm(dbpath, readonly, &db);
- if (r != BUXTON_ERROR_NONE)
- return r;
-
- d_key.dptr = (char *)key;
- d_key.dsize = strlen(key) + 1;
-
- d_data = gdbm_fetch(db, d_key);
- if (d_data.dptr == NULL)
- return BUXTON_ERROR_NOT_EXIST;
-
- *data = d_data.dptr;
- *dlen = d_data.dsize;
-
- bxt_dbg("Get '%s' Key '%s'", dbpath, key);
-
- return BUXTON_ERROR_NONE;
-}
-
-static int unset_value(const char *dbpath, const char *key)
-{
- GDBM_FILE db;
- int r;
- datum d_key;
-
- if (!dbpath || !*dbpath || !key || !*key) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- r = open_gdbm(dbpath, false, &db);
- if (r != BUXTON_ERROR_NONE)
- return r;
-
- d_key.dptr = (char *)key;
- d_key.dsize = strlen(key) + 1;
-
- r = gdbm_delete(db, d_key);
- if (r) {
- if (gdbm_errno == GDBM_ITEM_NOT_FOUND)
- return BUXTON_ERROR_NOT_EXIST;
-
- bxt_err("unset '%s' failed: %d", key, gdbm_errno);
- return BUXTON_ERROR_IO_ERROR;
- }
-
- gdbm_sync(db);
-
- bxt_dbg("Unset '%s' Key '%s'", dbpath, key);
-
- return BUXTON_ERROR_NONE;
-}
-
-static int list_keys(const char *dbpath, char ***keys, unsigned int *klen,
- bool readonly)
-{
- GDBM_FILE db;
- GList *list;
- GList *l;
- datum d_key;
- int i, r;
- unsigned int _klen;
- char **_keys;
-
- if (!dbpath || !*dbpath || !keys) {
- bxt_err("Invalid parameter");
- return BUXTON_ERROR_INVALID_PARAMETER;
- }
-
- r = open_gdbm(dbpath, readonly, &db);
- if (r != BUXTON_ERROR_NONE)
- return r;
-
- _klen = 0;
- list = NULL;
- d_key = gdbm_firstkey(db);
- while (d_key.dptr) {
- list = g_list_append(list, d_key.dptr);
- _klen++;
- d_key = gdbm_nextkey(db, d_key);
- }
-
- /* +1 for NULL terminated */
- _keys = malloc(sizeof(void *) * (_klen + 1));
- if (!_keys) {
- g_list_free_full(list, (GDestroyNotify)free);
- bxt_err("out of memory");
- return BUXTON_ERROR_OUT_OF_MEMORY;
- }
-
- for (i = 0, l = list; l && i < _klen; l = g_list_next(l), i++)
- _keys[i] = l->data;
-
- /* NULL terminated */
- _keys[i] = NULL;
-
- g_list_free(list);
-
- *keys = _keys;
-
- if (klen)
- *klen = _klen;
-
- bxt_dbg("List '%s'", dbpath);
-
- return BUXTON_ERROR_NONE;
-}
-
-static void module_exit(void)
-{
- g_hash_table_destroy(dbs);
- dbs = NULL;
-}
-
-static int module_init(void)
-{
- dbs = g_hash_table_new_full(g_str_hash, g_str_equal,
- (GDestroyNotify)free, (GDestroyNotify)free_db);
- if (!dbs) {
- bxt_err("out of memory");
- return BUXTON_ERROR_OUT_OF_MEMORY;
- }
-
- return BUXTON_ERROR_NONE;
-}
-
-DEFINE_BUXTON_BACKEND = {
- .name = "gdbm",
-
- .module_init = module_init,
- .module_exit = module_exit,
-
- .open_db = open_db,
- .close_db = close_db,
- .remove_db = remove_db,
- .set_value = set_value,
- .get_value = get_value,
- .unset_value = unset_value,
- .list_keys = list_keys,
-};
-
diff --git a/packaging/buxton2.spec b/packaging/buxton2.spec
index fdf0be5..1557aca 100644
--- a/packaging/buxton2.spec
+++ b/packaging/buxton2.spec
@@ -15,7 +15,6 @@ Source3: %{name}.socket
Source4: %{name}.tmpfiles.conf
Source1001: %{name}.manifest
BuildRequires: cmake
-BuildRequires: gdbm-devel
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libsystemd)