1 | #ifndef IO_H |
---|
2 | #define IO_H 1 |
---|
3 | #include <sys/types.h> |
---|
4 | #include <stdio.h> |
---|
5 | |
---|
6 | typedef struct io_t io_t; |
---|
7 | typedef struct iow_t iow_t; |
---|
8 | |
---|
9 | struct compression_type { |
---|
10 | const char *name; |
---|
11 | int compress_flag; |
---|
12 | const char *ext; |
---|
13 | }; |
---|
14 | extern struct compression_type compression_type[]; |
---|
15 | |
---|
16 | typedef struct { |
---|
17 | const char *name; |
---|
18 | off_t (*read)(io_t *io, void *buffer, off_t len); |
---|
19 | off_t (*peek)(io_t *io, void *buffer, off_t len); |
---|
20 | off_t (*tell)(io_t *io); |
---|
21 | off_t (*seek)(io_t *io, off_t offset, int whence); |
---|
22 | void (*close)(io_t *io); |
---|
23 | } io_source_t; |
---|
24 | |
---|
25 | typedef struct { |
---|
26 | const char *name; |
---|
27 | off_t (*write)(iow_t *iow, const char *buffer, off_t len); |
---|
28 | void (*close)(iow_t *iow); |
---|
29 | } iow_source_t; |
---|
30 | |
---|
31 | struct io_t { |
---|
32 | io_source_t *source; |
---|
33 | void *data; |
---|
34 | }; |
---|
35 | |
---|
36 | struct iow_t { |
---|
37 | iow_source_t *source; |
---|
38 | void *data; |
---|
39 | }; |
---|
40 | |
---|
41 | enum { |
---|
42 | WANDIO_COMPRESS_NONE = 0, |
---|
43 | WANDIO_COMPRESS_ZLIB = 1, |
---|
44 | WANDIO_COMPRESS_BZ2 = 2, |
---|
45 | WANDIO_COMPRESS_MASK = 3 |
---|
46 | }; |
---|
47 | |
---|
48 | |
---|
49 | io_t *bz_open(io_t *parent); |
---|
50 | io_t *zlib_open(io_t *parent); |
---|
51 | io_t *thread_open(io_t *parent); |
---|
52 | io_t *peek_open(io_t *parent); |
---|
53 | io_t *stdio_open(const char *filename); |
---|
54 | |
---|
55 | iow_t *zlib_wopen(iow_t *child, int compress_level); |
---|
56 | iow_t *bz_wopen(iow_t *child, int compress_level); |
---|
57 | iow_t *thread_wopen(iow_t *child); |
---|
58 | iow_t *stdio_wopen(const char *filename); |
---|
59 | |
---|
60 | io_t *wandio_create(const char *filename); |
---|
61 | off_t wandio_tell(io_t *io); |
---|
62 | off_t wandio_seek(io_t *io, off_t offset, int whence); |
---|
63 | off_t wandio_read(io_t *io, void *buffer, off_t len); |
---|
64 | off_t wandio_peek(io_t *io, void *buffer, off_t len); |
---|
65 | void wandio_destroy(io_t *io); |
---|
66 | |
---|
67 | iow_t *wandio_wcreate(const char *filename, int compression_level, int flags); |
---|
68 | off_t wandio_wwrite(iow_t *iow, const void *buffer, off_t len); |
---|
69 | void wandio_wdestroy(iow_t *iow); |
---|
70 | |
---|
71 | #endif |
---|