summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-10 17:48:04 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-10 17:48:04 +0000
commit1312f2db8ed90464e73acdcc07bb1aae92964345 (patch)
treeb8e55a20699c6308ccd20030f9c737140bf6171d /win
parent3151262b41f011e0f5707565461ce46447f12b07 (diff)
* Fix inspsocket to not include uio.h on windows.
* Wrap writev and some structs to fix inspsocket compile on win. * Fix a few compile errors due to latest trunk changes in win32wrapper code. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11822 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'win')
-rw-r--r--win/inspircd_win32wrapper.cpp34
-rw-r--r--win/inspircd_win32wrapper.h11
2 files changed, 40 insertions, 5 deletions
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index 223fb648e..eb73378f2 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -147,6 +147,30 @@ const char * dlerror()
return errormessage;
}
+ssize_t writev(int fd, const struct iovec* iov, int iovcnt)
+{
+ ssize_t ret;
+ size_t tot = 0;
+ int i;
+ char *buf, *p;
+
+ for(i = 0; i < iovcnt; ++i)
+ tot += iov[i].iov_len;
+ buf = (char*)malloc(tot);
+ if (tot != 0 && buf == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ p = buf;
+ for (i = 0; i < iovcnt; ++i) {
+ memcpy (p, iov[i].iov_base, iov[i].iov_len);
+ p += iov[i].iov_len;
+ }
+ ret = send((SOCKET)fd, buf, tot, 0);
+ free (buf);
+ return ret;
+}
+
#define TRED FOREGROUND_RED | FOREGROUND_INTENSITY
#define TGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define TYELLOW FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
@@ -415,7 +439,7 @@ void ClearConsole()
*/
void ChangeWindowsSpecificPointers()
{
- Instance->Logs->Log("win32",DEBUG,"Changing to windows specific pointer and functor set");
+ ServerInstance->Logs->Log("win32",DEBUG,"Changing to windows specific pointer and functor set");
}
DWORD WindowsForkStart()
@@ -504,14 +528,14 @@ void WindowsForkKillOwner()
if(!hProcess || !owner_processid)
{
printf("Could not open process id %u: %s.\n", owner_processid, dlerror());
- Instance->Exit(14);
+ ServerInstance->Exit(14);
}
// die die die
if(!TerminateProcess(hProcess, 0))
{
printf("Could not TerminateProcess(): %s\n", dlerror());
- Instance->Exit(14);
+ ServerInstance->Exit(14);
}
CloseHandle(hProcess);
@@ -522,7 +546,7 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, V
if (!*(data.GetString()))
{
std::string nameserver;
- conf->GetInstance()->Logs->Log("win32",DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in the registry...");
+ ServerInstance->Logs->Log("win32",DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in the registry...");
nameserver = FindNameServerWin();
/* Windows stacks multiple nameservers in one registry key, seperated by commas.
* Spotted by Cataclysm.
@@ -535,7 +559,7 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, V
if (nameserver.find(' ') != std::string::npos)
nameserver = nameserver.substr(0, nameserver.find(' '));
data.Set(nameserver.c_str());
- conf->GetInstance()->Logs->Log("win32",DEFAULT,"<dns:server> set to '%s' as first active resolver in registry.", nameserver.c_str());
+ ServerInstance->Logs->Log("win32",DEFAULT,"<dns:server> set to '%s' as first active resolver in registry.", nameserver.c_str());
}
return true;
}
diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h
index a1eba11e9..6b068adea 100644
--- a/win/inspircd_win32wrapper.h
+++ b/win/inspircd_win32wrapper.h
@@ -100,6 +100,7 @@ typedef unsigned __int32 uint32_t;
#include <process.h>
#include <stdio.h>
#include <algorithm>
+#include <io.h>
#ifdef ENABLE_CRASHDUMPS
#include <DbgHelp.h>
@@ -214,6 +215,7 @@ typedef unsigned long long uint64_t;
typedef signed char int8_t;
typedef signed long int32_t;
typedef signed long long int64_t;
+typedef signed long ssize_t;
/* Shared memory allocation functions */
void * ::operator new(size_t iSize);
@@ -226,6 +228,15 @@ class ServerConfig;
/* Look up the nameserver in use from the registry on windows */
CoreExport std::string FindNameServerWin();
+/* no uio.h on win, but win has alternatives in io.h rest is wrapped here */
+#define IOV_MAX 1024
+struct iovec
+{
+ size_t iov_len;
+ void* iov_base;
+};
+CoreExport ssize_t writev(int fd, const struct iovec* iov, int iovcnt);
+
/* Clear a windows console */
CoreExport void ClearConsole();