home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / unzip / part04 < prev    next >
Text File  |  1991-05-19  |  53KB  |  1,380 lines

  1. Newsgroups: comp.sources.misc
  2. From: David Kirschbaum <kirsch@usasoc.soc.mil>
  3. Subject:  v19i099:  unzip - Portable unzip v4.1, Part04/06
  4. Message-ID: <1991May20.012217.29304@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: a4894eb5cdc73475708606750812bb4c
  6. Date: Mon, 20 May 1991 01:22:17 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: David Kirschbaum <kirsch@usasoc.soc.mil>
  10. Posting-number: Volume 19, Issue 99
  11. Archive-name: unzip/part04
  12. Supersedes: unzip-3.1: Volume 14, Issue 102-106
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  ./v41/History.41 ./v41/Makefile ./v41/mapname.c
  20. #   ./v41/match.c
  21. # Wrapped by kent@sparky on Sun May 19 19:40:39 1991
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 4 (of 6)."'
  25. if test -f './v41/History.41' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'./v41/History.41'\"
  27. else
  28.   echo shar: Extracting \"'./v41/History.41'\" \(16045 characters\)
  29.   sed "s/^X//" >'./v41/History.41' <<'END_OF_FILE'
  30. Xunzip version 4.1, 13 May 91
  31. X
  32. X- Cave Newt, Info-ZIP #139
  33. XThese are the minor things I found:
  34. X   (1) the do-nothing file_io.c umask patch got included by mistake
  35. X   (2) those same two lines in unzip.c are shifted over again (somebody's
  36. X        patch program REALLY doesn't like those lines...they're full of
  37. X        feelthy tabs, which may have something to do with it)
  38. X   (3) the man page wasn't quite updated to reflect the -z and -o options
  39. X   (4) the Makefile now has two msc_os2 targets
  40. X
  41. XI've fixed (1) through (3) in this patch.  None of them actually has any
  42. Ximpact on the code--(2) is obviously cosmetic, and (1) is effectively so,
  43. Xalthough it's potentially dangerous.  For the man page I just updated the
  44. Xnroff source (unzip.1); unzip.man can be regenerated.  In addition to in-
  45. Xcluding "o" and "z" in the synopsis and adding the -z description, I also
  46. Xfigured I might as well put in the "4.1" comments, so I did that.
  47. X[Affected file_io.c, unzip.c, unzip.1]
  48. X
  49. X- Jim Dumser, Info-ZIP #140, 7 May 91
  50. XFirst is my "proposed" umask patch, after which I conceded to Greg's
  51. Xfix.  It was still included, and altho it doesn't hurt anybody, it
  52. Xreally shouldn't be in there.  [NOP, fixed by Cave Newt's patch above.]
  53. X
  54. XSecond is something that will hurt people.  There were 2 msc_os2 targets
  55. Xin the Makefile.  I picked the one that was submitted last (and for
  56. Xwhich the .def file was included), and removed the other.
  57. X[Affected Makefile]
  58. X
  59. X-Cave Newt, 8 May 91 (private message, not in Info-ZIP)
  60. XYes, it's YAVU (Yet Another VMS Update).  I edited the VMSNOTES file
  61. Xa little bit to reflect what I've lately figured out about the "variable
  62. Xlength, 510 byte max" format, and I undid the interior vmsattr.zip file
  63. Xsince there wasn't much need for it as a separate sub-sub-archive.  No
  64. Xbig changes, but we may as well get ready for the release.
  65. X[New VMS.zip]
  66. X
  67. X- Cave Newt, 10 May 91 (private message, not in Info-ZIP)
  68. XFirst of all, one last (?) change to the man page:  I forgot to update
  69. Xthe info for the -a switch, and it still contained your old e-mail
  70. Xaddress.  Good thing you ignored my impatient nagging, huh? :-)  Patch 
  71. Xbelow to the patch I already sent you...
  72. X[Affected unzip.1]
  73. X
  74. XAnd from the Coordinator:
  75. XWe're going public with this one, folks.  History, here we come!
  76. X
  77. X================
  78. X
  79. Xv4.07 BETA, 4 May 91
  80. X
  81. X- (That's "05-04-91" in feelthy civilian format)
  82. X
  83. X- Starting with v4.06 source, patched in the v4.06a stuff
  84. X  (see UNZ_406A.ZIP patch file)
  85. X
  86. X- Wim Bonner's OS2 Makefile patch (for long file names)
  87. X  and an "unzip.def" file.  (MAKEFILE.127)
  88. X- Cave Newt: fix for Makefile's pyramid target (MAKEFILE.406)
  89. X- Mark Adler's minor diffs to make it compile cleaner and smaller
  90. X  on the NeXT (plus trimmed out some feelthy tabs).  (UNZIP.125)
  91. X
  92. X- The Great Umask Wars commence, with Bo Kullmar, Cave Newt,
  93. X  and Jim Dumser all contributing to the Infamous Info-ZIP MindFog.
  94. X  (It all worked out in the end .. kinda ..)
  95. X  UNZIP_C.128: Bo's first shots at Fort Sumpter; UNZIP_C.129: Cave
  96. X  Newt throws in a few curves.
  97. X
  98. X- Bo Kullmar adds a -z option to only display the archive comment.
  99. X  He also notices the Infamous 8192 bug (an extra LF is inserted
  100. X  after every 8192 byte in the do_string function.
  101. X  (UNZIP_C.132)
  102. X
  103. X- Info-ZIP Coordinator prepares lengthy curses for anyone preparing
  104. X  to write 8192-byte-long archive comments.  (Private files)
  105. X
  106. X- Jim Dumser then leaps into the -z conflict.  He also discovers
  107. X  who's sneaking in feelthy tabs to our source!
  108. X  He then coins the famous phrase:
  109. X  "needs to be applied either before Bo's patch ("A -z option to unzip",
  110. X  91.129) or after my patch ("Re:  A -z option to unzip", 91.130).
  111. X  Actually, because the 91.129 patch does more than just add the COMMENT
  112. X  option, you really need to apply both Bo's and mine, then apply this."
  113. X  (Which *almost* invokes Info-ZIP Coordinator's curses.)
  114. X  (UNZIP_C.133, UNZIP_C.134)
  115. X
  116. X- Jim Dumser, returning to the Umask Front, discovers there *ain't*
  117. X  no feelthy umask() in Turbo C!  And MSC fakes it.  umask()-related
  118. X  code is #ifdef'ed for Unix systems only.  (DUMSER.407)
  119. X- Cave Newt chucks a grenade into umask() with yet more #ifdefs.
  120. X  (407.MSG)
  121. X- Jim Dumser pretends to clear up the confusion.  Contributes a stupendous
  122. X  diff or two just to be sure I got it all.  Bo Kullmar throws in one
  123. X  of them too.  Looks like I got it all.
  124. X
  125. X================
  126. X
  127. Xv4.06a, late April 91
  128. X
  129. X - unzip Makefile:  fix for pyramid target from Cave Newt.
  130. X   Somebody switched "make" with "$MAKE" or some such.
  131. X
  132. X- Makefile Change for OS/2 (and addition of def file)
  133. X  (Wim Bonner).  Tweak to the msc_os2 system of the Makefile,
  134. X  plus a wee little def file for OS/2.
  135. X
  136. X- Unzip 4.06 diffs for the NeXT (Mark Adler)
  137. X  "Here are some very minor diffs for Unzip 4.06 to make it compile cleaner
  138. X  and smaller on the NeXT.  (By the way, there were feelthy tabs in unzip.c,
  139. X  unzip.h, and a few other non-source files.)"
  140. X
  141. X================
  142. X
  143. X4.06, 25 April 1991
  144. X
  145. X- Minor patches to Makefile (Jim Dumser, Info-ZIP #096
  146. X- And then a BIG change to Makefile: a "generic" Makefile
  147. X  From Cave Newt (Info-ZIP #099)
  148. X- Case-conversion-info patch from Cave Newt (Info-ZIP #098):
  149. X  "Unzip does 'smart' lowercasing of filenames in zipfiles,
  150. X  a feature I like a lot (that's why I put it in :-).  But zip
  151. X  doesn't do any conversions, and it's easy to forget sometimes
  152. X  that all the names in a zipfile are really uppercase.  This is
  153. X  a PROPOSED patch that lets you know when case-conversion has
  154. X  occurred in unzip."
  155. X  Well, the Newt proposed .. and nobody screamed .. so it becomes
  156. X  gospel.
  157. X- VMS file attribute patch (Cave Newt, Info-ZIP #098):
  158. X  Wee little patches to the unix code, and some new files in the
  159. X  VMS.zip file.
  160. X- Wim Bonner, Info-ZIP #100, reported a "missing semicolon" error
  161. X  with MSC 6.0 and OS/2:
  162. X  "The problem is that there are a set of local variables declared in
  163. X  conditional defines, and they are after some code has already appeared
  164. X  in the subroutine.
  165. X  "If the conditional block is moved before the small amount of code, the
  166. X  file compiles OK."
  167. X  Fixed.
  168. X- Jim Dumser (Info-ZIP #???, 26 Mar), further patching Cave Newt's
  169. X  file attributes patch with more of his own.
  170. X- Info-ZIP #106:  Patched to solve problem with truncated comments.
  171. X- Added "-o" and "-n" patches by Gene McManus (Info-ZIP #106),
  172. X  to permit overwriting output files without prompting.
  173. X  These switches do virtually the same thing (so I don't know why
  174. X  he did them both) .. and the patches kinda conflict .. but I made
  175. X  it fit.
  176. X- Mac diffs from Johnny Lee (Info-ZIP #115):
  177. X  "Catching up with the permissions changes. Since I don't have any
  178. X  AppleShare docs handy, this patch only determines if a file
  179. X  is read-only or not."
  180. X- Cave Newt (Info-ZIP #120) fixes the -a switch usage screen.
  181. X- Cave Newt (Info-ZIP #121) *really* fixes the truncated zip comment
  182. X  (superseding my fix in #106).
  183. X
  184. XArchive still includes the MAC, VMS, and ATARI-specific code in
  185. Xtheir own separate .ZIPs.
  186. X
  187. XLast patches before public v4.10 release (I hope)
  188. X
  189. XDavid Kirschbaum
  190. XInfo-ZIP Coordinator
  191. X
  192. X================
  193. X
  194. X4.05, 19 Mar 91
  195. X
  196. X[We're going to use Greg Roelof's version, since his is probably the
  197. Xmost complete.  From the header of his message: ]
  198. X
  199. XHere's the package, in two parts.  The zipfile is basically complete, 
  200. Xexcept that it doesn't have a History.405 file or an unzip405.descr
  201. Xfile.  I've grouped the non-Unix-OS stuff into four sub-zipfiles inside
  202. Xthe main one:  one each for Atari ST, Mac, MS-DOS, and VMS.  This keeps
  203. Xthings a little cleaner and prevents collisions between the Atari Turbo
  204. Xmakefiles and the MS-DOS ones.  You can take them out for the beta
  205. Xversion if you want, but they aren't really all that big.  Note that
  206. Xthe Mac and Atari binaries are NOT included; the little zipfiles only
  207. Xcontain extra source files, notes, and makefile stuff.
  208. X
  209. XNow, a complete list of the changes to 4.05 from 4.04:
  210. X
  211. X  Missing 4.04 patches:
  212. X    - Antoine's FILENAME_MAX fix
  213. X        - size-of-encrypted-member (negative size factors) fix
  214. X    - Bo's missing <sys/timeb.h> for BSD moved into unzip.h
  215. X
  216. X  Bug fixes:
  217. X    - setting the time on stdout
  218. X    - listing of three digits of 21st century years instead of two
  219. X    - multiple usage screens for non-existent switches (e.g., unzip -XY)
  220. X    - [VMS] inability to set file dates when extracting directory trees
  221. X    - [VMS] choke-and-die on multiple-dot filenames (now converted to '_')
  222. X
  223. X  New features:
  224. X    - BIG Mac attack from Johnny Lee
  225. X    - (correct) handling of file permissions, both Unix zip and PKZIP
  226. X    - new -V option to retain version numbers from VMS-created zipfiles
  227. X    - ifdef'd code to deal with PAK bug ("on" for now)
  228. X    - detection of big-endian and/or struct-padding behavior, and noti-
  229. X       fication to user to recompile if necessary
  230. X
  231. X  New Makefile targets:
  232. X    - msc_os2 from Wim Bonner
  233. X    - sequent from Phil Howard
  234. X    - ultrix split into ultrix_vax and ultrix_risc
  235. X    - dec5820 commented out (ultrix_risc system)
  236. X    - renames:  diab -> dnix; cray_scc -> cray
  237. X
  238. X
  239. XNOT included in this release are the Atari patches; partly this is because
  240. Xthe majority of them had nothing to do with Atari at all and should have
  241. Xbeen posted to the group, and partly it is because the remaining ones, which
  242. XDID have to do with Atari, largely consisted of the removal of all the non-
  243. XAtari operating systems (like Unix, DOS, VMS; Mac didn't exist at the time).
  244. X
  245. XAlso not included are (1) the proposed "generic"/"generic2" makefile targets
  246. X(still waiting for some Info-ZIP feedback); (2) the ultimate VMS file-type
  247. Xfix on which I've been working (close, still waiting on someone); and (3) a 
  248. Xnew case-conversion-warning patch I'll post shortly to see what folks think.
  249. X(Oh, and the two 4.05 description files I mentioned above.)
  250. X
  251. XI don't *think* I missed any unzip patches that have been posted, but people
  252. Xshould check carefully to see if their favorite one is in here.  Also, the
  253. XMac patches collided rather violently with my own, so folks should keep their
  254. Xeyes peeled.  I tried to hand-tweak everything, but patch may have snuck one
  255. Xor two into a slightly wrong place.  No crashes yet on MY system...
  256. X
  257. XFinally, with the exception of the PAK-fix, I think I've removed everything
  258. Xthat hasn't been posted in one way or another (i.e., my own little tweaks).
  259. XSo this should be a nice, clean release, which should in turn make everyone
  260. Xvery happy.
  261. X
  262. XGreg
  263. X
  264. X================
  265. X
  266. Xv4.04, 22 Feb 91
  267. X
  268. X- Makefile:
  269. X  From: Michael Regoli <mr@ogre.cica.indiana.edu>
  270. X  It looks as if "make" is not defined for the IBM RT.  
  271. X  We need a MAKE macro definition on or about line 67:
  272. X  (And he sent a context diff.  Applied.)
  273. X
  274. X  From: bkahn@archive.webo.dg.com (Bruce Kahn)
  275. X  I just got a copy of 4.03 from the archives and it seems that my little
  276. X  addition to the Makefile from 3.1x to support Data General AViiONs was
  277. X  lost.  Im enclosing a diff -c on the 'current' 4.03 makefile to add this
  278. X  back in.
  279. X  (Applied after slight editing.)
  280. X
  281. X  And someone said Suns needed "-DBSD" on their make line (maybe
  282. X  Josh? Bo Kullmar?).  Anyway, Suns are now broken out onto their own line
  283. X  (basically "_16", plus "-DBSD").
  284. X
  285. X- file_io.c (The date/time problem, fixed by Bo Kullmar): 
  286. X  Lots of changes (confusing), so you'd want the original message
  287. X  and patch if you want details.  Usually named file_io.404.
  288. X  Bo's patch forgot one thing: a reference to /sys/timeb.h for BSD systems.
  289. X  (diff included and applied)
  290. X
  291. X- New VMS files from Cave Newt (entirely replacing old ones, and one
  292. X  VMSSHARE.OPT or some such deleted entirely).
  293. X
  294. X- unzip.c
  295. X
  296. X  From: Cave Newt <roelofs@amelia.nas.nasa.gov>
  297. X  Subject: Compression ratio calculation bug
  298. X
  299. X  Ah, yes, the old negative-ratio bug.  Below is a patch to fix this;
  300. X  here's the explanation:
  301. X  [explanation deleted, patch applied.]
  302. X
  303. X================
  304. X
  305. X
  306. Xv4.03, 8 Dec 90
  307. X
  308. X- Changes to VMSNOTES.
  309. X- Patched via Newt's "even more stupendous(ly long) 4.03 patches"
  310. X- Entirely new unzip.c and unzip.h
  311. X- misc.c, mapname.c and file_io.c patched via patch.403
  312. X- Fixes are for VMS: reversion to block-boundary seeks while
  313. X  retaining the random-access behavior that gives (n)unzip its speed.
  314. X- Routines to find end-of-central-directory sig rewritten and
  315. X  streamlined into a single function.
  316. X- New LSEEK macro added.
  317. X[Full details for all this horridness are in the unz403_p patch archive.]
  318. X- Fix involving making the filename longer
  319. X- fixing a leap-year bug (2000 IS a leap year).
  320. X- Consolidated more repeated error strings (unzip.c)
  321. X- Removed an unused macro (UPDCRC32).
  322. X
  323. X================
  324. X
  325. Xv4.02, 6 Dec 90
  326. X
  327. X- Per Cave Newt's request, changed nunzip's in VMS_MAKE.COM
  328. X  to unzip.
  329. X
  330. X- mapname.c :  History of changes removed.
  331. X
  332. X- Many changes, patches in Cave Newt's big unzip_c.401, unz402_p.zip,
  333. X  to include more extensive explanation and comments.
  334. X
  335. X- Bug in unzip.c related to encryption:
  336. X  Mark and Newt were getting "bus errors" (sic) when unzip tried to test
  337. X  or unzip an encrypted file. (Probably array overruns)
  338. X  Solution:  check general purpose bit flag to see if file is encrypted.
  339. X  If so, skip it (with regretful message).
  340. X  Later we may decrypt (Mark offers his routine).
  341. X
  342. X- -t option change:
  343. X  The -t option in 4.01 currently prints both the individual file "OKs"
  344. X  and a summary; this is redundant.  So now -t just prints the "OKs"
  345. X  (like the old versions), -tq just prints the summary, and -tqq
  346. X  doesn't print anything at all.
  347. X
  348. X- Misc indentation corrected.
  349. X
  350. X- man page changed:
  351. X  Separated the modifier options into their own little heading.
  352. X  Expanded the -a explanation to include EBCDIC, since that's why it was
  353. X  originally done in the first place.
  354. X  Added 3.1 to the list at the bottom.
  355. X
  356. X- Minor centralization of repeated error message strings.
  357. X
  358. X================
  359. X
  360. Xv4.01, 4 Dec 90:
  361. X
  362. X1 - From Down Under:
  363. XFrom: aas@cc.uq.oz.au
  364. X
  365. XThe makefile.msc as it stands more or less works for TurboC 2.0,
  366. Xso makefile.tc is probably redundant.  However, TurboC throws what
  367. Xwe colloquially call a `wobbly' over one line in file_io.c: where
  368. X`>> (space) =' is used instead of the ANSI `>>=' construct.  The
  369. Xfix is easy (appended).
  370. X
  371. X[Makefile.msc patched to include both Turbo C and MSC compiles,
  372. X renamed to MAKEFILE.DOS.  Actually, it's for OS/2 also.
  373. X Works just fine for Turbo C v2.0, can't test the others.
  374. X Removed MAKEFILE.TC.
  375. X]
  376. X
  377. XAnd the file_io.c patch was a one-liner at line 312 /318:
  378. X!     bitbuf >> = bits;
  379. Xchanged to:
  380. X!     bitbuf >>= bits;
  381. X
  382. X================
  383. X
  384. X2 - From: Cave Newt <roelofs@amelia.nas.nasa.gov>
  385. X    (details in unzip400.msg, unz401_p.zip)
  386. X
  387. X- a patch to 3.99 which you missed and I forgot about:  the name[STRSIZ]
  388. X  one in mapname.c.
  389. X  [Extracted to mapname.pch, mapname.c patched.]
  390. X
  391. X- indent11 (AKA "Mr. Mangler") likes tabs, which is going to play hell 
  392. X  with patches.
  393. X
  394. X  [I'm using indent11 with the "-kr" settings.
  395. X   And all source will be archived with NO tabs.
  396. X   Except for the stupid makefiles, however
  397. X  ]
  398. X
  399. X- "makefile.msc" should have been uppercase.
  400. X  [It's MAKEFILE.DOS now because of TC/MSC/OS2 integration.]
  401. X
  402. X- man page still says "3.1" at the top and has a weird (old)
  403. X  e-mail address for you at the bottom.
  404. X  [unzip.1 edited to reflect "4.0".]
  405. X
  406. X- Comments at the top of unzip.c say "unzip40.tar.Z" rather than
  407. X  "unzip400".
  408. X  [Fixed]
  409. X
  410. X================
  411. XFinal 4.01 Toad Hall Note:
  412. X- Compiling in Turbo C integrated environment (e.g., using the .PRJ
  413. X  file) produced an UNZIP.EXE a couple hundred bytes smaller than the
  414. X  one compiled via tcc and the MAKEFILE.DOS.  Obviously I've forgotten
  415. X  a switch somewhere, or my default tcc settings are slightly off.
  416. X  So if you want the absolute smallest, suggest integrated compile.
  417. X- No more stupid mixing of Unix and DOS text files.  EVERYTHING's gonna
  418. X  have (1) no tabs and (2) Unix LF line endings.  If you're gonna work
  419. X  in DOS, you'd better have FLIP or TOADCRLF or some such to convert
  420. X  these Unix files.
  421. X  We'll still indicate DOS files vs. Unix files via name case (e.g.,
  422. X  DOS files'll be all uppercase).  Of course, the VMS files are ALSO
  423. X  uppercase (meant to ask you about that, Cave Newt), but that's ok.
  424. X  For the DENSA members, anything starting with VMS is NOT DOS, ok?
  425. X================
  426. END_OF_FILE
  427.   if test 16045 -ne `wc -c <'./v41/History.41'`; then
  428.     echo shar: \"'./v41/History.41'\" unpacked with wrong size!
  429.   fi
  430.   # end of './v41/History.41'
  431. fi
  432. if test -f './v41/Makefile' -a "${1}" != "-c" ; then 
  433.   echo shar: Will not clobber existing file \"'./v41/Makefile'\"
  434. else
  435.   echo shar: Extracting \"'./v41/Makefile'\" \(14794 characters\)
  436.   sed "s/^X//" >'./v41/Makefile' <<'END_OF_FILE'
  437. X# Makefile for unzip
  438. X#
  439. X# ******** INSTRUCTIONS (such as they are) ********
  440. X#
  441. X# "make vax"    -- makes unzip on a VAX 11-780 BSD 4.3 in current directory
  442. X#           (or a SysV VAX, or an 8600 running Ultrix, or...)
  443. X# "make"    -- uses environment variable SYSTEM to set the type
  444. X#           system to compile for.  This doesn't work for some
  445. X#           particularly brain-damaged versions of make (VAX BSD,
  446. X#           Gould, and SCO Unix are in this group).
  447. X# "make wombat" -- Chokes and dies if you haven't added the specifics
  448. X#           for your Wombat 68000 (or whatever) to the systems list.
  449. X#
  450. X# CFLAGS are flags for the C compiler.  LDFLAGS are flags for the loader.
  451. X# LDFLAGS2 are more flags for the loader, if they need to be at the end
  452. X# of the line instead of at the beginning.
  453. X#
  454. X# My host (a VAX 11-780 running BSD 4.3) is hereafter referred to as
  455. X# "my host."
  456. X#
  457. X# My host's /usr/include/sys/param.h defines BSD for me.
  458. X# You may have to add "-DBSD" to the list of CFLAGS for your system.
  459. X#
  460. X# You MAY need to define "-DNOTINT16" if the program produces CRC errors
  461. X# during a "-t" run or extraction (this involves structure alignment/padding);
  462. X# you MUST define it if your machine is "big-endian" (i.e., it orders bytes
  463. X# in Motorola fashion rather than Intel fashion).  The latter case is charac-
  464. X# terized by errors of the form "some-kind-of-header signature not found.
  465. X# Please report to Info-ZIP." OR a silent do-nothing return with an exit code
  466. X# of 51 (EOF).  It should always be safe to define NOTINT16, but it does add
  467. X# some overhead, so first try compiling without it and see what happens.
  468. X# If death and destruction ensue, it's probably better to go ahead and use
  469. X# NOTINT16.
  470. X#
  471. X# Some versions of make do not define the macro "$(MAKE)" (my host did not).
  472. X# The makefile should now handle such systems correctly, more or less; the
  473. X# possible exception to this is if you've used a make command-line option
  474. X# (for example, the one which displays the commands which WOULD be executed,
  475. X# but doesn't actually execute them).  It probably needs some more tinkering.
  476. X# If things still don't work, use "make" instead of "$(MAKE)" in your system's
  477. X# makerule.  Or try adding the following line to your .login file:
  478. X#   setenv MAKE "make"
  479. X# (It didn't help on my host.)
  480. X#
  481. X# memcpy and memset are provided for those systems that don't have them;
  482. X# they're found in misc.c and will be used if -DZMEM is included in the list
  483. X# of CFLAGS.  These days ALMOST all systems have them (they're mandated by
  484. X# ANSI), but older systems might be lacking.  And at least ONE machine's
  485. X# version results in some serious performance degradation...
  486. X#
  487. X# To test your nice new unzip, insure your zip file includes some LARGE
  488. X# members.  Many systems ran just fine with zip file members < 512 bytes
  489. X# but failed with larger ones.  Members which are "shrunk" rather than
  490. X# "imploded" have also caused many problems in the past, so try to test a
  491. X# zipfile which contains some of both.  And it's quite possible that this
  492. X# program has NEVER been tested on a "reduced" file, so keep your eyes
  493. X# open.  (They're probably mythical, though.)
  494. X
  495. X#####################
  496. X# MACRO DEFINITIONS #
  497. X#####################
  498. X
  499. X# Defaults most systems use
  500. XCC = cc
  501. XCFLAGS = -O -DUNIX
  502. XLD = cc
  503. XLDFLAGS = -o unzip
  504. XEXE =
  505. XO = .o
  506. XOBJS = unzip$O file_io$O mapname$O match$O misc$O\
  507. X       unimplod$O unreduce$O unshrink$O
  508. X
  509. XSHELL = /bin/sh
  510. X
  511. X# list of supported systems in this version
  512. XSYSTEMS1 = 386i 3Bx amdahl apollo aviion convex cray cray_cc
  513. XSYSTEMS2 = dnix encore generic generic2 gould hp mips msc_dos
  514. XSYSTEMS3 = msc_os2 next pyramid rtaix sco sco_dos sequent sgi
  515. XSYSTEMS4 = stellar sun tahoe ultrix_risc ultrix_vax vax wombat
  516. X# SYSTEMS5 =
  517. X
  518. X####################
  519. X# DEFAULT HANDLING #
  520. X####################
  521. X
  522. X# The below will try to use your shell variable "SYSTEM" as the type system
  523. X# to use (e.g., if you type "make" with no parameters at the command line).
  524. X# The test for $(MAKE) is necessary for VAX BSD make (and Gould, apparently),
  525. X# as is the "goober" (else stupid makes see an "else ;" statement, which they
  526. X# don't like).  "goober" must then be made into a valid target for machines
  527. X# which DO define MAKE properly (and have SYSTEM set).  Quel kludge, non?
  528. X# And to top it all off, it appears that the VAX, at least, can't pick SYSTEM
  529. X# out of the environment either (which, I suppose, should not be surprising).
  530. X# [Btw, if the empty "goober" target causes someone else's make to barf, just
  531. X# add an "@echo > /dev/null" command (or whatever).  Works OK on the Amdahl
  532. X# and Crays, though.]
  533. X
  534. Xdefault:
  535. X    @if test -z "$(MAKE)"; then\
  536. X        if test -z "$(SYSTEM)";\
  537. X        then make ERROR;\
  538. X        else make $(SYSTEM) MAKE="make";\
  539. X        fi;\
  540. X    else\
  541. X        if test -z "$(SYSTEM)";\
  542. X        then $(MAKE) ERROR;\
  543. X        else $(MAKE) $(SYSTEM) goober;\
  544. X        fi;\
  545. X    fi
  546. X
  547. Xgoober:
  548. X
  549. XERROR:
  550. X    @echo
  551. X    @echo\
  552. X "  If you're not sure about the characteristics of your system, try typing"
  553. X    @echo\
  554. X '  "make generic".  If the compiler barfs and says something unpleasant about'
  555. X    @echo\
  556. X '  "timezone redefined," try typing "make clean" followed by "make generic2".'
  557. X    @echo\
  558. X '  One of these actions should produce a working copy of unzip on most Unix'
  559. X    @echo\
  560. X '  systems.  If you know a bit more about the machine on which you work, you'
  561. X    @echo\
  562. X '  might try "make list" for a list of the specific systems supported herein.'
  563. X    @echo\
  564. X '  And as a last resort, feel free to read the numerous comments within the'
  565. X    @echo\
  566. X '  Makefile itself.  Have an excruciatingly pleasant day.'
  567. X    @echo
  568. X
  569. Xlist:
  570. X    @echo
  571. X    @echo\
  572. X 'Type "make <system>", where <system> is one of the following:'
  573. X    @echo
  574. X    @echo  "    $(SYSTEMS1)"
  575. X    @echo  "    $(SYSTEMS2)"
  576. X    @echo  "    $(SYSTEMS3)"
  577. X    @echo  "    $(SYSTEMS4)"
  578. X#    @echo  "    $(SYSTEMS5)"
  579. X    @echo
  580. X    @echo\
  581. X 'Otherwise set the shell variable SYSTEM to one of these and just type "make".'
  582. X    @echo\
  583. X 'For further (very useful) information, please read the comments in Makefile.'
  584. X    @echo
  585. X
  586. X
  587. X###############################################
  588. X# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
  589. X###############################################
  590. X
  591. X.c$O :
  592. X    $(CC) -c $(CFLAGS) $*.c
  593. X
  594. Xunzip$(EXE):    $(OBJS)
  595. X    $(LD) $(LDFLAGS) $(OBJS) $(LDFLAGS2)
  596. X
  597. Xfile_io$O:      file_io.c unzip.h
  598. Xmapname$O:      mapname.c unzip.h
  599. Xmatch$O:        match.c unzip.h
  600. Xmisc$O:         misc.c unzip.h
  601. Xunimplod$O:     unimplod.c unzip.h
  602. Xunreduce$O:     unreduce.c unzip.h
  603. Xunshrink$O:     unshrink.c unzip.h
  604. Xunzip$O:        unzip.c unzip.h
  605. X
  606. Xclean:
  607. X    rm -f $(OBJS) unzip$(EXE)
  608. X
  609. X# Zipinfo section commented out because it's no longer compatible with
  610. X# the current unzip.h (I think).  Will be updated one of these days...
  611. X#
  612. X# zipinfo:    zipinfo.c unzip.h
  613. X#    $(CC) $(CFLAGS) -DNOTINT16 zipinfo.c -o zipinfo
  614. X
  615. X
  616. X################################
  617. X# INDIVIDUAL MACHINE MAKERULES #
  618. X################################
  619. X
  620. X# these are the makerules for various systems
  621. X# TABS ARE REQUIRED FOR SOME VERSIONS OF make!
  622. X
  623. X
  624. X# ---------------------------------------------------------------------------
  625. X#   Generic targets (can't assume make utility groks "$(MAKE)")
  626. X# ---------------------------------------------------------------------------
  627. X
  628. Xgeneric:    # first try for unknown systems:  hope make is called "make"...
  629. X    make unzip CFLAGS="$(CFLAGS) -DNOTINT16"
  630. X
  631. Xgeneric2:    # second try for unknown systems:  keep hoping...
  632. X    make unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DBSD"
  633. X
  634. X# ---------------------------------------------------------------------------
  635. X#   "Normal" (i.e., PC-like) group (no #defines):
  636. X# ---------------------------------------------------------------------------
  637. X
  638. X386i:        unzip    # sun386i, SunOS 4.0.2 ["sun:" works, too, but bigger]
  639. Xencore:        unzip    # Multimax
  640. Xsco:        unzip    # Xenix/386 (tested on 2.3.1); SCO Unix 3.2.0.
  641. Xultrix_vax:    unzip    # VAXen running Ultrix (just 4.0?); not RISC machines
  642. Xvax:        unzip    # general-purpose VAX target (not counting VMS)
  643. X
  644. X# ---------------------------------------------------------------------------
  645. X#   NOTINT16 (structure-padding and/or big-endian) group:
  646. X# ---------------------------------------------------------------------------
  647. X
  648. X3Bx:        _16    # AT&T 3B2/1000-80; should work on any WE32XXX machine
  649. Xamdahl:        _16    # Amdahl (IBM) mainframe, UTS (SysV) 1.2.4 and 2.0.1
  650. Xapollo:        _16    # Apollo Domain/OS machines
  651. Xaviion:         _16     # Data General AViiONs, DG/UX 4.3x
  652. Xconvex:        _16    # C200/C400
  653. Xcray_cc:    _16    # Cray-2 and Y-MP, using old-style compiler
  654. X#dec5820:    _16    # DEC 5820 (RISC), Test version of Ultrix v4.0
  655. Xdnix:        _16    # 680X0, DIAB dnix 5.2/5.3 (a Swedish System V clone)
  656. Xgould:        _16    # Gould PN9000 running UTX/32 2.1Bu01
  657. Xhp:        _16    # HP 9000 series (68020), 4.3BSD or HP-UX A.B3.10 Ver D
  658. Xmips:        _16    # MIPS M120-5(?), SysV R3 [error in sys/param.h file?]
  659. X#next:        _16    # 68030 BSD 4.3+Mach
  660. Xrtaix:        _16    # IBM RT 6150 under AIX 2.2.1
  661. Xstellar:    _16    # gs-2000
  662. Xtahoe:        _16    # tahoe (CCI Power6/32), 4.3BSD
  663. X
  664. X_16:
  665. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16"
  666. X
  667. X# ---------------------------------------------------------------------------
  668. X#   NOTINT16 + BSD (for timezone structs) group:
  669. X# ---------------------------------------------------------------------------
  670. X
  671. Xsun:        _16bsd    # Sun 4/110, SunOS 4.0.3c; Sun 3 (68020), SunOS 4.0.3
  672. Xultrix_risc:    _16bsd    # DEC 58x0 (MIPS guts), DECstation 2100; Ultrix v4.1
  673. X
  674. X_16bsd:
  675. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DBSD"
  676. X
  677. X# ---------------------------------------------------------------------------
  678. X#   "Unique" group (require non-standard options):
  679. X# ---------------------------------------------------------------------------
  680. X
  681. X# Sequent Symmetry is a 386 but needs -DZMEM
  682. X# This should also work on Balance but I can't test it just yet.
  683. X
  684. Xsequent:    # Sequent w/Dynix
  685. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DBSD -DZMEM"
  686. X
  687. X# I have finished porting unzip 3.0 to the Pyramid 90X under OSX4.1.
  688. X# The biggest problem was the default structure alignment yielding two
  689. X# extra bytes.  The compiler has the -q option to pack structures, and
  690. X# this was all that was needed.  To avoid needing ZMEMS we could compile in
  691. X# the att universe, but it runs slower!
  692. X
  693. Xpyramid:    # Pyramid 90X, probably all, under >= OSx4.1, BSD universe
  694. X    make unzip CFLAGS="$(CFLAGS) -q -DBSD -DNOTINT16 -DZMEM"
  695. X
  696. X# I successfully compiled and tested the unzip program (v30) for the
  697. X# Silicon Graphics environment (Personal Iris 4D20/G with IRIX v3.2.2)
  698. X#
  699. X#  Valter V. Cavecchia          | Bitnet:       cavecchi@itncisca
  700. X#  Centro di Fisica del C.N.R.  | Internet:     root@itnsg1.cineca.it
  701. X#  I-38050 Povo (TN) - Italy    | Decnet:       itnvax::cavecchia (37.65)
  702. X
  703. Xsgi:        # Silicon Graphics (tested on Personal Iris 4D20)
  704. X    $(MAKE) unzip \
  705. X    CFLAGS="$(CFLAGS) -I/usr/include/bsd -DBSD -DNOTINT16" \
  706. X    LDFLAGS="-lbsd $(LDFLAGS)"
  707. X
  708. X# Cray-2 and Y-MP, running Unicos 5.1.10 or 6.0 (SysV + BSD enhancements)
  709. X# and Standard (ANSI) C compiler 1.5 or 2.0.1.
  710. X
  711. Xcray:
  712. X    $(MAKE) unzip CC="scc" LD="scc" CFLAGS="$(CFLAGS) -DNOTINT16"
  713. X
  714. X# SCO cross compile from unix to DOS. Tested with Xenix/386 and
  715. X# OpenDeskTop. Should work with xenix/286 as well. (davidsen)
  716. X# Note that you *must* remove the unix objects and executable
  717. X# before doing this!
  718. X
  719. Xsco_dos:
  720. X    $(MAKE) unzip CFLAGS="-O -dos -M0" LDFLAGS="-dos" \
  721. X        LDFLAGS2="-o unzip.exe"
  722. X
  723. X# PCs (IBM-type), running MS-DOS, Microsoft C 6.00 and NMAKE.  Can't use the
  724. X# SYSTEM environment variable; that requires processing the "default:" target,
  725. X# which expands to some 200+ characters--well over DOS's 128-character limit.
  726. X# "nmake msc_dos" works fine, aside from an annoying message, "temporary file
  727. X# e:\ln023193 has been created."  I have no idea how to suppress this, but it
  728. X# appears to be benign (comes from the link phase; the file is always deleted).
  729. X# The environment variable FP should be set to something appropriate if your 
  730. X# library uses other than the default floating-point routines; for example, 
  731. X# SET FP=-FPi87 .  "msc_dos:" does NOT work with Dennis Vadura's dmake (dmake 
  732. X# doesn't seem to understand quotes, and it wants SHELL=$(COMSPEC).  NMAKE 
  733. X# ignores SHELL altogether.)  This target assumes the small-model library and 
  734. X# an 80286 or better.  At present, everything fits within the 128-character 
  735. X# command-line limit.  (Barely.)
  736. X
  737. Xmsc_dos:
  738. X    $(MAKE) -nologo unzip.exe CFLAGS="-Ox -nologo $(FP) -G2" CC=cl\
  739. X    LD=link EXE=.exe O=.obj LDFLAGS="/noi /nol" LDFLAGS2=",unzip;"
  740. X
  741. X# I do not believe that OS/2 has the 128 character command line limitation, 
  742. X# so when I have more time to get to know how nmake really works, I may figure 
  743. X# out how to set the makefile so that it works like most of the other things 
  744. X# in unix.  The main things I had to change were adding the define -DOS2 and 
  745. X# the C flag -Lp.  It still looks for the default named libraries, and not 
  746. X# the protected-mode names, but I am sure most people dealing with OS/2 know
  747. X# how to type slibcep when it says it can't find slibce.
  748. X
  749. Xmsc_os2:
  750. X    $(MAKE) -nologo unzip.exe CFLAGS="-Ox -nologo $(FP) -G2 -DOS2 -Lp"\
  751. X    CC=cl LD=link EXE=.exe O=.obj LDFLAGS="/noi /nol"\
  752. X    LDFLAGS2=",unzip,,,unzip.def;"
  753. X
  754. X# NeXT 2.x: make the executable smaller.
  755. Xnext:
  756. X    $(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16" LDFLAGS2="-object -s"
  757. X
  758. X# I didn't do this.  I swear.  No, really.
  759. X
  760. Xwombat:        # Wombat 68000 (or whatever)
  761. X    @echo
  762. X    @echo  '    Ha ha!  Just kidding.'
  763. X    @echo
  764. X
  765. X################
  766. X# ATTRIBUTIONS #
  767. X################
  768. X
  769. X# Thanks to the following people for their help in testing and/or porting
  770. X# to various machines:
  771. X#
  772. X#  386i:    Richard Stephen, stephen@corp.telecom.co.nz
  773. X#  3Bx:        Bob Kemp, hrrca!bobc@cbnewse.att.com
  774. X#  amdahl:    Kim DeVaughn, ked01@juts.ccc.amdahl.com
  775. X#  apollo:    Tim Geibelhaus
  776. X#  aviion:    Bruce Kahn, bkahn@archive.webo.dg.com
  777. X#  cray:    Greg Roelofs, roelofs@amelia.nas.nasa.gov
  778. X#  dec5820:    "Moby" Dick O'Connor, djo7613@u.washington.edu
  779. X#  dnix:    Bo Kullmar, bk@kullmar.se
  780. X#  gould:    Onno van der Linden, linden@fwi.uva.nl
  781. X#  hp:        Randy McCaskile, rmccask@seas.gwu.edu (HP-UX)
  782. X#           Gershon Elber, gershon@cs.utah.edu (HP BSD 4.3)
  783. X#  mips:    Peter Jones, jones@mips1.uqam.ca
  784. X#  msc_dos:    Greg Roelofs
  785. X#  msc_os2:    Wim Bonner, wbonner@yoda.eecs.wsu.edu
  786. X#  next:    Mark Adler, madler@piglet.caltech.edu
  787. X#  pyramid:    James Dugal, jpd@usl.edu
  788. X#  rtaix:    Erik-Jan Vens
  789. X#  sco:        Onno van der Linden (SCO Unix 3.2.0)
  790. X#           Bill Davidsen, davidsen@crdos1.crd.ge.com (Xenix/386)
  791. X#  sco_dos:    Bill Davidsen
  792. X#  sequent:    Phil Howard, phil@ux1.cso.uiuc.edu
  793. X#  sgi:        Valter V. Cavecchia (see comments for addresses)
  794. X#  sun:        Onno van der Linden (Sun 4)
  795. X#  tahoe:    Mark Edwards, mce%sdcc10@ucsd.edu
  796. X#  ultrix_vax:    Greg Flint, afc@klaatu.cc.purdue.edu
  797. X#  ultrix_risc:    Michael Graff, explorer@iastate.edu
  798. X#  vax:        Forrest Gehrke, feg@dodger.att.com (SysV)
  799. X#        David Kirschbaum, kirsch@usasoc.soc.mil (BSD 4.3)
  800. X#        Jim Steiner, steiner@pica.army.mil (8600+Ultrix)
  801. X#  wombat:    Joe Isuzu, joe@trustme.isuzu.com
  802. X
  803. X# SCO unix 3.2.0:
  804. X# Don't use -Ox with cc (derived from Microsoft 5.1), there is
  805. X# a bug in the loop optimization, which causes bad CRC's
  806. X#
  807. X# Onno van der Linden
  808. END_OF_FILE
  809.   if test 14794 -ne `wc -c <'./v41/Makefile'`; then
  810.     echo shar: \"'./v41/Makefile'\" unpacked with wrong size!
  811.   fi
  812.   # end of './v41/Makefile'
  813. fi
  814. if test -f './v41/mapname.c' -a "${1}" != "-c" ; then 
  815.   echo shar: Will not clobber existing file \"'./v41/mapname.c'\"
  816. else
  817.   echo shar: Extracting \"'./v41/mapname.c'\" \(12601 characters\)
  818.   sed "s/^X//" >'./v41/mapname.c' <<'END_OF_FILE'
  819. X/*---------------------------------------------------------------------------
  820. X
  821. X  mapname.c
  822. X
  823. X  This routine changes DEC-20, VAX/VMS, and DOS-style filenames into normal
  824. X  Unix names (and vice versa, in some cases); it also creates any necessary 
  825. X  directories, if the -d switch was specified.
  826. X
  827. X  ---------------------------------------------------------------------------
  828. X
  829. X  Action:  renames argument files as follows:
  830. X
  831. X     strips Unix and PKZIP DOS path name from front (up to rightmost '/') if
  832. X       present.
  833. X     strips DEC device:, node:: names from front (up to rightmost ':') if
  834. X       present.  (This also takes care of any DOS drive: artifacts.)
  835. X     strips DEC-20 <directory> or VMS [directory] name if present.
  836. X     strips DEC-20 version number from end (everything after 2nd dot) if
  837. X       present.
  838. X     strips VMS generation number from end (everything after ';') if present,
  839. X       unless "-V" switch specified.
  840. X     honors DEC-20 CTRL-V quote for special characters.
  841. X     discards unquoted unprintable characters.
  842. X     [VMS] converts Unix-style pathnames to VMS style.
  843. X
  844. X     Returns 0 if no error, 1 if filename truncated, 2 for any other error.
  845. X
  846. X  ---------------------------------------------------------------------------
  847. X
  848. X  Author:  David Kirschbaum, 25 Apr 90
  849. X     (Based on good old xxu.c by Frank da Cruz, CUCCA)
  850. X     Subsequent tweaks by Bill Davidsen, James Dugal, Larry Jones,
  851. X     Mark Edwards, Greg Roelofs, Antoine Verheijen.
  852. X
  853. X  ---------------------------------------------------------------------------
  854. X
  855. X  Dot notes:
  856. X
  857. X     - Unix allows multiple dots in directory names; MS-DOS and OS/2 FAT
  858. X       allow one; VMS does not allow any.  Things are almost as bad with
  859. X       regular filenames (VMS allows a single dot but TOPS-20 allows two,
  860. X       if you count the one in front of the version number).  As of v4.04,
  861. X       mapname converts directory-name dots to underscores on VMS, but it
  862. X       otherwise leaves the dots alone.  Since it is now possible to create
  863. X       zipfiles under Unix, this whole routine pretty much needs to be
  864. X       rewritten (different rules for each output OS and for different 
  865. X       parts of the path name).
  866. X     - If each zip program stores local-format names (like the coming VMS
  867. X       one will), it would probably be best to convert to an intermediate 
  868. X       format first (assuming we're not extracting under the same OS as
  869. X       that under which the zipfile was created), then from that to the 
  870. X       current operating system's format.
  871. X
  872. X  ------------------------------------------------------------------------- */
  873. X
  874. X
  875. X#include "unzip.h"
  876. X
  877. X
  878. X/********************/
  879. X/*  Mapname Defines */
  880. X/********************/
  881. X
  882. X#ifdef VMS
  883. X#define PERMS   0
  884. X#else
  885. X#define PERMS   0777
  886. X#endif
  887. X
  888. X#ifndef NO_MKDIR
  889. X#ifdef DOS_OS2
  890. X#if (_MSC_VER >= 600)           /* have special MSC mkdir prototype */
  891. X#include <direct.h>
  892. X#else                           /* own prototype because dir.h conflicts?? */
  893. Xint mkdir(const char *path);
  894. X#endif                          /* !(MSC 6.0 or later) */
  895. X#define MKDIR(path,mode)   mkdir(path)
  896. X#else                           /* !DOS_OS2 */
  897. X#define MKDIR(path,mode)   mkdir(path,mode)
  898. X#endif
  899. X#endif                          /* !NO_MKDIR */
  900. X
  901. X/***************************/
  902. X/*  Function mapped_name() */
  903. X/***************************/
  904. X
  905. Xmapped_name()
  906. X{
  907. X#ifdef NO_MKDIR
  908. X    char command[FILNAMSIZ+40]; /* buffer for system() call */
  909. X#endif
  910. X#ifdef VMS
  911. X    int stat_val;               /* temp. holder for stat() return value */
  912. X    char *dp, *xp;              /* ptrs to directory name */
  913. X#endif
  914. X    char name[FILNAMSIZ];       /* file name buffer */
  915. X    char *pp, *cp, *cdp;        /* character pointers */
  916. X    char delim = '\0';          /* Directory Delimiter */
  917. X    int dc = 0;                 /* Counters */
  918. X    int quote = FALSE;          /* Flags */
  919. X    int indir = FALSE;
  920. X    int done = FALSE;
  921. X    register int workch;        /* hold the character being tested */
  922. X
  923. X
  924. X
  925. X/*---------------------------------------------------------------------------
  926. X    Initialize various pointers and counters and stuff.
  927. X  ---------------------------------------------------------------------------*/
  928. X
  929. X#ifdef MAP_DEBUG
  930. X    fprintf(stderr, "%s ", filename);   /* echo name of this file */
  931. X#endif
  932. X    pp = name;                  /* Point to translation buffer */
  933. X    *name = '\0';               /* Initialize buffer */
  934. X
  935. X    if (dflag) {                /* -d => retain directory structure */
  936. X        cdp = (char *) malloc(strlen(filename) + 3);  /* place for */
  937. X        if (cdp == NULL) {      /*   holding directory name */
  938. X            fprintf(stderr, "malloc failed in conversion of [%s]\n", filename);
  939. X            return (2);
  940. X        }
  941. X#ifdef VMS
  942. X        *cdp++ = '[';
  943. X        xp = cdp;               /* always points to last non-NULL char */
  944. X        *cdp++ = '.';
  945. X#endif
  946. X#ifdef MACOS
  947. X        *cdp = ':';             /* the Mac uses ':' as a directory separator */
  948. X        cdp[1] = '\0';
  949. X#else
  950. X        *cdp = '\0';
  951. X#endif
  952. X    }
  953. X    dc = 0;                     /* Filename dot counter */
  954. X
  955. X/*---------------------------------------------------------------------------
  956. X    Begin main loop through characters in filename.
  957. X  ---------------------------------------------------------------------------*/
  958. X
  959. X    for (cp = filename; (workch = *cp++) != 0  &&  !done;) {
  960. X
  961. X        if (quote) {            /* If this char quoted... */
  962. X            *pp++ = workch;     /*  include it literally. */
  963. X            quote = FALSE;
  964. X        } else if (indir) {     /* If in directory name... */
  965. X            if (workch == delim)
  966. X                indir = FALSE;  /*  look for end delimiter. */
  967. X        } else
  968. X            switch (workch) {
  969. X            case '<':           /* Discard DEC-20 directory name */
  970. X                indir = TRUE;
  971. X                delim = '>';
  972. X                break;
  973. X            case '[':           /* Discard VMS directory name */
  974. X                indir = TRUE;
  975. X                delim = ']';
  976. X                break;
  977. X            case '/':           /* Discard Unix path name... */
  978. X            case '\\':          /*  or MS-DOS path name...
  979. X                                 *  UNLESS -d flag was given. */
  980. X                /*
  981. X                 * Special processing case:  if -d flag was specified on
  982. X                 * command line, create any necessary directories included
  983. X                 * in the pathname.  Creation of directories is straight-
  984. X                 * forward on BSD and MS-DOS machines but requires use of
  985. X                 * the system() command on SysV systems (or any others which
  986. X                 * don't have mkdir()).  The stat() check is necessary with
  987. X                 * MSC because it doesn't have an EEXIST errno, and it saves
  988. X                 * the overhead of multiple system() calls on SysV machines.
  989. X                 */
  990. X
  991. X                if (dflag) {
  992. X                    *pp = '\0';
  993. X#ifdef VMS
  994. X                    dp = name;
  995. X                    while (*++xp = *dp++)   /* copy name to cdp, while */
  996. X                        if (*xp == '.')     /*   changing all dots... */
  997. X                            *xp = '_';      /*   ...to underscores */
  998. X                    strcpy(xp, ".dir");    /* add extension for stat check */
  999. X                    stat_val = stat(cdp, &statbuf);
  1000. X                    *xp = '\0';         /* remove extension for all else */
  1001. X                    if (stat_val) {     /* doesn't exist, so create */
  1002. X#else
  1003. X                    strcat(cdp, name);
  1004. X                    if (stat(cdp, &statbuf)) {  /* doesn't exist, so create */
  1005. X#endif
  1006. X#ifdef NO_MKDIR
  1007. X                        sprintf(command, "IFS=\" \t\n\" /bin/mkdir %s 2>/dev/null", cdp);
  1008. X                        if (system(command)) {
  1009. X#else
  1010. X                        if (MKDIR(cdp, PERMS) == -1) {
  1011. X#endif
  1012. X                            perror(cdp);
  1013. X                            free(cdp);
  1014. X                            fprintf(stderr, "Unable to process [%s]\n", filename);
  1015. X                            return (2);
  1016. X                        }
  1017. X                    } else if (!(statbuf.st_mode & S_IFDIR)) {
  1018. X                        fprintf(stderr, "%s:  exists but is not a directory\n",
  1019. X                                cdp);
  1020. X                        free(cdp);
  1021. X                        fprintf(stderr, "unable to process [%s]\n", filename);
  1022. X                        return (2);
  1023. X                    }
  1024. X#ifdef VMS
  1025. X                    *xp = '/';  /* for now... (mkdir()) */
  1026. X#else /* !VMS */
  1027. X#ifdef MACOS
  1028. X                    strcat(cdp, ":");
  1029. X#else /* !MACOS */
  1030. X                    strcat(cdp, "/");
  1031. X#endif /* ?MACOS */
  1032. X#endif /* ?VMS */
  1033. X                }               /***** FALL THROUGH to ':' case  **** */
  1034. X            case ':':           /* Discard DEC dev: or node:: name */
  1035. X                pp = name;
  1036. X                break;
  1037. X            case '.':                   /* DEC-20 generation number
  1038. X                                         * or MS-DOS type */
  1039. X#ifdef NUKE_DOTS
  1040. X                if (++dc == 1)          /* Keep first dot */
  1041. X                    *pp++ = workch;
  1042. X#else
  1043. X                ++dc;                   /* Not used, but what the hell. */
  1044. X                *pp++ = workch;
  1045. X#endif
  1046. X                break;
  1047. X            case ';':                   /* VMS generation or DEC-20 attrib */
  1048. X                if (V_flag)             /* If requested, save VMS ";##" */
  1049. X                    *pp++ = workch;     /*  version info; else discard */
  1050. X                else                    /*  everything starting with */
  1051. X                    done = TRUE;        /*  semicolon.  (Worry about */
  1052. X                break;                  /*  DEC-20 later.) */
  1053. X            case '\026':                /* Control-V quote for special chars */
  1054. X                quote = TRUE;           /* Set flag for next time. */
  1055. X                break;
  1056. X            default:                    /* some other char */
  1057. X                if (isdigit(workch))    /* '0'..'9' */
  1058. X                    *pp++ = workch;     /* accept them, no tests */
  1059. X                else {
  1060. X                    if (workch == ' ')  /* change blanks to underscore */
  1061. X                        *pp++ = '_';
  1062. X                    else if (isprint(workch))   /* Other printable, just keep */
  1063. X                        *pp++ = workch;
  1064. X                }
  1065. X            }                   /* switch */
  1066. X    }                           /* for loop */
  1067. X    *pp = '\0';                 /* Done with name, terminate it */
  1068. X
  1069. X/*---------------------------------------------------------------------------
  1070. X    We COULD check for existing names right now, create a "unique" name, etc.
  1071. X    However, since other unzips don't do that...we won't bother.  Maybe an-
  1072. X    other day, ne?  If this went bad, the name'll either be nulled out (in
  1073. X    which case we'll return non-0) or following procedures won't be able to
  1074. X    create the extracted file, and other error msgs will result.
  1075. X  ---------------------------------------------------------------------------*/
  1076. X
  1077. X    if (*name == '\0') {
  1078. X        fprintf(stderr, "conversion of [%s] failed\n", filename);
  1079. X        return (2);
  1080. X    }
  1081. X    if (dflag) {
  1082. X#ifdef VMS
  1083. X        *xp++ = ']';            /* proper end-of-dir-name delimiter */
  1084. X        if (xp == cdp) {        /* no path-name stuff, so... */
  1085. X            strcpy(filename, name);  /* copy file name into global */
  1086. X            cdp -= 2;           /*   prepare to free malloc'd space */
  1087. X        } else {                /* we've added path-name stuff... */
  1088. X            *xp = '\0';         /*   so terminate... */
  1089. X            dp = cdp;           /*   and convert to VMS subdir separators:  */
  1090. X            while (*++dp)       /*   (skip first char:  better not be "/") */
  1091. X                if (*dp == '/') /*   change all slashes */
  1092. X                    *dp = '.';  /*     to dots */
  1093. X            cdp -= 2;           /*   include leading bracket and dot */
  1094. X            strcpy(filename, cdp);   /* copy VMS-style path name into global */
  1095. X            strcat(filename, name);  /* concatenate file name to global */
  1096. X        }
  1097. X#else
  1098. X        strcpy(filename, cdp);  /* Either "" or slash-terminated path */
  1099. X        strcat(filename, name); /* append file name to path name */
  1100. X#endif
  1101. X        free(cdp);
  1102. X    } else
  1103. X        strcpy(filename, name); /* copy converted name into global */
  1104. X
  1105. X#if FILENAME_MAX < (FILNAMSIZ - 1)
  1106. X    /*
  1107. X     * Check the length of the file name and truncate if necessary.
  1108. X     */
  1109. X    if (FILENAME_MAX < strlen(filename)) {
  1110. X        fprintf(stderr, "warning:  filename too long--truncating.\n");
  1111. X        filename[FILENAME_MAX] = '\0';
  1112. X        fprintf(stderr, "[ %s ]\n", filename);
  1113. X        return (1);             /* 1:  warning error */
  1114. X    }
  1115. X#endif
  1116. X
  1117. X    return (0);
  1118. X}
  1119. END_OF_FILE
  1120.   if test 12601 -ne `wc -c <'./v41/mapname.c'`; then
  1121.     echo shar: \"'./v41/mapname.c'\" unpacked with wrong size!
  1122.   fi
  1123.   # end of './v41/mapname.c'
  1124. fi
  1125. if test -f './v41/match.c' -a "${1}" != "-c" ; then 
  1126.   echo shar: Will not clobber existing file \"'./v41/match.c'\"
  1127. else
  1128.   echo shar: Extracting \"'./v41/match.c'\" \(5358 characters\)
  1129.   sed "s/^X//" >'./v41/match.c' <<'END_OF_FILE'
  1130. X/*--------------------------------------------------------------------------
  1131. X
  1132. X  match.c
  1133. X
  1134. X  The match() routine recursively compares a string to a "pattern" (regular
  1135. X  expression), returning TRUE if a match is found or FALSE if not.  This
  1136. X  version is specifically for use with unzip.c:  it leaves the case (upper,
  1137. X  lower, or mixed) of the string alone, but converts any uppercase characters
  1138. X  in the pattern to lowercase if indicated by the global variable lcflag
  1139. X  (which is to say, string is assumed to have been converted to lowercase
  1140. X  already, if such was necessary).
  1141. X
  1142. X  --------------------------------------------------------------------------
  1143. X
  1144. X  Revision history:
  1145. X
  1146. X     Original Author:  Thom Henderson
  1147. X     Original System V port:  Mike Stump
  1148. X
  1149. X     03/22/87  C. Seaman      enhancements, bug fixes, cleanup
  1150. X     11/13/89  C. Mascott     adapted for use with unzip
  1151. X     01/25/90  J. Cowan       made case-insensitive (only for smart toupper())
  1152. X     03/17/90  D. Kirschbaum  prototypes, other tweaks for Turbo C
  1153. X     05/18/90  M. O'Carroll   DOS and OS/2 family version
  1154. X     09/20/90  G. Roelofs     modified for lcflag, moved stuff to header file
  1155. X
  1156. X  --------------------------------------------------------------------------
  1157. X
  1158. X  Copyright, originally from arcmatch.c, version 1.1 (?):
  1159. X
  1160. X     * ARC - Archive utility - ARCMATCH
  1161. X     *
  1162. X     * Version 2.17, created on 12/17/85) at 20:32:18
  1163. X     *
  1164. X     * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  1165. X
  1166. X  --------------------------------------------------------------------------*/
  1167. X
  1168. X
  1169. X#include "unzip.h"
  1170. X
  1171. X
  1172. X/*******************/
  1173. X/*  Match Defines  */
  1174. X/*******************/
  1175. X
  1176. X#define ASTERISK        '*'     /* The '*' metacharacter */
  1177. X#define QUESTION        '?'     /* The '?' metacharacter */
  1178. X#define BACK_SLASH      '\\'    /* The '\' metacharacter */
  1179. X#define LEFT_BRACKET    '['     /* The '[' metacharacter */
  1180. X#define RIGHT_BRACKET   ']'     /* The ']' metacharacter */
  1181. X#define EOS             '\000'  /* end-of-string */
  1182. X
  1183. X#define IS_OCTAL(ch)    (ch >= '0' && ch <= '7')
  1184. X
  1185. X
  1186. X
  1187. X/********************/
  1188. X/*  Match Typedefs  */
  1189. X/********************/
  1190. X
  1191. Xtypedef short int INT;
  1192. Xtypedef short int BOOLEAN;
  1193. X
  1194. X
  1195. X
  1196. X/*************************************/
  1197. X/*  Match Local Function Prototypes  */
  1198. X/*************************************/
  1199. X
  1200. Xstatic BOOLEAN do_list __((register char *string, char *pattern));
  1201. Xstatic void list_parse __((char **patp, char *lowp, char *highp));
  1202. Xstatic char nextch __((char **patp));
  1203. X
  1204. X
  1205. X
  1206. X
  1207. X
  1208. X/**********************/
  1209. X/*  Function match()  */
  1210. X/**********************/
  1211. X
  1212. Xint match(string, pattern)
  1213. Xchar *string;
  1214. Xchar *pattern;
  1215. X{
  1216. X    register int ismatch;
  1217. X
  1218. X    ismatch = FALSE;
  1219. X    switch (*pattern) {
  1220. X    case ASTERISK:
  1221. X        pattern++;
  1222. X        do {
  1223. X            ismatch = match(string, pattern);
  1224. X        }
  1225. X        while (!ismatch && *string++ != EOS);
  1226. X        break;
  1227. X    case QUESTION:
  1228. X        if (*string != EOS)
  1229. X            ismatch = match(++string, ++pattern);
  1230. X        break;
  1231. X    case EOS:
  1232. X        if (*string == EOS)
  1233. X            ismatch = TRUE;
  1234. X        break;
  1235. X    case LEFT_BRACKET:
  1236. X        if (*string != EOS)
  1237. X            ismatch = do_list(string, pattern);
  1238. X        break;
  1239. X    case BACK_SLASH:
  1240. X        pattern++;
  1241. X    default:
  1242. X        if (*string == ((lcflag && isupper(*pattern)) ? tolower(*pattern) : *pattern)) {
  1243. X            string++;
  1244. X            pattern++;
  1245. X            ismatch = match(string, pattern);
  1246. X        } else
  1247. X            ismatch = FALSE;
  1248. X        break;
  1249. X    }
  1250. X    return (ismatch);
  1251. X}
  1252. X
  1253. X
  1254. X
  1255. X
  1256. X
  1257. X/************************/
  1258. X/*  Function do_list()  */
  1259. X/************************/
  1260. X
  1261. Xstatic BOOLEAN do_list(string, pattern)
  1262. Xregister char *string;
  1263. Xchar *pattern;
  1264. X{
  1265. X    register BOOLEAN ismatch;
  1266. X    register BOOLEAN if_found;
  1267. X    register BOOLEAN if_not_found;
  1268. X    auto char lower;
  1269. X    auto char upper;
  1270. X
  1271. X    pattern++;
  1272. X    if (*pattern == '!') {
  1273. X        if_found = FALSE;
  1274. X        if_not_found = TRUE;
  1275. X        pattern++;
  1276. X    } else {
  1277. X        if_found = TRUE;
  1278. X        if_not_found = FALSE;
  1279. X    }
  1280. X    ismatch = if_not_found;
  1281. X    while (*pattern != ']' && *pattern != EOS) {
  1282. X        list_parse(&pattern, &lower, &upper);
  1283. X        if (*string >= lower && *string <= upper) {
  1284. X            ismatch = if_found;
  1285. X            while (*pattern != ']' && *pattern != EOS)
  1286. X                pattern++;
  1287. X        }
  1288. X    }
  1289. X
  1290. X    if (*pattern++ != ']') {
  1291. X        printf("Character class error\n");
  1292. X        exit(1);
  1293. X    } else if (ismatch)
  1294. X        ismatch = match(++string, pattern);
  1295. X
  1296. X    return (ismatch);
  1297. X}
  1298. X
  1299. X
  1300. X
  1301. X
  1302. X
  1303. X/***************************/
  1304. X/*  Function list_parse()  */
  1305. X/***************************/
  1306. X
  1307. Xstatic void list_parse(patp, lowp, highp)
  1308. Xchar **patp;
  1309. Xchar *lowp;
  1310. Xchar *highp;
  1311. X{
  1312. X    *lowp = nextch(patp);
  1313. X    if (**patp == '-') {
  1314. X        (*patp)++;
  1315. X        *highp = nextch(patp);
  1316. X    } else
  1317. X        *highp = *lowp;
  1318. X}
  1319. X
  1320. X
  1321. X
  1322. X
  1323. X
  1324. X/***********************/
  1325. X/*  Function nextch()  */
  1326. X/***********************/
  1327. X
  1328. Xstatic char nextch(patp)
  1329. Xchar **patp;
  1330. X{
  1331. X    register char ch;
  1332. X    register char chsum;
  1333. X    register INT count;
  1334. X
  1335. X    ch = *(*patp)++;
  1336. X    if (ch == '\\') {
  1337. X        ch = *(*patp)++;
  1338. X        if (IS_OCTAL(ch)) {
  1339. X            chsum = 0;
  1340. X            for (count = 0; count < 3 && IS_OCTAL(ch); count++) {
  1341. X                chsum *= 8;
  1342. X                chsum += ch - '0';
  1343. X                ch = *(*patp)++;
  1344. X            }
  1345. X            (*patp)--;
  1346. X            ch = chsum;
  1347. X        }
  1348. X    }
  1349. X    return (ch);
  1350. X}
  1351. END_OF_FILE
  1352.   if test 5358 -ne `wc -c <'./v41/match.c'`; then
  1353.     echo shar: \"'./v41/match.c'\" unpacked with wrong size!
  1354.   fi
  1355.   # end of './v41/match.c'
  1356. fi
  1357. echo shar: End of archive 4 \(of 6\).
  1358. cp /dev/null ark4isdone
  1359. MISSING=""
  1360. for I in 1 2 3 4 5 6 ; do
  1361.     if test ! -f ark${I}isdone ; then
  1362.     MISSING="${MISSING} ${I}"
  1363.     fi
  1364. done
  1365. if test "${MISSING}" = "" ; then
  1366.     echo You have unpacked all 6 archives.
  1367.     rm -f ark[1-9]isdone
  1368. else
  1369.     echo You still must unpack the following archives:
  1370.     echo "        " ${MISSING}
  1371. fi
  1372. exit 0
  1373. exit 0 # Just in case...
  1374. -- 
  1375. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1376. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1377. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1378. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1379.