src/SysDeps/posix.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef __SYSDEPS_POSIX_H__
00033 #define __SYSDEPS_POSIX_H__
00034 
00035 #include "SysDeps/host_type.h"
00036 
00037 #include <stdio.h>
00038 #include <errno.h>
00039 #include <fcntl.h>
00040 #include <sys/stat.h>
00041 
00042 #ifdef HOST_IS_WINDOWS
00043 
00044 #include <io.h>
00045 #include <process.h>
00046 #include <direct.h>
00047 
00048 #elif defined(HOST_IS_CYGWIN)
00049 
00050 #include <io.h>
00051 #include <process.h>
00052 #include <dirent.h>
00053 
00054 #elif defined(HOST_IS_LINUX)
00055 
00056 #include <unistd.h>
00057 #include <fcntl.h>
00058 #include <stdarg.h>
00059 #include <utime.h>
00060 #include <sys/types.h>
00061 #include <sys/stat.h>
00062 #include <sys/time.h>
00063 #include <sys/times.h>
00064 #include <sys/resource.h>
00065 #include <sys/file.h>
00066 #include <sys/mman.h>
00067 #include <sys/wait.h>
00068 #include <sys/socket.h>
00069 #include <sys/times.h>
00070 #include <sys/ioctl.h>
00071 #include <sys/mount.h>
00072 
00073 #else
00074 #error "unknown host type"
00075 #endif
00076 
00077 
00078 #ifdef HOST_IS_WINDOWS
00079 namespace Onikiri {
00080     namespace POSIX {
00081         typedef struct stat posix_struct_stat;
00082         const int POSIX_O_BINARY = _O_BINARY;
00083         const int POSIX_O_RDONLY = _O_RDONLY;
00084         const int POSIX_O_WRONLY = _O_WRONLY;
00085         const int POSIX_O_RDWR   = _O_RDWR;
00086         const int POSIX_O_APPEND = _O_APPEND;
00087         const int POSIX_O_CREAT  = _O_CREAT;
00088         const int POSIX_O_EXCL   = _O_EXCL;
00089         const int POSIX_O_TRUNC  = _O_TRUNC;
00090 
00091         const int POSIX_S_IFDIR  = _S_IFDIR;
00092         const int POSIX_S_IFCHR  = _S_IFCHR;
00093         const int POSIX_S_IFREG  = _S_IFREG;
00094         const int POSIX_S_IFIFO  = _S_IFIFO;
00095 
00096         const int POSIX_S_IWRITE = _S_IWRITE;
00097         const int POSIX_S_IREAD  = _S_IREAD;
00098 
00099         const int POSIX_F_OK = 0;
00100         const int POSIX_X_OK = 0;
00101         const int POSIX_W_OK = 2;
00102         const int POSIX_R_OK = 4;
00103 
00104         const int POSIX_SEEK_SET = SEEK_SET;
00105         const int POSIX_SEEK_CUR = SEEK_CUR;
00106         const int POSIX_SEEK_END = SEEK_END;
00107 
00108         int posix_geterrno();
00109 
00110         int posix_getpid();
00111 
00112         // Linux mF 959, 10 Windows lD
00113         inline int posix_getuid()
00114             { return 959; }
00115         inline int posix_geteuid()
00116             { return 959; }
00117         inline int posix_getgid()
00118             { return 10; }
00119         inline int posix_getegid()
00120             { return 10; }
00121 
00122         char *posix_getcwd(char* buf, int maxlen);
00123         int posix_chdir(const char* path);
00124 
00125         int posix_open(const char* name, int flags);
00126         int posix_open(const char* name, int flags, int pmode);
00127         int posix_read(int fd, void* buf, unsigned int count);
00128         int posix_write(int fd, void* buf, unsigned int count);
00129         int posix_close(int fd);
00130         s64 posix_lseek(int fd, s64 offset, int whence);
00131         int posix_dup(int fd);
00132 
00133         int posix_stat(const char* path, posix_struct_stat* s);
00134         int posix_fstat(int fd, posix_struct_stat* s);
00135         int posix_lstat(const char* path, posix_struct_stat* s);
00136 
00137         int posix_fileno(FILE *file);
00138         int posix_access(const char* path, int mode);
00139         int posix_unlink(const char* path);
00140         int posix_rename(const char* oldpath, const char* newpath);
00141 
00142         int posix_truncate(const char* path, s64 length);
00143         int posix_ftruncate(int fd, s64 length);
00144     }
00145 }
00146 #elif defined(HOST_IS_CYGWIN) || defined(HOST_IS_LINUX)
00147 namespace Onikiri {
00148     namespace POSIX {
00149         typedef struct stat posix_struct_stat;
00150         const int POSIX_O_BINARY = 0;
00151         const int POSIX_O_RDONLY = O_RDONLY;
00152         const int POSIX_O_WRONLY = O_WRONLY;
00153         const int POSIX_O_RDWR   = O_RDWR;
00154         const int POSIX_O_APPEND = O_APPEND;
00155         const int POSIX_O_CREAT  = O_CREAT;
00156         const int POSIX_O_EXCL   = O_EXCL;
00157         const int POSIX_O_TRUNC  = O_TRUNC;
00158 
00159         const int POSIX_S_IFDIR  = S_IFDIR;
00160         const int POSIX_S_IFCHR  = S_IFCHR;
00161         const int POSIX_S_IFREG  = S_IFREG;
00162         const int POSIX_S_IFIFO  = S_IFIFO;
00163 
00164         const int POSIX_S_IWRITE = S_IWRITE;
00165         const int POSIX_S_IREAD  = S_IREAD;
00166 
00167         const int POSIX_F_OK = F_OK;
00168         const int POSIX_X_OK = X_OK;
00169         const int POSIX_W_OK = W_OK;
00170         const int POSIX_R_OK = R_OK;
00171 
00172         const int POSIX_SEEK_SET = SEEK_SET;
00173         const int POSIX_SEEK_CUR = SEEK_CUR;
00174         const int POSIX_SEEK_END = SEEK_END;
00175 
00176         inline int posix_geterrno()
00177             { return errno; }
00178 
00179         inline int posix_getpid()
00180             { return getpid(); }
00181 
00182         inline int posix_getuid()
00183             { return getuid(); }
00184         inline int posix_geteuid()
00185             { return geteuid(); }
00186         inline int posix_getgid()
00187             { return getgid(); }
00188         inline int posix_getegid()
00189             { return getegid(); }
00190 
00191         inline char *posix_getcwd(char* buf, int maxlen)
00192             { return getcwd(buf, maxlen); }
00193         inline int posix_chdir(const char* path)
00194             { return chdir(path); }
00195 
00196         inline int posix_open(const char* name, int flags)
00197             { return open(name, flags); }
00198         inline int posix_open(const char* name, int flags, int pmode)
00199             { return open(name, flags, pmode); }
00200         inline int posix_read(int fd, void* buf, unsigned int count)
00201             { return read(fd, buf, count); }
00202         inline int posix_write(int fd, void* buf, unsigned int count)
00203             { return write(fd, buf, count); }
00204         inline int posix_close(int fd)
00205             { return close(fd); }
00206         inline int posix_dup(int fd)
00207             { return dup(fd); }
00208 
00209         // <TODO> {Coff_tTCYElseek64T|[g`FbND
00210 #if defined(HOST_IS_CYGWIN)
00211         // CYGWINlseek64
00212         inline s64 posix_lseek(int fd, s64 offset, int whence)
00213             { return lseek(fd, offset, whence); }
00214 #elif defined(HOST_IS_LINUX)
00215         inline s64 posix_lseek(int fd, s64 offset, int whence)
00216             { return lseek64(fd, offset, whence); }
00217 #endif
00218 
00219         inline int posix_stat(const char* path, posix_struct_stat* s)
00220             { return stat(path, s); }
00221         inline int posix_fstat(int fd, posix_struct_stat* s)
00222             { return fstat(fd, s); }
00223         inline int posix_lstat(const char* path, posix_struct_stat* s)
00224             { return lstat(path, s); }
00225 
00226         inline int posix_fileno(FILE *file)
00227             { return fileno(file); }
00228         inline int posix_access(const char* path, int mode)
00229             { return access(path, mode); }
00230         inline int posix_unlink(const char* path)
00231             { return unlink(path); }
00232         inline int posix_rename(const char* oldpath, const char* newpath)
00233             { return rename(oldpath, newpath); }
00234 
00235         inline int posix_truncate(const char* path, s64 length)
00236             { return truncate(path, length); }
00237         inline int posix_ftruncate(int fd, s64 length)
00238             { return ftruncate(fd, length); }
00239     }
00240 }
00241 #endif
00242 
00243 #endif

Onikiri2に対してTue Jun 18 14:34:26 2013に生成されました。  doxygen 1.4.7