summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eio/eio_private.h')
-rw-r--r--src/lib/eio/eio_private.h538
1 files changed, 538 insertions, 0 deletions
diff --git a/src/lib/eio/eio_private.h b/src/lib/eio/eio_private.h
new file mode 100644
index 0000000..d57277e
--- /dev/null
+++ b/src/lib/eio/eio_private.h
@@ -0,0 +1,538 @@
1#ifndef EIO_PRIVATE_H_
2#define EIO_PRIVATE_H_
3
4#ifdef HAVE_CONFIG_H
5# include "config.h"
6#endif
7
8#ifdef STDC_HEADERS
9# include <stdlib.h>
10# include <stddef.h>
11#else
12# ifdef HAVE_STDLIB_H
13# include <stdlib.h>
14# endif
15#endif
16#ifdef HAVE_ALLOCA_H
17# include <alloca.h>
18#elif !defined alloca
19# ifdef __GNUC__
20# define alloca __builtin_alloca
21# elif defined _AIX
22# define alloca __alloca
23# elif defined _MSC_VER
24# include <malloc.h>
25# define alloca _alloca
26# elif !defined HAVE_ALLOCA
27# ifdef __cplusplus
28extern "C"
29# endif
30void *alloca (size_t);
31# endif
32#endif
33
34#include <sys/types.h>
35#ifdef HAVE_DIRENT_H
36# include <dirent.h>
37# define NAMLEN(dirent) strlen ((dirent)->d_name)
38#else
39# define dirent direct
40# define NAMLEN(dirent) ((dirent)->d_namlen)
41# ifdef HAVE_SYS_NDIR_H
42# include <sys/ndir.h>
43# endif
44# ifdef HAVE_SYS_DIR_H
45# include <sys/dir.h>
46# endif
47# ifdef HAVE_NDIR_H
48# include <ndir.h>
49# endif
50#endif
51
52#include <stdio.h>
53#include <string.h>
54#include <ctype.h>
55#include <errno.h>
56#include <sys/types.h>
57#include <sys/stat.h>
58#include <sys/mman.h>
59#include <fcntl.h>
60
61#ifdef HAVE_PWD_H
62# include <pwd.h>
63#endif
64
65#ifdef HAVE_FEATURES_H
66# include <features.h>
67#endif
68
69#ifdef HAVE_UNISTD_H
70# include <unistd.h>
71#endif
72
73#ifdef HAVE_LIBGEN_H
74# include <libgen.h>
75#endif
76
77#ifdef HAVE_GRP_H
78# include <grp.h>
79#endif
80
81#ifdef EFL_HAVE_POSIX_THREADS
82# include <pthread.h>
83#endif
84
85#ifdef EFL_HAVE_WIN32_THREADS
86# ifndef WIN32_LEAN_AND_MEAN
87# define WIN32_LEAN_AND_MEAN
88# endif
89# include <windows.h>
90# undef WIN32_LEAN_AND_MEAN
91#endif
92
93#ifdef HAVE_EVIL
94# include <Evil.h>
95#endif
96
97#include <Ecore.h>
98
99#include "Eio.h"
100
101#ifdef _WIN32
102typedef struct __stat64 _eio_stat_t;
103#define _eio_stat(p, b) _stat64(p, b)
104#define _eio_lstat(p, b) _stat64(p, b)
105#else
106typedef struct stat _eio_stat_t;
107#define _eio_stat(p, b) stat(p, b)
108#define _eio_lstat(p, b) lstat(p, b)
109#endif
110
111/* Keeping 32 Eio_File_Progress alive should be enought */
112#define EIO_PROGRESS_LIMIT 32
113
114/* Huge TLB == 16M on most system */
115#define EIO_PACKET_SIZE 65536
116#define EIO_PACKET_COUNT 256
117
118#define EIO_PACKED_TIME 0.003
119
120extern int _eio_log_dom_global;
121
122#ifdef EIO_DEFAULT_LOG_COLOR
123# undef EIO_DEFAULT_LOG_COLOR
124#endif /* ifdef EIO_DEFAULT_LOG_COLOR */
125#define EIO_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
126#ifdef ERR
127# undef ERR
128#endif /* ifdef ERR */
129#define ERR(...) EINA_LOG_DOM_ERR(_eio_log_dom_global, __VA_ARGS__)
130#ifdef DBG
131# undef DBG
132#endif /* ifdef DBG */
133#define DBG(...) EINA_LOG_DOM_DBG(_eio_log_dom_global, __VA_ARGS__)
134#ifdef INF
135# undef INF
136#endif /* ifdef INF */
137#define INF(...) EINA_LOG_DOM_INFO(_eio_log_dom_global, __VA_ARGS__)
138#ifdef WRN
139# undef WRN
140#endif /* ifdef WRN */
141#define WRN(...) EINA_LOG_DOM_WARN(_eio_log_dom_global, __VA_ARGS__)
142#ifdef CRIT
143# undef CRIT
144#endif /* ifdef CRIT */
145#define CRIT(...) EINA_LOG_DOM_CRIT(_eio_log_dom_global, __VA_ARGS__)
146
147typedef struct _Eio_Eet_Open Eio_Eet_Open;
148typedef struct _Eio_Eet_Simple Eio_Eet_Simple;
149typedef struct _Eio_Eet_Write Eio_Eet_Write;
150typedef struct _Eio_Eet_Read Eio_Eet_Read;
151typedef struct _Eio_Eet_Image_Write Eio_Eet_Image_Write;
152typedef struct _Eio_File_Map Eio_File_Map;
153typedef struct _Eio_File_Map_Rule Eio_File_Map_Rule;
154typedef struct _Eio_File_Ls Eio_File_Ls;
155typedef struct _Eio_File_Direct_Ls Eio_File_Direct_Ls;
156typedef struct _Eio_File_Dir_Ls Eio_File_Dir_Ls;
157typedef struct _Eio_File_Char_Ls Eio_File_Char_Ls;
158typedef struct _Eio_File_Mkdir Eio_File_Mkdir;
159typedef struct _Eio_File_Mkdir Eio_File_Chmod;
160typedef struct _Eio_File_Unlink Eio_File_Unlink;
161typedef struct _Eio_File_Stat Eio_File_Stat;
162typedef struct _Eio_File_Progress Eio_File_Progress;
163typedef struct _Eio_File_Move Eio_File_Move;
164typedef struct _Eio_File_Chown Eio_File_Chown;
165typedef struct _Eio_Monitor_Backend Eio_Monitor_Backend;
166
167typedef struct _Eio_File_Xattr Eio_File_Xattr;
168
169typedef struct _Eio_Dir_Copy Eio_Dir_Copy;
170
171typedef struct _Eio_File_Direct_Info Eio_File_Direct_Info;
172typedef struct _Eio_File_Char Eio_File_Char;
173
174typedef struct _Eio_File_Associate Eio_File_Associate;
175
176struct _Eio_File_Associate
177{
178 void *data;
179
180 Eina_Free_Cb free_cb;
181};
182
183struct _Eio_File_Direct_Info
184{
185 Eina_File_Direct_Info info;
186
187 Eina_Hash *associated;
188};
189
190struct _Eio_File_Char
191{
192 const char *filename;
193
194 Eina_Hash *associated;
195};
196
197struct _Eio_File
198{
199 Ecore_Thread *thread;
200 const void *data;
201 void *container;
202
203 int error;
204
205 Eio_Error_Cb error_cb;
206 Eio_Done_Cb done_cb;
207
208 struct {
209 Eina_Hash *associated;
210 } worker, main;
211};
212
213struct _Eio_Eet_Simple
214{
215 Eio_File common;
216
217 Eet_File *ef;
218 Eio_Eet_Error_Cb error_cb;
219 Eet_Error error;
220};
221
222struct _Eio_Eet_Write
223{
224 Eio_File common;
225
226 Eet_File *ef;
227 Eet_Data_Descriptor *edd;
228 const char *name;
229 const char *cipher_key;
230 void *write_data;
231 int compress;
232 int size;
233
234 int result;
235 Eio_Done_Int_Cb done_cb;
236};
237
238struct _Eio_Eet_Read
239{
240 Eio_File common;
241
242 Eet_File *ef;
243 Eet_Data_Descriptor *edd;
244 const char *name;
245 const char *cipher_key;
246
247 int size;
248
249 void *result;
250 union {
251 Eio_Done_ERead_Cb eread;
252 Eio_Done_Data_Cb data;
253 Eio_Done_Read_Cb read;
254 } done_cb;
255};
256
257struct _Eio_Eet_Image_Write
258{
259 Eio_File common;
260
261 Eet_File *ef;
262 const char *name;
263 const char *cipher_key;
264 void *write_data;
265
266 unsigned int w;
267 unsigned int h;
268 int alpha;
269 int compress;
270 int quality;
271 int lossy;
272
273 int result;
274 Eio_Done_Int_Cb done_cb;
275};
276
277struct _Eio_Eet_Open
278{
279 Eio_File common;
280
281 Eio_Eet_Open_Cb eet_cb;
282 const char *filename;
283 Eet_File_Mode mode;
284
285 Eet_File *result;
286};
287
288struct _Eio_File_Map
289{
290 Eio_File common;
291
292 Eio_Open_Cb open_cb;
293 const char *name;
294 Eina_Bool shared;
295
296 Eina_File *result;
297};
298
299struct _Eio_File_Map_Rule
300{
301 Eio_File common;
302 Eio_Filter_Map_Cb filter_cb;
303 Eio_Map_Cb map_cb;
304
305 Eina_File_Populate rule;
306 Eina_File *file;
307
308 unsigned long int offset;
309 unsigned long int length;
310
311 void *result;
312};
313
314struct _Eio_File_Ls
315{
316 Eio_File common;
317 const char *directory;
318};
319
320struct _Eio_File_Direct_Ls
321{
322 Eio_File_Ls ls;
323
324 Eio_Filter_Direct_Cb filter_cb;
325 Eio_Main_Direct_Cb main_cb;
326
327 Eina_List *pack;
328 double start;
329};
330
331struct _Eio_File_Dir_Ls
332{
333 Eio_File_Ls ls;
334
335 Eio_Filter_Dir_Cb filter_cb;
336 Eio_Main_Direct_Cb main_cb;
337
338 Eina_List *pack;
339 double start;
340};
341
342struct _Eio_File_Char_Ls
343{
344 Eio_File_Ls ls;
345
346 Eio_Filter_Cb filter_cb;
347 Eio_Main_Cb main_cb;
348};
349
350struct _Eio_File_Mkdir
351{
352 Eio_File common;
353
354 const char *path;
355 mode_t mode;
356};
357
358struct _Eio_File_Unlink
359{
360 Eio_File common;
361
362 const char *path;
363};
364
365struct _Eio_File_Stat
366{
367 Eio_File common;
368
369 Eio_Stat_Cb done_cb;
370
371 Eina_Stat buffer;
372 const char *path;
373};
374
375typedef enum {
376 EIO_XATTR_DATA,
377 EIO_XATTR_STRING,
378 EIO_XATTR_DOUBLE,
379 EIO_XATTR_INT
380} Eio_File_Xattr_Op;
381
382struct _Eio_File_Xattr
383{
384 Eio_File common;
385
386 const char *path;
387 const char *attribute;
388 Eina_Xattr_Flags flags;
389
390 Eio_File_Xattr_Op op;
391
392 union {
393 struct {
394 Eio_Done_Data_Cb done_cb;
395
396 char *xattr_data;
397 ssize_t xattr_size;
398 } xdata;
399 struct {
400 Eio_Done_String_Cb done_cb;
401
402 char *xattr_string;
403 } xstring;
404 struct {
405 Eio_Done_Double_Cb done_cb;
406
407 double xattr_double;
408 } xdouble;
409 struct {
410 Eio_Done_Int_Cb done_cb;
411
412 int xattr_int;
413 } xint;
414 } todo;
415
416 Eina_Bool set : 1;
417};
418
419struct _Eio_File_Progress
420{
421 Eio_File common;
422
423 Eio_Progress_Cb progress_cb;
424
425 const char *source;
426 const char *dest;
427
428 Eio_File_Op op;
429};
430
431struct _Eio_File_Move
432{
433 Eio_File_Progress progress;
434
435 Eio_File *copy;
436};
437
438struct _Eio_Dir_Copy
439{
440 Eio_File_Progress progress;
441 Eio_Filter_Direct_Cb filter_cb;
442
443 Eina_List *files;
444 Eina_List *dirs;
445 Eina_List *links;
446};
447
448struct _Eio_File_Chown
449{
450 Eio_File common;
451
452 const char *path;
453 const char *user;
454 const char *group;
455};
456
457struct _Eio_Monitor
458{
459 Eio_Monitor_Backend *backend;
460 Eio_File *exist;
461
462 const char *path;
463
464 EINA_REFCOUNT;
465 int error;
466
467 time_t mtime;
468
469 Eina_Bool fallback : 1;
470 Eina_Bool rename : 1;
471 Eina_Bool delete_me : 1;
472};
473
474/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */
475Eina_Bool eio_file_set(Eio_File *common,
476 Eio_Done_Cb done_cb,
477 Eio_Error_Cb error_cb,
478 const void *data,
479 Ecore_Thread_Cb job_cb,
480 Ecore_Thread_Cb end_cb,
481 Ecore_Thread_Cb cancel_cb);
482
483/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */
484Eina_Bool eio_long_file_set(Eio_File *common,
485 Eio_Done_Cb done_cb,
486 Eio_Error_Cb error_cb,
487 const void *data,
488 Ecore_Thread_Cb heavy_cb,
489 Ecore_Thread_Notify_Cb notify_cb,
490 Ecore_Thread_Cb end_cb,
491 Ecore_Thread_Cb cancel_cb);
492
493void eio_file_free(Eio_File *common);
494void eio_async_free(Eio_File_Ls *async);
495
496void eio_file_container_set(Eio_File *common, void *container);
497
498void eio_file_error(Eio_File *common);
499void eio_file_thread_error(Eio_File *common, Ecore_Thread *thread);
500
501Eio_File_Direct_Info *eio_direct_info_malloc(void);
502void eio_direct_info_free(Eio_File_Direct_Info *data);
503
504Eio_File_Char *eio_char_malloc(void);
505void eio_char_free(Eio_File_Char *data);
506
507Eio_File_Associate *eio_associate_malloc(const void *data, Eina_Free_Cb free_cb);
508void eio_associate_free(void *data);
509
510Eio_Progress *eio_progress_malloc(void);
511void eio_progress_free(Eio_Progress *progress);
512
513void eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op,
514 long long current, long long max);
515void eio_progress_cb(Eio_Progress *progress, Eio_File_Progress *op);
516
517Eina_Bool eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy);
518
519void eio_monitor_init(void);
520void eio_monitor_backend_init(void);
521void eio_monitor_fallback_init(void);
522
523void eio_monitor_shutdown(void);
524void eio_monitor_backend_shutdown(void);
525void eio_monitor_fallback_shutdown(void);
526void eio_monitor_backend_add(Eio_Monitor *monitor);
527void eio_monitor_fallback_add(Eio_Monitor *monitor);
528
529void eio_monitor_backend_del(Eio_Monitor *monitor);
530void eio_monitor_fallback_del(Eio_Monitor *monitor);
531
532void _eio_monitor_send(Eio_Monitor *monitor, const char *filename, int event_code);
533void _eio_monitor_rename(Eio_Monitor *monitor, const char *newpath);
534
535void eio_async_end(void *data, Ecore_Thread *thread);
536void eio_async_error(void *data, Ecore_Thread *thread);
537
538#endif