winutils.h revision 999a029fc1cb9858f58d8006fc990eb9d7b7c9cd
#ifndef __WINUTILS_H_
# define __WINUTILS_H_
# ifdef RT_OS_WINDOWS
# include <WinSock2.h>
# include <ws2tcpip.h>
# include <mswsock.h>
# include <Windows.h>
/**
* of hton-family functions in LWIP and windock's headers.
*/
# ifndef PF_LOCAL
# endif
# ifdef DEBUG
AssertMsgFailed((__VA_ARGS__)); \
}while(0)
#else
DPRINTF0((__VA_ARGS__)); \
ExitProcess(code); \
}while(0)
#endif
# define __func__ __FUNCTION__
# define __attribute__(x) /* IGNORE */
/**
* tftpd emulation we're using POSIX operations which needs "DOS errno". see proxy_tftpd.c
*/
# ifndef _USE_WINSTD_ERRNO
/**
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms737828(v=vs.85).aspx
* "Error Codes - errno, h_errno and WSAGetLastError" says "Error codes set by Windows Sockets are
* not made available through the errno variable."
*/
# include <errno.h>
# ifdef errno
# endif
# define errno (WSAGetLastError())
# endif
/* Missing errno codes */
/**
* "Windows Sockets Error Codes" obtained with WSAGetLastError().
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
*/
# define EMSGSIZE WSAEMSGSIZE
# define ENETDOWN WSAENETDOWN
# define ENETUNREACH WSAENETUNREACH
# define EHOSTDOWN WSAEHOSTDOWN
# define EHOSTUNREACH WSAEHOSTUNREACH
/**
* parameters to shutdown (2) with Winsock2
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740481(v=vs.85).aspx
*/
# define SHUT_RD SD_RECEIVE
#if _WIN32_WINNT < 0x0600
/* otherwise defined the other way around in ws2def.h */
#define cmsghdr _WSACMSGHDR
#define CMSG_DATA WSA_CMSG_DATA
#define CMSG_LEN WSA_CMSG_LEN
#define CMSG_SPACE WSA_CMSG_SPACE
#define CMSG_FIRSTHDR WSA_CMSG_FIRSTHDR
#define CMSG_NXTHDR WSA_CMSG_NXTHDR
#endif /* _WIN32_WINNT < 0x0600 - provide unglified CMSG names */
# else /* !RT_OS_WINDOWS */
# define SOCKET int
# define INVALID_SOCKET (-1)
# define SOCKET_ERROR (-1)
# define closesocket(s) close(s)
# endif
#endif