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 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <string.h>
00029
00030 #include "asterisk.h"
00031
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00033
00034 #include "asterisk/lock.h"
00035 #include "asterisk/file.h"
00036 #include "asterisk/logger.h"
00037 #include "asterisk/channel.h"
00038 #include "asterisk/pbx.h"
00039 #include "asterisk/module.h"
00040 #include "asterisk/translate.h"
00041 #include "asterisk/options.h"
00042 #include "asterisk/utils.h"
00043 #include "asterisk/app.h"
00044
00045 static char *tdesc = "Send DTMF digits Application";
00046
00047 static char *app = "SendDTMF";
00048
00049 static char *synopsis = "Sends arbitrary DTMF digits";
00050
00051 static char *descrip =
00052 " SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n"
00053 " Accepted digits: 0-9, *#abcd\n"
00054 " The application will either pass the assigned digits or terminate if it\n"
00055 " encounters an error.\n";
00056
00057 STANDARD_LOCAL_USER;
00058
00059 LOCAL_USER_DECL;
00060
00061 static int senddtmf_exec(struct ast_channel *chan, void *data)
00062 {
00063 int res = 0;
00064 struct localuser *u;
00065 char *digits = NULL, *to = NULL;
00066 int timeout = 250;
00067
00068 if (ast_strlen_zero(data)) {
00069 ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00070 return 0;
00071 }
00072
00073 LOCAL_USER_ADD(u);
00074
00075 digits = ast_strdupa(data);
00076 if (!digits) {
00077 ast_log(LOG_ERROR, "Out of Memory!\n");
00078 LOCAL_USER_REMOVE(u);
00079 return -1;
00080 }
00081
00082 if ((to = strchr(digits,'|'))) {
00083 *to = '\0';
00084 to++;
00085 timeout = atoi(to);
00086 }
00087
00088 if(timeout <= 0)
00089 timeout = 250;
00090
00091 res = ast_dtmf_stream(chan,NULL,digits,timeout);
00092
00093 LOCAL_USER_REMOVE(u);
00094
00095 return res;
00096 }
00097
00098 int unload_module(void)
00099 {
00100 int res;
00101
00102 res = ast_unregister_application(app);
00103
00104 STANDARD_HANGUP_LOCALUSERS;
00105
00106 return res;
00107 }
00108
00109 int load_module(void)
00110 {
00111 return ast_register_application(app, senddtmf_exec, synopsis, descrip);
00112 }
00113
00114 char *description(void)
00115 {
00116 return tdesc;
00117 }
00118
00119 int usecount(void)
00120 {
00121 int res;
00122 STANDARD_USECOUNT(res);
00123 return res;
00124 }
00125
00126 char *key()
00127 {
00128 return ASTERISK_GPL_KEY;
00129 }