summaryrefslogtreecommitdiff
path: root/legacy/eet/src/examples
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
commitf7019f134dd8e8ae830eb1d39fb8570c74b730e9 (patch)
tree6fc137cbc4e6505629d2210cf11ace757d162490 /legacy/eet/src/examples
parent55d01901859bb2fcca1befeb1011e204d271d59f (diff)
formatting. <- uncrustify
SVN revision: 50698
Diffstat (limited to 'legacy/eet/src/examples')
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor.c167
-rw-r--r--legacy/eet/src/examples/eet-data-nested.c70
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c50
3 files changed, 144 insertions, 143 deletions
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor.c b/legacy/eet/src/examples/eet-data-file_descriptor.c
index a917e1d58b..70fba7b1e1 100644
--- a/legacy/eet/src/examples/eet-data-file_descriptor.c
+++ b/legacy/eet/src/examples/eet-data-file_descriptor.c
@@ -9,9 +9,9 @@
9// complex real-world structures based on elmdentica database 9// complex real-world structures based on elmdentica database
10typedef struct 10typedef struct
11{ 11{
12 const char *screen_name; 12 const char * screen_name;
13 const char *name; 13 const char * name;
14 const char *message; 14 const char * message;
15 unsigned int id; 15 unsigned int id;
16 unsigned int status_id; 16 unsigned int status_id;
17 unsigned int date; 17 unsigned int date;
@@ -20,22 +20,22 @@ typedef struct
20 20
21typedef struct 21typedef struct
22{ 22{
23 const char *dm_to; 23 const char * dm_to;
24 const char *message; 24 const char * message;
25} My_Post; 25} My_Post;
26 26
27typedef struct 27typedef struct
28{ 28{
29 unsigned int id; 29 unsigned int id;
30 const char *name; 30 const char * name;
31 Eina_List *messages; 31 Eina_List * messages;
32 Eina_List *posts; 32 Eina_List * posts;
33} My_Account; 33} My_Account;
34 34
35typedef struct 35typedef struct
36{ 36{
37 unsigned int version; // it is recommended to use versioned configuration! 37 unsigned int version; // it is recommended to use versioned configuration!
38 Eina_List *accounts; 38 Eina_List * accounts;
39} My_Cache; 39} My_Cache;
40 40
41// string that represents the entry in eet file, you might like to have 41// string that represents the entry in eet file, you might like to have
@@ -46,14 +46,14 @@ static const char MY_CACHE_FILE_ENTRY[] = "cache";
46// keep the descriptor static global, so it can be 46// keep the descriptor static global, so it can be
47// shared by different functions (load/save) of this and only this 47// shared by different functions (load/save) of this and only this
48// file. 48// file.
49static Eet_Data_Descriptor *_my_cache_descriptor; 49static Eet_Data_Descriptor * _my_cache_descriptor;
50static Eet_Data_Descriptor *_my_account_descriptor; 50static Eet_Data_Descriptor * _my_account_descriptor;
51static Eet_Data_Descriptor *_my_message_descriptor; 51static Eet_Data_Descriptor * _my_message_descriptor;
52static Eet_Data_Descriptor *_my_post_descriptor; 52static Eet_Data_Descriptor * _my_post_descriptor;
53 53
54// keep file handle alive, so mmap()ed strings are all alive as well 54// keep file handle alive, so mmap()ed strings are all alive as well
55static Eet_File *_my_cache_file = NULL; 55static Eet_File * _my_cache_file = NULL;
56static Eet_Dictionary *_my_cache_dict = NULL; 56static Eet_Dictionary * _my_cache_dict = NULL;
57 57
58static void 58static void
59_my_cache_descriptor_init(void) 59_my_cache_descriptor_init(void)
@@ -78,8 +78,8 @@ _my_cache_descriptor_init(void)
78 // Describe the members to be saved: 78 // Describe the members to be saved:
79 // Use a temporary macro so we don't type a lot, also avoid errors: 79 // Use a temporary macro so we don't type a lot, also avoid errors:
80 80
81#define ADD_BASIC(member, eet_type) \ 81#define ADD_BASIC(member, eet_type)\
82 EET_DATA_DESCRIPTOR_ADD_BASIC \ 82 EET_DATA_DESCRIPTOR_ADD_BASIC\
83 (_my_message_descriptor, My_Message, # member, member, eet_type) 83 (_my_message_descriptor, My_Message, # member, member, eet_type)
84 ADD_BASIC(screen_name, EET_T_STRING); 84 ADD_BASIC(screen_name, EET_T_STRING);
85 ADD_BASIC(name, EET_T_STRING); 85 ADD_BASIC(name, EET_T_STRING);
@@ -90,15 +90,15 @@ _my_cache_descriptor_init(void)
90 ADD_BASIC(timeline, EET_T_UINT); 90 ADD_BASIC(timeline, EET_T_UINT);
91#undef ADD_BASIC 91#undef ADD_BASIC
92 92
93#define ADD_BASIC(member, eet_type) \ 93#define ADD_BASIC(member, eet_type)\
94 EET_DATA_DESCRIPTOR_ADD_BASIC \ 94 EET_DATA_DESCRIPTOR_ADD_BASIC\
95 (_my_post_descriptor, My_Post, # member, member, eet_type) 95 (_my_post_descriptor, My_Post, # member, member, eet_type)
96 ADD_BASIC(dm_to, EET_T_STRING); 96 ADD_BASIC(dm_to, EET_T_STRING);
97 ADD_BASIC(message, EET_T_STRING); 97 ADD_BASIC(message, EET_T_STRING);
98#undef ADD_BASIC 98#undef ADD_BASIC
99 99
100#define ADD_BASIC(member, eet_type) \ 100#define ADD_BASIC(member, eet_type)\
101 EET_DATA_DESCRIPTOR_ADD_BASIC \ 101 EET_DATA_DESCRIPTOR_ADD_BASIC\
102 (_my_account_descriptor, My_Account, # member, member, eet_type) 102 (_my_account_descriptor, My_Account, # member, member, eet_type)
103 ADD_BASIC(name, EET_T_STRING); 103 ADD_BASIC(name, EET_T_STRING);
104 ADD_BASIC(id, EET_T_UINT); 104 ADD_BASIC(id, EET_T_UINT);
@@ -111,8 +111,8 @@ _my_cache_descriptor_init(void)
111 (_my_account_descriptor, My_Account, "posts", posts, 111 (_my_account_descriptor, My_Account, "posts", posts,
112 _my_post_descriptor); 112 _my_post_descriptor);
113 113
114#define ADD_BASIC(member, eet_type) \ 114#define ADD_BASIC(member, eet_type)\
115 EET_DATA_DESCRIPTOR_ADD_BASIC \ 115 EET_DATA_DESCRIPTOR_ADD_BASIC\
116 (_my_cache_descriptor, My_Cache, # member, member, eet_type) 116 (_my_cache_descriptor, My_Cache, # member, member, eet_type)
117 ADD_BASIC(version, EET_T_UINT); 117 ADD_BASIC(version, EET_T_UINT);
118#undef ADD_BASIC 118#undef ADD_BASIC
@@ -120,7 +120,7 @@ _my_cache_descriptor_init(void)
120 EET_DATA_DESCRIPTOR_ADD_LIST 120 EET_DATA_DESCRIPTOR_ADD_LIST
121 (_my_cache_descriptor, My_Cache, "accounts", accounts, 121 (_my_cache_descriptor, My_Cache, "accounts", accounts,
122 _my_account_descriptor); 122 _my_account_descriptor);
123} 123} /* _my_cache_descriptor_init */
124 124
125static void 125static void
126_my_cache_descriptor_shutdown(void) 126_my_cache_descriptor_shutdown(void)
@@ -129,12 +129,12 @@ _my_cache_descriptor_shutdown(void)
129 eet_data_descriptor_free(_my_account_descriptor); 129 eet_data_descriptor_free(_my_account_descriptor);
130 eet_data_descriptor_free(_my_message_descriptor); 130 eet_data_descriptor_free(_my_message_descriptor);
131 eet_data_descriptor_free(_my_post_descriptor); 131 eet_data_descriptor_free(_my_post_descriptor);
132} 132} /* _my_cache_descriptor_shutdown */
133 133
134// need to check if the pointer came from mmaped area in eet_dictionary 134// need to check if the pointer came from mmaped area in eet_dictionary
135// or it was allocated with eina_stringshare_add() 135// or it was allocated with eina_stringshare_add()
136static void 136static void
137_eet_string_free(const char *str) 137_eet_string_free(const char * str)
138{ 138{
139 if (!str) 139 if (!str)
140 return; 140 return;
@@ -143,12 +143,12 @@ _eet_string_free(const char *str)
143 return; 143 return;
144 144
145 eina_stringshare_del(str); 145 eina_stringshare_del(str);
146} 146} /* _eet_string_free */
147 147
148static My_Message * 148static My_Message *
149_my_message_new(const char *message) 149_my_message_new(const char * message)
150{ 150{
151 My_Message *msg = calloc(1, sizeof(My_Message)); 151 My_Message * msg = calloc(1, sizeof(My_Message));
152 if (!msg) 152 if (!msg)
153 { 153 {
154 fprintf(stderr, "ERROR: could not calloc My_Message\n"); 154 fprintf(stderr, "ERROR: could not calloc My_Message\n");
@@ -157,21 +157,21 @@ _my_message_new(const char *message)
157 157
158 msg->message = eina_stringshare_add(message); 158 msg->message = eina_stringshare_add(message);
159 return msg; 159 return msg;
160} 160} /* _my_message_new */
161 161
162static void 162static void
163_my_message_free(My_Message *msg) 163_my_message_free(My_Message * msg)
164{ 164{
165 _eet_string_free(msg->screen_name); 165 _eet_string_free(msg->screen_name);
166 _eet_string_free(msg->name); 166 _eet_string_free(msg->name);
167 _eet_string_free(msg->message); 167 _eet_string_free(msg->message);
168 free(msg); 168 free(msg);
169} 169} /* _my_message_free */
170 170
171static My_Post * 171static My_Post *
172_my_post_new(const char *message) 172_my_post_new(const char * message)
173{ 173{
174 My_Post *post = calloc(1, sizeof(My_Post)); 174 My_Post * post = calloc(1, sizeof(My_Post));
175 if (!post) 175 if (!post)
176 { 176 {
177 fprintf(stderr, "ERROR: could not calloc My_Post\n"); 177 fprintf(stderr, "ERROR: could not calloc My_Post\n");
@@ -180,20 +180,20 @@ _my_post_new(const char *message)
180 180
181 post->message = eina_stringshare_add(message); 181 post->message = eina_stringshare_add(message);
182 return post; 182 return post;
183} 183} /* _my_post_new */
184 184
185static void 185static void
186_my_post_free(My_Post *post) 186_my_post_free(My_Post * post)
187{ 187{
188 _eet_string_free(post->dm_to); 188 _eet_string_free(post->dm_to);
189 _eet_string_free(post->message); 189 _eet_string_free(post->message);
190 free(post); 190 free(post);
191} 191} /* _my_post_free */
192 192
193static My_Account * 193static My_Account *
194_my_account_new(const char *name) 194_my_account_new(const char * name)
195{ 195{
196 My_Account *acc = calloc(1, sizeof(My_Account)); 196 My_Account * acc = calloc(1, sizeof(My_Account));
197 if (!acc) 197 if (!acc)
198 { 198 {
199 fprintf(stderr, "ERROR: could not calloc My_Account\n"); 199 fprintf(stderr, "ERROR: could not calloc My_Account\n");
@@ -202,13 +202,13 @@ _my_account_new(const char *name)
202 202
203 acc->name = eina_stringshare_add(name); 203 acc->name = eina_stringshare_add(name);
204 return acc; 204 return acc;
205} 205} /* _my_account_new */
206 206
207static void 207static void
208_my_account_free(My_Account *acc) 208_my_account_free(My_Account * acc)
209{ 209{
210 My_Message *m; 210 My_Message * m;
211 My_Post *p; 211 My_Post * p;
212 212
213 _eet_string_free(acc->name); 213 _eet_string_free(acc->name);
214 214
@@ -219,12 +219,12 @@ _my_account_free(My_Account *acc)
219 _my_post_free(p); 219 _my_post_free(p);
220 220
221 free(acc); 221 free(acc);
222} 222} /* _my_account_free */
223 223
224static My_Cache * 224static My_Cache *
225_my_cache_new(void) 225_my_cache_new(void)
226{ 226{
227 My_Cache *my_cache = calloc(1, sizeof(My_Cache)); 227 My_Cache * my_cache = calloc(1, sizeof(My_Cache));
228 if (!my_cache) 228 if (!my_cache)
229 { 229 {
230 fprintf(stderr, "ERROR: could not calloc My_Cache\n"); 230 fprintf(stderr, "ERROR: could not calloc My_Cache\n");
@@ -233,34 +233,34 @@ _my_cache_new(void)
233 233
234 my_cache->version = 1; 234 my_cache->version = 1;
235 return my_cache; 235 return my_cache;
236} 236} /* _my_cache_new */
237 237
238static void 238static void
239_my_cache_free(My_Cache *my_cache) 239_my_cache_free(My_Cache * my_cache)
240{ 240{
241 My_Account *acc; 241 My_Account * acc;
242 EINA_LIST_FREE(my_cache->accounts, acc) 242 EINA_LIST_FREE(my_cache->accounts, acc)
243 _my_account_free(acc); 243 _my_account_free(acc);
244 free(my_cache); 244 free(my_cache);
245} 245} /* _my_cache_free */
246 246
247static My_Account * 247static My_Account *
248_my_cache_account_find(My_Cache *my_cache, const char *name) 248_my_cache_account_find(My_Cache * my_cache, const char * name)
249{ 249{
250 My_Account *acc; 250 My_Account * acc;
251 Eina_List *l; 251 Eina_List * l;
252 EINA_LIST_FOREACH(my_cache->accounts, l, acc) 252 EINA_LIST_FOREACH(my_cache->accounts, l, acc)
253 if (strcmp(acc->name, name) == 0) 253 if (strcmp(acc->name, name) == 0)
254 return acc; 254 return acc;
255 255
256 return NULL; 256 return NULL;
257} 257} /* _my_cache_account_find */
258 258
259static My_Cache * 259static My_Cache *
260_my_cache_load(const char *filename) 260_my_cache_load(const char * filename)
261{ 261{
262 My_Cache *my_cache; 262 My_Cache * my_cache;
263 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 263 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
264 if (!ef) 264 if (!ef)
265 { 265 {
266 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 266 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -290,13 +290,13 @@ _my_cache_load(const char *filename)
290 _my_cache_dict = eet_dictionary_get(ef); 290 _my_cache_dict = eet_dictionary_get(ef);
291 291
292 return my_cache; 292 return my_cache;
293} 293} /* _my_cache_load */
294 294
295static Eina_Bool 295static Eina_Bool
296_my_cache_save(const My_Cache *my_cache, const char *filename) 296_my_cache_save(const My_Cache * my_cache, const char * filename)
297{ 297{
298 char tmp[PATH_MAX]; 298 char tmp[PATH_MAX];
299 Eet_File *ef; 299 Eet_File * ef;
300 Eina_Bool ret; 300 Eina_Bool ret;
301 unsigned int i, len; 301 unsigned int i, len;
302 struct stat st; 302 struct stat st;
@@ -343,13 +343,13 @@ _my_cache_save(const My_Cache *my_cache, const char *filename)
343 } 343 }
344 344
345 return ret; 345 return ret;
346} 346} /* _my_cache_save */
347 347
348int main(int argc, char *argv[]) 348int main(int argc, char * argv[])
349{ 349{
350 My_Cache *my_cache; 350 My_Cache * my_cache;
351 const Eina_List *l_acc; 351 const Eina_List * l_acc;
352 My_Account *acc; 352 My_Account * acc;
353 int ret = 0; 353 int ret = 0;
354 354
355 if (argc < 3) 355 if (argc < 3)
@@ -387,7 +387,7 @@ int main(int argc, char *argv[])
387 { 387 {
388 if (argc == 5) 388 if (argc == 5)
389 { 389 {
390 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 390 My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
391 if (!acc) 391 if (!acc)
392 { 392 {
393 acc = _my_account_new(argv[4]); 393 acc = _my_account_new(argv[4]);
@@ -399,7 +399,7 @@ int main(int argc, char *argv[])
399 argv[4]); 399 argv[4]);
400 } 400 }
401 else 401 else
402 fprintf(stderr, 402 fprintf(stderr,
403 "ERROR: wrong number of parameters (%d).\n", 403 "ERROR: wrong number of parameters (%d).\n",
404 argc); 404 argc);
405 } 405 }
@@ -407,17 +407,17 @@ int main(int argc, char *argv[])
407 { 407 {
408 if (argc == 6) 408 if (argc == 6)
409 { 409 {
410 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 410 My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
411 if (acc) 411 if (acc)
412 { 412 {
413 My_Post *post = _my_post_new(argv[5]); 413 My_Post * post = _my_post_new(argv[5]);
414 acc->posts = eina_list_append(acc->posts, post); 414 acc->posts = eina_list_append(acc->posts, post);
415 } 415 }
416 else 416 else
417 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 417 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
418 } 418 }
419 else 419 else
420 fprintf(stderr, 420 fprintf(stderr,
421 "ERROR: wrong number of parameters (%d).\n", 421 "ERROR: wrong number of parameters (%d).\n",
422 argc); 422 argc);
423 } 423 }
@@ -425,32 +425,32 @@ int main(int argc, char *argv[])
425 { 425 {
426 if (argc == 6) 426 if (argc == 6)
427 { 427 {
428 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 428 My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
429 if (acc) 429 if (acc)
430 { 430 {
431 My_Message *msg = _my_message_new(argv[5]); 431 My_Message * msg = _my_message_new(argv[5]);
432 acc->messages = eina_list_append(acc->messages, msg); 432 acc->messages = eina_list_append(acc->messages, msg);
433 } 433 }
434 else 434 else
435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
436 } 436 }
437 else 437 else
438 fprintf(stderr, 438 fprintf(stderr,
439 "ERROR: wrong number of parameters (%d).\n", 439 "ERROR: wrong number of parameters (%d).\n",
440 argc); 440 argc);
441 } 441 }
442 else 442 else
443 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]); 443 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
444 } 444 }
445 445
446 printf("My_Cache:\n" 446 printf("My_Cache:\n"
447 "\tversion.: %#x\n" 447 "\tversion.: %#x\n"
448 "\taccounts: %u\n", 448 "\taccounts: %u\n",
449 my_cache->version, 449 my_cache->version,
450 eina_list_count(my_cache->accounts)); 450 eina_list_count(my_cache->accounts));
451 EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc) 451 EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc)
452 { 452 {
453 const My_Post *post; 453 const My_Post * post;
454 454
455 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n", 455 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
456 acc->id, acc->name ? acc->name : "", 456 acc->id, acc->name ? acc->name : "",
@@ -459,8 +459,8 @@ int main(int argc, char *argv[])
459 459
460 if (eina_list_count(acc->messages)) 460 if (eina_list_count(acc->messages))
461 { 461 {
462 const Eina_List *l; 462 const Eina_List * l;
463 const My_Message *msg; 463 const My_Message * msg;
464 printf("\t |messages:\n"); 464 printf("\t |messages:\n");
465 465
466 EINA_LIST_FOREACH(acc->messages, l, msg) 466 EINA_LIST_FOREACH(acc->messages, l, msg)
@@ -475,11 +475,11 @@ int main(int argc, char *argv[])
475 475
476 if (eina_list_count(acc->posts)) 476 if (eina_list_count(acc->posts))
477 { 477 {
478 const Eina_List *l; 478 const Eina_List * l;
479 const My_Post *post; 479 const My_Post * post;
480 printf("\t |posts:\n"); 480 printf("\t |posts:\n");
481 481
482 EINA_LIST_FOREACH(acc->posts, l, post) 482 EINA_LIST_FOREACH(acc->posts, l, post)
483 { 483 {
484 if (post->dm_to) 484 if (post->dm_to)
485 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message); 485 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
@@ -488,7 +488,7 @@ int main(int argc, char *argv[])
488 } 488 }
489 } 489 }
490 490
491 printf("\n"); 491 printf("\n");
492 } 492 }
493 493
494 if (!_my_cache_save(my_cache, argv[2])) 494 if (!_my_cache_save(my_cache, argv[2]))
@@ -502,4 +502,5 @@ end:
502 eina_shutdown(); 502 eina_shutdown();
503 503
504 return ret; 504 return ret;
505} 505} /* main */
506
diff --git a/legacy/eet/src/examples/eet-data-nested.c b/legacy/eet/src/examples/eet-data-nested.c
index 3675718a03..b11956fbd0 100644
--- a/legacy/eet/src/examples/eet-data-nested.c
+++ b/legacy/eet/src/examples/eet-data-nested.c
@@ -14,17 +14,17 @@
14typedef struct 14typedef struct
15{ 15{
16 unsigned int version; // it is recommended to use versioned configuration! 16 unsigned int version; // it is recommended to use versioned configuration!
17 const char *name; 17 const char * name;
18 int id; 18 int id;
19 int not_saved_value; // example of not saved data inside! 19 int not_saved_value; // example of not saved data inside!
20 Eina_Bool enabled; 20 Eina_Bool enabled;
21 Eina_List *subs; 21 Eina_List * subs;
22} My_Conf_Type; 22} My_Conf_Type;
23 23
24typedef struct 24typedef struct
25{ 25{
26 const char *server; 26 const char * server;
27 int port; 27 int port;
28} My_Conf_Subtype; 28} My_Conf_Subtype;
29 29
30// string that represents the entry in eet file, you might like to have 30// string that represents the entry in eet file, you might like to have
@@ -32,12 +32,11 @@ typedef struct
32// different strings 32// different strings
33static const char MY_CONF_FILE_ENTRY[] = "config"; 33static const char MY_CONF_FILE_ENTRY[] = "config";
34 34
35
36// keep the descriptor static global, so it can be 35// keep the descriptor static global, so it can be
37// shared by different functions (load/save) of this and only this 36// shared by different functions (load/save) of this and only this
38// file. 37// file.
39static Eet_Data_Descriptor *_my_conf_descriptor; 38static Eet_Data_Descriptor * _my_conf_descriptor;
40static Eet_Data_Descriptor *_my_conf_sub_descriptor; 39static Eet_Data_Descriptor * _my_conf_sub_descriptor;
41 40
42static void 41static void
43_my_conf_descriptor_init(void) 42_my_conf_descriptor_init(void)
@@ -64,11 +63,11 @@ _my_conf_descriptor_init(void)
64 63
65 // Describe the members to be saved: 64 // Describe the members to be saved:
66 // Use a temporary macro so we don't type a lot, also avoid errors: 65 // Use a temporary macro so we don't type a lot, also avoid errors:
67#define MY_CONF_ADD_BASIC(member, eet_type) \ 66#define MY_CONF_ADD_BASIC(member, eet_type)\
68 EET_DATA_DESCRIPTOR_ADD_BASIC \ 67 EET_DATA_DESCRIPTOR_ADD_BASIC\
69 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 68 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
70#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \ 69#define MY_CONF_SUB_ADD_BASIC(member, eet_type)\
71 EET_DATA_DESCRIPTOR_ADD_BASIC \ 70 EET_DATA_DESCRIPTOR_ADD_BASIC\
72 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type) 71 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
73 72
74 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING); 73 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
@@ -85,20 +84,20 @@ _my_conf_descriptor_init(void)
85 84
86#undef MY_CONF_ADD_BASIC 85#undef MY_CONF_ADD_BASIC
87#undef MY_CONF_SUB_ADD_BASIC 86#undef MY_CONF_SUB_ADD_BASIC
88} 87} /* _my_conf_descriptor_init */
89 88
90static void 89static void
91_my_conf_descriptor_shutdown(void) 90_my_conf_descriptor_shutdown(void)
92{ 91{
93 eet_data_descriptor_free(_my_conf_sub_descriptor); 92 eet_data_descriptor_free(_my_conf_sub_descriptor);
94 eet_data_descriptor_free(_my_conf_descriptor); 93 eet_data_descriptor_free(_my_conf_descriptor);
95} 94} /* _my_conf_descriptor_shutdown */
96 95
97static My_Conf_Type * 96static My_Conf_Type *
98_my_conf_new(void) 97_my_conf_new(void)
99{ 98{
100 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); 99 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type));
101 My_Conf_Subtype *sub; 100 My_Conf_Subtype * sub;
102 if (!my_conf) 101 if (!my_conf)
103 { 102 {
104 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 103 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -117,12 +116,12 @@ _my_conf_new(void)
117 } 116 }
118 117
119 return my_conf; 118 return my_conf;
120} 119} /* _my_conf_new */
121 120
122static void 121static void
123_my_conf_free(My_Conf_Type *my_conf) 122_my_conf_free(My_Conf_Type * my_conf)
124{ 123{
125 My_Conf_Subtype *sub; 124 My_Conf_Subtype * sub;
126 EINA_LIST_FREE(my_conf->subs, sub) 125 EINA_LIST_FREE(my_conf->subs, sub)
127 { 126 {
128 eina_stringshare_del(sub->server); 127 eina_stringshare_del(sub->server);
@@ -131,13 +130,13 @@ _my_conf_free(My_Conf_Type *my_conf)
131 130
132 eina_stringshare_del(my_conf->name); 131 eina_stringshare_del(my_conf->name);
133 free(my_conf); 132 free(my_conf);
134} 133} /* _my_conf_free */
135 134
136static My_Conf_Type * 135static My_Conf_Type *
137_my_conf_load(const char *filename) 136_my_conf_load(const char * filename)
138{ 137{
139 My_Conf_Type *my_conf; 138 My_Conf_Type * my_conf;
140 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 139 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
141 if (!ef) 140 if (!ef)
142 { 141 {
143 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 142 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -161,13 +160,13 @@ _my_conf_load(const char *filename)
161end: 160end:
162 eet_close(ef); 161 eet_close(ef);
163 return my_conf; 162 return my_conf;
164} 163} /* _my_conf_load */
165 164
166static Eina_Bool 165static Eina_Bool
167_my_conf_save(const My_Conf_Type *my_conf, const char *filename) 166_my_conf_save(const My_Conf_Type * my_conf, const char * filename)
168{ 167{
169 char tmp[PATH_MAX]; 168 char tmp[PATH_MAX];
170 Eet_File *ef; 169 Eet_File * ef;
171 Eina_Bool ret; 170 Eina_Bool ret;
172 unsigned int i, len; 171 unsigned int i, len;
173 struct stat st; 172 struct stat st;
@@ -205,13 +204,13 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
205 } 204 }
206 205
207 return ret; 206 return ret;
208} 207} /* _my_conf_save */
209 208
210int main(int argc, char *argv[]) 209int main(int argc, char * argv[])
211{ 210{
212 My_Conf_Type *my_conf; 211 My_Conf_Type * my_conf;
213 const My_Conf_Subtype *sub; 212 const My_Conf_Subtype * sub;
214 const Eina_List *l; 213 const Eina_List * l;
215 int ret = 0; 214 int ret = 0;
216 215
217 if (argc != 3) 216 if (argc != 3)
@@ -236,7 +235,7 @@ int main(int argc, char *argv[])
236 } 235 }
237 } 236 }
238 237
239 printf("My_Conf_Type:\n" 238 printf("My_Conf_Type:\n"
240 "\tversion: %#x\n" 239 "\tversion: %#x\n"
241 "\tname...: '%s'\n" 240 "\tname...: '%s'\n"
242 "\tid.....: %d\n" 241 "\tid.....: %d\n"
@@ -263,4 +262,5 @@ end:
263 eina_shutdown(); 262 eina_shutdown();
264 263
265 return ret; 264 return ret;
266} 265} /* main */
266
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
index a4efd4ad7a..14b0a869eb 100644
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ b/legacy/eet/src/examples/eet-data-simple.c
@@ -14,10 +14,10 @@
14typedef struct 14typedef struct
15{ 15{
16 unsigned int version; // it is recommended to use versioned configuration! 16 unsigned int version; // it is recommended to use versioned configuration!
17 const char *name; 17 const char * name;
18 int id; 18 int id;
19 int not_saved_value; // example of not saved data inside! 19 int not_saved_value; // example of not saved data inside!
20 Eina_Bool enabled; 20 Eina_Bool enabled;
21} My_Conf_Type; 21} My_Conf_Type;
22 22
23// string that represents the entry in eet file, you might like to have 23// string that represents the entry in eet file, you might like to have
@@ -25,11 +25,10 @@ typedef struct
25// different strings 25// different strings
26static const char MY_CONF_FILE_ENTRY[] = "config"; 26static const char MY_CONF_FILE_ENTRY[] = "config";
27 27
28
29// keep the descriptor static global, so it can be 28// keep the descriptor static global, so it can be
30// shared by different functions (load/save) of this and only this 29// shared by different functions (load/save) of this and only this
31// file. 30// file.
32static Eet_Data_Descriptor *_my_conf_descriptor; 31static Eet_Data_Descriptor * _my_conf_descriptor;
33 32
34static void 33static void
35_my_conf_descriptor_init(void) 34_my_conf_descriptor_init(void)
@@ -53,8 +52,8 @@ _my_conf_descriptor_init(void)
53 52
54 // Describe the members to be saved: 53 // Describe the members to be saved:
55 // Use a temporary macro so we don't type a lot, also avoid errors: 54 // Use a temporary macro so we don't type a lot, also avoid errors:
56#define MY_CONF_ADD_BASIC(member, eet_type) \ 55#define MY_CONF_ADD_BASIC(member, eet_type)\
57 EET_DATA_DESCRIPTOR_ADD_BASIC \ 56 EET_DATA_DESCRIPTOR_ADD_BASIC\
58 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 57 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
59 58
60 MY_CONF_ADD_BASIC(version, EET_T_UINT); 59 MY_CONF_ADD_BASIC(version, EET_T_UINT);
@@ -63,18 +62,18 @@ _my_conf_descriptor_init(void)
63 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 62 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
64 63
65#undef MY_CONF_ADD_BASIC 64#undef MY_CONF_ADD_BASIC
66} 65} /* _my_conf_descriptor_init */
67 66
68static void 67static void
69_my_conf_descriptor_shutdown(void) 68_my_conf_descriptor_shutdown(void)
70{ 69{
71 eet_data_descriptor_free(_my_conf_descriptor); 70 eet_data_descriptor_free(_my_conf_descriptor);
72} 71} /* _my_conf_descriptor_shutdown */
73 72
74static My_Conf_Type * 73static My_Conf_Type *
75_my_conf_new(void) 74_my_conf_new(void)
76{ 75{
77 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); 76 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type));
78 if (!my_conf) 77 if (!my_conf)
79 { 78 {
80 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 79 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -84,20 +83,20 @@ _my_conf_new(void)
84 my_conf->version = 0x112233; 83 my_conf->version = 0x112233;
85 my_conf->enabled = EINA_TRUE; 84 my_conf->enabled = EINA_TRUE;
86 return my_conf; 85 return my_conf;
87} 86} /* _my_conf_new */
88 87
89static void 88static void
90_my_conf_free(My_Conf_Type *my_conf) 89_my_conf_free(My_Conf_Type * my_conf)
91{ 90{
92 eina_stringshare_del(my_conf->name); 91 eina_stringshare_del(my_conf->name);
93 free(my_conf); 92 free(my_conf);
94} 93} /* _my_conf_free */
95 94
96static My_Conf_Type * 95static My_Conf_Type *
97_my_conf_load(const char *filename) 96_my_conf_load(const char * filename)
98{ 97{
99 My_Conf_Type *my_conf; 98 My_Conf_Type * my_conf;
100 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 99 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
101 if (!ef) 100 if (!ef)
102 { 101 {
103 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 102 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -121,13 +120,13 @@ _my_conf_load(const char *filename)
121end: 120end:
122 eet_close(ef); 121 eet_close(ef);
123 return my_conf; 122 return my_conf;
124} 123} /* _my_conf_load */
125 124
126static Eina_Bool 125static Eina_Bool
127_my_conf_save(const My_Conf_Type *my_conf, const char *filename) 126_my_conf_save(const My_Conf_Type * my_conf, const char * filename)
128{ 127{
129 char tmp[PATH_MAX]; 128 char tmp[PATH_MAX];
130 Eet_File *ef; 129 Eet_File * ef;
131 Eina_Bool ret; 130 Eina_Bool ret;
132 unsigned int i, len; 131 unsigned int i, len;
133 struct stat st; 132 struct stat st;
@@ -165,11 +164,11 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
165 } 164 }
166 165
167 return ret; 166 return ret;
168} 167} /* _my_conf_save */
169 168
170int main(int argc, char *argv[]) 169int main(int argc, char * argv[])
171{ 170{
172 My_Conf_Type *my_conf; 171 My_Conf_Type * my_conf;
173 int ret = 0; 172 int ret = 0;
174 173
175 if (argc != 3) 174 if (argc != 3)
@@ -194,7 +193,7 @@ int main(int argc, char *argv[])
194 } 193 }
195 } 194 }
196 195
197 printf("My_Conf_Type:\n" 196 printf("My_Conf_Type:\n"
198 "\tversion: %#x\n" 197 "\tversion: %#x\n"
199 "\tname...: '%s'\n" 198 "\tname...: '%s'\n"
200 "\tid.....: %d\n" 199 "\tid.....: %d\n"
@@ -215,4 +214,5 @@ end:
215 eina_shutdown(); 214 eina_shutdown();
216 215
217 return ret; 216 return ret;
218} 217} /* main */
218