MT#59962 AmUtils: use overloading for str2int

Use overloading for the various flavours of str2int functions.  This has
the benefit of automatically choosing the appropriate function for
aliased types that may be one or the other underlying type, such as
size_t.

Do a mass renaming of all relevant instances.

Change-Id: I7abb6b9031ee53332d2b04a6cba4a6cc667a4807
mr13.3.1
Richard Fuchs 1 year ago
parent af444f48d6
commit 80dc4e60ef

@ -298,7 +298,7 @@ int ConferenceFactory::onLoad()
MaxParticipants = 0;
string max_participants = cfg.getParameter("max_participants");
if (max_participants.length() && str2i(max_participants, MaxParticipants)) {
if (max_participants.length() && str2int(max_participants, MaxParticipants)) {
ERROR("while parsing max_participants parameter\n");
}

@ -858,7 +858,7 @@ void DSMCall::setPromptSet(const string& name) {
void DSMCall::addSeparator(const string& name, bool front) {
unsigned int id = 0;
if (str2i(name, id)) {
if (str2int(name, id)) {
SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
SET_STRERROR("separator id '"+name+"' not a number");
return;

@ -613,7 +613,7 @@ DSMAction::SEAction SCReturnFSMAction::getSEAction(string& param,
CONST_ACTION_2P(SCLogAction, ',', false);
EXEC_ACTION_START(SCLogAction) {
unsigned int lvl;
if (str2i(resolveVars(par1, sess, sc_sess, event_params), lvl)) {
if (str2int(resolveVars(par1, sess, sc_sess, event_params), lvl)) {
ERROR("unknown log level '%s'\n", par1.c_str());
EXEC_ACTION_STOP;
}
@ -625,7 +625,7 @@ EXEC_ACTION_START(SCLogAction) {
CONST_ACTION_2P(SCLogsAction, ',', false);
EXEC_ACTION_START(SCLogsAction) {
unsigned int lvl;
if (str2i(resolveVars(par1, sess, sc_sess, event_params), lvl)) {
if (str2int(resolveVars(par1, sess, sc_sess, event_params), lvl)) {
ERROR("unknown log level '%s'\n", par1.c_str());
EXEC_ACTION_STOP;
}
@ -656,7 +656,7 @@ EXEC_ACTION_START(SCErrorAction) {
void log_vars(const string& l_arg, AmSession* sess,
DSMSession* sc_sess, map<string,string>* event_params) {
unsigned int lvl;
if (str2i(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
if (str2int(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
ERROR("unknown log level '%s'\n", l_arg.c_str());
return;
}
@ -676,7 +676,7 @@ EXEC_ACTION_START(SCLogVarsAction) {
void log_params(const string& l_arg, AmSession* sess,
DSMSession* sc_sess, map<string,string>* event_params) {
unsigned int lvl;
if (str2i(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
if (str2int(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
ERROR("unknown log level '%s'\n", l_arg.c_str());
return;
}
@ -702,7 +702,7 @@ EXEC_ACTION_START(SCLogParamsAction) {
void log_selects(const string& l_arg, AmSession* sess,
DSMSession* sc_sess, map<string,string>* event_params) {
unsigned int lvl;
if (str2i(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
if (str2int(resolveVars(l_arg, sess, sc_sess, event_params), lvl)) {
ERROR("unknown log level '%s'\n", l_arg.c_str());
return;
}
@ -1076,19 +1076,19 @@ EXEC_ACTION_START(SCSubStrAction) {
unsigned int pos2 = 0;
size_t c_pos = par2.find(",");
if (c_pos == string::npos) {
if (str2i(resolveVars(par2, sess, sc_sess, event_params), pos)) {
if (str2int(resolveVars(par2, sess, sc_sess, event_params), pos)) {
ERROR("substr length '%s' unparseable\n",
resolveVars(par2, sess, sc_sess, event_params).c_str());
return false;
}
} else {
if (str2i(resolveVars(par2.substr(0, c_pos), sess, sc_sess, event_params), pos)) {
if (str2int(resolveVars(par2.substr(0, c_pos), sess, sc_sess, event_params), pos)) {
ERROR("substr length '%s' unparseable\n",
resolveVars(par2.substr(0, c_pos), sess, sc_sess, event_params).c_str());
return false;
}
if (str2i(resolveVars(par2.substr(c_pos+1), sess, sc_sess, event_params), pos2)) {
if (str2int(resolveVars(par2.substr(c_pos+1), sess, sc_sess, event_params), pos2)) {
ERROR("substr length '%s' unparseable\n",
resolveVars(par2.substr(0, c_pos-1), sess, sc_sess, event_params).c_str());
return false;
@ -1113,7 +1113,7 @@ EXEC_ACTION_START(SCIncAction) {
string var_name = (arg.length() && arg[0] == '$')?
arg.substr(1) : arg;
unsigned int val = 0;
str2i(sc_sess->var[var_name], val);
str2int(sc_sess->var[var_name], val);
sc_sess->var[var_name] = int2str(val+1);
DBG("inc: $%s now '%s'\n",
@ -1125,7 +1125,7 @@ CONST_ACTION_2P(SCSetTimerAction,',', false);
EXEC_ACTION_START(SCSetTimerAction) {
unsigned int timerid;
if (str2i(resolveVars(par1, sess, sc_sess, event_params), timerid)) {
if (str2int(resolveVars(par1, sess, sc_sess, event_params), timerid)) {
ERROR("timer id '%s' not decipherable\n",
resolveVars(par1, sess, sc_sess, event_params).c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
@ -1136,7 +1136,7 @@ EXEC_ACTION_START(SCSetTimerAction) {
}
unsigned int timeout;
if (str2i(resolveVars(par2, sess, sc_sess, event_params), timeout)) {
if (str2int(resolveVars(par2, sess, sc_sess, event_params), timeout)) {
ERROR("timeout value '%s' not decipherable\n",
resolveVars(par2, sess, sc_sess, event_params).c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
@ -1161,7 +1161,7 @@ EXEC_ACTION_START(SCRemoveTimerAction) {
unsigned int timerid;
string timerid_s = resolveVars(arg, sess, sc_sess, event_params);
if (str2i(timerid_s, timerid)) {
if (str2int(timerid_s, timerid)) {
ERROR("timer id '%s' not decipherable\n", timerid_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("timer id '"+timerid_s+"' not decipherable\n");
@ -1663,7 +1663,7 @@ EXEC_ACTION_START(SCSendDTMFAction) {
string duration = resolveVars(par2, sess, sc_sess, event_params);
unsigned int event_i;
if (str2i(event, event_i)) {
if (str2int(event, event_i)) {
ERROR("event '%s' not a valid DTMF event\n", event.c_str());
throw DSMException("core", "cause", "invalid DTMF:"+ event);
}
@ -1672,7 +1672,7 @@ EXEC_ACTION_START(SCSendDTMFAction) {
if (duration.empty()) {
duration_i = 500; // default
} else {
if (str2i(duration, duration_i)) {
if (str2int(duration, duration_i)) {
ERROR("event duration '%s' not a valid DTMF duration\n", duration.c_str());
throw DSMException("core", "cause", "invalid DTMF duration:"+ duration);
}
@ -1690,7 +1690,7 @@ EXEC_ACTION_START(SCSendDTMFSequenceAction) {
if (duration.empty()) {
duration_i = 500; // default
} else {
if (str2i(duration, duration_i)) {
if (str2int(duration, duration_i)) {
ERROR("event duration '%s' not a valid DTMF duration\n", duration.c_str());
throw DSMException("core", "cause", "invalid DTMF duration:"+ duration);
}

@ -178,7 +178,7 @@ EXEC_ACTION_START(SCS3PutMultiFileAction) {
keys_array = files_array;
unsigned int num_files = 0;
if (str2i(sc_sess->var[files_array+"_size"], num_files)) {
if (str2int(sc_sess->var[files_array+"_size"], num_files)) {
ERROR("determining size of '%s' array\n", files_array.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("determining size of '"+
@ -188,7 +188,7 @@ EXEC_ACTION_START(SCS3PutMultiFileAction) {
// safety check
unsigned int num_keys = 0;
if (str2i(sc_sess->var[keys_array+"_size"], num_keys)) {
if (str2int(sc_sess->var[keys_array+"_size"], num_keys)) {
ERROR("determining size of '%s' array\n", keys_array.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("determining size of '"+
@ -311,7 +311,7 @@ EXEC_ACTION_START(SCSQSCreateQueueAction) {
CHECK_PRELOAD_SQS;
string aVisibilityTimeout_s = resolveVars(par1, sess, sc_sess, event_params);
unsigned int aVisibilityTimeout = 0;
if (str2i(aVisibilityTimeout_s, aVisibilityTimeout)) {
if (str2int(aVisibilityTimeout_s, aVisibilityTimeout)) {
ERROR("unable to determine aVisibilityTimeout '%s' for new queue\n",
aVisibilityTimeout_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);

@ -101,7 +101,7 @@ EXEC_ACTION_START(ConfPostEventAction) {
string ev_id = resolveVars(par2, sess, sc_sess, event_params);
unsigned int ev;
if (str2i(ev_id, ev)) {
if (str2int(ev_id, ev)) {
ERROR("decoding conference event id '%s'\n", ev_id.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("decoding conference event id '"+ev_id+"%s'\n");
@ -349,7 +349,7 @@ EXEC_ACTION_START(ConfSetupMixInAction) {
if (seconds.empty()) {
s = 0;
} else {
if (str2i(seconds, s)) {
if (str2int(seconds, s)) {
throw DSMException("conference",
"cause", "could not interpret seconds value");
}

@ -136,7 +136,7 @@ bool curl_run_get(DSMSession* sc_sess, const string& url,
if (!sc_sess->var["curl.timeout"].empty()) {
unsigned int curl_timeout = 0;
if (str2i(sc_sess->var["curl.timeout"], curl_timeout)) {
if (str2int(sc_sess->var["curl.timeout"], curl_timeout)) {
WARN("curl.timeout '%s' not understood\n", sc_sess->var["curl.timeout"].c_str());
} else {
if ((curl_easy_setopt(m_curl_handle, CURLOPT_TIMEOUT, curl_timeout) != CURLE_OK) ||
@ -249,7 +249,7 @@ void curl_run_getfile(DSMSession* sc_sess, const string& url, const string& outf
if (!sc_sess->var["curl.timeout"].empty()) {
unsigned int curl_timeout = 0;
if (str2i(sc_sess->var["curl.timeout"], curl_timeout)) {
if (str2int(sc_sess->var["curl.timeout"], curl_timeout)) {
WARN("curl.timeout '%s' not understood\n", sc_sess->var["curl.timeout"].c_str());
} else {
if ((curl_easy_setopt(m_curl_handle, CURLOPT_TIMEOUT, curl_timeout) != CURLE_OK) ||
@ -332,7 +332,7 @@ bool curl_run_post(DSMSession* sc_sess, const string& par1, const string& par2,
if (!sc_sess->var["curl.timeout"].empty()) {
unsigned int curl_timeout = 0;
if (str2i(sc_sess->var["curl.timeout"], curl_timeout)) {
if (str2int(sc_sess->var["curl.timeout"], curl_timeout)) {
WARN("curl.timeout '%s' not understood\n", sc_sess->var["curl.timeout"].c_str());
} else {
if ((curl_easy_setopt(m_curl_handle, CURLOPT_TIMEOUT, curl_timeout) != CURLE_OK) ||

@ -109,7 +109,7 @@ void replyRequest(DSMSession* sc_sess, AmSession* sess,
string reason = resolveVars(par2, sess, sc_sess, event_params);
string hdrs = replaceLineEnds(resolveVars("$dlg.reply.hdrs", sess, sc_sess, event_params));
unsigned int code_i;
if (str2i(code, code_i)) {
if (str2int(code, code_i)) {
ERROR("decoding reply code '%s'\n", code.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
return;
@ -162,7 +162,7 @@ EXEC_ACTION_START(DLGAcceptInviteAction) {
if (code.length()) {
reason = resolveVars(par2, sess, sc_sess, event_params);
if (str2i(code, code_i)) {
if (str2int(code, code_i)) {
ERROR("decoding reply code '%s'\n", code.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("decoding reply code '"+
@ -572,7 +572,7 @@ EXEC_ACTION_START(DLGB2BRelayErrorAction) {
string code = resolveVars(par1, sess, sc_sess, event_params);
string reason = resolveVars(par2, sess, sc_sess, event_params);
unsigned int code_i;
if (str2i(code, code_i)) {
if (str2int(code, code_i)) {
ERROR("decoding reply code '%s'\n", code.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
EXEC_ACTION_STOP;

@ -327,7 +327,7 @@ EXEC_ACTION_START(SCMyQueryGetResultAction) {
unsigned int rowindex_i = 0;
string rowindex = resolveVars(par2, sess, sc_sess, event_params);
if (rowindex.length()) {
if (str2i(rowindex, rowindex_i)) {
if (str2int(rowindex, rowindex_i)) {
ERROR("row index '%s' not understood\n", rowindex.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("row index '"+rowindex+"' not understood\n");
@ -377,7 +377,7 @@ EXEC_ACTION_START(SCMyGetResultAction) {
string colname = resolveVars(par2, sess, sc_sess, event_params);
if (rowindex.length()) {
if (str2i(rowindex, rowindex_i)) {
if (str2int(rowindex, rowindex_i)) {
ERROR("row index '%s' not understood\n", rowindex.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("row index '"+rowindex+"' not understood");

@ -241,7 +241,7 @@ EXEC_ACTION_START(DSMRedisConnectAction) {
} else if (p[0] == "connect_timeout"){
str2int(p[1], connect_timeout);
} else if (p[0] == "port"){
str2i(p[1], redis_port);
str2int(p[1], redis_port);
} else {
ERROR("unknown redis_db_url config or connect parameter - "
"parameter '%s'\n", p[0].c_str());

@ -60,7 +60,7 @@ EXEC_ACTION_START(SIPSUBCreateAction) {
unsigned int expires = 0;
if (sc_sess->var.find(params_s+".expires") != sc_sess->var.end()) {
str2i(sc_sess->var[params_s+".expires"], expires);
str2int(sc_sess->var[params_s+".expires"], expires);
}
string handle = AmSipSubscriptionContainer::instance()->
@ -84,7 +84,7 @@ EXEC_ACTION_START(SIPSUBRefreshAction) {
string expires = resolveVars(par2, sess, sc_sess, event_params);
unsigned int expires_i = 0;
if (!expires.empty())
str2i(expires, expires_i);
str2int(expires, expires_i);
DBG("refreshing subscription with handle '%s'\n", handle.c_str());
if (!AmSipSubscriptionContainer::instance()->refreshSubscription(handle, expires_i)) {

@ -228,7 +228,7 @@ EXEC_ACTION_START(SCUnlinkArrayAction) {
string prefix = resolveVars(par2, sess, sc_sess, event_params);
unsigned int arr_size = 0;
if (str2i(sc_sess->var[fname + "_size"], arr_size)) {
if (str2int(sc_sess->var[fname + "_size"], arr_size)) {
ERROR("_size not present/parseable '$%s'\n", sc_sess->var[fname + "_size"].c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
return false;

@ -164,7 +164,7 @@ EXEC_ACTION_START(SCUPlayCountRightAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -183,7 +183,7 @@ EXEC_ACTION_START(SCUPlayCountLeftAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -201,7 +201,7 @@ EXEC_ACTION_START(SCUGetCountRightAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -226,7 +226,7 @@ EXEC_ACTION_START(SCUGetCountLeftAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -251,7 +251,7 @@ EXEC_ACTION_START(SCUGetCountRightNoSuffixAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -276,7 +276,7 @@ EXEC_ACTION_START(SCUGetCountLeftNoSuffixAction) {
string basedir = resolveVars(par2, sess, sc_sess, event_params);
unsigned int cnt = 0;
if (str2i(cnt_s,cnt)) {
if (str2int(cnt_s,cnt)) {
ERROR("could not parse count '%s'\n", cnt_s.c_str());
sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
sc_sess->SET_STRERROR("could not parse count '"+cnt_s+"'\n");
@ -307,7 +307,7 @@ EXEC_ACTION_START(SCURandomAction) {
unsigned int modulo = 0;
if (modulo_str.length())
str2i(modulo_str, modulo);
str2int(modulo_str, modulo);
if (modulo)
sc_sess->var[varname]=int2str(rand()%modulo);

@ -398,7 +398,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR, true);
if (iptel_app_param.length()) {
string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
if (code.length() && str2i(code, code_i)) {
if (code.length() && str2int(code, code_i)) {
ERROR("while parsing Final-Reply-Code parameter\n");
}
reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason");
@ -406,7 +406,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
reason = "Not Found";
} else {
string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code", true);
if (code.length() && str2i(code, code_i)) {
if (code.length() && str2int(code, code_i)) {
ERROR("while parsing P-Final-Reply-Code\n");
}
string h_reason = getHeader(invite_req.hdrs,"P-Final-Reply-Reason", true);

@ -211,7 +211,7 @@ int JsonrpcNetstringsConnection::netstringsRead() {
DBG("received '%c'\n", msgbuf[rcvd_size]);
if (msgbuf[rcvd_size] == ':') {
msgbuf[rcvd_size] = '\0';
if (str2i(std::string(msgbuf, rcvd_size), msg_size)) {
if (str2int(std::string(msgbuf, rcvd_size), msg_size)) {
ERROR("Protocol error decoding size '%s'\n", msgbuf);
close();
return REMOVE;

@ -853,7 +853,7 @@ int _RegisterCache::parseExpires(RegisterCacheCtx& ctx,
// move Expires as separate header to contact parameter
string expires_str = getHeader(req.hdrs, "Expires");
if (!expires_str.empty() && str2i(expires_str, ctx.requested_expires)) {
if (!expires_str.empty() && str2int(expires_str, ctx.requested_expires)) {
AmBasicSipDialog::reply_error(req, 400, "Bad Request",
"Warning: Malformed expires\r\n", logger);
return true; // error reply sent
@ -908,7 +908,7 @@ bool _RegisterCache::throttleRegister(RegisterCacheCtx& ctx,
contact_it->params["expires"] = long2str(contact_expires);
}
else {
if(!str2long(expires_it->second,contact_expires)) {
if(!str2int(expires_it->second,contact_expires)) {
AmBasicSipDialog::reply_error(req, 400, "Bad Request",
"Warning: Malformed expires\r\n", logger);
return true; // error reply sent
@ -1061,7 +1061,7 @@ bool _RegisterCache::saveSingleContact(RegisterCacheCtx& ctx,
if(contact->params.find("expires") != contact->params.end()) {
DBG("contact->params[\"expires\"] = '%s'",
contact->params["expires"].c_str());
if(str2i(contact->params["expires"],contact_expires)) {
if(str2int(contact->params["expires"],contact_expires)) {
AmBasicSipDialog::reply_error(req, 400, "Bad Request",
"Warning: Malformed expires\r\n", logger);
return true; // error reply sent

@ -73,7 +73,7 @@ int RegisterDialog::replyFromCache(const AmSipRequest& req)
long int expires;
AmUriParser& contact = contact_it->second;
if(!str2long(contact.params["expires"], expires)) {
if(!str2int(contact.params["expires"], expires)) {
ERROR("failed to parse contact-expires for the second time\n");
reply_error(req, 500, "Server internal error", "", logger);
return -1;
@ -113,7 +113,7 @@ int RegisterDialog::fixUacContacts(const AmSipRequest& req)
unsigned int requested_expires=0;
if (!expires.empty()) {
if (str2i(expires, requested_expires)) {
if (str2int(expires, requested_expires)) {
reply_error(req, 400, "Bad Request",
"Warning: Malformed expires\r\n",
logger);
@ -183,7 +183,7 @@ int RegisterDialog::fixUacContacts(const AmSipRequest& req)
if(expires_it != contact_it->params.end()) {
// 'expires=xxx' present:
if(!str2long(expires_it->second,contact_expires)) {
if(!str2int(expires_it->second,contact_expires)) {
reply_error(req, 400, "Bad Request",
"Warning: Malformed expires\r\n",
logger);
@ -436,7 +436,7 @@ void RegisterDialog::onSipReply(const AmSipRequest& req,
// unsigned int req_expires = 0;
// string expires_str = getHeader(req.hdrs, "Expires");
// if (!expires_str.empty()) {
// str2i(expires_str, req_expires);
// str2int(expires_str, req_expires);
// }
DBG("parsing server contact set '%s'\n", reply.contact.c_str());
@ -469,7 +469,7 @@ void RegisterDialog::onSipReply(const AmSipRequest& req,
// parameter to each contact
string expires_str = it->params["expires"];
if (!expires_str.empty()) {
str2i(expires_str, expires);
str2int(expires_str, expires);
}
AmUriParser& orig_contact = alias_it->second;
@ -481,7 +481,7 @@ void RegisterDialog::onSipReply(const AmSipRequest& req,
// check orig expires
string orig_expires_str = orig_contact.params["expires"];
unsigned int orig_expires=0;
str2i(orig_expires_str,orig_expires);
str2int(orig_expires_str,orig_expires);
if(!orig_expires || (expires < orig_expires)) {
orig_expires = expires;

@ -65,7 +65,7 @@ static string payload2str(const SdpPayload &p);
if (!what.empty()) { \
what = ctx.replaceParameters(what, #what, req); \
unsigned int num; \
if (str2i(what, num)) { \
if (str2int(what, num)) { \
ERROR(#what " '%s' not understood\n", what.c_str()); \
return false; \
} \
@ -331,7 +331,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
}
unsigned int from_code, to_code;
if (str2i(trans_components[0], from_code)) {
if (str2int(trans_components[0], from_code)) {
ERROR("%s: code '%s' in reply_translations not understood.\n",
name.c_str(), trans_components[0].c_str());
return false;
@ -340,7 +340,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
string to_reply = trans_components[1];
while (s_pos < to_reply.length() && to_reply[s_pos] != ' ')
s_pos++;
if (str2i(to_reply.substr(0, s_pos), to_code)) {
if (str2int(to_reply.substr(0, s_pos), to_code)) {
ERROR("%s: code '%s' in reply_translations not understood.\n",
name.c_str(), to_reply.substr(0, s_pos).c_str());
return false;
@ -1066,7 +1066,7 @@ int SBCCallProfile::refuse(ParamReplacerCtx& ctx, const AmSipRequest& req) const
size_t spos = m_refuse_with.find(' ');
unsigned int refuse_with_code;
if (spos == string::npos || spos == m_refuse_with.size() ||
str2i(m_refuse_with.substr(0, spos), refuse_with_code)) {
str2int(m_refuse_with.substr(0, spos), refuse_with_code)) {
ERROR("invalid refuse_with '%s'->'%s' in %s. Expected <code> <reason>\n",
refuse_with.c_str(), m_refuse_with.c_str(), profile_file.c_str());
return -1;
@ -1709,7 +1709,7 @@ bool PayloadDesc::read(const std::string &s)
vector<string> elems = explode(s, "/");
if (elems.size() > 1) {
name = elems[0];
str2i(elems[1], clock_rate);
str2int(elems[1], clock_rate);
}
else if (elems.size() > 0) {
name = elems[0];

@ -99,19 +99,19 @@ int CCBLRedis::onLoad() {
}
unsigned int i_redis_connections;
if (str2i(redis_connections, i_redis_connections)) {
if (str2int(redis_connections, i_redis_connections)) {
ERROR("could not understand redis_connections=%s\n", redis_connections.c_str());
return -1;
}
unsigned int i_redis_port;
if (str2i(redis_port, i_redis_port)) {
if (str2int(redis_port, i_redis_port)) {
ERROR("could not understand redis_port=%s\n", redis_port.c_str());
return -1;
}
unsigned int i_redis_max_conn_wait;
if (str2i(redis_max_conn_wait, i_redis_max_conn_wait)) {
if (str2int(redis_max_conn_wait, i_redis_max_conn_wait)) {
ERROR("could not understand redis_max_conn_wait=%s\n", redis_max_conn_wait.c_str());
return -1;
}
@ -293,7 +293,7 @@ void CCBLRedis::start(const string& cc_name, const string& ltag,
unsigned int argv_max = 0;
if (!values.hasMember("argc") ||
str2i(values["argc"].asCStr(), argv_max) || (!argv_max)) {
str2int(values["argc"].asCStr(), argv_max) || (!argv_max)) {
ERROR("deciphering argc\n");
res_cmd[SBC_CC_ACTION] = SBC_CC_REFUSE_ACTION;
res_cmd[SBC_CC_REFUSE_CODE] = 500;

@ -684,7 +684,7 @@ void SBCDSMInstance::flushPlaylist() {
void SBCDSMInstance::addSeparator(const string& name, bool front) {
unsigned int id = 0;
if (str2i(name, id)) {
if (str2int(name, id)) {
SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
SET_STRERROR("separator id '"+name+"' not a number");
return;

@ -58,7 +58,7 @@ int CCParallelCalls::onLoad() {
cfg.getParameter("refuse_reason") : refuse_reason;
if (cfg.hasParameter("refuse_code")) {
if (str2i(cfg.getParameter("refuse_code"), refuse_code)) {
if (str2int(cfg.getParameter("refuse_code"), refuse_code)) {
ERROR("refuse_code '%s' not understood\n", cfg.getParameter("refuse_code").c_str());
return -1;
}
@ -130,7 +130,7 @@ void CCParallelCalls::start(const string& cc_namespace,
unsigned int max_calls = 1; // default
if (values.hasMember("max_calls") && isArgCStr(values["max_calls"])) {
if (str2i(values["max_calls"].asCStr(), max_calls)) {
if (str2int(values["max_calls"].asCStr(), max_calls)) {
ERROR("max_calls '%s' could not be interpreted!\n", values["max_calls"].asCStr());
REFUSE_WITH_SERVER_INTERNAL_ERROR;
}

@ -251,28 +251,28 @@ int VoiceboxFactory::onLoad()
}
string s_repeat_key = cfg.getParameter("repeat_key", "1");
if (str2i(s_repeat_key, repeat_key)) {
if (str2int(s_repeat_key, repeat_key)) {
ERROR("repeat_key value '%s' unparseable.\n",
s_repeat_key.c_str());
return -1;
}
string s_save_key = cfg.getParameter("save_key", "2");
if (str2i(s_save_key, save_key)) {
if (str2int(s_save_key, save_key)) {
ERROR("save_key value '%s' unparseable.\n",
s_save_key.c_str());
return -1;
}
string s_delete_key = cfg.getParameter("delete_key", "3");
if (str2i(s_delete_key, delete_key)) {
if (str2int(s_delete_key, delete_key)) {
ERROR("delete_key value '%s' unparseable.\n",
s_delete_key.c_str());
return -1;
}
string s_startover_key = cfg.getParameter("startover_key", "4");
if (str2i(s_startover_key, startover_key)) {
if (str2int(s_startover_key, startover_key)) {
ERROR("startover_key value '%s' unparseable.\n",
s_startover_key.c_str());
return -1;

@ -150,7 +150,7 @@ int WebConferenceFactory::load()
use_direct_room = true;
string direct_room_strip_str = cfg.getParameter("direct_room_strip");
if (direct_room_strip_str.length() &&
str2i(direct_room_strip_str, direct_room_strip)) {
str2int(direct_room_strip_str, direct_room_strip)) {
ERROR("unable to decipher direct_room_strip amount '%s'\n",
direct_room_strip_str.c_str());
return -1;
@ -162,7 +162,7 @@ int WebConferenceFactory::load()
string room_pin_split_s = cfg.getParameter("room_pin_split");
if (!room_pin_split_s.empty()) {
if (str2i(room_pin_split_s, room_pin_split_pos)) {
if (str2int(room_pin_split_s, room_pin_split_pos)) {
ERROR("room_pin_split in webconference config not readable\n");
return -1;
}

@ -102,7 +102,7 @@ int XMLRPC2DI::load() {
string server_timeout = cfg.getParameter("server_timeout");
if (!server_timeout.empty()) {
unsigned int server_timeout_i = 0;
if (str2i(server_timeout, server_timeout_i)) {
if (str2int(server_timeout, server_timeout_i)) {
ERROR("could not understand server_timeout=%s\n",
server_timeout.c_str());
return -1;
@ -135,7 +135,7 @@ int XMLRPC2DI::load() {
return -1;
}
if (str2i(conf_xmlrpc_port, XMLRPCPort)) {
if (str2int(conf_xmlrpc_port, XMLRPCPort)) {
ERROR("configuration: unable to decode xmlrpc_port value '%s'!\n",
conf_xmlrpc_port.c_str());
return -1;

@ -455,7 +455,7 @@ int AmConfig::readConfiguration()
if (cfg.hasParameter("max_forwards")) {
unsigned int mf=0;
if(str2i(cfg.getParameter("max_forwards"), mf)) {
if(str2int(cfg.getParameter("max_forwards"), mf)) {
ERROR("invalid max_forwards specified\n");
}
else {
@ -627,7 +627,7 @@ int AmConfig::readConfiguration()
if (limit.size() != 3) {
ERROR("invalid session_limit specified.\n");
} else {
if (str2i(limit[0], SessionLimit) || str2i(limit[1], SessionLimitErrCode)) {
if (str2int(limit[0], SessionLimit) || str2int(limit[1], SessionLimitErrCode)) {
ERROR("invalid session_limit specified.\n");
}
SessionLimitErrReason = limit[2];
@ -639,7 +639,7 @@ int AmConfig::readConfiguration()
if (limit.size() != 3) {
ERROR("invalid options_session_limit specified.\n");
} else {
if (str2i(limit[0], OptionsSessionLimit) || str2i(limit[1], OptionsSessionLimitErrCode)) {
if (str2int(limit[0], OptionsSessionLimit) || str2int(limit[1], OptionsSessionLimitErrCode)) {
ERROR("invalid options_session_limit specified.\n");
}
OptionsSessionLimitErrReason = limit[2];
@ -652,7 +652,7 @@ int AmConfig::readConfiguration()
if (limit.size() != 3) {
ERROR("invalid cps_limit specified.\n");
} else {
if (str2i(limit[0], CPSLimit) || str2i(limit[1], CPSLimitErrCode)) {
if (str2int(limit[0], CPSLimit) || str2int(limit[1], CPSLimitErrCode)) {
ERROR("invalid cps_limit specified.\n");
}
CPSLimitErrReason = limit[2];
@ -672,7 +672,7 @@ int AmConfig::readConfiguration()
ret = -1;
} else {
if (str2i(c_reply.substr(0, spos), ShutdownModeErrCode)) {
if (str2int(c_reply.substr(0, spos), ShutdownModeErrCode)) {
ERROR("invalid shutdown_mode_reply specified, expected \"<code> <reason>\","
"e.g. shutdown_mode_reply=\"503 Not At The Moment, Please\".\n");
ret = -1;

@ -392,7 +392,7 @@ const string& AmConfigReader::getParameter(const string& param, const string& de
unsigned int AmConfigReader::getParameterInt(const string& param, unsigned int defval) const
{
unsigned int result=0;
if(!hasParameter(param) || str2i(getParameter(param),result))
if(!hasParameter(param) || str2int(getParameter(param),result))
return defval;
else
return result;

@ -172,7 +172,7 @@ int AmPrecodedFile::open(const std::string& filename) {
#define get_uint_item(name, index, description) \
unsigned int name; \
if (str2i(codec_def[index], name)) { \
if (str2int(codec_def[index], name)) { \
ERROR("decoding " description " in codec line '%s'\n", \
codec_line.c_str()); \
continue; \

@ -586,7 +586,7 @@ static bool parse_sdp_line_ex(AmSdp* sdp_msg, char*& s)
next = skip_till_next_line(s, line_len);
if (line_len) {
string version(s, line_len);
str2i(version, sdp_msg->version);
str2int(version, sdp_msg->version);
// DBG("parse_sdp_line_ex: found version '%s'\n", version.c_str());
} else {
sdp_msg->version = 0;
@ -880,7 +880,7 @@ static void parse_sdp_media(AmSdp* sdp_msg, char* s)
if (next > media_line)
port = string(media_line, int(next-media_line)-1);
str2i(port, m.port);
str2int(port, m.port);
/* number of ports */
media_line = next;
@ -889,7 +889,7 @@ static void parse_sdp_media(AmSdp* sdp_msg, char* s)
if (next > media_line)
nports = string(media_line, int(next-media_line)-1);
str2i(nports, m.nports);
str2int(nports, m.nports);
} else {
/* port number */
@ -897,7 +897,7 @@ static void parse_sdp_media(AmSdp* sdp_msg, char* s)
string port;
if (next > media_line)
port = string(media_line, int(next-media_line)-1);
str2i(port, m.port);
str2int(port, m.port);
media_line = next;
}
@ -943,7 +943,7 @@ static void parse_sdp_media(AmSdp* sdp_msg, char* s)
if (!value.empty()) {
payload.type = m.type;
str2i(value, payload_type);
str2int(value, payload_type);
payload.payload_type = payload_type;
m.payloads.push_back(payload);
}
@ -961,7 +961,7 @@ static void parse_sdp_media(AmSdp* sdp_msg, char* s)
}
if (!last_value.empty()) {
payload.type = m.type;
str2i(last_value, payload_type);
str2int(last_value, payload_type);
payload.payload_type = payload_type;
m.payloads.push_back(payload);
}
@ -1069,7 +1069,7 @@ static char* parse_sdp_attr(AmSdp* sdp_msg, char* s)
{
next = parse_until(attr_line, ' ');
string type(attr_line, int(next-attr_line)-1);
str2i(type,payload_type);
str2int(type,payload_type);
attr_line = next;
rtpmap_st = ENC_NAME;
break;
@ -1096,18 +1096,18 @@ static char* parse_sdp_attr(AmSdp* sdp_msg, char* s)
if(contains(attr_line, line_end, '/')){
next = parse_until(attr_line, '/');
string clk_rate(attr_line, int(next-attr_line)-1);
str2i(clk_rate, clock_rate);
str2int(clk_rate, clock_rate);
attr_line = next;
rtpmap_st = ENC_PARAM;
/* last line check */
}else if (*line_end == '\0') {
string clk_rate(attr_line, int(line_end-attr_line));
str2i(clk_rate, clock_rate);
str2int(clk_rate, clock_rate);
parsing = 0;
/* more lines to come */
}else{
string clk_rate(attr_line, int(line_end-attr_line)-1);
str2i(clk_rate, clock_rate);
str2int(clk_rate, clock_rate);
parsing=0;
}
break;
@ -1118,12 +1118,12 @@ static char* parse_sdp_attr(AmSdp* sdp_msg, char* s)
next = parse_until(attr_line, ' ');
if(next < line_end){
string value(attr_line, int(next-attr_line)-1);
str2i(value, encoding_param);
str2int(value, encoding_param);
attr_line = next;
rtpmap_st = ENC_PARAM;
}else{
string last_value(attr_line, int(line_end-attr_line)-1);
str2i(last_value, encoding_param);
str2int(last_value, encoding_param);
parsing = 0;
}
break;
@ -1156,7 +1156,7 @@ static char* parse_sdp_attr(AmSdp* sdp_msg, char* s)
{
next = parse_until(attr_line, line_end, ' ');
string fmtp_format(attr_line, int(next-attr_line)-1);
str2i(fmtp_format, payload_type);
str2int(fmtp_format, payload_type);
attr_line = next;
fmtp_st = FORMAT_PARAM;
break;
@ -1285,7 +1285,7 @@ static void parse_sdp_origin(AmSdp* sdp_msg, char* s)
break;
}
string id(origin_line, int(next-origin_line)-1);
str2uint128(id, origin.sessId);
str2int(id, origin.sessId);
origin_line = next;
origin_st = VERSION_ST;
break;
@ -1300,7 +1300,7 @@ static void parse_sdp_origin(AmSdp* sdp_msg, char* s)
break;
}
string version(origin_line, int(next-origin_line)-1);
str2uint128(version, origin.sessV);
str2int(version, origin.sessV);
origin_line = next;
origin_st = NETTYPE;
break;

@ -318,7 +318,7 @@ void AmSIPRegistration::onSipReply(const AmSipRequest& req,
DBG("contact found\n");
found = active = true;
if (str2i(server_contact.params["expires"], reg_expires)) {
if (str2int(server_contact.params["expires"], reg_expires)) {
ERROR("could not extract expires value, default to 300.\n");
reg_expires = 300;
}

@ -231,13 +231,13 @@ bool reverse_hex2int(const string& str, unsigned int& result)
return false;
}
bool str2i(const string& str, unsigned int& result)
bool str2int(const string& str, unsigned int& result)
{
char* s = (char*)str.c_str();
return str2i(s,result);
return str2int(s,result);
}
bool str2i(char*& str, unsigned int& result, char sep)
bool str2int(char*& str, unsigned int& result, char sep)
{
unsigned int ret=0;
int i=0;
@ -271,10 +271,10 @@ bool str2i(char*& str, unsigned int& result, char sep)
return false;
error_digits:
DBG("str2i: too many letters in [%s]\n", init);
DBG("str2int: too many letters in [%s]\n", init);
return true;
error_char:
DBG("str2i: unexpected char 0x%x in %s\n", *str, init);
DBG("str2int: unexpected char 0x%x in %s\n", *str, init);
return true;
}
@ -328,18 +328,18 @@ bool str2int(char*& str, int& result, char sep)
DBG("str2int: too many digits in [%s]\n", init);
return false;
error_char:
DBG("str2i: unexpected char 0x%x in %s\n", *str, init);
DBG("str2int: unexpected char 0x%x in %s\n", *str, init);
return false;
}
// long int could probably be the same size as int
bool str2long(const string& str, long& result)
bool str2int(const string& str, long& result)
{
char* s = (char*)str.c_str();
return str2long(s,result);
return str2int(s,result);
}
bool str2long(char*& str, long& result, char sep)
bool str2int(char*& str, long& result, char sep)
{
long ret=0;
int i=0;
@ -380,21 +380,21 @@ bool str2long(char*& str, long& result, char sep)
return true;
error_digits:
DBG("str2long: too many digits in [%s]\n", init);
DBG("str2int: too many digits in [%s]\n", init);
return false;
error_char:
DBG("str2long: unexpected char 0x%x in %s\n", *str, init);
DBG("str2int: unexpected char 0x%x in %s\n", *str, init);
return false;
}
bool str2uint128(const string& str, __uint128_t & result)
bool str2int(const string& str, __uint128_t & result)
{
char* s = (char*)str.c_str();
result = str2uint128(s);
result = str2int(s);
return (result ? true : false);
}
__uint128_t str2uint128(const char* str) {
__uint128_t str2int(const char* str) {
__uint128_t result = 0;
while (*str) {
if (*str < '0' || *str > '9') {
@ -409,13 +409,13 @@ __uint128_t str2uint128(const char* str) {
}
// long int could probably be the same size as int
bool str2ull(const string& str, unsigned long long& result)
bool str2int(const string& str, unsigned long long& result)
{
char* s = (char*)str.c_str();
return str2ull(s,result);
return str2int(s,result);
}
bool str2ull(char*& str, unsigned long long& result, char sep)
bool str2int(char*& str, unsigned long long& result, char sep)
{
unsigned long long ret=0;
int i=0;
@ -456,10 +456,10 @@ bool str2ull(char*& str, unsigned long long& result, char sep)
return true;
error_digits:
DBG("str2ull: too many digits in [%s]\n", init);
DBG("str2int: too many digits in [%s]\n", init);
return false;
error_char:
DBG("str2ull: unexpected char 0x%x in %s\n", *str, init);
DBG("str2int: unexpected char 0x%x in %s\n", *str, init);
return false;
}

@ -123,25 +123,25 @@ bool reverse_hex2int(const string& str, unsigned int& result);
string double2str(double val);
/**
* Convert a string to an uint.
* Convert a string to an uint.
* @param str [in] string to convert.
* @param result [out] result integer.
* @return true if failed (!!!)
*/
bool str2i(const string& str, unsigned int& result);
bool str2int(const string& str, unsigned int& result);
/**
* Internal version of preceeding 'str2i' method.
* Internal version of preceeding 'str2int' method.
* @param str [in,out] gets incremented until sep char or error occurs
* @param result [out] result of the function
* @param sep [in] character seprating the number to convert and the next token
* @return true if failed (!!!)
*/
bool str2i(char*& str, unsigned int& result, char sep = ' ');
bool str2int(char*& str, unsigned int& result, char sep = ' ');
/**
* Convert a string to an int.
* Convert a string to an int.
* @param str [in] string to convert.
* @param result [out] result integer.
* @return true on success (!!!)
@ -149,7 +149,7 @@ bool str2i(char*& str, unsigned int& result, char sep = ' ');
bool str2int(const string& str, int& result);
/**
* Internal version of preceeding 'str2int' method.
* Internal version of preceeding 'str2int' method.
* @param str [in,out] gets incremented until sep char or error occurs
* @param result [out] result of the function
* @param sep [in] character seprating the number to convert and the next token
@ -158,22 +158,22 @@ bool str2int(const string& str, int& result);
bool str2int(char*& str, int& result, char sep = ' ');
/**
* Convert a string to a long int.
* Convert a string to a long int.
* On many systems nowadays this could be the same as str2int.
* @param str [in] string to convert.
* @param result [out] result integer.
* @return true if on success (!!!).
*/
bool str2long(const string& str, long& result);
bool str2int(const string& str, long& result);
/**
* Internal version of preceeding 'str2long' method.
* Internal version of preceeding 'str2long' method.
* @param str [in,out] gets incremented until sep char or error occurs
* @param result [out] result of the function
* @param sep [in] character seprating the number to convert and the next token
* @return true on success
*/
bool str2long(char*& str, long& result, char sep = ' ');
bool str2int(char*& str, long& result, char sep = ' ');
/**
* Convert a string to a unsigned int128.
@ -181,13 +181,13 @@ bool str2long(char*& str, long& result, char sep = ' ');
* @param result [out] result unsinged int128.
* @return true on success.
*/
bool str2uint128(const string& str, __uint128_t & result);
bool str2int(const string& str, __uint128_t & result);
/**
* Convert a char array to a unsigned int128.
* @param str [in] string to convert.
* @return 0 (failed) or converted unsigned int128 value.
*/
__uint128_t str2uint128(const char* str);
__uint128_t str2int(const char* str);
/**
* Convert a string to a unsigned long long int.
@ -195,16 +195,16 @@ __uint128_t str2uint128(const char* str);
* @param result [out] result integer.
* @return true if on success (!!!).
*/
bool str2ull(const string& str, unsigned long long& result);
bool str2int(const string& str, unsigned long long& result);
/**
* Internal version of preceeding 'std2ull' method.
* Internal version of preceeding 'str2int' method.
* @param str [in,out] gets incremented until sep char or error occurs
* @param result [out] result of the function
* @param sep [in] character seprating the number to convert and the next token
* @return true on success
*/
bool str2ull(char*& str, unsigned long long& result, char sep = ' ');
bool str2int(char*& str, unsigned long long& result, char sep = ' ');
/* translates string value into bool, returns false on error */
bool str2bool(const string &s, bool &dst);

@ -210,7 +210,7 @@ int _SipCtrlInterface::load()
if (cfg.hasParameter("udp_rcvbuf")) {
unsigned int config_udp_rcvbuf = -1;
if (str2i(cfg.getParameter("udp_rcvbuf"), config_udp_rcvbuf)) {
if (str2int(cfg.getParameter("udp_rcvbuf"), config_udp_rcvbuf)) {
ERROR("invalid value specified for udp_rcvbuf\n");
return false;
}

@ -97,7 +97,7 @@ bool SessionTimer::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
unsigned int i_minse;
string min_se_hdr = getHeader(reply.hdrs, SIP_HDR_MIN_SE, true);
if (!min_se_hdr.empty()) {
if (str2i(strip_header_params(min_se_hdr), i_minse)) {
if (str2int(strip_header_params(min_se_hdr), i_minse)) {
WARN("error while parsing " SIP_HDR_MIN_SE " header value '%s'\n",
strip_header_params(min_se_hdr).c_str());
} else {
@ -245,7 +245,7 @@ bool SessionTimerFactory::checkSessionExpires(const AmSipRequest& req, AmConfigR
if (session_expires.length()) {
unsigned int i_se;
if (!str2i(strip_header_params(session_expires), i_se)) {
if (!str2int(strip_header_params(session_expires), i_se)) {
if (i_se < sst_cfg.getMinimumTimer()) {
throw AmSession::Exception(422, "Session Interval Too Small",
SIP_HDR_COLSP(SIP_HDR_MIN_SE)+
@ -275,7 +275,7 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
bool rem_has_sess_expires = false;
unsigned int rem_sess_expires=0;
if (!sess_expires_hdr.empty()) {
if (str2i(strip_header_params(sess_expires_hdr),
if (str2int(strip_header_params(sess_expires_hdr),
rem_sess_expires)) {
WARN("error while parsing " SIP_HDR_SESSION_EXPIRES " header value '%s'\n",
strip_header_params(sess_expires_hdr).c_str()); // exception?
@ -288,7 +288,7 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
unsigned int i_minse = min_se;
string min_se_hdr = getHeader(req.hdrs, SIP_HDR_MIN_SE, true);
if (!min_se_hdr.empty()) {
if (str2i(strip_header_params(min_se_hdr),
if (str2int(strip_header_params(min_se_hdr),
i_minse)) {
WARN("error while parsing " SIP_HDR_MIN_SE " header value '%s'\n",
strip_header_params(min_se_hdr).c_str()); // exception?
@ -370,7 +370,7 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipReply& reply)
if (!sess_expires_hdr.empty()) {
unsigned int sess_i_tmp = 0;
if (str2i(strip_header_params(sess_expires_hdr),
if (str2int(strip_header_params(sess_expires_hdr),
sess_i_tmp)) {
WARN("error while parsing " SIP_HDR_SESSION_EXPIRES " header value '%s'\n",
strip_header_params(sess_expires_hdr).c_str()); // exception?

@ -41,7 +41,7 @@ static int parse_args(int argc, char* argv[], const string& flags,
/* returns non-zero if error occured */
int str2i(const char* str, unsigned short* result)
int str2int(const char* str, unsigned short* result)
{
int i=0;
unsigned short ret=0;
@ -63,10 +63,10 @@ int str2i(const char* str, unsigned short* result)
return 0;
error_digits:
fprintf(stderr,"str2i: too many letters in [%s]\n", init);
fprintf(stderr,"str2int: too many letters in [%s]\n", init);
return -1;
error_char:
fprintf(stderr,"str2i: unexpected char %c in %s\n", *str, init);
fprintf(stderr,"str2int: unexpected char %c in %s\n", *str, init);
return -1;
}
@ -100,7 +100,7 @@ int main(int argc, char** argv)
case 's': { server=it->second; } break;
case 'p': { port=it->second; } break;
case 'c': { cmd=it->second; } break;
case 't': { if (str2i(it->second.c_str(),&timeout_s)<0) {
case 't': { if (str2int(it->second.c_str(),&timeout_s)<0) {
fprintf(stderr,"timeout '%s' not understood\n",it->second.c_str());
return -1;
} } break;
@ -112,7 +112,7 @@ int main(int argc, char** argv)
return -1;
}
if(str2i(port.c_str(),&addr.sin_port) == -1){
if(str2int(port.c_str(),&addr.sin_port) == -1){
fprintf(stderr,"port '%s' is not a valid integer\n",port.c_str());
return -1;
}

@ -723,7 +723,7 @@ void UACAuth::checkAuthentication(const AmSipRequest* req, const string& realm,
// get nonce count from request
string nonce_count_str = find_attribute("nc", auth_hdr);
if (str2i(nonce_count_str, client_nonce_count)) {
if (str2int(nonce_count_str, client_nonce_count)) {
DBG("Error parsing nonce_count '%s'\n", nonce_count_str.c_str());
goto auth_end;
}

@ -440,7 +440,7 @@ int main(int argc, char* argv[])
if(!AmConfig::DaemonGid.empty()){
unsigned int gid;
if(str2i(AmConfig::DaemonGid, gid)){
if(str2int(AmConfig::DaemonGid, gid)){
struct group* grnam = getgrnam(AmConfig::DaemonGid.c_str());
if(grnam != NULL){
gid = grnam->gr_gid;
@ -461,7 +461,7 @@ int main(int argc, char* argv[])
if(!AmConfig::DaemonUid.empty()){
unsigned int uid;
if(str2i(AmConfig::DaemonUid, uid)){
if(str2int(AmConfig::DaemonUid, uid)){
struct passwd* pwnam = getpwnam(AmConfig::DaemonUid.c_str());
if(pwnam != NULL){
uid = pwnam->pw_uid;

@ -527,7 +527,7 @@ inline int parse_via_params(sip_via_parm* parm, const char** c, int len)
parm->has_rport = true;
parm->rport = (*it)->value;
if(parm->rport.len) {
if(str2i(c2stlstr(parm->rport),parm->rport_i)) {
if(str2int(c2stlstr(parm->rport),parm->rport_i)) {
DBG("invalid port number in Via 'sent-by' address.\n");
}
}

Loading…
Cancel
Save