📄 unz.h
字号:
/*--------------------------------------------------------------------------- And some Mac stuff for good measure: ---------------------------------------------------------------------------*/#ifdef THINK_C# define MACOS# ifndef __STDC__ /* if Think C hasn't defined __STDC__ ... */# define __STDC__ 1 /* make sure it's defined: it needs it */# else /* __STDC__ defined */# if !__STDC__ /* sometimes __STDC__ is defined as 0; */# undef __STDC__ /* it needs to be 1 or required header */# define __STDC__ 1 /* files are not properly included. */# endif /* !__STDC__ */# endif /* ?defined(__STDC__) */#endif /* THINK_C */#ifdef MPW# define MACOS# include <Errors.h># include <Files.h># include <Memory.h># include <Quickdraw.h># include <ToolUtils.h># define CtoPstr c2pstr# define PtoCstr p2cstr# ifdef CR# undef CR# endif#endif /* MPW */#ifdef MACOS# define open(x,y) macopen(x,y, gnVRefNum, glDirID)# define close macclose# define read macread# define write macwrite# define lseek maclseek# define creat(x,y) maccreat(x, gnVRefNum, glDirID, gostCreator, gostType)# define stat(x,y) macstat(x,y,gnVRefNum, glDirID)# ifndef isascii# define isascii(c) ((unsigned char)(c) <= 0x3F)# endif# include "macstat.h"typedef struct _ZipExtraHdr { unsigned short header; /* 2 bytes */ unsigned short data; /* 2 bytes */} ZIP_EXTRA_HEADER;typedef struct _MacInfoMin { unsigned short header; /* 2 bytes */ unsigned short data; /* 2 bytes */ unsigned long signature; /* 4 bytes */ FInfo finfo; /* 16 bytes */ unsigned long lCrDat; /* 4 bytes */ unsigned long lMdDat; /* 4 bytes */ unsigned long flags ; /* 4 bytes */ unsigned long lDirID; /* 4 bytes */ /*------------*/} MACINFOMIN; /* = 40 bytes for size of data */typedef struct _MacInfo { unsigned short header; /* 2 bytes */ unsigned short data; /* 2 bytes */ unsigned long signature; /* 4 bytes */ FInfo finfo; /* 16 bytes */ unsigned long lCrDat; /* 4 bytes */ unsigned long lMdDat; /* 4 bytes */ unsigned long flags ; /* 4 bytes */ unsigned long lDirID; /* 4 bytes */ char rguchVolName[28]; /* 28 bytes */ /*------------*/} MACINFO; /* = 68 bytes for size of data */#endif /* MACOS *//*--------------------------------------------------------------------------- And finally, some random extra stuff: ---------------------------------------------------------------------------*/#ifdef MINIX# include <stdio.h>#endif#ifdef SHORT_NAMES /* Mark Williams C, ...? */# define extract_or_test_files xtr_or_tst_files# define extract_or_test_member xtr_or_tst_member#endif#ifdef MTS# include <unix.h> /* Some important non-ANSI routines */# define mkdir(s,n) (-1) /* No "make directory" capability */# define EBCDIC /* Set EBCDIC conversion on */#endif/*************//* Defines *//*************/#ifndef WSIZE# define WSIZE 0x8000 /* window size--must be a power of two, and */#endif /* !WSIZE */ /* at least 32K for zip's deflate method */#define DIR_BLKSIZ 64 /* number of directory entries per block * (should fit in 4096 bytes, usually) */#ifndef INBUFSIZ# define INBUFSIZ 2048 /* works for MS-DOS small model */#endif /* !INBUFSIZ *//* * 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# include <limits.h>#endif /* DOS_OS2 */#ifdef _MAX_PATH# define FILNAMSIZ (_MAX_PATH)#else /* !_MAX_PATH */# define FILNAMSIZ 1025#endif /* ?_MAX_PATH */#ifndef PATH_MAX# ifdef MAXPATHLEN /* defined in <sys/param.h> some systems */# define PATH_MAX MAXPATHLEN# else# if FILENAME_MAX > 255 /* used like PATH_MAX on some systems */# define PATH_MAX FILENAME_MAX# else# define PATH_MAX (FILNAMSIZ - 1)# endif# endif /* ?MAXPATHLEN */#endif /* !PATH_MAX */#define OUTBUFSIZ INBUFSIZ#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 DOS_OS2_FAT_ 0 /* version_made_by codes (central dir) */#define AMIGA_ 1#define VMS_ 2 /* make sure these are not defined on */#define UNIX_ 3 /* the respective systems!! (like, for */#define VM_CMS_ 4 /* instance, "VMS", or "UNIX": CFLAGS = */#define ATARI_ 5 /* -O -DUNIX) */#define OS2_HPFS_ 6#define MAC_ 7#define Z_SYSTEM_ 8#define CPM_ 9/* #define TOPS20_ 10? (TOPS20_ is to be defined in PKZIP 2.0...) */#define NUM_HOSTS 10 /* 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 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) */#define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */#define VMS_VERSION 42 /* if OS-needed-to-extract is VMS: can do *//*--------------------------------------------------------------------------- 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 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 ascii_to_native(c) ebcdic[(c)]# define NATIVE "EBCDIC"#endif#if MPW# define FFLUSH putc('\n',stderr);#else /* !MPW */# define FFLUSH fflush(stderr);#endif /* ?MPW */#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 */#ifdef CRYPT# define PWLEN 80# define DECRYPT(b) (update_keys(t=((b)&0xff)^decrypt_byte()),t)#endif /* CRYPT */#ifdef QQ /* Newtware version */# define QCOND (!quietflg) /* for no file comments with -vq or -vqq */#else /* (original) Bill Davidsen version */# define QCOND (which_hdr) /* no way to kill file comments with -v, -l */#endif#ifndef TRUE# define TRUE 1 /* sort of obvious */#endif#ifndef FALSE# define FALSE 0#endif#ifndef SEEK_SET /* These should all be declared in stdio.h! But */# define SEEK_SET 0 /* since they're not (in many cases), do so here. */# define SEEK_CUR 1# define SEEK_END 2#endif#ifndef S_IRUSR# define S_IRWXU 00700 /* read, write, execute: owner */# define S_IRUSR 00400 /* read permission: owner */# define S_IWUSR 00200 /* write permission: owner */# define S_IXUSR 00100 /* execute permission: owner */# define S_IRWXG 00070 /* read, write, execute: group */# define S_IRGRP 00040 /* read permission: group */# define S_IWGRP 00020 /* write permission: group */# define S_IXGRP 00010 /* execute permission: group */# define S_IRWXO 00007 /* read, write, execute: other */# define S_IROTH 00004 /* read permission: other */# define S_IWOTH 00002 /* write permission: other */# define S_IXOTH 00001 /* execute permission: other */#endif /* !S_IRUSR */#ifdef ZIPINFO /* these are individually checked because SysV doesn't */# ifndef S_IFBLK /* have some of them, Microsoft C others, etc. */# define S_IFBLK 0060000 /* block special */# endif# ifndef S_IFIFO /* in Borland C, not MSC */# define S_IFIFO 0010000 /* fifo */# endif# ifndef S_IFLNK /* in BSD, not SysV */# define S_IFLNK 0120000 /* symbolic link */# endif# ifndef S_IFSOCK /* in BSD, not SysV */# define S_IFSOCK 0140000 /* socket */# endif# ifndef S_ISUID# define S_ISUID 04000 /* set user id on execution */# endif# ifndef S_ISGID# define S_ISGID 02000 /* set group id on execution */# endif# ifndef S_ISVTX# define S_ISVTX 01000 /* directory permissions control */# endif# ifndef S_ENFMT# define S_ENFMT S_ISGID /* record locking enforcement flag */# endif#endif /* ZIPINFO *//**************//* Typedefs *//**************/#ifndef _BULL_SOURCE /* Bull has it defined somewhere already */ typedef unsigned char byte; /* code assumes UNSIGNED bytes */#endif /* !_BULL_SOURCE */typedef char boolean;typedef long longint;typedef unsigned short UWORD;typedef unsigned long ULONG;typedef unsigned char uch;typedef unsigned short ush;typedef unsigned long ulg;typedef struct min_info { unsigned unix_attr; unsigned dos_attr; int hostnum; longint offset; ULONG compr_size; /* compressed size (needed if extended header) */ ULONG crc; /* crc (needed if extended header) */ unsigned encrypted : 1; /* file encrypted: decrypt before uncompressing */ unsigned ExtLocHdr : 1; /* use time instead of CRC for decrypt check */ unsigned text : 1; /* file is text or binary */ unsigned lcflag : 1; /* convert filename to lowercase */} min_info;typedef struct VMStimbuf { char *revdate; /* (both correspond to Unix modtime/st_mtime) */ char *credate;} VMStimbuf;/*--------------------------------------------------------------------------- Zipfile layout declarations. If these headers ever change, make sure the xxREC_SIZE defines (above) change with them! ---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -