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