New release 0.3.0; license change to MPLv2, for more changes see ChangeLog
authorihuerner <ihuerner@b9707d8c-442e-47db-affb-152dabb2260b>
Mon, 26 Nov 2012 12:08:10 +0000 (12:08 +0000)
committerihuerner <ihuerner@b9707d8c-442e-47db-affb-152dabb2260b>
Mon, 26 Nov 2012 12:08:10 +0000 (12:08 +0000)
31 files changed:
COPYING
ChangeLog
configure.ac
include/persistence_client_library_error_def.h
include/persistence_client_library_file.h
include/persistence_client_library_key.h
persistence_client_library.pc.in
src/Makefile.am
src/crc32.h
src/persistence_client_library.c
src/persistence_client_library.h
src/persistence_client_library_access_helper.c
src/persistence_client_library_access_helper.h
src/persistence_client_library_custom_loader.c
src/persistence_client_library_custom_loader.h
src/persistence_client_library_data_access.c
src/persistence_client_library_data_access.h
src/persistence_client_library_dbus_service.c
src/persistence_client_library_dbus_service.h
src/persistence_client_library_file.c
src/persistence_client_library_handle.c
src/persistence_client_library_handle.h
src/persistence_client_library_itzam_errors.h
src/persistence_client_library_key.c
src/persistence_client_library_lc_interface.c
src/persistence_client_library_lc_interface.h
src/persistence_client_library_pas_interface.c
src/persistence_client_library_pas_interface.h
test/data/Data.tar.gz
test/persistence_client_library_dbus_test.c
test/persistence_client_library_test.c

diff --git a/COPYING b/COPYING
index 755c92e..10b31ca 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,12 +1,4 @@
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
-documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
-the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
-and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+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/.
 
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
-BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
index d0a6914..6c2f6db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,20 @@
+Revision 0.3.0
+- Switched to the MPL v2 license
+- Fixed dbus signal issues
+- Corrected dbus persistence admin interface parameters
+- Removed static code analysis warnings
+- Removed gvdb library, only Itzam/C will be used now.
+- Adjusted customer plugin interface (long to int datatype)
+- Adjusted file and key interface (long to int)
+
+
 Revision 0.2.4
 - Updated test data
 - Internal data reorganization
 - Fixed a problem with cursor (warning: still not fully working as expected)
 - Fixed a problem with internal database handling
 
+
 Revision 0.2.3
 - Fixed handle problem
 - added cursor functions
index d64f667..9aaede7 100644 (file)
@@ -1,7 +1,7 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_INIT([Persistence Client Library], [0.2.4], [not-valid@xse.de])
+AC_INIT([Persistence Client Library], [0.3.0], [not-valid@xse.de])
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 AC_GNU_SOURCE()
@@ -49,8 +49,7 @@ AC_CHECK_FUNCS([fdatasync ftruncate mkdir munmap rmdir strerror utime dlopen])
 PKG_CHECK_MODULES(DEPS,
                   automotive-dlt
                   dbus-1
-                  libitzam
-                  glib-2.0)
+                  libitzam)
 
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)
index 5df6e0f..f3c4e0d 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_error_def.h
 #define EPERS_FILEREMOVE         (-25)
 /// err code to signalize last entry in DB
 #define EPERS_LAST_ENTRY_IN_DB   (-26)
+/// internal database error
+#define EPERS_DB_ERROR_INTERNAL  (-27)
+/// db key size is to long
+#define EPERS_DB_KEY_SIZE        (-28)
+/// db value size is to long
+#define EPERS_DB_VALUE_SIZE      (-29)
 
 
 /**
index a2a373a..06b0700 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_file.h
@@ -45,7 +31,7 @@ extern "C" {
 #endif
 
 
-#define        PERSIST_FILEAPI_INTERFACE_VERSION   (0x01000000U)
+#define        PERSIST_FILEAPI_INTERFACE_VERSION   (0x01030000U)
 
 
 
@@ -114,7 +100,7 @@ int file_open(unsigned char ldbid, char* resource_id, unsigned char user_no, uns
  * On error a negative value will be returned with th follwoing error codes:
  * EPERS_LOCKFS or EPERS_COMMON
  */
-int file_read_data(int fd, void * buffer, unsigned long buffer_size);
+int file_read_data(int fd, void * buffer, int buffer_size);
 
 
 
@@ -180,7 +166,7 @@ int file_unmap_data(void* address, long size);
  * On error a negative value will be returned with th follwoing error codes:
  * EPERS_LOCKFS or EPERS_COMMON
  */
-int file_write_data(int fd, const void * buffer, unsigned long buffer_size);
+int file_write_data(int fd, const void * buffer, int buffer_size);
 
 
 
index 23cc01e..becee04 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_key.h
@@ -46,7 +32,7 @@ extern "C" {
 #endif
 
 
-#define        PERSIST_KEYVALUEAPI_INTERFACE_VERSION   (0x01000000U)
+#define        PERSIST_KEYVALUEAPI_INTERFACE_VERSION   (0x01030000U)
 
 
 
@@ -126,7 +112,7 @@ int key_handle_open(unsigned char ldbid, char* resource_id, unsigned char user_n
  * @return positive value: the bytes read; On error a negative value will be returned with th follwoing error codes:
  *
  */
-int key_handle_read_data(int key_handle, unsigned char* buffer, unsigned long buffer_size);
+int key_handle_read_data(int key_handle, unsigned char* buffer, int buffer_size);
 
 
 
@@ -151,7 +137,7 @@ int key_handle_register_notify_on_change(int key_handle);
  *
  * @return positive value: the bytes written; On error a negative value will be returned with th follwoing error codes:
  */
-int key_handle_write_data(int key_handle, unsigned char* buffer, unsigned long buffer_size);
+int key_handle_write_data(int key_handle, unsigned char* buffer, int buffer_size);
 
 
 
@@ -167,7 +153,7 @@ int key_handle_write_data(int key_handle, unsigned char* buffer, unsigned long b
  *
  * @return positive value: the bytes read; On error a negative value will be returned with th follwoing error codes:
  */
-int key_read_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no, unsigned char* buffer, unsigned long buffer_size);
+int key_read_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no, unsigned char* buffer, int buffer_size);
 
 
 
@@ -198,7 +184,7 @@ int key_register_notify_on_change(unsigned char ldbid, char* resource_id, unsign
  *
  * @return positive value: the bytes written; On error a negative value will be returned with th follwoing error codes:
  */
-int key_write_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no, unsigned char* buffer, unsigned long buffer_size);
+int key_write_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no, unsigned char* buffer, int buffer_size);
 
 
 #ifdef __cplusplus
index e3d982d..28b2e2b 100644 (file)
@@ -8,6 +8,6 @@ datadir=@datadir@
 Name: persistence client library
 Description: persistence client library 
 Version: @VERSION@
-Requires: automotive-dlt glib-2.0
-Libs: -L${libdir} -lgvdb -lrt -lglib-2.0 -ldl
+Requires: automotive-dlt
+Libs: -L${libdir} -lrt -ldl
 Cflags: -I${includedir}
index db5cc1b..7155b3b 100644 (file)
@@ -2,15 +2,11 @@ AUTOMAKE_OPTIONS = foreign
 
 
 if DEBUG
-AM_CFLAGS = $(DEPS_CFLAGS) -g -I../include \
-                          -Iglib-2.0 \
-                          -Idbus-1.0 \
-                          -Iglib-2.0/include
+AM_CFLAGS = $(DEPS_CFLAGS) -g -I../include \                          
+                          -Idbus-1.0
 else
-AM_CFLAGS = $(DEPS_CFLAGS) -I../include \
-                          -Iglib-2.0 \
-                          -Idbus-1.0 \
-                          -Iglib-2.0/include
+AM_CFLAGS = $(DEPS_CFLAGS) -I../include \                         
+                          -Idbus-1.0
 endif
 
 
@@ -21,7 +17,7 @@ include_HEADERS = ../include/persistence_client_library_key.h \
 
 lib_LTLIBRARIES = libpersistence_client_library.la
 
-libpersistence_client_library_la_LIBADD = $(DEPS_LIBS) -ldl -lgvdb
+libpersistence_client_library_la_LIBADD = $(DEPS_LIBS) -ldl
 
 
 libpersistence_client_library_la_SOURCES = \
@@ -35,6 +31,7 @@ libpersistence_client_library_la_SOURCES = \
                                      persistence_client_library_dbus_service.c \
                                      persistence_client_library_custom_loader.c \
                                      persistence_client_library_access_helper.c \
+                                     persistence_client_library_itzam_errors.c \
                                      crc32.c
 
 libpersistence_client_library_la_LDFLAGS = -export-dynamic $(LDFLAGS)
index ea785a3..bf7e9c1 100644 (file)
@@ -7,23 +7,11 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright
+ *
+ * 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           crc32.h
index 8b939d8..fcd2dc7 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIcacheON WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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.c
@@ -54,20 +40,9 @@ extern char* __progname;
 /// debug log and trace (DLT) setup
 DLT_DECLARE_CONTEXT(persClientLibCtx);
 
+const char* gResTableCfg = "/resource-table-cfg.itz";
 
-/// resource configuration table name
-const char* gResTableCfg = "/resource-table-cfg.gvdb";
 
-#ifdef USE_GVDB
-/// shared cached default database
-const char* gSharedCachedDefault = "/cached-default.dconf";
-/// shared cached database
-const char* gSharedCached        = "/cached.dconf";
-/// shared write through default database
-const char* gSharedWtDefault     = "wt-default.dconf";
-/// shared write through database
-const char* gSharedWt            = "/wt.dconf";
-#else
 /// shared cached default database
 const char* gSharedCachedDefault = "/cached-default.itz";
 /// shared cached database
@@ -76,18 +51,9 @@ const char* gSharedCached        = "/cached.itz";
 const char* gSharedWtDefault     = "/wt-default.itz";
 /// shared write through database
 const char* gSharedWt            = "/wt.itz";
-#endif
+
 
 /// local cached default database
-#ifdef USE_GVDB
-const char* gLocalCachedDefault  = "cached-default.gvdb";
-/// local cached default database
-const char* gLocalCached         = "/cached.gvdb";
-/// local write through default database
-const char* gLocalWtDefault      = "wt-default.gvdb";
-/// local write through default database
-const char* gLocalWt             = "/wt.gvdb";
-#else
 const char* gLocalCachedDefault  = "cached-default.itz";
 /// local cached default database
 const char* gLocalCached         = "/cached.itz";
@@ -95,7 +61,7 @@ const char* gLocalCached         = "/cached.itz";
 const char* gLocalWtDefault      = "wt-default.itz";
 /// local write through default database
 const char* gLocalWt             = "/wt.itz";
-#endif
+
 
 
 /// directory structure node name defintion
@@ -140,10 +106,10 @@ void pers_library_init(void)
    int status = 0;
    int i = 0;
 
-   //DLT_REGISTER_APP("Persistence Client Library","persClientLib");
-   //DLT_REGISTER_CONTEXT(persClientLibCtx,"persClientLib","Context for Logging");
+   DLT_REGISTER_APP("Persistence Client Library","persClientLib");
+   DLT_REGISTER_CONTEXT(persClientLibCtx,"persClientLib","Context for Logging");
 
-   //DLT_LOG(persClientLibCtx, DLT_LOG_ERROR, DLT_STRING("Initialize Persistence Client Library!!!!"));
+   DLT_LOG(persClientLibCtx, DLT_LOG_ERROR, DLT_STRING("Initialize Persistence Client Library!!!!"));
 
    /// environment variable for on demand loading of custom libraries
    const char *pOnDemandLoad = getenv("PERS_CUSTOM_LIB_LOAD_ON_DEMAND");
@@ -156,16 +122,8 @@ void pers_library_init(void)
       gMaxKeyValDataSize = atoi(pDataSize);
    }
 
-   // initialize mutex
-   pthread_mutex_init(&gDbusInitializedMtx, NULL);
-
-   // setup dbus main dispatching loop
-   printf("*** setup dbus main loop\n");
    setup_dbus_mainloop();
 
-   // wain until dbus main loop has been setup and running
-   //pthread_mutex_lock(&gDbusInitializedMtx);
-
 
    // register for lifecycle and persistence admin service dbus messages
    register_lifecycle();
@@ -221,14 +179,16 @@ void pers_library_init(void)
 
    //printf("A p p l i c a t i o n   n a m e => %s \n", __progname /*program_invocation_short_name*/);   // TODO: only temp solution for application name
    strncpy(gAppId, __progname, maxAppNameLen);
+   // destory mutex
+   pthread_mutex_destroy(&gDbusInitializedMtx);
+   pthread_cond_destroy(&gDbusInitializedCond);
 }
 
 
 
 void pers_library_destroy(void)
 {
-   // destory mutex
-   pthread_mutex_destroy(&gDbusInitializedMtx);
+
 
    // unregister for lifecycle and persistence admin service dbus messages
    unregister_lifecycle();
index 35904bd..8610d92 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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.h
 
 #include "persistence_client_library_lc_interface.h"
 #include "../include/persistence_client_library_error_def.h"
-#include <gvdb-reader.h>
 #include "crc32.h"
 
 #include <string.h>
 #include <stdio.h>
 
+
 /// constant definitions
 enum _PersistenceConstantDef
 {
@@ -56,8 +42,11 @@ enum _PersistenceConstantDef
    NsmErrorStatus_OK       = 1,
    NsmErrorStatus_Fail     = -1,
 
-   KeySize                 = 64,
-   ValueSize               = 16384,
+   PrctKeySize             = 64,    /// persistence resource config table max key size
+   PrctValueSize           = 256,   /// persistence resource config table max value size
+
+   DbKeySize               = 64,    /// database max key size
+   DbValueSize             = 16384, /// database max value size
 
    PasMsg_Block            = 1,     /// persistence administration service block access
    PasMsg_WriteBack        = 2,     /// persistence administration service write_back
index 447a259..5c0affa 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_access_helper.c
 
 
 #include "persistence_client_library_access_helper.h"
-#include "gvdb-builder.h"
-
+#include "persistence_client_library_itzam_errors.h"
 #include <stdlib.h>
 
 
 /// pointer to resource table database
-GvdbTable* gResource_table[] = { NULL, NULL, NULL, NULL };
+itzam_btree gResource_table[4];
+/// array to hold the information of database is already open
+int gResourceOpen[] = {0,0,0,0};
+
 
+/// structure definition of an persistence resource configuration table entry
+typedef struct record_t
+{
+    char m_key[PrctKeySize];        // the key
+    char m_data[PrctValueSize];     // data for the key
+}
+prct_record;
 
 
 PersistenceRCT_e get_table_id(int ldbid, int* groupId)
@@ -71,18 +66,18 @@ PersistenceRCT_e get_table_id(int ldbid, int* groupId)
 }
 
 
-GvdbTable* get_resource_cfg_table_by_idx(int i)
+itzam_btree* get_resource_cfg_table_by_idx(int i)
 {
-   return gResource_table[i];
+   return &gResource_table[i];
 }
 
 
 // status: OK
-GvdbTable* get_resource_cfg_table(PersistenceRCT_e rct, int group)
+itzam_btree* get_resource_cfg_table(PersistenceRCT_e rct, int group)
 {
-   if(gResource_table[rct] == NULL)   // check if database is already open
+   if(gResourceOpen[rct] == 0)   // check if database is already open
    {
-      GError* error = NULL;
+      itzam_state  state;
       char filename[dbPathMaxLen];
       memset(filename, 0, dbPathMaxLen);
 
@@ -101,19 +96,16 @@ GvdbTable* get_resource_cfg_table(PersistenceRCT_e rct, int group)
          printf("get_resource_cfg_table - error: no valid PersistenceRCT_e\n");
          break;
       }
-
-      gResource_table[rct] = gvdb_table_new(filename, TRUE, &error);
-      //printf("get_resource_cfg_table - group %d | db filename: %s \n", group, filename);
-
-      if(gResource_table[rct] == NULL)
+      //printf("get_resource_cfg_table => %s \n", filename);
+      state = itzam_btree_open(&gResource_table[rct], filename, itzam_comparator_string, error_handler, 0 , 0);
+      if(state != ITZAM_OKAY)
       {
-         printf("get_resource_cfg_table - Database error: %s\n", error->message);
-         g_error_free(error);
-         error = NULL;
+         fprintf(stderr, "\nget_resource_cfg_table => Itzam problem: %s\n", STATE_MESSAGES[state]);
       }
+      gResourceOpen[rct] = 1;
    }
 
-   return gResource_table[rct];
+   return &gResource_table[rct];
 }
 
 
@@ -133,6 +125,7 @@ int de_serialize_data(char* buffer, PersistenceConfigurationKey_s* pc)
 {
    int rval = 1;
    char* token = NULL;
+   //printf("\nde_serialize_data: %s \n", buffer);
    if((buffer != NULL) && (pc != NULL))
    {
       token = strtok(buffer, " ");     // policy
@@ -282,46 +275,27 @@ int get_db_context(PersistenceConfigurationKey_s* dbContext, char* resource_id,
    rct = get_table_id(dbContext->context.ldbid, &groupId);
 
    // get resource configuration table
-   GvdbTable* resource_table = get_resource_cfg_table(rct, groupId);
+   itzam_btree* resource_table = get_resource_cfg_table(rct, groupId);
 
    if(resource_table != NULL)
    {
-      GVariant* dbValue = NULL;
-
+      prct_record search;
       // check if resouce id is in write through table
-      dbValue = gvdb_table_get_value(resource_table, resource_id);
-
-      if(dbValue != NULL)
+      if(itzam_true == itzam_btree_find(resource_table, resource_id, &search))
       {
-
-         gconstpointer valuePtr = NULL;
-         int size = g_variant_get_size(dbValue);
-         valuePtr = g_variant_get_data(dbValue);
-         if(valuePtr != NULL)
+         //printf("get_db_context ==> data: %s\n", search.m_data);
+         de_serialize_data(search.m_data, dbContext);
+         if(dbContext->storage != PersistenceStorage_custom )
+         {
+            rval = get_db_path_and_key(dbContext, resource_id, isFile, dbKey, dbPath);
+         }
+         else
          {
-            char* buffer = malloc(size);
-            if(buffer != NULL)
-            {
-               memcpy(buffer, valuePtr, size);
-               de_serialize_data(buffer, dbContext);
-
-               if(dbContext->storage != PersistenceStorage_custom )
-               {
-                  rval = get_db_path_and_key(dbContext, resource_id, isFile, dbKey, dbPath);
-               }
-               else
-               {
-                  //printf("***************** dbEntry.custom_name %s \n", dbEntry.custom_name);
-                  // if customer storage, we use the custom name as path
-                  strncpy(dbPath, dbContext->custom_name, strlen(dbContext->custom_name));
-               }
-
-               free(buffer);
-               buffer = NULL;
-               free_pers_conf_key(dbContext);
-               resourceFound = 1;
-            }
+            // if customer storage, we use the custom name as path
+            strncpy(dbPath, dbContext->custom_name, strlen(dbContext->custom_name));
          }
+         free_pers_conf_key(dbContext);
+         resourceFound = 1;
       }
       else
       {
@@ -335,7 +309,6 @@ int get_db_context(PersistenceConfigurationKey_s* dbContext, char* resource_id,
       rval = EPERS_NOPRCTABLE;
    }
 
-
    if(resourceFound == 0)
    {
       printf("get_db_context - error resource not found %s \n", resource_id);
index 842302b..ca74615 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_access_helper.h
@@ -34,7 +20,7 @@
  */
 
 #include "persistence_client_library.h"
-
+#include <itzam.h>
 
 /**
  * @brief Create database search key and database location path
@@ -78,7 +64,7 @@ int get_db_context(PersistenceConfigurationKey_s* dbContext, char* resource_id,
  *
  * @return pointer to the gvdb database table or NULL if no valid database has been found
  */
-GvdbTable* get_resource_cfg_table_by_idx(int i);
+itzam_btree* get_resource_cfg_table_by_idx(int i);
 
 
 /**
@@ -105,5 +91,4 @@ int de_serialize_data(char* buffer, PersistenceConfigurationKey_s* pc);
 void free_pers_conf_key(PersistenceConfigurationKey_s* pc);
 
 
-
 #endif /* PERSISTENCE_CLIENT_LIBRARY_ACCESS_HELPER_H */
index beb26cf..9cd2ed3 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_custom_loader.c
index d4fa7fd..68cf285 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_custom_loader.h
@@ -71,7 +57,7 @@ typedef struct _Pers_custom_functs_s
    void* handle;
 
    /// create backup
-   long (*custom_plugin_create_backup)(const char* backup_id);
+   int (*custom_plugin_create_backup)(const char* backup_id);
 
    /// custom library deinit function
    int (*custom_plugin_deinit)();
@@ -80,34 +66,34 @@ typedef struct _Pers_custom_functs_s
    int (*custom_plugin_delete_data)(const char* path);
 
    /// get backup
-   long (*custom_plugin_get_backup)(const char* backup_id, long size);
+   int (*custom_plugin_get_backup)(const char* backup_id, int size);
 
    // get the size
    int (*custom_plugin_get_size)(const char* path);
 
    /// custom get data function
-   long (*custom_plugin_get_data)(const char* path, char* buffer, long size);
+   int (*custom_plugin_get_data)(const char* path, char* buffer, int size);
 
    /// custom close function
    int (*custom_plugin_handle_close)(int handle);
 
    /// custom get data function
-   long (*custom_plugin_handle_get_data)(long handle, char* buffer, long size);
+   int (*custom_plugin_handle_get_data)(int handle, char* buffer, int size);
 
    /// custom open function
-   long (*custom_plugin_handle_open)(const char* path, int flag, int mode);
+   int (*custom_plugin_handle_open)(const char* path, int flag, int mode);
 
    /// custom set data function
-   long (*custom_plugin_handle_set_data)(long handle, char* buffer, long size);
+   int (*custom_plugin_handle_set_data)(int handle, char* buffer, int size);
 
    /// custom library init function
    int (*custom_plugin_init)();
 
    /// restore backup
-   long (*custom_plugin_restore_backup)(const char* backup_id);
+   int (*custom_plugin_restore_backup)(const char* backup_id);
 
    /// custom set data function
-   long (*custom_plugin_set_data)(const char* path, char* buffer, long size);
+   int (*custom_plugin_set_data)(const char* path, char* buffer, int size);
 
    /// custom status notification function
    int (*custom_plugin_get_status_notification_clbk)(plugin_callback_t pFunct);
index 7837e4a..1e56e4e 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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.c
 
 #include "persistence_client_library_data_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>
 #include <stdio.h>
 #include <stdlib.h>
-#include <itzam.h>
 
-// definition of a key-value pair
+
+/// definition of a key-value pair stored in the database
 typedef struct _KeyValuePair_s
 {
-    char m_key[KeySize];
-    char m_data[ValueSize];
+    char m_key[DbKeySize];       /// the key
+    char m_data[DbValueSize];    /// the data
+    unsigned int m_data_size;   /// the size of the data
 }
 KeyValuePair_s;
 
@@ -65,15 +53,13 @@ CursorEntry_s gCursorArray[maxPersHandle];
 /// handle index
 static int gHandleIdx = 1;
 
-static int gInitialized = 0;
-
 /// free handle array
 int gFreeCursorHandleArray[maxPersHandle];
 // free head index
 int gFreeCursorHandleIdxHead = 0;
 
-// mutex
-pthread_mutex_t gMtx;
+// mutex to controll access to the cursor array
+pthread_mutex_t gMtx = PTHREAD_MUTEX_INITIALIZER;
 
 
 /// btree array
@@ -85,18 +71,11 @@ static int gBtreeCreated[PersistenceStoragePolicy_LastEntry][PersistencePolicy_L
 };
 
 
-void error_handler(const char * function_name, itzam_error error)
-{
-    fprintf(stderr, "Itzam error in %s: %s\n", function_name, ERROR_STRINGS[error]);
-}
-
-
 
 itzam_btree* database_get(PersistenceStorage_e storage, PersistencePolicy_e policy, const char* dbPath)
 {
    itzam_btree* btree = NULL;
-   if(   (storage >= PersistenceStorage_local)
-      && (storage <= PersistenceStorage_shared)  )
+   if(storage <= PersistenceStorage_shared)
    {
       if(gBtreeCreated[storage][policy] == 0)
       {
@@ -104,7 +83,7 @@ itzam_btree* database_get(PersistenceStorage_e storage, PersistencePolicy_e poli
          state = itzam_btree_open(&gBtree[storage][policy], dbPath, itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/);
          if (state != ITZAM_OKAY)
          {
-            fprintf(stderr, "Open Itzam problem: %s\n", STATE_MESSAGES[state]);
+            fprintf(stderr, "database_get ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]);
          }
          gBtreeCreated[storage][policy] = 1;
       }
@@ -115,21 +94,19 @@ itzam_btree* database_get(PersistenceStorage_e storage, PersistencePolicy_e poli
    {
       printf("btree_get ==> invalid storage type\n");
    }
-
    return btree;
 }
 
 
 void database_close(PersistenceStorage_e storage, PersistencePolicy_e policy)
 {
-   if(   (storage >= PersistenceStorage_local)
-      && (storage <= PersistenceStorage_shared)  )
+   if(storage <= PersistenceStorage_shared )
    {
       itzam_state  state = ITZAM_FAILED;
       state = itzam_btree_close(&gBtree[storage][policy]);
       if (state != ITZAM_OKAY)
       {
-         fprintf(stderr, "Close Itzam problem: %s\n", STATE_MESSAGES[state]);
+         fprintf(stderr, "database_close ==> Close Itzam problem: %s\n", STATE_MESSAGES[state]);
       }
       gBtreeCreated[storage][policy] = 0;
    }
@@ -143,7 +120,7 @@ void database_close(PersistenceStorage_e storage, PersistencePolicy_e policy)
 
 
 
-int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage, PersistencePolicy_e policy, unsigned char* buffer, unsigned long buffer_size)
+int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage, PersistencePolicy_e policy, unsigned char* buffer, unsigned int buffer_size)
 {
    int read_size = -1;
 
@@ -158,7 +135,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage,
       {
          if(itzam_true == itzam_btree_find(btree, key, &search))
          {
-            read_size = strlen(search.m_data);
+            read_size = search.m_data_size;
             if(read_size > buffer_size)
             {
                read_size = buffer_size;   // truncate data size to buffer size
@@ -178,7 +155,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage,
       else
       {
          read_size = EPERS_NOPRCTABLE;
-         fprintf(stderr, "\nOpen Itzam problem: %s\n", STATE_MESSAGES[state]);
+         fprintf(stderr, "\npersistence_get_data ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]);
       }
    }
    else if(PersistenceStorage_custom == storage)   // custom storage implementation via custom library
@@ -201,7 +178,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage,
 
 
 
-int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage, PersistencePolicy_e policy, unsigned char* buffer, unsigned long buffer_size)
+int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage, PersistencePolicy_e policy, unsigned char* buffer, unsigned int buffer_size)
 {
    int write_size = -1;
 
@@ -217,30 +194,39 @@ int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage,
       {
          int keySize = 0;
          keySize = (int)strlen((const char*)key);
-         if(keySize < KeySize)
+         if(keySize < DbKeySize)
          {
             int dataSize = 0;
             dataSize = (int)strlen( (const char*)buffer);
-            if(dataSize < ValueSize)
+            if(dataSize < DbValueSize)
             {
-               memset(insert.m_key, 0, KeySize);
+               // key
+               memset(insert.m_key, 0, DbKeySize);
                memcpy(insert.m_key, key, keySize);
                if(itzam_true == itzam_btree_find(btree, key, &insert))
                {
                   // key already available, so delete "old" key
                   state = itzam_btree_remove(btree, (const void *)&insert);
                }
-               memset(insert.m_data, 0, ValueSize);
+
+               // data
+               memset(insert.m_data, 0, DbValueSize);
                memcpy(insert.m_data, buffer, dataSize);
+
+               // data size
+               insert.m_data_size = buffer_size;
+
                state = itzam_btree_insert(btree,(const void *)&insert);
                if (state != ITZAM_OKAY)
                {
-                  fprintf(stderr, "\nInsert Itzam problem: %s\n", STATE_MESSAGES[state]);
+                  fprintf(stderr, "\npersistence_set_data ==> Insert Itzam problem: %s\n", STATE_MESSAGES[state]);
+                  write_size = EPERS_DB_ERROR_INTERNAL;
                }
             }
             else
             {
-               fprintf(stderr, "\nset_value_to_table_itzam => data to long » size %d | maxSize: %d\n", dataSize, KeySize);
+               fprintf(stderr, "\npersistence_set_data ==> set_value_to_table_itzam => data to long » size %d | maxSize: %d\n", dataSize, DbKeySize);
+               write_size = EPERS_DB_VALUE_SIZE;
             }
 
             //
@@ -250,13 +236,14 @@ int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage,
          }
          else
          {
-            fprintf(stderr, "\nset_value_to_table_itzam => key to long » size: %d | maxSize: %d\n", keySize, KeySize);
+            fprintf(stderr, "\nset_value_to_table_itzam => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize);
+            write_size = EPERS_DB_KEY_SIZE;
          }
       }
       else
       {
          write_size = EPERS_NOPRCTABLE;
-         fprintf(stderr, "\nOpen Itzam problem: %s\n", STATE_MESSAGES[state]);
+         fprintf(stderr, "\npersistence_set_data ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]);
       }
    }
    else if(PersistenceStorage_custom == storage)   // custom storage implementation via custom library
@@ -291,9 +278,9 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceStorage_e stor
       if(btree != NULL)
       {
          keySize = (int)strlen((const char*)key);
-         if(keySize < KeySize)
+         if(keySize < DbKeySize)
          {
-            memset(search.m_key,0, KeySize);
+            memset(search.m_key,0, DbKeySize);
             memcpy(search.m_key, key, keySize);
             if(itzam_true == itzam_btree_find(btree, key, &search))
             {
@@ -304,6 +291,11 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceStorage_e stor
                read_size = EPERS_NOKEY;
             }
          }
+         else
+         {
+            fprintf(stderr, "persistence_get_data_size => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize);
+            read_size = EPERS_DB_KEY_SIZE;
+         }
          //
          // workaround till lifecycle is working correctly
          //
@@ -312,7 +304,7 @@ int persistence_get_data_size(char* dbPath, char* key, PersistenceStorage_e stor
       else
       {
          read_size = EPERS_NOPRCTABLE;
-         fprintf(stderr, "\nOpen Itzam problem: %s\n", STATE_MESSAGES[state]);
+         fprintf(stderr, "\npersistence_get_data_size ==> Open Itzam problem: %s\n", STATE_MESSAGES[state]);
       }
    }
    else if(PersistenceStorage_custom == storage)   // custom storage implementation via custom library
@@ -346,21 +338,23 @@ int persistence_delete_data(char* dbPath, char* dbKey, PersistenceStorage_e stor
       {
          int keySize = 0;
          keySize = (int)strlen((const char*)dbKey);
-         if(keySize < KeySize)
+         if(keySize < DbKeySize)
          {
             itzam_state  state;
 
-            memset(delete.m_key,0, KeySize);
+            memset(delete.m_key,0, DbKeySize);
             memcpy(delete.m_key, dbKey, keySize);
             state = itzam_btree_remove(btree, (const void *)&delete);
             if (state != ITZAM_OKAY)
             {
-               fprintf(stderr, "Remove Itzam problem: %s\n", STATE_MESSAGES[state]);
+               fprintf(stderr, "persistence_delete_data ==> Remove Itzam problem: %s\n", STATE_MESSAGES[state]);
+               ret = EPERS_DB_ERROR_INTERNAL;
             }
          }
          else
          {
-            fprintf(stderr, "persistence_delete_data => key to long » size: %d | maxSize: %d\n", keySize, KeySize);
+            fprintf(stderr, "persistence_delete_data => key to long » size: %d | maxSize: %d\n", keySize, DbKeySize);
+            ret = EPERS_DB_KEY_SIZE;
          }
          //
          // workaround till lifecycle is working correctly
@@ -404,12 +398,6 @@ int get_cursor_handle()
 {
    int handle = 0;
 
-   if(gInitialized == 0)
-   {
-      gInitialized = 1;
-      pthread_mutex_init(&gMtx, 0);
-   }
-
    if(pthread_mutex_lock(&gMtx) == 0)
    {
       if(gFreeCursorHandleIdxHead > 0)   // check if we have a free spot in the array before the current max
@@ -430,7 +418,6 @@ int get_cursor_handle()
       }
       pthread_mutex_unlock(&gMtx);
    }
-
    return handle;
 }
 
@@ -453,7 +440,7 @@ int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, Per
    int handle = -1;
    itzam_btree*  btree = NULL;
 
-   printf("CREATE-Cursor: %d | path: %s \n", (int)storage, dbPath);
+   //printf("CREATE-Cursor: %d | path: %s \n", (int)storage, dbPath);
    btree = database_get(storage, policy, dbPath);
    if(btree != NULL)
    {
@@ -476,13 +463,12 @@ int persistence_db_cursor_create(char* dbPath, PersistenceStorage_e storage, Per
          }
       }
    }
-
    return handle;
 }
 
 
 
-int persistence_db_cursor_next(int handlerDB)
+int persistence_db_cursor_next(unsigned int handlerDB)
 {
    int rval = -1;
    if(handlerDB < maxPersHandle && handlerDB >= 0)
@@ -503,25 +489,24 @@ int persistence_db_cursor_next(int handlerDB)
       }
       else
       {
-         printf("persistence_db_cursor_get_key ==> invalid handle: %d \n", handlerDB);
+         printf("persistence_db_cursor_get_key ==> invalid handle: %u \n", handlerDB);
       }
    }
    else
    {
-      printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %d | max: : %d \n", handlerDB, maxPersHandle);
+      printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, maxPersHandle);
    }
-
    return rval;
 }
 
 
 
-int persistence_db_cursor_get_key(int handlerDB, char * bufKeyName_out, int bufSize)
+int persistence_db_cursor_get_key(unsigned int handlerDB, char * bufKeyName_out, int bufSize)
 {
    int rval = -1;
    KeyValuePair_s search;
 
-   if(handlerDB < maxPersHandle && handlerDB >= 0)
+   if(handlerDB < maxPersHandle)
    {
       if(gCursorArray[handlerDB].m_empty != 1)
       {
@@ -540,25 +525,24 @@ int persistence_db_cursor_get_key(int handlerDB, char * bufKeyName_out, int bufS
       }
       else
       {
-         printf("persistence_db_cursor_get_key ==> invalid handle: %d \n", handlerDB);
+         printf("persistence_db_cursor_get_key ==> invalid handle: %u \n", handlerDB);
       }
    }
    else
    {
-      printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %d | max: : %d \n", handlerDB, maxPersHandle);
+      printf("persistence_db_cursor_get_key ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, maxPersHandle);
    }
-
    return rval;
 }
 
 
 
-int persistence_db_cursor_get_data(int handlerDB, char * bufData_out, int bufSize)
+int persistence_db_cursor_get_data(unsigned int handlerDB, char * bufData_out, int bufSize)
 {
    int rval = -1;
    KeyValuePair_s search;
 
-   if(handlerDB < maxPersHandle && handlerDB >= 0)
+   if(handlerDB < maxPersHandle)
    {
       if(gCursorArray[handlerDB].m_empty != 1)
       {
@@ -578,25 +562,24 @@ int persistence_db_cursor_get_data(int handlerDB, char * bufData_out, int bufSiz
       }
       else
       {
-         printf("persistence_db_cursor_get_data ==> invalid handle: %d \n", handlerDB);
+         printf("persistence_db_cursor_get_data ==> invalid handle: %u \n", handlerDB);
       }
    }
    else
    {
-      printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %d | max: : %d \n", handlerDB, maxPersHandle);
+      printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, maxPersHandle);
    }
-
    return rval;
 }
 
 
 
-int persistence_db_cursor_get_data_size(int handlerDB)
+int persistence_db_cursor_get_data_size(unsigned int handlerDB)
 {
    int size = -1;
    KeyValuePair_s search;
 
-   if(handlerDB < maxPersHandle && handlerDB >= 0)
+   if(handlerDB < maxPersHandle)
    {
       if(gCursorArray[handlerDB].m_empty != 1)
       {
@@ -605,37 +588,38 @@ int persistence_db_cursor_get_data_size(int handlerDB)
       }
       else
       {
-         printf("persistence_db_cursor_get_data ==> invalid handle: %d \n", handlerDB);
+         printf("persistence_db_cursor_get_data ==> invalid handle: %u \n", handlerDB);
       }
    }
    else
    {
-      printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %d | max: : %d \n", handlerDB, maxPersHandle);
+      printf("persistence_db_cursor_get_data ==> handle bigger than max » handleDB: %u | max: : %d \n", handlerDB, maxPersHandle);
    }
-
    return size;
 }
 
 
 
-int persistence_db_cursor_destroy(int handlerDB)
+int persistence_db_cursor_destroy(unsigned int handlerDB)
 {
    int rval = -1;
    itzam_state  state;
 
-   state = itzam_btree_cursor_free(&gCursorArray[handlerDB].m_cursor);
-   if (state == ITZAM_OKAY)
+   if(handlerDB < maxPersHandle)
    {
-      rval = 0;
-      database_close(gCursorArray[handlerDB].storage, gCursorArray[handlerDB].policy);
+      state = itzam_btree_cursor_free(&gCursorArray[handlerDB].m_cursor);
+      if (state == ITZAM_OKAY)
+      {
+         rval = 0;
+         database_close(gCursorArray[handlerDB].storage, gCursorArray[handlerDB].policy);
 
-      gCursorArray[handlerDB].m_empty = 1;
-      gCursorArray[handlerDB].storage = PersistenceStoragePolicy_LastEntry;
-      gCursorArray[handlerDB].policy = PersistencePolicy_LastEntry;
+         gCursorArray[handlerDB].m_empty = 1;
+         gCursorArray[handlerDB].storage = PersistenceStoragePolicy_LastEntry;
+         gCursorArray[handlerDB].policy = PersistencePolicy_LastEntry;
 
-      close_cursor_handle(handlerDB);
+         close_cursor_handle(handlerDB);
+      }
    }
-
    return rval;
 }
 
index 5e4e5ff..f9405ac 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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
@@ -53,7 +39,7 @@
  *   EPERS_SETDTAFAILED  EPERS_NOPRCTABLE  EPERS_NOKEYDATA  EPERS_NOKEY
  */
 int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage, PersistencePolicy_e policy,
-                         unsigned char* buffer, unsigned long buffer_size);
+                         unsigned char* buffer, unsigned int buffer_size);
 
 
 
@@ -63,12 +49,15 @@ int persistence_set_data(char* dbPath, char* key, PersistenceStorage_e storage,
  * @param dbPath the path to the database where the key is in
  * @param key the database key
  * @param storage the storage identifier (local, shared or custom)
+ * @param policy the storage policy (cached or write throug)
+ * @param buffer the buffer holding the data
+ * @param buffer_size the size of the buffer
  *
  * @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, PersistenceStorage_e storage, PersistencePolicy_e policy,
-                         unsigned char* buffer, unsigned long buffer_size);
+                         unsigned char* buffer, unsigned int buffer_size);
 
 
 
@@ -78,6 +67,7 @@ int persistence_get_data(char* dbPath, char* key, PersistenceStorage_e storage,
  * @param dbPath the path to the database where the key is in
  * @param key the database key
  * @param storage the storage identifier (local, shared or custom)
+ * @param policy the storage policy (cached or write throug)
  *
  * @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
@@ -99,6 +89,12 @@ int persistence_reg_notify_on_change(char* dbPath, char* key);
 
 /**
  * @brief delete data
+ *
+ * @param dbPath the path to the database where the key is in
+ * @param key the database key to register on
+ *
+ * @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, PersistenceStorage_e storage, PersistencePolicy_e policy);
 
@@ -134,7 +130,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(int handlerDB);
+int persistence_db_cursor_next(unsigned int handlerDB);
 
 /**
  * @brief get the name of the key pointed by the cursor associated with the database
@@ -145,7 +141,7 @@ int persistence_db_cursor_next(int handlerDB);
  *
  * @return read size (if >= 0), error other way
  */
-int persistence_db_cursor_get_key(int handlerDB, char * bufKeyName_out, int bufSize) ;
+int persistence_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
@@ -156,7 +152,7 @@ int persistence_db_cursor_get_key(int handlerDB, char * bufKeyName_out, int bufS
  *
  * @return read size (if >= 0), error other way
  */
-int persistence_db_cursor_get_data(int handlerDB, char * bufData_out, int bufSize) ;
+int persistence_db_cursor_get_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
@@ -165,7 +161,7 @@ int persistence_db_cursor_get_data(int handlerDB, char * bufData_out, int bufSiz
  *
  * @return positive value for data size, negative value for error
  */
-int persistence_db_cursor_get_data_size(int handlerDB) ;
+int persistence_db_cursor_get_data_size(unsigned int handlerDB) ;
 
 
 /**
@@ -175,7 +171,7 @@ int persistence_db_cursor_get_data_size(int handlerDB) ;
  *
  * @return 0 for success, negative value in case of error
  */
-int persistence_db_cursor_destroy(int handlerDB) ;
+int persistence_db_cursor_destroy(unsigned int handlerDB) ;
 
 
 #endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ACCESS_H */
index 145b1e2..005964a 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_dbus_service.c
@@ -43,6 +29,9 @@
 #include <stdlib.h>
 
 
+pthread_mutex_t gDbusInitializedMtx  = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t  gDbusInitializedCond = PTHREAD_COND_INITIALIZER;
+
 /// polling structure
 typedef struct SPollInfo
 {
@@ -168,11 +157,6 @@ static void  unregisterObjectPathFallback(DBusConnection *connection, void *user
 
 void* run_mainloop(void* dataPtr)
 {
-   printf("      *** run_mainloop ==> pthread_mutex_lock => \n");
-   // lock mutex to make sure dbus main loop is running
-   //pthread_mutex_lock(&gDbusInitializedMtx);
-   printf("      *** run_mainloop ==> pthread_mutex_lock <= \n");
-
    // persistence admin message
    static const struct DBusObjectPathVTable vtablePersAdmin
       = {unregisterMessageHandler, checkPersAdminMsg, NULL, };
@@ -186,7 +170,6 @@ void* run_mainloop(void* dataPtr)
       = {unregisterObjectPathFallback, handleObjectPathMessageFallback, NULL, };
 
    // setup the dbus
-   printf("      *** run_mainloop ==> mainLoop\n");
    mainLoop(vtablePersAdmin, vtableLifecycle, vtableFallback, dataPtr);
 
    printf("Exit dbus main loop!!!!\n");
@@ -238,14 +221,20 @@ int setup_dbus_mainloop(void)
       gDbusConn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
    }
 
-   printf("   *** setup_dbus_mainloop ==> pthread_create\n");
+   // wain until dbus main loop has been setup and running
+   pthread_mutex_lock(&gDbusInitializedMtx);
+
    // create here the dbus connection and pass to main loop
    rval = pthread_create(&thread, NULL, run_mainloop, gDbusConn);
-
-   if (rval)
+   if(rval)
    {
      fprintf(stderr, "Server: - ERROR! pthread_create( run_mainloop ) returned: %d\n", rval);
    }
+
+   // wait for condition variable
+   pthread_cond_wait(&gDbusInitializedCond, &gDbusInitializedMtx);
+
+   pthread_mutex_unlock(&gDbusInitializedMtx);
    return rval;
 }
 
@@ -307,13 +296,14 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
              DBusObjectPathVTable vtableFallback, void* userData)
 {
    DBusError err;
+   // lock mutex to make sure dbus main loop is running
+   pthread_mutex_lock(&gDbusInitializedMtx);
 
    signal(SIGTERM, sigHandler);
    signal(SIGQUIT, sigHandler);
    signal(SIGINT,  sigHandler);
 
    DBusConnection* conn = (DBusConnection*)userData;
-
    dbus_error_init(&err);
 
    if (dbus_error_is_set(&err))
@@ -339,15 +329,13 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
          gPollInfo.fds[0].fd = gPipefds[0];
          gPollInfo.fds[0].events = POLLIN;
 
-//         dbus_bus_add_match(conn, "type='signal', sender='org.genivi.persistence.admin',interface='org.genivi.persistence.admin',member='PersistenceModeChanged',path='/org/genivi/persistence/admin'", &err);
-//         dbus_connection_add_filter(conn, checkPersAdminSignal, NULL, NULL);
+         dbus_bus_add_match(conn, "type='signal',interface='org.genivi.persistence.admin',member='PersistenceModeChanged',path='/org/genivi/persistence/admin'", &err);
 
          // register for messages
          if (   (TRUE==dbus_connection_register_object_path(conn, "/org/genivi/persistence/adminconsumer", &vtable, userData))
              && (TRUE==dbus_connection_register_object_path(conn, "/com/contiautomotive/NodeStateManager/LifecycleConsumer", &vtable2, userData))
              && (TRUE==dbus_connection_register_fallback(conn, "/", &vtableFallback, userData)) )
          {
-            printf("* * * * mainLoop ==> success: dbus_connection_register_object_path \n");
             if (TRUE!=dbus_connection_set_watch_functions(conn, addWatch, removeWatch, watchToggled, NULL, NULL))
             {
                printf("dbus_connection_set_watch_functions() failed\n");
@@ -355,15 +343,16 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
             else
             {
                char buf[64];
-                  // mainloop is running now, release mutex
-                  //pthread_mutex_unlock(&gDbusInitializedMtx);
+
+               pthread_cond_signal(&gDbusInitializedCond);
+               pthread_mutex_unlock(&gDbusInitializedMtx);
                do
                {
                   bContinue = 0; /* assume error */
 
-                  while (DBUS_DISPATCH_DATA_REMAINS==dbus_connection_dispatch(conn));
+                  while(DBUS_DISPATCH_DATA_REMAINS==dbus_connection_dispatch(conn));
 
-                  while ((-1==(ret=poll(gPollInfo.fds, gPollInfo.nfds, 500)))&&(EINTR==errno));
+                  while((-1==(ret=poll(gPollInfo.fds, gPollInfo.nfds, 500)))&&(EINTR==errno));
 
                   if(0>ret)
                   {
@@ -446,13 +435,15 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
             dbus_connection_unregister_object_path(conn, "/com/contiautomotive/NodeStateManager/LifecycleConsumer");
             dbus_connection_unregister_object_path(conn, "/");
          }
-         printf("* * * * mainLoop ==> error: dbus_connection_register_object_path\n");
          close(gPipefds[1]);
          close(gPipefds[0]);
       }
       dbus_connection_unref(conn);
       dbus_shutdown();
    }
+
+   pthread_cond_signal(&gDbusInitializedCond);
+   pthread_mutex_unlock(&gDbusInitializedMtx);
    return 0;
 }
 
index b209ce5..fa93622 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_dbus_service.h
@@ -38,7 +24,8 @@
 #include <pthread.h>
 
 /// mutex to make sure main loop is running
-pthread_mutex_t gDbusInitializedMtx;
+extern pthread_mutex_t gDbusInitializedMtx;
+extern pthread_cond_t  gDbusInitializedCond;
 
 
 /// command definitions for main loop
index d965f10..db33476 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_file.c
@@ -52,12 +38,11 @@ int file_close(int fd)
 {
    int rval = -1;
 
-   rval = close(fd);
    if(fd < maxPersHandle)
    {
       __sync_fetch_and_sub(&gOpenFdArray[fd], FileClosed);   // set closed flag
+      rval = close(fd);
    }
-
    return rval;
 }
 
@@ -120,12 +105,7 @@ int file_open(unsigned char ldbid, char* resource_id, unsigned char user_no, uns
    if(shared_DB != -1)  // check valid database context
    {
       handle = open(dbPath, flags);
-
-      if(handle == -1)
-      {
-         printf("file_open ERROR: %s \n", strerror(errno) );
-      }
-      else
+      if(handle != -1)
       {
          if(handle < maxPersHandle)
          {
@@ -133,9 +113,14 @@ int file_open(unsigned char ldbid, char* resource_id, unsigned char user_no, uns
          }
          else
          {
+            close(handle);
             handle = EPERS_MAXHANDLE;
          }
       }
+      else
+      {
+         printf("file_open ERROR: %s \n", strerror(errno) );
+      }
    }
 
    return handle;
@@ -143,7 +128,7 @@ int file_open(unsigned char ldbid, char* resource_id, unsigned char user_no, uns
 
 
 
-int file_read_data(int fd, void * buffer, unsigned long buffer_size)
+int file_read_data(int fd, void * buffer, int buffer_size)
 {
    return read(fd, buffer, buffer_size);
 }
@@ -227,7 +212,7 @@ int file_unmap_data(void* address, long size)
 
 
 
-int file_write_data(int fd, const void * buffer, unsigned long buffer_size)
+int file_write_data(int fd, const void * buffer, int buffer_size)
 {
    int size = 0;
 
index 8b2564e..215fb87 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_handle.c
@@ -34,6 +20,7 @@
 
 #include "persistence_client_library_handle.h"
 
+#include <pthread.h>
 #include <stdlib.h>
 
 /// handle index
index 0df6185..8f7dd5c 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_handle.h
index 9ac4044..7324ea6 100644 (file)
@@ -75,66 +75,16 @@ Small changes to use in persistence
  * @see
  */
 
-static const char * ERROR_STRINGS [] =
-{
-    "invalid datafile signature",
-    "invalid version",
-    "can not open 64-bit datafile on 32-bit operating system",
-    "write failed",
-    "open failed",
-    "read failed",
-    "close failed",
-    "seek failed",
-    "tell failed",
-    "duplicate remove",
-    "flush failed",
-    "rewrite record too small",
-    "page not found",
-    "lost key",
-    "key not written",
-    "key seek failed",
-    "unable to remove key record",
-    "record seek failed",
-    "unable to remove data record",
-    "list of deleted records could not be read",
-    "list of deleted records could not be written",
-    "iterator record count differs from database internal count",
-    "rewrite over deleted record",
-    "invalid column index",
-    "invalid row index",
-    "invalid hash value",
-    "memory allocation failed",
-    "attempt reading deleted record",
-    "invalid record signature found",
-    "invalid file locking mode",
-    "unable to lock datafile",
-    "unable to unlock datafile",
-    "size mismatch when reading record",
-    "attempt to start new transaction while one is already active",
-    "no transaction active",
-    "attempt to free a B-tree cursor when cursors were active",
-    "invalid datafile object",
-    "size_t is incompatible with Itzam",
-    "could not create datafile",
-    "global shared memory requires Administrator or user with SeCreateGlobalPrivilege",
-    "cannot create global shared memory",
-    "another process or thread has already created shared objects for this datafile",
-    "invalid operation for read only file"
-};
-
-static const char * STATE_MESSAGES [] =
-{
-    "okay",
-    "operation failed",
-    "version mismatch in files",
-    "iterator at end",
-    "iterator at beginning",
-    "key not found",
-    "duplicate key",
-    "exceeded maximum file size on 32-bit system",
-    "unable to write data record for index",
-    "sizeof(size_t) smaller than required for file references; possibly 64-bit DB on 32-bit platform",
-    "invalid operation for read only file"
-};
+#include <itzam.h>
+
+/// error string messages definition
+extern const char * ERROR_STRINGS [];
+
+/// error state messages definition
+extern const char * STATE_MESSAGES [];
+
+/// error handler
+void error_handler(const char * function_name, itzam_error error);
+
 
 #endif /* PERSISTENCE_CLIENT_ITZAM_ERRORS_H */
index 9a79117..5a8c5a4 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_key.c
@@ -66,8 +52,7 @@ int key_handle_open(unsigned char ldbid, char* resource_id, unsigned char user_n
    handle = get_db_context(&dbContext, resource_id, resIsNoFile, dbKey, dbPath);
    if(handle >= 0)
    {
-      if(   dbContext.storage >= PersistenceStorage_local
-         && dbContext.storage < PersistenceStoragePolicy_LastEntry)  // check if store policy is valid
+      if(dbContext.storage < PersistenceStoragePolicy_LastEntry)  // check if store policy is valid
       {
          if(PersistenceStorage_custom ==  dbContext.storage)
          {
@@ -181,7 +166,7 @@ int key_handle_get_size(int key_handle)
 
 
 
-int key_handle_read_data(int key_handle, unsigned char* buffer, unsigned long buffer_size)
+int key_handle_read_data(int key_handle, unsigned char* buffer, int buffer_size)
 {
    int size = 0;
    if(key_handle < maxPersHandle)
@@ -220,7 +205,7 @@ int key_handle_register_notify_on_change(int key_handle)
 
 
 
-int key_handle_write_data(int key_handle, unsigned char* buffer, unsigned long buffer_size)
+int key_handle_write_data(int key_handle, unsigned char* buffer, int buffer_size)
 {
    int size = 0;
 
@@ -362,7 +347,7 @@ int key_get_size(unsigned char ldbid, char* resource_id, unsigned char user_no,
 
 // status: OK
 int key_read_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no,
-                  unsigned char* buffer, unsigned long buffer_size)
+                  unsigned char* buffer, int buffer_size)
 {
    int data_size = 0;
 
@@ -407,7 +392,7 @@ int key_read_data(unsigned char ldbid, char* resource_id, unsigned char user_no,
 
 
 int key_write_data(unsigned char ldbid, char* resource_id, unsigned char user_no, unsigned char seat_no,
-                   unsigned char* buffer, unsigned long buffer_size)
+                   unsigned char* buffer, int buffer_size)
 {
    int data_size = 0;
 
index 69ce19a..214b50c 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_lc_interface.c
@@ -40,6 +26,7 @@
 #include "persistence_client_library_custom_loader.h"
 #include "persistence_client_library_access_helper.h"
 #include "persistence_client_library_data_access.h"
+#include "persistence_client_library_itzam_errors.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -289,7 +276,9 @@ int send_prepare_shutdown_complete(int requestId)
 void process_prepare_shutdown(unsigned char requestId)
 {
    int i = 0;
-   GvdbTable* resourceTable = NULL;
+   //GvdbTable* resourceTable = NULL;
+   itzam_btree* resourceTable = NULL;
+   itzam_state  state = ITZAM_FAILED;
 
    // block write
    pers_lock_access();
@@ -297,10 +286,11 @@ void process_prepare_shutdown(unsigned char requestId)
    // flush open files to disk
    for(i=0; i<maxPersHandle; i++)
    {
-      if(gOpenFdArray[i] == FileOpen)
+      int tmp = i;
+      if(gOpenFdArray[tmp] == FileOpen)
       {
-         fsync(i);
-         close(i);
+         fsync(tmp);
+         close(tmp);
       }
    }
 
@@ -311,7 +301,11 @@ void process_prepare_shutdown(unsigned char requestId)
      // dereference opend database
      if(resourceTable != NULL)
      {
-        gvdb_table_unref(resourceTable);
+        state = itzam_btree_close(resourceTable);
+        if (state != ITZAM_OKAY)
+        {
+           fprintf(stderr, "\nOpen Itzam problem: %s\n", STATE_MESSAGES[state]);
+        }
      }
    }
 
index cdc6d90..bd612d1 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_lc_interface.h
index f04730c..056b9a3 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_pas_interface.c
@@ -108,8 +94,8 @@ int check_pas_request(unsigned int request, unsigned int requestID)
 
 DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *message)
 {
-   int request = 0, requestID = 0;
-   int errorCode = 0;
+   int request = 0, requestID = 0, errorCode = 0;
+   int errorReturn = 0;
 
    DBusMessage *reply;
    DBusError error;
@@ -117,6 +103,7 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *
 
    if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32 , &request,
                                                 DBUS_TYPE_INT32 , &requestID,
+                                                DBUS_TYPE_INT32 , &errorCode,
                                                 DBUS_TYPE_INVALID))
    {
       reply = dbus_message_new_error(message, error.name, error.message);
@@ -138,7 +125,7 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *
       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    }
 
-   errorCode = check_pas_request(request, requestID);
+   errorReturn = check_pas_request(request, requestID);
 
    reply = dbus_message_new_method_return(message);
 
@@ -148,7 +135,7 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *
       printf("DBus No memory\n");
    }
 
-   if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &errorCode, DBUS_TYPE_INVALID))
+   if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &errorReturn, DBUS_TYPE_INVALID))
    {
      //DLT_LOG(mgrContext, DLT_LOG_ERROR, DLT_STRING("DBus No memory"));
       printf("DBus No memory\n");
@@ -276,7 +263,7 @@ DBusHandlerResult checkPersAdminMsg(DBusConnection * connection, DBusMessage * m
 
 int send_pas_register(const char* method, int notificationFlag)
 {
-   int rval = 0;
+   int rval = 0, errorCode = 0;
 
    DBusError error;
    dbus_error_init (&error);
@@ -290,12 +277,14 @@ int send_pas_register(const char* method, int notificationFlag)
                                                       "/org/genivi/persistence/admin",    // path
                                                        "org.genivi.persistence.admin",    // interface
                                                        method);                  // method
+
    if(message != NULL)
    {
       dbus_message_append_args(message, DBUS_TYPE_STRING, &busName,  // bus name
                                         DBUS_TYPE_STRING, &objName,
-                                        DBUS_TYPE_INT32, &notificationFlag,
-                                        DBUS_TYPE_INT32, &gTimeoutMs,
+                                        DBUS_TYPE_INT32,  &notificationFlag,
+                                        DBUS_TYPE_UINT32, &gTimeoutMs,
+                                        DBUS_TYPE_INT32,  &errorCode,
                                         DBUS_TYPE_INVALID);
 
       if(conn != NULL)
@@ -332,7 +321,7 @@ int send_pas_register(const char* method, int notificationFlag)
 
 int send_pas_request(const char* method, unsigned int requestID, int status)
 {
-   int rval = 0;
+   int rval = 0, errorCode = 0;
 
    DBusError error;
    dbus_error_init (&error);
@@ -347,6 +336,7 @@ int send_pas_request(const char* method, unsigned int requestID, int status)
    {
       dbus_message_append_args(message, DBUS_TYPE_UINT32, &requestID,
                                         DBUS_TYPE_INT32,  &status,
+                                        DBUS_TYPE_INT32,  &errorCode,
                                         DBUS_TYPE_INVALID);
 
       if(conn != NULL)
index e5ac3df..1b087e3 100644 (file)
@@ -7,23 +7,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_pas_interface.h
index f906a35..26847e7 100644 (file)
Binary files a/test/data/Data.tar.gz and b/test/data/Data.tar.gz differ
index 0cbc5fe..56cac76 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining 
-   a copy of this software and associated documentation files (the "Software"), 
-   to deal in the Software without restriction, including without limitation 
-   the rights to use, copy, modify, merge, publish, distribute, sublicense, 
-   and/or sell copies of the Software, and to permit persons to whom the 
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included 
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_dbus_test.c
index 54b7009..3315a25 100644 (file)
@@ -4,23 +4,9 @@
  * Company         XS Embedded GmbH
  *****************************************************************************/
 /******************************************************************************
-   Permission is hereby granted, free of charge, to any person obtaining 
-   a copy of this software and associated documentation files (the "Software"), 
-   to deal in the Software without restriction, including without limitation 
-   the rights to use, copy, modify, merge, publish, distribute, sublicense, 
-   and/or sell copies of the Software, and to permit persons to whom the 
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included 
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
-   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
-   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
-   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
-   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 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_test.c
@@ -77,7 +63,6 @@ START_TEST (test_GetData)
 
    memset(buffer, 0, READ_SIZE);
    ret = key_read_data(0,    "language/current_language", 3, 0, buffer, READ_SIZE);
-   printf("Buffer: %s \n", buffer);
    fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
@@ -119,8 +104,9 @@ START_TEST (test_GetDataHandle)
    snprintf(sysTimeBuffer, 128, "TimeAndData: \"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
                                                                   locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
    // open handle ---------------------------------------------------
-   handle = key_handle_open(0xFF, "posHandle/last_position", 0, 0);
-   fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last position");
+   handle = key_handle_open(0xFF, "posHandle/last_position", 1, 0);
+   printf("Handle: %d\n", handle);
+   fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
 
    ret = key_handle_read_data(handle, buffer, READ_SIZE);
    fail_unless(strncmp((char*)buffer, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", ret-1) == 0, "Buffer not correctly read");
@@ -193,6 +179,7 @@ START_TEST(test_SetData)
    // write data
    snprintf(sysTimeBuffer, 128, "\"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
                                                                  locTime->tm_hour, locTime->tm_min, locTime->tm_sec);
+
    ret = key_write_data(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
    fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
 
@@ -463,13 +450,13 @@ START_TEST(test_Cursor)
    // create cursor
    handle = persistence_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz",
                                           PersistenceStorage_local, PersistencePolicy_wc);
-   printf("Handle  : %d \n", handle);
+
    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);
-   printf("Handle1 : %d \n", handle1);
+
    fail_unless(handle1 != -1, "Failed to create cursor!!");
 
    do