home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / unzip / part07 < prev    next >
Encoding:
Text File  |  1992-04-02  |  54.1 KB  |  1,468 lines

  1. Newsgroups: comp.sources.misc
  2. From: info-zip@cs.ucla.edu (Info-Zip)
  3. Subject:  v29i037:  unzip - Info-ZIP's portable UnZip v4.2, Part07/12
  4. Message-ID: <1992Apr3.063246.28969@sparky.imd.sterling.com>
  5. X-Md4-Signature: 297f2c9b5887a4a4b6a0f335e9e97781
  6. Date: Fri, 3 Apr 1992 06:32:46 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: info-zip@cs.ucla.edu (Info-Zip)
  10. Posting-number: Volume 29, Issue 37
  11. Archive-name: unzip/part07
  12. Environment: Unix, VMS, OS/2, MS-DOS, Amiga, Macintosh
  13. Supersedes: unzip, Volume 19, Issues 96-101
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  Makefile OS2/unzip.bad ZipRules misc.c
  22. # Wrapped by kent@sparky on Mon Mar 30 01:45:54 1992
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 7 (of 12)."'
  26. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Makefile'\"
  28. else
  29.   echo shar: Extracting \"'Makefile'\" \(21837 characters\)
  30.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  31. X# ===========================================================================
  32. X# Makefile for UnZip, ZipInfo & Ship:  Unix, OS/2 and MS-DOS (MSC NMAKE only)
  33. X# Version:  no decrypt + (conditionally) inflate
  34. X# ===========================================================================
  35. X#
  36. X#
  37. X# INSTRUCTIONS (such as they are):
  38. X#
  39. X# "make vax"    -- makes UnZip on a VAX 11-780 BSD 4.3 in current directory
  40. X#           (or a SysV VAX, or an 8600 running Ultrix, or...)
  41. X# "make"    -- uses environment variable SYSTEM to set the type
  42. X#           system to compile for.  This doesn't work for some
  43. X#           particularly brain-damaged versions of make (VAX BSD,
  44. X#           Gould, and SCO Unix are in this group).  If SYSTEM not
  45. X#           set, gives instructions on what to try instead.
  46. X# "make list"    -- lists all supported systems (targets), including ship
  47. X#           and zipinfo targets
  48. X# "make wombat" -- Chokes and dies if you haven't added the specifics
  49. X#           for your Wombat 68000 (or whatever) to the systems list.
  50. X#
  51. X# CFLAGS are flags for the C compiler.  LDFLAGS are flags for the loader.
  52. X# LDFLAGS2 are more flags for the loader, if they need to be at the end of
  53. X# the line instead of at the beginning.
  54. X#
  55. X# My host (a VAX 11-780 running BSD 4.3) is hereafter referred to as "my host."
  56. X#
  57. X# My host's /usr/include/sys/param.h defines BSD for me.  You may have to add
  58. X# "-DBSD" to the list of CFLAGS for your system.
  59. X#
  60. X# Some versions of make do not define the macro "$(MAKE)" (my host did not).
  61. X# The makefile should now handle such systems correctly, more or less; the
  62. X# possible exception to this is if you've used a make command-line option
  63. X# (for example, the one which displays the commands which WOULD be executed,
  64. X# but doesn't actually execute them).  It probably needs some more tinkering.
  65. X# If things still don't work, use "make" instead of "$(MAKE)" in your system's
  66. X# makerule.  Or try adding the following line to your .login file:
  67. X#   setenv MAKE "make"
  68. X# (It didn't help on my host.)
  69. X#
  70. X# memcpy and memset are provided for those systems that don't have them;
  71. X# they're found in misc.c and will be used if -DZMEM is included in the list
  72. X# of CFLAGS.  These days ALMOST all systems have them (they're mandated by
  73. X# ANSI), but older systems might be lacking.  And at least ONE machine's
  74. X# version results in some serious performance degradation...
  75. X#
  76. X# SCO Unix 3.2.0:  Don't use -Ox with cc (derived from Microsoft 5.1); there
  77. X# is a bug in the loop optimization which causes bad CRC's.  [Onno van der
  78. X# Linden]
  79. X#
  80. X# Be sure to test your nice new UnZip; successful compilation does not always
  81. X# imply a working program.
  82. X
  83. X
  84. X#####################
  85. X# MACRO DEFINITIONS #
  86. X#####################
  87. X
  88. X# Defaults most systems use (use LOCAL_UNZIP in environment to add flags).
  89. X# To add inflation:  uncomment INFL_OBJ below or add it to your environment
  90. X# as appropriate, and add -DINFLATE to CFLAGS or to LOCAL_UNZIP.  (This
  91. X# won't work if you don't have inflate.c, so don't be a goober...)
  92. X
  93. XCC = cc
  94. XCFLAGS = -O -DUNIX $(CR) $(LOCAL_UNZIP)
  95. XZC = -DZMEM
  96. XLD = cc
  97. XLDFLAGS = -o unzip
  98. XLDFLAGS2 = -s
  99. XZL = -o zipinfo
  100. XZL2 = -s
  101. XMV = mv
  102. XEXE =
  103. XO = .o
  104. X#INFL_OBJ = inflate.o  -or-  inflate.obj  (pick one)
  105. XOBJS = unzip$O extract$O file_io$O $(INFL_OBJ)\
  106. X   mapname$O match$O misc$O unimplod$O unreduce$O unshrink$O
  107. XOS2_OBJS = unzip.obj dosname.obj extract.obj file_io.obj $(INFL_OBJ)\
  108. X   mapname.obj match.obj misc.obj unimplod.obj unreduce.obj unshrink.obj
  109. XZI_OBJS = zipinfo$O misc_$O match$O
  110. X
  111. XSHELL = /bin/sh
  112. X
  113. X# list of supported systems in this version
  114. XSYSTEMS1 = 386i 3Bx 7300 amdahl apollo aviion bsd bull coherent convex
  115. XSYSTEMS2 = cray cray_cc cyber_sgi dec dnix encore eta gcc_os2 generic
  116. XSYSTEMS3 = generic2 gould hk68 hp icc_os2 minix mips msc_dos msc_os2 next
  117. XSYSTEMS4 = p_iris pyramid rs6000 rtaix sco sco_dos sco_x286 sequent sgi
  118. XSYSTEMS5 = stellar sun sysv tahoe ultrix vax wombat
  119. X
  120. XSYS_UTIL1 = ship ship_dos ship_gcc ship_icc ship_os2 ship_sysv zi_dos
  121. XSYS_UTIL2 = zi_gcc zi_icc zi_os2 zipinfo 
  122. X
  123. X####################
  124. X# DEFAULT HANDLING #
  125. X####################
  126. X
  127. X# The below will try to use your shell variable "SYSTEM" as the type system
  128. X# to use (e.g., if you type "make" with no parameters at the command line).
  129. X# The test for $(MAKE) is necessary for VAX BSD make (and Gould, apparently),
  130. X# as is the "goober" (else stupid makes see an "else ;" statement, which they
  131. X# don't like).  "goober" must then be made into a valid target for machines
  132. X# which DO define MAKE properly (and have SYSTEM set).  Quel kluge, non?
  133. X# And to top it all off, it appears that the VAX, at least, can't pick SYSTEM
  134. X# out of the environment either (which, I suppose, should not be surprising).
  135. X# [Btw, if the empty "goober" target causes someone else's make to barf, just
  136. X# add an "@echo > /dev/null" command (or whatever).  Works OK on the Amdahl
  137. X# and Crays, though.]
  138. X
  139. Xdefault:
  140. X    @if test -z "$(MAKE)"; then\
  141. X        if test -z "$(SYSTEM)";\
  142. X        then make ERROR;\
  143. X        else make $(SYSTEM) MAKE="make";\
  144. X        fi;\
  145. X    else\
  146. X        if test -z "$(SYSTEM)";\
  147. X        then $(MAKE) ERROR;\
  148. X        else $(MAKE) $(SYSTEM) goober;\
  149. X        fi;\
  150. X    fi
  151. X
  152. Xgoober:
  153. X
  154. XERROR:
  155. X    @echo
  156. X    @echo\
  157. X "  If you're not sure about the characteristics of your system, try typing"
  158. X    @echo\
  159. X '  "make generic".  If the compiler barfs and says something unpleasant about'
  160. X    @echo\
  161. X '  "timezone redefined," try typing "make clean" followed by "make generic2".'
  162. X    @echo\
  163. X '  One of these actions should produce a working copy of unzip on most Unix'
  164. X    @echo\
  165. X '  systems.  If you know a bit more about the machine on which you work, you'
  166. X    @echo\
  167. X '  might try "make list" for a list of the specific systems supported herein.'
  168. X    @echo\
  169. X '  And as a last resort, feel free to read the numerous comments within the'
  170. X    @echo\
  171. X '  Makefile itself.  Have an excruciatingly pleasant day.'
  172. X    @echo
  173. X
  174. Xlist:
  175. X    @echo
  176. X    @echo\
  177. X 'Type "make <system>", where <system> is one of the following:'
  178. X    @echo
  179. X    @echo  "    $(SYSTEMS1)"
  180. X    @echo  "    $(SYSTEMS2)"
  181. X    @echo  "    $(SYSTEMS3)"
  182. X    @echo  "    $(SYSTEMS4)"
  183. X    @echo  "    $(SYSTEMS5)"
  184. X    @echo
  185. X    @echo\
  186. X 'Otherwise set the shell variable SYSTEM to one of these and just type "make".'
  187. X    @echo\
  188. X 'Targets for related utilities (ZipInfo and Ship) include:'
  189. X    @echo
  190. X    @echo  "    $(SYS_UTIL1)"
  191. X    @echo  "    $(SYS_UTIL2)"
  192. X    @echo
  193. X    @echo\
  194. X 'For further (very useful) information, please read the comments in Makefile.'
  195. X    @echo
  196. X
  197. X
  198. X###############################################
  199. X# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
  200. X###############################################
  201. X
  202. X.c$O :
  203. X    $(CC) -c $(CFLAGS) $*.c
  204. X
  205. Xunzip$(EXE):    $(OBJS)
  206. X    $(LD) $(LDFLAGS) $(OBJS) $(LDFLAGS2)
  207. X
  208. Xcrypt$O:        crypt.c unzip.h zip.h    # may or may not be in distribution
  209. Xdosname.obj:    dosname.c        # for OS/2 only
  210. Xextract$O:      extract.c unzip.h
  211. Xfile_io$O:      file_io.c unzip.h
  212. Xinflate$O:      inflate.c unzip.h    # may or may not be in distribution
  213. Xmapname$O:      mapname.c unzip.h
  214. Xmatch$O:        match.c unzip.h
  215. Xmisc$O:         misc.c unzip.h
  216. Xunimplod$O:     unimplod.c unzip.h
  217. Xunreduce$O:     unreduce.c unzip.h
  218. Xunshrink$O:     unshrink.c unzip.h
  219. Xunzip$O:        unzip.c unzip.h
  220. X
  221. Xclean:
  222. X    rm -f $(OBJS) unzip$(EXE)
  223. X
  224. X
  225. X################################
  226. X# INDIVIDUAL MACHINE MAKERULES #
  227. X################################
  228. X
  229. X# these are the makerules for various systems
  230. X# TABS ARE REQUIRED FOR MANY VERSIONS OF "MAKE"!
  231. X
  232. X
  233. X# ---------------------------------------------------------------------------
  234. X#   Generic targets (can't assume make utility groks "$(MAKE)")
  235. X# ---------------------------------------------------------------------------
  236. X
  237. Xgeneric:    unzip    # first try if unknown
  238. X
  239. Xgeneric2:        # second try if unknown:  hope make is called "make"...
  240. X    make unzip CFLAGS="$(CFLAGS) -DBSD"
  241. X
  242. X# ---------------------------------------------------------------------------
  243. X#   "Normal" group (both big- and little-endian, structure-padding or not):
  244. X# ---------------------------------------------------------------------------
  245. X
  246. X386i:        unzip    # sun386i, SunOS 4.0.2 ["sun:" works, too, but bigger]
  247. X3Bx:        unzip    # AT&T 3B2/1000-80; should work on any WE32XXX machine
  248. X7300:        unzip    # AT&T 7300 (M68000/SysV)
  249. Xapollo:        unzip    # Apollo Domain/OS machines
  250. Xaviion:         unzip    # Data General AViiONs, DG/UX 4.3x
  251. Xbull:        unzip    # Bull DPX/2, BOS 2.00.45 (doesn't require -Xk switch)
  252. Xcoherent:    unzip    # Coherent 3.10, Mark Williams C
  253. Xcray_cc:    unzip    # Cray-2 and Y-MP, using default (possibly old) compiler
  254. Xdec:        unzip    # DEC 5820 (MIPS RISC), test version of Ultrix v4.0
  255. Xdnix:        unzip    # 680X0, DIAB dnix 5.2/5.3 (a Swedish System V clone)
  256. Xencore:        unzip    # Multimax
  257. Xeta:        unzip    # ETA-10P*, hybrid SysV with BSD 4.3 enhancements
  258. Xgould:        unzip    # Gould PN9000 running UTX/32 2.1Bu01
  259. Xhp:        unzip    # HP 9000 series (68020), 4.3BSD or HP-UX A.B3.10 Ver D
  260. Xhp_ux:        unzip    # (to match zip's makefile entry)
  261. Xmips:        unzip    # MIPS M120-5(?), SysV R3 [error in sys/param.h file?]
  262. Xrs6000:        unzip    # IBM RS/6000 under AIX 3
  263. Xrtaix:        unzip    # IBM RT 6150 under AIX 2.2.1
  264. Xsco:        unzip    # Xenix/386 (tested on 2.3.1); SCO Unix 3.2.0.
  265. Xstellar:    unzip    # gs-2000
  266. Xsun:        unzip    # Sun 4/110, SunOS 4.0.3c; Sun 3 (68020), SunOS 4.0.3
  267. Xtahoe:        unzip    # tahoe (CCI Power6/32), 4.3BSD
  268. Xultrix:        unzip    # VAXen, DEC 58x0 (MIPS guts), DECstation 2100; v4.x
  269. Xvax:        unzip    # general-purpose VAX target (not counting VMS)
  270. X
  271. X# ---------------------------------------------------------------------------
  272. X#   BSD group (for timezone structs [struct timeb]):
  273. X# ---------------------------------------------------------------------------
  274. X
  275. Xbsd:        _bsd    # generic BSD (BSD 4.2, Ultrix handled in unzip.h)
  276. X
  277. X_bsd:
  278. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DBSD"
  279. X
  280. X# ---------------------------------------------------------------------------
  281. X#   SysV group (for extern long timezone and ioctl.h instead of sgtty.h):
  282. X# ---------------------------------------------------------------------------
  283. X
  284. Xsysv:        _sysv    # generic SysV
  285. Xamdahl:        _sysv    # Amdahl (IBM) mainframe, UTS (SysV) 1.2.4 and 2.0.1
  286. Xsgi:        _sysv    # Silicon Graphics Iris 4D, Irix SysV rel. 3.3.2
  287. X
  288. X_sysv:
  289. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DTERMIO"
  290. X
  291. X# ---------------------------------------------------------------------------
  292. X#   "Unique" group (require non-standard options):
  293. X# ---------------------------------------------------------------------------
  294. X
  295. X# Enclosed you'll find a context diff for the unzip41 makefile
  296. X# which enhances compilation on a convex.  The previous version
  297. X# probably worked great a couple of years ago, and would still do
  298. X# so if one compiles in our "backward compatible" pcc mode.   The
  299. X# following allows it to work better in a modern convexian environment
  300. X# (define __STDC__ manually because default compilation mode has
  301. X# extensions and thus doesn't do so).  [5 Mar 1992:  -D__STDC__ removed
  302. X# for now because of problems with stat.h]
  303. X#
  304. X#    $(MAKE) unzip CFLAGS="$(CFLAGS) -D__STDC__ -DCONVEX -ext" ...
  305. Xconvex:            # previous version was tested on C200/C400
  306. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DCONVEX -ext"\
  307. X     LDFLAGS="$(LDFLAGS) -ext"
  308. X
  309. X# Cray-2 and Y-MP, running Unicos 5.1 or 6.0 (SysV + BSD enhancements)
  310. X# and Standard (ANSI) C compiler 1.5, 2.0 or 3.0.
  311. Xcray:
  312. X    $(MAKE) unzip CC="scc" LD="scc"
  313. X
  314. X# The unzip41 build on a Cyber 910/SGI running Irix v3.3.3 was successful
  315. X# with the following change to Makefile:
  316. Xcyber_sgi:
  317. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -I/usr/include/bsd"\
  318. X     LDFLAGS="-lbsd $(LDFLAGS)"
  319. X
  320. X# OS/2 2.0 (32-bit) with GNU C compiler (emx)
  321. Xgcc_os2:
  322. X    $(MAKE) unzip.exe CC=gcc LD=gcc EXE=.exe\
  323. X     OBJS="$(OBJS) dosname.o"\
  324. X     CFLAGS="-O -DOS2 -DEMX32 $(CR) $(LOCAL_UNZIP)"\
  325. X     LDFLAGS="-s" LDFLAGS2="-los2 -o unzip.exe"
  326. X
  327. X# Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000
  328. Xhk68:
  329. X    $(MAKE) unzip CC="gcc" LD="gcc" LDFLAGS="-n $(LDFLAGS)" \
  330. X    CFLAGS="-ga -X138 -DUNIX $(CR) $(LOCAL_UNZIP) -Dlocaltime=localti -Dtimezone=timezon"
  331. X
  332. X# OS/2 2.0 (32-bit) with IBM C Set/2 compiler
  333. X#
  334. Xfile_io2.obj:        # compile this one module without optimization
  335. X    $(CC) -c $(CFLAGS) -O- -Fofile_io2.obj file_io.c
  336. X
  337. Xicc_os2:
  338. X    $(MAKE) -nologo unzip.exe CC=icc LD=icc EXE=.exe O=.obj\
  339. X     OBJS="$(OS2_OBJS:file_io.obj=file_io2.obj)"\
  340. X     CFLAGS="-Q -Sm -O -Gs -DOS2 $(CR) $(LOCAL_UNZIP)"\
  341. X     LDFLAGS="-Q" LDFLAGS2="unzip.def -Fe unzip.exe"
  342. X
  343. X# Minix 1.5 PC for the 386 with gcc or bcc
  344. Xminix:
  345. X    $(MAKE) unzip CC=gcc CFLAGS="$(CFLAGS) -DMINIX"
  346. X
  347. X# PCs (IBM-type), running MS-DOS, Microsoft C 6.00 and NMAKE.  Can't use the
  348. X# SYSTEM environment variable; that requires processing the "default:" target,
  349. X# which expands to some 200+ characters--well over DOS's 128-character limit.
  350. X# "nmake msc_dos" works fine, aside from an annoying message, "temporary file
  351. X# e:\ln023193 has been created."  I have no idea how to suppress this, but it
  352. X# appears to be benign (comes from the link phase; the file is always deleted).
  353. X# The environment variable LOCAL_UNZIP should be set to something appropriate
  354. X# if your library uses other than the default floating-point routines; for 
  355. X# example, SET LOCAL_UNZIP=-FPi87.  This target assumes the small-model library
  356. X# and an 80286 or better.  At present, everything should still fit within the
  357. X# 128-character command-line limit (barely); if not, remove the -nologo.  [GRR]
  358. X#
  359. Xmsc_dos:
  360. X    $(MAKE) unzip.exe\
  361. X     CFLAGS="-Ox $(CR) $(LOCAL_UNZIP) -nologo -G2" CC=cl\
  362. X     LD=link EXE=.exe O=.obj LDFLAGS="/noi /nol" LDFLAGS2=",unzip;"
  363. X
  364. X# The stack size for OS/2 must be increased to 0x1000, i.e. 
  365. X# "-F 1000" has to be added to LDFLAGS for msc_os2. Otherwise
  366. X# stack overflow occurs, which are only detected if compiled
  367. X# with debugging option, i.e. not with -Gs!! Otherwise something
  368. X# minor important seems to be overwritten :-)  [K. U. Rommel]
  369. X#
  370. X# Extra stack causes errors in GRR version ("/st:0x1000"); no problems
  371. X# encountered so far without.  EXEHDR /VERBOSE reports 0a00 bytes of
  372. X# extra stack already, so maybe the two versions are different... [GRR]
  373. X#
  374. X# $(LOCAL_UNZIP):  math libraries and/or any other personal or debugging
  375. X#                  definitions:  e.g., SET LOCAL_UNZIP=-FPi87 -DDEBUG_STRUC
  376. X# $(NOD):  intended to be used as   SET NOD=-link /nod:slibcep   to allow the
  377. X#          use of default library names (slibce.lib) instead of protected-mode
  378. X#          names (slibcep.lib), but it fails:  MSC adds its own /nod qualifier,
  379. X#          and there seems to be no way to override this.  Typical...
  380. X#
  381. X#msc_os2:        # old Newtware version (may not work)
  382. X#    $(MAKE) -nologo unzip.exe CC=cl LD=link EXE=.exe O=.obj\
  383. X#      OBJS="$(OBJS) dosname.obj"\
  384. X#      CFLAGS="-nologo -Ox -G2s -DOS2 $(CR) $(LOCAL_UNZIP) -Lp"\
  385. X#      LDFLAGS="/noi /nol" LDFLAGS2=",unzip,,,unzip.def"
  386. X#    bind -nologo unzip.exe -n DOSSETPATHINFO
  387. Xmsc_os2:        # Kai Uwe Rommel version
  388. X    $(MAKE) -nologo unzip.exe CC=cl LD=cl EXE=.exe O=.obj\
  389. X     OBJS="$(OS2_OBJS)"\
  390. X     CFLAGS="-nologo -Ox -G2s -DOS2 $(CR) $(LOCAL_UNZIP)"\
  391. X     LDFLAGS="-nologo $(LOCAL_UNZIP) -Lp -F 1000"\
  392. X     LDFLAGS2="unzip.def -o unzip.exe $(NOD)"
  393. X    bind -nologo unzip.exe -n DOSSETPATHINFO
  394. X
  395. X# NeXT 2.x: make the executable smaller.
  396. Xnext:            # 68030 BSD 4.3+Mach
  397. X    $(MAKE) unzip LDFLAGS2="-object -s"
  398. X
  399. X# I successfully compiled and tested the unzip program (v30) for the
  400. X# Silicon Graphics environment (Personal Iris 4D20/G with IRIX v3.2.2)
  401. Xp_iris:            # Silicon Graphics Personal Iris 4D20
  402. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -I/usr/include/bsd -DBSD"\
  403. X     LDFLAGS="-lbsd $(LDFLAGS)"
  404. X
  405. X# I have finished porting unzip 3.0 to the Pyramid 90X under OSX4.1.
  406. X# The biggest problem was the default structure alignment yielding two
  407. X# extra bytes.  The compiler has the -q option to pack structures, and
  408. X# this was all that was needed.  To avoid needing ZMEMS we could compile in
  409. X# the att universe, but it runs slower!
  410. X#
  411. Xpyramid:    # Pyramid 90X, probably all, under >= OSx4.1, BSD universe
  412. X    make unzip CFLAGS="$(CFLAGS) -q -DBSD -DZMEM"
  413. X
  414. X# SCO cross compile from unix to DOS. Tested with Xenix/386 and
  415. X# OpenDeskTop. Should work with xenix/286 as well. (davidsen)
  416. X# Note that you *must* remove the unix objects and executable
  417. X# before doing this!
  418. X#
  419. Xsco_dos:
  420. X    $(MAKE) unzip CFLAGS="-O $(CR) $(LOCAL_UNZIP) -dos -M0" LDFLAGS="-dos"\
  421. X     LDFLAGS2="-o unzip.exe"
  422. X
  423. X# SCO Xenix/286 2.2.1
  424. Xsco_x286:
  425. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -Ml2" LDFLAGS="$(LDFLAGS) -Ml2"
  426. X
  427. X# Sequent Symmetry is a 386 but needs -DZMEM
  428. X# This should also work on Balance but I can't test it just yet.
  429. Xsequent:    # Sequent w/Dynix
  430. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DBSD -DZMEM"
  431. X
  432. X# I didn't do this.  I swear.  No, really.
  433. Xwombat:        # Wombat 68000 (or whatever)
  434. X    @echo
  435. X    @echo  '    Ha ha!  Just kidding.'
  436. X    @echo
  437. X
  438. X
  439. X##################
  440. X# SHIP MAKERULES #
  441. X##################
  442. X
  443. X# Ship section:  ship comes with the Zip distribution and is more properly
  444. X# supported there.  But the following targets should at least get you started
  445. X# if for some reason you're only interested in UnZip.  The comments near the
  446. X# top of ship.c explain how to use it, and a little further poking around
  447. X# should clear up any problems related to things which should be defined but
  448. X# aren't, or which shouldn't be defined but are.  As with ZipInfo below, we
  449. X# assume *some* competence...
  450. X
  451. X_ship:    ship.c $(DEF)
  452. X    $(CC) $(CFLAGS) ship.c $(DEF) $(LDFLAGS2)
  453. X
  454. Xship:            # most BSD-type systems, by default
  455. X    $(MAKE) _ship LDFLAGS2="-s -o ship"
  456. X
  457. Xship_sysv:        # not tested; DIRENT used only to determine mailer
  458. X    $(MAKE) _ship CFLAGS="$(CFLAGS) -DDIRENT" LDFLAGS2="-s -o ship"
  459. X
  460. Xship_dos:        # not tested
  461. X    $(MAKE) -nologo _ship CC=cl EXE=.exe\
  462. X     CFLAGS="-nologo -Ox $(LOCAL_UNZIP) -G2s -F 2000"\
  463. X     LDFLAGS2="-o ship.exe"
  464. X
  465. Xship_os2:        # MSC 6.0, 16-bit OS/2
  466. X    $(MAKE) -nologo _ship CC=cl EXE=.exe DEF=ship.def\
  467. X     CFLAGS="-nologo -Ox $(LOCAL_UNZIP) -G2s -DOS2 -Lp -F 2000"\
  468. X     LDFLAGS2="-o ship.exe"
  469. X    bind -nologo ship.exe
  470. X
  471. Xship_icc:        # IBM C Set/2, 32-bit OS/2
  472. X    $(MAKE) -nologo _ship CC=icc EXE=.exe DEF=ship.def\
  473. X     CFLAGS="-Q -Sm -O $(LOCAL_UNZIP) -Gs -DOS2"\
  474. X     LDFLAGS2="-Fe ship.exe"
  475. X
  476. Xship_gcc:        # GNU gcc / emx, 32-bit OS/2
  477. X    $(MAKE) _ship CC=gcc LD=gcc EXE=.exe\
  478. X     CFLAGS="-O -DOS2" LDFLAGS2="-s -o ship.exe"
  479. X
  480. X
  481. X#####################
  482. X# ZIPINFO MAKERULES #
  483. X#####################
  484. X
  485. X# Zipinfo section:  it is assumed here that anyone competent enough to
  486. X# wonder about the internal guts of a zipfile is probably also competent
  487. X# enough to compile the program without a lot of hand-holding.  If not...
  488. X# oh well. :-)
  489. X
  490. Xzipinfo$O:    zipinfo.c unzip.h
  491. X    $(CC) -c $(CFLAGS) $(ZC) zipinfo.c
  492. X
  493. Xmisc_$O:    misc.c unzip.h
  494. X    $(MV) misc.c misc_.c
  495. X    $(CC) -c $(CFLAGS) $(ZC) -DZIPINFO misc_.c
  496. X    $(MV) misc_.c misc.c
  497. X
  498. Xzipinfo$(EXE):    $(ZI_OBJS)
  499. X    $(LD) $(ZL) $(ZI_OBJS) $(ZL2)
  500. X
  501. Xzi_dos:
  502. X    $(MAKE) zipinfo.exe CFLAGS="-Ox -nologo $(LOCAL_UNZIP) -G2" CC=cl\
  503. X     LD=link EXE=.exe O=.obj ZL="/noi /nol" ZL2=",zipinfo;" ZC="" MV="ren"
  504. X
  505. X#zi_os2:         # GRR (Newtware) version (do not delete!)
  506. X#    $(MAKE) -nologo zipinfo.exe CC=cl LD=link EXE=.exe O=.obj\
  507. X#     CFLAGS="-nologo -Ox $(LOCAL_UNZIP) -G2s -DOS2 -Lp" ZC="" MV="ren"\
  508. X#     ZL="/nol /noi" ZL2=",zipinfo,,,zipinfo.def"
  509. X#    bind -nologo zipinfo.exe
  510. Xzi_os2:         # Kai Uwe Rommel version (do not delete!)
  511. X    $(MAKE) -nologo zipinfo.exe CC=cl LD=cl EXE=.exe O=.obj\
  512. X     CFLAGS="-nologo -Ox $(LOCAL_UNZIP) -G2s -DOS2" ZC="" MV="ren"\
  513. X     ZL="-nologo $(LOCAL_UNZIP) -Lp -Fb" ZL2="zipinfo.def -o zipinfo.exe"
  514. X
  515. Xzi_icc:            # IBM C Set/2, 32-bit OS/2
  516. X    $(MAKE) -nologo zipinfo.exe CC=icc LD=icc EXE=.exe O=.obj\
  517. X     CFLAGS="-Q -Sm -O -Gs -DOS2" ZC="" MV="ren"\
  518. X     ZL="-Q" ZL2="zipinfo.def -Fe zipinfo.exe"
  519. X
  520. Xzi_gcc:            # GNU gcc / emx, 32-bit OS/2
  521. X    $(MAKE) zipinfo.exe CC=gcc LD=gcc EXE=.exe\
  522. X     CFLAGS="-O -DOS2 -DEMX32" ZC="" MV="ren"\
  523. X     ZL="-s" ZL2="-o zipinfo.exe"
  524. X
  525. X
  526. X################
  527. X# ATTRIBUTIONS #
  528. X################
  529. X
  530. X# Thanks to the following people for their help in testing and/or porting
  531. X# to various machines (and thanks to the many others who aren't listed
  532. X# here but should be):
  533. X#
  534. X#  (original Unix port:  Carl Mascott <cmascott@world.std.com>)
  535. X#  386i:    Richard Stephen <stephen@corp.telecom.co.nz>
  536. X#  3Bx:        Bob Kemp <hrrca!bobc@cbnewse.att.com>
  537. X#  7300:    Richard H. Gumpertz <rhg@cpsolv.CPS.COM>
  538. X#        Greg Roelofs <roelofs@amelia.nas.nasa.gov>
  539. X#  amdahl:    Kim DeVaughn <ked01@juts.ccc.amdahl.com>, Greg Roelofs
  540. X#  apollo:    Tim Geibelhaus
  541. X#  aviion:    Bruce Kahn <bkahn@archive.webo.dg.com>
  542. X#  bull:    Matt D'Errico <doc@magna.com>
  543. X#  coherent:    David Fenyes <dfenyes@thesis1.med.uth.tmc.edu>
  544. X#  convex:    Randy Wright <rwright@convex.com>
  545. X#  cray:    Greg Roelofs, Paul Borman <prb@cray.com>
  546. X#  cyber_sgi:    Clint Pulley <u001@cs910.cciw.ca>
  547. X#  dec:        "Moby" Dick O'Connor <djo7613@u.washington.edu>
  548. X#  dnix:    Bo Kullmar <bk@kullmar.se>
  549. X#  eta:        Greg Flint <afc@klaatu.cc.purdue.edu>
  550. X#  gould:    Onno van der Linden <linden@fwi.uva.nl>
  551. X#  hk68:    John Limpert <gronk!johnl@uunet.UU.NET>
  552. X#  hp:        Randy McCaskile <rmccask@seas.gwu.edu> (HP-UX)
  553. X#        Gershon Elber <gershon@cs.utah.edu> (HP BSD 4.3)
  554. X#  icc_os2:    Kai Uwe Rommel <rommel@informatik.tu-muenchen.de>
  555. X#  minix:    Kai Uwe Rommel (Minix 1.5)
  556. X#  mips:    Peter Jones <jones@mips1.uqam.ca>
  557. X#  msc_dos:    Greg Roelofs
  558. X#  msc_os2:    Wim Bonner <wbonner@yoda.eecs.wsu.edu>
  559. X#        Kai Uwe Rommel, Greg Roelofs
  560. X#  next:    Mark Adler <madler@piglet.caltech.edu>
  561. X#  p_iris:    Valter V. Cavecchia <root@itnsg1.cineca.it>
  562. X#  pyramid:    James Dugal <jpd@usl.edu>
  563. X#  rs6000:    Filip Gieszczykiewicz <fmg@smi.med.pitt.edu>
  564. X#  rtaix:    Erik-Jan Vens
  565. X#  sco:        Onno van der Linden (SCO Unix 3.2.0)
  566. X#           Bill Davidsen <davidsen@crdos1.crd.ge.com> (Xenix/386)
  567. X#  sco_dos:    Bill Davidsen
  568. X#  sco_x286:    Ricky Mobley <ddi1!lrark!rick@uunet.UU.NET>
  569. X#  sequent:    Phil Howard <phil@ux1.cso.uiuc.edu>
  570. X#  sgi:        Greg Roelofs (Iris 4D/380?)
  571. X#  sun:        Onno van der Linden (Sun 4), Greg Roelofs (Sun 3, 4)
  572. X#  tahoe:    Mark Edwards <mce%sdcc10@ucsd.edu>
  573. X#  ultrix:    Greg Flint (VAX)
  574. X#        Michael Graff <explorer@iastate.edu> (DECstation 2100?)
  575. X#        Greg Roelofs (DEC 5810)
  576. X#        Alex A Sergejew <aas@brain.wph.uq.oz.au>
  577. X#  vax:        Forrest Gehrke <feg@dodger.att.com> (SysV)
  578. X#        David Kirschbaum <kirsch@usasoc.soc.mil> (BSD 4.3)
  579. X#        Jim Steiner <steiner@pica.army.mil> (8600+Ultrix)
  580. X#  wombat:    Joe Isuzu <joe@trustme.isuzu.com>
  581. X#  zi_dos:    Greg Roelofs
  582. X#  zi_icc:    Kai Uwe Rommel
  583. X#  zi_os2:    Greg Roelofs, Kai Uwe Rommel
  584. X#  zipinfo:    Greg Roelofs
  585. END_OF_FILE
  586.   if test 21837 -ne `wc -c <'Makefile'`; then
  587.     echo shar: \"'Makefile'\" unpacked with wrong size!
  588.   fi
  589.   # end of 'Makefile'
  590. fi
  591. if test -f 'OS2/unzip.bad' -a "${1}" != "-c" ; then 
  592.   echo shar: Will not clobber existing file \"'OS2/unzip.bad'\"
  593. else
  594.   echo shar: Extracting \"'OS2/unzip.bad'\" \(15 characters\)
  595.   sed "s/^X//" >'OS2/unzip.bad' <<'END_OF_FILE'
  596. XDOSSETPATHINFO
  597. END_OF_FILE
  598.   if test 15 -ne `wc -c <'OS2/unzip.bad'`; then
  599.     echo shar: \"'OS2/unzip.bad'\" unpacked with wrong size!
  600.   fi
  601.   # end of 'OS2/unzip.bad'
  602. fi
  603. if test -f 'ZipRules' -a "${1}" != "-c" ; then 
  604.   echo shar: Will not clobber existing file \"'ZipRules'\"
  605. else
  606.   echo shar: Extracting \"'ZipRules'\" \(5218 characters\)
  607.   sed "s/^X//" >'ZipRules' <<'END_OF_FILE'
  608. XSubject: Info-ZIP Rules (No Feelthy ...)
  609. X
  610. XIn discussions with Mark Adler (and others), I realized we in the Info-ZIP
  611. Xcommunity have been evolving a set of rules that maybe oughtta be
  612. Xdocumented, archived, and available to potential contributors.
  613. X
  614. XThe following appear to meet our requirements.  Please observe these
  615. Xrules when submitting source, context diff, or other files to Info-ZIP.
  616. X
  617. X
  618. X1 - "NO FEELTHY TABS"
  619. X
  620. X    Many editors and EMail systems either have no capability to use and/or
  621. Xdisplay the Ascii 9 TAB character correctly, or there are variable tab
  622. Xcolumns, or other horrors.  (My MaxEMail offline email editor for one.)
  623. X
  624. X    Bottom line:  use spaces, not tabs.
  625. X
  626. X    Related utility programs:  Unix and MS-DOS :  expand, unexpand.
  627. XMS-DOS: Buerg's TABS; Toad Hall's TOADSOFT.  And some editors have the
  628. Xconversion built-in.
  629. X
  630. X    Exceptions:  The Unix Makefile.  Some makes seem to require "real"
  631. Xtabs.  If they need it there, fine.  So don't fiddle the Makefile.
  632. X
  633. X
  634. X2 - "NO FEELTHY CRS"
  635. X
  636. X    All source, documentation and other text files shall have Unix style
  637. Xline endings (LF, Ctrl-J), NOT the MS-DOS CR/LF or Mac CR line endings.
  638. X
  639. X    Reason:  "Real programmers" in any environment can convert back and
  640. Xforth between Unix and DOS/Mac style.  MS-DOS Turbo C can use Unix or
  641. XMS-DOS line endings (donno about Mac Turbo C).  Buerg's LIST file display
  642. Xutility for MS-DOS can use Unix or MS-DOS line endings.  Unix utilities
  643. Xlike diff and patch die a horrible death (or produce horrible output) if
  644. Xtarget files have CRs.
  645. X
  646. X    Related utilities:  flip for Unix and MS-DOS.
  647. X
  648. X    Exceptions:  The zip archive README and zip.doc files, which Mark
  649. XAdler wants to leave in MSDOS for "unsophisticated" (read brain-dead) DOS
  650. Xusers.  Also the batch files to compile under MS-DOS (where it requires
  651. Xthe CRs.)
  652. X
  653. X
  654. X3 - "NO FEELTHY HEX"
  655. X
  656. X    We'll use uuencode/uudecode compatible converters to move binary files
  657. Xthrough our 7-bit EMail systems (xxencode on special request).  Uuencoded
  658. Xfiles, if larger than +/- 32Kb, will be broken into smaller (< 32Kb)
  659. Xfiles (via David M. Read's UUXFER utility).
  660. X
  661. X    Reason:  to prevent sounds of gagging mailers from resounding
  662. Xthroughout the land.  To be standard with the Uunet side of the world.
  663. XTo be relatively efficient in the binary->Ascii conversion.  (Yeah, yeah,
  664. XI know, there's better conversions out there.  But not as widely known.)
  665. X
  666. X    Related utilities:  uuencode, uudecode, uuxfer20, quux, others.
  667. XJust make sure they don't leave imbedded or trailing spaces.  (E.g., they
  668. Xshould use the "`" character in place of Ascii 32.)  Else mailers are
  669. Xprone to truncate or whatever.  Message me if you need one.
  670. X
  671. X
  672. X4 - "NO FEELTHY TARS"
  673. X
  674. X    unzip will be available in .tar.Z (16-bit compressed tar), .arc (as
  675. Xavailable on Unix, SIMTEL20, PKPAK, etc., *NOT* the latest proprietary
  676. XSEA version), or .zip format.  (If requesting we EMail you source,
  677. Xspecify desired format.)  zip source will only be distributed in .zip
  678. Xarchives.
  679. X
  680. X    Reason:  For unzip development or use, anyone should have one of the
  681. Xspecified dearchivers.  For zip development or use, you shouldn't be
  682. Xmessing with zip unless you can already unzip.  (This protects the
  683. Xinnocent.)
  684. X
  685. X    Related utilities:  Unix:  arc, tar, compress, zip, unzip.  MS-DOS:
  686. XPKUNPAK, PKUNZIP, PAK, TAR, COMPRESS, and others.
  687. X
  688. X    Exceptions:  EMail me directly for any special circumstances or
  689. Xrequirements (zoo, BinHex, 12-bit compress, etc.)
  690. X
  691. X
  692. X5 - "NO FEELTHY FANCY_NAMES"
  693. X
  694. X    Assume the worst:  that someone on a brain-damaged DOS system has to
  695. Xwork with everything your magic fingers produced.  Keep the file names
  696. Xunimaginative and within MS-DOS limits (e.g., ordinary A..Z, 1..9, "-$_!"
  697. Xtype characters, in the "filename.typ" 8-dot-3 format).  MacUsers, giggle
  698. Xall you want, but no spaces.
  699. X
  700. X    Reason:  Compatibility with different file systems.  MS-DOS is the
  701. Xmost limited.
  702. X
  703. X
  704. X6 - "NO FEELTHY GRAPHICS"
  705. X
  706. X    Do all your editing in a plain-text ASCII editor.  No WordPerfect,
  707. XWord, WordStar document mode, or other word processor files, thenkyew.
  708. XNo desktop publishing.  No TIFFs, no GIFs, no imbedded pictures or dancing
  709. Xladies (too bad, Cave Newt).
  710. X
  711. X    Reason:  Compatibility with different consoles.  My old XT clone is
  712. Xthe most limited!
  713. X
  714. X    Related utilities:  vi, ed, EDLIN, Turbo C editor, UED, EASYEDIT, cat
  715. Xor "COPY CON UNZIP.C"; various word processor -> text conversion utilities.
  716. X
  717. X
  718. X7 - "NO FEELTHY DASHES"
  719. X
  720. X    Don't have repeated dashes (starting at the left margin) in any
  721. Xsource code or patches you try to EMail to me or Info-ZIP.  Instead, be
  722. Xsure to always prefix them with a space, asterisk, comment, whatever, like
  723. Xthis:
  724. X#---------------   or
  725. X/*--------------   or even
  726. X ---------------   (just indented)
  727. X
  728. X    Reason:  Most "undigestify" utilities (that break down newsletters
  729. Xinto their separate messages) use that "--------" (starting at the left
  730. Xmargin) as the symbol that it's hit the end of a message.  I'd rather not
  731. Xhave your C source file broken up into a dozen separate untitled messages
  732. Xin my mail system, thank you.  I'll be going through the unzip source Any
  733. XDay Now and changing anything like that by indenting, prefixing, whatever.
  734. X
  735. X
  736. X*-------------------*
  737. X
  738. XDavid Kirschbaum
  739. XInfo-ZIP Coordinator
  740. END_OF_FILE
  741.   if test 5218 -ne `wc -c <'ZipRules'`; then
  742.     echo shar: \"'ZipRules'\" unpacked with wrong size!
  743.   fi
  744.   # end of 'ZipRules'
  745. fi
  746. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  747.   echo shar: Will not clobber existing file \"'misc.c'\"
  748. else
  749.   echo shar: Extracting \"'misc.c'\" \(23910 characters\)
  750.   sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  751. X/*---------------------------------------------------------------------------
  752. X
  753. X  misc.c
  754. X
  755. X  This file contains a number of useful but not particularly closely related
  756. X  functions; their main claim to fame is that they don't change much, so this
  757. X  file should rarely need to be recompiled.  The CRC-32 stuff is from crc32.c;
  758. X  do_string() is from nunzip.c; makeword() and makelong() are from unzip.c;
  759. X  memset() and memcpy() are from zmemset.c and zmemcpy.c, respectively; and
  760. X  dos_to_unix_time() is from set_file_time_and_close() in file_io.c.  ebcdic[],
  761. X  check_for_newer(), dateformat(), and return_VMS() are new.  Things lumped
  762. X  together here to cut down on the size of unzip.c and the number of associ-
  763. X  ated files floating around.
  764. X
  765. X  ---------------------------------------------------------------------------
  766. X
  767. X  Copyrights:  see accompanying file "COPYING" in UnZip source distribution.
  768. X
  769. X  ---------------------------------------------------------------------------*/
  770. X
  771. X
  772. X#include "unzip.h"
  773. X
  774. X
  775. X
  776. X#ifndef ZIPINFO   /* no need to calculate CRCs */
  777. X
  778. X/**************************/
  779. X/*  Function UpdateCRC()  */
  780. X/**************************/
  781. X
  782. X /*--------------------------------------------------------------------
  783. X
  784. X   First, the polynomial itself and its table of feedback terms.  The
  785. X   polynomial is
  786. X   X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
  787. X
  788. X   Note that we take it "backwards" and put the highest-order term in
  789. X   the lowest-order bit.  The X^32 term is "implied"; the LSB is the
  790. X   X^31 term, etc.  The X^0 term (usually shown as "+1") results in
  791. X   the MSB being 1.
  792. X
  793. X   Note that the usual hardware shift register implementation, which
  794. X   is what we're using (we're merely optimizing it by doing eight-bit
  795. X   chunks at a time) shifts bits into the lowest-order term.  In our
  796. X   implementation, that means shifting towards the right.  Why do we
  797. X   do it this way?  Because the calculated CRC must be transmitted in
  798. X   order from highest-order term to lowest-order term.  UARTs transmit
  799. X   characters in order from LSB to MSB.  By storing the CRC this way,
  800. X   we hand it to the UART in the order low-byte to high-byte; the UART
  801. X   sends each low-bit to hight-bit; and the result is transmission bit
  802. X   by bit from highest- to lowest-order term without requiring any bit
  803. X   shuffling on our part.  Reception works similarly.
  804. X
  805. X   The feedback terms table consists of 256, 32-bit entries.  Notes:
  806. X
  807. X       The table can be generated at runtime if desired; code to do so
  808. X       is shown later.  It might not be obvious, but the feedback
  809. X       terms simply represent the results of eight shift/xor opera-
  810. X       tions for all combinations of data and CRC register values.
  811. X
  812. X       The values must be right-shifted by eight bits by the "updcrc"
  813. X       logic; the shift must be unsigned (bring in zeroes).  On some
  814. X       hardware you could probably optimize the shift in assembler by
  815. X       using byte-swap instructions.
  816. X       polynomial $edb88320
  817. X
  818. X   --------------------------------------------------------------------*/
  819. X
  820. XULONG crc_32_tab[] =
  821. X{
  822. X    0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
  823. X    0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
  824. X    0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
  825. X    0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
  826. X    0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
  827. X    0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
  828. X    0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
  829. X    0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
  830. X    0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
  831. X    0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
  832. X    0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
  833. X    0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
  834. X    0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
  835. X    0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
  836. X    0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
  837. X    0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
  838. X    0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
  839. X    0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
  840. X    0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
  841. X    0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
  842. X    0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
  843. X    0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
  844. X    0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
  845. X    0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
  846. X    0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
  847. X    0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
  848. X    0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
  849. X    0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
  850. X    0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
  851. X    0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
  852. X    0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
  853. X    0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
  854. X    0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
  855. X    0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
  856. X    0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
  857. X    0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
  858. X    0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
  859. X    0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
  860. X    0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
  861. X    0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
  862. X    0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
  863. X    0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
  864. X    0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
  865. X    0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
  866. X    0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
  867. X    0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
  868. X    0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
  869. X    0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
  870. X    0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
  871. X    0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
  872. X    0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
  873. X    0x2d02ef8dL
  874. X};
  875. X
  876. X
  877. Xvoid UpdateCRC(s, len)
  878. Xregister byte *s;
  879. Xregister int len;
  880. X /* update running CRC calculation with contents of a buffer */
  881. X{
  882. X    register ULONG crcval = crc32val;
  883. X
  884. X
  885. X    while (len--)
  886. X        crcval = crc_32_tab[((byte) crcval ^ (*s++)) & 0xff] ^ (crcval >> 8);
  887. X    crc32val = crcval;
  888. X}
  889. X
  890. X#endif /* !ZIPINFO */
  891. X
  892. X
  893. X
  894. X
  895. X
  896. X/**************************/
  897. X/*  Function do_string()  */
  898. X/**************************/
  899. X
  900. Xint do_string(len, option)      /* return PK-type error code */
  901. Xunsigned int len;               /* without prototype, UWORD converted to this */
  902. Xint option;
  903. X{
  904. X    int block_length, error = 0;
  905. X    UWORD comment_bytes_left, extra_len;
  906. X
  907. X
  908. X
  909. X/*---------------------------------------------------------------------------
  910. X    This function processes arbitrary-length (well, usually) strings.  Three
  911. X    options are allowed:  SKIP, wherein the string is skipped pretty logical,
  912. X    eh?); DISPLAY, wherein the string is printed to standard output after un-
  913. X    dergoing any necessary or unnecessary character conversions; and FILENAME,
  914. X    wherein the string is put into the filename[] array after undergoing ap-
  915. X    propriate conversions (including case-conversion, if that is indicated:
  916. X    see the global variable pInfo->lcflag).  The latter option should be OK,
  917. X    since filename is now dimensioned at 1025, but we check anyway.
  918. X
  919. X    The string, by the way, is assumed to start at the current file-pointer
  920. X    position; its length is given by len.  So start off by checking length
  921. X    of string:  if zero, we're already set.
  922. X  ---------------------------------------------------------------------------*/
  923. X
  924. X    if (!len)
  925. X        return (0);             /* 0:  no error */
  926. X
  927. X    switch (option) {
  928. X
  929. X    /*
  930. X     * First case:  print string on standard output.  First set loop vari-
  931. X     * ables, then loop through the comment in chunks of OUTBUFSIZ bytes,
  932. X     * converting formats and printing as we go.  The second half of the
  933. X     * loop conditional was added because the file might be truncated, in
  934. X     * which case comment_bytes_left will remain at some non-zero value for
  935. X     * all time.  outbuf is used as a scratch buffer because it is avail-
  936. X     * able (we should be either before or in between any file processing).
  937. X     * [The typecast in front of the min() macro was added because of the
  938. X     * new promotion rules under ANSI C; readbuf() wants an int, but min()
  939. X     * returns a signed long, if I understand things correctly.  The proto-
  940. X     * type should handle it, but just in case...]
  941. X     */
  942. X
  943. X    case DISPLAY:
  944. X        comment_bytes_left = len;
  945. X        block_length = OUTBUFSIZ;    /* for the while statement, first time */
  946. X        while (comment_bytes_left > 0 && block_length > 0) {
  947. X            if ((block_length = readbuf((char *) outbuf,
  948. X                         (int) min(OUTBUFSIZ, comment_bytes_left))) <= 0)
  949. X                return (51);    /* 51:  unexpected EOF */
  950. X            comment_bytes_left -= block_length;
  951. X            NUKE_CRs(outbuf, block_length);     /* (modifies block_length) */
  952. X
  953. X            /*  this is why we allocated an extra byte for outbuf: */
  954. X            outbuf[block_length] = '\0';        /* terminate w/zero:  ASCIIZ */
  955. X
  956. X            A_TO_N(outbuf);     /* translate string to native */
  957. X
  958. X            printf("%s", outbuf);
  959. X        }
  960. X        printf("\n", outbuf);   /* assume no newline at end */
  961. X        break;
  962. X
  963. X    /*
  964. X     * Second case:  read string into filename[] array.  The filename should
  965. X     * never ever be longer than FILNAMSIZ-1 (1024), but for now we'll check,
  966. X     * just to be sure.
  967. X     */
  968. X
  969. X    case FILENAME:
  970. X        extra_len = 0;
  971. X        if (len >= FILNAMSIZ) {
  972. X            fprintf(stderr, "warning:  filename too long--truncating.\n");
  973. X            error = 1;          /* 1:  warning error */
  974. X            extra_len = len - FILNAMSIZ + 1;
  975. X            len = FILNAMSIZ - 1;
  976. X        }
  977. X        if (readbuf(filename, len) <= 0)
  978. X            return (51);        /* 51:  unexpected EOF */
  979. X        filename[len] = '\0';   /* terminate w/zero:  ASCIIZ */
  980. X
  981. X        A_TO_N(filename);       /* translate string to native */
  982. X
  983. X#ifndef ZIPINFO
  984. X        if (pInfo->lcflag)
  985. X            TOLOWER(filename, filename);  /* replace with lowercase filename */
  986. X#endif
  987. X
  988. X        if (!extra_len)         /* we're done here */
  989. X            break;
  990. X
  991. X        /*
  992. X         * We truncated the filename, so print what's left and then fall
  993. X         * through to the SKIP routine.
  994. X         */
  995. X        fprintf(stderr, "[ %s ]\n", filename);
  996. X        len = extra_len;
  997. X        /*  FALL THROUGH...  */
  998. X
  999. X    /*
  1000. X     * Third case:  skip string, adjusting readbuf's internal variables
  1001. X     * as necessary (and possibly skipping to and reading a new block of
  1002. X     * data).
  1003. X     */
  1004. X
  1005. X    case SKIP:
  1006. X        LSEEK(cur_zipfile_bufstart + (inptr-inbuf) + len)
  1007. X        break;
  1008. X
  1009. X    /*
  1010. X     * Fourth case:  assume we're at the start of an "extra field"; malloc
  1011. X     * storage for it and read data into the allocated space.
  1012. X     */
  1013. X
  1014. X    case EXTRA_FIELD:
  1015. X        if (extra_field != NULL)
  1016. X            free(extra_field);
  1017. X        if ((extra_field = (byte *)malloc(len)) == NULL) {
  1018. X            fprintf(stderr,
  1019. X              "warning:  extra field too long (%d).  Ignoring...\n", len);
  1020. X            LSEEK(cur_zipfile_bufstart + (inptr-inbuf) + len)
  1021. X        } else
  1022. X            if (readbuf((char *)extra_field, len) <= 0)
  1023. X                return 51;      /* 51:  unexpected EOF */
  1024. X        break;
  1025. X
  1026. X    }                           /* end switch (option) */
  1027. X    return error;
  1028. X
  1029. X}                               /* end function do_string() */
  1030. X
  1031. X
  1032. X
  1033. X
  1034. X
  1035. X#ifndef ZIPINFO
  1036. X#ifndef VMS
  1037. X
  1038. X/*********************************/
  1039. X/*  Function dos_to_unix_time()  */
  1040. X/*********************************/
  1041. X
  1042. Xtime_t dos_to_unix_time(ddate, dtime)
  1043. Xunsigned ddate, dtime;
  1044. X{
  1045. X    static short yday[]={0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  1046. X    int yr, mo, dy, hh, mm, ss, leap;
  1047. X    long m_time, days=0;
  1048. X#if !defined(MACOS) && !defined(MSC)
  1049. X#if defined(BSD) || defined(MTS)
  1050. X    static struct timeb tbp;
  1051. X#else /* !(BSD || MTS) */
  1052. X    extern long timezone;    /* declared in <time.h> for MSC (& Borland?) */
  1053. X#endif /* ?(BSD || MTS) */
  1054. X#endif /* !MACOS && !MSC (may need to change to DOS_OS2) */
  1055. X
  1056. X#   define YRBASE  1970
  1057. X
  1058. X    /* dissect date */
  1059. X    yr = ((ddate >> 9) & 0x7f) + (1980 - YRBASE);
  1060. X    mo = ((ddate >> 5) & 0x0f) - 1;
  1061. X    dy = (ddate & 0x1f) - 1;
  1062. X
  1063. X    /* dissect time */
  1064. X    hh = (dtime >> 11) & 0x1f;
  1065. X    mm = (dtime >> 5) & 0x3f;
  1066. X    ss = (dtime & 0x1f) * 2;
  1067. X
  1068. X    /* leap = # of leap years from BASE up to but not including current year */
  1069. X    leap = ((yr + YRBASE - 1) / 4);   /* leap year base factor */
  1070. X
  1071. X    /* How many days from BASE to this year? (& add expired days this year) */
  1072. X    days = (yr * 365) + (leap - 492) + yday[mo];
  1073. X
  1074. X    /* if year is a leap year and month is after February, add another day */
  1075. X    if ((mo > 1) && ((yr+YRBASE)%4 == 0) && ((yr+YRBASE) != 2100))
  1076. X        ++days;                 /* OK through 2199 */
  1077. X
  1078. X    /* convert date & time to seconds relative to 00:00:00, 01/01/YRBASE */
  1079. X    m_time = ((long)(days + dy) * 86400) + ((long) hh * 3600) + (mm * 60) + ss;
  1080. X      /* - 1;   MS-DOS times always rounded up to nearest even second */
  1081. X
  1082. X#if !defined(MACOS) && !defined(EMX32)
  1083. X#if defined(BSD) || defined(MTS)
  1084. X    ftime(&tbp);
  1085. X    m_time += tbp.timezone * 60L;
  1086. X#else /* !(BSD || MTS) */
  1087. X    tzset();                    /* set `timezone' */
  1088. X    m_time += timezone;         /* account for timezone differences */
  1089. X#endif /* ?(BSD || MTS) */
  1090. X#endif /* !MACOS && !EMX32 */
  1091. X
  1092. X    if (localtime((time_t *)&m_time)->tm_isdst)
  1093. X        m_time -= 60L * 60L;    /* adjust for daylight savings time */
  1094. X
  1095. X    return m_time;
  1096. X
  1097. X} /* end function dos_to_unix_time() */
  1098. X
  1099. X#endif /* !VMS */
  1100. X
  1101. X
  1102. X
  1103. X
  1104. X
  1105. X/********************************/
  1106. X/*  Function check_for_newer()  */  /* could make this into a macro for Unix */
  1107. X/********************************/
  1108. X
  1109. Xint check_for_newer(filename)   /* return 1 if existing file newer or equal; */
  1110. Xchar *filename;                 /*  0 if older; -1 if doesn't exist yet */
  1111. X{
  1112. X#ifdef VMS
  1113. X    int dy, mo, yr, hh, mm, ss, dy2, mo2, yr2, hh2, mm2, ss2;
  1114. X    float sec;
  1115. X    char mon[4];
  1116. X    static char actimbuf[24], modtimbuf[24];
  1117. X    static char *month[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
  1118. X                            "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
  1119. X    struct VMStimbuf {
  1120. X        char *actime;           /* VMS revision date, ASCII format */
  1121. X        char *modtime;          /* VMS creation date, ASCII format */
  1122. X    } ascii_times={actimbuf,modtimbuf};
  1123. X
  1124. X
  1125. X    if (stat(filename, &statbuf))
  1126. X        return -1;
  1127. X
  1128. X    if (VMSmunch(filename, GET_TIMES, &ascii_times) != RMS$_NMF)
  1129. X        return 0;   /* exists but can't get the time:  assume older */
  1130. X
  1131. X    sscanf(modtimbuf, "%2d-%3s-%04d %02d:%02d:%05f", &dy, mon,
  1132. X      &yr, &hh, &mm, &sec);
  1133. X
  1134. X    yr2 = ((lrec.last_mod_file_date >> 9) & 0x7f) + 1980;
  1135. X    if (yr > yr2)
  1136. X        return 1;
  1137. X    else if (yr < yr2)
  1138. X        return 0;
  1139. X
  1140. X    for (mo = 0;  mo < 11;  ++mo)
  1141. X        if (!strcmp(mon, month[mo]))
  1142. X            break;
  1143. X    mo2 = ((lrec.last_mod_file_date >> 5) & 0x0f) - 1;
  1144. X    if (mo > mo2)
  1145. X        return 1;
  1146. X    else if (mo < mo2)
  1147. X        return 0;
  1148. X
  1149. X    dy2 = (lrec.last_mod_file_date & 0x1f);
  1150. X    if (dy > dy2)
  1151. X        return 1;
  1152. X    else if (dy < dy2)
  1153. X        return 0;
  1154. X
  1155. X    hh2 = (lrec.last_mod_file_time >> 11) & 0x1f;
  1156. X    if (hh > hh2)
  1157. X        return 1;
  1158. X    else if (hh < hh2)
  1159. X        return 0;
  1160. X
  1161. X    mm2 = (lrec.last_mod_file_time >> 5) & 0x3f;
  1162. X    if (mm > mm2)
  1163. X        return 1;
  1164. X    else if (mm < mm2)
  1165. X        return 0;
  1166. X
  1167. X    /* round to nearest 2 secs--may become 60, but doesn't matter for compare */
  1168. X    ss = (int)(sec + 1.) & -2;
  1169. X    ss2 = (lrec.last_mod_file_time & 0x1f) * 2;
  1170. X    if (ss >= ss2)
  1171. X        return 1;
  1172. X
  1173. X    return 0;
  1174. X
  1175. X#else /* !VMS */        /* round up filetime to nearest 2 secs --v  */
  1176. X    return stat(filename, &statbuf)?  -1 :
  1177. X      ( ((statbuf.st_mtime & 1)? statbuf.st_mtime+1 : statbuf.st_mtime) >=
  1178. X      dos_to_unix_time(lrec.last_mod_file_date, lrec.last_mod_file_time) );
  1179. X#endif /* ?VMS */
  1180. X
  1181. X} /* end function check_for_newer() */
  1182. X
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X/***************************/
  1188. X/*  Function dateformat()  */
  1189. X/***************************/
  1190. X
  1191. Xint dateformat()
  1192. X{
  1193. X
  1194. X/*-----------------------------------------------------------------------------
  1195. X  For those operating systems which support it, this function returns a value
  1196. X  which tells how national convention says that numeric dates are displayed.
  1197. X
  1198. X  Return values are DF_YMD, DF_DMY and DF_MDY.  The meanings should be fairly
  1199. X  obvious.
  1200. X -----------------------------------------------------------------------------*/
  1201. X
  1202. X#ifdef OS2
  1203. X    COUNTRYINFO    ctryi;
  1204. X    COUNTRYCODE    ctryc;
  1205. X#ifdef __32BIT__
  1206. X    ULONG          cbCountryInfo;
  1207. X#else
  1208. X    USHORT         cbCountryInfo;
  1209. X#endif
  1210. X
  1211. X
  1212. X    ctryc.country = ctryc.codepage = 0;
  1213. X    if (DosGetCtryInfo(sizeof ctryi, &ctryc, &ctryi, &cbCountryInfo) != NO_ERROR)
  1214. X        return DF_MDY;
  1215. X    else
  1216. X        switch (ctryi.fsDateFmt) {
  1217. X            case 0 /* DATEFMT_MM_DD_YY */ :
  1218. X                return DF_MDY;
  1219. X            case 1 /* DATEFMT_DD_MM_YY */ :
  1220. X                return DF_DMY;
  1221. X            case 2 /* DATEFMT_YY_MM_DD */ :
  1222. X                return DF_YMD;
  1223. X        }
  1224. X#else /* !OS2 */
  1225. X#ifdef MSDOS
  1226. X    unsigned short int CountryInfo[18];
  1227. X    union REGS regs;
  1228. X    struct SREGS sregs;
  1229. X
  1230. X
  1231. X    regs.x.ax = 0x3800;
  1232. X    regs.x.dx = FP_OFF(CountryInfo);
  1233. X    sregs.ds  = FP_SEG(CountryInfo);
  1234. X    int86x(0x21, ®s, ®s, &sregs);
  1235. X    switch(CountryInfo[0]) {
  1236. X        case 0:
  1237. X            return DF_MDY;
  1238. X        case 1:
  1239. X            return DF_DMY;
  1240. X        case 2:
  1241. X            return DF_YMD;
  1242. X    }
  1243. X#endif /* !MSDOS */
  1244. X#endif /* ?OS2 */
  1245. X
  1246. X    return DF_MDY;   /* default for Unix, VMS, etc. */
  1247. X}                               /* end function dateformat() */
  1248. X
  1249. X#endif /* !ZIPINFO */
  1250. X
  1251. X
  1252. X
  1253. X
  1254. X
  1255. X#ifdef EBCDIC
  1256. X
  1257. X/*
  1258. X * This is the MTS ASCII->EBCDIC translation table. It provides a 1-1
  1259. X * translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC.
  1260. X */
  1261. X
  1262. Xunsigned char ebcdic[] =
  1263. X{
  1264. X    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  1265. X    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
  1266. X    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
  1267. X    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
  1268. X    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
  1269. X    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d,
  1270. X    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
  1271. X    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
  1272. X    0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
  1273. X    0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xff,
  1274. X    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc,
  1275. X    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
  1276. X    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
  1277. X    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59,
  1278. X    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
  1279. X    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf
  1280. X};
  1281. X
  1282. X#endif                          /* EBCDIC */
  1283. X
  1284. X
  1285. X
  1286. X
  1287. X
  1288. X/*************************/
  1289. X/*  Function makeword()  */
  1290. X/*************************/
  1291. X
  1292. XUWORD makeword(b)
  1293. Xbyte *b;
  1294. X /*
  1295. X  * Convert Intel style 'short' integer to non-Intel non-16-bit
  1296. X  * host format.  This routine also takes care of byte-ordering.
  1297. X  */
  1298. X{
  1299. X/*
  1300. X    return  ( ((UWORD)(b[1]) << 8)  |  (UWORD)(b[0]) );
  1301. X */
  1302. X    return ((b[1] << 8) | b[0]);
  1303. X}
  1304. X
  1305. X
  1306. X
  1307. X
  1308. X
  1309. X/*************************/
  1310. X/*  Function makelong()  */
  1311. X/*************************/
  1312. X
  1313. XULONG makelong(sig)
  1314. Xbyte *sig;
  1315. X /*
  1316. X  * Convert intel style 'long' variable to non-Intel non-16-bit
  1317. X  * host format.  This routine also takes care of byte-ordering.
  1318. X  */
  1319. X{
  1320. X    return (((ULONG) sig[3]) << 24)
  1321. X        + (((ULONG) sig[2]) << 16)
  1322. X        + (((ULONG) sig[1]) << 8)
  1323. X        + ((ULONG) sig[0]);
  1324. X}
  1325. X
  1326. X
  1327. X
  1328. X
  1329. X
  1330. X#ifdef VMS
  1331. X
  1332. X/***************************/
  1333. X/*  Function return_VMS()  */
  1334. X/***************************/
  1335. X
  1336. Xvoid return_VMS(zip_error)
  1337. Xint zip_error;
  1338. X{
  1339. X#ifdef RETURN_CODES
  1340. X/*---------------------------------------------------------------------------
  1341. X    Do our own, explicit processing of error codes and print message, since
  1342. X    VMS misinterprets return codes as rather obnoxious system errors ("access
  1343. X    violation," for example).
  1344. X  ---------------------------------------------------------------------------*/
  1345. X
  1346. X    switch (zip_error) {
  1347. X
  1348. X    case 0:
  1349. X        break;                  /* life is fine... */
  1350. X    case 1:
  1351. X        fprintf(stderr, "\n[return-code 1:  warning error \
  1352. X(e.g., failed CRC or unknown compression method)]\n");
  1353. X        break;
  1354. X    case 2:
  1355. X    case 3:
  1356. X        fprintf(stderr, "\n[return-code %d:  error in zipfile \
  1357. X(e.g., can't find local file header sig)]\n",
  1358. X                zip_error);
  1359. X        break;
  1360. X    case 4:
  1361. X    case 5:
  1362. X    case 6:
  1363. X    case 7:
  1364. X    case 8:
  1365. X        fprintf(stderr, "\n[return-code %d:  insufficient memory]\n",
  1366. X                zip_error);
  1367. X        break;
  1368. X    case 9:
  1369. X        fprintf(stderr, "\n[return-code 9:  zipfile not found]\n");
  1370. X        break;
  1371. X    case 10:                    /* this is the one that gives "access violation," I think */
  1372. X        fprintf(stderr, "\n[return-code 10:  bad or illegal parameters \
  1373. Xspecified on command line]\n");
  1374. X        break;
  1375. X    case 11:                    /* I'm not sure this one is implemented, but maybe soon? */
  1376. X        fprintf(stderr, "\n[return-code 11:  no files found to \
  1377. Xextract/view/etc.]\n");
  1378. X        break;
  1379. X    case 50:
  1380. X        fprintf(stderr, "\n[return-code 50:  disk full \
  1381. X(or otherwise unable to open output file)]\n");
  1382. X        break;
  1383. X    case 51:
  1384. X        fprintf(stderr, "\n[return-code 51:  unexpected EOF in zipfile \
  1385. X(i.e., truncated)]\n");
  1386. X        break;
  1387. X    default:
  1388. X        fprintf(stderr, "\n[return-code %d:  unknown return-code \
  1389. X(who put this one in?  Wasn't me...)]\n",
  1390. X                zip_error);
  1391. X        break;
  1392. X    }
  1393. X#endif                          /* RETURN_CODES */
  1394. X
  1395. X    exit(0);                    /* everything okey-dokey as far as VMS concerned */
  1396. X}
  1397. X
  1398. X#endif                          /* VMS */
  1399. X
  1400. X
  1401. X
  1402. X
  1403. X
  1404. X#ifdef ZMEM                     /* memset, memcpy for systems without them */
  1405. X
  1406. X/***********************/
  1407. X/*  Function memset()  */
  1408. X/***********************/
  1409. X
  1410. Xchar *memset(buf, init, len)
  1411. Xregister char *buf, init;       /* buffer loc and initializer */
  1412. Xregister unsigned int len;      /* length of the buffer */
  1413. X{
  1414. X    char *start;
  1415. X
  1416. X    start = buf;
  1417. X    while (len--)
  1418. X        *(buf++) = init;
  1419. X    return (start);
  1420. X}
  1421. X
  1422. X
  1423. X
  1424. X
  1425. X
  1426. X/***********************/
  1427. X/*  Function memcpy()  */
  1428. X/***********************/
  1429. X
  1430. Xchar *memcpy(dst, src, len)
  1431. Xregister char *dst, *src;
  1432. Xregister unsigned int len;
  1433. X{
  1434. X    char *start;
  1435. X
  1436. X    start = dst;
  1437. X    while (len-- > 0)
  1438. X        *dst++ = *src++;
  1439. X    return (start);
  1440. X}
  1441. X
  1442. X#endif                          /* ZMEM */
  1443. END_OF_FILE
  1444.   if test 23910 -ne `wc -c <'misc.c'`; then
  1445.     echo shar: \"'misc.c'\" unpacked with wrong size!
  1446.   fi
  1447.   # end of 'misc.c'
  1448. fi
  1449. echo shar: End of archive 7 \(of 12\).
  1450. cp /dev/null ark7isdone
  1451. MISSING=""
  1452. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1453.     if test ! -f ark${I}isdone ; then
  1454.     MISSING="${MISSING} ${I}"
  1455.     fi
  1456. done
  1457. if test "${MISSING}" = "" ; then
  1458.     echo You have unpacked all 12 archives.
  1459.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1460. else
  1461.     echo You still must unpack the following archives:
  1462.     echo "        " ${MISSING}
  1463. fi
  1464. exit 0
  1465.  
  1466.  
  1467. exit 0 # Just in case...
  1468.