Implemented default data handling for read
authorIngo Huerner <ingo.huerner@xse.de>
Wed, 21 Aug 2013 13:25:46 +0000 (15:25 +0200)
committerIngo Huerner <ingo.huerner@xse.de>
Wed, 21 Aug 2013 13:25:46 +0000 (15:25 +0200)
configure.ac
include_protected/persistence_client_library_data_organization.h
src/persistence_client_library_backup_filelist.c
src/persistence_client_library_data_organization.c
src/persistence_client_library_db_access.c
src/persistence_client_library_handle.c
src/persistence_client_library_prct_access.c
test/persistence_client_library_test.c

index 36b5f92..205a8b1 100644 (file)
@@ -4,7 +4,7 @@
 
 # create tag version information
 m4_define([pers_client_library_tag_version_major], [0])
-m4_define([pers_client_library_tag_version_minor], [6])
+m4_define([pers_client_library_tag_version_minor], [7])
 m4_define([pers_client_library_tag_version_micro], [0])
 m4_define([pers_client_library_tag_version], [pers_client_library_tag_version_major().pers_client_library_tag_version_minor().pers_client_library_tag_version_micro()])
 
@@ -17,7 +17,7 @@ AC_GNU_SOURCE()
 
 # create library version information
 m4_define([pers_client_library_version_current],  [6])
-m4_define([pers_client_library_version_revision], [1])
+m4_define([pers_client_library_version_revision], [2])
 m4_define([pers_client_library_version_age],      [0])
 m4_define([pers_client_library_version], [pers_client_library_version_current():pers_client_library_version_revision():pers_client_library_version_age()])
 
index 01ad010..d6539ef 100644 (file)
@@ -24,7 +24,7 @@
 extern "C" {
 #endif
 
-#define  PERSIST_CLIENT_LIBRARY_DATA_ORGANIZATION_INTERFACE_VERSION   (0x01040000U)
+#define  PERSIST_CLIENT_LIBRARY_DATA_ORGANIZATION_INTERFACE_VERSION   (0x02000000U)
 
 #include "../include/persistence_client_library_error_def.h"
 #include "../include/persistence_client_library_key.h"
@@ -95,23 +95,18 @@ enum _PersistenceConstantDef
 /// resource configuration table name
 extern const char* gResTableCfg;
 
-/// shared cached default database
-extern const char* gSharedCachedDefault;
+/// configurable default database name
+extern const char* gConfigDefault;
+
+/// default database name
+extern const char* gDefault;
+
+
 /// shared cached database
-extern const char* gSharedCached;
-/// shared write through default database
-extern const char* gSharedWtDefault;
-/// shared write through database
-extern const char* gSharedWt;
-
-/// local cached default database
-extern const char* gLocalCachedDefault;
-/// local cached default database
-extern const char* gLocalCached;
-/// local write through default database
-extern const char* gLocalWtDefault;
-/// local write through default database
-extern const char* gLocalWt;
+extern const char* gCached;
+
+/// write through database name
+extern const char* gWt;
 
 
 /// directory structure node name defintion
@@ -135,6 +130,19 @@ extern const char* gSharedPublicCachePath;
 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
 extern const char* gSharedPublicWtPath;
 
+/// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
+extern const char* gLocalCachePathKey;
+/// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
+extern const char* gLocalWtPathKey;
+/// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
+extern const char* gSharedCachePathKey;
+/// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
+extern const char* gSharedWtPathKey;
+/// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
+extern const char* gSharedPublicCachePathKey;
+/// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
+extern const char* gSharedPublicWtPathKey;
+
 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/>userno>/<seat>/>seatno>/<resource>
 extern const char* gLocalCacheFilePath;
 
index 7a32e14..7ce72da 100644 (file)
@@ -66,7 +66,7 @@ const char gCharLookup[] =
 
 
 char* gpConfigFileMap = 0;
-char* gpTokenArray[TOKENARRAYSIZE];
+char* gpTokenArray[TOKENARRAYSIZE] = {0};
 int gTokenCounter = 0;
 unsigned int gConfigFileSize = 0;
 
index 05ba317..001ded6 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+// rrsource configuration database name
 const char* gResTableCfg = "/resource-table-cfg.itz";
 
+/// configurable default database name
+const char* gConfigDefault = "/configurable-default-data.itz";
 
-/// shared cached default database
-const char* gSharedCachedDefault = "/cached-default.itz";
-/// shared cached database
-const char* gSharedCached        = "/cached.itz";
-/// shared write through default database
-const char* gSharedWtDefault     = "/wt-default.itz";
-/// shared write through database
-const char* gSharedWt            = "/wt.itz";
-
-
-/// local cached default database
-const char* gLocalCachedDefault  = "cached-default.itz";
-/// local cached default database
-const char* gLocalCached         = "/cached.itz";
-/// local write through default database
-const char* gLocalWtDefault      = "wt-default.itz";
-/// local write through default database
-const char* gLocalWt             = "/wt.itz";
+/// default database name
+const char* gDefault = "/default-data.itz";
 
+/// write through database name
+const char* gWt             = "/wt.itz";
+/// cached database name
+const char* gCached        = "/cached.itz";
 
 
 /// directory structure node name defintion
@@ -54,21 +45,31 @@ const char* gUser = "/user/";
 const char* gSeat = "/seat/";
 
 
-/// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
-const char* gLocalCachePath        = "/Data/mnt-c/%s%s";
+/// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
+const char* gLocalCachePath        = "/Data/mnt-c/%s";
 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
-const char* gLocalWtPath           = "/Data/mnt-wt/%s%s";
+const char* gLocalWtPath           = "/Data/mnt-wt/%s";
 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
-const char* gSharedCachePath       = "/Data/mnt-c/%s/Shared_Group_%x%s";
+const char* gSharedCachePath       = "/Data/mnt-c/%s/Shared_Group_%x";
 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
-const char* gSharedWtPath          = "/Data/mnt-wt/%s/Shared_Group_%x%s";
-
+const char* gSharedWtPath          = "/Data/mnt-wt/%s/Shared_Group_%x";
 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
-const char* gSharedPublicCachePath = "/Data/mnt-c/%s/Shared_Public%s";
-
+const char* gSharedPublicCachePath = "/Data/mnt-c/%s/Shared_Public";
 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
-const char* gSharedPublicWtPath    = "/Data/mnt-wt/%s/Shared_Public%s";
+const char* gSharedPublicWtPath    = "/Data/mnt-wt/%s/Shared_Public";
 
+/// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
+const char* gLocalCachePathKey        = "/Data/mnt-c/%s%s";
+/// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
+const char* gLocalWtPathKey           = "/Data/mnt-wt/%s%s";
+/// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
+const char* gSharedCachePathKey       = "/Data/mnt-c/%s/Shared_Group_%x%s";
+/// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
+const char* gSharedWtPathKey          = "/Data/mnt-wt/%s/Shared_Group_%x%s";
+/// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
+const char* gSharedPublicCachePathKey = "/Data/mnt-c/%s/Shared_Public%s";
+/// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
+const char* gSharedPublicWtPathKey    = "/Data/mnt-wt/%s/Shared_Public%s";
 
 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/<seat>/<resource>
 const char* gLocalCacheFilePath        = "/Data/mnt-c/%s/user/%d/seat/%d/%s";
index 3424d94..aab7a1f 100644 (file)
@@ -33,7 +33,7 @@
 /// definition of a key-value pair stored in the database
 typedef struct _KeyValuePair_s
 {
-    char m_key[DbKeySize];       /// the key
+    char m_key[DbKeySize];    /// the key
     char m_data[DbValueSize];    /// the data
     unsigned int m_data_size;   /// the size of the data
 }
@@ -73,6 +73,38 @@ static int gBtreeCreated[DbTableSize][PersistencePolicy_LastEntry] = { {0} };
 int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* context, unsigned int reason);
 
 
+
+
+
+
+int pers_db_open_default(itzam_btree* btree, PersistenceInfo_s* info, const char* dbPath, int configDefault)
+{
+   itzam_state  state = ITZAM_FAILED;
+   char path[DbPathMaxLen] = {0};
+
+   if(1 == configDefault)
+   {
+      snprintf(path, DbPathMaxLen, "%s%s", dbPath, gConfigDefault);
+   }
+   else if(0 == configDefault)
+   {
+      snprintf(path, DbPathMaxLen, "%s%s", dbPath, gDefault);
+   }
+   else
+   {
+      return -1;  // invalid
+   }
+
+   state = itzam_btree_open(btree, path, itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/);
+   if (state != ITZAM_OKAY)
+   {
+      DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_open_default ==> itzam_btree_open => Itzam problem"), DLT_STRING(STATE_MESSAGES[state]));
+   }
+
+   return 1;
+}
+
+
 itzam_btree* pers_db_open(PersistenceInfo_s* info, const char* dbPath)
 {
    int arrayIdx = 0;
@@ -87,7 +119,22 @@ itzam_btree* pers_db_open(PersistenceInfo_s* info, const char* dbPath)
       if(gBtreeCreated[arrayIdx][info->configKey.policy] == 0)
       {
          itzam_state  state = ITZAM_FAILED;
-         state = itzam_btree_open(&gBtree[arrayIdx][info->configKey.policy], dbPath,
+         char path[DbPathMaxLen] = {0};
+
+         if(PersistencePolicy_wt == info->configKey.policy)
+         {
+            snprintf(path, DbPathMaxLen, "%s%s", dbPath, gWt);
+         }
+         else if(PersistencePolicy_wc == info->configKey.policy)
+         {
+            snprintf(path, DbPathMaxLen, "%s%s", dbPath, gCached);
+         }
+         else
+         {
+            return btree;
+         }
+
+         state = itzam_btree_open(&gBtree[arrayIdx][info->configKey.policy], path,
                                   itzam_comparator_string, error_handler, 0/*recover*/, 0/*read_only*/);
          if (state != ITZAM_OKAY)
          {
@@ -162,7 +209,6 @@ void pers_db_close_all()
 }
 
 
-
 int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned char* buffer, unsigned int buffer_size)
 {
    int read_size = -1;
@@ -171,7 +217,11 @@ int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned
       || PersistenceStorage_local == info->configKey.storage)
    {
       itzam_btree* btree = NULL;
+      itzam_btree btreeDefault;
+      itzam_btree btreeConfDefault;
       KeyValuePair_s search;
+      int keyFound = 0;
+      itzam_state  state = ITZAM_FAILED;
 
       btree = pers_db_open(info, dbPath);
       if(btree != NULL)
@@ -184,17 +234,76 @@ int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned
                read_size = buffer_size;   // truncate data size to buffer size
             }
             memcpy(buffer, search.m_data, read_size);
+            keyFound = 1;
          }
-         else
+      }
+
+
+      // 1. check if _configurable_ default data is available
+      // --------------------------------
+      if(keyFound == 0)
+      {
+         if(pers_db_open_default(&btreeConfDefault, info, dbPath, 1) != -1)
          {
-            read_size = EPERS_NOKEY;
+            if(itzam_true == itzam_btree_find(&btreeConfDefault, key, &search)) // read db
+            {
+               read_size = search.m_data_size;
+               if(read_size > buffer_size)
+               {
+                  read_size = buffer_size;   // truncate data size to buffer size
+               }
+               memcpy(buffer, search.m_data, read_size);
+
+               keyFound = 1;
+            }
+            else
+            {
+               DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==> 2. resource not found in default config => search in default db"), DLT_STRING(key));
+            }
+
+            state = itzam_btree_close(&btreeConfDefault);
+            if (state != ITZAM_OKAY)
+            {
+               DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==> default: itzam_btree_close => Itzam problem"), DLT_STRING(STATE_MESSAGES[state]));
+            }
          }
       }
-      else
+
+      // 2. check if default data is available
+      // --------------------------------
+      if(keyFound == 0)
       {
-         DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==>no resource config table"), DLT_STRING(dbPath), DLT_STRING(key) );
-         read_size = EPERS_NOPRCTABLE;
+         if(pers_db_open_default(&btreeDefault, info, dbPath, 0) != -1)
+         {
+            if(itzam_true == itzam_btree_find(&btreeDefault, key, &search)) // read db
+            {
+               read_size = search.m_data_size;
+               if(read_size > buffer_size)
+               {
+                  read_size = buffer_size;   // truncate data size to buffer size
+               }
+               memcpy(buffer, search.m_data, read_size);
+            }
+            else
+            {
+               DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==> 3. reasoure not found in both default db's"), DLT_STRING(key) );
+               read_size = EPERS_NOKEY;   // the key is not available neither in regular db nor in the default db's
+            }
+
+            state = itzam_btree_close(&btreeDefault);
+            if (state != ITZAM_OKAY)
+            {
+               DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==> default: itzam_btree_close => Itzam problem"), DLT_STRING(STATE_MESSAGES[state]));
+            }
+         }
+         else
+         {
+            DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pers_db_read_key ==>no resource config table"), DLT_STRING(dbPath), DLT_STRING(key) );
+            read_size = EPERS_NOPRCTABLE;
+         }
       }
+
+
    }
    else if(PersistenceStorage_custom == info->configKey.storage)   // custom storage implementation via custom library
    {
index 821e9a3..a6a952d 100644 (file)
@@ -40,7 +40,7 @@ PersistenceFileHandle_s gFileHandleArray[MaxPersHandle];
 
 
 /// free handle array
-int gFreeHandleArray[MaxPersHandle];
+int gFreeHandleArray[MaxPersHandle] = {0};
 
 int gFreeHandleIdxHead = 0;
 
index f3142b4..c0e450a 100644 (file)
@@ -86,13 +86,13 @@ itzam_btree* get_resource_cfg_table(PersistenceRCT_e rct, int group)
          switch(rct)    // create db name
          {
          case PersistenceRCT_local:
-            snprintf(filename, DbPathMaxLen, gLocalWtPath, gAppId, gResTableCfg);
+            snprintf(filename, DbPathMaxLen, gLocalWtPathKey, gAppId, gResTableCfg);
             break;
          case PersistenceRCT_shared_public:
-            snprintf(filename, DbPathMaxLen, gSharedPublicWtPath, gAppId, gResTableCfg);
+            snprintf(filename, DbPathMaxLen, gSharedPublicWtPathKey, gAppId, gResTableCfg);
             break;
          case PersistenceRCT_shared_group:
-            snprintf(filename, DbPathMaxLen, gSharedWtPath, gAppId, group, gResTableCfg);
+            snprintf(filename, DbPathMaxLen, gSharedWtPathKey, gAppId, group, gResTableCfg);
             break;
          default:
             DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_resource_cfg_table - error: no valid PersistenceRCT_e"));
@@ -283,16 +283,16 @@ int get_db_path_and_key(PersistenceInfo_s* dbContext, const char* resource_id, c
          if(PersistencePolicy_wc == dbContext->configKey.policy)
          {
             if(dbContext->configKey.type == PersistenceResourceType_key)
-               snprintf(dbPath, DbPathMaxLen, gSharedCachePath, gAppId, dbContext->context.ldbid, gSharedCached);
+               snprintf(dbPath, DbPathMaxLen, gSharedCachePath, gAppId, dbContext->context.ldbid);
             else
-               snprintf(dbPath, DbPathMaxLen, gSharedCachePath, gAppId, dbContext->context.ldbid, dbKey);
+               snprintf(dbPath, DbPathMaxLen, gSharedCachePathKey, gAppId, dbContext->context.ldbid, dbKey);
          }
          else if(PersistencePolicy_wt == dbContext->configKey.policy)
          {
             if(dbContext->configKey.type == PersistenceResourceType_key)
-               snprintf(dbPath, DbPathMaxLen, gSharedWtPath, gAppId, dbContext->context.ldbid, gSharedWt);
+               snprintf(dbPath, DbPathMaxLen, gSharedWtPath, gAppId, dbContext->context.ldbid);
             else
-               snprintf(dbPath, DbPathMaxLen, gSharedWtPath, gAppId, dbContext->context.ldbid, dbKey);
+               snprintf(dbPath, DbPathMaxLen, gSharedWtPathKey, gAppId, dbContext->context.ldbid, dbKey);
          }
       }
       else
@@ -304,16 +304,16 @@ int get_db_path_and_key(PersistenceInfo_s* dbContext, const char* resource_id, c
          if(PersistencePolicy_wc == dbContext->configKey.policy)
          {
             if(dbContext->configKey.type == PersistenceResourceType_key)
-               snprintf(dbPath, DbPathMaxLen, gSharedPublicCachePath, gAppId, gSharedCached);
+               snprintf(dbPath, DbPathMaxLen, gSharedPublicCachePath, gAppId);
             else
-               snprintf(dbPath, DbPathMaxLen, gSharedPublicCachePath, gAppId, dbKey);
+               snprintf(dbPath, DbPathMaxLen, gSharedPublicCachePathKey, gAppId, dbKey);
          }
          else if(PersistencePolicy_wt == dbContext->configKey.policy)
          {
             if(dbContext->configKey.type == PersistenceResourceType_key)
-               snprintf(dbPath, DbPathMaxLen, gSharedPublicWtPath, gAppId, gSharedWt);
+               snprintf(dbPath, DbPathMaxLen, gSharedPublicWtPath, gAppId);
             else
-               snprintf(dbPath, DbPathMaxLen, gSharedPublicWtPath, gAppId, dbKey);
+               snprintf(dbPath, DbPathMaxLen, gSharedPublicWtPathKey, gAppId, dbKey);
          }
       }
 
@@ -326,23 +326,23 @@ int get_db_path_and_key(PersistenceInfo_s* dbContext, const char* resource_id, c
       if(PersistencePolicy_wc == dbContext->configKey.policy)
       {
          if(dbContext->configKey.type == PersistenceResourceType_key)
-            snprintf(dbPath, DbPathMaxLen, gLocalCachePath, gAppId, gLocalCached);
+            snprintf(dbPath, DbPathMaxLen, gLocalCachePath, gAppId);
          else
-            snprintf(dbPath, DbPathMaxLen, gLocalCachePath, gAppId, dbKey);
+            snprintf(dbPath, DbPathMaxLen, gLocalCachePathKey, gAppId, dbKey);
       }
       else if(PersistencePolicy_wt == dbContext->configKey.policy)
       {
          if(dbContext->configKey.type == PersistenceResourceType_key)
-            snprintf(dbPath, DbPathMaxLen, gLocalWtPath, gAppId, gLocalWt);
+            snprintf(dbPath, DbPathMaxLen, gLocalWtPath, gAppId);
          else
-            snprintf(dbPath, DbPathMaxLen, gLocalWtPath, gAppId, dbKey);
+            snprintf(dbPath, DbPathMaxLen, gLocalWtPathKey, gAppId, dbKey);
       }
 
       storePolicy = PersistenceStorage_local;   // we have a local database
    }
 
    //printf("get_db_path_and_key - dbKey  : [key ]: %s \n",  dbKey);
-   //printf("get_db_path_and_key - dbPath : [path]: %s\n\n", dbPath);
+   //printf("get_db_path_and_key - dbPath : [path]: %s\n", dbPath);
    return storePolicy;
 }
 
index a77f0e5..cdcb93f 100644 (file)
@@ -44,7 +44,7 @@
 #define READ_SIZE    1024
 
 /// application id
-char gTheAppId[MaxAppNameLen];
+char gTheAppId[MaxAppNameLen] = {0};
 
 // definition of weekday
 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
@@ -61,12 +61,10 @@ START_TEST (test_GetData)
    int ret = 0;
    unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
 
-   unsigned char buffer[READ_SIZE];
+   unsigned char buffer[READ_SIZE] = {0};
 
    pclInitLibrary(gTheAppId, shutdownReg);
 
-   memset(buffer, 0, READ_SIZE);
-
    /**
     * Logical DB ID: 0xFF with user 0 and seat 0
     *       ==> local value accessible by all users (user 0, seat 0)
@@ -158,7 +156,7 @@ START_TEST (test_GetDataHandle)
    int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
-   unsigned char buffer[READ_SIZE];
+   unsigned char buffer[READ_SIZE] = {0};
    struct tm *locTime;
 
    char sysTimeBuffer[128];
@@ -166,7 +164,6 @@ START_TEST (test_GetDataHandle)
    pclInitLibrary(gTheAppId, shutdownReg);
 
    time_t t = time(0);
-   memset(buffer, 0, READ_SIZE);
 
    locTime = localtime(&t);
 
@@ -260,9 +257,9 @@ START_TEST(test_SetData)
 {
    int ret = 0;
    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
-   unsigned char buffer[READ_SIZE];
-   char write1[READ_SIZE];
-   char write2[READ_SIZE];
+   unsigned char buffer[READ_SIZE]  = {0};
+   char write1[READ_SIZE] = {0};
+   char write2[READ_SIZE] = {0};
    char sysTimeBuffer[256];
 
    struct tm *locTime;
@@ -272,9 +269,6 @@ START_TEST(test_SetData)
    time_t t = time(0);
 
    locTime = localtime(&t);
-   memset(buffer, 0, READ_SIZE);
-   memset(write1, 0, READ_SIZE);
-   memset(write2, 0, READ_SIZE);
 
    // 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),
@@ -377,14 +371,13 @@ START_TEST(test_SetDataNoPRCT)
 {
    int ret = 0;
    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
-   unsigned char buffer[READ_SIZE];
+   unsigned char buffer[READ_SIZE] = {0};
    struct tm *locTime;
 
    pclInitLibrary(gTheAppId, shutdownReg);
    time_t t = time(0);
 
    char sysTimeBuffer[128];
-   memset(buffer, 0, READ_SIZE);
 
    locTime = localtime(&t);
 
@@ -505,7 +498,7 @@ START_TEST(test_DataFile)
    int writeSize = 16*1024;
    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
-   unsigned char buffer[READ_SIZE];
+   unsigned char buffer[READ_SIZE] = {0};
    const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
    char* writeBuffer;
    char* fileMap = NULL;
@@ -527,8 +520,6 @@ START_TEST(test_DataFile)
       writeBuffer[idx++] = 'F';
       writeBuffer[idx++] = ' ';
    }
-   memset(buffer, 0, READ_SIZE);
-
    // create file
    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
              O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
@@ -748,20 +739,14 @@ END_TEST
 START_TEST(test_Cursor)
 {
    int handle = -1, rval = 0, size = 0, handle1 = 0;
-   char bufferKeySrc[READ_SIZE];
-   char bufferDataSrc[READ_SIZE];
-   char bufferKeyDst[READ_SIZE];
-   char bufferDataDst[READ_SIZE];
+   char bufferKeySrc[READ_SIZE]  = {0};
+   char bufferDataSrc[READ_SIZE] = {0};
+   char bufferKeyDst[READ_SIZE]  = {0};
+   char bufferDataDst[READ_SIZE] = {0};
    unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
    pclInitLibrary(gTheAppId, shutdownReg);
 
-   memset(bufferKeySrc, 0, READ_SIZE);
-   memset(bufferDataSrc, 0, READ_SIZE);
-
-   memset(bufferKeyDst, 0, READ_SIZE);
-   memset(bufferDataDst, 0, READ_SIZE);
-
    // create cursor
    handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
    fail_unless(handle != -1, "Failed to create cursor!!");
@@ -817,7 +802,7 @@ END_TEST
 START_TEST(test_Plugin)
 {
        int ret = 0;
-       unsigned char buffer[READ_SIZE];
+       unsigned char buffer[READ_SIZE]  = {0};
 
        unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
        pclInitLibrary(gTheAppId, shutdownReg);
@@ -858,6 +843,54 @@ END_TEST
 
 
 
+
+
+START_TEST(test_ReadDefault)
+{
+   int ret = 0;
+   unsigned char buffer[READ_SIZE]  = {0};
+
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+   pclInitLibrary(gTheAppId, shutdownReg);
+
+   ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
+   fail_unless(ret != EPERS_NOT_INITIALIZED);
+   printf("B U F F E R: %s\n", buffer);
+   fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
+   fail_unless(ret != EPERS_NOT_INITIALIZED);
+   printf("B U F F E R: %s\n", buffer);
+   fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_ReadConfDefault)
+{
+   int ret = 0;
+   unsigned char buffer[READ_SIZE]  = {0};
+
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+   pclInitLibrary(gTheAppId, shutdownReg);
+
+   ret = pclKeyReadData(0xFF, "statusHandle/confdefault01",     3, 2, buffer, READ_SIZE);
+   fail_unless(ret != EPERS_NOT_INITIALIZED);
+   fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   ret = pclKeyReadData(0xFF, "statusHandle/confdefault02",     3, 2, buffer, READ_SIZE);
+   fail_unless(ret != EPERS_NOT_INITIALIZED);
+   fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   pclDeinitLibrary();
+}
+END_TEST
+
+
+
 static Suite * persistencyClientLib_suite()
 {
    Suite * s  = suite_create("Persistency client library");
@@ -898,6 +931,11 @@ static Suite * persistencyClientLib_suite()
    TCase * tc_Plugin = tcase_create("Plugin");
    tcase_add_test(tc_Plugin, test_Plugin);
 
+   TCase * tc_ReadDefault = tcase_create("ReadDefault");
+   tcase_add_test(tc_ReadDefault, test_ReadDefault);
+
+   TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
+   tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
 
    suite_add_tcase(s, tc_persGetData);
    suite_add_tcase(s, tc_persSetData);
@@ -910,6 +948,8 @@ static Suite * persistencyClientLib_suite()
    suite_add_tcase(s, tc_persDataFile);
    suite_add_tcase(s, tc_persDataFileRecovery);
    suite_add_tcase(s, tc_Cursor);
+   suite_add_tcase(s, tc_ReadDefault);
+   suite_add_tcase(s, tc_ReadConfDefault);
 
    suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
    return s;