home *** CD-ROM | disk | FTP | other *** search
- From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Newsgroups: comp.sources.misc
- Subject: v44i080: unzip - Info-ZIP portable UnZip, version 5.12, Part15/20
- Date: 18 Sep 1994 23:16:35 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <35j3b3$qqk@sparky.sterling.com>
- X-Md4-Signature: c7739000dd02e82faf0f3a3e70ff5601
-
- Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Posting-number: Volume 44, Issue 80
- Archive-name: unzip/part15
- Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT, AMIGA?, ATARI TOS, SGI, DEC, Cray, Convex, Amdahl, Sun
- Supersedes: unzip50: Volume 31, Issue 104-117
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: unzip-5.12/ZipPorts unzip-5.12/human68k/options.s.UU
- # unzip-5.12/os2/wat_met.dif unzip-5.12/unix/unzipsfx.1
- # unzip-5.12/unshrink.c
- # Wrapped by kent@sparky on Sat Sep 17 23:33:45 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 15 (of 20)."'
- if test -f 'unzip-5.12/ZipPorts' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/ZipPorts'\"
- else
- echo shar: Extracting \"'unzip-5.12/ZipPorts'\" \(13591 characters\)
- sed "s/^X//" >'unzip-5.12/ZipPorts' <<'END_OF_FILE'
- X__________________________________________________________________________
- X
- X This is the Info-ZIP file ZipPorts, last updated on 15 August 1994.
- X__________________________________________________________________________
- X
- X
- XThis document defines a set of rules and guidelines for those who wish to
- Xcontribute patches to Zip and UnZip (or even entire ports to new operating
- Xsystems). The list below is something between a style sheet and a "Miss
- XManners" etiquette guide. While Info-ZIP encourages contributions and
- Xfixes from anyone who finds something worth changing, we are also aware
- Xof the fact that no two programmers have the programming style and that
- Xunrestrained changes by a few dozen contributors would result in hideously
- Xugly (and unmaintainable) Frankenstein code. So consider the following an
- Xattempt by the maintainers to maintain sanity as well as useful code.
- X
- X(The first version of this document was called either "ZipRules" or the
- X"No Feelthy ..." file and was compiled by David Kirschbaum in consulta-
- Xtion with Mark Adler, Cave McNewt and others. The current incarnation
- Xexpands upon the original with insights gained from a few more years of
- Xhappy hacking...)
- X
- X
- XSummary:
- X
- X (0) The Platinum Rule: DON'T BREAK EXISTING PORTS
- X(0.1) The Golden Rule: DO UNTO THE CODE AS OTHERS HAVE DONE BEFORE
- X(0.2) The Silver Rule: DO UNTO THE LATEST BETA CODE
- X(0.3) The Bronze Rule: NO FEELTHY PIGGYBACKS
- X
- X (1) NO FEELTHY TABS
- X (2) NO FEELTHY CARRIAGE RETURNS
- X (3) NO FEELTHY 8-BIT CHARS
- X (4) NO FEELTHY LEFT-JUSTIFIED DASHES
- X (5) NO FEELTHY FANCY_FILENAMES
- X (6) NO FEELTHY NON-ZIPFILES AND NO FEELTHY E-MAIL BETAS
- X (7) NO FEELTHY E-MAIL BINARIES
- X
- X
- XExplanations:
- X
- X (0) The Platinum Rule: DON'T BREAK EXISTING PORTS
- X
- X No doubt about it, this is the one which really pisses us off and
- X pretty much guarantees that your port or patch will be ignored and/
- X or laughed at. Examples range from the *really* severe cases which
- X "port" by ripping out all of the existing multi-OS code, to more
- X subtle oopers like relying on a local capability which doesn't exist
- X on other OSes or in older compilers (e.g., the use of ANSI "#elif"
- X constructs, C++ comments, GNU extensions, etc.). As to the former,
- X use #ifdefs for your new code (see rule 0.3). And as to the latter,
- X trust us--there are few things we'd like better than to be able to
- X use some of the elegant "new" features out there (many of which have
- X been around for a decade or more). But our code still compiles on
- X machines dating back even longer, at least in spirit--e.g., the AT&T
- X 3B1 family and Dynix/ptx. Until we say otherwise, dinosaurs are
- X supported.
- X
- X
- X(0.1) The Golden Rule: DO UNTO THE CODE AS OTHERS HAVE DONE BEFORE
- X
- X In other words, try to fit into the local style of programming--no
- X matter how painful it may be. This includes cosmetic aspects like
- X indenting the same amount (both in the main C code and in the in-
- X clude files), using braces and comments similarly, NO TABS (see rule
- X #1), etc.; but also more substantive things like (for UnZip) putting
- X character strings into static (far) variables and using the LoadFar-
- X String macros to avoid overflowing limited MS-DOS data segments, and
- X using the PRINTF/FPRINTF/PUTC macros instead of the corresponding
- X functions so that dynamic-link-library ports are simpler.
- X
- X Note that not only do Zip and UnZip differ in these respects, so do
- X individual parts of each program. While it would be nice to have
- X global consistency, cosmetic changes are not a high priority; for
- X now we'll settle for local consistency--i.e., don't make things any
- X worse than they already are.
- X
- X Exception (BIG exception): single-letter variable names. Despite
- X the prevailing practice in much of Zip and parts of UnZip, and de-
- X spite the fact that one-letter variables allow you to pack really
- X cool, compact and complicated expressions onto one line, they also
- X make the code very difficult to maintain and are therefore *strongly*
- X discouraged. Don't ask us who is responsible in the first place;
- X while this sort of brain damage is not uncommon among former BASIC
- X programmers, it is nevertheless a lifelong embarrassment, and we do
- X try to pity the poor sod (that is, when we're not chasing bugs and
- X cursing him). :-)
- X
- X
- X(0.2) The Silver Rule: DO UNTO THE LATEST BETA CODE
- X
- X Few things are as annoying as receiving a large patch which obviously
- X represents a lot of time and careful work but which is relative to
- X an old version of Info-ZIP code. As wonderful as Larry Wall's patch
- X program is at applying context diffs to modified code, we regularly
- X make near-global changes and/or reorganize big chunks of the sources
- X (particularly in UnZip), and "patch" can't work miracles--big changes
- X invariably break any patch which is relative to an old version of the
- X code.
- X
- X Bottom line: contact the Info-ZIP core team FIRST (via the zip-bugs
- X e-mail address) and get up to date with the latest code before begin-
- X ning a big new port.
- X
- X
- X(0.3) The Bronze Rule: NO FEELTHY PIGGYBACKS
- X
- X UnZip is currently ported to something like 10 operating systems
- X (a few more or less depending on how one counts), and each of these
- X has a unique macro identifying it: AMIGA, ATARI_ST, __human68k__,
- X MACOS, MSDOS, OS2, NT (or WIN32), TOPS20, UNIX, VMS. Zip is moving
- X in the same direction. New ports should NOT piggyback one of the
- X existing ports unless they are substantially similar--for example,
- X Minix and Coherent are basically Unix and therefore are included in
- X the UNIX macro, but DOS djgpp ports and OS/2 emx ports (both of which
- X use the Unix-originated GNU C compiler and often have "unix" defined
- X by default) are obviously *not* Unix. [The existing MTS port is a
- X special exception; basically only one person knows what MTS really
- X is, and he's not telling. Presumably it's not very close to Unix,
- X but it's not worth arguing about it now.] Along the same lines,
- X neither OS/2 nor Human68K is the same as (or even close to) MS-DOS.
- X
- X Bottom line: when adding a new port (e.g., MVS), create a new macro
- X for it ("MVS"), a new subdirectory ("mvs") and a new source file for
- X OS-specific code ("mvs/mvs.c"). Use #ifdefs to fit any OS-specific
- X changes into the existing code (e.g., unzip.h). If it's close enough
- X to an existing port that piggybacking is a temptation, define a new
- X "combination macro" (e.g., "MVS_UNIX") and replace the old macros as
- X required. (This last applies to UnZip, at least; Jean-loup prefers
- X fewer macros and long #ifdef lines, so talk to him about Zip.) See
- X also rule 0.1.
- X
- X (Note that, for UnZip, new ports need not attempt to deal with all
- X features. Among other things, the wildcard-zipfile code in do_wild()
- X may be replaced with a supplied dummy version, since opendir/readdir/
- X closedir() or the equivalent can be difficult to implement.)
- X
- X
- X (1) NO FEELTHY TABS
- X
- X Some editors and e-mail systems either have no capability to use
- X and/or display tab characters (ASCII 9) correctly, or they use non-
- X standard or variable-width tab columns, or other horrors. Some edi-
- X tors auto-convert spaces to tabs, after which the blind use of "diff
- X -c" results in a huge and mostly useless patch. Yes, *we* know about
- X diff's "-b" option, but not everyone does. And yes, we also know this
- X makes the source files bigger, even after compression; so be it.
- X
- X Bottom line: use spaces, not tabs.
- X
- X Exception: some of the makefiles (the Unix one in particular), for
- X which tabs are required as part of the syntax.
- X
- X Related utility programs:
- X Unix, OS/2 and MS-DOS: expand, unexpand.
- X MS-DOS: Buerg's TABS; Toad Hall's TOADSOFT.
- X And some editors have the conversion built-in.
- X
- X
- X (2) NO FEELTHY CARRIAGE RETURNS
- X
- X All source, documentation and other text files shall have Unix style
- X line endings (LF only, a.k.a. ctrl-J), not the DOS/OS2/NT CR+LF or Mac
- X CR-only line endings.
- X
- X Reason: "real programmers" in any environment can convert back and
- X forth between Unix and DOS/Mac style. All PC compilers but a few old
- X Borland versions can use either Unix or MS-DOS end-of-lines. Buerg's
- X LIST (file-display utility) for MS-DOS can use Unix or MS-DOS EOLs.
- X Both Zip and UnZip can convert line-endings as appropriate. But Unix
- X utilities like diff and patch die a horrible death (or produce horrible
- X output) if the target files have CRs.
- X
- X Related utilities: flip for Unix, OS/2 and MS-DOS; Unix "tr".
- X
- X Exceptions: documentation in pre-compiled binary distributions should
- X be in the local (target) format.
- X
- X
- X (3) NO FEELTHY 8-BIT CHARS
- X
- X Do all your editing in a plain-text ASCII editor. No WordPerfect, MS
- X Word, WordStar document mode, or other word processor files, thenkyew.
- X No desktop publishing. *Especially* no EBCDIC. No TIFFs, no GIFs, no
- X embedded pictures or dancing ladies (too bad, Cave Newt). [Sigh... -CN]
- X
- X Reason: compatibility with different consoles. My old XT clone is
- X the most limited!
- X
- X Exceptions: some Macintosh makefiles apparently require some 8-bit
- X characters; the Human68k port uses 8-bit characters to Kanji or Kana
- X comments (I think); etc.
- X
- X Related utilities: vi, emacs, EDLIN, Turbo C editor, other programmers'
- X editors, various word processor -> text conversion utilities.
- X
- X
- X (4) NO FEELTHY LEFT-JUSTIFIED DASHES
- X
- X Always precede repeated dashes (------) with one or more leading non-
- X dash characters: spaces, tabs, pound signs (#), comments (/*), what-
- X ever.
- X
- X Reason: sooner or later your source file will be e-mailed through an
- X undigestifier utility, most of which treat leading dashes as end-of-
- X message separators. We'd rather not have your code broken up into a
- X dozen separate untitled messages, thank you.
- X
- X
- X (5) NO FEELTHY FANCY_FILENAMES
- X
- X Assume the worst: that someone on a brain-damaged DOS system has to
- X work with everything your magic fingers produced. Keep the filenames
- X unimaginative and within MS-DOS limits (i.e., ordinary A..Z, 1..9,
- X "-$_!"-type characters, in the 8.3 "filename.ext" format). Mac and
- X Unix users, giggle all you want, but no spaces or multiple dots.
- X
- X Reason: compatibility with different file systems. MS-DOS FAT is the
- X most limited, with the exception of CompuServe (6.3, argh).
- X
- X Exceptions: slightly longer names are occasionally acceptable within
- X OS-specific subdirectories, but don't do that unless there's a good
- X reason for it.
- X
- X
- X (6) NO FEELTHY NON-ZIPFILES AND NO FEELTHY E-MAIL BETAS
- X
- X Beta testers and developers are in general expected to have both
- X ftp capability and the ability to deal with zipfiles. Those without
- X should either find a friend who does or else learn about ftp-mailers.
- X
- X Reason: the core development team barely has time to work on the
- X code, much less prepare oddball formats and/or mail betas out (and
- X the situation is getting worse, sigh).
- X
- X Exceptions: anyone seriously proposing to do a new port will be
- X given special treatment, particularly with respect to UnZip; we
- X obviously realize that bootstrapping a completely new port can be
- X quite difficult and have no desire to make it even harder due to
- X lack of access to the latest code (rule 0.2).
- X
- X Public releases of UnZip, on the other hand, will be available in
- X the following formats: .tar.Z (16-bit compress'd tar), .zoo (ver-
- X sion 2.10, available for Unix, OS/2, MS-DOS, VMS, etc.), and .zip
- X (either "plain" or self-extracting). Zip sources and executables
- X will generally only be distributed in .zip format, since Zip is
- X pretty much useless without UnZip.
- X
- X
- X (7) NO FEELTHY E-MAIL BINARIES
- X
- X Binary files (e.g., executables, test zipfiles, etc.) should NEVER
- X be mailed raw. Where possible, they should be uploaded via ftp in
- X BINARY mode; if that's impossible, Mark's "ship" ASCII-encoder should
- X be used; and if that's unavailable, uuencode or xxencode should be
- X used. Weirdo NeXTmail, mailtool and MIME formats are also Right Out.
- X
- X Files larger than 50KB may need to be broken into pieces for mailing
- X (be sure to label them in order!), unless "ship" is used (it can
- X auto-split, label and mail files if told to do so). If Down Under
- X is involved, files must be broken into under-20KB chunks.
- X
- X Reasons: to prevent sounds of gagging mailers from resounding through-
- X out the land. To be relatively efficient in the binary->ASCII conver-
- X sion. (Yeah, yeah, I know, there's better conversions out there. But
- X not as widely known, and they often break on BITNET gateways.)
- X
- X Related utilities: ship, uuencode, uudecode, uuxfer20, quux, others.
- X Just make sure they don't leave embedded or trailing spaces (that is,
- X they should use the "`" character in place of ASCII 32). Otherwise
- X mailers are prone to truncate or whatever.
- X
- X
- XGreg Roelofs (a.k.a. Cave Newt)
- XInfo-ZIP UnZip guy
- X
- XDavid Kirschbaum
- Xformer Info-ZIP Coordinator
- END_OF_FILE
- if test 13591 -ne `wc -c <'unzip-5.12/ZipPorts'`; then
- echo shar: \"'unzip-5.12/ZipPorts'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/ZipPorts'
- fi
- if test -f 'unzip-5.12/human68k/options.s.UU' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/human68k/options.s.UU'\"
- else
- echo shar: Extracting \"'unzip-5.12/human68k/options.s.UU'\" \(3262 characters\)
- sed "s/^X//" >'unzip-5.12/human68k/options.s.UU' <<'END_OF_FILE'
- Xbegin 644 unzip-5.12/human68k/options.s
- XM*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BH**@D)
- XM"0D)*@HJ"51W96YT>4]N92YX((%U@L:"HX*E@LF"H8+M@O&!=@DJ"BH)<&%T
- XM8V@@9F]R(&AU;6%N(%9E<B R+C R+#(N,#,)*@HJ"0D)"0DJ"BHJ*BHJ*BHJ
- XM*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ"BH**@EF:6QE(&YA
- XM;64Z"6]P=&EO;G,N<PHJ"6%U=&AO<CH)"8)D@IB"E" H5"Y+87=A;6]T;RD*
- XM*@EL87-T(&UO9&EF>3H).3(O,R\Q"BH)"0DY,B\S+S$W('1H86YK<R!9554H
- XM2$%254M!*0HJ"F)L<&5E:SH);6%C<F\*"6UO=F5Q+FP)(R0X-"QD, H)=')A
- XM< DC,34*"65N9&T**@IG971P9&(Z"6UA8W)O"@ED8RYW"21F9C4Q"@EE;F1M
- XM"BH*"2YX9&5F"5]4=V5N='E/;F5/<'1I;VYS"BH*"2YT97AT"BH*7U1W96YT
- XM>4]N94]P=&EO;G,Z"@EM;W9E;2YL"6$P+6$R+"TH<W I"@EB<W()<V5A<F-H
- XM7VUE;6]R>5]B;&EN9&QY"@ET<W0N; ED, H)8FYE"7)E='5R;@H)8G-R"7-E
- XM87)C:%]D979I8V5?8FQI;F1L>0IR971U<FXZ"@EM;W9E;2YL"2AS<"DK+&$P
- XM+6$R"@ER=',**@IS96%R8VA?9&5V:6-E7V)L:6YD;'DZ"@EL96$))# P,# V
- XM.# P+&$Q"G-E87)C:%].54Q?9&5V:6-E7VQO;W Z"@EC;7 N; DC)# P,#(P
- XM,# P+&$Q"@EB8V,)<V1?;F]T7V9O=6YD"@EB;'!E96L*"6-M<"YL"2,G3E5,
- XM("<L9# *"6)E<0EF;W5N9%].54Q?9&5V:6-E"BH);&5A"30H83$I+&$Q"0D)
- XM*B"(R(FZ@LR7=I?,@N:"Z H)"0D)"0DJ((*Q@K&"Q8-#@Y.#3H.*@XDX-G
- XM@K>"Z95+EW:"S0H)"0D)"0DJ((*@@NB"W(*Y@O$),3DY,BXP,RXQ-R!9554H
- XM2$%254M!*2X*"6-M<"YW"2,G3E4G+&0P"@EB;F4)<V5A<F-H7TY53%]D979I
- XM8V5?;&]O< H);&5A"2TR*&$Q*2QA,0H)8G)A"7-E87)C:%].54Q?9&5V:6-E
- XM7VQO;W **@IF;W5N9%].54Q?9&5V:6-E.@HJ"6QE80DM,30H83$I+&$Q"0D)
- XM*B"!J2""L8*Q@JJ"J(*I@K6"H@H);&5A"2TQ."AA,2DL83$)"0DJ($E/0U,@
- XM0E],4$5%2R""S);?@NB2;"!A,0H)"0D)"0DJ((+-(&0P((+,DFR"\([FD[Z"
- XMM8*]@T:(.,@U@@*R T"@D)"0D)"2H@@LB"S(+%CI^"S(-F@V^#0X-8@M:"
- XMS(-!@VB#C(-8@LT*"0D)"0D)*B M,3@H83$I((+&@LB"Z(+<@K<),3DY,BXP
- XM,RXQ-R!9554N"G-E87)C:%]D979I8V4Z"@EB;'!E96L*<V1?;&]O<#H*"6UO
- XM=F4N; ED,"QA, H);&5A"20P,#!%*&$P*2QA,@H)8G-R"6-H96-K7U17"@ET
- XM<W0N; ED, H)8FYE"7-D7V5N9 H);&5A+FP)*&$P*2QA,0H)8FQP965K"@EC
- XM;7 N; DC)&9F9F9F9F9F+&0P"@EB;F4)<V1?;&]O< IS9%]N;W1?9F]U;F0Z
- XM"@EM;W9E<2YL"2,P+&0P"G-D7V5N9#H*"7)T<PHJ"G-E87)C:%]M96UO<GE?
- XM8FQI;F1L>3H*"6=E='!D8@H);6]V92YL"60P+&$Q"@EL96$)+3$V*&$Q*2QA
- XM,0IS96%R8VA?=&]P7VQO;W Z"@EL96$)-"AA,2DL83$*"6)L<&5E:PH)='-T
- XM+FP)9# *"6)E<0EF;W5N9%]T;W *"6UO=F4N; ED,"QA,0H)8G)A"7-E87)C
- XM:%]T;W!?;&]O< HJ"F9O=6YD7W1O<#H*"6QE80DM."AA,2DL83$)"0DJ((+(
- XM@KJ"J8*Q@LR-<X*J@U*#@8.3@V>-<X+)@LB"P8+$@J*"W(*U@KT**@EL96$)
- XM."AA,2DL83$)"0DJ()&]E:J"L8+!@K^"JH-2@XDX-GC7."OH+&CG:"HH+<
- XM@K<*"0D)"0D)*B Q.3DR+C S+C$W(%E552A(05)52T$I+@IS96%R8VA?;65M
- XM;W)Y.@H);&5A"3$R*&$Q*2QA,0H)8FQP965K"G-M7VQO;W Z"@EM;W9E+FP)
- XM9# L83 *"6QE80DD,#$P12AA,"DL83(*"6)S<@EC:&5C:U]45PH)='-T+FP)
- XM9# *"6)N90ES;5]E;F0*"6QE80DD,# P0RAA,"DL83$*"6)L<&5E:PH)='-T
- XM+FP)9# *"6)N90ES;5]L;V]P"@EM;W9E<2YL"2,P+&0P"G-M7V5N9#H*"7)T
- XM<PHJ"F-H96-K7U17.@H);&5A"2AA,BDL83$*"6)L<&5E:PH)8VUP+FP)(R<_
- XM5'=E)RQD, H)8F5Q"6-H96-K7VYE=PH)8VUP+FP)(R<J5'=E)RQD, H)8FYE
- XM"6-H96-K7V5R<F]R"F-H96-K7V]L9#H*"6QE80DD,# P-"AA,BDL83$*"6)L
- XM<&5E:PH)8VUP+FP)(R=N='DJ)RQD, H)8FYE"6-H96-K7V5R<F]R"@EM;W9E
- XM<2YL"2,M,2QD, H)<G1S"BH*8VAE8VM?;F5W.@H);&5A"20P,# T*&$R*2QA
- XM,0H)8FQP965K"@EC;7 N; DC)VYT>3\G+&0P"@EB97$)8VAE8VM?;F5W7T4*
- XM"6-M<"YL"2,G;G1Y12<L9# *"6)N90EC:&5C:U]E<G)O<@IC:&5C:U]N97=?
- XM13H*"6QE80DD,# P."AA,BDL83$*"6)L<&5E:PH)<G1S"BH*8VAE8VM?97)R
- XM;W(Z"@EM;W9E<2YL"2,P+&0P"@ER=',**@H)9&,N8@DG5'=E;G1Y3VYE($]P
- XM=&EO;B!#:&5C:V5R(%9E<B Q+C P("<*"61C+F())T-O<'ER:6=H=" Q.3DQ
- XE+#DR(()D@IB"E" H@G,N@FIA=V%M;W1O*2<L, HJ"@DN96YD"F=H
- X
- Xend
- END_OF_FILE
- if test 3262 -ne `wc -c <'unzip-5.12/human68k/options.s.UU'`; then
- echo shar: \"'unzip-5.12/human68k/options.s.UU'\" unpacked with wrong size!
- else
- echo shar: Uudecoding \"'unzip-5.12/human68k/options.s'\" \(2332 characters\)
- cat unzip-5.12/human68k/options.s.UU | uudecode
- if test 2332 -ne `wc -c <'unzip-5.12/human68k/options.s'`; then
- echo shar: \"'unzip-5.12/human68k/options.s'\" uudecoded with wrong size!
- else
- rm unzip-5.12/human68k/options.s.UU
- fi
- fi
- # end of 'unzip-5.12/human68k/options.s.UU'
- fi
- if test -f 'unzip-5.12/os2/wat_met.dif' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/os2/wat_met.dif'\"
- else
- echo shar: Extracting \"'unzip-5.12/os2/wat_met.dif'\" \(19538 characters\)
- sed "s/^X//" >'unzip-5.12/os2/wat_met.dif' <<'END_OF_FILE'
- XDate: Wed, 3 Aug 1994 19:34:23 +0200
- XFrom: Kai Uwe Rommel <rommel@ars.muc.de>
- X
- XEnclosed I send the revised set of patches. That does now also include
- Xsome changes required for MetaWare High C++ for OS/2.
- X
- X
- Xdiff -cbr unzip/envargs.c unzip-2/envargs.c
- X*** unzip/envargs.c Thu Apr 21 10:02:16 1994
- X--- unzip-2/envargs.c Tue Aug 02 11:48:46 1994
- X***************
- X*** 180,186 ****
- X--- 180,188 ----
- X char ***argvp;
- X {
- X #ifndef MSC /* declared differently in MSC 7.0 headers, at least */
- X+ #ifndef __WATCOMC__
- X extern char **environ; /* environment */
- X+ #endif
- X #endif
- X char **envp; /* pointer into environment */
- X char **newargv; /* new argument list */
- Xdiff -cbr unzip/extract.c unzip-2/extract.c
- X*** unzip/extract.c Fri Jul 22 13:03:48 1994
- X--- unzip-2/extract.c Tue Aug 02 11:48:46 1994
- X***************
- X*** 863,869 ****
- X--- 863,873 ----
- X if (cflag) {
- X outfile = stdout;
- X #ifdef DOS_NT_OS2
- X+ #ifdef __HIGHC__
- X+ setmode(outfile, _BINARY);
- X+ #else
- X setmode(fileno(outfile), O_BINARY);
- X+ #endif
- X # define NEWLINE "\r\n"
- X #else
- X # define NEWLINE "\n"
- Xdiff -cbr unzip/funzip.c unzip-2/funzip.c
- X*** unzip/funzip.c Sun Jul 31 20:28:52 1994
- X--- unzip-2/funzip.c Tue Aug 02 11:48:48 1994
- X***************
- X*** 238,250 ****
- X--- 238,258 ----
- X else
- X {
- X #ifdef DOS_NT_OS2
- X+ #ifdef __HIGHC__
- X+ setmode(stdin, _BINARY);
- X+ #else
- X setmode(0, O_BINARY); /* some buggy C libraries require BOTH setmode() */
- X+ #endif
- X #endif /* call AND the fdopen() in binary mode :-( */
- X if ((in = fdopen(0, FOPR)) == (FILE *)NULL)
- X err(2, "cannot find stdin");
- X }
- X #ifdef DOS_NT_OS2
- X+ #ifdef __HIGHC__
- X+ setmode(stdout, _BINARY);
- X+ #else
- X setmode(1, O_BINARY);
- X+ #endif
- X #endif
- X if ((out = fdopen(1, FOPW)) == (FILE *)NULL)
- X err(2, "cannot write to stdout");
- Xdiff -cbr unzip/msdos/msdos.c unzip-2/msdos/msdos.c
- X*** unzip/msdos/msdos.c Wed Jul 27 22:20:06 1994
- X--- unzip-2/msdos/msdos.c Tue Aug 02 11:48:52 1994
- X***************
- X*** 37,45 ****
- X static int renamed_fullpath; /* ditto */
- X static unsigned nLabelDrive; /* ditto, plus volumelabel() */
- X
- X! #if (defined(__GO32__) || defined(__EMX__))
- X! # define MKDIR(path,mode) mkdir(path,mode)
- X # include <dirent.h> /* use readdir() */
- X # define direct dirent
- X # define Opendir opendir
- X # define Readdir readdir
- X--- 37,57 ----
- X static int renamed_fullpath; /* ditto */
- X static unsigned nLabelDrive; /* ditto, plus volumelabel() */
- X
- X! #if (defined(__WATCOMC__) && defined(__386__))
- X! # define WREGS(v,r) (v##.w.##r)
- X! # define int86x int386x
- X! #else
- X! # define WREGS(v,r) (v##.x.##r)
- X! #endif
- X!
- X! #if (defined(__GO32__) || defined(__EMX__) || defined(__WATCOMC__))
- X! # ifdef __WATCOMC__
- X! # include <direct.h>
- X! # define MKDIR(path,mode) mkdir(path)
- X! # else
- X # include <dirent.h> /* use readdir() */
- X+ # define MKDIR(path,mode) mkdir(path,mode)
- X+ # endif
- X # define direct dirent
- X # define Opendir opendir
- X # define Readdir readdir
- X***************
- X*** 774,791 ****
- X regs.h.bl = (uch)nDrive;
- X #ifdef __EMX__
- X _int86(0x21, ®s, ®s);
- X! if (regs.x.flags & 1)
- X #else
- X intdos(®s, ®s);
- X! if (regs.x.cflag) /* error: do default a/b check instead */
- X #endif
- X {
- X Trace((stderr,
- X "error in DOS function 0x44 (AX = 0x%04x): guessing instead...\n",
- X! regs.x.ax));
- X return (nDrive == 1 || nDrive == 2)? TRUE : FALSE;
- X } else
- X! return regs.x.ax? FALSE : TRUE;
- X }
- X
- X
- X--- 786,803 ----
- X regs.h.bl = (uch)nDrive;
- X #ifdef __EMX__
- X _int86(0x21, ®s, ®s);
- X! if (WREGS(regs,flags) & 1)
- X #else
- X intdos(®s, ®s);
- X! if (WREGS(regs,cflag)) /* error: do default a/b check instead */
- X #endif
- X {
- X Trace((stderr,
- X "error in DOS function 0x44 (AX = 0x%04x): guessing instead...\n",
- X! WREGS(regs,ax)));
- X return (nDrive == 1 || nDrive == 2)? TRUE : FALSE;
- X } else
- X! return WREGS(regs,ax)? FALSE : TRUE;
- X }
- X
- X
- X***************
- X*** 854,874 ****
- X
- X /* set the disk transfer address for subsequent FCB calls */
- X sregs.ds = FP_SEG(pdta);
- X! regs.x.dx = FP_OFF(pdta);
- X! Trace((stderr, "segment:offset of pdta = %x:%x\n", sregs.ds, regs.x.dx));
- X Trace((stderr, "&dta = %lx, pdta = %lx\n", (ulg)&dta, (ulg)pdta));
- X regs.h.ah = 0x1a;
- X intdosx(®s, ®s, &sregs);
- X
- X /* fill in the FCB */
- X sregs.ds = FP_SEG(pfcb);
- X! regs.x.dx = FP_OFF(pfcb);
- X pfcb->flag = 0xff; /* extended FCB */
- X pfcb->vattr = 0x08; /* attribute: disk volume label */
- X pfcb->drive = (uch)nLabelDrive;
- X
- X #ifdef DEBUG
- X! Trace((stderr, "segment:offset of pfcb = %x:%x\n", sregs.ds, regs.x.dx));
- X Trace((stderr, "&fcb = %lx, pfcb = %lx\n", (ulg)&fcb, (ulg)pfcb));
- X Trace((stderr, "(2nd check: labelling drive %c:)\n", pfcb->drive-1+'A'));
- X if (pfcb->flag != fcb.flag)
- X--- 866,886 ----
- X
- X /* set the disk transfer address for subsequent FCB calls */
- X sregs.ds = FP_SEG(pdta);
- X! WREGS(regs,dx) = FP_OFF(pdta);
- X! Trace((stderr, "segment:offset of pdta = %x:%x\n", sregs.ds, WREGS(regs,dx)));
- X Trace((stderr, "&dta = %lx, pdta = %lx\n", (ulg)&dta, (ulg)pdta));
- X regs.h.ah = 0x1a;
- X intdosx(®s, ®s, &sregs);
- X
- X /* fill in the FCB */
- X sregs.ds = FP_SEG(pfcb);
- X! WREGS(regs,dx) = FP_OFF(pfcb);
- X pfcb->flag = 0xff; /* extended FCB */
- X pfcb->vattr = 0x08; /* attribute: disk volume label */
- X pfcb->drive = (uch)nLabelDrive;
- X
- X #ifdef DEBUG
- X! Trace((stderr, "segment:offset of pfcb = %x:%x\n", sregs.ds, WREGS(regs,dx)));
- X Trace((stderr, "&fcb = %lx, pfcb = %lx\n", (ulg)&fcb, (ulg)pfcb));
- X Trace((stderr, "(2nd check: labelling drive %c:)\n", pfcb->drive-1+'A'));
- X if (pfcb->flag != fcb.flag)
- X***************
- X*** 894,900 ****
- X strncpy((char *)fcb.vn, "???????????", 11); /* i.e., "*.*" */
- X Trace((stderr, "fcb.vn = %lx\n", (ulg)fcb.vn));
- X Trace((stderr, "regs.h.ah = %x, regs.x.dx = %04x, sregs.ds = %04x\n",
- X! regs.h.ah, regs.x.dx, sregs.ds));
- X Trace((stderr, "flag = %x, drive = %d, vattr = %x, vn = %s = %s.\n",
- X fcb.flag, fcb.drive, fcb.vattr, fcb.vn, pfcb->vn));
- X intdosx(®s, ®s, &sregs);
- X--- 906,912 ----
- X strncpy((char *)fcb.vn, "???????????", 11); /* i.e., "*.*" */
- X Trace((stderr, "fcb.vn = %lx\n", (ulg)fcb.vn));
- X Trace((stderr, "regs.h.ah = %x, regs.x.dx = %04x, sregs.ds = %04x\n",
- X! regs.h.ah, WREGS(regs,dx), sregs.ds));
- X Trace((stderr, "flag = %x, drive = %d, vattr = %x, vn = %s = %s.\n",
- X fcb.flag, fcb.drive, fcb.vattr, fcb.vn, pfcb->vn));
- X intdosx(®s, ®s, &sregs);
- X***************
- X*** 1058,1065 ****
- X union REGS regs;
- X
- X sregs.ds = FP_SEG(CountryInfo);
- X! regs.x.dx = FP_OFF(CountryInfo);
- X! regs.x.ax = 0x3800;
- X int86x(0x21, ®s, ®s, &sregs);
- X
- X #else /* __GO32__ || __EMX__ */
- X--- 1070,1077 ----
- X union REGS regs;
- X
- X sregs.ds = FP_SEG(CountryInfo);
- X! WREGS(regs,dx) = FP_OFF(CountryInfo);
- X! WREGS(regs,ax) = 0x3800;
- X int86x(0x21, ®s, ®s, &sregs);
- X
- X #else /* __GO32__ || __EMX__ */
- Xdiff -cbr unzip/os2/makefile.os2 unzip-2/os2/makefile.os2
- X*** unzip/os2/makefile.os2 Sat Jul 23 13:42:04 1994
- X--- unzip-2/os2/makefile.os2 Tue Aug 02 11:53:42 1994
- X***************
- X*** 32,43 ****
- X # For Watcom C/386, edit the os2$(OBJ) target so that os2/os2.c reads
- X # os2\os2.c instead. Watcom can't handle forward slashes; gcc can't
- X # handle backslashes. We'll see about making this a macro next time...
- X
- X default:
- X @echo "Enter `$(MAKE) -f makefile.os2 target' with makefile.os2 copied"
- X @echo "to the main UnZip directory and where target is one of:"
- X @echo " msc mscdos ibm ibmdyn ibmdebug ibmprof"
- X! @echo " watcom borland gcc gccdyn gccdebug gccdos"
- X
- X # MS C 6.00 for OS/2, 16-bit (should figure out way to split unzip/funzip
- X # compiles so former is always large model and latter always small model...)
- X--- 32,45 ----
- X # For Watcom C/386, edit the os2$(OBJ) target so that os2/os2.c reads
- X # os2\os2.c instead. Watcom can't handle forward slashes; gcc can't
- X # handle backslashes. We'll see about making this a macro next time...
- X+ # Same for msdos/msdos.c ...
- X
- X default:
- X @echo "Enter `$(MAKE) -f makefile.os2 target' with makefile.os2 copied"
- X @echo "to the main UnZip directory and where target is one of:"
- X @echo " msc mscdos ibm ibmdyn ibmdebug ibmprof"
- X! @echo " metaware borland gcc gccdyn gccdebug gccdos"
- X! @echo " watcom watcom16 watcomdos watcom16dos"
- X
- X # MS C 6.00 for OS/2, 16-bit (should figure out way to split unzip/funzip
- X # compiles so former is always large model and latter always small model...)
- X***************
- X*** 52,57 ****
- X--- 54,71 ----
- X OBJ=".obj" \
- X DEF="os2\unzip16.def"
- X
- X+ # MS C 6.00 for OS/2, debug version
- X+ mscdebug:
- X+ $(MAKE) -f makefile.os2 all \
- X+ CC="cl -nologo -AL -Zi -Od -I. $(FP)" \
- X+ CFLAGS="-G2 -Zp1 -W3 -DOS2 -DMSC" \
- X+ NFLAGS="" \
- X+ LDFLAGS="-Lp -Fe" \
- X+ LDFLAGS2="-link /noe" \
- X+ OUT="-Fo" \
- X+ OBJ=".obj" \
- X+ DEF="os2\unzip16.def"
- X+
- X # cross-compilation for MS-DOS with MS C 6.00 (same comment as above...formerly;
- X # now unzip is small model again, with [almost] all strings in far memory)
- X mscdos:
- X***************
- X*** 59,65 ****
- X CC="cl -nologo -AS -Oaict -Gs -I. $(FP)" \
- X CFLAGS="-Zp1 -W3 $(LOCAL_UNZIP)" \
- X NFLAGS="" \
- X! LDFLAGS="-F 0c00 -Lr -Fe" \
- X LDFLAGS2="-link /noe /exe" \
- X OUT="-Fo" \
- X OBJ=".obj" \
- X--- 73,79 ----
- X CC="cl -nologo -AS -Oaict -Gs -I. $(FP)" \
- X CFLAGS="-Zp1 -W3 $(LOCAL_UNZIP)" \
- X NFLAGS="" \
- X! LDFLAGS="-F 0C00 -Lr -Fe" \
- X LDFLAGS2="-link /noe /exe" \
- X OUT="-Fo" \
- X OBJ=".obj" \
- X***************
- X*** 114,131 ****
- X OBJ=".obj" \
- X DEF="os2\unzip.def"
- X
- X! # Watcom C/386 9.0
- X watcom:
- X $(MAKE) -f makefile.os2 all \
- X CC="wcl386 -zq -Ox -s -I." \
- X CFLAGS="-Zp1 -DOS2 $(LOCAL_UNZIP)" \
- X NFLAGS="" \
- X! LDFLAGS="-k0x40000 -x -Fe=" \
- X LDFLAGS2="" \
- X OUT="-Fo" \
- X OBJ=".obj" \
- X DEF=""
- X
- X # Borland C++
- X borland:
- X $(MAKE) -f makefile.os2 all \
- X--- 128,194 ----
- X OBJ=".obj" \
- X DEF="os2\unzip.def"
- X
- X! # Watcom C/386 9.0 or higher
- X watcom:
- X $(MAKE) -f makefile.os2 all \
- X CC="wcl386 -zq -Ox -s -I." \
- X CFLAGS="-Zp1 -DOS2 $(LOCAL_UNZIP)" \
- X NFLAGS="" \
- X! LDFLAGS="-k0x40000 -x -l=os2v2 -Fe=" \
- X LDFLAGS2="" \
- X OUT="-Fo" \
- X OBJ=".obj" \
- X DEF=""
- X
- X+ # Watcom C/286 9.0 or higher
- X+ watcom16:
- X+ $(MAKE) -f makefile.os2 all \
- X+ CC="wcl -zq -ml -Ox -s -I." \
- X+ CFLAGS="-Zp1 -DOS2" \
- X+ NFLAGS="" \
- X+ LDFLAGS="-k0x2000 -x -l=os2 -Fe=" \
- X+ LDFLAGS2="" \
- X+ OUT="-Fo" \
- X+ OBJ=".obj"
- X+
- X+ # Watcom C/386 9.0 or higher, crosscompilation for DOS
- X+ watcomdos:
- X+ $(MAKE) -f makefile.os2 all \
- X+ CC="wcl386 -zq -Ox -s -I." \
- X+ CFLAGS="-Zp1 -DMSDOS" \
- X+ NFLAGS="" \
- X+ LDFLAGS="-k0x40000 -x -l=dos4g -Fe=" \
- X+ LDFLAGS2="" \
- X+ OUT="-Fo" \
- X+ OBJ=".obj" \
- X+ OBJU2="msdos.obj" \
- X+ OBJX2="msdos_.obj"
- X+
- X+ # Watcom C/286 9.0 or higher, crosscompilation for DOS
- X+ watcom16dos:
- X+ $(MAKE) -f makefile.os2 all \
- X+ CC="wcl -zq -mm -Ox -s -I." \
- X+ CFLAGS="-Zp1 -DMSDOS" \
- X+ NFLAGS="" \
- X+ LDFLAGS="-k0xC00 -x -l=dos -Fe=" \
- X+ LDFLAGS2="" \
- X+ OUT="-Fo" \
- X+ OBJ=".obj" \
- X+ OBJU2="msdos.obj" \
- X+ OBJX2="msdos_.obj"
- X+
- X+ # MetaWare High C/C++ 3.2
- X+ metaware:
- X+ $(MAKE) -f makefile.os2 all \
- X+ CC="hc -O2 -I." \
- X+ CFLAGS="-D__32BIT__ -DOS2" \
- X+ NFLAGS="" \
- X+ LDFLAGS="-o " \
- X+ LDFLAGS2="" \
- X+ OUT="-o ./" \
- X+ OBJ=".obj" \
- X+ DEF="-Hdef=os2\unzip.def"
- X+
- X # Borland C++
- X borland:
- X $(MAKE) -f makefile.os2 all \
- X***************
- X*** 192,198 ****
- X extract$(OBJ) file_io$(OBJ) inflate$(OBJ) match$(OBJ) \
- X unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ)
- X OBJU2 = os2$(OBJ)
- X! OBJX = unzip_$(OBJ) crypt$(OBJ) extract_$(OBJ) file_io$(OBJ) \
- X inflate$(OBJ) match$(OBJ)
- X OBJX2 = os2_$(OBJ)
- X OBJF = funzip$(OBJ) crypt_$(OBJ) inflate_$(OBJ)
- X--- 255,261 ----
- X extract$(OBJ) file_io$(OBJ) inflate$(OBJ) match$(OBJ) \
- X unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ)
- X OBJU2 = os2$(OBJ)
- X! OBJX = unzipsfx$(OBJ) crypt$(OBJ) extract_$(OBJ) file_io$(OBJ) \
- X inflate$(OBJ) match$(OBJ)
- X OBJX2 = os2_$(OBJ)
- X OBJF = funzip$(OBJ) crypt_$(OBJ) inflate_$(OBJ)
- X***************
- X*** 252,256 ****
- X inflate_$(OBJ): inflate.c inflate.h unzip.h crypt.h # funzip only
- X $(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ inflate.c
- X
- X! unzip_$(OBJ): unzip.c unzip.h crypt.h version.h # unzipsfx only
- X $(CC) -c $(CFLAGS) -DSFX $(OUT)$@ unzip.c
- X--- 315,319 ----
- X inflate_$(OBJ): inflate.c inflate.h unzip.h crypt.h # funzip only
- X $(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ inflate.c
- X
- X! unzipsfx$(OBJ): unzip.c unzip.h crypt.h version.h # unzipsfx only
- X $(CC) -c $(CFLAGS) -DSFX $(OUT)$@ unzip.c
- Xdiff -cbr unzip/os2/os2.c unzip-2/os2/os2.c
- X*** unzip/os2/os2.c Wed Jul 27 22:23:02 1994
- X--- unzip-2/os2/os2.c Tue Aug 02 11:48:54 1994
- X***************
- X*** 73,78 ****
- X--- 73,79 ----
- X #define INCL_DOSDEVICES
- X #define INCL_DOSDEVIOCTL
- X #define INCL_DOSERRORS
- X+ #define INCL_DOSMISC
- X #include <os2.h>
- X
- X #ifdef __32BIT__
- X***************
- X*** 229,238 ****
- X #endif
- X
- X
- X- #ifdef __WATCOMC__
- X- unsigned char __near _osmode = OS2_MODE;
- X- #endif
- X-
- X #ifndef SFX
- X static char *getdirent(char *);
- X static void free_dircontents(struct _dircontents *);
- X--- 230,235 ----
- X***************
- X*** 387,394 ****
- X if ( (pFEA2list = (PFEA2LIST) malloc((size_t) pEAblock -> lSize)) == NULL )
- X return;
- X
- X! if ( memextract((char *) pFEA2list, pEAblock -> lSize,
- X! (char *) (pEAblock + 1),
- X pEAblock -> nSize - sizeof(pEAblock -> lSize)) )
- X {
- X free(pFEA2list);
- X--- 384,391 ----
- X if ( (pFEA2list = (PFEA2LIST) malloc((size_t) pEAblock -> lSize)) == NULL )
- X return;
- X
- X! if ( memextract((uch *) pFEA2list, pEAblock -> lSize,
- X! (uch *) (pEAblock + 1),
- X pEAblock -> nSize - sizeof(pEAblock -> lSize)) )
- X {
- X free(pFEA2list);
- X***************
- X*** 450,474 ****
- X char *GetLoadPath(void)
- X {
- X #ifdef __32BIT__ /* generic for 32-bit API */
- X-
- X PTIB pptib;
- X PPIB pppib;
- X char *szPath;
- X
- X DosGetInfoBlocks(&pptib, &pppib);
- X szPath = pppib -> pib_pchenv;
- X
- X while (*szPath) /* find end of process environment */
- X szPath = strchr(szPath, 0) + 1;
- X
- X return szPath + 1; /* .exe file name follows environment */
- X
- X- #else /* 16-bit, specific for MS C 6.00, note: requires large data model */
- X-
- X- extern char _far *_pgmptr;
- X- return _pgmptr;
- X-
- X- #endif
- X } /* end function GetLoadPath() */
- X
- X
- X--- 447,472 ----
- X char *GetLoadPath(void)
- X {
- X #ifdef __32BIT__ /* generic for 32-bit API */
- X PTIB pptib;
- X PPIB pppib;
- X char *szPath;
- X
- X DosGetInfoBlocks(&pptib, &pppib);
- X szPath = pppib -> pib_pchenv;
- X+ #else /* 16-bit, note: requires large data model */
- X+ SEL selEnv;
- X+ USHORT offCmd;
- X+ char *szPath;
- X+
- X+ DosGetEnv(&selEnv, &offCmd);
- X+ szPath = MAKEP(selEnv, 0);
- X+ #endif
- X
- X while (*szPath) /* find end of process environment */
- X szPath = strchr(szPath, 0) + 1;
- X
- X return szPath + 1; /* .exe file name follows environment */
- X
- X } /* end function GetLoadPath() */
- X
- X
- X***************
- X*** 680,686 ****
- X {
- X static USHORT nLastDrive=(USHORT)(-1), nResult;
- X ULONG lMap;
- X! BYTE bData[64], bName[3];
- X #ifdef __32BIT__
- X ULONG nDrive, cbData;
- X PFSQBUFFER2 pData = (PFSQBUFFER2) bData;
- X--- 678,685 ----
- X {
- X static USHORT nLastDrive=(USHORT)(-1), nResult;
- X ULONG lMap;
- X! BYTE bData[64];
- X! char bName[3];
- X #ifdef __32BIT__
- X ULONG nDrive, cbData;
- X PFSQBUFFER2 pData = (PFSQBUFFER2) bData;
- X***************
- X*** 689,698 ****
- X PFSQBUFFER pData = (PFSQBUFFER) bData;
- X #endif
- X
- X- if ( _osmode == DOS_MODE )
- X- return TRUE;
- X- else
- X- {
- X /* We separate FAT and HPFS+other file systems here.
- X at the moment I consider other systems to be similar to HPFS,
- X i.e. support long file names and case sensitive */
- X--- 688,693 ----
- X***************
- X*** 713,725 ****
- X cbData = sizeof(bData);
- X
- X if ( !DosQueryFSAttach(bName, 0, FSAIL_QUERYNAME, (PVOID) pData, &cbData) )
- X! nResult = !strcmp(pData -> szFSDName + pData -> cbName, "FAT");
- X else
- X nResult = FALSE;
- X
- X /* End of this ugly code */
- X return nResult;
- X- }
- X } /* end function IsFileSystemFAT() */
- X
- X
- X--- 708,719 ----
- X cbData = sizeof(bData);
- X
- X if ( !DosQueryFSAttach(bName, 0, FSAIL_QUERYNAME, (PVOID) pData, &cbData) )
- X! nResult = !strcmp((char *) (pData -> szFSDName) + pData -> cbName, "FAT");
- X else
- X nResult = FALSE;
- X
- X /* End of this ugly code */
- X return nResult;
- X } /* end function IsFileSystemFAT() */
- X
- X
- X***************
- X*** 1398,1404 ****
- X ULONG action;
- X #else
- X USHORT rc;
- X! UINT action;
- X #endif
- X
- X
- X--- 1392,1398 ----
- X ULONG action;
- X #else
- X USHORT rc;
- X! USHORT action;
- X #endif
- X
- X
- X***************
- X*** 1579,1597 ****
- X eaop.fpGEAList = NULL;
- X eaop.oError = 0;
- X
- X! strcpy(fealst.szName, ".LONGNAME");
- X! strcpy(fealst.szValue, longname);
- X
- X! fealst.cbList = sizeof(fealst) - CCHMAXPATH + strlen(fealst.szValue);
- X! fealst.cbName = (BYTE) strlen(fealst.szName);
- X! fealst.cbValue = sizeof(USHORT) * 2 + strlen(fealst.szValue);
- X
- X #ifdef __32BIT__
- X fealst.oNext = 0;
- X #endif
- X fealst.fEA = 0;
- X fealst.eaType = 0xFFFD;
- X! fealst.eaSize = strlen(fealst.szValue);
- X
- X return DosSetPathInfo(name, FIL_QUERYEASIZE,
- X (PBYTE) &eaop, sizeof(eaop), 0);
- X--- 1573,1591 ----
- X eaop.fpGEAList = NULL;
- X eaop.oError = 0;
- X
- X! strcpy((char *) fealst.szName, ".LONGNAME");
- X! strcpy((char *) fealst.szValue, longname);
- X
- X! fealst.cbList = sizeof(fealst) - CCHMAXPATH + strlen((char *) fealst.szValue);
- X! fealst.cbName = (BYTE) strlen((char *) fealst.szName);
- X! fealst.cbValue = sizeof(USHORT) * 2 + strlen((char *) fealst.szValue);
- X
- X #ifdef __32BIT__
- X fealst.oNext = 0;
- X #endif
- X fealst.fEA = 0;
- X fealst.eaType = 0xFFFD;
- X! fealst.eaSize = strlen((char *) fealst.szValue);
- X
- X return DosSetPathInfo(name, FIL_QUERYEASIZE,
- X (PBYTE) &eaop, sizeof(eaop), 0);
- X***************
- X*** 1880,1886 ****
- X
- X if (!bInitialized)
- X InitNLS();
- X! for ( szPtr = szArg; *szPtr; szPtr++ )
- X *szPtr = cLowerCase[*szPtr];
- X return szArg;
- X }
- X--- 1874,1880 ----
- X
- X if (!bInitialized)
- X InitNLS();
- X! for ( szPtr = (unsigned char *) szArg; *szPtr; szPtr++ )
- X *szPtr = cLowerCase[*szPtr];
- X return szArg;
- X }
- Xdiff -cbr unzip/unzip.h unzip-2/unzip.h
- X*** unzip/unzip.h Sun Jul 31 20:09:44 1994
- X--- unzip-2/unzip.h Tue Aug 02 11:48:56 1994
- X***************
- X*** 437,447 ****
- X--- 437,449 ----
- X #endif
- X
- X #ifdef __WATCOMC__
- X+ # ifdef __386__
- X # define __32BIT__
- X # undef far
- X # define far
- X # undef near
- X # define near
- X+ # endif
- X # define PIPE_ERROR (errno == -1)
- X #endif
- X
- X***************
- X*** 770,776 ****
- X #endif
- X
- X /* GRR: NT defines MSDOS?? */
- X! #if (!defined(MSDOS) && !defined(__IBMC__)) || defined(NT)
- X # define near
- X # define far
- X #endif
- X--- 772,778 ----
- X #endif
- X
- X /* GRR: NT defines MSDOS?? */
- X! #if (!defined(MSDOS) && !defined(__IBMC__) && defined(__32BIT__)) || defined(NT)
- X # define near
- X # define far
- X #endif
- END_OF_FILE
- if test 19538 -ne `wc -c <'unzip-5.12/os2/wat_met.dif'`; then
- echo shar: \"'unzip-5.12/os2/wat_met.dif'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/os2/wat_met.dif'
- fi
- if test -f 'unzip-5.12/unix/unzipsfx.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/unix/unzipsfx.1'\"
- else
- echo shar: Extracting \"'unzip-5.12/unix/unzipsfx.1'\" \(12523 characters\)
- sed "s/^X//" >'unzip-5.12/unix/unzipsfx.1' <<'END_OF_FILE'
- X.\" Info-ZIP grants permission to any individual or institution to use, copy,
- X.\" or redistribute this software, so long as: (1) all of the original files
- X.\" are included; (2) it is not sold for profit; and (3) this notice is re-
- X.\" tained.
- X.\"
- X.\" unzipsfx.1 by Greg Roelofs
- X.\"
- X.\" =========================================================================
- X.\" define .Y macro (for user-command examples; normal Courier font):
- X.de Y
- X.ft CW
- X.in +4n
- X.nf
- X\&\\$1
- X.ft
- X.in
- X.fi
- X..
- X.\" =========================================================================
- X.TH UNZIPSFX 1L "28 Aug 94 (v5.12)"
- X.SH NAME
- Xunzipsfx \- self-extracting stub for prepending to ZIP archives
- X.PD
- X.\" =========================================================================
- X.SH SYNOPSIS
- X\fB<name of unzipsfx+archive combo>\fP [\fB\-cfptuz\fP[\fBajnoqsCLV$\fP]]
- X[\fIfile(s)\fP\ .\|.\|. [\fB\-x\fP\ \fIxfile(s)\fP\ .\|.\|.]]
- X.PD
- X.\" =========================================================================
- X.SH DESCRIPTION
- X\fIunzipsfx\fP is a modified version of \fIunzip\fP(1L) designed to be prepended
- Xto existing ZIP archives in order to form self-extracting archives. Instead
- Xof taking its first non-flag argument to be the zipfile(s) to be extracted,
- X\fIunzipsfx\fP seeks itself under the name by which it was invoked
- Xand tests or extracts the contents of the appended archive. Because the
- Xexecutable stub adds bulk to the archive (the whole purpose of which is to
- Xbe as small as possible), a number of the regular version's less-vital
- Xcapabilities have been removed. Among these are the usage (or help) screen,
- Xthe listing and diagnostic functions (\fB\-l\fP and \fB\-v\fP), the ability
- Xto decompress older compression formats (the ``reduce,'' ``shrink'' and
- X``implode'' methods), and the ability to extract to a directory other than
- Xthe current one. Decryption is supported as a compile-time option but
- Xshould be avoided unless the attached archive contains encrypted files.
- X.LP
- X\fBNote that
- Xself-extracting archives made with\fP \fIunzipsfx\fP \fBare no more (or less)
- Xportable across different operating systems than is
- Xthe\fP \fIunzip\fP \fBexecutable itself.\fP In general a self-extracting
- Xarchive made on
- Xa particular Unix system, for example, will only self-extract under the same
- Xflavor of Unix. Regular \fIunzip\fP may still be used to extract the
- Xembedded archive as with any normal zipfile, although it will generate
- Xa harmless warning about extra bytes at the beginning of the zipfile.
- X.PD
- X.\" =========================================================================
- X.SH ARGUMENTS
- X.IP [\fIfile(s)\fP]
- XAn optional list of archive members to be processed.
- XRegular expressions (wildcards) similar to those in Unix \fIegrep\fP(1)
- Xmay be used to match multiple members. These wildcards may contain:
- X.RS
- X.IP *
- Xmatches a sequence of 0 or more characters
- X.IP ?
- Xmatches exactly 1 character
- X.IP [.\|.\|.]
- Xmatches any single character found inside the brackets; ranges are specified
- Xby a beginning character, a hyphen, and an ending character. If an exclamation
- Xpoint or a caret (`!' or `^') follows the left bracket, then the range of
- Xcharacters within the brackets is complemented (that is, anything \fIexcept\fP
- Xthe characters inside the brackets is considered a match).
- X.RE
- X.IP
- X(Be sure to quote any character which might otherwise be interpreted or
- Xmodified by the operating system, particularly under Unix and VMS.)
- X.IP [\fB\-x\fP\ \fIxfile(s)\fP]
- XAn optional list of archive members to be excluded from processing.
- XSince wildcard characters match directory separators (`/'), this option
- Xmay be used to exclude any files which are in subdirectories. For
- Xexample, ``\fCfoosfx *.[ch] -x */*\fR'' would extract all C source files
- Xin the main directory, but none in any subdirectories. Without the \fB\-x\fP
- Xoption, all C source files in all directories within the zipfile would be
- Xextracted.
- XUnlike in \fIunzip\fP(1L), the \fB\-x\fP option may only be used if one or
- Xmore \fIfiles\fP are given. This is because there is no zipfile separating
- Xthe normal options from the \fB\-x\fP option, so \fIunzipsfx\fP sees it as
- Xanother normal option. For historical reasons, the ``normal'' \fB\-x\fP is
- Xsilently ignored. See the \fBEXAMPLES\fP section below.
- X.LP
- XIf \fIunzipsfx\fP is compiled with SFX_EXDIR defined, the following option
- Xis also enabled:
- X.IP [\fB\-d\fP\ \fIexdir\fP]
- XAn optional directory to which to extract files. By default, all files
- Xand subdirectories are recreated in the current directory; the \fB\-d\fP
- Xoption allows extraction in an arbitrary directory (always assuming one
- Xhas permission to write to the directory). The option and directory may
- Xbe concatenated without any white space between them, but note that this
- Xmay cause normal shell behavior to be suppressed. In particular,
- X``\fC\-d\ ~\fR'' (tilde) is expanded by Unix C shells into the name
- Xof the user's home directory, but ``\fC\-d~\fR'' is treated as a
- Xliteral subdirectory ``\fB~\fP'' of the current directory. As with
- X\fB\-x\fP, the \fB\-d\fP option may only be used if one or more \fIfiles\fP
- Xare given.
- X.PD
- X.\" =========================================================================
- X.SH OPTIONS
- X\fIunzipsfx\fP supports the following \fIunzip\fP(1L) options: \fB\-c\fP
- Xand \fB\-p\fP (extract to standard output/screen), \fB\-f\fP and \fB\-u\fP
- X(freshen and update existing files upon extraction), \fB\-t\fP (test
- Xarchive) and \fB\-z\fP (print archive comment). All normal listing options
- X(\fB\-l\fP, \fB\-v\fP and \fB\-Z\fP) have been removed, but the testing
- Xoption (\fB\-t\fP) may be used as a ``poor man's'' listing. Alternatively,
- Xthose creating self-extracting archives may wish to include a short listing
- Xin the zipfile comment.
- X.LP
- XSee \fIunzip\fP(1L) for a more complete description of these options.
- X.PD
- X.\" =========================================================================
- X.SH MODIFIERS
- X\fIunzipsfx\fP currently supports all \fIunzip\fP(1L) modifiers: \fB\-a\fP
- X(convert text files), \fB\-n\fP (never overwrite), \fB\-o\fP (overwrite
- Xwithout prompting), \fB\-q\fP (operate quietly), \fB\-C\fP (match names
- Xcase-insenstively), \fB\-L\fP (convert uppercase-OS names to lowercase),
- X\fB\-j\fP (junk paths) and \fB\-V\fP (retain version numbers); plus the
- Xfollowing operating-system specific options: \fB\-X\fP (restore VMS
- Xowner/protection info), \fB\-s\fP (convert spaces in filenames to underscores
- X[DOS, OS/2, NT]) and \fB\-$\fP (restore volume label [DOS, OS/2, NT, Amiga]).
- X.LP
- X(Support for regular ASCII text-conversion may be removed in future versions,
- Xsince it is simple enough for the archive's creator to ensure that text
- Xfiles have the appropriate format for the local OS. EBCDIC conversion will
- Xof course continue to be supported since the zipfile format implies ASCII
- Xstorage of text files.)
- X.LP
- XSee \fIunzip\fP(1L) for a more complete description of these modifiers.
- X.PD
- X.\" =========================================================================
- X.SH ENVIRONMENT OPTIONS
- X\fIunzipsfx\fP uses the same environment variables as \fIunzip\fP(1L) does,
- Xalthough this is likely to be an issue only for the person creating and
- Xtesting the self-extracting archive. See \fIunzip\fP(1L) for details.
- X.PD
- X.\" =========================================================================
- X.SH DECRYPTION
- XDecryption is supported exactly as in \fIunzip\fP(1L); that is, interactively
- Xwith a non-echoing prompt for the password(s). See \fIunzip\fP(1L) for
- Xdetails. Once again, note that if the archive has no encrypted files there
- Xis no reason to use a version of \fIunzipsfx\fP with decryption support;
- Xthat only adds to the size of the archive.
- X.PD
- X.\" =========================================================================
- X.SH EXAMPLES
- XTo create a self-extracting archive \fIletters\fP from a regular zipfile
- X\fIletters.zip\fP and change the new archive's permissions to be
- Xworld-executable under Unix:
- X.LP
- X.PD 0
- X.Y "cat unzipsfx letters.zip > letters"
- X.Y "chmod 755 letters"
- X.PD
- X.LP
- XTo create the same archive under MS-DOS, OS/2 or NT (note the use of the
- X\fB/b\fP [binary] option to the \fIcopy\fP command):
- X.LP
- X.Y "copy /b unzipsfx.exe+letters.zip letters.exe"
- X.LP
- XUnder VMS:
- X.LP
- X.Y "copy unzipsfx.exe,letters.zip letters.exe"
- X.Y "letters == ""$currentdisk:[currentdir]letters.exe"""
- X.LP
- X(The VMS \fIappend\fP command may also be used. The second command installs
- Xthe new program as a ``foreign command'' capable of taking arguments.)
- XTo test (or list) the newly created self-extracting archive:
- X.LP
- X.Y "letters \-t"
- X.LP
- XTo test \fIletters\fP quietly, printing only a summary message indicating
- Xwhether the archive is OK or not:
- X.LP
- X.Y "letters \-tq"
- X.LP
- XTo extract the complete contents into the current directory, recreating all
- Xfiles and subdirectories as necessary:
- X.LP
- X.Y "letters"
- X.LP
- XTo extract all \fC*.txt\fP files (in Unix quote the `*'):
- X.LP
- X.Y "letters *.txt"
- X.LP
- XTo extract everything \fIexcept\fP the \fC*.txt\fP files:
- X.LP
- X.Y "letters * -x *.txt"
- X.LP
- X(Note that with regular \fIunzip\fP(1L) it would not be necessary to use
- Xthe first `*'; ``\fCunzip letters -x *.txt\fP'' would work equally well.
- XWith \fIunzipsfx\fP the \fB\-x\fP option would be silently ignored and
- Xthe effect would be the same as in the previous example, i.e., the opposite
- Xof what was intended.)
- XTo extract only the README file to standard output (the screen):
- X.LP
- X.Y "letters -c README"
- X.LP
- XTo print only the zipfile comment:
- X.LP
- X.Y "letters \-z"
- X.PD
- X.\" =========================================================================
- X.SH LIMITATIONS
- XThe principle and fundamental limitation of \fIunzipsfx\fP is that it is
- Xnot portable across architectures or operating systems, and therefore
- Xneither are the resulting archives. For some architectures there is
- Xlimited portability, however (e.g., between some flavors of Intel-based Unix).
- X.LP
- X\fIunzipsfx\fP has no knowledge of the user's PATH, so in general an archive
- Xmust either be in the current directory when it is invoked, or else a full
- Xor relative path must be given. If a user attempts to extract the archive
- Xfrom a directory in the PATH other than the current one, \fIunzipsfx\fP will
- Xprint a warning to the effect, ``can't find myself.'' This is always true
- Xunder Unix and may be true in some cases under MS-DOS, depending on the
- Xcompiler used (Microsoft C fully qualifies the program name, but other
- Xcompilers may not). Under OS/2 and NT there are operating-system calls
- Xavailable which provide the full path name, so the archive may be invoked
- Xfrom anywhere in the user's path. The situation is not known for Atari TOS,
- XMacOS, etc.
- X.LP
- XAs noted above, a number of the normal \fIunzip\fP(1L) functions have
- Xbeen removed in order to make \fIunzipsfx\fP smaller: usage and diagnostic
- Xinfo, listing functions and extraction to other directories. Also, only
- Xstored and deflated files are supported. The latter limitation is mainly
- Xrelevant to those who create SFX archives, however.
- X.LP
- XVMS users must know how to set up self-extracting archives as foreign
- Xcommands in order to use any of \fIunzipsfx\fP's options. This is not
- Xnecessary for simple extraction, but the command to do so then becomes,
- Xe.g., ``\fCrun letters\fR'' (to continue the examples given above).
- X.LP
- X\fIunzipsfx\fP is not supported on the Amiga because of the way the loader
- Xworks; the entire archive contents would be loaded into memory by default.
- XIt may be possible to work around this by defining the attached archive to
- Xbe a ``debug hunk,'' but compatibility problems between the ROM levels of
- Xolder Amigas and newer ones are likely to cause problems regardless.
- X.LP
- XAll current bugs in \fIunzip\fP(1L) exist in \fIunzipsfx\fP as well.
- X.PD
- X.\" =========================================================================
- X.SH DIAGNOSTICS
- X\fIunzipsfx\fP's exit status (error level) is identical to that of
- X\fIunzip\fP(1L); see the corresponding man page.
- X.PD
- X.\" =========================================================================
- X.SH SEE ALSO
- X\fIfunzip\fP(1L), \fIunzip\fP(1L), \fIzip\fP(1L), \fIzipcloak\fP(1L),
- X\fIzipgrep\fP(1L), \fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
- X.PD
- X.\" =========================================================================
- X.SH AUTHORS
- XGreg Roelofs was responsible for the basic modifications to UnZip necessary
- Xto create UnZipSFX. See \fIunzip\fP(1L) for the current list of zip-bugs
- Xauthors, or the file CONTRIBS in the UnZip source distribution for the
- Xfull list of Info-ZIP contributors.
- X.PD
- END_OF_FILE
- if test 12523 -ne `wc -c <'unzip-5.12/unix/unzipsfx.1'`; then
- echo shar: \"'unzip-5.12/unix/unzipsfx.1'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/unix/unzipsfx.1'
- fi
- if test -f 'unzip-5.12/unshrink.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/unshrink.c'\"
- else
- echo shar: Extracting \"'unzip-5.12/unshrink.c'\" \(17522 characters\)
- sed "s/^X//" >'unzip-5.12/unshrink.c' <<'END_OF_FILE'
- X#include "unzip.h"
- X
- X#ifdef NEW_UNSHRINK
- X
- X/*---------------------------------------------------------------------------
- X
- X unshrink.c version 0.94 26 Apr 94
- X
- X Shrinking is basically a dynamic LZW algorithm with allowed code sizes of
- X up to 13 bits; in addition, there is provision for partial clearing of
- X leaf nodes. PKWARE uses the special code 256 (decimal) to indicate a
- X change in code size or a partial clear of the code tree: 256,1 for the
- X former and 256,2 for the latter. See the notes in the code below about
- X orphaned nodes after partial clearing.
- X
- X This replacement version of unshrink.c was written from scratch. It is
- X based only on the algorithms described in Mark Nelson's _The Data Compres-
- X sion Book_ and in Terry Welch's original paper in the June 1984 issue of
- X IEEE _Computer_; no existing source code, including any in Nelson's book,
- X was used.
- X
- X Memory requirements are fairly large. While the NODE struct could be mod-
- X ified to fit in a single 64KB segment (as a "far" data structure), for now
- X it is assumed that a flat, 32-bit address space is available. outbuf2 is
- X always malloc'd, and flush() is always called with unshrink == FALSE.
- X
- X Copyright (C) 1994 Greg Roelofs. See the accompanying file "COPYING" in
- X the UnZip 5.11 (or later) source distribution.
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X/* #include "unzip.h" */
- X
- X#ifdef DEBUG
- X# define OUTDBG(c) if ((c)=='\n') {PUTC('^',stderr); PUTC('J',stderr);}\
- X else PUTC((c),stderr);
- X#else
- X# define OUTDBG(c)
- X#endif
- X
- Xtypedef struct leaf {
- X struct leaf *parent;
- X struct leaf *next_sibling;
- X struct leaf *first_child;
- X uch value;
- X} NODE;
- X
- Xstatic void partial_clear __((NODE *cursib));
- X
- Xstatic NODE *node, *bogusnode, *lastfreenode;
- X
- X
- Xint unshrink()
- X{
- X#ifdef MACOS
- X static uch *stacktop = NULL;
- X#else
- X static uch *stacktop = stack + 8192 - 1;
- X#endif
- X register uch *newstr;
- X int codesize=9, code, oldcode=0, len, KwKwK;
- X unsigned int outbufsiz;
- X NODE *freenode, *curnode, *lastnode=node, *oldnode;
- X
- X
- X/*---------------------------------------------------------------------------
- X Initialize various variables.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MACOS
- X if (stacktop == NULL) stacktop = stack + 8192 - 1;
- X#endif
- X
- X if ((node = (NODE *)malloc(8192*sizeof(NODE))) == (NODE *)NULL)
- X return PK_MEM3;
- X bogusnode = node + 256;
- X lastfreenode = node + 256;
- X
- X#ifndef SMALL_MEM /* always true, at least for now */
- X /* non-memory-limited machines: allocate second (large) buffer for
- X * textmode conversion in flush(), but only if needed */
- X if (pInfo->textmode && !outbuf2 &&
- X (outbuf2 = (uch *)malloc(TRANSBUFSIZ)) == (uch *)NULL)
- X {
- X free(node);
- X return PK_MEM3;
- X }
- X#endif
- X
- X /* this stuff was an attempt to debug compiler errors(?) when had
- X * node[8192] in union work area...no clues what was wrong (SGI worked)
- X Trace((stderr, "\nsizeof(NODE) = %d\n", sizeof(NODE)));
- X Trace((stderr, "sizeof(node) = %d\n", sizeof(node)));
- X Trace((stderr, "sizeof(area) = %d\n", sizeof(area)));
- X Trace((stderr, "address of node[0] = %d\n", (int)&node[0]));
- X Trace((stderr, "address of node[6945] = %d\n", (int)&node[6945]));
- X */
- X
- X for (code = 0; code < 256; ++code) {
- X node[code].value = code;
- X node[code].parent = bogusnode;
- X node[code].next_sibling = &node[code+1];
- X node[code].first_child = (NODE *)NULL;
- X }
- X node[255].next_sibling = (NODE *)NULL;
- X for (code = 257; code < 8192; ++code)
- X node[code].parent = node[code].next_sibling = (NODE *)NULL;
- X
- X outptr = outbuf;
- X outcnt = 0L;
- X if (pInfo->textmode)
- X outbufsiz = RAWBUFSIZ;
- X else
- X outbufsiz = OUTBUFSIZ;
- X
- X/*---------------------------------------------------------------------------
- X Get and output first code, then loop over remaining ones.
- X ---------------------------------------------------------------------------*/
- X
- X READBITS(codesize, oldcode)
- X if (!zipeof) {
- X *outptr++ = (uch)oldcode;
- X OUTDBG((uch)oldcode)
- X if (++outcnt == outbufsiz) {
- X flush(outbuf, outcnt, FALSE);
- X outptr = outbuf;
- X outcnt = 0L;
- X }
- X }
- X
- X do {
- X READBITS(codesize, code)
- X if (zipeof)
- X break;
- X if (code == 256) { /* GRR: possible to have consecutive escapes? */
- X READBITS(codesize, code)
- X if (code == 1) {
- X ++codesize;
- X Trace((stderr, " (codesize now %d bits)\n", codesize));
- X } else if (code == 2) {
- X Trace((stderr, " (partial clear code)\n"));
- X#ifdef DEBUG
- X fprintf(stderr, " should clear:\n");
- X for (curnode = node+257; curnode < node+8192; ++curnode)
- X if (!curnode->first_child)
- X fprintf(stderr, "%d\n", curnode-node);
- X fprintf(stderr, " did clear:\n");
- X#endif
- X partial_clear(node); /* recursive clear of leafs */
- X lastfreenode = bogusnode; /* reset start of free-node search */
- X }
- X continue;
- X }
- X
- X /*-----------------------------------------------------------------------
- X Translate code: traverse tree from leaf back to root.
- X -----------------------------------------------------------------------*/
- X
- X curnode = &node[code];
- X newstr = stacktop;
- X
- X if (curnode->parent)
- X KwKwK = FALSE;
- X else {
- X KwKwK = TRUE;
- X Trace((stderr, " (found a KwKwK code %d; oldcode = %d)\n", code,
- X oldcode));
- X --newstr; /* last character will be same as first character */
- X curnode = &node[oldcode];
- X }
- X
- X do {
- X *newstr-- = curnode->value;
- X curnode = curnode->parent;
- X } while (curnode != bogusnode);
- X
- X len = stacktop - newstr++;
- X if (KwKwK)
- X *stacktop = *newstr;
- X
- X /*-----------------------------------------------------------------------
- X Write expanded string in reverse order to output buffer.
- X -----------------------------------------------------------------------*/
- X
- X Trace((stderr, "code %4d; oldcode %4d; char %3d (%c); string [", code,
- X oldcode, (int)(*newstr), *newstr));
- X {
- X register uch *p;
- X
- X for (p = newstr; p < newstr+len; ++p) {
- X *outptr++ = *p;
- X OUTDBG(*p)
- X if (++outcnt == outbufsiz) {
- X flush(outbuf, outcnt, FALSE);
- X outptr = outbuf;
- X outcnt = 0L;
- X }
- X }
- X }
- X
- X /*-----------------------------------------------------------------------
- X Add new leaf (first character of newstr) to tree as child of oldcode.
- X -----------------------------------------------------------------------*/
- X
- X /* search for freenode */
- X freenode = lastfreenode + 1;
- X while (freenode->parent) /* add if-test before loop for speed? */
- X ++freenode;
- X lastfreenode = freenode;
- X Trace((stderr, "]; newcode %d\n", freenode-node));
- X
- X oldnode = &node[oldcode];
- X if (!oldnode->first_child) { /* no children yet: add first one */
- X if (!oldnode->parent) {
- X /*
- X * oldnode is itself a free node: the only way this can happen
- X * is if a partial clear occurred immediately after oldcode was
- X * received and therefore immediately before this step (adding
- X * freenode). This is subtle: even though the parent no longer
- X * exists, it is treated as if it does, and pointers are set as
- X * usual. Thus freenode is an orphan, *but only until the tree
- X * fills up to the point where oldnode is reused*. At that
- X * point the reborn oldnode "adopts" the orphaned node. Such
- X * wacky guys at PKWARE...
- X *
- X * To mark this, we set oldnode->next_sibling to point at the
- X * bogus node (256) and then check for this in the freenode sec-
- X * tion just below.
- X */
- X Trace((stderr, " [%d's parent (%d) was just cleared]\n",
- X freenode-node, oldcode));
- X oldnode->next_sibling = bogusnode;
- X }
- X oldnode->first_child = freenode;
- X } else {
- X curnode = oldnode->first_child;
- X while (curnode) { /* find last child in sibling chain */
- X lastnode = curnode;
- X curnode = curnode->next_sibling;
- X }
- X lastnode->next_sibling = freenode;
- X }
- X freenode->value = *newstr;
- X freenode->parent = oldnode;
- X if (freenode->next_sibling != bogusnode) /* no adoptions today... */
- X freenode->first_child = (NODE *)NULL;
- X freenode->next_sibling = (NODE *)NULL;
- X
- X oldcode = code;
- X } while (!zipeof);
- X
- X/*---------------------------------------------------------------------------
- X Flush any remaining data, free malloc'd space and return to sender...
- X ---------------------------------------------------------------------------*/
- X
- X if (outcnt > 0L)
- X flush(outbuf, outcnt, FALSE);
- X
- X free(node);
- X return PK_OK;
- X
- X} /* end function unshrink() */
- X
- X
- X
- X
- X
- Xstatic void partial_clear(cursib) /* like, totally recursive, eh? */
- X NODE *cursib;
- X{
- X NODE *lastsib=(NODE *)NULL;
- X
- X /* Loop over siblings, removing any without children; recurse on those
- X * which do have children. This hits even the orphans because they're
- X * always adopted (parent node is reused) before tree becomes full and
- X * needs clearing.
- X */
- X do {
- X if (cursib->first_child) {
- X partial_clear(cursib->first_child);
- X lastsib = cursib;
- X } else if ((cursib - node) > 256) { /* no children (leaf): clear it */
- X Trace((stderr, "%d\n", cursib-node));
- X if (!lastsib)
- X cursib->parent->first_child = cursib->next_sibling;
- X else
- X lastsib->next_sibling = cursib->next_sibling;
- X cursib->parent = (NODE *)NULL;
- X }
- X cursib = cursib->next_sibling;
- X } while (cursib);
- X return;
- X}
- X
- X
- X
- X#else /* !NEW_UNSHRINK */
- X
- X
- X
- X/*---------------------------------------------------------------------------
- X
- X unshrink.c
- X
- X Shrinking is a dynamic Lempel-Ziv-Welch compression algorithm with partial
- X clearing. Sadly, it uses more memory than any of the other algorithms (at
- X a minimum, 8K+8K+16K, assuming 16-bit short ints), and this does not even
- X include the output buffer (the other algorithms leave the uncompressed data
- X in the work area, typically called slide[]). For machines with a 64KB data
- X space, this is a problem, particularly when text conversion is required and
- X line endings have more than one character. UnZip's solution is to use two
- X roughly equal halves of outbuf for the ASCII conversion in such a case; the
- X "unshrink" argument to flush() signals that this is the case.
- X
- X For large-memory machines, a second outbuf is allocated for translations,
- X but only if unshrinking and only if translations are required.
- X
- X | binary mode | text mode
- X ---------------------------------------------------
- X big mem | big outbuf | big outbuf + big outbuf2 <- malloc'd here
- X small mem | small outbuf | half + half small outbuf
- X
- X This version contains code which is copyright (C) 1989 Samuel H. Smith.
- X See the accompanying file "COPYING" in the UnZip 5.11 (or later) source
- X distribution.
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X/* #include "unzip.h" */
- X
- X/* MAX_BITS 13 (in unzip.h; defines size of global work area) */
- X#define INIT_BITS 9
- X#define FIRST_ENT 257
- X#define CLEAR 256
- X
- X#define OUTB(c) {\
- X *outptr++=(uch)(c);\
- X if (++outcnt==outbufsiz) {\
- X flush(outbuf,outcnt,TRUE);\
- X outcnt=0L;\
- X outptr=outbuf;\
- X }\
- X}
- X
- Xstatic void partial_clear __((void));
- X
- Xint codesize, maxcode, maxcodemax, free_ent;
- X
- X
- X
- X
- X/*************************/
- X/* Function unshrink() */
- X/*************************/
- X
- Xint unshrink() /* return PK-type error code */
- X{
- X register int code;
- X register int stackp;
- X int finchar;
- X int oldcode;
- X int incode;
- X unsigned int outbufsiz;
- X
- X
- X /* non-memory-limited machines: allocate second (large) buffer for
- X * textmode conversion in flush(), but only if needed */
- X#ifndef SMALL_MEM
- X if (pInfo->textmode && !outbuf2 &&
- X (outbuf2 = (uch *)malloc(TRANSBUFSIZ)) == (uch *)NULL)
- X return PK_MEM3;
- X#endif
- X
- X outptr = outbuf;
- X outcnt = 0L;
- X if (pInfo->textmode)
- X outbufsiz = RAWBUFSIZ;
- X else
- X outbufsiz = OUTBUFSIZ;
- X
- X /* decompress the file */
- X codesize = INIT_BITS;
- X maxcode = (1 << codesize) - 1;
- X maxcodemax = HSIZE; /* (1 << MAX_BITS) */
- X free_ent = FIRST_ENT;
- X
- X code = maxcodemax;
- X/*
- X OvdL: -Ox with SCO's 3.2.0 cc gives
- X a. warning: overflow in constant multiplication
- X b. segmentation fault (core dumped) when using the executable
- X for (code = maxcodemax; code > 255; code--)
- X prefix_of[code] = -1;
- X */
- X do {
- X prefix_of[code] = -1;
- X } while (--code > 255);
- X
- X for (code = 255; code >= 0; code--) {
- X prefix_of[code] = 0;
- X suffix_of[code] = (uch)code;
- X }
- X
- X READBITS(codesize,oldcode) /* ; */
- X if (zipeof)
- X return PK_COOL;
- X finchar = oldcode;
- X
- X OUTB(finchar)
- X
- X stackp = HSIZE;
- X
- X while (!zipeof) {
- X READBITS(codesize,code) /* ; */
- X if (zipeof) {
- X if (outcnt > 0L)
- X flush(outbuf, outcnt, TRUE); /* flush last, partial buffer */
- X return PK_COOL;
- X }
- X
- X while (code == CLEAR) {
- X READBITS(codesize,code) /* ; */
- X switch (code) {
- X case 1:
- X codesize++;
- X if (codesize == MAX_BITS)
- X maxcode = maxcodemax;
- X else
- X maxcode = (1 << codesize) - 1;
- X break;
- X
- X case 2:
- X partial_clear();
- X break;
- X }
- X
- X READBITS(codesize,code) /* ; */
- X if (zipeof) {
- X if (outcnt > 0L)
- X flush(outbuf, outcnt, TRUE); /* partial buffer */
- X return PK_COOL;
- X }
- X }
- X
- X
- X /* special case for KwKwK string */
- X incode = code;
- X if (prefix_of[code] == -1) {
- X stack[--stackp] = (uch)finchar;
- X code = oldcode;
- X }
- X /* generate output characters in reverse order */
- X while (code >= FIRST_ENT) {
- X if (prefix_of[code] == -1) {
- X stack[--stackp] = (uch)finchar;
- X code = oldcode;
- X } else {
- X stack[--stackp] = suffix_of[code];
- X code = prefix_of[code];
- X }
- X }
- X
- X finchar = suffix_of[code];
- X stack[--stackp] = (uch)finchar;
- X
- X
- X /* and put them out in forward order, block copy */
- X if ((HSIZE - stackp + outcnt) < outbufsiz) {
- X /* GRR: this is not necessarily particularly efficient:
- X * typically output only 2-5 bytes per loop (more
- X * than a dozen rather rare?) */
- X memcpy(outptr, &stack[stackp], HSIZE - stackp);
- X outptr += HSIZE - stackp;
- X outcnt += HSIZE - stackp;
- X stackp = HSIZE;
- X }
- X /* output byte by byte if we can't go by blocks */
- X else
- X while (stackp < HSIZE)
- X OUTB(stack[stackp++])
- X
- X
- X /* generate new entry */
- X code = free_ent;
- X if (code < maxcodemax) {
- X prefix_of[code] = oldcode;
- X suffix_of[code] = (uch)finchar;
- X
- X do
- X code++;
- X while ((code < maxcodemax) && (prefix_of[code] != -1));
- X
- X free_ent = code;
- X }
- X /* remember previous code */
- X oldcode = incode;
- X }
- X
- X /* never reached? */
- X /* flush last, partial buffer */
- X if (outcnt > 0L)
- X flush(outbuf, outcnt, TRUE);
- X
- X return PK_OK;
- X
- X} /* end function unshrink() */
- X
- X
- X
- X/******************************/
- X/* Function partial_clear() */
- X/******************************/
- X
- Xstatic void partial_clear()
- X{
- X register int pr;
- X register int cd;
- X
- X /* mark all nodes as potentially unused */
- X for (cd = FIRST_ENT; cd < free_ent; cd++)
- X prefix_of[cd] |= 0x8000;
- X
- X /* unmark those that are used by other nodes */
- X for (cd = FIRST_ENT; cd < free_ent; cd++) {
- X pr = prefix_of[cd] & 0x7fff; /* reference to another node? */
- X if (pr >= FIRST_ENT) /* flag node as referenced */
- X prefix_of[pr] &= 0x7fff;
- X }
- X
- X /* clear the ones that are still marked */
- X for (cd = FIRST_ENT; cd < free_ent; cd++)
- X if ((prefix_of[cd] & 0x8000) != 0)
- X prefix_of[cd] = -1;
- X
- X /* find first cleared node as next free_ent */
- X cd = FIRST_ENT;
- X while ((cd < maxcodemax) && (prefix_of[cd] != -1))
- X cd++;
- X free_ent = cd;
- X}
- X
- X
- X#endif /* ?NEW_UNSHRINK */
- END_OF_FILE
- if test 17522 -ne `wc -c <'unzip-5.12/unshrink.c'`; then
- echo shar: \"'unzip-5.12/unshrink.c'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/unshrink.c'
- fi
- echo shar: End of archive 15 \(of 20\).
- cp /dev/null ark15isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-