|
NAMEfilter_read , filter_write ,
filter_end , filter_convert ,
filter_destroy , filter_fopen ,
filter_process —
generic data filtering
LIBRARYPDEL Library (libpdel, -lpdel)SYNOPSIS#include <sys/types.h>
#include <stdio.h>
#include <pdel/io/filter.h>
int
int
int
int
void
FILE *
int
DESCRIPTIONThese functions operate on filters, which are objects that have an input side and an output side and perform some kind of encoding or operation on data as it passes through.Filter ObjectsA filter object looks like this:struct filter { filter_read_t *read; /* read data out of filter */ filter_write_t *write; /* write data into filter */ filter_end_t *end; /* signal end of data */ filter_convert_t *convert; /* map # bytes in <-> out */ filter_destroy_t *destroy; /* destroy filter */ void *private; /* object private data */ }; typedef int filter_read_t(struct filter *f, void *buf, int len); typedef int filter_write_t(struct filter *f, const void *data, int len); typedef int filter_end_t(struct filter *f); typedef int filter_convert_t(struct filter *f, int num, int forward); typedef void filter_destroy_t(struct filter **fp); Note: these functions must be implemented to be thread-safe. For example, two threads should be able to write to and read from the same filter object simultaneously. The The The The The The By implementing these methods and providing a constructor function to create new instances, user-defined filters may be used with the functions below. Filter Functionsfilter_fopen () pushes a filter on top of a
uni-directional stream, returning a new stream. Data read from or written to
the newly created stream will pass through the filter. The
mode argument is as described for
fopen(3),
but is restricted to being either "r" or "w".
If flags is zero, calling fclose(3) on the newly created stream causes the underlying stream fp to be closed and filter to be destroyed. Otherwise, the flags value may contain any of the following values OR'd together: FILTER_NO_CLOSE_STREAM fclose() does not close underlying stream FILTER_NO_DESTROY_FILTER fclose() does not destroy the filter
RETURN VALUESAll functions that have a return value use -1 orNULL to
indicate an error, with errno set appropriately.
SEE ALSObase64(3), fopen(3), libpdel(3), string_fp(3), typed_mem(3)HISTORYThe PDEL library was developed at Packet Design, LLC.http://www.packetdesign.com/
AUTHORSArchie Cobbs ⟨archie@freebsd.org⟩
Visit the GSP FreeBSD Man Page Interface. |