summaryrefslogtreecommitdiff
path: root/src/persistence_client_library_data_organization.h
blob: 133799db339dfa289490f5ef8c6fa5b6479678aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#ifndef PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H
#define PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H

/******************************************************************************
 * Project         Persistency
 * (c) copyright   2012
 * Company         XS Embedded GmbH
 *****************************************************************************/
/******************************************************************************
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
******************************************************************************/
 /**
 * @file           persistence_client_library_data_organization.h
 * @ingroup        Persistence client library
 * @author         Ingo Huerner
 * @brief          Header of the persistence client library data organization.
 * @see            
 */


#ifdef __cplusplus
extern "C" {
#endif

#define  PERSIST_CLIENT_LIBRARY_DATA_ORGANIZATION_INTERFACE_VERSION   (0x03000000U)

#include "../include/persistence_client_library_error_def.h"
#include "../include/persistence_client_library_key.h"

#include <persComRct.h>
#include <persComDbAccess.h>
#include <persComDataOrg.h>

#include <string.h>


// define PERS_ORG_ROOT_PATH has been defined in persistence common object

/// cached path location
#define CACHEPREFIX         PERS_ORG_ROOT_PATH "/mnt-c/"
/// write through path location
#define WTPREFIX            PERS_ORG_ROOT_PATH "/mnt-wt/"


/// structure used to manage database context
typedef struct _PersistenceDbContext_s
{
	/// lofical database id
   unsigned int ldbid;
   /// user number
   unsigned int user_no;
   /// seat number
   unsigned int seat_no;
} PersistenceDbContext_s;

/// persistence information
typedef struct _PersistenceInfo_s
{
	/// database context ::PersistenceDbContext_s
   PersistenceDbContext_s           context;
   /// Persistence resource configuration key
   PersistenceConfigurationKey_s    configKey;

} PersistenceInfo_s;


/// storages to manage the data
typedef enum PersDefaultType_e_
{
	/// get the data from configurable defaults
   PersDefaultType_Configurable = 0,
   /// get the data from factory defaults
   PersDefaultType_Factory,

   /** insert new entries here ... */

   /// last entry
   PersDefaultType_LastEntry

} PersDefaultType_e;

/// storages to manage the data
typedef enum PersGetDefault_e_
{
	/// get the data from configurable defaults
   PersGetDefault_Data = 0,
   /// get the data from factory defaults
   PersGetDefault_Size,

   /** insert new entries here ... */

   /// last entry
   PersGetDefault_LastEntry

} PersGetDefault_e;

/// enumerator used to identify the policy to manage the data
typedef enum _PersNotifyRegPolicy_e
{
	/// register to change notifications
   Notify_register   = 0,
   ///  unregister for change notifications
   Notify_unregister = 1,

   /// last entry
   Notify_lastEntry
} PersNotifyRegPolicy_e;


/// constant definitions
enum _PersistenceConstantDef
{
	/// flag to identify if a backup should NOT be created
	DONT_CREATE_BACKUP   = 0,
	/// flag to identify if a backup should be created
	CREATE_BACKUP        = 1,
	/// flag to identify that resource a not file
   ResIsNoFile          = 0,
   /// flag to identify that resource a file
   ResIsFile            = 1,
   /// flag to indicate that access is not locked
   AccessNoLock         = 1,
   /// flag to identify if file will be closed
   FileClosed           = 1,
   /// flag to identify if file has been opened
   FileOpen             = 1,
   /// make partial Shutdown (close but not free everything)
   Shutdown_Partial      = 0,
   /// make complete Shutdown (close and free everything)
   Shutdown_Full         = 1,
   /// max number of shutdown cancel calls
   Shutdown_MaxCount     = 3,
   /// lifecycle shutdown normal
   NsmShutdownNormal       = 1,
   /// lifecycle return OK indicator
   NsmErrorStatus_OK       = 1,
   /// lifecycle return failed indicator
   NsmErrorStatus_Fail     = -1,
   /// lifecycle return that message is pending
   NsmErrorStatus_ResponsePending = 7,
   /// max checksum size
   ChecksumBufSize         = 64,
   /// max character sub match size
   DbusSubMatchSize        = 12,
   /// max character size of the dbus match rule size
   DbusMatchRuleSize       = 300,
   /// persistence resource config table max value size
   PrctValueSize           = sizeof(PersistenceConfigurationKey_s),
   /// number of persistence resource config tables to store
   PrctDbTableSize         = 1024,
   /// write buffer size
   RDRWBufferSize          = 1024,
   /// database table size
   DbTableSize             = 1024,
   /// persistence administration service block access
   PasMsg_Block            = 0x0001,
   /// persistence administration service unblock access
   PasMsg_Unblock          = 0x0002,
   /// persistence administration service write_back
   PasMsg_WriteBack        = 0x0010,
   /// persistence administration service msg return status
   PasErrorStatus_RespPend = 0x0001,
   /// persistence administration service msg return status
   PasErrorStatus_OK       = 0x0002,
   /// persistence administration service msg return status
   PasErrorStatus_FAIL     = 0x8000,
   /// max number of parallel open persistence handles
   MaxPersHandle = 512,
   /// length of the config key responsible name
   MaxConfKeyLengthResp    = 32,
   /// length of the config key custom name
   MaxConfKeyLengthCusName = 32,
   /// length of the customer ID
   MaxRctLengthCustom_ID   = 64,
   /// token array size
   TOKENARRAYSIZE = 255,
};

/**
 * @brief get the local cache path
 *
 * @ return the path
 */
const char* getLocalCachePath(void);

/**
 * @brief get the local wt path
 *
 * @ return the path
 */
const char* getLocalWtPath(void);

/**
 * @brief get the shared cache path
 *
 * @ return the path
 */
const char* getSharedCachePath(void);

/**
 * @brief get the shared wt path
 *
 * @ return the path
 */
const char* getSharedWtPath(void);

/**
 * @brief get the shared public cache path
 *
 * @ return the path
 */
const char* getSharedPublicCachePath(void);

/**
 * @brief get shared public wt path
 *
 * @ return the path
 */
const char* getSharedPublicWtPath(void);

/**
 * @brief get the local cache path key
 *
 * @ return the key
 */
const char* getLocalCachePathKey(void);

/**
 * @brief get local wt path key
 *
 * @ return the key
 */
const char* getLocalWtPathKey(void);

/**
 * @brief get the shared cache path key
 *
 * @ return the key
 */
const char* getSharedCachePathKey(void);

/**
 * @brief get the shared wt path key
 *
 * @ return the key
 */
const char* getSharedWtPathKey(void);

/**
 * @brief get the shared public cache path key
 *
 * @ return the key
 */
const char* getSharedPublicCachePathKey(void);

/**
 * @brief get the shared public write through path
 *
 * @ return the key
 */
const char* getSharedPublicWtPathKey(void);

/**
 * @brief get local cache file path
 *
 * @ return the path
 */
const char* getLocalCacheFilePath(void);

/// file descriptor used to call syncfs to commit buffer cache to disk
extern int gSyncFd;

/// flag to didicate if the lib is used by the NodeStateManager (appid)
extern int gIsNodeStateManager;


/// application id
extern char gAppId[PERS_RCT_MAX_LENGTH_RESPONSIBLE] __attribute__ ((visibility ("hidden")));


/// flag to indicate if client library has been initialized
extern unsigned int gPclInitCounter __attribute__ ((visibility ("hidden")));

/// dbus pending return value
extern int gDbusPendingRvalue __attribute__ ((visibility ("hidden")));


/// flag to indicate if PCL has registered to PAS
extern int gPasRegistered;


extern int gDbusMainloopRunning;


/**
 * @brief definition of change callback function
 *
 * @param pclNotification_s callback notification structure
 */
extern int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);

/// character lookup table used for parsing configuration files
extern const char gCharLookup[] __attribute__ ((visibility ("hidden")));


#ifdef __cplusplus
}
#endif

#endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ORGANIZATION_H */