Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Tailor.h

Go to the documentation of this file.
00001 /* @(#)root/zip:$Name:  $:$Id: Tailor.h,v 1.1.1.1 2000/05/16 17:00:47 rdm Exp $ */
00002 
00003 /*************************************************************************
00004  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 /* tailor.h -- Not copyrighted 1993 Mark Adler */
00011 
00012 /* Define MSDOS for Turbo C and Power C */
00013 #ifdef WIN32
00014 #define MSDOS
00015 #endif
00016 #ifdef __POWERC
00017 #  define __TURBOC__
00018 #  define MSDOS
00019 #endif /* __POWERC */
00020 
00021 #if (defined(__MSDOS__) && !defined(MSDOS))
00022 #  define MSDOS
00023 #endif
00024 
00025 #ifdef ATARI_ST
00026 #  undef MSDOS   /* avoid the MS-DOS specific includes */
00027 #endif
00028 
00029 /* Use prototypes and ANSI libraries if _STDC__, or Microsoft or Borland C,
00030  * or Silicon Graphics, or IBM C Set/2, or Watcom C, or GNU gcc under emx.
00031  */
00032 #if defined(__STDC__) || defined(MSDOS) || defined(ATARI_ST) || defined(sgi)
00033 #  ifndef PROTO
00034 #    define PROTO
00035 #  endif /* !PROTO */
00036 #  define MODERN
00037 #endif
00038 
00039 #if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__) || defined(__MWERKS__)
00040 #  ifndef PROTO
00041 #    define PROTO
00042 #  endif /* !PROTO */
00043 #  define MODERN
00044 #endif
00045 
00046 #if defined(__BORLANDC__) || (defined(__alpha) && defined(VMS))
00047 #  ifndef PROTO
00048 #    define PROTO
00049 #  endif /* !PROTO */
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 /* __convexc__ */
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 /* Turn off prototypes if requested */
00079 #if (defined(NOPROTO) && defined(PROTO))
00080 #  undef PROTO
00081 #endif
00082 
00083 /* Used to remove arguments in function prototypes for non-ANSI C */
00084 #ifdef PROTO
00085 #  define OF(a) a
00086 #else /* !PROTO */
00087 #  define OF(a) ()
00088 #endif /* ?PROTO */
00089 
00090 /* Avoid using const if compiler does not support it */
00091 #ifndef MODERN  /* if this fails, try: ifndef__STDC__ */
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      /* Turbo C 2.0 does not accept static allocations of large arrays */
00103      void far * fcalloc OF((unsigned items, unsigned size));
00104      void fcfree (void *ptr);
00105 #  else /* !__TURBOC__ */
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 /* ?__TURBOC__ */
00112 #else /* !MSDOS */
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(); /* essential for 16 bit systems (AT&T 6300) */
00131 #  endif
00132 #endif /* ?MSDOS */
00133 
00134 
00135 #if (defined(OS2) && !defined(MSDOS))
00136 /* MSDOS is defined anyway with MS C 16-bit. So the block above works.
00137  * For the 32-bit compilers, MSDOS must not be defined in the block above. */
00138 #  define MSDOS
00139 /* inherit MS-DOS file system etc. stuff */
00140 #endif
00141 
00142 
00143 /* Define MSVMS if MSDOS or VMS defined -- ATARI also does, Amiga could */
00144 #if defined(MSDOS) || defined(VMS)
00145 #  define MSVMS
00146 #endif
00147 
00148 /* case mapping functions. case_map is used to ignore case in comparisons,
00149  * to_up is used to force upper case even on Unix (for dosify option).
00150  */
00151  /* || defined(AMIGA) is removed from the next line because the line
00152     is too long for PATCHY */
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 /* Define void, voidp, and extent (size_t) */
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 /* !M_XENIX */
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 /* !MODERN */
00175    typedef unsigned int extent;
00176 #  define void int
00177    typedef char voidp;
00178 #endif /* ?MODERN */
00179 
00180 /* Get types and stat */
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 /* !VMS */
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          /* default to MEDIUM_MEM, but allow makefile override */
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);   /* SAS has no unistd.h */
00217 #      endif
00218 #        ifdef AZTEC_C
00219 #          include "amiga/z-stat.h"
00220 #          define RMDIR
00221 #        endif
00222 #      else /* !AMIGA */
00223 #        include <sys/types.h>
00224 #      include <sys/stat.h>
00225 #    endif
00226 #  endif
00227 #  endif
00228 #endif /* ?VMS */
00229 
00230 /* Some systems define S_IFLNK but do not support symbolic links */
00231 #if defined (S_IFLNK) && defined(NO_SYMLINK)
00232 #  undef S_IFLNK
00233 #endif
00234 
00235 
00236 /* For Pyramid */
00237 #ifdef pyr
00238 #  define strrchr rindex
00239 #  define ZMEM
00240 #endif /* pyr */
00241 
00242 
00243 /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
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 /* !VMS */
00249 #  if defined(MODERN)
00250 #    define FOPR "rb"
00251 #    define FOPM "r+b"
00252 #    ifdef TOPS20 /* TOPS20 MODERN? You kidding? */
00253 #      define FOPW "w8"
00254 #    else
00255 #      define FOPW "wb"
00256 #    endif
00257 #  else /* !MODERN */
00258 #    ifdef AMIGA
00259 #      define FOPR "rb"
00260 #      define FOPM "rb+"
00261 #      define FOPW "wb"
00262 #    else /* !AMIGA */
00263 #    define FOPR "r"
00264 #    define FOPM "r+"
00265 #    define FOPW "w"
00266 #    endif /* ?AMIGA */
00267 #  endif /* ?MODERN */
00268 #endif /* VMS */
00269 
00270 /* Open the old zip file in exclusive mode if possible (to avoid adding
00271  * zip file to itself).
00272  */
00273 #ifdef OS2
00274 #  define FOPR_EX FOPM
00275 #else
00276 #  define FOPR_EX FOPR
00277 #endif
00278 
00279 /* Define this symbol if your target allows access to unaligned data.
00280  * This is not mandatory, just a speed optimization. The compressed
00281  * output is strictly identical.
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 /* Under MSDOS we may run out of memory when processing a large number
00291  * of files. Compile with MEDIUM_MEM to reduce the memory requirements or
00292  * with SMALL_MEM to use as little memory as possible.
00293  */
00294 #ifdef SMALL_MEM
00295 #   define CBSZ 2048 /* buffer size for copying files */
00296 #   define ZBSZ 2048 /* buffer size for temporary zip file */
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 /* Some libraries do not allow a buffer size > 32K */
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  /* pretend it's Unix */
00332 #endif
00333 
00334 #ifdef ATARI_ST
00335 #  define MSDOS  /* what? should be fixed */
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 /* __IBMC__ */
00349 
00350 /* a whole bunch of functions needs Tos '\\' filenames
00351  * instead of '/',  the translation functions are in fileio.c:
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  /* ATARI */
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 /* The following OS codes are defined in pkzip appnote.txt */
00385 #ifdef AMIGA
00386 #  define OS_CODE  0x100
00387 #endif
00388 #ifdef VMS
00389 #  define OS_CODE  0x200
00390 #endif
00391 /* unix    3 */
00392 /* vms/cms 4 */
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 /* z system 8 */
00403 /* cp/m     9 */
00404 #ifdef TOPS20
00405 #  define OS_CODE  0xa00
00406 #endif
00407 #ifdef WIN32
00408 #  define OS_CODE  0xb00
00409 #endif
00410 /* qdos 12 */
00411 
00412 #if defined(MSDOS) && !defined(OS_CODE)
00413 #  define OS_CODE  0x000
00414 #endif
00415 #ifndef OS_CODE
00416 #  define OS_CODE  0x300  /* assume Unix */
00417 #  ifndef R__UNIX
00418 #    define R__UNIX
00419 #  endif
00420 #endif
00421 
00422 
00423 /* end of tailor.h */
00424 

Generated on Thu Dec 18 14:52:16 2003 for ROOT by doxygen1.2.16