summaryrefslogtreecommitdiff
path: root/legacy/eet/src/examples
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
commit8893a9ff35f58e012be3cc838bd94268add13e10 (patch)
treee5c560542a70ccf657e1da45fb57d8dee99d3348 /legacy/eet/src/examples
parenta331fe3bca4816e3a45662afd986e364b3586eed (diff)
ran ecrustify on eet. this seems to do a good job of eet. comments?
SVN revision: 64237
Diffstat (limited to 'legacy/eet/src/examples')
-rw-r--r--legacy/eet/src/examples/eet-basic.c53
-rw-r--r--legacy/eet/src/examples/eet-data-cipher_decipher.c36
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor_01.c242
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor_02.c7
-rw-r--r--legacy/eet/src/examples/eet-data-nested.c81
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c41
-rw-r--r--legacy/eet/src/examples/eet-file.c121
7 files changed, 300 insertions, 281 deletions
diff --git a/legacy/eet/src/examples/eet-basic.c b/legacy/eet/src/examples/eet-basic.c
index 390cd713d6..05ff397789 100644
--- a/legacy/eet/src/examples/eet-basic.c
+++ b/legacy/eet/src/examples/eet-basic.c
@@ -3,37 +3,38 @@
3int 3int
4main(void) 4main(void)
5{ 5{
6 Eet_File *ef; 6 Eet_File *ef;
7 char *ret; 7 char *ret;
8 int size; 8 int size;
9 char *entries[] = 9 char *entries[] =
10 { 10 {
11 "Entry 1", 11 "Entry 1",
12 "Big text string here compared to others", 12 "Big text string here compared to others",
13 "Eet is cool" 13 "Eet is cool"
14 }; 14 };
15 15
16 eet_init(); 16 eet_init();
17 17
18 // blindly open an file for output and write strings with their NUL char 18 // blindly open an file for output and write strings with their NUL char
19 ef = eet_open("test.eet", EET_FILE_MODE_WRITE); 19 ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
20 eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0); 20 eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
21 eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1); 21 eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
22 eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0); 22 eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
23 eet_close(ef); 23 eet_close(ef);
24 24
25 // open the file again and blindly get the entries we wrote 25 // open the file again and blindly get the entries we wrote
26 ef = eet_open("test.eet", EET_FILE_MODE_READ); 26 ef = eet_open("test.eet", EET_FILE_MODE_READ);
27 ret = eet_read(ef, "Entry 1", &size); 27 ret = eet_read(ef, "Entry 1", &size);
28 printf("%s\n", ret); 28 printf("%s\n", ret);
29 free(ret); 29 free(ret);
30 ret = eet_read(ef, "Entry 2", &size); 30 ret = eet_read(ef, "Entry 2", &size);
31 printf("%s\n", ret); 31 printf("%s\n", ret);
32 free(ret); 32 free(ret);
33 ret = eet_read(ef, "Entry 3", &size); 33 ret = eet_read(ef, "Entry 3", &size);
34 printf("%s\n", ret); 34 printf("%s\n", ret);
35 free(ret); 35 free(ret);
36 eet_close(ef); 36 eet_close(ef);
37 37
38 eet_shutdown(); 38 eet_shutdown();
39} 39}
40
diff --git a/legacy/eet/src/examples/eet-data-cipher_decipher.c b/legacy/eet/src/examples/eet-data-cipher_decipher.c
index 1688e020a4..2ef965c745 100644
--- a/legacy/eet/src/examples/eet-data-cipher_decipher.c
+++ b/legacy/eet/src/examples/eet-data-cipher_decipher.c
@@ -27,7 +27,7 @@ main(void)
27 if (!(file = tmpnam(file))) 27 if (!(file = tmpnam(file)))
28 { 28 {
29 fprintf( 29 fprintf(
30 stderr, "ERROR: could not create temporary file (%s).\n", file); 30 stderr, "ERROR: could not create temporary file (%s).\n", file);
31 goto panic; 31 goto panic;
32 } 32 }
33 33
@@ -36,14 +36,14 @@ main(void)
36 if (!ef) 36 if (!ef)
37 { 37 {
38 fprintf( 38 fprintf(
39 stderr, "ERROR: could not access file (%s).\n", file); 39 stderr, "ERROR: could not access file (%s).\n", file);
40 goto error; 40 goto error;
41 } 41 }
42 42
43 if (!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0, key)) 43 if (!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0, key))
44 { 44 {
45 fprintf( 45 fprintf(
46 stderr, "ERROR: could not access file (%s).\n", file); 46 stderr, "ERROR: could not access file (%s).\n", file);
47 goto error; 47 goto error;
48 } 48 }
49 49
@@ -54,7 +54,7 @@ main(void)
54 if (!ef) 54 if (!ef)
55 { 55 {
56 fprintf( 56 fprintf(
57 stderr, "ERROR: could not access file (%s).\n", file); 57 stderr, "ERROR: could not access file (%s).\n", file);
58 goto error; 58 goto error;
59 } 59 }
60 60
@@ -62,22 +62,22 @@ main(void)
62 if (!test) 62 if (!test)
63 { 63 {
64 fprintf( 64 fprintf(
65 stderr, "ERROR: could decript contents on file %s, with key %s.\n", 65 stderr, "ERROR: could decript contents on file %s, with key %s.\n",
66 file, key); 66 file, key);
67 goto error; 67 goto error;
68 } 68 }
69 69
70 if (size != (int)strlen(buffer) + 1) 70 if (size != (int)strlen(buffer) + 1)
71 { 71 {
72 fprintf( 72 fprintf(
73 stderr, "ERROR: something is wrong with the decripted data\n"); 73 stderr, "ERROR: something is wrong with the decripted data\n");
74 goto error; 74 goto error;
75 } 75 }
76 76
77 if (memcmp(test, buffer, strlen(buffer) + 1) != 0) 77 if (memcmp(test, buffer, strlen(buffer) + 1) != 0)
78 { 78 {
79 fprintf( 79 fprintf(
80 stderr, "ERROR: something is wrong with the decripted data\n"); 80 stderr, "ERROR: something is wrong with the decripted data\n");
81 goto error; 81 goto error;
82 } 82 }
83 83
@@ -88,7 +88,7 @@ main(void)
88 if (!ef) 88 if (!ef)
89 { 89 {
90 fprintf( 90 fprintf(
91 stderr, "ERROR: could not access file (%s).\n", file); 91 stderr, "ERROR: could not access file (%s).\n", file);
92 goto error; 92 goto error;
93 } 93 }
94 94
@@ -96,24 +96,24 @@ main(void)
96 96
97 if (size == (int)strlen(buffer) + 1) 97 if (size == (int)strlen(buffer) + 1)
98 if (memcmp(test, buffer, strlen(buffer) + 1) == 0) 98 if (memcmp(test, buffer, strlen(buffer) + 1) == 0)
99 { 99 {
100 fprintf( 100 fprintf(
101 stderr, "ERROR: something is wrong with the contents of %s, as" 101 stderr, "ERROR: something is wrong with the contents of %s, as"
102 " we accessed it with a different key and it decripted our" 102 " we accessed it with a different key and it decripted our"
103 " information right.\n", file); 103 " information right.\n", file);
104 goto error; 104 goto error;
105 } 105 }
106 106
107 eet_close(ef); 107 eet_close(ef);
108 108
109 error: 109error:
110 if (unlink(file) != 0) 110 if (unlink(file) != 0)
111 { 111 {
112 fprintf( 112 fprintf(
113 stderr, "ERROR: could not unlink file (%s).\n", file); 113 stderr, "ERROR: could not unlink file (%s).\n", file);
114 } 114 }
115 115
116 panic: 116panic:
117 eet_shutdown(); 117 eet_shutdown();
118} 118}
119 119
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor_01.c b/legacy/eet/src/examples/eet-data-file_descriptor_01.c
index ed0f7243a7..4b5b75f865 100644
--- a/legacy/eet/src/examples/eet-data-file_descriptor_01.c
+++ b/legacy/eet/src/examples/eet-data-file_descriptor_01.c
@@ -82,48 +82,48 @@ _my_cache_descriptor_init(void)
82 // Describe the members to be saved: 82 // Describe the members to be saved:
83 // Use a temporary macro so we don't type a lot, also avoid errors: 83 // Use a temporary macro so we don't type a lot, also avoid errors:
84 84
85#define ADD_BASIC(member, eet_type)\ 85#define ADD_BASIC(member, eet_type) \
86 EET_DATA_DESCRIPTOR_ADD_BASIC\ 86 EET_DATA_DESCRIPTOR_ADD_BASIC \
87 (_my_message_descriptor, My_Message, # member, member, eet_type) 87 (_my_message_descriptor, My_Message, # member, member, eet_type)
88 ADD_BASIC(screen_name, EET_T_STRING); 88 ADD_BASIC(screen_name, EET_T_STRING);
89 ADD_BASIC(name, EET_T_STRING); 89 ADD_BASIC(name, EET_T_STRING);
90 ADD_BASIC(message, EET_T_STRING); 90 ADD_BASIC(message, EET_T_STRING);
91 ADD_BASIC(id, EET_T_UINT); 91 ADD_BASIC(id, EET_T_UINT);
92 ADD_BASIC(status_id, EET_T_UINT); 92 ADD_BASIC(status_id, EET_T_UINT);
93 ADD_BASIC(date, EET_T_UINT); 93 ADD_BASIC(date, EET_T_UINT);
94 ADD_BASIC(timeline, EET_T_UINT); 94 ADD_BASIC(timeline, EET_T_UINT);
95#undef ADD_BASIC 95#undef ADD_BASIC
96 96
97#define ADD_BASIC(member, eet_type)\ 97#define ADD_BASIC(member, eet_type) \
98 EET_DATA_DESCRIPTOR_ADD_BASIC\ 98 EET_DATA_DESCRIPTOR_ADD_BASIC \
99 (_my_post_descriptor, My_Post, # member, member, eet_type) 99 (_my_post_descriptor, My_Post, # member, member, eet_type)
100 ADD_BASIC(dm_to, EET_T_STRING); 100 ADD_BASIC(dm_to, EET_T_STRING);
101 ADD_BASIC(message, EET_T_STRING); 101 ADD_BASIC(message, EET_T_STRING);
102#undef ADD_BASIC 102#undef ADD_BASIC
103 103
104#define ADD_BASIC(member, eet_type)\ 104#define ADD_BASIC(member, eet_type) \
105 EET_DATA_DESCRIPTOR_ADD_BASIC\ 105 EET_DATA_DESCRIPTOR_ADD_BASIC \
106 (_my_account_descriptor, My_Account, # member, member, eet_type) 106 (_my_account_descriptor, My_Account, # member, member, eet_type)
107 ADD_BASIC(name, EET_T_STRING); 107 ADD_BASIC(name, EET_T_STRING);
108 ADD_BASIC(id, EET_T_UINT); 108 ADD_BASIC(id, EET_T_UINT);
109#undef ADD_BASIC 109#undef ADD_BASIC
110 110
111 EET_DATA_DESCRIPTOR_ADD_LIST 111 EET_DATA_DESCRIPTOR_ADD_LIST
112 (_my_account_descriptor, My_Account, "messages", messages, 112 (_my_account_descriptor, My_Account, "messages", messages,
113 _my_message_descriptor); 113 _my_message_descriptor);
114 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY 114 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY
115 (_my_account_descriptor, My_Account, "posts", posts, 115 (_my_account_descriptor, My_Account, "posts", posts,
116 _my_post_descriptor); 116 _my_post_descriptor);
117 117
118#define ADD_BASIC(member, eet_type)\ 118#define ADD_BASIC(member, eet_type) \
119 EET_DATA_DESCRIPTOR_ADD_BASIC\ 119 EET_DATA_DESCRIPTOR_ADD_BASIC \
120 (_my_cache_descriptor, My_Cache, # member, member, eet_type) 120 (_my_cache_descriptor, My_Cache, # member, member, eet_type)
121 ADD_BASIC(version, EET_T_UINT); 121 ADD_BASIC(version, EET_T_UINT);
122#undef ADD_BASIC 122#undef ADD_BASIC
123 123
124 EET_DATA_DESCRIPTOR_ADD_HASH 124 EET_DATA_DESCRIPTOR_ADD_HASH
125 (_my_cache_descriptor, My_Cache, "accounts", accounts, 125 (_my_cache_descriptor, My_Cache, "accounts", accounts,
126 _my_account_descriptor); 126 _my_account_descriptor);
127} /* _my_cache_descriptor_init */ 127} /* _my_cache_descriptor_init */
128 128
129static void 129static void
@@ -138,21 +138,21 @@ _my_cache_descriptor_shutdown(void)
138// need to check if the pointer came from mmaped area in eet_dictionary 138// need to check if the pointer came from mmaped area in eet_dictionary
139// or it was allocated with eina_stringshare_add() 139// or it was allocated with eina_stringshare_add()
140static void 140static void
141_eet_string_free(const char * str) 141_eet_string_free(const char *str)
142{ 142{
143 if (!str) 143 if (!str)
144 return; 144 return;
145 145
146 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str))) 146 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str)))
147 return; 147 return;
148 148
149 eina_stringshare_del(str); 149 eina_stringshare_del(str);
150} /* _eet_string_free */ 150} /* _eet_string_free */
151 151
152static My_Message * 152static My_Message *
153_my_message_new(const char * message) 153_my_message_new(const char *message)
154{ 154{
155 My_Message * msg = calloc(1, sizeof(My_Message)); 155 My_Message *msg = calloc(1, sizeof(My_Message));
156 if (!msg) 156 if (!msg)
157 { 157 {
158 fprintf(stderr, "ERROR: could not calloc My_Message\n"); 158 fprintf(stderr, "ERROR: could not calloc My_Message\n");
@@ -164,7 +164,7 @@ _my_message_new(const char * message)
164} /* _my_message_new */ 164} /* _my_message_new */
165 165
166static void 166static void
167_my_message_free(My_Message * msg) 167_my_message_free(My_Message *msg)
168{ 168{
169 _eet_string_free(msg->screen_name); 169 _eet_string_free(msg->screen_name);
170 _eet_string_free(msg->name); 170 _eet_string_free(msg->name);
@@ -173,7 +173,8 @@ _my_message_free(My_Message * msg)
173} /* _my_message_free */ 173} /* _my_message_free */
174 174
175static Eina_Bool 175static Eina_Bool
176_my_post_add(My_Account *acc, const char * message) 176_my_post_add(My_Account *acc,
177 const char *message)
177{ 178{
178 int new_count = acc->posts_count + 1; 179 int new_count = acc->posts_count + 1;
179 My_Post *post = realloc(acc->posts, new_count * sizeof(My_Post)); 180 My_Post *post = realloc(acc->posts, new_count * sizeof(My_Post));
@@ -187,20 +188,20 @@ _my_post_add(My_Account *acc, const char * message)
187 post[acc->posts_count].dm_to = NULL; 188 post[acc->posts_count].dm_to = NULL;
188 acc->posts_count = new_count; 189 acc->posts_count = new_count;
189 acc->posts = post; 190 acc->posts = post;
190 return EINA_TRUE;; 191 return EINA_TRUE;
191} /* _my_post_new */ 192} /* _my_post_new */
192 193
193static void 194static void
194_my_post_free(My_Post * post) 195_my_post_free(My_Post *post)
195{ 196{
196 _eet_string_free(post->dm_to); 197 _eet_string_free(post->dm_to);
197 _eet_string_free(post->message); 198 _eet_string_free(post->message);
198} /* _my_post_free */ 199} /* _my_post_free */
199 200
200static My_Account * 201static My_Account *
201_my_account_new(const char * name) 202_my_account_new(const char *name)
202{ 203{
203 My_Account * acc = calloc(1, sizeof(My_Account)); 204 My_Account *acc = calloc(1, sizeof(My_Account));
204 if (!acc) 205 if (!acc)
205 { 206 {
206 fprintf(stderr, "ERROR: could not calloc My_Account\n"); 207 fprintf(stderr, "ERROR: could not calloc My_Account\n");
@@ -212,15 +213,15 @@ _my_account_new(const char * name)
212} /* _my_account_new */ 213} /* _my_account_new */
213 214
214static void 215static void
215_my_account_free(My_Account * acc) 216_my_account_free(My_Account *acc)
216{ 217{
217 My_Message * m; 218 My_Message *m;
218 int i; 219 int i;
219 220
220 _eet_string_free(acc->name); 221 _eet_string_free(acc->name);
221 222
222 EINA_LIST_FREE(acc->messages, m) 223 EINA_LIST_FREE(acc->messages, m)
223 _my_message_free(m); 224 _my_message_free(m);
224 225
225 for (i = 0; i < acc->posts_count; i++) 226 for (i = 0; i < acc->posts_count; i++)
226 _my_post_free(&acc->posts[i]); 227 _my_post_free(&acc->posts[i]);
@@ -232,7 +233,7 @@ _my_account_free(My_Account * acc)
232static My_Cache * 233static My_Cache *
233_my_cache_new(void) 234_my_cache_new(void)
234{ 235{
235 My_Cache * my_cache = calloc(1, sizeof(My_Cache)); 236 My_Cache *my_cache = calloc(1, sizeof(My_Cache));
236 if (!my_cache) 237 if (!my_cache)
237 { 238 {
238 fprintf(stderr, "ERROR: could not calloc My_Cache\n"); 239 fprintf(stderr, "ERROR: could not calloc My_Cache\n");
@@ -246,32 +247,36 @@ _my_cache_new(void)
246} /* _my_cache_new */ 247} /* _my_cache_new */
247 248
248static Eina_Bool 249static Eina_Bool
249_my_cache_account_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata) 250_my_cache_account_free_cb(const Eina_Hash *hash,
251 const void *key,
252 void *data,
253 void *fdata)
250{ 254{
251 _my_account_free(data); 255 _my_account_free(data);
252 return EINA_TRUE; 256 return EINA_TRUE;
253} 257}
254 258
255static void 259static void
256_my_cache_free(My_Cache * my_cache) 260_my_cache_free(My_Cache *my_cache)
257{ 261{
258 My_Account * acc; 262 My_Account *acc;
259 eina_hash_foreach(my_cache->accounts, _my_cache_account_free_cb, NULL); 263 eina_hash_foreach(my_cache->accounts, _my_cache_account_free_cb, NULL);
260 eina_hash_free(my_cache->accounts); 264 eina_hash_free(my_cache->accounts);
261 free(my_cache); 265 free(my_cache);
262} /* _my_cache_free */ 266} /* _my_cache_free */
263 267
264static My_Account * 268static My_Account *
265_my_cache_account_find(My_Cache * my_cache, const char * name) 269_my_cache_account_find(My_Cache *my_cache,
270 const char *name)
266{ 271{
267 return eina_hash_find(my_cache->accounts, name); 272 return eina_hash_find(my_cache->accounts, name);
268} /* _my_cache_account_find */ 273} /* _my_cache_account_find */
269 274
270static My_Cache * 275static My_Cache *
271_my_cache_load(const char * filename) 276_my_cache_load(const char *filename)
272{ 277{
273 My_Cache * my_cache; 278 My_Cache *my_cache;
274 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ); 279 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
275 if (!ef) 280 if (!ef)
276 { 281 {
277 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 282 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -295,7 +300,7 @@ _my_cache_load(const char * filename)
295 } 300 }
296 301
297 if (_my_cache_file) 302 if (_my_cache_file)
298 eet_close(_my_cache_file); 303 eet_close(_my_cache_file);
299 304
300 _my_cache_file = ef; 305 _my_cache_file = ef;
301 _my_cache_dict = eet_dictionary_get(ef); 306 _my_cache_dict = eet_dictionary_get(ef);
@@ -304,10 +309,11 @@ _my_cache_load(const char * filename)
304} /* _my_cache_load */ 309} /* _my_cache_load */
305 310
306static Eina_Bool 311static Eina_Bool
307_my_cache_save(const My_Cache * my_cache, const char * filename) 312_my_cache_save(const My_Cache *my_cache,
313 const char *filename)
308{ 314{
309 char tmp[PATH_MAX]; 315 char tmp[PATH_MAX];
310 Eet_File * ef; 316 Eet_File *ef;
311 Eina_Bool ret; 317 Eina_Bool ret;
312 unsigned int i, len; 318 unsigned int i, len;
313 struct stat st; 319 struct stat st;
@@ -335,7 +341,7 @@ _my_cache_save(const My_Cache * my_cache, const char * filename)
335 } 341 }
336 342
337 ret = eet_data_write 343 ret = eet_data_write
338 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE); 344 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE);
339 345
340 // VERY IMPORTANT NOTE: 346 // VERY IMPORTANT NOTE:
341 // after eet_close(), all strings mmaped from file will be GONE, invalid! 347 // after eet_close(), all strings mmaped from file will be GONE, invalid!
@@ -356,12 +362,14 @@ _my_cache_save(const My_Cache * my_cache, const char * filename)
356 return ret; 362 return ret;
357} /* _my_cache_save */ 363} /* _my_cache_save */
358 364
359int main(int argc, char * argv[]) 365int
366main(int argc,
367 char *argv[])
360{ 368{
361 My_Cache * my_cache; 369 My_Cache *my_cache;
362 const Eina_List * l_acc; 370 const Eina_List *l_acc;
363 Eina_Iterator *it; 371 Eina_Iterator *it;
364 My_Account * acc; 372 My_Account *acc;
365 int ret = 0; 373 int ret = 0;
366 374
367 if (argc < 3) 375 if (argc < 3)
@@ -399,58 +407,58 @@ int main(int argc, char * argv[])
399 { 407 {
400 if (argc == 5) 408 if (argc == 5)
401 { 409 {
402 My_Account * acc = _my_cache_account_find(my_cache, argv[4]); 410 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
403 if (!acc) 411 if (!acc)
404 { 412 {
405 acc = _my_account_new(argv[4]); 413 acc = _my_account_new(argv[4]);
406 eina_hash_direct_add(my_cache->accounts, acc->name, acc); 414 eina_hash_direct_add(my_cache->accounts, acc->name, acc);
407 } 415 }
408 else 416 else
409 fprintf(stderr, "ERROR: account '%s' already exists.\n", 417 fprintf(stderr, "ERROR: account '%s' already exists.\n",
410 argv[4]); 418 argv[4]);
411 } 419 }
412 else 420 else
413 fprintf(stderr, 421 fprintf(stderr,
414 "ERROR: wrong number of parameters (%d).\n", 422 "ERROR: wrong number of parameters (%d).\n",
415 argc); 423 argc);
416 } 424 }
417 else if (strcmp(argv[3], "post") == 0) 425 else if (strcmp(argv[3], "post") == 0)
418 { 426 {
419 if (argc == 6) 427 if (argc == 6)
420 { 428 {
421 My_Account * acc = _my_cache_account_find(my_cache, argv[4]); 429 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
422 if (acc) 430 if (acc)
423 { 431 {
424 _my_post_add(acc, argv[5]); 432 _my_post_add(acc, argv[5]);
425 } 433 }
426 else 434 else
427 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
428 } 436 }
429 else 437 else
430 fprintf(stderr, 438 fprintf(stderr,
431 "ERROR: wrong number of parameters (%d).\n", 439 "ERROR: wrong number of parameters (%d).\n",
432 argc); 440 argc);
433 } 441 }
434 else if (strcmp(argv[3], "message") == 0) 442 else if (strcmp(argv[3], "message") == 0)
435 { 443 {
436 if (argc == 6) 444 if (argc == 6)
437 { 445 {
438 My_Account * acc = _my_cache_account_find(my_cache, argv[4]); 446 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
439 if (acc) 447 if (acc)
440 { 448 {
441 My_Message * msg = _my_message_new(argv[5]); 449 My_Message *msg = _my_message_new(argv[5]);
442 acc->messages = eina_list_append(acc->messages, msg); 450 acc->messages = eina_list_append(acc->messages, msg);
443 } 451 }
444 else 452 else
445 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 453 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
446 } 454 }
447 else 455 else
448 fprintf(stderr, 456 fprintf(stderr,
449 "ERROR: wrong number of parameters (%d).\n", 457 "ERROR: wrong number of parameters (%d).\n",
450 argc); 458 argc);
451 } 459 }
452 else 460 else
453 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]); 461 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
454 } 462 }
455 463
456 printf("My_Cache:\n" 464 printf("My_Cache:\n"
@@ -460,52 +468,52 @@ int main(int argc, char * argv[])
460 eina_hash_population(my_cache->accounts)); 468 eina_hash_population(my_cache->accounts));
461 it = eina_hash_iterator_data_new(my_cache->accounts); 469 it = eina_hash_iterator_data_new(my_cache->accounts);
462 EINA_ITERATOR_FOREACH(it, acc) 470 EINA_ITERATOR_FOREACH(it, acc)
463 { 471 {
464 const My_Post * post; 472 const My_Post *post;
465 473
466 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n", 474 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
467 acc->id, acc->name ? acc->name : "", 475 acc->id, acc->name ? acc->name : "",
468 eina_list_count(acc->messages), 476 eina_list_count(acc->messages),
469 acc->posts_count); 477 acc->posts_count);
470 478
471 if (eina_list_count(acc->messages)) 479 if (eina_list_count(acc->messages))
472 { 480 {
473 const Eina_List * l; 481 const Eina_List *l;
474 const My_Message * msg; 482 const My_Message *msg;
475 printf("\t |messages:\n"); 483 printf("\t |messages:\n");
476 484
477 EINA_LIST_FOREACH(acc->messages, l, msg) 485 EINA_LIST_FOREACH(acc->messages, l, msg)
478 { 486 {
479 printf("\t | %-8x '%s' [%s]: '%.20s'\n", 487 printf("\t | %-8x '%s' [%s]: '%.20s'\n",
480 msg->id, 488 msg->id,
481 msg->name ? msg->name : "", 489 msg->name ? msg->name : "",
482 msg->screen_name ? msg->screen_name : "", 490 msg->screen_name ? msg->screen_name : "",
483 msg->message ? msg->message : ""); 491 msg->message ? msg->message : "");
484 } 492 }
485 } 493 }
486 494
487 if (acc->posts_count) 495 if (acc->posts_count)
488 { 496 {
489 const My_Post * post; 497 const My_Post *post;
490 int i; 498 int i;
491 printf("\t |posts:\n"); 499 printf("\t |posts:\n");
492 500
493 for (i = 0; i < acc->posts_count; i++) 501 for (i = 0; i < acc->posts_count; i++)
494 { 502 {
495 post = &acc->posts[i]; 503 post = &acc->posts[i];
496 if (post->dm_to) 504 if (post->dm_to)
497 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message); 505 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
498 else 506 else
499 printf("\t | '%.20s'\n", post->message); 507 printf("\t | '%.20s'\n", post->message);
500 } 508 }
501 } 509 }
502 510
503 printf("\n"); 511 printf("\n");
504 } 512 }
505 eina_iterator_free(it); 513 eina_iterator_free(it);
506 514
507 if (!_my_cache_save(my_cache, argv[2])) 515 if (!_my_cache_save(my_cache, argv[2]))
508 ret = -3; 516 ret = -3;
509 517
510 _my_cache_free(my_cache); 518 _my_cache_free(my_cache);
511 519
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor_02.c b/legacy/eet/src/examples/eet-data-file_descriptor_02.c
index 9690d6b19b..65ba79ec40 100644
--- a/legacy/eet/src/examples/eet-data-file_descriptor_02.c
+++ b/legacy/eet/src/examples/eet-data-file_descriptor_02.c
@@ -115,7 +115,9 @@ _st3_set(Example_Struct3 *st3,
115 st3->body = v1; 115 st3->body = v1;
116} /* _st3_set */ 116} /* _st3_set */
117 117
118static const char * /* union type_get() */ 118static const char *
119/* union
120 type_get() */
119_union_type_get(const void *data, 121_union_type_get(const void *data,
120 Eina_Bool *unknow) 122 Eina_Bool *unknow)
121{ 123{
@@ -259,7 +261,8 @@ static Eet_Data_Descriptor *_variant_unified_descriptor;
259static Eet_File *_cache_file = NULL; 261static Eet_File *_cache_file = NULL;
260static Eet_Dictionary *_cache_dict = NULL; 262static Eet_Dictionary *_cache_dict = NULL;
261 263
262static void /* declaring types */ 264static void
265/* declaring types */
263_data_descriptors_init(void) 266_data_descriptors_init(void)
264{ 267{
265 Eet_Data_Descriptor_Class eddc; 268 Eet_Data_Descriptor_Class eddc;
diff --git a/legacy/eet/src/examples/eet-data-nested.c b/legacy/eet/src/examples/eet-data-nested.c
index 882fc24264..a6b0e1208a 100644
--- a/legacy/eet/src/examples/eet-data-nested.c
+++ b/legacy/eet/src/examples/eet-data-nested.c
@@ -17,17 +17,17 @@
17typedef struct 17typedef struct
18{ 18{
19 unsigned int version; // it is recommended to use versioned configuration! 19 unsigned int version; // it is recommended to use versioned configuration!
20 const char * name; 20 const char *name;
21 int id; 21 int id;
22 int not_saved_value; // example of not saved data inside! 22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled; 23 Eina_Bool enabled;
24 Eina_List * subs; 24 Eina_List *subs;
25} My_Conf_Type; 25} My_Conf_Type;
26 26
27typedef struct 27typedef struct
28{ 28{
29 const char * server; 29 const char *server;
30 int port; 30 int port;
31} My_Conf_Subtype; 31} My_Conf_Subtype;
32 32
33// string that represents the entry in eet file, you might like to have 33// string that represents the entry in eet file, you might like to have
@@ -38,8 +38,8 @@ static const char MY_CONF_FILE_ENTRY[] = "config";
38// keep the descriptor static global, so it can be 38// keep the descriptor static global, so it can be
39// shared by different functions (load/save) of this and only this 39// shared by different functions (load/save) of this and only this
40// file. 40// file.
41static Eet_Data_Descriptor * _my_conf_descriptor; 41static Eet_Data_Descriptor *_my_conf_descriptor;
42static Eet_Data_Descriptor * _my_conf_sub_descriptor; 42static Eet_Data_Descriptor *_my_conf_sub_descriptor;
43 43
44static void 44static void
45_my_conf_descriptor_init(void) 45_my_conf_descriptor_init(void)
@@ -66,24 +66,24 @@ _my_conf_descriptor_init(void)
66 66
67 // Describe the members to be saved: 67 // Describe the members to be saved:
68 // Use a temporary macro so we don't type a lot, also avoid errors: 68 // Use a temporary macro so we don't type a lot, also avoid errors:
69#define MY_CONF_ADD_BASIC(member, eet_type)\ 69#define MY_CONF_ADD_BASIC(member, eet_type) \
70 EET_DATA_DESCRIPTOR_ADD_BASIC\ 70 EET_DATA_DESCRIPTOR_ADD_BASIC \
71 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 71 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
72#define MY_CONF_SUB_ADD_BASIC(member, eet_type)\ 72#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \
73 EET_DATA_DESCRIPTOR_ADD_BASIC\ 73 EET_DATA_DESCRIPTOR_ADD_BASIC \
74 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type) 74 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
75 75
76 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING); 76 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
77 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT); 77 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT);
78 78
79 MY_CONF_ADD_BASIC(version, EET_T_UINT); 79 MY_CONF_ADD_BASIC(version, EET_T_UINT);
80 MY_CONF_ADD_BASIC(name, EET_T_STRING); 80 MY_CONF_ADD_BASIC(name, EET_T_STRING);
81 MY_CONF_ADD_BASIC(id, EET_T_INT); 81 MY_CONF_ADD_BASIC(id, EET_T_INT);
82 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 82 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
83 83
84 // And add the sub descriptor as a linked list at 'subs' in the main struct 84 // And add the sub descriptor as a linked list at 'subs' in the main struct
85 EET_DATA_DESCRIPTOR_ADD_LIST 85 EET_DATA_DESCRIPTOR_ADD_LIST
86 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor); 86 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor);
87 87
88#undef MY_CONF_ADD_BASIC 88#undef MY_CONF_ADD_BASIC
89#undef MY_CONF_SUB_ADD_BASIC 89#undef MY_CONF_SUB_ADD_BASIC
@@ -99,8 +99,8 @@ _my_conf_descriptor_shutdown(void)
99static My_Conf_Type * 99static My_Conf_Type *
100_my_conf_new(void) 100_my_conf_new(void)
101{ 101{
102 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type)); 102 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
103 My_Conf_Subtype * sub; 103 My_Conf_Subtype *sub;
104 if (!my_conf) 104 if (!my_conf)
105 { 105 {
106 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 106 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -122,24 +122,24 @@ _my_conf_new(void)
122} /* _my_conf_new */ 122} /* _my_conf_new */
123 123
124static void 124static void
125_my_conf_free(My_Conf_Type * my_conf) 125_my_conf_free(My_Conf_Type *my_conf)
126{ 126{
127 My_Conf_Subtype * sub; 127 My_Conf_Subtype *sub;
128 EINA_LIST_FREE(my_conf->subs, sub) 128 EINA_LIST_FREE(my_conf->subs, sub)
129 { 129 {
130 eina_stringshare_del(sub->server); 130 eina_stringshare_del(sub->server);
131 free(sub); 131 free(sub);
132 } 132 }
133 133
134 eina_stringshare_del(my_conf->name); 134 eina_stringshare_del(my_conf->name);
135 free(my_conf); 135 free(my_conf);
136} /* _my_conf_free */ 136} /* _my_conf_free */
137 137
138static My_Conf_Type * 138static My_Conf_Type *
139_my_conf_load(const char * filename) 139_my_conf_load(const char *filename)
140{ 140{
141 My_Conf_Type * my_conf; 141 My_Conf_Type *my_conf;
142 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ); 142 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
143 if (!ef) 143 if (!ef)
144 { 144 {
145 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 145 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -148,7 +148,7 @@ _my_conf_load(const char * filename)
148 148
149 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY); 149 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
150 if (!my_conf) 150 if (!my_conf)
151 goto end; 151 goto end;
152 152
153 if (my_conf->version < 0x112233) 153 if (my_conf->version < 0x112233)
154 { 154 {
@@ -166,10 +166,11 @@ end:
166} /* _my_conf_load */ 166} /* _my_conf_load */
167 167
168static Eina_Bool 168static Eina_Bool
169_my_conf_save(const My_Conf_Type * my_conf, const char * filename) 169_my_conf_save(const My_Conf_Type *my_conf,
170 const char *filename)
170{ 171{
171 char tmp[PATH_MAX]; 172 char tmp[PATH_MAX];
172 Eet_File * ef; 173 Eet_File *ef;
173 Eina_Bool ret; 174 Eina_Bool ret;
174 unsigned int i, len; 175 unsigned int i, len;
175 struct stat st; 176 struct stat st;
@@ -197,7 +198,7 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
197 } 198 }
198 199
199 ret = eet_data_write 200 ret = eet_data_write
200 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE); 201 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
201 eet_close(ef); 202 eet_close(ef);
202 203
203 if (ret) 204 if (ret)
@@ -209,11 +210,13 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
209 return ret; 210 return ret;
210} /* _my_conf_save */ 211} /* _my_conf_save */
211 212
212int main(int argc, char * argv[]) 213int
214main(int argc,
215 char *argv[])
213{ 216{
214 My_Conf_Type * my_conf; 217 My_Conf_Type *my_conf;
215 const My_Conf_Subtype * sub; 218 const My_Conf_Subtype *sub;
216 const Eina_List * l; 219 const Eina_List *l;
217 int ret = 0; 220 int ret = 0;
218 221
219 if (argc != 3) 222 if (argc != 3)
@@ -250,12 +253,12 @@ int main(int argc, char * argv[])
250 my_conf->enabled); 253 my_conf->enabled);
251 254
252 EINA_LIST_FOREACH(my_conf->subs, l, sub) 255 EINA_LIST_FOREACH(my_conf->subs, l, sub)
253 printf("\t\tserver: '%s', port: %d\n", 256 printf("\t\tserver: '%s', port: %d\n",
254 sub->server ? sub->server : "", 257 sub->server ? sub->server : "",
255 sub->port); 258 sub->port);
256 259
257 if (!_my_conf_save(my_conf, argv[2])) 260 if (!_my_conf_save(my_conf, argv[2]))
258 ret = -3; 261 ret = -3;
259 262
260 _my_conf_free(my_conf); 263 _my_conf_free(my_conf);
261 264
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
index 395a8d66ab..1951fc012b 100644
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ b/legacy/eet/src/examples/eet-data-simple.c
@@ -17,7 +17,7 @@
17typedef struct 17typedef struct
18{ 18{
19 unsigned int version; // it is recommended to use versioned configuration! 19 unsigned int version; // it is recommended to use versioned configuration!
20 const char * name; 20 const char *name;
21 int id; 21 int id;
22 int not_saved_value; // example of not saved data inside! 22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled; 23 Eina_Bool enabled;
@@ -31,7 +31,7 @@ static const char MY_CONF_FILE_ENTRY[] = "config";
31// keep the descriptor static global, so it can be 31// keep the descriptor static global, so it can be
32// shared by different functions (load/save) of this and only this 32// shared by different functions (load/save) of this and only this
33// file. 33// file.
34static Eet_Data_Descriptor * _my_conf_descriptor; 34static Eet_Data_Descriptor *_my_conf_descriptor;
35 35
36static void 36static void
37_my_conf_descriptor_init(void) 37_my_conf_descriptor_init(void)
@@ -55,13 +55,13 @@ _my_conf_descriptor_init(void)
55 55
56 // Describe the members to be saved: 56 // Describe the members to be saved:
57 // Use a temporary macro so we don't type a lot, also avoid errors: 57 // Use a temporary macro so we don't type a lot, also avoid errors:
58#define MY_CONF_ADD_BASIC(member, eet_type)\ 58#define MY_CONF_ADD_BASIC(member, eet_type) \
59 EET_DATA_DESCRIPTOR_ADD_BASIC\ 59 EET_DATA_DESCRIPTOR_ADD_BASIC \
60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
61 61
62 MY_CONF_ADD_BASIC(version, EET_T_UINT); 62 MY_CONF_ADD_BASIC(version, EET_T_UINT);
63 MY_CONF_ADD_BASIC(name, EET_T_STRING); 63 MY_CONF_ADD_BASIC(name, EET_T_STRING);
64 MY_CONF_ADD_BASIC(id, EET_T_INT); 64 MY_CONF_ADD_BASIC(id, EET_T_INT);
65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
66 66
67#undef MY_CONF_ADD_BASIC 67#undef MY_CONF_ADD_BASIC
@@ -76,7 +76,7 @@ _my_conf_descriptor_shutdown(void)
76static My_Conf_Type * 76static My_Conf_Type *
77_my_conf_new(void) 77_my_conf_new(void)
78{ 78{
79 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type)); 79 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
80 if (!my_conf) 80 if (!my_conf)
81 { 81 {
82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -89,17 +89,17 @@ _my_conf_new(void)
89} /* _my_conf_new */ 89} /* _my_conf_new */
90 90
91static void 91static void
92_my_conf_free(My_Conf_Type * my_conf) 92_my_conf_free(My_Conf_Type *my_conf)
93{ 93{
94 eina_stringshare_del(my_conf->name); 94 eina_stringshare_del(my_conf->name);
95 free(my_conf); 95 free(my_conf);
96} /* _my_conf_free */ 96} /* _my_conf_free */
97 97
98static My_Conf_Type * 98static My_Conf_Type *
99_my_conf_load(const char * filename) 99_my_conf_load(const char *filename)
100{ 100{
101 My_Conf_Type * my_conf; 101 My_Conf_Type *my_conf;
102 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ); 102 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
103 if (!ef) 103 if (!ef)
104 { 104 {
105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -108,7 +108,7 @@ _my_conf_load(const char * filename)
108 108
109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY); 109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
110 if (!my_conf) 110 if (!my_conf)
111 goto end; 111 goto end;
112 112
113 if (my_conf->version < 0x112233) 113 if (my_conf->version < 0x112233)
114 { 114 {
@@ -126,10 +126,11 @@ end:
126} /* _my_conf_load */ 126} /* _my_conf_load */
127 127
128static Eina_Bool 128static Eina_Bool
129_my_conf_save(const My_Conf_Type * my_conf, const char * filename) 129_my_conf_save(const My_Conf_Type *my_conf,
130 const char *filename)
130{ 131{
131 char tmp[PATH_MAX]; 132 char tmp[PATH_MAX];
132 Eet_File * ef; 133 Eet_File *ef;
133 Eina_Bool ret; 134 Eina_Bool ret;
134 unsigned int i, len; 135 unsigned int i, len;
135 struct stat st; 136 struct stat st;
@@ -157,7 +158,7 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
157 } 158 }
158 159
159 ret = eet_data_write 160 ret = eet_data_write
160 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE); 161 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
161 eet_close(ef); 162 eet_close(ef);
162 163
163 if (ret) 164 if (ret)
@@ -169,9 +170,11 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
169 return ret; 170 return ret;
170} /* _my_conf_save */ 171} /* _my_conf_save */
171 172
172int main(int argc, char * argv[]) 173int
174main(int argc,
175 char *argv[])
173{ 176{
174 My_Conf_Type * my_conf; 177 My_Conf_Type *my_conf;
175 int ret = 0; 178 int ret = 0;
176 179
177 if (argc != 3) 180 if (argc != 3)
@@ -207,7 +210,7 @@ int main(int argc, char * argv[])
207 my_conf->enabled); 210 my_conf->enabled);
208 211
209 if (!_my_conf_save(my_conf, argv[2])) 212 if (!_my_conf_save(my_conf, argv[2]))
210 ret = -3; 213 ret = -3;
211 214
212 _my_conf_free(my_conf); 215 _my_conf_free(my_conf);
213 216
diff --git a/legacy/eet/src/examples/eet-file.c b/legacy/eet/src/examples/eet-file.c
index 017a6cd6bf..740c179f7b 100644
--- a/legacy/eet/src/examples/eet-file.c
+++ b/legacy/eet/src/examples/eet-file.c
@@ -12,25 +12,25 @@ create_eet_file(void)
12 char buf[1024], *ptr; 12 char buf[1024], *ptr;
13 int size, len, i; 13 int size, len, i;
14 const char *some_strings[] = { 14 const char *some_strings[] = {
15 "And some more strings", 15 "And some more strings",
16 "spread across several", 16 "spread across several",
17 "elements of an array!" 17 "elements of an array!"
18 }; 18 };
19 const char some_data[] = 19 const char some_data[] =
20 "\x1e\xe7\x0f\x42\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x35" 20 "\x1e\xe7\x0f\x42\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x35"
21 "\x00\x00\x00\xa0\x00\x00\x00\xa0\x00\x00\x00\x24\x00\x00\x00\x11" 21 "\x00\x00\x00\xa0\x00\x00\x00\xa0\x00\x00\x00\x24\x00\x00\x00\x11"
22 "\x00\x00\x00\x00\x2f\x6d\x69\x73\x74\x65\x72\x69\x6f\x75\x73\x2f" 22 "\x00\x00\x00\x00\x2f\x6d\x69\x73\x74\x65\x72\x69\x6f\x75\x73\x2f"
23 "\x64\x61\x74\x61\x00\x41\x6e\x20\x45\x45\x54\x20\x69\x6e\x73\x69" 23 "\x64\x61\x74\x61\x00\x41\x6e\x20\x45\x45\x54\x20\x69\x6e\x73\x69"
24 "\x64\x65\x20\x6f\x66\x20\x61\x6e\x20\x45\x45\x54\x21\x0a\x54\x68" 24 "\x64\x65\x20\x6f\x66\x20\x61\x6e\x20\x45\x45\x54\x21\x0a\x54\x68"
25 "\x69\x73\x20\x77\x61\x73\x6e\x27\x74\x20\x72\x65\x61\x6c\x6c\x79" 25 "\x69\x73\x20\x77\x61\x73\x6e\x27\x74\x20\x72\x65\x61\x6c\x6c\x79"
26 "\x20\x75\x73\x65\x66\x75\x6c\x20\x62\x75\x74\x20\x69\x74\x20\x68" 26 "\x20\x75\x73\x65\x66\x75\x6c\x20\x62\x75\x74\x20\x69\x74\x20\x68"
27 "\x65\x6c\x70\x65\x64\x20\x74\x6f\x20\x73\x68\x6f\x77\x20\x68\x6f" 27 "\x65\x6c\x70\x65\x64\x20\x74\x6f\x20\x73\x68\x6f\x77\x20\x68\x6f"
28 "\x77\x0a\x74\x6f\x20\x75\x73\x65\x20\x65\x65\x74\x5f\x6d\x65\x6d" 28 "\x77\x0a\x74\x6f\x20\x75\x73\x65\x20\x65\x65\x74\x5f\x6d\x65\x6d"
29 "\x6f\x70\x65\x6e\x5f\x72\x65\x61\x64\x28\x29\x20\x74\x6f\x20\x6f" 29 "\x6f\x70\x65\x6e\x5f\x72\x65\x61\x64\x28\x29\x20\x74\x6f\x20\x6f"
30 "\x70\x65\x6e\x20\x61\x6e\x20\x65\x65\x74\x20\x66\x69\x6c\x65\x20" 30 "\x70\x65\x6e\x20\x61\x6e\x20\x65\x65\x74\x20\x66\x69\x6c\x65\x20"
31 "\x66\x72\x6f\x6d\x0a\x64\x61\x74\x61\x20\x61\x6c\x72\x65\x61\x64" 31 "\x66\x72\x6f\x6d\x0a\x64\x61\x74\x61\x20\x61\x6c\x72\x65\x61\x64"
32 "\x79\x20\x6c\x6f\x61\x64\x65\x64\x20\x69\x6e\x20\x6d\x65\x6d\x6f" 32 "\x79\x20\x6c\x6f\x61\x64\x65\x64\x20\x69\x6e\x20\x6d\x65\x6d\x6f"
33 "\x72\x79\x2e\x0a\x00"; 33 "\x72\x79\x2e\x0a\x00";
34 34
35 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE); 35 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
36 if (!ef) return 0; 36 if (!ef) return 0;
@@ -60,67 +60,68 @@ create_eet_file(void)
60 60
61 eet_delete(ef, "/several/strings"); 61 eet_delete(ef, "/several/strings");
62 62
63 return (eet_close(ef) == EET_ERROR_NONE); 63 return eet_close(ef) == EET_ERROR_NONE;
64} 64}
65 65
66int 66int
67main(void) 67main(void)
68{ 68{
69 Eet_File *ef; 69 Eet_File *ef;
70 char *ret, **list; 70 char *ret, **list;
71 int size, num, i; 71 int size, num, i;
72 72
73 eet_init(); 73 eet_init();
74 74
75 if (!create_eet_file()) 75 if (!create_eet_file())
76 return -1; 76 return -1;
77 77
78 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ); 78 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
79 if (!ef) return -1; 79 if (!ef) return -1;
80 80
81 list = eet_list(ef, "*", &num); 81 list = eet_list(ef, "*", &num);
82 if (list) 82 if (list)
83 { 83 {
84 for (i = 0; i < num; i++) 84 for (i = 0; i < num; i++)
85 printf("Key stored: %s\n", list[i]); 85 printf("Key stored: %s\n", list[i]);
86 free(list); 86 free(list);
87 } 87 }
88 88
89 ret = eet_read(ef, "/key/to_store/at", &size); 89 ret = eet_read(ef, "/key/to_store/at", &size);
90 if (ret) 90 if (ret)
91 { 91 {
92 printf("Data read (%i bytes):\n%s\n", size, ret); 92 printf("Data read (%i bytes):\n%s\n", size, ret);
93 free(ret); 93 free(ret);
94 } 94 }
95 95
96 ret = eet_read(ef, "/several/strings", &size); 96 ret = eet_read(ef, "/several/strings", &size);
97 if (ret) 97 if (ret)
98 { 98 {
99 printf("More data read (%i bytes):\n%s\n", size, ret); 99 printf("More data read (%i bytes):\n%s\n", size, ret);
100 free(ret); 100 free(ret);
101 } 101 }
102 102
103 ret = eet_read(ef, "/some/mysterious/data", &size); 103 ret = eet_read(ef, "/some/mysterious/data", &size);
104 if (ret) 104 if (ret)
105 { 105 {
106 Eet_File *ef2; 106 Eet_File *ef2;
107 107
108 ef2 = eet_memopen_read(ret, size); 108 ef2 = eet_memopen_read(ret, size);
109 109
110 num = eet_num_entries(ef2); 110 num = eet_num_entries(ef2);
111 printf("Mysterious data has %d entries\n", num); 111 printf("Mysterious data has %d entries\n", num);
112 112
113 printf("Mysterious data:\n%s\n", 113 printf("Mysterious data:\n%s\n",
114 (char *)eet_read_direct(ef2, "/mysterious/data", NULL)); 114 (char *)eet_read_direct(ef2, "/mysterious/data", NULL));
115 115
116 eet_close(ef2); 116 eet_close(ef2);
117 117
118 free(ret); 118 free(ret);
119 } 119 }
120 120
121 eet_close(ef); 121 eet_close(ef);
122 122
123 eet_shutdown(); 123 eet_shutdown();
124 124
125 return 0; 125 return 0;
126} 126}
127