odbx_init(3) | OpenDBX | odbx_init(3) |
odbx_init - Allocate per connection data structures
#include <opendbx/api.h>
int odbx_init
(odbx_t** handle, const char* backend, const char* host,
const char* port);
odbx_init() allocates and initializes an opaque object required for all further operations within the OpenDBX library which is used to identify the connection and to maintain per connection information. Depending on the backend it can open a connection to the database server but often this is done not until performing authentication through odbx_bind().
The pointer of the newly allocated connection object is stored in handle if odbx_init() completes successfully. Otherwise, the value of the handle variable will be undefined and must not be used as input for other functions of the library. The returned connection object must be freed by odbx_finish() to avoid memory leaks if it will be no longer used by the application.
The OpenDBX library provides access to several different database implementations through a single interface and therefore has to know which one of the available backend modules it should use for the operations. The backend parameter will be used to perform the lookup of the requested module. It has to be a zero-terminated ASCII string with all characters in in lower case. Currently, these backend modules are available:
Connecting to a database server requires at least an identifier to know where the database is located. There are several kinds of identifiers like host names, IP addresses, named pipes, etc. which could be used. One of them can be provided via the host parameter and it is up to the native database library what it will accept. Most native libraries accept at least host names and IP addresses and also use the provided port in this case. The available methods for host are:
Depending on the native database library, it's also possible to use database specific default values for the host and port parameters by supplying empty, zero-terminated strings or a NULL value.
odbx_init() returns ODBX_ERR_SUCCESS, or an error code whose value is less than zero if one of the operations couldn't be completed successfully. Possible error codes are listed in the error section and they can be feed to odbx_error() and odbx_error_type() to get further details.
odbx_bind(), odbx_capabilities(), odbx_error(), odbx_finish(), odbx_get_option(), odbx_set_option()
20 November 2020 |