| 1 |
/* win32lib.h: bits and pieces for win32 and msvc. |
| 2 |
|
| 3 |
Copyright 2006, 2010-2016 Akira Kakuto. |
| 4 |
Copyright 1996, 1997, 1998, 1999 Fabrice Popineau. |
| 5 |
|
| 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. |
| 10 |
|
| 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. |
| 15 |
|
| 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/>. */ |
| 18 |
|
| 19 |
|
| 20 |
#ifndef KPATHSEA_WIN32LIB_H |
| 21 |
#define KPATHSEA_WIN32LIB_H |
| 22 |
|
| 23 |
#ifndef KPSE_COMPAT_API |
| 24 |
#define KPSE_COMPAT_API 1 |
| 25 |
#endif |
| 26 |
|
| 27 |
#pragma warning( disable : 4007 4096 4018 4244 ) |
| 28 |
|
| 29 |
#include <kpathsea/c-auto.h> |
| 30 |
#include <kpathsea/c-proto.h> |
| 31 |
|
| 32 |
/* |
| 33 |
* Define symbols to identify the version of Unix this is. |
| 34 |
* Define all the symbols that apply correctly. |
| 35 |
*/ |
| 36 |
|
| 37 |
#ifndef DOSISH |
| 38 |
#define DOSISH |
| 39 |
#endif |
| 40 |
|
| 41 |
#ifndef MAXPATHLEN |
| 42 |
#define MAXPATHLEN _MAX_PATH |
| 43 |
#endif |
| 44 |
|
| 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 |
| 54 |
|
| 55 |
/* These have to be defined because our compilers treat __STDC__ as being |
| 56 |
defined (most of them anyway). */ |
| 57 |
|
| 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 lseek _lseek |
| 83 |
#define memicmp _memicmp |
| 84 |
#define mktemp _mktemp |
| 85 |
#define open _open |
| 86 |
#define putenv _putenv |
| 87 |
#define read _read |
| 88 |
#define rmdir _rmdir |
| 89 |
#define setmode _setmode |
| 90 |
#define spawnlp _spawnlp |
| 91 |
#define stat _stat |
| 92 |
#define stricmp _stricmp |
| 93 |
#define strdup _strdup |
| 94 |
#define strlwr _strlwr |
| 95 |
#define strnicmp _strnicmp |
| 96 |
#define tempnam _tempnam |
| 97 |
#define timeb _timeb |
| 98 |
#define timezone _timezone |
| 99 |
#define unlink _unlink |
| 100 |
#define umask _umask |
| 101 |
#define utime _utime |
| 102 |
#define write _write |
| 103 |
#endif /* !__cplusplus */ |
| 104 |
|
| 105 |
#define getwd(dir) GetCurrentDirectory(MAXPATHLEN, dir) |
| 106 |
|
| 107 |
#ifdef strcasecmp |
| 108 |
#undef strcasecmp |
| 109 |
#endif |
| 110 |
#ifdef strncasecmp |
| 111 |
#undef strncasecmp |
| 112 |
#endif |
| 113 |
#define strcasecmp _stricmp |
| 114 |
#define strncasecmp _strnicmp |
| 115 |
|
| 116 |
#ifndef S_IFMT |
| 117 |
#define S_IFMT _S_IFMT |
| 118 |
#endif |
| 119 |
#ifndef S_IFDIR |
| 120 |
#define S_IFDIR _S_IFDIR |
| 121 |
#endif |
| 122 |
#ifndef S_IFCHR |
| 123 |
#define S_IFCHR _S_IFCHR |
| 124 |
#endif |
| 125 |
#ifndef S_IFIFO |
| 126 |
#define S_IFIFO _S_IFIFO |
| 127 |
#endif |
| 128 |
#ifndef S_IFREG |
| 129 |
#define S_IFREG _S_IFREG |
| 130 |
#endif |
| 131 |
#ifndef S_IREAD |
| 132 |
#define S_IREAD _S_IREAD |
| 133 |
#endif |
| 134 |
#ifndef S_IWRITE |
| 135 |
#define S_IWRITE _S_IWRITE |
| 136 |
#endif |
| 137 |
#define S_IEXEC _S_IEXEC |
| 138 |
#ifndef S_IXUSR |
| 139 |
#define S_IXUSR _S_IEXEC |
| 140 |
#endif |
| 141 |
#ifndef S_IXGRP |
| 142 |
#define S_IXGRP _S_IEXEC |
| 143 |
#endif |
| 144 |
#ifndef S_IXOTH |
| 145 |
#define S_IXOTH _S_IEXEC |
| 146 |
#endif |
| 147 |
#ifndef S_IRUSR |
| 148 |
#define S_IRUSR _S_IREAD |
| 149 |
#endif |
| 150 |
#ifndef S_IWUSR |
| 151 |
#define S_IWUSR _S_IWRITE |
| 152 |
#endif |
| 153 |
#ifndef S_IROTH |
| 154 |
#define S_IROTH _S_IREAD |
| 155 |
#endif |
| 156 |
#ifndef S_IWOTH |
| 157 |
#define S_IWOTH _S_IWRITE |
| 158 |
#endif |
| 159 |
#ifndef S_IRGRP |
| 160 |
#define S_IRGRP _S_IREAD |
| 161 |
#endif |
| 162 |
#ifndef S_IWGRP |
| 163 |
#define S_IWGRP _S_IWRITE |
| 164 |
#endif |
| 165 |
#ifndef O_RDWR |
| 166 |
#define O_RDWR _O_RDWR |
| 167 |
#endif |
| 168 |
#ifndef O_CREAT |
| 169 |
#define O_CREAT _O_CREAT |
| 170 |
#endif |
| 171 |
#ifndef O_TRUNC |
| 172 |
#define O_TRUNC _O_TRUNC |
| 173 |
#endif |
| 174 |
#ifndef O_RDONLY |
| 175 |
#define O_RDONLY _O_RDONLY |
| 176 |
#endif |
| 177 |
#ifndef O_WRONLY |
| 178 |
#define O_WRONLY _O_WRONLY |
| 179 |
#endif |
| 180 |
#ifndef O_APPEND |
| 181 |
#define O_APPEND _O_APPEND |
| 182 |
#endif |
| 183 |
#ifndef O_TEXT |
| 184 |
#define O_TEXT _O_TEXT |
| 185 |
#endif |
| 186 |
#ifndef O_BINARY |
| 187 |
#define O_BINARY _O_BINARY |
| 188 |
#endif |
| 189 |
#ifndef O_EXCL |
| 190 |
#define O_EXCL _O_EXCL |
| 191 |
#endif |
| 192 |
|
| 193 |
#if defined (S_IFBLK) && !defined (S_ISBLK) |
| 194 |
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */ |
| 195 |
#endif |
| 196 |
|
| 197 |
#if defined (S_IFCHR) && !defined (S_ISCHR) |
| 198 |
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */ |
| 199 |
#endif |
| 200 |
|
| 201 |
#if defined (S_IFDIR) && !defined (S_ISDIR) |
| 202 |
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */ |
| 203 |
#endif |
| 204 |
|
| 205 |
#if defined (S_IFREG) && !defined (S_ISREG) |
| 206 |
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */ |
| 207 |
#endif |
| 208 |
|
| 209 |
#if defined (S_IFIFO) && !defined (S_ISFIFO) |
| 210 |
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */ |
| 211 |
#endif |
| 212 |
|
| 213 |
#if defined (S_IFLNK) && !defined (S_ISLNK) |
| 214 |
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */ |
| 215 |
#endif |
| 216 |
|
| 217 |
#if defined (S_IFSOCK) && !defined (S_ISSOCK) |
| 218 |
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */ |
| 219 |
#endif |
| 220 |
|
| 221 |
/* Define this so that winsock.h definitions don't get included when |
| 222 |
windows.h is... For this to have proper effect, config.h must |
| 223 |
always be included before windows.h. */ |
| 224 |
#if !defined(_WINSOCKAPI_) && !defined(WWW_WIN_DLL) |
| 225 |
#define _WINSOCKAPI_ 1 |
| 226 |
#endif |
| 227 |
|
| 228 |
#define boolean saved_boolean |
| 229 |
#include <windows.h> |
| 230 |
#undef boolean |
| 231 |
|
| 232 |
#include <kpathsea/types.h> |
| 233 |
|
| 234 |
/* Defines size_t and alloca (). */ |
| 235 |
#include <malloc.h> |
| 236 |
|
| 237 |
/* For proper declaration of environ. */ |
| 238 |
#include <stdlib.h> |
| 239 |
#include <io.h> |
| 240 |
#include <fcntl.h> |
| 241 |
#include <stdio.h> |
| 242 |
#include <process.h> |
| 243 |
|
| 244 |
/* For _getcwd. */ |
| 245 |
#include <direct.h> |
| 246 |
|
| 247 |
/* Web2C takes care of ensuring that these are defined. */ |
| 248 |
#ifdef max |
| 249 |
#undef max |
| 250 |
#undef min |
| 251 |
#endif |
| 252 |
|
| 253 |
#ifdef __cplusplus |
| 254 |
extern "C" { |
| 255 |
#endif |
| 256 |
|
| 257 |
extern KPSEDLL double win32_floor (double x); |
| 258 |
extern KPSEDLL FILE *win32_popen (const char *cmd, const char *mode); |
| 259 |
extern KPSEDLL int win32_pclose (FILE *f); |
| 260 |
extern KPSEDLL struct passwd *kpathsea_getpwnam (kpathsea kpse, char *name); |
| 261 |
extern KPSEDLL int win32_system(const char *cmd); |
| 262 |
extern KPSEDLL void kpathsea_init_user_info (kpathsea kpse); |
| 263 |
|
| 264 |
#if defined (KPSE_COMPAT_API) |
| 265 |
extern KPSEDLL struct passwd *getpwnam (char *name); |
| 266 |
#endif /* KPSE_COMPAT_API */ |
| 267 |
|
| 268 |
#define system(p) win32_system(p) |
| 269 |
#define popen(cmd, mode) win32_popen(cmd, mode) |
| 270 |
#define pclose(file) win32_pclose(file) |
| 271 |
/* Functions for WIN32 */ |
| 272 |
extern KPSEDLL FILE *popen(const char * str, const char * str2); |
| 273 |
extern KPSEDLL int pclose(FILE * f); |
| 274 |
extern KPSEDLL int system(const char * cmd); |
| 275 |
|
| 276 |
extern KPSEDLL void texlive_gs_init(void); |
| 277 |
extern KPSEDLL int kpathsea_getlongpath (kpathsea kpse, char *output, char *input, int len); |
| 278 |
extern KPSEDLL char *kpathsea_get_home_directory (kpathsea kpse); |
| 279 |
|
| 280 |
#if defined (KPSE_COMPAT_API) |
| 281 |
extern KPSEDLL int getlongpath (char *output, char *input, int len); |
| 282 |
extern KPSEDLL char *get_home_directory (void); |
| 283 |
#endif |
| 284 |
|
| 285 |
#define off_t __int64 |
| 286 |
#define xfseeko xfseek64 |
| 287 |
#define xftello xftell64 |
| 288 |
|
| 289 |
#ifdef __cplusplus |
| 290 |
} |
| 291 |
#endif |
| 292 |
|
| 293 |
#endif /* not KPATHSEA_WIN32LIB_H */ |