# fpInit()

This function initializes a Filter session. Its return value, `pContext`, is passed as the first argument to the File Extraction interface and all other Filter functions.

## Syntax

    void * pascal fpInit(
        KVMemoryStream  *pMemAllocator,
        KVDynLink       *pDynLink,
        char            *pszKeyViewDir,
        KVCharSet        outputCharSet,
        DWORD            dwFlags );

## Arguments

`pMemAllocator` | A pointer to a developer-defined memory allocator. If `NULL` is passed, the default C run-time memory allocation is used.
`pDynLink` | This argument is reserved. It must be `NULL`.
`pszKeyViewDir` | A pointer to the directory where the Filter components (such as the `formats.ini` file, license key file (`kv.lic`), and file filters) are located. This is normally the `install\OS\bin` directory.
`outputCharSet` | The character set to use for textual output when the source character set can be determined from the document or is specified by fpSetSrcCharSet(). The character sets are enumerated in `KVCharSet` in `kvcharset.h`.
`dwFlags` | Instructions on how to process a file or stream. See Flags for dwFlags for more information.

## Flags for dwFlags

`KVF_CONTENTACCESS` | Reserved for internal use.
`KVF_METADATA` | Reserved for internal use.
`KVF_OUTOFPROCESS` | Enables out-of-process filtering. This is enabled by default. See The Filter Process Model.
`KVF_INPROCESS` | Enables in-process filtering. See The Filter Process Model.
`KVF_HEADERFOOTERTAGS` | Puts tags around header and footer data.
`KVF_HEADERFOOTER` | Extracts headers and footers.
`KVF_UNICODEMSBLSB` | Uses the byte order for Big Endian systems (MSBLSB) for Unicode text. MSBLSB is the "Most Significant Byte Least Significant Byte."
`KVF_UNICODELSBMSB` | Uses the byte order for Little Endian systems (LSBMSB) for Unicode text. LSBMSB is the "Least Significant Byte Most Significant Byte."
`KVF_UNICODEMARKER` | Generates the byte order marker for Unicode text.
`KVF_NODEFAULTCHARSETCONVERT` | Prevents default conversion of document character encoding. See Prevent the Default Conversion of a Character Set.
`KVF_OOPLOGON` | Enables the out-of-process error log. See Enable or Disable Error Logging.
`KVF_OOPMEMTRACEON` | Enables memory trace for the out-of-process error log. See Report Memory Errors.
`KVF_OOPLOGOFF` | Disables the out-of-process error log. Enable or Disable Error Logging.
`KVF_OOPMEMTRACEOFF` | Disables memory trace for the out-of-process error log. See Report Memory Errors.
`KVF_FILTERCONTAINERCONTENT` | This flag is used by the Container API which is obsolete. It filters the main file and subfiles of a container file by using the standard filtering functions, and extracts the text to a single file.
`KVF_DETECT_OUTOFPROCESS` `KVF_DETECT_INPROCESS` | Set these flags in `fpInit()` or `fpOpenStreamEx2()` to specify whether files are detected out of process or in process for a filtering session. These flags override the `default_detect_inprocess` flag in `formats.ini`. If you set neither of these flags, file detection behavior is determined by the `KVF_OUTOFPROCESS` or `KVF_INPROCESS` flags in these calls. If you do not set these flags, behavior is determined by `default_detect_inprocess` in `formats.ini`. See Run File Detection In or Out of Process.

## Returns

- If the call is successful, the return value is the pointer `pContext` which is passed as the first argument to all other File Extraction API and Filter API functions.
- If the call is unsuccessful, the return value is `NULL`.

## Discussion

- If this function returns `NULL`, check `stderr` for the KeyView installation error messages "`KeyView Filter SDK License Key has Expired"` and "`KeyView Filter SDK License Key is Invalid`", and pass them to your application.
- To make sure that multithreaded filter processes are thread-safe, you must create a unique context pointer for every thread by calling `fpInit()`. In addition, threads must not share context pointers, and you must use the same context pointer for all API calls in the same thread. Creating a context pointer for every thread does not affect performance because the context pointer uses minimal resources.
- When the filtering context is no longer required, call fpShutdown() to terminate it.

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm