More Windoze crap

master
leitner 21 years ago
parent 9a0e23f420
commit 15a54e002b

@ -0,0 +1,16 @@
#ifdef __MINGW32__
#include "socket.h"
#include "windoze.h"
void __winsock_init(void) {
static int inited;
if (!inited) {
WSADATA wsaData;
if (WSAStartup( MAKEWORD(2,2), &wsaData ) ||
LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2)
exit(111);
inited=1;
}
}
#endif

@ -0,0 +1,39 @@
#ifdef __MINGW32__
#include <winsock2.h>
#include <errno.h>
#include <stdio.h>
#include "socket.h"
int winsock2errno(long l) {
long x;
if (l==-1)
switch ((x=WSAGetLastError())) {
case WSANOTINITIALISED:
printf("WSANOTINITIALISED!\n");
exit(111);
case WSAENETDOWN:
printf("WSAENETDOWN!\n");
exit(111);
case WSAEINTR:
errno=EINTR; break;
case WSAEBADF:
errno=EBADF; break;
case WSAEACCES:
errno=EACCES; break;
case WSAEFAULT:
errno=EFAULT; break;
case WSAEINVAL:
errno=EINVAL; break;
case WSAEMFILE:
errno=EMFILE; break;
case WSAENAMETOOLONG:
errno=ENAMETOOLONG; break;
case WSAENOTEMPTY:
errno=ENOTEMPTY; break;
default:
errno=x;
break;
}
return l;
}
#endif
Loading…
Cancel
Save