Janitor for Zapateller: convert to use argument macros

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44100 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Tilghman Lesher 19 years ago
parent 3cea4702a3
commit 235f8f5bcf

@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h" #include "asterisk/pbx.h"
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/app.h"
static char *app = "Zapateller"; static char *app = "Zapateller";
@ -59,36 +60,36 @@ static int zapateller_exec(struct ast_channel *chan, void *data)
{ {
int res = 0; int res = 0;
struct ast_module_user *u; struct ast_module_user *u;
int answer = 0, nocallerid = 0; int i, answer = 0, nocallerid = 0;
char *c; char *parse = ast_strdupa((char *)data);
char *stringp=NULL; AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(options)[2];
);
u = ast_module_user_add(chan); u = ast_module_user_add(chan);
stringp=data; AST_STANDARD_APP_ARGS(args, parse);
c = strsep(&stringp, "|");
while(!ast_strlen_zero(c)) { for (i = 0; i < args.argc; i++) {
if (!strcasecmp(c, "answer")) if (!strcasecmp(args.options[i], "answer"))
answer = 1; answer = 1;
else if (!strcasecmp(c, "nocallerid")) else if (!strcasecmp(args.options[i], "nocallerid"))
nocallerid = 1; nocallerid = 1;
}
c = strsep(&stringp, "|");
}
ast_stopstream(chan); ast_stopstream(chan);
if (chan->_state != AST_STATE_UP) { if (chan->_state != AST_STATE_UP) {
if (answer) if (answer)
res = ast_answer(chan); res = ast_answer(chan);
if (!res) { if (!res)
res = ast_safe_sleep(chan, 500); res = ast_safe_sleep(chan, 500);
}
} }
if (chan->cid.cid_num && nocallerid) {
if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid) {
ast_module_user_remove(u); ast_module_user_remove(u);
return res; return res;
} }
if (!res) if (!res)
res = ast_tonepair(chan, 950, 0, 330, 0); res = ast_tonepair(chan, 950, 0, 330, 0);
if (!res) if (!res)
@ -97,6 +98,7 @@ static int zapateller_exec(struct ast_channel *chan, void *data)
res = ast_tonepair(chan, 1800, 0, 330, 0); res = ast_tonepair(chan, 1800, 0, 330, 0);
if (!res) if (!res)
res = ast_tonepair(chan, 0, 0, 1000, 0); res = ast_tonepair(chan, 0, 0, 1000, 0);
ast_module_user_remove(u); ast_module_user_remove(u);
return res; return res;
} }

Loading…
Cancel
Save