1 #ifndef PERSISTENCE_CLIENT_LIBRARY_CUSTOM_LOADER_H
2 #define PERSISTENCE_CLIENT_LIBRARY_CUSTOM_LOADER_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_custom_loader.h
16 * @ingroup Persistence client library
17 * @author Ingo Huerner
18 * @brief Header of the persistence client library custom library_loader.
22 #include "../include/persistence_client_custom.h"
25 /// enumerator used to identify the policy to manage the data
26 typedef enum _PersistenceCustomLibs_e
28 PersCustomLib_early = 0, /// predefined custom library for early persistence
29 PersCustomLib_secure = 1, /// predefined custom library for secure persistence
30 PersCustomLib_emergency = 2, /// predefined custom library for emengency persistence
31 PersCustomLib_HWinfo = 3, /// predefined custom library for hw information
32 PersCustomLib_Custom1 = 4, /// custom library 1
33 PersCustomLib_Custom2 = 5, /// custom library 2
34 PersCustomLib_Custom3 = 6, /// custom library 3
36 // insert new entries here ...
38 PersCustomLib_LastEntry /// last entry
40 } PersistenceCustomLibs_e;
43 /// enumerator fo custom library defines
44 enum _PersCustomLibDefines_e
46 PersCustomPathSize = 12
48 } PersCustomLibDefines_e;
52 /// structure definition for custom library functions
53 typedef struct _Pers_custom_functs_s
55 /// custom library handle
59 int (*custom_plugin_create_backup)(const char* backup_id);
61 /// custom library deinit function
62 int (*custom_plugin_deinit)();
64 /// custom delete function
65 int (*custom_plugin_delete_data)(const char* path);
68 int (*custom_plugin_get_backup)(char* backup_id, int size);
71 int (*custom_plugin_get_size)(const char* path);
73 /// custom get data function
74 int (*custom_plugin_get_data)(const char* path, char* buffer, int size);
76 /// custom close function
77 int (*custom_plugin_handle_close)(int handle);
79 /// custom get data function
80 int (*custom_plugin_handle_get_data)(int handle, char* buffer, int size);
82 /// custom open function
83 int (*custom_plugin_handle_open)(const char* path, int flag, int mode);
85 /// custom set data function
86 int (*custom_plugin_handle_set_data)(int handle, char* buffer, int size);
88 /// custom library init function
89 int (*custom_plugin_init)();
92 int (*custom_plugin_restore_backup)(const char* backup_id);
94 /// custom set data function
95 int (*custom_plugin_set_data)(const char* path, char* buffer, int size);
97 /// custom status notification function
98 int (*custom_plugin_get_status_notification_clbk)(plugin_callback_t pFunct);
101 int (*custom_plugin_handle_get_size)(int handle);
103 /// initialize plugin (non blocking)
104 int (*custom_plugin_init_async)(plugin_callback_async_t pfInitCompletedCB);
107 int (*custom_plugin_clear_all_data)(void);
110 int (*custom_plugin_sync)(void);
113 }Pers_custom_functs_s;
116 /// custom library functions array
117 Pers_custom_functs_s gPersCustomFuncs[PersCustomLib_LastEntry];
121 * @brief Translate a client library name into a id
123 * @param lib_name the library name
124 * @param substring indicator if a substring search is neccessary
126 * @return the library id or PersCustomLib_LastEntry if nothing found
128 PersistenceCustomLibs_e custom_client_name_to_id(const char* lib_name, int substring);
131 * @brief get the names of the custom libraries to load
133 * @return 0 for success or a negative value with the following errors:
136 int get_custom_libraries();
141 * @brief get the names of the custom libraries to load
143 * @param customLib the enumerator id identifying the custom library
144 * @param customFuncts function pointer array of loaded custom library functions
146 * @return 0 for success or a negative value with one of the following errors:
147 * EPERS_NOPLUGINFCNT EPERS_DLOPENERROR
150 int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s *customFuncts);
155 * @brief get the names of the custom libraries to load
157 * @return 0 for success orr a negative value with one of the following errors:
158 * EPERS_NOPLUGINFCNT EPERS_DLOPENERROR
160 int load_all_custom_libraries();
164 * @brief get the position in the array
166 * @param customLib the enumerator id identifying the custom library
168 * @return the array position or -1 if the position can't be found
170 int check_valid_idx(int idx);
175 * @brief get the custom library name form an index
177 * @return the name of the custom library ot NULL if invalid
179 char* get_custom_client_lib_name(int idx);
183 * @brief invalidate customer plugin function
185 void invalidate_custom_plugin(int idx);
188 #endif /* PERSISTENCE_CLIENT_LIBRARY_CUSTOM_LOADER_H */