summaryrefslogtreecommitdiff
path: root/legacy/eet
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-07-28 01:45:57 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-07-28 01:45:57 +0000
commit926db95c5476a7e58ae30873227140b627fc292d (patch)
tree921fa2fb03c97910853287c1a15379175e845994 /legacy/eet
parentba10bce4342f61992ceaf06dc6299639cac83a81 (diff)
testing uncrustify on eet. this shall be standard efl formatting from
now on. you may run indent on code and convert to your own formatting if you want.. but all code MUST be "uncrustified" before being cxommitted to svn or before generating patches. time to get the formatting monster under control. SVN revision: 50563
Diffstat (limited to 'legacy/eet')
-rw-r--r--legacy/eet/src/bin/eet_main.c219
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor.c371
-rw-r--r--legacy/eet/src/examples/eet-data-nested.c128
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c93
-rw-r--r--legacy/eet/src/lib/Eet.h5975
-rw-r--r--legacy/eet/src/lib/Eet_private.h137
-rw-r--r--legacy/eet/src/lib/eet_cipher.c1181
-rw-r--r--legacy/eet/src/lib/eet_connection.c199
-rw-r--r--legacy/eet/src/lib/eet_data.c4689
-rw-r--r--legacy/eet/src/lib/eet_dictionary.c261
-rw-r--r--legacy/eet/src/lib/eet_image.c1862
-rw-r--r--legacy/eet/src/lib/eet_lib.c2172
-rw-r--r--legacy/eet/src/lib/eet_node.c534
-rw-r--r--legacy/eet/src/lib/eet_utils.c17
-rw-r--r--legacy/eet/src/tests/eet_data_suite.c39
-rw-r--r--legacy/eet/src/tests/eet_suite.c1218
16 files changed, 10888 insertions, 8207 deletions
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
index 5964d8a8ef..587146f7b8 100644
--- a/legacy/eet/src/bin/eet_main.c
+++ b/legacy/eet/src/bin/eet_main.c
@@ -58,20 +58,25 @@ do_eet_list(const char *file)
58 if (!ef) 58 if (!ef)
59 { 59 {
60 ERR("cannot open for reading: %s\n", file); 60 ERR("cannot open for reading: %s\n", file);
61 exit(-1); 61 exit(-1);
62 } 62 }
63
63 list = eet_list(ef, "*", &num); 64 list = eet_list(ef, "*", &num);
64 if (list) 65 if (list)
65 { 66 {
66 for (i = 0; i < num; i++) 67 for (i = 0; i < num; i++)
67 printf("%s\n",list[i]); 68 printf("%s\n",list[i]);
68 free(list); 69 free(list);
69 } 70 }
71
70 eet_close(ef); 72 eet_close(ef);
71} 73}
72 74
73static void 75static void
74do_eet_extract(const char *file, const char *key, const char *out, const char *crypto_key) 76do_eet_extract(const char *file,
77 const char *key,
78 const char *out,
79 const char *crypto_key)
75{ 80{
76 Eet_File *ef; 81 Eet_File *ef;
77 void *data; 82 void *data;
@@ -81,26 +86,30 @@ do_eet_extract(const char *file, const char *key, const char *out, const char *c
81 ef = eet_open(file, EET_FILE_MODE_READ); 86 ef = eet_open(file, EET_FILE_MODE_READ);
82 if (!ef) 87 if (!ef)
83 { 88 {
84 ERR("cannot open for reading: %s\n", file); 89 ERR("cannot open for reading: %s\n", file);
85 exit(-1); 90 exit(-1);
86 } 91 }
92
87 data = eet_read_cipher(ef, key, &size, crypto_key); 93 data = eet_read_cipher(ef, key, &size, crypto_key);
88 if (!data) 94 if (!data)
89 { 95 {
90 ERR("cannot read key %s\n", key); 96 ERR("cannot read key %s\n", key);
91 exit(-1); 97 exit(-1);
92 } 98 }
99
93 f = fopen(out, "wb"); 100 f = fopen(out, "wb");
94 if (!f) 101 if (!f)
95 { 102 {
96 ERR("cannot open %s\n", out); 103 ERR("cannot open %s\n", out);
97 exit(-1); 104 exit(-1);
98 } 105 }
106
99 if (fwrite(data, size, 1, f) != 1) 107 if (fwrite(data, size, 1, f) != 1)
100 { 108 {
101 ERR("cannot write to %s\n", out); 109 ERR("cannot write to %s\n", out);
102 exit(-1); 110 exit(-1);
103 } 111 }
112
104 fclose(f); 113 fclose(f);
105 free(data); 114 free(data);
106 eet_close(ef); 115 eet_close(ef);
@@ -113,7 +122,10 @@ do_eet_decode_dump(void *data, const char *str)
113} 122}
114 123
115static void 124static void
116do_eet_decode(const char *file, const char *key, const char *out, const char *crypto_key) 125do_eet_decode(const char *file,
126 const char *key,
127 const char *out,
128 const char *crypto_key)
117{ 129{
118 Eet_File *ef; 130 Eet_File *ef;
119 FILE *f; 131 FILE *f;
@@ -121,26 +133,33 @@ do_eet_decode(const char *file, const char *key, const char *out, const char *cr
121 ef = eet_open(file, EET_FILE_MODE_READ); 133 ef = eet_open(file, EET_FILE_MODE_READ);
122 if (!ef) 134 if (!ef)
123 { 135 {
124 ERR("cannot open for reading: %s\n", file); 136 ERR("cannot open for reading: %s\n", file);
125 exit(-1); 137 exit(-1);
126 } 138 }
139
127 f = fopen(out, "wb"); 140 f = fopen(out, "wb");
128 if (!f) 141 if (!f)
129 { 142 {
130 ERR("cannot open %s\n", out); 143 ERR("cannot open %s\n", out);
131 exit(-1); 144 exit(-1);
132 } 145 }
146
133 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f)) 147 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f))
134 { 148 {
135 ERR("cannot write to %s\n", out); 149 ERR("cannot write to %s\n", out);
136 exit(-1); 150 exit(-1);
137 } 151 }
152
138 fclose(f); 153 fclose(f);
139 eet_close(ef); 154 eet_close(ef);
140} 155}
141 156
142static void 157static void
143do_eet_insert(const char *file, const char *key, const char *out, int compress, const char *crypto_key) 158do_eet_insert(const char *file,
159 const char *key,
160 const char *out,
161 int compress,
162 const char *crypto_key)
144{ 163{
145 Eet_File *ef; 164 Eet_File *ef;
146 void *data; 165 void *data;
@@ -149,32 +168,37 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress,
149 168
150 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 169 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
151 if (!ef) 170 if (!ef)
152 ef = eet_open(file, EET_FILE_MODE_WRITE); 171 ef = eet_open(file, EET_FILE_MODE_WRITE);
172
153 if (!ef) 173 if (!ef)
154 { 174 {
155 ERR("cannot open for read+write: %s\n", file); 175 ERR("cannot open for read+write: %s\n", file);
156 exit(-1); 176 exit(-1);
157 } 177 }
178
158 f = fopen(out, "rb"); 179 f = fopen(out, "rb");
159 if (!f) 180 if (!f)
160 { 181 {
161 ERR("cannot open %s\n", out); 182 ERR("cannot open %s\n", out);
162 exit(-1); 183 exit(-1);
163 } 184 }
185
164 fseek(f, 0, SEEK_END); 186 fseek(f, 0, SEEK_END);
165 size = ftell(f); 187 size = ftell(f);
166 rewind(f); 188 rewind(f);
167 data = malloc(size); 189 data = malloc(size);
168 if (!data) 190 if (!data)
169 { 191 {
170 ERR("cannot allocate %i bytes\n", size); 192 ERR("cannot allocate %i bytes\n", size);
171 exit(-1); 193 exit(-1);
172 } 194 }
195
173 if (fread(data, size, 1, f) != 1) 196 if (fread(data, size, 1, f) != 1)
174 { 197 {
175 ERR("cannot read file %s\n", out); 198 ERR("cannot read file %s\n", out);
176 exit(-1); 199 exit(-1);
177 } 200 }
201
178 fclose(f); 202 fclose(f);
179 eet_write_cipher(ef, key, data, size, compress, crypto_key); 203 eet_write_cipher(ef, key, data, size, compress, crypto_key);
180 free(data); 204 free(data);
@@ -182,7 +206,11 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress,
182} 206}
183 207
184static void 208static void
185do_eet_encode(const char *file, const char *key, const char *out, int compress, const char *crypto_key) 209do_eet_encode(const char *file,
210 const char *key,
211 const char *out,
212 int compress,
213 const char *crypto_key)
186{ 214{
187 Eet_File *ef; 215 Eet_File *ef;
188 char *text; 216 char *text;
@@ -192,38 +220,44 @@ do_eet_encode(const char *file, const char *key, const char *out, int compress,
192 220
193 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 221 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
194 if (!ef) 222 if (!ef)
195 ef = eet_open(file, EET_FILE_MODE_WRITE); 223 ef = eet_open(file, EET_FILE_MODE_WRITE);
224
196 if (!ef) 225 if (!ef)
197 { 226 {
198 ERR("cannot open for read+write: %s\n", file); 227 ERR("cannot open for read+write: %s\n", file);
199 exit(-1); 228 exit(-1);
200 } 229 }
230
201 f = fopen(out, "rb"); 231 f = fopen(out, "rb");
202 if (!f) 232 if (!f)
203 { 233 {
204 ERR("cannot open %s\n", out); 234 ERR("cannot open %s\n", out);
205 exit(-1); 235 exit(-1);
206 } 236 }
237
207 fseek(f, 0, SEEK_END); 238 fseek(f, 0, SEEK_END);
208 textlen = ftell(f); 239 textlen = ftell(f);
209 rewind(f); 240 rewind(f);
210 text = malloc(textlen); 241 text = malloc(textlen);
211 if (!text) 242 if (!text)
212 { 243 {
213 ERR("cannot allocate %i bytes\n", size); 244 ERR("cannot allocate %i bytes\n", size);
214 exit(-1); 245 exit(-1);
215 } 246 }
247
216 if (fread(text, textlen, 1, f) != 1) 248 if (fread(text, textlen, 1, f) != 1)
217 { 249 {
218 ERR("cannot read file %s\n", out); 250 ERR("cannot read file %s\n", out);
219 exit(-1); 251 exit(-1);
220 } 252 }
253
221 fclose(f); 254 fclose(f);
222 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress)) 255 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress))
223 { 256 {
224 ERR("cannot parse %s\n", out); 257 ERR("cannot parse %s\n", out);
225 exit(-1); 258 exit(-1);
226 } 259 }
260
227 free(text); 261 free(text);
228 eet_close(ef); 262 eet_close(ef);
229} 263}
@@ -236,9 +270,10 @@ do_eet_remove(const char *file, const char *key)
236 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 270 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
237 if (!ef) 271 if (!ef)
238 { 272 {
239 ERR("cannot open for read+write: %s\n", file); 273 ERR("cannot open for read+write: %s\n", file);
240 exit(-1); 274 exit(-1);
241 } 275 }
276
242 eet_delete(ef, key); 277 eet_delete(ef, key);
243 eet_close(ef); 278 eet_close(ef);
244} 279}
@@ -254,8 +289,8 @@ do_eet_check(const char *file)
254 ef = eet_open(file, EET_FILE_MODE_READ); 289 ef = eet_open(file, EET_FILE_MODE_READ);
255 if (!ef) 290 if (!ef)
256 { 291 {
257 ERR("checking signature of `%s` failed\n", file); 292 ERR("checking signature of `%s` failed\n", file);
258 exit(-1); 293 exit(-1);
259 } 294 }
260 295
261 der = eet_identity_x509(ef, &der_length); 296 der = eet_identity_x509(ef, &der_length);
@@ -278,15 +313,15 @@ do_eet_sign(const char *file, const char *private_key, const char *public_key)
278 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 313 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
279 if (!ef) 314 if (!ef)
280 { 315 {
281 ERR("cannot open for read+write: %s.\n", file); 316 ERR("cannot open for read+write: %s.\n", file);
282 exit(-1); 317 exit(-1);
283 } 318 }
284 319
285 key = eet_identity_open(public_key, private_key, NULL); 320 key = eet_identity_open(public_key, private_key, NULL);
286 if (!key) 321 if (!key)
287 { 322 {
288 ERR("cannot open key '%s:%s'.\n", public_key, private_key); 323 ERR("cannot open key '%s:%s'.\n", public_key, private_key);
289 exit(-1); 324 exit(-1);
290 } 325 }
291 326
292 fprintf(stdout, "Using the following key to sign `%s`.\n", file); 327 fprintf(stdout, "Using the following key to sign `%s`.\n", file);
@@ -301,83 +336,75 @@ int
301main(int argc, char **argv) 336main(int argc, char **argv)
302{ 337{
303 if (!eet_init()) 338 if (!eet_init())
304 return -1; 339 return -1;
305 340
306 _eet_main_log_dom = eina_log_domain_register("Eet_Main",EINA_COLOR_CYAN); 341 _eet_main_log_dom = eina_log_domain_register("Eet_Main",EINA_COLOR_CYAN);
307 if(_eet_main_log_dom < -1) 342 if(_eet_main_log_dom < -1)
308 { 343 {
309 EINA_LOG_ERR("Impossible to create a log domain for eet_main.\n"); 344 EINA_LOG_ERR("Impossible to create a log domain for eet_main.\n");
310 eet_shutdown(); 345 eet_shutdown();
311 return(-1); 346 return(-1);
312 } 347 }
348
313 if (argc < 2) 349 if (argc < 2)
314 { 350 {
315 help: 351help:
316 printf("Usage:\n" 352 printf(
317 " eet -l FILE.EET list all keys in FILE.EET\n" 353 "Usage:\n"
318 " eet -x FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE\n" 354 " eet -l FILE.EET list all keys in FILE.EET\n"
319 " eet -d FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE\n" 355 " eet -x FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE\n"
320 " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" 356 " eet -d FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE\n"
321 " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" 357 " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
322 " eet -r FILE.EET KEY remove KEY in FILE.EET\n" 358 " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
323 " eet -c FILE.EET report and check the signature information of an eet file\n" 359 " eet -r FILE.EET KEY remove KEY in FILE.EET\n"
324 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n" 360 " eet -c FILE.EET report and check the signature information of an eet file\n"
325 ); 361 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n"
326 eet_shutdown(); 362 );
327 return -1; 363 eet_shutdown();
364 return -1;
328 } 365 }
366
329 if ((!strncmp(argv[1], "-h", 2))) 367 if ((!strncmp(argv[1], "-h", 2)))
330 { 368 goto help;
331 goto help;
332 }
333 else if ((!strcmp(argv[1], "-l")) && (argc > 2)) 369 else if ((!strcmp(argv[1], "-l")) && (argc > 2))
334 { 370 do_eet_list(argv[2]);
335 do_eet_list(argv[2]);
336 }
337 else if ((!strcmp(argv[1], "-x")) && (argc > 4)) 371 else if ((!strcmp(argv[1], "-x")) && (argc > 4))
338 { 372 {
339 if (argc > 5) 373 if (argc > 5)
340 do_eet_extract(argv[2], argv[3], argv[4], argv[5]); 374 do_eet_extract(argv[2], argv[3], argv[4], argv[5]);
341 else 375 else
342 do_eet_extract(argv[2], argv[3], argv[4], NULL); 376 do_eet_extract(argv[2], argv[3], argv[4], NULL);
343 } 377 }
344 else if ((!strcmp(argv[1], "-d")) && (argc > 4)) 378 else if ((!strcmp(argv[1], "-d")) && (argc > 4))
345 { 379 {
346 if (argc > 5) 380 if (argc > 5)
347 do_eet_decode(argv[2], argv[3], argv[4], argv[5]); 381 do_eet_decode(argv[2], argv[3], argv[4], argv[5]);
348 else 382 else
349 do_eet_decode(argv[2], argv[3], argv[4], NULL); 383 do_eet_decode(argv[2], argv[3], argv[4], NULL);
350 } 384 }
351 else if ((!strcmp(argv[1], "-i")) && (argc > 5)) 385 else if ((!strcmp(argv[1], "-i")) && (argc > 5))
352 { 386 {
353 if (argc > 6) 387 if (argc > 6)
354 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]); 388 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
355 else 389 else
356 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL); 390 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
357 } 391 }
358 else if ((!strcmp(argv[1], "-e")) && (argc > 5)) 392 else if ((!strcmp(argv[1], "-e")) && (argc > 5))
359 { 393 {
360 if (argc > 6) 394 if (argc > 6)
361 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]); 395 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
362 else 396 else
363 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL); 397 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
364 } 398 }
365 else if ((!strcmp(argv[1], "-r")) && (argc > 3)) 399 else if ((!strcmp(argv[1], "-r")) && (argc > 3))
366 { 400 do_eet_remove(argv[2], argv[3]);
367 do_eet_remove(argv[2], argv[3]);
368 }
369 else if ((!strcmp(argv[1], "-c")) && (argc > 2)) 401 else if ((!strcmp(argv[1], "-c")) && (argc > 2))
370 { 402 do_eet_check(argv[2]);
371 do_eet_check(argv[2]);
372 }
373 else if ((!strcmp(argv[1], "-s")) && (argc > 4)) 403 else if ((!strcmp(argv[1], "-s")) && (argc > 4))
374 { 404 do_eet_sign(argv[2], argv[3], argv[4]);
375 do_eet_sign(argv[2], argv[3], argv[4]);
376 }
377 else 405 else
378 { 406 goto help;
379 goto help; 407
380 }
381 eina_log_domain_unregister(_eet_main_log_dom); 408 eina_log_domain_unregister(_eet_main_log_dom);
382 eet_shutdown(); 409 eet_shutdown();
383 return 0; 410 return 0;
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor.c b/legacy/eet/src/examples/eet-data-file_descriptor.c
index c97b3984e5..a917e1d58b 100644
--- a/legacy/eet/src/examples/eet-data-file_descriptor.c
+++ b/legacy/eet/src/examples/eet-data-file_descriptor.c
@@ -7,7 +7,8 @@
7#include <unistd.h> 7#include <unistd.h>
8 8
9// complex real-world structures based on elmdentica database 9// complex real-world structures based on elmdentica database
10typedef struct { 10typedef struct
11{
11 const char *screen_name; 12 const char *screen_name;
12 const char *name; 13 const char *name;
13 const char *message; 14 const char *message;
@@ -17,19 +18,22 @@ typedef struct {
17 unsigned int timeline; 18 unsigned int timeline;
18} My_Message; 19} My_Message;
19 20
20typedef struct { 21typedef struct
22{
21 const char *dm_to; 23 const char *dm_to;
22 const char *message; 24 const char *message;
23} My_Post; 25} My_Post;
24 26
25typedef struct { 27typedef struct
28{
26 unsigned int id; 29 unsigned int id;
27 const char *name; 30 const char *name;
28 Eina_List *messages; 31 Eina_List *messages;
29 Eina_List *posts; 32 Eina_List *posts;
30} My_Account; 33} My_Account;
31 34
32typedef struct { 35typedef struct
36{
33 unsigned int version; // it is recommended to use versioned configuration! 37 unsigned int version; // it is recommended to use versioned configuration!
34 Eina_List *accounts; 38 Eina_List *accounts;
35} My_Cache; 39} My_Cache;
@@ -74,47 +78,47 @@ _my_cache_descriptor_init(void)
74 // Describe the members to be saved: 78 // Describe the members to be saved:
75 // 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:
76 80
77#define ADD_BASIC(member, eet_type) \ 81#define ADD_BASIC(member, eet_type) \
78 EET_DATA_DESCRIPTOR_ADD_BASIC \ 82 EET_DATA_DESCRIPTOR_ADD_BASIC \
79 (_my_message_descriptor, My_Message, #member, member, eet_type) 83 (_my_message_descriptor, My_Message, # member, member, eet_type)
80 ADD_BASIC(screen_name, EET_T_STRING); 84 ADD_BASIC(screen_name, EET_T_STRING);
81 ADD_BASIC(name, EET_T_STRING); 85 ADD_BASIC(name, EET_T_STRING);
82 ADD_BASIC(message, EET_T_STRING); 86 ADD_BASIC(message, EET_T_STRING);
83 ADD_BASIC(id, EET_T_UINT); 87 ADD_BASIC(id, EET_T_UINT);
84 ADD_BASIC(status_id, EET_T_UINT); 88 ADD_BASIC(status_id, EET_T_UINT);
85 ADD_BASIC(date, EET_T_UINT); 89 ADD_BASIC(date, EET_T_UINT);
86 ADD_BASIC(timeline, EET_T_UINT); 90 ADD_BASIC(timeline, EET_T_UINT);
87#undef ADD_BASIC 91#undef ADD_BASIC
88 92
89#define ADD_BASIC(member, eet_type) \ 93#define ADD_BASIC(member, eet_type) \
90 EET_DATA_DESCRIPTOR_ADD_BASIC \ 94 EET_DATA_DESCRIPTOR_ADD_BASIC \
91 (_my_post_descriptor, My_Post, #member, member, eet_type) 95 (_my_post_descriptor, My_Post, # member, member, eet_type)
92 ADD_BASIC(dm_to, EET_T_STRING); 96 ADD_BASIC(dm_to, EET_T_STRING);
93 ADD_BASIC(message, EET_T_STRING); 97 ADD_BASIC(message, EET_T_STRING);
94#undef ADD_BASIC 98#undef ADD_BASIC
95 99
96#define ADD_BASIC(member, eet_type) \ 100#define ADD_BASIC(member, eet_type) \
97 EET_DATA_DESCRIPTOR_ADD_BASIC \ 101 EET_DATA_DESCRIPTOR_ADD_BASIC \
98 (_my_account_descriptor, My_Account, #member, member, eet_type) 102 (_my_account_descriptor, My_Account, # member, member, eet_type)
99 ADD_BASIC(name, EET_T_STRING); 103 ADD_BASIC(name, EET_T_STRING);
100 ADD_BASIC(id, EET_T_UINT); 104 ADD_BASIC(id, EET_T_UINT);
101#undef ADD_BASIC 105#undef ADD_BASIC
102 106
103 EET_DATA_DESCRIPTOR_ADD_LIST 107 EET_DATA_DESCRIPTOR_ADD_LIST
104 (_my_account_descriptor, My_Account, "messages", messages, 108 (_my_account_descriptor, My_Account, "messages", messages,
105 _my_message_descriptor); 109 _my_message_descriptor);
106 EET_DATA_DESCRIPTOR_ADD_LIST 110 EET_DATA_DESCRIPTOR_ADD_LIST
107 (_my_account_descriptor, My_Account, "posts", posts, 111 (_my_account_descriptor, My_Account, "posts", posts,
108 _my_post_descriptor); 112 _my_post_descriptor);
109 113
110#define ADD_BASIC(member, eet_type) \ 114#define ADD_BASIC(member, eet_type) \
111 EET_DATA_DESCRIPTOR_ADD_BASIC \ 115 EET_DATA_DESCRIPTOR_ADD_BASIC \
112 (_my_cache_descriptor, My_Cache, #member, member, eet_type) 116 (_my_cache_descriptor, My_Cache, # member, member, eet_type)
113 ADD_BASIC(version, EET_T_UINT); 117 ADD_BASIC(version, EET_T_UINT);
114#undef ADD_BASIC 118#undef ADD_BASIC
115 119
116 EET_DATA_DESCRIPTOR_ADD_LIST 120 EET_DATA_DESCRIPTOR_ADD_LIST
117 (_my_cache_descriptor, My_Cache, "accounts", accounts, 121 (_my_cache_descriptor, My_Cache, "accounts", accounts,
118 _my_account_descriptor); 122 _my_account_descriptor);
119} 123}
120 124
@@ -133,9 +137,11 @@ static void
133_eet_string_free(const char *str) 137_eet_string_free(const char *str)
134{ 138{
135 if (!str) 139 if (!str)
136 return; 140 return;
141
137 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str))) 142 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str)))
138 return; 143 return;
144
139 eina_stringshare_del(str); 145 eina_stringshare_del(str);
140} 146}
141 147
@@ -145,9 +151,10 @@ _my_message_new(const char *message)
145 My_Message *msg = calloc(1, sizeof(My_Message)); 151 My_Message *msg = calloc(1, sizeof(My_Message));
146 if (!msg) 152 if (!msg)
147 { 153 {
148 fprintf(stderr, "ERROR: could not calloc My_Message\n"); 154 fprintf(stderr, "ERROR: could not calloc My_Message\n");
149 return NULL; 155 return NULL;
150 } 156 }
157
151 msg->message = eina_stringshare_add(message); 158 msg->message = eina_stringshare_add(message);
152 return msg; 159 return msg;
153} 160}
@@ -167,9 +174,10 @@ _my_post_new(const char *message)
167 My_Post *post = calloc(1, sizeof(My_Post)); 174 My_Post *post = calloc(1, sizeof(My_Post));
168 if (!post) 175 if (!post)
169 { 176 {
170 fprintf(stderr, "ERROR: could not calloc My_Post\n"); 177 fprintf(stderr, "ERROR: could not calloc My_Post\n");
171 return NULL; 178 return NULL;
172 } 179 }
180
173 post->message = eina_stringshare_add(message); 181 post->message = eina_stringshare_add(message);
174 return post; 182 return post;
175} 183}
@@ -188,9 +196,10 @@ _my_account_new(const char *name)
188 My_Account *acc = calloc(1, sizeof(My_Account)); 196 My_Account *acc = calloc(1, sizeof(My_Account));
189 if (!acc) 197 if (!acc)
190 { 198 {
191 fprintf(stderr, "ERROR: could not calloc My_Account\n"); 199 fprintf(stderr, "ERROR: could not calloc My_Account\n");
192 return NULL; 200 return NULL;
193 } 201 }
202
194 acc->name = eina_stringshare_add(name); 203 acc->name = eina_stringshare_add(name);
195 return acc; 204 return acc;
196} 205}
@@ -204,10 +213,10 @@ _my_account_free(My_Account *acc)
204 _eet_string_free(acc->name); 213 _eet_string_free(acc->name);
205 214
206 EINA_LIST_FREE(acc->messages, m) 215 EINA_LIST_FREE(acc->messages, m)
207 _my_message_free(m); 216 _my_message_free(m);
208 217
209 EINA_LIST_FREE(acc->posts, p) 218 EINA_LIST_FREE(acc->posts, p)
210 _my_post_free(p); 219 _my_post_free(p);
211 220
212 free(acc); 221 free(acc);
213} 222}
@@ -218,8 +227,8 @@ _my_cache_new(void)
218 My_Cache *my_cache = calloc(1, sizeof(My_Cache)); 227 My_Cache *my_cache = calloc(1, sizeof(My_Cache));
219 if (!my_cache) 228 if (!my_cache)
220 { 229 {
221 fprintf(stderr, "ERROR: could not calloc My_Cache\n"); 230 fprintf(stderr, "ERROR: could not calloc My_Cache\n");
222 return NULL; 231 return NULL;
223 } 232 }
224 233
225 my_cache->version = 1; 234 my_cache->version = 1;
@@ -231,7 +240,7 @@ _my_cache_free(My_Cache *my_cache)
231{ 240{
232 My_Account *acc; 241 My_Account *acc;
233 EINA_LIST_FREE(my_cache->accounts, acc) 242 EINA_LIST_FREE(my_cache->accounts, acc)
234 _my_account_free(acc); 243 _my_account_free(acc);
235 free(my_cache); 244 free(my_cache);
236} 245}
237 246
@@ -241,8 +250,9 @@ _my_cache_account_find(My_Cache *my_cache, const char *name)
241 My_Account *acc; 250 My_Account *acc;
242 Eina_List *l; 251 Eina_List *l;
243 EINA_LIST_FOREACH(my_cache->accounts, l, acc) 252 EINA_LIST_FOREACH(my_cache->accounts, l, acc)
244 if (strcmp(acc->name, name) == 0) 253 if (strcmp(acc->name, name) == 0)
245 return acc; 254 return acc;
255
246 return NULL; 256 return NULL;
247} 257}
248 258
@@ -253,28 +263,29 @@ _my_cache_load(const char *filename)
253 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 263 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
254 if (!ef) 264 if (!ef)
255 { 265 {
256 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 266 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
257 return NULL; 267 return NULL;
258 } 268 }
259 269
260 my_cache = eet_data_read(ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY); 270 my_cache = eet_data_read(ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY);
261 if (!my_cache) 271 if (!my_cache)
262 { 272 {
263 eet_close(ef); 273 eet_close(ef);
264 return NULL; 274 return NULL;
265 } 275 }
266 276
267 if (my_cache->version < 1) 277 if (my_cache->version < 1)
268 { 278 {
269 fprintf(stderr, 279 fprintf(stderr,
270 "WARNING: version %#x was too old, upgrading it to %#x\n", 280 "WARNING: version %#x was too old, upgrading it to %#x\n",
271 my_cache->version, 1); 281 my_cache->version, 1);
272 282
273 my_cache->version = 1; 283 my_cache->version = 1;
274 } 284 }
275 285
276 if (_my_cache_file) 286 if (_my_cache_file)
277 eet_close(_my_cache_file); 287 eet_close(_my_cache_file);
288
278 _my_cache_file = ef; 289 _my_cache_file = ef;
279 _my_cache_dict = eet_dictionary_get(ef); 290 _my_cache_dict = eet_dictionary_get(ef);
280 291
@@ -293,27 +304,27 @@ _my_cache_save(const My_Cache *my_cache, const char *filename)
293 len = eina_strlcpy(tmp, filename, sizeof(tmp)); 304 len = eina_strlcpy(tmp, filename, sizeof(tmp));
294 if (len + 12 >= (int)sizeof(tmp)) 305 if (len + 12 >= (int)sizeof(tmp))
295 { 306 {
296 fprintf(stderr, "ERROR: file name is too big: %s\n", filename); 307 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
297 return EINA_FALSE; 308 return EINA_FALSE;
298 } 309 }
299 310
300 i = 0; 311 i = 0;
301 do 312 do
302 { 313 {
303 snprintf(tmp + len, 12, ".%u", i); 314 snprintf(tmp + len, 12, ".%u", i);
304 i++; 315 i++;
305 } 316 }
306 while (stat(tmp, &st) == 0); 317 while (stat(tmp, &st) == 0);
307 318
308 ef = eet_open(tmp, EET_FILE_MODE_WRITE); 319 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
309 if (!ef) 320 if (!ef)
310 { 321 {
311 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp); 322 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
312 return EINA_FALSE; 323 return EINA_FALSE;
313 } 324 }
314 325
315 ret = eet_data_write 326 ret = eet_data_write
316 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE); 327 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE);
317 328
318 // VERY IMPORTANT NOTE: 329 // VERY IMPORTANT NOTE:
319 // after eet_close(), all strings mmaped from file will be GONE, invalid! 330 // after eet_close(), all strings mmaped from file will be GONE, invalid!
@@ -327,8 +338,8 @@ _my_cache_save(const My_Cache *my_cache, const char *filename)
327 338
328 if (ret) 339 if (ret)
329 { 340 {
330 unlink(filename); 341 unlink(filename);
331 rename(tmp, filename); 342 rename(tmp, filename);
332 } 343 }
333 344
334 return ret; 345 return ret;
@@ -343,15 +354,15 @@ int main(int argc, char *argv[])
343 354
344 if (argc < 3) 355 if (argc < 3)
345 { 356 {
346 fprintf(stderr, 357 fprintf(stderr,
347 "Usage:\n\t%s <input> <output> [action] [action-params]\n\n" 358 "Usage:\n\t%s <input> <output> [action] [action-params]\n\n"
348 "Where actions and their parameters:\n" 359 "Where actions and their parameters:\n"
349 "\tacc <name>\n" 360 "\tacc <name>\n"
350 "\tpost <account-name> <message>\n" 361 "\tpost <account-name> <message>\n"
351 "\tmessage <account-name> <message>\n" 362 "\tmessage <account-name> <message>\n"
352 "\n", 363 "\n",
353 argv[0]); 364 argv[0]);
354 return -1; 365 return -1;
355 } 366 }
356 367
357 eina_init(); 368 eina_init();
@@ -361,127 +372,131 @@ int main(int argc, char *argv[])
361 my_cache = _my_cache_load(argv[1]); 372 my_cache = _my_cache_load(argv[1]);
362 if (!my_cache) 373 if (!my_cache)
363 { 374 {
364 printf("creating new cache.\n"); 375 printf("creating new cache.\n");
365 my_cache = _my_cache_new(); 376 my_cache = _my_cache_new();
366 if (!my_cache) 377 if (!my_cache)
367 { 378 {
368 ret = -2; 379 ret = -2;
369 goto end; 380 goto end;
370 } 381 }
371 } 382 }
372 383
373 if (argc > 3) 384 if (argc > 3)
374 { 385 {
375 if (strcmp(argv[3], "acc") == 0) 386 if (strcmp(argv[3], "acc") == 0)
376 { 387 {
377 if (argc == 5) 388 if (argc == 5)
378 { 389 {
379 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 390 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
380 if (!acc) 391 if (!acc)
381 { 392 {
382 acc = _my_account_new(argv[4]); 393 acc = _my_account_new(argv[4]);
383 my_cache->accounts = eina_list_append 394 my_cache->accounts = eina_list_append
384 (my_cache->accounts, acc); 395 (my_cache->accounts, acc);
385 } 396 }
386 else 397 else
387 fprintf(stderr, "ERROR: account '%s' already exists.\n", 398 fprintf(stderr, "ERROR: account '%s' already exists.\n",
388 argv[4]); 399 argv[4]);
389 } 400 }
390 else 401 else
391 fprintf(stderr, "ERROR: wrong number of parameters (%d).\n", 402 fprintf(stderr,
392 argc); 403 "ERROR: wrong number of parameters (%d).\n",
393 } 404 argc);
394 else if (strcmp(argv[3], "post") == 0) 405 }
395 { 406 else if (strcmp(argv[3], "post") == 0)
396 if (argc == 6) 407 {
397 { 408 if (argc == 6)
398 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 409 {
399 if (acc) 410 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
400 { 411 if (acc)
401 My_Post *post = _my_post_new(argv[5]); 412 {
402 acc->posts = eina_list_append(acc->posts, post); 413 My_Post *post = _my_post_new(argv[5]);
403 } 414 acc->posts = eina_list_append(acc->posts, post);
404 else 415 }
405 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 416 else
406 } 417 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
407 else 418 }
408 fprintf(stderr, "ERROR: wrong number of parameters (%d).\n", 419 else
409 argc); 420 fprintf(stderr,
410 } 421 "ERROR: wrong number of parameters (%d).\n",
411 else if (strcmp(argv[3], "message") == 0) 422 argc);
412 { 423 }
413 if (argc == 6) 424 else if (strcmp(argv[3], "message") == 0)
414 { 425 {
415 My_Account *acc = _my_cache_account_find(my_cache, argv[4]); 426 if (argc == 6)
416 if (acc) 427 {
417 { 428 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
418 My_Message *msg = _my_message_new(argv[5]); 429 if (acc)
419 acc->messages = eina_list_append(acc->messages, msg); 430 {
420 } 431 My_Message *msg = _my_message_new(argv[5]);
421 else 432 acc->messages = eina_list_append(acc->messages, msg);
422 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); 433 }
423 } 434 else
424 else 435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
425 fprintf(stderr, "ERROR: wrong number of parameters (%d).\n", 436 }
426 argc); 437 else
427 } 438 fprintf(stderr,
428 else 439 "ERROR: wrong number of parameters (%d).\n",
429 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]); 440 argc);
441 }
442 else
443 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
430 } 444 }
431 445
432 printf("My_Cache:\n" 446 printf("My_Cache:\n"
433 "\tversion.: %#x\n" 447 "\tversion.: %#x\n"
434 "\taccounts: %u\n", 448 "\taccounts: %u\n",
435 my_cache->version, 449 my_cache->version,
436 eina_list_count(my_cache->accounts)); 450 eina_list_count(my_cache->accounts));
437 EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc) 451 EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc)
438 { 452 {
439 const My_Post *post; 453 const My_Post *post;
440 454
441 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n", 455 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
442 acc->id, acc->name ? acc->name : "", 456 acc->id, acc->name ? acc->name : "",
443 eina_list_count(acc->messages), 457 eina_list_count(acc->messages),
444 eina_list_count(acc->posts)); 458 eina_list_count(acc->posts));
445 459
446 if (eina_list_count(acc->messages)) 460 if (eina_list_count(acc->messages))
447 { 461 {
448 const Eina_List *l; 462 const Eina_List *l;
449 const My_Message *msg; 463 const My_Message *msg;
450 printf("\t |messages:\n"); 464 printf("\t |messages:\n");
451 465
452 EINA_LIST_FOREACH(acc->messages, l, msg) 466 EINA_LIST_FOREACH(acc->messages, l, msg)
453 { 467 {
454 printf("\t | %-8x '%s' [%s]: '%.20s'\n", 468 printf("\t | %-8x '%s' [%s]: '%.20s'\n",
455 msg->id, 469 msg->id,
456 msg->name ? msg->name : "", 470 msg->name ? msg->name : "",
457 msg->screen_name ? msg->screen_name : "", 471 msg->screen_name ? msg->screen_name : "",
458 msg->message ? msg->message : ""); 472 msg->message ? msg->message : "");
459 } 473 }
460 } 474 }
461 475
462 if (eina_list_count(acc->posts)) 476 if (eina_list_count(acc->posts))
463 { 477 {
464 const Eina_List *l; 478 const Eina_List *l;
465 const My_Post *post; 479 const My_Post *post;
466 printf("\t |posts:\n"); 480 printf("\t |posts:\n");
467 481
468 EINA_LIST_FOREACH(acc->posts, l, post) 482 EINA_LIST_FOREACH(acc->posts, l, post)
469 { 483 {
470 if (post->dm_to) 484 if (post->dm_to)
471 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message); 485 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
472 else 486 else
473 printf("\t | '%.20s'\n", post->message); 487 printf("\t | '%.20s'\n", post->message);
474 } 488 }
475 } 489 }
476 printf("\n"); 490
477 } 491 printf("\n");
492 }
478 493
479 if (!_my_cache_save(my_cache, argv[2])) 494 if (!_my_cache_save(my_cache, argv[2]))
480 ret = -3; 495 ret = -3;
481 496
482 _my_cache_free(my_cache); 497 _my_cache_free(my_cache);
483 498
484 end: 499end:
485 _my_cache_descriptor_shutdown(); 500 _my_cache_descriptor_shutdown();
486 eet_shutdown(); 501 eet_shutdown();
487 eina_shutdown(); 502 eina_shutdown();
diff --git a/legacy/eet/src/examples/eet-data-nested.c b/legacy/eet/src/examples/eet-data-nested.c
index 52a095d3c1..3675718a03 100644
--- a/legacy/eet/src/examples/eet-data-nested.c
+++ b/legacy/eet/src/examples/eet-data-nested.c
@@ -11,7 +11,8 @@
11// will be automatically handled. The other members will have their 11// will be automatically handled. The other members will have their
12// space reserved and zeroed (as it uses calloc()), but not 12// space reserved and zeroed (as it uses calloc()), but not
13// saved or loaded from eet files. 13// saved or loaded from eet files.
14typedef struct { 14typedef struct
15{
15 unsigned int version; // it is recommended to use versioned configuration! 16 unsigned int version; // it is recommended to use versioned configuration!
16 const char *name; 17 const char *name;
17 int id; 18 int id;
@@ -20,7 +21,8 @@ typedef struct {
20 Eina_List *subs; 21 Eina_List *subs;
21} My_Conf_Type; 22} My_Conf_Type;
22 23
23typedef struct { 24typedef struct
25{
24 const char *server; 26 const char *server;
25 int port; 27 int port;
26} My_Conf_Subtype; 28} My_Conf_Subtype;
@@ -62,24 +64,24 @@ _my_conf_descriptor_init(void)
62 64
63 // Describe the members to be saved: 65 // Describe the members to be saved:
64 // Use a temporary macro so we don't type a lot, also avoid errors: 66 // Use a temporary macro so we don't type a lot, also avoid errors:
65#define MY_CONF_ADD_BASIC(member, eet_type) \ 67#define MY_CONF_ADD_BASIC(member, eet_type) \
66 EET_DATA_DESCRIPTOR_ADD_BASIC \ 68 EET_DATA_DESCRIPTOR_ADD_BASIC \
67 (_my_conf_descriptor, My_Conf_Type, #member, member, eet_type) 69 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
68#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \ 70#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \
69 EET_DATA_DESCRIPTOR_ADD_BASIC \ 71 EET_DATA_DESCRIPTOR_ADD_BASIC \
70 (_my_conf_sub_descriptor, My_Conf_Subtype, #member, member, eet_type) 72 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
71 73
72 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING); 74 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
73 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT); 75 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT);
74 76
75 MY_CONF_ADD_BASIC(version, EET_T_UINT); 77 MY_CONF_ADD_BASIC(version, EET_T_UINT);
76 MY_CONF_ADD_BASIC(name, EET_T_STRING); 78 MY_CONF_ADD_BASIC(name, EET_T_STRING);
77 MY_CONF_ADD_BASIC(id, EET_T_INT); 79 MY_CONF_ADD_BASIC(id, EET_T_INT);
78 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 80 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
79 81
80 // And add the sub descriptor as a linked list at 'subs' in the main struct 82 // And add the sub descriptor as a linked list at 'subs' in the main struct
81 EET_DATA_DESCRIPTOR_ADD_LIST 83 EET_DATA_DESCRIPTOR_ADD_LIST
82 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor); 84 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor);
83 85
84#undef MY_CONF_ADD_BASIC 86#undef MY_CONF_ADD_BASIC
85#undef MY_CONF_SUB_ADD_BASIC 87#undef MY_CONF_SUB_ADD_BASIC
@@ -99,8 +101,8 @@ _my_conf_new(void)
99 My_Conf_Subtype *sub; 101 My_Conf_Subtype *sub;
100 if (!my_conf) 102 if (!my_conf)
101 { 103 {
102 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 104 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
103 return NULL; 105 return NULL;
104 } 106 }
105 107
106 my_conf->version = 0x112233; 108 my_conf->version = 0x112233;
@@ -109,9 +111,9 @@ _my_conf_new(void)
109 sub = calloc(1, sizeof(My_Conf_Subtype)); 111 sub = calloc(1, sizeof(My_Conf_Subtype));
110 if (sub) 112 if (sub)
111 { 113 {
112 sub->server = eina_stringshare_add("my-server.com"); 114 sub->server = eina_stringshare_add("my-server.com");
113 sub->port = 1234; 115 sub->port = 1234;
114 my_conf->subs = eina_list_append(my_conf->subs, sub); 116 my_conf->subs = eina_list_append(my_conf->subs, sub);
115 } 117 }
116 118
117 return my_conf; 119 return my_conf;
@@ -122,10 +124,10 @@ _my_conf_free(My_Conf_Type *my_conf)
122{ 124{
123 My_Conf_Subtype *sub; 125 My_Conf_Subtype *sub;
124 EINA_LIST_FREE(my_conf->subs, sub) 126 EINA_LIST_FREE(my_conf->subs, sub)
125 { 127 {
126 eina_stringshare_del(sub->server); 128 eina_stringshare_del(sub->server);
127 free(sub); 129 free(sub);
128 } 130 }
129 131
130 eina_stringshare_del(my_conf->name); 132 eina_stringshare_del(my_conf->name);
131 free(my_conf); 133 free(my_conf);
@@ -138,25 +140,25 @@ _my_conf_load(const char *filename)
138 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 140 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
139 if (!ef) 141 if (!ef)
140 { 142 {
141 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 143 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
142 return NULL; 144 return NULL;
143 } 145 }
144 146
145 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY); 147 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
146 if (!my_conf) 148 if (!my_conf)
147 goto end; 149 goto end;
148 150
149 if (my_conf->version < 0x112233) 151 if (my_conf->version < 0x112233)
150 { 152 {
151 fprintf(stderr, 153 fprintf(stderr,
152 "WARNING: version %#x was too old, upgrading it to %#x\n", 154 "WARNING: version %#x was too old, upgrading it to %#x\n",
153 my_conf->version, 0x112233); 155 my_conf->version, 0x112233);
154 156
155 my_conf->version = 0x112233; 157 my_conf->version = 0x112233;
156 my_conf->enabled = EINA_TRUE; 158 my_conf->enabled = EINA_TRUE;
157 } 159 }
158 160
159 end: 161end:
160 eet_close(ef); 162 eet_close(ef);
161 return my_conf; 163 return my_conf;
162} 164}
@@ -173,33 +175,33 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
173 len = eina_strlcpy(tmp, filename, sizeof(tmp)); 175 len = eina_strlcpy(tmp, filename, sizeof(tmp));
174 if (len + 12 >= (int)sizeof(tmp)) 176 if (len + 12 >= (int)sizeof(tmp))
175 { 177 {
176 fprintf(stderr, "ERROR: file name is too big: %s\n", filename); 178 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
177 return EINA_FALSE; 179 return EINA_FALSE;
178 } 180 }
179 181
180 i = 0; 182 i = 0;
181 do 183 do
182 { 184 {
183 snprintf(tmp + len, 12, ".%u", i); 185 snprintf(tmp + len, 12, ".%u", i);
184 i++; 186 i++;
185 } 187 }
186 while (stat(tmp, &st) == 0); 188 while (stat(tmp, &st) == 0);
187 189
188 ef = eet_open(tmp, EET_FILE_MODE_WRITE); 190 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
189 if (!ef) 191 if (!ef)
190 { 192 {
191 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp); 193 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
192 return EINA_FALSE; 194 return EINA_FALSE;
193 } 195 }
194 196
195 ret = eet_data_write 197 ret = eet_data_write
196 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE); 198 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
197 eet_close(ef); 199 eet_close(ef);
198 200
199 if (ret) 201 if (ret)
200 { 202 {
201 unlink(filename); 203 unlink(filename);
202 rename(tmp, filename); 204 rename(tmp, filename);
203 } 205 }
204 206
205 return ret; 207 return ret;
@@ -214,8 +216,8 @@ int main(int argc, char *argv[])
214 216
215 if (argc != 3) 217 if (argc != 3)
216 { 218 {
217 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]); 219 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
218 return -1; 220 return -1;
219 } 221 }
220 222
221 eina_init(); 223 eina_init();
@@ -225,37 +227,37 @@ int main(int argc, char *argv[])
225 my_conf = _my_conf_load(argv[1]); 227 my_conf = _my_conf_load(argv[1]);
226 if (!my_conf) 228 if (!my_conf)
227 { 229 {
228 printf("creating new configuration.\n"); 230 printf("creating new configuration.\n");
229 my_conf = _my_conf_new(); 231 my_conf = _my_conf_new();
230 if (!my_conf) 232 if (!my_conf)
231 { 233 {
232 ret = -2; 234 ret = -2;
233 goto end; 235 goto end;
234 } 236 }
235 } 237 }
236 238
237 printf("My_Conf_Type:\n" 239 printf("My_Conf_Type:\n"
238 "\tversion: %#x\n" 240 "\tversion: %#x\n"
239 "\tname...: '%s'\n" 241 "\tname...: '%s'\n"
240 "\tid.....: %d\n" 242 "\tid.....: %d\n"
241 "\tenabled: %hhu\n" 243 "\tenabled: %hhu\n"
242 "\tsubs...:\n", 244 "\tsubs...:\n",
243 my_conf->version, 245 my_conf->version,
244 my_conf->name ? my_conf->name : "", 246 my_conf->name ? my_conf->name : "",
245 my_conf->id, 247 my_conf->id,
246 my_conf->enabled); 248 my_conf->enabled);
247 249
248 EINA_LIST_FOREACH(my_conf->subs, l, sub) 250 EINA_LIST_FOREACH(my_conf->subs, l, sub)
249 printf("\t\tserver: '%s', port: %d\n", 251 printf("\t\tserver: '%s', port: %d\n",
250 sub->server ? sub->server : "", 252 sub->server ? sub->server : "",
251 sub->port); 253 sub->port);
252 254
253 if (!_my_conf_save(my_conf, argv[2])) 255 if (!_my_conf_save(my_conf, argv[2]))
254 ret = -3; 256 ret = -3;
255 257
256 _my_conf_free(my_conf); 258 _my_conf_free(my_conf);
257 259
258 end: 260end:
259 _my_conf_descriptor_shutdown(); 261 _my_conf_descriptor_shutdown();
260 eet_shutdown(); 262 eet_shutdown();
261 eina_shutdown(); 263 eina_shutdown();
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
index 72d00c96d9..a4efd4ad7a 100644
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ b/legacy/eet/src/examples/eet-data-simple.c
@@ -11,7 +11,8 @@
11// will be automatically handled. The other members will have their 11// will be automatically handled. The other members will have their
12// space reserved and zeroed (as it uses calloc()), but not 12// space reserved and zeroed (as it uses calloc()), but not
13// saved or loaded from eet files. 13// saved or loaded from eet files.
14typedef struct { 14typedef struct
15{
15 unsigned int version; // it is recommended to use versioned configuration! 16 unsigned int version; // it is recommended to use versioned configuration!
16 const char *name; 17 const char *name;
17 int id; 18 int id;
@@ -52,13 +53,13 @@ _my_conf_descriptor_init(void)
52 53
53 // Describe the members to be saved: 54 // Describe the members to be saved:
54 // Use a temporary macro so we don't type a lot, also avoid errors: 55 // Use a temporary macro so we don't type a lot, also avoid errors:
55#define MY_CONF_ADD_BASIC(member, eet_type) \ 56#define MY_CONF_ADD_BASIC(member, eet_type) \
56 EET_DATA_DESCRIPTOR_ADD_BASIC \ 57 EET_DATA_DESCRIPTOR_ADD_BASIC \
57 (_my_conf_descriptor, My_Conf_Type, #member, member, eet_type) 58 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
58 59
59 MY_CONF_ADD_BASIC(version, EET_T_UINT); 60 MY_CONF_ADD_BASIC(version, EET_T_UINT);
60 MY_CONF_ADD_BASIC(name, EET_T_STRING); 61 MY_CONF_ADD_BASIC(name, EET_T_STRING);
61 MY_CONF_ADD_BASIC(id, EET_T_INT); 62 MY_CONF_ADD_BASIC(id, EET_T_INT);
62 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 63 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
63 64
64#undef MY_CONF_ADD_BASIC 65#undef MY_CONF_ADD_BASIC
@@ -76,8 +77,8 @@ _my_conf_new(void)
76 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); 77 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
77 if (!my_conf) 78 if (!my_conf)
78 { 79 {
79 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 80 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
80 return NULL; 81 return NULL;
81 } 82 }
82 83
83 my_conf->version = 0x112233; 84 my_conf->version = 0x112233;
@@ -99,25 +100,25 @@ _my_conf_load(const char *filename)
99 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 100 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
100 if (!ef) 101 if (!ef)
101 { 102 {
102 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 103 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
103 return NULL; 104 return NULL;
104 } 105 }
105 106
106 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY); 107 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
107 if (!my_conf) 108 if (!my_conf)
108 goto end; 109 goto end;
109 110
110 if (my_conf->version < 0x112233) 111 if (my_conf->version < 0x112233)
111 { 112 {
112 fprintf(stderr, 113 fprintf(stderr,
113 "WARNING: version %#x was too old, upgrading it to %#x\n", 114 "WARNING: version %#x was too old, upgrading it to %#x\n",
114 my_conf->version, 0x112233); 115 my_conf->version, 0x112233);
115 116
116 my_conf->version = 0x112233; 117 my_conf->version = 0x112233;
117 my_conf->enabled = EINA_TRUE; 118 my_conf->enabled = EINA_TRUE;
118 } 119 }
119 120
120 end: 121end:
121 eet_close(ef); 122 eet_close(ef);
122 return my_conf; 123 return my_conf;
123} 124}
@@ -134,33 +135,33 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
134 len = eina_strlcpy(tmp, filename, sizeof(tmp)); 135 len = eina_strlcpy(tmp, filename, sizeof(tmp));
135 if (len + 12 >= (int)sizeof(tmp)) 136 if (len + 12 >= (int)sizeof(tmp))
136 { 137 {
137 fprintf(stderr, "ERROR: file name is too big: %s\n", filename); 138 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
138 return EINA_FALSE; 139 return EINA_FALSE;
139 } 140 }
140 141
141 i = 0; 142 i = 0;
142 do 143 do
143 { 144 {
144 snprintf(tmp + len, 12, ".%u", i); 145 snprintf(tmp + len, 12, ".%u", i);
145 i++; 146 i++;
146 } 147 }
147 while (stat(tmp, &st) == 0); 148 while (stat(tmp, &st) == 0);
148 149
149 ef = eet_open(tmp, EET_FILE_MODE_WRITE); 150 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
150 if (!ef) 151 if (!ef)
151 { 152 {
152 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp); 153 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
153 return EINA_FALSE; 154 return EINA_FALSE;
154 } 155 }
155 156
156 ret = eet_data_write 157 ret = eet_data_write
157 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE); 158 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
158 eet_close(ef); 159 eet_close(ef);
159 160
160 if (ret) 161 if (ret)
161 { 162 {
162 unlink(filename); 163 unlink(filename);
163 rename(tmp, filename); 164 rename(tmp, filename);
164 } 165 }
165 166
166 return ret; 167 return ret;
@@ -173,8 +174,8 @@ int main(int argc, char *argv[])
173 174
174 if (argc != 3) 175 if (argc != 3)
175 { 176 {
176 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]); 177 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
177 return -1; 178 return -1;
178 } 179 }
179 180
180 eina_init(); 181 eina_init();
@@ -184,31 +185,31 @@ int main(int argc, char *argv[])
184 my_conf = _my_conf_load(argv[1]); 185 my_conf = _my_conf_load(argv[1]);
185 if (!my_conf) 186 if (!my_conf)
186 { 187 {
187 printf("creating new configuration.\n"); 188 printf("creating new configuration.\n");
188 my_conf = _my_conf_new(); 189 my_conf = _my_conf_new();
189 if (!my_conf) 190 if (!my_conf)
190 { 191 {
191 ret = -2; 192 ret = -2;
192 goto end; 193 goto end;
193 } 194 }
194 } 195 }
195 196
196 printf("My_Conf_Type:\n" 197 printf("My_Conf_Type:\n"
197 "\tversion: %#x\n" 198 "\tversion: %#x\n"
198 "\tname...: '%s'\n" 199 "\tname...: '%s'\n"
199 "\tid.....: %d\n" 200 "\tid.....: %d\n"
200 "\tenabled: %hhu\n", 201 "\tenabled: %hhu\n",
201 my_conf->version, 202 my_conf->version,
202 my_conf->name ? my_conf->name : "", 203 my_conf->name ? my_conf->name : "",
203 my_conf->id, 204 my_conf->id,
204 my_conf->enabled); 205 my_conf->enabled);
205 206
206 if (!_my_conf_save(my_conf, argv[2])) 207 if (!_my_conf_save(my_conf, argv[2]))
207 ret = -3; 208 ret = -3;
208 209
209 _my_conf_free(my_conf); 210 _my_conf_free(my_conf);
210 211
211 end: 212end:
212 _my_conf_descriptor_shutdown(); 213 _my_conf_descriptor_shutdown();
213 eet_shutdown(); 214 eet_shutdown();
214 eina_shutdown(); 215 eina_shutdown();
diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h
index 78532185a0..2104d8068d 100644
--- a/legacy/eet/src/lib/Eet.h
+++ b/legacy/eet/src/lib/Eet.h
@@ -34,1491 +34,1653 @@
34#ifdef __cplusplus 34#ifdef __cplusplus
35extern "C" { 35extern "C" {
36#endif 36#endif
37 37
38 /** 38/**
39 * @file Eet.h 39 * @file Eet.h
40 * @brief The file that provides the eet functions. 40 * @brief The file that provides the eet functions.
41 * 41 *
42 * This header provides the Eet management functions. 42 * This header provides the Eet management functions.
43 * 43 *
44 */ 44 */
45 45
46#define EET_VERSION_MAJOR 1 46#define EET_VERSION_MAJOR 1
47#define EET_VERSION_MINOR 3 47#define EET_VERSION_MINOR 3
48 /** 48/**
49 * @typedef Eet_Version 49 * @typedef Eet_Version
50 * 50 *
51 * This is the Eet version information structure that can be used at 51 * This is the Eet version information structure that can be used at
52 * runtiime to detect which version of eet is being used and adapt 52 * runtiime to detect which version of eet is being used and adapt
53 * appropriately as follows for example: 53 * appropriately as follows for example:
54 * 54 *
55 * @code 55 * @code
56 * #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined(EET_VERSION_MINOR) && (EET_VERSION_MINOR > 2) 56 * #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined(EET_VERSION_MINOR) && (EET_VERSION_MINOR > 2)
57 * printf("Eet version: %i.%i.%i\n", 57 * printf("Eet version: %i.%i.%i\n",
58 * eet_version->major, 58 * eet_version->major,
59 * eet_version->minor, 59 * eet_version->minor,
60 * eet_version->micro); 60 * eet_version->micro);
61 * if (eet_version->revision > 0) 61 * if (eet_version->revision > 0)
62 * { 62 * {
63 * printf(" Built from SVN revision # %i\n", eet_version->revision); 63 * printf(" Built from SVN revision # %i\n", eet_version->revision);
64 * } 64 * }
65 * #endif 65 * #endif
66 * @endcode 66 * @endcode
67 * 67 *
68 * Note the #if check can be dropped if your program refuses to compile or 68 * Note the #if check can be dropped if your program refuses to compile or
69 * work with an Eet version less than 1.3.0. 69 * work with an Eet version less than 1.3.0.
70 */ 70 */
71 typedef struct _Eet_Version 71typedef struct _Eet_Version
72 { 72{
73 int major; /** < major (binary or source incompatible changes) */ 73 int major; /** < major (binary or source incompatible changes) */
74 int minor; /** < minor (new features, bugfixes, major improvements version) */ 74 int minor; /** < minor (new features, bugfixes, major improvements version) */
75 int micro; /** < micro (bugfix, internal improvements, no new features version) */ 75 int micro; /** < micro (bugfix, internal improvements, no new features version) */
76 int revision; /** < svn revision (0 if a proper rlease or the svn revsion number Eet is built from) */ 76 int revision; /** < svn revision (0 if a proper rlease or the svn revsion number Eet is built from) */
77 } Eet_Version; 77} Eet_Version;
78 78
79 EAPI extern Eet_Version *eet_version; 79EAPI extern Eet_Version *eet_version;
80 80
81 /** 81/**
82 * @defgroup Eet_Group Top level functions 82 * @defgroup Eet_Group Top level functions
83 * Functions that affect Eet as a whole. 83 * Functions that affect Eet as a whole.
84 * 84 *
85 * @{ 85 * @{
86 */ 86 */
87 87
88 /** 88/**
89 * @enum _Eet_Error 89 * @enum _Eet_Error
90 * All the error identifiers known by Eet. 90 * All the error identifiers known by Eet.
91 */ 91 */
92 typedef enum _Eet_Error 92typedef enum _Eet_Error
93 { 93{
94 EET_ERROR_NONE, /**< No error, it's all fine! */ 94 EET_ERROR_NONE, /**< No error, it's all fine! */
95 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */ 95 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
96 EET_ERROR_EMPTY, /**< There was nothing to do */ 96 EET_ERROR_EMPTY, /**< There was nothing to do */
97 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */ 97 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */
98 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */ 98 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
99 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */ 99 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
100 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */ 100 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
101 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */ 101 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */
102 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */ 102 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
103 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */ 103 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
104 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */ 104 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
105 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */ 105 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
106 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */ 106 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
107 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */ 107 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
108 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */ 108 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
109 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */ 109 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
110 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */ 110 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
111 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */ 111 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
112 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */ 112 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
113 } Eet_Error; /**< Eet error identifiers */ 113} Eet_Error; /**< Eet error identifiers */
114 114
115 /** 115/**
116 * @} 116 * @}
117 */ 117 */
118 118
119 /** 119/**
120 * Initialize the EET library. 120 * Initialize the EET library.
121 * 121 *
122 * @return The new init count. 122 * @return The new init count.
123 * 123 *
124 * @since 1.0.0 124 * @since 1.0.0
125 * @ingroup Eet_Group 125 * @ingroup Eet_Group
126 */ 126 */
127 EAPI int eet_init(void); 127EAPI int eet_init(void);
128 128
129 /** 129/**
130 * Shut down the EET library. 130 * Shut down the EET library.
131 * 131 *
132 * @return The new init count. 132 * @return The new init count.
133 * 133 *
134 * @since 1.0.0 134 * @since 1.0.0
135 * @ingroup Eet_Group 135 * @ingroup Eet_Group
136 */ 136 */
137 EAPI int eet_shutdown(void); 137EAPI int eet_shutdown(void);
138 138
139 /** 139/**
140 * Clear eet cache 140 * Clear eet cache
141 * 141 *
142 * Eet didn't free items by default. If you are under memory 142 * Eet didn't free items by default. If you are under memory
143 * presure, just call this function to recall all memory that are 143 * presure, just call this function to recall all memory that are
144 * not yet referenced anymore. The cache take care of modification 144 * not yet referenced anymore. The cache take care of modification
145 * on disk. 145 * on disk.
146 * 146 *
147 * @since 1.0.0 147 * @since 1.0.0
148 * @ingroup Eet_Group 148 * @ingroup Eet_Group
149 */ 149 */
150 EAPI void eet_clearcache(void); 150EAPI void eet_clearcache(void);
151 151
152 152
153 /** 153/**
154 * @defgroup Eet_File_Group Eet File Main Functions 154 * @defgroup Eet_File_Group Eet File Main Functions
155 * 155 *
156 * Functions to create, destroy and do basic manipulation of 156 * Functions to create, destroy and do basic manipulation of
157 * #Eet_File handles. 157 * #Eet_File handles.
158 * 158 *
159 * @{ 159 * @{
160 */ 160 */
161 161
162 /** 162/**
163 * @enum _Eet_File_Mode 163 * @enum _Eet_File_Mode
164 * Modes that a file can be opened. 164 * Modes that a file can be opened.
165 */ 165 */
166 typedef enum _Eet_File_Mode 166typedef enum _Eet_File_Mode
167 { 167{
168 EET_FILE_MODE_INVALID = -1, 168 EET_FILE_MODE_INVALID = -1,
169 EET_FILE_MODE_READ, /**< File is read-only. */ 169 EET_FILE_MODE_READ, /**< File is read-only. */
170 EET_FILE_MODE_WRITE, /**< File is write-only. */ 170 EET_FILE_MODE_WRITE, /**< File is write-only. */
171 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */ 171 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
172 } Eet_File_Mode; /**< Modes that a file can be opened. */ 172} Eet_File_Mode; /**< Modes that a file can be opened. */
173 173
174 /** 174/**
175 * @typedef Eet_File 175 * @typedef Eet_File
176 * Opaque handle that defines an Eet file (or memory). 176 * Opaque handle that defines an Eet file (or memory).
177 * 177 *
178 * @see eet_open() 178 * @see eet_open()
179 * @see eet_memopen_read() 179 * @see eet_memopen_read()
180 * @see eet_close() 180 * @see eet_close()
181 */ 181 */
182 typedef struct _Eet_File Eet_File; 182typedef struct _Eet_File Eet_File;
183 183
184 /** 184/**
185 * @typedef Eet_Dictionary 185 * @typedef Eet_Dictionary
186 * Opaque handle that defines a file-backed (mmaped) dictionary of strings. 186 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
187 */ 187 */
188 typedef struct _Eet_Dictionary Eet_Dictionary; 188typedef struct _Eet_Dictionary Eet_Dictionary;
189 189
190 190
191 /** 191/**
192 * @} 192 * @}
193 */ 193 */
194 194
195 /** 195/**
196 * Open an eet file on disk, and returns a handle to it. 196 * Open an eet file on disk, and returns a handle to it.
197 * @param file The file path to the eet file. eg: @c "/tmp/file.eet". 197 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
198 * @param mode The mode for opening. Either #EET_FILE_MODE_READ, 198 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
199 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE. 199 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
200 * @return An opened eet file handle. 200 * @return An opened eet file handle.
201 * @ingroup Eet_File_Group 201 * @ingroup Eet_File_Group
202 * 202 *
203 * This function will open an exiting eet file for reading, and build 203 * This function will open an exiting eet file for reading, and build
204 * the directory table in memory and return a handle to the file, if it 204 * the directory table in memory and return a handle to the file, if it
205 * exists and can be read, and no memory errors occur on the way, otherwise 205 * exists and can be read, and no memory errors occur on the way, otherwise
206 * NULL will be returned. 206 * NULL will be returned.
207 * 207 *
208 * It will also open an eet file for writing. This will, if successful, 208 * It will also open an eet file for writing. This will, if successful,
209 * delete the original file and replace it with a new empty file, till 209 * delete the original file and replace it with a new empty file, till
210 * the eet file handle is closed or flushed. If it cannot be opened for 210 * the eet file handle is closed or flushed. If it cannot be opened for
211 * writing or a memory error occurs, NULL is returned. 211 * writing or a memory error occurs, NULL is returned.
212 * 212 *
213 * You can also open the file for read/write. If you then write a key that 213 * You can also open the file for read/write. If you then write a key that
214 * does not exist it will be created, if the key exists it will be replaced 214 * does not exist it will be created, if the key exists it will be replaced
215 * by the new data. 215 * by the new data.
216 * 216 *
217 * Example: 217 * Example:
218 * @code 218 * @code
219 * #include <Eet.h> 219 * #include <Eet.h>
220 * #include <stdio.h> 220 * #include <stdio.h>
221 * #include <string.h> 221 * #include <string.h>
222 * 222 *
223 * int 223 * int
224 * main(int argc, char **argv) 224 * main(int argc, char **argv)
225 * { 225 * {
226 * Eet_File *ef; 226 * Eet_File *ef;
227 * char buf[1024], *ret, **list; 227 * char buf[1024], *ret, **list;
228 * int size, num, i; 228 * int size, num, i;
229 * 229 *
230 * eet_init(); 230 * eet_init();
231 * 231 *
232 * strcpy(buf, "Here is a string of data to save!"); 232 * strcpy(buf, "Here is a string of data to save!");
233 * 233 *
234 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE); 234 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
235 * if (!ef) return -1; 235 * if (!ef) return -1;
236 * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1)) 236 * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
237 * fprintf(stderr, "Error writing data!\n"); 237 * fprintf(stderr, "Error writing data!\n");
238 * eet_close(ef); 238 * eet_close(ef);
239 * 239 *
240 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ); 240 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
241 * if (!ef) return -1; 241 * if (!ef) return -1;
242 * list = eet_list(ef, "*", &num); 242 * list = eet_list(ef, "*", &num);
243 * if (list) 243 * if (list)
244 * { 244 * {
245 * for (i = 0; i < num; i++) 245 * for (i = 0; i < num; i++)
246 * printf("Key stored: %s\n", list[i]); 246 * printf("Key stored: %s\n", list[i]);
247 * free(list); 247 * free(list);
248 * } 248 * }
249 * ret = eet_read(ef, "/key/to_store/at", &size); 249 * ret = eet_read(ef, "/key/to_store/at", &size);
250 * if (ret) 250 * if (ret)
251 * { 251 * {
252 * printf("Data read (%i bytes):\n%s\n", size, ret); 252 * printf("Data read (%i bytes):\n%s\n", size, ret);
253 * free(ret); 253 * free(ret);
254 * } 254 * }
255 * eet_close(ef); 255 * eet_close(ef);
256 * 256 *
257 * eet_shutdown(); 257 * eet_shutdown();
258 * 258 *
259 * return 0; 259 * return 0;
260 * } 260 * }
261 * @endcode 261 * @endcode
262 * 262 *
263 * @since 1.0.0 263 * @since 1.0.0
264 */ 264 */
265 EAPI Eet_File *eet_open(const char *file, Eet_File_Mode mode); 265EAPI Eet_File * eet_open(const char *file, Eet_File_Mode mode);
266 266
267 /** 267/**
268 * Open an eet file directly from a memory location. The data are not copied, 268 * Open an eet file directly from a memory location. The data are not copied,
269 * so you must keep them around as long as the eet file is open. Their is 269 * so you must keep them around as long as the eet file is open. Their is
270 * currently no cache for this kind of Eet_File, so it's reopen every time 270 * currently no cache for this kind of Eet_File, so it's reopen every time
271 * you do use eet_memopen_read. 271 * you do use eet_memopen_read.
272 * 272 *
273 * @since 1.1.0 273 * @since 1.1.0
274 * @ingroup Eet_File_Group 274 * @ingroup Eet_File_Group
275 */ 275 */
276 EAPI Eet_File *eet_memopen_read(const void *data, size_t size); 276EAPI Eet_File * eet_memopen_read(const void *data, size_t size);
277 277
278 /** 278/**
279 * Get the mode an Eet_File was opened with. 279 * Get the mode an Eet_File was opened with.
280 * @param ef A valid eet file handle. 280 * @param ef A valid eet file handle.
281 * @return The mode ef was opened with. 281 * @return The mode ef was opened with.
282 * 282 *
283 * @since 1.0.0 283 * @since 1.0.0
284 * @ingroup Eet_File_Group 284 * @ingroup Eet_File_Group
285 */ 285 */
286 EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); 286EAPI Eet_File_Mode eet_mode_get(Eet_File *ef);
287 287
288 /** 288/**
289 * Close an eet file handle and flush and writes pending. 289 * Close an eet file handle and flush and writes pending.
290 * @param ef A valid eet file handle. 290 * @param ef A valid eet file handle.
291 * 291 *
292 * This function will flush any pending writes to disk if the eet file 292 * This function will flush any pending writes to disk if the eet file
293 * was opened for write, and free all data associated with the file handle 293 * was opened for write, and free all data associated with the file handle
294 * and file, and close the file. 294 * and file, and close the file.
295 * 295 *
296 * If the eet file handle is not valid nothing will be done. 296 * If the eet file handle is not valid nothing will be done.
297 * 297 *
298 * @since 1.0.0 298 * @since 1.0.0
299 * @ingroup Eet_File_Group 299 * @ingroup Eet_File_Group
300 */ 300 */
301 EAPI Eet_Error eet_close(Eet_File *ef); 301EAPI Eet_Error eet_close(Eet_File *ef);
302 302
303 /** 303/**
304 * Sync content of an eet file handle, flushing pending writes. 304 * Sync content of an eet file handle, flushing pending writes.
305 * @param ef A valid eet file handle. 305 * @param ef A valid eet file handle.
306 * 306 *
307 * This function will flush any pending writes to disk. The eet file must 307 * This function will flush any pending writes to disk. The eet file must
308 * be opened for write. 308 * be opened for write.
309 * 309 *
310 * If the eet file handle is not valid nothing will be done. 310 * If the eet file handle is not valid nothing will be done.
311 * 311 *
312 * @since 1.2.4 312 * @since 1.2.4
313 * @ingroup Eet_File_Group 313 * @ingroup Eet_File_Group
314 */ 314 */
315 EAPI Eet_Error eet_sync(Eet_File *ef); 315EAPI Eet_Error eet_sync(Eet_File *ef);
316 316
317 /** 317/**
318 * Return a handle to the shared string dictionary of the Eet file 318 * Return a handle to the shared string dictionary of the Eet file
319 * @param ef A valid eet file handle. 319 * @param ef A valid eet file handle.
320 * @return A handle to the dictionary of the file 320 * @return A handle to the dictionary of the file
321 * 321 *
322 * This function returns a handle to the dictionary of an Eet file whose 322 * This function returns a handle to the dictionary of an Eet file whose
323 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or 323 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
324 * if the file handle is known to be invalid. 324 * if the file handle is known to be invalid.
325 * 325 *
326 * @see eet_dictionary_string_check() to know if given string came 326 * @see eet_dictionary_string_check() to know if given string came
327 * from the dictionary or it was dynamically allocated using 327 * from the dictionary or it was dynamically allocated using
328 * the #Eet_Data_Descriptor_Class instructrions. 328 * the #Eet_Data_Descriptor_Class instructrions.
329 * 329 *
330 * @since 1.0.0 330 * @since 1.0.0
331 * @ingroup Eet_File_Group 331 * @ingroup Eet_File_Group
332 */ 332 */
333 EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef); 333EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef);
334 334
335 /** 335/**
336 * Check if a given string comes from a given dictionary 336 * Check if a given string comes from a given dictionary
337 * @param ed A valid dictionary handle 337 * @param ed A valid dictionary handle
338 * @param string A valid 0 byte terminated C string 338 * @param string A valid 0 byte terminated C string
339 * @return 1 if it is in the dictionary, 0 otherwise 339 * @return 1 if it is in the dictionary, 0 otherwise
340 * 340 *
341 * This checks the given dictionary to see if the given string is actually 341 * This checks the given dictionary to see if the given string is actually
342 * inside that dictionary (i.e. comes from it) and returns 1 if it does. 342 * inside that dictionary (i.e. comes from it) and returns 1 if it does.
343 * If the dictionary handle is invlide, the string is NULL or the string is 343 * If the dictionary handle is invlide, the string is NULL or the string is
344 * not in the dictionary, 0 is returned. 344 * not in the dictionary, 0 is returned.
345 * 345 *
346 * @since 1.0.0 346 * @since 1.0.0
347 * @ingroup Eet_File_Group 347 * @ingroup Eet_File_Group
348 */ 348 */
349 EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); 349EAPI int eet_dictionary_string_check(Eet_Dictionary *ed,
350 350 const char *string);
351 /** 351
352 * Read a specified entry from an eet file and return data 352/**
353 * @param ef A valid eet file handle opened for reading. 353 * Read a specified entry from an eet file and return data
354 * @param name Name of the entry. eg: "/base/file_i_want". 354 * @param ef A valid eet file handle opened for reading.
355 * @param size_ret Number of bytes read from entry and returned. 355 * @param name Name of the entry. eg: "/base/file_i_want".
356 * @return The data stored in that entry in the eet file. 356 * @param size_ret Number of bytes read from entry and returned.
357 * 357 * @return The data stored in that entry in the eet file.
358 * This function finds an entry in the eet file that is stored under the 358 *
359 * name specified, and returns that data, decompressed, if successful. 359 * This function finds an entry in the eet file that is stored under the
360 * NULL is returned if the lookup fails or if memory errors are 360 * name specified, and returns that data, decompressed, if successful.
361 * encountered. It is the job of the calling program to call free() on 361 * NULL is returned if the lookup fails or if memory errors are
362 * the returned data. The number of bytes in the returned data chunk are 362 * encountered. It is the job of the calling program to call free() on
363 * placed in size_ret. 363 * the returned data. The number of bytes in the returned data chunk are
364 * 364 * placed in size_ret.
365 * If the eet file handle is not valid NULL is returned and size_ret is 365 *
366 * filled with 0. 366 * If the eet file handle is not valid NULL is returned and size_ret is
367 * 367 * filled with 0.
368 * @see eet_read_cipher() 368 *
369 * 369 * @see eet_read_cipher()
370 * @since 1.0.0 370 *
371 * @ingroup Eet_File_Group 371 * @since 1.0.0
372 */ 372 * @ingroup Eet_File_Group
373 EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret); 373 */
374 374EAPI void * eet_read(Eet_File *ef, const char *name, int *size_ret);
375 /** 375
376 * Read a specified entry from an eet file and return data 376/**
377 * @param ef A valid eet file handle opened for reading. 377 * Read a specified entry from an eet file and return data
378 * @param name Name of the entry. eg: "/base/file_i_want". 378 * @param ef A valid eet file handle opened for reading.
379 * @param size_ret Number of bytes read from entry and returned. 379 * @param name Name of the entry. eg: "/base/file_i_want".
380 * @return The data stored in that entry in the eet file. 380 * @param size_ret Number of bytes read from entry and returned.
381 * 381 * @return The data stored in that entry in the eet file.
382 * This function finds an entry in the eet file that is stored under the 382 *
383 * name specified, and returns that data if not compressed and successful. 383 * This function finds an entry in the eet file that is stored under the
384 * NULL is returned if the lookup fails or if memory errors are 384 * name specified, and returns that data if not compressed and successful.
385 * encountered or if the data is comrpessed. The calling program must never 385 * NULL is returned if the lookup fails or if memory errors are
386 * call free() on the returned data. The number of bytes in the returned 386 * encountered or if the data is comrpessed. The calling program must never
387 * data chunk are placed in size_ret. 387 * call free() on the returned data. The number of bytes in the returned
388 * 388 * data chunk are placed in size_ret.
389 * If the eet file handle is not valid NULL is returned and size_ret is 389 *
390 * filled with 0. 390 * If the eet file handle is not valid NULL is returned and size_ret is
391 * 391 * filled with 0.
392 * @since 1.0.0 392 *
393 * @ingroup Eet_File_Group 393 * @since 1.0.0
394 */ 394 * @ingroup Eet_File_Group
395 EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret); 395 */
396 396EAPI const void * eet_read_direct(Eet_File *ef,
397 /** 397 const char *name,
398 * Write a specified entry to an eet file handle 398 int *size_ret);
399 * @param ef A valid eet file handle opened for writing. 399
400 * @param name Name of the entry. eg: "/base/file_i_want". 400/**
401 * @param data Pointer to the data to be stored. 401 * Write a specified entry to an eet file handle
402 * @param size Length in bytes in the data to be stored. 402 * @param ef A valid eet file handle opened for writing.
403 * @param compress Compression flags (1 == compress, 0 = don't compress). 403 * @param name Name of the entry. eg: "/base/file_i_want".
404 * @return bytes written on successful write, 0 on failure. 404 * @param data Pointer to the data to be stored.
405 * 405 * @param size Length in bytes in the data to be stored.
406 * This function will write the specified chunk of data to the eet file 406 * @param compress Compression flags (1 == compress, 0 = don't compress).
407 * and return greater than 0 on success. 0 will be returned on failure. 407 * @return bytes written on successful write, 0 on failure.
408 * 408 *
409 * The eet file handle must be a valid file handle for an eet file opened 409 * This function will write the specified chunk of data to the eet file
410 * for writing. If it is not, 0 will be returned and no action will be 410 * and return greater than 0 on success. 0 will be returned on failure.
411 * performed. 411 *
412 * 412 * The eet file handle must be a valid file handle for an eet file opened
413 * Name, and data must not be NULL, and size must be > 0. If these 413 * for writing. If it is not, 0 will be returned and no action will be
414 * conditions are not met, 0 will be returned. 414 * performed.
415 * 415 *
416 * The data will be copied (and optionally compressed) in ram, pending 416 * Name, and data must not be NULL, and size must be > 0. If these
417 * a flush to disk (it will stay in ram till the eet file handle is 417 * conditions are not met, 0 will be returned.
418 * closed though). 418 *
419 * 419 * The data will be copied (and optionally compressed) in ram, pending
420 * @see eet_write_cipher() 420 * a flush to disk (it will stay in ram till the eet file handle is
421 * 421 * closed though).
422 * @since 1.0.0 422 *
423 * @ingroup Eet_File_Group 423 * @see eet_write_cipher()
424 */ 424 *
425 EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress); 425 * @since 1.0.0
426 426 * @ingroup Eet_File_Group
427 /** 427 */
428 * Delete a specified entry from an Eet file being written or re-written 428EAPI int eet_write(Eet_File *ef,
429 * @param ef A valid eet file handle opened for writing. 429 const char *name,
430 * @param name Name of the entry. eg: "/base/file_i_want". 430 const void *data,
431 * @return Success or failure of the delete. 431 int size,
432 * 432 int compress);
433 * This function will delete the specified chunk of data from the eet file 433
434 * and return greater than 0 on success. 0 will be returned on failure. 434/**
435 * 435 * Delete a specified entry from an Eet file being written or re-written
436 * The eet file handle must be a valid file handle for an eet file opened 436 * @param ef A valid eet file handle opened for writing.
437 * for writing. If it is not, 0 will be returned and no action will be 437 * @param name Name of the entry. eg: "/base/file_i_want".
438 * performed. 438 * @return Success or failure of the delete.
439 * 439 *
440 * Name, must not be NULL, otherwise 0 will be returned. 440 * This function will delete the specified chunk of data from the eet file
441 * 441 * and return greater than 0 on success. 0 will be returned on failure.
442 * @since 1.0.0 442 *
443 * @ingroup Eet_File_Group 443 * The eet file handle must be a valid file handle for an eet file opened
444 */ 444 * for writing. If it is not, 0 will be returned and no action will be
445 EAPI int eet_delete(Eet_File *ef, const char *name); 445 * performed.
446 446 *
447 /** 447 * Name, must not be NULL, otherwise 0 will be returned.
448 * Alias a specific section to another one. Destination may exist or not, 448 *
449 * no check are done. 449 * @since 1.0.0
450 * @param ef A valid eet file handle opened for writing. 450 * @ingroup Eet_File_Group
451 * @param name Name of the entry. eg: "/base/file_i_want". 451 */
452 * @param destination Destionation of the alias. eg: "/base/the_real_stuff_i_want". 452EAPI int eet_delete(Eet_File *ef, const char *name);
453 * @param compress Compression flags (1 == compress, 0 = don't compress). 453
454 * @return EINA_TRUE on success, EINA_FALSE on failure. 454/**
455 * 455 * Alias a specific section to another one. Destination may exist or not,
456 * Name and Destination must not be NULL, otherwhise EINA_FALSE will be returned. 456 * no check are done.
457 * 457 * @param ef A valid eet file handle opened for writing.
458 * @since 1.3.3 458 * @param name Name of the entry. eg: "/base/file_i_want".
459 * @ingroup Eet_File_Group 459 * @param destination Destionation of the alias. eg: "/base/the_real_stuff_i_want".
460 */ 460 * @param compress Compression flags (1 == compress, 0 = don't compress).
461 EAPI Eina_Bool eet_alias(Eet_File *ef, const char *name, const char *destination, int compress); 461 * @return EINA_TRUE on success, EINA_FALSE on failure.
462 462 *
463 463 * Name and Destination must not be NULL, otherwhise EINA_FALSE will be returned.
464 /** 464 *
465 * List all entries in eet file matching shell glob. 465 * @since 1.3.3
466 * @param ef A valid eet file handle. 466 * @ingroup Eet_File_Group
467 * @param glob A shell glob to match against. 467 */
468 * @param count_ret Number of entries found to match. 468EAPI Eina_Bool eet_alias(Eet_File *ef,
469 * @return Pointer to an array of strings. 469 const char *name,
470 * 470 const char *destination,
471 * This function will list all entries in the eet file matching the 471 int compress);
472 * supplied shell glob and return an allocated list of their names, if 472
473 * there are any, and if no memory errors occur. 473
474 * 474/**
475 * The eet file handle must be valid and glob must not be NULL, or NULL 475 * List all entries in eet file matching shell glob.
476 * will be returned and count_ret will be filled with 0. 476 * @param ef A valid eet file handle.
477 * 477 * @param glob A shell glob to match against.
478 * The calling program must call free() on the array returned, but NOT 478 * @param count_ret Number of entries found to match.
479 * on the string pointers in the array. They are taken as read-only 479 * @return Pointer to an array of strings.
480 * internals from the eet file handle. They are only valid as long as 480 *
481 * the file handle is not closed. When it is closed those pointers in the 481 * This function will list all entries in the eet file matching the
482 * array are now not valid and should not be used. 482 * supplied shell glob and return an allocated list of their names, if
483 * 483 * there are any, and if no memory errors occur.
484 * On success the array returned will have a list of string pointers 484 *
485 * that are the names of the entries that matched, and count_ret will have 485 * The eet file handle must be valid and glob must not be NULL, or NULL
486 * the number of entries in this array placed in it. 486 * will be returned and count_ret will be filled with 0.
487 * 487 *
488 * Hint: an easy way to list all entries in an eet file is to use a glob 488 * The calling program must call free() on the array returned, but NOT
489 * value of "*". 489 * on the string pointers in the array. They are taken as read-only
490 * 490 * internals from the eet file handle. They are only valid as long as
491 * @since 1.0.0 491 * the file handle is not closed. When it is closed those pointers in the
492 * @ingroup Eet_File_Group 492 * array are now not valid and should not be used.
493 */ 493 *
494 EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret); 494 * On success the array returned will have a list of string pointers
495 495 * that are the names of the entries that matched, and count_ret will have
496 /** 496 * the number of entries in this array placed in it.
497 * Return the number of entries in the specified eet file. 497 *
498 * @param ef A valid eet file handle. 498 * Hint: an easy way to list all entries in an eet file is to use a glob
499 * @return Number of entries in ef or -1 if the number of entries 499 * value of "*".
500 * cannot be read due to open mode restrictions. 500 *
501 * 501 * @since 1.0.0
502 * @since 1.0.0 502 * @ingroup Eet_File_Group
503 * @ingroup Eet_File_Group 503 */
504 */ 504EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret);
505 EAPI int eet_num_entries(Eet_File *ef); 505
506 506/**
507 /** 507 * Return the number of entries in the specified eet file.
508 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions 508 * @param ef A valid eet file handle.
509 * 509 * @return Number of entries in ef or -1 if the number of entries
510 * Most of the @ref Eet_File_Group have alternative versions that 510 * cannot be read due to open mode restrictions.
511 * accounts for ciphers to protect their content. 511 *
512 * 512 * @since 1.0.0
513 * @see @ref Eet_Cipher_Group 513 * @ingroup Eet_File_Group
514 * 514 */
515 * @ingroup Eet_File_Group 515EAPI int eet_num_entries(Eet_File *ef);
516 */ 516
517 517/**
518 /** 518 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
519 * Read a specified entry from an eet file and return data using a cipher. 519 *
520 * @param ef A valid eet file handle opened for reading. 520 * Most of the @ref Eet_File_Group have alternative versions that
521 * @param name Name of the entry. eg: "/base/file_i_want". 521 * accounts for ciphers to protect their content.
522 * @param size_ret Number of bytes read from entry and returned. 522 *
523 * @param cipher_key The key to use as cipher. 523 * @see @ref Eet_Cipher_Group
524 * @return The data stored in that entry in the eet file. 524 *
525 * 525 * @ingroup Eet_File_Group
526 * This function finds an entry in the eet file that is stored under the 526 */
527 * name specified, and returns that data, decompressed, if successful. 527
528 * NULL is returned if the lookup fails or if memory errors are 528/**
529 * encountered. It is the job of the calling program to call free() on 529 * Read a specified entry from an eet file and return data using a cipher.
530 * the returned data. The number of bytes in the returned data chunk are 530 * @param ef A valid eet file handle opened for reading.
531 * placed in size_ret. 531 * @param name Name of the entry. eg: "/base/file_i_want".
532 * 532 * @param size_ret Number of bytes read from entry and returned.
533 * If the eet file handle is not valid NULL is returned and size_ret is 533 * @param cipher_key The key to use as cipher.
534 * filled with 0. 534 * @return The data stored in that entry in the eet file.
535 * 535 *
536 * @see eet_read() 536 * This function finds an entry in the eet file that is stored under the
537 * 537 * name specified, and returns that data, decompressed, if successful.
538 * @since 1.0.0 538 * NULL is returned if the lookup fails or if memory errors are
539 * @ingroup Eet_File_Cipher_Group 539 * encountered. It is the job of the calling program to call free() on
540 */ 540 * the returned data. The number of bytes in the returned data chunk are
541 EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key); 541 * placed in size_ret.
542 542 *
543 /** 543 * If the eet file handle is not valid NULL is returned and size_ret is
544 * Write a specified entry to an eet file handle using a cipher. 544 * filled with 0.
545 * @param ef A valid eet file handle opened for writing. 545 *
546 * @param name Name of the entry. eg: "/base/file_i_want". 546 * @see eet_read()
547 * @param data Pointer to the data to be stored. 547 *
548 * @param size Length in bytes in the data to be stored. 548 * @since 1.0.0
549 * @param compress Compression flags (1 == compress, 0 = don't compress). 549 * @ingroup Eet_File_Cipher_Group
550 * @param cipher_key The key to use as cipher. 550 */
551 * @return bytes written on successful write, 0 on failure. 551EAPI void * eet_read_cipher(Eet_File *ef,
552 * 552 const char *name,
553 * This function will write the specified chunk of data to the eet file 553 int *size_ret,
554 * and return greater than 0 on success. 0 will be returned on failure. 554 const char *cipher_key);
555 * 555
556 * The eet file handle must be a valid file handle for an eet file opened 556/**
557 * for writing. If it is not, 0 will be returned and no action will be 557 * Write a specified entry to an eet file handle using a cipher.
558 * performed. 558 * @param ef A valid eet file handle opened for writing.
559 * 559 * @param name Name of the entry. eg: "/base/file_i_want".
560 * Name, and data must not be NULL, and size must be > 0. If these 560 * @param data Pointer to the data to be stored.
561 * conditions are not met, 0 will be returned. 561 * @param size Length in bytes in the data to be stored.
562 * 562 * @param compress Compression flags (1 == compress, 0 = don't compress).
563 * The data will be copied (and optionally compressed) in ram, pending 563 * @param cipher_key The key to use as cipher.
564 * a flush to disk (it will stay in ram till the eet file handle is 564 * @return bytes written on successful write, 0 on failure.
565 * closed though). 565 *
566 * 566 * This function will write the specified chunk of data to the eet file
567 * @see eet_write() 567 * and return greater than 0 on success. 0 will be returned on failure.
568 * 568 *
569 * @since 1.0.0 569 * The eet file handle must be a valid file handle for an eet file opened
570 * @ingroup Eet_File_Cipher_Group 570 * for writing. If it is not, 0 will be returned and no action will be
571 */ 571 * performed.
572 EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key); 572 *
573 573 * Name, and data must not be NULL, and size must be > 0. If these
574 574 * conditions are not met, 0 will be returned.
575 /** 575 *
576 * @defgroup Eet_File_Image_Group Image Store and Load 576 * The data will be copied (and optionally compressed) in ram, pending
577 * 577 * a flush to disk (it will stay in ram till the eet file handle is
578 * Eet efficiently stores and loads images, including alpha 578 * closed though).
579 * channels and lossy compressions. 579 *
580 */ 580 * @see eet_write()
581 581 *
582 /** 582 * @since 1.0.0
583 * Read just the header data for an image and dont decode the pixels. 583 * @ingroup Eet_File_Cipher_Group
584 * @param ef A valid eet file handle opened for reading. 584 */
585 * @param name Name of the entry. eg: "/base/file_i_want". 585EAPI int eet_write_cipher(Eet_File *ef,
586 * @param w A pointer to the unsigned int to hold the width in pixels. 586 const char *name,
587 * @param h A pointer to the unsigned int to hold the height in pixels. 587 const void *data,
588 * @param alpha A pointer to the int to hold the alpha flag. 588 int size,
589 * @param compress A pointer to the int to hold the compression amount. 589 int compress,
590 * @param quality A pointer to the int to hold the quality amount. 590 const char *cipher_key);
591 * @param lossy A pointer to the int to hold the lossiness flag. 591
592 * @return 1 on successfull decode, 0 otherwise 592
593 * 593/**
594 * This function reads an image from an eet file stored under the named 594 * @defgroup Eet_File_Image_Group Image Store and Load
595 * key in the eet file and return a pointer to the decompressed pixel data. 595 *
596 * 596 * Eet efficiently stores and loads images, including alpha
597 * The other parameters of the image (width, height etc.) are placed into 597 * channels and lossy compressions.
598 * the values pointed to (they must be supplied). The pixel data is a linear 598 */
599 * array of pixels starting from the top-left of the image scanning row by 599
600 * row from left to right. Each pile is a 32bit value, with the high byte 600/**
601 * being the alpha channel, the next being red, then green, and the low byte 601 * Read just the header data for an image and dont decode the pixels.
602 * being blue. The width and height are measured in pixels and will be 602 * @param ef A valid eet file handle opened for reading.
603 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 603 * @param name Name of the entry. eg: "/base/file_i_want".
604 * that the alpha channel is not used. 1 denotes that it is significant. 604 * @param w A pointer to the unsigned int to hold the width in pixels.
605 * Compress is filled with the compression value/amount the image was 605 * @param h A pointer to the unsigned int to hold the height in pixels.
606 * stored with. The quality value is filled with the quality encoding of 606 * @param alpha A pointer to the int to hold the alpha flag.
607 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 607 * @param compress A pointer to the int to hold the compression amount.
608 * the image was encoded lossily or not. 608 * @param quality A pointer to the int to hold the quality amount.
609 * 609 * @param lossy A pointer to the int to hold the lossiness flag.
610 * On success the function returns 1 indicating the header was read and 610 * @return 1 on successfull decode, 0 otherwise
611 * decoded properly, or 0 on failure. 611 *
612 * 612 * This function reads an image from an eet file stored under the named
613 * @see eet_data_image_header_read_cipher() 613 * key in the eet file and return a pointer to the decompressed pixel data.
614 * 614 *
615 * @since 1.0.0 615 * The other parameters of the image (width, height etc.) are placed into
616 * @ingroup Eet_File_Image_Group 616 * the values pointed to (they must be supplied). The pixel data is a linear
617 */ 617 * array of pixels starting from the top-left of the image scanning row by
618 EAPI int eet_data_image_header_read(Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 618 * row from left to right. Each pile is a 32bit value, with the high byte
619 619 * being the alpha channel, the next being red, then green, and the low byte
620 /** 620 * being blue. The width and height are measured in pixels and will be
621 * Read image data from the named key in the eet file. 621 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
622 * @param ef A valid eet file handle opened for reading. 622 * that the alpha channel is not used. 1 denotes that it is significant.
623 * @param name Name of the entry. eg: "/base/file_i_want". 623 * Compress is filled with the compression value/amount the image was
624 * @param w A pointer to the unsigned int to hold the width in pixels. 624 * stored with. The quality value is filled with the quality encoding of
625 * @param h A pointer to the unsigned int to hold the height in pixels. 625 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
626 * @param alpha A pointer to the int to hold the alpha flag. 626 * the image was encoded lossily or not.
627 * @param compress A pointer to the int to hold the compression amount. 627 *
628 * @param quality A pointer to the int to hold the quality amount. 628 * On success the function returns 1 indicating the header was read and
629 * @param lossy A pointer to the int to hold the lossiness flag. 629 * decoded properly, or 0 on failure.
630 * @return The image pixel data decoded 630 *
631 * 631 * @see eet_data_image_header_read_cipher()
632 * This function reads an image from an eet file stored under the named 632 *
633 * key in the eet file and return a pointer to the decompressed pixel data. 633 * @since 1.0.0
634 * 634 * @ingroup Eet_File_Image_Group
635 * The other parameters of the image (width, height etc.) are placed into 635 */
636 * the values pointed to (they must be supplied). The pixel data is a linear 636EAPI int eet_data_image_header_read(Eet_File *ef,
637 * array of pixels starting from the top-left of the image scanning row by 637 const char *name,
638 * row from left to right. Each pile is a 32bit value, with the high byte 638 unsigned int *w,
639 * being the alpha channel, the next being red, then green, and the low byte 639 unsigned int *h,
640 * being blue. The width and height are measured in pixels and will be 640 int *alpha,
641 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 641 int *compress,
642 * that the alpha channel is not used. 1 denotes that it is significant. 642 int *quality,
643 * Compress is filled with the compression value/amount the image was 643 int *lossy);
644 * stored with. The quality value is filled with the quality encoding of 644
645 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 645/**
646 * the image was encoded lossily or not. 646 * Read image data from the named key in the eet file.
647 * 647 * @param ef A valid eet file handle opened for reading.
648 * On success the function returns a pointer to the image data decoded. The 648 * @param name Name of the entry. eg: "/base/file_i_want".
649 * calling application is responsible for calling free() on the image data 649 * @param w A pointer to the unsigned int to hold the width in pixels.
650 * when it is done with it. On failure NULL is returned and the parameter 650 * @param h A pointer to the unsigned int to hold the height in pixels.
651 * values may not contain any sensible data. 651 * @param alpha A pointer to the int to hold the alpha flag.
652 * 652 * @param compress A pointer to the int to hold the compression amount.
653 * @see eet_data_image_read_cipher() 653 * @param quality A pointer to the int to hold the quality amount.
654 * 654 * @param lossy A pointer to the int to hold the lossiness flag.
655 * @since 1.0.0 655 * @return The image pixel data decoded
656 * @ingroup Eet_File_Image_Group 656 *
657 */ 657 * This function reads an image from an eet file stored under the named
658 EAPI void *eet_data_image_read(Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 658 * key in the eet file and return a pointer to the decompressed pixel data.
659 659 *
660 /** 660 * The other parameters of the image (width, height etc.) are placed into
661 * Read image data from the named key in the eet file. 661 * the values pointed to (they must be supplied). The pixel data is a linear
662 * @param ef A valid eet file handle opened for reading. 662 * array of pixels starting from the top-left of the image scanning row by
663 * @param name Name of the entry. eg: "/base/file_i_want". 663 * row from left to right. Each pile is a 32bit value, with the high byte
664 * @param src_x The starting x coordinate from where to dump the stream. 664 * being the alpha channel, the next being red, then green, and the low byte
665 * @param src_y The starting y coordinate from where to dump the stream. 665 * being blue. The width and height are measured in pixels and will be
666 * @param d A pointer to the pixel surface. 666 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
667 * @param w The expected width in pixels of the pixel surface to decode. 667 * that the alpha channel is not used. 1 denotes that it is significant.
668 * @param h The expected height in pixels of the pixel surface to decode. 668 * Compress is filled with the compression value/amount the image was
669 * @param row_stride The length of a pixels line in the destination surface. 669 * stored with. The quality value is filled with the quality encoding of
670 * @param alpha A pointer to the int to hold the alpha flag. 670 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
671 * @param compress A pointer to the int to hold the compression amount. 671 * the image was encoded lossily or not.
672 * @param quality A pointer to the int to hold the quality amount. 672 *
673 * @param lossy A pointer to the int to hold the lossiness flag. 673 * On success the function returns a pointer to the image data decoded. The
674 * @return 1 on success, 0 otherwise. 674 * calling application is responsible for calling free() on the image data
675 * 675 * when it is done with it. On failure NULL is returned and the parameter
676 * This function reads an image from an eet file stored under the named 676 * values may not contain any sensible data.
677 * key in the eet file and return a pointer to the decompressed pixel data. 677 *
678 * 678 * @see eet_data_image_read_cipher()
679 * The other parameters of the image (width, height etc.) are placed into 679 *
680 * the values pointed to (they must be supplied). The pixel data is a linear 680 * @since 1.0.0
681 * array of pixels starting from the top-left of the image scanning row by 681 * @ingroup Eet_File_Image_Group
682 * row from left to right. Each pile is a 32bit value, with the high byte 682 */
683 * being the alpha channel, the next being red, then green, and the low byte 683EAPI void *eet_data_image_read(Eet_File *ef,
684 * being blue. The width and height are measured in pixels and will be 684 const char *name,
685 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 685 unsigned int *w,
686 * that the alpha channel is not used. 1 denotes that it is significant. 686 unsigned int *h,
687 * Compress is filled with the compression value/amount the image was 687 int *alpha,
688 * stored with. The quality value is filled with the quality encoding of 688 int *compress,
689 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 689 int *quality,
690 * the image was encoded lossily or not. 690 int *lossy);
691 * 691
692 * On success the function returns 1, and 0 on failure. On failure the 692/**
693 * parameter values may not contain any sensible data. 693 * Read image data from the named key in the eet file.
694 * 694 * @param ef A valid eet file handle opened for reading.
695 * @see eet_data_image_read_to_surface_cipher() 695 * @param name Name of the entry. eg: "/base/file_i_want".
696 * 696 * @param src_x The starting x coordinate from where to dump the stream.
697 * @since 1.0.2 697 * @param src_y The starting y coordinate from where to dump the stream.
698 * @ingroup Eet_File_Image_Group 698 * @param d A pointer to the pixel surface.
699 */ 699 * @param w The expected width in pixels of the pixel surface to decode.
700 EAPI int eet_data_image_read_to_surface(Eet_File *ef, const char *name, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy); 700 * @param h The expected height in pixels of the pixel surface to decode.
701 701 * @param row_stride The length of a pixels line in the destination surface.
702 /** 702 * @param alpha A pointer to the int to hold the alpha flag.
703 * Write image data to the named key in an eet file. 703 * @param compress A pointer to the int to hold the compression amount.
704 * @param ef A valid eet file handle opened for writing. 704 * @param quality A pointer to the int to hold the quality amount.
705 * @param name Name of the entry. eg: "/base/file_i_want". 705 * @param lossy A pointer to the int to hold the lossiness flag.
706 * @param data A pointer to the image pixel data. 706 * @return 1 on success, 0 otherwise.
707 * @param w The width of the image in pixels. 707 *
708 * @param h The height of the image in pixels. 708 * This function reads an image from an eet file stored under the named
709 * @param alpha The alpha channel flag. 709 * key in the eet file and return a pointer to the decompressed pixel data.
710 * @param compress The compression amount. 710 *
711 * @param quality The quality encoding amount. 711 * The other parameters of the image (width, height etc.) are placed into
712 * @param lossy The lossiness flag. 712 * the values pointed to (they must be supplied). The pixel data is a linear
713 * @return Success if the data was encoded and written or not. 713 * array of pixels starting from the top-left of the image scanning row by
714 * 714 * row from left to right. Each pile is a 32bit value, with the high byte
715 * This function takes image pixel data and encodes it in an eet file 715 * being the alpha channel, the next being red, then green, and the low byte
716 * stored under the supplied name key, and returns how many bytes were 716 * being blue. The width and height are measured in pixels and will be
717 * actually written to encode the image data. 717 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
718 * 718 * that the alpha channel is not used. 1 denotes that it is significant.
719 * The data expected is the same format as returned by eet_data_image_read. 719 * Compress is filled with the compression value/amount the image was
720 * If this is not the case weird things may happen. Width and height must 720 * stored with. The quality value is filled with the quality encoding of
721 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning 721 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
722 * the alpha values are not useful and 1 meaning they are). Compress can 722 * the image was encoded lossily or not.
723 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression). 723 *
724 * This is only used if the image is not lossily encoded. Quality is used on 724 * On success the function returns 1, and 0 on failure. On failure the
725 * lossy compression and should be a value from 0 to 100. The lossy flag 725 * parameter values may not contain any sensible data.
726 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with 726 *
727 * image quality loss (but then have a much smaller encoding). 727 * @see eet_data_image_read_to_surface_cipher()
728 * 728 *
729 * On success this function returns the number of bytes that were required 729 * @since 1.0.2
730 * to encode the image data, or on failure it returns 0. 730 * @ingroup Eet_File_Image_Group
731 * 731 */
732 * @see eet_data_image_write_cipher() 732EAPI int eet_data_image_read_to_surface(Eet_File *ef,
733 * 733 const char *name,
734 * @since 1.0.0 734 unsigned int src_x,
735 * @ingroup Eet_File_Image_Group 735 unsigned int src_y,
736 */ 736 unsigned int *d,
737 EAPI int eet_data_image_write(Eet_File *ef, const char *name, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); 737 unsigned int w,
738 738 unsigned int h,
739 /** 739 unsigned int row_stride,
740 * Decode Image data header only to get information. 740 int *alpha,
741 * @param data The encoded pixel data. 741 int *compress,
742 * @param size The size, in bytes, of the encoded pixel data. 742 int *quality,
743 * @param w A pointer to the unsigned int to hold the width in pixels. 743 int *lossy);
744 * @param h A pointer to the unsigned int to hold the height in pixels. 744
745 * @param alpha A pointer to the int to hold the alpha flag. 745/**
746 * @param compress A pointer to the int to hold the compression amount. 746 * Write image data to the named key in an eet file.
747 * @param quality A pointer to the int to hold the quality amount. 747 * @param ef A valid eet file handle opened for writing.
748 * @param lossy A pointer to the int to hold the lossiness flag. 748 * @param name Name of the entry. eg: "/base/file_i_want".
749 * @return 1 on success, 0 on failure. 749 * @param data A pointer to the image pixel data.
750 * 750 * @param w The width of the image in pixels.
751 * This function takes encoded pixel data and decodes it into raw RGBA 751 * @param h The height of the image in pixels.
752 * pixels on success. 752 * @param alpha The alpha channel flag.
753 * 753 * @param compress The compression amount.
754 * The other parameters of the image (width, height etc.) are placed into 754 * @param quality The quality encoding amount.
755 * the values pointed to (they must be supplied). The pixel data is a linear 755 * @param lossy The lossiness flag.
756 * array of pixels starting from the top-left of the image scanning row by 756 * @return Success if the data was encoded and written or not.
757 * row from left to right. Each pixel is a 32bit value, with the high byte 757 *
758 * being the alpha channel, the next being red, then green, and the low byte 758 * This function takes image pixel data and encodes it in an eet file
759 * being blue. The width and height are measured in pixels and will be 759 * stored under the supplied name key, and returns how many bytes were
760 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 760 * actually written to encode the image data.
761 * that the alpha channel is not used. 1 denotes that it is significant. 761 *
762 * Compress is filled with the compression value/amount the image was 762 * The data expected is the same format as returned by eet_data_image_read.
763 * stored with. The quality value is filled with the quality encoding of 763 * If this is not the case weird things may happen. Width and height must
764 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 764 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
765 * the image was encoded lossily or not. 765 * the alpha values are not useful and 1 meaning they are). Compress can
766 * 766 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
767 * On success the function returns 1 indicating the header was read and 767 * This is only used if the image is not lossily encoded. Quality is used on
768 * decoded properly, or 0 on failure. 768 * lossy compression and should be a value from 0 to 100. The lossy flag
769 * 769 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
770 * @see eet_data_image_header_decode_cipher() 770 * image quality loss (but then have a much smaller encoding).
771 * 771 *
772 * @since 1.0.0 772 * On success this function returns the number of bytes that were required
773 * @ingroup Eet_File_Image_Group 773 * to encode the image data, or on failure it returns 0.
774 */ 774 *
775 EAPI int eet_data_image_header_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 775 * @see eet_data_image_write_cipher()
776 776 *
777 /** 777 * @since 1.0.0
778 * Decode Image data into pixel data. 778 * @ingroup Eet_File_Image_Group
779 * @param data The encoded pixel data. 779 */
780 * @param size The size, in bytes, of the encoded pixel data. 780EAPI int eet_data_image_write(Eet_File *ef,
781 * @param w A pointer to the unsigned int to hold the width in pixels. 781 const char *name,
782 * @param h A pointer to the unsigned int to hold the height in pixels. 782 const void *data,
783 * @param alpha A pointer to the int to hold the alpha flag. 783 unsigned int w,
784 * @param compress A pointer to the int to hold the compression amount. 784 unsigned int h,
785 * @param quality A pointer to the int to hold the quality amount. 785 int alpha,
786 * @param lossy A pointer to the int to hold the lossiness flag. 786 int compress,
787 * @return The image pixel data decoded 787 int quality,
788 * 788 int lossy);
789 * This function takes encoded pixel data and decodes it into raw RGBA 789
790 * pixels on success. 790/**
791 * 791 * Decode Image data header only to get information.
792 * The other parameters of the image (width, height etc.) are placed into 792 * @param data The encoded pixel data.
793 * the values pointed to (they must be supplied). The pixel data is a linear 793 * @param size The size, in bytes, of the encoded pixel data.
794 * array of pixels starting from the top-left of the image scanning row by 794 * @param w A pointer to the unsigned int to hold the width in pixels.
795 * row from left to right. Each pixel is a 32bit value, with the high byte 795 * @param h A pointer to the unsigned int to hold the height in pixels.
796 * being the alpha channel, the next being red, then green, and the low byte 796 * @param alpha A pointer to the int to hold the alpha flag.
797 * being blue. The width and height are measured in pixels and will be 797 * @param compress A pointer to the int to hold the compression amount.
798 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 798 * @param quality A pointer to the int to hold the quality amount.
799 * that the alpha channel is not used. 1 denotes that it is significant. 799 * @param lossy A pointer to the int to hold the lossiness flag.
800 * Compress is filled with the compression value/amount the image was 800 * @return 1 on success, 0 on failure.
801 * stored with. The quality value is filled with the quality encoding of 801 *
802 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 802 * This function takes encoded pixel data and decodes it into raw RGBA
803 * the image was encoded lossily or not. 803 * pixels on success.
804 * 804 *
805 * On success the function returns a pointer to the image data decoded. The 805 * The other parameters of the image (width, height etc.) are placed into
806 * calling application is responsible for calling free() on the image data 806 * the values pointed to (they must be supplied). The pixel data is a linear
807 * when it is done with it. On failure NULL is returned and the parameter 807 * array of pixels starting from the top-left of the image scanning row by
808 * values may not contain any sensible data. 808 * row from left to right. Each pixel is a 32bit value, with the high byte
809 * 809 * being the alpha channel, the next being red, then green, and the low byte
810 * @see eet_data_image_decode_cipher() 810 * being blue. The width and height are measured in pixels and will be
811 * 811 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
812 * @since 1.0.0 812 * that the alpha channel is not used. 1 denotes that it is significant.
813 * @ingroup Eet_File_Image_Group 813 * Compress is filled with the compression value/amount the image was
814 */ 814 * stored with. The quality value is filled with the quality encoding of
815 EAPI void *eet_data_image_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 815 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
816 816 * the image was encoded lossily or not.
817 /** 817 *
818 * Decode Image data into pixel data. 818 * On success the function returns 1 indicating the header was read and
819 * @param data The encoded pixel data. 819 * decoded properly, or 0 on failure.
820 * @param size The size, in bytes, of the encoded pixel data. 820 *
821 * @param src_x The starting x coordinate from where to dump the stream. 821 * @see eet_data_image_header_decode_cipher()
822 * @param src_y The starting y coordinate from where to dump the stream. 822 *
823 * @param d A pointer to the pixel surface. 823 * @since 1.0.0
824 * @param w The expected width in pixels of the pixel surface to decode. 824 * @ingroup Eet_File_Image_Group
825 * @param h The expected height in pixels of the pixel surface to decode. 825 */
826 * @param row_stride The length of a pixels line in the destination surface. 826EAPI int eet_data_image_header_decode(const void *data,
827 * @param alpha A pointer to the int to hold the alpha flag. 827 int size,
828 * @param compress A pointer to the int to hold the compression amount. 828 unsigned int *w,
829 * @param quality A pointer to the int to hold the quality amount. 829 unsigned int *h,
830 * @param lossy A pointer to the int to hold the lossiness flag. 830 int *alpha,
831 * @return 1 on success, 0 otherwise. 831 int *compress,
832 * 832 int *quality,
833 * This function takes encoded pixel data and decodes it into raw RGBA 833 int *lossy);
834 * pixels on success. 834
835 * 835/**
836 * The other parameters of the image (alpha, compress etc.) are placed into 836 * Decode Image data into pixel data.
837 * the values pointed to (they must be supplied). The pixel data is a linear 837 * @param data The encoded pixel data.
838 * array of pixels starting from the top-left of the image scanning row by 838 * @param size The size, in bytes, of the encoded pixel data.
839 * row from left to right. Each pixel is a 32bit value, with the high byte 839 * @param w A pointer to the unsigned int to hold the width in pixels.
840 * being the alpha channel, the next being red, then green, and the low byte 840 * @param h A pointer to the unsigned int to hold the height in pixels.
841 * being blue. The width and height are measured in pixels and will be 841 * @param alpha A pointer to the int to hold the alpha flag.
842 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 842 * @param compress A pointer to the int to hold the compression amount.
843 * that the alpha channel is not used. 1 denotes that it is significant. 843 * @param quality A pointer to the int to hold the quality amount.
844 * Compress is filled with the compression value/amount the image was 844 * @param lossy A pointer to the int to hold the lossiness flag.
845 * stored with. The quality value is filled with the quality encoding of 845 * @return The image pixel data decoded
846 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 846 *
847 * the image was encoded lossily or not. 847 * This function takes encoded pixel data and decodes it into raw RGBA
848 * 848 * pixels on success.
849 * On success the function returns 1, and 0 on failure. On failure the 849 *
850 * parameter values may not contain any sensible data. 850 * The other parameters of the image (width, height etc.) are placed into
851 * 851 * the values pointed to (they must be supplied). The pixel data is a linear
852 * @see eet_data_image_decode_to_surface_cipher() 852 * array of pixels starting from the top-left of the image scanning row by
853 * 853 * row from left to right. Each pixel is a 32bit value, with the high byte
854 * @since 1.0.2 854 * being the alpha channel, the next being red, then green, and the low byte
855 * @ingroup Eet_File_Image_Group 855 * being blue. The width and height are measured in pixels and will be
856 */ 856 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
857 EAPI int eet_data_image_decode_to_surface(const void *data, int size, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy); 857 * that the alpha channel is not used. 1 denotes that it is significant.
858 858 * Compress is filled with the compression value/amount the image was
859 /** 859 * stored with. The quality value is filled with the quality encoding of
860 * Encode image data for storage or transmission. 860 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
861 * @param data A pointer to the image pixel data. 861 * the image was encoded lossily or not.
862 * @param size_ret A pointer to an int to hold the size of the returned data. 862 *
863 * @param w The width of the image in pixels. 863 * On success the function returns a pointer to the image data decoded. The
864 * @param h The height of the image in pixels. 864 * calling application is responsible for calling free() on the image data
865 * @param alpha The alpha channel flag. 865 * when it is done with it. On failure NULL is returned and the parameter
866 * @param compress The compression amount. 866 * values may not contain any sensible data.
867 * @param quality The quality encoding amount. 867 *
868 * @param lossy The lossiness flag. 868 * @see eet_data_image_decode_cipher()
869 * @return The encoded image data. 869 *
870 * 870 * @since 1.0.0
871 * This function stakes image pixel data and encodes it with compression and 871 * @ingroup Eet_File_Image_Group
872 * possible loss of quality (as a trade off for size) for storage or 872 */
873 * transmission to another system. 873EAPI void *eet_data_image_decode(const void *data,
874 * 874 int size,
875 * The data expected is the same format as returned by eet_data_image_read. 875 unsigned int *w,
876 * If this is not the case weird things may happen. Width and height must 876 unsigned int *h,
877 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning 877 int *alpha,
878 * the alpha values are not useful and 1 meaning they are). Compress can 878 int *compress,
879 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression). 879 int *quality,
880 * This is only used if the image is not lossily encoded. Quality is used on 880 int *lossy);
881 * lossy compression and should be a value from 0 to 100. The lossy flag 881
882 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with 882/**
883 * image quality loss (but then have a much smaller encoding). 883 * Decode Image data into pixel data.
884 * 884 * @param data The encoded pixel data.
885 * On success this function returns a pointer to the encoded data that you 885 * @param size The size, in bytes, of the encoded pixel data.
886 * can free with free() when no longer needed. 886 * @param src_x The starting x coordinate from where to dump the stream.
887 * 887 * @param src_y The starting y coordinate from where to dump the stream.
888 * @see eet_data_image_encode_cipher() 888 * @param d A pointer to the pixel surface.
889 * 889 * @param w The expected width in pixels of the pixel surface to decode.
890 * @since 1.0.0 890 * @param h The expected height in pixels of the pixel surface to decode.
891 * @ingroup Eet_File_Image_Group 891 * @param row_stride The length of a pixels line in the destination surface.
892 */ 892 * @param alpha A pointer to the int to hold the alpha flag.
893 EAPI void *eet_data_image_encode(const void *data, int *size_ret, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); 893 * @param compress A pointer to the int to hold the compression amount.
894 894 * @param quality A pointer to the int to hold the quality amount.
895 /** 895 * @param lossy A pointer to the int to hold the lossiness flag.
896 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher 896 * @return 1 on success, 0 otherwise.
897 * 897 *
898 * Most of the @ref Eet_File_Image_Group have alternative versions 898 * This function takes encoded pixel data and decodes it into raw RGBA
899 * that accounts for ciphers to protect their content. 899 * pixels on success.
900 * 900 *
901 * @see @ref Eet_Cipher_Group 901 * The other parameters of the image (alpha, compress etc.) are placed into
902 * 902 * the values pointed to (they must be supplied). The pixel data is a linear
903 * @ingroup Eet_File_Image_Group 903 * array of pixels starting from the top-left of the image scanning row by
904 */ 904 * row from left to right. Each pixel is a 32bit value, with the high byte
905 905 * being the alpha channel, the next being red, then green, and the low byte
906 /** 906 * being blue. The width and height are measured in pixels and will be
907 * Read just the header data for an image and dont decode the pixels using a cipher. 907 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
908 * @param ef A valid eet file handle opened for reading. 908 * that the alpha channel is not used. 1 denotes that it is significant.
909 * @param name Name of the entry. eg: "/base/file_i_want". 909 * Compress is filled with the compression value/amount the image was
910 * @param cipher_key The key to use as cipher. 910 * stored with. The quality value is filled with the quality encoding of
911 * @param w A pointer to the unsigned int to hold the width in pixels. 911 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
912 * @param h A pointer to the unsigned int to hold the height in pixels. 912 * the image was encoded lossily or not.
913 * @param alpha A pointer to the int to hold the alpha flag. 913 *
914 * @param compress A pointer to the int to hold the compression amount. 914 * On success the function returns 1, and 0 on failure. On failure the
915 * @param quality A pointer to the int to hold the quality amount. 915 * parameter values may not contain any sensible data.
916 * @param lossy A pointer to the int to hold the lossiness flag. 916 *
917 * @return 1 on successfull decode, 0 otherwise 917 * @see eet_data_image_decode_to_surface_cipher()
918 * 918 *
919 * This function reads an image from an eet file stored under the named 919 * @since 1.0.2
920 * key in the eet file and return a pointer to the decompressed pixel data. 920 * @ingroup Eet_File_Image_Group
921 * 921 */
922 * The other parameters of the image (width, height etc.) are placed into 922EAPI int eet_data_image_decode_to_surface(const void *data,
923 * the values pointed to (they must be supplied). The pixel data is a linear 923 int size,
924 * array of pixels starting from the top-left of the image scanning row by 924 unsigned int src_x,
925 * row from left to right. Each pile is a 32bit value, with the high byte 925 unsigned int src_y,
926 * being the alpha channel, the next being red, then green, and the low byte 926 unsigned int *d,
927 * being blue. The width and height are measured in pixels and will be 927 unsigned int w,
928 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 928 unsigned int h,
929 * that the alpha channel is not used. 1 denotes that it is significant. 929 unsigned int row_stride,
930 * Compress is filled with the compression value/amount the image was 930 int *alpha,
931 * stored with. The quality value is filled with the quality encoding of 931 int *compress,
932 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 932 int *quality,
933 * the image was encoded lossily or not. 933 int *lossy);
934 * 934
935 * On success the function returns 1 indicating the header was read and 935/**
936 * decoded properly, or 0 on failure. 936 * Encode image data for storage or transmission.
937 * 937 * @param data A pointer to the image pixel data.
938 * @see eet_data_image_header_read() 938 * @param size_ret A pointer to an int to hold the size of the returned data.
939 * 939 * @param w The width of the image in pixels.
940 * @since 1.0.0 940 * @param h The height of the image in pixels.
941 * @ingroup Eet_File_Image_Cipher_Group 941 * @param alpha The alpha channel flag.
942 */ 942 * @param compress The compression amount.
943 EAPI int eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 943 * @param quality The quality encoding amount.
944 944 * @param lossy The lossiness flag.
945 /** 945 * @return The encoded image data.
946 * Read image data from the named key in the eet file using a cipher. 946 *
947 * @param ef A valid eet file handle opened for reading. 947 * This function stakes image pixel data and encodes it with compression and
948 * @param name Name of the entry. eg: "/base/file_i_want". 948 * possible loss of quality (as a trade off for size) for storage or
949 * @param cipher_key The key to use as cipher. 949 * transmission to another system.
950 * @param w A pointer to the unsigned int to hold the width in pixels. 950 *
951 * @param h A pointer to the unsigned int to hold the height in pixels. 951 * The data expected is the same format as returned by eet_data_image_read.
952 * @param alpha A pointer to the int to hold the alpha flag. 952 * If this is not the case weird things may happen. Width and height must
953 * @param compress A pointer to the int to hold the compression amount. 953 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
954 * @param quality A pointer to the int to hold the quality amount. 954 * the alpha values are not useful and 1 meaning they are). Compress can
955 * @param lossy A pointer to the int to hold the lossiness flag. 955 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
956 * @return The image pixel data decoded 956 * This is only used if the image is not lossily encoded. Quality is used on
957 * 957 * lossy compression and should be a value from 0 to 100. The lossy flag
958 * This function reads an image from an eet file stored under the named 958 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
959 * key in the eet file and return a pointer to the decompressed pixel data. 959 * image quality loss (but then have a much smaller encoding).
960 * 960 *
961 * The other parameters of the image (width, height etc.) are placed into 961 * On success this function returns a pointer to the encoded data that you
962 * the values pointed to (they must be supplied). The pixel data is a linear 962 * can free with free() when no longer needed.
963 * array of pixels starting from the top-left of the image scanning row by 963 *
964 * row from left to right. Each pile is a 32bit value, with the high byte 964 * @see eet_data_image_encode_cipher()
965 * being the alpha channel, the next being red, then green, and the low byte 965 *
966 * being blue. The width and height are measured in pixels and will be 966 * @since 1.0.0
967 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 967 * @ingroup Eet_File_Image_Group
968 * that the alpha channel is not used. 1 denotes that it is significant. 968 */
969 * Compress is filled with the compression value/amount the image was 969EAPI void *eet_data_image_encode(const void *data,
970 * stored with. The quality value is filled with the quality encoding of 970 int *size_ret,
971 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 971 unsigned int w,
972 * the image was encoded lossily or not. 972 unsigned int h,
973 * 973 int alpha,
974 * On success the function returns a pointer to the image data decoded. The 974 int compress,
975 * calling application is responsible for calling free() on the image data 975 int quality,
976 * when it is done with it. On failure NULL is returned and the parameter 976 int lossy);
977 * values may not contain any sensible data. 977
978 * 978/**
979 * @see eet_data_image_read() 979 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
980 * 980 *
981 * @since 1.0.0 981 * Most of the @ref Eet_File_Image_Group have alternative versions
982 * @ingroup Eet_File_Image_Cipher_Group 982 * that accounts for ciphers to protect their content.
983 */ 983 *
984 EAPI void *eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 984 * @see @ref Eet_Cipher_Group
985 985 *
986 /** 986 * @ingroup Eet_File_Image_Group
987 * Read image data from the named key in the eet file using a cipher. 987 */
988 * @param ef A valid eet file handle opened for reading. 988
989 * @param name Name of the entry. eg: "/base/file_i_want". 989/**
990 * @param cipher_key The key to use as cipher. 990 * Read just the header data for an image and dont decode the pixels using a cipher.
991 * @param src_x The starting x coordinate from where to dump the stream. 991 * @param ef A valid eet file handle opened for reading.
992 * @param src_y The starting y coordinate from where to dump the stream. 992 * @param name Name of the entry. eg: "/base/file_i_want".
993 * @param d A pointer to the pixel surface. 993 * @param cipher_key The key to use as cipher.
994 * @param w The expected width in pixels of the pixel surface to decode. 994 * @param w A pointer to the unsigned int to hold the width in pixels.
995 * @param h The expected height in pixels of the pixel surface to decode. 995 * @param h A pointer to the unsigned int to hold the height in pixels.
996 * @param row_stride The length of a pixels line in the destination surface. 996 * @param alpha A pointer to the int to hold the alpha flag.
997 * @param alpha A pointer to the int to hold the alpha flag. 997 * @param compress A pointer to the int to hold the compression amount.
998 * @param compress A pointer to the int to hold the compression amount. 998 * @param quality A pointer to the int to hold the quality amount.
999 * @param quality A pointer to the int to hold the quality amount. 999 * @param lossy A pointer to the int to hold the lossiness flag.
1000 * @param lossy A pointer to the int to hold the lossiness flag. 1000 * @return 1 on successfull decode, 0 otherwise
1001 * @return 1 on success, 0 otherwise. 1001 *
1002 * 1002 * This function reads an image from an eet file stored under the named
1003 * This function reads an image from an eet file stored under the named 1003 * key in the eet file and return a pointer to the decompressed pixel data.
1004 * key in the eet file and return a pointer to the decompressed pixel data. 1004 *
1005 * 1005 * The other parameters of the image (width, height etc.) are placed into
1006 * The other parameters of the image (width, height etc.) are placed into 1006 * the values pointed to (they must be supplied). The pixel data is a linear
1007 * the values pointed to (they must be supplied). The pixel data is a linear 1007 * array of pixels starting from the top-left of the image scanning row by
1008 * array of pixels starting from the top-left of the image scanning row by 1008 * row from left to right. Each pile is a 32bit value, with the high byte
1009 * row from left to right. Each pile is a 32bit value, with the high byte 1009 * being the alpha channel, the next being red, then green, and the low byte
1010 * being the alpha channel, the next being red, then green, and the low byte 1010 * being blue. The width and height are measured in pixels and will be
1011 * being blue. The width and height are measured in pixels and will be 1011 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1012 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 1012 * that the alpha channel is not used. 1 denotes that it is significant.
1013 * that the alpha channel is not used. 1 denotes that it is significant. 1013 * Compress is filled with the compression value/amount the image was
1014 * Compress is filled with the compression value/amount the image was 1014 * stored with. The quality value is filled with the quality encoding of
1015 * stored with. The quality value is filled with the quality encoding of 1015 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1016 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 1016 * the image was encoded lossily or not.
1017 * the image was encoded lossily or not. 1017 *
1018 * 1018 * On success the function returns 1 indicating the header was read and
1019 * On success the function returns 1, and 0 on failure. On failure the 1019 * decoded properly, or 0 on failure.
1020 * parameter values may not contain any sensible data. 1020 *
1021 * 1021 * @see eet_data_image_header_read()
1022 * @see eet_data_image_read_to_surface() 1022 *
1023 * 1023 * @since 1.0.0
1024 * @since 1.0.2 1024 * @ingroup Eet_File_Image_Cipher_Group
1025 * @ingroup Eet_File_Image_Cipher_Group 1025 */
1026 */ 1026EAPI int eet_data_image_header_read_cipher(Eet_File *ef,
1027 EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy); 1027 const char *name,
1028 1028 const char *cipher_key,
1029 /** 1029 unsigned int *w,
1030 * Write image data to the named key in an eet file using a cipher. 1030 unsigned int *h,
1031 * @param ef A valid eet file handle opened for writing. 1031 int *alpha,
1032 * @param name Name of the entry. eg: "/base/file_i_want". 1032 int *compress,
1033 * @param cipher_key The key to use as cipher. 1033 int *quality,
1034 * @param data A pointer to the image pixel data. 1034 int *lossy);
1035 * @param w The width of the image in pixels. 1035
1036 * @param h The height of the image in pixels. 1036/**
1037 * @param alpha The alpha channel flag. 1037 * Read image data from the named key in the eet file using a cipher.
1038 * @param compress The compression amount. 1038 * @param ef A valid eet file handle opened for reading.
1039 * @param quality The quality encoding amount. 1039 * @param name Name of the entry. eg: "/base/file_i_want".
1040 * @param lossy The lossiness flag. 1040 * @param cipher_key The key to use as cipher.
1041 * @return Success if the data was encoded and written or not. 1041 * @param w A pointer to the unsigned int to hold the width in pixels.
1042 * 1042 * @param h A pointer to the unsigned int to hold the height in pixels.
1043 * This function takes image pixel data and encodes it in an eet file 1043 * @param alpha A pointer to the int to hold the alpha flag.
1044 * stored under the supplied name key, and returns how many bytes were 1044 * @param compress A pointer to the int to hold the compression amount.
1045 * actually written to encode the image data. 1045 * @param quality A pointer to the int to hold the quality amount.
1046 * 1046 * @param lossy A pointer to the int to hold the lossiness flag.
1047 * The data expected is the same format as returned by eet_data_image_read. 1047 * @return The image pixel data decoded
1048 * If this is not the case weird things may happen. Width and height must 1048 *
1049 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning 1049 * This function reads an image from an eet file stored under the named
1050 * the alpha values are not useful and 1 meaning they are). Compress can 1050 * key in the eet file and return a pointer to the decompressed pixel data.
1051 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression). 1051 *
1052 * This is only used if the image is not lossily encoded. Quality is used on 1052 * The other parameters of the image (width, height etc.) are placed into
1053 * lossy compression and should be a value from 0 to 100. The lossy flag 1053 * the values pointed to (they must be supplied). The pixel data is a linear
1054 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with 1054 * array of pixels starting from the top-left of the image scanning row by
1055 * image quality loss (but then have a much smaller encoding). 1055 * row from left to right. Each pile is a 32bit value, with the high byte
1056 * 1056 * being the alpha channel, the next being red, then green, and the low byte
1057 * On success this function returns the number of bytes that were required 1057 * being blue. The width and height are measured in pixels and will be
1058 * to encode the image data, or on failure it returns 0. 1058 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1059 * 1059 * that the alpha channel is not used. 1 denotes that it is significant.
1060 * @see eet_data_image_write() 1060 * Compress is filled with the compression value/amount the image was
1061 * 1061 * stored with. The quality value is filled with the quality encoding of
1062 * @since 1.0.0 1062 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1063 * @ingroup Eet_File_Image_Cipher_Group 1063 * the image was encoded lossily or not.
1064 */ 1064 *
1065 EAPI int eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); 1065 * On success the function returns a pointer to the image data decoded. The
1066 1066 * calling application is responsible for calling free() on the image data
1067 1067 * when it is done with it. On failure NULL is returned and the parameter
1068 /** 1068 * values may not contain any sensible data.
1069 * Decode Image data header only to get information using a cipher. 1069 *
1070 * @param data The encoded pixel data. 1070 * @see eet_data_image_read()
1071 * @param cipher_key The key to use as cipher. 1071 *
1072 * @param size The size, in bytes, of the encoded pixel data. 1072 * @since 1.0.0
1073 * @param w A pointer to the unsigned int to hold the width in pixels. 1073 * @ingroup Eet_File_Image_Cipher_Group
1074 * @param h A pointer to the unsigned int to hold the height in pixels. 1074 */
1075 * @param alpha A pointer to the int to hold the alpha flag. 1075EAPI void *eet_data_image_read_cipher(Eet_File *ef,
1076 * @param compress A pointer to the int to hold the compression amount. 1076 const char *name,
1077 * @param quality A pointer to the int to hold the quality amount. 1077 const char *cipher_key,
1078 * @param lossy A pointer to the int to hold the lossiness flag. 1078 unsigned int *w,
1079 * @return 1 on success, 0 on failure. 1079 unsigned int *h,
1080 * 1080 int *alpha,
1081 * This function takes encoded pixel data and decodes it into raw RGBA 1081 int *compress,
1082 * pixels on success. 1082 int *quality,
1083 * 1083 int *lossy);
1084 * The other parameters of the image (width, height etc.) are placed into 1084
1085 * the values pointed to (they must be supplied). The pixel data is a linear 1085/**
1086 * array of pixels starting from the top-left of the image scanning row by 1086 * Read image data from the named key in the eet file using a cipher.
1087 * row from left to right. Each pixel is a 32bit value, with the high byte 1087 * @param ef A valid eet file handle opened for reading.
1088 * being the alpha channel, the next being red, then green, and the low byte 1088 * @param name Name of the entry. eg: "/base/file_i_want".
1089 * being blue. The width and height are measured in pixels and will be 1089 * @param cipher_key The key to use as cipher.
1090 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 1090 * @param src_x The starting x coordinate from where to dump the stream.
1091 * that the alpha channel is not used. 1 denotes that it is significant. 1091 * @param src_y The starting y coordinate from where to dump the stream.
1092 * Compress is filled with the compression value/amount the image was 1092 * @param d A pointer to the pixel surface.
1093 * stored with. The quality value is filled with the quality encoding of 1093 * @param w The expected width in pixels of the pixel surface to decode.
1094 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 1094 * @param h The expected height in pixels of the pixel surface to decode.
1095 * the image was encoded lossily or not. 1095 * @param row_stride The length of a pixels line in the destination surface.
1096 * 1096 * @param alpha A pointer to the int to hold the alpha flag.
1097 * On success the function returns 1 indicating the header was read and 1097 * @param compress A pointer to the int to hold the compression amount.
1098 * decoded properly, or 0 on failure. 1098 * @param quality A pointer to the int to hold the quality amount.
1099 * 1099 * @param lossy A pointer to the int to hold the lossiness flag.
1100 * @see eet_data_image_header_decode() 1100 * @return 1 on success, 0 otherwise.
1101 * 1101 *
1102 * @since 1.0.0 1102 * This function reads an image from an eet file stored under the named
1103 * @ingroup Eet_File_Image_Cipher_Group 1103 * key in the eet file and return a pointer to the decompressed pixel data.
1104 */ 1104 *
1105 EAPI int eet_data_image_header_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 1105 * The other parameters of the image (width, height etc.) are placed into
1106 1106 * the values pointed to (they must be supplied). The pixel data is a linear
1107 /** 1107 * array of pixels starting from the top-left of the image scanning row by
1108 * Decode Image data into pixel data using a cipher. 1108 * row from left to right. Each pile is a 32bit value, with the high byte
1109 * @param data The encoded pixel data. 1109 * being the alpha channel, the next being red, then green, and the low byte
1110 * @param cipher_key The key to use as cipher. 1110 * being blue. The width and height are measured in pixels and will be
1111 * @param size The size, in bytes, of the encoded pixel data. 1111 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1112 * @param w A pointer to the unsigned int to hold the width in pixels. 1112 * that the alpha channel is not used. 1 denotes that it is significant.
1113 * @param h A pointer to the unsigned int to hold the height in pixels. 1113 * Compress is filled with the compression value/amount the image was
1114 * @param alpha A pointer to the int to hold the alpha flag. 1114 * stored with. The quality value is filled with the quality encoding of
1115 * @param compress A pointer to the int to hold the compression amount. 1115 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1116 * @param quality A pointer to the int to hold the quality amount. 1116 * the image was encoded lossily or not.
1117 * @param lossy A pointer to the int to hold the lossiness flag. 1117 *
1118 * @return The image pixel data decoded 1118 * On success the function returns 1, and 0 on failure. On failure the
1119 * 1119 * parameter values may not contain any sensible data.
1120 * This function takes encoded pixel data and decodes it into raw RGBA 1120 *
1121 * pixels on success. 1121 * @see eet_data_image_read_to_surface()
1122 * 1122 *
1123 * The other parameters of the image (width, height etc.) are placed into 1123 * @since 1.0.2
1124 * the values pointed to (they must be supplied). The pixel data is a linear 1124 * @ingroup Eet_File_Image_Cipher_Group
1125 * array of pixels starting from the top-left of the image scanning row by 1125 */
1126 * row from left to right. Each pixel is a 32bit value, with the high byte 1126EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef,
1127 * being the alpha channel, the next being red, then green, and the low byte 1127 const char *name,
1128 * being blue. The width and height are measured in pixels and will be 1128 const char *cipher_key,
1129 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 1129 unsigned int src_x,
1130 * that the alpha channel is not used. 1 denotes that it is significant. 1130 unsigned int src_y,
1131 * Compress is filled with the compression value/amount the image was 1131 unsigned int *d,
1132 * stored with. The quality value is filled with the quality encoding of 1132 unsigned int w,
1133 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 1133 unsigned int h,
1134 * the image was encoded lossily or not. 1134 unsigned int row_stride,
1135 * 1135 int *alpha,
1136 * On success the function returns a pointer to the image data decoded. The 1136 int *compress,
1137 * calling application is responsible for calling free() on the image data 1137 int *quality,
1138 * when it is done with it. On failure NULL is returned and the parameter 1138 int *lossy);
1139 * values may not contain any sensible data. 1139
1140 * 1140/**
1141 * @see eet_data_image_decode() 1141 * Write image data to the named key in an eet file using a cipher.
1142 * 1142 * @param ef A valid eet file handle opened for writing.
1143 * @since 1.0.0 1143 * @param name Name of the entry. eg: "/base/file_i_want".
1144 * @ingroup Eet_File_Image_Cipher_Group 1144 * @param cipher_key The key to use as cipher.
1145 */ 1145 * @param data A pointer to the image pixel data.
1146 EAPI void *eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); 1146 * @param w The width of the image in pixels.
1147 1147 * @param h The height of the image in pixels.
1148 /** 1148 * @param alpha The alpha channel flag.
1149 * Decode Image data into pixel data using a cipher. 1149 * @param compress The compression amount.
1150 * @param data The encoded pixel data. 1150 * @param quality The quality encoding amount.
1151 * @param cipher_key The key to use as cipher. 1151 * @param lossy The lossiness flag.
1152 * @param size The size, in bytes, of the encoded pixel data. 1152 * @return Success if the data was encoded and written or not.
1153 * @param src_x The starting x coordinate from where to dump the stream. 1153 *
1154 * @param src_y The starting y coordinate from where to dump the stream. 1154 * This function takes image pixel data and encodes it in an eet file
1155 * @param d A pointer to the pixel surface. 1155 * stored under the supplied name key, and returns how many bytes were
1156 * @param w The expected width in pixels of the pixel surface to decode. 1156 * actually written to encode the image data.
1157 * @param h The expected height in pixels of the pixel surface to decode. 1157 *
1158 * @param row_stride The length of a pixels line in the destination surface. 1158 * The data expected is the same format as returned by eet_data_image_read.
1159 * @param alpha A pointer to the int to hold the alpha flag. 1159 * If this is not the case weird things may happen. Width and height must
1160 * @param compress A pointer to the int to hold the compression amount. 1160 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1161 * @param quality A pointer to the int to hold the quality amount. 1161 * the alpha values are not useful and 1 meaning they are). Compress can
1162 * @param lossy A pointer to the int to hold the lossiness flag. 1162 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1163 * @return 1 on success, 0 otherwise. 1163 * This is only used if the image is not lossily encoded. Quality is used on
1164 * 1164 * lossy compression and should be a value from 0 to 100. The lossy flag
1165 * This function takes encoded pixel data and decodes it into raw RGBA 1165 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1166 * pixels on success. 1166 * image quality loss (but then have a much smaller encoding).
1167 * 1167 *
1168 * The other parameters of the image (alpha, compress etc.) are placed into 1168 * On success this function returns the number of bytes that were required
1169 * the values pointed to (they must be supplied). The pixel data is a linear 1169 * to encode the image data, or on failure it returns 0.
1170 * array of pixels starting from the top-left of the image scanning row by 1170 *
1171 * row from left to right. Each pixel is a 32bit value, with the high byte 1171 * @see eet_data_image_write()
1172 * being the alpha channel, the next being red, then green, and the low byte 1172 *
1173 * being blue. The width and height are measured in pixels and will be 1173 * @since 1.0.0
1174 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes 1174 * @ingroup Eet_File_Image_Cipher_Group
1175 * that the alpha channel is not used. 1 denotes that it is significant. 1175 */
1176 * Compress is filled with the compression value/amount the image was 1176EAPI int eet_data_image_write_cipher(Eet_File *ef,
1177 * stored with. The quality value is filled with the quality encoding of 1177 const char *name,
1178 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if 1178 const char *cipher_key,
1179 * the image was encoded lossily or not. 1179 const void *data,
1180 * 1180 unsigned int w,
1181 * On success the function returns 1, and 0 on failure. On failure the 1181 unsigned int h,
1182 * parameter values may not contain any sensible data. 1182 int alpha,
1183 * 1183 int compress,
1184 * @see eet_data_image_decode_to_surface() 1184 int quality,
1185 * 1185 int lossy);
1186 * @since 1.0.2 1186
1187 * @ingroup Eet_File_Image_Cipher_Group 1187
1188 */ 1188/**
1189 EAPI int eet_data_image_decode_to_surface_cipher(const void *data, const char *cipher_key, int size, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy); 1189 * Decode Image data header only to get information using a cipher.
1190 1190 * @param data The encoded pixel data.
1191 /** 1191 * @param cipher_key The key to use as cipher.
1192 * Encode image data for storage or transmission using a cipher. 1192 * @param size The size, in bytes, of the encoded pixel data.
1193 * @param data A pointer to the image pixel data. 1193 * @param w A pointer to the unsigned int to hold the width in pixels.
1194 * @param cipher_key The key to use as cipher. 1194 * @param h A pointer to the unsigned int to hold the height in pixels.
1195 * @param size_ret A pointer to an int to hold the size of the returned data. 1195 * @param alpha A pointer to the int to hold the alpha flag.
1196 * @param w The width of the image in pixels. 1196 * @param compress A pointer to the int to hold the compression amount.
1197 * @param h The height of the image in pixels. 1197 * @param quality A pointer to the int to hold the quality amount.
1198 * @param alpha The alpha channel flag. 1198 * @param lossy A pointer to the int to hold the lossiness flag.
1199 * @param compress The compression amount. 1199 * @return 1 on success, 0 on failure.
1200 * @param quality The quality encoding amount. 1200 *
1201 * @param lossy The lossiness flag. 1201 * This function takes encoded pixel data and decodes it into raw RGBA
1202 * @return The encoded image data. 1202 * pixels on success.
1203 * 1203 *
1204 * This function stakes image pixel data and encodes it with compression and 1204 * The other parameters of the image (width, height etc.) are placed into
1205 * possible loss of quality (as a trade off for size) for storage or 1205 * the values pointed to (they must be supplied). The pixel data is a linear
1206 * transmission to another system. 1206 * array of pixels starting from the top-left of the image scanning row by
1207 * 1207 * row from left to right. Each pixel is a 32bit value, with the high byte
1208 * The data expected is the same format as returned by eet_data_image_read. 1208 * being the alpha channel, the next being red, then green, and the low byte
1209 * If this is not the case weird things may happen. Width and height must 1209 * being blue. The width and height are measured in pixels and will be
1210 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning 1210 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1211 * the alpha values are not useful and 1 meaning they are). Compress can 1211 * that the alpha channel is not used. 1 denotes that it is significant.
1212 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression). 1212 * Compress is filled with the compression value/amount the image was
1213 * This is only used if the image is not lossily encoded. Quality is used on 1213 * stored with. The quality value is filled with the quality encoding of
1214 * lossy compression and should be a value from 0 to 100. The lossy flag 1214 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1215 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with 1215 * the image was encoded lossily or not.
1216 * image quality loss (but then have a much smaller encoding). 1216 *
1217 * 1217 * On success the function returns 1 indicating the header was read and
1218 * On success this function returns a pointer to the encoded data that you 1218 * decoded properly, or 0 on failure.
1219 * can free with free() when no longer needed. 1219 *
1220 * 1220 * @see eet_data_image_header_decode()
1221 * @see eet_data_image_encode() 1221 *
1222 * 1222 * @since 1.0.0
1223 * @since 1.0.0 1223 * @ingroup Eet_File_Image_Cipher_Group
1224 * @ingroup Eet_File_Image_Cipher_Group 1224 */
1225 */ 1225EAPI int eet_data_image_header_decode_cipher(const void *data,
1226 EAPI void *eet_data_image_encode_cipher(const void *data, const char *cipher_key, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy, int *size_ret); 1226 const char *cipher_key,
1227 1227 int size,
1228 1228 unsigned int *w,
1229 /** 1229 unsigned int *h,
1230 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms 1230 int *alpha,
1231 * 1231 int *compress,
1232 * Eet allows one to protect entries of an #Eet_File 1232 int *quality,
1233 * individually. This may be used to ensure data was not tampered or 1233 int *lossy);
1234 * that third party does not read your data. 1234
1235 * 1235/**
1236 * @see @ref Eet_File_Cipher_Group 1236 * Decode Image data into pixel data using a cipher.
1237 * @see @ref Eet_File_Image_Cipher_Group 1237 * @param data The encoded pixel data.
1238 * 1238 * @param cipher_key The key to use as cipher.
1239 * @{ 1239 * @param size The size, in bytes, of the encoded pixel data.
1240 */ 1240 * @param w A pointer to the unsigned int to hold the width in pixels.
1241 1241 * @param h A pointer to the unsigned int to hold the height in pixels.
1242 /** 1242 * @param alpha A pointer to the int to hold the alpha flag.
1243 * @typedef Eet_Key 1243 * @param compress A pointer to the int to hold the compression amount.
1244 * Opaque handle that defines an identity (also known as key) 1244 * @param quality A pointer to the int to hold the quality amount.
1245 * in Eet's cipher system. 1245 * @param lossy A pointer to the int to hold the lossiness flag.
1246 */ 1246 * @return The image pixel data decoded
1247 typedef struct _Eet_Key Eet_Key; 1247 *
1248 1248 * This function takes encoded pixel data and decodes it into raw RGBA
1249 /** 1249 * pixels on success.
1250 * @} 1250 *
1251 */ 1251 * The other parameters of the image (width, height etc.) are placed into
1252 1252 * the values pointed to (they must be supplied). The pixel data is a linear
1253 1253 * array of pixels starting from the top-left of the image scanning row by
1254 /** 1254 * row from left to right. Each pixel is a 32bit value, with the high byte
1255 * Callback used to request if needed the password of a private key. 1255 * being the alpha channel, the next being red, then green, and the low byte
1256 * 1256 * being blue. The width and height are measured in pixels and will be
1257 * @param buffer the buffer where to store the password. 1257 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1258 * @param size the maximum password size (size of buffer, including '@\0'). 1258 * that the alpha channel is not used. 1 denotes that it is significant.
1259 * @param rwflag if the buffer is also readable or just writable. 1259 * Compress is filled with the compression value/amount the image was
1260 * @param data currently unused, may contain some context in future. 1260 * stored with. The quality value is filled with the quality encoding of
1261 * @return 1 on success and password was set to @p buffer, 0 on failure. 1261 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1262 * 1262 * the image was encoded lossily or not.
1263 * @since 1.2.0 1263 *
1264 * @ingroup Eet_Cipher_Group 1264 * On success the function returns a pointer to the image data decoded. The
1265 */ 1265 * calling application is responsible for calling free() on the image data
1266 typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data); 1266 * when it is done with it. On failure NULL is returned and the parameter
1267 1267 * values may not contain any sensible data.
1268 /** 1268 *
1269 * Create an Eet_Key needed for signing an eet file. 1269 * @see eet_data_image_decode()
1270 * 1270 *
1271 * The certificate should provide the public that match the private key. 1271 * @since 1.0.0
1272 * No verification is done to ensure that. 1272 * @ingroup Eet_File_Image_Cipher_Group
1273 * 1273 */
1274 * @param certificate_file The file where to find the certificate. 1274EAPI void *eet_data_image_decode_cipher(const void *data,
1275 * @param private_key_file The file that contains the private key. 1275 const char *cipher_key,
1276 * @param cb Function to callback if password is required to unlock 1276 int size,
1277 * private key. 1277 unsigned int *w,
1278 * @return A key handle to use, or @c NULL on failure. 1278 unsigned int *h,
1279 * 1279 int *alpha,
1280 * @see eet_identity_close() 1280 int *compress,
1281 * 1281 int *quality,
1282 * @since 1.2.0 1282 int *lossy);
1283 * @ingroup Eet_Cipher_Group 1283
1284 */ 1284/**
1285 EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char *private_key_file, Eet_Key_Password_Callback cb); 1285 * Decode Image data into pixel data using a cipher.
1286 1286 * @param data The encoded pixel data.
1287 /** 1287 * @param cipher_key The key to use as cipher.
1288 * Close and release all ressource used by an Eet_Key. An 1288 * @param size The size, in bytes, of the encoded pixel data.
1289 * reference counter prevent it from being freed until all file 1289 * @param src_x The starting x coordinate from where to dump the stream.
1290 * using it are also closed. 1290 * @param src_y The starting y coordinate from where to dump the stream.
1291 * 1291 * @param d A pointer to the pixel surface.
1292 * @param key the key handle to close and free resources. 1292 * @param w The expected width in pixels of the pixel surface to decode.
1293 * 1293 * @param h The expected height in pixels of the pixel surface to decode.
1294 * @since 1.2.0 1294 * @param row_stride The length of a pixels line in the destination surface.
1295 * @ingroup Eet_Cipher_Group 1295 * @param alpha A pointer to the int to hold the alpha flag.
1296 */ 1296 * @param compress A pointer to the int to hold the compression amount.
1297 EAPI void eet_identity_close(Eet_Key *key); 1297 * @param quality A pointer to the int to hold the quality amount.
1298 1298 * @param lossy A pointer to the int to hold the lossiness flag.
1299 /** 1299 * @return 1 on success, 0 otherwise.
1300 * Set a key to sign a file 1300 *
1301 * 1301 * This function takes encoded pixel data and decodes it into raw RGBA
1302 * @param ef the file to set the identity. 1302 * pixels on success.
1303 * @param key the key handle to set as identity. 1303 *
1304 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or 1304 * The other parameters of the image (alpha, compress etc.) are placed into
1305 * #EET_ERROR_NONE on success. 1305 * the values pointed to (they must be supplied). The pixel data is a linear
1306 * 1306 * array of pixels starting from the top-left of the image scanning row by
1307 * @since 1.2.0 1307 * row from left to right. Each pixel is a 32bit value, with the high byte
1308 * @ingroup Eet_Cipher_Group 1308 * being the alpha channel, the next being red, then green, and the low byte
1309 */ 1309 * being blue. The width and height are measured in pixels and will be
1310 EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key); 1310 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1311 1311 * that the alpha channel is not used. 1 denotes that it is significant.
1312 /** 1312 * Compress is filled with the compression value/amount the image was
1313 * Display both private and public key of an Eet_Key. 1313 * stored with. The quality value is filled with the quality encoding of
1314 * 1314 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1315 * @param key the handle to print. 1315 * the image was encoded lossily or not.
1316 * @param out where to print. 1316 *
1317 * 1317 * On success the function returns 1, and 0 on failure. On failure the
1318 * @since 1.2.0 1318 * parameter values may not contain any sensible data.
1319 * @ingroup Eet_Cipher_Group 1319 *
1320 */ 1320 * @see eet_data_image_decode_to_surface()
1321 EAPI void eet_identity_print(Eet_Key *key, FILE *out); 1321 *
1322 1322 * @since 1.0.2
1323 /** 1323 * @ingroup Eet_File_Image_Cipher_Group
1324 * Get the x509 der certificate associated with an Eet_File. Will return NULL 1324 */
1325 * if the file is not signed. 1325EAPI int eet_data_image_decode_to_surface_cipher(const void *data,
1326 * 1326 const char *cipher_key,
1327 * @param ef The file handle to query. 1327 int size,
1328 * @param der_length The length of returned data, may be @c NULL. 1328 unsigned int src_x,
1329 * @return the x509 certificate or @c NULL on error. 1329 unsigned int src_y,
1330 * 1330 unsigned int *d,
1331 * @since 1.2.0 1331 unsigned int w,
1332 * @ingroup Eet_Cipher_Group 1332 unsigned int h,
1333 */ 1333 unsigned int row_stride,
1334 EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length); 1334 int *alpha,
1335 1335 int *compress,
1336 /** 1336 int *quality,
1337 * Get the raw signature associated with an Eet_File. Will return NULL 1337 int *lossy);
1338 * if the file is not signed. 1338
1339 * 1339/**
1340 * @param ef The file handle to query. 1340 * Encode image data for storage or transmission using a cipher.
1341 * @param signature_length The length of returned data, may be @c NULL. 1341 * @param data A pointer to the image pixel data.
1342 * @return the raw signature or @c NULL on error. 1342 * @param cipher_key The key to use as cipher.
1343 * 1343 * @param size_ret A pointer to an int to hold the size of the returned data.
1344 * @ingroup Eet_Cipher_Group 1344 * @param w The width of the image in pixels.
1345 */ 1345 * @param h The height of the image in pixels.
1346 EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length); 1346 * @param alpha The alpha channel flag.
1347 1347 * @param compress The compression amount.
1348 /** 1348 * @param quality The quality encoding amount.
1349 * Get the SHA1 associated with a file. Could be the one used to 1349 * @param lossy The lossiness flag.
1350 * sign the data or if the data where not signed, it will be the 1350 * @return The encoded image data.
1351 * SHA1 of the file. 1351 *
1352 * 1352 * This function stakes image pixel data and encodes it with compression and
1353 * @param ef The file handle to query. 1353 * possible loss of quality (as a trade off for size) for storage or
1354 * @param sha1_length The length of returned data, may be @c NULL. 1354 * transmission to another system.
1355 * @return the associated SHA1 or @c NULL on error. 1355 *
1356 * 1356 * The data expected is the same format as returned by eet_data_image_read.
1357 * @since 1.2.0 1357 * If this is not the case weird things may happen. Width and height must
1358 * @ingroup Eet_Cipher_Group 1358 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1359 */ 1359 * the alpha values are not useful and 1 meaning they are). Compress can
1360 EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length); 1360 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1361 1361 * This is only used if the image is not lossily encoded. Quality is used on
1362 /** 1362 * lossy compression and should be a value from 0 to 100. The lossy flag
1363 * Display the x509 der certificate to out. 1363 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1364 * 1364 * image quality loss (but then have a much smaller encoding).
1365 * @param certificate the x509 certificate to print 1365 *
1366 * @param der_length The length the certificate. 1366 * On success this function returns a pointer to the encoded data that you
1367 * @param out where to print. 1367 * can free with free() when no longer needed.
1368 * 1368 *
1369 * @since 1.2.0 1369 * @see eet_data_image_encode()
1370 * @ingroup Eet_Cipher_Group 1370 *
1371 */ 1371 * @since 1.0.0
1372 EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out); 1372 * @ingroup Eet_File_Image_Cipher_Group
1373 1373 */
1374 1374EAPI void *eet_data_image_encode_cipher(const void *data,
1375 /** 1375 const char *cipher_key,
1376 * @defgroup Eet_Data_Group Eet Data Serialization 1376 unsigned int w,
1377 * 1377 unsigned int h,
1378 * Convenience functions to serialize and parse complex data 1378 int alpha,
1379 * structures to binary blobs. 1379 int compress,
1380 * 1380 int quality,
1381 * While Eet core just handles binary blobs, it is often required 1381 int lossy,
1382 * to save some structured data of different types, such as 1382 int *size_ret);
1383 * strings, integers, lists, hashes and so on. 1383
1384 * 1384
1385 * Eet can serialize and then parse data types given some 1385/**
1386 * construction instructions. These are defined in two levels: 1386 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1387 * 1387 *
1388 * - #Eet_Data_Descriptor_Class to tell generic memory handling, 1388 * Eet allows one to protect entries of an #Eet_File
1389 * such as the size of the type, how to allocate memory, strings, 1389 * individually. This may be used to ensure data was not tampered or
1390 * lists, hashes and so on. 1390 * that third party does not read your data.
1391 * 1391 *
1392 * - #Eet_Data_Descriptor to tell inside such type, the members and 1392 * @see @ref Eet_File_Cipher_Group
1393 * their offsets inside the memory blob, their types and 1393 * @see @ref Eet_File_Image_Cipher_Group
1394 * names. These members can be simple types or other 1394 *
1395 * #Eet_Data_Descriptor, allowing hierarchical types to be 1395 * @{
1396 * defined. 1396 */
1397 * 1397
1398 * Given that C provides no introspection, this process can be 1398/**
1399 * quite cumbersome, so we provide lots of macros and convenience 1399 * @typedef Eet_Key
1400 * functions to aid creating the types. 1400 * Opaque handle that defines an identity (also known as key)
1401 * 1401 * in Eet's cipher system.
1402 * Example: 1402 */
1403 * 1403typedef struct _Eet_Key Eet_Key;
1404 * @code 1404
1405 * #include <Eet.h> 1405/**
1406 * #include <Evas.h> 1406 * @}
1407 * 1407 */
1408 * typedef struct _blah2 1408
1409 * { 1409
1410 * char *string; 1410/**
1411 * } Blah2; 1411 * Callback used to request if needed the password of a private key.
1412 * 1412 *
1413 * typedef struct _blah3 1413 * @param buffer the buffer where to store the password.
1414 * { 1414 * @param size the maximum password size (size of buffer, including '@\0').
1415 * char *string; 1415 * @param rwflag if the buffer is also readable or just writable.
1416 * } Blah3; 1416 * @param data currently unused, may contain some context in future.
1417 * 1417 * @return 1 on success and password was set to @p buffer, 0 on failure.
1418 * typedef struct _blah 1418 *
1419 * { 1419 * @since 1.2.0
1420 * char character; 1420 * @ingroup Eet_Cipher_Group
1421 * short sixteen; 1421 */
1422 * int integer; 1422typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag,
1423 * long long lots; 1423 void *data);
1424 * float floating; 1424
1425 * double floating_lots; 1425/**
1426 * char *string; 1426 * Create an Eet_Key needed for signing an eet file.
1427 * Blah2 *blah2; 1427 *
1428 * Eina_List *blah3; 1428 * The certificate should provide the public that match the private key.
1429 * } Blah; 1429 * No verification is done to ensure that.
1430 * 1430 *
1431 * int 1431 * @param certificate_file The file where to find the certificate.
1432 * main(int argc, char **argv) 1432 * @param private_key_file The file that contains the private key.
1433 * { 1433 * @param cb Function to callback if password is required to unlock
1434 * Blah blah; 1434 * private key.
1435 * Blah2 blah2; 1435 * @return A key handle to use, or @c NULL on failure.
1436 * Blah3 blah3; 1436 *
1437 * Eet_Data_Descriptor *edd, *edd2, *edd3; 1437 * @see eet_identity_close()
1438 * Eet_Data_Descriptor_Class eddc, eddc2, eddc3; 1438 *
1439 * void *data; 1439 * @since 1.2.0
1440 * int size; 1440 * @ingroup Eet_Cipher_Group
1441 * FILE *f; 1441 */
1442 * Blah *blah_in; 1442EAPI Eet_Key * eet_identity_open(const char *certificate_file,
1443 * 1443 const char *private_key_file,
1444 * eet_init(); 1444 Eet_Key_Password_Callback cb);
1445 * 1445
1446 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3); 1446/**
1447 * edd3 = eet_data_descriptor_stream_new(&eddc3); 1447 * Close and release all ressource used by an Eet_Key. An
1448 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING); 1448 * reference counter prevent it from being freed until all file
1449 * 1449 * using it are also closed.
1450 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2); 1450 *
1451 * edd2 = eet_data_descriptor_stream_new(&eddc2); 1451 * @param key the key handle to close and free resources.
1452 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING); 1452 *
1453 * 1453 * @since 1.2.0
1454 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah); 1454 * @ingroup Eet_Cipher_Group
1455 * edd = eet_data_descriptor_stream_new(&eddc); 1455 */
1456 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR); 1456EAPI void eet_identity_close(Eet_Key *key);
1457 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT); 1457
1458 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT); 1458/**
1459 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG); 1459 * Set a key to sign a file
1460 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT); 1460 *
1461 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE); 1461 * @param ef the file to set the identity.
1462 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING); 1462 * @param key the key handle to set as identity.
1463 * EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2); 1463 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1464 * EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3); 1464 * #EET_ERROR_NONE on success.
1465 * 1465 *
1466 * blah3.string = "PANTS"; 1466 * @since 1.2.0
1467 * 1467 * @ingroup Eet_Cipher_Group
1468 * blah2.string = "subtype string here!"; 1468 */
1469 * 1469EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key);
1470 * blah.character = '7'; 1470
1471 * blah.sixteen = 0x7777; 1471/**
1472 * blah.integer = 0xc0def00d; 1472 * Display both private and public key of an Eet_Key.
1473 * blah.lots = 0xdeadbeef31337777; 1473 *
1474 * blah.floating = 3.141592654; 1474 * @param key the handle to print.
1475 * blah.floating_lots = 0.777777777777777; 1475 * @param out where to print.
1476 * blah.string = "bite me like a turnip"; 1476 *
1477 * blah.blah2 = &blah2; 1477 * @since 1.2.0
1478 * blah.blah3 = eina_list_append(NULL, &blah3); 1478 * @ingroup Eet_Cipher_Group
1479 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1479 */
1480 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1480EAPI void eet_identity_print(Eet_Key *key, FILE *out);
1481 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1481
1482 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1482/**
1483 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1483 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1484 * blah.blah3 = eina_list_append(blah.blah3, &blah3); 1484 * if the file is not signed.
1485 * 1485 *
1486 * data = eet_data_descriptor_encode(edd, &blah, &size);