A bunny plugin is not a simple dynamic library.
To be a valid bunny plugin, a dynamic library must
implement a __get_function_list function of type
t_bunny_get_function_list.
This function must return an array of t_bunny_prototype that should
be statically allocated. The array must be terminated by a t_bunny_prototype
with NULL stored inside function_ptr.
Prototypes described inside this array must match the real definition
of functions or your program will crash when a function will be incorrectly
called, matching its description but not its real type.
The plugin module header is lapin/container/plugin.h.
typedef enum e_bunny_value_type
{
 
BVT_VOID =
'v',
 
BVT_INTEGER =
'i',
 
BVT_DOUBLE =
'd',
 
BVT_STRING =
's',
 
BVT_POINTER =
'p',
}
t_bunny_value_type;
INDEX
k
typedef union u_bunny_value
{
 
int64_t integer;
 
double real;
 
const char *
string;
 
void *
any;
}
t_bunny_value;
INDEX
Description
  This structure represents a single function loaded from a dynamic library
that match the bunny plugin format. It can be called by using
bunny_plugin_call
with its
name used as
funcname.
Attributes
-
const char *name:
  The name of the function represented by this structure.
-
const void *function_ptr:
  The address of the function in memory.
-
t_bunny_value_type return_value:
  The type of the returned value of the represented function.
-
size_t nbrparam:
  The quantity of parameters the function takes. This is also
the size in elements of the attribute parameters.
-
t_bunny_value_type parameters[]:
  An array of nbrparam elements, which indicates which types
are expected when calling the function represented by this structure.
INDEX
Description
  This structure represents a loaded dynamic library which match the
bunny plugin format.
Attributes
-
const char * const name:
  The name of the file containing the loaded library.
-
const void * const library_handler:
  The library itself, loaded into memory.
-
const size_t nbr_functions:
  The size of the prototypes array in elements.
-
const t_bunny_prototype prototypes[]:
  All functions in the loaded plugin that was returned
by the bunny plugin interface.
INDEX
Description
  Load the sent dynamic library and functions inside.
Parameters
-
const char *libfile:
  A dynamic library file, which respect the bunny plugin format.
Error values and logs
On error, $Vbunny_errno is set to:
-
EINVAL:
Cannot open the sent file, or the sent dynamic library
does not contains the function __get_function_list which is mandatory
for a bunny plugin.
-
ENOMEM:
Out of memory.
-
BE_CONFIGURED_FUNCTION_NOT_FOUND:
A function present in the bunny plugin table was not
found in the loaded plugin.
-
BE_TOO_MANY_PARAMETERS:
Functions in bunny plugin can only have up to 4 parameters.
Logs written by this function are tagged with the "ressource" and
"plugin" label.
INDEX
Description
  Delete the sent plugin.
INDEX
Description
  Return a function pointer from the library represented by plugin,
even if it is not part of the bunny plugin interface: any function
inside the library can be requested.
Parameters
-
const t_bunny_plugin *plugin:
  The dynamic library in which funcname is.
-
const char *funcname:
  The name of the function you want to fetch.
Return value
-
On success, the function returns the address of the requested
function. You have to cast it yourself into the correct type.
-
On failure, it returns NULL.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "plugin" label.
INDEX
Description
  Call funcname, a bunny plugin function from plugin with param_len
parameters from the array params and store the returned value inside
return_value.
Parameters
-
t_bunny_plugin *plugin:
  The dynamic library in which funcname is.
-
const char *funcname:
  The name of the function you want to call
-
t_bunny_value *return_value:
  A space where to store the value that was returned by funcname.
-
size_t param_len:
  How many parameters there is inside params.
-
t_bunny_value *params:
  Parameters to give to funcname.
Return value
Return true if the function was found and called.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "plugin" label.
INDEX
Description
  Call
funcname, a bunny plugin function from
plugin with parameters
from ... variadic parameters and store the returned value inside
return_value.
... variadic parameters are read thanks to the description of
funcname registered inside plugin. Watch what you send!
It should be only made of t_bunny_value with specific fields written.
Parameters
-
t_bunny_plugin *plugin:
  The dynamic library in which funcname is.
-
const char *funcname:
  The name of the function you want to call
-
t_bunny_value *return_value:
  A space where to store the value that was returned by funcname.
-
...:
  Parameters to send to funcname. Those are reads after the
description of the function prototype of funcname, described
in a t_bunny_prototype stored inside plugin.
Those parameters should all be t_bunny_value. Some systems
may make lucky conversion from native types to a union compatible
format, but I currently cannot guarantee it, because I consider
I did not have tested it enough.
Return value
Return true if the function was found and called.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the "plugin" label.
INDEX