| #ifndef _UNISTD_H |
| #define _UNISTD_H |
| |
| #define _IO_H_ |
| |
| #include <sys/types.h> |
| |
| /* |
| * Attributes of files as returned by _findfirst et al. |
| */ |
| #define _A_NORMAL 0x00000000 |
| #define _A_RDONLY 0x00000001 |
| #define _A_HIDDEN 0x00000002 |
| #define _A_SYSTEM 0x00000004 |
| #define _A_VOLID 0x00000008 |
| #define _A_SUBDIR 0x00000010 |
| #define _A_ARCH 0x00000020 |
| |
| /* Standard file descriptors. */ |
| #define STDIN_FILENO 0 /* Standard input. */ |
| #define STDOUT_FILENO 1 /* Standard output. */ |
| #define STDERR_FILENO 2 /* Standard error output. */ |
| |
| #ifndef RC_INVOKED |
| |
| #ifndef _INTPTR_T_DEFINED |
| #define _INTPTR_T_DEFINED |
| #ifdef _WIN64 |
| typedef __int64 intptr_t; |
| #else |
| typedef int intptr_t; |
| #endif |
| #endif |
| |
| #ifndef _FSIZE_T_DEFINED |
| typedef unsigned long _fsize_t; |
| #define _FSIZE_T_DEFINED |
| #endif |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW chdir(const char *); |
| _CRTIMP char *__cdecl __MINGW_NOTHROW getcwd(char *, int); |
| _CRTIMP char *__cdecl __MINGW_NOTHROW mktemp(char *); |
| //_CRTIMP int __cdecl __MINGW_NOTHROW chmod(const char *, mode_t); |
| |
| #ifdef __MSVCRT__ |
| _CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int); |
| _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int); |
| |
| #ifndef __NO_MINGW_LFS |
| __CRT_INLINE off64_t lseek64(int, off64_t, int); |
| __CRT_INLINE off64_t lseek64(int fd, off64_t offset, int whence) { |
| return _lseeki64(fd, (__int64)offset, whence); |
| } |
| #endif |
| |
| #endif /* __MSVCRT__ */ |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* Not RC_INVOKED */ |
| |
| /* TODO: Maximum number of open handles has not been tested, I just set |
| * it the same as FOPEN_MAX. */ |
| #define HANDLE_MAX FOPEN_MAX |
| |
| /* Some defines for _access nAccessMode (MS doesn't define them, but |
| * it doesn't seem to hurt to add them). */ |
| #define F_OK 0 /* Check for file existence */ |
| /* Well maybe it does hurt. On newer versions of MSVCRT, an access mode |
| of 1 causes invalid parameter error. */ |
| #define X_OK 1 /* Execute permission, Always OK */ |
| #define W_OK 2 /* Check for write permission */ |
| #define R_OK 4 /* Check for read permission */ |
| |
| #ifndef RC_INVOKED |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW access(const char*, int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW chsize(int, long); |
| _CRTIMP int __cdecl __MINGW_NOTHROW close(int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW commit(int); |
| |
| /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80), |
| * the "owner write permission" bit (on FAT). */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW creat(const char *, mode_t); |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW dup(int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW dup2(int, int); |
| _CRTIMP long __cdecl __MINGW_NOTHROW filelength(int); |
| _CRTIMP long __cdecl __MINGW_NOTHROW get_osfhandle(int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW isatty(int); |
| |
| /* LK_... locking commands defined in sys/locking.h. */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW _locking(int, int, long); |
| |
| #ifndef _STDIO_H |
| /* These are also defined in stdio.h. */ |
| #ifndef SEEK_SET |
| #define SEEK_SET 0 |
| #endif |
| |
| #ifndef SEEK_CUR |
| #define SEEK_CUR 1 |
| #endif |
| |
| #ifndef SEEK_END |
| #define SEEK_END 2 |
| #endif |
| #endif |
| |
| long __cdecl __MINGW_NOTHROW lseek(int, off_t, int); |
| |
| /* Optional third argument is unsigned unPermissions. */ |
| int __cdecl __MINGW_NOTHROW open(const char *, int, ...); |
| |
| int __cdecl __MINGW_NOTHROW pipe(int *); |
| int __cdecl __MINGW_NOTHROW read(int, void *, size_t); |
| int __cdecl __MINGW_NOTHROW _setmode(int, int); |
| long __cdecl __MINGW_NOTHROW _tell(int); |
| int __cdecl __MINGW_NOTHROW link(const char *, const char *); |
| int __cdecl __MINGW_NOTHROW symlink(const char *, const char *); |
| /* Should umask be in sys/stat.h and/or sys/types.h instead? */ |
| int __cdecl __MINGW_NOTHROW umask(int); |
| int __cdecl __MINGW_NOTHROW unlink(const char *); |
| int __cdecl __MINGW_NOTHROW write(int, const void *, size_t); |
| int __cdecl __MINGW_NOTHROW readlink(const char *, char *, size_t); |
| int __cdecl __MINGW_NOTHROW rmdir(const char *); |
| |
| void __cdecl __MINGW_NOTHROW _exit(int) __MINGW_ATTRIB_NORETURN; |
| |
| unsigned int __cdecl __MINGW_NOTHROW sleep(unsigned int); |
| int __cdecl __MINGW_NOTHROW usleep(unsigned long int); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* Not RC_INVOKED */ |
| |
| #include <process.h> |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| pid_t __cdecl __MINGW_NOTHROW getppid(void); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #define __UNISTD_GETOPT__ |
| #include <getopt.h> |
| #undef __UNISTD_GETOPT__ |
| |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| #define TTY_FD_INVALID (-1) |
| #define TTY_FD_DEFAULT (-2) |
| |
| int _get_stdout_fd(void); |
| int _get_stderr_fd(void); |
| int _set_stdout_fd(int); |
| int _set_stderr_fd(int); |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* _UNISTD_H */ |