1 /* 2 Copyright (c) 2006 by Dan Kennedy. 3 Copyright (c) 2006 by Juliusz Chroboczek. 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), to deal 7 in the Software without restriction, including without limitation the rights 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 copies of the Software, and to permit persons to whom the Software is 10 furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 THE SOFTWARE. 22 */ 23 /*Adaptions by memphiz@xbmc.org*/ 24 25 #ifndef win32_COMPAT_H_ 26 #define win32_COMPAT_H_ 27 #define NO_IPv6 1 28 29 #include <winsock2.h> 30 #include <ws2tcpip.h> 31 #include <ws2ipdef.h> 32 #include <basetsd.h> 33 #include <io.h> 34 #include <sys/stat.h> 35 #include <time.h> 36 37 typedef unsigned long fsblkcnt_t; 38 typedef unsigned long fsfilcnt_t; 39 typedef unsigned int uid_t; 40 typedef unsigned int gid_t; 41 typedef int socklen_t; 42 43 #ifndef S_IRUSR 44 #define S_IRUSR 0000400 45 #define S_IWUSR 0000200 46 #define S_IXUSR 0000100 47 #endif 48 #ifndef S_IRWXG 49 #define S_IRWXG 0000070 /* RWX mask for group */ 50 #define S_IRGRP 0000040 51 #define S_IWGRP 0000020 52 #define S_IXGRP 0000010 53 #define S_IRWXO 0000007 /* RWX mask for other */ 54 #define S_IROTH 0000004 55 #define S_IWOTH 0000002 56 #define S_IXOTH 0000001 57 #endif 58 59 #ifndef MSG_NOSIGNAL 60 #define MSG_NOSIGNAL 0 61 #endif 62 63 #define F_GETFL 3 64 #define F_SETFL 4 65 66 #ifndef S_IFLNK 67 #define S_IFLNK 0xA000 /* Link */ 68 #endif 69 70 #ifndef F_RDLCK 71 #define F_RDLCK 0 72 #define F_WRLCK 1 73 #define F_UNLCK 2 74 #endif 75 76 #ifndef S_IFIFO 77 #define S_IFIFO 0x1000 /* FIFO */ 78 #endif 79 80 #ifndef S_IFBLK 81 #define S_IFBLK 0x3000 /* Block: Is this ever set under w32? */ 82 #endif 83 84 #ifndef S_IFSOCK 85 #define S_IFSOCK 0x0 /* not defined in mingw either */ 86 #endif 87 88 #ifndef major 89 #define major(a) 0 90 #endif 91 92 #ifndef minor 93 #define minor(a) 0 94 #endif 95 96 #ifndef O_NONBLOCK 97 #define O_NONBLOCK 0x40000000 98 #endif 99 100 #ifndef O_SYNC 101 #define O_SYNC 0 102 #endif 103 104 #ifndef O_NOFOLLOW 105 #define O_NOFOLLOW 00400000 106 #endif 107 108 #define MSG_DONTWAIT 0 109 #define ssize_t SSIZE_T 110 111 #if(_WIN32_WINNT < 0x0600) 112 113 #define POLLIN 0x0001 /* There is data to read */ 114 #define POLLPRI 0x0002 /* There is urgent data to read */ 115 #define POLLOUT 0x0004 /* Writing now will not block */ 116 #define POLLERR 0x0008 /* Error condition */ 117 #define POLLHUP 0x0010 /* Hung up */ 118 #define POLLNVAL 0x0020 /* Invalid request: fd not open */ 119 120 struct pollfd { 121 SOCKET fd; /* file descriptor */ 122 short events; /* requested events */ 123 short revents; /* returned events */ 124 }; 125 #endif 126 127 #define close closesocket 128 #define ioctl ioctlsocket 129 130 #ifndef ESTALE 131 #define ESTALE 116 132 #endif 133 134 /* Wrapper macros to call misc. functions win32 is missing */ 135 #define poll(x, y, z) win32_poll(x, y, z) 136 #define snprintf sprintf_s 137 #define inet_pton(x,y,z) win32_inet_pton(x,y,z) 138 #define open(x, y, z) _open(x, y, z) 139 #ifndef lseek 140 #define lseek(x, y, z) _lseek(x, y, z) 141 #endif 142 #define read(x, y, z) _read(x, y, z) 143 #define write(x, y, z) _write(x, y, z) 144 int getpid(void); 145 int win32_inet_pton(int af, const char * src, void * dst); 146 int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout); 147 int win32_gettimeofday(struct timeval *tv, struct timezone *tz); 148 #ifdef __MINGW32__ 149 # define win32_gettimeofday mingw_gettimeofday 150 #endif 151 152 #define DllExport 153 154 #endif//win32_COMPAT_H_ 155