summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-06-19 01:28:40 +0000
committerMatthew Jordan <mjordan@digium.com>2013-06-19 01:28:40 +0000
commit68103abba38b3ccd362dd1e9018b4045b9b7cb57 (patch)
tree27546c663cc6fa131b1e2051947947f0321ce8f4 /funcs
parentda1f4f0c3d62c23316471a87ccd6101c17329197 (diff)
Handle variable substitution in dummy variables
When func_cdr is used for variable substitution, there is no channel name and hence no run-time information available for CDR variable substitution. In that case, the correct thing to do is to use the CDR object on the channel passed to the function. This patch checks to see if the channel passed in has a name - if not, it uses ast_cdr_format_var instead of ast_cdr_get_var. This allows CDR backends to continue to use variable substitution in order to resolve ast_cdr object properties. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_cdr.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 492716dcf..762523869 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -205,8 +205,9 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
char *buf, size_t len)
{
char format_buf[128];
+ char *value = NULL;
struct ast_flags flags = { 0 };
- char tempbuf[128];
+ char tempbuf[512];
char *info;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(variable);
@@ -228,7 +229,15 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
}
- if (ast_cdr_getvar(ast_channel_name(chan), args.variable, tempbuf, sizeof(tempbuf))) {
+ if (ast_strlen_zero(ast_channel_name(chan))) {
+ /* Format request on a dummy channel */
+ ast_cdr_format_var(ast_channel_cdr(chan), args.variable, &value, tempbuf, sizeof(tempbuf), 0);
+ if (ast_strlen_zero(value)) {
+ return 0;
+ }
+ ast_copy_string(tempbuf, value, sizeof(tempbuf));
+ ast_set_flag(&flags, OPT_UNPARSED);
+ }else if (ast_cdr_getvar(ast_channel_name(chan), args.variable, tempbuf, sizeof(tempbuf))) {
return 0;
}