Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "asterisk.h"
00032
00033 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 154542 $")
00034
00035 #include "asterisk/file.h"
00036 #include "asterisk/channel.h"
00037 #include "asterisk/pbx.h"
00038 #include "asterisk/module.h"
00039 #include "asterisk/astdb.h"
00040 #include "asterisk/lock.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 static char *d_app = "DBdel";
00084 static char *dt_app = "DBdeltree";
00085
00086 static int deltree_exec(struct ast_channel *chan, void *data)
00087 {
00088 char *argv, *family, *keytree;
00089
00090 argv = ast_strdupa(data);
00091
00092 if (strchr(argv, '/')) {
00093 family = strsep(&argv, "/");
00094 keytree = strsep(&argv, "\0");
00095 if (!family || !keytree) {
00096 ast_debug(1, "Ignoring; Syntax error in argument\n");
00097 return 0;
00098 }
00099 if (ast_strlen_zero(keytree))
00100 keytree = 0;
00101 } else {
00102 family = argv;
00103 keytree = 0;
00104 }
00105
00106 if (keytree)
00107 ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
00108 else
00109 ast_verb(3, "DBdeltree: family=%s\n", family);
00110
00111 if (ast_db_deltree(family, keytree))
00112 ast_verb(3, "DBdeltree: Error deleting key from database.\n");
00113
00114 return 0;
00115 }
00116
00117 static int del_exec(struct ast_channel *chan, void *data)
00118 {
00119 char *argv, *family, *key;
00120 static int deprecation_warning = 0;
00121
00122 if (!deprecation_warning) {
00123 deprecation_warning = 1;
00124 ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
00125 }
00126
00127 argv = ast_strdupa(data);
00128
00129 if (strchr(argv, '/')) {
00130 family = strsep(&argv, "/");
00131 key = strsep(&argv, "\0");
00132 if (!family || !key) {
00133 ast_debug(1, "Ignoring; Syntax error in argument\n");
00134 return 0;
00135 }
00136 ast_verb(3, "DBdel: family=%s, key=%s\n", family, key);
00137 if (ast_db_del(family, key))
00138 ast_verb(3, "DBdel: Error deleting key from database.\n");
00139 } else {
00140 ast_debug(1, "Ignoring, no parameters\n");
00141 }
00142
00143 return 0;
00144 }
00145
00146 static int unload_module(void)
00147 {
00148 int retval;
00149
00150 retval = ast_unregister_application(dt_app);
00151 retval |= ast_unregister_application(d_app);
00152
00153 return retval;
00154 }
00155
00156 static int load_module(void)
00157 {
00158 int retval;
00159
00160 retval = ast_register_application_xml(d_app, del_exec);
00161 retval |= ast_register_application_xml(dt_app, deltree_exec);
00162
00163 return retval;
00164 }
00165
00166 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Database Access Functions");