src/reader.c File Reference

#include <stdlib.h>
#include "rdd.h"
#include "reader.h"

Include dependency graph for reader.c:

Go to the source code of this file.

Functions

int rdd_new_reader (RDD_READER **self, RDD_READ_OPS *ops, unsigned statesize)
 Allocates and partially initializes a reader object.
int rdd_reader_close (RDD_READER *r, int recurse)
 Closes and deallocates the reader object.
int rdd_reader_read (RDD_READER *r, unsigned char *buf, unsigned nbyte, unsigned *nread)
 Generic read routine.
int rdd_reader_seek (RDD_READER *r, rdd_count_t pos)
 Updates the current file position.
int rdd_reader_skip (RDD_READER *r, rdd_count_t skip)
 Moves the file pointer skip bytes forward.
int rdd_reader_tell (RDD_READER *r, rdd_count_t *pos)
 Returns the current file position in bytes.

Variables

static char copyright []


Function Documentation

int rdd_new_reader ( RDD_READER **  r,
RDD_READ_OPS ops,
unsigned  statesize 
)

Allocates and partially initializes a reader object.

Parameters:
r output value: a new reader object.
ops pointers to implementation-specific reader functions.
statesize size in bytes of implementation-specific state.
Returns:
Returns RDD_OK on success. Returns RDD_NOMEM when there is insufficient memory to allocate the reader object or its state buffer.
rdd_new_reader allocates a reader object and initializes its ops field to argument . The state field is set to point to a new buffer (allocated with malloc()) with size statesize. The state buffer is zeroed.

Definition at line 50 of file reader.c.

References _RDD_READER::ops, RDD_BADARG, RDD_NOMEM, RDD_OK, and _RDD_READER::state.

int rdd_reader_close ( RDD_READER r,
int  recurse 
)

Closes and deallocates the reader object.

Parameters:
r pointer to the reader object.
recurse recursive-close flag
Returns:
Returns RDD_OK on success.
All resources associated with the reader are released. If this reader is stacked on top of other readers, then those readers will also be closed iff recurse is nonzero.

Definition at line 107 of file reader.c.

References _RDD_READ_OPS::close, _RDD_READER::ops, RDD_OK, and _RDD_READER::state.

int rdd_reader_read ( RDD_READER r,
unsigned char *  buf,
unsigned  nbyte,
unsigned *  nread 
)

Generic read routine.

Parameters:
r pointer to the reader object.
buf pointer to the target buffer; the size of this buffer must be at least nbyte bytes.
nbyte the number of bytes to read
nread output value: the number of bytes actually read; the value in *read is valid only if RDD_OK is returned.
Returns:
Returns RDD_OK if the read succeeds. If the read succeeds, *nread will be equal to nbyte except when there are fewer than nbyte bytes left until the end of the file is reached. In that case *nread will be equal to the number of bytes left. If *nread equals 0, then end-of-file has been reached.

Definition at line 71 of file reader.c.

References _RDD_READER::ops, and _RDD_READ_OPS::read.

int rdd_reader_seek ( RDD_READER r,
rdd_count_t  pos 
)

Updates the current file position.

Parameters:
r pointer to the reader object.
pos the new (absolute) file position in bytes.
Returns:
Returns RDD_OK on success.
Note: not all readers implement the seek() routine.

Definition at line 84 of file reader.c.

References _RDD_READER::ops, and _RDD_READ_OPS::seek.

int rdd_reader_skip ( RDD_READER r,
rdd_count_t  skip 
)

Moves the file pointer skip bytes forward.

Parameters:
r pointer to the reader object.
skip the number of bytes to move forward.
Returns:
Returns RDD_OK on success.
Note: not all readers implement the skip() routine.

Definition at line 90 of file reader.c.

References RDD_OK, rdd_reader_seek(), and rdd_reader_tell().

Here is the call graph for this function:

int rdd_reader_tell ( RDD_READER r,
rdd_count_t pos 
)

Returns the current file position in bytes.

Parameters:
r pointer to the reader object.
pos output value: the current file position in bytes. The value in *pos is valid only if RDD_OK is returned.
Returns:
Returns RDD_OK on success.

Definition at line 78 of file reader.c.

References _RDD_READER::ops, and _RDD_READ_OPS::tell.


Variable Documentation

char copyright[] [static]

Initial value:

"@(#) Copyright (c) 2002-2004\n\
    Netherlands Forensic Institute.  All rights reserved.\n"

Definition at line 34 of file reader.c.


Generated on Sun Feb 6 12:36:33 2011 for rdd by  doxygen 1.5.6