Support the ${param$defvalue} syntax in parameter matching similar to parameter expansions.

Original patch by Allan Sandfeld Jensen.


git-svn-id: http://voip.null.ro/svn/yate@3387 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-06-16 14:15:44 +00:00
parent 98dd09240a
commit 6e7460ed4c
1 changed files with 11 additions and 3 deletions

View File

@ -376,14 +376,22 @@ static bool oneContext(Message &msg, String &str, const String &context, String
r = r.substr(p+1);
match.trimBlanks();
r.trimBlanks();
String def;
p = match.find('$');
if (p >= 0) {
// param is in ${<name>$<default>} format
def = match.substr(p+1);
match = match.substr(0,p);
match.trimBlanks();
}
if (match.null() || r.null()) {
Debug("RegexRoute",DebugWarn,"Missing parameter or rule in rule #%u in context '%s'",
i+1,context.c_str());
continue;
}
DDebug("RegexRoute",DebugAll,"Using message parameter '%s'",
match.c_str());
match = msg.getValue(match);
DDebug("RegexRoute",DebugAll,"Using message parameter '%s' default '%s'",
match.c_str(),def.c_str());
match = msg.getValue(match,def);
}
else if (r.startsWith("$(")) {
// handle special matching by param $(function)regexp