Groonga supports plugin. You can create a new plugin with the following API.
TOOD: Describe about how to create the minimum plugin here or create a tutorial about it.
GRN_PLUGIN_MALLOC() allocates size bytes and returns a pointer to the allocated memory space. Note that the memory space is associated with ctx.
GRN_PLUGIN_REALLOC() resizes the memory space pointed to by ptr or allocates a new memory space of size bytes. GRN_PLUGIN_REALLOC() returns a pointer to the memory space. The contents is unchanged or copied from the old memory space to the new memory space.
GRN_PLUGIN_FREE() frees a memory space allocated by GRN_PLUGIN_MALLOC() or GRN_PLUGIN_REALLOC(). This means that ptr must be a pointer returned by GRN_PLUGIN_MALLOC() or GRN_PLUGIN_REALLOC().
GRN_PLUGIN_LOG() reports a log of level. Its error message is generated from the varying number of arguments, in which the first one is the format string and the rest are its arguments. See grn_log_level in "groonga.h" for more details of level.
GRN_PLUGIN_ERROR() reports an error of error_code. Its error message is generated from the varying number of arguments, in which the first one is the format string and the rest are its arguments. See grn_rc in "groonga.h" for more details of error_code.
grn_plugin_mutex is available to make a critical section. See the following functions.
grn_plugin_mutex_open() returns a pointer to a new object of grn_plugin_mutex. Memory for the new object is obtained with GRN_PLUGIN_MALLOC(). grn_plugin_mutex_open() returns NULL if sufficient memory is not available.
grn_plugin_mutex_close() finalizes an object of grn_plugin_mutex and then frees memory allocated for that object.
grn_plugin_mutex_lock() locks a mutex object. If the object is already locked, the calling thread waits until the object will be unlocked.
grn_plugin_mutex_unlock() unlocks a mutex object. grn_plugin_mutex_unlock() should not be called for an unlocked object.
grn_plugin_proc_alloc() allocates a grn_obj object. You can use it in function that is registered as GRN_PROC_FUNCTION.
It gets a variable value from grn_user_data by specifying the variable name.
Parameters: |
|
---|---|
Returns: | A variable value on success, NULL otherwise. |
It gets a variable value from grn_user_data by specifying the offset position of the variable.
Parameters: |
|
---|---|
Returns: | A variable value on success, NULL otherwise. |
grn_plugin_win32_base_dir() returns the groonga install directory. The install directory is computed from the directory that has groonga.dll. You can use the directory to generate install directory aware path. It only works on Windows. It returns NULL on other platforms.
grn_plugin_charlen() returns the length (#bytes) of the first character in the string specified by str_ptr and str_length. If the starting bytes are invalid as a character, grn_plugin_charlen() returns 0. See grn_encoding in "groonga.h" for more details of encoding.
grn_plugin_isspace() returns the length (#bytes) of the first character in the string specified by str_ptr and str_length if it is a space character. Otherwise, grn_plugin_isspace() returns 0.
It initializes a grn_expr_var.
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS. It doesn't fail. |
It creates a command.
Parameters: |
|
---|---|
Returns: | The created command object if it creates a command successfully, NULL otherwise. See ctx for error details. |