summaryrefslogtreecommitdiff
path: root/Administrator/inc/private/ssw_pers_admin_config.h
blob: 319ab855a6ddfbf3351168c6ed6004a2ad22124c (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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#ifndef OSS_PERSISTENCE_ADMIN_CONFIG_H
#define OSS_PERSISTENCE_ADMIN_CONFIG_H
/**********************************************************************************************************************
*
* Copyright (C) 2012 Continental Automotive Systems, Inc.
*
* Author: Ionut.Ieremie@continental-corporation.com
*
* Interface: protected - Access to configuration files (json, xml)   
*
*
* 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/.
*
* Date       Author             Reason
* 2013.03.25 uidl9757  1.0.0.0  Created
*
**********************************************************************************************************************/


#ifdef __cplusplus
extern "C"
{
#endif  /* #ifdef __cplusplus */

#include "persComDataOrg.h"
#include "persComDbAccess.h"
#include "persComRct.h"


/*
 *  Structure of uncompressed WebTool's output
 *
 *  []resource
 *   ...[]public
 *   .   ...installRules.json
 *   .   ...[]public
 *   .       ...[]file
 *   .       .      []defaultData
 *   .       .      []configurableDefaultData
 *   .       .      []initialData
 *   .       ...[]key
 *   .       .      factoryDefaultData.json
 *   .       .      configurableDefaultData.json
 *   .       .      initialDefault.json
 *   .       ...installExceptions.json
 *   .       ...resourceconfiguration.json
 *   ...[]groups
 *   .   ...installRules.json
 *   .   ...[]10
 *   .       ...[]file
 *   .       .      []defaultData
 *   .       .      []configurableDefaultData
 *   .       .      []initialData
 *   .       ...[]key
 *   .       .      factoryDefaultData.json
 *   .       .      configurableDefaultData.json
 *   .       .      initialDefault.json
 *   .       ...GroupContent.json
 *   .       ...installExceptions.json
 *   .       ...resourceconfiguration.json
 *   .      []20
 *   ...[]apps
 *       ...installRules.json
 *       ...[]one_application
 *       .   ...[]file
 *       .   .      []defaultData
 *       .   .      []configurableDefaultData
 *       .   .      []initialData
 *       .   ...[]key
 *       .   .      factoryDefaultData.json
 *       .   .      configurableDefaultData.json
 *       .   .      initialDefault.json
 *       .   .  installExceptions.json
 *       .   ...resourceconfiguration.json
 *       ...[]another_application
 */

#define PERSADM_CFG_RESOURCE_ROOT_FOLDER_NAME "resource"
#define PERSADM_CFG_RESOURCE_PUBLIC_FOLDER_NAME "public"
#define PERSADM_CFG_RESOURCE_PUBLIC_FOLDER_PATHNAME PERSADM_CFG_RESOURCE_ROOT_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_PUBLIC_FOLDER_NAME
#define PERSADM_CFG_RESOURCE_GROUPS_FOLDER_NAME "groups"
#define PERSADM_CFG_RESOURCE_GROUPS_FOLDER_PATHNAME PERSADM_CFG_RESOURCE_ROOT_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_GROUPS_FOLDER_NAME
#define PERSADM_CFG_RESOURCE_APPS_FOLDER_NAME "apps"
#define PERSADM_CFG_RESOURCE_APPS_FOLDER_PATHNAME PERSADM_CFG_RESOURCE_ROOT_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_APPS_FOLDER_NAME

#define PERSADM_CFG_RESOURCE_RCT_FILENAME "resourceconfiguration.json"
#define PERSADM_CFG_RESOURCE_INSTALL_RULES_FILENAME "installRules.json"
#define PERSADM_CFG_RESOURCE_INSTALL_EXCEPTIONS_FILENAME "installExceptions.json"
#define PERSADM_CFG_RESOURCE_GROUP_CONTENT_FILENAME "GroupContent.json"

#define PERSADM_CFG_RESOURCE_ROOT_FILEDATA_FOLDER_NAME "file"
#define PERSADM_CFG_RESOURCE_FACTORY_DEFAULT_FILEDATA_FOLDER_NAME PERS_ORG_DEFAULT_DATA_FOLDER_NAME
#define PERSADM_CFG_RESOURCE_CONFIG_DEFAULT_FILEDATA_FOLDER_NAME PERS_ORG_CONFIG_DEFAULT_DATA_FOLDER_NAME
#define PERSADM_CFG_RESOURCE_NON_DEFAULT_FILEDATA_FOLDER_NAME "initialData.json"

#define PERSADM_CFG_RESOURCE_ROOT_KEYDATA_FOLDER_NAME "key"
#define PERSADM_CFG_RESOURCE_FACTORY_DEFAULT_KEYDATA_FILENAME "factoryDefaultData.json"
#define PERSADM_CFG_RESOURCE_CONFIG_KEYDEFAULT_DATA_FILENAME "configurableDefaultData.json"
#define PERSADM_CFG_RESOURCE_NON_DEFAULT_KEYDATA_FILENAME "initialDefault.json"

 
/** types of configuration files */
typedef enum PersAdminCfgFileTypes_e_
{
    PersAdminCfgFileType_InstallRules    = 0,    /**< config rules for all the applications or groups */
    PersAdminCfgFileType_InstallExceptions,      /**< config rules for a single application or group */
    PersAdminCfgFileType_RCT,                    /**< resource configuration table */
    PersAdminCfgFileType_Database,               /**< database with default or init values for resourceIDs */
    PersAdminCfgFileType_GroupContent,           /**< list with the applications that are member of a group */

   /** insert new entries here ... */
    PersAdminCfgFileType_LastEntry         /**< last entry */
} PersAdminCfgFileTypes_e;


/** global rules */
typedef enum PersAdminCfgInstallRules_e_
{
    PersAdminCfgInstallRules_NewInstall    = 0,             /**< delete existent data and install the new data */
    PersAdminCfgInstallRules_Uninstall,                     /**< remove the existent data */
    PersAdminCfgInstallRules_DontTouch,                     /**< don't touch the application/group/resource */
    PersAdminCfgInstallRules_UpdateAll,                     /**< update(merge) the existent data with new data (factory-default, config-default and non-default) */
    PersAdminCfgInstallRules_UpdateAllSkipDefaultFactory,   /**< update(merge) the existent data with new data (config-default and non-default) */
    PersAdminCfgInstallRules_UpdateAllSkipDefaultConfig,    /**< update(merge) the existent data with new data (factory-default and non-default) */
    PersAdminCfgInstallRules_UpdateAllSkipDefaultAll,       /**< update(merge) the existent data with new data (non-default) */
    PersAdminCfgInstallRules_UpdateDefaultFactory,          /**< update(merge) the existent data with new data (factory-default) */
    PersAdminCfgInstallRules_UpdateDefaultConfig,           /**< update(merge) the existent data with new data (config-default) */
    PersAdminCfgInstallRules_UpdateDefaultAll,              /**< update(merge) the existent data with new data (factory-default, config-default) */
    PersAdminCfgInstallRules_UpdateSetOfResources,          /**< update/remove data for a set of resources (factory-default, config-default and non-default) */
    PersAdminCfgInstallRules_UninstallNonDefault,           /**< uninstall non-default data (similar to reset to default) */

   /** insert new entries here ... */
    PersAdminCfgInstallRules_LastEntry            /**< last entry */
} PersAdminCfgInstallRules_e;


/** local rules */
typedef enum PersAdminCfgInstallExceptions_e_
{
    PersAdminCfgInstallExceptions_Update    = 0,        /**< update(merge) the resource's existent data with new data */
    PersAdminCfgInstallExceptions_DontTouch,            /**< don't touch the resource's data */
    PersAdminCfgInstallExceptions_Delete,               /**< remove the resource's existent data */

   /** insert new entries here ... */
    PersAdminCfgInstallExceptions_LastEntry             /**< last entry */
} PersAdminCfgInstallExceptions_e;

 
/** entry in global rules file */
typedef struct PersAdminCfgInstallRulesEntry_s_
{
     char                           responsible[PERS_RCT_MAX_LENGTH_RESPONSIBLE];       /**< name of the application/group */
     PersAdminCfgInstallRules_e     eRule;                                              /**< config rule for itemIdentifier */
} PersAdminCfgInstallRulesEntry_s;

/** entry in local rules file */
typedef struct PersAdminCfgRuleLocalEntry_s_
{
    char                                itemIdentifier[PERS_DB_MAX_LENGTH_KEY_NAME];        /**< name of the resource */
     PersAdminCfgInstallExceptions_e    eRule;                                              /**< config rule for itemIdentifier */
} PersAdminCfgRuleLocalEntry_s;

/** entry in database */
typedef struct PersAdminCfgDbEntry_s_
{
    char                        itemIdentifier[PERS_DB_MAX_LENGTH_KEY_NAME];        /**< name of the resource */
    char                        data[PERS_DB_MAX_SIZE_KEY_DATA];                    /**< config rule for itemIdentifier */
} PersAdminCfgDbEntry_s ;


/** entry in group content */
typedef struct PersAdminCfgGroupContentEntry_s_
{
    char                        appName[PERS_RCT_MAX_LENGTH_RESPONSIBLE];           /**< name of the application that is member of the group */
} PersAdminCfgGroupContentEntry_s ;

/** entry in resource config table */
typedef struct PersAdminCfgRctEntry_s_
{
    char                            resourceID[PERS_RCT_MAX_LENGTH_RESOURCE_ID];        /**< identifier of the resource */
    PersistenceConfigurationKey_s   sConfig ;                                           /**< configuration for resourceID */
} PersAdminCfgRctEntry_s ;

/** entry in config files for key type resources */
typedef struct PersAdminCfgKeyDataEntry_s_
{
    char    identifier[PERS_DB_MAX_LENGTH_KEY_NAME];            /**< identifier of the resource */
    int     dataSize ;                                          /**< size of data */ 
    char    data[PERS_DB_MAX_SIZE_KEY_DATA];                    /**< init/default data for the key type resource */
} PersAdminCfgKeyDataEntry_s ;


/***********************************************************************************************************************************
*********************************************** General usage **********************************************************************
***********************************************************************************************************************************/

/** 
 * \brief Obtain a handler to config file (RCT, rules, DB) indicated by cfgFilePathname
 *
 * \param cfgFilePathname       [in] absolute path to config file (length limited to \ref PERS_ORG_MAX_LENGTH_PATH_FILENAME)
 * \param eCfgFileType          [in] absolute path to config file (length limited to \ref PERS_ORG_MAX_LENGTH_PATH_FILENAME)
 *
 * \return >= 0 for valid handler, negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgFileOpen(char const * filePathname, PersAdminCfgFileTypes_e eCfgFileType) ;

/**
 * \brief Close handler to config file
 *
 * \param handlerCfgFile        [in] handler obtained with persCfgFileOpen
 *
 * \return 0 for success, negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgFileClose(signed int handlerCfgFile) ;

/***********************************************************************************************************************************
*********************************************** RCT related ************************************************************************
***********************************************************************************************************************************/

/**
 * \brief read a resourceID's configuration from RCT
 *
 * \param handlerRCT    [in] handler obtained with persAdmCfgFileOpen
 * \param resourceID    [in] resource's identifier (length limited to \ref PERS_RCT_MAX_LENGTH_RESOURCE_ID)
 * \param psConfig_out  [out]where to return the configuration for resourceID
 *
 * \return 0 for success, or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRctRead(signed int handlerRCT, char const * resourceID, PersistenceConfigurationKey_s* psConfig_out) ;


/**
 * \brief Find the buffer's size needed to accommodate the list of resourceIDs in RCT
 * \note : resourceIDs in the list are separated by '\0'
 *
 * \param handlerRCT    [in] handler obtained with persAdmCfgFileOpen
 *
 * \return needed size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRctGetSizeResourcesList(signed int handlerRCT) ;

/**
 * \brief Get the list of the resourceIDs in RCT
 * \note : resourceIDs in the list are separated by '\0'
 *
 * \param handlerRCT        [in] handler obtained with persAdmCfgFileOpen
 * \param listBuffer_out    [out]buffer where to return the list of resourceIDs
 * \param listBufferSize    [in] size of listBuffer_out
 *
 * \return list size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRctGetResourcesList(signed int handlerRCT, char* listBuffer_out, signed int listBufferSize) ;


/***********************************************************************************************************************************
*********************************************** Install Rules related **************************************************************
***********************************************************************************************************************************/

/**
 * \brief Find the buffer's size needed to accommodate the list of apps/groups names in install rules file
 * \note : the items in the list are separated by '\0'
 *
 * \param handlerRulesFile    [in] handler obtained with persAdmCfgFileOpen
 *
 * \return needed size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRulesGetSizeFoldersList(signed int handlerRulesFile) ;

/**
 * \brief Get the list of apps/groups names in install rules file
 * \note : the items in the list are separated by '\0'
 *
 * \param handlerRulesFile  [in] handler obtained with persAdmCfgFileOpen
 * \param listBuffer_out    [out]buffer where to return the list of apps/groups names
 * \param listBufferSize    [in] size of listBuffer_out
 *
 * \return list size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRulesGetFoldersList(signed int handlerRulesFile, char* listBuffer_out, signed int listBufferSize) ;

/**
 * \brief Get the rule for the app/group install folder
 *
 * \param handlerRulesFile  [in] handler obtained with persAdmCfgFileOpen
 * \param folderName        [in] name of the app/group install folder
 * \param peRule_out        [out]buffer where to return the rule for the folder
 *
 * \return 0 for success, or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgRulesGetRuleForFolder(signed int handlerRulesFile, char* folderName, PersAdminCfgInstallRules_e* peRule_out) ;


/***********************************************************************************************************************************
*********************************************** Install Exceptions related *********************************************************
***********************************************************************************************************************************/

/**
 * \brief Find the buffer's size needed to accommodate the list of resources in install exceptions file
 * \note : the items in the list are separated by '\0'
 *
 * \param handlerExceptionsFile     [in] handler obtained with persAdmCfgFileOpen
 *
 * \return needed size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgExcGetSizeResourcesList(signed int handlerExceptionsFile) ;

/**
 * \brief Get the list of resources in install exceptions file
 * \note : the items in the list are separated by '\0'
 *
 * \param handlerExceptionsFile     [in] handler obtained with persAdmCfgFileOpen
 * \param listBuffer_out            [out]buffer where to return the list of apps/groups names
 * \param listBufferSize            [in] size of listBuffer_out
 *
 * \return list size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgExcGetFoldersList(signed int handlerExceptionsFile, char* listBuffer_out, signed int listBufferSize) ;

/**
 * \brief Get the rule for the app/group install folder
 *
 * \param handlerRulesFile  [in] handler obtained with persAdmCfgFileOpen
 * \param resource          [in] identifier of the resource affected by the exception
 * \param peException_out   [out]buffer where to return the exception for the resource
 *
 * \return 0 for success, or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgExcGetExceptionForResource(signed int handlerExceptionsFile, char* resource, PersAdminCfgInstallExceptions_e* peException_out) ;

/***********************************************************************************************************************************
*********************************************** Group content related **************************************************************
***********************************************************************************************************************************/

/**
 * \brief Find the buffer's size needed to accomodate the list of members in the group
 *
 * \param handlerGroupContent   [in] handler obtained with persAdmCfgFileOpen
 *
 * \return needed size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgGroupContentGetSizeMembersList(signed int handlerGroupContent) ;


/**
 * \brief Get the list of members in the group
 * \note : resourceIDs in the list are separated by '\0'
 *
 * \param handlerGroupContent   [in] handler obtained with persAdmCfgFileOpen
 * \param listBuffer_out        [out]buffer where to return the list of resourceIDs
 * \param listBufferSize        [in] size of listBuffer_out
 *
 * \return list size [byte], or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgGroupContentGetMembersList(signed int handlerGroupContent, char* listBuffer_out, signed int listBufferSize) ;


/***********************************************************************************************************************************
*********************************************** Default data related **************************************************************
***********************************************************************************************************************************/

/**
 * \brief Get the default value for the key type resourceID
 *
 * \param hDefaultDataFile      [in] handler obtained with persAdmCfgFileOpen
 *
 * \return size of default data (0 means there is no default data for the key), or negative value for error (\ref PERSADM_CFG_ERROR_CODES_DEFINES)
 */
signed int persAdmCfgReadDefaultData(signed int hDefaultDataFile, char const * resourceID, char* defaultDataBuffer_out, signed int bufferSize) ;


#ifdef __cplusplus
}
#endif /* extern "C" { */

#endif /* OSS_PERSISTENCE_ADMIN_CONFIG_H */