In Filter, the source input can be either a physical file accessed through a file path, or a filter stream created from a data source. A filter stream in the C API implementation is a C data structure that contains pointers to I/O functions similar to their standard ANSI C counterparts. This structure is passed to filter functions in place of the standard input source. The input stream is defined by the KVInputStream structure in kvtypes.h
.
You can create an input stream by using the fpFiletoInputStreamCreate() function, or by using code similar to the code in the Filter sample program. The fpFiletoInputStreamCreate()
function assigns C equivalent I/O functions to fpOpen()
, fpRead()
, fpSeek()
, fpTell()
, and fpClose()
. The code in the Filter sample program is shown below. This code assigns the file I/O functions (myOpen
, myRead
, and so on) to KVInputStream
.
typedef struct { char *pszName; FILE *fp; } MyOpenInfo; KVInputStream IO; MyOpenInfo o; /* Initialize the input stream */ o.pszName = pszFileIn; IO.pInputStreamPrivateData = (void *)&o; IO.fpOpen = myOpen; IO.fpRead = myRead; IO.fpSeek = mySeek; IO.fpTell = myTell; IO.fpClose = myClose;
The output for extracted content is either a physical file accessed through a file path and specified in the call to fpFilterFile(), or an output buffer specified in the call to fpFilterStream(). The buffer is defined by the KVFilterOutput data structure in kvtypes.h
.
|