summaryrefslogtreecommitdiff
path: root/legacy/eet
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-17 16:35:38 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-17 16:35:38 +0000
commit8abaff3bdf53ecc7e605b82b12e385b8c0a02327 (patch)
tree4c828ae7083f724fd0214cf3624b20a7cf9448d2 /legacy/eet
parent12732ab7ebcacad66352d3d48306e9945a4a584f (diff)
merge: add eet
SVN revision: 76768
Diffstat (limited to 'legacy/eet')
-rw-r--r--legacy/eet/ChangeLog629
-rw-r--r--legacy/eet/NEWS67
-rw-r--r--legacy/eet/README68
-rw-r--r--legacy/eet/eet.pc.in12
-rw-r--r--legacy/eet/eet.spec.in76
-rw-r--r--legacy/eet/m4/efl_binary.m479
-rw-r--r--legacy/eet/m4/efl_check_libs.m4119
-rw-r--r--legacy/eet/src/bin/eet_main.c507
-rw-r--r--legacy/eet/src/examples/eet-basic.c40
-rw-r--r--legacy/eet/src/examples/eet-data-cipher_decipher.c119
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor_01.c529
-rw-r--r--legacy/eet/src/examples/eet-data-file_descriptor_02.c944
-rw-r--r--legacy/eet/src/examples/eet-data-nested.c272
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c224
-rw-r--r--legacy/eet/src/examples/eet-file.c127
-rw-r--r--legacy/eet/src/lib/Eet.h4271
-rw-r--r--legacy/eet/src/lib/Eet_private.h329
-rw-r--r--legacy/eet/src/lib/eet_alloc.c93
-rw-r--r--legacy/eet/src/lib/eet_cipher.c1391
-rw-r--r--legacy/eet/src/lib/eet_connection.c228
-rw-r--r--legacy/eet/src/lib/eet_data.c5014
-rw-r--r--legacy/eet/src/lib/eet_dictionary.c514
-rw-r--r--legacy/eet/src/lib/eet_image.c1881
-rw-r--r--legacy/eet/src/lib/eet_lib.c2707
-rw-r--r--legacy/eet/src/lib/eet_node.c797
-rw-r--r--legacy/eet/src/lib/eet_utils.c36
-rw-r--r--legacy/eet/src/lib/lz4/README7
-rw-r--r--legacy/eet/src/lib/lz4/lz4.c819
-rw-r--r--legacy/eet/src/lib/lz4/lz4.h120
-rw-r--r--legacy/eet/src/lib/lz4/lz4hc.c663
-rw-r--r--legacy/eet/src/lib/lz4/lz4hc.h60
-rw-r--r--legacy/eet/src/tests/TODO3
-rw-r--r--legacy/eet/src/tests/cert.pem22
-rw-r--r--legacy/eet/src/tests/eet_data_suite.c73
-rw-r--r--legacy/eet/src/tests/eet_suite.c2779
-rw-r--r--legacy/eet/src/tests/eet_suite.h9
-rw-r--r--legacy/eet/src/tests/key.pem15
-rw-r--r--legacy/eet/src/tests/key_enc.pem17
-rw-r--r--legacy/eet/src/tests/key_enc_none.pem16
39 files changed, 0 insertions, 25676 deletions
diff --git a/legacy/eet/ChangeLog b/legacy/eet/ChangeLog
deleted file mode 100644
index cc26e44429..0000000000
--- a/legacy/eet/ChangeLog
+++ /dev/null
@@ -1,629 +0,0 @@
12008-04-20 Carsten Haitzler (The Rasterman)
2
3 1.0.0 release
4
52008-04-28 Carsten Haitzler (The Rasterman)
6
7 * Fixed allocation of a list (EET_G_LIST) of simple types
8 (IS_SIMPLE_TYPE) to alloc the correct amount (using the correct type
9 offset). Also fixed a hash (EET_G_HASH) of simple types too.
10
112008-05-14 Cedric BAIL
12
13 * Fix conversion from a text to a hash (EET_G_HASH).
14
15 * Fix inlined string (EET_T_INLINED_STRING) dump/undump by introducing
16 the new word for the parser 'inlined'.
17
182008-05-15 Cedric BAIL
19
20 * Fix a typo preventing the parsing of unsigned int (EET_T_UINT).
21
22 * Fix group of simple type by implicitly creating a structure with
23 the simple type in it.
24
25 * Remove dead code handling group of simple type and put assert
26 instead.
27
282008-05-16 Cedric BAIL
29
30 * Fix eet_data_descriptor3_new as it purpose was to introduce
31 str_direct_alloc/str_direct_free usage. Application should now receive
32 direct pointer to read only (mmaped) string.
33
34 * Fix EET_FILE_MODE_READ_WRITE when file doesn't exist.
35
36 * Fix some miss use of efn->offset.
37
38 * Introduce unit test in EFL. The current set provide an overall
39 coverage rate of 2111 of 2607 lines (81.0%) for eet. It helped
40 finding and fixing the bugs of the last three days.
41 The test suite is based on library check. At this time we need
42 cvs version, look at http://check.sourceforge.net/ to find it.
43 The covering is done by gcov
44 The html report is done by lcov version 1.6 or above.
45 You can found it at http://ltp.sourceforge.net/coverage/lcov.php.
46
472008-05-19 Cedric BAIL
48
49 * Old Eet file format is now marked as deprecated and accessing old
50 file will display a warning. You can already remove completely all
51 code related to it, but it's still enabled by default. We will later
52 disable it by default and at some point drop the support completely.
53
54 * Remove use of strcpy and sprintf definitively.
55
562008-06-02 Cedric BAIL
57
58 * Introduce tile support and the possibility to decompress eet
59 image inside an existing surface.
60
612008-06-26 Cedric BAIL
62
63 * Massiv code cleanup.
64 * Add EET_G_ARRAY and EET_G_VAR_ARRAY support.
65 * Plan for version 2.0 API break of eet_data_descriptor_element_add.
66
672008-07-17 Cedric BAIL
68
69 Implement various speed improvement :
70
71 * Use the precomputed hash value for Eet_Data_Chunk.
72 * Use a hash table instead of a list for pointer that need to be freed.
73 * Use directly the pointer from the dictionary to do a pointer
74 comparison instead of a strcmp.
75
762008-07-24 Cedric BAIL
77
78 * Fix wrongly stored image when compressed size is bigger than
79 uncompressed. Fix bug #523.
80
812008-07-24 Vincent Torri
82
83 * Add Visual Studio solution and vc projects to compile Eet
84 with Microsoft tools.
85
86 Written by Dmitriy Mazovka.
87
882008-08-20 Cedric BAIL
89
90 * Fix the dictionnary check during eet_open.
91
922008-08-22 Cedric BAIL
93
94 * Fix memory leaks in eet_data strings
95
962008-09-03 Cedric BAIL
97
98 * Fix inline-jpeg decode to use mem buf, not tmp-file on platforms that
99 don't support mem_open() etc.
100 * Add eet_memopen_read() to be able to open an eet file already
101 mapped in memory (eg compiled-in or mmaped some other way).
102
1032008-09-11 Cedric BAIL
104
105 * Improve hash generation speed for big files.
106 * Inline more functions explicitly for speed.
107
1082008-09-25 Carsten Haitzler (The Rasterman)
109
110 1.1.0 release
111
1122008-10-20 Cedric BAIL
113
114 * Make use of eina.
115
1162008-10-23 Cedric BAIL
117
118 * Fix string in list and hash.
119
1202008-10-24 Cedric BAIL
121
122 * Fix array in eet_data.
123
1242008-11-13 Cedric BAIL
125
126 * Add crypto support to eet with OpenSSL.
127
1282008-11-13 Arnaud de Turckheim
129
130 * Add GNUtls support to eet.
131
1322008-11-14 Cedric BAIL
133
134 * Make password callback work with GNUtls.
135
1362008-11-26 Cedric BAIL
137
138 * Add a function to retrieve raw signature.
139
1402009-01-30 Cedric BAIL
141
142 * Fix a corrupted pointer use in eet_cipher.c
143
1442009-02-09 Chidambar Zinnoury
145
146 * Add some missing __UNUSED__ flags.
147
1482009-02-26 Luis Felipe Strano Moraes
149
150 * Fix problem reported by llvm
151
1522009-03-09 Cedric BAIL
153
154 * Add sha1 retrieval for an Eet_File.
155
1562009-03-17 Gustavo Sverzut Barbieri
157
158 * Force fsync() after data is written to file, solve ext4 issues.
159
1602009-03-18 Carsten Haitzler (The Rasterman)
161
162 * Disable fsync. Edit the code if you need it.
163
1642009-03-19 Cedric BAIL
165
166 * Make eet_data thread safe.
167
1682009-03-25 Cedric BAIL
169
170 * Fix eet pkg-config dependencies.
171 * Fix double init of gcry.
172
1732009-04-22 Carsten Haitzler (The Rasterman)
174
175 * Release eet 1.2.0
176
1772009-05-18 Cedric BAIL
178
179 * Cleanup Eet_Data code.
180
1812009-06-02 Cedric BAIL
182
183 * Make eet_node API usable.
184
1852009-06-14 Carsten Haitzler (The Rasterman)
186
187 * Release eet 1.2.1
188
1892009-07-08 Cedric BAIL
190
191 * Reorder gcry init to be used during gnutls init.
192
1932009-07-11 Hanspeter Portner
194
195 * Improve docs/examples in Eet.h
196
1972009-07-23 Cedric BAIL
198
199 * Fix init on system without SECMEM.
200
2012009-07-29 Carsten Haitzler (The Rasterman)
202
203 * Release eet 1.2.2
204
2052009-08-13 Cedric BAIL
206
207 * Deprecating eet_data_descriptor*_new.
208 * Add eet_data_descriptor_stream_new and eet_data_descriptor_file_new.
209 * Add eina helper.
210 * Cleanup Eet_Data_Descriptor code.
211
2122009-08-16 Carsten Haitzler (The Rasterman)
213
214 * Fix eet data encode to encode empty structs etc. so save saves
215 something as opposed to nothing
216
2172009-08-16 Carsten Haitzler (The Rasterman)
218
219 * Fix documentation of eet_data_write() and eet_write() for return
220 value to return # of bytes written, not 1 or 0
221
2222009-08-16 Vincent Torri
223
224 * Fix build with suncc (missing alloca() declaration in eet_cipher.c)
225
2262009-09-15 Mathieu Taillefumier
227
228 * Use new Eina_Log infrastructure to report error.
229
2302009-09-15 Cedric BAIL
231
232 * Remove apparently useless eet_freeleak_* from eet_data.
233
2342009-09-29 Cedric BAIL
235
236 * Add Fixed Point support and make it possible to switch from float
237 and double to any fixed point variant supported by eina.
238
239 Note: File saved with fixed point could be read by older version of
240 eet library with EET_T_DOUBLE type.
241
2422009-10-01 Mathieu Taillefumier
243
244 * remove useless Eina_Log macros.
245
2462009-10-01 Vincent Torri
247
248 * Check the returned value of eet_init() in the binary.
249 * Use binary mode of fopen() in eet_main() for Windows compatibility.
250
2512009-10-09 Vincent Torri
252
253 * initialize eina first in eet_init().
254
2552009-11-02 Vincent Torri
256
257 * allow generation of one single file with all source code in it.
258 See configure help to enable it (--enable-amalgamation).
259
2602009-11-11 Vincent Torri
261
262 * Add check on libgcrypt library in configure. Needed when GNUtls
263 support is enabled.
264
2652009-12-02 Carsten Haitzler (The Rasterman)
266
267 * Release eet 1.2.3
268
2692009-12-03 Cedric BAIL
270
271 * Make all operation on Eet_File thread safe.
272
2732009-12-07 Cedric BAIL
274
275 * Fix error when retrieving a different float type than the stored one.
276 * Reduce conversion with a little memory overhead.
277
2782009-12-07 Vincent Torri
279
280 * Include winsock2.h in eet_image.c for htonl definition on Windows.
281 * Fix Visual Studio project files
282
2832009-12-11 Cedric BAIL
284
285 * Make eet_data_descriptor_free safe to call on NULL pointer.
286
2872009-12-21 Cedric BAIL
288
289 * More work on eet_node dump code.
290
2912009-12-28 Cedric BAIL
292
293 * Add fully functionnal eet_node dump code.
294
2952009-12-29 Cedric BAIL
296
297 * Don't mess up when memory realloc failed during data descriptor creation.
298
2992010-01-04 Carsten Haitzler (The Rasterman)
300
301 * Fix another thread deadlock in mutex handling even in a single-threaded app.
302
3032010-01-12 Cedric BAIL
304
305 * Rewrite Eet_Data. Now you can do list/hash/array of strings and all
306 the test suite is passing.
307 * Add eet_data_node_decode_cipher and eet_data_node_read_cipher.
308
3092010-01-15 Cedric BAIL
310
311 * Fix amalgamation.
312
3132010-01-16 Vincent Torri
314
315 * eet_cipher.c: Fix arithmetic pointer on void *
316
3172010-01-17 Cedric BAIL
318
319 * Add a mempool for Eet_Node.
320
3212010-01-21 Cedric BAIL
322
323 * Add experimental API to walk Eet_Node tree.
324
3252010-01-22 Cedric BAIL
326
327 * Add VAR_ARRAY tests.
328
3292010-01-27 Cedric BAIL
330
331 * Improve security by zeroying cipher material as soon as possible.
332
3332010-01-27 Cedric BAIL
334
335 * Improve security by zeroying cipher material as soon as possible.
336
3372010-03-01 Albin Tonnerre
338
339 * Fix override of global symbols.
340
3412010-03-15 Adam Simpkins / Cedric BAIL
342
343 * Fix clearcache race condition.
344
3452010-04-02 Cedric BAIL
346
347 * Fix eet_data_node_read_cipher return type.
348 * Add Eet_Connection.
349
3502010-04-07 Cedric BAIL
351
352 * Improve eet_eina_file_data_descriptor_class_set by using
353 eina_hash_direct_add to avoid duplication hash key string.
354
3552010-04-08 Cedric BAIL
356
357 * Fix file corruption reported by Tiago Falcao <tiago@profusion.mobi>
358
3592010-04-09 Cedric BAIL
360
361 * Add eet_sync.
362 * Only delete the file at the last possible time.
363 * Reduce open file descriptor.
364
3652010-04-16 Cedric BAIL
366
367 * Handle fixed point in data stream.
368
3692010-04-21 Cedric BAIL
370
371 * Add EET_G_UNION and EET_G_VARIANT.
372
3732010-05-29 Carsten Haitzler (The Rasterman)
374
375 * Add EET_VERSION_MAJOR, EET_VERSION_MINOR.
376 * Add Eet_Version, eet_version.
377 * Make configure.ac use m4 defines for version
378 * Support SVN revision in version check
379
3802010-06-07 Carsten Haitzler (The Rasterman)
381
382 * Release eet 1.3.0
383
3842010-06-27 Carsten Haitzler (The Rasterman)
385
386 * Release eet 1.3.2
387
3882010-06-29 Vincent Torri
389
390 * On Windows 64, long is of size 32 bits and not 64 bits. Also
391 LONG_BIT is not defined on Windows.
392
3932010-06-29 Cedric BAIL
394
395 * Add eet_alias support.
396 * Fix possible dead lock in eet_write_cipher.
397
3982010-07-08 Carsten Haitzler (The Rasterman)
399
400 * Moved Eet.h into $includedir/eet-MAJOR_VERSION/
401
4022010-07-15 Vincent Torri
403
404 * Add native Windows thread support instead of using pthread
405 (less overhead). On other OS, pthread is still used by default.
406 Pass --enable-win32-threads to activate thread support on
407 Windows.
408
4092010-07-20 Cedric BAIL
410
411 * Improve file change detection in eet_open by checking size also.
412
4132010-08-02 Cedric BAIL
414
415 * Fix bug in eet_connection code when running on 32bits machine.
416
4172010-08-06 Cedric BAIL
418
419 * Add EET_DATA_DESCRIPTOR_ADD_HASH_STRING.
420
4212010-08-06 Cedric BAIL
422
423 * Break eet_eina_* function helper to provide a clean API/ABI to
424 prevent futur break. This should prevent the ABI break that was
425 introduced with release 1.3.0.
426
427 * Add a specific allocator for array. This should fix wrong allocation
428 case discovered with recent edje file format change.
429
4302010-08-23 Carsten Haitzler (The Rasterman)
431
432 * Fix some cppcheck complaints - all of them bogus though.
433 Nothing actually fixed.
434
4352010-08-27 Cedric BAIL
436
437 * Prevent the build of eet data structure that doesn't match what
438 the application is expecting.
439
4402010-09-02 Cedric BAIL
441
442 * Fix bug of ever growing dictionnary and improve strcmp comparison.
443
4442010-11-12 Cedric BAIL
445
446 * Don't try to read broken file when open in READ_WRITE mode.
447
4482010-11-14 Cedric BAIL
449
450 * Fix bug with cypher and compression used together.
451
4522010-11-21 Carsten Haitzler (The Rasterman)
453
454 * Fix another bug related to cipher and compression (leak and
455 bad free)
456
4572010-11-25 Cedric BAIL
458
459 * Add EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING.
460
4612010-11-26 Cedric BAIL
462
463 * Reduce memory used by Eet dictionary.
464
4652010-11-29 Cedric BAIL
466
467 * Improve speed of Eet_String users. It does impact all string
468 encoding/decoding, but even faster for stringshare encoding.
469
470 * Improve speed when decoding mostly array with eet_data_read.
471
4722010-12-03 Cedric BAIL
473
474 * Improve portability.
475
4762010-12-07 Carsten Haitzler (The Rasterman)
477
478 * Move raw function pointer defs to typedefs in public API for
479 readability improvements.
480
4812011-01-29 Carsten Haitzler (The Rasterman)
482
483 * 1.4.0 release
484
4852011-01-29 Vincent Torri
486
487 * Use eina_stringshare_add() instead of strdup() on mmaped file names
488 on Windows. This fix eet shut down on Windows.
489
4902011-02-14 Cedric BAIL
491
492 * Improve Eet_Data to make decoding of EET_G_UNION and EET_G_*ARRAY
493 faster and less memory heavy.
494
4952011-05-14 Cedric BAIL
496
497 * Use Eina_Lock.
498 * Sync GNUTLS initialisation with Eina.
499
5002011-05-17 Cedric BAIL
501
502 * Use Eina_File.
503 * Fix test forgetting to initialize eet.
504
5052011-05-23 Vincent Torri
506
507 * Fix compilation with libjpeg 8 on Windows.
508
5092011-06-10 Cedric BAIL
510
511 * Add EET_DATA_DESCRIPTOR_ADD_LIST_STRING helper to define List of char *.
512
5132011-07-04 Mike Blumenkrantz
514
515 * Add functions to manipulate nodes:
516 eet_node_children_get, eet_node_next_get, eet_node_parent_get,
517 eet_node_type_get, eet_node_value_get, eet_node_name_get
518 * Fix segmentation faults in several eet_node functions
519
5202011-07-16 Vincent Torri
521
522 * On Windows, open() in text mode followed by fdopen() in
523 binary mode does not create a stream in binary mode.
524 So add O_BINARY to open().
525
5262011-07-29 Mike Blumenkrantz
527
528 * Add eet_alias_get to return the destination name of an alias
529
5302011-09-15 Cedric Bail
531
532 * Add eet_data_xattr_cipher_get and eet_data_xattr_cipher_set.
533
5342011-10-04 Carsten Haitzler (The Rasterman)
535
536 * Fix issue where an empty eet file (no keys) is not openable
537 for read/write anymore. Allow it.
538
5392011-10-28 David Seikel (onefang)
540
541 * Added a new macro for adding arrays of basic types.
542 EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY
543
5442011-11-16 Carsten Haitzler (The Rasterman)
545
546 * JPEG encode and decode in eet now uses ISLOW (not IFAST) due to
547 noticable quality losses in the chase for speed. It will use
548 IFAST for quality less than 60 when encoding
549
5502011-12-02 Carsten Haitzler (The Rasterman)
551
552 1.5.0 release
553
5542011-12-02 Mike Blumenkrantz
555
556 * added eet_file_get to return the filename of an Eet_File
557 * Eet_File filenames are now stringshared
558 * added mempool allocators
559
5602011-12-29 Carsten Haitzler (The Rasterman)
561
562 * increase eet_connection packet size to 1Mb - more reasonable.
563
5642012-01-07 Boris Faure (billiob)
565
566 * make eet tool write to standard output if no output file given.
567
5682012-02-09 Cedric Bail
569
570 * add support for GNUTLS 3.x.
571
5722012-02-10 Cedric Bail
573
574 * add eet_dictionary_count.
575 * add "eet -t FILE.EET".
576
5772012-03-29 David Seikel (onefang)
578
579 * Added a new macro for adding variable arrays of basic types.
580 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY
581
5822012-04-26 Carsten Haitzler (The Rasterman)
583
584 1.6.0 release
585
5862012-05-11 Cedric Bail
587
588 * Force destruction of all pending file when shuting down eet.
589
5902012-05-14 Carsten Haitzler (The Rasterman)
591
592 * Add LZ4/LZ4HC compression & decompression capabilities
593
5942012-05-15 Cedric Bail
595
596 * Make eet_dictionary thread safe.
597
5982012-05-30 Cedric Bail
599
600 * Check that gnutls and openssl don't return below zero size during decipher.
601
6022012-06-27 Leandro Santiago
603
604 * Fix crash when cyphering huge amount of data.
605
6062012-07-16 Cedric Bail
607
608 * Add code to detect overrun and underrun in eet_data_descriptor_element_add.
609 * Fix possible wrong size decoding for simple type.
610
6112012-08-09 Cedric Bail
612
613 * Don't copy string around for nothing.
614
6152012-08-22 Igor Murzov (GArik_)
616
617 * Fixed memory leak of eet_data_chunk_put().
618
6192012-08-24 Cedric Bail
620
621 * Add eet_connection_empty.
622
6232012-08-26 Cedric Bail
624
625 * Correctly initialize dictionary correctly.
626
6272012-08-30 Carsten Haitzler (The Rasterman)
628
629 1.7.0 release
diff --git a/legacy/eet/NEWS b/legacy/eet/NEWS
deleted file mode 100644
index 9555bc938c..0000000000
--- a/legacy/eet/NEWS
+++ /dev/null
@@ -1,67 +0,0 @@
1Eet 1.7.0
2
3Changes since Eet 1.6.0:
4--------------------------
5
6Additions:
7 * Add code to detect overrun and underrun during Eet Data Descriptor setup.
8 * Add eet_connection_empty.
9
10Fixes:
11 * Force destruction of all pending file when shuting down eet.
12 * Make eet_dictionary thread safe.
13 * Check that gnutls and openssl don't return below zero size during decipher.
14 * Fix crash when cyphering huge amount of data.
15 * Possible wrong size decoding of simple type.
16 * Don't strdup string around for nothing.
17 * Always initialize dictionary correctly.
18 * Fixed memory leak of eet_data_chunk_put().
19
20Eet 1.6.0
21
22Changes since Eet 1.5.0:
23--------------------------
24
25Additions:
26 * eet_file_get to return filenames of Eet_Files.
27 * added support for GNUTLS 3.x.
28 * eet_dictionary_count.
29 * EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY API
30
31Improvements:
32
33 * most allocations moved to mempools.
34 * support GNUTLS 3.x.
35 * add "eet -t FILE.EET" to get some stat out of an eet file.
36 * eet filenames are now stringshare'd.
37 * increased eet_connection packet size to 1Mb.
38 * make eet tool write to stdout if no output file is given.
39
40Eet 1.5.0
41
42Changes since Eet 1.4.0:
43--------------------------
44
45Additions:
46
47 * EET_DATA_DESCRIPTOR_ADD_LIST_STRING API for string lists
48 * eet_node API's to manipulate nodes
49 * eet_alias_get API
50 * eet_data_xattr_cipher_get and eet_data_xattr_cipher_set APIs
51 * EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY API
52
53Fixes:
54
55 * eet shutdown on windows
56 * test case to init eet
57 * compilation against libjpeg 8 on windows
58 * binary open on windows
59 * unopenable empty eet file for read/write
60
61Improvements:
62
63 * better speed and memory footprint of EET_G_UNION and EET_G_ARRAY
64 * use stringshare for mmaped file names
65 * use eina locking wrappers
66 * use eina_file for file IO
67 * jpeg encode and decode quality improved at expense of speed
diff --git a/legacy/eet/README b/legacy/eet/README
deleted file mode 100644
index 989f4bbd7d..0000000000
--- a/legacy/eet/README
+++ /dev/null
@@ -1,68 +0,0 @@
1Eet 1.7.99
2
3******************************************************************************
4
5 FOR ANY ISSUES PLEASE EMAIL:
6 enlightenment-devel@lists.sourceforge.net
7
8******************************************************************************
9
10Requirements:
11-------------
12Must have:
13 libc
14 zlib
15 libjpeg
16 eina (1.1.0 or better)
17 (For windows you also need: evil)
18
19Optional requirements:
20 gnutls (1.7.6 or better)
21 openssl
22
23Eet is a tiny library designed to write an arbitrary set of chunks of
24data to a file and optionally compress each chunk (very much like a
25zip file) and allow fast random-access reading of the file later
26on. It does not do zip as a zip itself has more complexity than is
27needed, and it was much simpler to implement this once here.
28
29It also can encode and decode data structures in memory, as well as
30image data for saving to eet files or sending across the network to
31other machines, or just writing to arbitrary files on the system. All
32data is encoded in a platform independent way and can be written and
33read by any architecture. This data once encoded can be sent to
34another process or machine and decoded on the other end without
35needing to go into an eet file. Eet can also optionally encrypt files
36and use digital signatures (with gnutls or openssl support).
37
38------------------------------------------------------------------------------
39COMPILING AND INSTALLING:
40
41 ./configure
42 make
43(do this as root unless you are installing in your users directories):
44 make install
45
46To get the coverage report:
47 make coverage
48The report is created in the coverage/ subdir
49If you want to be able to run coverage test over eet, you will need gcov
50(usually any distro provides it) and lcov from:
51 http://ltp.sourceforge.net/coverage/lcov.php.
52For coverage support you also need "make check" support with the check
53library (see below).
54
55For compilation with MinGW, fnmatch.h is probably missing. That file can be
56found here:
57 http://www.koders.com/c/fid2B518462CB1EED3D4E31E271DB83CD1582F6EEBE.aspx
58It should be installed in the mingw include directory.
59
60For compilation with mingw32ce, run configure with the option
61 --host=arm-wince-mingw32ce
62
63For compilation with cegcc, follow the wiki:
64 http://wiki.enlightenment.org/index.php/Category:EFL_Windows_CE
65
66If you want to be able to run "make check", you need library check
67 from http://check.sourceforge.net/
68
diff --git a/legacy/eet/eet.pc.in b/legacy/eet/eet.pc.in
deleted file mode 100644
index ee958878be..0000000000
--- a/legacy/eet/eet.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: eet
7Description: Library for speedy data storage, retrieval, and compression
8Version: @VERSION@
9@pkgconfig_requires_private@: @requirements_pc_eet@
10Libs: -L${libdir} -leet
11Libs.private: @requirements_libs_eet@ -lm
12Cflags: -I${includedir}/eet-@VMAJ@
diff --git a/legacy/eet/eet.spec.in b/legacy/eet/eet.spec.in
deleted file mode 100644
index 5a91f60044..0000000000
--- a/legacy/eet/eet.spec.in
+++ /dev/null
@@ -1,76 +0,0 @@
1%{!?_rel:%{expand:%%global _rel 0.enl%{?dist}}}
2%define _missing_doc_files_terminate_build 0
3
4Summary: Library for speedy data storage, retrieval, and compression.
5Name: @PACKAGE@
6Version: @VERSION@
7Release: %{_rel}
8License: BSD
9Group: System Environment/Libraries
10Source: http://download.enlightenment.org/releases/%{name}-%{version}.tar.gz
11Packager: %{?_packager:%{_packager}}%{!?_packager:Michael Jennings <mej@eterm.org>}
12Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:The Enlightenment Project (http://www.enlightenment.org/)}
13Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
14URL: http://www.enlightenment.org/
15BuildRequires: libjpeg-devel zlib-devel
16BuildRoot: %{_tmppath}/%{name}-%{version}-root
17
18%description
19Eet is a tiny library designed to write an arbitrary set of chunks of
20data to a file and optionally compress each chunk (very much like a
21zip file) and allow fast random-access reading of the file later
22on. It does not do zip as a zip itself has more complexity than is
23needed, and it was much simpler to implement this once here.
24
25It also can encode and decode data structures in memory, as well as
26image data for saving to eet files or sending across the network to
27other machines, or just writing to arbitrary files on the system. All
28data is encoded in a platform independent way and can be written and
29read by any architecture.
30
31%package devel
32Summary: Eet headers, static libraries, documentation and test programs
33Group: System Environment/Libraries
34Requires: %{name} = %{version}
35Requires: libjpeg-devel, zlib-devel
36
37%description devel
38Headers, static libraries, test programs and documentation for Eet
39
40%prep
41%setup -q
42
43%build
44%{configure} --prefix=%{_prefix}
45### use this if you have build problems
46#./configure --prefix=%{_prefix}
47%{__make} %{?_smp_mflags} %{?mflags}
48
49%install
50%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install
51
52%clean
53test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
54
55%post
56/sbin/ldconfig
57
58%postun
59/sbin/ldconfig
60
61%files
62%defattr(-, root, root)
63%doc AUTHORS COPYING COPYING-PLAIN README
64%{_libdir}/*.so.*
65
66%files devel
67%defattr(-, root, root)
68%{_bindir}/eet*
69%{_libdir}/pkgconfig/*
70%{_includedir}/*
71%{_libdir}/*.a
72%{_libdir}/*.so
73%{_datadir}/eet
74%{_libdir}/*.la
75
76%changelog
diff --git a/legacy/eet/m4/efl_binary.m4 b/legacy/eet/m4/efl_binary.m4
deleted file mode 100644
index fc2f200509..0000000000
--- a/legacy/eet/m4/efl_binary.m4
+++ /dev/null
@@ -1,79 +0,0 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that checks if a binary is built or not
5
6dnl Usage: EFL_ENABLE_BIN(binary)
7dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _)
8dnl Define have_binary (- is transformed into _)
9dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _)
10
11AC_DEFUN([EFL_ENABLE_BIN],
12[
13
14m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
15m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl
16
17have_[]m4_defn([DOWN])="yes"
18
19dnl configure option
20
21AC_ARG_ENABLE([$1],
22 [AC_HELP_STRING([--disable-$1], [disable building of ]DOWN)],
23 [
24 if test "x${enableval}" = "xyes" ; then
25 have_[]m4_defn([DOWN])="yes"
26 else
27 have_[]m4_defn([DOWN])="no"
28 fi
29 ])
30
31AC_MSG_CHECKING([whether to build ]DOWN[ binary])
32AC_MSG_RESULT([$have_[]m4_defn([DOWN])])
33
34if test "x$have_[]m4_defn([DOWN])" = "xyes"; then
35 UP[]_PRG=DOWN[${EXEEXT}]
36fi
37
38AC_SUBST(UP[]_PRG)
39
40AM_CONDITIONAL(BUILD_[]UP, test "x$have_[]m4_defn([DOWN])" = "xyes")
41
42AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$2], [$3])
43
44])
45
46dnl Macro that specifies the binary to be used
47
48dnl Usage: EFL_WITH_BIN(binary, package, msg)
49dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _)
50dnl Define with_binary (- is transformed into _)
51dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _)
52
53AC_DEFUN([EFL_WITH_BIN],
54[
55
56m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
57m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl
58
59AC_REQUIRE([PKG_PROG_PKG_CONFIG])
60AC_MSG_NOTICE([$PKG_CONFIG])
61
62with_[]m4_defn([DOWN])=m4_esyscmd($PKG_CONFIG --variable=prefix $2)/bin/m4_defn([DOWN])
63
64dnl configure option
65
66AC_ARG_WITH([$1],
67 [AC_HELP_STRING([--with-$1-bin=PATH], [specify a specific path to ]DOWN)],
68 [
69 with_[]m4_defn([DOWN])=$withval
70 _efl_msg="( explicitely set)"
71 ])
72
73AC_MSG_NOTICE([$msg: ]m4_defn([DOWN])[$_efl_msg])
74
75AC_SUBST(with_[]m4_defn([DOWN]))
76
77AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$4], [$5])
78
79])
diff --git a/legacy/eet/m4/efl_check_libs.m4 b/legacy/eet/m4/efl_check_libs.m4
deleted file mode 100644
index b1c37894b6..0000000000
--- a/legacy/eet/m4/efl_check_libs.m4
+++ /dev/null
@@ -1,119 +0,0 @@
1dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com>
2dnl This code is public domain and can be freely used or copied.
3
4dnl Macro that check dependencies libraries for the EFL:
5
6dnl libjpeg
7dnl zlib
8
9dnl _EFL_CHECK_LIB_LIBJPEG is for internal use
10dnl _EFL_CHECK_LIB_LIBJPEG(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
11
12AC_DEFUN([_EFL_CHECK_LIB_LIBJPEG],
13[
14m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
15m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
16
17AC_CHECK_HEADER([jpeglib.h],
18 [have_dep="yes"],
19 [
20 AC_MSG_ERROR(["Cannot find jpeglib.h. Make sure your CFLAGS environment variable contains include lines for the location of this file"])
21 have_dep="no"
22 ])
23
24if test "x${have_dep}" = "xyes" ; then
25 AC_CHECK_LIB([jpeg], [jpeg_std_error],
26 [
27 have_dep="yes"
28 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -ljpeg"
29 ],
30 [
31 AC_MSG_ERROR("Cannot find libjpeg library. Make sure your LDFLAGS environment variable contains include lines for the location of this file")
32 have_dep="no"
33 ])
34fi
35
36AS_IF([test "x${have_dep}" = "xyes"], [$2], [$3])
37
38m4_popdef([DOWNEFL])
39m4_popdef([UPEFL])
40])
41
42dnl _EFL_CHECK_LIB_ZLIB is for internal use
43dnl _EFL_CHECK_LIB_ZLIB(EFL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
44
45AC_DEFUN([_EFL_CHECK_LIB_ZLIB],
46[
47m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
48m4_pushdef([DOWNEFL], m4_translit([$1], [-A-Z], [_a-z]))dnl
49
50PKG_CHECK_EXISTS([zlib],
51 [
52 _efl_have_lib="yes"
53 requirements_pc_[]m4_defn([DOWNEFL])="${requirements_pc_[]m4_defn([DOWNEFL])} zlib"
54 ],
55 [
56 _efl_have_lib="no"
57 ])
58
59if test "x${_efl_have_lib}" = "xno" ; then
60 AC_CHECK_HEADER([zlib.h],
61 [_efl_have_lib="yes"],
62 [
63 AC_MSG_ERROR(["Cannot find zlib.h. Make sure your CFLAGS environment variable contains include lines for the location of this file"])
64 _efl_have_lib="no"
65 ])
66
67 if test "x${_efl_have_lib}" = "xyes" ; then
68 AC_CHECK_LIB([z], [zlibVersion],
69 [
70 _efl_have_lib="yes"
71 requirements_libs_[]m4_defn([DOWNEFL])="${requirements_libs_[]m4_defn([DOWNEFL])} -lz"
72 ],
73 [
74 AC_MSG_ERROR(["Cannot find libjpeg library. Make sure your LDFLAGS environment variable contains include lines for the location of this file"])
75 _efl_have_lib="no"
76 ])
77 fi
78fi
79
80AS_IF([test "x${_efl_have_lib}" = "xyes"], [$2], [$3])
81
82m4_popdef([DOWNEFL])
83m4_popdef([UPEFL])
84])
85
86dnl Macro that checks for a library
87dnl
88dnl EFL_CHECK_LIB(EFL, LIBRARY)
89dnl AC_DEFINE : EFL_HAVE_LIBRARY (LIBRARY being replaced by its value)
90
91AC_DEFUN([EFL_CHECK_LIB],
92[
93m4_pushdef([UP], m4_translit([$2], [-a-z], [_A-Z]))dnl
94m4_pushdef([DOWN], m4_translit([$2], [-A-Z], [_a-z]))dnl
95
96m4_default([_EFL_CHECK_LIB_]m4_defn([UP]))($1, [have_lib="yes"], [have_lib="no"])
97
98AC_MSG_CHECKING([for ]m4_defn([DOWN]))
99AC_MSG_RESULT([${have_lib}])
100
101if test "x${have_lib}" = "xyes" ; then
102 AC_DEFINE([HAVE_]m4_defn([UP]), [1], [Define to 1 if the `]m4_defn([DOWN])[' library is installed.])
103fi
104
105efl_lib_[]m4_defn([DOWN])="${have_lib}"
106
107m4_popdef([DOWN])
108m4_popdef([UP])
109])
110
111dnl Macro that iterates over a sequence of white separated libraries
112dnl and that calls EFL_CHECK_LIB() for each of these libraries
113dnl
114dnl EFL_CHECK_LIBS(EFL, LIBRARIES)
115
116AC_DEFUN([EFL_CHECK_LIBS],
117[
118m4_foreach_w([lib], [$2], [EFL_CHECK_LIB($1, m4_defn([lib]))])
119])
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
deleted file mode 100644
index 8a93d11b4f..0000000000
--- a/legacy/eet/src/bin/eet_main.c
+++ /dev/null
@@ -1,507 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8
9#ifdef HAVE_UNISTD_H
10# include <unistd.h>
11#endif /* ifdef HAVE_UNISTD_H */
12
13#ifdef HAVE_EVIL
14# include <Evil.h>
15#endif /* ifdef HAVE_EVIL */
16
17#include <Eet.h>
18
19static int _eet_main_log_dom = -1;
20
21#ifdef EET_DEFAULT_LOG_COLOR
22#undef EET_DEFAULT_LOG_COLOR
23#endif /* ifdef EET_DEFAULT_LOG_COLOR */
24#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
25#ifdef ERR
26#undef ERR
27#endif /* ifdef ERR */
28#define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__)
29#ifdef DBG
30#undef DBG
31#endif /* ifdef DBG */
32#define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__)
33#ifdef INF
34#undef INF
35#endif /* ifdef INF */
36#define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__)
37#ifdef WRN
38#undef WRN
39#endif /* ifdef WRN */
40#define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__)
41#ifdef CRIT
42#undef CRIT
43#endif /* ifdef CRIT */
44#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
45
46static void
47do_eet_list(const char *file)
48{
49 int i, num;
50 char **list;
51 Eet_File *ef;
52
53 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef)
55 {
56 ERR("cannot open for reading: %s", file);
57 exit(-1);
58 }
59
60 list = eet_list(ef, "*", &num);
61 if (list)
62 {
63 for (i = 0; i < num; i++)
64 printf("%s\n", list[i]);
65 free(list);
66 }
67
68 eet_close(ef);
69} /* do_eet_list */
70
71static void
72do_eet_stats(const char *file)
73{
74 int i, num;
75 int count[2] = { 0, 0 };
76 int size[2] = { 0, 0 };
77 char **list;
78 Eet_File *ef;
79 Eet_Dictionary *ed;
80
81 ef = eet_open(file, EET_FILE_MODE_READ);
82 if (!ef)
83 {
84 ERR("cannot open for reading: %s", file);
85 exit(-1);
86 }
87
88 printf("*** sections stats ***\n");
89 list = eet_list(ef, "*", &num);
90 if (list)
91 {
92 for (i = 0; i < num; i++)
93 {
94 const void *ro = NULL;
95 void *rw = NULL;
96 int tsize;
97
98 ro = eet_read_direct(ef, list[i], &tsize);
99 if (!ro) rw = eet_read(ef, list[i], &tsize);
100 printf(rw ? "%s of size %i is compressed.\n" : "%s of size %i is not compressed.\n", list[i], tsize);
101 count[rw ? 0 : 1]++;
102 size[rw ? 0 : 1] += tsize;
103 free(rw);
104 }
105 free(list);
106 }
107
108 printf("*** dictionary ***\n");
109 ed = eet_dictionary_get(ef);
110 if (ed)
111 {
112 printf("%i strings inside the dictionary.\n", eet_dictionary_count(ed));
113 }
114 else
115 {
116 printf("no dictionary in this file.\n");
117 }
118 printf("*** global ***\n");
119 printf("%i sections\n", num);
120 printf("- %i of them are compressed (%02.2f%%) expanding in %i bytes.\n",
121 count[0], (float) count[0] * 100 / (float) num, size[0]);
122 printf("- %i of them are directly mappable in memory (%02.2f%%) representing %i bytes.\n",
123 count[1], (float) count[1] * 100 / (float) num, size[1]);
124
125 eet_close(ef);
126}
127
128static void
129do_eet_extract(const char *file,
130 const char *key,
131 const char *out,
132 const char *crypto_key)
133{
134 Eet_File *ef;
135 void *data;
136 int size = 0;
137 FILE *f = stdout;
138
139 ef = eet_open(file, EET_FILE_MODE_READ);
140 if (!ef)
141 {
142 ERR("cannot open for reading: %s", file);
143 exit(-1);
144 }
145
146 data = eet_read_cipher(ef, key, &size, crypto_key);
147 if (!data)
148 {
149 ERR("cannot read key %s", key);
150 exit(-1);
151 }
152
153 if (out)
154 {
155 f = fopen(out, "wb");
156 if (!f)
157 {
158 ERR("cannot open %s", out);
159 exit(-1);
160 }
161 }
162
163 if (fwrite(data, size, 1, f) != 1)
164 {
165 ERR("cannot write to %s", out ? out : "standard output");
166 exit(-1);
167 }
168
169 if (out) fclose(f);
170 free(data);
171 eet_close(ef);
172} /* do_eet_extract */
173
174static void
175do_eet_decode_dump(void *data,
176 const char *str)
177{
178 fputs(str, (FILE *)data);
179} /* do_eet_decode_dump */
180
181static void
182do_eet_decode(const char *file,
183 const char *key,
184 const char *out,
185 const char *crypto_key)
186{
187 Eet_File *ef;
188 FILE *f = stdout;
189
190 ef = eet_open(file, EET_FILE_MODE_READ);
191 if (!ef)
192 {
193 ERR("cannot open for reading: %s", file);
194 exit(-1);
195 }
196
197 if (out)
198 {
199 f = fopen(out, "wb");
200 if (!f)
201 {
202 ERR("cannot open %s", out);
203 exit(-1);
204 }
205 }
206
207 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f))
208 {
209 ERR("cannot write to %s", out ? out : "standard output");
210 exit(-1);
211 }
212
213 if (out) fclose(f);
214 eet_close(ef);
215} /* do_eet_decode */
216
217static void
218do_eet_insert(const char *file,
219 const char *key,
220 const char *out,
221 int compress,
222 const char *crypto_key)
223{
224 Eet_File *ef;
225 void *data;
226 int size = 0;
227 FILE *f;
228
229 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
230 if (!ef)
231 ef = eet_open(file, EET_FILE_MODE_WRITE);
232
233 if (!ef)
234 {
235 ERR("cannot open for read+write: %s", file);
236 exit(-1);
237 }
238
239 f = fopen(out, "rb");
240 if (!f)
241 {
242 ERR("cannot open %s", out);
243 exit(-1);
244 }
245
246 fseek(f, 0, SEEK_END);
247 size = ftell(f);
248 rewind(f);
249 data = malloc(size);
250 if (!data)
251 {
252 ERR("cannot allocate %i bytes", size);
253 exit(-1);
254 }
255
256 if (fread(data, size, 1, f) != 1)
257 {
258 ERR("cannot read file %s", out);
259 exit(-1);
260 }
261
262 fclose(f);
263 eet_write_cipher(ef, key, data, size, compress, crypto_key);
264 free(data);
265 eet_close(ef);
266} /* do_eet_insert */
267
268static void
269do_eet_encode(const char *file,
270 const char *key,
271 const char *out,
272 int compress,
273 const char *crypto_key)
274{
275 Eet_File *ef;
276 char *text;
277 int textlen = 0;
278 int size = 0;
279 FILE *f;
280
281 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
282 if (!ef)
283 ef = eet_open(file, EET_FILE_MODE_WRITE);
284
285 if (!ef)
286 {
287 ERR("cannot open for read+write: %s", file);
288 exit(-1);
289 }
290
291 f = fopen(out, "rb");
292 if (!f)
293 {
294 ERR("cannot open %s", out);
295 exit(-1);
296 }
297
298 fseek(f, 0, SEEK_END);
299 textlen = ftell(f);
300 rewind(f);
301 text = malloc(textlen);
302 if (!text)
303 {
304 ERR("cannot allocate %i bytes", size);
305 exit(-1);
306 }
307
308 if (fread(text, textlen, 1, f) != 1)
309 {
310 ERR("cannot read file %s", out);
311 exit(-1);
312 }
313
314 fclose(f);
315 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress))
316 {
317 ERR("cannot parse %s", out);
318 exit(-1);
319 }
320
321 free(text);
322 eet_close(ef);
323} /* do_eet_encode */
324
325static void
326do_eet_remove(const char *file,
327 const char *key)
328{
329 Eet_File *ef;
330
331 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
332 if (!ef)
333 {
334 ERR("cannot open for read+write: %s", file);
335 exit(-1);
336 }
337
338 eet_delete(ef, key);
339 eet_close(ef);
340} /* do_eet_remove */
341
342static void
343do_eet_check(const char *file)
344{
345 Eet_File *ef;
346 const void *der;
347 int der_length;
348 int sign_length;
349
350 ef = eet_open(file, EET_FILE_MODE_READ);
351 if (!ef)
352 {
353 ERR("checking signature of `%s` failed", file);
354 exit(-1);
355 }
356
357 der = eet_identity_x509(ef, &der_length);
358
359 fprintf(stdout, "Certificate length %i.\n", der_length);
360 eet_identity_certificate_print(der, der_length, stdout);
361
362 eet_identity_signature(ef, &sign_length);
363 fprintf(stdout, "Signature length %i.\n", sign_length);
364
365 eet_close(ef);
366} /* do_eet_check */
367
368static void
369do_eet_sign(const char *file,
370 const char *private_key,
371 const char *public_key)
372{
373 Eet_File *ef;
374 Eet_Key *key;
375
376 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
377 if (!ef)
378 {
379 ERR("cannot open for read+write: %s.", file);
380 exit(-1);
381 }
382
383 key = eet_identity_open(public_key, private_key, NULL);
384 if (!key)
385 {
386 ERR("cannot open key '%s:%s'.", public_key, private_key);
387 exit(-1);
388 }
389
390 fprintf(stdout, "Using the following key to sign `%s`.\n", file);
391 eet_identity_print(key, stdout);
392
393 eet_identity_set(ef, key);
394
395 eet_close(ef);
396} /* do_eet_sign */
397
398int
399main(int argc,
400 char **argv)
401{
402 if (!eet_init())
403 return -1;
404
405 _eet_main_log_dom = eina_log_domain_register("eet_main", EINA_COLOR_CYAN);
406 if(_eet_main_log_dom < -1)
407 {
408 EINA_LOG_ERR("Impossible to create a log domain for eet_main.");
409 eet_shutdown();
410 return -1;
411 }
412
413 if (argc < 2)
414 {
415help:
416 printf(
417 "Usage:\n"
418 " eet -l FILE.EET list all keys in FILE.EET\n"
419 " eet -x FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
420 " eet -d FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
421 " 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"
422 " 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"
423 " eet -r FILE.EET KEY remove KEY in FILE.EET\n"
424 " eet -c FILE.EET report and check the signature information of an eet file\n"
425 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n"
426 " eet -t FILE.EET give some statistic about a file\n"
427 );
428 eet_shutdown();
429 return -1;
430 }
431
432 if ((!strncmp(argv[1], "-h", 2)))
433 goto help;
434 else if ((!strcmp(argv[1], "-l")) && (argc > 2))
435 do_eet_list(argv[2]);
436 else if ((!strcmp(argv[1], "-x")) && (argc > 3))
437 {
438 switch (argc)
439 {
440 case 4:
441 {
442 do_eet_extract(argv[2], argv[3], NULL, NULL);
443 break;
444 }
445 case 5:
446 {
447 do_eet_extract(argv[2], argv[3], argv[4], NULL);
448 break;
449 }
450 default:
451 {
452 do_eet_extract(argv[2], argv[3], argv[4], argv[5]);
453 break;
454 }
455 }
456 }
457 else if ((!strcmp(argv[1], "-d")) && (argc > 3))
458 {
459 switch (argc)
460 {
461 case 4:
462 {
463 do_eet_decode(argv[2], argv[3], NULL, NULL);
464 break;
465 }
466 case 5:
467 {
468 do_eet_decode(argv[2], argv[3], argv[4], NULL);
469 break;
470 }
471 default:
472 {
473 do_eet_decode(argv[2], argv[3], argv[4], argv[5]);
474 break;
475 }
476 }
477 }
478 else if ((!strcmp(argv[1], "-i")) && (argc > 5))
479 {
480 if (argc > 6)
481 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
482 else
483 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
484 }
485 else if ((!strcmp(argv[1], "-e")) && (argc > 5))
486 {
487 if (argc > 6)
488 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
489 else
490 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
491 }
492 else if ((!strcmp(argv[1], "-r")) && (argc > 3))
493 do_eet_remove(argv[2], argv[3]);
494 else if ((!strcmp(argv[1], "-c")) && (argc > 2))
495 do_eet_check(argv[2]);
496 else if ((!strcmp(argv[1], "-s")) && (argc > 4))
497 do_eet_sign(argv[2], argv[3], argv[4]);
498 else if ((!strcmp(argv[1], "-t")) && (argc > 2))
499 do_eet_stats(argv[2]);
500 else
501 goto help;
502
503 eina_log_domain_unregister(_eet_main_log_dom);
504 eet_shutdown();
505 return 0;
506} /* main */
507
diff --git a/legacy/eet/src/examples/eet-basic.c b/legacy/eet/src/examples/eet-basic.c
deleted file mode 100644
index 05ff397789..0000000000
--- a/legacy/eet/src/examples/eet-basic.c
+++ /dev/null
@@ -1,40 +0,0 @@
1#include <Eet.h>
2
3int
4main(void)
5{
6 Eet_File *ef;
7 char *ret;
8 int size;
9 char *entries[] =
10 {
11 "Entry 1",
12 "Big text string here compared to others",
13 "Eet is cool"
14 };
15
16 eet_init();
17
18 // blindly open an file for output and write strings with their NUL char
19 ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
20 eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
21 eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
22 eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
23 eet_close(ef);
24
25 // open the file again and blindly get the entries we wrote
26 ef = eet_open("test.eet", EET_FILE_MODE_READ);
27 ret = eet_read(ef, "Entry 1", &size);
28 printf("%s\n", ret);
29 free(ret);
30 ret = eet_read(ef, "Entry 2", &size);
31 printf("%s\n", ret);
32 free(ret);
33 ret = eet_read(ef, "Entry 3", &size);
34 printf("%s\n", ret);
35 free(ret);
36 eet_close(ef);
37
38 eet_shutdown();
39}
40
diff --git a/legacy/eet/src/examples/eet-data-cipher_decipher.c b/legacy/eet/src/examples/eet-data-cipher_decipher.c
deleted file mode 100644
index 2ef965c745..0000000000
--- a/legacy/eet/src/examples/eet-data-cipher_decipher.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_cipher_decipher eet-data-file_cipher_decipher.c `pkg-config --cflags --libs eet eina`
3 */
4
5#include <Eina.h>
6#include <Eet.h>
7#include <stdio.h>
8#include <limits.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <unistd.h>
12
13int
14main(void)
15{
16 const char *buffer = "Here is a string of data to save !";
17 const char *key = "This is a crypto key";
18 const char *key_bad = "This is another crypto key";
19
20 char *file = strdup("/tmp/eet_cipher_example_XXXXX");
21 Eet_File *ef;
22 char *test;
23 int size;
24
25 eet_init();
26
27 if (!(file = tmpnam(file)))
28 {
29 fprintf(
30 stderr, "ERROR: could not create temporary file (%s).\n", file);
31 goto panic;
32 }
33
34 /* Crypt an eet file. */
35 ef = eet_open(file, EET_FILE_MODE_WRITE);
36 if (!ef)
37 {
38 fprintf(
39 stderr, "ERROR: could not access file (%s).\n", file);
40 goto error;
41 }
42
43 if (!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0, key))
44 {
45 fprintf(
46 stderr, "ERROR: could not access file (%s).\n", file);
47 goto error;
48 }
49
50 eet_close(ef);
51
52 /* Decrypt an eet file. */
53 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef)
55 {
56 fprintf(
57 stderr, "ERROR: could not access file (%s).\n", file);
58 goto error;
59 }
60
61 test = eet_read_cipher(ef, "keys/tests", &size, key);
62 if (!test)
63 {
64 fprintf(
65 stderr, "ERROR: could decript contents on file %s, with key %s.\n",
66 file, key);
67 goto error;
68 }
69
70 if (size != (int)strlen(buffer) + 1)
71 {
72 fprintf(
73 stderr, "ERROR: something is wrong with the decripted data\n");
74 goto error;
75 }
76
77 if (memcmp(test, buffer, strlen(buffer) + 1) != 0)
78 {
79 fprintf(
80 stderr, "ERROR: something is wrong with the decripted data\n");
81 goto error;
82 }
83
84 eet_close(ef);
85
86 /* Decrypt an eet file, now using our BAD key!! */
87 ef = eet_open(file, EET_FILE_MODE_READ);
88 if (!ef)
89 {
90 fprintf(
91 stderr, "ERROR: could not access file (%s).\n", file);
92 goto error;
93 }
94
95 test = eet_read_cipher(ef, "keys/tests", &size, key_bad);
96
97 if (size == (int)strlen(buffer) + 1)
98 if (memcmp(test, buffer, strlen(buffer) + 1) == 0)
99 {
100 fprintf(
101 stderr, "ERROR: something is wrong with the contents of %s, as"
102 " we accessed it with a different key and it decripted our"
103 " information right.\n", file);
104 goto error;
105 }
106
107 eet_close(ef);
108
109error:
110 if (unlink(file) != 0)
111 {
112 fprintf(
113 stderr, "ERROR: could not unlink file (%s).\n", file);
114 }
115
116panic:
117 eet_shutdown();
118}
119
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor_01.c b/legacy/eet/src/examples/eet-data-file_descriptor_01.c
deleted file mode 100644
index 4b5b75f865..0000000000
--- a/legacy/eet/src/examples/eet-data-file_descriptor_01.c
+++ /dev/null
@@ -1,529 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_descriptor eet-data-file_descriptor.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// complex real-world structures based on elmdentica database
13typedef struct
14{
15 const char *screen_name;
16 const char *name;
17 const char *message;
18 unsigned int id;
19 unsigned int status_id;
20 unsigned int date;
21 unsigned int timeline;
22} My_Message;
23
24typedef struct
25{
26 const char *dm_to;
27 const char *message;
28} My_Post;
29
30typedef struct
31{
32 unsigned int id;
33 const char *name;
34 Eina_List *messages;
35 My_Post *posts;
36 int posts_count;
37} My_Account;
38
39typedef struct
40{
41 unsigned int version; // it is recommended to use versioned configuration!
42 Eina_Hash *accounts;
43} My_Cache;
44
45// string that represents the entry in eet file, you might like to have
46// different profiles or so in the same file, this is possible with
47// different strings
48static const char MY_CACHE_FILE_ENTRY[] = "cache";
49
50// keep the descriptor static global, so it can be
51// shared by different functions (load/save) of this and only this
52// file.
53static Eet_Data_Descriptor *_my_cache_descriptor;
54static Eet_Data_Descriptor *_my_account_descriptor;
55static Eet_Data_Descriptor *_my_message_descriptor;
56static Eet_Data_Descriptor *_my_post_descriptor;
57
58// keep file handle alive, so mmap()ed strings are all alive as well
59static Eet_File *_my_cache_file = NULL;
60static Eet_Dictionary *_my_cache_dict = NULL;
61
62static void
63_my_cache_descriptor_init(void)
64{
65 Eet_Data_Descriptor_Class eddc;
66
67 // The FILE variant is good for caches and things that are just
68 // appended, but needs to take care when changing strings and files must
69 // be kept open so mmap()ed strings will be kept alive.
70 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Cache);
71 _my_cache_descriptor = eet_data_descriptor_file_new(&eddc);
72
73 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Account);
74 _my_account_descriptor = eet_data_descriptor_file_new(&eddc);
75
76 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Message);
77 _my_message_descriptor = eet_data_descriptor_file_new(&eddc);
78
79 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Post);
80 _my_post_descriptor = eet_data_descriptor_file_new(&eddc);
81
82 // Describe the members to be saved:
83 // Use a temporary macro so we don't type a lot, also avoid errors:
84
85#define ADD_BASIC(member, eet_type) \
86 EET_DATA_DESCRIPTOR_ADD_BASIC \
87 (_my_message_descriptor, My_Message, # member, member, eet_type)
88 ADD_BASIC(screen_name, EET_T_STRING);
89 ADD_BASIC(name, EET_T_STRING);
90 ADD_BASIC(message, EET_T_STRING);
91 ADD_BASIC(id, EET_T_UINT);
92 ADD_BASIC(status_id, EET_T_UINT);
93 ADD_BASIC(date, EET_T_UINT);
94 ADD_BASIC(timeline, EET_T_UINT);
95#undef ADD_BASIC
96
97#define ADD_BASIC(member, eet_type) \
98 EET_DATA_DESCRIPTOR_ADD_BASIC \
99 (_my_post_descriptor, My_Post, # member, member, eet_type)
100 ADD_BASIC(dm_to, EET_T_STRING);
101 ADD_BASIC(message, EET_T_STRING);
102#undef ADD_BASIC
103
104#define ADD_BASIC(member, eet_type) \
105 EET_DATA_DESCRIPTOR_ADD_BASIC \
106 (_my_account_descriptor, My_Account, # member, member, eet_type)
107 ADD_BASIC(name, EET_T_STRING);
108 ADD_BASIC(id, EET_T_UINT);
109#undef ADD_BASIC
110
111 EET_DATA_DESCRIPTOR_ADD_LIST
112 (_my_account_descriptor, My_Account, "messages", messages,
113 _my_message_descriptor);
114 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY
115 (_my_account_descriptor, My_Account, "posts", posts,
116 _my_post_descriptor);
117
118#define ADD_BASIC(member, eet_type) \
119 EET_DATA_DESCRIPTOR_ADD_BASIC \
120 (_my_cache_descriptor, My_Cache, # member, member, eet_type)
121 ADD_BASIC(version, EET_T_UINT);
122#undef ADD_BASIC
123
124 EET_DATA_DESCRIPTOR_ADD_HASH
125 (_my_cache_descriptor, My_Cache, "accounts", accounts,
126 _my_account_descriptor);
127} /* _my_cache_descriptor_init */
128
129static void
130_my_cache_descriptor_shutdown(void)
131{
132 eet_data_descriptor_free(_my_cache_descriptor);
133 eet_data_descriptor_free(_my_account_descriptor);
134 eet_data_descriptor_free(_my_message_descriptor);
135 eet_data_descriptor_free(_my_post_descriptor);
136} /* _my_cache_descriptor_shutdown */
137
138// need to check if the pointer came from mmaped area in eet_dictionary
139// or it was allocated with eina_stringshare_add()
140static void
141_eet_string_free(const char *str)
142{
143 if (!str)
144 return;
145
146 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str)))
147 return;
148
149 eina_stringshare_del(str);
150} /* _eet_string_free */
151
152static My_Message *
153_my_message_new(const char *message)
154{
155 My_Message *msg = calloc(1, sizeof(My_Message));
156 if (!msg)
157 {
158 fprintf(stderr, "ERROR: could not calloc My_Message\n");
159 return NULL;
160 }
161
162 msg->message = eina_stringshare_add(message);
163 return msg;
164} /* _my_message_new */
165
166static void
167_my_message_free(My_Message *msg)
168{
169 _eet_string_free(msg->screen_name);
170 _eet_string_free(msg->name);
171 _eet_string_free(msg->message);
172 free(msg);
173} /* _my_message_free */
174
175static Eina_Bool
176_my_post_add(My_Account *acc,
177 const char *message)
178{
179 int new_count = acc->posts_count + 1;
180 My_Post *post = realloc(acc->posts, new_count * sizeof(My_Post));
181 if (!post)
182 {
183 fprintf(stderr, "ERROR: could add My_Post\n");
184 return EINA_FALSE;
185 }
186
187 post[acc->posts_count].message = eina_stringshare_add(message);
188 post[acc->posts_count].dm_to = NULL;
189 acc->posts_count = new_count;
190 acc->posts = post;
191 return EINA_TRUE;
192} /* _my_post_new */
193
194static void
195_my_post_free(My_Post *post)
196{
197 _eet_string_free(post->dm_to);
198 _eet_string_free(post->message);
199} /* _my_post_free */
200
201static My_Account *
202_my_account_new(const char *name)
203{
204 My_Account *acc = calloc(1, sizeof(My_Account));
205 if (!acc)
206 {
207 fprintf(stderr, "ERROR: could not calloc My_Account\n");
208 return NULL;
209 }
210
211 acc->name = eina_stringshare_add(name);
212 return acc;
213} /* _my_account_new */
214
215static void
216_my_account_free(My_Account *acc)
217{
218 My_Message *m;
219 int i;
220
221 _eet_string_free(acc->name);
222
223 EINA_LIST_FREE(acc->messages, m)
224 _my_message_free(m);
225
226 for (i = 0; i < acc->posts_count; i++)
227 _my_post_free(&acc->posts[i]);
228 free(acc->posts);
229
230 free(acc);
231} /* _my_account_free */
232
233static My_Cache *
234_my_cache_new(void)
235{
236 My_Cache *my_cache = calloc(1, sizeof(My_Cache));
237 if (!my_cache)
238 {
239 fprintf(stderr, "ERROR: could not calloc My_Cache\n");
240 return NULL;
241 }
242
243 my_cache->accounts = eina_hash_string_small_new(NULL);
244
245 my_cache->version = 1;
246 return my_cache;
247} /* _my_cache_new */
248
249static Eina_Bool
250_my_cache_account_free_cb(const Eina_Hash *hash,
251 const void *key,
252 void *data,
253 void *fdata)
254{
255 _my_account_free(data);
256 return EINA_TRUE;
257}
258
259static void
260_my_cache_free(My_Cache *my_cache)
261{
262 My_Account *acc;
263 eina_hash_foreach(my_cache->accounts, _my_cache_account_free_cb, NULL);
264 eina_hash_free(my_cache->accounts);
265 free(my_cache);
266} /* _my_cache_free */
267
268static My_Account *
269_my_cache_account_find(My_Cache *my_cache,
270 const char *name)
271{
272 return eina_hash_find(my_cache->accounts, name);
273} /* _my_cache_account_find */
274
275static My_Cache *
276_my_cache_load(const char *filename)
277{
278 My_Cache *my_cache;
279 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
280 if (!ef)
281 {
282 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
283 return NULL;
284 }
285
286 my_cache = eet_data_read(ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY);
287 if (!my_cache)
288 {
289 eet_close(ef);
290 return NULL;
291 }
292
293 if (my_cache->version < 1)
294 {
295 fprintf(stderr,
296 "WARNING: version %#x was too old, upgrading it to %#x\n",
297 my_cache->version, 1);
298
299 my_cache->version = 1;
300 }
301
302 if (_my_cache_file)
303 eet_close(_my_cache_file);
304
305 _my_cache_file = ef;
306 _my_cache_dict = eet_dictionary_get(ef);
307
308 return my_cache;
309} /* _my_cache_load */
310
311static Eina_Bool
312_my_cache_save(const My_Cache *my_cache,
313 const char *filename)
314{
315 char tmp[PATH_MAX];
316 Eet_File *ef;
317 Eina_Bool ret;
318 unsigned int i, len;
319 struct stat st;
320
321 len = eina_strlcpy(tmp, filename, sizeof(tmp));
322 if (len + 12 >= (int)sizeof(tmp))
323 {
324 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
325 return EINA_FALSE;
326 }
327
328 i = 0;
329 do
330 {
331 snprintf(tmp + len, 12, ".%u", i);
332 i++;
333 }
334 while (stat(tmp, &st) == 0);
335
336 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
337 if (!ef)
338 {
339 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
340 return EINA_FALSE;
341 }
342
343 ret = eet_data_write
344 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE);
345
346 // VERY IMPORTANT NOTE:
347 // after eet_close(), all strings mmaped from file will be GONE, invalid!
348 // you'll need to free the old cache and open the new one.
349 // For cache this is okay, as you should be saving not so often or just
350 // at end.
351 //
352 // This is a trade off, you save memory by using mmap()ed strings, but
353 // you have to care about this.
354 eet_close(ef);
355
356 if (ret)
357 {
358 unlink(filename);
359 rename(tmp, filename);
360 }
361
362 return ret;
363} /* _my_cache_save */
364
365int
366main(int argc,
367 char *argv[])
368{
369 My_Cache *my_cache;
370 const Eina_List *l_acc;
371 Eina_Iterator *it;
372 My_Account *acc;
373 int ret = 0;
374
375 if (argc < 3)
376 {
377 fprintf(stderr,
378 "Usage:\n\t%s <input> <output> [action] [action-params]\n\n"
379 "Where actions and their parameters:\n"
380 "\tacc <name>\n"
381 "\tpost <account-name> <message>\n"
382 "\tmessage <account-name> <message>\n"
383 "\n",
384 argv[0]);
385 return -1;
386 }
387
388 eina_init();
389 eet_init();
390 _my_cache_descriptor_init();
391
392 my_cache = _my_cache_load(argv[1]);
393 if (!my_cache)
394 {
395 printf("creating new cache.\n");
396 my_cache = _my_cache_new();
397 if (!my_cache)
398 {
399 ret = -2;
400 goto end;
401 }
402 }
403
404 if (argc > 3)
405 {
406 if (strcmp(argv[3], "acc") == 0)
407 {
408 if (argc == 5)
409 {
410 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
411 if (!acc)
412 {
413 acc = _my_account_new(argv[4]);
414 eina_hash_direct_add(my_cache->accounts, acc->name, acc);
415 }
416 else
417 fprintf(stderr, "ERROR: account '%s' already exists.\n",
418 argv[4]);
419 }
420 else
421 fprintf(stderr,
422 "ERROR: wrong number of parameters (%d).\n",
423 argc);
424 }
425 else if (strcmp(argv[3], "post") == 0)
426 {
427 if (argc == 6)
428 {
429 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
430 if (acc)
431 {
432 _my_post_add(acc, argv[5]);
433 }
434 else
435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
436 }
437 else
438 fprintf(stderr,
439 "ERROR: wrong number of parameters (%d).\n",
440 argc);
441 }
442 else if (strcmp(argv[3], "message") == 0)
443 {
444 if (argc == 6)
445 {
446 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
447 if (acc)
448 {
449 My_Message *msg = _my_message_new(argv[5]);
450 acc->messages = eina_list_append(acc->messages, msg);
451 }
452 else
453 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
454 }
455 else
456 fprintf(stderr,
457 "ERROR: wrong number of parameters (%d).\n",
458 argc);
459 }
460 else
461 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
462 }
463
464 printf("My_Cache:\n"
465 "\tversion.: %#x\n"
466 "\taccounts: %u\n",
467 my_cache->version,
468 eina_hash_population(my_cache->accounts));
469 it = eina_hash_iterator_data_new(my_cache->accounts);
470 EINA_ITERATOR_FOREACH(it, acc)
471 {
472 const My_Post *post;
473
474 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
475 acc->id, acc->name ? acc->name : "",
476 eina_list_count(acc->messages),
477 acc->posts_count);
478
479 if (eina_list_count(acc->messages))
480 {
481 const Eina_List *l;
482 const My_Message *msg;
483 printf("\t |messages:\n");
484
485 EINA_LIST_FOREACH(acc->messages, l, msg)
486 {
487 printf("\t | %-8x '%s' [%s]: '%.20s'\n",
488 msg->id,
489 msg->name ? msg->name : "",
490 msg->screen_name ? msg->screen_name : "",
491 msg->message ? msg->message : "");
492 }
493 }
494
495 if (acc->posts_count)
496 {
497 const My_Post *post;
498 int i;
499 printf("\t |posts:\n");
500
501 for (i = 0; i < acc->posts_count; i++)
502 {
503 post = &acc->posts[i];
504 if (post->dm_to)
505 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
506 else
507 printf("\t | '%.20s'\n", post->message);
508 }
509 }
510
511 printf("\n");
512 }
513 eina_iterator_free(it);
514
515 if (!_my_cache_save(my_cache, argv[2]))
516 ret = -3;
517
518 _my_cache_free(my_cache);
519
520end:
521 if (_my_cache_file)
522 eet_close(_my_cache_file);
523 _my_cache_descriptor_shutdown();
524 eet_shutdown();
525 eina_shutdown();
526
527 return ret;
528} /* main */
529
diff --git a/legacy/eet/src/examples/eet-data-file_descriptor_02.c b/legacy/eet/src/examples/eet-data-file_descriptor_02.c
deleted file mode 100644
index 65ba79ec40..0000000000
--- a/legacy/eet/src/examples/eet-data-file_descriptor_02.c
+++ /dev/null
@@ -1,944 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_descriptor_02 eet-data-file_descriptor_02.c `pkg-config --cflags --libs eet eina`
3 */
4
5#include <Eina.h>
6#include <Eet.h>
7#include <stdio.h>
8#include <limits.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <unistd.h>
12
13typedef enum _Example_Data_Type Example_Data_Type;
14typedef struct _Example_Variant_Type Example_Variant_Type;
15typedef struct _Example_Variant Example_Variant;
16typedef struct _Example_Union Example_Union;
17typedef struct _Example_Struct1 Example_Struct1;
18typedef struct _Example_Struct2 Example_Struct2;
19typedef struct _Example_Struct3 Example_Struct3;
20typedef struct _Example_Lists Example_Lists;
21
22enum _Example_Data_Type
23{
24 EET_UNKNOWN = 0,
25 EET_STRUCT1,
26 EET_STRUCT2,
27 EET_STRUCT3
28};
29
30struct
31{
32 Example_Data_Type u;
33 const char *name;
34} eet_mapping[] = {
35 { EET_STRUCT1, "ST1" },
36 { EET_STRUCT2, "ST2" },
37 { EET_STRUCT3, "ST3" },
38 { EET_UNKNOWN, NULL }
39};
40
41struct _Example_Struct1
42{
43 double val1;
44 int stuff;
45 const char *s1;
46};
47
48struct _Example_Struct2
49{
50 Eina_Bool b1;
51 unsigned long long v1;
52};
53
54struct _Example_Struct3
55{
56 int body;
57};
58
59struct _Example_Union
60{
61 Example_Data_Type type;
62
63 union {
64 Example_Struct1 st1;
65 Example_Struct2 st2;
66 Example_Struct3 st3;
67 } u;
68};
69
70struct _Example_Variant_Type
71{
72 const char *type;
73 Eina_Bool unknow : 1;
74};
75
76struct _Example_Variant
77{
78 Example_Variant_Type t;
79
80 void *data; /* differently than the union type, we
81 * don't need to pre-allocate the memory
82 * for the field*/
83};
84
85struct _Example_Lists
86{
87 Eina_List *union_list;
88 Eina_List *variant_list;
89};
90
91static void
92_st1_set(Example_Struct1 *st1,
93 double v1,
94 int v2,
95 const char *v3)
96{
97 st1->val1 = v1;
98 st1->stuff = v2;
99 st1->s1 = v3;
100} /* _st1_set */
101
102static void
103_st2_set(Example_Struct2 *st2,
104 Eina_Bool v1,
105 unsigned long long v2)
106{
107 st2->b1 = v1;
108 st2->v1 = v2;
109} /* _st2_set */
110
111static void
112_st3_set(Example_Struct3 *st3,
113 int v1)
114{
115 st3->body = v1;
116} /* _st3_set */
117
118static const char *
119/* union
120 type_get() */
121_union_type_get(const void *data,
122 Eina_Bool *unknow)
123{
124 const Example_Data_Type *u = data;
125 int i;
126
127 if (unknow)
128 *unknow = EINA_FALSE;
129
130 for (i = 0; eet_mapping[i].name != NULL; ++i)
131 if (*u == eet_mapping[i].u)
132 return eet_mapping[i].name;
133
134 if (unknow)
135 *unknow = EINA_TRUE;
136
137 return NULL;
138} /* _union_type_get */
139
140static Eina_Bool
141_union_type_set(const char *type,
142 void *data,
143 Eina_Bool unknow)
144{
145 Example_Data_Type *u = data;
146 int i;
147
148 if (unknow)
149 return EINA_FALSE;
150
151 for (i = 0; eet_mapping[i].name != NULL; ++i)
152 if (strcmp(eet_mapping[i].name, type) == 0)
153 {
154 *u = eet_mapping[i].u;
155 return EINA_TRUE;
156 }
157
158 return EINA_FALSE;
159} /* _union_type_set */
160
161static const char *
162_variant_type_get(const void *data,
163 Eina_Bool *unknow)
164{
165 const Example_Variant_Type *type = data;
166 int i;
167
168 if (unknow)
169 *unknow = type->unknow;
170
171 for (i = 0; eet_mapping[i].name != NULL; ++i)
172 if (strcmp(type->type, eet_mapping[i].name) == 0)
173 return eet_mapping[i].name;
174
175 if (unknow)
176 *unknow = EINA_FALSE;
177
178 return type->type;
179} /* _variant_type_get */
180
181static Eina_Bool
182_variant_type_set(const char *type,
183 void *data,
184 Eina_Bool unknow)
185{
186 Example_Variant_Type *vt = data;
187
188 vt->type = type;
189 vt->unknow = unknow;
190 return EINA_TRUE;
191} /* _variant_type_set */
192
193static Eet_Data_Descriptor *
194_st1_dd(void)
195{
196 Eet_Data_Descriptor_Class eddc;
197 Eet_Data_Descriptor *res;
198
199 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct1);
200 res = eet_data_descriptor_file_new(&eddc);
201 EET_DATA_DESCRIPTOR_ADD_BASIC(
202 res, Example_Struct1, "val1", val1, EET_T_DOUBLE);
203 EET_DATA_DESCRIPTOR_ADD_BASIC(
204 res, Example_Struct1, "stuff", stuff, EET_T_INT);
205 EET_DATA_DESCRIPTOR_ADD_BASIC(
206 res, Example_Struct1, "s1", s1, EET_T_STRING);
207
208 return res;
209} /* _st1_dd */
210
211static Eet_Data_Descriptor *
212_st2_dd(void)
213{
214 Eet_Data_Descriptor_Class eddc;
215 Eet_Data_Descriptor *res;
216
217 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct2);
218 res = eet_data_descriptor_file_new(&eddc);
219 EET_DATA_DESCRIPTOR_ADD_BASIC(
220 res, Example_Struct2, "b1", b1, EET_T_UCHAR);
221 EET_DATA_DESCRIPTOR_ADD_BASIC(
222 res, Example_Struct2, "v1", v1, EET_T_ULONG_LONG);
223
224 return res;
225} /* _st2_dd */
226
227static Eet_Data_Descriptor *
228_st3_dd(void)
229{
230 Eet_Data_Descriptor_Class eddc;
231 Eet_Data_Descriptor *res;
232
233 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct3);
234 res = eet_data_descriptor_file_new(&eddc);
235 EET_DATA_DESCRIPTOR_ADD_BASIC(
236 res, Example_Struct3, "body", body, EET_T_INT);
237
238 return res;
239} /* _st3_dd */
240
241/* string that represents the entry in the eet file. you might like to
242 * have different profiles or so in the same file, this is possible
243 * with different strings
244 */
245static const char CACHE_FILE_ENTRY[] = "cache";
246
247/* keep the descriptor static global, so it can be shared by different
248 * functions (load/save) of this and only this file.
249 */
250static Eet_Data_Descriptor *_lists_descriptor;
251static Eet_Data_Descriptor *_struct_1_descriptor;
252static Eet_Data_Descriptor *_struct_2_descriptor;
253static Eet_Data_Descriptor *_struct_3_descriptor;
254static Eet_Data_Descriptor *_union_descriptor;
255static Eet_Data_Descriptor *_variant_descriptor;
256static Eet_Data_Descriptor *_union_unified_descriptor;
257static Eet_Data_Descriptor *_variant_unified_descriptor;
258
259/* keep file handle alive, so mmap()ed strings are all alive as
260 * well */
261static Eet_File *_cache_file = NULL;
262static Eet_Dictionary *_cache_dict = NULL;
263
264static void
265/* declaring types */
266_data_descriptors_init(void)
267{
268 Eet_Data_Descriptor_Class eddc;
269
270 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Lists);
271 _lists_descriptor = eet_data_descriptor_file_new(&eddc);
272
273 _struct_1_descriptor = _st1_dd();
274 _struct_2_descriptor = _st2_dd();
275 _struct_3_descriptor = _st3_dd();
276
277 /* for union */
278 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Union);
279 _union_descriptor = eet_data_descriptor_file_new(&eddc);
280
281 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
282 eddc.func.type_get = _union_type_get;
283 eddc.func.type_set = _union_type_set;
284 _union_unified_descriptor = eet_data_descriptor_file_new(&eddc);
285
286 EET_DATA_DESCRIPTOR_ADD_MAPPING(
287 _union_unified_descriptor, "ST1", _struct_1_descriptor);
288 EET_DATA_DESCRIPTOR_ADD_MAPPING(
289 _union_unified_descriptor, "ST2", _struct_2_descriptor);
290 EET_DATA_DESCRIPTOR_ADD_MAPPING(
291 _union_unified_descriptor, "ST3", _struct_3_descriptor);
292
293 EET_DATA_DESCRIPTOR_ADD_UNION(
294 _union_descriptor, Example_Union, "u", u, type,
295 _union_unified_descriptor);
296
297 EET_DATA_DESCRIPTOR_ADD_LIST(
298 _lists_descriptor, Example_Lists, "union_list", union_list,
299 _union_descriptor);
300
301 /* for variant */
302 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Variant);
303 _variant_descriptor = eet_data_descriptor_file_new(&eddc);
304
305 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
306 eddc.func.type_get = _variant_type_get;
307 eddc.func.type_set = _variant_type_set;
308 _variant_unified_descriptor = eet_data_descriptor_stream_new(&eddc);
309
310 EET_DATA_DESCRIPTOR_ADD_MAPPING(
311 _variant_unified_descriptor, "ST1", _struct_1_descriptor);
312 EET_DATA_DESCRIPTOR_ADD_MAPPING(
313 _variant_unified_descriptor, "ST2", _struct_2_descriptor);
314 EET_DATA_DESCRIPTOR_ADD_MAPPING(
315 _variant_unified_descriptor, "ST3", _struct_3_descriptor);
316
317 EET_DATA_DESCRIPTOR_ADD_VARIANT(
318 _variant_descriptor, Example_Variant, "data", data, t,
319 _variant_unified_descriptor);
320
321 EET_DATA_DESCRIPTOR_ADD_LIST(
322 _lists_descriptor, Example_Lists, "variant_list", variant_list,
323 _variant_descriptor);
324} /* _data_descriptors_init */
325
326static void
327_data_descriptors_shutdown(void)
328{
329 eet_data_descriptor_free(_lists_descriptor);
330 eet_data_descriptor_free(_struct_1_descriptor);
331 eet_data_descriptor_free(_struct_2_descriptor);
332 eet_data_descriptor_free(_struct_3_descriptor);
333 eet_data_descriptor_free(_union_descriptor);
334 eet_data_descriptor_free(_variant_descriptor);
335 eet_data_descriptor_free(_union_unified_descriptor);
336 eet_data_descriptor_free(_variant_unified_descriptor);
337} /* _data_descriptors_shutdown */
338
339/* need to check if the pointer came from mmap()ed area in
340 * eet_dictionary or it was allocated with eina_stringshare_add()
341 */
342static void
343_string_free(const char *str)
344{
345 if (!str)
346 return;
347
348 if ((_cache_dict) && (eet_dictionary_string_check(_cache_dict, str)))
349 return;
350
351 eina_stringshare_del(str);
352} /* _string_free */
353
354static Example_Union *
355_union_1_new(const char *v1,
356 const char *v2,
357 const char *v3)
358{
359 Example_Union *un = calloc(1, sizeof(Example_Union));
360 if (!un)
361 {
362 fprintf(
363 stderr, "ERROR: could not allocate an Example_Union struct.\n");
364 return NULL;
365 }
366
367 un->type = EET_STRUCT1;
368 _st1_set(&(un->u.st1), atof(v1), atoi(v2), eina_stringshare_add(v3));
369
370 return un;
371}
372
373static Example_Union *
374_union_2_new(const char *v1,
375 const char *v2)
376{
377 Example_Union *un = calloc(1, sizeof(Example_Union));
378 if (!un)
379 {
380 fprintf(
381 stderr, "ERROR: could not allocate an Example_Union struct.\n");
382 return NULL;
383 }
384
385 un->type = EET_STRUCT2;
386 _st2_set(&(un->u.st2), atoi(v1), atoi(v2));
387
388 return un;
389}
390
391static Example_Union *
392_union_3_new(const char *v1)
393{
394 Example_Union *un = calloc(1, sizeof(Example_Union));
395 if (!un)
396 {
397 fprintf(
398 stderr, "ERROR: could not allocate an Example_Union struct.\n");
399 return NULL;
400 }
401
402 un->type = EET_STRUCT3;
403 _st3_set(&(un->u.st3), atoi(v1));
404
405 return un;
406}
407
408static Example_Variant *
409_variant_1_new(const char *v1,
410 const char *v2,
411 const char *v3)
412{
413 Example_Struct1 *st1;
414 Example_Variant *va = calloc(1, sizeof(Example_Variant));
415 if (!va)
416 {
417 fprintf(
418 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
419 return NULL;
420 }
421
422 va = calloc(1, sizeof (Example_Variant));
423 va->t.type = eet_mapping[0].name;
424 st1 = calloc(1, sizeof (Example_Struct1));
425 _st1_set(st1, atof(v1), atoi(v2), eina_stringshare_add(v3));
426 va->data = st1;
427
428 return va;
429}
430
431static Example_Variant *
432_variant_2_new(const char *v1,
433 const char *v2)
434{
435 printf("varinant 2 new\n");
436
437 Example_Struct2 *st2;
438 Example_Variant *va = calloc(1, sizeof(Example_Variant));
439 if (!va)
440 {
441 fprintf(
442 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
443 return NULL;
444 }
445
446 va = calloc(1, sizeof (Example_Variant));
447
448 va->t.type = eet_mapping[1].name;
449
450 printf("type gets %s\n", va->t.type);
451
452 st2 = calloc(1, sizeof (Example_Struct2));
453 _st2_set(st2, atoi(v1), atoi(v2));
454 va->data = st2;
455
456 return va;
457}
458
459static Example_Variant *
460_variant_3_new(const char *v1)
461{
462 Example_Struct3 *st3;
463 Example_Variant *va = calloc(1, sizeof(Example_Variant));
464 if (!va)
465 {
466 fprintf(
467 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
468 return NULL;
469 }
470
471 va = calloc(1, sizeof (Example_Variant));
472 va->t.type = eet_mapping[2].name;
473 st3 = calloc(1, sizeof (Example_Struct3));
474 _st3_set(st3, atoi(v1));
475 va->data = st3;
476
477 return va;
478}
479
480static Example_Lists *
481_data_new(void)
482{
483 Example_Lists *example_lists = calloc(1, sizeof(Example_Lists));
484 if (!example_lists)
485 {
486 fprintf(stderr, "ERROR: could not allocate a Example_Lists struct.\n");
487 return NULL;
488 }
489
490 return example_lists;
491} /* _data_new */
492
493static void
494_union_free(Example_Union *un)
495{
496 if (un->type == EET_STRUCT1)
497 {
498 Example_Struct1 *st1 = &(un->u.st1);
499 _string_free(st1->s1);
500 }
501
502 free(un);
503}
504
505static void
506_variant_free(Example_Variant *va)
507{
508 if (!strcmp(va->t.type, eet_mapping[0].name))
509 {
510 Example_Struct1 *st1 = va->data;
511 _string_free(st1->s1);
512 }
513
514 free(va->data);
515 free(va);
516}
517
518static void
519_data_free(Example_Lists *cache)
520{
521 Example_Union *un;
522 Example_Variant *va;
523
524 EINA_LIST_FREE(cache->union_list, un)
525 _union_free(un);
526
527 EINA_LIST_FREE(cache->variant_list, va)
528 _variant_free(va);
529
530 free(cache);
531} /* _data_free */
532
533static Example_Lists *
534_data_load(const char *filename)
535{
536 Example_Lists *data;
537 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
538 if (!ef)
539 {
540 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
541 return NULL;
542 }
543
544 data = eet_data_read(ef, _lists_descriptor, CACHE_FILE_ENTRY);
545 if (!data)
546 {
547 eet_close(ef);
548 return NULL;
549 }
550
551 if (_cache_file)
552 eet_close(_cache_file);
553
554 _cache_file = ef;
555 _cache_dict = eet_dictionary_get(ef);
556
557 return data;
558} /* _data_load */
559
560static Eina_Bool
561_data_save(const Example_Lists *cache,
562 const char *filename)
563{
564 char tmp[PATH_MAX];
565 Eet_File *ef;
566 Eina_Bool ret;
567 unsigned int i, len;
568 struct stat st;
569
570 len = eina_strlcpy(tmp, filename, sizeof(tmp));
571 if (len + 12 >= (int)sizeof(tmp))
572 {
573 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
574 return EINA_FALSE;
575 }
576
577 i = 0;
578 do
579 {
580 snprintf(tmp + len, 12, ".%u", i);
581 i++;
582 }
583 while (stat(tmp, &st) == 0);
584
585 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
586 if (!ef)
587 {
588 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
589 return EINA_FALSE;
590 }
591
592 ret = eet_data_write
593 (ef, _lists_descriptor, CACHE_FILE_ENTRY, cache, EINA_TRUE);
594
595 eet_close(ef);
596
597 if (ret)
598 {
599 unlink(filename);
600 rename(tmp, filename);
601 }
602
603 return ret;
604} /* _data_save */
605
606static void
607_print_union(const Example_Union *un)
608{
609 printf("\t | type: %s'\n", eet_mapping[un->type - 1].name);
610
611 switch (un->type)
612 {
613 case EET_STRUCT1:
614 printf("\t\t val1: %f\n", un->u.st1.val1);
615 printf("\t\t stuff: %d\n", un->u.st1.stuff);
616 printf("\t\t s1: %s\n", un->u.st1.s1);
617 break;
618
619 case EET_STRUCT2:
620 printf("\t\t val1: %i\n", un->u.st2.b1);
621 printf("\t\t stuff: %lli\n", un->u.st2.v1);
622 break;
623
624 case EET_STRUCT3:
625 printf("\t\t val1: %i\n", un->u.st3.body);
626 break;
627
628 default:
629 return;
630 }
631}
632
633static void
634_print_variant(const Example_Variant *va)
635{
636 printf("\t | type: %s'\n", va->t.type);
637
638 switch (va->t.type[2])
639 {
640 case '1':
641 {
642 Example_Struct1 *st1 = va->data;
643
644 printf("\t\t val1: %f\n", st1->val1);
645 printf("\t\t stuff: %d\n", st1->stuff);
646 printf("\t\t s1: %s\n", st1->s1);
647 }
648 break;
649
650 case '2':
651 {
652 Example_Struct2 *st2 = va->data;
653
654 printf("\t\t val1: %i\n", st2->b1);
655 printf("\t\t stuff: %lli\n", st2->v1);
656 }
657 break;
658
659 case '3':
660 {
661 Example_Struct3 *st3 = va->data;
662
663 printf("\t\t val1: %i\n", st3->body);
664 }
665 break;
666
667 default:
668 return;
669 }
670}
671
672int
673main(int argc,
674 char *argv[])
675{
676 Example_Lists *data_lists;
677 int ret = 0;
678
679 if (argc < 3)
680 {
681 fprintf(stderr,
682 "Usage:\n\t%s <input> <output> [action action-params]\n\n"
683 "where actions and their parameters are:\n"
684 "\tunion <type> [fields]\n"
685 "\tvariant <type> [fields]\n"
686 "\n",
687 argv[0]);
688 return -1;
689 }
690
691 eina_init();
692 eet_init();
693 _data_descriptors_init();
694
695 data_lists = _data_load(argv[1]);
696 if (!data_lists)
697 {
698 printf("Creating new data lists.\n");
699 data_lists = _data_new();
700 if (!data_lists)
701 {
702 ret = -2;
703 goto end;
704 }
705 }
706
707 if (argc > 3)
708 {
709 if (strcmp(argv[3], "union") == 0)
710 {
711 if (argc > 4)
712 {
713 int type = atoi(argv[4]);
714 Example_Union *un;
715
716 if (type < EET_STRUCT1 || type > EET_STRUCT3)
717 {
718 fprintf(stderr,
719 "ERROR: invalid type parameter (%s).\n",
720 argv[4]);
721 goto cont;
722 }
723
724 switch (type)
725 {
726 case 1:
727 if (argc != 8)
728 {
729 fprintf(
730 stderr, "ERROR: wrong number of parameters"
731 " (%d).\n", argc);
732 goto cont;
733 }
734
735 un = _union_1_new(
736 argv[5], argv[6], argv[7]);
737 if (!un)
738 {
739 fprintf(
740 stderr, "ERROR: could not create the "
741 "requested union.\n");
742 goto cont;
743 }
744 data_lists->union_list =
745 eina_list_append(data_lists->union_list, un);
746 break;
747
748 case 2:
749 if (argc != 7)
750 {
751 fprintf(
752 stderr, "ERROR: wrong number of parameters"
753 " (%d).\n", argc);
754 goto cont;
755 }
756
757 un = _union_2_new(argv[5], argv[6]);
758 if (!un)
759 {
760 fprintf(
761 stderr, "ERROR: could not create the "
762 "requested union.\n");
763 goto cont;
764 }
765 data_lists->union_list =
766 eina_list_append(data_lists->union_list, un);
767 break;
768
769 case 3:
770 if (argc != 6)
771 {
772 fprintf(
773 stderr, "ERROR: wrong number of parameters"
774 " (%d).\n", argc);
775 goto cont;
776 }
777
778 un = _union_3_new(argv[5]);
779 if (!un)
780 {
781 fprintf(
782 stderr, "ERROR: could not create the "
783 "requested union.\n");
784 goto cont;
785 }
786 data_lists->union_list =
787 eina_list_append(data_lists->union_list, un);
788 break;
789
790 default:
791 fprintf(
792 stderr, "ERROR: bad type of of struct passed\n");
793 goto cont;
794 }
795 }
796 else
797 fprintf(stderr,
798 "ERROR: wrong number of parameters (%d).\n",
799 argc);
800 }
801 else if (strcmp(argv[3], "variant") == 0)
802 {
803 if (argc > 4)
804 {
805 int type = atoi(argv[4]);
806 Example_Variant *va;
807
808 if (type < EET_STRUCT1 || type > EET_STRUCT3)
809 {
810 fprintf(stderr,
811 "ERROR: invalid type parameter (%s).\n",
812 argv[4]);
813 goto cont;
814 }
815
816 switch (type)
817 {
818 case 1:
819 if (argc != 8)
820 {
821 fprintf(
822 stderr, "ERROR: wrong number of parameters"
823 " (%d).\n", argc);
824 goto cont;
825 }
826
827 va = _variant_1_new(
828 argv[5], argv[6], argv[7]);
829 if (!va)
830 {
831 fprintf(
832 stderr, "ERROR: could not create the "
833 "requested variant.\n");
834 goto cont;
835 }
836 data_lists->variant_list =
837 eina_list_append(data_lists->variant_list, va);
838 break;
839
840 case 2:
841 if (argc != 7)
842 {
843 fprintf(
844 stderr, "ERROR: wrong number of parameters"
845 " (%d).\n", argc);
846 goto cont;
847 }
848
849 va = _variant_2_new(argv[5], argv[6]);
850 if (!va)
851 {
852 fprintf(
853 stderr, "ERROR: could not create the "
854 "requested variant.\n");
855 goto cont;
856 }
857 data_lists->variant_list =
858 eina_list_append(data_lists->variant_list, va);
859 break;
860
861 case 3:
862 if (argc != 6)
863 {
864 fprintf(
865 stderr, "ERROR: wrong number of parameters"
866 " (%d).\n", argc);
867 goto cont;
868 }
869
870 va = _variant_3_new(argv[5]);
871 if (!va)
872 {
873 fprintf(
874 stderr, "ERROR: could not create the "
875 "requested variant.\n");
876 goto cont;
877 }
878 data_lists->variant_list =
879 eina_list_append(data_lists->variant_list, va);
880 break;
881
882 default:
883 fprintf(
884 stderr, "ERROR: bad type of of struct passed\n");
885 goto cont;
886 }
887 }
888 else
889 fprintf(stderr,
890 "ERROR: wrong number of parameters (%d).\n",
891 argc);
892 }
893 else
894 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[3]);
895 }
896
897cont:
898 printf("Cached data:\n");
899
900 printf("\tstats: unions=%u, variants=%u\n",
901 eina_list_count(data_lists->union_list),
902 eina_list_count(data_lists->variant_list));
903
904 if (eina_list_count(data_lists->union_list))
905 {
906 const Eina_List *l;
907 const Example_Union *un;
908 printf("\t * union list:\n");
909
910 EINA_LIST_FOREACH(data_lists->union_list, l, un)
911 {
912 _print_union(un);
913 }
914 }
915
916 if (eina_list_count(data_lists->variant_list))
917 {
918 const Eina_List *l;
919 const Example_Variant *un;
920 printf("\t * variant list:\n");
921
922 EINA_LIST_FOREACH(data_lists->variant_list, l, un)
923 {
924 _print_variant(un);
925 }
926 }
927
928 printf("\n");
929
930 if (!_data_save(data_lists, argv[2]))
931 ret = -3;
932
933 _data_free(data_lists);
934
935end:
936 if (_cache_file)
937 eet_close(_cache_file);
938 _data_descriptors_shutdown();
939 eet_shutdown();
940 eina_shutdown();
941
942 return ret;
943} /* main */
944
diff --git a/legacy/eet/src/examples/eet-data-nested.c b/legacy/eet/src/examples/eet-data-nested.c
deleted file mode 100644
index a6b0e1208a..0000000000
--- a/legacy/eet/src/examples/eet-data-nested.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * build: gcc -o eet_data_nested eet-data-nested.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// The struct that will be loaded and saved.
13// note that only the members described in the eet_data_descriptor
14// will be automatically handled. The other members will have their
15// space reserved and zeroed (as it uses calloc()), but not
16// saved or loaded from eet files.
17typedef struct
18{
19 unsigned int version; // it is recommended to use versioned configuration!
20 const char *name;
21 int id;
22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled;
24 Eina_List *subs;
25} My_Conf_Type;
26
27typedef struct
28{
29 const char *server;
30 int port;
31} My_Conf_Subtype;
32
33// string that represents the entry in eet file, you might like to have
34// different profiles or so in the same file, this is possible with
35// different strings
36static const char MY_CONF_FILE_ENTRY[] = "config";
37
38// keep the descriptor static global, so it can be
39// shared by different functions (load/save) of this and only this
40// file.
41static Eet_Data_Descriptor *_my_conf_descriptor;
42static Eet_Data_Descriptor *_my_conf_sub_descriptor;
43
44static void
45_my_conf_descriptor_init(void)
46{
47 Eet_Data_Descriptor_Class eddc;
48
49 // The class describe the functions to use to create the type and its
50 // full allocated size.
51 //
52 // Eina types are very convenient, so use them to create the descriptor,
53 // so we get eina_list, eina_hash and eina_stringshare automatically!
54 //
55 // The STREAM variant is better for configuration files as the values
56 // will likely change a lot.
57 //
58 // The other variant, FILE, is good for caches and things that are just
59 // appended, but needs to take care when changing strings and files must
60 // be kept open so mmap()ed strings will be kept alive.
61 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Type);
62 _my_conf_descriptor = eet_data_descriptor_stream_new(&eddc);
63
64 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Subtype);
65 _my_conf_sub_descriptor = eet_data_descriptor_stream_new(&eddc);
66
67 // Describe the members to be saved:
68 // Use a temporary macro so we don't type a lot, also avoid errors:
69#define MY_CONF_ADD_BASIC(member, eet_type) \
70 EET_DATA_DESCRIPTOR_ADD_BASIC \
71 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
72#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \
73 EET_DATA_DESCRIPTOR_ADD_BASIC \
74 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
75
76 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
77 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT);
78
79 MY_CONF_ADD_BASIC(version, EET_T_UINT);
80 MY_CONF_ADD_BASIC(name, EET_T_STRING);
81 MY_CONF_ADD_BASIC(id, EET_T_INT);
82 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
83
84 // And add the sub descriptor as a linked list at 'subs' in the main struct
85 EET_DATA_DESCRIPTOR_ADD_LIST
86 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor);
87
88#undef MY_CONF_ADD_BASIC
89#undef MY_CONF_SUB_ADD_BASIC
90} /* _my_conf_descriptor_init */
91
92static void
93_my_conf_descriptor_shutdown(void)
94{
95 eet_data_descriptor_free(_my_conf_sub_descriptor);
96 eet_data_descriptor_free(_my_conf_descriptor);
97} /* _my_conf_descriptor_shutdown */
98
99static My_Conf_Type *
100_my_conf_new(void)
101{
102 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
103 My_Conf_Subtype *sub;
104 if (!my_conf)
105 {
106 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
107 return NULL;
108 }
109
110 my_conf->version = 0x112233;
111 my_conf->enabled = EINA_TRUE;
112
113 sub = calloc(1, sizeof(My_Conf_Subtype));
114 if (sub)
115 {
116 sub->server = eina_stringshare_add("my-server.com");
117 sub->port = 1234;
118 my_conf->subs = eina_list_append(my_conf->subs, sub);
119 }
120
121 return my_conf;
122} /* _my_conf_new */
123
124static void
125_my_conf_free(My_Conf_Type *my_conf)
126{
127 My_Conf_Subtype *sub;
128 EINA_LIST_FREE(my_conf->subs, sub)
129 {
130 eina_stringshare_del(sub->server);
131 free(sub);
132 }
133
134 eina_stringshare_del(my_conf->name);
135 free(my_conf);
136} /* _my_conf_free */
137
138static My_Conf_Type *
139_my_conf_load(const char *filename)
140{
141 My_Conf_Type *my_conf;
142 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
143 if (!ef)
144 {
145 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
146 return NULL;
147 }
148
149 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
150 if (!my_conf)
151 goto end;
152
153 if (my_conf->version < 0x112233)
154 {
155 fprintf(stderr,
156 "WARNING: version %#x was too old, upgrading it to %#x\n",
157 my_conf->version, 0x112233);
158
159 my_conf->version = 0x112233;
160 my_conf->enabled = EINA_TRUE;
161 }
162
163end:
164 eet_close(ef);
165 return my_conf;
166} /* _my_conf_load */
167
168static Eina_Bool
169_my_conf_save(const My_Conf_Type *my_conf,
170 const char *filename)
171{
172 char tmp[PATH_MAX];
173 Eet_File *ef;
174 Eina_Bool ret;
175 unsigned int i, len;
176 struct stat st;
177
178 len = eina_strlcpy(tmp, filename, sizeof(tmp));
179 if (len + 12 >= (int)sizeof(tmp))
180 {
181 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
182 return EINA_FALSE;
183 }
184
185 i = 0;
186 do
187 {
188 snprintf(tmp + len, 12, ".%u", i);
189 i++;
190 }
191 while (stat(tmp, &st) == 0);
192
193 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
194 if (!ef)
195 {
196 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
197 return EINA_FALSE;
198 }
199
200 ret = eet_data_write
201 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
202 eet_close(ef);
203
204 if (ret)
205 {
206 unlink(filename);
207 rename(tmp, filename);
208 }
209
210 return ret;
211} /* _my_conf_save */
212
213int
214main(int argc,
215 char *argv[])
216{
217 My_Conf_Type *my_conf;
218 const My_Conf_Subtype *sub;
219 const Eina_List *l;
220 int ret = 0;
221
222 if (argc != 3)
223 {
224 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
225 return -1;
226 }
227
228 eina_init();
229 eet_init();
230 _my_conf_descriptor_init();
231
232 my_conf = _my_conf_load(argv[1]);
233 if (!my_conf)
234 {
235 printf("creating new configuration.\n");
236 my_conf = _my_conf_new();
237 if (!my_conf)
238 {
239 ret = -2;
240 goto end;
241 }
242 }
243
244 printf("My_Conf_Type:\n"
245 "\tversion: %#x\n"
246 "\tname...: '%s'\n"
247 "\tid.....: %d\n"
248 "\tenabled: %hhu\n"
249 "\tsubs...:\n",
250 my_conf->version,
251 my_conf->name ? my_conf->name : "",
252 my_conf->id,
253 my_conf->enabled);
254
255 EINA_LIST_FOREACH(my_conf->subs, l, sub)
256 printf("\t\tserver: '%s', port: %d\n",
257 sub->server ? sub->server : "",
258 sub->port);
259
260 if (!_my_conf_save(my_conf, argv[2]))
261 ret = -3;
262
263 _my_conf_free(my_conf);
264
265end:
266 _my_conf_descriptor_shutdown();
267 eet_shutdown();
268 eina_shutdown();
269
270 return ret;
271} /* main */
272
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
deleted file mode 100644
index 1951fc012b..0000000000
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ /dev/null
@@ -1,224 +0,0 @@
1/*
2 * build: gcc -o eet_data_simple eet-data-simple.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// The struct that will be loaded and saved.
13// note that only the members described in the eet_data_descriptor
14// will be automatically handled. The other members will have their
15// space reserved and zeroed (as it uses calloc()), but not
16// saved or loaded from eet files.
17typedef struct
18{
19 unsigned int version; // it is recommended to use versioned configuration!
20 const char *name;
21 int id;
22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled;
24} My_Conf_Type;
25
26// string that represents the entry in eet file, you might like to have
27// different profiles or so in the same file, this is possible with
28// different strings
29static const char MY_CONF_FILE_ENTRY[] = "config";
30
31// keep the descriptor static global, so it can be
32// shared by different functions (load/save) of this and only this
33// file.
34static Eet_Data_Descriptor *_my_conf_descriptor;
35
36static void
37_my_conf_descriptor_init(void)
38{
39 Eet_Data_Descriptor_Class eddc;
40
41 // The class describe the functions to use to create the type and its
42 // full allocated size.
43 //
44 // Eina types are very convenient, so use them to create the descriptor,
45 // so we get eina_list, eina_hash and eina_stringshare automatically!
46 //
47 // The STREAM variant is better for configuration files as the values
48 // will likely change a lot.
49 //
50 // The other variant, FILE, is good for caches and things that are just
51 // appended, but needs to take care when changing strings and files must
52 // be kept open so mmap()ed strings will be kept alive.
53 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Type);
54 _my_conf_descriptor = eet_data_descriptor_stream_new(&eddc);
55
56 // Describe the members to be saved:
57 // Use a temporary macro so we don't type a lot, also avoid errors:
58#define MY_CONF_ADD_BASIC(member, eet_type) \
59 EET_DATA_DESCRIPTOR_ADD_BASIC \
60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
61
62 MY_CONF_ADD_BASIC(version, EET_T_UINT);
63 MY_CONF_ADD_BASIC(name, EET_T_STRING);
64 MY_CONF_ADD_BASIC(id, EET_T_INT);
65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
66
67#undef MY_CONF_ADD_BASIC
68} /* _my_conf_descriptor_init */
69
70static void
71_my_conf_descriptor_shutdown(void)
72{
73 eet_data_descriptor_free(_my_conf_descriptor);
74} /* _my_conf_descriptor_shutdown */
75
76static My_Conf_Type *
77_my_conf_new(void)
78{
79 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
80 if (!my_conf)
81 {
82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
83 return NULL;
84 }
85
86 my_conf->version = 0x112233;
87 my_conf->enabled = EINA_TRUE;
88 return my_conf;
89} /* _my_conf_new */
90
91static void
92_my_conf_free(My_Conf_Type *my_conf)
93{
94 eina_stringshare_del(my_conf->name);
95 free(my_conf);
96} /* _my_conf_free */
97
98static My_Conf_Type *
99_my_conf_load(const char *filename)
100{
101 My_Conf_Type *my_conf;
102 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
103 if (!ef)
104 {
105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
106 return NULL;
107 }
108
109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
110 if (!my_conf)
111 goto end;
112
113 if (my_conf->version < 0x112233)
114 {
115 fprintf(stderr,
116 "WARNING: version %#x was too old, upgrading it to %#x\n",
117 my_conf->version, 0x112233);
118
119 my_conf->version = 0x112233;
120 my_conf->enabled = EINA_TRUE;
121 }
122
123end:
124 eet_close(ef);
125 return my_conf;
126} /* _my_conf_load */
127
128static Eina_Bool
129_my_conf_save(const My_Conf_Type *my_conf,
130 const char *filename)
131{
132 char tmp[PATH_MAX];
133 Eet_File *ef;
134 Eina_Bool ret;
135 unsigned int i, len;
136 struct stat st;
137
138 len = eina_strlcpy(tmp, filename, sizeof(tmp));
139 if (len + 12 >= (int)sizeof(tmp))
140 {
141 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
142 return EINA_FALSE;
143 }
144
145 i = 0;
146 do
147 {
148 snprintf(tmp + len, 12, ".%u", i);
149 i++;
150 }
151 while (stat(tmp, &st) == 0);
152
153 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
154 if (!ef)
155 {
156 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
157 return EINA_FALSE;
158 }
159
160 ret = eet_data_write
161 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
162 eet_close(ef);
163
164 if (ret)
165 {
166 unlink(filename);
167 rename(tmp, filename);
168 }
169
170 return ret;
171} /* _my_conf_save */
172
173int
174main(int argc,
175 char *argv[])
176{
177 My_Conf_Type *my_conf;
178 int ret = 0;
179
180 if (argc != 3)
181 {
182 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
183 return -1;
184 }
185
186 eina_init();
187 eet_init();
188 _my_conf_descriptor_init();
189
190 my_conf = _my_conf_load(argv[1]);
191 if (!my_conf)
192 {
193 printf("creating new configuration.\n");
194 my_conf = _my_conf_new();
195 if (!my_conf)
196 {
197 ret = -2;
198 goto end;
199 }
200 }
201
202 printf("My_Conf_Type:\n"
203 "\tversion: %#x\n"
204 "\tname...: '%s'\n"
205 "\tid.....: %d\n"
206 "\tenabled: %hhu\n",
207 my_conf->version,
208 my_conf->name ? my_conf->name : "",
209 my_conf->id,
210 my_conf->enabled);
211
212 if (!_my_conf_save(my_conf, argv[2]))
213 ret = -3;
214
215 _my_conf_free(my_conf);
216
217end:
218 _my_conf_descriptor_shutdown();
219 eet_shutdown();
220 eina_shutdown();
221
222 return ret;
223} /* main */
224
diff --git a/legacy/eet/src/examples/eet-file.c b/legacy/eet/src/examples/eet-file.c
deleted file mode 100644
index 740c179f7b..0000000000
--- a/legacy/eet/src/examples/eet-file.c
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 * build: gcc -o eet_file eet-file.c `pkg-config --cflags --libs eet`
3 */