⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unzip.h

📁 另一个解zip文件的程序
💻 H
📖 第 1 页 / 共 5 页
字号:

void     envargs         __((int *, char ***, char *, char *)); /* envargs.c */
void     mksargs         __((int *, char ***));                 /* envargs.c */

int      dateformat      __((void));
void     version         __((void));                                /* local */
int      mapattr         __((void));                                /* local */
int      mapname         __((int renamed));                         /* local */
int      checkdir        __((char *pathcomp, int flag));            /* local */
char    *do_wild         __((char *wildzipfn));                     /* local */
char    *GetLoadPath     __((void));                                /* local */
#ifndef MTS /* macro in MTS */
   void  close_outfile   __((void));                                /* local */
#endif





/************/
/*  Macros  */
/************/

#ifndef MAX
#  define MAX(a,b)   ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#  define MIN(a,b)   ((a) < (b) ? (a) : (b))
#endif

#ifdef DEBUG
#  define Trace(x)   FPRINTF x
#else
#  define Trace(x)
#endif

#if defined(UNIX) || defined(T20_VMS)   /* generally old systems */
#  define ToLower(x)   ((char)(isupper((int)x)? tolower((int)x) : x))
#else
#  define ToLower      tolower          /* assumed "smart"; used in match() */
#endif


#define LSEEK(abs_offset) {LONGINT request=(abs_offset)+extra_bytes,\
   inbuf_offset=request%INBUFSIZ, bufstart=request-inbuf_offset;\
   if(request<0) {FPRINTF(stderr, LoadFarStringSmall(SeekMsg), LoadFarString(ReportMsg)); return(3);}\
   else if(bufstart!=cur_zipfile_bufstart)\
   {cur_zipfile_bufstart=lseek(zipfd,(LONGINT)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 (file_io.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)
 *      ulg abs_offset;
 *  {
 *      LONGINT   request = abs_offset + extra_bytes;
 *      LONGINT   inbuf_offset = request % INBUFSIZ;
 *      LONGINT   bufstart = request - inbuf_offset;
 *
 *      if (request < 0) {
 *          FPRINTF(stderr, LoadFarStringSmall(SeekMsg),
 *            LoadFarString(ReportMsg));
 *          return(3);             /-* 3:  severe error in zipfile *-/
 *      } else if (bufstart != cur_zipfile_bufstart) {
 *          cur_zipfile_bufstart = lseek(zipfd, (LONGINT)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)
 *      ush length;
 *  {
 *      if (length && ((error = do_string(length, SKIP)) != 0)) {
 *          error_in_archive = error;   /-* might be warning *-/
 *          if (error > 1)              /-* fatal *-/
 *              return (error);
 *      }
 *  }
 *
 */


#ifdef FUNZIP
#  define FLUSH    flush
#  define NEXTBYTE getc(in)   /* redefined in crypt.h if full version */
#  ifdef BSD_LIBRARY
#   ifdef getc
#    undef getc
#   endif
#   define getc(in) lib_nextbyte()
#  endif
#else
#  define FLUSH(w) if (mem_mode) outcnt=(w); else flush(slide,(ulg)w,0)
#  define NEXTBYTE \
     (csize-- <= 0L ? EOF : (--incnt >= 0 ? (int)(*inptr++) : readbyte()))
#endif


#define READBITS(nbits,zdest) {if(nbits>bits_left) {int temp; zipeof=1;\
  while (bits_left<=8*(sizeof(bitbuf)-1) && (temp=NEXTBYTE)!=EOF) {\
  bitbuf|=(ulg)temp<<bits_left; bits_left+=8; zipeof=0;}}\
  zdest=(int)((ush)bitbuf&mask_bits[nbits]);bitbuf>>=nbits;bits_left-=nbits;}

/*
 * macro READBITS(nbits,zdest)    * only used by unreduce and unshrink *
 *  {
 *      if (nbits > bits_left) {  * fill bitbuf, which is 8*sizeof(ulg) bits *
 *          int temp;
 *
 *          zipeof = 1;
 *          while (bits_left <= 8*(sizeof(bitbuf)-1) &&
 *                 (temp = NEXTBYTE) != EOF) {
 *              bitbuf |= (ulg)temp << bits_left;
 *              bits_left += 8;
 *              zipeof = 0;
 *          }
 *      }
 *      zdest = (int)((ush)bitbuf & mask_bits[nbits]);
 *      bitbuf >>= nbits;
 *      bits_left -= nbits;
 *  }
 *
 */


/* GRR:  should change name to STRLOWER and use StringLower if possible */

/*
 *  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.
 */
#ifdef __human68k__
#  define TOLOWER(str1, str2) \
   { \
       char *p=(str1), *q=(str2); \
       uch c; \
       while ((c = *p++) != '\0') { \
           if (iskanji(c)) { \
               if (*p == '\0') \
                   break; \
               *q++ = c; \
               *q++ = *p++; \
           } else \
               *q++ = isupper(c) ? tolower(c) : c; \
       } \
       *q = '\0'; \
   }
#else
#  define TOLOWER(str1, str2) \
   { \
       char  *p, *q; \
       p = (str1) - 1; \
       q = (str2); \
       while (*++p) \
           *q++ = (char)(isupper((int)(*p))? tolower((int)(*p)) : *p); \
       *q = '\0'; \
   }
#endif
/*
 *  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 native
#  define native(c)   (c)
#  define A_TO_N(str1)
#else
#  ifndef NATIVE
#    define NATIVE     "native chars"
#  endif
#  define A_TO_N(str1) {register unsigned char *p;\
     for (p=str1; *p; p++) *p=native(*p);}
#endif

/*
 *  Translate the zero-terminated string in str1 from ASCII to the native
 *  character set. The translation is performed in-place and uses the
 *  "native" macro to translate each character.
 *
 *  macro A_TO_N( str1 )
 *  {
 *      register unsigned char *p;
 *
 *      for (p = str1;  *p;  ++p)
 *          *p = native(*p);
 *  }
 *
 *  NOTE:  Using the "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
 *    "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       zipinfo_mode;
   extern int       aflag;
   extern int       cflag;
   extern int       C_flag;
   extern int       fflag;
   extern int       hflag;
   extern int       jflag;
   extern int       lflag;
   extern int       L_flag;
   extern int       overwrite_none;
   extern int       overwrite_all;
   extern int       force_flag;
   extern int       qflag;
#ifdef DOS_NT_OS2
   extern int       sflag;
   extern int       volflag;
#endif
   extern int       tflag;
   extern int       T_flag;
   extern int       uflag;
   extern int       vflag;
   extern int       V_flag;
#ifdef VMS
   extern int       secinf;
#endif
   extern int       zflag;
#ifdef MACOS
   extern int       HFSFlag;
#endif
   extern int       filespecs;
   extern int       xfilespecs;
   extern int       process_all_files;
   extern int       create_dirs;
#ifndef NO_ZIPINFO
   extern int       newzip;
#endif
   extern LONGINT   real_ecrec_offset;
   extern LONGINT   expect_ecrec_offset;
   extern long      csize;
   extern long      ucsize;
   extern long      used_csize;
   extern char      **pfnames;
   extern char      **pxnames;
   extern char near sig[];
   extern char near answerbuf[];
   extern min_info  *pInfo;

   extern union work area;

#ifdef FUNZIP
   extern ulg near  crc_32_tab[];
#else
   extern ulg       *crc_32_tab;
#endif
   extern ulg       crc32val;
   extern ush near  mask_bits[];

   extern uch       *inbuf;
   extern uch       *inptr;
   extern int       incnt;
   extern ulg       bitbuf;
   extern int       bits_left;
   extern boolean   zipeof;
   extern char      *zipfn;
   extern int       zipfd;
   extern LONGINT   ziplen;
   extern LONGINT   cur_zipfile_bufstart;
   extern LONGINT   extra_bytes;
   extern uch       *extra_field;
   extern uch       *hold;
   extern char near local_hdr_sig[];
   extern char near central_hdr_sig[];
   extern char near end_central_sig[];
   extern local_file_hdr  lrec;
   extern cdir_file_hdr   crec;
   extern ecdir_rec       ecrec;
   extern struct stat     statbuf;

   extern int       mem_mode;
   extern int       disk_full;
   extern int       newfile;
#ifdef SYMLINKS
   extern int       symlnk;
#endif
#ifdef FUNZIP
   extern FILE      *in;
#endif
   extern FILE      *outfile;
   extern uch       *outbuf;
   extern uch       *outbuf2;
   extern uch       *outptr;
   extern ulg       outcnt;
#ifdef MSWIN
   extern char      *filename;
#else
   extern char near filename[];
#endif

#ifdef DECLARE_ERRNO
   extern int       errno;
#endif

#ifdef EBCDIC
   extern uch       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

   extern char Far  CentSigMsg[];
   extern char Far  EndSigMsg[];
   extern char Far  SeekMsg[];
   extern char Far  ReportMsg[];
   extern char Far  FilenameNotMatched[];
   extern char Far  ExclFilenameNotMatched[];

#endif /* !__unzip_h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -