1 /******************************************************************************
4 * Company XS Embedded GmbH
5 *****************************************************************************/
6 /******************************************************************************
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 ******************************************************************************/
26 * @file persistenceCustomLib_Demo.c
27 * @ingroup Persistency client library
28 * @author Ingo Huerner
29 * @brief Demo implementation of the persistence custom client library
37 #include "../include/persistence_client_custom.h"
40 * @brief close the given handle
42 * @param handle the handle to close
44 * @return positive value: successfully closed; negative value: error
47 int plugin_handle_close(int handle)
51 //printf("* * * * * plugin_close- handle: %d!\n", handle);
60 * @param path the path to the data to delete
62 * @return positive value: delete success; negative value: error
65 int plugin_delete_data(const char* path)
69 //printf("* * * * * plugin_delete_data - path: %s!\n", path);
78 * @param handle the handle returned from open
79 * @param buffer the buffer to store data
80 * @param size the number of bytes to get data
82 * @return positive value: size data read in bytes; negative value: error
85 int plugin_handle_get_data(int handle, char* buffer, int size)
88 //printf("plugin_handle_get_data: %s\n", LIBIDENT);
90 return snprintf(buffer, size, "Custom plugin -> plugin_get_data_handle: %s!", LIBIDENT);
95 * @param buffer the buffer to store data
96 * @param size the number of bytes to get data
98 * @return positive value: size data read in bytes; negative value: error
101 int plugin_get_data(const char* path, char* buffer, int size)
105 //printf("Custom plugin -> plugin_get_data: %s!\n", LIBIDENT);
107 return snprintf(buffer, size, "Custom plugin -> plugin_get_data: %s!", LIBIDENT);
113 * @brief initialize plugin
115 * @return positive value: init success; negative value: error
122 //printf("* * * * * plugin_init sync => %s!\n", LIBIDENT);
127 int plugin_init_async(plugin_callback_async_t pfInitCompletedCB)
131 //printf("* * * * * plugin_init_async => %s!\n", LIBIDENT);
138 * @brief deinitialize plugin
140 * @return positive value: init success; negative value: error
147 //printf("* * * * * plugin_deinit: %s!\n", LIBIDENT);
156 * @brief open a resource
158 * @param path the path to the resource to open
159 * @param flag open flags
160 * @param mode the open mode
162 * @return positive value: handle; negative value: error
165 int plugin_handle_open(const char* path, int flag, int mode)
169 //printf("* * * * * plugin_open - path: %s | flag: %d | mode: %d | plugin: %s!\n", path, flag, mode, LIBIDENT);
178 * @param handle the handle given by open
179 * @param buffer the data to write
180 * @param size the number of bytes to write
182 * @return positive size data set; negative value: error
185 int plugin_handle_set_data(int handle, char* buffer, int size)
189 //printf("* * * * * plugin_handle_set_data: %s!\n", LIBIDENT);
196 * @param buffer the data to write
197 * @param size the number of bytes to write
199 * @return positive size data set; negative value: error
202 int plugin_set_data(const char* path, char* buffer, int size)
206 //printf("* * * * * plugin_set_data: %s!\n", LIBIDENT);
213 * @brief typdef of callback function prototype
215 * @param status status identifier
216 * @param dataPtr data
218 typedef int (*plugin_callback_t) (int status, void* dataPtr);
222 * @brief registercallback for status notifications
224 * @param pFunct the callback
226 * @return positive value: register success; negative value error
228 int plugin_get_status_notification_clbk(plugin_callback_t pFunct)
232 //printf("* * * * * plugin_get_status_notification_clbk: %s!\n", LIBIDENT);
238 int plugin_handle_get_size(int handle)
242 //printf("* * * * * plugin_get_size_handle: %d | %s!\n", handle, LIBIDENT);
248 int plugin_get_size(const char* path)
252 //printf("* * * * * plugin_get_size: %s | %s!\n", path, LIBIDENT);
259 int plugin_create_backup(const char* backup_id)
263 printf("* * * * * plugin_create_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
269 int plugin_restore_backup(const char* backup_id)
273 printf("* * * * * plugin_restore_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
280 int plugin_get_backup(char* backup_id, int size)
284 printf("* * * * * plugin_get_backup: backup_id %s\n", backup_id);
290 int plugin_clear_all_data(void)
292 printf("plugin_clear_all_data\n");
297 int plugin_sync(void)
299 printf("plugin_sync\n");