]> git.pond.sub.org Git - empserver/blobdiff - src/lib/w32/unistd.h
Update copyright notice
[empserver] / src / lib / w32 / unistd.h
index 807be4a5f87294266c6140c0f71b194f0247ec08..6ec9e3cc0e98157e29819cd7b25d8ceb50902b8a 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *
  *  ---
  *
- *  unistd.h: POSIX emulation for WIN32
- * 
+ *  unistd.h: POSIX emulation for Windows
+ *
  *  Known contributors to this file:
  *     Ron Koenderink, 2007
+ *     Markus Armbruster, 2007-2009
  */
 
 /*
  * breaks if the system's declaration is included later.  Include them
  * here.  Major name space pollution, can't be helped.
  */
+#include <getopt.h>
 #include <io.h>
-#include <stdio.h>
 #include <direct.h>
 #include <sys/stat.h>
-
-#include "w32misc.h"
-
-/*
- * getopt.c
- */
-extern int getopt(int, char * const[], const char *);
-extern char *optarg;
-extern int optind, opterr, optopt;
+#include "w32types.h"
 
 /*
- * posixfile.c
+ * w32file.c
  */
 /* Should be in sys/stat.h */
-#define mkdir(dir, perm)    posix_mkdir((dir), (perm))
-extern int posix_mkdir(const char *dirname, mode_t perm);
+#define mkdir(dir, perm)    w32_mkdir((dir), (perm))
+extern int w32_mkdir(const char *dirname, mode_t perm);
 
-/*
- * posixio.c
- */
 /* Should be in sys/stat.h */
 #ifndef S_IRUSR
 #define S_IRUSR            _S_IREAD
@@ -88,53 +77,22 @@ extern int posix_mkdir(const char *dirname, mode_t perm);
 #define S_IXOTH            0
 #define S_IRWXO            S_IROTH | S_IWOTH | S_IXOTH
 #endif
-#define fstat(fd, buffer) \
-    posix_fstat((fd), (buffer))
-extern int posix_fstat(int fd, struct stat *buffer);
 
 /* Should be in fcntl.h */
 #define O_NONBLOCK  1
 
-#define F_RDLCK            0
-#define F_WRLCK            1
 #define F_GETFL            1
 #define F_SETFL            2
-#define F_SETLK            3
 
-struct flock
-{
-    short l_type;
-    short l_whence;
-    off_t l_start;
-    off_t l_len;
-    /* intentionally missing: pid_t l_pid */
-};
-
-#define creat(fname, pmode) \
-    posix_open((fname), _O_WRONLY | _O_CREAT |_O_TRUNC, (pmode))
-#define open(fname, oflag, ...) \
-    posix_open((fname), (oflag), __VA_ARGS__)
-extern int posix_open(const char *fname, int oflag, ...);
 extern int fcntl(int fd, int cmd, ...);
 
 /* Stuff that actually belongs here */
-#define close(fd) \
-    posix_close((fd))
-#define lseek(fd, offset, origin) \
-    posix_lseek((fd), (offset), (origin))
-#define read   posix_read
-#define write(fd, buffer, count) \
-    posix_write((fd), (buffer), (count))
-#define fsync(fd) \
-    posix_fsync((fd))
-extern int ftruncate(int fd, off_t length);
-extern int posix_close(int fd);
-extern off_t posix_lseek(int fd, off_t offset, int origin);
-extern ssize_t posix_read(int fd, void *buffer, size_t count);
-extern ssize_t posix_write(int fd, const void *buffer, size_t count);
-extern int posix_fsync(int fd);
-
-/* Low-level stuff specific to the emulation */
-extern int posix_fd2socket(int fd);
+#define close(fd) w32_close_function((fd))
+extern int (*w32_close_function)(int);
+#define ftruncate(fd, length) _chsize((fd), (length))
+#define read(fd, buf, sz) w32_read_function((fd), (buf), (sz))
+extern int (*w32_read_function)(int, void *, unsigned);
+#define write(fd, buf, sz) w32_write_function((fd), (buf), (sz))
+extern int (*w32_write_function)(int, const void *, unsigned);
 
 #endif /* UNISTD_H */