Index: apps/app_sendtext.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_sendtext.c,v retrieving revision 1.14 diff -u -r1.14 app_sendtext.c --- apps/app_sendtext.c 6 Nov 2005 15:09:46 -0000 1.14 +++ apps/app_sendtext.c 7 Nov 2005 19:50:14 -0000 @@ -41,6 +41,7 @@ #include "asterisk/translate.h" #include "asterisk/image.h" #include "asterisk/options.h" +#include "asterisk/app.h" static const char *tdesc = "Send Text Applications"; @@ -49,7 +50,7 @@ static const char *synopsis = "Send a Text Message"; static const char *descrip = -" SendText(text): Sends text to current channel (callee).\n" +" SendText(text[|options]): Sends text to current channel (callee).\n" "Otherwise, execution will continue at the next priority level.\n" "Result of transmission will be stored in the SENDTEXTSTATUS\n" "channel variable:\n" @@ -58,11 +59,12 @@ " UNSUPPORTED Text transmission not supported by channel\n" "\n" "At this moment, text is supposed to be 7 bit ASCII in most channels.\n" +"The option string many contain zero or the following character:\n" +"'j' -- jump to n+101 priority if the client doesn't support\n" +" text transport\n" "Old deprecated behavior: \n" " SendText only returns 0 if the text was sent correctly or if\n" -" the channel does not support text transport.\n" -" If the client does not support text transport, and there exists a\n" -" step with priority n + 101, then execution will continue at that step.\n"; +" the channel does not support text transport.\n"; STANDARD_LOCAL_USER; @@ -73,26 +75,47 @@ int res = 0; struct localuser *u; char *status = "UNSUPPORTED"; + char *parse = NULL; + int priority_jump = 0; + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(text); + AST_APP_ARG(options); + ); + LOCAL_USER_ADD(u); + if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "SendText requires an argument (text)\n"); + ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n"); + LOCAL_USER_REMOVE(u); return -1; + } else { + parse = ast_strdupa(data); + if (!parse) { + ast_log(LOG_ERROR, "Out of memory!\n"); + LOCAL_USER_REMOVE(u); + return -1; + } } - LOCAL_USER_ADD(u); + AST_STANDARD_APP_ARGS(args, parse); + + if (args.options) { + if (strchr(args.options, 'j')) + priority_jump = 1; + } ast_mutex_lock(&chan->lock); if (!chan->tech->send_text) { ast_mutex_unlock(&chan->lock); /* Does not support transport */ - if (option_priority_jumping) + if (priority_jump || option_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); LOCAL_USER_REMOVE(u); return 0; } status = "FAILURE"; ast_mutex_unlock(&chan->lock); - res = ast_sendtext(chan, (char *)data); + res = ast_sendtext(chan, args.text); if (!res) status = "SUCCESS"; pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);