summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-06-14 10:55:28 +0200
committerPeter Kozak <spag@golwen.net>2013-06-14 10:55:28 +0200
commit66ef95959eabf843832eeae4c844cbd05eabd5e3 (patch)
tree7ee2d17f4b810fd430e21051d2ae7368e386e4d1 /misc/freeswitch/scripts/dialplan
parent23b112aee1979033c58735b1a028cd92210cec09 (diff)
expression function added
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 50653d8..c2b229d 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -160,13 +160,21 @@ function Router.route_match(self, route)
table.insert(arguments, common.array.expand_variables(argument, destination, self.variables));
end
result, replacement = self['fun_' .. variable_name](self, unpack(arguments))
- if self.log_details or true then
+ if not common.str.blank(element.pattern) then
+ if self.log_details then
+ self.log:debug('ELEMENT_FUNCTION - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', replacement);
+ end
+ result, replacement = self:element_match(tostring(element.pattern), tostring(replacement), tostring(replacement));
+ end
+ if self.log_details then
if result then
self.log:debug('ELEMENT_MATCH - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', replacement);
else
self.log:debug('ELEMENT_NO_MATCH - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', tostring(replacement));
end
end
+ else
+ self.log:error('ELEMENT_FUNCTION - function not found: ', 'fun_' .. variable_name);
end
end
end
@@ -267,3 +275,14 @@ function Router.fun_speeddial(self, number, name)
end
end
end
+
+
+function Router.fun_expression(self, expression_str)
+ expression_str = expression_str:gsub('[^%d%.%+%(%)%^%%%*%/-<>]', '');
+ result = loadstring("return (" .. expression_str .. ")")();
+ if result then
+ return true, result;
+ else
+ return false, result;
+ end
+end