sync with experimental
[luatex.git] / source / texk / kpathsea / win32lib.h
blob28aae28d8d5f116cd1e13fda6ffef3beb6e9881d
1 /* win32lib.h: bits and pieces for win32 and msvc.
3 Copyright 2006, 2010-2015 Akira Kakuto.
4 Copyright 1996, 1997, 1998, 1999 Fabrice Popineau.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, see <http://www.gnu.org/licenses/>. */
20 #ifndef KPATHSEA_WIN32LIB_H
21 #define KPATHSEA_WIN32LIB_H
23 #ifndef KPSE_COMPAT_API
24 #define KPSE_COMPAT_API 1
25 #endif
27 #pragma warning( disable : 4007 4096 4018 4244 )
29 #include <kpathsea/c-auto.h>
30 #include <kpathsea/c-proto.h>
33 * Define symbols to identify the version of Unix this is.
34 * Define all the symbols that apply correctly.
37 #ifndef DOSISH
38 #define DOSISH
39 #endif
41 #ifndef MAXPATHLEN
42 #define MAXPATHLEN _MAX_PATH
43 #endif
45 #define HAVE_DUP2 1
46 #define HAVE_RENAME 1
47 #define HAVE_RMDIR 1
48 #define HAVE_MKDIR 1
49 #define HAVE_GETHOSTNAME 1
50 #define HAVE_RANDOM 1
51 #define USE_UTIME 1
52 #define HAVE_MOUSE 1
53 #define HAVE_TZNAME 1
55 /* These have to be defined because our compilers treat __STDC__ as being
56 defined (most of them anyway). */
58 #if !defined(__cplusplus)
59 #define access _access
60 #define alloca _alloca
61 #define chdir _chdir
62 #define chmod _chmod
63 #define close _close
64 #define creat _creat
65 #define daylight _daylight
66 #define dup _dup
67 #define dup2 _dup2
68 #define execlp _execlp
69 #define execvp _execvp
70 #define fcloseall _fcloseall
71 #define fdopen _fdopen
72 #define fileno _fileno
73 #define flushall _flushall
74 #define fstat _fstat
75 #define ftime _ftime
76 #define getpid _getpid
77 #define getcwd _getcwd
78 #define inline __inline
79 #define isascii __isascii
80 #define isatty _isatty
81 #define itoa _itoa
82 #define link _link
83 #define lseek _lseek
84 #define memicmp _memicmp
85 #define mktemp _mktemp
86 #define open _open
87 #define putenv _putenv
88 #define read _read
89 #define rmdir _rmdir
90 #define setmode _setmode
91 #define spawnlp _spawnlp
92 #define stat _stat
93 #define stricmp _stricmp
94 #define strdup _strdup
95 #define strlwr _strlwr
96 #define strnicmp _strnicmp
97 #define tempnam _tempnam
98 #define timeb _timeb
99 #define timezone _timezone
100 #define unlink _unlink
101 #define umask _umask
102 #define utime _utime
103 #define write _write
104 #endif /* !__cplusplus */
106 #define getwd(dir) GetCurrentDirectory(MAXPATHLEN, dir)
108 #ifdef strcasecmp
109 #undef strcasecmp
110 #endif
111 #ifdef strncasecmp
112 #undef strncasecmp
113 #endif
114 #define strcasecmp _stricmp
115 #define strncasecmp _strnicmp
117 #ifndef S_IFMT
118 #define S_IFMT _S_IFMT
119 #endif
120 #ifndef S_IFDIR
121 #define S_IFDIR _S_IFDIR
122 #endif
123 #ifndef S_IFCHR
124 #define S_IFCHR _S_IFCHR
125 #endif
126 #ifndef S_IFIFO
127 #define S_IFIFO _S_IFIFO
128 #endif
129 #ifndef S_IFREG
130 #define S_IFREG _S_IFREG
131 #endif
132 #ifndef S_IREAD
133 #define S_IREAD _S_IREAD
134 #endif
135 #ifndef S_IWRITE
136 #define S_IWRITE _S_IWRITE
137 #endif
138 #define S_IEXEC _S_IEXEC
139 #ifndef S_IXUSR
140 #define S_IXUSR _S_IEXEC
141 #endif
142 #ifndef S_IXGRP
143 #define S_IXGRP _S_IEXEC
144 #endif
145 #ifndef S_IXOTH
146 #define S_IXOTH _S_IEXEC
147 #endif
148 #ifndef S_IRUSR
149 #define S_IRUSR _S_IREAD
150 #endif
151 #ifndef S_IWUSR
152 #define S_IWUSR _S_IWRITE
153 #endif
154 #ifndef S_IROTH
155 #define S_IROTH _S_IREAD
156 #endif
157 #ifndef S_IWOTH
158 #define S_IWOTH _S_IWRITE
159 #endif
160 #ifndef S_IRGRP
161 #define S_IRGRP _S_IREAD
162 #endif
163 #ifndef S_IWGRP
164 #define S_IWGRP _S_IWRITE
165 #endif
166 #ifndef O_RDWR
167 #define O_RDWR _O_RDWR
168 #endif
169 #ifndef O_CREAT
170 #define O_CREAT _O_CREAT
171 #endif
172 #ifndef O_TRUNC
173 #define O_TRUNC _O_TRUNC
174 #endif
175 #ifndef O_RDONLY
176 #define O_RDONLY _O_RDONLY
177 #endif
178 #ifndef O_WRONLY
179 #define O_WRONLY _O_WRONLY
180 #endif
181 #ifndef O_APPEND
182 #define O_APPEND _O_APPEND
183 #endif
184 #ifndef O_TEXT
185 #define O_TEXT _O_TEXT
186 #endif
187 #ifndef O_BINARY
188 #define O_BINARY _O_BINARY
189 #endif
190 #ifndef O_EXCL
191 #define O_EXCL _O_EXCL
192 #endif
194 #if defined (S_IFBLK) && !defined (S_ISBLK)
195 #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
196 #endif
198 #if defined (S_IFCHR) && !defined (S_ISCHR)
199 #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
200 #endif
202 #if defined (S_IFDIR) && !defined (S_ISDIR)
203 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
204 #endif
206 #if defined (S_IFREG) && !defined (S_ISREG)
207 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
208 #endif
210 #if defined (S_IFIFO) && !defined (S_ISFIFO)
211 #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
212 #endif
214 #if defined (S_IFLNK) && !defined (S_ISLNK)
215 #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
216 #endif
218 #if defined (S_IFSOCK) && !defined (S_ISSOCK)
219 #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
220 #endif
222 /* Define this so that winsock.h definitions don't get included when
223 windows.h is... For this to have proper effect, config.h must
224 always be included before windows.h. */
225 #if !defined(_WINSOCKAPI_) && !defined(WWW_WIN_DLL)
226 #define _WINSOCKAPI_ 1
227 #endif
229 #define boolean saved_boolean
230 #include <windows.h>
231 #undef boolean
233 #include <kpathsea/types.h>
235 /* Defines size_t and alloca (). */
236 #include <malloc.h>
238 /* For proper declaration of environ. */
239 #include <stdlib.h>
240 #include <io.h>
241 #include <fcntl.h>
242 #include <stdio.h>
243 #include <process.h>
245 /* For _getcwd. */
246 #include <direct.h>
248 /* Web2C takes care of ensuring that these are defined. */
249 #ifdef max
250 #undef max
251 #undef min
252 #endif
254 #ifdef __cplusplus
255 extern "C" {
256 #endif
258 extern KPSEDLL double win32_floor (double x);
259 extern KPSEDLL FILE *win32_popen (const char *cmd, const char *mode);
260 extern KPSEDLL int win32_pclose (FILE *f);
261 extern KPSEDLL struct passwd *kpathsea_getpwnam (kpathsea kpse, char *name);
262 extern KPSEDLL int win32_system(const char *cmd);
263 extern KPSEDLL void kpathsea_init_user_info (kpathsea kpse);
265 #if defined (KPSE_COMPAT_API)
266 extern KPSEDLL struct passwd *getpwnam (char *name);
267 #endif /* KPSE_COMPAT_API */
269 #define system(p) win32_system(p)
270 #define popen(cmd, mode) win32_popen(cmd, mode)
271 #define pclose(file) win32_pclose(file)
272 /* Functions for WIN32 */
273 extern KPSEDLL FILE *popen(const char * str, const char * str2);
274 extern KPSEDLL int pclose(FILE * f);
275 extern KPSEDLL int system(const char * cmd);
277 extern KPSEDLL void texlive_gs_init(void);
278 extern KPSEDLL int getlongpath (char *output, char *input, int len);
279 extern KPSEDLL char *get_home_directory (void);
281 #define off_t __int64
282 #define xfseeko xfseek64
283 #define xftello xftell64
285 #ifdef __cplusplus
287 #endif
289 #endif /* not KPATHSEA_WIN32LIB_H */