Browse Source

More Windoze crap

master
Felix von Leitner 18 years ago
parent
commit
32770a95df
  1. 16
      socket/init.c
  2. 39
      unix/winsock2errno.c

16
socket/init.c

@ -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

39
unix/winsock2errno.c

@ -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