Go to the documentation of this file.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
00042 #if __GNUC__ >= 4
00043 #ifdef LT_BUILDING_DLL
00044 #define DLLEXPORT __attribute__ ((visibility("default")))
00045 #define DLLLOCAL __attribute__ ((visibility("hidden")))
00046 #else
00047 #define DLLEXPORT
00048 #define DLLLOCAL
00049 #endif
00050 #else
00051 #define DLLEXPORT
00052 #define DLLLOCAL
00053 #endif
00054
00055
00056
00067 typedef struct io_t io_t;
00068 typedef struct iow_t iow_t;
00071 struct compression_type {
00073 const char *name;
00076 const char *ext;
00078 int compress_type;
00079 };
00080
00082 extern struct compression_type compression_type[];
00083
00085 typedef struct {
00087 const char *name;
00088
00097 off_t (*read)(io_t *io, void *buffer, off_t len);
00098
00108 off_t (*peek)(io_t *io, void *buffer, off_t len);
00109
00115 off_t (*tell)(io_t *io);
00116
00127 off_t (*seek)(io_t *io, off_t offset, int whence);
00128
00133 void (*close)(io_t *io);
00134 } io_source_t;
00135
00137 typedef struct {
00139 const char *name;
00140
00148 off_t (*write)(iow_t *iow, const char *buffer, off_t len);
00149
00154 void (*close)(iow_t *iow);
00155 } iow_source_t;
00156
00158 struct io_t {
00160 io_source_t *source;
00162 void *data;
00163 };
00164
00166 struct iow_t {
00168 iow_source_t *source;
00170 void *data;
00171 };
00172
00174 enum {
00176 WANDIO_COMPRESS_NONE = 0,
00178 WANDIO_COMPRESS_ZLIB = 1,
00180 WANDIO_COMPRESS_BZ2 = 2,
00182 WANDIO_COMPRESS_LZO = 3,
00184 WANDIO_COMPRESS_MASK = 7
00185 };
00186
00195 io_t *bz_open(io_t *parent);
00196 io_t *zlib_open(io_t *parent);
00197 io_t *thread_open(io_t *parent);
00198 io_t *peek_open(io_t *parent);
00199 io_t *stdio_open(const char *filename);
00200
00201 iow_t *zlib_wopen(iow_t *child, int compress_level);
00202 iow_t *bz_wopen(iow_t *child, int compress_level);
00203 iow_t *lzo_wopen(iow_t *child, int compress_level);
00204 iow_t *thread_wopen(iow_t *child);
00205 iow_t *stdio_wopen(const char *filename, int fileflags);
00206
00207
00208
00226 io_t *wandio_create(const char *filename);
00227
00233 off_t wandio_tell(io_t *io);
00234
00247 off_t wandio_seek(io_t *io, off_t offset, int whence);
00248
00256 off_t wandio_read(io_t *io, void *buffer, off_t len);
00257
00266 off_t wandio_peek(io_t *io, void *buffer, off_t len);
00267
00273 void wandio_destroy(io_t *io);
00274
00284 iow_t *wandio_wcreate(const char *filename, int compression_type, int compression_level, int flags);
00285
00293 off_t wandio_wwrite(iow_t *iow, const void *buffer, off_t len);
00294
00300 void wandio_wdestroy(iow_t *iow);
00301
00306 extern int force_directio_read;
00307 extern int force_directio_write;
00308 extern uint64_t write_waits;
00309 extern uint64_t read_waits;
00310 extern unsigned int use_threads;
00311 extern unsigned int max_buffers;
00312
00313
00314 #endif