Fixed a problem with sporadic blocking of pclDeinitLibrary
[profile/ivi/persistence-client-library.git] / test / persistence_test_customlib.c
1 /******************************************************************************
2  * Project         Persistency
3  * (c) copyright   2012
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:
13
14    The above copyright notice and this permission notice shall be included 
15    in all copies or substantial portions of the Software.
16
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 ******************************************************************************/
25  /**
26  * @file           persistenceCustomLib_Demo.c
27  * @ingroup        Persistency client library
28  * @author         Ingo Huerner
29  * @brief          Demo implementation of the persistence custom client library
30  * @see            
31  */
32
33
34 #include <stdio.h>
35 #include <string.h>
36
37 #include "../include/persistence_client_custom.h"
38
39 /**
40  * @brief close the given handle
41  *
42  * @param handle the handle to close
43  *
44  * @return positive value: successfully closed; negative value: error
45  */
46 // OK
47 int plugin_handle_close(int handle)
48 {
49    int rval = 99;
50
51    //printf("* * * * * plugin_close- handle: %d!\n", handle);
52
53    return rval;
54 }
55
56
57 /**
58  * @brief delete data
59  *
60  * @param path the path to the data to delete
61  *
62  * @return positive value: delete success; negative value: error
63  */
64 // OK
65 int plugin_delete_data(const char* path)
66 {
67    int rval = 99;
68
69    //printf("* * * * * plugin_delete_data - path: %s!\n", path);
70
71    return rval;
72 }
73
74
75 /**
76  * @brief get data
77  *
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
81  *
82  * @return positive value: size data read in bytes; negative value: error
83  */
84 // OK
85 int plugin_handle_get_data(int handle, char* buffer, int size)
86 {
87    //int strSize = 99;
88    //printf("plugin_handle_get_data: %s\n", LIBIDENT);
89
90    return snprintf(buffer, size, "Custom plugin -> plugin_get_data_handle: %s!", LIBIDENT);
91 }
92 /**
93  * @brief get data
94  *
95  * @param buffer the buffer to store data
96  * @param size the number of bytes to get data
97  *
98  * @return positive value: size data read in bytes; negative value: error
99  */
100 // OK
101 int plugin_get_data(const char* path, char* buffer, int size)
102 {
103    //int strSize = 99;
104
105    //printf("Custom plugin -> plugin_get_data: %s!\n", LIBIDENT);
106
107    return snprintf(buffer, size, "Custom plugin -> plugin_get_data: %s!", LIBIDENT);
108 }
109
110
111
112 /**
113  * @brief initialize plugin
114  *
115  * @return positive value: init success; negative value: error
116  */
117 // OK
118 int plugin_init()
119 {
120    //int rval = 99;
121
122    //printf("* * * * * plugin_init sync  => %s!\n", LIBIDENT);
123
124    return 1;
125 }
126
127 int plugin_init_async(plugin_callback_async_t pfInitCompletedCB)
128 {
129    //int rval = -1;
130
131         //printf("* * * * * plugin_init_async => %s!\n", LIBIDENT);
132
133         return 1;
134 }
135
136
137 /**
138  * @brief deinitialize plugin
139  *
140  * @return positive value: init success; negative value: error
141  */
142 // OK
143 int plugin_deinit()
144 {
145    int rval = 99;
146
147    //printf("* * * * * plugin_deinit: %s!\n", LIBIDENT);
148
149    return rval;
150 }
151
152
153
154
155 /**
156  * @brief open a resource
157  *
158  * @param path the path to the resource to open
159  * @param flag open flags
160  * @param mode the open mode
161  *
162  * @return positive value: handle; negative value: error
163  */
164 // OK
165 int plugin_handle_open(const char* path, int flag, int mode)
166 {
167    int rval = 100;
168
169    //printf("* * * * * plugin_open - path: %s | flag: %d | mode: %d | plugin: %s!\n", path, flag, mode, LIBIDENT);
170
171    return rval;
172 }
173
174
175 /**
176  * @brief set data
177  *
178  * @param handle the handle given by open
179  * @param buffer the data to write
180  * @param size the number of bytes to write
181  *
182  * @return positive size data set; negative value: error
183  */
184 // OK
185 int plugin_handle_set_data(int handle, char* buffer, int size)
186 {
187    int rval = 99;
188
189    //printf("* * * * * plugin_handle_set_data: %s!\n", LIBIDENT);
190
191    return rval;
192 }
193 /**
194  * @brief set data
195  *
196  * @param buffer the data to write
197  * @param size the number of bytes to write
198  *
199  * @return positive size data set; negative value: error
200  */
201 // OK
202 int plugin_set_data(const char* path, char* buffer, int size)
203 {
204    int rval = 99;
205
206    //printf("* * * * * plugin_set_data: %s!\n", LIBIDENT);
207
208    return rval;
209 }
210
211
212 /**
213  * @brief typdef of callback function prototype
214  *
215  * @param status status identifier
216  * @param dataPtr data
217  */
218 typedef int (*plugin_callback_t) (int status, void* dataPtr);
219
220
221 /**
222  * @brief registercallback for status notifications
223  *
224  * @param pFunct the callback
225  *
226  * @return positive value: register success; negative value error
227  */
228 int plugin_get_status_notification_clbk(plugin_callback_t pFunct)
229 {
230    int rval = 99;
231
232    //printf("* * * * * plugin_get_status_notification_clbk: %s!\n", LIBIDENT);
233
234    return rval;
235 }
236
237
238 int plugin_handle_get_size(int handle)
239 {
240    int rval = 99;
241
242    //printf("* * * * * plugin_get_size_handle: %d | %s!\n", handle, LIBIDENT);
243
244    return rval;
245 }
246
247 // OK
248 int plugin_get_size(const char* path)
249 {
250    int rval = 99;
251
252    //printf("* * * * * plugin_get_size: %s | %s!\n", path, LIBIDENT);
253
254    return rval;
255 }
256
257
258 // OK
259 int plugin_create_backup(const char* backup_id)
260 {
261    int rval = -1;
262
263    printf("* * * * * plugin_create_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
264
265    return rval;
266 }
267
268 // OK
269 int plugin_restore_backup(const char* backup_id)
270 {
271    int rval = -1;
272
273    printf("* * * * * plugin_restore_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
274
275    return rval;
276
277 }
278
279 // OK
280 int plugin_get_backup(char* backup_id, int size)
281 {
282    int rval = -1;
283
284    printf("* * * * * plugin_get_backup: backup_id %s\n", backup_id);
285
286    return rval;
287 }
288
289
290 int plugin_clear_all_data(void)
291 {
292    printf("plugin_clear_all_data\n");
293    return 1;
294 }
295
296
297 int plugin_sync(void)
298 {
299    printf("plugin_sync\n");
300    return 1;
301 }
302
303
304