mirror of
https://github.com/anope/anope.git
synced 2026-07-05 03:33:12 +02:00
Fixed windows build
This commit is contained in:
@@ -4,6 +4,7 @@ file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
|
||||
# If using Windows, add the windows.cpp, the win32 threading engine, and the socket engine to the list
|
||||
if(WIN32)
|
||||
append_to_list(SRC_SRCS win32/windows.cpp)
|
||||
append_to_list(SRC_SRCS win32/sigaction/sigaction.cpp)
|
||||
append_to_list(SRC_SRCS threadengines/threadengine_win32.cpp)
|
||||
append_to_list(SRC_SRCS socketengines/pipeengine_win32.cpp)
|
||||
# If not using Windows, add the pthread threading engine to the list
|
||||
|
||||
+2
-2
@@ -255,7 +255,7 @@ bool DNSManager::ProcessRead()
|
||||
unsigned char packet_buffer[524];
|
||||
sockaddrs from_server;
|
||||
socklen_t x = sizeof(from_server);
|
||||
int length = recvfrom(this->GetFD(), &packet_buffer, sizeof(packet_buffer), 0, &from_server.sa, &x);
|
||||
int length = recvfrom(this->GetFD(), reinterpret_cast<char *>(&packet_buffer), sizeof(packet_buffer), 0, &from_server.sa, &x);
|
||||
|
||||
if (length < 12)
|
||||
return true;
|
||||
@@ -497,7 +497,7 @@ bool DNSManager::ProcessWrite()
|
||||
unsigned char buffer[524];
|
||||
r->FillBuffer(buffer);
|
||||
|
||||
sendto(this->GetFD(), buffer, r->payload_count + 12, 0, &this->addrs.sa, this->addrs.size());
|
||||
sendto(this->GetFD(), reinterpret_cast<char *>(buffer), r->payload_count + 12, 0, &this->addrs.sa, this->addrs.size());
|
||||
|
||||
delete r;
|
||||
DNSEngine->packets.erase(DNSEngine->packets.begin());
|
||||
|
||||
+3
-3
@@ -666,7 +666,7 @@ bool ConnectionSocket::ProcessRead()
|
||||
{
|
||||
int optval = 0;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval)
|
||||
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, reinterpret_cast<char *>(&optval), &optlen) && !optval)
|
||||
{
|
||||
this->connected = true;
|
||||
this->OnConnect();
|
||||
@@ -694,7 +694,7 @@ bool ConnectionSocket::ProcessWrite()
|
||||
{
|
||||
int optval = 0;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval)
|
||||
if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, reinterpret_cast<char *>(&optval), &optlen) && !optval)
|
||||
{
|
||||
this->connected = true;
|
||||
this->OnConnect();
|
||||
@@ -720,7 +720,7 @@ void ConnectionSocket::ProcessError()
|
||||
{
|
||||
int optval = 0;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen);
|
||||
getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, reinterpret_cast<char *>(&optval), &optlen);
|
||||
errno = optval;
|
||||
this->OnError(optval ? Anope::LastError() : "");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,15 @@
|
||||
#define snprintf _snprintf
|
||||
/* VS2008 hates having this define before its own */
|
||||
#define vsnprintf _vsnprintf
|
||||
#define stat _stat
|
||||
#define S_ISREG(x) ((x) & _S_IFREG)
|
||||
|
||||
#include "sigaction/sigaction.h"
|
||||
|
||||
namespace Anope
|
||||
{
|
||||
class string;
|
||||
}
|
||||
|
||||
extern CoreExport void OnStartup();
|
||||
extern CoreExport void OnShutdown();
|
||||
@@ -50,6 +59,7 @@ extern CoreExport const char *inet_ntop(int af, const void *src, char *dst, size
|
||||
extern CoreExport int gettimeofday(timeval *tv, void *);
|
||||
extern CoreExport Anope::string GetWindowsVersion();
|
||||
extern CoreExport bool SupportedWindowsVersion();
|
||||
extern int mkstemp(char *input);
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // WINDOWS_H
|
||||
|
||||
+14
-1
@@ -34,7 +34,7 @@ WindowsLanguage WindowsLanguages[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
WSADATA SocketEngine::wsa;
|
||||
WSADATA wsa;
|
||||
|
||||
void OnStartup()
|
||||
{
|
||||
@@ -302,4 +302,17 @@ bool SupportedWindowsVersion()
|
||||
return false;
|
||||
}
|
||||
|
||||
int mkstemp(char *input)
|
||||
{
|
||||
input = _mktemp(input);
|
||||
if (input == NULL)
|
||||
{
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd = open(input, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE);
|
||||
return fd;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user