1 | /* $Id: mscfakes.h 526 2006-09-16 14:37:51Z 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 <io.h>
|
---|
31 | #include <direct.h>
|
---|
32 | #include <time.h>
|
---|
33 | #undef setmode
|
---|
34 | #include "getopt.h"
|
---|
35 |
|
---|
36 | #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
---|
37 | #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
---|
38 | #define S_ISLNK(m) 0
|
---|
39 | #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
|
---|
40 | #define S_IXUSR _S_IEXEC
|
---|
41 | #define S_IWUSR _S_IWRITE
|
---|
42 | #define S_IRUSR _S_IREAD
|
---|
43 | #define S_IRWXG 0000070
|
---|
44 | #define S_IRGRP 0000040
|
---|
45 | #define S_IWGRP 0000020
|
---|
46 | #define S_IXGRP 0000010
|
---|
47 | #define S_IRWXO 0000007
|
---|
48 | #define S_IROTH 0000004
|
---|
49 | #define S_IWOTH 0000002
|
---|
50 | #define S_IXOTH 0000001
|
---|
51 | #define S_ISUID 0004000
|
---|
52 | #define S_ISGID 0002000
|
---|
53 | #define ALLPERMS 0000777
|
---|
54 |
|
---|
55 | #define PATH_MAX _MAX_PATH
|
---|
56 | #define MAXPATHLEN _MAX_PATH
|
---|
57 |
|
---|
58 | #define EX_OK 0
|
---|
59 | #define EX_OSERR 1
|
---|
60 | #define EX_NOUSER 1
|
---|
61 | #define EX_USAGE 1
|
---|
62 |
|
---|
63 | #define STDIN_FILENO 0
|
---|
64 | #define STDOUT_FILENO 1
|
---|
65 | #define STDERR_FILENO 2
|
---|
66 |
|
---|
67 | #define F_OK 0
|
---|
68 | #define X_OK 1
|
---|
69 | #define W_OK 2
|
---|
70 | #define R_OK 4
|
---|
71 |
|
---|
72 | #define EFTYPE EINVAL
|
---|
73 |
|
---|
74 | #define _PATH_DEVNULL "/dev/null"
|
---|
75 |
|
---|
76 | #define MAX(a,b) ((a) >= (b) ? (a) : (b))
|
---|
77 |
|
---|
78 | typedef int mode_t;
|
---|
79 | typedef unsigned short nlink_t;
|
---|
80 | typedef unsigned short uid_t;
|
---|
81 | typedef unsigned short gid_t;
|
---|
82 | typedef long ssize_t;
|
---|
83 | typedef unsigned long u_long;
|
---|
84 | typedef unsigned int u_int;
|
---|
85 | typedef unsigned short u_short;
|
---|
86 |
|
---|
87 | #ifndef timerisset
|
---|
88 | struct timeval
|
---|
89 | {
|
---|
90 | long tv_sec;
|
---|
91 | long tv_usec;
|
---|
92 | };
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | struct iovec
|
---|
96 | {
|
---|
97 | char *iov_base;
|
---|
98 | size_t iov_len;
|
---|
99 | };
|
---|
100 |
|
---|
101 |
|
---|
102 | #define chown(path, uid, gid) 0 /** @todo implement fchmod! */
|
---|
103 | char *dirname(char *path);
|
---|
104 | #define fsync(fd) 0
|
---|
105 | #define fchown(fd,uid,gid) 0
|
---|
106 | #define fchmod(fd, mode) 0 /** @todo implement fchmod! */
|
---|
107 | #define geteuid() 0
|
---|
108 | #define lstat(path, s) stat(path, s)
|
---|
109 | #define lchmod(path, mod) chmod(path, mod)
|
---|
110 | #define lchown(path, uid, gid) chown(path, uid, gid)
|
---|
111 | #define lutimes(path, tvs) utimes(path, tvs)
|
---|
112 | int link(const char *pszDst, const char *pszLink);
|
---|
113 | int mkdir_msc(const char *path, mode_t mode);
|
---|
114 | #define mkdir(path, mode) mkdir_msc(path, mode)
|
---|
115 | #define mkfifo(path, mode) -1
|
---|
116 | #define mknod(path, mode, devno) -1
|
---|
117 | int mkstemp(char *temp);
|
---|
118 | #define readlink(link, buf, size) -1
|
---|
119 | #define reallocf(old, size) realloc(old, size)
|
---|
120 | #if _MSC_VER < 1400
|
---|
121 | int snprintf(char *buf, size_t size, const char *fmt, ...);
|
---|
122 | #else
|
---|
123 | #define snprintf _snprintf
|
---|
124 | #endif
|
---|
125 | size_t strlcpy(char *, const char *, size_t);
|
---|
126 | int symlink(const char *pszDst, const char *pszLink);
|
---|
127 | int utimes(const char *pszPath, const struct timeval *paTimes);
|
---|
128 | int writev(int fd, const struct iovec *vector, int count);
|
---|
129 |
|
---|
130 | #endif /* _MSC_VER */
|
---|
131 | #endif
|
---|
132 |
|
---|