[asterisk-commits] mjordan: trunk r392214 - /trunk/funcs/func_cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 18 20:28:41 CDT 2013


Author: mjordan
Date: Tue Jun 18 20:28:40 2013
New Revision: 392214

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392214
Log:
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.

Modified:
    trunk/funcs/func_cdr.c

Modified: trunk/funcs/func_cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_cdr.c?view=diff&rev=392214&r1=392213&r2=392214
==============================================================================
--- trunk/funcs/func_cdr.c (original)
+++ trunk/funcs/func_cdr.c Tue Jun 18 20:28:40 2013
@@ -205,8 +205,9 @@
 		    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 @@
 		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;
 	}
 




More information about the asterisk-commits mailing list