| 1 |
/* config.h: master configuration file, included first by all compilable |
| 2 |
source files (not headers). |
| 3 |
|
| 4 |
Copyright 1993, 1995, 1996, 1997, 2008, 2010, 2011, 2016 Karl Berry. |
| 5 |
Copyright 2000, 2003, 2004, 2005 Olaf Weber. |
| 6 |
|
| 7 |
This library is free software; you can redistribute it and/or |
| 8 |
modify it under the terms of the GNU Lesser General Public |
| 9 |
License as published by the Free Software Foundation; either |
| 10 |
version 2.1 of the License, or (at your option) any later version. |
| 11 |
|
| 12 |
This library is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
Lesser General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU Lesser General Public License |
| 18 |
along with this library; if not, see <http://www.gnu.org/licenses/>. */ |
| 19 |
|
| 20 |
#ifndef KPATHSEA_CONFIG_H |
| 21 |
#define KPATHSEA_CONFIG_H |
| 22 |
|
| 23 |
/* System defines are for non-Unix systems only. (Testing for all Unix |
| 24 |
variations should be done in configure.) Presently the defines used |
| 25 |
are: AMIGA DOS OS2 WIN32. I do not use any of these systems myself; |
| 26 |
if you do, I'd be grateful for any changes. */ |
| 27 |
|
| 28 |
#if defined(DJGPP) || defined(__DJGPP__) || \ |
| 29 |
defined(CYGWIN) || defined(__CYGWIN__) || \ |
| 30 |
defined(CYGWIN32) || defined(__CYGWIN32__) || \ |
| 31 |
defined(MINGW32) || defined(__MINGW32__) |
| 32 |
#define __i386_pc_gnu__ |
| 33 |
#endif |
| 34 |
|
| 35 |
/* If we have either DOS or OS2, we are DOSISH. Cygwin pretends to be |
| 36 |
Unix, mostly, so don't include it here. */ |
| 37 |
#if defined(OS2) || \ |
| 38 |
defined(MSDOS) || defined(__MSDOS__) || defined(DOS) || \ |
| 39 |
defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || \ |
| 40 |
defined(DJGPP) || defined(__DJGPP__) || \ |
| 41 |
defined(MINGW32) || defined(__MINGW32__) |
| 42 |
#define DOSISH |
| 43 |
#endif |
| 44 |
|
| 45 |
/* case-insensitive filename comparisons? */ |
| 46 |
#if defined (DOSISH) |
| 47 |
#define MONOCASE_FILENAMES |
| 48 |
#endif |
| 49 |
|
| 50 |
/* NULL device. */ |
| 51 |
#if defined (DOSISH) |
| 52 |
#define DEV_NULL "NUL" |
| 53 |
#else |
| 54 |
#define DEV_NULL "/dev/null" |
| 55 |
#endif |
| 56 |
|
| 57 |
#if defined (WIN32) && !defined (__STDC__) |
| 58 |
#define __STDC__ 1 |
| 59 |
#endif |
| 60 |
|
| 61 |
/* System dependencies that are figured out by `configure'. */ |
| 62 |
#include <kpathsea/c-auto.h> |
| 63 |
|
| 64 |
#ifdef __DJGPP__ |
| 65 |
#include <fcntl.h> /* for long filenames' stuff */ |
| 66 |
#include <dir.h> /* for `getdisk' */ |
| 67 |
#include <io.h> /* for `setmode' */ |
| 68 |
#endif |
| 69 |
|
| 70 |
/* Some drivers have partially integrated kpathsea changes. */ |
| 71 |
#ifndef KPATHSEA |
| 72 |
#define KPATHSEA 34 |
| 73 |
#endif |
| 74 |
|
| 75 |
#ifdef __MINGW32__ |
| 76 |
/* In mingw32, the eof() function is part of the !_NO_OLDNAMES section |
| 77 |
of <io.h>, that is read in automatically via <unistd.h>. We cannot |
| 78 |
allow that because web2c/lib/eofeoln.c defines a private, |
| 79 |
incompatible function named eof(). |
| 80 |
But many of the other things defined via !_NO_OLDNAMES are needed, |
| 81 |
so #define _NO_OLDNAMES cannot be used. So, temporarily define eof |
| 82 |
as a macro. |
| 83 |
*/ |
| 84 |
#define eof saved_eof |
| 85 |
#include <kpathsea/c-std.h> /* <stdio.h>, <math.h>, etc. */ |
| 86 |
#undef eof |
| 87 |
#else |
| 88 |
#include <kpathsea/c-std.h> /* <stdio.h>, <math.h>, etc. */ |
| 89 |
#endif |
| 90 |
|
| 91 |
#include <kpathsea/c-proto.h> /* KPSEDLL. */ |
| 92 |
|
| 93 |
/* |
| 94 |
This must be included after "c-proto.h" |
| 95 |
but before "lib.h". FP. |
| 96 |
*/ |
| 97 |
#if defined (WIN32) || defined (_WIN32) |
| 98 |
#ifdef __MINGW32__ |
| 99 |
#include <kpathsea/mingw32.h> |
| 100 |
#else |
| 101 |
#include <kpathsea/win32lib.h> |
| 102 |
#endif |
| 103 |
#include <kpathsea/types.h> |
| 104 |
#include <kpathsea/knj.h> |
| 105 |
#endif |
| 106 |
|
| 107 |
#if defined(WIN32) || defined(WRAP_SNPRINTF) |
| 108 |
/* All Unix systems known to us have snprintf() and vsnprintf(), |
| 109 |
while all known Windows systems have _snprintf() and _vsnprintf(). |
| 110 |
|
| 111 |
Consider a call |
| 112 |
RET = snprintf(BUF, SIZE, FMT, ...) |
| 113 |
and let LEN be the number that would be written to BUF if SIZE were |
| 114 |
sufficiently large (not counting the trailing null byte). |
| 115 |
|
| 116 |
C99 requires that snprintf |
| 117 |
(A) modifies at most the first SIZE bytes of BUF, |
| 118 |
(B) writes a trailing null byte except when SIZE=0, and |
| 119 |
(C) always returns LEN. |
| 120 |
|
| 121 |
All known implementations (except some ancient buggy ones, e.g., for |
| 122 |
64-bit Solaris 7 from Oct. 1998) satisfy (A). As long as LEN<SIZE |
| 123 |
they all write a trailing null byte and return LEN. |
| 124 |
|
| 125 |
Condition (C) is, however, violated for LEN>=SIZE by some older |
| 126 |
implementations (SUSv2, glibc <= 2.0.6, etc.) and for Windows even |
| 127 |
(B) is violated.. |
| 128 |
|
| 129 |
TeX Live does not require the full C99 semantics, but will need that |
| 130 |
(1) there is always a trailing null byte, and |
| 131 |
(2) for LEN>=SIZE the return value is either >=SIZE or <0, i.e., |
| 132 |
(unsigned)RET >= (unsigned)SIZE. |
| 133 |
|
| 134 |
A violation of (2) is detected by configure (except when cross |
| 135 |
compiling) and by a runtime check in the initialization routine |
| 136 |
kpathsea_set_program_name. |
| 137 |
|
| 138 |
A violation of (1) is handled here through static inline wrapper |
| 139 |
functions. */ |
| 140 |
|
| 141 |
|
| 142 |
#undef snprintf |
| 143 |
#undef vsnprintf |
| 144 |
|
| 145 |
#ifdef __cplusplus |
| 146 |
extern "C" { |
| 147 |
#endif |
| 148 |
|
| 149 |
static inline int |
| 150 |
kpse_vsnprintf (char *str, size_t size, const char *format, va_list ap) |
| 151 |
{ |
| 152 |
#ifdef WIN32 |
| 153 |
int ret = _vsnprintf (str, size, format, ap); |
| 154 |
#else |
| 155 |
int ret = vsnprintf (str, size, format, ap); |
| 156 |
#endif |
| 157 |
if (size > 0 && (unsigned)ret >= (unsigned)size) |
| 158 |
str [size - 1] = '\0'; |
| 159 |
return ret; |
| 160 |
} |
| 161 |
|
| 162 |
static inline int |
| 163 |
kpse_snprintf (char *str, size_t size, const char *format, ...) |
| 164 |
{ |
| 165 |
int ret; |
| 166 |
va_list ap; |
| 167 |
|
| 168 |
va_start (ap, format); |
| 169 |
ret = kpse_vsnprintf (str, size, format, ap); |
| 170 |
va_end (ap); |
| 171 |
return ret; |
| 172 |
} |
| 173 |
|
| 174 |
#ifdef __cplusplus |
| 175 |
} |
| 176 |
#endif |
| 177 |
|
| 178 |
#define snprintf kpse_snprintf |
| 179 |
#define vsnprintf kpse_vsnprintf |
| 180 |
|
| 181 |
#endif /* WIN32 || WRAP_SNPRINTF */ |
| 182 |
|
| 183 |
/* Transform filename characters for use in hash tables. */ |
| 184 |
#if defined(MONOCASE_FILENAMES) |
| 185 |
#if defined(WIN32) && !defined(__i386_pc_gnu__) |
| 186 |
/* This is way faster under Win32. */ |
| 187 |
#define TRANSFORM(x) ((unsigned)CharLower((LPTSTR)(BYTE)(x))) |
| 188 |
#else |
| 189 |
#define TRANSFORM(x) (tolower(x)) |
| 190 |
#endif |
| 191 |
#else |
| 192 |
#define TRANSFORM(x) (x) |
| 193 |
#endif |
| 194 |
|
| 195 |
#include <kpathsea/debug.h> /* Runtime tracing. */ |
| 196 |
#include <kpathsea/lib.h> /* STREQ, etc. */ |
| 197 |
#include <kpathsea/types.h> /* <sys/types.h>, boolean, string, etc. */ |
| 198 |
#include <kpathsea/progname.h> /* for kpse_invocation_*name */ |
| 199 |
|
| 200 |
|
| 201 |
/* If you want to find subdirectories in a directory with non-Unix |
| 202 |
semantics (specifically, if a directory with no subdirectories does |
| 203 |
not have exactly two links), define this. */ |
| 204 |
#if !defined (VMS) && !defined (VMCMS) |
| 205 |
#if !defined (DOSISH) || defined(__DJGPP__) |
| 206 |
/* Surprise! DJGPP returns st_nlink exactly like on Unix. */ |
| 207 |
#define ST_NLINK_TRICK |
| 208 |
#endif /* either not DOSISH or __DJGPP__ */ |
| 209 |
#endif /* not DOS and not VMS and not VMCMS */ |
| 210 |
|
| 211 |
#ifdef AMIGA |
| 212 |
/* No popen/pclose on Amiga, but rather than put #ifdef's in tex-make.c, |
| 213 |
let's get rid of the functions here. (CallMF will automatically |
| 214 |
generate fonts.) pclose must not be simply empty, since it still |
| 215 |
occurs in a comparison. */ |
| 216 |
#define popen(cmd, mode) NULL |
| 217 |
#define pclose(file) 0 |
| 218 |
#endif /* AMIGA */ |
| 219 |
|
| 220 |
#ifdef OS2 |
| 221 |
#define access ln_access |
| 222 |
#define chmod ln_chmod |
| 223 |
#define creat ln_creat |
| 224 |
#define fopen ln_fopen |
| 225 |
#define freopen ln_freopen |
| 226 |
#define lstat ln_lstat |
| 227 |
#define open ln_open |
| 228 |
#define remove ln_remove |
| 229 |
#define rename ln_rename |
| 230 |
#define sopen ln_sopen |
| 231 |
#define stat ln_stat |
| 232 |
#define unlink ln_unlink |
| 233 |
#endif /* OS2 */ |
| 234 |
|
| 235 |
#endif /* not KPATHSEA_CONFIG_H */ |