9.2. Writing Entry Store/Fetch Functions

Unlike most other types of plug-in functions, a parameter block is not passed to entry store and entry fetch plug-in functions when they are called. Instead, entry store and entry fetch plug-in functions must have the following prototype:
void function_name( char **entry, unsigned long *len );
The function parameters are described below:
  • entry — Pointer to a string specifying the entry in LDIF format; for details on this format, see slapi_str2entry() and slapi_entry2str().
  • len — Pointer to the length of the entry string.
Because the text of the entry is passed in as an argument, you can modify the entry before it gets saved to disk and modify the entry after it is read from disk. The pointer can be reallocated to get more room. For example:
  void my_entry_fetch( char **entry, unsigned long *len )
  {
    ...
    *len = newsize;
    *entry = slapi_ch_realloc(*entry, (*len) * sizeof(char));
    ... append to *entry ...
  }
The server calls slapi_ch_free() to free the memory, so to allocate more memory, use one of the slapi memory allocation functions.

Note

The testentry.c sample file has example entry store and entry fetch plug-in functions. This example file is with other examples in the /usr/lib64/dirsrv/plugins directory.