Show Table of Contents
11.7. Writing an Initialization Function
Internally, the server keeps a list of matching rule plug-ins. When dealing with matching rules, the server attempts to find the matching rule plug-in to handle the given matching rule. Refer to Section 11.2.3, “How the Server Associates Plug-ins with OIDs”, for details.
In order to add your plug-in to that internal list, you need to write an initialization function. The initialization function takes a single Slapi_PBlock argument. The function should set the following parameters:
- The
SLAPI_PLUGIN_MR_FILTER_CREATE_FNparameter should be set to the filter factory function.Refer to Section 11.4.1, “How the Server Handles the Filter”, and Section 11.4.3, “Writing a Filter Factory Function”, for details. - The
SLAPI_PLUGIN_MR_INDEXER_CREATE_FNparameter should be set to the indexer factory function if you have defined one. [Optional]Refer to Section 11.3.1, “How the Server Sets Up the Index”, and Section 11.3.3, “Writing the Indexer Factory Function”, for details. - The
SLAPI_PLUGIN_CLOSE_FNparameter should be set to the close function if you have defined one. [Optional]Refer to Section 11.9, “Specifying Start and Close Functions”, for details. - The
SLAPI_PLUGIN_PRIVATEparameter should be set to any private data you want made accessible to the plug-in functions. [Optional]
You need to register the initialization function so that the server runs the function when starting. For how to register matching rule functions, refer to Section 11.8, “Registering Matching Rule Functions”.
The following table summarizes the different parameters that the initialization function should get and set in the parameter block that is passed in.
Table 11.7. Input and Output Parameters Available to a Matching Rule Plug-in Initialization Function
| Parameter Name | Data Type | Description |
|---|---|---|
SLAPI_PLUGIN_ARGC | int | Input parameter. Number of arguments in the plugin directive, not including the library name and initialization function name. |
SLAPI_PLUGIN_ARGV | char ** | Input parameter. Array of string arguments in the plugin directive, not including the library name and initialization function name. |
SLAPI_PLUGIN_MR_FILTER_CREATE_FN | void * (function pointer) | Output parameter. The factory function used for creating filters. |
SLAPI_PLUGIN_MR_INDEXER_CREATE_FN | void * (function pointer) | Output parameter. The factory function used for creating indexers. |
SLAPI_PLUGIN_CLOSE_FN | void * (function pointer) | Output parameter. The close function, which the server calls before shutting down. |
SLAPI_PLUGIN_PRIVATE | void * | Output parameter. Pointer to any private data you want passed to your plug-in functions. |

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.