📄 unz.h
字号:
typedef byte 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 byte 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 byte 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 */ byte version_needed_to_extract[2]; UWORD general_purpose_bit_flag; UWORD compression_method; UWORD last_mod_file_time; UWORD last_mod_file_date; ULONG crc32; ULONG compressed_size; ULONG uncompressed_size; UWORD filename_length; UWORD extra_field_length; } local_file_hdr; typedef struct central_directory_file_header { /* CENTRAL */ byte version_made_by[2]; byte version_needed_to_extract[2]; UWORD general_purpose_bit_flag; UWORD compression_method; UWORD last_mod_file_time; UWORD last_mod_file_date; ULONG crc32; ULONG compressed_size; ULONG uncompressed_size; UWORD filename_length; UWORD extra_field_length; UWORD file_comment_length; UWORD disk_number_start; UWORD internal_file_attributes; ULONG external_file_attributes; ULONG relative_offset_local_header; } cdir_file_hdr; typedef struct end_central_dir_record { /* END CENTRAL */ UWORD number_this_disk; UWORD num_disk_with_start_central_dir; UWORD num_entries_centrl_dir_ths_disk; UWORD total_entries_central_dir; ULONG size_central_directory; ULONG offset_start_central_directory; UWORD zipfile_comment_length; } ecdir_rec;/*************************//* Function Prototypes *//*************************/#ifndef __# define __ OF#endif/*--------------------------------------------------------------------------- Decompression functions: ---------------------------------------------------------------------------*/int explode ();void unReduce ();void unShrink ();/*--------------------------------------------------------------------------- Functions in file_io.c and crypt.c: ---------------------------------------------------------------------------*/int FillBitBuffer ();int ReadByte __((UWORD *x)); /* file_io.c *//************//* Macros *//************/#ifndef MAX# define MAX(a,b) ((a) > (b) ? (a) : (b))#endif#ifndef MIN# define MIN(a,b) ((a) < (b) ? (a) : (b))#endif#define LSEEK(abs_offset) {longint request=(abs_offset)+extra_bytes,\ inbuf_offset=request%INBUFSIZ, bufstart=request-inbuf_offset;\ if(request<0) {fprintf(stderr, SeekMsg, ReportMsg); return(3);}\ else if(bufstart!=cur_zipfile_bufstart)\ {cur_zipfile_bufstart=lseek(zipfd,bufstart,SEEK_SET);\ if((incnt=read(zipfd,(char *)inbuf,INBUFSIZ))<=0) return(51);\ inptr=inbuf+(int)inbuf_offset; incnt-=(int)inbuf_offset;} else\ {incnt+=(inptr-inbuf)-(int)inbuf_offset; inptr=inbuf+(int)inbuf_offset;}}/* * Seek to the block boundary of the block which includes abs_offset, * then read block into input buffer and set pointers appropriately. * If block is already in the buffer, just set the pointers. This macro * is used by process_end_central_dir (unzip.c) and do_string (misc.c). * A slightly modified version is embedded within extract_or_test_files * (unzip.c). ReadByte and readbuf (file_io.c) are compatible. * * macro LSEEK(abs_offset) * ULONG abs_offset; * { * longint request = abs_offset + extra_bytes; * longint inbuf_offset = request % INBUFSIZ; * longint bufstart = request - inbuf_offset; * * if (request < 0) { * fprintf(stderr, SeekMsg, ReportMsg); * return(3); /-* 3: severe error in zipfile *-/ * } else if (bufstart != cur_zipfile_bufstart) { * cur_zipfile_bufstart = lseek(zipfd, bufstart, SEEK_SET); * if ((incnt = read(zipfd,inbuf,INBUFSIZ)) <= 0) * return(51); /-* 51: unexpected EOF *-/ * inptr = inbuf + (int)inbuf_offset; * incnt -= (int)inbuf_offset; * } else { * incnt += (inptr-inbuf) - (int)inbuf_offset; * inptr = inbuf + (int)inbuf_offset; * } * } * */#define SKIP_(length) if(length&&((error=do_string(length,SKIP))!=0))\ {error_in_archive=error; if(error>1) return error;}/* * Skip a variable-length field, and report any errors. Used in zipinfo.c * and unzip.c in several functions. * * macro SKIP_(length) * UWORD length; * { * if (length && ((error = do_string(length, SKIP)) != 0)) { * error_in_archive = error; /-* might be warning *-/ * if (error > 1) /-* fatal *-/ * return (error); * } * } * */#define READBIT(nbits,zdest) {if(nbits>bits_left) FillBitBuffer();\ zdest=(int)((UWORD)bitbuf&mask_bits[nbits]);bitbuf>>=nbits;bits_left-=nbits;}/* * macro READBIT(nbits,zdest) * { * if (nbits > bits_left) * FillBitBuffer(); * zdest = (int)((UWORD)bitbuf & mask_bits[nbits]); * bitbuf >>= nbits; * bits_left -= nbits; * } * */#define PEEKBIT(nbits) (nbits>bits_left? (FillBitBuffer(),\ (UWORD)bitbuf & mask_bits[nbits]) : (UWORD)bitbuf & mask_bits[nbits])#define NUKE_CRs(buf,len) {register int i,j; for (i=j=0; j<len;\ (buf)[i++]=(buf)[j++]) if ((buf)[j]=='\r') ++j; len=i;}/* * Remove all the ASCII carriage returns from buffer buf (length len), * shortening as necessary (note that len gets modified in the process, * so it CANNOT be an expression). This macro is intended to be used * BEFORE A_TO_N(); hence the check for CR instead of '\r'. NOTE: The * if-test gets performed one time too many, but it doesn't matter. * * macro NUKE_CRs(buf,len) * { * register int i, j; * * for (i = j = 0; j < len; (buf)[i++] = (buf)[j++]) * if ((buf)[j] == CR) * ++j; * len = i; * } * */#define TOLOWER(str1,str2) {char *ps1,*ps2; ps1=(str1)-1; ps2=(str2);\ while(*++ps1) *ps2++=(char)(isupper((int)(*ps1))?tolower((int)(*ps1)):*ps1);\ *ps2='\0';}/* * Copy the zero-terminated string in str1 into str2, converting any * uppercase letters to lowercase as we go. str2 gets zero-terminated * as well, of course. str1 and str2 may be the same character array. * * macro TOLOWER( str1, str2 ) * { * char *ps1, *ps2; * * ps1 = (str1) - 1; * ps2 = (str2); * while (*++ps1) * *ps2++ = (char)(isupper((int)(*ps1))? tolower((int)(*ps1)) : *ps1); * *ps2='\0'; * } * * NOTES: This macro makes no assumptions about the characteristics of * the tolower() function or macro (beyond its existence), nor does it * make assumptions about the structure of the character set (i.e., it * should work on EBCDIC machines, too). The fact that either or both * of isupper() and tolower() may be macros has been taken into account; * watch out for "side effects" (in the C sense) when modifying this * macro. */#ifndef ascii_to_native# define ascii_to_native(c) (c)# define A_TO_N(str1)#else# ifndef NATIVE# define NATIVE "native chars"# endif# define A_TO_N(str1) {register unsigned char *ps1;\ for (ps1=str1; *ps1; ps1++) *ps1=ascii_to_native(*ps1);}#endif/* * Translate the zero-terminated string in str1 from ASCII to the native * character set. The translation is performed in-place and uses the * ascii_to_native macro to translate each character. * * macro A_TO_N( str1 ) * { * register unsigned char *ps1; * * for (ps1 = str1; *ps1; ++ps1) * *ps1 = ascii_to_native(*ps1); * } * * NOTE: Using the ascii_to_native macro means that is it the only part of * unzip which knows which translation table (if any) is actually in use * to produce the native character set. This makes adding new character * set translation tables easy, insofar as all that is needed is an * appropriate ascii_to_native macro definition and the translation * table itself. Currently, the only non-ASCII native character set * implemented is EBCDIC, but this may not always be so. *//*************//* Globals *//*************/#ifdef MACOS union work { struct { short *Prefix_of; /* (8193 * sizeof(short)) */ byte *Suffix_of; byte *Stack; } shrink; byte *Slide; };#else union work { struct { short Prefix_of[HSIZE + 2]; /* (8194 * sizeof(short)) */ byte Suffix_of[HSIZE + 2]; /* also s-f length_nodes (smaller) */ byte Stack[HSIZE + 2]; /* also s-f distance_nodes (smaller) */ } shrink; byte Slide[WSIZE]; };#endif extern union work area;# define prefix_of area.shrink.Prefix_of# define suffix_of area.shrink.Suffix_of# define stack area.shrink.Stack# define slide area.Slide extern ULONG crc32val; extern UWORD mask_bits[]; extern int bits_left; extern ULONG bitbuf; extern boolean zipeof;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -