1 /******************************************************************************
4 * Company XS Embedded GmbH
5 *****************************************************************************/
6 /******************************************************************************
7 * This Source Code Form is subject to the terms of the
8 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
9 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ******************************************************************************/
12 * @file persistence_client_library_data_organization.c
13 * @ingroup Persistence client library
14 * @author Ingo Huerner
15 * @brief Implementation of persistence database low level access
19 #include "persistence_client_library_data_organization.h"
26 // define PERS_ORG_ROOT_PATH comes form persistence common object
28 /// cached path location
29 #define CACHEPREFIX PERS_ORG_ROOT_PATH "/mnt-c/"
30 /// write through path location
31 #define WTPREFIX PERS_ORG_ROOT_PATH "/mnt-wt/"
32 /// path for the backup location
33 const char* gBackupPrefix = PERS_ORG_ROOT_PATH "/mnt-backup/";
35 /// size of cached path string
36 const int gCPathPrefixSize = sizeof(CACHEPREFIX)-1;
37 /// size of write through string
38 const int gWTPathPrefixSize = sizeof(WTPREFIX)-1;
41 /// backup filename postfix
42 const char* gBackupPostfix = "~";
43 /// backup checksum filename postfix
44 const char* gBackupCsPostfix = "~.crc";
46 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
47 const char* gLocalCachePath = CACHEPREFIX "%s";
48 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
49 const char* gLocalWtPath = WTPREFIX "%s";
50 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
51 const char* gSharedCachePath = CACHEPREFIX "%s/shared_group_%x";
52 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
53 const char* gSharedWtPath = WTPREFIX "%s/shared_group_%x";
54 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
55 const char* gSharedPublicCachePath = CACHEPREFIX "%s/shared_public";
56 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
57 const char* gSharedPublicWtPath = WTPREFIX "%s/shared_public";
59 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
60 const char* gLocalCachePathKey = CACHEPREFIX "%s%s";
61 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
62 const char* gLocalWtPathKey = WTPREFIX "%s%s";
63 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
64 const char* gSharedCachePathKey = CACHEPREFIX "%s/shared_group_%x%s";
65 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
66 const char* gSharedWtPathKey = WTPREFIX "%s/shared_group_%x%s";
67 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
68 const char* gSharedPublicCachePathKey = CACHEPREFIX "%s/shared_public%s";
69 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
70 const char* gSharedPublicWtPathKey = WTPREFIX "%s/shared_public%s";
72 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/<seat>/<resource>
73 const char* gLocalCacheFilePath = CACHEPREFIX "%s"PERS_ORG_USER_FOLDER_NAME_"%d"PERS_ORG_SEAT_FOLDER_NAME_"%d/%s";
76 const char* gChangeSignal = "PersistenceResChange";
77 const char* gDeleteSignal = "PersistenceResDelete";
78 const char* gCreateSignal = "PersistenceResCreate";
81 char gNotifykey[DbKeyMaxLen] = { [0 ... DbKeyMaxLen-1] = 0};
83 unsigned int gNotifyLdbid = 0;
84 unsigned int gNotifyUserNo = 0;
85 unsigned int gNotifySeatNo = 0;
86 pclNotifyStatus_e gNotifyReason = 0;
87 PersNotifyRegPolicy_e gNotifyPolicy = 0;
90 int gTimeoutMs = 5000;
92 int gDbusPendingRvalue = 0;
96 char gAppId[MaxAppNameLen] = { [0 ... MaxAppNameLen-1] = 0};
99 /// max key value data size [default 16kB]
100 int gMaxKeyValDataSize = defaultMaxKeyValDataSize;
103 unsigned int gPclInitialized = PCLnotInitialized;
106 DltContext gPclDLTContext;
108 int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
111 const char gCharLookup[] =
113 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)
114 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 (?)
115 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 (_)
116 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 (~)