Filtering in Stream Mode

To use the Filtering stream-based I/O

  1. Load the kvfilter library and obtain the KV_GetFilterInterfaceEx() entry point. The filter sample program contains sample code for all platforms.
  2. Initialize a filter session by calling fpInit(). This function’s return value, pContext, is passed as the first argument to all other Filter functions.
  3. Pass the context pointer from fpInit() and the address of a structure that contains pointers to the File Extraction API functions in the call to KVGetExtractInterface(). See KVGetExtractInterface().
  4. Create an input stream (KVInputStream) by calling fpFiletoInputStreamCreate() or by using code similar to the example code in the Filter sample program.
  5. Open the stream by calling fpOpenStream().
  6. Declare the input stream in the KVOpenFileArg structure.
  7. Open the source file by calling fpOpenFile() and passing the KVOpenFileArg structure. This call defines the parameters necessary to open a file for extraction.
  8. Determine whether the source file is a container file (that is, whether it contains subfiles) by calling fpGetMainFileInfo().
  9. If the call to fpGetMainFileInfo() determined that the source file is a container file, proceed to step 10; otherwise, proceed to step 13.
  10. Determine whether the subfile is a container file by calling fpGetSubFileInfo().
  11. Extract the subfile to a stream by calling fpExtractSubFile().
  12. If the call to fpGetSubFileInfo() determined that the subfile is a container file, repeat step 4 through step 11 until all subfiles are extracted; otherwise, proceed to step 13.
  13. Filter the stream by calling fpFilterStream(). Call fpFilterStream() repeatedly until the entire output buffer is processed.
  14. Close the stream by calling fpCloseStream().
  15. Free the memory allocated for the input stream by calling fpFileToInputStreamFree().
  16. Close the file by calling fpCloseFile().
  17. Repeat Filtering in Stream Mode through Filtering in Stream Mode as required for additional source files.
  18. Terminate the filter session by calling fpShutdown().