src/filter.h File Reference


Detailed Description

Generic filter interface.

A filter is an object that reads a data stream. A filter can perform computations using the data stream's contents, but it is _not_ allowed to modify the data stream that is passed to it. The data that is sent to one filter may later be passed to another filter.

Two types of filters are distinguished: stream filters and block filters. Both filters receive their input through successive calls to their input() routine. Block filters must also supply a block size B and a block() routine. The block routine is called after every B bytes of input data. These B bytes, however, may be passed to the filter through multiple calls to the filter's input() routine.

Definition in file filter.h.

#include <stdio.h>
#include "rdd.h"
#include "writer.h"

Include dependency graph for filter.h:

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

Go to the source code of this file.

Data Structures

struct  _RDD_FILTER
struct  _RDD_FILTER_OPS

Typedefs

typedef struct _RDD_FILTER RDD_FILTER
typedef struct _RDD_FILTER_OPS RDD_FILTER_OPS
typedef int(* rdd_fltr_block_fun )(struct _RDD_FILTER *f, unsigned nbyte)
typedef int(* rdd_fltr_close_fun )(struct _RDD_FILTER *f)
typedef void(* rdd_fltr_error_fun )(rdd_count_t pos, rdd_checksum_t expected, rdd_checksum_t computed, void *env)
typedef int(* rdd_fltr_free_fun )(struct _RDD_FILTER *f)
typedef int(* rdd_fltr_input_fun )(struct _RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)
typedef int(* rdd_fltr_rslt_fun )(struct _RDD_FILTER *f, unsigned char *buf, unsigned pos)

Functions

int rdd_filter_close (RDD_FILTER *f)
 Closes a filter for input.
int rdd_filter_free (RDD_FILTER *f)
 Deallocates a filter and its resources.
int rdd_filter_get_result (RDD_FILTER *f, unsigned char *buf, unsigned nbyte)
 Obtains a filter's result.
int rdd_filter_push (RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)
 Pushes a data buffer into a filter.
int rdd_new_adler32_blockfilter (RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite)
int rdd_new_crc32_blockfilter (RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite)
int rdd_new_filter (RDD_FILTER **f, RDD_FILTER_OPS *ops, unsigned statesize, unsigned blocksize)
int rdd_new_md5_blockfilter (RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite)
int rdd_new_md5_streamfilter (RDD_FILTER **f)
int rdd_new_sha1_streamfilter (RDD_FILTER **f)
int rdd_new_sha256_streamfilter (RDD_FILTER **f)
int rdd_new_sha384_streamfilter (RDD_FILTER **f)
int rdd_new_sha512_streamfilter (RDD_FILTER **f)
int rdd_new_stats_blockfilter (RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite)
int rdd_new_verify_adler32_blockfilter (RDD_FILTER **f, FILE *fp, unsigned blocksize, int swap, rdd_fltr_error_fun err, void *env)
int rdd_new_verify_crc32_blockfilter (RDD_FILTER **f, FILE *fp, unsigned blocksize, int swap, rdd_fltr_error_fun err, void *env)
int rdd_new_write_streamfilter (RDD_FILTER **f, RDD_WRITER *writer)


Typedef Documentation

typedef struct _RDD_FILTER RDD_FILTER

typedef int(* rdd_fltr_block_fun)(struct _RDD_FILTER *f, unsigned nbyte)

Definition at line 63 of file filter.h.

typedef int(* rdd_fltr_close_fun)(struct _RDD_FILTER *f)

Definition at line 66 of file filter.h.

typedef void(* rdd_fltr_error_fun)(rdd_count_t pos, rdd_checksum_t expected, rdd_checksum_t computed, void *env)

Definition at line 92 of file filter.h.

typedef int(* rdd_fltr_free_fun)(struct _RDD_FILTER *f)

Definition at line 72 of file filter.h.

typedef int(* rdd_fltr_input_fun)(struct _RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)

Definition at line 60 of file filter.h.

typedef int(* rdd_fltr_rslt_fun)(struct _RDD_FILTER *f, unsigned char *buf, unsigned pos)

Definition at line 69 of file filter.h.


Function Documentation

int rdd_filter_close ( RDD_FILTER f  ) 

Closes a filter for input.

Parameters:
f the filter
Returns:
Returns RDD_OK on success.
This function must be called exactly once after the last data buffer has been pushed into the filter (with rdd_filter_push()).

Definition at line 160 of file filter.c.

References _RDD_FILTER_OPS::block, _RDD_FILTER_OPS::close, is_block_filter, _RDD_FILTER::ops, _RDD_FILTER::pos, and RDD_OK.

int rdd_filter_free ( RDD_FILTER f  ) 

Deallocates a filter and its resources.

Parameters:
f the filter
Returns:
Returns RDD_OK on success.
This function destroys a filter. No operations can be performed on a filter after this function has been called.

Definition at line 193 of file filter.c.

References _RDD_FILTER_OPS::free, _RDD_FILTER::ops, RDD_OK, and _RDD_FILTER::state.

int rdd_filter_get_result ( RDD_FILTER f,
unsigned char *  buf,
unsigned  nbyte 
)

Obtains a filter's result.

Parameters:
f the filter
buf the client's result buffer
nbyte the size of the client's result buffer
Returns:
Returns RDD_OK on success.
This function copies a filter's result value to a client buffer. A result is simply an array of bytes. The interpretation of the result bytes is filter-specific. Not all filters compute a result.

Definition at line 181 of file filter.c.

References _RDD_FILTER_OPS::get_result, _RDD_FILTER::ops, RDD_BADARG, and RDD_NOTFOUND.

int rdd_filter_push ( RDD_FILTER f,
const unsigned char *  buf,
unsigned  nbyte 
)

Pushes a data buffer into a filter.

Parameters:
f the filter
buf the data buffer
nbyte the size in bytes of data buffer buf
Returns:
Returns RDD_OK on success.
This function pushes buffer buf into filter f. The filter must not modify buffer buf. The filter will process the buffer as it sees fit.

Passes a buffer of nbyte bytes to a filter. If the filter is a stream filter it will simply pass the buffer to the client's handler. If the filter is a block filter, it processes the buffer block by block, calling the client's block handler at each block boundary.

Definition at line 149 of file filter.c.

References block_filter_push(), is_stream_filter, and stream_filter_push().

Here is the call graph for this function:

int rdd_new_adler32_blockfilter ( RDD_FILTER **  f,
unsigned  blocksize,
const char *  outpath,
int  overwrite 
)

Definition at line 238 of file checksumblockfilter.c.

References new_checksum_blockfilter(), and RDD_ADLER32.

Here is the call graph for this function:

int rdd_new_crc32_blockfilter ( RDD_FILTER **  f,
unsigned  blocksize,
const char *  outpath,
int  overwrite 
)

Definition at line 246 of file checksumblockfilter.c.

References new_checksum_blockfilter(), and RDD_CRC32.

Here is the call graph for this function:

int rdd_new_filter ( RDD_FILTER **  self,
RDD_FILTER_OPS ops,
unsigned  statesize,
unsigned  blocksize 
)

This is a convenience routine that can (and should) be used by filter implementations to initialize the 'base' filter.

Definition at line 63 of file filter.c.

References _RDD_FILTER_OPS::block, _RDD_FILTER::blocksize, _RDD_FILTER::ops, _RDD_FILTER::pos, RDD_BADARG, RDD_NOMEM, RDD_OK, and _RDD_FILTER::state.

int rdd_new_md5_blockfilter ( RDD_FILTER **  f,
unsigned  blocksize,
const char *  outpath,
int  overwrite 
)

int rdd_new_md5_streamfilter ( RDD_FILTER **  f  ) 

Definition at line 79 of file md5streamfilter.c.

References _RDD_MD5_STREAM_FILTER::md5_state, RDD_BADARG, rdd_new_filter(), RDD_OK, and _RDD_FILTER::state.

Here is the call graph for this function:

int rdd_new_sha1_streamfilter ( RDD_FILTER **  f  ) 

Definition at line 79 of file sha1streamfilter.c.

References RDD_BADARG, rdd_new_filter(), RDD_OK, _RDD_SHA1_STREAM_FILTER::sha1_state, and _RDD_FILTER::state.

Here is the call graph for this function:

int rdd_new_sha256_streamfilter ( RDD_FILTER **  f  ) 

Definition at line 72 of file sha256streamfilter.c.

References RDD_BADARG, rdd_new_filter(), RDD_OK, _RDD_SHA256_STREAM_FILTER::sha256_state, and _RDD_FILTER::state.

Here is the call graph for this function:

int rdd_new_sha384_streamfilter ( RDD_FILTER **  f  ) 

Definition at line 72 of file sha384streamfilter.c.

References RDD_BADARG, rdd_new_filter(), RDD_OK, _RDD_SHA384_STREAM_FILTER::sha384_state, and _RDD_FILTER::state.

Here is the call graph for this function:

int rdd_new_sha512_streamfilter ( RDD_FILTER **  f  ) 

Definition at line 72 of file sha512streamfilter.c.

References RDD_BADARG, rdd_new_filter(), RDD_OK, _RDD_SHA512_STREAM_FILTER::sha512_state, and _RDD_FILTER::state.

Here is the call graph for this function:

int rdd_new_stats_blockfilter ( RDD_FILTER **  f,
unsigned  blocksize,
const char *  outpath,
int  overwrite 
)

int rdd_new_verify_adler32_blockfilter ( RDD_FILTER **  f,
FILE *  fp,
unsigned  blocksize,
int  swap,
rdd_fltr_error_fun  err,
void *  env 
)

Definition at line 246 of file verifyblockfilter.c.

References new_verify_checksum_blockfilter(), and RDD_ADLER32.

Here is the call graph for this function:

int rdd_new_verify_crc32_blockfilter ( RDD_FILTER **  f,
FILE *  fp,
unsigned  blocksize,
int  swap,
rdd_fltr_error_fun  err,
void *  env 
)

Definition at line 255 of file verifyblockfilter.c.

References new_verify_checksum_blockfilter(), and RDD_CRC32.

Here is the call graph for this function:

int rdd_new_write_streamfilter ( RDD_FILTER **  f,
RDD_WRITER writer 
)

Definition at line 83 of file writestreamfilter.c.

References rdd_new_filter(), RDD_OK, _RDD_FILTER::state, and _RDD_WRITE_STREAM_FILTER::writer.

Here is the call graph for this function:


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