Tailor.h

Go to the documentation of this file.
00001 /* @(#)root/zip:$Id: Tailor.h 20882 2007-11-19 11:31:26Z rdm $ */
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 /* This definition of voidp is in conflict with the zlib one (zconf.h)
00174    voidp is used only in zlib code.
00175    typedef void voidp;
00176 */
00177 #else /* !MODERN */
00178    typedef unsigned int extent;
00179 #  define void int
00180 /* This definition of voidp is in conflict with the zlib one (zconf.h)
00181    voidp is used only in zlib code.
00182    typedef char voidp;
00183 */
00184 #endif /* ?MODERN */
00185 
00186 /* Get types and stat */
00187 #ifdef VMS
00188 #  include <types.h>
00189 #  include <stat.h>
00190 #  define unlink delete
00191 #  define NO_SYMLINK
00192 #  define SSTAT vms_stat
00193 #else /* !VMS */
00194 #  if defined(MACOS)
00195 #    include <types.h>
00196 #    include <stddef.h>
00197 #    include <Files.h>
00198 #    include <StandardFile.h>
00199 #    include <Think.h>
00200 #    include <LoMem.h>
00201 #    include <Pascal.h>
00202 #    include "macstat.h"
00203 #    define NO_SYMLINK
00204 #  elif defined (__MWERKS__)
00205 #    include <stddef.h>
00206 #    include <stat.h>
00207 #    define NO_SYMLINK
00208 #  else
00209 #    ifdef ATARI_ST
00210 #      include <ext.h>
00211 #      include <tos.h>
00212 #    else
00213 #      ifdef AMIGA
00214          int wild OF((char *));
00215          /* default to MEDIUM_MEM, but allow makefile override */
00216 #        if ( (!defined(BIG_MEM)) && (!defined(SMALL_MEM)))
00217 #           define MEDIUM_MEM
00218 #        endif
00219 #        if defined(LATTICE) || defined(__SASC)
00220 #        include <sys/types.h>
00221 #          include <sys/stat.h>
00222            extern int isatty(int);   /* SAS has no unistd.h */
00223 #      endif
00224 #        ifdef AZTEC_C
00225 #          include "amiga/z-stat.h"
00226 #          define RMDIR
00227 #        endif
00228 #      else /* !AMIGA */
00229 #        include <sys/types.h>
00230 #      include <sys/stat.h>
00231 #    endif
00232 #  endif
00233 #  endif
00234 #endif /* ?VMS */
00235 
00236 /* Some systems define S_IFLNK but do not support symbolic links */
00237 #if defined (S_IFLNK) && defined(NO_SYMLINK)
00238 #  undef S_IFLNK
00239 #endif
00240 
00241 
00242 /* For Pyramid */
00243 #ifdef pyr
00244 #  define strrchr rindex
00245 #  define ZMEM
00246 #endif /* pyr */
00247 
00248 
00249 /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
00250 #ifdef VMS
00251 #  define FOPR  "r","ctx=stm"
00252 #  define FOPM  "r+","ctx=stm","rfm=fix","mrs=512"
00253 #  define FOPW  "w","ctx=stm","rfm=fix","mrs=512"
00254 #else /* !VMS */
00255 #  if defined(MODERN)
00256 #    define FOPR "rb"
00257 #    define FOPM "r+b"
00258 #    ifdef TOPS20 /* TOPS20 MODERN? You kidding? */
00259 #      define FOPW "w8"
00260 #    else
00261 #      define FOPW "wb"
00262 #    endif
00263 #  else /* !MODERN */
00264 #    ifdef AMIGA
00265 #      define FOPR "rb"
00266 #      define FOPM "rb+"
00267 #      define FOPW "wb"
00268 #    else /* !AMIGA */
00269 #    define FOPR "r"
00270 #    define FOPM "r+"
00271 #    define FOPW "w"
00272 #    endif /* ?AMIGA */
00273 #  endif /* ?MODERN */
00274 #endif /* VMS */
00275 
00276 /* Open the old zip file in exclusive mode if possible (to avoid adding
00277  * zip file to itself).
00278  */
00279 #ifdef OS2
00280 #  define FOPR_EX FOPM
00281 #else
00282 #  define FOPR_EX FOPR
00283 #endif
00284 
00285 /* Define this symbol if your target allows access to unaligned data.
00286  * This is not mandatory, just a speed optimization. The compressed
00287  * output is strictly identical.
00288  */
00289 #if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
00290 #    define UNALIGNED_OK
00291 #endif
00292 #if defined(mc68020) || defined(vax)
00293 #    define UNALIGNED_OK
00294 #endif
00295 
00296 /* Under MSDOS we may run out of memory when processing a large number
00297  * of files. Compile with MEDIUM_MEM to reduce the memory requirements or
00298  * with SMALL_MEM to use as little memory as possible.
00299  */
00300 #ifdef SMALL_MEM
00301 #   define CBSZ 2048 /* buffer size for copying files */
00302 #   define ZBSZ 2048 /* buffer size for temporary zip file */
00303 #else
00304 # ifdef MEDIUM_MEM
00305 #   define CBSZ 8192
00306 #   define ZBSZ 8192
00307 # else
00308 #  ifdef OS2
00309 #   ifdef __32BIT__
00310 #     define CBSZ 0x40000
00311 #     define ZBSZ 0x40000
00312 #   else
00313 #     define CBSZ 0xE000
00314 #     define ZBSZ 0x7F00 /* Some libraries do not allow a buffer size > 32K */
00315 #   endif
00316 #  else
00317 #   ifdef TOPS20
00318 #    define CBSZ 524288
00319 #    define ZBSZ 524288
00320 #   else
00321 #    define CBSZ 16384
00322 #    define ZBSZ 16384
00323 #   endif
00324 #  endif
00325 # endif
00326 #endif
00327 
00328 #if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
00329 #   define DYN_ALLOC
00330 #endif
00331 
00332 #ifdef __human68k__
00333 #  include <sys/xglob.h>
00334 #  define MSVMS
00335 #  define SSTAT h68_stat
00336   int h68_stat OF((char *, struct stat *));
00337 #  define OS_CODE  0x300  /* pretend it's Unix */
00338 #endif
00339 
00340 #ifdef ATARI_ST
00341 #  define MSDOS  /* what? should be fixed */
00342 #  define MSVMS
00343 #  ifndef O_BINARY
00344 #    define O_BINARY 0
00345 #  endif
00346 #  ifndef S_IFMT
00347 #    define S_IFMT        (S_IFCHR|S_IFREG|S_IFDIR)
00348 #  endif
00349 
00350 #ifdef __IBMC__
00351 #  ifndef S_IFMT
00352 #    define S_IFMT 0xF000
00353 #  endif
00354 #endif /* __IBMC__ */
00355 
00356 /* a whole bunch of functions needs Tos '\\' filenames
00357  * instead of '/',  the translation functions are in fileio.c:
00358  */
00359 #  define unlink    st_unlink
00360 #  define chmod     st_chmod
00361 #  define mktemp    st_mktemp
00362 #  define fopen     st_fopen
00363 #  define open      st_open
00364 #  define SSTAT     st_stat
00365 #  define findfirst st_findfirst
00366 #  define link      st_rename
00367 #  define rmdir     st_rmdir
00368 
00369   int st_unlink    OF((char *));
00370   int st_chmod     OF((char *, int));
00371   char *st_mktemp  OF((char *));
00372   FILE *st_fopen   OF((char *, char *));
00373   int st_open      OF((char *, int));
00374   int st_stat      OF((char *, struct stat *));
00375   int st_findfirst OF((char *, struct ffblk *, int));
00376   int st_rename    OF((char *, char *));
00377   int st_rmdir     OF((char *));
00378 #endif  /* ATARI */
00379 
00380 #ifndef SSTAT
00381 #  define SSTAT      stat
00382 #endif
00383 #ifdef S_IFLNK
00384 #  define LSTAT      lstat
00385 #else
00386 #  define LSTAT      SSTAT
00387 #endif
00388 
00389 
00390 /* The following OS codes are defined in pkzip appnote.txt */
00391 #ifdef AMIGA
00392 #  define OS_CODE  0x100
00393 #endif
00394 #ifdef VMS
00395 #  define OS_CODE  0x200
00396 #endif
00397 /* unix    3 */
00398 /* vms/cms 4 */
00399 #ifdef ATARI_ST
00400 #  define OS_CODE  0x500
00401 #endif
00402 #ifdef OS2
00403 #  define OS_CODE  0x600
00404 #endif
00405 #if defined(MACOS) || defined(__MWERKS__)
00406 #  define OS_CODE  0x700
00407 #endif
00408 /* z system 8 */
00409 /* cp/m     9 */
00410 #ifdef TOPS20
00411 #  define OS_CODE  0xa00
00412 #endif
00413 #ifdef WIN32
00414 #  define OS_CODE  0xb00
00415 #endif
00416 /* qdos 12 */
00417 
00418 #if defined(MSDOS) && !defined(OS_CODE)
00419 #  define OS_CODE  0x000
00420 #endif
00421 #ifndef OS_CODE
00422 #  define OS_CODE  0x300  /* assume Unix */
00423 #  ifndef R__UNIX
00424 #    define R__UNIX
00425 #  endif
00426 #endif
00427 
00428 
00429 /* end of tailor.h */
00430 

Generated on Tue Jul 5 14:12:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1