📄 unzip.h
字号:
void inflate __( (void) ); /* inflate.c *//* */void unImplode __( (void) ); /* unimplod.c *//* * static void ReadLengths __( (sf_tree *tree) ); * static void SortLengths __( (sf_tree *tree) ); * static void GenerateTrees __( (sf_tree *tree, sf_node *nodes) ); * static void LoadTree __( (sf_tree *tree, int treesize, sf_node *nodes) ); * static void LoadTrees __( (void) ); * static void ReadTree __( (register sf_node *nodes, int *dest) ); */void unReduce __( (void) ); /* unreduce.c *//* * static void LoadFollowers __( (void) ); */void unShrink __( (void) ); /* unshrink.c *//* * static void partial_clear __( (void) ); *//*--------------------------------------------------------------------------- Functions in match.c, mapname.c, misc.c, etc.: ---------------------------------------------------------------------------*/int match __( (char *string, char *pattern) ); /* match.c *//* * static BOOLEAN do_list __( (register char *string, char *pattern) ); * static void list_parse __( (char **patp, char *lowp, char *highp) ); * static char nextch __( (char **patp) ); */int mapname __( (int create_dirs) ); /* mapname.c */void UpdateCRC __( (register unsigned char *s, register int len) );int do_string __( (unsigned int len, int option) ); /* misc.c */time_t dos_to_unix_time __( (unsigned ddate, unsigned dtime) ); /* misc.c */int check_for_newer __( (char *filename) ); /* misc.c */int dateformat __( (void) ); /* misc.c */UWORD makeword __( (byte *b) ); /* misc.c */ULONG makelong __( (byte *sig) ); /* misc.c */void return_VMS __( (int zip_error) ); /* misc.c */#ifdef ZMEM char *memset __( (register char *buf, register char init, register unsigned int len) ); char *memcpy __( (register char *dst, register char *src, register unsigned int len) );#endif /* These guys MUST be ifdef'd because their definition */ /* conflicts with the standard one. Others (makeword, */ /* makelong, return_VMS) don't matter. */int VMSmunch __( (char *filename, int action, char *extra) );#ifdef AMIGA int utime __( (char *file, time_t timep[]) );#endif/************//* Macros *//************/#ifndef min /* MSC defines this in stdlib.h */# 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+inbuf_offset; incnt-=inbuf_offset;}\ else {incnt+=(inptr-inbuf)-inbuf_offset; inptr=inbuf+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) * longint 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 + inbuf_offset; * incnt -= inbuf_offset; * } else { * incnt += (inptr-inbuf) - inbuf_offset; * inptr = inbuf + 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 OUTB(intc) {*outptr++=intc; if (++outcnt==OUTBUFSIZ) FlushOutput();}/* * macro OUTB(intc) * { * *outptr++ = intc; * if (++outcnt == OUTBUFSIZ) * FlushOutput(); * } * */#define READBIT(nbits,zdest) {if(nbits>bits_left) FillBitBuffer();\ zdest=(int)(bitbuf&mask_bits[nbits]); bitbuf>>=nbits; bits_left-=nbits;}/* * macro READBIT(nbits,zdest) * { * if (nbits > bits_left) * FillBitBuffer(); * zdest = (int)(bitbuf & mask_bits[nbits]); * bitbuf >>= nbits; * bits_left -= nbits; * } * */#define PEEKBIT(nbits) ( nbits > bits_left ? (FillBitBuffer(), bitbuf & mask_bits[nbits]) : 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++=(isupper(*ps1))?tolower(*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 ) * { * register char *ps1, *ps2; * * ps1 = (str1) - 1; * ps2 = (str2); * while ( *++ps1 ) * *ps2++ = (isupper(*ps1)) ? tolower(*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)); }/* * 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. */#endif/*************//* Globals *//*************/ extern int aflag;/* extern int bflag; reserved */ extern int cflag; extern int fflag; extern int jflag; extern int overwrite_none; extern int overwrite_all; extern int force_flag; extern int quietflg;#ifdef DOS_OS2 extern int sflag;#endif extern int tflag; extern int uflag; extern int V_flag;#ifdef VMS extern int secinf;#endif#ifdef MACOS extern int hfsflag;#endif extern int process_all_files; extern longint csize; extern longint ucsize; extern char *fnames[]; extern char **fnv; extern char sig[]; extern char answerbuf[]; extern min_info *pInfo; extern char *key; extern ULONG keys[]; extern short prefix_of[];#ifdef MACOS extern byte *suffix_of; extern byte *stack;#else extern byte suffix_of[]; extern byte stack[];#endif extern ULONG crc32val; extern ULONG mask_bits[]; extern byte *inbuf; extern byte *inptr; extern int incnt; extern ULONG bitbuf; extern int bits_left; extern boolean zipeof; extern int zipfd; extern char zipfn[]; extern longint extra_bytes; extern longint cur_zipfile_bufstart; extern byte *extra_field; extern char local_hdr_sig[]; extern char central_hdr_sig[]; extern char end_central_sig[]; extern local_file_hdr lrec; extern cdir_file_hdr crec; extern ecdir_rec ecrec; extern struct stat statbuf; extern byte *outbuf; extern byte *outptr; extern byte *outout; extern longint outpos; extern int outcnt; extern int outfd; extern int disk_full; extern char filename[]; extern char *EndSigMsg; extern char *CentSigMsg; extern char *SeekMsg; extern char *ReportMsg;#ifdef DECLARE_ERRNO extern int errno;#endif#ifdef EBCDIC extern byte ebcdic[];#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -