2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, 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
35 * We can provide POSIX headers that don't exist in Windows, but we
36 * can't augment existing headers. Some stuff that should be in such
37 * headers ends up here, and some in w32misc.h. Can't be helped.
44 * We override system functions by defining them as macros. This
45 * breaks if the system's declaration is included later. Include them
46 * here. Major name space pollution, can't be helped.
58 extern int getopt(int, char * const[], const char *);
60 extern int optind, opterr, optopt;
65 /* Should be in sys/stat.h */
66 #define mkdir(dir, perm) posix_mkdir((dir), (perm))
67 extern int posix_mkdir(const char *dirname, mode_t perm);
72 /* Should be in sys/stat.h */
74 #define S_IRUSR _S_IREAD
75 #define S_IWUSR _S_IWRITE
76 #define S_IXUSR _S_IEXEC
77 #define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
83 #define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
89 #define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
91 #define fstat(fd, buffer) \
92 posix_fstat((fd), (buffer))
93 extern int posix_fstat(int fd, struct stat *buffer);
95 /* Should be in fcntl.h */
110 /* intentionally missing: pid_t l_pid */
113 #define creat(fname, pmode) \
114 posix_open((fname), _O_WRONLY | _O_CREAT |_O_TRUNC, (pmode))
115 #define open(fname, oflag, ...) \
116 posix_open((fname), (oflag), __VA_ARGS__)
117 extern int posix_open(const char *fname, int oflag, ...);
118 extern int fcntl(int fd, int cmd, ...);
120 /* Stuff that actually belongs here */
123 #define lseek(fd, offset, origin) \
124 posix_lseek((fd), (offset), (origin))
125 #define read posix_read
126 #define write(fd, buffer, count) \
127 posix_write((fd), (buffer), (count))
130 extern int ftruncate(int fd, off_t length);
131 extern int posix_close(int fd);
132 extern off_t posix_lseek(int fd, off_t offset, int origin);
133 extern ssize_t posix_read(int fd, void *buffer, size_t count);
134 extern ssize_t posix_write(int fd, const void *buffer, size_t count);
135 extern int posix_fsync(int fd);
137 /* Low-level stuff specific to the emulation */
138 extern int posix_fd2socket(int fd);
140 #endif /* UNISTD_H */