48.2. slapi_register_object_extension()

Description

When a plug-in is initialized, it must register its object extensions. It must provide the name of the object to be extended, e.g., Operation, and constructor and destructor functions. These functions are called when the object is constructed and destroyed. The extension functions must allocate some memory and initialize it for its own use. The registration function will fail if any objects have already been created; this is why the registration must happen during plug-in initialization. In return, the plug-in will receive two handles, one for the object type and another one for the object extension; these only have meaning for the slapi_get_object_extension() function.

Syntax

#include "slapi-plugin.h"
int slapi_register_object_extension( const char *pluginname, const char *objectname, 
 slapi_extension_constructor_fnptr constructor, slapi_extension_destructor_fnptr destructor,  
 int *objecttype, int *extensionhandle);

Parameters

This function takes the following parameters:

pluginname
Plug-in name.
objectname
The name of the core server object to be extended. Objects that can be extended (possible values for the objectname parameter):
  • SLAPI_EXT_CONNECTION (Connection)
  • SLAPI_EXT_OPERATION (Operation)
  • SLAPI_EXT_ENTRY (Entry)
  • SLAPI_EXT_MTNODE (Mapping Tree Node)
Currently, only Operation and Connection are supported.
constructor
The function provided by the plug-in which is to be called when an instance of the core server object is created. This function must allocate some memory and return a pointer to be stored in the extension block on the object.
destructor
The function which is called when an instance of an object is destroyed. This function must release any resources acquired by the constructor function.
objecttype
Handle to find the offset into the object where the extension block is stored.
extensionhandle
Address, which is used to find the extension within the block.
Returns

This function returns 0 if successful, error code otherwise.