00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifdef WIN32
00014 #define MSDOS
00015 #endif
00016 #ifdef __POWERC
00017 # define __TURBOC__
00018 # define MSDOS
00019 #endif
00020
00021 #if (defined(__MSDOS__) && !defined(MSDOS))
00022 # define MSDOS
00023 #endif
00024
00025 #ifdef ATARI_ST
00026 # undef MSDOS
00027 #endif
00028
00029
00030
00031
00032 #if defined(__STDC__) || defined(MSDOS) || defined(ATARI_ST) || defined(sgi)
00033 # ifndef PROTO
00034 # define PROTO
00035 # endif
00036 # define MODERN
00037 #endif
00038
00039 #if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__) || defined(__MWERKS__)
00040 # ifndef PROTO
00041 # define PROTO
00042 # endif
00043 # define MODERN
00044 #endif
00045
00046 #if defined(__BORLANDC__) || (defined(__alpha) && defined(VMS))
00047 # ifndef PROTO
00048 # define PROTO
00049 # endif
00050 # define MODERN
00051 #endif
00052
00053 #if defined(__EMX__) || defined(__WATCOMC__) || defined(__BORLANDC__)
00054 # if (defined(OS2) && !defined(__32BIT__))
00055 # define __32BIT__
00056 # endif
00057 #endif
00058
00059 #if (defined(__OS2__) && !defined(OS2))
00060 # define OS2
00061 #endif
00062
00063 #ifdef __convexc__
00064 # define CONVEX
00065 #endif
00066
00067 #ifdef __COMPILER_KCC__
00068 # define TOPS20
00069 # define NOPROTO
00070 # define NO_SYMLINK
00071 # define NO_TERMIO
00072 # define DIRENT
00073 # define BIG_MEM
00074 extern int isatty();
00075 # define R__window_size winsiz
00076 #endif
00077
00078
00079 #if (defined(NOPROTO) && defined(PROTO))
00080 # undef PROTO
00081 #endif
00082
00083
00084 #ifdef PROTO
00085 # define OF(a) a
00086 #else
00087 # define OF(a) ()
00088 #endif
00089
00090
00091 #ifndef MODERN
00092 # define const
00093 #endif
00094
00095 #if defined(MACOS) || defined(__MWERKS__)
00096 # define DYN_ALLOC
00097 #endif
00098 #if (defined(MSDOS) && !defined(__GO32__) && !defined(WIN32))
00099 # ifdef __TURBOC__
00100 # include <alloc.h>
00101 # define DYN_ALLOC
00102
00103 void far * fcalloc OF((unsigned items, unsigned size));
00104 void fcfree (void *ptr);
00105 # else
00106 # include <malloc.h>
00107 # define farmalloc _fmalloc
00108 # define farfree _ffree
00109 # define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
00110 # define fcfree(ptr) hfree((void huge *)(ptr))
00111 # endif
00112 #else
00113 # if defined(WIN32)
00114 # include <malloc.h>
00115 # endif
00116 # ifdef __WATCOMC__
00117 # undef huge
00118 # undef far
00119 # undef near
00120 # else
00121 # define huge
00122 # define far
00123 # define near
00124 # endif
00125 # define farmalloc malloc
00126 # define farfree free
00127 # define fcalloc(items,size) calloc((unsigned)(items), (unsigned)(size))
00128 # define fcfree free
00129 # if (!defined(PROTO) && !defined(TOPS20))
00130 extern char *calloc();
00131 # endif
00132 #endif
00133
00134
00135 #if (defined(OS2) && !defined(MSDOS))
00136
00137
00138 # define MSDOS
00139
00140 #endif
00141
00142
00143
00144 #if defined(MSDOS) || defined(VMS)
00145 # define MSVMS
00146 #endif
00147
00148
00149
00150
00151
00152
00153 #if defined(MSDOS) || defined(VMS) || defined(OS2) || defined(WIN32)
00154 # define case_map(c) upper[(c) & 0xff]
00155 # define to_up(c) upper[(c) & 0xff]
00156 #else
00157 # define case_map(c) (c)
00158 # define to_up(c) ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
00159 #endif
00160
00161
00162 #include <stdio.h>
00163 #include <string.h>
00164 #ifdef MODERN
00165 # if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
00166 # include <stddef.h>
00167 # endif
00168 # include <stdlib.h>
00169 # if defined(SYSV) || defined(__386BSD__)
00170 # include <unistd.h>
00171 # endif
00172 typedef size_t extent;
00173 typedef void voidp;
00174 #else
00175 typedef unsigned int extent;
00176 # define void int
00177 typedef char voidp;
00178 #endif
00179
00180
00181 #ifdef VMS
00182 # include <types.h>
00183 # include <stat.h>
00184 # define unlink delete
00185 # define NO_SYMLINK
00186 # define SSTAT vms_stat
00187 #else
00188 # if defined(MACOS)
00189 # include <types.h>
00190 # include <stddef.h>
00191 # include <Files.h>
00192 # include <StandardFile.h>
00193 # include <Think.h>
00194 # include <LoMem.h>
00195 # include <Pascal.h>
00196 # include "macstat.h"
00197 # define NO_SYMLINK
00198 # elif defined (__MWERKS__)
00199 # include <stddef.h>
00200 # include <stat.h>
00201 # define NO_SYMLINK
00202 # else
00203 # ifdef ATARI_ST
00204 # include <ext.h>
00205 # include <tos.h>
00206 # else
00207 # ifdef AMIGA
00208 int wild OF((char *));
00209
00210 # if ( (!defined(BIG_MEM)) && (!defined(SMALL_MEM)))
00211 # define MEDIUM_MEM
00212 # endif
00213 # if defined(LATTICE) || defined(__SASC)
00214 # include <sys/types.h>
00215 # include <sys/stat.h>
00216 extern int isatty(int);
00217 # endif
00218 # ifdef AZTEC_C
00219 # include "amiga/z-stat.h"
00220 # define RMDIR
00221 # endif
00222 # else
00223 # include <sys/types.h>
00224 # include <sys/stat.h>
00225 # endif
00226 # endif
00227 # endif
00228 #endif
00229
00230
00231 #if defined (S_IFLNK) && defined(NO_SYMLINK)
00232 # undef S_IFLNK
00233 #endif
00234
00235
00236
00237 #ifdef pyr
00238 # define strrchr rindex
00239 # define ZMEM
00240 #endif
00241
00242
00243
00244 #ifdef VMS
00245 # define FOPR "r","ctx=stm"
00246 # define FOPM "r+","ctx=stm","rfm=fix","mrs=512"
00247 # define FOPW "w","ctx=stm","rfm=fix","mrs=512"
00248 #else
00249 # if defined(MODERN)
00250 # define FOPR "rb"
00251 # define FOPM "r+b"
00252 # ifdef TOPS20
00253 # define FOPW "w8"
00254 # else
00255 # define FOPW "wb"
00256 # endif
00257 # else
00258 # ifdef AMIGA
00259 # define FOPR "rb"
00260 # define FOPM "rb+"
00261 # define FOPW "wb"
00262 # else
00263 # define FOPR "r"
00264 # define FOPM "r+"
00265 # define FOPW "w"
00266 # endif
00267 # endif
00268 #endif
00269
00270
00271
00272
00273 #ifdef OS2
00274 # define FOPR_EX FOPM
00275 #else
00276 # define FOPR_EX FOPR
00277 #endif
00278
00279
00280
00281
00282
00283 #if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
00284 # define UNALIGNED_OK
00285 #endif
00286 #if defined(mc68020) || defined(vax)
00287 # define UNALIGNED_OK
00288 #endif
00289
00290
00291
00292
00293
00294 #ifdef SMALL_MEM
00295 # define CBSZ 2048
00296 # define ZBSZ 2048
00297 #else
00298 # ifdef MEDIUM_MEM
00299 # define CBSZ 8192
00300 # define ZBSZ 8192
00301 # else
00302 # ifdef OS2
00303 # ifdef __32BIT__
00304 # define CBSZ 0x40000
00305 # define ZBSZ 0x40000
00306 # else
00307 # define CBSZ 0xE000
00308 # define ZBSZ 0x7F00
00309 # endif
00310 # else
00311 # ifdef TOPS20
00312 # define CBSZ 524288
00313 # define ZBSZ 524288
00314 # else
00315 # define CBSZ 16384
00316 # define ZBSZ 16384
00317 # endif
00318 # endif
00319 # endif
00320 #endif
00321
00322 #if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
00323 # define DYN_ALLOC
00324 #endif
00325
00326 #ifdef __human68k__
00327 # include <sys/xglob.h>
00328 # define MSVMS
00329 # define SSTAT h68_stat
00330 int h68_stat OF((char *, struct stat *));
00331 # define OS_CODE 0x300
00332 #endif
00333
00334 #ifdef ATARI_ST
00335 # define MSDOS
00336 # define MSVMS
00337 # ifndef O_BINARY
00338 # define O_BINARY 0
00339 # endif
00340 # ifndef S_IFMT
00341 # define S_IFMT (S_IFCHR|S_IFREG|S_IFDIR)
00342 # endif
00343
00344 #ifdef __IBMC__
00345 # ifndef S_IFMT
00346 # define S_IFMT 0xF000
00347 # endif
00348 #endif
00349
00350
00351
00352
00353 # define unlink st_unlink
00354 # define chmod st_chmod
00355 # define mktemp st_mktemp
00356 # define fopen st_fopen
00357 # define open st_open
00358 # define SSTAT st_stat
00359 # define findfirst st_findfirst
00360 # define link st_rename
00361 # define rmdir st_rmdir
00362
00363 int st_unlink OF((char *));
00364 int st_chmod OF((char *, int));
00365 char *st_mktemp OF((char *));
00366 FILE *st_fopen OF((char *, char *));
00367 int st_open OF((char *, int));
00368 int st_stat OF((char *, struct stat *));
00369 int st_findfirst OF((char *, struct ffblk *, int));
00370 int st_rename OF((char *, char *));
00371 int st_rmdir OF((char *));
00372 #endif
00373
00374 #ifndef SSTAT
00375 # define SSTAT stat
00376 #endif
00377 #ifdef S_IFLNK
00378 # define LSTAT lstat
00379 #else
00380 # define LSTAT SSTAT
00381 #endif
00382
00383
00384
00385 #ifdef AMIGA
00386 # define OS_CODE 0x100
00387 #endif
00388 #ifdef VMS
00389 # define OS_CODE 0x200
00390 #endif
00391
00392
00393 #ifdef ATARI_ST
00394 # define OS_CODE 0x500
00395 #endif
00396 #ifdef OS2
00397 # define OS_CODE 0x600
00398 #endif
00399 #if defined(MACOS) || defined(__MWERKS__)
00400 # define OS_CODE 0x700
00401 #endif
00402
00403
00404 #ifdef TOPS20
00405 # define OS_CODE 0xa00
00406 #endif
00407 #ifdef WIN32
00408 # define OS_CODE 0xb00
00409 #endif
00410
00411
00412 #if defined(MSDOS) && !defined(OS_CODE)
00413 # define OS_CODE 0x000
00414 #endif
00415 #ifndef OS_CODE
00416 # define OS_CODE 0x300
00417 # ifndef R__UNIX
00418 # define R__UNIX
00419 # endif
00420 #endif
00421
00422
00423
00424