source: trunk/src/kmk/kmkbuiltin/mscfakes.h@ 1320

Last change on this file since 1320 was 1309, checked in by bird, 18 years ago

combined the bulk of the cmp stuff into cmp_util.c. implemented cp --changed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: mscfakes.h 1309 2007-12-02 04:53:40Z bird $ */
2/** @file
3 *
4 * Unix fakes for MSC.
5 *
6 * Copyright (c) 2005-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
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#include <stdarg.h>
34#include <malloc.h>
35#undef setmode
36#include "getopt.h"
37
38#if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
39# define off_t __int64
40# define stat _stat64
41# define fstat _fstat64
42# define lseek _lseeki64
43#endif
44
45
46#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
47#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
48#define S_ISLNK(m) 0
49#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
50#define S_IXUSR _S_IEXEC
51#define S_IWUSR _S_IWRITE
52#define S_IRUSR _S_IREAD
53#define S_IRWXG 0000070
54#define S_IRGRP 0000040
55#define S_IWGRP 0000020
56#define S_IXGRP 0000010
57#define S_IRWXO 0000007
58#define S_IROTH 0000004
59#define S_IWOTH 0000002
60#define S_IXOTH 0000001
61#define S_ISUID 0004000
62#define S_ISGID 0002000
63#define ALLPERMS 0000777
64
65#define PATH_MAX _MAX_PATH
66#define MAXPATHLEN _MAX_PATH
67
68#define EX_OK 0
69#define EX_OSERR 1
70#define EX_NOUSER 1
71#define EX_USAGE 1
72
73#define STDIN_FILENO 0
74#define STDOUT_FILENO 1
75#define STDERR_FILENO 2
76
77#define F_OK 0
78#define X_OK 1
79#define W_OK 2
80#define R_OK 4
81
82#define EFTYPE EINVAL
83
84#define _PATH_DEVNULL "/dev/null"
85
86#define MAX(a,b) ((a) >= (b) ? (a) : (b))
87
88typedef int mode_t;
89typedef unsigned short nlink_t;
90typedef unsigned short uid_t;
91typedef unsigned short gid_t;
92typedef long ssize_t;
93typedef unsigned long u_long;
94typedef unsigned int u_int;
95typedef unsigned short u_short;
96
97#ifndef timerisset
98struct timeval
99{
100 long tv_sec;
101 long tv_usec;
102};
103#endif
104
105struct iovec
106{
107 char *iov_base;
108 size_t iov_len;
109};
110
111typedef __int64 intmax_t;
112typedef unsigned __int64 uintmax_t;
113
114#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
115char *dirname(char *path);
116#define fsync(fd) 0
117#define fchown(fd,uid,gid) 0
118#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
119#define geteuid() 0
120#define getegid() 0
121#define lstat(path, s) stat(path, s)
122#define lchmod(path, mod) chmod(path, mod)
123#define lchown(path, uid, gid) chown(path, uid, gid)
124#define lutimes(path, tvs) utimes(path, tvs)
125int link(const char *pszDst, const char *pszLink);
126int mkdir_msc(const char *path, mode_t mode);
127#define mkdir(path, mode) mkdir_msc(path, mode)
128#define mkfifo(path, mode) -1
129#define mknod(path, mode, devno) -1
130int mkstemp(char *temp);
131#define readlink(link, buf, size) -1
132#define reallocf(old, size) realloc(old, size)
133int rmdir_msc(const char *path);
134#define rmdir(path) rmdir_msc(path)
135intmax_t strtoimax(const char *nptr, char **endptr, int base);
136uintmax_t strtoumax(const char *nptr, char **endptr, int base);
137#define strtoll(a,b,c) strtoimax(a,b,c)
138#define strtoull(a,b,c) strtoumax(a,b,c)
139int asprintf(char **strp, const char *fmt, ...);
140int vasprintf(char **strp, const char *fmt, va_list ap);
141#if _MSC_VER < 1400
142int snprintf(char *buf, size_t size, const char *fmt, ...);
143#else
144#define snprintf _snprintf
145#endif
146size_t strlcpy(char *, const char *, size_t);
147int symlink(const char *pszDst, const char *pszLink);
148int utimes(const char *pszPath, const struct timeval *paTimes);
149int writev(int fd, const struct iovec *vector, int count);
150
151#endif /* _MSC_VER */
152#endif
153
Note: See TracBrowser for help on using the repository browser.