* 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 <direct.h>
#include <sys/stat.h>
-
-#include "w32misc.h"
+#include "w32types.h"
/*
- * getopt.c
- */
-extern int getopt(int, char * const[], const char *);
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-/*
- * 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);
/* Should be in sys/stat.h */
#ifndef S_IRUSR
/* 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 read posix_read
-extern ssize_t posix_read(int, void *, size_t);
-#define write(fd, buffer, count) \
- posix_write((fd), (buffer), (count))
-extern ssize_t posix_write(int, const void *, size_t);
-extern int posix_close(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 */