📄 unzip.h
字号:
int decrypt_byte __((void)); /* crypt.c */
void update_keys __((int)); /* crypt.c */
void init_keys __((char *)); /* crypt.c */
/*---------------------------------------------------------------------------
Macintosh file_io functions:
---------------------------------------------------------------------------*/
#ifdef MACOS
/* static int IsHFSDisk __((int)); */
void macfstest __((int));
int macmkdir __((char *, short, long));
void ResolveMacVol __((short, short *, long *, StringPtr));
short macopen __((char *, short, short, long));
short maccreat __((char *, short, long, OSType, OSType));
short macread __((short, char *, unsigned));
short macwrite __((short, char *, unsigned));
short macclose __((short));
long maclseek __((short, long, short));
#endif
/*---------------------------------------------------------------------------
OS/2 file_io functions:
---------------------------------------------------------------------------*/
void ChangeNameForFAT __((char *name)); /* os2unzip.c */
int IsFileNameValid __((char *name)); /* os2unzip.c */
int GetCountryInfo __((void)); /* os2unzip.c */
long GetFileTime __((char *name)); /* os2unzip.c */
void SetPathInfo __((char *path, UWORD moddate, UWORD modtime, int flags));
int SetLongNameEA __((char *name, char *longname)); /* os2unzip.c */
int IsEA __((void *extra_field)); /* os2unzip.c */
ULONG SizeOfEAs __((void *extra_field)); /* os2unzip.c */
void SetEAs __((char *path, void *eablock)); /* os2unzip.c */
int IsUpperNLS __((int nChr)); /* os2unzip.c */
int ToLowerNLS __((int nChr)); /* os2unzip.c */
/*---------------------------------------------------------------------------
VMS file_io functions:
---------------------------------------------------------------------------*/
int check_format __((void)); /* vms.c */
int find_vms_attrs __((void)); /* vms.c */
int CloseOutputFile __((void)); /* vms.c */
/* static byte *extract_block __((struct extra_block *, int *, byte *, int));*/
/* static int _flush_blocks __((int final_flag)); * vms.c */
/* static int _flush_records __((int final_flag)); * vms.c */
/* static int WriteBuffer __((unsigned char *buf, int len)); * vms.c */
/* static int WriteRecord __((unsigned char *rec, int len)); * vms.c */
/* static void message __((int string, char *status)); * vms.c */
int VMSmunch __((char *, int, char *)); /* VMSmunch.c */
/*---------------------------------------------------------------------------
Functions in match.c, mapname.c, misc.c, etc.:
---------------------------------------------------------------------------*/
int match __((char *string, char *pattern)); /* match.c */
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 */
void envargs __((int *, char ***, char *)); /* envargs.c */
#ifdef AMIGA
int utime __((char *file, time_t timep[])); /* utime.c */
#endif /* AMIGA */
#ifdef ZMEM /* these MUST be ifdef'd because of conflicts with the std def */
char *memset __((register char *buf, register char init,
register unsigned int len)); /* misc.c */
char *memcpy __((register char *dst, register char *src,
register unsigned int len)); /* misc.c */
#endif /* ZMEM */
/************/
/* 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 OUTB(intc) {*outptr++=(byte)(intc); if (++outcnt==OUTBUFSIZ)\
FlushOutput();}
/*
* macro OUTB(intc)
* {
* *outptr++ = (byte)(intc);
* if (++outcnt == OUTBUFSIZ)
* FlushOutput();
* }
*
*/
#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 */
/*************/
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[];
#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 byte *inbuf;
extern byte *inptr;
extern int incnt;
extern ULONG bitbuf;
extern int bits_left;
extern boolean zipeof;
extern int zipfd;
#ifdef MSWIN
extern char *zipfn;
#else
extern char zipfn[];
#endif
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;
#ifdef MSWIN
extern char *filename;
#else
extern char filename[];
#endif
extern longint outpos;
extern int outcnt;
extern int outfd;
extern int mem_mode;
extern int disk_full;
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
#ifdef MACOS
extern short gnVRefNum;
extern long glDirID;
extern OSType gostCreator;
extern OSType gostType;
extern boolean fMacZipped;
extern boolean macflag;
extern short giCursor;
extern CursHandle rghCursor[];
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -