Data Structures | Defines | Typedefs | Enumerations | Variables

wandio.h File Reference

Header file dealing with the Libtrace IO sub-system. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  compression_type
 Structure defining a supported compression method. More...
struct  io_source_t
 Structure defining a libtrace IO reader module. More...
struct  iow_source_t
 Structure defining a libtrace IO writer module. More...
struct  io_t
 A libtrace IO reader. More...
struct  iow_t
 A libtrace IO writer. More...

Defines

#define DLLEXPORT
 < Guard Define
#define DLLLOCAL

Typedefs

typedef struct io_t io_t
 Opaque IO handle structure for reading.
typedef struct iow_t iow_t
 Opaque IO handle structure for writing.

Enumerations

enum  {
  WANDIO_COMPRESS_NONE = 0, WANDIO_COMPRESS_ZLIB = 1, WANDIO_COMPRESS_BZ2 = 2, WANDIO_COMPRESS_LZO = 3,
  WANDIO_COMPRESS_MASK = 7
}
 

Enumeration of all supported compression methods.

More...

Functions

IO open functions

These functions deal with creating and initialising a new IO reader or writer.

io_tbz_open (io_t *parent)
io_tzlib_open (io_t *parent)
io_tthread_open (io_t *parent)
io_tpeek_open (io_t *parent)
io_tstdio_open (const char *filename)
iow_tzlib_wopen (iow_t *child, int compress_level)
iow_tbz_wopen (iow_t *child, int compress_level)
iow_tlzo_wopen (iow_t *child, int compress_level)
iow_tthread_wopen (iow_t *child)
iow_tstdio_wopen (const char *filename, int fileflags)
Libtrace IO API functions

These are the functions that should be called by the format modules to open and use files with the libtrace IO sub-system.

io_twandio_create (const char *filename)
 Creates a new libtrace IO reader and opens the provided file for reading.
off_t wandio_tell (io_t *io)
 Returns the current offset of the read pointer for a libtrace IO reader.
off_t wandio_seek (io_t *io, off_t offset, int whence)
 Changes the read pointer offset to the specified value for a libtrace IO reader.
off_t wandio_read (io_t *io, void *buffer, off_t len)
 Reads from a libtrace IO reader into the provided buffer.
off_t wandio_peek (io_t *io, void *buffer, off_t len)
 Reads from a libtrace IO reader into the provided buffer, but does not update the read pointer.
void wandio_destroy (io_t *io)
 Destroys a libtrace IO reader, closing the file and freeing the reader structure.
iow_twandio_wcreate (const char *filename, int compression_type, int compression_level, int flags)
 Creates a new libtrace IO writer and opens the provided file for writing.
off_t wandio_wwrite (iow_t *iow, const void *buffer, off_t len)
 Writes the contents of a buffer using a libtrace IO writer.
void wandio_wdestroy (iow_t *iow)
 Destroys a libtrace IO writer, closing the file and freeing the writer structure.

Variables

struct compression_type compression_type []
 The list of supported compression methods.
libtraceio options

int force_directio_read
int force_directio_write
uint64_t write_waits
uint64_t read_waits
unsigned int use_threads
unsigned int max_buffers

Detailed Description

Header file dealing with the Libtrace IO sub-system.

Author:
Perry Lorier
Shane Alcock
Version:
Id:
wandio.h 1756 2012-03-06 01:15:17Z salcock

Define Documentation

#define DLLEXPORT

< Guard Define


Typedef Documentation

typedef struct io_t io_t

Opaque IO handle structure for reading.

typedef struct iow_t iow_t

Opaque IO handle structure for writing.


Enumeration Type Documentation

anonymous enum

Enumeration of all supported compression methods.

Enumerator:
WANDIO_COMPRESS_NONE 

No compression.

WANDIO_COMPRESS_ZLIB 

Zlib compression.

WANDIO_COMPRESS_BZ2 

Bzip compression.

WANDIO_COMPRESS_LZO 

LZO compression.

WANDIO_COMPRESS_MASK 

All supported methods - used as a bitmask.


Function Documentation

io_t* wandio_create ( const char *  filename  ) 

Creates a new libtrace IO reader and opens the provided file for reading.

Parameters:
filename The name of the file to open
Returns:
A pointer to a new libtrace IO reader, or NULL if an error occurs

This function will attempt to detect the compression format used for the given file (if any), provided that libtrace was built with the appropriate libraries.

void wandio_destroy ( io_t io  ) 

Destroys a libtrace IO reader, closing the file and freeing the reader structure.

Parameters:
io The IO reader to destroy

References io_source_t::close, and io_t::source.

off_t wandio_peek ( io_t io,
void *  buffer,
off_t  len 
)

Reads from a libtrace IO reader into the provided buffer, but does not update the read pointer.

Parameters:
io The IO reader to read from
buffer The buffer to read into
len The size of the buffer
Returns:
The amount of bytes read, 0 if EOF is reached, -1 if an error occurs

References io_source_t::name, io_source_t::peek, and io_t::source.

off_t wandio_read ( io_t io,
void *  buffer,
off_t  len 
)

Reads from a libtrace IO reader into the provided buffer.

Parameters:
io The IO reader to read from
buffer The buffer to read into
len The size of the buffer
Returns:
The amount of bytes read, 0 if EOF is reached, -1 if an error occurs

References io_source_t::name, io_source_t::read, and io_t::source.

off_t wandio_seek ( io_t io,
off_t  offset,
int  whence 
)

Changes the read pointer offset to the specified value for a libtrace IO reader.

Parameters:
io The IO reader to adjust the read pointer for
offset The new offset for the read pointer
whence Indicates where to set the read pointer from. Can be one of SEEK_SET, SEEK_CUR or SEEK_END.
Returns:
The new value for the read pointer, or -1 if an error occurs

The arguments for this function are the same as those for lseek(2). See the lseek(2) manpage for more details.

References io_source_t::seek, and io_t::source.

off_t wandio_tell ( io_t io  ) 

Returns the current offset of the read pointer for a libtrace IO reader.

Parameters:
io The IO reader to get the read offset for
Returns:
The offset of the read pointer, or -1 if an error occurs

References io_t::source, and io_source_t::tell.

iow_t* wandio_wcreate ( const char *  filename,
int  compression_type,
int  compression_level,
int  flags 
)

Creates a new libtrace IO writer and opens the provided file for writing.

Parameters:
filename The name of the file to open
compression_type Compression type
compression_level The compression level to use when writing
flags Flags to apply when opening the file, e.g. O_CREATE
Returns:
A pointer to the new libtrace IO writer, or NULL if an error occurs

References WANDIO_COMPRESS_BZ2, WANDIO_COMPRESS_LZO, WANDIO_COMPRESS_MASK, and WANDIO_COMPRESS_ZLIB.

void wandio_wdestroy ( iow_t iow  ) 

Destroys a libtrace IO writer, closing the file and freeing the writer structure.

Parameters:
iow The IO writer to destroy

References iow_source_t::close, and iow_t::source.

off_t wandio_wwrite ( iow_t iow,
const void *  buffer,
off_t  len 
)

Writes the contents of a buffer using a libtrace IO writer.

Parameters:
iow The IO writer to write the data with
buffer The buffer to write out
len The amount of writable data in the buffer
Returns:
The amount of data written, or -1 if an error occurs

References iow_source_t::name, iow_t::source, and iow_source_t::write.


Variable Documentation

The list of supported compression methods.