[Asterisk-cvs] asterisk ChangeLog, 1.35, 1.36 cdr.c, 1.57,
1.58 pbx.c, 1.295, 1.296
russell
russell
Sun Nov 6 16:09:22 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv4878
Modified Files:
ChangeLog cdr.c pbx.c
Log Message:
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.
Index: ChangeLog
===================================================================
RCS file: /usr/cvsroot/asterisk/ChangeLog,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- ChangeLog 6 Nov 2005 19:44:39 -0000 1.35
+++ ChangeLog 6 Nov 2005 21:00:34 -0000 1.36
@@ -6,6 +6,7 @@
* 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: 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 at digium.com>
Index: cdr.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- cdr.c 28 Oct 2005 16:35:43 -0000 1.57
+++ cdr.c 6 Nov 2005 21:00:34 -0000 1.58
@@ -809,16 +809,18 @@
}
}
-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_flags flags = { 0 };
+ if (_flags)
+ ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
while (cdr) {
/* 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(&tmp, AST_CDR_FLAG_POSTED)) {
+ if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+ if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
ast_cdr_end(cdr);
if ((dup = ast_cdr_dup(cdr))) {
ast_cdr_detach(dup);
@@ -827,7 +829,7 @@
}
/* 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);
}
Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -d -r1.295 -r1.296
--- pbx.c 3 Nov 2005 21:19:10 -0000 1.295
+++ pbx.c 6 Nov 2005 21:00:34 -0000 1.296
@@ -5405,15 +5405,21 @@
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 @@
}
/* 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;
}
More information about the svn-commits
mailing list