Removed global variables for notifications; use now pipe instead of eventfd for mainl...
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_data_organization.c
index 73d45cf..83ecaec 100644 (file)
  * @see            
  */
 
-#include "../include_protected/persistence_client_library_data_organization.h"
+#include "persistence_client_library_data_organization.h"
 
 #include <string.h>
 #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";
+// define PERS_ORG_ROOT_PATH comes form persistence common object
 
-/// default database name
-const char* gDefault = "/default-data.itz";
+/// cached path location
+#define CACHEPREFIX         PERS_ORG_ROOT_PATH "/mnt-c/"
+/// write through path location
+#define WTPREFIX            PERS_ORG_ROOT_PATH "/mnt-wt/"
+/// path for the backup location
+const char* gBackupPrefix      = PERS_ORG_ROOT_PATH "/mnt-backup/";
 
-/// write through database name
-const char* gWt             = "/wt.itz";
-/// cached database name
-const char* gCached        = "/cached.itz";
+/// size of cached path string
+const int gCPathPrefixSize = sizeof(CACHEPREFIX)-1;
+/// size of write through string
+const int gWTPathPrefixSize = sizeof(WTPREFIX)-1;
 
 
-/// directory structure node name defintion
-const char* gNode = "/node";
-/// directory structure user name defintion
-const char* gUser = "/user/";
-/// directory structure seat name defintion
-const char* gSeat = "/seat/";
-
+/// backup filename postfix
+const char* gBackupPostfix     = "~";
+/// backup checksum filename postfix
+const char* gBackupCsPostfix   = "~.crc";
 
 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
-const char* gLocalCachePath        = "/Data/mnt-c/%s";
+const char* gLocalCachePath        = CACHEPREFIX "%s";
 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
-const char* gLocalWtPath           = "/Data/mnt-wt/%s";
+const char* gLocalWtPath           = WTPREFIX "%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";
+const char* gSharedCachePath       = CACHEPREFIX "%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";
+const char* gSharedWtPath          = WTPREFIX "%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";
+const char* gSharedPublicCachePath = CACHEPREFIX "%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";
+const char* gSharedPublicWtPath    = WTPREFIX "%s/shared_public";
 
 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
-const char* gLocalCachePathKey        = "/Data/mnt-c/%s%s";
+const char* gLocalCachePathKey        = CACHEPREFIX "%s%s";
 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
-const char* gLocalWtPathKey           = "/Data/mnt-wt/%s%s";
+const char* gLocalWtPathKey           = WTPREFIX "%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";
+const char* gSharedCachePathKey       = CACHEPREFIX "%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";
+const char* gSharedWtPathKey          = WTPREFIX "%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";
+const char* gSharedPublicCachePathKey = CACHEPREFIX "%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";
+const char* gSharedPublicWtPathKey    = WTPREFIX "%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";
+const char* gLocalCacheFilePath        = CACHEPREFIX "%s"PERS_ORG_USER_FOLDER_NAME_"%d"PERS_ORG_SEAT_FOLDER_NAME_"%d/%s";
 
 
 const char* gChangeSignal = "PersistenceResChange";
 const char* gDeleteSignal = "PersistenceResDelete";
 const char* gCreateSignal = "PersistenceResCreate";
 
-
-char gNotifykey[DbKeyMaxLen] = {0};
-unsigned int gNotifyLdbid  = 0;
-unsigned int gNotifyUserNo = 0;
-unsigned int gNotifySeatNo = 0;
-pclNotifyStatus_e       gNotifyReason = 0;
-PersNotifyRegPolicy_e   gNotifyPolicy = 0;
-
-
 int gTimeoutMs = 5000;
 
 int gDbusPendingRvalue = 0;
 
 
 /// application id
-char gAppId[MaxAppNameLen] = {0};
+char gAppId[MaxAppNameLen] = { [0 ... MaxAppNameLen-1] = 0};
 
 
 /// max key value data size [default 16kB]
@@ -104,8 +93,18 @@ int gMaxKeyValDataSize = defaultMaxKeyValDataSize;
 unsigned int gPclInitialized = PCLnotInitialized;
 
 
-DltContext gDLTContext;
+DltContext gPclDLTContext;
 
 int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
 
 
+const char gCharLookup[] =
+{
+   0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,  // from 0x0 (NULL)  to 0x1F (unit seperator)
+   0,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  // from 020 (space) to 0x2F (?)
+   1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  // from 040 (@)     to 0x5F (_)
+   1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1,1,  1,1,1,1,1,1,1     // from 060 (')     to 0x7E (~)
+
+};
+
+