diff --git a/src/net/Socket.h b/src/net/Socket.h index 1e88e88..de394a4 100644 --- a/src/net/Socket.h +++ b/src/net/Socket.h @@ -4,14 +4,16 @@ #ifndef XOP_SOCKET_H #define XOP_SOCKET_H -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined (__OpenBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include #include #include #include #include #include +#if 0 #include +#endif #include #include #include diff --git a/src/net/SocketUtil.cpp b/src/net/SocketUtil.cpp index 6c99930..a3fa2aa 100644 --- a/src/net/SocketUtil.cpp +++ b/src/net/SocketUtil.cpp @@ -23,7 +23,7 @@ bool SocketUtil::Bind(SOCKET sockfd, std::string ip, uint16_t port) void SocketUtil::SetNonBlock(SOCKET fd) { -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); #elif defined(WIN32) || defined(_WIN32) @@ -34,7 +34,7 @@ void SocketUtil::SetNonBlock(SOCKET fd) void SocketUtil::SetBlock(SOCKET fd, int write_timeout) { -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags&(~O_NONBLOCK)); #elif defined(WIN32) || defined(_WIN32) @@ -45,7 +45,7 @@ void SocketUtil::SetBlock(SOCKET fd, int write_timeout) if(write_timeout > 0) { #ifdef SO_SNDTIMEO -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) struct timeval tv = {write_timeout/1000, (write_timeout%1000)*1000}; setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof tv); #elif defined(WIN32) || defined(_WIN32) @@ -168,7 +168,7 @@ int SocketUtil::GetPeerAddr(SOCKET sockfd, struct sockaddr_in *addr) void SocketUtil::Close(SOCKET sockfd) { -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) ::close(sockfd); #elif defined(WIN32) || defined(_WIN32) ::closesocket(sockfd); diff --git a/src/net/TaskScheduler.cpp b/src/net/TaskScheduler.cpp index d6ff7ea..c4bb55b 100644 --- a/src/net/TaskScheduler.cpp +++ b/src/net/TaskScheduler.cpp @@ -1,5 +1,5 @@ #include "TaskScheduler.h" -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include #endif @@ -36,7 +36,7 @@ TaskScheduler::~TaskScheduler() void TaskScheduler::Start() { #if 0 -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) signal(SIGPIPE, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGUSR1, SIG_IGN); diff --git a/src/net/TcpSocket.cpp b/src/net/TcpSocket.cpp index 5178678..6ee0833 100644 --- a/src/net/TcpSocket.cpp +++ b/src/net/TcpSocket.cpp @@ -71,7 +71,7 @@ bool TcpSocket::Connect(std::string ip, uint16_t port, int timeout) void TcpSocket::Close() { -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) ::close(sockfd_); #elif defined(WIN32) || defined(_WIN32) closesocket(sockfd_); diff --git a/src/net/Timestamp.cpp b/src/net/Timestamp.cpp index 7f1c981..e98a38c 100644 --- a/src/net/Timestamp.cpp +++ b/src/net/Timestamp.cpp @@ -17,11 +17,11 @@ std::string Timestamp::Localtime() struct tm tm; localtime_s(&tm, &tt); stream << std::put_time(&tm, "%F %T"); -#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) char buffer[200] = {0}; std::string timeString; std::strftime(buffer, 200, "%F %T", std::localtime(&tt)); stream << buffer; #endif return stream.str(); -} \ No newline at end of file +} diff --git a/src/xop/rtsp.h b/src/xop/rtsp.h index 75b444e..ad2cc76 100644 --- a/src/xop/rtsp.h +++ b/src/xop/rtsp.h @@ -51,7 +51,7 @@ class Rtsp : public std::enable_shared_from_this char ip[100] = { 0 }; char suffix[100] = { 0 }; uint16_t port = 0; -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) if (sscanf(url.c_str() + 7, "%[^:]:%hu/%s", ip, &port, suffix) == 3) #elif defined(WIN32) || defined(_WIN32) if (sscanf_s(url.c_str() + 7, "%[^:]:%hu/%s", ip, 100, &port, suffix, 100) == 3) @@ -59,7 +59,7 @@ class Rtsp : public std::enable_shared_from_this { rtsp_url_info_.port = port; } -#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) else if (sscanf(url.c_str() + 7, "%[^/]/%s", ip, suffix) == 2) #elif defined(WIN32) || defined(_WIN32) else if (sscanf_s(url.c_str() + 7, "%[^/]/%s", ip, 100, suffix, 100) == 2)