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;
51 /// indicates the init method type
52 typedef enum PersInitType_e_
55 Init_Asynchronous = 1,
60 /// indicates the plugin loading type
61 typedef enum PersLoadingType_e_
63 LoadType_PclInit = 0, // load plugin during pclInitLibrary function
64 LoadType_OnDemand = 1, // load the pluing on demand, when a plugin function will be requested the first time.
70 /// structure definition for custom library functions
71 typedef struct _Pers_custom_functs_s
73 /// custom library handle
77 int (*custom_plugin_create_backup)(const char* backup_id);
79 /// custom library deinit function
80 int (*custom_plugin_deinit)();
82 /// custom delete function
83 int (*custom_plugin_delete_data)(const char* path);
86 int (*custom_plugin_get_backup)(char* backup_id, int size);
89 int (*custom_plugin_get_size)(const char* path);
91 /// custom get data function
92 int (*custom_plugin_get_data)(const char* path, char* buffer, int size);
94 /// custom close function
95 int (*custom_plugin_handle_close)(int handle);
97 /// custom get data function
98 int (*custom_plugin_handle_get_data)(int handle, char* buffer, int size);
100 /// custom open function
101 int (*custom_plugin_handle_open)(const char* path, int flag, int mode);
103 /// custom set data function
104 int (*custom_plugin_handle_set_data)(int handle, char* buffer, int size);
106 /// custom library init function
107 int (*custom_plugin_init)();
110 int (*custom_plugin_restore_backup)(const char* backup_id);
112 /// custom set data function
113 int (*custom_plugin_set_data)(const char* path, char* buffer, int size);
115 /// custom status notification function
116 int (*custom_plugin_get_status_notification_clbk)(plugin_callback_t pFunct);
119 int (*custom_plugin_handle_get_size)(int handle);
121 /// initialize plugin (non blocking)
122 int (*custom_plugin_init_async)(plugin_callback_async_t pfInitCompletedCB);
125 int (*custom_plugin_clear_all_data)(void);
128 int (*custom_plugin_sync)(void);
131 }Pers_custom_functs_s;
134 /// custom library functions array
135 Pers_custom_functs_s gPersCustomFuncs[PersCustomLib_LastEntry];
139 * @brief Translate a client library name into a id
141 * @param lib_name the library name
142 * @param substring indicator if a substring search is neccessary
144 * @return the library id or PersCustomLib_LastEntry if nothing found
146 PersistenceCustomLibs_e custom_client_name_to_id(const char* lib_name, int substring);
149 * @brief get the names of the custom libraries to load
151 * @return 0 for success or a negative value with the following errors:
154 int get_custom_libraries();
159 * @brief get the names of the custom libraries to load
161 * @param customLib the enumerator id identifying the custom library
162 * @param customFuncts function pointer array of loaded custom library functions
164 * @return 0 for success or a negative value with one of the following errors:
165 * EPERS_NOPLUGINFCNT EPERS_DLOPENERROR
168 int load_custom_library(PersistenceCustomLibs_e customLib, Pers_custom_functs_s *customFuncts);
172 * @brief get the position in the array
174 * @param customLib the enumerator id identifying the custom library
176 * @return the array position or -1 if the position can't be found
178 int check_valid_idx(int idx);
183 * @brief get the custom library name form an index
185 * @return the name of the custom library ot NULL if invalid
187 char* get_custom_client_lib_name(int idx);
191 * @brief invalidate customer plugin function
193 void invalidate_custom_plugin(int idx);
197 PersLoadingType_e getCustomLoadingType(int i);
199 PersInitType_e getCustomInitType(int i);
201 #endif /* PERSISTENCE_CLIENT_LIBRARY_CUSTOM_LOADER_H */