Database Independent Abstraction Layer for C: libdbi Plugin Author's Guide | ||
---|---|---|
Prev | Chapter 2. Plugin Functions | Next |
void dbd_register_plugin(const dbi_info_t **_plugin_info, const char ***_custom_functions, const char ***_reserved_words) |
This is the first function called after the plugin module is loaded into memory. It passes back meta-information back to libdbi through the pointers passed as arguments.
_plugin_info: A pointer used to link to the plugin's information struct.
_custom_functions: A pointer used to link to the plugin's string array of custom database-specific functions.
_reserved_words: A pointer used to link to the plugin's string array of reserved words.
int dbd_initialize(dbi_plugin_t *plugin) |
Performs any database-specific server initialization. This is called right after dbd_register_plugin().
plugin: The plugin's pointer.
-1 on error, 0 on success. If -1 is returned, the plugin will not be added to the list of available plugins.
int dbd_connect(dbi_driver_t *driver) |
Connects to the database, setting the driver's DB-specific connection handle and current database name. Connection parameters are already filled through the driver's option settings. The standard options that all plugins must recognize (if applicable) are: host, username, password, dbname, and port. Any plugin-specific functions must be prefixed with the name of the plugin and an underscore, such as "mysql_compression".
driver: The target driver instance of the plugin.
-1 on error, 0 on success.
int dbd_disconnect(dbi_driver_t *driver) |
Disconnects from the database server.
driver: The target driver instance of the plugin.
-1 on error, 0 on success.
int dbd_quote_string(dbi_plugin_t *plugin, const char *orig, char *dest) |
Given a string, wrap quotes around that string and escape any characters that the database server needs escaped.
plugin: A pointer to the plugin itself, which may be useful in weird cases.
orig: The string to quote and escape.
dest: The destination for the new string, which is already allocated as (strlen(orig)*2)+4+1. In the worst case, each character will need to be escaped, with two quote characters at both the beginning and end of the string, plus one for the terminating NULL.
The length of the new string.
int dbd_geterror(dbi_driver_t *driver, int *errno, char **errstr) |
Retrieves and stores error information, in numeric and/or string format.
driver: The target driver.
errno: The int variable to hold the error number.
errstr: The string to hold the error description.
0 if there was an error, 1 if errno was filled, 2 if errstr was filled, 3 if both errno and errstr were filled.