2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * unistd.h: POSIX emulation for WIN32
30 * Known contributors to this file:
31 * Ron Koenderink, 2007
41 #include "sys/socket.h"
50 extern int getopt(int, char * const[], const char *);
52 extern int optind, opterr, optopt;
57 #define mkdir(dir, perm) posix_mkdir((dir), (perm))
59 extern int posix_mkdir(const char *dirname, mode_t perm);
65 #define S_IRUSR _S_IREAD
66 #define S_IWUSR _S_IWRITE
67 #define S_IXUSR _S_IEXEC
68 #define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
74 #define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
80 #define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
83 typedef int socklen_t;
85 #define accept(fd, addr, addrlen) \
86 posix_accept((fd), (addr), (addrlen))
87 #define bind(fd, name, namelen) \
88 posix_bind((fd), (name), (namelen))
89 #define listen(fd, backlog) \
90 posix_listen((fd), (backlog))
91 #define setsockopt(fd, level, optname, optval, optlen) \
92 posix_setsockopt((fd), (level), (optname), (optval), (optlen))
93 #define shutdown(fd, how) \
94 posix_shutdown((fd), (how))
95 #define socket(domain, type, protocol) \
96 posix_socket((domain), (type), (protocol))
100 #define creat(fname, pmode) \
101 posix_open((fname), _O_WRONLY | _O_CREAT |_O_TRUNC, (pmode))
102 #define fstat(fd, buffer) \
103 posix_fstat((fd), (buffer))
104 #define lseek(fd, offset, origin) \
105 posix_lseek((fd), (offset), (origin))
106 #define open(fname, oflag, ...) \
107 posix_open((fname), (oflag), __VA_ARGS__)
108 #define read posix_read
109 #define write(fd, buffer, count) \
110 posix_write((fd), (buffer), (count))
111 #define fileno(stream) \
112 posix_fileno((stream))
122 #define EWOULDBLOCK WSAEWOULDBLOCK
123 #define ENOTSOCK WSAENOTSOCK
131 /* intentionally missing: pid_t l_pid */
134 extern int posix_fd2socket(int fd);
136 extern int posix_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
137 extern int posix_bind(int fd, const struct sockaddr *name, socklen_t namelen);
138 extern int posix_listen(int fd, int backlog);
139 extern int posix_setsockopt(int fd, int level, int optname,
140 const void *optval, socklen_t optlen);
141 extern int posix_shutdown(int fd, int how);
142 extern int posix_socket(int domain, int type, int protocol);
143 extern const char *inet_ntop(int af, const void *src, char *dst,
146 extern int posix_close(int fd);
147 extern int posix_fstat(int fd, struct stat *buffer);
148 extern off_t posix_lseek(int fd, off_t offset, int origin);
149 extern int posix_open(const char *fname, int oflag, ...);
150 extern ssize_t posix_read(int fd, void *buffer, size_t count);
151 extern ssize_t posix_write(int fd, const void *buffer, size_t count);
153 extern int posix_fileno(FILE *stream);
154 extern int posix_fsync(int fd);
155 extern int fcntl(int fd, int cmd, ...);
156 #endif /* UNISTD_H */