summaryrefslogtreecommitdiff
path: root/test/persistence_test_customlib.c
blob: 47dab637402372a0348b056544d7f7ed1ff6f193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/******************************************************************************
 * Project         Persistency
 * (c) copyright   2012
 * Company         XS Embedded GmbH
 *****************************************************************************/
/******************************************************************************
   Permission is hereby granted, free of charge, to any person obtaining 
   a copy of this software and associated documentation files (the "Software"), 
   to deal in the Software without restriction, including without limitation 
   the rights to use, copy, modify, merge, publish, distribute, sublicense, 
   and/or sell copies of the Software, and to permit persons to whom the 
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included 
   in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
 /**
 * @file           persistenceCustomLib_Demo.c
 * @ingroup        Persistency client library
 * @author         Ingo Huerner
 * @brief          Demo implementation of the persistence custom client library
 * @see            
 */


#include <stdio.h>
#include <string.h>

#include "../include/persistence_client_custom.h"

#define PERS_ORG_RCT_NAME "resource-table-cfg.itz"
#define PERS_ORG_RCT_NAME_ "/"PERS_ORG_RCT_NAME
const char* gResTableCfg = PERS_ORG_RCT_NAME_;

#define PERS_ORG_LOCAL_CONFIGURABLE_DEFAULT_DB_NAME "configurable-default-data.itz"
#define PERS_ORG_LOCAL_CONFIGURABLE_DEFAULT_DB_NAME_ "/"PERS_ORG_LOCAL_CONFIGURABLE_DEFAULT_DB_NAME
const char* gLocalConfigurableDefault = PERS_ORG_LOCAL_CONFIGURABLE_DEFAULT_DB_NAME_;

#define PERS_ORG_NODE_FOLDER_NAME "node"
#define PERS_ORG_NODE_FOLDER_NAME_ "/" PERS_ORG_NODE_FOLDER_NAME
const char* gNode = PERS_ORG_NODE_FOLDER_NAME_;

#define PERS_ORG_LOCAL_CACHE_DB_NAME "cached.itz"
#define PERS_ORG_LOCAL_CACHE_DB_NAME_ "/"PERS_ORG_LOCAL_CACHE_DB_NAME
const char* gLocalCached = PERS_ORG_LOCAL_CACHE_DB_NAME_;

#define PERS_ORG_LOCAL_FACTORY_DEFAULT_DB_NAME "default-data.itz"
#define PERS_ORG_LOCAL_FACTORY_DEFAULT_DB_NAME_ "/"PERS_ORG_LOCAL_FACTORY_DEFAULT_DB_NAME
const char* gLocalFactoryDefault = PERS_ORG_LOCAL_FACTORY_DEFAULT_DB_NAME_;

#define PERS_ORG_SEAT_FOLDER_NAME "seat"
#define PERS_ORG_SEAT_FOLDER_NAME_ "/"PERS_ORG_SEAT_FOLDER_NAME "/"
const char* gSeat = PERS_ORG_SEAT_FOLDER_NAME_;

#define PERS_ORG_LOCAL_WT_DB_NAME "wt.itz"
#define PERS_ORG_LOCAL_WT_DB_NAME_ "/" PERS_ORG_LOCAL_WT_DB_NAME;
const char* gLocalWt = PERS_ORG_LOCAL_WT_DB_NAME_;

#define PERS_ORG_USER_FOLDER_NAME "user"
#define PERS_ORG_USER_FOLDER_NAME_ "/"PERS_ORG_USER_FOLDER_NAME "/"
const char* gUser = PERS_ORG_USER_FOLDER_NAME_;

/**
 * @brief close the given handle
 *
 * @param handle the handle to close
 *
 * @return positive value: successfully closed; negative value: error
 */
// OK
int plugin_handle_close(int handle)
{
   int rval = 99;

   (void)handle;

   //printf("* * * * * plugin_close- handle: %d!\n", handle);

   return rval;
}


/**
 * @brief delete data
 *
 * @param path the path to the data to delete
 *
 * @return positive value: delete success; negative value: error
 */
// OK
int plugin_delete_data(const char* path)
{
   int rval = 13579;
   (void)path;

   //printf("* * * * * plugin_delete_data - path: %s!\n", path);

   return rval;
}


/**
 * @brief get data
 *
 * @param handle the handle returned from open
 * @param buffer the buffer to store data
 * @param size the number of bytes to get data
 *
 * @return positive value: size data read in bytes; negative value: error
 */
// OK
int plugin_handle_get_data(int handle, char* buffer, int size)
{
   //int strSize = 99;
   //printf("plugin_handle_get_data: %s\n", LIBIDENT);
   (void)handle;

   return snprintf(buffer, (size_t)size, "Custom plugin -> plugin_get_data_handle: %s!", LIBIDENT);
}
/**
 * @brief get data
 *
 * @param buffer the buffer to store data
 * @param size the number of bytes to get data
 *
 * @return positive value: size data read in bytes; negative value: error
 */
// OK
int plugin_get_data(const char* path, char* buffer, int size)
{
   //int strSize = 99;

   //printf("Custom plugin -> plugin_get_data: %s!\n", LIBIDENT);
   (void)path;
   (void)buffer;
   (void)size;

   return snprintf(buffer, (size_t)size, "Custom plugin -> plugin_get_data: %s!", LIBIDENT);
}



/**
 * @brief initialize plugin
 *
 * @return positive value: init success; negative value: error
 */
// OK
int plugin_init()
{
   //int rval = 99;

   //printf("* * * * * plugin_init sync  => %s!\n", LIBIDENT);

   return 1;
}

int plugin_init_async(plugin_callback_async_t pfInitCompletedCB)
{
   //int rval = -1;

	//printf("* * * * * plugin_init_async => %s!\n", LIBIDENT);
   (void)pfInitCompletedCB;

	return 1;
}


/**
 * @brief deinitialize plugin
 *
 * @return positive value: init success; negative value: error
 */
// OK
int plugin_deinit()
{
   int rval = 99;

   //printf("* * * * * plugin_deinit: %s!\n", LIBIDENT);

   return rval;
}




/**
 * @brief open a resource
 *
 * @param path the path to the resource to open
 * @param flag open flags
 * @param mode the open mode
 *
 * @return positive value: handle; negative value: error
 */
// OK
int plugin_handle_open(const char* path, int flag, int mode)
{
   int rval = 100;

   //printf("* * * * * plugin_open - path: %s | flag: %d | mode: %d | plugin: %s!\n", path, flag, mode, LIBIDENT);
   (void)path;
   (void)flag;
   (void)mode;

   return rval;
}


/**
 * @brief set data
 *
 * @param handle the handle given by open
 * @param buffer the data to write
 * @param size the number of bytes to write
 *
 * @return positive size data set; negative value: error
 */
// OK
int plugin_handle_set_data(int handle, char* buffer, int size)
{
   int rval = 123654;

   //printf("* * * * * plugin_handle_set_data: %s!\n", LIBIDENT);
   (void)handle;
   (void)buffer;
   (void)size;

   return rval;
}
/**
 * @brief set data
 *
 * @param buffer the data to write
 * @param size the number of bytes to write
 *
 * @return positive size data set; negative value: error
 */
// OK
int plugin_set_data(const char* path, char* buffer, int size)
{
   int rval = 321456;

   //printf("* * * * * plugin_set_data: %s!\n", LIBIDENT);
   (void)path;
   (void)buffer;
   (void)size;

   return rval;
}


/**
 * @brief typdef of callback function prototype
 *
 * @param status status identifier
 * @param dataPtr data
 */
typedef int (*plugin_callback_t) (int status, void* dataPtr);


/**
 * @brief registercallback for status notifications
 *
 * @param pFunct the callback
 *
 * @return positive value: register success; negative value error
 */
int plugin_get_status_notification_clbk(plugin_callback_t pFunct)
{
   int rval = 99;

   //printf("* * * * * plugin_get_status_notification_clbk: %s!\n", LIBIDENT);
   (void)pFunct;

   return rval;
}


int plugin_handle_get_size(int handle)
{
   int rval = 11223344;

   //printf("* * * * * plugin_get_size_handle: %d | %s!\n", handle, LIBIDENT);
   (void)handle;

   return rval;
}

// OK
int plugin_get_size(const char* path)
{
   int rval = 44332211;

   //printf("* * * * * plugin_get_size: %s | %s!\n", path, LIBIDENT);
   (void)path;

   return rval;
}


// OK
int plugin_create_backup(const char* backup_id)
{
   int rval = -1;

   printf("* * * * * plugin_create_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
   (void)backup_id;

   return rval;
}

// OK
int plugin_restore_backup(const char* backup_id)
{
   int rval = -1;

   printf("* * * * * plugin_restore_backup: backup_id %s | %s!\n", backup_id, LIBIDENT);
   (void)backup_id;

   return rval;

}

// OK
int plugin_get_backup(char* backup_id, int size)
{
   int rval = -1;

   printf("* * * * * plugin_get_backup: backup_id %s\n", backup_id);
   (void)backup_id;
   (void)size;

   return rval;
}


int plugin_clear_all_data(void)
{
   printf("plugin_clear_all_data\n");
   return 1;
}


int plugin_sync(void)
{
   printf("plugin_sync\n");
   return 1;
}