libamxb
4.8.2
Bus Agnostic C API
|
Functions | |
int | amxb_be_register (amxb_be_funcs_t *const funcs) |
Registers backend interface. More... | |
int | amxb_be_unregister (amxb_be_funcs_t *const funcs) |
Unregisters a backend interface. More... | |
amxb_be_funcs_t * | amxb_be_find (const char *name) |
Gets a backend function table using its name. More... | |
const amxb_be_info_t * | amxb_be_get_info (const char *name) |
Gets a backend information. More... | |
int | amxb_be_load (const char *path_name) |
Loads a shared object that implements a bus specific backend interface. More... | |
int | amxb_be_load_multiple (amxc_var_t *const bes) |
Loads multiple shared objects that each implement a bus specific backend interface. More... | |
int | amxb_be_remove (const char *backend_name) |
Removes and unloads a backend with a given name. More... | |
void | amxb_be_remove_all (void) |
Removes and unloads all backends. More... | |
amxc_array_t * | amxb_be_list (void) |
Get the loaded back-end names. More... | |
int | amxb_be_for_all_connections (amxb_be_task_fn_t fn, const amxc_var_t *args, void *priv) |
Calls a function on all open connections. More... | |
int | amxb_be_for_all_listeners (amxb_be_task_fn_t fn, const amxc_var_t *args, void *priv) |
Calls a function on all listen sockets. More... | |
amxb_bus_ctx_t * | amxb_be_who_has (const char *object_path) |
Searches a bus context that can provide a certain object. More... | |
void | amxb_be_cache_remove_ctx (amxb_bus_ctx_t *ctx) |
Removes a bus context from the lookup cache. More... | |
void | amxb_be_cache_remove_path (const char *object_path) |
Removes an object path and its corresponding bus context from the lookup cache. More... | |
void | amxb_be_cache_set_size (uint32_t size) |
Changes the size of the lookup cache. More... | |
int | amxb_set_config (amxc_var_t *const configuration) |
Passes configuration options to the backends. More... | |
int | amxb_check_version (const amxb_version_t *be_version) |
Compares the given version with the library version. More... | |
int | amxb_check_be_versions (const amxb_version_t *min, const amxb_version_t *max) |
Checks if the library version is in the given range. More... | |
const amxb_version_t * | amxb_get_version (void) |
Gets the version of the library. More... | |
void amxb_be_cache_remove_ctx | ( | amxb_bus_ctx_t * | ctx | ) |
Removes a bus context from the lookup cache.
Bus contexts are added to the lookup cache by amxb_be_who_has
ctx | a bus context |
Definition at line 654 of file amxb_backend_mngr.c.
void amxb_be_cache_remove_path | ( | const char * | object_path | ) |
Removes an object path and its corresponding bus context from the lookup cache.
Bus contexts are added to the lookup cache by amxb_be_who_has
object_path | Object path that must be removed from the cache |
Definition at line 670 of file amxb_backend_mngr.c.
void amxb_be_cache_set_size | ( | uint32_t | size | ) |
Changes the size of the lookup cache.
Bus contexts are added to the lookup cache by amxb_be_who_has.
When the new size is smaller then the current size, the oldes entries are removed from the cache.
size | the new size |
Definition at line 689 of file amxb_backend_mngr.c.
amxb_be_funcs_t* amxb_be_find | ( | const char * | name | ) |
Gets a backend function table using its name.
This function is mainly used internally to fetch the function table of a specific backend.
name | name of the backend |
Definition at line 432 of file amxb_backend_mngr.c.
int amxb_be_for_all_connections | ( | amxb_be_task_fn_t | fn, |
const amxc_var_t * | args, | ||
void * | priv | ||
) |
Calls a function on all open connections.
Loops over all backends and calls a functions for each open connection for the backend.
fn | function to be called |
args | a variant that is passed to the function |
priv | some private data, is passed as is to the function |
Definition at line 610 of file amxb_backend_mngr.c.
int amxb_be_for_all_listeners | ( | amxb_be_task_fn_t | fn, |
const amxc_var_t * | args, | ||
void * | priv | ||
) |
Calls a function on all listen sockets.
Loops over all backends and calls a functions for each listen socket for the backend.
fn | function to be called |
args | a variant that is passed to the function |
priv | some private data, is passed as is to the function |
Definition at line 631 of file amxb_backend_mngr.c.
const amxb_be_info_t* amxb_be_get_info | ( | const char * | name | ) |
Gets a backend information.
Fetches some meta-information from the backend.
name | name of the backend |
Definition at line 448 of file amxb_backend_mngr.c.
amxc_array_t* amxb_be_list | ( | void | ) |
Get the loaded back-end names.
This function returns an array of pointers to the loaded back-end names. You can iterate over this array using a simple for loop.
Example:
The array must be freed when not needed any more, use amxc_array_delete
.
amxc_array_delete
.Definition at line 606 of file amxb_backend_mngr.c.
int amxb_be_load | ( | const char * | path_name | ) |
Loads a shared object that implements a bus specific backend interface.
Loads a shared object into memory using dlopen. It is assumed that the shared object provides a backend interface implementation.
The symbol "amxb_be_info" is resolved using dlsym. If the shared object does not contain this symbol, the shared object is closed and the loading fails.
The function "amxb_be_info" is called and must return a backend information structure which must contain the minimum and maximum supported version of this library. If the version of this library is not within the range, the shared object is closed and loading fails.
path_name | absolute or relative path to a shared object that implements a backend interface |
Definition at line 470 of file amxb_backend_mngr.c.
int amxb_be_load_multiple | ( | amxc_var_t *const | bes | ) |
Loads multiple shared objects that each implement a bus specific backend interface.
The variant may contain a string or a linked list.
When the variant contains a string it will be split using ':' as a separator. Each individual part is assumed to be an absolute or relative path to a shared object file.
If it is a variant containing a list of variants, each variant in the list must contain an absolute or relative path to a shared object file.
When one or more shared objects can not be loaded, the function will load all other shared objects.
bes | list of backends |
Definition at line 536 of file amxb_backend_mngr.c.
int amxb_be_register | ( | amxb_be_funcs_t *const | funcs | ) |
Registers backend interface.
Backend can call this function to register the function table (backend interface) in a constructor function.
The preferred solution however is backend provides the function table using "amxb_be_info" which returns the backend information, this information may contain the function table.
The function table must contain at least:
When the backend provides the function "set_config" it will be called if backend specific configuration options are available.
funcs | The back-end function table |
Definition at line 372 of file amxb_backend_mngr.c.
int amxb_be_remove | ( | const char * | backend_name | ) |
Removes and unloads a backend with a given name.
Before the backend is unloaded all connections that are opened using that backend are closed.
All bus contexts related to that backend will be invalid after this function call.
backend_name | name of the backend |
Definition at line 578 of file amxb_backend_mngr.c.
void amxb_be_remove_all | ( | void | ) |
Removes and unloads all backends.
Before the backends are unloaded all connections are closed
Typically this function is used just before the application exits.
Definition at line 602 of file amxb_backend_mngr.c.
int amxb_be_unregister | ( | amxb_be_funcs_t *const | funcs | ) |
Unregisters a backend interface.
A backend can call this function to remove the function table (backend interface) in a destructor function.
However this is not recommended. The backend will be unloaded from memory when it is not required anymore using the function amxb_be_remove or amxb_be_remove_all.
When a backend's function table is unregistered all open connections for that backend will be closed before the function table is removed.
funcs | The back-end function table |
Definition at line 406 of file amxb_backend_mngr.c.
amxb_bus_ctx_t* amxb_be_who_has | ( | const char * | object_path | ) |
Searches a bus context that can provide a certain object.
Invoke a describe on all open connections (bus contexts), the first bus context that can provide the object is returned.
If a bus context is found, it is stored in a lookup cache. When this method is called again with same object path, the bus context is retrieved from the cache.
The lookup cache is limited in size (default 5 entries), but can be changed by calling amxb_be_cache_set_size.
object_path | an object path |
Definition at line 650 of file amxb_backend_mngr.c.
int amxb_check_be_versions | ( | const amxb_version_t * | min, |
const amxb_version_t * | max | ||
) |
Checks if the library version is in the given range.
min | the minimum version |
max | the maximum version |
Definition at line 339 of file amxb_backend_mngr.c.
int amxb_check_version | ( | const amxb_version_t * | be_version | ) |
Compares the given version with the library version.
be_version | the version that must be compared with the library version |
Definition at line 311 of file amxb_backend_mngr.c.
const amxb_version_t* amxb_get_version | ( | void | ) |
Gets the version of the library.
Definition at line 362 of file amxb_backend_mngr.c.
int amxb_set_config | ( | amxc_var_t *const | configuration | ) |
Passes configuration options to the backends.
The configuration must be a variant containing a hash table. If in the hash table a key is found with the name of a loaded backend, the value of that key is passed to the backend. The value itself can also be a hash table.
When passing a NULL pointer the configuration is reset for all backends
configuration | a hash table variant with configuration options |
Definition at line 707 of file amxb_backend_mngr.c.