Module: sems Branch: master Commit: a8e1357e25835d377c33ecbd01bd5f4446320ebc URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=a8e1357e25835d377c33ecbd01bd5f4446320ebc
Author: Juha Heinanen <[email protected]> Committer: Juha Heinanen <[email protected]> Date: Wed Mar 28 12:06:57 2012 +0300 apps/sbc: call control interface now supports quoted module parameter values - For example: P-Call-Control: ctl;append_headers="P-App-Param: param1=value1;param2" --- apps/sbc/SBC.cpp | 73 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 52 insertions(+), 21 deletions(-) diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index fdc9c8f..c537b87 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -621,30 +621,61 @@ UACAuthCred* SBCDialog::getCredentials() { } void SBCDialog::fixupCCInterface(const string& val, CCInterface& cc_if) { - DBG("instantiating CC interface from '%s'\n", val.c_str()); - vector<string> cc_params = explode(val, ";"); - if (cc_params.size()) { - vector<string>::iterator it=cc_params.begin(); - cc_if.cc_module = *it; - DBG(" module='%s'\n", it->c_str()); - it++; - while (it != cc_params.end()) { - size_t epos = it->find('='); - string p, v; - if (epos != string::npos) { - p = it->substr(0, epos); - if (it->length()>epos+1) - v = it->substr(epos+1); + INFO("instantiating CC interface from '%s'\n", val.c_str()); + size_t spos, last = val.length() - 1; + if (last < 0) { + spos = string::npos; + cc_if.cc_module = ""; + } else { + spos = val.find(";", 0); + cc_if.cc_module = val.substr(0, spos); + } + INFO(" module='%s'\n", cc_if.cc_module.c_str()); + while (spos < last) { + size_t epos = val.find("=", spos + 1); + if (epos == string::npos) { + cc_if.cc_values.insert(make_pair(val.substr(spos + 1), "")); + INFO(" '%s'='%s'\n", val.substr(spos + 1).c_str(), ""); + return; + } + if (epos == last) { + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos - 1), "")); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), ""); + return; + } + // if value starts with " char, it continues until another " is found + if (val[epos + 1] == '"') { + if (epos + 1 == last) { + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos - 1), "")); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), ""); + return; + } + size_t qpos = val.find('"', epos + 2); + if (qpos == string::npos) { + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos -1), val.substr(epos + 2))); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), val.substr(epos + 2).c_str()); + return; + } + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos - 1), val.substr(epos + 2, qpos - epos - 2))); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), val.substr(epos + 2, qpos - epos - 2).c_str()); + if (qpos < last) { + spos = val.find(";", qpos + 1); + } else { + return; + } } else { - p = *it; + size_t new_spos = val.find(";", epos + 1); + if (new_spos == string::npos) { + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos - 1), val.substr(epos + 1))); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), val.substr(epos + 1).c_str()); + return; + } + cc_if.cc_values.insert(make_pair(val.substr(spos + 1, epos - spos - 1), val.substr(epos + 1, new_spos - epos - 1))); + INFO(" '%s'='%s'\n", val.substr(spos + 1, epos - spos - 1).c_str(), val.substr(epos + 1, new_spos - epos - 1).c_str()); + spos = new_spos; } - DBG(" '%s'='%s'\n", p.c_str(), v.c_str()); - cc_if.cc_values.insert(make_pair(p,v)); - it++; - } - } else { - cc_if.cc_module = ""; } + return; } void SBCDialog::onInvite(const AmSipRequest& req) _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
