1 | /* $Id: mscfakes.h 633 2006-11-26 14:05:05Z bird $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * Unix fakes for MSC.
|
---|
5 | *
|
---|
6 | * Copyright (c) 2005 knut st. osmundsen <[email protected]>
|
---|
7 | *
|
---|
8 | *
|
---|
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.
|
---|
13 | *
|
---|
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.
|
---|
18 | *
|
---|
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
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef __mscfakes_h__
|
---|
26 | #define __mscfakes_h__
|
---|
27 | #ifdef _MSC_VER
|
---|
28 |
|
---|
29 | #define setmode setmode_msc
|
---|
30 | #include <sys/cdefs.h>
|
---|
31 | #include <io.h>
|
---|
32 | #include <direct.h>
|
---|
33 | #include <time.h>
|
---|
34 | #include <fcntl.h>
|
---|
35 | #include <limits.h>
|
---|
36 | #undef setmode
|
---|
37 | //#include "getopt.h"
|
---|
38 |
|
---|
39 | #if !defined(__GNUC__) && !defined(__attribute__)
|
---|
40 | #define __attribute__(a)
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
---|
44 | #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
---|
45 | #define S_ISLNK(m) 0
|
---|
46 | #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
|
---|
47 | #define S_IXUSR _S_IEXEC
|
---|
48 | #define S_IWUSR _S_IWRITE
|
---|
49 | #define S_IRUSR _S_IREAD
|
---|
50 | #define S_IRWXG 0000070
|
---|
51 | #define S_IRGRP 0000040
|
---|
52 | #define S_IWGRP 0000020
|
---|
53 | #define S_IXGRP 0000010
|
---|
54 | #define S_IRWXO 0000007
|
---|
55 | #define S_IROTH 0000004
|
---|
56 | #define S_IWOTH 0000002
|
---|
57 | #define S_IXOTH 0000001
|
---|
58 | #define S_ISUID 0004000
|
---|
59 | #define S_ISGID 0002000
|
---|
60 | #define ALLPERMS 0000777
|
---|
61 |
|
---|
62 | #define PATH_MAX _MAX_PATH
|
---|
63 | #define MAXPATHLEN _MAX_PATH
|
---|
64 |
|
---|
65 | #define EX_OK 0
|
---|
66 | #define EX_OSERR 1
|
---|
67 | #define EX_NOUSER 1
|
---|
68 | #define EX_USAGE 1
|
---|
69 |
|
---|
70 | #define STDIN_FILENO 0
|
---|
71 | #define STDOUT_FILENO 1
|
---|
72 | #define STDERR_FILENO 2
|
---|
73 |
|
---|
74 | #define F_OK 0
|
---|
75 | #define X_OK 1
|
---|
76 | #define W_OK 2
|
---|
77 | #define R_OK 4
|
---|
78 |
|
---|
79 | #define EFTYPE EINVAL
|
---|
80 |
|
---|
81 | #define _PATH_DEVNULL "/dev/null"
|
---|
82 |
|
---|
83 | #define MAX(a,b) ((a) >= (b) ? (a) : (b))
|
---|
84 |
|
---|
85 | typedef int mode_t;
|
---|
86 | typedef unsigned short nlink_t;
|
---|
87 | typedef long ssize_t;
|
---|
88 | typedef unsigned long u_long;
|
---|
89 | typedef unsigned int u_int;
|
---|
90 | typedef unsigned short u_short;
|
---|
91 |
|
---|
92 | #ifndef timerisset
|
---|
93 | struct timeval
|
---|
94 | {
|
---|
95 | long tv_sec;
|
---|
96 | long tv_usec;
|
---|
97 | };
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | struct iovec
|
---|
101 | {
|
---|
102 | char *iov_base;
|
---|
103 | size_t iov_len;
|
---|
104 | };
|
---|
105 |
|
---|
106 |
|
---|
107 | #define chown(path, uid, gid) 0 /** @todo implement fchmod! */
|
---|
108 | char *dirname(char *path);
|
---|
109 | #define fsync(fd) 0
|
---|
110 | #define fchown(fd,uid,gid) 0
|
---|
111 | #define fchmod(fd, mode) 0 /** @todo implement fchmod! */
|
---|
112 | #define geteuid() 0
|
---|
113 | #define lstat(path, s) stat(path, s)
|
---|
114 | #define lchmod(path, mod) chmod(path, mod)
|
---|
115 | #define lchown(path, uid, gid) chown(path, uid, gid)
|
---|
116 | #define lutimes(path, tvs) utimes(path, tvs)
|
---|
117 | int link(const char *pszDst, const char *pszLink);
|
---|
118 | int mkdir_msc(const char *path, mode_t mode);
|
---|
119 | #define mkdir(path, mode) mkdir_msc(path, mode)
|
---|
120 | #define mkfifo(path, mode) -1
|
---|
121 | #define mknod(path, mode, devno) -1
|
---|
122 | #define pipe(v) _pipe(v,0,0)
|
---|
123 | int mkstemp(char *temp);
|
---|
124 | #define readlink(link, buf, size) -1
|
---|
125 | #define reallocf(old, size) realloc(old, size)
|
---|
126 | #define strcasecmp stricmp
|
---|
127 | #define strncasecmp strnicmp
|
---|
128 | #if _MSC_VER < 1400
|
---|
129 | int snprintf(char *buf, size_t size, const char *fmt, ...);
|
---|
130 | #else
|
---|
131 | #define snprintf _snprintf
|
---|
132 | #endif
|
---|
133 | size_t strlcpy(char *, const char *, size_t);
|
---|
134 | int symlink(const char *pszDst, const char *pszLink);
|
---|
135 | int utimes(const char *pszPath, const struct timeval *paTimes);
|
---|
136 | int writev(int fd, const struct iovec *vector, int count);
|
---|
137 | #define F_DUPFD 0
|
---|
138 | #define F_GETFD 1
|
---|
139 | #define F_SETFD 2
|
---|
140 | #define F_GETFL 3
|
---|
141 | #define F_SETFL 4
|
---|
142 | #define FD_CLOEXEC 1
|
---|
143 | #define O_NONBLOCK 0 /// @todo
|
---|
144 | #define EWOULDBLOCK 512
|
---|
145 | int fcntl (int, int, ...);
|
---|
146 |
|
---|
147 | /* signal hacks */
|
---|
148 | typedef struct sigset
|
---|
149 | {
|
---|
150 | unsigned long __bitmap[1];
|
---|
151 | } sigset_t;
|
---|
152 | typedef void __sighandler_t(int);
|
---|
153 | typedef void __siginfohandler_t(int, struct __siginfo *, void *);
|
---|
154 | typedef __sighandler_t *sig_t; /** BSD 4.4 type. */
|
---|
155 | struct sigaction
|
---|
156 | {
|
---|
157 | union
|
---|
158 | {
|
---|
159 | __siginfohandler_t *__sa_sigaction;
|
---|
160 | __sighandler_t *__sa_handler;
|
---|
161 | } __sigaction_u;
|
---|
162 | sigset_t sa_mask;
|
---|
163 | int sa_flags;
|
---|
164 | };
|
---|
165 | #define sa_handler __sigaction_u.__sa_handler
|
---|
166 | #define sa_sigaction __sigaction_u.__sa_sigaction
|
---|
167 |
|
---|
168 | int sigprocmask(int, const sigset_t *, sigset_t *);
|
---|
169 | #define SIG_BLOCK 1
|
---|
170 | #define SIG_UNBLOCK 2
|
---|
171 | #define SIG_SETMASK 3
|
---|
172 |
|
---|
173 | #define SIGTTIN 29
|
---|
174 | #define SIGTSTP 28
|
---|
175 | #define SIGTTOU 27
|
---|
176 | #define SIGCONT 26
|
---|
177 | #define SIGPIPE 25
|
---|
178 | #define SIGQUIT 24
|
---|
179 | #define SIGHUP 23
|
---|
180 | #ifndef NSIG
|
---|
181 | #define NSIG 32
|
---|
182 | #endif
|
---|
183 | extern const char *const sys_siglist[NSIG];
|
---|
184 |
|
---|
185 | int kill(pid_t, int);
|
---|
186 | int sigaction(int, const struct sigaction *, struct sigaction *);
|
---|
187 | //int sigaddset(sigset_t *, int);
|
---|
188 | //int sigdelset(sigset_t *, int);
|
---|
189 | int sigemptyset(sigset_t *);
|
---|
190 | //int sigfillset(sigset_t *);
|
---|
191 | //int sigismember(const sigset_t *, int);
|
---|
192 | //int sigpending(sigset_t *);
|
---|
193 | //int sigsuspend(const sigset_t *);
|
---|
194 | //int sigwait(const sigset_t *, int *);
|
---|
195 | int siginterrupt(int, int);
|
---|
196 |
|
---|
197 | #endif /* _MSC_VER */
|
---|
198 | #endif
|
---|
199 |
|
---|