mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1508, Refactor srs_is_digital, support all zeros.
This commit is contained in:
parent
cee4feda61
commit
4382ced3bf
5 changed files with 38 additions and 18 deletions
|
@ -29,7 +29,6 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <math.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef SRS_OSX
|
||||
|
@ -1158,17 +1157,6 @@ string srs_get_peer_ip(int fd)
|
|||
return std::string(saddr);
|
||||
}
|
||||
|
||||
bool srs_is_digit_number(const string& str)
|
||||
{
|
||||
if (str.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int v = ::atoi(str.c_str());
|
||||
int powv = (int)pow(10, str.length() - 1);
|
||||
return v / powv >= 1 && v / powv <= 9;
|
||||
}
|
||||
|
||||
bool srs_is_boolean(const string& str)
|
||||
{
|
||||
return str == "true" || str == "false";
|
||||
|
|
|
@ -640,12 +640,6 @@ extern int srs_get_local_port(int fd);
|
|||
// Where peer ip is the client public ip which connected to server.
|
||||
extern std::string srs_get_peer_ip(int fd);
|
||||
|
||||
// Whether string is digit number
|
||||
// is_digit("1234567890") === true
|
||||
// is_digit("0123456789") === false
|
||||
// is_digit("1234567890a") === false
|
||||
// is_digit("a1234567890") === false
|
||||
extern bool srs_is_digit_number(const std::string& str);
|
||||
// Whether string is boolean
|
||||
// is_bool("true") == true
|
||||
// is_bool("false") == true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue