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
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.
42 #define MAXPATHLEN _MAX_PATH
49 #define HAVE_GETHOSTNAME 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
65 #define daylight _daylight
68 #define execlp _execlp
69 #define execvp _execvp
70 #define fcloseall _fcloseall
71 #define fdopen _fdopen
72 #define fileno _fileno
73 #define flushall _flushall
76 #define getpid _getpid
77 #define getcwd _getcwd
78 #define inline __inline
79 #define isascii __isascii
80 #define isatty _isatty
84 #define memicmp _memicmp
85 #define mktemp _mktemp
87 #define putenv _putenv
90 #define setmode _setmode
91 #define spawnlp _spawnlp
93 #define stricmp _stricmp
94 #define strdup _strdup
95 #define strlwr _strlwr
96 #define strnicmp _strnicmp
97 #define tempnam _tempnam
99 #define timezone _timezone
100 #define unlink _unlink
104 #endif /* !__cplusplus */
106 #define getwd(dir) GetCurrentDirectory(MAXPATHLEN, dir)
114 #define strcasecmp _stricmp
115 #define strncasecmp _strnicmp
118 #define S_IFMT _S_IFMT
121 #define S_IFDIR _S_IFDIR
124 #define S_IFCHR _S_IFCHR
127 #define S_IFIFO _S_IFIFO
130 #define S_IFREG _S_IFREG
133 #define S_IREAD _S_IREAD
136 #define S_IWRITE _S_IWRITE
138 #define S_IEXEC _S_IEXEC
140 #define S_IXUSR _S_IEXEC
143 #define S_IXGRP _S_IEXEC
146 #define S_IXOTH _S_IEXEC
149 #define S_IRUSR _S_IREAD
152 #define S_IWUSR _S_IWRITE
155 #define S_IROTH _S_IREAD
158 #define S_IWOTH _S_IWRITE
161 #define S_IRGRP _S_IREAD
164 #define S_IWGRP _S_IWRITE
167 #define O_RDWR _O_RDWR
170 #define O_CREAT _O_CREAT
173 #define O_TRUNC _O_TRUNC
176 #define O_RDONLY _O_RDONLY
179 #define O_WRONLY _O_WRONLY
182 #define O_APPEND _O_APPEND
185 #define O_TEXT _O_TEXT
188 #define O_BINARY _O_BINARY
191 #define O_EXCL _O_EXCL
194 #if defined (S_IFBLK) && !defined (S_ISBLK)
195 #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
198 #if defined (S_IFCHR) && !defined (S_ISCHR)
199 #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
202 #if defined (S_IFDIR) && !defined (S_ISDIR)
203 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
206 #if defined (S_IFREG) && !defined (S_ISREG)
207 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
210 #if defined (S_IFIFO) && !defined (S_ISFIFO)
211 #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
214 #if defined (S_IFLNK) && !defined (S_ISLNK)
215 #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
218 #if defined (S_IFSOCK) && !defined (S_ISSOCK)
219 #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
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
229 #define boolean saved_boolean
233 #include <kpathsea/types.h>
235 /* Defines size_t and alloca (). */
238 /* For proper declaration of environ. */
248 /* Web2C takes care of ensuring that these are defined. */
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
289 #endif /* not KPATHSEA_WIN32LIB_H */