Sets the value of a name-value pair in a parameter block.
#include "slapi-plugin.h" int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
This function takes the following parameters:
Parameter block.
ID of the name-value pair that you want to set. For a list of IDs that you can specify, see Chapter 15, Data Type and Structure Reference
Pointer to the value that you want to set in the parameter block.
This function returns 0 if successful, or -1 if an error occurs (for example, if an invalid ID is specified).
The value to be passed in must always be a pointer, even for integer arguments. For example, if you wanted to do a search with the ManageDSAIT control:
int managedsait = 1; ... slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &managedsait);
A call similar to the following example will cause a crash:
slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, 1);
However, for values which are already pointers such as char * strings , char **arrays,Slapi_Backend *, and so forth, you can pass in the value directly. For example:
char *target_dn = slapi_ch_strdup(some_dn); slapi_pblock_set(pb, SLAPI_TARGET_DN, target_dn);
or
slapi_pblock_set(pb, SLAPI_TARGET_DN, NULL);
With some compilers, you will have to cast the value argument to (void *).
If the caller allocates the memory passed in, the caller is responsible for freeing that memory. Also, it is recommended to use slapi_pblock_get() to retrieve the value to free rather than relying on a potentially dangling pointer. See the slapi_pblock_get() example for more details.
When setting parameters to register a plug-in, the plug-in type must always be set first, since many of the plug-in parameters depend on the type. For example, set the SLAPI_PLUGIN_TYPE to extended operation before setting the list of extended operation OIDs for the plug-in.