e1c23a62197660f94bbd9cc5a1c13c9f5baff339
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_handle.h
1 #ifndef PERSISTENCE_CLIENT_LIBRARY_HANDLE_H
2 #define PERSISTENCE_CLIENT_LIBRARY_HANDLE_H
3
4 /******************************************************************************
5  * Project         Persistency
6  * (c) copyright   2012
7  * Company         XS Embedded GmbH
8  *****************************************************************************/
9 /******************************************************************************
10  * This Source Code Form is subject to the terms of the
11  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
12  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
14  /**
15  * @file           persistence_client_library_handle.h
16  * @ingroup        Persistence client library
17  * @author         Ingo Huerner
18  * @brief          Header of the persistence client library handle.
19  *                 Library provides an API to access persistent data
20  * @see            
21  */
22
23 #include "../include_protected/persistence_client_library_data_organization.h"
24 #include "../include_protected/persistence_client_library_rc_table.h"
25
26
27 /// key handle structure definition
28 typedef struct _PersistenceKeyHandle_s
29 {
30    PersistenceInfo_s info;          /// persistence info
31    char dbPath[DbPathMaxLen];       /// path to the database
32    char dbKey[DbKeyMaxLen];         /// database key
33    char resourceID[DbResIDMaxLen];  /// resourceID
34 }
35 PersistenceKeyHandle_s;
36
37
38 /// file handle structure definition
39 typedef struct _PersistenceFileHandle_s
40 {
41    PersistencePermission_e permission;    /// access permission read/write
42    int backupCreated;                     /// flag to indicate if a backup has already been created
43    char backupPath[DbPathMaxLen];         /// path to the backup file
44    char csumPath[DbPathMaxLen];           /// path to the checksum file
45 }
46 PersistenceFileHandle_s;
47
48
49 /// persistence key handle array
50 extern PersistenceKeyHandle_s gKeyHandleArray[MaxPersHandle];
51
52
53 /// persistence file handle array
54 extern PersistenceFileHandle_s gFileHandleArray[MaxPersHandle];
55
56
57 /// open file descriptor handle array
58 extern int gOpenFdArray[MaxPersHandle];
59
60
61 /**
62  * @brief get persistence handle
63  *
64  * @return a new handle or 0 if an error occured
65  */
66 int get_persistence_handle_idx(char* dbPath, char* key, PersistenceInfo_s* info);
67
68
69 /**
70  * @brief close persistence handle
71  *
72  * @param the handle to close
73  *
74  * @return error code
75  */
76 int set_persistence_handle_close_idx(int handle, char* dbPath, char* key, PersistenceInfo_s* info);
77
78
79
80
81 #endif /* PERSISTENCY_CLIENT_LIBRARY_HANDLE_H */
82