📄 unzip.h
字号:
/*---------------------------------------------------------------------------
unzip.h
This header file is used by all of the UnZip source files. Its contents
are divided into seven more-or-less separate sections: predefined macros,
OS-dependent includes, (mostly) OS-independent defines, typedefs, function
prototypes (or "forward declarations," in the case of non-ANSI compilers),
macros, and global-variable declarations.
created Mark Adler & Jean-loup Gailly
modified Roger Fujii (STTNG:AFU)
modified Kevin Ray (RESMGR)
---------------------------------------------------------------------------*/
#ifndef __unzip_h /* prevent multiple inclusions */
#define __unzip_h
#include "resmgr.h"
/*****************************************/
/* Predefined, Machine-specific Macros */
/*****************************************/
#if defined(__GO32__) && defined(unix) /* MS-DOS extender: NOT Unix */
# undef unix
#endif
/* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
#ifdef __POWERC
# define __TURBOC__
# define MSDOS
#endif /* __POWERC */
#if defined(__MSDOS__) && (!defined(MSDOS)) /* just to make sure */
# define MSDOS
#endif
/* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
* Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
* or Macintosh, or Windows NT, or Sequent, or Atari.
*/
#if defined(__STDC__) || defined(MSDOS) || defined(sgi)
# ifndef PROTO
# define PROTO
# endif
# define MODERN
#endif
#if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__)
# ifndef PROTO
# define PROTO
# endif
# define MODERN
#endif
#if defined(THINK_C) || defined(MPW) || defined(WIN32) || defined(_SEQUENT_)
# ifndef PROTO
# define PROTO
# endif
# define MODERN
#endif
/* turn off prototypes if requested */
#if defined(NOPROTO) && defined(PROTO)
# undef PROTO
#endif
/* used to remove arguments in function prototypes for non-ANSI C */
#ifdef PROTO
# define OF(a) a
#else /* !PROTO */
# define OF(a) ()
#endif /* ?PROTO */
/* stat() bug for Borland, Watcom, VAX C (also GNU?), and Atari ST MiNT on
* TOS filesystems: returns 0 for wildcards! (returns 0xffffffff on Minix
* filesystem or U: drive under Atari MiNT) */
#if (defined(__TURBOC__) || defined(__WATCOMC__) || defined(VMS))
# define WILD_STAT_BUG
#endif
#define SSTAT stat
#define STRNICMP zstrnicmp
/***************************/
/* OS-Dependent Includes */
/***************************/
#ifndef MINIX /* Minix needs it after all the other includes (?) */
# include <stdio.h>
#endif
#include <ctype.h> /* skip for VMS, to use tolower() function? */
#include <errno.h> /* used in mapname() */
#include <string.h> /* GRR: EXPERIMENTAL! */
#ifdef MODERN
# include <limits.h> /* GRR: EXPERIMENTAL! (can be deleted) */
#endif
#ifdef EFT
# define LONGINT off_t /* Amdahl UTS nonsense ("extended file types") */
#else
# define LONGINT long
#endif
#ifdef MODERN
# ifndef NO_STDDEF_H
# include <stddef.h>
# endif
# ifndef NO_STDLIB_H
# include <stdlib.h> /* standard library prototypes, malloc(), etc. */
# endif
typedef size_t extent;
typedef void voidp;
#else /* !MODERN */
LONGINT lseek();
char *malloc();
typedef unsigned int extent;
typedef char voidp;
# define void int
#endif /* ?MODERN */
/* this include must be down here for SysV.4, for some reason... */
#include <signal.h> /* used in unzip.c, file_io.c */
/*---------------------------------------------------------------------------
MS-DOS and OS/2 section:
---------------------------------------------------------------------------*/
#ifdef __IBMC__
# define S_IFMT 0xF000
# define timezone _timezone
# define PIPE_ERROR (errno == EERRSET || errno == EOS2ERR)
#endif
#ifdef __WATCOMC__
# define __32BIT__
# undef far
# define far
# undef near
# define near
# define PIPE_ERROR (errno == -1)
#endif
#ifdef __EMX__
# ifndef __32BIT__
# define __32BIT__
# endif
# define far
#endif
#ifdef __GO32__ /* note: MS-DOS compiler, not OS/2 */
# ifndef __32BIT__
# define __32BIT__
# endif
# include <sys/timeb.h> /* for structure ftime */
int setmode(int, int); /* not in djgpp's include files */
#endif
#if defined(_MSC_VER) && (!defined(MSC))
# define MSC /* for old versions, MSC must be set explicitly */
#endif
#if defined(MSDOS) || defined(OS2)
# include <sys/types.h> /* off_t, time_t, dev_t, ... */
# include <sys/stat.h>
# include <io.h> /* lseek(), open(), setftime(), dup(), creat() */
# include <time.h> /* localtime() */
# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
# define DIR_END '\\'
# if (defined(M_I86CM) || defined(M_I86LM))
# define MED_MEM
# endif
# if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
# define MED_MEM
# endif
# ifndef __32BIT__
# ifndef MED_MEM
# define SMALL_MEM
# endif
# define USE_FWRITE /* write() cannot write more than 32767 bytes */
# endif
# define DATE_FORMAT dateformat()
# define lenEOL 2
# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
#endif
/*---------------------------------------------------------------------------
NT section:
---------------------------------------------------------------------------*/
#ifdef WIN32 /* NT */
# include <sys/types.h> /* off_t, time_t, dev_t, ... */
# include <sys/stat.h>
# include <io.h> /* read(), open(), etc. */
# include <time.h>
# include <memory.h>
# include <direct.h> /* mkdir() */
# include <fcntl.h>
# if defined(FILE_IO_C)
# include <conio.h>
# include <sys\types.h>
# include <sys\utime.h>
# include <windows.h>
# endif
# define DATE_FORMAT DF_MDY
# define lenEOL 2
# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
# define NT
#endif
/*************/
/* Defines */
/*************/
#define UNZIP
#define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */
#if defined(MSDOS) || defined(NT) || defined(OS2)
# define DOS_NT_OS2
#endif
#if defined(MSDOS) || defined(OS2)
# define DOS_OS2
#endif
#if defined(MSDOS) || defined(OS2) || defined(ATARI_ST)
# define DOS_OS2_TOS
#endif
#if defined(MSDOS) || defined(ATARI_ST)
# define DOS_TOS
#endif
#if defined(MSDOS) || defined(TOPS20) || defined(VMS)
# define DOS_T20_VMS
#endif
/* GRR: NT defines MSDOS?? */
#if (!defined(MSDOS) && !defined(__IBMC__)) || defined(NT)
# define near
# define far
#endif
#if defined(__GO32__) || defined(__EMX__)
# define near
# define far
#endif
/* clean up with a couple of defaults */
#ifndef DIR_END
# define DIR_END '/' /* last char before program name (or filename) */
#endif
#ifndef RETURN
# define RETURN return /* only used in main() */
#endif
#define DIR_BLKSIZ 64 /* number of directory entries per block
* (should fit in 4096 bytes, usually) */
#ifndef WSIZE
# define WSIZE 0x8000 /* window size--must be a power of two, and */
#endif /* at least 32K for zip's deflate method */
#ifndef INBUFSIZ
# define INBUFSIZ 0x0800 /* 2K: works for MS-DOS small model */
#endif
/* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048,
* OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes
* and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5
* chars/line, smaller than estimated 35-70 characters per line for C source
* and normal text. Hence difference is sufficient for most "average" files.
* (Argument scales for larger OUTBUFSIZ.)
*/
#ifdef SMALL_MEM /* i.e., 16-bit OS's: MS-DOS, OS/2 1.x, etc. */
# define NO_ZIPINFO /* GRR: true until move all strings to far memory */
# define OUTBUFSIZ INBUFSIZ
# if (lenEOL == 1)
# define RAWBUFSIZ (OUTBUFSIZ>>1)
# else
# define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7))
# endif
# define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ)
#else
# ifdef MED_MEM
# define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */
# define TRANSBUFSIZ 0xFF80
# else
# define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */
# define TRANSBUFSIZ (lenEOL*OUTBUFSIZ)
# endif
# define RAWBUFSIZ OUTBUFSIZ
#endif /* ?SMALL_MEM */
#if (defined(SFX) && !defined(NO_ZIPINFO))
# define NO_ZIPINFO
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
#ifndef PIPE_ERROR
# define PIPE_ERROR (errno == EPIPE)
#endif
#if defined(MODERN) || defined(AMIGA)
# define FOPR "rb"
# define FOPM "r+b"
# ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */
# define FOPW "w8"
# else
# define FOPW "wb"
# endif
#else /* !MODERN */
# define FOPR "r"
# define FOPM "r+"
# define FOPW "w"
#endif /* ?MODERN */
/*
* If <limits.h> exists on most systems, should include that, since it may
* define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
* _POSIX_PATH_MAX.
*/
#ifdef DOS_OS2_TOS
# include <limits.h>
#endif
#ifndef PATH_MAX
# ifdef MAXPATHLEN
# define PATH_MAX MAXPATHLEN /* in <sys/param.h> on some systems */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -