mirror of
https://github.com/BotChain-Robots/rpc.git
synced 2026-03-09 23:12:27 +01:00
Fix mDNS int parse crash, print errno on TCP connection failure
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void print_errno() {
|
||||
inline void print_errno() {
|
||||
char errbuf[ERRBUF_SIZE];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), 0, errbuf, sizeof(errbuf),
|
||||
NULL);
|
||||
@@ -23,7 +23,7 @@ void print_errno() {
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
void print_errno() {
|
||||
inline void print_errno() {
|
||||
spdlog::error("{}", strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
|
||||
inline std::vector<std::string> split(const std::string &str, const char delimiter) {
|
||||
std::vector<std::string> result;
|
||||
@@ -20,4 +22,15 @@ inline std::vector<std::string> split(const std::string &str, const char delimit
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool is_integer(const std::string& s) {
|
||||
if (s.empty()) return false;
|
||||
|
||||
size_t start = 0;
|
||||
if (s[0] == '-' || s[0] == '+')
|
||||
start = 1;
|
||||
|
||||
return start < s.size() &&
|
||||
std::all_of(s.begin() + start, s.end(), ::isdigit);
|
||||
}
|
||||
|
||||
#endif // STRING_H
|
||||
|
||||
Reference in New Issue
Block a user