• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

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 1756 2012-03-06 01:15:17Z 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 
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

Generated on Tue Mar 6 2012 14:15:35 for WAND Trace processing by  doxygen 1.7.1