6 * Copyright (c) 2005-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with This program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef __mscfakes_h__
26 #define __mscfakes_h__
36 #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
37 # define off_t __int64
39 # define fstat _fstat64
40 # define lseek _lseeki64
43 # define stat(_path, _st) my_other_stat(_path, _st)
44 extern int my_other_stat(const char *, struct stat
*);
49 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
50 #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
52 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
53 #define S_IXUSR _S_IEXEC
54 #define S_IWUSR _S_IWRITE
55 #define S_IRUSR _S_IREAD
56 #define S_IRWXG 0000070
57 #define S_IRGRP 0000040
58 #define S_IWGRP 0000020
59 #define S_IXGRP 0000010
60 #define S_IRWXO 0000007
61 #define S_IROTH 0000004
62 #define S_IWOTH 0000002
63 #define S_IXOTH 0000001
64 #define S_ISUID 0004000
65 #define S_ISGID 0002000
66 #define ALLPERMS 0000777
68 #define PATH_MAX _MAX_PATH
69 #define MAXPATHLEN _MAX_PATH
76 #define STDIN_FILENO 0
77 #define STDOUT_FILENO 1
78 #define STDERR_FILENO 2
87 #define _PATH_DEVNULL "/dev/null"
89 #define MAX(a,b) ((a) >= (b) ? (a) : (b))
92 typedef unsigned short nlink_t
;
93 typedef unsigned short uid_t
;
94 typedef unsigned short gid_t
;
96 typedef unsigned long u_long
;
97 typedef unsigned int u_int
;
98 typedef unsigned short u_short
;
114 typedef __int64
intmax_t;
115 typedef unsigned __int64
uintmax_t;
117 #define chown(path, uid, gid) 0 /** @todo implement fchmod! */
118 char *dirname(char *path
);
120 #define fchown(fd,uid,gid) 0
121 #define fchmod(fd, mode) 0 /** @todo implement fchmod! */
124 #define lstat(path, s) stat(path, s)
125 int lchmod(const char *path
, mode_t mode
);
126 int msc_chmod(const char *path
, mode_t mode
);
127 #define chmod msc_chmod
128 #define lchown(path, uid, gid) chown(path, uid, gid)
129 #define lutimes(path, tvs) utimes(path, tvs)
130 int link(const char *pszDst
, const char *pszLink
);
131 int mkdir_msc(const char *path
, mode_t mode
);
132 #define mkdir(path, mode) mkdir_msc(path, mode)
133 #define mkfifo(path, mode) -1
134 #define mknod(path, mode, devno) -1
135 int mkstemp(char *temp
);
136 #define readlink(link, buf, size) -1
137 #define reallocf(old, size) realloc(old, size)
138 int rmdir_msc(const char *path
);
139 #define rmdir(path) rmdir_msc(path)
140 intmax_t strtoimax(const char *nptr
, char **endptr
, int base
);
141 uintmax_t strtoumax(const char *nptr
, char **endptr
, int base
);
142 #define strtoll(a,b,c) strtoimax(a,b,c)
143 #define strtoull(a,b,c) strtoumax(a,b,c)
144 int asprintf(char **strp
, const char *fmt
, ...);
145 int vasprintf(char **strp
, const char *fmt
, va_list ap
);
147 int snprintf(char *buf
, size_t size
, const char *fmt
, ...);
149 #define snprintf _snprintf
151 size_t strlcpy(char *, const char *, size_t);
152 int symlink(const char *pszDst
, const char *pszLink
);
153 int utimes(const char *pszPath
, const struct timeval
*paTimes
);
154 int writev(int fd
, const struct iovec
*vector
, int count
);
156 #endif /* _MSC_VER */