00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef IO_H
00035 #define IO_H 1
00036 #include "config.h"
00037 #include <sys/types.h>
00038 #include <stdio.h>
00039 #include <inttypes.h>
00040 #include <stdbool.h>
00041
00052 typedef struct io_t io_t;
00053 typedef struct iow_t iow_t;
00056 struct compression_type {
00058 const char *name;
00061 const char *ext;
00063 int compress_type;
00064 };
00065
00067 extern struct compression_type compression_type[];
00068
00070 typedef struct {
00072 const char *name;
00073
00082 off_t (*read)(io_t *io, void *buffer, off_t len);
00083
00093 off_t (*peek)(io_t *io, void *buffer, off_t len);
00094
00100 off_t (*tell)(io_t *io);
00101
00112 off_t (*seek)(io_t *io, off_t offset, int whence);
00113
00118 void (*close)(io_t *io);
00119 } io_source_t;
00120
00122 typedef struct {
00124 const char *name;
00125
00133 off_t (*write)(iow_t *iow, const char *buffer, off_t len);
00134
00139 void (*close)(iow_t *iow);
00140 } iow_source_t;
00141
00143 struct io_t {
00145 io_source_t *source;
00147 void *data;
00148 };
00149
00151 struct iow_t {
00153 iow_source_t *source;
00155 void *data;
00156 };
00157
00159 enum {
00161 WANDIO_COMPRESS_NONE = 0,
00163 WANDIO_COMPRESS_ZLIB = 1,
00165 WANDIO_COMPRESS_BZ2 = 2,
00167 WANDIO_COMPRESS_LZO = 3,
00169 WANDIO_COMPRESS_MASK = 7
00170 };
00171
00180 io_t *bz_open(io_t *parent);
00181 io_t *zlib_open(io_t *parent);
00182 io_t *thread_open(io_t *parent);
00183 io_t *peek_open(io_t *parent);
00184 io_t *stdio_open(const char *filename);
00185
00186 iow_t *zlib_wopen(iow_t *child, int compress_level);
00187 iow_t *bz_wopen(iow_t *child, int compress_level);
00188 iow_t *lzo_wopen(iow_t *child, int compress_level);
00189 iow_t *thread_wopen(iow_t *child);
00190 iow_t *stdio_wopen(const char *filename, int fileflags);
00191
00192
00193
00211 io_t *wandio_create(const char *filename);
00212
00218 off_t wandio_tell(io_t *io);
00219
00232 off_t wandio_seek(io_t *io, off_t offset, int whence);
00233
00241 off_t wandio_read(io_t *io, void *buffer, off_t len);
00242
00251 off_t wandio_peek(io_t *io, void *buffer, off_t len);
00252
00258 void wandio_destroy(io_t *io);
00259
00269 iow_t *wandio_wcreate(const char *filename, int compression_type, int compression_level, int flags);
00270
00278 off_t wandio_wwrite(iow_t *iow, const void *buffer, off_t len);
00279
00285 void wandio_wdestroy(iow_t *iow);
00286
00291 extern int force_directio_read;
00292 extern int force_directio_write;
00293 extern uint64_t write_waits;
00294 extern uint64_t read_waits;
00295 extern unsigned int use_threads;
00296
00297
00298 #endif