1 #ifndef PERSISTENCE_CLIENT_LIBRARY_HANDLE_H
2 #define PERSISTENCE_CLIENT_LIBRARY_HANDLE_H
4 /******************************************************************************
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 ******************************************************************************/
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
23 #include "persistence_client_library_data_organization.h"
25 #include <persComRct.h>
27 /// key handle structure definition
28 typedef struct _PersistenceKeyHandle_s
31 char resource_id[DbResIDMaxLen];
32 /// logical database id
38 } PersistenceKeyHandle_s;
41 /// file handle structure definition
42 typedef struct _PersistenceFileHandle_s
44 /// access permission read/write
45 PersistencePermission_e permission;
46 /// flag to indicate if a backup has already been created
48 /// path to the backup file
49 char backupPath[DbPathMaxLen];
50 /// path to the checksum file
51 char csumPath[DbPathMaxLen];
54 } PersistenceFileHandle_s;
56 /// open file descriptor handle array
57 extern int gOpenFdArray[MaxPersHandle];
60 extern int gOpenHandleArray[MaxPersHandle];
62 //----------------------------------------------------------------
63 //----------------------------------------------------------------
66 * @brief get persistence handle
68 * @return a new handle or 0 if an error occured or EPERS_MAXHANDLE if max no of handles is reached
70 int get_persistence_handle_idx();
74 * @brief close persistence handle
76 * @param handle to close
78 void set_persistence_handle_close_idx(int handle);
82 * @brief close open key handles
85 void close_all_persistence_handle();
87 //----------------------------------------------------------------
88 //----------------------------------------------------------------
91 * @brief set data to the key handle
93 * @param idx the index
94 * @param id the resource id
95 * @param ldbid the logical database id
96 * @param user_no the user identifier
97 * @param seat_no the seat number
99 * @return a positive value (0 or greather) or -1 on error
101 int set_key_handle_data(int idx, const char* id, unsigned int ldbid, unsigned int user_no, unsigned int seat_no);
105 * @brief set data to the key handle
107 * @param idx the index
108 * @param handleStruct the handle structure
110 * @return 0 on success, -1 on error
112 int get_key_handle_data(int idx, PersistenceKeyHandle_s* handleStruct);
116 * @brief initialize the key handle array to defined values
118 void init_key_handle_array();
122 * @brief set data to the key handle
124 * @param idx the index
127 void clear_key_handle_array(int idx);
129 //----------------------------------------------------------------
130 //----------------------------------------------------------------
133 * @brief set data to the key handle
135 * @param idx the index
136 * @param permission the permission (read/write, read only, write only)
137 * @param backupCreated 0 is a backup has not been created or 1 if a backup has been created
138 * @param backup path to the backup file
139 * @param csumPath the path to the checksum file
140 * @param filePath the path to the file
143 int set_file_handle_data(int idx, PersistencePermission_e permission, int backupCreated,
144 const char* backup, const char* csumPath, char* filePath);
148 * @brief set data to the key handle
150 * @param idx the index
152 * @return the file permission
154 int get_file_permission(int idx);
158 * @brief set data to the key handle
159 * @attention "N index check will be done"
161 * @param idx the index
163 * @return the path to the backup
165 char* get_file_backup_path(int idx);
169 * @brief get the file checksum path
170 * @attention "N index check will be done"
172 * @param idx the index
174 * @return the checksum path
176 char* get_file_checksum_path(int idx);
180 * @brief set the file backup status of the file
181 * @attention "No index check will be done"
183 * @param idx the index
184 * @param status the backup status, 0 backup has been created,
185 * 1 backup has not been created
187 void set_file_backup_status(int idx, int status);
191 * @brief get the backup status of the file
192 * @attention "No index check will be done"
194 * @param idx the index
196 * @return 0 if no backup has been created,
197 * 1 if backup has been created
199 int get_file_backup_status(int idx);
201 //----------------------------------------------------------------
202 //----------------------------------------------------------------
205 * @brief set data to the key handle
207 * @param idx the index
208 * @param permission the permission (read/write, read only, write only)
209 * @param backupCreated 0 is a backup has not been created or 1 if a backup has been created
210 * @param backup path to the backup file
211 * @param csumPath the path to the checksum file
212 * @param filePath the path to the file
215 int set_ossfile_handle_data(int idx, PersistencePermission_e permission, int backupCreated,
216 const char* backup, const char* csumPath, char* filePath);
220 * @brief set data to the key handle
222 * @param idx the index
224 * @return the file permission
226 int get_ossfile_permission(int idx);
230 * @brief get file backup path
231 * @attention "No index check will be done"
233 * @param idx the index
235 * @return the path to the backup
237 char* get_ossfile_backup_path(int idx);
241 * @brief get file path
242 * @attention "No index check will be done"
244 * @param idx the index
246 * @return the path to the backup
248 char* get_ossfile_file_path(int idx);
252 * @brief get the file checksum path
253 * @attention "No index check will be done"
255 * @param idx the index
257 * @return the checksum path
259 char* get_ossfile_checksum_path(int idx);
262 * @brief get the file checksum path
263 * @attention "No index check will be done"
265 * @param idx the index
266 * @param file pointer to the file and path
268 * @return the checksum path
270 void set_ossfile_file_path(int idx, char* file);
273 * @brief set the file backup status of the file
274 * @attention "No index check will be done"
276 * @param idx the index
277 * @param status the backup status, 0 backup has been created,
278 * 1 backup has not been created
280 void set_ossfile_backup_status(int idx, int status);
284 * @brief get the backup status of the file
285 * @attention "No index check will be done"
287 * @param idx the index
289 * @return 0 if no backup has been created,
290 * 1 if backup has been created
292 int get_ossfile_backup_status(int idx);
295 #endif /* PERSISTENCY_CLIENT_LIBRARY_HANDLE_H */