wandio.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of libtrace
00003  *
00004  * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton, 
00005  * New Zealand.
00006  *
00007  * Authors: Daniel Lawson 
00008  *          Perry Lorier
00009  *          Shane Alcock 
00010  *          
00011  * All rights reserved.
00012  *
00013  * This code has been developed by the University of Waikato WAND 
00014  * research group. For further information please see http://www.wand.net.nz/
00015  *
00016  * libtrace is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  *
00021  * libtrace is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with libtrace; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  *
00030  * $Id: wandio.h 1685 2011-01-11 00:17:19Z salcock $
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

Generated on Fri Jul 1 09:50:24 2011 for WAND Trace processing by  doxygen 1.5.1