📄 unzip.h
字号:
#define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */
#define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */
#if defined(MSDOS) || defined(NT) || defined(OS2)
# define DOS_NT_OS2
#endif
#if defined(MSDOS) || defined(OS2)
# define DOS_OS2
#endif
#if defined(MSDOS) || defined(OS2) || defined(ATARI_ST)
# define DOS_OS2_TOS
#endif
#if defined(MSDOS) || defined(ATARI_ST)
# define DOS_TOS
#endif
#if defined(MSDOS) || defined(TOPS20) || defined(VMS)
# define DOS_T20_VMS
#endif
#if defined(TOPS20) || defined(VMS)
# define T20_VMS
#endif
/* clean up with a few defaults */
#ifndef DIR_END
# define DIR_END '/' /* last char before program name (or filename) */
#endif
#ifndef RETURN
# define RETURN return /* only used in main() */
#endif
#ifndef PRINTF
# define PRINTF printf
#endif
#ifndef FPRINTF
# define FPRINTF fprintf
#endif
#ifndef PUTC
# define PUTC putc /* putchar() not used: use PUTC(c,stdout) instead */
#endif
#define DIR_BLKSIZ 64 /* number of directory entries per block
* (should fit in 4096 bytes, usually) */
#ifndef WSIZE
# define WSIZE 0x8000 /* window size--must be a power of two, and */
#endif /* at least 32K for zip's deflate method */
#ifndef INBUFSIZ
# if (defined(MED_MEM) || defined(SMALL_MEM))
# define INBUFSIZ 2048 /* works for MS-DOS small model */
# else
# define INBUFSIZ 8192 /* larger buffers for real OSes */
# endif
#endif
/* GRR: NT defines MSDOS?? */
#if (!defined(MSDOS) && !defined(__IBMC__)) || defined(NT)
# define near
# define far
#endif
#if defined(__GO32__) || defined(__EMX__)
# define near
# define far
#endif
/* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048,
* OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes
* and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5
* chars/line, smaller than estimated 35-70 characters per line for C source
* and normal text. Hence difference is sufficient for most "average" files.
* (Argument scales for larger OUTBUFSIZ.)
*/
#ifdef SMALL_MEM /* i.e., 16-bit OS's: MS-DOS, OS/2 1.x, etc. */
# ifndef Far
# define Far far /* __far only works for MSC 6.00, not 6.0a or Borland */
# endif
# define OUTBUFSIZ INBUFSIZ
# if (lenEOL == 1)
# define RAWBUFSIZ (OUTBUFSIZ>>1)
# else
# define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7))
# endif
# define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ)
#else
# define LoadFarString(x) x
# define LoadFarStringSmall(x) x
# define LoadFarStringSmall2(x) x
# ifdef MED_MEM
# define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */
# define TRANSBUFSIZ 0xFF80
# else
# define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */
# define TRANSBUFSIZ (lenEOL*OUTBUFSIZ)
# define NEW_UNSHRINK
# endif
# define RAWBUFSIZ OUTBUFSIZ
#endif /* ?SMALL_MEM */
#ifndef Far
# define Far /* GRR: should combine this with near/far above */
#endif
#ifndef MAIN
# define MAIN main
#endif
#if (defined(SFX) && !defined(NO_ZIPINFO))
# define NO_ZIPINFO
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
#ifndef PIPE_ERROR
# define PIPE_ERROR (errno == EPIPE)
#endif
/* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
#ifdef VMS
# define FOPR "r","ctx=stm"
# define FOPM "r+","ctx=stm","rfm=fix","mrs=512"
# define FOPW "w","ctx=stm","rfm=fix","mrs=512"
#else /* !VMS */
# if defined(MODERN) || defined(AMIGA)
# define FOPR "rb"
# define FOPM "r+b"
# ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */
# define FOPW "w8"
# else
# define FOPW "wb"
# endif
# else /* !MODERN */
# define FOPR "r"
# define FOPM "r+"
# define FOPW "w"
# endif /* ?MODERN */
#endif /* VMS */
/*
* If <limits.h> exists on most systems, should include that, since it may
* define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
* _POSIX_PATH_MAX.
*/
#ifdef DOS_OS2_TOS
# include <limits.h>
#endif
#ifndef PATH_MAX
# ifdef MAXPATHLEN
# define PATH_MAX MAXPATHLEN /* in <sys/param.h> on some systems */
# else
# ifdef _MAX_PATH
# define PATH_MAX _MAX_PATH
# else
# if FILENAME_MAX > 255
# define PATH_MAX FILENAME_MAX /* used like PATH_MAX on some systems */
# else
# define PATH_MAX 1024
# endif
# endif /* ?_MAX_PATH */
# endif /* ?MAXPATHLEN */
#endif /* !PATH_MAX */
#define FILNAMSIZ (PATH_MAX+1)
#ifdef SHORT_SYMS /* Mark Williams C, ...? */
# define extract_or_test_files xtr_or_tst_files
# define extract_or_test_member xtr_or_tst_member
#endif
#ifdef REALLY_SHORT_SYMS /* TOPS-20 linker: first 6 chars */
# define process_cdir_file_hdr XXpcdfh
# define process_local_file_hdr XXplfh
# define extract_or_test_files XXxotf /* necessary? */
# define extract_or_test_member XXxotm /* necessary? */
# define check_for_newer XXcfn
# define overwrite_all XXoa
# define process_all_files XXpaf
# define extra_field XXef
# define explode_lit8 XXel8
# define explode_lit4 XXel4
# define explode_nolit8 XXnl8
# define explode_nolit4 XXnl4
# define cpdist8 XXcpdist8
# define inflate_codes XXic
# define inflate_stored XXis
# define inflate_fixed XXif
# define inflate_dynamic XXid
# define inflate_block XXib
# define maxcodemax XXmax
#endif
#define ZSUFX ".zip"
#define CENTRAL_HDR_SIG "\113\001\002" /* the infamous "PK" signature */
#define LOCAL_HDR_SIG "\113\003\004" /* bytes, sans "P" (so unzip */
#define END_CENTRAL_SIG "\113\005\006" /* executable not mistaken for */
#define EXTD_LOCAL_SIG "\113\007\010" /* zipfile itself) */
#define SKIP 0 /* choice of activities for do_string() */
#define DISPLAY 1
#define FILENAME 2
#define EXTRA_FIELD 3
#define DOES_NOT_EXIST -1 /* return values for check_for_newer() */
#define EXISTS_AND_OLDER 0
#define EXISTS_AND_NEWER 1
#define ROOT 0 /* checkdir() extract-to path: called once */
#define INIT 1 /* allocate buildpath: called once per member */
#define APPEND_DIR 2 /* append a dir comp.: many times per member */
#define APPEND_NAME 3 /* append actual filename: once per member */
#define GETPATH 4 /* retrieve the complete path and free it */
#define END 5 /* free root path prior to exiting program */
/* version_made_by codes (central dir): make sure these */
/* are not defined on their respective systems!! */
#define FS_FAT_ 0 /* filesystem used by MS-DOS, OS/2, NT */
#define AMIGA_ 1
#define VMS_ 2
#define UNIX_ 3
#define VM_CMS_ 4
#define ATARI_ 5 /* what if it's a minix filesystem? [cjh] */
#define FS_HPFS_ 6 /* filesystem used by OS/2, NT */
#define MAC_ 7
#define Z_SYSTEM_ 8
#define CPM_ 9
#define TOPS20_ 10
#define FS_NTFS_ 11 /* filesystem used by Windows NT */
#define QDOS_MAYBE_ 12 /* a bit premature, but somebody once started */
#define ACORN_ 13 /* Archimedes Acorn RISCOS */
#define NUM_HOSTS 14 /* index of last system + 1 */
#define STORED 0 /* compression methods */
#define SHRUNK 1
#define REDUCED1 2
#define REDUCED2 3
#define REDUCED3 4
#define REDUCED4 5
#define IMPLODED 6
#define TOKENIZED 7
#define DEFLATED 8
#define NUM_METHODS 9 /* index of last method + 1 */
/* don't forget to update list_files() appropriately if NUM_METHODS changes */
#define PK_OK 0 /* no error */
#define PK_COOL 0 /* no error */
#define PK_GNARLY 0 /* no error */
#define PK_WARN 1 /* warning error */
#define PK_ERR 2 /* error in zipfile */
#define PK_BADERR 3 /* severe error in zipfile */
#define PK_MEM 4 /* insufficient memory */
#define PK_MEM2 5 /* insufficient memory */
#define PK_MEM3 6 /* insufficient memory */
#define PK_MEM4 7 /* insufficient memory */
#define PK_MEM5 8 /* insufficient memory */
#define PK_NOZIP 9 /* zipfile not found */
#define PK_PARAM 10 /* bad or illegal parameters specified */
#define PK_FIND 11 /* no files found */
#define PK_DISK 50 /* disk full */
#define PK_EOF 51 /* unexpected EOF */
#define IZ_DIR 76 /* potential zipfile is a directory */
#define IZ_CREATED_DIR 77 /* directory created: set time and permissions */
#define IZ_VOL_LABEL 78 /* volume label, but can't set on hard disk */
#define DF_MDY 0 /* date format 10/26/91 (USA only) */
#define DF_DMY 1 /* date format 26/10/91 (most of the world) */
#define DF_YMD 2 /* date format 91/10/26 (a few countries) */
/*---------------------------------------------------------------------------
True sizes of the various headers, as defined by PKWARE--so it is not
likely that these will ever change. But if they do, make sure both these
defines AND the typedefs below get updated accordingly.
---------------------------------------------------------------------------*/
#define LREC_SIZE 26 /* lengths of local file headers, central */
#define CREC_SIZE 42 /* directory headers, and the end-of- */
#define ECREC_SIZE 18 /* central-dir record, respectively */
#define MAX_BITS 13 /* used in old unshrink() */
#define HSIZE (1 << MAX_BITS) /* size of global work area */
#define LF 10 /* '\n' on ASCII machines; must be 10 due to EBCDIC */
#define CR 13 /* '\r' on ASCII machines; must be 13 due to EBCDIC */
#define CTRLZ 26 /* DOS & OS/2 EOF marker (used in file_io.c, vms.c) */
#ifdef EBCDIC
# define native(c) ebcdic[(c)]
# define NATIVE "EBCDIC"
#endif
#ifdef MPW
# define FFLUSH(f) PUTC('\n',f)
#else
# define FFLUSH fflush
#endif
#ifdef ZMEM /* GRR: THIS IS AN EXPERIMENT... (seems to work) */
# undef ZMEM
# define memcpy(dest,src,len) bcopy(src,dest,len)
# define memzero bzero
#else
# define memzero(dest,len) memset(dest,0,len)
#endif
#ifdef VMS
# define ENV_UNZIP "UNZIP_OPTS" /* name of environment variable */
# define ENV_ZIPINFO "ZIPINFO_OPTS"
#else /* !VMS */
# define ENV_UNZIP "UNZIP"
# define ENV_ZIPINFO "ZIPINFO"
#endif /* ?VMS */
#define ENV_UNZIP2 "UNZIPOPT" /* alternate name for zip compat. */
#define ENV_ZIPINFO2 "ZIPINFOOPT"
#if !defined(QQ) && !defined(NOQQ)
# define QQ
#endif
#ifdef QQ /* Newtware version: no file */
# define QCOND (!qflag) /* comments with -vq or -vqq */
#else /* Bill Davidsen version: no way to */
# define QCOND (which_hdr) /* kill file comments when listing */
#endif
#ifdef OLD_QQ
# define QCOND2 (qflag < 2)
#else
# define QCOND2 (!qflag)
#endif
#ifndef TRUE
# define TRUE 1 /* sort of obvious */
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef SEEK_SET
# define SEEK_SET 0
# define SEEK_CUR 1
# define SEEK_END 2
#endif
#if (defined(UNIX) && defined(S_IFLNK) && !defined(MTS))
# define SYMLINKS
# ifndef S_ISLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# endif
#endif /* UNIX && S_IFLNK && !MTS */
#ifndef S_ISDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#ifndef IS_VOLID
# define IS_VOLID(m) ((m) & 0x08)
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -