HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
11.5 Handling sorting by matching rules
If you have set up indexing by a matching rule, you can also sort search results by that matching
rule. The server can use the keys in the index to sort the search results.
When processing a request to sort by a matching rule, the server does the following:
1. In a new Slapi_PBlock parameter block, the server sets the following parameters:
Sets the OID in the SLAPI_PLUGIN_MR_OID parameter.
Sets the attribute type (of the value being added, modified, or removed) in the
SLAPI_PLUGIN_MR_TYPE parameter.
Sets the SLAPI_PLUGIN_MR_USAGE parameter to SLAPI_PLUGIN_MR_USAGE_SORT.
(This indicates that the created indexer object will be used for sorting, not indexing.)
2. The server then calls the indexer factory function (specified in the
SLAPI_PLUGIN_MR_INDEXER_CREATE_FN parameter) for the plug-in.
3. The server generates the index keys for the values to be sorted:
The server sets the SLAPI_PLUGIN_MR_VALUES parameter to the array of berval
structures containing the values to be sorted.
The server calls the indexer function (specified by the SLAPI_PLUGIN_MR_INDEXER_FN
parameter).
The server then gets the value of the SLAPI_PLUGIN_MR_KEYS parameter, which is
an array of berval structures containing the keys corresponding to the values.
4. The server compares the keys to sort the results.
11.6 Writing a destructor function
The server calls the destructor function to free any memory that was allocated; for example, to
the indexer object or the filter object.
The destructor function takes a single Slapi_PBlock argument. The following table summarizes
the different parameters that the destructor function should get and set in the parameter block
that is passed in.
Table 11-6 Input and output parameters available to a destructor function
DescriptionData typeParameter name
Input parameter. Pointer to the filter object or
indexer object created by your factory function.
void *SLAPI_PLUGIN_OBJECT
For example, your destructor function can get the indexer object from the
SLAPI_PLUGIN_OBJECT parameter and free the object from memory.
This function will never be called for the same indexer or filter object concurrently. (If you plan
to manipulate global variables, remember that the server can call this function concurrently for
different filter or indexer objects.)
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 “How the server associates plug-ins with OIDs”, for details.
98 Writing matching rule plug-ins