src/copier.h File Reference


Detailed Description

Generic copier interface.

Copier objects, or copiers, implement a data copy algorithm. All copiers implement the interface that is defined here.

Definition in file copier.h.

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

Go to the source code of this file.

Data Structures

struct  _RDD_COPIER
struct  _RDD_COPIER_RETURN
struct  _RDD_COPY_OPS
struct  _RDD_ROBUST_PARAMS
 Robust copier configuration parameters. More...
struct  _RDD_SIMPLE_PARAMS
 Simple copier configuration parameters. More...

Typedefs

typedef struct _RDD_COPIER RDD_COPIER
typedef struct _RDD_COPIER_RETURN RDD_COPIER_RETURN
typedef int(* rdd_copy_exec_fun )(RDD_COPIER *c, RDD_READER *reader, RDD_FILTERSET *fset, RDD_COPIER_RETURN *ret)
typedef int(* rdd_copy_free_fun )(RDD_COPIER *c)
typedef struct _RDD_COPY_OPS RDD_COPY_OPS
typedef int(* rdd_proghandler_t )(rdd_count_t ncopied, rdd_count_t nsubstituted, void *env)
 Progress callback type.
typedef void(* rdd_readerrhandler_t )(rdd_count_t offset, unsigned nbyte, void *env)
 Read error callback type.
typedef struct _RDD_ROBUST_PARAMS RDD_ROBUST_PARAMS
 Robust copier configuration parameters.
typedef struct _RDD_SIMPLE_PARAMS RDD_SIMPLE_PARAMS
 Simple copier configuration parameters.
typedef void(* rdd_substhandler_t )(rdd_count_t offset, unsigned nbyte, void *env)
 Substitution callback type.

Functions

int rdd_copy_exec (RDD_COPIER *c, RDD_READER *r, RDD_FILTERSET *fset, RDD_COPIER_RETURN *ret)
 Generic copy routine that instructs a copier to start copying.
int rdd_copy_free (RDD_COPIER *c)
 Deallocates the copier object and releases its resources.
int rdd_new_copier (RDD_COPIER **c, RDD_COPY_OPS *ops, unsigned statesize)
 Allocates a copier object and space for its implementation-specific state.
int rdd_new_robust_copier (RDD_COPIER **c, rdd_count_t offset, rdd_count_t count, RDD_ROBUST_PARAMS *params)
 Creates a new robust copier.
int rdd_new_simple_copier (RDD_COPIER **c, RDD_SIMPLE_PARAMS *params)
 Creates a new simple copier.


Typedef Documentation

typedef struct _RDD_COPIER RDD_COPIER

typedef int(* rdd_copy_exec_fun)(RDD_COPIER *c, RDD_READER *reader, RDD_FILTERSET *fset, RDD_COPIER_RETURN *ret)

Definition at line 58 of file copier.h.

typedef int(* rdd_copy_free_fun)(RDD_COPIER *c)

Definition at line 63 of file copier.h.

typedef struct _RDD_COPY_OPS RDD_COPY_OPS

Each copier must supply an RDD_COPY_OPS structure that contains its specific copy routines.

typedef int(* rdd_proghandler_t)(rdd_count_t ncopied, rdd_count_t nsubstituted, void *env)

Progress callback type.

Definition at line 83 of file copier.h.

typedef void(* rdd_readerrhandler_t)(rdd_count_t offset, unsigned nbyte, void *env)

Read error callback type.

Definition at line 75 of file copier.h.

Robust copier configuration parameters.

Simple copier configuration parameters.

typedef void(* rdd_substhandler_t)(rdd_count_t offset, unsigned nbyte, void *env)

Substitution callback type.

Definition at line 79 of file copier.h.


Function Documentation

int rdd_copy_exec ( RDD_COPIER c,
RDD_READER r,
RDD_FILTERSET fset,
RDD_COPIER_RETURN ret 
)

Generic copy routine that instructs a copier to start copying.

Parameters:
c a pointer to the copier object.
r a reader object from which the copier will read its source data.
fset a filter set; the copier will push the data it reads from the reader to all filters in the filter set.
Returns:
Returns RDD_OK on success.
Every copier reads, or tries to read, data from reader r. The data it reads, or the data that it substitutes, is passed to the filter set fset. The current copier implementation differ in how they handle read errors. A simple copier will give up after the first read error, but a robust copier will retry and eventually substitute data if a read fails repeatedly.

Definition at line 75 of file copier.c.

References _RDD_COPY_OPS::exec, and _RDD_COPIER::ops.

int rdd_copy_free ( RDD_COPIER c  ) 

Deallocates the copier object and releases its resources.

Parameters:
c a pointer to the copier object.
Returns:
Returns RDD_OK on success.

Definition at line 84 of file copier.c.

References _RDD_COPY_OPS::free, _RDD_COPIER::ops, RDD_OK, and _RDD_COPIER::state.

int rdd_new_copier ( RDD_COPIER **  c,
RDD_COPY_OPS ops,
unsigned  statesize 
)

Allocates a copier object and space for its implementation-specific state.

Parameters:
c output value: will be set to a pointer to the new copier object.
ops a pointer to a copiers implementation-specific copy routines.
statesize the size in bytes of the copier's state.
Returns:
Returns RDD_OK on success. Returns RDD_NOMEM if there is insufficient memory to create the object.
This is a utility routine that does not belong to the copy interface. It is used to prevent code duplication in copier implementations, which must all allocate a copier object and some implementation-specific state. This routine allocates the object and that state. The state buffer is zeroed. Initializing it with sensible values is, of course, a job left to the copier implementation.

Definition at line 49 of file copier.c.

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

int rdd_new_robust_copier ( RDD_COPIER **  c,
rdd_count_t  offset,
rdd_count_t  count,
RDD_ROBUST_PARAMS params 
)

Creates a new robust copier.

Parameters:
c output value: will be set to a pointer to the new robust copier object.
offset byte offset; where to start copying
count the maximum number of bytes to copy
params the copier's error-handling parameters
Returns:
Returns RDD_OK on success. Returns RDD_NOMEM if there is insufficient memory to create the object.
A robust copier behaves like a simple copier as long as no errors occur and if the offset and count arguments are both set to zero.

The offset and count arguments are used to read a contiguous segment from the input stream supplied to rdd_copy_exec(): offset bytes from the input stream are skipped before the copier starts copying data and copying stops when count bytes have been copied or when end-of-file is encountered.

The parameters params specify the copier's behavior when read errors occur. A robust copier will enter a retry phase when a read fails. In that phase it reduces the amount of data it reads at a time and it will retry reads that fail.

Definition at line 120 of file robustcopier.c.

References _RDD_ROBUST_COPIER::count, _RDD_ROBUST_COPIER::curblocklen, error(), _RDD_ROBUST_COPIER::maxblocklen, _RDD_ROBUST_PARAMS::maxblocklen, _RDD_ROBUST_PARAMS::maxsubst, _RDD_ROBUST_COPIER::maxsubst, _RDD_ROBUST_COPIER::minblocklen, _RDD_ROBUST_PARAMS::minblocklen, _RDD_ROBUST_COPIER::mode, _RDD_ROBUST_COPIER::nbyte, _RDD_ROBUST_COPIER::nlost, _RDD_ROBUST_COPIER::nok, _RDD_ROBUST_COPIER::nread_err, _RDD_ROBUST_PARAMS::nretry, _RDD_ROBUST_COPIER::nretry, _RDD_ROBUST_COPIER::nsubst, _RDD_ROBUST_COPIER::ntry, _RDD_ROBUST_COPIER::offset, _RDD_ROBUST_PARAMS::progressenv, _RDD_ROBUST_COPIER::progressenv, _RDD_ROBUST_PARAMS::progressfun, _RDD_ROBUST_COPIER::progressfun, RDD_BADARG, rdd_new_alignedbuf(), rdd_new_copier(), RDD_OK, RDD_SECTOR_SIZE, READ_OK, _RDD_ROBUST_COPIER::readbuf, _RDD_ROBUST_PARAMS::readerrenv, _RDD_ROBUST_COPIER::readerrenv, _RDD_ROBUST_PARAMS::readerrfun, _RDD_ROBUST_COPIER::readerrfun, _RDD_ROBUST_COPIER::recovery_threshold, _RDD_COPIER::state, _RDD_ROBUST_PARAMS::substenv, _RDD_ROBUST_COPIER::substenv, _RDD_ROBUST_PARAMS::substfun, _RDD_ROBUST_COPIER::substfun, and _RDD_ROBUST_COPIER::verbose.

Here is the call graph for this function:

int rdd_new_simple_copier ( RDD_COPIER **  c,
RDD_SIMPLE_PARAMS params 
)

Creates a new simple copier.

Parameters:
c output value: will be set to a pointer to the new simple copier object.
params the copier's parameters
Returns:
Returns RDD_OK on success. Returns RDD_NOMEM if there is insufficient memory to create the object.
A simple copier reads data from its reader (see rdd_copy_exec()) until it reached end-of-file or until it encounters any error, including a read error.

The parameters params specify a callback function and its environment. This function is called periodically and can be used to report or track progress.

Definition at line 76 of file simplecopier.c.

References _RDD_SIMPLE_PARAMS::progressenv, _RDD_SIMPLE_COPIER::progressenv, _RDD_SIMPLE_PARAMS::progressfun, _RDD_SIMPLE_COPIER::progressfun, rdd_new_copier(), RDD_OK, _RDD_SIMPLE_COPIER::readbuf, and _RDD_COPIER::state.

Here is the call graph for this function:


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