Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Persistent data storage (akin to *doze registry) More...
Go to the source code of this file.
Data Structures | |
struct | ast_db_entry |
Functions | |
int | ast_db_del (const char *family, const char *key) |
Delete entry in astdb. More... | |
int | ast_db_del2 (const char *family, const char *key) |
Same as ast_db_del, but with more stringent error checking. More... | |
int | ast_db_deltree (const char *family, const char *keytree) |
Delete one or more entries in astdb. More... | |
int | ast_db_exists (const char *family, const char *key) |
Check if family/key exitsts. More... | |
void | ast_db_freetree (struct ast_db_entry *entry) |
Free structure created by ast_db_gettree() More... | |
int | ast_db_get (const char *family, const char *key, char *value, int valuelen) |
Get key value specified by family/key. More... | |
int | ast_db_get_allocated (const char *family, const char *key, char **out) |
Get key value specified by family/key as a heap allocated string. More... | |
struct ast_db_entry * | ast_db_gettree (const char *family, const char *keytree) |
Get a list of values within the astdb tree. More... | |
struct ast_db_entry * | ast_db_gettree_by_prefix (const char *family, const char *key_prefix) |
Get a list of values with the given key prefix. More... | |
int | ast_db_put (const char *family, const char *key, const char *value) |
Store value addressed by family/key. More... | |
Persistent data storage (akin to *doze registry)
Definition in file astdb.h.
int ast_db_del | ( | const char * | family, |
const char * | key | ||
) |
Delete entry in astdb.
Definition at line 478 of file main/db.c.
References ast_asprintf, ast_debug, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, db_sync(), dblock, and LOG_WARNING.
Referenced by __expire_registry(), add_cert_key_to_astdb(), ast_privacy_set(), AST_TEST_DEFINE(), auth_exec(), cache_lookup_internal(), cleanup_cert_from_astdb_and_fs(), destroy_all_channels(), dialgroup_refreshdb(), do_register_expire(), dump_queue_members(), function_db_delete(), handle_dbdel(), media_cache_item_del_from_astdb(), media_cache_remove_from_astdb(), mkintf(), process_clearcache(), reload_queue_members(), sorcery_astdb_delete(), stasis_app_device_state_delete(), and update_registry().
int ast_db_del2 | ( | const char * | family, |
const char * | key | ||
) |
Same as ast_db_del, but with more stringent error checking.
Unlike ast_db_del, if the key does not exist in the first place, an error is emitted and -1 is returned.
-1 | An error occured (including key not found to begin with) |
0 | Successfully deleted |
Definition at line 507 of file main/db.c.
References ast_asprintf, ast_db_get(), ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, db_sync(), dblock, LOG_WARNING, and tmp().
Referenced by handle_cli_database_del(), and manager_dbdel().
int ast_db_deltree | ( | const char * | family, |
const char * | keytree | ||
) |
Delete one or more entries in astdb.
If both parameters are NULL, the entire database will be purged. If only keytree is NULL, all entries within the family will be purged. It is an error for keytree to have a value when family is NULL.
-1 | An error occurred |
>= | 0 Number of records deleted |
Definition at line 565 of file main/db.c.
References ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), astdb, create_prefix(), db_sync(), dblock, LOG_WARNING, NULL, and prefix.
Referenced by ast_privacy_reset(), AST_TEST_DEFINE(), cleanup_cert_from_astdb_and_fs(), deinitialize_sorcery(), deltree_exec(), dundi_flush(), handle_cli_database_deltree(), handle_dbdeltree(), iax_provision_reload(), manager_dbdeltree(), media_cache_item_del_from_astdb(), and media_cache_remove_from_astdb().
int ast_db_exists | ( | const char * | family, |
const char * | key | ||
) |
Check if family/key exitsts.
family | |
key |
1 | if family/key exists |
0 | if family/key does not exist or an error occurred |
Definition at line 444 of file main/db.c.
References ast_asprintf, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, dblock, LOG_WARNING, and result.
Referenced by cleanup_cert_from_astdb_and_fs(), and retrieve_cert_from_cache().
void ast_db_freetree | ( | struct ast_db_entry * | entry | ) |
Free structure created by ast_db_gettree()
Definition at line 701 of file main/db.c.
References ast_free, last, and ast_db_entry::next.
Referenced by AST_TEST_DEFINE(), dundi_show_cache(), dundi_show_hints(), function_db_keycount(), function_db_keys(), handle_cli_devstate_list(), handle_cli_presencestate_list(), load_module(), media_cache_item_populate_from_astdb(), media_cache_populate_from_astdb(), populate_cache(), process_clearcache(), reload_queue_members(), sorcery_astdb_retrieve_fields_common(), sorcery_astdb_retrieve_prefix(), sorcery_astdb_retrieve_regex(), and stasis_app_device_states_to_json().
int ast_db_get | ( | const char * | family, |
const char * | key, | ||
char * | value, | ||
int | valuelen | ||
) |
Get key value specified by family/key.
Definition at line 427 of file main/db.c.
References ast_assert, db_get_common(), NULL, and value.
Referenced by ast_db_del2(), ast_pbx_uuid_get(), ast_privacy_check(), AST_TEST_DEFINE(), auth_exec(), blacklist_read(), cache_lookup_internal(), check_access(), create_addr(), custom_devstate_callback(), custom_presence_callback(), database_increment(), destroy_all_channels(), function_db_delete(), function_db_exists(), function_db_read(), handle_dbget(), iax_provision_version(), load_password(), mkintf(), populate_addr(), refresh_all_favorite(), reg_source_db(), retrieve_cert_from_cache(), sorcery_astdb_delete(), sorcery_astdb_update(), and stasis_device_state_cb().
int ast_db_get_allocated | ( | const char * | family, |
const char * | key, | ||
char ** | out | ||
) |
Get key value specified by family/key as a heap allocated string.
Given a family and key, sets out to a pointer to a heap allocated string. In the event of an error, out will be set to NULL. The string must be freed by calling ast_free().
-1 | An error occurred |
0 | Success |
Definition at line 437 of file main/db.c.
References db_get_common(), NULL, and out.
Referenced by AST_TEST_DEFINE(), handle_cli_database_get(), manager_dbget(), media_cache_item_del_from_astdb(), reload_queue_members(), and sorcery_astdb_retrieve_id().
struct ast_db_entry * ast_db_gettree | ( | const char * | family, |
const char * | keytree | ||
) |
Get a list of values within the astdb tree.
If family is specified, only those keys will be returned. If keytree is specified, subkeys are expected to exist (separated from the key with a slash). If subkeys do not exist and keytree is specified, the tree will consist of either a single entry or NULL will be returned.
Resulting tree should be freed by passing the return value to ast_db_freetree() when usage is concluded.
Definition at line 641 of file main/db.c.
References ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, create_prefix(), db_gettree_common(), dblock, LOG_WARNING, NULL, and prefix.
Referenced by AST_TEST_DEFINE(), dundi_show_cache(), dundi_show_hints(), function_db_keycount(), function_db_keys(), handle_cli_devstate_list(), handle_cli_presencestate_list(), load_module(), media_cache_item_populate_from_astdb(), media_cache_populate_from_astdb(), populate_cache(), process_clearcache(), reload_queue_members(), sorcery_astdb_retrieve_fields_common(), sorcery_astdb_retrieve_regex(), and stasis_app_device_states_to_json().
struct ast_db_entry * ast_db_gettree_by_prefix | ( | const char * | family, |
const char * | key_prefix | ||
) |
Get a list of values with the given key prefix.
family | The family to search under |
key_prefix | The key prefix to search under |
NULL | An error occurred |
Definition at line 673 of file main/db.c.
References ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, create_prefix(), db_gettree_common(), dblock, LOG_WARNING, NULL, and prefix.
Referenced by sorcery_astdb_retrieve_prefix().
int ast_db_put | ( | const char * | family, |
const char * | key, | ||
const char * | value | ||
) |
Store value addressed by family/key.
Definition at line 341 of file main/db.c.
References ast_asprintf, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, astdb, db_sync(), dblock, LOG_WARNING, and value.
Referenced by __analog_ss_thread(), add_cert_expiration_to_astdb(), add_cert_key_to_astdb(), ast_privacy_set(), AST_TEST_DEFINE(), asterisk_daemon(), cache_save(), cache_save_hint(), database_increment(), devstate_write(), dialgroup_refreshdb(), dump_queue_members(), function_db_write(), handle_cli_database_put(), handle_cli_devstate_change(), handle_cli_presencestate_change(), handle_command_response(), handle_dbput(), iax_provision_build(), manager_dbput(), media_cache_item_sync_to_astdb(), metadata_sync_to_astdb(), presence_write(), save_secret(), sorcery_astdb_create(), stasis_app_device_state_update(), and update_registry().