diff options
Diffstat (limited to 'src/lib/eio/eio_eet.c')
-rw-r--r-- | src/lib/eio/eio_eet.c | 640 |
1 files changed, 640 insertions, 0 deletions
diff --git a/src/lib/eio/eio_eet.c b/src/lib/eio/eio_eet.c new file mode 100644 index 0000000..c25cc4a --- /dev/null +++ b/src/lib/eio/eio_eet.c | |||
@@ -0,0 +1,640 @@ | |||
1 | /* EIO - EFL data type library | ||
2 | * Copyright (C) 2010 Enlightenment Developers: | ||
3 | * Cedric Bail <cedric.bail@free.fr> | ||
4 | * Vincent "caro" Torri <vtorri at univ-evry dot fr> | ||
5 | * Stephen "okra" Houston <UnixTitan@gmail.com> | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library; | ||
19 | * if not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | ||
21 | |||
22 | #include "eio_private.h" | ||
23 | #include "Eio.h" | ||
24 | |||
25 | /*============================================================================* | ||
26 | * Local * | ||
27 | *============================================================================*/ | ||
28 | |||
29 | /** | ||
30 | * @cond LOCAL | ||
31 | */ | ||
32 | |||
33 | static void | ||
34 | _eio_eet_open_job(void *data, Ecore_Thread *thread) | ||
35 | { | ||
36 | Eio_Eet_Open *eet = data; | ||
37 | |||
38 | eet->result = eet_open(eet->filename, eet->mode); | ||
39 | if (!eet->result) eio_file_thread_error(&eet->common, thread); | ||
40 | } | ||
41 | |||
42 | static void | ||
43 | _eio_eet_open_free(Eio_Eet_Open *eet) | ||
44 | { | ||
45 | if (eet->filename) eina_stringshare_del(eet->filename); | ||
46 | free(eet); | ||
47 | } | ||
48 | |||
49 | static void | ||
50 | _eio_eet_open_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
51 | { | ||
52 | Eio_Eet_Open *eet = data; | ||
53 | |||
54 | eet->eet_cb((void*) eet->common.data, &eet->common, eet->result); | ||
55 | _eio_eet_open_free(eet); | ||
56 | } | ||
57 | |||
58 | static void | ||
59 | _eio_eet_open_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
60 | { | ||
61 | Eio_Eet_Open *eet = data; | ||
62 | |||
63 | eio_file_error(&eet->common); | ||
64 | _eio_eet_open_free(eet); | ||
65 | } | ||
66 | |||
67 | static void | ||
68 | _eio_eet_close_job(void *data, Ecore_Thread *thread) | ||
69 | { | ||
70 | Eio_Eet_Simple *eet = data; | ||
71 | |||
72 | eet->error = eet_close(eet->ef); | ||
73 | if (eet->error != EET_ERROR_NONE) eio_file_thread_error(&eet->common, thread); | ||
74 | } | ||
75 | |||
76 | static void | ||
77 | _eio_eet_sync_job(void *data, Ecore_Thread *thread) | ||
78 | { | ||
79 | Eio_Eet_Simple *eet = data; | ||
80 | |||
81 | eet->error = eet_sync(eet->ef); | ||
82 | if (eet->error != EET_ERROR_NONE) eio_file_thread_error(&eet->common, thread); | ||
83 | } | ||
84 | |||
85 | static void | ||
86 | _eio_eet_simple_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
87 | { | ||
88 | Eio_Eet_Simple *eet = data; | ||
89 | |||
90 | eet->common.done_cb((void*) eet->common.data, &eet->common); | ||
91 | free(eet); | ||
92 | } | ||
93 | |||
94 | static void | ||
95 | _eio_eet_simple_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
96 | { | ||
97 | Eio_Eet_Simple *eet = data; | ||
98 | |||
99 | eet->error_cb((void*) eet->common.data, &eet->common, eet->error); | ||
100 | free(eet); | ||
101 | } | ||
102 | |||
103 | static void | ||
104 | _eio_eet_data_write_cipher_job(void *data, Ecore_Thread *thread) | ||
105 | { | ||
106 | Eio_Eet_Write *ew = data; | ||
107 | |||
108 | ew->result = eet_data_write_cipher(ew->ef, ew->edd, | ||
109 | ew->name, ew->cipher_key, | ||
110 | ew->write_data, | ||
111 | ew->compress); | ||
112 | if (ew->result == 0) eio_file_thread_error(&ew->common, thread); | ||
113 | } | ||
114 | |||
115 | static void | ||
116 | _eio_eet_write_cipher_free(Eio_Eet_Write *ew) | ||
117 | { | ||
118 | eina_stringshare_del(ew->name); | ||
119 | eina_stringshare_del(ew->cipher_key); | ||
120 | free(ew); | ||
121 | } | ||
122 | |||
123 | static void | ||
124 | _eio_eet_data_write_cipher_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
125 | { | ||
126 | Eio_Eet_Write *ew = data; | ||
127 | |||
128 | ew->done_cb((void*) ew->common.data, &ew->common, ew->result); | ||
129 | _eio_eet_write_cipher_free(ew); | ||
130 | } | ||
131 | |||
132 | static void | ||
133 | _eio_eet_data_write_cipher_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
134 | { | ||
135 | Eio_Eet_Write *ew = data; | ||
136 | |||
137 | eio_file_error(&ew->common); | ||
138 | _eio_eet_write_cipher_free(ew); | ||
139 | } | ||
140 | |||
141 | static void | ||
142 | _eio_eet_image_write_job(void *data, Ecore_Thread *thread) | ||
143 | { | ||
144 | Eio_Eet_Image_Write *eiw = data; | ||
145 | |||
146 | eiw->result = eet_data_image_write_cipher(eiw->ef, eiw->name, eiw->cipher_key, | ||
147 | eiw->write_data, | ||
148 | eiw->w, | ||
149 | eiw->h, | ||
150 | eiw->alpha, | ||
151 | eiw->compress, | ||
152 | eiw->quality, | ||
153 | eiw->lossy); | ||
154 | if (!eiw->result) eio_file_thread_error(&eiw->common, thread); | ||
155 | } | ||
156 | |||
157 | static void | ||
158 | _eio_eet_image_write_free(Eio_Eet_Image_Write *eiw) | ||
159 | { | ||
160 | eina_stringshare_del(eiw->name); | ||
161 | eina_stringshare_del(eiw->cipher_key); | ||
162 | free(eiw); | ||
163 | } | ||
164 | |||
165 | static void | ||
166 | _eio_eet_image_write_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
167 | { | ||
168 | Eio_Eet_Image_Write *eiw = data; | ||
169 | |||
170 | eiw->done_cb((void*) eiw->common.data, &eiw->common, eiw->result); | ||
171 | _eio_eet_image_write_free(eiw); | ||
172 | } | ||
173 | |||
174 | static void | ||
175 | _eio_eet_image_write_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
176 | { | ||
177 | Eio_Eet_Image_Write *eiw = data; | ||
178 | |||
179 | eio_file_error(&eiw->common); | ||
180 | _eio_eet_image_write_free(eiw); | ||
181 | } | ||
182 | |||
183 | static void | ||
184 | _eio_eet_write_job(void *data, Ecore_Thread *thread) | ||
185 | { | ||
186 | Eio_Eet_Write *ew = data; | ||
187 | |||
188 | ew->result = eet_write_cipher(ew->ef, | ||
189 | ew->name, ew->write_data, | ||
190 | ew->size, ew->compress, | ||
191 | ew->cipher_key); | ||
192 | if (!ew->result) eio_file_thread_error(&ew->common, thread); | ||
193 | } | ||
194 | |||
195 | static void | ||
196 | _eio_eet_write_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
197 | { | ||
198 | Eio_Eet_Write *ew = data; | ||
199 | |||
200 | ew->done_cb((void*) ew->common.data, &ew->common, ew->result); | ||
201 | _eio_eet_write_cipher_free(ew); | ||
202 | } | ||
203 | |||
204 | static void | ||
205 | _eio_eet_write_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
206 | { | ||
207 | Eio_Eet_Write *ew = data; | ||
208 | |||
209 | eio_file_error(&ew->common); | ||
210 | _eio_eet_write_cipher_free(ew); | ||
211 | } | ||
212 | |||
213 | static void | ||
214 | _eio_eet_data_read_cipher_job(void *data, Ecore_Thread *thread) | ||
215 | { | ||
216 | Eio_Eet_Read *er = data; | ||
217 | |||
218 | er->result = eet_data_read_cipher(er->ef, er->edd, | ||
219 | er->name, er->cipher_key); | ||
220 | if (!er->result) eio_file_thread_error(&er->common, thread); | ||
221 | } | ||
222 | |||
223 | static void | ||
224 | _eio_eet_read_free(Eio_Eet_Read *er) | ||
225 | { | ||
226 | eina_stringshare_del(er->name); | ||
227 | eina_stringshare_del(er->cipher_key); | ||
228 | free(er); | ||
229 | } | ||
230 | |||
231 | static void | ||
232 | _eio_eet_data_read_cipher_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
233 | { | ||
234 | Eio_Eet_Read *er = data; | ||
235 | |||
236 | er->done_cb.eread((void*) er->common.data, &er->common, er->result); | ||
237 | _eio_eet_read_free(er); | ||
238 | } | ||
239 | |||
240 | static void | ||
241 | _eio_eet_data_read_cipher_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
242 | { | ||
243 | Eio_Eet_Read *er = data; | ||
244 | |||
245 | eio_file_error(&er->common); | ||
246 | _eio_eet_read_free(er); | ||
247 | } | ||
248 | |||
249 | static void | ||
250 | _eio_eet_read_direct_job(void *data, Ecore_Thread *thread) | ||
251 | { | ||
252 | Eio_Eet_Read *er = data; | ||
253 | |||
254 | er->result = (void*) eet_read_direct(er->ef, er->name, &er->size); | ||
255 | if (!er->result) eio_file_thread_error(&er->common, thread); | ||
256 | } | ||
257 | |||
258 | static void | ||
259 | _eio_eet_read_direct_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
260 | { | ||
261 | Eio_Eet_Read *er = data; | ||
262 | |||
263 | er->done_cb.data((void*) er->common.data, &er->common, | ||
264 | er->result, er->size); | ||
265 | _eio_eet_read_free(er); | ||
266 | } | ||
267 | |||
268 | static void | ||
269 | _eio_eet_read_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
270 | { | ||
271 | Eio_Eet_Read *er = data; | ||
272 | |||
273 | eio_file_error(&er->common); | ||
274 | _eio_eet_read_free(er); | ||
275 | } | ||
276 | |||
277 | static void | ||
278 | _eio_eet_read_cipher_job(void *data, Ecore_Thread *thread) | ||
279 | { | ||
280 | Eio_Eet_Read *er = data; | ||
281 | |||
282 | er->result = (void*) eet_read_cipher(er->ef, er->name, | ||
283 | &er->size, er->cipher_key); | ||
284 | if (!er->result) eio_file_thread_error(&er->common, thread); | ||
285 | } | ||
286 | |||
287 | static void | ||
288 | _eio_eet_read_cipher_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
289 | { | ||
290 | Eio_Eet_Read *er = data; | ||
291 | |||
292 | er->done_cb.read((void*) er->common.data, &er->common, | ||
293 | er->result, er->size); | ||
294 | _eio_eet_read_free(er); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * @endcond | ||
299 | */ | ||
300 | |||
301 | /*============================================================================* | ||
302 | * Global * | ||
303 | *============================================================================*/ | ||
304 | |||
305 | |||
306 | /*============================================================================* | ||
307 | * API * | ||
308 | *============================================================================*/ | ||
309 | |||
310 | EAPI Eio_File * | ||
311 | eio_eet_open(const char *filename, | ||
312 | Eet_File_Mode mode, | ||
313 | Eio_Eet_Open_Cb eet_cb, | ||
314 | Eio_Error_Cb error_cb, | ||
315 | const void *data) | ||
316 | { | ||
317 | Eio_Eet_Open *eet; | ||
318 | |||
319 | EINA_SAFETY_ON_NULL_RETURN_VAL(filename, NULL); | ||
320 | EINA_SAFETY_ON_NULL_RETURN_VAL(eet_cb, NULL); | ||
321 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
322 | |||
323 | eet = malloc(sizeof (Eio_Eet_Open)); | ||
324 | EINA_SAFETY_ON_NULL_RETURN_VAL(eet, NULL); | ||
325 | |||
326 | eet->eet_cb = eet_cb; | ||
327 | eet->filename = eina_stringshare_add(filename); | ||
328 | eet->mode = mode; | ||
329 | eet->result = NULL; | ||
330 | |||
331 | if (!eio_file_set(&eet->common, | ||
332 | NULL, | ||
333 | error_cb, | ||
334 | data, | ||
335 | _eio_eet_open_job, | ||
336 | _eio_eet_open_end, | ||
337 | _eio_eet_open_cancel)) | ||
338 | return NULL; | ||
339 | return &eet->common; | ||
340 | } | ||
341 | |||
342 | EAPI Eio_File * | ||
343 | eio_eet_close(Eet_File *ef, | ||
344 | Eio_Done_Cb done_cb, | ||
345 | Eio_Eet_Error_Cb error_cb, | ||
346 | const void *data) | ||
347 | { | ||
348 | Eio_Eet_Simple *eet; | ||
349 | |||
350 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
351 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
352 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
353 | |||
354 | eet = malloc(sizeof (Eio_Eet_Simple)); | ||
355 | EINA_SAFETY_ON_NULL_RETURN_VAL(eet, NULL); | ||
356 | |||
357 | eet->ef = ef; | ||
358 | eet->error_cb = error_cb; | ||
359 | eet->error = EET_ERROR_NONE; | ||
360 | |||
361 | if (!eio_file_set(&eet->common, | ||
362 | done_cb, | ||
363 | NULL, | ||
364 | data, | ||
365 | _eio_eet_close_job, | ||
366 | _eio_eet_simple_end, | ||
367 | _eio_eet_simple_cancel)) | ||
368 | return NULL; | ||
369 | return &eet->common; | ||
370 | } | ||
371 | |||
372 | EAPI Eio_File * | ||
373 | eio_eet_flush(Eet_File *ef, | ||
374 | Eio_Done_Cb done_cb, | ||
375 | Eio_Eet_Error_Cb error_cb, | ||
376 | const void *data) | ||
377 | { | ||
378 | Eio_Eet_Simple *eet; | ||
379 | |||
380 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
381 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
382 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
383 | |||
384 | eet = malloc(sizeof (Eio_Eet_Simple)); | ||
385 | EINA_SAFETY_ON_NULL_RETURN_VAL(eet, NULL); | ||
386 | |||
387 | eet->ef = ef; | ||
388 | eet->error_cb = error_cb; | ||
389 | eet->error = EET_ERROR_NONE; | ||
390 | |||
391 | if (!eio_file_set(&eet->common, | ||
392 | done_cb, | ||
393 | NULL, | ||
394 | data, | ||
395 | _eio_eet_sync_job, | ||
396 | _eio_eet_simple_end, | ||
397 | _eio_eet_simple_cancel)) | ||
398 | return NULL; | ||
399 | return &eet->common; | ||
400 | } | ||
401 | |||
402 | EAPI Eio_File * | ||
403 | eio_eet_data_write_cipher(Eet_File *ef, | ||
404 | Eet_Data_Descriptor *edd, | ||
405 | const char *name, | ||
406 | const char *cipher_key, | ||
407 | void *write_data, | ||
408 | int compress, | ||
409 | Eio_Done_Int_Cb done_cb, | ||
410 | Eio_Error_Cb error_cb, | ||
411 | const void *user_data) | ||
412 | { | ||
413 | Eio_Eet_Write *ew; | ||
414 | |||
415 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
416 | EINA_SAFETY_ON_NULL_RETURN_VAL(edd, NULL); | ||
417 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
418 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
419 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
420 | |||
421 | ew = malloc(sizeof (Eio_Eet_Write)); | ||
422 | EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL); | ||
423 | |||
424 | ew->ef = ef; | ||
425 | ew->edd = edd; | ||
426 | ew->name = eina_stringshare_add(name); | ||
427 | ew->cipher_key = eina_stringshare_add(cipher_key); | ||
428 | ew->write_data = write_data; | ||
429 | ew->compress = compress; | ||
430 | ew->done_cb = done_cb; | ||
431 | ew->result = 0; | ||
432 | |||
433 | if (!eio_file_set(&ew->common, | ||
434 | NULL, | ||
435 | error_cb, | ||
436 | user_data, | ||
437 | _eio_eet_data_write_cipher_job, | ||
438 | _eio_eet_data_write_cipher_end, | ||
439 | _eio_eet_data_write_cipher_cancel)) | ||
440 | return NULL; | ||
441 | return &ew->common; | ||
442 | } | ||
443 | |||
444 | EAPI Eio_File * | ||
445 | eio_eet_data_read_cipher(Eet_File *ef, | ||
446 | Eet_Data_Descriptor *edd, | ||
447 | const char *name, | ||
448 | const char *cipher_key, | ||
449 | Eio_Done_ERead_Cb done_cb, | ||
450 | Eio_Error_Cb error_cb, | ||
451 | const void *data) | ||
452 | { | ||
453 | Eio_Eet_Read *er; | ||
454 | |||
455 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
456 | EINA_SAFETY_ON_NULL_RETURN_VAL(edd, NULL); | ||
457 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
458 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
459 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
460 | |||
461 | er = malloc(sizeof (Eio_Eet_Read)); | ||
462 | EINA_SAFETY_ON_NULL_RETURN_VAL(er, NULL); | ||
463 | |||
464 | er->ef = ef; | ||
465 | er->edd = edd; | ||
466 | er->name = eina_stringshare_add(name); | ||
467 | er->cipher_key = eina_stringshare_add(cipher_key); | ||
468 | er->done_cb.eread = done_cb; | ||
469 | |||
470 | if (!eio_file_set(&er->common, | ||
471 | NULL, | ||
472 | error_cb, | ||
473 | data, | ||
474 | _eio_eet_data_read_cipher_job, | ||
475 | _eio_eet_data_read_cipher_end, | ||
476 | _eio_eet_data_read_cipher_cancel)) | ||
477 | return NULL; | ||
478 | |||
479 | return &er->common; | ||
480 | } | ||
481 | |||
482 | EAPI Eio_File * | ||
483 | eio_eet_data_image_write_cipher(Eet_File *ef, | ||
484 | const char *name, | ||
485 | const char *cipher_key, | ||
486 | void *write_data, | ||
487 | unsigned int w, | ||
488 | unsigned int h, | ||
489 | int alpha, | ||
490 | int compress, | ||
491 | int quality, | ||
492 | int lossy, | ||
493 | Eio_Done_Int_Cb done_cb, | ||
494 | Eio_Error_Cb error_cb, | ||
495 | const void *user_data) | ||
496 | { | ||
497 | Eio_Eet_Image_Write *eiw; | ||
498 | |||
499 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
500 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
501 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
502 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
503 | |||
504 | eiw = malloc(sizeof (Eio_Eet_Image_Write)); | ||
505 | EINA_SAFETY_ON_NULL_RETURN_VAL(eiw, NULL); | ||
506 | |||
507 | eiw->ef = ef; | ||
508 | eiw->name = eina_stringshare_add(name); | ||
509 | eiw->cipher_key = eina_stringshare_add(cipher_key); | ||
510 | eiw->write_data = write_data; | ||
511 | eiw->w = w; | ||
512 | eiw->h = h; | ||
513 | eiw->alpha = alpha; | ||
514 | eiw->compress = compress; | ||
515 | eiw->quality = quality; | ||
516 | eiw->lossy = lossy; | ||
517 | eiw->done_cb = done_cb; | ||
518 | eiw->result = 0; | ||
519 | |||
520 | if (!eio_file_set(&eiw->common, | ||
521 | NULL, | ||
522 | error_cb, | ||
523 | user_data, | ||
524 | _eio_eet_image_write_job, | ||
525 | _eio_eet_image_write_end, | ||
526 | _eio_eet_image_write_cancel)) | ||
527 | return NULL; | ||
528 | return &eiw->common; | ||
529 | } | ||
530 | |||
531 | EAPI Eio_File * | ||
532 | eio_eet_read_direct(Eet_File *ef, | ||
533 | const char *name, | ||
534 | Eio_Done_Data_Cb done_cb, | ||
535 | Eio_Error_Cb error_cb, | ||
536 | const void *data) | ||
537 | { | ||
538 | Eio_Eet_Read *er; | ||
539 | |||
540 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
541 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
542 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
543 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
544 | |||
545 | er = malloc(sizeof (Eio_Eet_Read)); | ||
546 | EINA_SAFETY_ON_NULL_RETURN_VAL(er, NULL); | ||
547 | |||
548 | er->ef = ef; | ||
549 | er->name = eina_stringshare_add(name); | ||
550 | er->cipher_key = NULL; | ||
551 | er->done_cb.data = done_cb; | ||
552 | er->result = NULL; | ||
553 | |||
554 | if (!eio_file_set(&er->common, | ||
555 | NULL, | ||
556 | error_cb, | ||
557 | data, | ||
558 | _eio_eet_read_direct_job, | ||
559 | _eio_eet_read_direct_end, | ||
560 | _eio_eet_read_cancel)) | ||
561 | return NULL; | ||
562 | |||
563 | return &er->common; | ||
564 | } | ||
565 | |||
566 | EAPI Eio_File * | ||
567 | eio_eet_read_cipher(Eet_File *ef, | ||
568 | const char *name, | ||
569 | const char *cipher_key, | ||
570 | Eio_Done_Read_Cb done_cb, | ||
571 | Eio_Error_Cb error_cb, | ||
572 | const void *data) | ||
573 | { | ||
574 | Eio_Eet_Read *er; | ||
575 | |||
576 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
577 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
578 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
579 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
580 | |||
581 | er = malloc(sizeof (Eio_Eet_Read)); | ||
582 | EINA_SAFETY_ON_NULL_RETURN_VAL(er, NULL); | ||
583 | |||
584 | er->ef = ef; | ||
585 | er->name = eina_stringshare_add(name); | ||
586 | er->cipher_key = eina_stringshare_add(cipher_key); | ||
587 | er->done_cb.read = done_cb; | ||
588 | er->result = NULL; | ||
589 | |||
590 | if (!eio_file_set(&er->common, | ||
591 | NULL, | ||
592 | error_cb, | ||
593 | data, | ||
594 | _eio_eet_read_cipher_job, | ||
595 | _eio_eet_read_cipher_end, | ||
596 | _eio_eet_read_cancel)) | ||
597 | return NULL; | ||
598 | return &er->common; | ||
599 | } | ||
600 | |||
601 | EAPI Eio_File * | ||
602 | eio_eet_write_cipher(Eet_File *ef, | ||
603 | const char *name, | ||
604 | void *write_data, | ||
605 | int size, | ||
606 | int compress, | ||
607 | const char *cipher_key, | ||
608 | Eio_Done_Int_Cb done_cb, | ||
609 | Eio_Error_Cb error_cb, | ||
610 | const void *user_data) | ||
611 | { | ||
612 | Eio_Eet_Write *ew; | ||
613 | |||
614 | EINA_SAFETY_ON_NULL_RETURN_VAL(ef, NULL); | ||
615 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | ||
616 | EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL); | ||
617 | EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL); | ||
618 | |||
619 | ew = malloc(sizeof (Eio_Eet_Write)); | ||
620 | EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL); | ||
621 | |||
622 | ew->ef = ef; | ||
623 | ew->name = eina_stringshare_add(name); | ||
624 | ew->cipher_key = eina_stringshare_add(cipher_key); | ||
625 | ew->write_data = write_data; | ||
626 | ew->size = size; | ||
627 | ew->compress = compress; | ||
628 | ew->done_cb = done_cb; | ||
629 | ew->result = 0; | ||
630 | |||
631 | if (!eio_file_set(&ew->common, | ||
632 | NULL, | ||
633 | error_cb, | ||
634 | user_data, | ||
635 | _eio_eet_write_job, | ||
636 | _eio_eet_write_end, | ||
637 | _eio_eet_write_cancel)) | ||
638 | return NULL; | ||
639 | return &ew->common; | ||
640 | } | ||