src/filter.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rdd.h"
#include "writer.h"
#include "filter.h"

Include dependency graph for filter.c:

Go to the source code of this file.

Defines

#define is_block_filter(fltr)   ((fltr)->ops->block != 0)
#define is_stream_filter(fltr)   ((fltr)->ops->block == 0)

Functions

static int block_filter_push (RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)
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_filter (RDD_FILTER **self, RDD_FILTER_OPS *ops, unsigned statesize, unsigned blocksize)
static int stream_filter_push (RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)

Variables

static char copyright []


Define Documentation

#define is_block_filter ( fltr   )     ((fltr)->ops->block != 0)

Definition at line 57 of file filter.c.

#define is_stream_filter ( fltr   )     ((fltr)->ops->block == 0)

Definition at line 56 of file filter.c.


Function Documentation

static int block_filter_push ( RDD_FILTER f,
const unsigned char *  buf,
unsigned  nbyte 
) [static]

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.

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_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.

static int stream_filter_push ( RDD_FILTER f,
const unsigned char *  buf,
unsigned  nbyte 
) [static]

Definition at line 99 of file filter.c.

References _RDD_FILTER_OPS::input, and _RDD_FILTER::ops.


Variable Documentation

char copyright[] [static]

Initial value:

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

Definition at line 39 of file filter.c.


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