#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "asterisk/options.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/astdb.h"
#include "asterisk/lock.h"
Include dependency graph for app_db.c:
Go to the source code of this file.
Functions | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Database Access Functions") | |
static int | del_exec (struct ast_channel *chan, void *data) |
static int | deltree_exec (struct ast_channel *chan, void *data) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static char * | d_app = "DBdel" |
static char * | d_descrip |
static char * | d_synopsis = "Delete a key from the database" |
static char * | dt_app = "DBdeltree" |
static char * | dt_descrip |
static char * | dt_synopsis = "Delete a family or keytree from the database" |
Definition in file app_db.c.
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Database Access Functions" | ||||
) |
static int del_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 109 of file app_db.c.
References ast_db_del(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_verbose(), ast_module_user::chan, LOG_DEBUG, LOG_WARNING, option_verbose, strsep(), and VERBOSE_PREFIX_3.
Referenced by load_module().
00110 { 00111 char *argv, *family, *key; 00112 struct ast_module_user *u; 00113 static int deprecation_warning = 0; 00114 00115 u = ast_module_user_add(chan); 00116 00117 if (!deprecation_warning) { 00118 deprecation_warning = 1; 00119 ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n"); 00120 } 00121 00122 argv = ast_strdupa(data); 00123 00124 if (strchr(argv, '/')) { 00125 family = strsep(&argv, "/"); 00126 key = strsep(&argv, "\0"); 00127 if (!family || !key) { 00128 ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); 00129 ast_module_user_remove(u); 00130 return 0; 00131 } 00132 if (option_verbose > 2) 00133 ast_verbose(VERBOSE_PREFIX_3 "DBdel: family=%s, key=%s\n", family, key); 00134 if (ast_db_del(family, key)) { 00135 if (option_verbose > 2) 00136 ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n"); 00137 } 00138 } else { 00139 ast_log(LOG_DEBUG, "Ignoring, no parameters\n"); 00140 } 00141 00142 ast_module_user_remove(u); 00143 00144 return 0; 00145 }
static int deltree_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 68 of file app_db.c.
References ast_db_deltree(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_strlen_zero(), ast_verbose(), ast_module_user::chan, LOG_DEBUG, option_verbose, strsep(), and VERBOSE_PREFIX_3.
Referenced by load_module().
00069 { 00070 char *argv, *family, *keytree; 00071 struct ast_module_user *u; 00072 00073 u = ast_module_user_add(chan); 00074 00075 argv = ast_strdupa(data); 00076 00077 if (strchr(argv, '/')) { 00078 family = strsep(&argv, "/"); 00079 keytree = strsep(&argv, "\0"); 00080 if (!family || !keytree) { 00081 ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); 00082 ast_module_user_remove(u); 00083 return 0; 00084 } 00085 if (ast_strlen_zero(keytree)) 00086 keytree = 0; 00087 } else { 00088 family = argv; 00089 keytree = 0; 00090 } 00091 00092 if (option_verbose > 2) { 00093 if (keytree) 00094 ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: family=%s, keytree=%s\n", family, keytree); 00095 else 00096 ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: family=%s\n", family); 00097 } 00098 00099 if (ast_db_deltree(family, keytree)) { 00100 if (option_verbose > 2) 00101 ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: Error deleting key from database.\n"); 00102 } 00103 00104 ast_module_user_remove(u); 00105 00106 return 0; 00107 }
static int load_module | ( | void | ) | [static] |
Definition at line 157 of file app_db.c.
References ast_register_application(), del_exec(), and deltree_exec().
00158 { 00159 int retval; 00160 00161 retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip); 00162 retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip); 00163 00164 return retval; 00165 }
static int unload_module | ( | void | ) | [static] |
Definition at line 147 of file app_db.c.
References ast_unregister_application().
00148 { 00149 int retval; 00150 00151 retval = ast_unregister_application(dt_app); 00152 retval |= ast_unregister_application(d_app); 00153 00154 return retval; 00155 }
char* d_descrip [static] |
char* d_synopsis = "Delete a key from the database" [static] |
char* dt_descrip [static] |
char* dt_synopsis = "Delete a family or keytree from the database" [static] |