aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-17 16:29:44 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-17 16:29:44 +0000
commit3ce8f8c39b01d4f6825d8496a432e951f41cff08 (patch)
tree22eeb580fe3c03543c5d44dfbc66132a3714fa8b /funcs
parent811546a2d06bc94a28e6ba1173134d41155cb88e (diff)
Add 'l' option to CDR dialplan function which will cause it to pass the last CDR record to getvar instead of the first. (issue #7689 reported by voipgate)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40226 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_cdr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 96a8f7f17..f3606662b 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -42,9 +42,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
enum {
OPT_RECURSIVE = (1 << 0),
OPT_UNPARSED = (1 << 1),
+ OPT_LAST = (1 << 2),
} cdr_option_flags;
AST_APP_OPTIONS(cdr_func_options, {
+ AST_APP_OPTION('l', OPT_LAST),
AST_APP_OPTION('r', OPT_RECURSIVE),
AST_APP_OPTION('u', OPT_UNPARSED),
});
@@ -54,6 +56,7 @@ static int cdr_read(struct ast_channel *chan, char *cmd, char *parse,
{
char *ret;
struct ast_flags flags = { 0 };
+ struct ast_cdr *cdr = chan->cdr;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(variable);
AST_APP_ARG(options);
@@ -62,7 +65,7 @@ static int cdr_read(struct ast_channel *chan, char *cmd, char *parse,
if (ast_strlen_zero(parse))
return -1;
- if (!chan->cdr)
+ if (!cdr)
return -1;
AST_STANDARD_APP_ARGS(args, parse);
@@ -70,7 +73,11 @@ static int cdr_read(struct ast_channel *chan, char *cmd, char *parse,
if (!ast_strlen_zero(args.options))
ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
- ast_cdr_getvar(chan->cdr, args.variable, &ret, buf, len,
+ if (ast_test_flag(&flags, OPT_LAST))
+ while (cdr->next)
+ cdr = cdr->next;
+
+ ast_cdr_getvar(cdr, args.variable, &ret, buf, len,
ast_test_flag(&flags, OPT_RECURSIVE),
ast_test_flag(&flags, OPT_UNPARSED));