Functions for interaction with the Asterisk database.
More...
Go to the source code of this file.
|
static void | __reg_module (void) |
|
static void | __unreg_module (void) |
|
struct ast_module * | AST_MODULE_SELF_SYM (void) |
|
static int | function_db_delete (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len) |
|
static int | function_db_delete_write (struct ast_channel *chan, const char *cmd, char *parse, const char *value) |
| Wrapper to execute DB_DELETE from a write operation. Allows execution even if live_dangerously is disabled. More...
|
|
static int | function_db_exists (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len) |
|
static int | function_db_keys (struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **result, ssize_t maxlen) |
|
static int | function_db_read (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len) |
|
static int | function_db_write (struct ast_channel *chan, const char *cmd, char *parse, const char *value) |
|
static int | load_module (void) |
|
static int | unload_module (void) |
|
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Database (astdb) related dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
static struct ast_custom_function | db_delete_function |
|
static struct ast_custom_function | db_exists_function |
|
static struct ast_custom_function | db_function |
|
static struct ast_custom_function | db_keys_function |
|
Functions for interaction with the Asterisk database.
- Author
- Russell Bryant russe.nosp@m.lb@c.nosp@m.lemso.nosp@m.n.ed.nosp@m.u
Definition in file func_db.c.
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ AST_MODULE_SELF_SYM()
◆ function_db_delete()
static int function_db_delete |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Definition at line 283 of file func_db.c.
References args, AST_APP_ARG, ast_db_del(), ast_db_get(), ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, ast_strlen_zero, LOG_WARNING, and pbx_builtin_setvar_helper().
Referenced by function_db_delete_write().
306 ast_debug(1,
"DB_DELETE: %s/%s not found in database.\n",
args.family,
args.key);
309 ast_debug(1,
"DB_DELETE: %s/%s could not be deleted from the database\n",
args.family,
args.key);
#define ast_strlen_zero(foo)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
◆ function_db_delete_write()
static int function_db_delete_write |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
const char * |
value |
|
) |
| |
|
static |
Wrapper to execute DB_DELETE from a write operation. Allows execution even if live_dangerously is disabled.
Definition at line 322 of file func_db.c.
References buf, and function_db_delete().
static int function_db_delete(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static void parse(struct mgcp_request *req)
◆ function_db_exists()
static int function_db_exists |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Definition at line 190 of file func_db.c.
References args, AST_APP_ARG, ast_db_get(), AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, ast_strlen_zero, LOG_WARNING, and pbx_builtin_setvar_helper().
#define ast_strlen_zero(foo)
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
◆ function_db_keys()
static int function_db_keys |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
struct ast_str ** |
result, |
|
|
ssize_t |
maxlen |
|
) |
| |
|
static |
Definition at line 228 of file func_db.c.
References ast_db_freetree(), ast_db_gettree(), ast_free, ast_str_append(), ast_str_append_escapecommas(), ast_str_reset(), escape_buf, ast_db_entry::key, last, ast_db_entry::next, and NULL.
230 size_t parselen = strlen(
parse);
233 const char *
last =
"";
236 while (
parse[0] ==
'/') {
240 while (
parse[parselen - 1] ==
'/') {
241 parse[--parselen] =
'\0';
251 for (; dbe; dbe = dbe->
next) {
253 char *curkey = &dbe->
key[parselen + 1], *slash;
254 if (*curkey ==
'/') {
258 if ((slash = strchr(curkey,
'/'))) {
263 if (!strcasecmp(last, curkey)) {
268 if (orig_dbe != dbe) {
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
char * ast_str_append_escapecommas(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Append a non-NULL terminated substring to the end of a dynamic string, with escaping of commas...
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
struct ast_db_entry * next
struct sla_ringing_trunk * last
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
static void parse(struct mgcp_request *req)
static struct ast_threadstorage escape_buf
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
◆ function_db_read()
static int function_db_read |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Definition at line 126 of file func_db.c.
References args, AST_APP_ARG, ast_db_get(), ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, ast_strlen_zero, LOG_WARNING, and pbx_builtin_setvar_helper().
#define ast_strlen_zero(foo)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void parse(struct mgcp_request *req)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
◆ function_db_write()
static int function_db_write |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
const char * |
value |
|
) |
| |
|
static |
Definition at line 157 of file func_db.c.
References args, AST_APP_ARG, ast_db_put(), AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_APP_ARGS, ast_strlen_zero, and LOG_WARNING.
#define ast_strlen_zero(foo)
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static void parse(struct mgcp_request *req)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
Definition at line 348 of file func_db.c.
References AST_CFE_BOTH, AST_CFE_READ, ast_custom_function_register, and ast_custom_function_register_escalating.
static struct ast_custom_function db_delete_function
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
static struct ast_custom_function db_keys_function
static struct ast_custom_function db_exists_function
#define ast_custom_function_register(acf)
Register a custom function.
static struct ast_custom_function db_function
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
Definition at line 336 of file func_db.c.
References ast_custom_function_unregister().
static struct ast_custom_function db_delete_function
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static struct ast_custom_function db_keys_function
static struct ast_custom_function db_exists_function
static struct ast_custom_function db_function
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Database (astdb) related dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static |
◆ ast_module_info
◆ db_delete_function
Initial value:= {
.name = "DB_DELETE",
}
static int function_db_delete(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int function_db_delete_write(struct ast_channel *chan, const char *cmd, char *parse, const char *value)
Wrapper to execute DB_DELETE from a write operation. Allows execution even if live_dangerously is dis...
Definition at line 330 of file func_db.c.
◆ db_exists_function
Initial value:= {
.name = "DB_EXISTS",
.read_max = 2,
}
static int function_db_exists(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition at line 222 of file func_db.c.
◆ db_function
Initial value:= {
.name = "DB",
}
static int function_db_write(struct ast_channel *chan, const char *cmd, char *parse, const char *value)
static int function_db_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition at line 184 of file func_db.c.
◆ db_keys_function
Initial value:= {
.name = "DB_KEYS",
}
static int function_db_keys(struct ast_channel *chan, const char *cmd, char *parse, struct ast_str **result, ssize_t maxlen)
Definition at line 278 of file func_db.c.