Copier objects, or copiers, implement a data copy algorithm. All copiers implement the interface that is defined here.
Definition in file copier.h.
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 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 |
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) |
typedef void(* rdd_readerrhandler_t)(rdd_count_t offset, unsigned nbyte, void *env) |
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) |
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.
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. |
RDD_OK
on success.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.
c | a pointer to the copier object. |
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.
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. |
RDD_OK
on success. Returns RDD_NOMEM
if there is insufficient memory to create the object.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.
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 |
RDD_OK
on success. Returns RDD_NOMEM
if there is insufficient memory to create the object.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.
int rdd_new_simple_copier | ( | RDD_COPIER ** | c, | |
RDD_SIMPLE_PARAMS * | params | |||
) |
Creates a new simple copier.
c | output value: will be set to a pointer to the new simple copier object. | |
params | the copier's parameters |
RDD_OK
on success. Returns RDD_NOMEM
if there is insufficient memory to create the object.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.