]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_win32wrapper.h
Remove <options:ircumsgprefix> entirely
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.h
index 9e67241268ddd3eaa1931546ad2f50a2d8890f6d..2218d930063d0d42aa40620a5f58679e511905b3 100644 (file)
@@ -84,6 +84,8 @@
 #define strcasecmp _stricmp
 #define strncasecmp _strnicmp
 
+typedef int ssize_t;
+
 /* Convert formatted (xxx.xxx.xxx.xxx) string to in_addr struct */
 CoreExport int insp_inet_pton(int af, const char * src, void * dst);
 
@@ -197,8 +199,6 @@ CoreExport void closedir(DIR * handle);
 void * ::operator new(size_t iSize);
 void ::operator delete(void * ptr);
 
-#define DISABLE_WRITEV
-
 #include <exception>
 
 class CWin32Exception : public std::exception
@@ -216,3 +216,27 @@ private:
 
 // Same value as EXIT_STATUS_FORK (EXIT_STATUS_FORK is unused on Windows)
 #define EXIT_STATUS_SERVICE 4
+
+// POSIX iovec
+struct iovec
+{
+       void* iov_base; // Starting address
+       size_t iov_len; // Number of bytes to transfer
+};
+
+// Windows WSABUF with POSIX field names
+struct WindowsIOVec
+{
+       // POSIX iovec has iov_base then iov_len, WSABUF in Windows has the fields in reverse order
+       u_long iov_len; // Number of bytes to transfer
+       char FAR* iov_base; // Starting address
+};
+
+inline ssize_t writev(int fd, const WindowsIOVec* iov, int count)
+{
+       DWORD sent;
+       int ret = WSASend(fd, reinterpret_cast<LPWSABUF>(const_cast<WindowsIOVec*>(iov)), count, &sent, 0, NULL, NULL);
+       if (ret == 0)
+               return sent;
+       return -1;
+}