mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
use the right int type for port.
This commit is contained in:
parent
1c7d5f1852
commit
d8f18aee37
20 changed files with 105 additions and 149 deletions
|
@ -180,13 +180,27 @@ string srs_dns_resolve(string host)
|
|||
|
||||
void srs_parse_hostport(const string& hostport, string& host, int& port)
|
||||
{
|
||||
host = hostport;
|
||||
|
||||
size_t pos = hostport.find(":");
|
||||
if (pos != std::string::npos) {
|
||||
string p = hostport.substr(pos + 1);
|
||||
host = hostport.substr(0, pos);
|
||||
port = ::atoi(p.c_str());
|
||||
} else {
|
||||
host = hostport;
|
||||
}
|
||||
}
|
||||
|
||||
void srs_parse_endpoint(string hostport, string& ip, int& port)
|
||||
{
|
||||
ip = "0.0.0.0";
|
||||
|
||||
size_t pos = string::npos;
|
||||
if ((pos = hostport.find(":")) != string::npos) {
|
||||
ip = hostport.substr(0, pos);
|
||||
string sport = hostport.substr(pos + 1);
|
||||
port = ::atoi(sport.c_str());
|
||||
} else {
|
||||
port = ::atoi(hostport.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +220,10 @@ string srs_float2str(double value)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
string srs_bool2switch(bool v) {
|
||||
return v? "on" : "off";
|
||||
}
|
||||
|
||||
bool srs_is_little_endian()
|
||||
{
|
||||
// convert to network(big-endian) order, if not equals,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue