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
1.2-netsec
Russell Bryant 20 years ago
parent bb7eb69c09
commit 7d4a5abb1d

@ -6,6 +6,7 @@
* apps/app_externalivr.c: Add a space that fixes building on older versions of gcc * apps/app_externalivr.c: Add a space that fixes building on older versions of gcc
* many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels. * many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels.
* many files: Update applications to add an exit status variable, make priority jumping optional, and use new args parsing macros * many files: Update applications to add an exit status variable, make priority jumping optional, and use new args parsing macros
* pbx.c cdr.c res/res_features.c apps/app_dial.c include/asterisk/cdr.h: 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.
2005-11-05 Kevin P. Fleming <kpfleming@digium.com> 2005-11-05 Kevin P. Fleming <kpfleming@digium.com>

@ -828,7 +828,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
} }
if (ast_test_flag(&opts, OPT_RESETCDR) && chan->cdr) if (ast_test_flag(&opts, OPT_RESETCDR) && chan->cdr)
ast_cdr_reset(chan->cdr, 0); ast_cdr_reset(chan->cdr, NULL);
if (ast_test_flag(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY])) if (ast_test_flag(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
opt_args[OPT_ARG_PRIVACY] = ast_strdupa(chan->exten); opt_args[OPT_ARG_PRIVACY] = ast_strdupa(chan->exten);
if (ast_test_flag(&opts, OPT_PRIVACY) || ast_test_flag(&opts, OPT_SCREENING)) { if (ast_test_flag(&opts, OPT_PRIVACY) || ast_test_flag(&opts, OPT_SCREENING)) {

12
cdr.c

@ -809,16 +809,18 @@ static void post_cdr(struct ast_cdr *cdr)
} }
} }
void ast_cdr_reset(struct ast_cdr *cdr, int flags) void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
{ {
struct ast_flags tmp = {flags};
struct ast_cdr *dup; struct ast_cdr *dup;
struct ast_flags flags = { 0 };
if (_flags)
ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
while (cdr) { while (cdr) {
/* Detach if post is requested */ /* Detach if post is requested */
if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) { if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
ast_cdr_end(cdr); ast_cdr_end(cdr);
if ((dup = ast_cdr_dup(cdr))) { if ((dup = ast_cdr_dup(cdr))) {
ast_cdr_detach(dup); ast_cdr_detach(dup);
@ -827,7 +829,7 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags)
} }
/* clear variables */ /* clear variables */
if (!ast_test_flag(&tmp, AST_CDR_FLAG_KEEP_VARS)) { if (!ast_test_flag(&flags, AST_CDR_FLAG_KEEP_VARS)) {
ast_cdr_free_vars(cdr, 0); ast_cdr_free_vars(cdr, 0);
} }

@ -45,6 +45,7 @@
/* Include channel.h after relevant declarations it will need */ /* Include channel.h after relevant declarations it will need */
#include "asterisk/channel.h" #include "asterisk/channel.h"
#include "asterisk/utils.h"
struct ast_channel; struct ast_channel;
@ -256,7 +257,7 @@ extern char *ast_cdr_disp2str(int disposition);
* \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it * \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it
* |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's * |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's
*/ */
extern void ast_cdr_reset(struct ast_cdr *cdr, int flags); extern void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
/*! Flags to a string */ /*! Flags to a string */
/*! /*!

40
pbx.c

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

@ -216,20 +216,20 @@ static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *call
static void *ast_bridge_call_thread(void *data) static void *ast_bridge_call_thread(void *data)
{ {
struct ast_bridge_thread_obj *tobj = data; struct ast_bridge_thread_obj *tobj = data;
tobj->chan->appl = "Transferred Call"; tobj->chan->appl = "Transferred Call";
tobj->chan->data = tobj->peer->name; tobj->chan->data = tobj->peer->name;
tobj->peer->appl = "Transferred Call"; tobj->peer->appl = "Transferred Call";
tobj->peer->data = tobj->chan->name; tobj->peer->data = tobj->chan->name;
if (tobj->chan->cdr) { if (tobj->chan->cdr) {
ast_cdr_reset(tobj->chan->cdr,0); ast_cdr_reset(tobj->chan->cdr, NULL);
ast_cdr_setdestchan(tobj->chan->cdr, tobj->peer->name); ast_cdr_setdestchan(tobj->chan->cdr, tobj->peer->name);
} }
if (tobj->peer->cdr) { if (tobj->peer->cdr) {
ast_cdr_reset(tobj->peer->cdr,0); ast_cdr_reset(tobj->peer->cdr, NULL);
ast_cdr_setdestchan(tobj->peer->cdr, tobj->chan->name); ast_cdr_setdestchan(tobj->peer->cdr, tobj->chan->name);
} }
ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig); ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
ast_hangup(tobj->chan); ast_hangup(tobj->chan);
ast_hangup(tobj->peer); ast_hangup(tobj->peer);

Loading…
Cancel
Save