Article View: vmsnet.sources
Article #69Zip v1.9 & UnZip v5.0, part 05/22
From: goathunter
Date: Tue, 01 Sep 1992 22:49
Date: Tue, 01 Sep 1992 22:49
1413 lines
49760 bytes
49760 bytes
Submitted-by: goathunter@wkuvx1.bitnet
Posting-number: Volume 3, Issue 127
Archive-name: zip_unzip/part05
-+-+-+-+-+-+-+-+ START OF PART 5 -+-+-+-+-+-+-+-+
X if (n != (unsigned)((`7Eb) & 0xffff))
X return 1; /* error in compressed data */
X DUMPBITS(16)
X
X
X /* read and output the compressed data */
X while (n--)
X `7B
X NEEDBITS(8)
X slide`5Bw++`5D = (byte)b;
X if (w == WSIZE)
X `7B
X flush(w);
X w = 0;
X `7D
X DUMPBITS(8)
X `7D
X
X
X /* restore the globals from the locals */
X wp = w; /* restore global window pointer */
X bb = b; /* restore global bit buffer */
X bk = k;
X return 0;
X`7D
X
X
X
Xint inflate_fixed()
X/* decompress an inflated type 1 (fixed Huffman codes) block. We should
X either replace this with a custom decoder, or at least precompute the
X Huffman tables. */
X`7B
X int i; /* temporary variable */
X struct huft *tl; /* literal/length code table */
X struct huft *td; /* distance code table */
X int bl; /* lookup bits for tl */
X int bd; /* lookup bits for td */
X unsigned l`5B288`5D; /* length list for huft_build */
X
X
X /* set up literal table */
X for (i = 0; i < 144; i++)
X l`5Bi`5D = 8;
X for (; i < 256; i++)
X l`5Bi`5D = 9;
X for (; i < 280; i++)
X l`5Bi`5D = 7;
X for (; i < 288; i++) /* make a complete, but wrong code set */
X l`5Bi`5D = 8;
X bl = 7;
X if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0)
X return i;
X
X
X /* set up distance table */
X for (i = 0; i < 30; i++) /* make an incomplete code set */
X l`5Bi`5D = 5;
X bd = 5;
X if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1)
X `7B
X huft_free(tl);
X return i;
X `7D
X
X
X /* decompress until an end-of-block code */
X if (inflate_codes(tl, td, bl, bd))
X return 1;
X
X
X /* free the decoding tables, return */
X huft_free(tl);
X huft_free(td);
X return 0;
X`7D
X
X
X
Xint inflate_dynamic()
X/* decompress an inflated type 2 (dynamic Huffman codes) block. */
X`7B
X int i; /* temporary variables */
X unsigned j;
X unsigned l; /* last length */
X unsigned m; /* mask for bit lengths table */
X unsigned n; /* number of lengths to get */
X struct huft *tl; /* literal/length code table */
X struct huft *td; /* distance code table */
X int bl; /* lookup bits for tl */
X int bd; /* lookup bits for td */
X unsigned nb; /* number of bit length codes */
X unsigned nl; /* number of literal/length codes */
X unsigned nd; /* number of distance codes */
X unsigned ll`5B286+30`5D; /* literal/length and distance code lengths */
X register ULONG b; /* bit buffer */
X register unsigned k; /* number of bits in bit buffer */
X
X
X /* make local bit buffer */
X b = bb;
X k = bk;
X
X
X /* read in table lengths */
X NEEDBITS(5)
X nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */
X DUMPBITS(5)
X NEEDBITS(5)
X nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
X DUMPBITS(5)
X NEEDBITS(4)
X nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
X DUMPBITS(4)
X if (nl > 286 `7C`7C nd > 30)
X return 1; /* bad lengths */
X
X
X /* read in bit-length-code lengths */
X for (j = 0; j < nb; j++)
X `7B
X NEEDBITS(3)
X ll`5Bborder`5Bj`5D`5D = (unsigned)b & 7;
X DUMPBITS(3)
X `7D
X for (; j < 19; j++)
X ll`5Bborder`5Bj`5D`5D = 0;
X
X
X /* build decoding table for trees--single level, 7 bit lookup */
X bl = 7;
X if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0)
X `7B
X if (i == 1)
X huft_free(tl);
X return i; /* incomplete code set */
X `7D
X
X
X /* read in literal and distance code lengths */
X n = nl + nd;
X m = mask_bits`5Bbl`5D;
X i = l = 0;
X while ((unsigned)i < n)
X `7B
X NEEDBITS((unsigned)bl)
X j = (td = tl + ((unsigned)b & m))->b;
X DUMPBITS(j)
X j = td->v.n;
X if (j < 16) /* length of code in bits (0..15) */
X ll`5Bi++`5D = l = j; /* save last length in l */
X else if (j == 16) /* repeat last length 3 to 6 times */
X `7B
X NEEDBITS(2)
X j = 3 + ((unsigned)b & 3);
X DUMPBITS(2)
X if ((unsigned)i + j > n)
X return 1;
X while (j--)
X ll`5Bi++`5D = l;
X `7D
X else if (j == 17) /* 3 to 10 zero length codes */
X `7B
X NEEDBITS(3)
X j = 3 + ((unsigned)b & 7);
X DUMPBITS(3)
X if ((unsigned)i + j > n)
X return 1;
X while (j--)
X ll`5Bi++`5D = 0;
X l = 0;
X `7D
X else /* j == 18: 11 to 138 zero length codes */
X `7B
X NEEDBITS(7)
X j = 11 + ((unsigned)b & 0x7f);
X DUMPBITS(7)
X if ((unsigned)i + j > n)
X return 1;
X while (j--)
X ll`5Bi++`5D = 0;
X l = 0;
X `7D
X `7D
X
X
X /* free decoding table for trees */
X huft_free(tl);
X
X
X /* restore the global bit buffer */
X bb = b;
X bk = k;
X
X
X /* build the decoding tables for literal/length and distance codes */
X bl = lbits;
X if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
X `7B
X if (i == 1)
X huft_free(tl);
X return i; /* incomplete code set */
X `7D
X bd = dbits;
X if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
X `7B
X if (i == 1)
X huft_free(td);
X huft_free(tl);
X return i; /* incomplete code set */
X `7D
X
X
X /* decompress until an end-of-block code */
X if (inflate_codes(tl, td, bl, bd))
X return 1;
X
X
X /* free the decoding tables, return */
X huft_free(tl);
X huft_free(td);
X return 0;
X`7D
X
X
X
Xint inflate_block(e)
Xint *e; /* last block flag */
X/* decompress an inflated block */
X`7B
X unsigned t; /* block type */
X register ULONG b; /* bit buffer */
X register unsigned k; /* number of bits in bit buffer */
X
X
X /* make local bit buffer */
X b = bb;
X k = bk;
X
X
X /* read in last block bit */
X NEEDBITS(1)
X *e = (int)b & 1;
X DUMPBITS(1)
X
X
X /* read in block type */
X NEEDBITS(2)
X t = (unsigned)b & 3;
X DUMPBITS(2)
X
X
X /* restore the global bit buffer */
X bb = b;
X bk = k;
X
X
X /* inflate that block type */
X if (t == 2)
X return inflate_dynamic();
X if (t == 0)
X return inflate_stored();
X if (t == 1)
X return inflate_fixed();
X
X
X /* bad block type */
X return 2;
X`7D
X
X
X
Xint inflate_entry()
X/* decompress an inflated entry */
X`7B
X int e; /* last block flag */
X int r; /* result code */
X unsigned h; /* maximum struct huft's malloc'ed */
X
X
X /* initialize window, bit buffer */
X wp = 0;
X bk = 0;
X bb = 0;
X
X
X /* decompress until the last block */
X h = 0;
X do `7B
X hufts = 0;
X if ((r = inflate_block(&e)) != 0)
X return r;
X if (hufts > h)
X h = hufts;
X `7D while (!e);
X
X
X /* flush out slide */
X flush(wp);
X
X
X /* return success */
X#ifdef DEBUG
X fprintf(stderr, "<%u> ", h);
X#endif /* DEBUG */
X return 0;
X`7D
X
X
Xvoid inflate()
X/* ignore the return code for now ... */
X`7B
X inflate_entry();
X`7D
$ CALL UNPACK [.UNZIP50]INFLATE.C;1 394025229
$ create 'f'
X#===========================================================================
V===
X# Makefile for UnZip, ZipInfo & FUnZip: Unix, OS/2, MS-DOS ("real" makes on
Vly)
X# Version: 5.0 (inflate,explode) 20 August 1
V992
X#===========================================================================
V===
X#
X#
X# INSTRUCTIONS (such as they are):
X#
X# "make vax"`09-- makes UnZip on a VAX 11-780 BSD 4.3 in current directory
X#`09`09 (or a SysV VAX, or an 8600 running Ultrix, or...)
X# "make"`09-- uses environment variable SYSTEM to set the type
X#`09`09 system to compile for. This doesn't work for some
X#`09`09 particularly brain-damaged versions of make (VAX BSD,
X#`09`09 Gould, and SCO Unix are in this group). If SYSTEM not
X#`09`09 set, gives instructions on what to try instead.
X# "make list"`09-- lists all supported systems (targets), including related
X#`09`09 utilities' targets
X# "make wombat" -- Chokes and dies if you haven't added the specifics
X#`09`09 for your Wombat 68000 (or whatever) to the systems list.
X#
X# CF are flags for the C compiler. LF are flags for the loader. LF2 are
X# more flags for the loader, if they need to be at the end of the line
X# instead of at the beginning (for example, some libraries). LOCAL_UNZIP
X# is an environment variable that can be used to add default C flags to
X# your compile without editing the Makefile (e.g., -DDEBUG_STRUC, or -FPi87
X# on PCs).
X#
X# My host (a VAX 11-780 running BSD 4.3) is hereafter referred to as "my hos
Vt."
X#
X# My host's /usr/include/sys/param.h defines BSD for me. You may have to ad
Vd
X# "-DBSD" to the list of CF for your system.
X#
X# Some versions of make do not define the macro "$(MAKE)" (my host did not).
X# The makefile should now handle such systems correctly, more or less; the
X# possible exception to this is if you've used a make command-line option
X# (for example, the one which displays the commands which WOULD be executed,
X# but doesn't actually execute them). It probably needs some more tinkering
V.
X# If things still don't work, use "make" instead of "$(MAKE)" in your system
V's
X# makerule. Or try adding the following line to your .login file:
X# setenv MAKE "make"
X# (It didn't help on my host.)
X#
X# Memcpy and memset are provided for those systems that don't have them;
X# they're found in misc.c and will be used if -DZMEM is included in the list
X# of CF. These days *almost* all systems have them (they're mandated by
X# ANSI), but older systems might be lacking. And at least one machine's
X# version results in some serious performance degradation...
X#
X# Be sure to test your nice new UnZip; successful compilation does not alway
Vs
X# imply a working program.
X
X
X#####################
X# MACRO DEFINITIONS #
X#####################
X
X# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,`20
X# such as -DNOMEMCPY).
X
XCRYPTF =
XCRYPTO =
X# Uncomment next two lines for decryption version:
X#CRYPTF = -DCRYPT
X#CRYPTO = crypt$O
X
X# UnZip flags
XCC = cc#`09try using "gcc" target rather than changing this (if you do,
XLD = cc#`09you MUST change LD, too--else "unresolved symbol: ___main")
XLOC = $(LOCAL_UNZIP) $(CRYPTF)
XCF = -O $(LOC)
XLF = -o unzip
XLF2 = -s
X
X# ZipInfo flags
XZC = -DZIPINFO
XZL = -o zipinfo
XZL2 = -s
X
X# FUnZip flags
XFC = # not used
XFL = -o funzip
XFL2 = -s
X
X# general-purpose stuff
XLN = rm -f misc_.c; ln
XRM = rm -f
XE =
XO = .o
XSHELL = /bin/sh
XINSTALL = cp#`09 `09 probably can change this to 'install' if you have it
XBINDIR = /usr/local/bin# target directory - where to install executables
X
X# object files
XOBJS1 = unzip$O $(CRYPTO) envargs$O explode$O extract$O file_io$O inflate$O
XOBJS2 = mapname$O match$O misc$O unreduce$O unshrink$O
XOBJS = $(OBJS1) $(OBJS2)
XLOBJS = $(OBJS)
XOS2_OBJS = $(OBJS:.o=.obj) os2unzip.obj
XOBJZ = zipinfo$O envargs$O match$O misc_$O
XOS2_OBJZ = $(OBJZ:.o=.obj) os2zinfo.obj
XOBJF = funzip$O $(CRYPTO) inflate$O
XOS2_OBJF = # not yet supported
XUNZIPS = unzip$E # zipinfo$E funzip$E`09# zipinfo, funzip not fully supporte
Vd
X#`09`09`09`09`09# yet (next release)
X
X# list of supported systems/targets in this version
XSYSTEMS1 = 386i 3Bx 7300 amdahl apollo aviion bsd bull c120 c210 coherent
XSYSTEMS2 = convex cray cray_cc cray_v3 cyber_sgi dec dnix encore eta
XSYSTEMS3 = gcc gcc_dos generic generic2 gould hk68 hp indigo linux
XSYSTEMS4 = minix mips msc_dos next osf1 p_iris pyramid rs6000 rtaix
XSYSTEMS5 = sco sco_dos sco_x286 sequent sgi stellar sun sysv sysv6300
XSYSTEMS6 = tahoe ultrix vax wombat xos
X
XSYS_UTIL1 = zi_dos zi_gcc zi_indigo zipinfo fu_gcc funzip
X# SYS_UTIL2 = ship ship_dos ship_sysv
X
X
X####################
X# DEFAULT HANDLING #
X####################
X
X# The below will try to use your shell variable "SYSTEM" as the type system
X# to use (e.g., if you type "make" with no parameters at the command line).
X# The test for $(MAKE) is necessary for VAX BSD make (and Gould, apparently)
V,
X# as is the "goober" (else stupid makes see an "else ;" statement, which the
Vy
X# don't like). "goober" must then be made into a valid target for machines
X# which DO define MAKE properly (and have SYSTEM set). Quel kludge, non?
X# And to top it all off, it appears that the VAX, at least, can't pick SYSTE
VM
X# out of the environment either (which, I suppose, should not be surprising)
V.
X# `5BBtw, if the empty "goober" target causes someone else's make to barf, j
Vust
X# add an "@echo > /dev/null" command (or whatever). Works OK on the Amdahl
X# and Crays, though.`5D
X
Xdefault:
X`09@if test -z "$(MAKE)"; then\
X`09`09if test -z "$(SYSTEM)";\
X`09`09then make help;\
X`09`09else make $(SYSTEM) MAKE="make";\
X`09`09fi;\
X`09else\
X`09`09if test -z "$(SYSTEM)";\
X`09`09then $(MAKE) help;\
X`09`09else $(MAKE) $(SYSTEM) goober;\
X`09`09fi;\
X`09fi
X
Xgoober:
X
Xhelp:
X`09@echo
X`09@echo\
X " If you're not sure about the characteristics of your system, try typing"
X`09@echo\
X ' "make generic". If the compiler barfs and says something unpleasant abo
Vut'
X`09@echo\
X ' "timezone redefined," try typing "make clean" followed by "make generic2
V".'
X`09@echo\
X ' One of these actions should produce a working copy of unzip on most Unix
V'
X`09@echo\
X ' systems. If you know a bit more about the machine on which you work, yo
Vu'
X`09@echo\
X ' might try "make list" for a list of the specific systems supported herei
Vn.'
X`09@echo\
X ' And as a last resort, feel free to read the numerous comments within the
V'
X`09@echo\
X ' Makefile itself. Note that to compile the decryption version of UnZip,'
X`09@echo\
X ' you must obtain crypt.c separately, in addition to uncommenting two line
Vs'
X`09@echo\
X ' in Makefile (see the main Contents file for ftp and mail-server sites).'
X`09@echo\
X ' Have an excruciatingly pleasant day.'
X`09@echo
X
Xlist:
X`09@echo
X`09@echo\
X 'Type "make <system>", where <system> is one of the following:'
X`09@echo
X`09@echo "`09$(SYSTEMS1)"
X`09@echo "`09$(SYSTEMS2)"
X`09@echo "`09$(SYSTEMS3)"
X`09@echo "`09$(SYSTEMS4)"
X`09@echo "`09$(SYSTEMS5)"
X`09@echo "`09$(SYSTEMS6)"
X`09@echo
X`09@echo\
X 'Otherwise set the shell variable SYSTEM to one of these and just type "mak
Ve".'
X`09@echo\
X 'Targets for related utilities (ZipInfo) include:'
X`09@echo
X`09@echo "`09$(SYS_UTIL1)"
X#`09@echo "`09$(SYS_UTIL2)"
X`09@echo
X`09@echo\
X 'For further (very useful) information, please read the comments in Makefil
Ve.'
X`09@echo
X
X
X###############################################
X# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
X###############################################
X
X.c$O :
X`09$(CC) -c $(CF) $*.c
X
Xunzips:`09`09$(UNZIPS)
X
Xunzip$E:`09$(OBJS)
X`09$(LD) $(LF) $(LOBJS) $(LF2)
X
Xcrypt$O: crypt.c unzip.h zip.h`09# may or may not be in distribution
Xenvargs$O: envargs.c unzip.h
Xexplode$O: explode.c unzip.h
Xextract$O: extract.c unzip.h
Xfile_io$O: file_io.c unzip.h
Xfunzip$O: funzip.c unzip.h
Xinflate$O: inflate.c unzip.h
Xmapname$O: mapname.c unzip.h
Xmatch$O: match.c unzip.h
Xmisc$O: misc.c unzip.h
Xos2unzip$O: os2unzip.c unzip.h`09# for OS/2 only
Xos2zinfo$O: os2unzip.c unzip.h`09# for OS/2 only
Xunreduce$O: unreduce.c unzip.h
Xunshrink$O: unshrink.c unzip.h
Xunzip$O: unzip.c unzip.h
X
Xall:`09generic_msg generic zipinfo
X
Xgeneric_msg:
X`09@echo
X`09@echo\
X ' Attempting "make generic" and "make zipinfo" now. If this fails for som
Ve'
X`09@echo\
X ' reason, type "make help" and/or "make list" for suggestions.'
X`09@echo
X
Xinstall:`09$(UNZIPS)
X`09$(INSTALL) $(UNZIPS) $(BINDIR)
X
Xclean:
X`09rm -f $(OBJS) unzip$E $(OBJZ) zipinfo$E
X
X
X################################
X# INDIVIDUAL MACHINE MAKERULES #
X################################
X
X# these are the makerules for various systems
X# TABS ARE REQUIRED FOR MANY VERSIONS OF "MAKE"!
X
X
X# --------------------------------------------------------------------------
V-
X# Generic targets (can't assume make utility groks "$(MAKE)")
X# --------------------------------------------------------------------------
V-
X
Xgeneric:`09unzip`09# first try if unknown
X
Xgeneric2:`09`09# second try if unknown: hope make is called "make"...
X`09make unzip CF="$(CF) -DBSD"
X
X# --------------------------------------------------------------------------
V-
X# "Normal" group (both big- and little-endian, structure-padding or not):
X# --------------------------------------------------------------------------
V-
X
X386i:`09`09unzip`09# sun386i, SunOS 4.0.2
X3Bx:`09`09unzip`09# AT&T 3B2/1000-80; should work on any WE32XXX machine
X7300:`09`09unzip`09# AT&T 7300 (M68000/SysV)
Xapollo:`09`09unzip`09# Apollo Domain/OS machines
Xbull:`09`09unzip`09# Bull DPX/2, BOS 2.00.45 (doesn't require -Xk switch)
Xcoherent:`09unzip`09# Coherent 3.10, Mark Williams C
Xcray_cc:`09unzip`09# Cray-2 and Y-MP, using default (possibly old) compiler
Xdec:`09`09unzip`09# DEC 5820 (MIPS RISC), test version of Ultrix v4.0
Xencore:`09`09unzip`09# Multimax
Xeta:`09`09unzip`09# ETA-10P*, hybrid SysV with BSD 4.3 enhancements
Xgould:`09`09unzip`09# Gould PN9000 running UTX/32 2.1Bu01
Xhp:`09`09unzip`09# HP 9000 series (68020), 4.3BSD or HP-UX A.B3.10 Ver D
Xhp_ux:`09`09unzip`09# (to match zip's makefile entry)
Xmips:`09`09unzip`09# MIPS M120-5(?), SysV.3 `5Berror in sys/param.h file?`5D
Xpyramid:`09unzip`09# Pyramid 90X, prob. all, under >= OSx4.1, BSD universe
Xrtaix:`09`09unzip`09# IBM RT 6150 under AIX 2.2.1
Xsco:`09`09unzip`09# Xenix/386 (tested on 2.3.1); SCO Unix 3.2.0.
Xstellar:`09unzip`09# gs-2000
Xsun:`09`09unzip`09# Sun 3, 4; SunOS 4.x (SOME SYSTEMS ARE SYSTEM V!)
Xtahoe:`09`09unzip`09# tahoe (CCI Power6/32), 4.3BSD
Xultrix:`09`09unzip`09# VAXen, DEC 58x0 (MIPS guts), DECstation 2100; v4.x
Xvax:`09`09unzip`09# general-purpose VAX target (not counting VMS)
X
X# --------------------------------------------------------------------------
V-
X# BSD group (for timezone structs `5Bstruct timeb`5D):
X# --------------------------------------------------------------------------
V-
X
Xbsd:`09`09_bsd`09# generic BSD (BSD 4.2 & Ultrix handled in unzip.h)
X
X_bsd:
X`09$(MAKE) unzip CF="$(CF) -DBSD"
X
X# --------------------------------------------------------------------------
V-
X# SysV group (for extern long timezone and ioctl.h instead of sgtty.h):
X# --------------------------------------------------------------------------
V-
X
Xamdahl:`09`09_sysv`09# Amdahl (IBM) mainframe, UTS (SysV) 1.2.4 and 2.0.1
Xaviion: _sysv`09# Data General AViiONs, DG/UX 4.3x
Xsgi:`09`09_sysv`09# Silicon Graphics Iris 4D, Irix SysV rel. 3.3.2
Xsysv:`09`09_sysv`09# generic System V Unix
Xxos:`09`09_sysv`09# Olivetti LSX-3005..3045, X/OS 2.3 and 2.4
X
X_sysv:
X`09$(MAKE) unzip CF="$(CF) -DSYSV -DTERMIO"
X
X# --------------------------------------------------------------------------
V-
X# "Unique" group (require non-standard options):
X# --------------------------------------------------------------------------
V-
X
X# Apparently the C-120 has an optimization bug, and possibly another
X# bug in the (SysV?) time routines which adds 11 years to the date.
X# -DCONVEX not needed? `5BRZM: The remark above the C-120 entry`20
X# about a bug may not be true. I think it is rather time procedures
X# uncompatibility between unixes.`5D `5BGRR: So is -O2 ok for c120?`5D
X#
Xc120:`09`09`09# Convex C-120, OS 9.0, with non-vectorizing cc 4.0
X`09$(MAKE) unzip CF="-O1 $(LOC) -Dunix -DBSD"
X
Xc210:`09`09`09# Convex C-210, OS 9.0, cc 4.0
X`09$(MAKE) unzip CF="-O2 $(LOC) -Dunix -DBSD"
X
X# Enclosed you'll find a context diff for the unzip41 makefile
X# which enhances compilation on a convex. The previous version
X# probably worked great a couple of years ago, and would still do
X# so if one compiles in our "backward compatible" pcc mode. The
X# following allows it to work better in a modern convexian environment.
X# `5BThis target results in the following error on various Convex's,`20
X# however: "cc: Error on line 79 of file_io.c: 'ioctl' redeclared:
X# incompatible types."`5D
X#
Xconvex:`09`09`09# previous target was tested on C200/C400
X`09$(MAKE) unzip CF="$(CF) -Dunix -DCONVEX -ext" LF="$(LF) -ext"
X
X# Cray-2 and Y-MP, running Unicos 5.1 to 6.1 (SysV + BSD enhancements)
X# and Standard (ANSI) C compiler 1.5, 2.0 or 3.0.
Xcray:
X`09$(MAKE) unzip CC="scc" LD="scc"
X
X# Ditto, for Cray Standard C 3.0 or later.
Xcray_v3:
X`09$(MAKE) unzip CC="scc" LD="scc" CF="$(CF) -h scalar3 -h vector3"
X
X# The unzip41 build on a Cyber 910/SGI running Irix v3.3.3 was successful
X# with the following change to Makefile:
Xcyber_sgi:
X`09$(MAKE) unzip CF="$(CF) -I/usr/include/bsd"\
X`09 LF="-lbsd $(LF)"
X
X# The DIAB dnix 5.3 compiler does not define __STDC__ but understands
X# prototypes, void, etc., anyway. It also does not provide any predefined
X# macros to detect this (aside from "unix" and the four file, line, time
X# and date macros). Thus we must define MODERN and PROTO by hand.
X#
Xdnix:`09`09# 680X0, DIAB dnix 5.2/5.3 (a Swedish System V clone)
X`09$(MAKE) unzip CF="$(CF) -DPROTO -DMODERN"
X
X# Generic BSDish Unix gcc. `60`60The -O2 only works with the latest version
V of
X# gcc; you may have to use -O only for earlier versions. I have no idea why
X# -s causes this bug in gcc.'' `5BBug: "nm: unzip: no name list", "collect
V:
X# /usr/bin/nm returned 1 exit status".`5D If you don't have strip, don't
X# worry about it (it just makes the executable smaller).
X#
Xgcc:
X`09$(MAKE) unzip CC=gcc LD=gcc CF="-O2 $(LOC)" LF2=""
X`09strip unzip
X
X# MS-DOS with D.J. Delorie's djgcc 1.06. Note that go32 doesn't support
X# dos function 0x38 (yet); to fix, append to line 400 of exphdlr.c (go32)
X# the following: "case 0x38:".
X#
Xgcc_dos:`09# may need to add -Uunix to CF
X`09$(MAKE) unzip CC=gcc LD=gcc CF="-O2 -Wall $(LOC)"\
X`09 LF="-s" LF2="-o unzip"
X`09aout2exe unzip
X
X# Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000
Xhk68:
X`09$(MAKE) unzip CC="gcc" LD="gcc" LF="-n $(LF)" \
X`09CF="-ga -X138 $(LOC) -Dlocaltime=localti -Dtimezone=timezon"
X
X# Rules needed to build the unzip program for an Iris Indigo running
X# Irix Version 4.0.1
Xindigo:
X`09$(MAKE) unzip CF="-cckr $(CF) -DTERMIO"
X
X# Linux is almost sysv but not quite
Xlinux: # Linux pre-0.96 with gcc 2.1
X`09$(MAKE) unzip CF="$(CF) -DTERMIO -DLINUX" CC=gcc LD=gcc
X
X# Minix 1.5 PC for the 386 with gcc or bcc
Xminix:
X`09$(MAKE) unzip CC=gcc CF="$(CF) -DMINIX"
X
X# PCs (IBM-type), running MS-DOS, Microsoft C 6.0 and NMAKE. Can't use
X# SYSTEM environment variable: "default" target is > 200 characters.
X# "nmake msc_dos" works fine, aside from (possibly) an irrelevant message
X# about the creation of a temporary file. Environment variable LOCAL_UNZIP
X# should be set via "SET LOCAL_UNZIP=-FPi87" if you use the 80x87 library;
X# also add -G2 or -G3 if using a 286/386/486 system.
X#
X#msc_dos:
X#`09$(MAKE) unzip.exe\
X#`09 CF="-Ox $(LOC) -nologo -G2" CC=cl LD=link E=.exe O=.obj\
X#`09 LF="/noi/nol" LF2=",unzip;"
X
Xmsc_dos:`09rsp
X`09$(MAKE) unzip.exe CF="-Ox $(LOC) -nologo" CC=cl LD=link E=.exe\
X`09 O=.obj LOBJS="" LF="@rsp" LF2=""
X`09del rsp
X
Xrsp:
X`09echo $(OBJS1:.o=.obj)+ > rsp
X`09echo $(OBJS2:.o=.obj)/noi/e/st:0x1000; >> rsp
X
X# $(LOCAL_UNZIP): math libraries and/or any other personal or debugging
X# definitions: e.g., SET LOCAL_UNZIP=-FPi87 -DDEBUG_STRUC
X# $(NOD): intended to be used as SET NOD=-link /nod:slibcep to allow th
Ve
X# use of default library names (slibce.lib) instead of protected-mo
Vde
X# names (slibcep.lib), but it fails: MSC adds its own /nod qualifi
Ver,
X# and there seems to be no way to override this. Typical...
X#
Xmsc_os2:`09`09# 16-bit OS/2 (1.x) with MSC 6.00 (use makefile.os2)
X`09$(MAKE) -nologo unzip.exe zipinfo.exe CC=cl LD=cl E=.exe O=.obj\
X`09 OBJS="$(OS2_OBJS)" OBJZ="$(OS2_OBJZ)"\
X`09 CF="-nologo -AC -Ocegit -G2s -DOS2 -DMSC $(LOC)"\
X`09 LF="-nologo -AC $(LOC) -Lp -F 2000"\
X`09 LF2="unzip.def -o unzip.exe $(NOD)" LN="copy" RM="del"\
X`09 ZL="-nologo -AC $(LOC) -Lp -Fb" ZL2="zipinfo.def -o zipinfo.exe"
X
X# NeXT 2.x: make the executable smaller.
Xnext:`09`09`09# 68030 BSD 4.3+Mach
X`09$(MAKE) unzip LF2="-object -s"
X
X# Rules to build the unzip program on a DecStation running DEC OSF/1 V1.0.
X# This machine hasn't got ftime(3) in the standard C library.
Xosf1:
X`09$(MAKE) unzip LF2="-lbsd"
X
X# I successfully compiled and tested the unzip program (v30) for the
X# Silicon Graphics environment (Personal Iris 4D20/G with IRIX v3.2.2)
Xp_iris:
X`09$(MAKE) unzip CF="$(CF) -I/usr/include/bsd -DBSD"\
X`09 LF="-lbsd $(LF)"
X
X# I have finished porting unzip 3.0 to the Pyramid 90X under OSX4.1.
X# The biggest problem was the default structure alignment yielding two
X# extra bytes. The compiler has the -q option to pack structures, and
X# this was all that was needed. To avoid needing ZMEMS we could compile
X# in the AT&T universe, but it runs more slowly!
X#
X#UnZip 5.0f: moved to regular targets as test
X#pyramid:`09# Pyramid 90X, probably all, under >= OSx4.1, BSD universe
X#`09make unzip CF="$(CF) -q"
X
X# IBM RS/6000 under AIX 3.2
Xrs6000:
X`09$(MAKE) unzip CF="$(CF) -DBSD -D_BSD -DUNIX" LF="-lbsd $(LF)"
X
X# SCO cross compile from unix to DOS. Tested with Xenix/386 and OpenDeskTop.
X# Should work with xenix/286 as well. (davidsen) Note that you *must* remov
Ve
X# the unix objects and executable before doing this! (Piet Plomp: gcc won'
Vt
X# recognize the -M0 flag which forces 8086 code.)
X#
Xsco_dos:`09# uncomment zipinfo in UNZIPS if desired
X`09$(MAKE) unzips CF="-O $(LOC) -DNO_ERRNO -dos -M0" LF="-dos -F 2000"\
X`09 LF2="-o unzip.exe" ZL="-dos" ZL2="-o zipinfo.exe"
X
X# SCO Xenix/286 2.2.1
Xsco_x286:
X`09$(MAKE) unzip CF="$(CF) -Ml2" LF="$(LF) -Ml2"
X
X# Sequent Symmetry is a 386 but needs -DZMEM
X# This should also work on Balance but I can't test it just yet.
Xsequent:`09# Sequent w/Dynix
X`09$(MAKE) unzip CF="$(CF) -DBSD -DZMEM"
X
X# AT&T 6300+, running System V.? Unix: out-of-memory error if don't use -Ml
Xsysv6300:
X`09$(MAKE) unzip CF="$(CF) -Ml -DTERMIO" LF="$(LF) -Ml"
X
X# I didn't do this. I swear. No, really.
Xwombat:`09`09# Wombat 68000 (or whatever)
X`09@echo
X`09@echo '`09Ha ha! Just kidding.'
X`09@echo
X
X
X#####################
X# ZIPINFO MAKERULES #
X#####################
X
X# ZipInfo section: less hand-holding here, but it should be pretty
X# straightforward by now.
X
Xzipinfo$O:`09zipinfo.c unzip.h
X`09$(CC) -c $(CF) zipinfo.c
X
Xmisc_$O:`09misc.c unzip.h
X`09$(LN) misc.c misc_.c
X`09$(CC) -c $(CF) $(ZC) misc_.c
X`09$(RM) misc_.c
X
Xos2zinfo$O:`09os2unzip.c unzip.h
X`09$(LN) os2unzip.c os2zinfo.c
X`09$(CC) -c $(CF) $(ZC) os2zinfo.c
X`09$(RM) os2zinfo.c
X
Xzipinfo$E:`09$(OBJZ)
X`09$(LD) $(ZL) $(OBJZ) $(ZL2)
X
Xzi_gcc:`09`09`09# GNU gcc under Unix (if no strip, don't worry)
X`09$(MAKE) zipinfo CC=gcc LD=gcc ZL2=""
X`09strip zipinfo
X
Xzi_indigo:`09`09# SGI Iris Indigo
X`09$(MAKE) zipinfo CF="-cckr -O -DUNIX $(LOC)"
X
Xzi_dos:`09`09`09# MSC 6.0 + nmake, MS-DOS
X`09$(MAKE) zipinfo.exe CF="-Ox -nologo $(LOC) -G2" CC=cl\
X`09 LD=link E=.exe O=.obj ZL="/noi /nol" ZL2=",zipinfo;"\
X`09 LN="copy" RM="DEL"
X
X
X####################
X# FUNZIP MAKERULES #
X####################
X
X# FUnZip section: FUnZip (Filter UnZip) is a last-minute addition to the
X# UnZip suite and is still VERY raw. Its purpose is to take a zipfile from`
V20
X# stdin and decompress the first entry to stdout. Only non-encrypted, store
Vd
X# or deflated files are allowed at present. FUnZip may be absorbed into
X# regular UnZip in a subsequent release. This target should work for some
X# Unix systems but is not guaranteed to work for all (or even most).
X
Xfunzip$E:`09$(OBJF)
X`09$(LD) $(FL) $(OBJF) $(FL2)
X
Xfu_gcc:`09`09`09# GNU gcc under Unix (if no strip, don't worry)
X`09$(MAKE) funzip CC=gcc LD=gcc FL2=""
X`09strip funzip
X
X
X################
X# ATTRIBUTIONS #
X################
X
X# Thanks to the following people for their help in testing and/or porting
X# to various machines (and thanks to the many others who aren't listed
X# here but should be):
X#
X# (original Unix port: Carl Mascott <cmascott@world.std.com>)
X# 386i:`09Richard Stephen <stephen@corp.telecom.co.nz>
X# 3Bx:`09`09Bob Kemp <hrrca!bobc@cbnewse.att.com>
X# 7300:`09Richard H. Gumpertz <rhg@cpsolv.CPS.COM>
X#`09`09Greg Roelofs <roelofs@amelia.nas.nasa.gov>
X# amdahl:`09Kim DeVaughn <ked01@juts.ccc.amdahl.com>, Greg Roelofs
X# apollo:`09Tim Geibelhaus
X# aviion:`09Bruce Kahn <bkahn@archive.webo.dg.com>
X# bull:`09Matt D'Errico <doc@magna.com>
X# c120:`09Rafal Maszkowski <sgumk%pltumk11.bitnet>
X# coherent:`09David Fenyes <dfenyes@thesis1.med.uth.tmc.edu>
X# convex:`09Randy Wright <rwright@convex.com>
X# cray:`09Greg Roelofs, Paul Borman <prb@cray.com>
X# cray_cc:`09Greg Roelofs
X# cray_v3:`09Greg Roelofs
X# cyber_sgi:`09Clint Pulley <u001@cs910.cciw.ca>
X# dec:`09`09"Moby" Dick O'Connor <djo7613@u.washington.edu>
X# dnix:`09Bo Kullmar <bk@kullmar.se>
X# eta:`09`09Greg Flint <afc@klaatu.cc.purdue.edu>
X# gcc:`09`09Jean-loup Gailly <jloup@chorus.fr>
X# gcc_dos:`09Onno van der Linden <linden@fwi.uva.nl>
X# gcc_os2:`09Kai Uwe Rommel <rommel@informatik.tu-muenchen.de>
X# gould:`09Onno van der Linden
X# hk68:`09John Limpert <gronk!johnl@uunet.UU.NET>
X# hp:`09`09Randy McCaskile <rmccask@seas.gwu.edu> (HP-UX)
X#`09`09Gershon Elber <gershon@cs.utah.edu> (HP BSD 4.3)
X# icc_os2:`09Kai Uwe Rommel
X# indigo:`09Kjetil Wiekhorst J`7Crgensen <jorgens@lise.unit.no>
X# linux:`09Humberto Ortiz-Zuazaga <zuazaga@ucunix.san.uc.edu>
X# minix:`09Kai Uwe Rommel (Minix 1.5)
X# mips:`09Peter Jones <jones@mips1.uqam.ca>
X# msc_dos:`09Greg Roelofs <roe2@ellis.uchicago.edu>
X#`09`09Piet W. Plomp <piet@icce.rug.nl>
X# msc_os2:`09Wim Bonner <wbonner@yoda.eecs.wsu.edu>
X#`09`09Kai Uwe Rommel, Greg Roelofs
X# next:`09Mark Adler <madler@piglet.caltech.edu>
X# osf1:`09Kjetil Wiekhorst J`7B\o`7Drgensen
X# p_iris:`09Valter V. Cavecchia <root@itnsg1.cineca.it>
X# pyramid:`09James Dugal <jpd@usl.edu>
X# rs6000:`09Filip Gieszczykiewicz <fmg@smi.med.pitt.edu>
X#`09`09Trevor Paquette <tpaquett@ita.lgc.com>
X# rtaix:`09Erik-Jan Vens
X# sco:`09`09Onno van der Linden (SCO Unix 3.2.0)
X# `09`09Bill Davidsen <davidsen@crdos1.crd.ge.com> (Xenix/386)
X# sco_dos:`09Bill Davidsen, Piet W. Plomp
X# sco_x286:`09Ricky Mobley <ddi1!lrark!rick@uunet.UU.NET>
X# sequent:`09Phil Howard <phil@ux1.cso.uiuc.edu>
X# sgi:`09`09Greg Roelofs (Iris 4D/380?)
X# sun:`09`09Onno van der Linden (Sun 4), Greg Roelofs (Sun 3, 4)
X# sysv:`09Greg Roelofs
X# sysv6300:`09Peter Mauzey <ptm@mtdcc.att.com>
X# tahoe:`09Mark Edwards <mce%sdcc10@ucsd.edu>
X# ultrix:`09Greg Flint (VAX)
X#`09`09Michael Graff <explorer@iastate.edu> (DECstation 2100?)
X#`09`09Greg Roelofs (DEC 5810)
X#`09`09Alex A Sergejew <aas@brain.wph.uq.oz.au>
X# vax:`09`09Forrest Gehrke <feg@dodger.att.com> (SysV)
X#`09`09David Kirschbaum <kirsch@usasoc.soc.mil> (BSD 4.3)
X#`09`09Jim Steiner <steiner@pica.army.mil> (8600+Ultrix)
X# wombat:`09Joe Isuzu <joe@trustme.isuzu.com>
X# xos:`09`09Fulvio Marino <fulvio@iconet.ico.olivetti.com>
X# zi_dos:`09Greg Roelofs
X# zi_icc:`09Kai Uwe Rommel
X# zi_os2:`09Greg Roelofs, Kai Uwe Rommel
X# zipinfo:`09Greg Roelofs
$ CALL UNPACK [.UNZIP50]MAKEFILE.;1 1597202701
$ create 'f'
X$ !
X$ !`09`09"Makefile" for VMS versions of UnZip and ZipInfo
X$ !`09`09`09`09(version: GNU C)
X$ !
X$ ! Find out current disk and directory
X$ !
X$ my_name = f$env("procedure")
X$ here = f$parse(my_name,,,"device") + f$parse(my_name,,,"directory")
X$ set verify`09! like "echo on", eh?
X$ !
X$ ! Do UnZip:
X$ ! (for decryption version, add /def=CRYPT to each of following lines,
X$ ! uncomment crypt compile line, and add crypt to link line)
X$ !
X$ gcc unzip
X$ gcc envargs
X$ gcc explode
X$ gcc extract
X$ gcc file_io
X$ gcc inflate
X$ gcc mapname
X$ gcc match
X$ gcc misc
X$ gcc unreduce
X$ gcc unshrink
X$ gcc vms
X$! gcc crypt
X$ link unzip, envargs, explode, extract, file_io, inflate, mapname,-
X`09match, misc, unreduce, unshrink, vms, gnu_cc:`5B000000`5Dgcclib.olb/lib,-
X`09sys$input:/opt
X sys$share:vaxcrtl.exe/shareable
X$ !
X$ ! Do ZipInfo:
X$ !
X$ gcc zipinfo
X$ gcc /def=(ZIPINFO) /object=misc_.obj misc
X$ gcc /def=(ZIPINFO) /object=vms_.obj vms
X$ link zipinfo, envargs, match, misc_, vms_, gnu_cc:`5B000000`5Dgcclib.olb/l
Vib,-
X`09sys$input:/opt
X sys$share:vaxcrtl.exe/shareable
X$ !
X$ ! Next line: put a similar line (full pathname for unzip.exe and zipinfo.
Vexe)
X$ ! in login.com. Remember to include the leading "$" before disk name.
X$ !
X$ unzip == "$''here'unzip.exe"`09`09! set up symbol to use unzip
X$ zipinfo == "$''here'zipinfo.exe"`09! set up symbol to use zipinfo
X$ !
X$ set noverify
$ CALL UNPACK [.UNZIP50]MAKE_GCC_UNZIP.COM;1 1193557854
$ create 'f'
X$ !
X$ !`09`09"Makefile" for VMS versions of UnZip and ZipInfo
X$ !`09`09`09`09(version: VAX C)
X$ !
X$ ! Find out current disk and directory
X$ !
X$ my_name = f$env("procedure")
X$ here = f$parse(my_name,,,"device") + f$parse(my_name,,,"directory")
X$ set verify`09! like "echo on", eh?
X$ !
X$ ! Do UnZip:
X$ ! (for decryption version, add /def=CRYPT to compile line, and add
X$ ! crypt to both compile and link lines)
X$ !
X$ cc unzip, envargs, explode, extract, file_io, inflate, mapname,-
X`09match, misc, unreduce, unshrink, vms
X$ link unzip, envargs, explode, extract, file_io, inflate, mapname,-
X`09match, misc, unreduce, unshrink, vms, sys$input:/opt
X sys$share:vaxcrtl.exe/shareable
X$ !
X$ ! Do ZipInfo:
X$ !
X$ cc zipinfo
X$ cc /def=(ZIPINFO) /obj=misc_.obj misc.c
X$ cc /def=(ZIPINFO) /obj=vms_.obj vms.c
X$ link zipinfo, envargs, match, misc_, vms_, sys$input:/opt
X sys$share:vaxcrtl.exe/shareable
X$ !
X$ ! Next line: put a similar line (full pathname for unzip.exe and zipinfo.
Vexe)
X$ ! in login.com. Remember to include the leading "$" before disk name.
X$ !
X$ unzip == "$''here'unzip.exe"`09`09! set up symbol to use unzip
X$ zipinfo == "$''here'zipinfo.exe"`09! set up symbol to use zipinfo
X$ !
X$ set noverify
$ CALL UNPACK [.UNZIP50]MAKE_VAXC_UNZIP.COM;1 1869379771
$ create 'f'
X/*--------------------------------------------------------------------------
V-
X
X mapname.c
X
X This routine changes DEC-20, VAX/VMS, and DOS-style filenames into normal
X Unix names (and vice versa, in some cases); it also creates any necessary`
V20
X directories, if the -d switch was specified.
X
X --------------------------------------------------------------------------
V-
X
X Notes:
X
X - This routine REALLY needs to be rewritten (different routines for
X each output OS, with different rules for different parts of the path
X name). If each zip program stores local-format names (like the VMS
X one did at one time), it would probably be best to convert to an in-
X termediate format first (assuming we're not extracting under the same
X OS as that under which the zipfile was created), then from that to
X the current operating system's format.
X - The strcpy and strcat operations on both cdp and filename may over-
X write memory, since they don't check lengths. With a kilobyte in
X which to work, this is probably not that big a deal, but it could
X cause problems eventually.
X
X --------------------------------------------------------------------------
V-*/
X
X
X#include "unzip.h"
X
X
X/*******************/
X/* Mapname Defines */
X/*******************/
X
X#ifdef VMS
X# define PERMS 0
X#else
X# define PERMS 0777
X#endif
X
X#ifndef NO_MKDIR
X# if (defined(DOS_OS2) && !defined(__GO32__))
X# if (_MSC_VER >= 600) /* have special MSC mkdir prototype */
X# include <direct.h>
X# else /* own prototype because dir.h conflicts? */
X int mkdir(const char *path);
X# endif /* ?(MSC 6.0 or later) */
X# define MKDIR(path,mode) mkdir(path)
X# else /* !DOS_OS2 `7C`7C __GO32__ */
X# ifdef MACOS
X# define MKDIR(path,mode) macmkdir(path,gnVRefNum,glDirID)
X# else /* !MACOS */
X# define MKDIR(path,mode) mkdir(path,mode)
X# endif /* ?MACOS */
X# endif /* ?(DOS_OS2 && !__GO32__) */
X#endif /* !NO_MKDIR */
X
X
X
X
X/************************/
X/* Function mapname() */
X/************************/
X
Xint mapname(create_dirs) /* return 0 if no error, 1 if caution (filename *
V/
X int create_dirs; /* truncated), 2 if warning (skip file because *
V/
X`7B /* dir doesn't exist), 3 if error (skip file)
V */
X#ifdef NO_MKDIR
X char command`5BFILNAMSIZ+40`5D; /* buffer for system() call */
X#endif
X#ifdef VMS
X int stat_val; /* temp. holder for stat() return value */
X char *dp, *xp; /* pointers to directory name */
X char *np; /* pointer into filename */
X#endif /* VMS */
X#ifdef DOS_VMS
X char *last_dot=NULL; /* last dot not converted to underscore */
X#endif /* DOS_VMS */
X#ifdef OS2
X char *last;
X extern char longfilename`5B`5D; /* AFTER file created and closed */
X extern int longname; /* used also in file_io.c: set EAs */
X int longdir;
X#endif /* OS2 */
X char name`5BFILNAMSIZ`5D; /* file name buffer */
X char *pp, *cp, *cdp; /* character pointers */
X char delim = '\0'; /* directory delimiter */
X int quote = FALSE; /* flags */
X int indir = FALSE;
X int done = FALSE;
X int created = FALSE;
X register unsigned workch; /* hold the character being tested */
X
X
X/*--------------------------------------------------------------------------
V-
X Initialize various pointers and counters and stuff.
X --------------------------------------------------------------------------
V-*/
X
X#ifdef MAP_DEBUG
X fprintf(stderr, "%s ", filename); /* echo name of this file */
X#endif
X cdp = (char *)NULL;
X pp = name; /* point to translation buffer */
X *name = '\0'; /* initialize buffer */
X if (!jflag) `7B /* -j => junk pathnames */
X cdp = (char *)malloc(strlen(filename) + 3); /* place for holding *
V/
X if (cdp == (char *)NULL) `7B /* directory name *
V/
X fprintf(stderr, "mapname: out of memory `5B%s`5D\n", filename);
X return 3;
X `7D
X#ifdef VMS
X *cdp++ = '`5B';
X xp = cdp; /* always points to last non-NULL char */
X *cdp++ = '.';
X#endif /* VMS */
X#ifdef MACOS
X *cdp = ':'; /* the Mac uses ':' as a directory separator
V */
X cdp`5B1`5D = '\0';
X#else /* !MACOS */
X *cdp = '\0';
X#endif /* ?MACOS */
X `7D
X
X/*--------------------------------------------------------------------------
V-
X Begin main loop through characters in filename.
X --------------------------------------------------------------------------
V-*/
X
X for (cp = filename; (workch = (unsigned char) *cp++) != 0 && !done;) `
V7B
X
X if (quote) `7B /* if char quoted, */
X *pp++ = (char) workch; /* include it literally */
X quote = FALSE;
X `7D else if (indir) `7B /* if in directory name, */
X if (workch == (unsigned)delim) /* look for end delimiter */
X indir = FALSE;
X `7D else
X switch (workch) `7B
X case '<': /* discard DEC-20 directory name */
X indir = TRUE;
X delim = '>';
X break;
X case '`5B': /* discard VMS directory name */
X indir = TRUE;
X delim = '`5D';
X break;
X case '/': /* discard Unix path name */
X case '\\': /* or MS-DOS path name... */
X /* iff -j flag was given */
X /*
X * Special processing case: if -j flag was not specified on
X * command line and create_dirs is TRUE, create any necessar
Vy
X * directories included in the pathname. Creation of dirs i
Vs
X * straightforward on BSD and MS-DOS machines but requires u
Vse
X * of the system() command on SysV systems (or any others wh
Vich
X * don't have mkdir()). The stat() check is necessary with
X * MSC because it doesn't have an EEXIST errno, and it saves
X * the overhead of multiple system() calls on SysV machines.
X */
X
X if (!jflag) `7B
X *pp = '\0';
X#ifdef VMS
X dp = name;
X while (*++xp = *dp++); /* copy name to cdp */
X last_dot = NULL; /* dir name: no dots allowed */
X strcpy(xp, ".dir"); /* add extension for stat check
V */
X stat_val = stat(cdp, &statbuf);
X *xp = '\0'; /* remove extension for all else
V */
X if (stat_val) `7B /* doesn't exist, so create */
X#else /* !VMS */
X#ifdef MSDOS
X if (last_dot != NULL) `7B /* one dot in dir name is leg
Val */
X *last_dot = '.';
X last_dot = NULL;
X `7D
X#endif /* MSDOS */
X strcat(cdp, name);
X#ifdef OS2
X if ((longdir = !IsFileNameValid(cdp)) != 0) `7B
X last = strrchr(cdp, '/');
X strcpy(longfilename, last ? last + 1 : cdp);
X fprintf(stderr, "renaming directory \"%s\"", cdp);
X ChangeNameForFAT(cdp);
X fprintf(stderr, " to \"%s\"\n", cdp);
X `7D
X#endif /* OS2 */
X if (stat(cdp, &statbuf)) `7B /* doesn't exist, so creat
Ve */
X#endif /* ?VMS */
X if (!create_dirs) /* told not to create (freshening)
V */
X return 2;
X#ifdef NO_MKDIR
X sprintf(command,
X "IFS=\" \t\n\" /bin/mkdir %s 2>/dev/null", cdp);
X if (system(command)) `7B
X#else /* !NO_MKDIR */
X if (MKDIR(cdp, PERMS) == -1) `7B
X#endif /* ?NO_MKDIR */
X perror(cdp);
X free(cdp);
X fprintf(stderr, "mapame: unable to process `5B%
Vs`5D\n",
X filename);
X return 3;
X `7D
X created = TRUE;
X#ifdef OS2
X if (longdir)
X SetLongNameEA(cdp, longfilename);
X#endif /* OS2 */
X `7D else if (!(statbuf.st_mode & S_IFDIR)) `7B
X fprintf(stderr,
X "mapname: %s exists but is not a directory\n", cd
Vp);
X free(cdp);
X fprintf(stderr, "mapame: unable to process `5B%s`5D
V\n",
X filename);
X return 3;
X `7D
X#ifdef VMS
X *xp = '/'; /* for now... (mkdir()) */
X#else /* !VMS */
X#ifdef MACOS
X strcat(cdp, ":");
X#else /* !MACOS */
X strcat(cdp, "/");
X#endif /* ?MACOS */
X#endif /* ?VMS */
X `7D
X pp = name;
X break;
X case ':':
X#ifdef UNIX /* colon is a valid character in Unix */
X *pp++ = workch; /* filenames, so keep it; anywhere else,
V */
X#else /* !UNIX */ /* change it to an underscore (should */
X *pp++ = '_'; /* NOT have stored drive/node names!!) */
X#endif /* ?UNIX */
X /* pp = name; (OLD) discard DEC dev: or node:: name */
X break;
X case '.': /* DEC-20 generation number or */
X#ifdef DOS_VMS /* MS-DOS or VMS separator */
X last_dot = pp; /* point at last dot so far... */
X *pp++ = '_'; /* convert dot to underscore */
X#else /* !DOS_VMS */
X *pp++ = workch;
X#endif /* ?DOS_VMS */
X break;
X case ';': /* VMS generation or DEC-20 attrib *
V/
X#ifdef MACOS
X if (V_flag `7C`7C macflag)
X#else /* !MACOS */
X if (V_flag) /* if requested, save VMS ";##"
V */
X#endif /* ?MACOS */ /* version info or Macintosh */
X *pp++ = (char) workch; /* (?) info; otherwise discard
V */
X else /* everything starting with */
X done = TRUE; /* semicolon. (Worry about */
X break; /* DEC-20 later.) */
X case '\026': /* control-V quote for special chars
V */
X quote = TRUE; /* set flag for next character */
X break;
X case ' ':
X#if (defined(VMS) `7C`7C defined(MTS))
X *pp++ = '_'; /* change spaces to underscore */
X#else /* !(VMS `7C`7C MTS) */ /* under VMS and MTS, and under
V DOS */
X#ifdef DOS_OS2 /* and OS/2 if -s not specified. */
X if (!sflag)
X *pp++ = '_';
X else
X#endif /* DOS_OS2 */
X *pp++ = (char) workch; /* otherwise, leave as spaces */
X#endif /* ?(VMS `7C`7C MTS) */
X break;
X default:
X#ifdef MACOS
X if ((macflag && ((unsigned)workch > 0x1F)) `7C`7C isprint(wo
Vrkch))
X#else /* !MACOS */
X#if (defined(DOS_OS2) `7C`7C (defined(UNIX) && !defined(VMS))) /* allow non
V-US */
X if (isprint(workch) `7C`7C (128 <= workch && workch <= 254))
X#else /* !(DOS_OS2 `7C`7C UNIX) */
X if (isprint(workch)) /* other printable, just keep */
X#endif /* ?(DOS_OS2 `7C`7C UNIX) */
X#endif /* ?MACOS */
X *pp++ = (char) workch;
X `7D /* end switch */
X `7D /* end for loop */
X *pp = '\0'; /* done with name: terminate it */
X#ifdef DOS_VMS /* and put a dot back in if VMS */
X if (last_dot != NULL) /* or MS-DOS */
X *last_dot = '.';
X#endif /* DOS_VMS */
X
X/*--------------------------------------------------------------------------
V-
X We COULD check for existing names right now, create a "unique" name, etc
V.
X At present, we do this in extract_or_test_files() (immediately after we
X return from here). If conversion went bad, the name'll either be nulled
X out (in which case we'll return non-0), or following procedures won't be
X able to create the extracted file and other error msgs will result.
X --------------------------------------------------------------------------
V-*/
X
X if (filename`5Bstrlen(filename) - 1`5D == '/') `7B
+-+-+-+-+-+-+-+- END OF PART 5 +-+-+-+-+-+-+-+-
Technical Details
Message-ID:
<8009604@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!mvb.saic.com!vmsnet-sourcesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!mvb.saic.com!vmsnet-sources From: goathunter@wkuvx1.bitnet Newsgroups: vmsnet.sources Subject: Zip v1.9 & UnZip v5.0, part 05/22 Message-ID: <8009604@MVB.SAIC.COM> Date: Tue, 01 Sep 1992 22:49:47 GMT Organization: Western Kentucky University, Bowling Green, KY Lines: 1413 Approved: Mark.Berryman@Mvb.Saic.Com