diff options
-rw-r--r-- | include_protected/persistence_client_library_db_access.h (renamed from include_protected/persistence_client_library_data_access.h) | 61 | ||||
-rw-r--r-- | include_protected/persistence_client_library_db_access_ll.h | 34 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/persistence_client_library.c | 3 | ||||
-rw-r--r-- | src/persistence_client_library_db_access.c (renamed from src/persistence_client_library_data_access.c) | 119 | ||||
-rw-r--r-- | src/persistence_client_library_db_access_ll.c | 29 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_service.c | 1 | ||||
-rw-r--r-- | src/persistence_client_library_file.c | 4 | ||||
-rw-r--r-- | src/persistence_client_library_key.c | 18 | ||||
-rw-r--r-- | src/persistence_client_library_lc_interface.c | 6 | ||||
-rw-r--r-- | src/persistence_client_library_prct_access.c (renamed from src/persistence_client_library_access_helper.c) | 7 | ||||
-rw-r--r-- | src/persistence_client_library_prct_access.h (renamed from src/persistence_client_library_access_helper.h) | 5 | ||||
-rw-r--r-- | test/persistence_client_library_test.c | 26 |
13 files changed, 182 insertions, 135 deletions
diff --git a/include_protected/persistence_client_library_data_access.h b/include_protected/persistence_client_library_db_access.h index d0ec7df..e9cf3a7 100644 --- a/include_protected/persistence_client_library_data_access.h +++ b/include_protected/persistence_client_library_db_access.h @@ -1,5 +1,5 @@ -#ifndef PERSISTENCE_CLIENT_LIBRARY_DATA_ACCESS_H -#define PERSISTENCE_CLIENT_LIBRARY_DATA_ACCESS_H +#ifndef PERSISTENCE_CLIENT_LIBRARY_DB_ACCESS_H +#define PERSISTENCE_CLIENT_LIBRARY_DB_ACCESS_H /****************************************************************************** * Project Persistency @@ -15,7 +15,7 @@ * @file persistence_client_library_data_access.h * @ingroup Persistence client library * @author Ingo Huerner - * @brief Header of the persistence client library data access. + * @brief Header of the persistence client library database access. * Library provides an API to access persistent data * @see */ @@ -24,7 +24,7 @@ extern "C" { #endif -#define PERSIST_DATA_ACCESS_INTERFACE_VERSION (0x02100000U) +#define PERSIST_DATA_ACCESS_INTERFACE_VERSION (0x03000000U) #include "persistence_client_library.h" @@ -43,7 +43,7 @@ extern "C" { * @return the number of bytes written or a negative value if an error occured with the following error codes: * EPERS_SETDTAFAILED EPERS_NOPRCTABLE EPERS_NOKEYDATA EPERS_NOKEY */ -int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size); +int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size); @@ -59,7 +59,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig * @return the number of bytes read or a negative value if an error occured with the following error codes: * EPERS_NOPRCTABLE EPERS_NOKEYDATA EPERS_NOKEY */ -int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size); +int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size); @@ -73,19 +73,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig * @return size of data in bytes read from the key or on error a negative value with the following error codes: * EPERS_NOPRCTABLE or EPERS_NOKEY */ -int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info); - - - -/** - * @brief register for change notifications of a key - * - * @param dbPath the path to the database where the key is in - * @param key the database key to register on - * - * @return 0 of registration was successfull; -1 if registration failes - */ -int persistence_reg_notify_on_change(char* dbPath, char* key); +int pers_db_get_key_size(char* dbPath, char* key, PersistenceInfo_s* info); @@ -99,7 +87,7 @@ int persistence_reg_notify_on_change(char* dbPath, char* key); * @return 0 if deletion was successfull; * or an error code: EPERS_DB_KEY_SIZE, EPERS_NOPRCTABLE, EPERS_DB_ERROR_INTERNAL or EPERS_NOPLUGINFUNCT */ -int persistence_delete_data(char* dbPath, char* dbKey, PersistenceInfo_s* info); +int pers_db_delete_key(char* dbPath, char* dbKey, PersistenceInfo_s* info); @@ -108,14 +96,27 @@ int persistence_delete_data(char* dbPath, char* dbKey, PersistenceInfo_s* info); * * @param info persistence information */ -void database_close(PersistenceInfo_s* info); +void pers_db_close(PersistenceInfo_s* info); /** * @brief close all databases */ -void database_close_all(); +void pers_db_close_all(); + + + +/** + * @brief register for change notifications of a key + * + * @param dbPath the path to the database where the key is in + * @param key the database key to register on + * + * @return 0 of registration was successfull; -1 if registration failes + */ +int persistence_reg_notify_on_change(char* dbPath, char* key); + //--------------------------------------------------------------------------------------------- @@ -127,11 +128,10 @@ void database_close_all(); * to access the first entry in DB, call persistence_db_cursor_next * * @param dbPath[in] absolute path to the database - * @param storage[in] the storage identifier (local, shared or custom) * * @return handler to the DB (to be used in successive calls) or error code (< 0) */ -int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, PersistencePolicy_e policy); +int pers_db_cursor_create(char* dbPath); /** * @brief move cursor to the next position @@ -140,7 +140,7 @@ int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, Per * * @return 0 for success, negative value in case of error (check against EPERS_LAST_ENTRY_IN_DB) */ -int persistence_db_cursor_next(unsigned int handlerDB); +int pers_db_cursor_next(unsigned int handlerDB); /** * @brief get the name of the key pointed by the cursor associated with the database @@ -151,7 +151,7 @@ int persistence_db_cursor_next(unsigned int handlerDB); * * @return read size (if >= 0), error other way */ -int persistence_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bufSize) ; +int pers_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bufSize) ; /** * @brief get the data of the key pointed by the cursor associated with the database @@ -162,7 +162,7 @@ int persistence_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, * * @return read size (if >= 0), error other way */ -int persistence_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, int bufSize) ; +int pers_db_cursor_get_key_data(unsigned int handlerDB, char * bufData_out, int bufSize) ; /** * @brief get the data size of the key pointed by the cursor associated with the database @@ -171,7 +171,7 @@ int persistence_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, i * * @return positive value for data size, negative value for error */ -int persistence_db_cursor_get_data_size(unsigned int handlerDB) ; +int pers_db_cursor_get_data_size(unsigned int handlerDB) ; /** @@ -181,10 +181,11 @@ int persistence_db_cursor_get_data_size(unsigned int handlerDB) ; * * @return 0 for success, negative value in case of error */ -int persistence_db_cursor_destroy(unsigned int handlerDB) ; +int pers_db_cursor_destroy(unsigned int handlerDB) ; + #ifdef __cplusplus } #endif -#endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ACCESS_H */ +#endif /* PERSISTENCY_CLIENT_LIBRARY_DB_ACCESS_H */ diff --git a/include_protected/persistence_client_library_db_access_ll.h b/include_protected/persistence_client_library_db_access_ll.h new file mode 100644 index 0000000..5609db7 --- /dev/null +++ b/include_protected/persistence_client_library_db_access_ll.h @@ -0,0 +1,34 @@ +#ifndef PERSISTENCE_CLIENT_LIBRARY_DB_ACCESS_LL_H +#define PERSISTENCE_CLIENT_LIBRARY_DB_ACCESS_LL_H + +/****************************************************************************** + * Project Persistency + * (c) copyright 2012 + * Company XS Embedded GmbH + *****************************************************************************/ +/****************************************************************************** + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed + * with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +******************************************************************************/ + /** + * @file persistence_client_library_data_access.h + * @ingroup Persistence client library + * @author Ingo Huerner + * @brief Header of the persistence client library database low level access. + * @see + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define PERSIST_DATA_LL_ACCESS_INTERFACE_VERSION (0x01000000U) + +// TODO: put here low level database access function + +#ifdef __cplusplus +} +#endif + +#endif /* PERSISTENCY_CLIENT_LIBRARY_DB_ACCESS_LL_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 7155b3b..92ac187 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,13 +24,13 @@ libpersistence_client_library_la_SOURCES = \ persistence_client_library.c \ persistence_client_library_key.c \ persistence_client_library_file.c \ - persistence_client_library_data_access.c \ + persistence_client_library_db_access.c \ persistence_client_library_handle.c \ persistence_client_library_lc_interface.c \ persistence_client_library_pas_interface.c \ persistence_client_library_dbus_service.c \ persistence_client_library_custom_loader.c \ - persistence_client_library_access_helper.c \ + persistence_client_library_prct_access.c \ persistence_client_library_itzam_errors.c \ crc32.c diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 1a8a1c3..185a29a 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -20,14 +20,11 @@ #include "../include_protected/persistence_client_library.h" -#include "../include_protected/persistence_client_library_data_access.h" - #include "persistence_client_library_lc_interface.h" #include "persistence_client_library_pas_interface.h" #include "persistence_client_library_dbus_service.h" #include "persistence_client_library_handle.h" #include "persistence_client_library_custom_loader.h" -#include "persistence_client_library_access_helper.h" #include <string.h> #include <errno.h> diff --git a/src/persistence_client_library_data_access.c b/src/persistence_client_library_db_access.c index 8cb38c5..4d60c91 100644 --- a/src/persistence_client_library_data_access.c +++ b/src/persistence_client_library_db_access.c @@ -12,14 +12,13 @@ * @file persistence_client_library_data_access.c * @ingroup Persistence client library * @author Ingo Huerner - * @brief Implementation of persistence data access + * @brief Implementation of persistence database access * Library provides an API to access persistent data * @see */ -#include "../include_protected/persistence_client_library_data_access.h" +#include "../include_protected/persistence_client_library_db_access.h" #include "persistence_client_library_custom_loader.h" -#include "persistence_client_library_access_helper.h" #include "persistence_client_library_itzam_errors.h" #include <string.h> @@ -41,9 +40,8 @@ KeyValuePair_s; typedef struct _CursorEntry_s { itzam_btree_cursor m_cursor; - PersistenceStorage_e storage; - PersistencePolicy_e policy; - int m_empty; + itzam_btree m_btree; + int m_empty; } CursorEntry_s; @@ -67,8 +65,7 @@ static itzam_btree gBtree[DbTableSize][PersistencePolicy_LastEntry]; static int gBtreeCreated[DbTableSize][PersistencePolicy_LastEntry] = { {0} }; - -itzam_btree* database_get(PersistenceInfo_s* info, const char* dbPath) +itzam_btree* pers_db_open(PersistenceInfo_s* info, const char* dbPath) { int arrayIdx = 0; itzam_btree* btree = NULL; @@ -85,7 +82,7 @@ itzam_btree* database_get(PersistenceInfo_s* info, const char* dbPath) itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/); if (state != ITZAM_OKAY) { - fprintf(stderr, "database_get ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); + fprintf(stderr, "pers_db_open ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); } gBtreeCreated[arrayIdx][info->configKey.policy] = 1; } @@ -100,7 +97,8 @@ itzam_btree* database_get(PersistenceInfo_s* info, const char* dbPath) } -void database_close(PersistenceInfo_s* info) + +void pers_db_close(PersistenceInfo_s* info) { int arrayIdx = info->configKey.storage + info->context.ldbid; @@ -110,17 +108,19 @@ void database_close(PersistenceInfo_s* info) state = itzam_btree_close(&gBtree[arrayIdx][info->configKey.policy]); if (state != ITZAM_OKAY) { - fprintf(stderr, "database_close ==> Close Itzam problem: %s\n", STATE_MESSAGES[state]); + fprintf(stderr, "pers_db_close ==> Close Itzam problem: %s\n", STATE_MESSAGES[state]); } gBtreeCreated[arrayIdx][info->configKey.policy] = 0; } else { - printf("database_close ==> invalid storage type\n"); + printf("pers_db_close ==> invalid storage type\n"); } } -void database_close_all() + + +void pers_db_close_all() { int i = 0; @@ -133,7 +133,7 @@ void database_close_all() state = itzam_btree_close(&gBtree[i][PersistencePolicy_wc]); if (state != ITZAM_OKAY) { - fprintf(stderr, "database_close ==> Close WC: Itzam problem: %s\n", STATE_MESSAGES[state]); + fprintf(stderr, "pers_db_close_all ==> Close WC: Itzam problem: %s\n", STATE_MESSAGES[state]); } gBtreeCreated[i][PersistencePolicy_wc] = 0; } @@ -145,7 +145,7 @@ void database_close_all() state = itzam_btree_close(&gBtree[i][PersistencePolicy_wt]); if (state != ITZAM_OKAY) { - fprintf(stderr, "database_close ==> Close WT: Itzam problem: %s\n", STATE_MESSAGES[state]); + fprintf(stderr, "pers_db_close_all ==> Close WT: Itzam problem: %s\n", STATE_MESSAGES[state]); } gBtreeCreated[i][PersistencePolicy_wt] = 0; } @@ -154,7 +154,7 @@ void database_close_all() -int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size) +int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size) { int read_size = -1; @@ -165,7 +165,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig itzam_state state = ITZAM_FAILED; KeyValuePair_s search; - btree = database_get(info, dbPath); + btree = pers_db_open(info, dbPath); if(btree != NULL) { if(itzam_true == itzam_btree_find(btree, key, &search)) @@ -185,7 +185,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig // // workaround till lifecycle is working correctly // - database_close(info); + pers_db_close(info); } else { @@ -213,7 +213,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig -int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size) +int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size) { int write_size = -1; @@ -225,7 +225,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig itzam_state state = ITZAM_FAILED; KeyValuePair_s insert; - btree = database_get(info, dbPath); + btree = pers_db_open(info, dbPath); if(btree != NULL) { int keySize = 0; @@ -268,7 +268,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig // // workaround till lifecycle is working correctly // - database_close(info); + pers_db_close(info); } else { @@ -299,7 +299,7 @@ int persistence_set_data(char* dbPath, char* key, PersistenceInfo_s* info, unsig -int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info) +int pers_db_get_key_size(char* dbPath, char* key, PersistenceInfo_s* info) { int read_size = -1; @@ -311,7 +311,7 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info) itzam_state state = ITZAM_FAILED; KeyValuePair_s search; - btree = database_get(info, dbPath); + btree = pers_db_open(info, dbPath); if(btree != NULL) { keySize = (int)strlen((const char*)key); @@ -336,7 +336,7 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info) // // workaround till lifecycle is working correctly // - database_close(info); + pers_db_close(info); } else { @@ -361,7 +361,7 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceInfo_s* info) -int persistence_delete_data(char* dbPath, char* dbKey, PersistenceInfo_s* info) +int pers_db_delete_key(char* dbPath, char* dbKey, PersistenceInfo_s* info) { int ret = 0; if(PersistenceStorage_custom != info->configKey.storage) @@ -370,7 +370,7 @@ int persistence_delete_data(char* dbPath, char* dbKey, PersistenceInfo_s* info) KeyValuePair_s delete; //printf("delete_key_from_table_itzam => Path: \"%s\" | key: \"%s\" \n", dbPath, key); - btree = database_get(info, dbPath); + btree = pers_db_open(info, dbPath); if(btree != NULL) { int keySize = 0; @@ -396,7 +396,7 @@ int persistence_delete_data(char* dbPath, char* dbKey, PersistenceInfo_s* info) // // workaround till lifecycle is working correctly // - database_close(info); + pers_db_close(info); } else { @@ -428,7 +428,9 @@ int persistence_reg_notify_on_change(char* dbPath, char* key) } + //--------------------------------------------------------------------------------------------------------- +// C U R S O R F U N C T I O N S //--------------------------------------------------------------------------------------------------------- int get_cursor_handle() @@ -473,35 +475,33 @@ void close_cursor_handle(int handlerDB) -int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, PersistencePolicy_e policy) +int pers_db_cursor_create(char* dbPath) { int handle = -1; - itzam_btree* btree = NULL; + itzam_state state = ITZAM_FAILED; - PersistenceInfo_s info; - info.configKey.storage = storage; - info.configKey.policy = policy; + handle = get_cursor_handle(); - //printf("CREATE-Cursor: %d | path: %s \n", (int)storage, dbPath); - btree = database_get(&info, dbPath); - if(btree != NULL) + if(handle < MaxPersHandle && handle >= 0) { - itzam_state state; - handle = get_cursor_handle(); - if(handle < MaxPersHandle && handle >= 0) + // open database + state = itzam_btree_open(&gCursorArray[handle].m_btree, dbPath, itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/); + if (state != ITZAM_OKAY) + { + fprintf(stderr, "pers_db_open ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]); + } + else { - state = itzam_btree_cursor_create(&gCursorArray[handle].m_cursor, btree); + itzam_state state; + + state = itzam_btree_cursor_create(&gCursorArray[handle].m_cursor, &gCursorArray[handle].m_btree); if(state == ITZAM_OKAY) { gCursorArray[handle].m_empty = 0; - gCursorArray[handle].storage = storage; - gCursorArray[handle].policy = policy; } else { gCursorArray[handle].m_empty = 1; - gCursorArray[handle].storage = PersistenceStoragePolicy_LastEntry; - gCursorArray[handle].policy = PersistencePolicy_LastEntry; } } } @@ -510,7 +510,7 @@ int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, Per -int persistence_db_cursor_next(unsigned int handlerDB) +int pers_db_cursor_next(unsigned int handlerDB) { int rval = -1; if(handlerDB < MaxPersHandle && handlerDB >= 0) @@ -543,7 +543,7 @@ int persistence_db_cursor_next(unsigned int handlerDB) -int persistence_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bufSize) +int pers_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bufSize) { int rval = -1; KeyValuePair_s search; @@ -579,7 +579,7 @@ int persistence_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, -int persistence_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, int bufSize) +int pers_db_cursor_get_key_data(unsigned int handlerDB, char * bufData_out, int bufSize) { int rval = -1; KeyValuePair_s search; @@ -616,7 +616,7 @@ int persistence_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, i -int persistence_db_cursor_get_data_size(unsigned int handlerDB) +int pers_db_cursor_get_data_size(unsigned int handlerDB) { int size = -1; KeyValuePair_s search; @@ -642,31 +642,18 @@ int persistence_db_cursor_get_data_size(unsigned int handlerDB) -int persistence_db_cursor_destroy(unsigned int handlerDB) +int pers_db_cursor_destroy(unsigned int handlerDB) { int rval = -1; - itzam_state state; - if(handlerDB < MaxPersHandle) { - state = itzam_btree_cursor_free(&gCursorArray[handlerDB].m_cursor); - if (state == ITZAM_OKAY) - { - rval = 0; - /* - PersistenceInfo_s info; - info.configKey.storage = gCursorArray[handlerDB].storage; - info.configKey.policy = gCursorArray[handlerDB].policy; - - database_close(&info); // to do correct cursor handling - */ + itzam_btree_cursor_free(&gCursorArray[handlerDB].m_cursor); + gCursorArray[handlerDB].m_empty = 1; - gCursorArray[handlerDB].m_empty = 1; - gCursorArray[handlerDB].storage = PersistenceStoragePolicy_LastEntry; - gCursorArray[handlerDB].policy = PersistencePolicy_LastEntry; + itzam_btree_close(&gCursorArray[handlerDB].m_btree); + close_cursor_handle(handlerDB); - close_cursor_handle(handlerDB); - } + rval = 0; } return rval; } diff --git a/src/persistence_client_library_db_access_ll.c b/src/persistence_client_library_db_access_ll.c new file mode 100644 index 0000000..4452902 --- /dev/null +++ b/src/persistence_client_library_db_access_ll.c @@ -0,0 +1,29 @@ +/****************************************************************************** + * Project Persistency + * (c) copyright 2012 + * Company XS Embedded GmbH + *****************************************************************************/ +/****************************************************************************** + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed + * with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +******************************************************************************/ + /** + * @file persistence_client_library_data_access_ll.c + * @ingroup Persistence client library + * @author Ingo Huerner + * @brief Implementation of persistence database low level access + * @see + */ + +#include "../include_protected/persistence_client_library_db_access_ll.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +// TODO: put here low level database access function + + + + diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c index a598317..eec0412 100644 --- a/src/persistence_client_library_dbus_service.c +++ b/src/persistence_client_library_dbus_service.c @@ -16,7 +16,6 @@ * @see */ -//#include "persistence_client_service_dbus_service.h" #include "persistence_client_library_dbus_service.h" #include "persistence_client_library_lc_interface.h" diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index ea0c9c9..2dcaeb0 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -19,11 +19,11 @@ #include "persistence_client_library_file.h" #include "../include_protected/persistence_client_library.h" -#include "../include_protected/persistence_client_library_data_access.h" +#include "../include_protected/persistence_client_library_db_access.h" #include "persistence_client_library_pas_interface.h" #include "persistence_client_library_handle.h" -#include "persistence_client_library_access_helper.h" +#include "persistence_client_library_prct_access.h" #include <fcntl.h> // for open flags #include <errno.h> diff --git a/src/persistence_client_library_key.c b/src/persistence_client_library_key.c index 3772ea1..05084dd 100644 --- a/src/persistence_client_library_key.c +++ b/src/persistence_client_library_key.c @@ -19,11 +19,11 @@ #include "persistence_client_library_key.h" -#include "../include_protected/persistence_client_library_data_access.h" +#include "../include_protected/persistence_client_library_db_access.h" #include "persistence_client_library_handle.h" #include "persistence_client_library_pas_interface.h" -#include "persistence_client_library_access_helper.h" +#include "persistence_client_library_prct_access.h" #include "persistence_client_library_custom_loader.h" @@ -156,7 +156,7 @@ int key_handle_get_size(int key_handle) } else { - size = persistence_get_data_size(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, + size = pers_db_get_key_size(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, &gHandleArray[key_handle].info); } } @@ -186,7 +186,7 @@ int key_handle_read_data(int key_handle, unsigned char* buffer, int buffer_size) } else { - size = persistence_get_data(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, + size = pers_db_read_key(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, &gHandleArray[key_handle].info, buffer, buffer_size); } } @@ -230,7 +230,7 @@ int key_handle_write_data(int key_handle, unsigned char* buffer, int buffer_size } else { - size = persistence_set_data(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, + size = pers_db_write_key(gHandleArray[key_handle].dbPath, gHandleArray[key_handle].dbKey, &gHandleArray[key_handle].info, buffer, buffer_size); } } @@ -287,7 +287,7 @@ int key_delete(unsigned char ldbid, char* resource_id, unsigned char user_no, un if( dbContext.configKey.storage < PersistenceStoragePolicy_LastEntry && dbContext.configKey.storage >= PersistenceStorage_local) // check if store policy is valid { - rval = persistence_delete_data(dbPath, dbKey, &dbContext); + rval = pers_db_delete_key(dbPath, dbKey, &dbContext); } else { @@ -328,7 +328,7 @@ int key_get_size(unsigned char ldbid, char* resource_id, unsigned char user_no, if( dbContext.configKey.storage < PersistenceStoragePolicy_LastEntry && dbContext.configKey.storage >= PersistenceStorage_local) // check if store policy is valid { - data_size = persistence_get_data_size(dbPath, dbKey, &dbContext); + data_size = pers_db_get_key_size(dbPath, dbKey, &dbContext); } else { @@ -373,7 +373,7 @@ int key_read_data(unsigned char ldbid, char* resource_id, unsigned char user_no, if( dbContext.configKey.storage < PersistenceStoragePolicy_LastEntry && dbContext.configKey.storage >= PersistenceStorage_local) // check if store policy is valid { - data_size = persistence_get_data(dbPath, dbKey, &dbContext, buffer, buffer_size); + data_size = pers_db_read_key(dbPath, dbKey, &dbContext, buffer, buffer_size); } else { @@ -425,7 +425,7 @@ int key_write_data(unsigned char ldbid, char* resource_id, unsigned char user_no if( dbContext.configKey.storage < PersistenceStoragePolicy_LastEntry && dbContext.configKey.storage >= PersistenceStorage_local) // check if store policy is valid { - data_size = persistence_set_data(dbPath, dbKey, &dbContext, buffer, buffer_size); + data_size = pers_db_write_key(dbPath, dbKey, &dbContext, buffer, buffer_size); } else { diff --git a/src/persistence_client_library_lc_interface.c b/src/persistence_client_library_lc_interface.c index 963132e..1b0fbe4 100644 --- a/src/persistence_client_library_lc_interface.c +++ b/src/persistence_client_library_lc_interface.c @@ -20,13 +20,13 @@ #include "persistence_client_library_lc_interface.h" #include "../include_protected/persistence_client_library.h" -#include "../include_protected/persistence_client_library_data_access.h" +#include "../include_protected/persistence_client_library_db_access.h" #include "persistence_client_library_handle.h" #include "persistence_client_library_pas_interface.h" #include "persistence_client_library_dbus_service.h" #include "persistence_client_library_custom_loader.h" -#include "persistence_client_library_access_helper.h" +#include "persistence_client_library_prct_access.h" #include "persistence_client_library_itzam_errors.h" #include <errno.h> @@ -311,7 +311,7 @@ void process_prepare_shutdown(unsigned char requestId) } //close opend database - database_close_all(); + pers_db_close_all(); // unload custom client libraries diff --git a/src/persistence_client_library_access_helper.c b/src/persistence_client_library_prct_access.c index b5845f2..f4b8ddb 100644 --- a/src/persistence_client_library_access_helper.c +++ b/src/persistence_client_library_prct_access.c @@ -9,15 +9,16 @@ * with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ******************************************************************************/ /** - * @file persistence_client_library_access_helper.c + * @file persistence_client_library_prct_access.c * @ingroup Persistence client library * @author Ingo Huerner - * @brief Implementation of persistence access helper functions + * @brief Implementation of persistence resource configuration config + * table access functions * @see */ -#include "persistence_client_library_access_helper.h" +#include "persistence_client_library_prct_access.h" #include "persistence_client_library_itzam_errors.h" #include <stdlib.h> diff --git a/src/persistence_client_library_access_helper.h b/src/persistence_client_library_prct_access.h index 7a0a236..201e995 100644 --- a/src/persistence_client_library_access_helper.h +++ b/src/persistence_client_library_prct_access.h @@ -12,10 +12,11 @@ * with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ******************************************************************************/ /** - * @file persistence_client_library_access_helper.h + * @file persistence_client_library_prct_access.h * @ingroup Persistence client library * @author Ingo Huerner - * @brief Header of the persistence client library access helper. + * @brief Header of persistence resource configuration config + * table access functions * @see */ diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 9de9148..60adcfe 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -31,7 +31,7 @@ #include "../include/persistence_client_library_error_def.h" // protected header, should be used only be persistence components -#include "../include_protected/persistence_client_library_data_access.h" +#include "../include_protected/persistence_client_library_db_access.h" #define BUF_SIZE 64 @@ -447,14 +447,12 @@ START_TEST(test_Cursor) memset(bufferDataDst, 0, READ_SIZE); // create cursor - handle = persistence_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz", - PersistenceStorage_local, PersistencePolicy_wc); + handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz"); fail_unless(handle != -1, "Failed to create cursor!!"); // create cursor - handle1 = persistence_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/wt.itz", - PersistenceStorage_local, PersistencePolicy_wt); + handle1 = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/wt.itz"); fail_unless(handle1 != -1, "Failed to create cursor!!"); @@ -466,34 +464,34 @@ START_TEST(test_Cursor) memset(bufferDataDst, 0, READ_SIZE); // get key - rval = persistence_db_cursor_get_key(handle, bufferKeySrc, 128); + rval = pers_db_cursor_get_key(handle, bufferKeySrc, 128); fail_unless(rval != -1, "Cursor failed to get key!!"); // get data - rval = persistence_db_cursor_get_data(handle, bufferDataSrc, 128); + rval = pers_db_cursor_get_key_data(handle, bufferDataSrc, 128); fail_unless(rval != -1, "Cursor failed to get data!!"); // get size - size = persistence_db_cursor_get_data_size(handle); + size = pers_db_cursor_get_data_size(handle); fail_unless(size != -1, "Cursor failed to get size!!"); //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size); // get key - rval = persistence_db_cursor_get_key(handle1, bufferKeyDst, 128); + rval = pers_db_cursor_get_key(handle1, bufferKeyDst, 128); fail_unless(rval != -1, "Cursor failed to get key!!"); // get data - rval = persistence_db_cursor_get_data(handle1, bufferDataDst, 128); + rval = pers_db_cursor_get_key_data(handle1, bufferDataDst, 128); fail_unless(rval != -1, "Cursor failed to get data!!"); // get size - size = persistence_db_cursor_get_data_size(handle1); + size = pers_db_cursor_get_data_size(handle1); fail_unless(size != -1, "Cursor failed to get size!!"); //printf(" 2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size); } - while( (persistence_db_cursor_next(handle) == 0) && (persistence_db_cursor_next(handle1) == 0) ); // next cursor + while( (pers_db_cursor_next(handle) == 0) && (pers_db_cursor_next(handle1) == 0) ); // next cursor // destory cursor - rval = persistence_db_cursor_destroy(handle); + rval = pers_db_cursor_destroy(handle); fail_unless(rval != -1, "Failed to destroy cursor!!"); - rval = persistence_db_cursor_destroy(handle1); + rval = pers_db_cursor_destroy(handle1); fail_unless(rval != -1, "Failed to destroy cursor!!"); } END_TEST |