Annotation of coherent/b/bin/unzip/unzip.h, revision 1.1

1.1     ! root        1: /*---------------------------------------------------------------------------
        !             2: 
        !             3:   unzip.h
        !             4: 
        !             5:   This header file is used by all of the unzip source files.  Its contents
        !             6:   are divided into seven more-or-less separate sections:  predefined macros,
        !             7:   OS-dependent includes, (mostly) OS-independent defines, typedefs, function 
        !             8:   prototypes (or "prototypes," in the case of non-ANSI compilers), macros, 
        !             9:   and global-variable declarations.
        !            10: 
        !            11:   ---------------------------------------------------------------------------*/
        !            12: 
        !            13: 
        !            14: 
        !            15: /*****************************************/
        !            16: /*  Predefined, Machine-specific Macros  */
        !            17: /*****************************************/
        !            18: 
        !            19: #if (defined(__GO32__) && defined(unix))   /* DOS extender */
        !            20: #  undef unix
        !            21: #endif
        !            22: 
        !            23: #if defined(unix) || defined(__convexc__) || defined(M_XENIX)
        !            24: #  ifndef UNIX
        !            25: #  define UNIX
        !            26: #  endif /* !UNIX */
        !            27: #endif /* unix || __convexc__ || M_XENIX */
        !            28: 
        !            29: /* Much of the following is swiped from zip's tailor.h: */
        !            30: 
        !            31: /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
        !            32: #ifdef __POWERC
        !            33: #  define __TURBOC__
        !            34: #  define MSDOS
        !            35: #endif /* __POWERC */
        !            36: #if (defined(__TURBOC__) && defined(__MSDOS__) && !defined(MSDOS))
        !            37: #  define MSDOS
        !            38: #endif
        !            39: 
        !            40: /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C,
        !            41:  * or Silicon Graphics, or Convex, or IBM C Set/2, or GNU gcc under emx, or
        !            42:  * or Watcom C, or Macintosh, or Windows NT.
        !            43:  */
        !            44: #if (__STDC__ || defined(MSDOS) || defined(sgi) || defined(CONVEX))
        !            45: #  ifndef PROTO
        !            46: #    define PROTO
        !            47: #  endif
        !            48: #  define MODERN
        !            49: #endif
        !            50: #if (defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__))
        !            51: #  ifndef PROTO
        !            52: #    define PROTO
        !            53: #  endif
        !            54: #  define MODERN
        !            55: #endif
        !            56: #if (defined(THINK_C) || defined(MPW) || defined(WIN32))
        !            57: #  ifndef PROTO
        !            58: #    define PROTO
        !            59: #  endif
        !            60: #  define MODERN
        !            61: #endif
        !            62: 
        !            63: /* turn off prototypes if requested */
        !            64: #if (defined(NOPROTO) && defined(PROTO))
        !            65: #  undef PROTO
        !            66: #endif
        !            67: 
        !            68: /* used to remove arguments in function prototypes for non-ANSI C */
        !            69: #ifdef PROTO
        !            70: #  define OF(a) a
        !            71: #else /* !PROTO */
        !            72: #  define OF(a) ()
        !            73: #endif /* ?PROTO */
        !            74: 
        !            75: #if (defined(ultrix) || defined(bsd4_2) || defined(sun) || defined(pyr))
        !            76: #  if (!defined(BSD) && !defined(__SYSTEM_FIVE) && !defined(SYSV))
        !            77: #    define BSD
        !            78: #  endif /* !BSD && !__SYSTEM_FIVE && !SYSV */
        !            79: #endif /* ultrix || bsd4_2 || sun || pyr */
        !            80: 
        !            81: #if (defined(CONVEX) || defined(CRAY) || defined(__SYSTEM_FIVE))
        !            82: #  ifndef TERMIO
        !            83: #    define TERMIO
        !            84: #  endif /* !TERMIO */
        !            85: #endif /* CONVEX || CRAY || __SYSTEM_FIVE */
        !            86: 
        !            87: #ifdef pyr  /* Pyramid */
        !            88: #  ifndef ZMEM
        !            89: #    define ZMEM
        !            90: #  endif /* !ZMEM */
        !            91: #endif /* pyr */
        !            92: 
        !            93: #ifdef CRAY
        !            94: #  ifdef ZMEM
        !            95: #    undef ZMEM
        !            96: #  endif /* ZMEM */
        !            97: #endif /* CRAY */
        !            98: 
        !            99: /* the i386 test below is to catch SCO Unix (which has redefinition
        !           100:  * warnings if param.h is included), but it probably doesn't hurt if
        !           101:  * other 386 Unixes get nailed, too...except now that 386BSD and BSDI
        !           102:  * exist.  Sigh.  <sys/param.h> is mostly included for "BSD", I think.
        !           103:  * [An alternate fix for SCO Unix is below.]
        !           104:  */
        !           105: #if (defined(MINIX) || (defined(i386) && defined(unix)))
        !           106: #  define NO_PARAM_H
        !           107: #endif /* MINIX || (i386 && unix) */
        !           108: 
        !           109: 
        !           110: 
        !           111: 
        !           112: 
        !           113: /***************************/
        !           114: /*  OS-Dependent Includes  */
        !           115: /***************************/
        !           116: 
        !           117: #ifndef MINIX            /* Minix needs it after all the other includes (?) */
        !           118: #  include <stdio.h>
        !           119: #endif
        !           120: #include <ctype.h>       /* skip for VMS, to use tolower() function? */
        !           121: #include <errno.h>       /* used in mapname() */
        !           122: #ifndef NO_ERRNO
        !           123: #  define DECLARE_ERRNO  /* everybody except MSC 6.0, SCO cc, Watcom C/386 */
        !           124: #endif /* !NO_ERRNO */
        !           125: #ifdef VMS
        !           126: #  include <types.h>     /* (placed up here instead of in VMS section below */
        !           127: #  include <stat.h>      /* because types.h is used in some other headers) */
        !           128: #else /* !VMS */
        !           129: #  if !defined(THINK_C) && !defined(MPW)
        !           130: #    include <sys/types.h>                 /* off_t, time_t, dev_t, ... */
        !           131: #    include <sys/stat.h>
        !           132: #  endif /* !THINK_C && !MPW */
        !           133: #endif /* ?VMS */
        !           134: 
        !           135: #ifdef MODERN
        !           136: #  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
        !           137: #    include <stddef.h>
        !           138: #  endif
        !           139: #  if (!defined(__GNUC__) && !defined(apollo))   /* both define __STDC__ */
        !           140: #    include <stdlib.h>    /* standard library prototypes, malloc(), etc. */
        !           141: #  else
        !           142: #    ifdef __EMX__
        !           143: #      include <stdlib.h>  /* emx IS gcc but has stdlib.h */
        !           144: #    endif
        !           145: #  endif
        !           146: #  include <string.h>      /* defines strcpy, strcmp, memcpy, etc. */
        !           147:    typedef size_t extent;
        !           148:    typedef void voidp;
        !           149: #else /* !MODERN */
        !           150:    char *malloc();
        !           151:    char *strchr(), *strrchr();
        !           152:    long lseek();
        !           153:    typedef unsigned int extent;
        !           154: #  define void int
        !           155:    typedef char voidp;
        !           156: #endif /* ?MODERN */
        !           157: 
        !           158: /* this include must be down here for SysV.4, for some reason... */
        !           159: #include <signal.h>      /* used in unzip.c, file_io.c */
        !           160: 
        !           161: 
        !           162: 
        !           163: /*---------------------------------------------------------------------------
        !           164:     Next, a word from our Unix (mostly) sponsors:
        !           165:   ---------------------------------------------------------------------------*/
        !           166: 
        !           167: #ifdef UNIX
        !           168: #  ifdef AMIGA
        !           169: #    include <libraries/dos.h>
        !           170: #  else /* !AMIGA */
        !           171: #    ifndef NO_PARAM_H
        !           172: #if 0  /* [GRR: this is an alternate fix for SCO's redefinition bug] */
        !           173: #      ifdef NGROUPS_MAX
        !           174: #        undef NGROUPS_MAX     /* SCO bug:  defined again in <param.h> */
        !           175: #      endif /* NGROUPS_MAX */
        !           176: #endif /* 0 */
        !           177: #      include <sys/param.h>   /* conflict with <sys/types.h>, some systems? */
        !           178: #    endif /* !NO_PARAM_H */
        !           179: #  endif /* ?AMIGA */
        !           180: 
        !           181: #  ifndef BSIZE
        !           182: #    ifdef MINIX
        !           183: #      define BSIZE   1024
        !           184: #    else /* !MINIX */
        !           185: #      define BSIZE   DEV_BSIZE  /* assume common for all Unix systems */
        !           186: #    endif /* ?MINIX */
        !           187: #  endif
        !           188: 
        !           189: #  ifndef BSD
        !           190: #    if (!defined(AMIGA) && !defined(MINIX))
        !           191: #      define NO_MKDIR           /* for mapname() */
        !           192: #    endif /* !AMIGA && !MINIX */
        !           193: #    include <time.h>
        !           194:      struct tm *gmtime(), *localtime();
        !           195: #  else   /* BSD */
        !           196: #    include <sys/time.h>
        !           197: #    include <sys/timeb.h>
        !           198: #    ifdef _AIX
        !           199: #      include <time.h>
        !           200: #    endif
        !           201: #  endif
        !           202: 
        !           203: #else   /* !UNIX */
        !           204: #  define BSIZE   512               /* disk block size */
        !           205: #endif /* ?UNIX */
        !           206: 
        !           207: #if (defined(V7) || defined(BSD))
        !           208: #  define strchr    index
        !           209: #  define strrchr   rindex
        !           210: #endif
        !           211: 
        !           212: /*---------------------------------------------------------------------------
        !           213:     And now, our MS-DOS and OS/2 corner:
        !           214:   ---------------------------------------------------------------------------*/
        !           215: 
        !           216: #ifdef __TURBOC__
        !           217: #  define DOS_OS2
        !           218: #  include <sys/timeb.h>      /* for structure ftime                        */
        !           219: #  ifndef __BORLANDC__        /* there appears to be a bug (?) in Borland's */
        !           220: #    include <mem.h>          /*   MEM.H related to __STDC__ and far poin-  */
        !           221: #  endif                      /*   ters. (dpk)  [mem.h included for memcpy] */
        !           222: #  include <dos.h>            /* for REGS macro (at least for Turbo C 2.0)  */
        !           223: #else                         /* NOT Turbo C (or Power C)...                */
        !           224: #  ifdef MSDOS                /*   but still MS-DOS, so we'll assume it's   */
        !           225: #    ifndef MSC               /*   Microsoft's compiler and fake the ID, if */
        !           226: #      define MSC             /*   necessary (it is in 5.0; apparently not  */
        !           227: #    endif                    /*   in 5.1 and 6.0)                          */
        !           228: #    include <dos.h>          /* for _dos_setftime()                        */
        !           229: #  endif
        !           230: #endif
        !           231: 
        !           232: #if (defined(__IBMC__) && defined(__OS2__))
        !           233: #  define DOS_OS2
        !           234: #  define S_IFMT 0xF000
        !           235: #  define timezone _timezone
        !           236: #endif
        !           237: 
        !           238: #ifdef __WATCOMC__
        !           239: #  define DOS_OS2
        !           240: #  define __32BIT__
        !           241: #  ifdef DECLARE_ERRNO
        !           242: #    undef DECLARE_ERRNO
        !           243: #  endif
        !           244: #  undef far
        !           245: #  define far
        !           246: #endif
        !           247: 
        !           248: #ifdef __EMX__
        !           249: #  define DOS_OS2
        !           250: #  define __32BIT__
        !           251: #  define far
        !           252: #endif /* __EMX__ */
        !           253: 
        !           254: #ifdef MSC                    /* defined for all versions of MSC now         */
        !           255: #  define DOS_OS2             /* Turbo C under DOS, MSC under DOS or OS/2    */
        !           256: #  if (defined(_MSC_VER) && (_MSC_VER >= 600))    /* new with 5.1 or 6.0 ... */
        !           257: #    undef DECLARE_ERRNO      /* errno is now a function in a dynamic link   */
        !           258: #  endif                      /*   library (or something)--incompatible with */
        !           259: #endif                        /*   the usual "extern int errno" declaration  */
        !           260: 
        !           261: #ifdef DOS_OS2                /* defined for all MS-DOS and OS/2 compilers   */
        !           262: #  include <io.h>             /* lseek(), open(), setftime(), dup(), creat() */
        !           263: #  include <time.h>           /* localtime() */
        !           264: #endif
        !           265: 
        !           266: #ifdef OS2                    /* defined for all OS/2 compilers */
        !           267: #  ifdef isupper
        !           268: #    undef isupper
        !           269: #  endif
        !           270: #  ifdef tolower
        !           271: #    undef tolower
        !           272: #  endif
        !           273: #  define isupper(x)   IsUpperNLS((unsigned char)(x))
        !           274: #  define tolower(x)   ToLowerNLS((unsigned char)(x))
        !           275: #endif
        !           276: 
        !           277: #ifdef WIN32
        !           278: #  include <io.h>             /* read(), open(), etc. */
        !           279: #  include <time.h>
        !           280: #  include <memory.h>
        !           281: #  include <direct.h>         /* mkdir() */
        !           282: #  ifdef FILE_IO_C
        !           283: #    include <fcntl.h>
        !           284: #    include <conio.h>
        !           285: #    include <sys\types.h>
        !           286: #    include <sys\utime.h>
        !           287: #    include <windows.h>
        !           288: #    define DOS_OS2
        !           289: #    define getch() getchar()
        !           290: #  endif
        !           291: #endif
        !           292: 
        !           293: /*---------------------------------------------------------------------------
        !           294:     Followed by some VMS (mostly) stuff:
        !           295:   ---------------------------------------------------------------------------*/
        !           296: 
        !           297: #ifdef VMS
        !           298: #  include <time.h>               /* the usual non-BSD time functions */
        !           299: #  include <file.h>               /* same things as fcntl.h has */
        !           300: #  include <rms.h>
        !           301: #  define _MAX_PATH NAM$C_MAXRSS  /* to define FILNAMSIZ below */
        !           302: #  define UNIX                    /* can share most of same code from now on */
        !           303: #  define RETURN    return_VMS    /* VMS interprets return codes incorrectly */
        !           304: #else /* !VMS */
        !           305: #  ifndef THINK_C
        !           306: #    define RETURN  return        /* only used in main() */
        !           307: #  else
        !           308: #    define RETURN(v) { int n;\
        !           309:                         n = (v);\
        !           310:                         fprintf(stderr, "\npress <return> to continue ");\
        !           311:                         while (getc(stdin) != '\n');\
        !           312:                         putc('\n', stderr);\
        !           313:                         InitCursor();\
        !           314:                         goto start;\
        !           315:                       }
        !           316: #  endif
        !           317: #  ifdef V7
        !           318: #    define O_RDONLY  0
        !           319: #    define O_WRONLY  1
        !           320: #    define O_RDWR    2
        !           321: #  else /* !V7 */
        !           322: #    ifdef MTS
        !           323: #      include <sys/file.h>     /* MTS uses this instead of fcntl.h */
        !           324: #      include <timeb.h>
        !           325: #      include <time.h>
        !           326: #    else /* !MTS */
        !           327: #      ifdef COHERENT           /* Coherent 3.10/Mark Williams C */
        !           328: #        include <fcntl.h>
        !           329: #        include <time.h>
        !           330: #        define O_BINARY       0
        !           331: #        define SHORT_NAMES
        !           332: #        define tzset  settz
        !           333: #      else /* !COHERENT */
        !           334: #        include <fcntl.h>      /* O_BINARY for open() w/o CR/LF translation */
        !           335: #      endif /* ?COHERENT */
        !           336: #    endif /* ?MTS */
        !           337: #  endif /* ?V7 */
        !           338: #endif /* ?VMS */
        !           339: 
        !           340: #if (defined(MSDOS) || defined(VMS))
        !           341: #  define DOS_VMS
        !           342: #endif
        !           343: 
        !           344: /*---------------------------------------------------------------------------
        !           345:     And some Mac stuff for good measure:
        !           346:   ---------------------------------------------------------------------------*/
        !           347: 
        !           348: #ifdef THINK_C
        !           349: #  define MACOS
        !           350: #  ifndef __STDC__            /* if Think C hasn't defined __STDC__ ... */
        !           351: #    define __STDC__ 1        /*   make sure it's defined: it needs it */
        !           352: #  else /* __STDC__ defined */
        !           353: #    if !__STDC__             /* sometimes __STDC__ is defined as 0; */
        !           354: #      undef __STDC__         /*   it needs to be 1 or required header */
        !           355: #      define __STDC__ 1      /*   files are not properly included. */
        !           356: #    endif /* !__STDC__ */
        !           357: #  endif /* ?defined(__STDC__) */
        !           358: #endif /* THINK_C */
        !           359: 
        !           360: #ifdef MPW
        !           361: #  define MACOS
        !           362: #  include <Errors.h>
        !           363: #  include <Files.h>
        !           364: #  include <Memory.h>
        !           365: #  include <Quickdraw.h>
        !           366: #  include <ToolUtils.h>
        !           367: #  define CtoPstr c2pstr
        !           368: #  define PtoCstr p2cstr
        !           369: #  ifdef CR
        !           370: #    undef  CR
        !           371: #  endif
        !           372: #endif /* MPW */
        !           373: 
        !           374: #ifdef MACOS
        !           375: #  define open(x,y) macopen(x,y, gnVRefNum, glDirID)
        !           376: #  define close macclose
        !           377: #  define read macread
        !           378: #  define write macwrite
        !           379: #  define lseek maclseek
        !           380: #  define creat(x,y) maccreat(x, gnVRefNum, glDirID, gostCreator, gostType)
        !           381: #  define stat(x,y) macstat(x,y,gnVRefNum, glDirID)
        !           382: 
        !           383: #  ifndef isascii
        !           384: #    define isascii(c) ((unsigned char)(c) <= 0x3F)
        !           385: #  endif
        !           386: 
        !           387: #  include "macstat.h"
        !           388: 
        !           389: typedef struct _ZipExtraHdr {
        !           390:     unsigned short header;    /*    2 bytes */
        !           391:     unsigned short data;      /*    2 bytes */
        !           392: } ZIP_EXTRA_HEADER;
        !           393: 
        !           394: typedef struct _MacInfoMin {
        !           395:     unsigned short header;    /*    2 bytes */
        !           396:     unsigned short data;      /*    2 bytes */
        !           397:     unsigned long signature;  /*    4 bytes */
        !           398:     FInfo finfo;              /*   16 bytes */
        !           399:     unsigned long lCrDat;     /*    4 bytes */
        !           400:     unsigned long lMdDat;     /*    4 bytes */
        !           401:     unsigned long flags ;     /*    4 bytes */
        !           402:     unsigned long lDirID;     /*    4 bytes */
        !           403:                               /*------------*/
        !           404: } MACINFOMIN;                 /* = 40 bytes for size of data */
        !           405: 
        !           406: typedef struct _MacInfo {
        !           407:     unsigned short header;    /*    2 bytes */
        !           408:     unsigned short data;      /*    2 bytes */
        !           409:     unsigned long signature;  /*    4 bytes */
        !           410:     FInfo finfo;              /*   16 bytes */
        !           411:     unsigned long lCrDat;     /*    4 bytes */
        !           412:     unsigned long lMdDat;     /*    4 bytes */
        !           413:     unsigned long flags ;     /*    4 bytes */
        !           414:     unsigned long lDirID;     /*    4 bytes */
        !           415:     char rguchVolName[28];    /*   28 bytes */
        !           416:                               /*------------*/
        !           417: } MACINFO;                    /* = 68 bytes for size of data */
        !           418: #endif /* MACOS */
        !           419: 
        !           420: /*---------------------------------------------------------------------------
        !           421:     And finally, some random extra stuff:
        !           422:   ---------------------------------------------------------------------------*/
        !           423: 
        !           424: #ifdef MINIX
        !           425: #  include <stdio.h>
        !           426: #endif
        !           427: 
        !           428: #ifdef SHORT_NAMES         /* Mark Williams C, ...? */
        !           429: #  define extract_or_test_files    xtr_or_tst_files
        !           430: #  define extract_or_test_member   xtr_or_tst_member
        !           431: #endif
        !           432: 
        !           433: #ifdef MTS
        !           434: #  include <unix.h>          /* Some important non-ANSI routines */
        !           435: #  define mkdir(s,n) (-1)    /* No "make directory" capability */
        !           436: #  define EBCDIC             /* Set EBCDIC conversion on */
        !           437: #endif
        !           438: 
        !           439: 
        !           440: 
        !           441: 
        !           442: 
        !           443: /*************/
        !           444: /*  Defines  */
        !           445: /*************/
        !           446: 
        !           447: #ifndef WSIZE
        !           448: #  define WSIZE 0x8000       /* window size--must be a power of two, and */
        !           449: #endif /* !WSIZE */          /*  at least 32K for zip's deflate method */
        !           450: 
        !           451: #define DIR_BLKSIZ    64     /* number of directory entries per block
        !           452:                               *  (should fit in 4096 bytes, usually) */
        !           453: #ifndef INBUFSIZ
        !           454: #  define INBUFSIZ    2048   /* works for MS-DOS small model */
        !           455: #endif /* !INBUFSIZ */
        !           456: 
        !           457: /*
        !           458:  * If <limits.h> exists on most systems, should include that, since it may
        !           459:  * define some or all of the following:  NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
        !           460:  * _POSIX_PATH_MAX.
        !           461:  */
        !           462: #ifdef DOS_OS2
        !           463: #  include <limits.h>
        !           464: #endif /* DOS_OS2 */
        !           465: 
        !           466: #ifdef _MAX_PATH
        !           467: #  define FILNAMSIZ       (_MAX_PATH)
        !           468: #else /* !_MAX_PATH */
        !           469: #  define FILNAMSIZ       1025
        !           470: #endif /* ?_MAX_PATH */
        !           471: 
        !           472: #ifndef PATH_MAX
        !           473: #  ifdef MAXPATHLEN                /* defined in <sys/param.h> some systems */
        !           474: #    define PATH_MAX      MAXPATHLEN
        !           475: #  else
        !           476: #    if FILENAME_MAX > 255         /* used like PATH_MAX on some systems */
        !           477: #      define PATH_MAX    FILENAME_MAX
        !           478: #    else
        !           479: #      define PATH_MAX    (FILNAMSIZ - 1)
        !           480: #    endif
        !           481: #  endif /* ?MAXPATHLEN */
        !           482: #endif /* !PATH_MAX */
        !           483: 
        !           484: #define OUTBUFSIZ         INBUFSIZ
        !           485: 
        !           486: #define ZSUFX             ".zip"
        !           487: #define CENTRAL_HDR_SIG   "\113\001\002"   /* the infamous "PK" signature */
        !           488: #define LOCAL_HDR_SIG     "\113\003\004"   /*  bytes, sans "P" (so unzip */
        !           489: #define END_CENTRAL_SIG   "\113\005\006"   /*  executable not mistaken for */
        !           490: #define EXTD_LOCAL_SIG    "\113\007\010"   /*  zipfile itself) */
        !           491: 
        !           492: #define SKIP              0    /* choice of activities for do_string() */
        !           493: #define DISPLAY           1
        !           494: #define FILENAME          2
        !           495: #define EXTRA_FIELD       3
        !           496: 
        !           497: #define DOES_NOT_EXIST    -1   /* return values for check_for_newer() */
        !           498: #define EXISTS_AND_OLDER  0
        !           499: #define EXISTS_AND_NEWER  1
        !           500: 
        !           501: #define DOS_OS2_FAT_      0    /* version_made_by codes (central dir) */
        !           502: #define AMIGA_            1
        !           503: #define VMS_              2    /* make sure these are not defined on */
        !           504: #define UNIX_             3    /*  the respective systems!!  (like, for */
        !           505: #define VM_CMS_           4    /*  instance, "VMS", or "UNIX":  CFLAGS = */
        !           506: #define ATARI_            5    /*  -O -DUNIX) */
        !           507: #define OS2_HPFS_         6
        !           508: #define MAC_              7
        !           509: #define Z_SYSTEM_         8
        !           510: #define CPM_              9
        !           511: /* #define TOPS20_   10?  (TOPS20_ is to be defined in PKZIP 2.0...)  */
        !           512: #define NUM_HOSTS         10   /* index of last system + 1 */
        !           513: 
        !           514: #define STORED            0    /* compression methods */
        !           515: #define SHRUNK            1
        !           516: #define REDUCED1          2
        !           517: #define REDUCED2          3
        !           518: #define REDUCED3          4
        !           519: #define REDUCED4          5
        !           520: #define IMPLODED          6
        !           521: #define TOKENIZED         7
        !           522: #define DEFLATED          8
        !           523: #define NUM_METHODS       9    /* index of last method + 1 */
        !           524: /* don't forget to update list_files() appropriately if NUM_METHODS changes */
        !           525: 
        !           526: #define DF_MDY            0    /* date format 10/26/91 (USA only) */
        !           527: #define DF_DMY            1    /* date format 26/10/91 (most of the world) */
        !           528: #define DF_YMD            2    /* date format 91/10/26 (a few countries) */
        !           529: 
        !           530: #define UNZIP_VERSION     20   /* compatible with PKUNZIP 2.0 */
        !           531: #define VMS_VERSION       42   /* if OS-needed-to-extract is VMS:  can do */
        !           532: 
        !           533: /*---------------------------------------------------------------------------
        !           534:     True sizes of the various headers, as defined by PKWare--so it is not
        !           535:     likely that these will ever change.  But if they do, make sure both these
        !           536:     defines AND the typedefs below get updated accordingly.
        !           537:   ---------------------------------------------------------------------------*/
        !           538: #define LREC_SIZE     26    /* lengths of local file headers, central */
        !           539: #define CREC_SIZE     42    /*  directory headers, and the end-of-    */
        !           540: #define ECREC_SIZE    18    /*  central-dir record, respectively      */
        !           541: 
        !           542: #define MAX_BITS      13                 /* used in unShrink() */
        !           543: #define HSIZE         (1 << MAX_BITS)    /* size of global work area */
        !           544: 
        !           545: #define LF      10    /* '\n' on ASCII machines.  Must be 10 due to EBCDIC */
        !           546: #define CR      13    /* '\r' on ASCII machines.  Must be 13 due to EBCDIC */
        !           547: #define CTRLZ   26    /* DOS & OS/2 EOF marker (used in file_io.c, vms.c) */
        !           548: 
        !           549: #ifdef EBCDIC
        !           550: #  define ascii_to_native(c)   ebcdic[(c)]
        !           551: #  define NATIVE    "EBCDIC"
        !           552: #endif
        !           553: 
        !           554: #if MPW
        !           555: #  define FFLUSH    putc('\n',stderr);
        !           556: #else /* !MPW */
        !           557: #  define FFLUSH    fflush(stderr);
        !           558: #endif /* ?MPW */
        !           559: 
        !           560: #ifdef VMS
        !           561: #  define ENV_UNZIP     "UNZIP_OPTS"      /* name of environment variable */
        !           562: #  define ENV_ZIPINFO   "ZIPINFO_OPTS"
        !           563: #else /* !VMS */
        !           564: #  define ENV_UNZIP     "UNZIP"
        !           565: #  define ENV_ZIPINFO   "ZIPINFO"
        !           566: #endif /* ?VMS */
        !           567: 
        !           568: #ifdef CRYPT
        !           569: #  define PWLEN         80
        !           570: #  define DECRYPT(b)    (update_keys(t=((b)&0xff)^decrypt_byte()),t)
        !           571: #endif /* CRYPT */
        !           572: 
        !           573: #ifdef QQ  /* Newtware version */
        !           574: #  define QCOND   (!quietflg)   /* for no file comments with -vq or -vqq */
        !           575: #else      /* (original) Bill Davidsen version  */
        !           576: #  define QCOND   (which_hdr)   /* no way to kill file comments with -v, -l */
        !           577: #endif
        !           578: 
        !           579: #ifndef TRUE
        !           580: #  define TRUE      1   /* sort of obvious */
        !           581: #endif
        !           582: #ifndef FALSE
        !           583: #  define FALSE     0
        !           584: #endif
        !           585: 
        !           586: #ifndef SEEK_SET        /* These should all be declared in stdio.h!  But   */
        !           587: #  define SEEK_SET  0   /*  since they're not (in many cases), do so here. */
        !           588: #  define SEEK_CUR  1
        !           589: #  define SEEK_END  2
        !           590: #endif
        !           591: 
        !           592: #ifndef S_IRUSR
        !           593: #  define S_IRWXU       00700       /* read, write, execute: owner */
        !           594: #  define S_IRUSR       00400       /* read permission: owner */
        !           595: #  define S_IWUSR       00200       /* write permission: owner */
        !           596: #  define S_IXUSR       00100       /* execute permission: owner */
        !           597: #  define S_IRWXG       00070       /* read, write, execute: group */
        !           598: #  define S_IRGRP       00040       /* read permission: group */
        !           599: #  define S_IWGRP       00020       /* write permission: group */
        !           600: #  define S_IXGRP       00010       /* execute permission: group */
        !           601: #  define S_IRWXO       00007       /* read, write, execute: other */
        !           602: #  define S_IROTH       00004       /* read permission: other */
        !           603: #  define S_IWOTH       00002       /* write permission: other */
        !           604: #  define S_IXOTH       00001       /* execute permission: other */
        !           605: #endif /* !S_IRUSR */
        !           606: 
        !           607: #ifdef ZIPINFO      /* these are individually checked because SysV doesn't */
        !           608: #  ifndef S_IFBLK   /*  have some of them, Microsoft C others, etc. */
        !           609: #    define   S_IFBLK     0060000     /* block special */
        !           610: #  endif
        !           611: #  ifndef S_IFIFO  /* in Borland C, not MSC */
        !           612: #    define   S_IFIFO     0010000     /* fifo */
        !           613: #  endif
        !           614: #  ifndef S_IFLNK  /* in BSD, not SysV */
        !           615: #    define   S_IFLNK     0120000     /* symbolic link */
        !           616: #  endif
        !           617: #  ifndef S_IFSOCK  /* in BSD, not SysV */
        !           618: #    define   S_IFSOCK    0140000     /* socket */
        !           619: #  endif
        !           620: #  ifndef S_ISUID
        !           621: #    define S_ISUID       04000       /* set user id on execution */
        !           622: #  endif
        !           623: #  ifndef S_ISGID
        !           624: #    define S_ISGID       02000       /* set group id on execution */
        !           625: #  endif
        !           626: #  ifndef S_ISVTX
        !           627: #    define S_ISVTX       01000       /* directory permissions control */
        !           628: #  endif
        !           629: #  ifndef S_ENFMT
        !           630: #    define S_ENFMT       S_ISGID     /* record locking enforcement flag */
        !           631: #  endif
        !           632: #endif /* ZIPINFO */
        !           633: 
        !           634: 
        !           635: 
        !           636: 
        !           637: 
        !           638: /**************/
        !           639: /*  Typedefs  */
        !           640: /**************/
        !           641: 
        !           642: #ifndef _BULL_SOURCE                /* Bull has it defined somewhere already */
        !           643:    typedef unsigned char  byte;     /* code assumes UNSIGNED bytes */
        !           644: #endif /* !_BULL_SOURCE */
        !           645: 
        !           646: typedef char              boolean;
        !           647: typedef long              longint;
        !           648: typedef unsigned short    UWORD;
        !           649: typedef unsigned long     ULONG;
        !           650: typedef unsigned char     uch;
        !           651: typedef unsigned short    ush;
        !           652: typedef unsigned long     ulg;
        !           653: 
        !           654: typedef struct min_info {
        !           655:     unsigned unix_attr;
        !           656:     unsigned dos_attr;
        !           657:     int hostnum;
        !           658:     longint offset;
        !           659:     ULONG compr_size;        /* compressed size (needed if extended header) */
        !           660:     ULONG crc;               /* crc (needed if extended header) */
        !           661:     unsigned encrypted : 1;  /* file encrypted: decrypt before uncompressing */
        !           662:     unsigned ExtLocHdr : 1;  /* use time instead of CRC for decrypt check */
        !           663:     unsigned text : 1;       /* file is text or binary */
        !           664:     unsigned lcflag : 1;     /* convert filename to lowercase */
        !           665: } min_info;
        !           666: 
        !           667: typedef struct VMStimbuf {
        !           668:     char *revdate;           /* (both correspond to Unix modtime/st_mtime) */
        !           669:     char *credate;
        !           670: } VMStimbuf;
        !           671: 
        !           672: /*---------------------------------------------------------------------------
        !           673:     Zipfile layout declarations.  If these headers ever change, make sure the
        !           674:     xxREC_SIZE defines (above) change with them!
        !           675:   ---------------------------------------------------------------------------*/
        !           676: 
        !           677:    typedef byte   local_byte_hdr[ LREC_SIZE ];
        !           678: #      define L_VERSION_NEEDED_TO_EXTRACT_0     0
        !           679: #      define L_VERSION_NEEDED_TO_EXTRACT_1     1
        !           680: #      define L_GENERAL_PURPOSE_BIT_FLAG        2
        !           681: #      define L_COMPRESSION_METHOD              4
        !           682: #      define L_LAST_MOD_FILE_TIME              6
        !           683: #      define L_LAST_MOD_FILE_DATE              8
        !           684: #      define L_CRC32                           10
        !           685: #      define L_COMPRESSED_SIZE                 14
        !           686: #      define L_UNCOMPRESSED_SIZE               18
        !           687: #      define L_FILENAME_LENGTH                 22
        !           688: #      define L_EXTRA_FIELD_LENGTH              24
        !           689: 
        !           690:    typedef byte   cdir_byte_hdr[ CREC_SIZE ];
        !           691: #      define C_VERSION_MADE_BY_0               0
        !           692: #      define C_VERSION_MADE_BY_1               1
        !           693: #      define C_VERSION_NEEDED_TO_EXTRACT_0     2
        !           694: #      define C_VERSION_NEEDED_TO_EXTRACT_1     3
        !           695: #      define C_GENERAL_PURPOSE_BIT_FLAG        4
        !           696: #      define C_COMPRESSION_METHOD              6
        !           697: #      define C_LAST_MOD_FILE_TIME              8
        !           698: #      define C_LAST_MOD_FILE_DATE              10
        !           699: #      define C_CRC32                           12
        !           700: #      define C_COMPRESSED_SIZE                 16
        !           701: #      define C_UNCOMPRESSED_SIZE               20
        !           702: #      define C_FILENAME_LENGTH                 24
        !           703: #      define C_EXTRA_FIELD_LENGTH              26
        !           704: #      define C_FILE_COMMENT_LENGTH             28
        !           705: #      define C_DISK_NUMBER_START               30
        !           706: #      define C_INTERNAL_FILE_ATTRIBUTES        32
        !           707: #      define C_EXTERNAL_FILE_ATTRIBUTES        34
        !           708: #      define C_RELATIVE_OFFSET_LOCAL_HEADER    38
        !           709: 
        !           710:    typedef byte   ec_byte_rec[ ECREC_SIZE+4 ];
        !           711: /*     define SIGNATURE                         0   space-holder only */
        !           712: #      define NUMBER_THIS_DISK                  4
        !           713: #      define NUM_DISK_WITH_START_CENTRAL_DIR   6
        !           714: #      define NUM_ENTRIES_CENTRL_DIR_THS_DISK   8
        !           715: #      define TOTAL_ENTRIES_CENTRAL_DIR         10
        !           716: #      define SIZE_CENTRAL_DIRECTORY            12
        !           717: #      define OFFSET_START_CENTRAL_DIRECTORY    16
        !           718: #      define ZIPFILE_COMMENT_LENGTH            20
        !           719: 
        !           720: 
        !           721:    typedef struct local_file_header {                 /* LOCAL */
        !           722:        byte version_needed_to_extract[2];
        !           723:        UWORD general_purpose_bit_flag;
        !           724:        UWORD compression_method;
        !           725:        UWORD last_mod_file_time;
        !           726:        UWORD last_mod_file_date;
        !           727:        ULONG crc32;
        !           728:        ULONG compressed_size;
        !           729:        ULONG uncompressed_size;
        !           730:        UWORD filename_length;
        !           731:        UWORD extra_field_length;
        !           732:    } local_file_hdr;
        !           733: 
        !           734:    typedef struct central_directory_file_header {     /* CENTRAL */
        !           735:        byte version_made_by[2];
        !           736:        byte version_needed_to_extract[2];
        !           737:        UWORD general_purpose_bit_flag;
        !           738:        UWORD compression_method;
        !           739:        UWORD last_mod_file_time;
        !           740:        UWORD last_mod_file_date;
        !           741:        ULONG crc32;
        !           742:        ULONG compressed_size;
        !           743:        ULONG uncompressed_size;
        !           744:        UWORD filename_length;
        !           745:        UWORD extra_field_length;
        !           746:        UWORD file_comment_length;
        !           747:        UWORD disk_number_start;
        !           748:        UWORD internal_file_attributes;
        !           749:        ULONG external_file_attributes;
        !           750:        ULONG relative_offset_local_header;
        !           751:    } cdir_file_hdr;
        !           752: 
        !           753:    typedef struct end_central_dir_record {            /* END CENTRAL */
        !           754:        UWORD number_this_disk;
        !           755:        UWORD num_disk_with_start_central_dir;
        !           756:        UWORD num_entries_centrl_dir_ths_disk;
        !           757:        UWORD total_entries_central_dir;
        !           758:        ULONG size_central_directory;
        !           759:        ULONG offset_start_central_directory;
        !           760:        UWORD zipfile_comment_length;
        !           761:    } ecdir_rec;
        !           762: 
        !           763: 
        !           764: 
        !           765: 
        !           766: 
        !           767: /*************************/
        !           768: /*  Function Prototypes  */
        !           769: /*************************/
        !           770: 
        !           771: #ifndef __
        !           772: #  define __   OF
        !           773: #endif
        !           774: 
        !           775: /*---------------------------------------------------------------------------
        !           776:     Functions in unzip.c and/or zipinfo.c:
        !           777:   ---------------------------------------------------------------------------*/
        !           778: 
        !           779: int    usage                     __((int error));
        !           780: int    process_zipfile           __((void));
        !           781: int    find_end_central_dir      __((void));
        !           782: int    process_end_central_dir   __((void));
        !           783: int    list_files                __((void));                      /* unzip.c */
        !           784: int    process_cdir_file_hdr     __((void));                      /* unzip.c */
        !           785: int    process_local_file_hdr    __((void));                      /* unzip.c */
        !           786: int    process_central_dir       __((void));
        !           787: int    long_info                 __((void));                    /* zipinfo.c */
        !           788: int    short_info                __((void));                    /* zipinfo.c */
        !           789: char   *zipinfo_time             __((UWORD *datez, UWORD *timez));
        !           790: 
        !           791: /*---------------------------------------------------------------------------
        !           792:     Functions in extract.c:
        !           793:   ---------------------------------------------------------------------------*/
        !           794: 
        !           795: int    extract_or_test_files     __((void));
        !           796: /* static int   store_info               __((void)); */
        !           797: /* static int   extract_or_test_member   __((void)); */
        !           798: int    memextract                __((byte *, ULONG, byte *, ULONG));
        !           799: int    FlushMemory               __((void));
        !           800: int    ReadMemoryByte            __((UWORD *x));
        !           801: 
        !           802: /*---------------------------------------------------------------------------
        !           803:     Decompression functions:
        !           804:   ---------------------------------------------------------------------------*/
        !           805: 
        !           806: int    explode                   __((void));                    /* explode.c */
        !           807: 
        !           808: int    inflate                   __((void));                    /* inflate.c */
        !           809: 
        !           810: void   unReduce                  __((void));                   /* unreduce.c */
        !           811: /* static void  LoadFollowers    __((void));                    * unreduce.c */
        !           812: 
        !           813: void   unShrink                  __((void));                   /* unshrink.c */
        !           814: /* static void  partial_clear    __((void));                    * unshrink.c */
        !           815: 
        !           816: /*---------------------------------------------------------------------------
        !           817:     Functions in file_io.c and crypt.c:
        !           818:   ---------------------------------------------------------------------------*/
        !           819: 
        !           820: int    open_input_file           __((void));                    /* file_io.c */
        !           821: int    readbuf                   __((char *buf, register unsigned len));
        !           822: int    create_output_file        __((void));             /* file_io.c, vms.c */
        !           823: int    FillBitBuffer             __((void));                    /* file_io.c */
        !           824: int    ReadByte                  __((UWORD *x));                /* file_io.c */
        !           825: int    FlushOutput               __((void));             /* file_io.c, vms.c */
        !           826: /* static int   dos2unix         __((unsigned char *, int));     * file_io.c */
        !           827: void   set_file_time_and_close   __((void));                    /* file_io.c */
        !           828: void   handler                   __((int signal));              /* file_io.c */
        !           829: int    echo                      __((int opt));                 /* file_io.c */
        !           830: void   echoff                    __((int f));                   /* file_io.c */
        !           831: void   echon                     __((void));                    /* file_io.c */
        !           832: char   *getp                     __((char *, char *, int));     /* file_io.c */
        !           833: 
        !           834: int    decrypt_byte              __((void));                      /* crypt.c */
        !           835: void   update_keys               __((int));                       /* crypt.c */
        !           836: void   init_keys                 __((char *));                    /* crypt.c */
        !           837: 
        !           838: /*---------------------------------------------------------------------------
        !           839:     Macintosh file_io functions:
        !           840:   ---------------------------------------------------------------------------*/
        !           841: 
        !           842: #ifdef MACOS
        !           843: /* static int   IsHFSDisk        __((int)); */
        !           844:    void     macfstest            __((int));
        !           845:    int      macmkdir             __((char *, short, long));
        !           846:    void     ResolveMacVol        __((short, short *, long *, StringPtr));
        !           847:    short    macopen              __((char *, short, short, long));
        !           848:    short    maccreat             __((char *, short, long, OSType, OSType));
        !           849:    short    macread              __((short, char *, unsigned));
        !           850:    short    macwrite             __((short, char *, unsigned));
        !           851:    short    macclose             __((short));
        !           852:    long     maclseek             __((short, long, short));
        !           853: #endif
        !           854: 
        !           855: /*---------------------------------------------------------------------------
        !           856:     OS/2 file_io functions:
        !           857:   ---------------------------------------------------------------------------*/
        !           858: 
        !           859: void     ChangeNameForFAT  __((char *name));                   /* os2unzip.c */
        !           860: int      IsFileNameValid   __((char *name));                   /* os2unzip.c */
        !           861: int      GetCountryInfo    __((void));                         /* os2unzip.c */
        !           862: long     GetFileTime       __((char *name));                   /* os2unzip.c */
        !           863: void     SetPathInfo __((char *path, UWORD moddate, UWORD modtime, int flags));
        !           864: int      SetLongNameEA     __((char *name, char *longname));   /* os2unzip.c */
        !           865: int      IsEA              __((void *extra_field));            /* os2unzip.c */
        !           866: ULONG    SizeOfEAs         __((void *extra_field));            /* os2unzip.c */
        !           867: void     SetEAs            __((char *path, void *eablock));    /* os2unzip.c */
        !           868: int      IsUpperNLS        __((int nChr));                     /* os2unzip.c */
        !           869: int      ToLowerNLS        __((int nChr));                     /* os2unzip.c */
        !           870: 
        !           871: /*---------------------------------------------------------------------------
        !           872:     VMS file_io functions:
        !           873:   ---------------------------------------------------------------------------*/
        !           874: 
        !           875: int      check_format      __((void));                              /* vms.c */
        !           876: int      find_vms_attrs    __((void));                              /* vms.c */
        !           877: int      CloseOutputFile   __((void));                              /* vms.c */
        !           878: /* static byte *extract_block __((struct extra_block *, int *, byte *, int));*/
        !           879: /* static int  _flush_blocks  __((int final_flag));                  * vms.c */
        !           880: /* static int  _flush_records __((int final_flag));                  * vms.c */
        !           881: /* static int  WriteBuffer    __((unsigned char *buf, int len));     * vms.c */
        !           882: /* static int  WriteRecord    __((unsigned char *rec, int len));     * vms.c */
        !           883: /* static void message        __((int string, char *status));        * vms.c */
        !           884: 
        !           885: int      VMSmunch          __((char *, int, char *));          /* VMSmunch.c */
        !           886: 
        !           887: /*---------------------------------------------------------------------------
        !           888:     Functions in match.c, mapname.c, misc.c, etc.:
        !           889:   ---------------------------------------------------------------------------*/
        !           890: 
        !           891: int      match             __((char *string, char *pattern));     /* match.c */
        !           892: 
        !           893: int      mapname           __((int create_dirs));               /* mapname.c */
        !           894: 
        !           895: void     UpdateCRC         __((register unsigned char *s, register int len));
        !           896: int      do_string         __((unsigned int len, int option));     /* misc.c */
        !           897: time_t   dos_to_unix_time  __((unsigned ddate, unsigned dtime));   /* misc.c */
        !           898: int      check_for_newer   __((char *filename));                   /* misc.c */
        !           899: int      dateformat        __((void));                             /* misc.c */
        !           900: UWORD    makeword          __((byte *b));                          /* misc.c */
        !           901: ULONG    makelong          __((byte *sig));                        /* misc.c */
        !           902: void     return_VMS        __((int zip_error));                    /* misc.c */
        !           903: 
        !           904: void     envargs           __((int *, char ***, char *));       /* envargs.c */
        !           905: 
        !           906: #ifdef AMIGA
        !           907:    int   utime             __((char *file, time_t timep[]));      /* utime.c */
        !           908: #endif /* AMIGA */
        !           909: 
        !           910: #ifdef ZMEM   /* these MUST be ifdef'd because of conflicts with the std def */
        !           911:    char  *memset           __((register char *buf, register char init,
        !           912:                                register unsigned int len));        /* misc.c */
        !           913:    char  *memcpy           __((register char *dst, register char *src,
        !           914:                                register unsigned int len));        /* misc.c */
        !           915: #endif /* ZMEM */
        !           916: 
        !           917: 
        !           918: 
        !           919: 
        !           920: 
        !           921: /************/
        !           922: /*  Macros  */
        !           923: /************/
        !           924: 
        !           925: #ifndef MAX
        !           926: #  define MAX(a,b)   ((a) > (b) ? (a) : (b))
        !           927: #endif
        !           928: 
        !           929: #ifndef MIN
        !           930: #  define MIN(a,b)   ((a) < (b) ? (a) : (b))
        !           931: #endif
        !           932: 
        !           933: 
        !           934: #define LSEEK(abs_offset) {longint request=(abs_offset)+extra_bytes,\
        !           935:    inbuf_offset=request%INBUFSIZ, bufstart=request-inbuf_offset;\
        !           936:    if(request<0) {fprintf(stderr, SeekMsg, ReportMsg); return(3);}\
        !           937:    else if(bufstart!=cur_zipfile_bufstart)\
        !           938:    {cur_zipfile_bufstart=lseek(zipfd,bufstart,SEEK_SET);\
        !           939:    if((incnt=read(zipfd,(char *)inbuf,INBUFSIZ))<=0) return(51);\
        !           940:    inptr=inbuf+(int)inbuf_offset; incnt-=(int)inbuf_offset;} else\
        !           941:    {incnt+=(inptr-inbuf)-(int)inbuf_offset; inptr=inbuf+(int)inbuf_offset;}}
        !           942: 
        !           943: /*
        !           944:  *  Seek to the block boundary of the block which includes abs_offset,
        !           945:  *  then read block into input buffer and set pointers appropriately.
        !           946:  *  If block is already in the buffer, just set the pointers.  This macro
        !           947:  *  is used by process_end_central_dir (unzip.c) and do_string (misc.c).
        !           948:  *  A slightly modified version is embedded within extract_or_test_files
        !           949:  *  (unzip.c).  ReadByte and readbuf (file_io.c) are compatible.
        !           950:  *
        !           951:  *  macro LSEEK(abs_offset)
        !           952:  *      ULONG   abs_offset;
        !           953:  *  {
        !           954:  *      longint   request = abs_offset + extra_bytes;
        !           955:  *      longint   inbuf_offset = request % INBUFSIZ;
        !           956:  *      longint   bufstart = request - inbuf_offset;
        !           957:  *
        !           958:  *      if (request < 0) {
        !           959:  *          fprintf(stderr, SeekMsg, ReportMsg);
        !           960:  *          return(3);             /-* 3:  severe error in zipfile *-/
        !           961:  *      } else if (bufstart != cur_zipfile_bufstart) {
        !           962:  *          cur_zipfile_bufstart = lseek(zipfd, bufstart, SEEK_SET);
        !           963:  *          if ((incnt = read(zipfd,inbuf,INBUFSIZ)) <= 0)
        !           964:  *              return(51);        /-* 51:  unexpected EOF *-/
        !           965:  *          inptr = inbuf + (int)inbuf_offset;
        !           966:  *          incnt -= (int)inbuf_offset;
        !           967:  *      } else {
        !           968:  *          incnt += (inptr-inbuf) - (int)inbuf_offset;
        !           969:  *          inptr = inbuf + (int)inbuf_offset;
        !           970:  *      }
        !           971:  *  }
        !           972:  *
        !           973:  */
        !           974: 
        !           975: 
        !           976: #define SKIP_(length) if(length&&((error=do_string(length,SKIP))!=0))\
        !           977:   {error_in_archive=error; if(error>1) return error;}
        !           978: 
        !           979: /*
        !           980:  *  Skip a variable-length field, and report any errors.  Used in zipinfo.c
        !           981:  *  and unzip.c in several functions.
        !           982:  *
        !           983:  *  macro SKIP_(length)
        !           984:  *      UWORD   length;
        !           985:  *  {
        !           986:  *      if (length && ((error = do_string(length, SKIP)) != 0)) {
        !           987:  *          error_in_archive = error;   /-* might be warning *-/
        !           988:  *          if (error > 1)              /-* fatal *-/
        !           989:  *              return (error);
        !           990:  *      }
        !           991:  *  }
        !           992:  *
        !           993:  */
        !           994: 
        !           995: 
        !           996: #define OUTB(intc) {*outptr++=(byte)(intc); if (++outcnt==OUTBUFSIZ)\
        !           997:   FlushOutput();}
        !           998: 
        !           999: /*
        !          1000:  *  macro OUTB(intc)
        !          1001:  *  {
        !          1002:  *      *outptr++ = (byte)(intc);
        !          1003:  *      if (++outcnt == OUTBUFSIZ)
        !          1004:  *          FlushOutput();
        !          1005:  *  }
        !          1006:  *
        !          1007:  */
        !          1008: 
        !          1009: 
        !          1010: #define READBIT(nbits,zdest) {if(nbits>bits_left) FillBitBuffer();\
        !          1011:   zdest=(int)((UWORD)bitbuf&mask_bits[nbits]);bitbuf>>=nbits;bits_left-=nbits;}
        !          1012: 
        !          1013: /*
        !          1014:  * macro READBIT(nbits,zdest)
        !          1015:  *  {
        !          1016:  *      if (nbits > bits_left)
        !          1017:  *          FillBitBuffer();
        !          1018:  *      zdest = (int)((UWORD)bitbuf & mask_bits[nbits]);
        !          1019:  *      bitbuf >>= nbits;
        !          1020:  *      bits_left -= nbits;
        !          1021:  *  }
        !          1022:  *
        !          1023:  */
        !          1024: 
        !          1025: 
        !          1026: #define PEEKBIT(nbits) (nbits>bits_left? (FillBitBuffer(),\
        !          1027:   (UWORD)bitbuf & mask_bits[nbits]) : (UWORD)bitbuf & mask_bits[nbits])
        !          1028: 
        !          1029: 
        !          1030: #define NUKE_CRs(buf,len) {register int i,j; for (i=j=0; j<len;\
        !          1031:   (buf)[i++]=(buf)[j++]) if ((buf)[j]=='\r') ++j; len=i;}
        !          1032: 
        !          1033: /*
        !          1034:  *  Remove all the ASCII carriage returns from buffer buf (length len),
        !          1035:  *  shortening as necessary (note that len gets modified in the process,
        !          1036:  *  so it CANNOT be an expression).  This macro is intended to be used
        !          1037:  *  BEFORE A_TO_N(); hence the check for CR instead of '\r'.  NOTE:  The
        !          1038:  *  if-test gets performed one time too many, but it doesn't matter.
        !          1039:  *
        !          1040:  *  macro NUKE_CRs(buf,len)
        !          1041:  *  {
        !          1042:  *      register int   i, j;
        !          1043:  *
        !          1044:  *      for (i = j = 0;  j < len;  (buf)[i++] = (buf)[j++])
        !          1045:  *          if ((buf)[j] == CR)
        !          1046:  *              ++j;
        !          1047:  *      len = i;
        !          1048:  *  }
        !          1049:  *
        !          1050:  */
        !          1051: 
        !          1052: 
        !          1053: #define TOLOWER(str1,str2) {char *ps1,*ps2; ps1=(str1)-1; ps2=(str2);\
        !          1054:   while(*++ps1) *ps2++=(char)(isupper((int)(*ps1))?tolower((int)(*ps1)):*ps1);\
        !          1055:   *ps2='\0';}
        !          1056: 
        !          1057: /*
        !          1058:  *  Copy the zero-terminated string in str1 into str2, converting any
        !          1059:  *  uppercase letters to lowercase as we go.  str2 gets zero-terminated
        !          1060:  *  as well, of course.  str1 and str2 may be the same character array.
        !          1061:  *
        !          1062:  *  macro TOLOWER( str1, str2 )
        !          1063:  *  {
        !          1064:  *      char  *ps1, *ps2;
        !          1065:  *
        !          1066:  *      ps1 = (str1) - 1;
        !          1067:  *      ps2 = (str2);
        !          1068:  *      while (*++ps1)
        !          1069:  *          *ps2++ = (char)(isupper((int)(*ps1))? tolower((int)(*ps1)) : *ps1);
        !          1070:  *      *ps2='\0';
        !          1071:  *  }
        !          1072:  *
        !          1073:  *  NOTES:  This macro makes no assumptions about the characteristics of
        !          1074:  *    the tolower() function or macro (beyond its existence), nor does it
        !          1075:  *    make assumptions about the structure of the character set (i.e., it
        !          1076:  *    should work on EBCDIC machines, too).  The fact that either or both
        !          1077:  *    of isupper() and tolower() may be macros has been taken into account;
        !          1078:  *    watch out for "side effects" (in the C sense) when modifying this
        !          1079:  *    macro.
        !          1080:  */
        !          1081: 
        !          1082: 
        !          1083: #ifndef ascii_to_native
        !          1084: #  define ascii_to_native(c)   (c)
        !          1085: #  define A_TO_N(str1)
        !          1086: #else
        !          1087: #  ifndef NATIVE
        !          1088: #    define NATIVE     "native chars"
        !          1089: #  endif
        !          1090: #  define A_TO_N(str1) {register unsigned char *ps1;\
        !          1091:      for (ps1=str1; *ps1; ps1++) *ps1=ascii_to_native(*ps1);}
        !          1092: #endif
        !          1093: 
        !          1094: /*
        !          1095:  *  Translate the zero-terminated string in str1 from ASCII to the native
        !          1096:  *  character set. The translation is performed in-place and uses the
        !          1097:  *  ascii_to_native macro to translate each character.
        !          1098:  *
        !          1099:  *  macro A_TO_N( str1 )
        !          1100:  *  {
        !          1101:  *      register unsigned char *ps1;
        !          1102:  *
        !          1103:  *      for (ps1 = str1;  *ps1;  ++ps1)
        !          1104:  *          *ps1 = ascii_to_native(*ps1);
        !          1105:  *  }
        !          1106:  *
        !          1107:  *  NOTE:  Using the ascii_to_native macro means that is it the only part of
        !          1108:  *    unzip which knows which translation table (if any) is actually in use
        !          1109:  *    to produce the native character set.  This makes adding new character
        !          1110:  *    set translation tables easy, insofar as all that is needed is an
        !          1111:  *    appropriate ascii_to_native macro definition and the translation
        !          1112:  *    table itself.  Currently, the only non-ASCII native character set
        !          1113:  *    implemented is EBCDIC, but this may not always be so.
        !          1114:  */
        !          1115: 
        !          1116: 
        !          1117: 
        !          1118: 
        !          1119: 
        !          1120: /*************/
        !          1121: /*  Globals  */
        !          1122: /*************/
        !          1123: 
        !          1124:    extern int       aflag;
        !          1125: /* extern int       bflag;   reserved */
        !          1126:    extern int       cflag;
        !          1127:    extern int       fflag;
        !          1128:    extern int       jflag;
        !          1129:    extern int       overwrite_none;
        !          1130:    extern int       overwrite_all;
        !          1131:    extern int       force_flag;
        !          1132:    extern int       quietflg;
        !          1133: #ifdef DOS_OS2
        !          1134:    extern int       sflag;
        !          1135: #endif
        !          1136:    extern int       tflag;
        !          1137:    extern int       uflag;
        !          1138:    extern int       V_flag;
        !          1139: #ifdef VMS
        !          1140:    extern int       secinf;
        !          1141: #endif
        !          1142: #ifdef MACOS
        !          1143:    extern int       hfsflag;
        !          1144: #endif
        !          1145:    extern int       process_all_files;
        !          1146:    extern longint   csize;
        !          1147:    extern longint   ucsize;
        !          1148:    extern char      *fnames[];
        !          1149:    extern char      **fnv;
        !          1150:    extern char      sig[];
        !          1151:    extern char      answerbuf[];
        !          1152:    extern min_info  *pInfo;
        !          1153:    extern char      *key;
        !          1154:    extern ULONG     keys[];
        !          1155: 
        !          1156: #ifdef MACOS
        !          1157:    union work {
        !          1158:      struct {
        !          1159:        short *Prefix_of;        /* (8193 * sizeof(short)) */
        !          1160:        byte *Suffix_of;
        !          1161:        byte *Stack;
        !          1162:      } shrink;
        !          1163:      byte *Slide;
        !          1164:    };
        !          1165: #else
        !          1166:    union work {
        !          1167:      struct {
        !          1168:        short Prefix_of[HSIZE + 2];      /* (8194 * sizeof(short)) */
        !          1169:        byte Suffix_of[HSIZE + 2];       /* also s-f length_nodes (smaller) */
        !          1170:        byte Stack[HSIZE + 2];           /* also s-f distance_nodes (smaller) */
        !          1171:      } shrink;
        !          1172:      byte Slide[WSIZE];
        !          1173:    };
        !          1174: #endif
        !          1175:    extern union work area;
        !          1176: 
        !          1177: #  define prefix_of area.shrink.Prefix_of
        !          1178: #  define suffix_of area.shrink.Suffix_of
        !          1179: #  define stack area.shrink.Stack
        !          1180: #  define slide area.Slide
        !          1181: 
        !          1182:    extern ULONG     crc32val;
        !          1183:    extern UWORD     mask_bits[];
        !          1184: 
        !          1185:    extern byte      *inbuf;
        !          1186:    extern byte      *inptr;
        !          1187:    extern int       incnt;
        !          1188:    extern ULONG     bitbuf;
        !          1189:    extern int       bits_left;
        !          1190:    extern boolean   zipeof;
        !          1191:    extern int       zipfd;
        !          1192: #ifdef MSWIN
        !          1193:    extern char      *zipfn;
        !          1194: #else
        !          1195:    extern char      zipfn[];
        !          1196: #endif
        !          1197:    extern longint   extra_bytes;
        !          1198:    extern longint   cur_zipfile_bufstart;
        !          1199:    extern byte      *extra_field;
        !          1200:    extern char      local_hdr_sig[];
        !          1201:    extern char      central_hdr_sig[];
        !          1202:    extern char      end_central_sig[];
        !          1203:    extern local_file_hdr  lrec;
        !          1204:    extern cdir_file_hdr   crec;
        !          1205:    extern ecdir_rec       ecrec;
        !          1206:    extern struct stat     statbuf;
        !          1207: 
        !          1208:    extern byte      *outbuf;
        !          1209:    extern byte      *outptr;
        !          1210: #ifdef MSWIN
        !          1211:    extern byte __far *outout;
        !          1212:    extern char     *filename;
        !          1213: #else
        !          1214:    extern byte      *outout;
        !          1215:    extern char      filename[];
        !          1216: #endif
        !          1217:    extern longint   outpos;
        !          1218:    extern int       outcnt;
        !          1219:    extern int       outfd;
        !          1220:    extern int       mem_mode;
        !          1221:    extern int       disk_full;
        !          1222: 
        !          1223:    extern char      *EndSigMsg;
        !          1224:    extern char      *CentSigMsg;
        !          1225:    extern char      *SeekMsg;
        !          1226:    extern char      *ReportMsg;
        !          1227: 
        !          1228: #ifdef DECLARE_ERRNO
        !          1229:    extern int       errno;
        !          1230: #endif
        !          1231: 
        !          1232: #ifdef EBCDIC
        !          1233:    extern byte      ebcdic[];
        !          1234: #endif
        !          1235: 
        !          1236: #ifdef MACOS
        !          1237:    extern short     gnVRefNum;
        !          1238:    extern long      glDirID;
        !          1239:    extern OSType    gostCreator;
        !          1240:    extern OSType    gostType;
        !          1241:    extern boolean   fMacZipped;
        !          1242:    extern boolean   macflag;
        !          1243:    extern short     giCursor;
        !          1244:    extern CursHandle rghCursor[];
        !          1245: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.