static char *app = "AMD";
static char *synopsis = "Attempts to detect answering machines";
static char *descrip =
-" AMD([initialSilence][|greeting][|afterGreetingSilence][|totalAnalysisTime]\n"
-" [|minimumWordLength][|betweenWordsSilence][|maximumNumberOfWords]\n"
-" [|silenceThreshold])\n"
+" AMD([initialSilence],[greeting],[afterGreetingSilence],[totalAnalysisTime]\n"
+" ,[minimumWordLength],[betweenWordsSilence],[maximumNumberOfWords]\n"
+" ,[silenceThreshold])\n"
" This application attempts to detect answering machines at the beginning\n"
" of outbound calls. Simply call this application after the call\n"
" has been answered (outbound only, of course).\n"
static char *synopsis = "Authenticate a user";
static char *descrip =
-" Authenticate(password[|options[|maxdigits]]): This application asks the caller\n"
+" Authenticate(password[,options[,maxdigits]]): This application asks the caller\n"
"to enter a given password in order to continue dialplan execution. If the password\n"
"begins with the '/' character, it is interpreted as a file which contains a list of\n"
"valid passwords, listed 1 password per line in the file.\n"
static char *synopsis = "Check channel availability";
static char *descrip =
-" ChanIsAvail(Technology/resource[&Technology2/resource2...][|options]): \n"
+" ChanIsAvail(Technology/resource[&Technology2/resource2...][,options]): \n"
"This application will check to see if any of the specified channels are\n"
"available. The following variables will be set by this application:\n"
" ${AVAILCHAN} - the name of the available channel, if one exists\n"
static const char *tdesc = "Listen to a channel, and optionally whisper into it";
static const char *app_chan = "ChanSpy";
static const char *desc_chan =
-" ChanSpy([chanprefix][|options]): This application is used to listen to the\n"
+" ChanSpy([chanprefix][,options]): This application is used to listen to the\n"
"audio from an Asterisk channel. This includes the audio coming in and\n"
"out of the channel being spied on. If the 'chanprefix' parameter is specified,\n"
"only channels beginning with this string will be spied upon.\n"
static const char *app_ext = "ExtenSpy";
static const char *desc_ext =
-" ExtenSpy(exten[@context][|options]): This application is used to listen to the\n"
+" ExtenSpy(exten[@context][,options]): This application is used to listen to the\n"
"audio from an Asterisk channel. This includes the audio coming in and\n"
"out of the channel being spied on. Only channels created by outgoing calls for the\n"
"specified extension will be selected for spying. If the optional context is not\n"
static const char *synopsis = "Play a file with fast forward and rewind";
static const char *descrip =
-" ControlPlayback(file[|skipms[|ff[|rew[|stop[|pause[|restart|options]]]]]]]):\n"
+" ControlPlayback(file[,skipms[,ff[,rew[,stop[,pause[,restart,options]]]]]]]):\n"
"This application will play back the given filename. By default, the '*' key\n"
"can be used to rewind, and the '#' key can be used to fast-forward.\n"
"Parameters:\n"
static char *app = "Dictate";
static char *synopsis = "Virtual Dictation Machine";
-static char *desc = " Dictate([<base_dir>[|<filename>]])\n"
+static char *desc = " Dictate([<base_dir>[,<filename>]])\n"
"Start dictation machine using optional base dir for files.\n";
static char *synopsis = "Provide directory of voicemail extensions";
static char *descrip =
-" Directory(vm-context[|dial-context[|options]]): This application will present\n"
+" Directory(vm-context[,dial-context[,options]]): This application will present\n"
"the calling channel with a directory of extensions from which they can search\n"
"by name. The list of names and corresponding extensions is retrieved from the\n"
"voicemail configuration file, voicemail.conf.\n"
static char *synopsis = "DISA (Direct Inward System Access)";
static char *descrip =
-"DISA(<numeric passcode>[|<context>[|<cid>[|mailbox[|options]]]]) or\n"
-"DISA(<filename>[||||options])\n"
+"DISA(<numeric passcode>[,<context>[,<cid>[,mailbox[,options]]]]) or\n"
+"DISA(<filename>[,,,,options])\n"
"The DISA, Direct Inward System Access, application allows someone from \n"
"outside the telephone switch (PBX) to obtain an \"internal\" system \n"
"dialtone and to place calls from it as if they were placing a call from \n"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/options.h"
+#include "asterisk/app.h"
#define FESTIVAL_CONFIG "festival.conf"
+#define MAXLEN 180
+#define MAXFESTLEN 2048
static char *app = "Festival";
static char *synopsis = "Say text to the user";
static char *descrip =
-" Festival(text[|intkeys]): Connect to Festival, send the argument, get back the waveform,"
+" Festival(text[,intkeys]): Connect to Festival, send the argument, get back the waveform,"
"play it to the user, allowing any given interrupt keys to immediately terminate and return\n"
"the value, or 'any' to allow any number back (useful in dialplan)\n";
-static char *socket_receive_file_to_buff(int fd,int *size)
+static char *socket_receive_file_to_buff(int fd, int *size)
{
- /* Receive file (probably a waveform file) from socket using */
- /* Festival key stuff technique, but long winded I know, sorry */
- /* but will receive any file without closing the stream or */
- /* using OOB data */
- static char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */
- char *buff;
- int bufflen;
- int n,k,i;
- char c;
-
- bufflen = 1024;
- if (!(buff = ast_malloc(bufflen)))
- {
- /* TODO: Handle memory allocation failure */
- }
- *size=0;
-
- for (k=0; file_stuff_key[k] != '\0';)
- {
- n = read(fd,&c,1);
- if (n==0) break; /* hit stream eof before end of file */
- if ((*size)+k+1 >= bufflen)
- { /* +1 so you can add a NULL if you want */
- bufflen += bufflen/4;
- if (!(buff = ast_realloc(buff, bufflen)))
- {
- /* TODO: Handle memory allocation failure */
- }
- }
- if (file_stuff_key[k] == c)
- k++;
- else if ((c == 'X') && (file_stuff_key[k+1] == '\0'))
- { /* It looked like the key but wasn't */
- for (i=0; i < k; i++,(*size)++)
- buff[*size] = file_stuff_key[i];
- k=0;
- /* omit the stuffed 'X' */
- }
- else
- {
- for (i=0; i < k; i++,(*size)++)
- buff[*size] = file_stuff_key[i];
- k=0;
- buff[*size] = c;
- (*size)++;
- }
-
- }
-
- return buff;
-}
+ /* Receive file (probably a waveform file) from socket using
+ * Festival key stuff technique, but long winded I know, sorry
+ * but will receive any file without closing the stream or
+ * using OOB data
+ */
+ static char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */
+ char *buff, *tmp;
+ int bufflen;
+ int n,k,i;
+ char c;
-static int send_waveform_to_fd(char *waveform, int length, int fd) {
+ bufflen = 1024;
+ if (!(buff = ast_malloc(bufflen)))
+ return NULL;
+ *size = 0;
+
+ for (k = 0; file_stuff_key[k] != '\0';) {
+ n = read(fd, &c, 1);
+ if (n == 0)
+ break; /* hit stream eof before end of file */
+ if ((*size) + k + 1 >= bufflen) {
+ /* +1 so you can add a terminating NULL if you want */
+ bufflen += bufflen / 4;
+ if (!(tmp = ast_realloc(buff, bufflen))) {
+ ast_free(buff);
+ return NULL;
+ }
+ buff = tmp;
+ }
+ if (file_stuff_key[k] == c)
+ k++;
+ else if ((c == 'X') && (file_stuff_key[k+1] == '\0')) {
+ /* It looked like the key but wasn't */
+ for (i = 0; i < k; i++, (*size)++)
+ buff[*size] = file_stuff_key[i];
+ k = 0;
+ /* omit the stuffed 'X' */
+ } else {
+ for (i = 0; i < k; i++, (*size)++)
+ buff[*size] = file_stuff_key[i];
+ k = 0;
+ buff[*size] = c;
+ (*size)++;
+ }
+ }
+
+ return buff;
+}
- int res;
- int x;
+static int send_waveform_to_fd(char *waveform, int length, int fd)
+{
+ int res;
+ int x;
#ifdef __PPC__
char c;
#endif
sigfillset(&fullset);
pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
- res = fork();
- if (res < 0)
- ast_log(LOG_WARNING, "Fork failed\n");
- if (res) {
+ res = fork();
+ if (res < 0)
+ ast_log(LOG_WARNING, "Fork failed\n");
+ if (res) {
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
- return res;
+ return res;
+ }
+ for (x = 0; x < 256; x++) {
+ if (x != fd)
+ close(x);
}
- for (x=0;x<256;x++) {
- if (x != fd)
- close(x);
- }
if (ast_opt_high_priority)
ast_set_priority(0);
signal(SIGPIPE, SIG_DFL);
pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
-/*IAS */
#ifdef __PPC__
- for( x=0; x<length; x+=2)
- {
- c = *(waveform+x+1);
- *(waveform+x+1)=*(waveform+x);
- *(waveform+x)=c;
+ for (x = 0; x < length; x += 2) {
+ c = *(waveform + x + 1);
+ *(waveform + x + 1) = *(waveform + x);
+ *(waveform + x) = c;
}
#endif
-
- write(fd,waveform,length);
+ write(fd, waveform, length);
close(fd);
exit(0);
}
-
-static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys) {
- int res=0;
+static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys)
+{
+ int res = 0;
int fds[2];
- int ms = -1;
int pid = -1;
int needed = 0;
int owriteformat;
} myf = {
.f = { 0, },
};
-
- if (pipe(fds)) {
- ast_log(LOG_WARNING, "Unable to create pipe\n");
- return -1;
- }
-
+
+ if (pipe(fds)) {
+ ast_log(LOG_WARNING, "Unable to create pipe\n");
+ return -1;
+ }
+
/* Answer if it's not already going */
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
return -1;
}
- res=send_waveform_to_fd(waveform,length,fds[1]);
+ res = send_waveform_to_fd(waveform, length, fds[1]);
if (res >= 0) {
pid = res;
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
user */
for (;;) {
- ms = 1000;
- res = ast_waitfor(chan, ms);
+ res = ast_waitfor(chan, 1000);
if (res < 1) {
res = -1;
break;
}
if (res < needed) { /* last frame */
ast_debug(1, "Last frame\n");
- res=0;
+ res = 0;
ast_frfree(f);
break;
}
close(fds[0]);
close(fds[1]);
-/* if (pid > -1) */
-/* kill(pid, SIGKILL); */
+#if 0
+ if (pid > -1)
+ kill(pid, SIGKILL);
+#endif
if (!res && owriteformat)
ast_set_write_format(chan, owriteformat);
return res;
}
-#define MAXLEN 180
-#define MAXFESTLEN 2048
-
-
-
-
static int festival_exec(struct ast_channel *chan, void *vdata)
{
int usecache;
- int res=0;
- struct sockaddr_in serv_addr;
+ int res = 0;
+ struct sockaddr_in serv_addr;
struct hostent *serverhost;
struct ast_hostent ahp;
int fd;
const char *cachedir;
const char *temp;
const char *festivalcommand;
- int port=1314;
+ int port = 1314;
int n;
char ack[4];
char *waveform;
char MD5Hex[33] = "";
char koko[4] = "";
char cachefile[MAXFESTLEN]="";
- int readcache=0;
- int writecache=0;
+ int readcache = 0;
+ int writecache = 0;
int strln;
int fdesc = -1;
char buffer[16384];
int seekpos = 0;
char *data;
- char *intstr;
struct ast_config *cfg;
char *newfestivalcommand;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(text);
+ AST_APP_ARG(interrupt);
+ );
if (ast_strlen_zero(vdata)) {
ast_log(LOG_WARNING, "festival requires an argument (text)\n");
port = atoi(temp);
}
if (!(temp = ast_variable_retrieve(cfg, "general", "usecache"))) {
- usecache=0;
+ usecache = 0;
} else {
usecache = ast_true(temp);
}
}
data = ast_strdupa(vdata);
+ AST_STANDARD_APP_ARGS(args, data);
- intstr = strchr(data, '|');
- if (intstr) {
- *intstr = '\0';
- intstr++;
- if (!strcasecmp(intstr, "any"))
- intstr = AST_DIGIT_ANY;
- }
-
- ast_debug(1, "Text passed to festival server : %s\n",(char *)data);
+ if (args.interrupt && !strcasecmp(args.interrupt, "any"))
+ args.interrupt = AST_DIGIT_ANY;
+
+ ast_debug(1, "Text passed to festival server : %s\n", args.text);
/* Connect to local festival server */
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd < 0) {
- ast_log(LOG_WARNING,"festival_client: can't get socket\n");
+ ast_log(LOG_WARNING, "festival_client: can't get socket\n");
ast_config_destroy(cfg);
return -1;
}
/* its a name rather than an ipnum */
serverhost = ast_gethostbyname(host, &ahp);
- if (serverhost == (struct hostent *)0) {
- ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
+ if (serverhost == NULL) {
+ ast_log(LOG_WARNING, "festival_client: gethostbyname failed\n");
ast_config_destroy(cfg);
return -1;
}
- memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
+ memmove(&serv_addr.sin_addr, serverhost->h_addr, serverhost->h_length);
}
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
- ast_log(LOG_WARNING,"festival_client: connect to server failed\n");
+ ast_log(LOG_WARNING, "festival_client: connect to server failed\n");
ast_config_destroy(cfg);
- return -1;
- }
-
- /* Compute MD5 sum of string */
- MD5Init(&md5ctx);
- MD5Update(&md5ctx,(unsigned char const *)data,strlen(data));
- MD5Final(MD5Res,&md5ctx);
- MD5Hex[0] = '\0';
-
- /* Convert to HEX and look if there is any matching file in the cache
- directory */
- for (i=0;i<16;i++) {
- snprintf(koko, sizeof(koko), "%X",MD5Res[i]);
- strncat(MD5Hex, koko, sizeof(MD5Hex) - strlen(MD5Hex) - 1);
- }
- readcache=0;
- writecache=0;
- if (strlen(cachedir)+strlen(MD5Hex)+1<=MAXFESTLEN && (usecache==-1)) {
- snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
- fdesc=open(cachefile,O_RDWR);
- if (fdesc==-1) {
- fdesc=open(cachefile,O_CREAT|O_RDWR,AST_FILE_MODE);
- if (fdesc!=-1) {
- writecache=1;
- strln=strlen((char *)data);
- ast_debug(1,"line length : %d\n",strln);
- write(fdesc,&strln,sizeof(int));
- write(fdesc,data,strln);
- seekpos=lseek(fdesc,0,SEEK_CUR);
- ast_debug(1,"Seek position : %d\n",seekpos);
- }
- } else {
- read(fdesc,&strln,sizeof(int));
- ast_debug(1,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
- if (strlen((char *)data)==strln) {
- ast_debug(1,"Size OK\n");
- read(fdesc,&bigstring,strln);
- bigstring[strln] = 0;
- if (strcmp(bigstring,data)==0) {
- readcache=1;
- } else {
- ast_log(LOG_WARNING,"Strings do not match\n");
- }
- } else {
- ast_log(LOG_WARNING,"Size mismatch\n");
- }
- }
+ return -1;
+ }
+
+ /* Compute MD5 sum of string */
+ MD5Init(&md5ctx);
+ MD5Update(&md5ctx, (unsigned char *)args.text, strlen(args.text));
+ MD5Final(MD5Res, &md5ctx);
+ MD5Hex[0] = '\0';
+
+ /* Convert to HEX and look if there is any matching file in the cache
+ directory */
+ for (i = 0; i < 16; i++) {
+ snprintf(koko, sizeof(koko), "%X", MD5Res[i]);
+ strncat(MD5Hex, koko, sizeof(MD5Hex) - strlen(MD5Hex) - 1);
+ }
+ readcache = 0;
+ writecache = 0;
+ if (strlen(cachedir) + strlen(MD5Hex) + 1 <= MAXFESTLEN && (usecache == -1)) {
+ snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
+ fdesc = open(cachefile, O_RDWR);
+ if (fdesc == -1) {
+ fdesc = open(cachefile, O_CREAT | O_RDWR, AST_FILE_MODE);
+ if (fdesc != -1) {
+ writecache = 1;
+ strln = strlen(args.text);
+ ast_debug(1, "line length : %d\n", strln);
+ write(fdesc, &strln, sizeof(strln));
+ write(fdesc, args.text, strln);
+ seekpos = lseek(fdesc, 0, SEEK_CUR);
+ ast_debug(1, "Seek position : %d\n", seekpos);
+ }
+ } else {
+ read(fdesc, &strln, sizeof(strln));
+ ast_debug(1, "Cache file exists, strln=%d, strlen=%d\n", strln, (int)strlen(args.text));
+ if (strlen(args.text) == strln) {
+ ast_debug(1, "Size OK\n");
+ read(fdesc, &bigstring, strln);
+ bigstring[strln] = 0;
+ if (strcmp(bigstring, args.text) == 0) {
+ readcache = 1;
+ } else {
+ ast_log(LOG_WARNING, "Strings do not match\n");
+ }
+ } else {
+ ast_log(LOG_WARNING, "Size mismatch\n");
+ }
+ }
}
-
- if (readcache==1) {
+
+ if (readcache == 1) {
close(fd);
- fd=fdesc;
- ast_debug(1,"Reading from cache...\n");
+ fd = fdesc;
+ ast_debug(1, "Reading from cache...\n");
} else {
- ast_debug(1,"Passing text to festival...\n");
- fs=fdopen(dup(fd),"wb");
- fprintf(fs,festivalcommand,(char *)data);
+ ast_debug(1, "Passing text to festival...\n");
+ fs = fdopen(dup(fd), "wb");
+ fprintf(fs, festivalcommand, args.text);
fflush(fs);
fclose(fs);
}
/* Write to cache and then pass it down */
- if (writecache==1) {
- ast_debug(1,"Writing result to cache...\n");
- while ((strln=read(fd,buffer,16384))!=0) {
- write(fdesc,buffer,strln);
+ if (writecache == 1) {
+ ast_debug(1, "Writing result to cache...\n");
+ while ((strln = read(fd, buffer, 16384)) != 0) {
+ write(fdesc, buffer, strln);
}
close(fd);
close(fdesc);
- fd=open(cachefile,O_RDWR);
- lseek(fd,seekpos,SEEK_SET);
+ fd = open(cachefile, O_RDWR);
+ lseek(fd, seekpos, SEEK_SET);
}
- ast_debug(1,"Passing data to channel...\n");
-
+ ast_debug(1, "Passing data to channel...\n");
+
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
wave = 0;
do {
- int read_data;
- for (n=0; n < 3; )
- {
- read_data = read(fd,ack+n,3-n);
- /* this avoids falling in infinite loop
- * in case that festival server goes down
- * */
- if ( read_data == -1 )
- {
- ast_log(LOG_WARNING,"Unable to read from cache/festival fd\n");
- close(fd);
- ast_config_destroy(cfg);
- return -1;
- }
- n += read_data;
- }
+ int read_data;
+ for (n = 0; n < 3; ) {
+ read_data = read(fd, ack + n, 3 - n);
+ /* this avoids falling in infinite loop
+ * in case that festival server goes down
+ */
+ if (read_data == -1) {
+ ast_log(LOG_WARNING, "Unable to read from cache/festival fd\n");
+ close(fd);
+ ast_config_destroy(cfg);
+ return -1;
+ }
+ n += read_data;
+ }
ack[3] = '\0';
- if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
- ast_debug(1,"Festival WV command\n");
- waveform = socket_receive_file_to_buff(fd,&filesize);
- res = send_waveform_to_channel(chan,waveform,filesize, intstr);
- ast_free(waveform);
+ if (strcmp(ack, "WV\n") == 0) { /* receive a waveform */
+ ast_debug(1, "Festival WV command\n");
+ if ((waveform = socket_receive_file_to_buff(fd, &filesize))) {
+ res = send_waveform_to_channel(chan, waveform, filesize, args.interrupt);
+ ast_free(waveform);
+ }
break;
- }
- else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
- ast_debug(1,"Festival LP command\n");
- waveform = socket_receive_file_to_buff(fd,&filesize);
- waveform[filesize]='\0';
- ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform);
- ast_free(waveform);
- } else if (strcmp(ack,"ER\n") == 0) { /* server got an error */
- ast_log(LOG_WARNING,"Festival returned ER\n");
- res=-1;
+ } else if (strcmp(ack, "LP\n") == 0) { /* receive an s-expr */
+ ast_debug(1, "Festival LP command\n");
+ if ((waveform = socket_receive_file_to_buff(fd, &filesize))) {
+ waveform[filesize] = '\0';
+ ast_log(LOG_WARNING, "Festival returned LP : %s\n", waveform);
+ ast_free(waveform);
+ }
+ } else if (strcmp(ack, "ER\n") == 0) { /* server got an error */
+ ast_log(LOG_WARNING, "Festival returned ER\n");
+ res = -1;
break;
- }
- } while (strcmp(ack,"OK\n") != 0);
+ }
+ } while (strcmp(ack, "OK\n") != 0);
close(fd);
ast_config_destroy(cfg);
return res;
-
}
static int unload_module(void)
static char *app = "FollowMe";
static char *synopsis = "Find-Me/Follow-Me application";
static char *descrip =
-" FollowMe(followmeid|options):\n"
+" FollowMe(followmeid,options):\n"
"This application performs Find-Me/Follow-Me functionality for the caller\n"
"as defined in the profile matching the <followmeid> parameter in\n"
"followme.conf. If the specified <followmeid> profile doesn't exist in\n"
static char *synopsis = "Send an image file";
static char *descrip =
-" SendImage(filename): Sends an image on a channel. \n"
-"If the channel supports image transport but the image send\n"
-"fails, the channel will be hung up. Otherwise, the dialplan\n"
-"continues execution.\n"
-"This application sets the following channel variable upon completion:\n"
-" SENDIMAGESTATUS The status is the result of the attempt as a text string, one of\n"
-" OK | NOSUPPORT \n";
+" SendImage(filename): Sends an image on a channel.\n"
+"If the channel supports image transport but the image send fails, the channel\n"
+"will be hung up. Otherwise, the dialplan continues execution. This\n"
+"application sets the following channel variable upon completion:\n"
+" SENDIMAGESTATUS The status is the result of the attempt, one of:\n"
+" OK | NOSUPPORT \n";
static int sendimage_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *parse;
- AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(filename);
- AST_APP_ARG(options);
- );
-
- parse = ast_strdupa(data);
- AST_STANDARD_APP_ARGS(args, parse);
-
- if (ast_strlen_zero(args.filename)) {
- ast_log(LOG_WARNING, "SendImage requires an argument (filename[|options])\n");
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
return -1;
}
- if (args.options) {
- }
-
if (!ast_supports_images(chan)) {
/* Does not support transport */
pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
return 0;
}
- if (!(res = ast_send_image(chan, args.filename)))
+ if (!(res = ast_send_image(chan, data)))
pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
return res;
#define MACRO_EXIT_RESULT 1024
static char *descrip =
-" Macro(macroname|arg1|arg2...): Executes a macro using the context\n"
+" Macro(macroname,arg1,arg2...): Executes a macro using the context\n"
"'macro-<macroname>', jumping to the 's' extension of that context and\n"
"executing each step, then returning when the steps end. \n"
"The calling extension, context, and priority are stored in ${MACRO_EXTEN}, \n"
" (now allows arguments like a Macro) with explict Return() calls instead.\n";
static char *if_descrip =
-" MacroIf(<expr>?macroname_a[|arg1][:macroname_b[|arg1]])\n"
+" MacroIf(<expr>?macroname_a[,arg1][:macroname_b[,arg1]])\n"
"Executes macro defined in <macroname_a> if <expr> is true\n"
"(otherwise <macroname_b> if provided)\n"
"Arguments and return values as in application macro()\n";
static char *exclusive_descrip =
-" MacroExclusive(macroname|arg1|arg2...):\n"
+" MacroExclusive(macroname,arg1,arg2...):\n"
"Executes macro defined in the context 'macro-macroname'\n"
"Only one call at a time may run the macro.\n"
"(we'll wait if another call is busy executing in the Macro)\n"
char *save_macro_offset;
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n");
+ ast_log(LOG_WARNING, "Macro() requires arguments. See \"core show application macro\" for help.\n");
return -1;
}
" '1' -- do not play message when first person enters\n";
static const char *descrip2 =
-" MeetMeCount(confno[|var]): Plays back the number of users in the specified\n"
+" MeetMeCount(confno[,var]): Plays back the number of users in the specified\n"
"MeetMe conference. If var is specified, playback will be skipped and the value\n"
"will be returned in the variable. Upon app completion, MeetMeCount will hangup\n"
"the channel, unless priority n+1 exists, in which case priority progress will\n"
"";
static const char *descrip4 =
-" MeetMeChannelAdmin(channel|command): Run admin command for a specific\n"
+" MeetMeChannelAdmin(channel,command): Run admin command for a specific\n"
"channel in any coference.\n"
" 'k' -- Kick the specified user out of the conference he is in\n"
" 'm' -- Unmute the specified user\n"
if (strstr(argv[1], "lock")) {
if (strcmp(argv[1], "lock") == 0) {
/* Lock */
- strncat(cmdline, "|L", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",L", sizeof(cmdline) - strlen(cmdline) - 1);
} else {
/* Unlock */
- strncat(cmdline, "|l", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",l", sizeof(cmdline) - strlen(cmdline) - 1);
}
} else if (strstr(argv[1], "mute")) {
if (argc < 4)
if (strcmp(argv[1], "mute") == 0) {
/* Mute */
if (strcmp(argv[3], "all") == 0) {
- strncat(cmdline, "|N", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",N", sizeof(cmdline) - strlen(cmdline) - 1);
} else {
- strncat(cmdline, "|M|", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",M,", sizeof(cmdline) - strlen(cmdline) - 1);
strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
}
} else {
/* Unmute */
if (strcmp(argv[3], "all") == 0) {
- strncat(cmdline, "|n", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",n", sizeof(cmdline) - strlen(cmdline) - 1);
} else {
- strncat(cmdline, "|m|", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",m,", sizeof(cmdline) - strlen(cmdline) - 1);
strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
}
}
return RESULT_SHOWUSAGE;
if (strcmp(argv[3], "all") == 0) {
/* Kick all */
- strncat(cmdline, "|K", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",K", sizeof(cmdline) - strlen(cmdline) - 1);
} else {
/* Kick a single user */
- strncat(cmdline, "|k|", sizeof(cmdline) - strlen(cmdline) - 1);
+ strncat(cmdline, ",k,", sizeof(cmdline) - strlen(cmdline) - 1);
strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
- }
+ }
} else if(strcmp(argv[1], "list") == 0) {
int concise = ( 4 == argc && ( !strcasecmp(argv[3], "concise") ) );
/* List all the users in a conference */
if (!(parse = ast_strdupa(var->value)))
return NULL;
- AST_NONSTANDARD_APP_ARGS(args, parse, ',');
+ AST_STANDARD_APP_ARGS(args, parse);
ast_log(LOG_NOTICE,"Will conf %s match %s?\n", confno, args.confno);
if (!strcasecmp(args.confno, confno)) {
/* Bingo it's a valid conference */
}
ast_stopstream(cnf->lchan);
- flags = O_CREAT|O_TRUNC|O_WRONLY;
+ flags = O_CREAT | O_TRUNC | O_WRONLY;
cnf->recording = MEETME_RECORD_ACTIVE;
trunk_ref->chan = NULL;
if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
- strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1);
+ strncat(conf_name, ",K", sizeof(conf_name) - strlen(conf_name) - 1);
admin_exec(NULL, conf_name);
trunk_ref->trunk->hold_stations = 0;
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
char buf[80];
struct sla_station_ref *station_ref;
- snprintf(buf, sizeof(buf), "SLA_%s|K", ringing_trunk->trunk->name);
+ snprintf(buf, sizeof(buf), "SLA_%s,K", ringing_trunk->trunk->name);
admin_exec(NULL, buf);
sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
trunk_ref->chan = NULL;
if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
- strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1);
+ strncat(conf_name, ",K", sizeof(conf_name) - strlen(conf_name) - 1);
admin_exec(NULL, conf_name);
trunk_ref->trunk->hold_stations = 0;
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
if (n> 0) {
ogroup[0]= dtable[igroup[0]>>2];
- ogroup[1]= dtable[((igroup[0]&3)<<4)|(igroup[1]>>4)];
- ogroup[2]= dtable[((igroup[1]&0xF)<<2)|(igroup[2]>>6)];
+ ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)];
+ ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)];
ogroup[3]= dtable[igroup[2]&0x3F];
if (n<3) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmpptr, '|', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
if (argc == 2 && !ast_strlen_zero(argv[1]))
template = argv[1];
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmp, ',', argv, sizeof(argv) / sizeof(argv[0]));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
return -1;
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmpptr, '|', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1]))
ast_log(LOG_ERROR, "Out of memory\n");
error = TRUE;
} else
- argc = ast_app_separate_args(tmpptr, '|', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
}
if (argc <=1) {
static const char *app = "MixMonitor";
static const char *synopsis = "Record a call and mix the audio during the recording";
static const char *desc = ""
-" MixMonitor(<file>.<ext>[|<options>[|<command>]])\n\n"
+" MixMonitor(<file>.<ext>[,<options>[,<command>]])\n\n"
"Records the audio on the current channel to the specified file.\n"
"If the filename is an absolute path, uses that path, otherwise\n"
"creates the file in the configured monitoring directory from\n"
static const char *page_synopsis = "Pages phones";
static const char *page_descrip =
-"Page(Technology/Resource&Technology2/Resource2[|options])\n"
+"Page(Technology/Resource&Technology2/Resource2[,options])\n"
" Places outbound calls to the given technology / resource and dumps\n"
"them into a conference bridge as muted participants. The original\n"
"caller is dumped into the conference as a speaker and the room is\n"
if (options)
ast_app_parse_options(page_opts, &flags, opts, options);
- snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe|%ud|%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
+ snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
/* Go through parsing/calling each device */
}
if (!res) {
- snprintf(meetmeopts, sizeof(meetmeopts), "%ud|A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"),
+ snprintf(meetmeopts, sizeof(meetmeopts), "%ud,A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"),
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
pbx_exec(chan, app, meetmeopts);
}
static char *synopsis = "Park and Announce";
static char *descrip =
-" ParkAndAnnounce(announce:template|timeout|dial|[return_context]):\n"
+" ParkAndAnnounce(announce:template,timeout,dial[,return_context]):\n"
"Park a call into the parkinglot and announce the call to another channel.\n"
"\n"
"announce template: Colon-separated list of files to announce. The word PARKED\n"
static char *synopsis = "Play a file";
static char *descrip =
-" Playback(filename[&filename2...][|option]): Plays back given filenames (do not put\n"
+" Playback(filename[&filename2...][,option]): Plays back given filenames (do not put\n"
"extension). Options may also be included following a pipe symbol. The 'skip'\n"
"option causes the playback of the message to be skipped if the channel\n"
"is not in the 'up' state (i.e. it hasn't been answered yet). If 'skip' is \n"
static char *synopsis = "Require phone number to be entered, if no CallerID sent";
static char *descrip =
- " PrivacyManager([maxretries[|minlength[|options]]]): If no Caller*ID \n"
+ " PrivacyManager([maxretries[,minlength[,options]]]): If no Caller*ID \n"
"is sent, PrivacyManager answers the channel and asks the caller to\n"
"enter their phone number. The caller is given 3 attempts to do so.\n"
"The application does nothing if Caller*ID was received on the channel.\n"
static char *synopsis = "Queue a call for a call queue";
static char *descrip =
-" Queue(queuename[|options[|URL][|announceoverride][|timeout][|AGI][|macro][|gosub]):\n"
+" Queue(queuename[,options[,URL][,announceoverride][,timeout][,AGI][,macro][,gosub]):\n"
"Queues an incoming call in a particular call queue as defined in queues.conf.\n"
"This application will return to the dialplan if the queue does not exist, or\n"
"any of the join options cause the caller to not enter the queue.\n"
static char *app_aqm = "AddQueueMember" ;
static char *app_aqm_synopsis = "Dynamically adds queue members" ;
static char *app_aqm_descrip =
-" AddQueueMember(queuename[|interface[|penalty[|options[|membername]]]]):\n"
+" AddQueueMember(queuename[,interface[,penalty[,options[,membername]]]]):\n"
"Dynamically adds interface to an existing queue.\n"
"If the interface is already in the queue it will return an error.\n"
" This application sets the following channel variable upon completion:\n"
" AQMSTATUS The status of the attempt to add a queue member as a \n"
" text string, one of\n"
" ADDED | MEMBERALREADY | NOSUCHQUEUE \n"
-"Example: AddQueueMember(techsupport|SIP/3000)\n"
+"Example: AddQueueMember(techsupport,SIP/3000)\n"
"";
static char *app_rqm = "RemoveQueueMember" ;
static char *app_rqm_synopsis = "Dynamically removes queue members" ;
static char *app_rqm_descrip =
-" RemoveQueueMember(queuename[|interface[|options]]):\n"
+" RemoveQueueMember(queuename[,interface[,options]]):\n"
"Dynamically removes interface to an existing queue\n"
"If the interface is NOT in the queue it will return an error.\n"
" This application sets the following channel variable upon completion:\n"
" RQMSTATUS The status of the attempt to remove a queue member as a\n"
" text string, one of\n"
" REMOVED | NOTINQUEUE | NOSUCHQUEUE \n"
-"Example: RemoveQueueMember(techsupport|SIP/3000)\n"
+"Example: RemoveQueueMember(techsupport,SIP/3000)\n"
"";
static char *app_pqm = "PauseQueueMember" ;
static char *app_pqm_synopsis = "Pauses a queue member" ;
static char *app_pqm_descrip =
-" PauseQueueMember([queuename]|interface[|options]):\n"
+" PauseQueueMember([queuename],interface[,options]):\n"
"Pauses (blocks calls for) a queue member.\n"
"The given interface will be paused in the given queue. This prevents\n"
"any calls from being sent from the queue to the interface until it is\n"
" PQMSTATUS The status of the attempt to pause a queue member as a\n"
" text string, one of\n"
" PAUSED | NOTFOUND\n"
-"Example: PauseQueueMember(|SIP/3000)\n";
+"Example: PauseQueueMember(,SIP/3000)\n";
static char *app_upqm = "UnpauseQueueMember" ;
static char *app_upqm_synopsis = "Unpauses a queue member" ;
static char *app_upqm_descrip =
-" UnpauseQueueMember([queuename]|interface[|options]):\n"
+" UnpauseQueueMember([queuename],interface[,options]):\n"
"Unpauses (resumes calls to) a queue member.\n"
"This is the counterpart to PauseQueueMember and operates exactly the\n"
"same way, except it unpauses instead of pausing the given interface.\n"
" UPQMSTATUS The status of the attempt to unpause a queue \n"
" member as a text string, one of\n"
" UNPAUSED | NOTFOUND\n"
-"Example: UnpauseQueueMember(|SIP/3000)\n";
+"Example: UnpauseQueueMember(,SIP/3000)\n";
static char *app_ql = "QueueLog" ;
static char *app_ql_synopsis = "Writes to the queue_log" ;
static char *app_ql_descrip =
-" QueueLog(queuename|uniqueid|agent|event[|additionalinfo]):\n"
+" QueueLog(queuename,uniqueid,agent,event[,additionalinfo]):\n"
"Allows you to write your own events into the queue log\n"
-"Example: QueueLog(101|${UNIQUEID}|${AGENT}|WENTONBREAK|600)\n";
+"Example: QueueLog(101,${UNIQUEID},${AGENT},WENTONBREAK,600)\n";
/*! \brief Persistent Members astdb family */
static const char *pm_family = "Queue/PersistentMembers";
static char *synopsis = "Read a variable";
static char *descrip =
-" Read(variable[|filename[&filename2...]][|maxdigits][|option][|attempts][|timeout])\n\n"
+" Read(variable[,filename[&filename2...]][,maxdigits][,option][,attempts][,timeout])\n\n"
"Reads a #-terminated string of digits a certain number of times from the\n"
"user in to the given variable.\n"
" filename -- file(s) to play before reading digits or tone with option i\n"
ast_verb(3, "Accepting a maximum of %d digits.\n", maxdigits);
}
if (ast_strlen_zero(arglist.variable)) {
- ast_log(LOG_WARNING, "Invalid! Usage: Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])\n\n");
+ ast_log(LOG_WARNING, "Invalid! Usage: Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])\n\n");
return -1;
}
ts=NULL;
static char *synopsis = "Record to a file";
static char *descrip =
-" Record(filename.format|silence[|maxduration][|options])\n\n"
+" Record(filename.format,silence[,maxduration][,options])\n\n"
"Records from the channel into a given filename. If the file exists it will\n"
"be overwritten.\n"
"- 'format' is the format of the file type to be recorded (wav, gsm, etc).\n"
static char *synopsis = "Radio Repeater/Remote Base Control System";
static char *descrip =
-" Rpt(nodename[|options]): Radio Remote Link or Remote Base Link Endpoint Process.\n"
+" Rpt(nodename[,options]): Radio Remote Link or Remote Base Link Endpoint Process.\n"
"\n"
" Not specifying an option puts it in normal endpoint mode (where source\n"
" IP and nodename are verified).\n"
" this if you have checked security already (like with an IAX2\n"
" user/password or something).\n"
"\n"
-" Rannounce-string[|timeout[|timeout-destination]] - Amateur Radio\n"
+" Rannounce-string[,timeout[,timeout-destination]] - Amateur Radio\n"
" Reverse Autopatch. Caller is put on hold, and announcement (as\n"
" specified by the 'announce-string') is played on radio system.\n"
" Users of radio system can access autopatch, dial specified\n"
static char *sayunixtime_synopsis = "Says a specified time in a custom format";
static char *sayunixtime_descrip =
-"SayUnixTime([unixtime][|[timezone][|format]])\n"
+"SayUnixTime([unixtime][,[timezone][,format]])\n"
" unixtime: time, in seconds since Jan 1, 1970. May be negative.\n"
" defaults to now.\n"
" timezone: timezone, see /usr/share/zoneinfo for a list.\n"
" format: a format the time is to be said in. See voicemail.conf.\n"
" defaults to \"ABdY 'digits/at' IMp\"\n";
static char *datetime_descrip =
-"DateTime([unixtime][|[timezone][|format]])\n"
+"DateTime([unixtime][,[timezone][,format]])\n"
" unixtime: time, in seconds since Jan 1, 1970. May be negative.\n"
" defaults to now.\n"
" timezone: timezone, see /usr/share/zoneinfo for a list.\n"
static int sayunixtime_exec(struct ast_channel *chan, void *data)
{
AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(timeval);
- AST_APP_ARG(timezone);
- AST_APP_ARG(format);
+ AST_APP_ARG(timeval);
+ AST_APP_ARG(timezone);
+ AST_APP_ARG(format);
);
char *parse;
int res = 0;
static char *synopsis = "Sends arbitrary DTMF digits";
static char *descrip =
-" SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n"
+" SendDTMF(digits[,timeout_ms]): Sends DTMF digits on a channel. \n"
" Accepted digits: 0-9, *#abcd, w (.5s pause)\n"
" The application will either pass the assigned digits or terminate if it\n"
" encounters an error.\n";
-static int senddtmf_exec(struct ast_channel *chan, void *data)
+static int senddtmf_exec(struct ast_channel *chan, void *vdata)
{
int res = 0;
- char *digits = NULL, *to = NULL;
- int timeout = 250;
+ char *data;
+ int timeout;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(digits);
+ AST_APP_ARG(timeout);
+ );
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
return 0;
}
- digits = ast_strdupa(data);
+ data = ast_strdupa(vdata);
+ AST_STANDARD_APP_ARGS(args, data);
- if ((to = strchr(digits,'|'))) {
- *to = '\0';
- to++;
- timeout = atoi(to);
- }
-
- if (timeout <= 0)
- timeout = 250;
-
- res = ast_dtmf_stream(chan,NULL,digits,timeout);
+ timeout = atoi(args.timeout);
+ res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout);
return res;
}
static const char *synopsis = "Send a Text Message";
static const char *descrip =
-" SendText(text[|options]): Sends text to current channel (callee).\n"
+" SendText(text[,options]): Sends text to current channel (callee).\n"
"Result of transmission will be stored in the SENDTEXTSTATUS\n"
"channel variable:\n"
" SUCCESS Transmission succeeded\n"
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
+ ast_log(LOG_WARNING, "SendText requires an argument (text[,options])\n");
return -1;
} else
parse = ast_strdupa(data);
static char *synopsis = "Communicates with SMS service centres and SMS capable analogue phones";
static char *descrip =
- " SMS(name|[a][s][t][p(d)][r][o]|addr|body):\n"
+ " SMS(name,[a][s][t][p(d)][r][o],addr,body):\n"
"SMS handles exchange of SMS data with a call to/from SMS capable\n"
"phone or SMS PSTN service center. Can send and/or receive SMS messages.\n"
"Works to ETSI ES 201 912; compatible with BT SMS PSTN service in UK\n"
"Tell the speech recognition engine that it should start trying to get results from audio being fed to it. This has no arguments.\n";
static char *speechbackground_descrip =
-"SpeechBackground(Sound File|Timeout)\n"
+"SpeechBackground(Sound File,Timeout)\n"
"This application plays a sound file and waits for the person to speak. Once they start speaking playback of the file stops, and silence is heard.\n"
"Once they stop talking the processing sound is played to indicate the speech recognition engine is working.\n"
"Once results are available the application returns and results (score and text) are available using dialplan functions.\n"
"again before calling any other application. It takes no arguments.\n";
static char *speechload_descrip =
-"SpeechLoadGrammar(Grammar Name|Path)\n"
+"SpeechLoadGrammar(Grammar Name,Path)\n"
"Load a grammar only on the channel, not globally.\n"
"It takes the grammar name as first argument and path as second.\n";
return 0;
}
-/*! \brief SpeechLoadGrammar(Grammar Name|Path) Dialplan Application */
-static int speech_load(struct ast_channel *chan, void *data)
+/*! \brief SpeechLoadGrammar(Grammar Name,Path) Dialplan Application */
+static int speech_load(struct ast_channel *chan, void *vdata)
{
- int res = 0, argc = 0;
+ int res = 0;
struct ast_speech *speech = find_speech(chan);
- char *argv[2], *args = NULL, *name = NULL, *path = NULL;
+ char *data;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(grammar);
+ AST_APP_ARG(path);
+ );
- args = ast_strdupa(data);
+ data = ast_strdupa(vdata);
+ AST_STANDARD_APP_ARGS(args, data);
if (speech == NULL)
- return -1;
+ return -1;
- /* Parse out arguments */
- argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
- if (argc != 2)
+ if (args.argc != 2)
return -1;
- name = argv[0];
- path = argv[1];
- /* Load the grammar locally on the object */
- res = ast_speech_grammar_load(speech, name, path);
+ /* Load the grammar locally on the object */
+ res = ast_speech_grammar_load(speech, args.grammar, args.path);
- return res;
+ return res;
}
/*! \brief SpeechUnloadGrammar(Grammar Name) Dialplan Application */
static int speech_unload(struct ast_channel *chan, void *data)
{
- int res = 0;
- struct ast_speech *speech = find_speech(chan);
+ int res = 0;
+ struct ast_speech *speech = find_speech(chan);
- if (speech == NULL)
+ if (speech == NULL)
return -1;
- /* Unload the grammar */
- res = ast_speech_grammar_unload(speech, data);
+ /* Unload the grammar */
+ res = ast_speech_grammar_unload(speech, data);
- return res;
+ return res;
}
/*! \brief SpeechDeactivateGrammar(Grammar Name) Dialplan Application */
static int speech_deactivate(struct ast_channel *chan, void *data)
{
- int res = 0;
- struct ast_speech *speech = find_speech(chan);
+ int res = 0;
+ struct ast_speech *speech = find_speech(chan);
- if (speech == NULL)
- return -1;
+ if (speech == NULL)
+ return -1;
- /* Deactivate the grammar on the speech object */
- res = ast_speech_grammar_deactivate(speech, data);
+ /* Deactivate the grammar on the speech object */
+ res = ast_speech_grammar_deactivate(speech, data);
- return res;
+ return res;
}
/*! \brief SpeechActivateGrammar(Grammar Name) Dialplan Application */
/*! \brief SpeechProcessingSound(Sound File) Dialplan Application */
static int speech_processing_sound(struct ast_channel *chan, void *data)
{
- int res = 0;
- struct ast_speech *speech = find_speech(chan);
+ int res = 0;
+ struct ast_speech *speech = find_speech(chan);
- if (speech == NULL)
- return -1;
+ if (speech == NULL)
+ return -1;
if (speech->processing_sound != NULL) {
ast_free(speech->processing_sound);
speech->processing_sound = ast_strdup(data);
- return res;
+ return res;
}
/*! \brief Helper function used by speech_background to playback a soundfile */
static int speech_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
{
- struct ast_filestream *fs = NULL;
+ struct ast_filestream *fs = NULL;
if (!(fs = ast_openstream(chan, filename, preflang)))
return -1;
ast_playstream(fs);
- return 0;
+ return 0;
}
-/*! \brief SpeechBackground(Sound File|Timeout) Dialplan Application */
+/*! \brief SpeechBackground(Sound File,Timeout) Dialplan Application */
static int speech_background(struct ast_channel *chan, void *data)
{
- unsigned int timeout = 0;
- int res = 0, done = 0, argc = 0, started = 0, quieted = 0, max_dtmf_len = 0;
- struct ast_speech *speech = find_speech(chan);
- struct ast_frame *f = NULL;
- int oldreadformat = AST_FORMAT_SLINEAR;
- char dtmf[AST_MAX_EXTENSION] = "";
- time_t start, current;
- struct ast_datastore *datastore = NULL;
- char *argv[2], *args = NULL, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
+ unsigned int timeout = 0;
+ int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
+ struct ast_speech *speech = find_speech(chan);
+ struct ast_frame *f = NULL;
+ int oldreadformat = AST_FORMAT_SLINEAR;
+ char dtmf[AST_MAX_EXTENSION] = "";
+ time_t start, current;
+ struct ast_datastore *datastore = NULL;
+ char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
const char *tmp2 = NULL;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(soundfile);
+ AST_APP_ARG(timeout);
+ );
- args = ast_strdupa(data);
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
- if (speech == NULL)
- return -1;
+ if (speech == NULL)
+ return -1;
/* If channel is not already answered, then answer it */
if (chan->_state != AST_STATE_UP && ast_answer(chan))
return -1;
- /* Record old read format */
- oldreadformat = chan->readformat;
+ /* Record old read format */
+ oldreadformat = chan->readformat;
- /* Change read format to be signed linear */
- if (ast_set_read_format(chan, speech->format))
- return -1;
+ /* Change read format to be signed linear */
+ if (ast_set_read_format(chan, speech->format))
+ return -1;
- /* Parse out options */
- argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
- if (argc > 0) {
- /* Yay sound file */
- filename_tmp = ast_strdupa(argv[0]);
- if (!ast_strlen_zero(argv[1])) {
- if ((timeout = atoi(argv[1])) == 0)
+ if (!ast_strlen_zero(args.soundfile)) {
+ /* Yay sound file */
+ filename_tmp = ast_strdupa(args.soundfile);
+ if (!ast_strlen_zero(args.timeout)) {
+ if ((timeout = atoi(args.timeout)) == 0)
timeout = -1;
} else
timeout = 0;
- }
+ }
/* See if the maximum DTMF length variable is set... we use a variable in case they want to carry it through their entire dialplan */
if ((tmp2 = pbx_builtin_getvar_helper(chan, "SPEECH_DTMF_MAXLEN")) && !ast_strlen_zero(tmp2))
dtmf_terminator = tmp2[0];
}
- /* Before we go into waiting for stuff... make sure the structure is ready, if not - start it again */
- if (speech->state == AST_SPEECH_STATE_NOT_READY || speech->state == AST_SPEECH_STATE_DONE) {
+ /* Before we go into waiting for stuff... make sure the structure is ready, if not - start it again */
+ if (speech->state == AST_SPEECH_STATE_NOT_READY || speech->state == AST_SPEECH_STATE_DONE) {
ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
- ast_speech_start(speech);
- }
+ ast_speech_start(speech);
+ }
/* Ensure no streams are currently running */
ast_stopstream(chan);
- /* Okay it's streaming so go into a loop grabbing frames! */
- while (done == 0) {
+ /* Okay it's streaming so go into a loop grabbing frames! */
+ while (done == 0) {
/* If the filename is null and stream is not running, start up a new sound file */
if (!quieted && (chan->streamid == -1 && chan->timingfunc == NULL) && (filename = strsep(&filename_tmp, "&"))) {
/* Discard old stream information */
speech_streamfile(chan, filename, chan->language);
}
- /* Run scheduled stuff */
- ast_sched_runq(chan->sched);
-
- /* Yay scheduling */
- res = ast_sched_wait(chan->sched);
- if (res < 0) {
- res = 1000;
- }
-
- /* If there is a frame waiting, get it - if not - oh well */
- if (ast_waitfor(chan, res) > 0) {
- f = ast_read(chan);
- if (f == NULL) {
- /* The channel has hung up most likely */
- done = 3;
- break;
- }
- }
+ /* Run scheduled stuff */
+ ast_sched_runq(chan->sched);
+
+ /* Yay scheduling */
+ res = ast_sched_wait(chan->sched);
+ if (res < 0)
+ res = 1000;
+
+ /* If there is a frame waiting, get it - if not - oh well */
+ if (ast_waitfor(chan, res) > 0) {
+ f = ast_read(chan);
+ if (f == NULL) {
+ /* The channel has hung up most likely */
+ done = 3;
+ break;
+ }
+ }
/* Do timeout check (shared between audio/dtmf) */
if ((!quieted || strlen(dtmf)) && started == 1) {
}
}
- /* Do checks on speech structure to see if it's changed */
- ast_mutex_lock(&speech->lock);
- if (ast_test_flag(speech, AST_SPEECH_QUIET)) {
+ /* Do checks on speech structure to see if it's changed */
+ ast_mutex_lock(&speech->lock);
+ if (ast_test_flag(speech, AST_SPEECH_QUIET)) {
if (chan->stream)
ast_stopstream(chan);
ast_clear_flag(speech, AST_SPEECH_QUIET);
quieted = 1;
- }
- /* Check state so we can see what to do */
- switch (speech->state) {
- case AST_SPEECH_STATE_READY:
- /* If audio playback has stopped do a check for timeout purposes */
- if (chan->streamid == -1 && chan->timingfunc == NULL)
- ast_stopstream(chan);
- if (!quieted && chan->stream == NULL && timeout && started == 0 && !filename_tmp) {
+ }
+ /* Check state so we can see what to do */
+ switch (speech->state) {
+ case AST_SPEECH_STATE_READY:
+ /* If audio playback has stopped do a check for timeout purposes */
+ if (chan->streamid == -1 && chan->timingfunc == NULL)
+ ast_stopstream(chan);
+ if (!quieted && chan->stream == NULL && timeout && started == 0 && !filename_tmp) {
if (timeout == -1) {
done = 1;
if (f)
}
time(&start);
started = 1;
- }
- /* Write audio frame out to speech engine if no DTMF has been received */
- if (!strlen(dtmf) && f != NULL && f->frametype == AST_FRAME_VOICE) {
- ast_speech_write(speech, f->data, f->datalen);
- }
- break;
- case AST_SPEECH_STATE_WAIT:
- /* Cue up waiting sound if not already playing */
+ }
+ /* Write audio frame out to speech engine if no DTMF has been received */
+ if (!strlen(dtmf) && f != NULL && f->frametype == AST_FRAME_VOICE) {
+ ast_speech_write(speech, f->data, f->datalen);
+ }
+ break;
+ case AST_SPEECH_STATE_WAIT:
+ /* Cue up waiting sound if not already playing */
if (!strlen(dtmf)) {
if (chan->stream == NULL) {
if (speech->processing_sound != NULL) {
}
}
}
- break;
- case AST_SPEECH_STATE_DONE:
+ break;
+ case AST_SPEECH_STATE_DONE:
/* Now that we are done... let's switch back to not ready state */
ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
if (!strlen(dtmf)) {
ast_stopstream(chan);
}
}
- break;
- default:
- break;
- }
- ast_mutex_unlock(&speech->lock);
-
- /* Deal with other frame types */
- if (f != NULL) {
- /* Free the frame we received */
- switch (f->frametype) {
- case AST_FRAME_DTMF:
+ break;
+ default:
+ break;
+ }
+ ast_mutex_unlock(&speech->lock);
+
+ /* Deal with other frame types */
+ if (f != NULL) {
+ /* Free the frame we received */
+ switch (f->frametype) {
+ case AST_FRAME_DTMF:
if (dtmf_terminator != '\0' && f->subclass == dtmf_terminator) {
done = 1;
} else {
if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
done = 1;
}
- break;
- case AST_FRAME_CONTROL:
- switch (f->subclass) {
- case AST_CONTROL_HANGUP:
- /* Since they hung up we should destroy the speech structure */
- done = 3;
- default:
- break;
- }
- default:
- break;
- }
- ast_frfree(f);
- f = NULL;
- }
- }
-
- if (strlen(dtmf)) {
+ break;
+ case AST_FRAME_CONTROL:
+ switch (f->subclass) {
+ case AST_CONTROL_HANGUP:
+ /* Since they hung up we should destroy the speech structure */
+ done = 3;
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ ast_frfree(f);
+ f = NULL;
+ }
+ }
+
+ if (!ast_strlen_zero(dtmf)) {
/* We sort of make a results entry */
speech->results = ast_calloc(1, sizeof(*speech->results));
if (speech->results != NULL) {
}
}
- /* See if it was because they hung up */
- if (done == 3) {
- /* Destroy speech structure */
- ast_speech_destroy(speech);
- datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
- if (datastore != NULL) {
- ast_channel_datastore_remove(chan, datastore);
- }
- } else {
- /* Channel is okay so restore read format */
- ast_set_read_format(chan, oldreadformat);
- }
+ /* See if it was because they hung up */
+ if (done == 3) {
+ /* Destroy speech structure */
+ ast_speech_destroy(speech);
+ datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
+ if (datastore != NULL)
+ ast_channel_datastore_remove(chan, datastore);
+ } else {
+ /* Channel is okay so restore read format */
+ ast_set_read_format(chan, oldreadformat);
+ }
- return 0;
+ return 0;
}
res |= ast_unregister_application("SpeechLoadGrammar");
res |= ast_unregister_application("SpeechUnloadGrammar");
res |= ast_unregister_application("SpeechActivateGrammar");
- res |= ast_unregister_application("SpeechDeactivateGrammar");
+ res |= ast_unregister_application("SpeechDeactivateGrammar");
res |= ast_unregister_application("SpeechStart");
res |= ast_unregister_application("SpeechBackground");
res |= ast_unregister_application("SpeechDestroy");
res |= ast_register_application("SpeechLoadGrammar", speech_load, "Load a Grammar", speechload_descrip);
res |= ast_register_application("SpeechUnloadGrammar", speech_unload, "Unload a Grammar", speechunload_descrip);
res |= ast_register_application("SpeechActivateGrammar", speech_activate, "Activate a Grammar", speechactivategrammar_descrip);
- res |= ast_register_application("SpeechDeactivateGrammar", speech_deactivate, "Deactivate a Grammar", speechdeactivategrammar_descrip);
+ res |= ast_register_application("SpeechDeactivateGrammar", speech_deactivate, "Deactivate a Grammar", speechdeactivategrammar_descrip);
res |= ast_register_application("SpeechStart", speech_start, "Start recognizing voice in the audio stream", speechstart_descrip);
res |= ast_register_application("SpeechBackground", speech_background, "Play a sound file and wait for speech to be recognized", speechbackground_descrip);
res |= ast_register_application("SpeechDestroy", speech_destroy, "End speech recognition", speechdestroy_descrip);
static const char *pop_synopsis = "Remove one address from gosub stack";
static const char *gosub_descrip =
-"Gosub([[context|]exten|]priority[(arg1[|...][|argN])])\n"
+"Gosub([[context,]exten,]priority[(arg1[,...][,argN])])\n"
" Jumps to the label specified, saving the return address.\n";
static const char *gosubif_descrip =
-"GosubIf(condition?labeliftrue[(arg1[|...])][:labeliffalse[(arg1[|...])]])\n"
+"GosubIf(condition?labeliftrue[(arg1[,...])][:labeliffalse[(arg1[,...])]])\n"
" If the condition is true, then jump to labeliftrue. If false, jumps to\n"
"labeliffalse, if specified. In either case, a jump saves the return point\n"
"in the dialplan, to be returned to with a Return.\n";
static char *synopsis = "Background a file with talk detect";
static char *descrip =
-" BackgroundDetect(filename[|sil[|min|[max]]]): Plays back a given\n"
+" BackgroundDetect(filename[,sil[,min,[max]]]): Plays back a given\n"
"filename, waiting for interruption from a given digit (the digit must\n"
"start the beginning of a valid extension, or it will be ignored).\n"
"During the playback of the file, audio is monitored in the receive\n"
static const char *synopsis = "Transfer caller to remote extension";
static const char *descrip =
-" Transfer([Tech/]dest[|options]): Requests the remote caller be transferred\n"
+" Transfer([Tech/]dest[,options]): Requests the remote caller be transferred\n"
"to a given destination. If TECH (SIP, IAX2, LOCAL etc) is used, only\n"
"an incoming call with the same channel technology will be transfered.\n"
"Note that for SIP, if you transfer before call is setup, a 302 redirect\n"
);
if (ast_strlen_zero((char *)data)) {
- ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n");
+ ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[,options])\n");
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
return 0;
} else
static char *synopsis = "Send a URL";
static char *descrip =
-" SendURL(URL[|option]): Requests client go to URL (IAX2) or sends the \n"
+" SendURL(URL[,option]): Requests client go to URL (IAX2) or sends the \n"
"URL to the client (other channels).\n"
"Result is returned in the SENDURLSTATUS channel variable:\n"
" SUCCESS URL successfully sent to client\n"
static char *synopsis = "Send an arbitrary event to the manager interface";
static char *descrip =
-" UserEvent(eventname[|body]): Sends an arbitrary event to the manager\n"
+" UserEvent(eventname[,body]): Sends an arbitrary event to the manager\n"
"interface, with an optional body representing additional arguments. The\n"
"body may be specified as a | delimeted list of headers. Each additional\n"
"argument will be placed on a new line in the event. The format of the\n"
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "UserEvent requires an argument (eventname|optional event body)\n");
+ ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
return -1;
}
static char *synopsis_vm = "Leave a Voicemail message";
static char *descrip_vm =
- " VoiceMail(mailbox[@context][&mailbox[@context]][...][|options]): This\n"
+ " VoiceMail(mailbox[@context][&mailbox[@context]][...][,options]): This\n"
"application allows the calling party to leave a message for the specified\n"
"list of mailboxes. When multiple mailboxes are specified, the greeting will\n"
"be taken from the first mailbox specified. Dialplan execution will stop if the\n"
static char *synopsis_vmain = "Check Voicemail messages";
static char *descrip_vmain =
- " VoiceMailMain([mailbox][@context][|options]): This application allows the\n"
+ " VoiceMailMain([mailbox][@context][,options]): This application allows the\n"
"calling party to check voicemail messages. A specific mailbox, and optional\n"
"corresponding context, may be specified. If a mailbox is not provided, the\n"
"calling party will be prompted to enter one. If a context is not specified,\n"
"Check to see if Voicemail mailbox exists";
static char *descrip_vm_box_exists =
- " MailboxExists(mailbox[@context][|options]): Check to see if the specified\n"
+ " MailboxExists(mailbox[@context][,options]): Check to see if the specified\n"
"mailbox exists. If no voicemail context is specified, the 'default' context\n"
"will be used.\n"
" This application will set the following channel variable upon completion:\n"
static char *synopsis_vmauthenticate = "Authenticate with Voicemail passwords";
static char *descrip_vmauthenticate =
- " VMAuthenticate([mailbox][@context][|options]): This application behaves the\n"
+ " VMAuthenticate([mailbox][@context][,options]): This application behaves the\n"
"same way as the Authenticate application, but the passwords are taken from\n"
"voicemail.conf.\n"
" If the mailbox is specified, only that mailbox's password will be considered\n"
static char *app = "WaitForSilence";
static char *synopsis = "Waits for a specified amount of silence";
static char *descrip =
-" WaitForSilence(silencerequired[|iterations][|timeout]) \n"
+" WaitForSilence(silencerequired[,iterations][,timeout]) \n"
"Wait for Silence: Waits for up to 'silencerequired' \n"
"milliseconds of silence, 'iterations' times or once if omitted.\n"
"An optional timeout specified the number of seconds to return\n"
"include two or more calls to WaitForSilence when dealing with an answering\n"
"machine; first waiting for the spiel to finish, then waiting for the beep, etc.\n\n"
"Examples:\n"
-" - WaitForSilence(500|2) will wait for 1/2 second of silence, twice\n"
+" - WaitForSilence(500,2) will wait for 1/2 second of silence, twice\n"
" - WaitForSilence(1000) will wait for 1 second of silence, once\n"
-" - WaitForSilence(300|3|10) will wait for 300ms silence, 3 times,\n"
+" - WaitForSilence(300,3,10) will wait for 300ms silence, 3 times,\n"
" and returns after 10 sec, even if silence is not detected\n\n"
"Sets the channel variable WAITSTATUS with to one of these values:\n"
"SILENCE - if exited with silence detected\n"
res = ast_answer(chan); /* Answer the channel */
- if (!data || ( (sscanf(data, "%d|%d|%d", &silencereqd, &iterations, &timeout) != 3) &&
+ if (!data || ( (sscanf(data, "%d,%d,%d", &silencereqd, &iterations, &timeout) != 3) &&
(sscanf(data, "%d|%d", &silencereqd, &iterations) != 2) &&
(sscanf(data, "%d", &silencereqd) != 1) ) ) {
ast_log(LOG_WARNING, "Using default value of 1000ms, 1 iteration, no timeout\n");
static struct ast_custom_function cdr_function = {
.name = "CDR",
.synopsis = "Gets or sets a CDR variable",
- .syntax = "CDR(<name>[|options])",
+ .syntax = "CDR(<name>[,options])",
.read = cdr_read,
.write = cdr_write,
.desc =
" and this variable will be stored on the cdr.\n"
" raw values for disposition:\n"
" 1 = NO ANSWER\n"
-" 2 = BUSY\n"
-" 3 = FAILED\n"
-" 4 = ANSWERED\n"
+" 2 = BUSY\n"
+" 3 = FAILED\n"
+" 4 = ANSWERED\n"
" raw values for amaflags:\n"
" 1 = OMIT\n"
" 2 = BILLING\n"
" remote_count Number of transmitted packets\n"
" rtt Round trip time\n"
" all All statistics (in a form suited to logging, but not for parsing)\n"
- "R/O rtpdest Get remote RTP destination information\n"
- " This option takes one additional argument:\n"
- " Argument 1:\n"
- " audio Get audio destination\n"
- " video Get video destination\n"
+ "R/O rtpdest Get remote RTP destination information\n"
+ " This option takes one additional argument:\n"
+ " Argument 1:\n"
+ " audio Get audio destination\n"
+ " video Get video destination\n"
"\n"
"chan_iax2 provides the following additional options:\n"
"R/W osptoken Get or set the OSP token information for a call\n"
struct ast_custom_function acf_curl = {
.name = "CURL",
.synopsis = "Retrieves the contents of a URL",
- .syntax = "CURL(url[|post-data])",
+ .syntax = "CURL(url[,post-data])",
.desc =
" url - URL to retrieve\n"
" post-data - Optional data to send as a POST (GET is default action)\n",
#include "asterisk/enum.h"
#include "asterisk/app.h"
-static char *synopsis = "Syntax: ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])\n";
+static char *synopsis = "Syntax: ENUMLOOKUP(number[,Method-type[,options[,record#[,zone-suffix]]]])\n";
static int function_enum(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
static struct ast_custom_function enum_query_function = {
.name = "ENUMQUERY",
.synopsis = "Initiate an ENUM query",
- .syntax = "ENUMQUERY(number[|Method-type[|zone-suffix]])",
+ .syntax = "ENUMQUERY(number[,Method-type[,zone-suffix]])",
.desc = "This will do a ENUM lookup of the given phone number.\n"
"If no method-tpye is given, the default will be sip. If no\n"
"zone-suffix is given, the default will be \"e164.arpa\".\n"
static struct ast_custom_function enum_result_function = {
.name = "ENUMRESULT",
.synopsis = "Retrieve results from a ENUMQUERY",
- .syntax = "ENUMRESULT(id|resultnum)",
+ .syntax = "ENUMRESULT(id,resultnum)",
.desc = "This function will retrieve results from a previous use\n"
"of the ENUMQUERY function.\n"
" id - This argument is the identifier returned by the ENUMQUERY function.\n"
.synopsis =
"General or specific querying of NAPTR records for ENUM or ENUM-like DNS pointers",
.syntax =
- "ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])",
+ "ENUMLOOKUP(number[,Method-type[,options[,record#[,zone-suffix]]]])",
.desc =
"Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n"
"Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n"
}
}
- if ((tmp = ast_variable_retrieve(cfg, catg, "read"))) {
- ast_log(LOG_WARNING, "Parameter 'read' is deprecated for category %s. Please use 'readsql' instead.\n", catg);
+ if ((tmp = ast_variable_retrieve(cfg, catg, "readsql")))
ast_copy_string((*query)->sql_read, tmp, sizeof((*query)->sql_read));
- } else if ((tmp = ast_variable_retrieve(cfg, catg, "readsql")))
+ else if ((tmp = ast_variable_retrieve(cfg, catg, "read"))) {
+ ast_log(LOG_WARNING, "Parameter 'read' is deprecated for category %s. Please use 'readsql' instead.\n", catg);
ast_copy_string((*query)->sql_read, tmp, sizeof((*query)->sql_read));
+ }
if (!ast_strlen_zero((*query)->sql_read) && ast_strlen_zero((*query)->readhandle[0])) {
ast_free(*query);
return EINVAL;
}
- if ((tmp = ast_variable_retrieve(cfg, catg, "write"))) {
- ast_log(LOG_WARNING, "Parameter 'write' is deprecated for category %s. Please use 'writesql' instead.\n", catg);
+ if ((tmp = ast_variable_retrieve(cfg, catg, "writesql")))
ast_copy_string((*query)->sql_write, tmp, sizeof((*query)->sql_write));
- } else if ((tmp = ast_variable_retrieve(cfg, catg, "writesql")))
+ else if ((tmp = ast_variable_retrieve(cfg, catg, "write"))) {
+ ast_log(LOG_WARNING, "Parameter 'write' is deprecated for category %s. Please use 'writesql' instead.\n", catg);
ast_copy_string((*query)->sql_write, tmp, sizeof((*query)->sql_write));
+ }
if (!ast_strlen_zero((*query)->sql_write) && ast_strlen_zero((*query)->writehandle[0])) {
ast_free(*query);
"Gets or sets various channel timeouts. The timeouts that can be\n"
"manipulated are:\n" "\n"
"absolute: The absolute maximum amount of time permitted for a call. A\n"
- " setting of 0 disables the timeout.\n" "\n"
+ " setting of 0 disables the timeout.\n" "\n"
"digit: The maximum amount of time permitted between digits when the\n"
" user is typing in an extension. When this timeout expires,\n"
" after the user has started to type in an extension, the\n"
" extension, or if it doesn't exist the call would be\n"
" terminated). The default timeout is 5 seconds.\n" "\n"
"response: The maximum amount of time permitted after falling through a\n"
- " series of priorities for a channel in which the user may\n"
- " begin typing an extension. If the user does not type an\n"
- " extension in this amount of time, control will pass to the\n"
- " 't' extension if it exists, and if not the call would be\n"
- " terminated. The default timeout is 10 seconds.\n",
+ " series of priorities for a channel in which the user may\n"
+ " begin typing an extension. If the user does not type an\n"
+ " extension in this amount of time, control will pass to the\n"
+ " 't' extension if it exists, and if not the call would be\n"
+ " terminated. The default timeout is 10 seconds.\n",
.read = timeout_read,
.write = timeout_write,
};
static char *deadsynopsis = "Executes AGI on a hungup channel";
static char *descrip =
-" [E|Dead]AGI(command|args): Executes an Asterisk Gateway Interface compliant\n"
+" [E|Dead]AGI(command,args): Executes an Asterisk Gateway Interface compliant\n"
"program on a channel. AGI allows Asterisk to launch external programs\n"
"written in any language to control a telephony channel, play audio,\n"
"read DTMF digits, etc. by communicating with the AGI protocol on stdin\n"
static char *monitor_synopsis = "Monitor a channel";
-static char *monitor_descrip = "Monitor([file_format[:urlbase]|[fname_base]|[options]]):\n"
+static char *monitor_descrip = "Monitor([file_format[:urlbase],[fname_base],[options]]):\n"
"Used to start monitoring a channel. The channel's input and output\n"
"voice packets are logged to files until the channel hangs up or\n"
"monitoring is stopped by the StopMonitor application.\n"
static int start_monitor_exec(struct ast_channel *chan, void *data)
{
char *arg = NULL;
- char *format = NULL;
- char *fname_base = NULL;
char *options = NULL;
char *delay = NULL;
char *urlprefix = NULL;
int joinfiles = 0;
int waitforbridge = 0;
int res = 0;
+ char *parse;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(format);
+ AST_APP_ARG(fname_base);
+ AST_APP_ARG(options);
+ );
/* Parse arguments. */
- if (!ast_strlen_zero((char*)data)) {
- arg = ast_strdupa((char*)data);
- format = arg;
- fname_base = strchr(arg, '|');
- if (fname_base) {
- *fname_base = 0;
- fname_base++;
- if ((options = strchr(fname_base, '|'))) {
- *options = 0;
- options++;
- if (strchr(options, 'm'))
- stream_action |= X_JOIN;
- if (strchr(options, 'b'))
- waitforbridge = 1;
- if (strchr(options, 'i'))
- stream_action &= ~X_REC_IN;
- if (strchr(options, 'o'))
- stream_action &= ~X_REC_OUT;
- }
- }
- arg = strchr(format,':');
- if (arg) {
- *arg++ = 0;
- urlprefix = arg;
- }
+ if (ast_strlen_zero((char*)data)) {
+ ast_log(LOG_ERROR, "Monitor requires an argument\n");
+ return 0;
}
+
+ parse = ast_strdupa((char*)data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (strchr(args.options, 'm'))
+ stream_action |= X_JOIN;
+ if (strchr(args.options, 'b'))
+ waitforbridge = 1;
+ if (strchr(args.options, 'i'))
+ stream_action &= ~X_REC_IN;
+ if (strchr(args.options, 'o'))
+ stream_action &= ~X_REC_OUT;
+
+ arg = strchr(args.format, ':');
+ if (arg) {
+ *arg++ = 0;
+ urlprefix = arg;
+ }
+
if (urlprefix) {
- snprintf(tmp,sizeof(tmp) - 1,"%s/%s.%s",urlprefix,fname_base,
- ((strcmp(format,"gsm")) ? "wav" : "gsm"));
+ snprintf(tmp, sizeof(tmp), "%s/%s.%s", urlprefix, args.fname_base,
+ ((strcmp(args.format, "gsm")) ? "wav" : "gsm"));
if (!chan->cdr && !(chan->cdr = ast_cdr_alloc()))
return -1;
ast_cdr_setuserfield(chan, tmp);
arg = strchr(options, 'b');
if (arg) {
*arg = 'X';
- pbx_builtin_setvar_helper(chan,"AUTO_MONITOR",delay);
+ pbx_builtin_setvar_helper(chan,"AUTO_MONITOR", delay);
}
}
return 0;
}
- res = ast_monitor_start(chan, format, fname_base, 1, stream_action);
+ res = ast_monitor_start(chan, args.format, args.fname_base, 1, stream_action);
if (res < 0)
- res = ast_monitor_change_fname(chan, fname_base, 1);
+ res = ast_monitor_change_fname(chan, args.fname_base, 1);
if (stream_action & X_JOIN) {
if ((stream_action & X_REC_IN) && (stream_action & X_REC_OUT))