1 /* win32lib.h: bits and pieces for win32 and msvc. 2 3 Copyright 2006, 2010-2013 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 #define access _access 59 #define alloca _alloca 60 #define chdir _chdir 61 #define chmod _chmod 62 #define close _close 63 #define creat _creat 64 #define daylight _daylight 65 #define dup _dup 66 #define dup2 _dup2 67 #define execlp _execlp 68 #define execvp _execvp 69 #define fcloseall _fcloseall 70 #define fdopen _fdopen 71 #define fileno _fileno 72 #define flushall _flushall 73 #define fstat _fstat 74 #define ftime _ftime 75 #define getpid _getpid 76 #define getcwd _getcwd 77 #define getwd(dir) GetCurrentDirectory(MAXPATHLEN, dir) 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 88 #define putenv _putenv 89 #define read _read 90 #define rmdir _rmdir 91 #define setmode _setmode 92 #define spawnlp _spawnlp 93 #define stat _stat 94 #define stricmp _stricmp 95 #ifdef strcasecmp 96 #undef strcasecmp 97 #endif 98 #define strcasecmp _stricmp 99 #define strdup _strdup 100 #define strlwr _strlwr 101 #define strncasecmp _strnicmp 102 #define strnicmp _strnicmp 103 #define tempnam _tempnam 104 #define timeb _timeb 105 #define timezone _timezone 106 #define unlink _unlink 107 #define umask _umask 108 #define utime _utime 109 #define write _write 110 111 #ifndef S_IFMT 112 #define S_IFMT _S_IFMT 113 #endif 114 #ifndef S_IFDIR 115 #define S_IFDIR _S_IFDIR 116 #endif 117 #ifndef S_IFCHR 118 #define S_IFCHR _S_IFCHR 119 #endif 120 #ifndef S_IFIFO 121 #define S_IFIFO _S_IFIFO 122 #endif 123 #ifndef S_IFREG 124 #define S_IFREG _S_IFREG 125 #endif 126 #ifndef S_IREAD 127 #define S_IREAD _S_IREAD 128 #endif 129 #ifndef S_IWRITE 130 #define S_IWRITE _S_IWRITE 131 #endif 132 #define S_IEXEC _S_IEXEC 133 #ifndef S_IXUSR 134 #define S_IXUSR _S_IEXEC 135 #endif 136 #ifndef S_IXGRP 137 #define S_IXGRP _S_IEXEC 138 #endif 139 #ifndef S_IXOTH 140 #define S_IXOTH _S_IEXEC 141 #endif 142 #ifndef S_IRUSR 143 #define S_IRUSR _S_IREAD 144 #endif 145 #ifndef S_IWUSR 146 #define S_IWUSR _S_IWRITE 147 #endif 148 #ifndef S_IROTH 149 #define S_IROTH _S_IREAD 150 #endif 151 #ifndef S_IWOTH 152 #define S_IWOTH _S_IWRITE 153 #endif 154 #ifndef S_IRGRP 155 #define S_IRGRP _S_IREAD 156 #endif 157 #ifndef S_IWGRP 158 #define S_IWGRP _S_IWRITE 159 #endif 160 #ifndef O_RDWR 161 #define O_RDWR _O_RDWR 162 #endif 163 #ifndef O_CREAT 164 #define O_CREAT _O_CREAT 165 #endif 166 #ifndef O_TRUNC 167 #define O_TRUNC _O_TRUNC 168 #endif 169 #ifndef O_RDONLY 170 #define O_RDONLY _O_RDONLY 171 #endif 172 #ifndef O_WRONLY 173 #define O_WRONLY _O_WRONLY 174 #endif 175 #ifndef O_APPEND 176 #define O_APPEND _O_APPEND 177 #endif 178 #ifndef O_TEXT 179 #define O_TEXT _O_TEXT 180 #endif 181 #ifndef O_BINARY 182 #define O_BINARY _O_BINARY 183 #endif 184 #ifndef O_EXCL 185 #define O_EXCL _O_EXCL 186 #endif 187 188 #if defined (S_IFBLK) && !defined (S_ISBLK) 189 #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */ 190 #endif 191 192 #if defined (S_IFCHR) && !defined (S_ISCHR) 193 #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */ 194 #endif 195 196 #if defined (S_IFDIR) && !defined (S_ISDIR) 197 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */ 198 #endif 199 200 #if defined (S_IFREG) && !defined (S_ISREG) 201 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */ 202 #endif 203 204 #if defined (S_IFIFO) && !defined (S_ISFIFO) 205 #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */ 206 #endif 207 208 #if defined (S_IFLNK) && !defined (S_ISLNK) 209 #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */ 210 #endif 211 212 #if defined (S_IFSOCK) && !defined (S_ISSOCK) 213 #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */ 214 #endif 215 216 /* Define this so that winsock.h definitions don't get included when 217 windows.h is... For this to have proper effect, config.h must 218 always be included before windows.h. */ 219 #if !defined(_WINSOCKAPI_) && !defined(WWW_WIN_DLL) 220 #define _WINSOCKAPI_ 1 221 #endif 222 223 #define boolean saved_boolean 224 #include <windows.h> 225 #undef boolean 226 227 #include <kpathsea/types.h> 228 229 /* Defines size_t and alloca (). */ 230 #include <malloc.h> 231 232 /* For proper declaration of environ. */ 233 #include <stdlib.h> 234 #include <io.h> 235 #include <fcntl.h> 236 #include <stdio.h> 237 #include <process.h> 238 239 /* For _getcwd. */ 240 #include <direct.h> 241 242 /* Web2C takes care of ensuring that these are defined. */ 243 #ifdef max 244 #undef max 245 #undef min 246 #endif 247 248 #ifdef __cplusplus 249 extern "C" { 250 #endif 251 252 extern KPSEDLL FILE *win32_popen (const char *cmd, const char *mode); 253 extern KPSEDLL int win32_pclose (FILE *f); 254 extern KPSEDLL struct passwd *kpathsea_getpwnam (kpathsea kpse, char *name); 255 extern KPSEDLL int win32_system(const char *cmd); 256 extern KPSEDLL void kpathsea_init_user_info (kpathsea kpse); 257 258 #if defined (KPSE_COMPAT_API) 259 extern KPSEDLL struct passwd *getpwnam (char *name); 260 #endif /* KPSE_COMPAT_API */ 261 262 #define system(p) win32_system(p) 263 #define popen(cmd, mode) win32_popen(cmd, mode) 264 #define pclose(file) win32_pclose(file) 265 /* Functions for WIN32 */ 266 extern KPSEDLL FILE *popen(const char * str, const char * str2); 267 extern KPSEDLL int pclose(FILE * f); 268 extern KPSEDLL int system(const char * cmd); 269 270 extern KPSEDLL void texlive_gs_init(void); 271 extern KPSEDLL int getlongpath (char *output, char *input, int len); 272 extern KPSEDLL char *get_home_directory (void); 273 274 #define off_t __int64 275 #define xfseeko xfseek64 276 #define xftello xftell64 277 278 #ifdef __cplusplus 279 } 280 #endif 281 282 #endif /* not KPATHSEA_WIN32LIB_H */ 283