📄 unzip.h
字号:
# 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_ 12? */
#define NUM_HOSTS 12 /* 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 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
#define ENV_UNZIP "UNZIP"
#define ENV_ZIPINFO "ZIPINFO"
#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
#define SIGNATURE_SIZE 4
/**************/
/* Typedefs */
/**************/
typedef char bule;
typedef unsigned char uch; /* code assumes unsigned bytes; these type- */
typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */
typedef unsigned long ulg; /* predefined on some systems) & match zip */
typedef struct min_info {
long offset;
ulg compr_size; /* compressed size (needed if extended header) */
ulg crc; /* crc (needed if extended header) */
int hostnum;
unsigned file_attr; /* local flavor, as used by creat(), chmod()... */
unsigned encrypted : 1; /* file encrypted: decrypt before uncompressing */
unsigned ExtLocHdr : 1; /* use time instead of CRC for decrypt check */
unsigned textfile : 1; /* file is text (according to zip) */
unsigned textmode : 1; /* file is to be extracted as text */
unsigned lcflag : 1; /* convert filename to lowercase */
unsigned vollabel : 1; /* "file" is an MS-DOS volume (disk) label */
} min_info;
typedef struct VMStimbuf {
char *revdate; /* (both correspond to Unix modtime/st_mtime) */
char *credate;
} VMStimbuf;
/*---------------------------------------------------------------------------
Zipfile work area declarations.
---------------------------------------------------------------------------*/
#ifdef MALLOC_WORK
union work {
struct {
short *Prefix_of; /* (8193 * sizeof(short)) */
uch *Suffix_of;
uch *Stack;
} shrink; /* unshrink() */
uch *Slide; /* explode(), inflate(), unreduce() */
};
#else /* !MALLOC_WORK */
union work {
struct {
#ifdef HSIZE2 /* needed to avoid errors on some machines? */
short Prefix_of[HSIZE + 2]; /* (8194 * sizeof(short)) */
uch Suffix_of[HSIZE + 2]; /* also s-f length_nodes (smaller) */
uch Stack[HSIZE + 2]; /* also s-f distance_nodes (smaller) */
#else /* !HSIZE2 */
short Prefix_of[HSIZE]; /* (8192 * sizeof(short)) */
uch Suffix_of[HSIZE]; /* also s-f length_nodes (smaller) */
uch Stack[HSIZE]; /* also s-f distance_nodes (smaller) */
#endif /* ?HSIZE2 */
} shrink;
uch Slide[WSIZE];
};
#endif /* ?MALLOC_WORK */
//#define prefix_of area.shrink.Prefix_of
//#define suffix_of area.shrink.Suffix_of
//#define stack area.shrink.Stack
//#define slide area.Slide
/*---------------------------------------------------------------------------
Zipfile layout declarations. If these headers ever change, make sure the
xxREC_SIZE defines (above) change with them!
---------------------------------------------------------------------------*/
typedef uch local_byte_hdr[ LREC_SIZE ];
# define L_VERSION_NEEDED_TO_EXTRACT_0 0
# define L_VERSION_NEEDED_TO_EXTRACT_1 1
# define L_GENERAL_PURPOSE_BIT_FLAG 2
# define L_COMPRESSION_METHOD 4
# define L_LAST_MOD_FILE_TIME 6
# define L_LAST_MOD_FILE_DATE 8
# define L_CRC32 10
# define L_COMPRESSED_SIZE 14
# define L_UNCOMPRESSED_SIZE 18
# define L_FILENAME_LENGTH 22
# define L_EXTRA_FIELD_LENGTH 24
typedef uch cdir_byte_hdr[ CREC_SIZE ];
# define C_VERSION_MADE_BY_0 0
# define C_VERSION_MADE_BY_1 1
# define C_VERSION_NEEDED_TO_EXTRACT_0 2
# define C_VERSION_NEEDED_TO_EXTRACT_1 3
# define C_GENERAL_PURPOSE_BIT_FLAG 4
# define C_COMPRESSION_METHOD 6
# define C_LAST_MOD_FILE_TIME 8
# define C_LAST_MOD_FILE_DATE 10
# define C_CRC32 12
# define C_COMPRESSED_SIZE 16
# define C_UNCOMPRESSED_SIZE 20
# define C_FILENAME_LENGTH 24
# define C_EXTRA_FIELD_LENGTH 26
# define C_FILE_COMMENT_LENGTH 28
# define C_DISK_NUMBER_START 30
# define C_INTERNAL_FILE_ATTRIBUTES 32
# define C_EXTERNAL_FILE_ATTRIBUTES 34
# define C_RELATIVE_OFFSET_LOCAL_HEADER 38
typedef uch ec_byte_rec[ ECREC_SIZE+4 ];
/* define SIGNATURE 0 space-holder only */
# define NUMBER_THIS_DISK 4
# define NUM_DISK_WITH_START_CENTRAL_DIR 6
# define NUM_ENTRIES_CENTRL_DIR_THS_DISK 8
# define TOTAL_ENTRIES_CENTRAL_DIR 10
# define SIZE_CENTRAL_DIRECTORY 12
# define OFFSET_START_CENTRAL_DIRECTORY 16
# define ZIPFILE_COMMENT_LENGTH 20
typedef struct local_file_header { /* LOCAL */
uch version_needed_to_extract[2];
ush general_purpose_bit_flag;
ush compression_method;
ush last_mod_file_time;
ush last_mod_file_date;
ulg crc32;
ulg csize;
ulg ucsize;
ush filename_length;
ush extra_field_length;
} local_file_hdr;
typedef struct central_directory_file_header { /* CENTRAL */
uch version_made_by[2];
uch version_needed_to_extract[2];
ush general_purpose_bit_flag;
ush compression_method;
ush last_mod_file_time;
ush last_mod_file_date;
ulg crc32;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -