Convert some built-in applications to use new args parsing macros.

Change ast_cdr_reset to take a pointer to an ast_flags structure instead of an integer for flags.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6987 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2005-11-06 21:00:35 +00:00
parent bb7eb69c09
commit 7d4a5abb1d
6 changed files with 41 additions and 23 deletions

40
pbx.c
View File

@@ -5405,15 +5405,21 @@ static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
static int pbx_builtin_answer(struct ast_channel *chan, void *data)
{
int delay = atoi(data);
int delay = 0;
int res;
if (chan->_state == AST_STATE_UP)
delay = 0;
else if (!ast_strlen_zero(data))
delay = atoi(data);
res = ast_answer(chan);
if (res)
return res;
if (delay)
res = ast_safe_sleep(chan, delay);
return res;
}
@@ -5427,26 +5433,34 @@ static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data)
}
/* Copy the language as specified */
if (data)
ast_copy_string(chan->language, (char *) data, sizeof(chan->language));
if (!ast_strlen_zero(data))
ast_copy_string(chan->language, data, sizeof(chan->language));
return 0;
}
AST_APP_OPTIONS(resetcdr_opts, {
AST_APP_OPTION('w', AST_CDR_FLAG_POSTED),
AST_APP_OPTION('a', AST_CDR_FLAG_LOCKED),
AST_APP_OPTION('v', AST_CDR_FLAG_KEEP_VARS),
});
static int pbx_builtin_resetcdr(struct ast_channel *chan, void *data)
{
int flags = 0;
/* Reset the CDR as specified */
if(data) {
if(strchr((char *)data, 'w'))
flags |= AST_CDR_FLAG_POSTED;
if(strchr((char *)data, 'a'))
flags |= AST_CDR_FLAG_LOCKED;
if(strchr((char *)data, 'v'))
flags |= AST_CDR_FLAG_KEEP_VARS;
char *args;
struct ast_flags flags = { 0 };
if (!ast_strlen_zero(data)) {
args = ast_strdupa(data);
if (!args) {
ast_log(LOG_ERROR, "Out of memory!\n");
return -1;
}
ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
}
ast_cdr_reset(chan->cdr, flags);
ast_cdr_reset(chan->cdr, &flags);
return 0;
}