home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
You can browse this item here: unsit_15.shr
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
66%
| dexvert
| PC-Shrink Archive (archive/pcShrink)
| ext
| Supported |
66%
| dexvert
| Apple IIGS SH3/SHR (image/a2gsSHStar)
| ext
| Supported |
66%
| dexvert
| Magic Draw (image/magicDraw)
| ext
| Supported |
66%
| dexvert
| Apple IIGS Preferred Format (image/a2gsPreferred)
| ext
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| C source text
| default
| |
99%
| file
| C source, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| application/x-shellscript
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|00000010| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|00000020| 63 68 69 76 65 2c 20 6d | 65 61 6e 69 6e 67 3a 0a |chive, m|eaning:.|
|00000030| 23 20 31 2e 20 52 65 6d | 6f 76 65 20 65 76 65 72 |# 1. Rem|ove ever|
|00000040| 79 74 68 69 6e 67 20 61 | 62 6f 76 65 20 74 68 65 |ything a|bove the|
|00000050| 20 23 21 20 2f 62 69 6e | 2f 73 68 20 6c 69 6e 65 | #! /bin|/sh line|
|00000060| 2e 0a 23 20 32 2e 20 53 | 61 76 65 20 74 68 65 20 |..# 2. S|ave the |
|00000070| 72 65 73 75 6c 74 69 6e | 67 20 74 65 78 74 20 69 |resultin|g text i|
|00000080| 6e 20 61 20 66 69 6c 65 | 2e 0a 23 20 33 2e 20 45 |n a file|..# 3. E|
|00000090| 78 65 63 75 74 65 20 74 | 68 65 20 66 69 6c 65 20 |xecute t|he file |
|000000a0| 77 69 74 68 20 2f 62 69 | 6e 2f 73 68 20 28 6e 6f |with /bi|n/sh (no|
|000000b0| 74 20 63 73 68 29 20 74 | 6f 20 63 72 65 61 74 65 |t csh) t|o create|
|000000c0| 20 74 68 65 20 66 69 6c | 65 73 3a 0a 23 09 52 45 | the fil|es:.#.RE|
|000000d0| 41 44 4d 45 0a 23 09 4d | 61 6b 65 66 69 6c 65 0a |ADME.#.M|akefile.|
|000000e0| 23 09 75 6e 73 69 74 2e | 63 0a 23 09 73 74 75 66 |#.unsit.|c.#.stuf|
|000000f0| 66 69 74 2e 68 0a 23 09 | 75 70 64 63 72 63 2e 63 |fit.h.#.|updcrc.c|
|00000100| 0a 23 09 67 65 74 6f 70 | 74 2e 63 0a 23 09 75 6e |.#.getop|t.c.#.un|
|00000110| 73 69 74 2e 31 0a 23 20 | 54 68 69 73 20 61 72 63 |sit.1.# |This arc|
|00000120| 68 69 76 65 20 63 72 65 | 61 74 65 64 3a 20 57 65 |hive cre|ated: We|
|00000130| 64 20 4a 61 6e 20 31 30 | 20 31 34 3a 32 35 3a 31 |d Jan 10| 14:25:1|
|00000140| 32 20 31 39 39 30 0a 65 | 78 70 6f 72 74 20 50 41 |2 1990.e|xport PA|
|00000150| 54 48 3b 20 50 41 54 48 | 3d 2f 62 69 6e 3a 24 50 |TH; PATH|=/bin:$P|
|00000160| 41 54 48 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |ATH.if t|est -f '|
|00000170| 52 45 41 44 4d 45 27 0a | 74 68 65 6e 0a 09 65 63 |README'.|then..ec|
|00000180| 68 6f 20 73 68 61 72 3a | 20 77 69 6c 6c 20 6e 6f |ho shar:| will no|
|00000190| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|000001a0| 73 74 69 6e 67 20 66 69 | 6c 65 20 22 27 52 45 41 |sting fi|le "'REA|
|000001b0| 44 4d 45 27 22 0a 65 6c | 73 65 0a 63 61 74 20 3c |DME'".el|se.cat <|
|000001c0| 3c 20 5c 53 48 41 52 5f | 45 4f 46 20 3e 20 27 52 |< \SHAR_|EOF > 'R|
|000001d0| 45 41 44 4d 45 27 0a 09 | 09 09 20 20 55 6e 73 69 |EADME'..|.. Unsi|
|000001e0| 74 2c 20 76 65 72 73 69 | 6f 6e 20 31 2e 35 0a 0a |t, versi|on 1.5..|
|000001f0| 54 68 65 73 65 20 61 72 | 65 20 74 68 65 20 73 6f |These ar|e the so|
|00000200| 75 63 65 73 20 66 6f 72 | 20 22 75 6e 73 69 74 22 |uces for| "unsit"|
|00000210| 2c 20 61 20 55 6e 69 78 | 20 70 72 6f 67 72 61 6d |, a Unix| program|
|00000220| 20 66 6f 72 20 62 72 65 | 61 6b 69 6e 67 20 61 70 | for bre|aking ap|
|00000230| 61 72 74 0a 53 74 75 66 | 66 49 74 20 61 72 63 68 |art.Stuf|fIt arch|
|00000240| 69 76 65 20 66 69 6c 65 | 73 20 63 72 65 61 74 65 |ive file|s create|
|00000250| 64 20 6f 6e 20 61 20 4d | 61 63 69 6e 74 6f 73 68 |d on a M|acintosh|
|00000260| 20 69 6e 74 6f 20 73 65 | 70 61 72 61 74 65 20 66 | into se|parate f|
|00000270| 69 6c 65 73 20 6f 6e 0a | 74 68 65 20 55 6e 69 78 |iles on.|the Unix|
|00000280| 20 73 79 73 74 65 6d 2e | 20 20 53 65 65 20 74 68 | system.| See th|
|00000290| 65 20 64 6f 63 75 6d 65 | 6e 74 61 74 69 6f 6e 20 |e docume|ntation |
|000002a0| 61 74 20 74 68 65 20 62 | 65 67 69 6e 6e 69 6e 67 |at the b|eginning|
|000002b0| 20 6f 66 20 22 75 6e 73 | 69 74 2e 63 22 0a 6f 72 | of "uns|it.c".or|
|000002c0| 20 74 68 65 20 6d 61 6e | 20 70 61 67 65 20 22 75 | the man| page "u|
|000002d0| 6e 73 69 74 2e 31 22 20 | 66 6f 72 20 6d 6f 72 65 |nsit.1" |for more|
|000002e0| 20 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 2e 0a 0a 54 | informa|tion...T|
|000002f0| 6f 20 62 75 69 6c 64 20 | 74 68 65 20 70 72 6f 67 |o build |the prog|
|00000300| 72 61 6d 2c 20 63 6f 6d | 70 69 6c 65 20 75 6e 73 |ram, com|pile uns|
|00000310| 69 74 2e 63 20 61 6e 64 | 20 75 70 64 63 72 63 2e |it.c and| updcrc.|
|00000320| 63 20 61 6e 64 20 6c 69 | 6e 6b 20 74 6f 67 65 74 |c and li|nk toget|
|00000330| 68 65 72 2e 0a 49 66 20 | 79 6f 75 72 20 73 79 73 |her..If |your sys|
|00000340| 74 65 6d 20 64 6f 65 73 | 6e 27 74 20 68 61 76 65 |tem does|n't have|
|00000350| 20 74 68 65 20 67 65 74 | 6f 70 74 28 29 20 72 6f | the get|opt() ro|
|00000360| 75 74 69 6e 65 20 69 6e | 20 69 74 73 20 73 74 61 |utine in| its sta|
|00000370| 6e 64 61 72 64 0a 6c 69 | 62 72 61 72 79 2c 20 61 |ndard.li|brary, a|
|00000380| 6c 73 6f 20 63 6f 6d 70 | 69 6c 65 20 67 65 74 6f |lso comp|ile geto|
|00000390| 70 74 2e 63 20 61 6e 64 | 20 69 6e 63 6c 75 64 65 |pt.c and| include|
|000003a0| 20 69 74 20 69 6e 20 74 | 68 65 20 6c 69 6e 6b 2e | it in t|he link.|
|000003b0| 0a 0a 54 68 69 73 20 70 | 72 6f 67 72 61 6d 20 6f |..This p|rogram o|
|000003c0| 70 65 6e 73 20 61 20 70 | 69 70 65 20 74 6f 20 74 |pens a p|ipe to t|
|000003d0| 68 65 20 22 63 6f 6d 70 | 72 65 73 73 22 20 70 72 |he "comp|ress" pr|
|000003e0| 6f 67 72 61 6d 20 66 6f | 72 20 64 6f 69 6e 67 20 |ogram fo|r doing |
|000003f0| 74 68 65 0a 75 6e 63 6f | 6d 70 72 65 73 73 69 6f |the.unco|mpressio|
|00000400| 6e 20 6f 66 20 73 6f 6d | 65 20 6f 66 20 74 68 65 |n of som|e of the|
|00000410| 20 66 69 6c 65 73 20 69 | 6e 20 74 68 65 20 61 72 | files i|n the ar|
|00000420| 63 68 69 76 65 2e 20 20 | 4d 6f 73 74 20 55 6e 69 |chive. |Most Uni|
|00000430| 78 20 73 69 74 65 73 0a | 70 72 6f 62 61 62 6c 79 |x sites.|probably|
|00000440| 20 61 6c 72 65 61 64 79 | 20 68 61 76 65 20 22 63 | already| have "c|
|00000450| 6f 6d 70 72 65 73 73 22 | 2e 20 20 49 66 20 6e 6f |ompress"|. If no|
|00000460| 74 2c 20 69 74 20 63 61 | 6e 20 62 65 20 66 6f 75 |t, it ca|n be fou|
|00000470| 6e 64 20 69 6e 20 74 68 | 65 0a 63 6f 6d 70 2e 73 |nd in th|e.comp.s|
|00000480| 6f 75 72 63 65 73 2e 75 | 6e 69 78 20 61 72 63 68 |ources.u|nix arch|
|00000490| 69 76 65 73 2e 0a 0a 43 | 6f 6d 6d 65 6e 74 73 20 |ives...C|omments |
|000004a0| 61 6e 64 20 62 75 67 20 | 72 65 70 6f 72 74 73 20 |and bug |reports |
|000004b0| 73 68 6f 75 6c 64 20 62 | 65 20 73 65 6e 64 20 74 |should b|e send t|
|000004c0| 6f 20 77 65 62 65 72 25 | 62 72 61 6e 64 2e 75 73 |o weber%|brand.us|
|000004d0| 63 2e 65 64 75 40 6f 62 | 65 72 6f 6e 2e 75 73 63 |c.edu@ob|eron.usc|
|000004e0| 2e 65 64 75 0a 0a 0a 09 | 09 09 09 41 6c 6c 61 6e |.edu....|...Allan|
|000004f0| 20 47 2e 20 57 65 62 65 | 72 0a 09 09 09 09 53 69 | G. Webe|r.....Si|
|00000500| 67 6e 61 6c 20 61 6e 64 | 20 49 6d 61 67 65 20 50 |gnal and| Image P|
|00000510| 72 6f 63 65 73 73 69 6e | 67 20 49 6e 73 74 69 74 |rocessin|g Instit|
|00000520| 75 74 65 0a 09 09 09 09 | 55 6e 69 76 65 72 73 69 |ute.....|Universi|
|00000530| 74 79 20 6f 66 20 53 6f | 75 74 68 65 72 6e 20 43 |ty of So|uthern C|
|00000540| 61 6c 69 66 6f 72 6e 69 | 61 0a 09 09 09 09 50 6f |aliforni|a.....Po|
|00000550| 77 65 6c 6c 20 48 61 6c | 6c 20 33 30 36 2c 20 4d |well Hal|l 306, M|
|00000560| 43 2d 30 32 37 32 0a 09 | 09 09 09 4c 6f 73 20 41 |C-0272..|...Los A|
|00000570| 6e 67 65 6c 65 73 2c 20 | 43 41 20 39 30 30 38 39 |ngeles, |CA 90089|
|00000580| 2d 30 32 37 32 0a 09 09 | 09 09 28 32 31 33 29 20 |-0272...|..(213) |
|00000590| 37 34 33 2d 35 35 31 39 | 0a 53 48 41 52 5f 45 4f |743-5519|.SHAR_EO|
|000005a0| 46 0a 66 69 20 23 20 65 | 6e 64 20 6f 66 20 6f 76 |F.fi # e|nd of ov|
|000005b0| 65 72 77 72 69 74 69 6e | 67 20 63 68 65 63 6b 0a |erwritin|g check.|
|000005c0| 69 66 20 74 65 73 74 20 | 2d 66 20 27 4d 61 6b 65 |if test |-f 'Make|
|000005d0| 66 69 6c 65 27 0a 74 68 | 65 6e 0a 09 65 63 68 6f |file'.th|en..echo|
|000005e0| 20 73 68 61 72 3a 20 77 | 69 6c 6c 20 6e 6f 74 20 | shar: w|ill not |
|000005f0| 6f 76 65 72 2d 77 72 69 | 74 65 20 65 78 69 73 74 |over-wri|te exist|
|00000600| 69 6e 67 20 66 69 6c 65 | 20 22 27 4d 61 6b 65 66 |ing file| "'Makef|
|00000610| 69 6c 65 27 22 0a 65 6c | 73 65 0a 63 61 74 20 3c |ile'".el|se.cat <|
|00000620| 3c 20 5c 53 48 41 52 5f | 45 4f 46 20 3e 20 27 4d |< \SHAR_|EOF > 'M|
|00000630| 61 6b 65 66 69 6c 65 27 | 0a 47 45 54 4f 50 54 20 |akefile'|.GETOPT |
|00000640| 3d 20 0a 23 47 45 54 4f | 50 54 20 3d 20 67 65 74 |= .#GETO|PT = get|
|00000650| 6f 70 74 2e 6f 0a 0a 75 | 6e 73 69 74 20 3a 20 75 |opt.o..u|nsit : u|
|00000660| 6e 73 69 74 2e 6f 20 75 | 70 64 63 72 63 2e 6f 20 |nsit.o u|pdcrc.o |
|00000670| 24 28 47 45 54 4f 50 54 | 29 0a 09 63 63 20 2d 6f |$(GETOPT|)..cc -o|
|00000680| 20 75 6e 73 69 74 20 75 | 6e 73 69 74 2e 6f 20 75 | unsit u|nsit.o u|
|00000690| 70 64 63 72 63 2e 6f 20 | 24 28 47 45 54 4f 50 54 |pdcrc.o |$(GETOPT|
|000006a0| 29 0a 0a 75 6e 73 69 74 | 2e 6f 20 3a 20 75 6e 73 |)..unsit|.o : uns|
|000006b0| 69 74 2e 63 20 73 74 75 | 66 66 69 74 2e 68 0a 67 |it.c stu|ffit.h.g|
|000006c0| 65 74 6f 70 74 2e 6f 20 | 3a 20 67 65 74 6f 70 74 |etopt.o |: getopt|
|000006d0| 2e 63 0a 0a 75 6e 73 69 | 74 2e 73 68 61 72 20 3a |.c..unsi|t.shar :|
|000006e0| 20 52 45 41 44 4d 45 20 | 4d 61 6b 65 66 69 6c 65 | README |Makefile|
|000006f0| 20 75 6e 73 69 74 2e 63 | 20 73 74 75 66 66 69 74 | unsit.c| stuffit|
|00000700| 2e 68 20 75 70 64 63 72 | 63 2e 63 20 67 65 74 6f |.h updcr|c.c geto|
|00000710| 70 74 2e 63 20 75 6e 73 | 69 74 2e 31 0a 09 73 68 |pt.c uns|it.1..sh|
|00000720| 61 72 20 52 45 41 44 4d | 45 20 4d 61 6b 65 66 69 |ar READM|E Makefi|
|00000730| 6c 65 20 75 6e 73 69 74 | 2e 63 20 73 74 75 66 66 |le unsit|.c stuff|
|00000740| 69 74 2e 68 20 75 70 64 | 63 72 63 2e 63 20 67 65 |it.h upd|crc.c ge|
|00000750| 74 6f 70 74 2e 63 20 75 | 6e 73 69 74 2e 31 20 5c |topt.c u|nsit.1 \|
|00000760| 0a 09 3e 75 6e 73 69 74 | 2e 73 68 61 72 0a 53 48 |..>unsit|.shar.SH|
|00000770| 41 52 5f 45 4f 46 0a 66 | 69 20 23 20 65 6e 64 20 |AR_EOF.f|i # end |
|00000780| 6f 66 20 6f 76 65 72 77 | 72 69 74 69 6e 67 20 63 |of overw|riting c|
|00000790| 68 65 63 6b 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |heck.if |test -f |
|000007a0| 27 75 6e 73 69 74 2e 63 | 27 0a 74 68 65 6e 0a 09 |'unsit.c|'.then..|
|000007b0| 65 63 68 6f 20 73 68 61 | 72 3a 20 77 69 6c 6c 20 |echo sha|r: will |
|000007c0| 6e 6f 74 20 6f 76 65 72 | 2d 77 72 69 74 65 20 65 |not over|-write e|
|000007d0| 78 69 73 74 69 6e 67 20 | 66 69 6c 65 20 22 27 75 |xisting |file "'u|
|000007e0| 6e 73 69 74 2e 63 27 22 | 0a 65 6c 73 65 0a 63 61 |nsit.c'"|.else.ca|
|000007f0| 74 20 3c 3c 20 5c 53 48 | 41 52 5f 45 4f 46 20 3e |t << \SH|AR_EOF >|
|00000800| 20 27 75 6e 73 69 74 2e | 63 27 0a 2f 2a 0a 09 20 | 'unsit.|c'./*.. |
|00000810| 20 20 20 20 20 20 75 6e | 73 69 74 20 2d 20 4d 61 | un|sit - Ma|
|00000820| 63 69 6e 74 6f 73 68 20 | 53 74 75 66 66 49 74 20 |cintosh |StuffIt |
|00000830| 66 69 6c 65 20 65 78 74 | 72 61 63 74 6f 72 0a 0a |file ext|ractor..|
|00000840| 09 09 20 20 20 20 20 56 | 65 72 73 69 6f 6e 20 31 |.. V|ersion 1|
|00000850| 2e 35 63 2c 20 66 6f 72 | 20 53 74 75 66 66 49 74 |.5c, for| StuffIt|
|00000860| 20 31 2e 35 0a 0a 09 09 | 09 20 20 20 20 41 75 67 | 1.5....|. Aug|
|00000870| 75 73 74 20 33 2c 20 31 | 39 38 39 0a 0a 54 68 69 |ust 3, 1|989..Thi|
|00000880| 73 20 70 72 6f 67 72 61 | 6d 20 77 69 6c 6c 20 75 |s progra|m will u|
|00000890| 6e 70 61 63 6b 20 61 20 | 4d 61 63 69 6e 74 6f 73 |npack a |Macintos|
|000008a0| 68 20 53 74 75 66 66 49 | 74 20 66 69 6c 65 20 69 |h StuffI|t file i|
|000008b0| 6e 74 6f 20 73 65 70 61 | 72 61 74 65 20 66 69 6c |nto sepa|rate fil|
|000008c0| 65 73 2e 0a 54 68 65 20 | 64 61 74 61 20 66 6f 72 |es..The |data for|
|000008d0| 6b 20 6f 66 20 61 20 53 | 74 75 66 66 49 74 20 66 |k of a S|tuffIt f|
|000008e0| 69 6c 65 20 63 6f 6e 74 | 61 69 6e 73 20 62 6f 74 |ile cont|ains bot|
|000008f0| 68 20 74 68 65 20 64 61 | 74 61 20 61 6e 64 20 72 |h the da|ta and r|
|00000900| 65 73 6f 75 72 63 65 0a | 66 6f 72 6b 73 20 6f 66 |esource.|forks of|
|00000910| 20 74 68 65 20 70 61 63 | 6b 65 64 20 66 69 6c 65 | the pac|ked file|
|00000920| 73 2e 20 20 54 68 65 20 | 70 72 6f 67 72 61 6d 20 |s. The |program |
|00000930| 77 69 6c 6c 20 75 6e 70 | 61 63 6b 20 65 61 63 68 |will unp|ack each|
|00000940| 20 4d 61 63 20 66 69 6c | 65 20 69 6e 74 6f 0a 73 | Mac fil|e into.s|
|00000950| 65 70 61 72 61 74 65 20 | 2e 64 61 74 61 2c 20 2e |eparate |.data, .|
|00000960| 72 73 72 63 2e 2c 20 61 | 6e 64 20 2e 69 6e 66 6f |rsrc., a|nd .info|
|00000970| 20 66 69 6c 65 73 20 74 | 68 61 74 20 63 61 6e 20 | files t|hat can |
|00000980| 62 65 20 64 6f 77 6e 6c | 6f 61 64 65 64 20 74 6f |be downl|oaded to|
|00000990| 20 61 0a 4d 61 63 20 75 | 73 69 6e 67 20 6d 61 63 | a.Mac u|sing mac|
|000009a0| 70 75 74 2e 20 20 54 68 | 65 20 70 72 6f 67 72 61 |put. Th|e progra|
|000009b0| 6d 20 69 73 20 6d 75 63 | 68 20 6c 69 6b 65 20 74 |m is muc|h like t|
|000009c0| 68 65 20 22 75 6e 70 69 | 74 22 20 70 72 6f 67 72 |he "unpi|t" progr|
|000009d0| 61 6d 20 66 6f 72 0a 62 | 72 65 61 6b 69 6e 67 20 |am for.b|reaking |
|000009e0| 61 70 61 72 74 20 50 61 | 63 6b 69 74 20 61 72 63 |apart Pa|ckit arc|
|000009f0| 68 69 76 65 20 66 69 6c | 65 73 2e 0a 0a 09 09 09 |hive fil|es......|
|00000a00| 2a 2a 2a 2a 2a 20 49 4d | 50 4f 52 54 41 4e 54 20 |***** IM|PORTANT |
|00000a10| 2a 2a 2a 2a 2a 0a 54 6f | 20 65 78 74 72 61 63 74 |*****.To| extract|
|00000a20| 20 53 74 75 66 66 49 74 | 20 66 69 6c 65 73 20 74 | StuffIt| files t|
|00000a30| 68 61 74 20 68 61 76 65 | 20 62 65 65 6e 20 63 6f |hat have| been co|
|00000a40| 6d 70 72 65 73 73 65 64 | 20 77 69 74 68 20 74 68 |mpressed| with th|
|00000a50| 65 20 4c 65 6d 70 65 6c | 2d 5a 69 76 0a 63 6f 6d |e Lempel|-Ziv.com|
|00000a60| 70 72 65 73 73 69 6f 6e | 20 6d 65 74 68 6f 64 2c |pression| method,|
|00000a70| 20 75 6e 73 69 74 20 70 | 69 70 65 73 20 74 68 65 | unsit p|ipes the|
|00000a80| 20 64 61 74 61 20 74 68 | 72 6f 75 67 68 20 74 68 | data th|rough th|
|00000a90| 65 20 22 63 6f 6d 70 72 | 65 73 73 22 0a 70 72 6f |e "compr|ess".pro|
|00000aa0| 67 72 61 6d 20 77 69 74 | 68 20 74 68 65 20 61 70 |gram wit|h the ap|
|00000ab0| 70 72 6f 70 72 69 61 74 | 65 20 73 77 69 74 63 68 |propriat|e switch|
|00000ac0| 65 73 2c 20 72 61 74 68 | 65 72 20 74 68 61 6e 20 |es, rath|er than |
|00000ad0| 69 6e 63 6f 72 70 6f 72 | 61 74 65 20 74 68 65 0a |incorpor|ate the.|
|00000ae0| 75 6e 63 6f 6d 70 72 65 | 73 73 69 6f 6e 20 72 6f |uncompre|ssion ro|
|00000af0| 75 74 69 6e 65 73 20 77 | 69 74 68 69 6e 20 22 75 |utines w|ithin "u|
|00000b00| 6e 73 69 74 22 2e 20 20 | 54 68 65 72 65 66 6f 72 |nsit". |Therefor|
|00000b10| 65 2c 20 69 74 20 69 73 | 20 6e 65 63 65 73 73 61 |e, it is| necessa|
|00000b20| 72 79 20 74 6f 0a 68 61 | 76 65 20 74 68 65 20 22 |ry to.ha|ve the "|
|00000b30| 63 6f 6d 70 72 65 73 73 | 22 20 70 72 6f 67 72 61 |compress|" progra|
|00000b40| 6d 20 6f 6e 20 74 68 65 | 20 73 79 73 74 65 6d 20 |m on the| system |
|00000b50| 61 6e 64 20 69 6e 20 74 | 68 65 20 73 65 61 72 63 |and in t|he searc|
|00000b60| 68 20 70 61 74 68 20 74 | 6f 0a 6d 61 6b 65 20 22 |h path t|o.make "|
|00000b70| 75 6e 73 69 74 22 20 77 | 6f 72 6b 2e 20 20 22 43 |unsit" w|ork. "C|
|00000b80| 6f 6d 70 72 65 73 73 22 | 20 69 73 20 61 76 61 69 |ompress"| is avai|
|00000b90| 6c 61 62 6c 65 20 66 72 | 6f 6d 20 74 68 65 20 63 |lable fr|om the c|
|00000ba0| 6f 6d 70 2e 73 6f 75 72 | 63 65 73 2e 75 6e 69 78 |omp.sour|ces.unix|
|00000bb0| 0a 61 72 63 68 69 76 65 | 73 2e 0a 0a 54 68 65 20 |.archive|s...The |
|00000bc0| 70 72 6f 67 72 61 6d 20 | 73 79 6e 74 61 78 20 69 |program |syntax i|
|00000bd0| 73 20 6d 75 63 68 20 6c | 69 6b 65 20 75 6e 70 69 |s much l|ike unpi|
|00000be0| 74 20 61 6e 64 20 6d 61 | 63 70 75 74 2f 6d 61 63 |t and ma|cput/mac|
|00000bf0| 67 65 74 2c 20 77 69 74 | 68 20 73 6f 6d 65 20 61 |get, wit|h some a|
|00000c00| 64 64 65 64 0a 6f 70 74 | 69 6f 6e 73 3a 0a 0a 09 |dded.opt|ions:...|
|00000c10| 75 6e 73 69 74 20 5b 2d | 72 64 75 6c 76 71 66 6d |unsit [-|rdulvqfm|
|00000c20| 5d 20 73 74 75 66 66 69 | 74 2d 66 69 6c 65 2e 64 |] stuffi|t-file.d|
|00000c30| 61 74 61 0a 0a 54 68 65 | 20 2d 72 20 61 6e 64 20 |ata..The| -r and |
|00000c40| 2d 64 20 66 6c 61 67 73 | 20 77 69 6c 6c 20 63 61 |-d flags| will ca|
|00000c50| 75 73 65 20 6f 6e 6c 79 | 20 74 68 65 20 72 65 73 |use only| the res|
|00000c60| 6f 75 72 63 65 20 61 6e | 64 20 64 61 74 61 20 66 |ource an|d data f|
|00000c70| 6f 72 6b 73 20 74 6f 20 | 62 65 0a 77 72 69 74 74 |orks to |be.writt|
|00000c80| 65 6e 2e 20 20 54 68 65 | 20 2d 75 20 66 6c 61 67 |en. The| -u flag|
|00000c90| 20 77 69 6c 6c 20 63 61 | 75 73 65 20 6f 6e 6c 79 | will ca|use only|
|00000ca0| 20 74 68 65 20 64 61 74 | 61 20 66 6f 72 6b 20 74 | the dat|a fork t|
|00000cb0| 6f 20 62 65 20 77 72 69 | 74 74 65 6e 20 61 6e 64 |o be wri|tten and|
|00000cc0| 0a 74 6f 20 68 61 76 65 | 20 63 61 72 72 69 61 67 |.to have| carriag|
|00000cd0| 65 20 72 65 74 75 72 6e | 20 63 68 61 72 61 63 74 |e return| charact|
|00000ce0| 65 72 73 20 63 68 61 6e | 67 65 64 20 74 6f 20 55 |ers chan|ged to U|
|00000cf0| 6e 69 78 20 6e 65 77 6c | 69 6e 65 20 63 68 61 72 |nix newl|ine char|
|00000d00| 61 63 74 65 72 73 2e 0a | 54 68 65 20 2d 6c 20 66 |acters..|The -l f|
|00000d10| 6c 61 67 20 77 69 6c 6c | 20 6d 61 6b 65 20 74 68 |lag will| make th|
|00000d20| 65 20 70 72 6f 67 72 61 | 6d 20 6f 6e 6c 79 20 6c |e progra|m only l|
|00000d30| 69 73 74 20 74 68 65 20 | 66 69 6c 65 73 20 69 6e |ist the |files in|
|00000d40| 20 74 68 65 20 53 74 75 | 66 66 49 74 0a 66 69 6c | the Stu|ffIt.fil|
|00000d50| 65 2e 20 20 54 68 65 20 | 2d 76 20 66 6c 61 67 20 |e. The |-v flag |
|00000d60| 63 61 75 73 65 73 20 74 | 68 65 20 70 72 6f 67 72 |causes t|he progr|
|00000d70| 61 6d 20 74 6f 20 6c 69 | 73 74 20 74 68 65 20 6e |am to li|st the n|
|00000d80| 61 6d 65 73 2c 20 73 69 | 7a 65 73 2c 20 74 79 70 |ames, si|zes, typ|
|00000d90| 65 2c 0a 61 6e 64 20 63 | 72 65 61 74 6f 72 73 20 |e,.and c|reators |
|00000da0| 6f 66 20 74 68 65 20 66 | 69 6c 65 73 20 69 74 20 |of the f|iles it |
|00000db0| 69 73 20 77 72 69 74 69 | 6e 67 2e 20 20 54 68 65 |is writi|ng. The|
|00000dc0| 20 2d 71 20 66 6c 61 67 | 20 63 61 75 73 65 73 20 | -q flag| causes |
|00000dd0| 69 74 20 74 6f 0a 6c 69 | 73 74 20 74 68 65 20 6e |it to.li|st the n|
|00000de0| 61 6d 65 2c 20 74 79 70 | 65 20 61 6e 64 20 73 69 |ame, typ|e and si|
|00000df0| 7a 65 20 6f 66 20 65 61 | 63 68 20 66 69 6c 65 20 |ze of ea|ch file |
|00000e00| 61 6e 64 20 77 61 69 74 | 20 66 6f 72 20 61 20 27 |and wait| for a '|
|00000e10| 79 27 20 6f 72 20 27 6e | 27 0a 66 6f 72 20 65 69 |y' or 'n|'.for ei|
|00000e20| 74 68 65 72 20 77 72 69 | 74 69 6e 67 20 74 68 61 |ther wri|ting tha|
|00000e30| 74 20 66 69 6c 65 20 6f | 72 20 73 6b 69 70 70 69 |t file o|r skippi|
|00000e40| 6e 67 20 69 74 2c 20 72 | 65 73 70 65 63 74 69 76 |ng it, r|espectiv|
|00000e50| 65 6c 79 2e 20 20 54 68 | 65 20 2d 6d 0a 66 6c 61 |ely. Th|e -m.fla|
|00000e60| 67 20 69 73 20 75 73 65 | 64 20 77 68 65 6e 20 74 |g is use|d when t|
|00000e70| 68 65 20 69 6e 70 75 74 | 20 66 69 6c 65 20 69 6e |he input| file in|
|00000e80| 20 69 6e 20 74 68 65 20 | 4d 61 63 42 69 6e 61 72 | in the |MacBinar|
|00000e90| 79 20 66 6f 72 6d 61 74 | 20 69 6e 73 74 65 61 64 |y format| instead|
|00000ea0| 20 6f 66 0a 74 68 72 65 | 65 20 73 65 70 61 72 61 | of.thre|e separa|
|00000eb0| 74 65 20 2e 64 61 74 61 | 2c 20 2e 69 6e 66 6f 2c |te .data|, .info,|
|00000ec0| 20 61 6e 64 20 2e 72 73 | 72 63 20 66 69 6c 65 73 | and .rs|rc files|
|00000ed0| 2e 20 20 49 74 20 63 61 | 75 73 65 73 20 74 68 65 |. It ca|uses the|
|00000ee0| 20 70 72 6f 67 72 61 6d | 0a 74 6f 20 73 6b 69 70 | program|.to skip|
|00000ef0| 20 74 68 65 20 31 32 38 | 20 62 79 74 65 20 4d 61 | the 128| byte Ma|
|00000f00| 63 42 69 6e 61 72 79 20 | 68 65 61 64 65 72 20 62 |cBinary |header b|
|00000f10| 65 66 6f 72 65 20 6c 6f | 6f 6b 69 6e 67 20 66 6f |efore lo|oking fo|
|00000f20| 72 20 74 68 65 20 53 74 | 75 66 66 49 74 0a 68 65 |r the St|uffIt.he|
|00000f30| 61 64 65 72 2e 0a 0a 56 | 65 72 73 69 6f 6e 20 31 |ader...V|ersion 1|
|00000f40| 2e 35 20 6f 66 20 74 68 | 65 20 75 6e 73 69 74 20 |.5 of th|e unsit |
|00000f50| 73 75 70 70 6f 72 74 73 | 20 65 78 74 72 61 63 74 |supports| extract|
|00000f60| 69 6e 67 20 66 69 6c 65 | 73 20 61 6e 64 20 66 6f |ing file|s and fo|
|00000f70| 6c 64 65 72 73 20 61 73 | 0a 69 6d 70 6c 65 6d 65 |lders as|.impleme|
|00000f80| 6e 74 65 64 20 62 79 20 | 53 74 75 66 66 49 74 20 |nted by |StuffIt |
|00000f90| 31 2e 35 27 73 20 22 48 | 69 65 72 61 72 63 68 79 |1.5's "H|ierarchy|
|00000fa0| 20 4d 61 69 6e 74 61 69 | 6e 65 64 20 46 6f 6c 64 | Maintai|ned Fold|
|00000fb0| 65 72 22 20 66 65 61 74 | 75 72 65 2e 0a 45 61 63 |er" feat|ure..Eac|
|00000fc0| 68 20 66 6f 6c 64 65 72 | 20 69 73 20 65 78 74 72 |h folder| is extr|
|00000fd0| 61 63 74 65 64 20 61 73 | 20 61 20 73 75 62 64 69 |acted as| a subdi|
|00000fe0| 72 65 63 74 6f 72 79 20 | 6f 6e 20 74 68 65 20 55 |rectory |on the U|
|00000ff0| 6e 69 78 20 73 79 73 74 | 65 6d 20 77 69 74 68 20 |nix syst|em with |
|00001000| 74 68 65 0a 66 69 6c 65 | 73 20 69 6e 20 74 68 65 |the.file|s in the|
|00001010| 20 66 6f 6c 64 65 72 20 | 70 6c 61 63 65 64 20 69 | folder |placed i|
|00001020| 6e 20 74 68 65 20 63 6f | 72 72 65 73 70 6f 6e 64 |n the co|rrespond|
|00001030| 69 6e 67 20 73 75 62 64 | 69 72 65 63 74 6f 72 79 |ing subd|irectory|
|00001040| 2e 20 20 54 68 65 20 2d | 66 0a 6f 70 74 69 6f 6e |. The -|f.option|
|00001050| 20 63 61 6e 20 62 65 20 | 75 73 65 64 20 74 6f 20 | can be |used to |
|00001060| 22 66 6c 61 74 74 65 6e | 22 20 6f 75 74 20 74 68 |"flatten|" out th|
|00001070| 65 20 68 69 65 72 61 72 | 63 68 79 20 61 6e 64 20 |e hierar|chy and |
|00001080| 75 6e 73 69 74 20 77 69 | 6c 6c 20 73 74 6f 72 65 |unsit wi|ll store|
|00001090| 0a 61 6c 6c 20 74 68 65 | 20 66 69 6c 65 73 20 69 |.all the| files i|
|000010a0| 6e 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 64 69 |n the cu|rrent di|
|000010b0| 72 65 63 74 6f 72 79 2e | 20 20 49 66 20 74 68 65 |rectory.| If the|
|000010c0| 20 71 75 65 72 79 20 6f | 70 74 69 6f 6e 20 28 2d | query o|ption (-|
|000010d0| 71 29 20 69 73 0a 75 73 | 65 64 20 61 6e 64 20 61 |q) is.us|ed and a|
|000010e0| 20 22 6e 22 20 72 65 73 | 70 6f 6e 73 65 20 69 73 | "n" res|ponse is|
|000010f0| 20 67 69 76 65 6e 20 74 | 6f 20 61 20 66 6f 6c 64 | given t|o a fold|
|00001100| 65 72 20 6e 61 6d 65 2c | 20 6e 6f 6e 65 20 6f 66 |er name,| none of|
|00001110| 20 74 68 65 20 66 69 6c | 65 73 0a 6f 72 20 66 6f | the fil|es.or fo|
|00001120| 6c 64 65 72 73 20 69 6e | 20 74 68 61 74 20 66 6f |lders in| that fo|
|00001130| 6c 64 65 72 20 77 69 6c | 6c 20 62 65 20 65 78 74 |lder wil|l be ext|
|00001140| 72 61 63 65 64 2e 0a 0a | 53 6f 6d 65 20 6f 66 20 |raced...|Some of |
|00001150| 74 68 65 20 70 72 6f 67 | 72 61 6d 20 69 73 20 62 |the prog|ram is b|
|00001160| 6f 72 72 6f 77 65 64 20 | 66 72 6f 6d 20 74 68 65 |orrowed |from the|
|00001170| 20 6d 61 63 70 75 74 2e | 63 2f 6d 61 63 67 65 74 | macput.|c/macget|
|00001180| 2e 63 20 70 72 6f 67 72 | 61 6d 73 2e 0a 4d 61 6e |.c progr|ams..Man|
|00001190| 79 2c 20 6d 61 6e 79 20 | 74 68 61 6e 6b 73 20 74 |y, many |thanks t|
|000011a0| 6f 20 52 61 79 6d 6f 6e | 64 20 4c 61 75 2c 20 74 |o Raymon|d Lau, t|
|000011b0| 68 65 20 61 75 74 68 6f | 72 20 6f 66 20 53 74 75 |he autho|r of Stu|
|000011c0| 66 66 49 74 2c 20 66 6f | 72 20 69 6e 63 6c 75 64 |ffIt, fo|r includ|
|000011d0| 69 6e 67 0a 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ing.info|rmation |
|000011e0| 6f 6e 20 74 68 65 20 66 | 6f 72 6d 61 74 20 6f 66 |on the f|ormat of|
|000011f0| 20 74 68 65 20 53 74 75 | 66 66 49 74 20 61 72 63 | the Stu|ffIt arc|
|00001200| 68 69 76 65 73 20 69 6e | 20 74 68 65 0a 64 6f 63 |hives in| the.doc|
|00001210| 75 6d 65 6e 74 61 74 69 | 6f 6e 2e 20 20 53 65 76 |umentati|on. Sev|
|00001220| 65 72 61 6c 20 63 68 61 | 6e 67 65 73 20 61 6e 64 |eral cha|nges and|
|00001230| 20 65 6e 68 61 6e 63 65 | 6d 65 6e 74 73 20 73 75 | enhance|ments su|
|00001240| 70 70 6c 69 65 64 20 62 | 79 20 44 61 76 69 64 0a |pplied b|y David.|
|00001250| 53 68 61 6e 6b 73 20 28 | 63 64 65 40 61 74 65 6c |Shanks (|cde@atel|
|00001260| 61 62 73 2e 55 55 43 50 | 29 20 68 61 76 65 20 62 |abs.UUCP|) have b|
|00001270| 65 65 6e 20 69 6e 63 6f | 72 70 6f 72 61 74 65 64 |een inco|rporated|
|00001280| 20 69 6e 74 6f 20 74 68 | 65 20 70 72 6f 67 72 61 | into th|e progra|
|00001290| 6d 20 66 6f 72 0a 64 6f | 69 6e 67 20 74 68 69 6e |m for.do|ing thin|
|000012a0| 67 73 20 6c 69 6b 65 20 | 73 75 70 70 6f 72 74 69 |gs like |supporti|
|000012b0| 6e 67 20 53 79 73 74 65 | 6d 20 56 20 61 6e 64 20 |ng Syste|m V and |
|000012c0| 72 65 63 6f 67 6e 69 7a | 69 6e 67 20 4d 61 63 42 |recogniz|ing MacB|
|000012d0| 69 6e 61 72 79 20 66 69 | 6c 65 73 2e 0a 49 27 6d |inary fi|les..I'm|
|000012e0| 20 61 6c 77 61 79 73 20 | 67 6c 61 64 20 74 6f 20 | always |glad to |
|000012f0| 72 65 63 65 69 76 65 20 | 61 64 76 69 63 65 2c 20 |receive |advice, |
|00001300| 73 75 67 67 65 73 74 69 | 6f 6e 73 2c 20 6f 72 20 |suggesti|ons, or |
|00001310| 63 6f 6d 6d 65 6e 74 73 | 20 61 62 6f 75 74 20 74 |comments| about t|
|00001320| 68 65 0a 70 72 6f 67 72 | 61 6d 20 73 6f 20 66 65 |he.progr|am so fe|
|00001330| 65 6c 20 66 72 65 65 20 | 74 6f 20 73 65 6e 64 20 |el free |to send |
|00001340| 77 68 61 74 65 76 65 72 | 20 79 6f 75 20 74 68 69 |whatever| you thi|
|00001350| 6e 6b 20 77 6f 75 6c 64 | 20 62 65 20 68 65 6c 70 |nk would| be help|
|00001360| 66 75 6c 0a 0a 0a 09 41 | 75 74 68 6f 72 3a 20 41 |ful....A|uthor: A|
|00001370| 6c 6c 61 6e 20 47 2e 20 | 57 65 62 65 72 0a 09 09 |llan G. |Weber...|
|00001380| 77 65 62 65 72 25 62 72 | 61 6e 64 2e 75 73 63 2e |weber%br|and.usc.|
|00001390| 65 64 75 40 6f 62 65 72 | 6f 6e 2e 75 73 63 2e 65 |edu@ober|on.usc.e|
|000013a0| 64 75 0a 09 09 2e 2e 2e | 73 64 63 72 64 63 66 21 |du......|sdcrdcf!|
|000013b0| 75 73 63 2d 6f 62 65 72 | 6f 6e 21 62 72 61 6e 64 |usc-ober|on!brand|
|000013c0| 21 77 65 62 65 72 0a 09 | 44 61 74 65 3a 20 20 20 |!weber..|Date: |
|000013d0| 41 70 72 69 6c 20 33 2c | 20 31 39 38 39 0a 0a 2a |April 3,| 1989..*|
|000013e0| 2f 0a 0a 23 69 6e 63 6c | 75 64 65 20 3c 73 74 64 |/..#incl|ude <std|
|000013f0| 69 6f 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |io.h>.#i|nclude <|
|00001400| 73 79 73 2f 74 79 70 65 | 73 2e 68 3e 0a 23 69 6e |sys/type|s.h>.#in|
|00001410| 63 6c 75 64 65 20 3c 73 | 79 73 2f 73 74 61 74 2e |clude <s|ys/stat.|
|00001420| 68 3e 0a 0a 74 79 70 65 | 64 65 66 20 6c 6f 6e 67 |h>..type|def long|
|00001430| 20 4f 53 54 79 70 65 3b | 0a 0a 23 69 6e 63 6c 75 | OSType;|..#inclu|
|00001440| 64 65 20 22 73 74 75 66 | 66 69 74 2e 68 22 0a 0a |de "stuf|fit.h"..|
|00001450| 2f 2a 0a 20 2a 20 44 65 | 66 69 6e 65 20 74 68 65 |/*. * De|fine the|
|00001460| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 69 66 20 79 6f | followi|ng if yo|
|00001470| 75 72 20 55 6e 69 78 20 | 63 61 6e 20 6f 6e 6c 79 |ur Unix |can only|
|00001480| 20 68 61 6e 64 6c 65 20 | 31 34 20 63 68 61 72 61 | handle |14 chara|
|00001490| 63 74 65 72 20 66 69 6c | 65 20 6e 61 6d 65 73 0a |cter fil|e names.|
|000014a0| 20 2a 20 28 65 2e 67 2e | 20 56 65 72 73 69 6f 6e | * (e.g.| Version|
|000014b0| 20 37 20 61 6e 64 20 53 | 79 73 74 65 6d 20 56 29 | 7 and S|ystem V)|
|000014c0| 2e 0a 20 2a 2f 0a 2f 2a | 20 23 64 65 66 69 6e 65 |.. */./*| #define|
|000014d0| 20 53 48 4f 52 54 4e 41 | 4d 45 53 20 2a 2f 0a 0a | SHORTNA|MES */..|
|000014e0| 2f 2a 0a 20 2a 20 54 68 | 65 20 66 6f 6c 6c 6f 77 |/*. * Th|e follow|
|000014f0| 69 6e 67 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 |ing defi|nes the |
|00001500| 6e 61 6d 65 20 6f 66 20 | 74 68 65 20 63 6f 6d 70 |name of |the comp|
|00001510| 72 65 73 73 20 70 72 6f | 67 72 61 6d 20 74 68 61 |ress pro|gram tha|
|00001520| 74 20 69 73 20 75 73 65 | 64 20 66 6f 72 20 74 68 |t is use|d for th|
|00001530| 65 0a 20 2a 20 75 6e 63 | 6f 6d 70 72 65 73 73 69 |e. * unc|ompressi|
|00001540| 6f 6e 20 6f 66 20 4c 65 | 6d 70 65 6c 2d 5a 69 76 |on of Le|mpel-Ziv|
|00001550| 20 63 6f 6d 70 72 65 73 | 73 65 64 20 66 69 6c 65 | compres|sed file|
|00001560| 73 2e 20 20 49 66 20 74 | 68 65 20 70 61 74 68 20 |s. If t|he path |
|00001570| 69 73 20 73 65 74 20 75 | 70 20 74 6f 0a 20 2a 20 |is set u|p to. * |
|00001580| 69 6e 63 6c 75 64 65 20 | 74 68 65 20 72 69 67 68 |include |the righ|
|00001590| 74 20 64 69 72 65 63 74 | 6f 72 79 2c 20 74 68 69 |t direct|ory, thi|
|000015a0| 73 20 73 68 6f 75 6c 64 | 20 77 6f 72 6b 2e 0a 20 |s should| work.. |
|000015b0| 2a 2f 0a 23 64 65 66 69 | 6e 65 20 43 4f 4d 50 52 |*/.#defi|ne COMPR|
|000015c0| 45 53 53 20 20 20 22 63 | 6f 6d 70 72 65 73 73 22 |ESS "c|ompress"|
|000015d0| 0a 0a 23 64 65 66 69 6e | 65 20 49 4f 42 55 46 53 |..#defin|e IOBUFS|
|000015e0| 49 5a 20 20 20 34 30 39 | 36 0a 0a 23 64 65 66 69 |IZ 409|6..#defi|
|000015f0| 6e 65 20 4d 41 43 42 49 | 4e 48 44 52 53 49 5a 45 |ne MACBI|NHDRSIZE|
|00001600| 20 20 31 32 38 4c 0a 0a | 23 64 65 66 69 6e 65 20 | 128L..|#define |
|00001610| 49 4e 49 54 5f 43 52 43 | 20 30 4c 0a 65 78 74 65 |INIT_CRC| 0L.exte|
|00001620| 72 6e 20 75 6e 73 69 67 | 6e 65 64 20 73 68 6f 72 |rn unsig|ned shor|
|00001630| 74 20 75 70 64 63 72 63 | 28 29 3b 0a 0a 23 64 65 |t updcrc|();..#de|
|00001640| 66 69 6e 65 20 49 4e 46 | 4f 42 59 54 45 53 20 31 |fine INF|OBYTES 1|
|00001650| 32 38 0a 0a 23 64 65 66 | 69 6e 65 20 42 59 54 45 |28..#def|ine BYTE|
|00001660| 4d 41 53 4b 20 30 78 66 | 66 0a 0a 23 64 65 66 69 |MASK 0xf|f..#defi|
|00001670| 6e 65 20 53 5f 53 49 47 | 4e 41 54 55 52 45 20 20 |ne S_SIG|NATURE |
|00001680| 20 20 30 0a 23 64 65 66 | 69 6e 65 20 53 5f 4e 55 | 0.#def|ine S_NU|
|00001690| 4d 46 49 4c 45 53 20 20 | 20 20 20 34 0a 23 64 65 |MFILES | 4.#de|
|000016a0| 66 69 6e 65 20 53 5f 41 | 52 43 4c 45 4e 47 54 48 |fine S_A|RCLENGTH|
|000016b0| 20 20 20 20 36 0a 23 64 | 65 66 69 6e 65 20 53 5f | 6.#d|efine S_|
|000016c0| 53 49 47 4e 41 54 55 52 | 45 32 20 20 31 30 0a 23 |SIGNATUR|E2 10.#|
|000016d0| 64 65 66 69 6e 65 09 53 | 5f 56 45 52 53 49 4f 4e |define.S|_VERSION|
|000016e0| 20 20 20 20 20 31 34 0a | 23 64 65 66 69 6e 65 20 | 14.|#define |
|000016f0| 53 49 54 48 44 52 53 49 | 5a 45 20 20 20 20 32 32 |SITHDRSI|ZE 22|
|00001700| 0a 0a 23 64 65 66 69 6e | 65 20 46 5f 43 4f 4d 50 |..#defin|e F_COMP|
|00001710| 52 4d 45 54 48 4f 44 20 | 20 20 20 30 0a 23 64 65 |RMETHOD | 0.#de|
|00001720| 66 69 6e 65 20 46 5f 43 | 4f 4d 50 44 4d 45 54 48 |fine F_C|OMPDMETH|
|00001730| 4f 44 20 20 20 20 31 0a | 23 64 65 66 69 6e 65 20 |OD 1.|#define |
|00001740| 46 5f 46 4e 41 4d 45 20 | 20 20 20 20 20 20 20 20 |F_FNAME | |
|00001750| 20 32 0a 23 64 65 66 69 | 6e 65 20 46 5f 46 54 59 | 2.#defi|ne F_FTY|
|00001760| 50 45 20 20 20 20 20 20 | 20 20 20 36 36 0a 23 64 |PE | 66.#d|
|00001770| 65 66 69 6e 65 20 46 5f | 43 52 45 41 54 4f 52 20 |efine F_|CREATOR |
|00001780| 20 20 20 20 20 20 37 30 | 0a 23 64 65 66 69 6e 65 | 70|.#define|
|00001790| 20 46 5f 46 4e 44 52 46 | 4c 41 47 53 20 20 20 20 | F_FNDRF|LAGS |
|000017a0| 20 37 34 0a 23 64 65 66 | 69 6e 65 20 46 5f 43 52 | 74.#def|ine F_CR|
|000017b0| 45 41 54 49 4f 4e 44 41 | 54 45 20 20 37 36 0a 23 |EATIONDA|TE 76.#|
|000017c0| 64 65 66 69 6e 65 20 46 | 5f 4d 4f 44 44 41 54 45 |define F|_MODDATE|
|000017d0| 20 20 20 20 20 20 20 38 | 30 0a 23 64 65 66 69 6e | 8|0.#defin|
|000017e0| 65 20 46 5f 52 53 52 43 | 4c 45 4e 47 54 48 20 20 |e F_RSRC|LENGTH |
|000017f0| 20 20 38 34 0a 23 64 65 | 66 69 6e 65 20 46 5f 44 | 84.#de|fine F_D|
|00001800| 41 54 41 4c 45 4e 47 54 | 48 20 20 20 20 38 38 0a |ATALENGT|H 88.|
|00001810| 23 64 65 66 69 6e 65 20 | 46 5f 43 4f 4d 50 52 4c |#define |F_COMPRL|
|00001820| 45 4e 47 54 48 20 20 20 | 39 32 0a 23 64 65 66 69 |ENGTH |92.#defi|
|00001830| 6e 65 20 46 5f 43 4f 4d | 50 44 4c 45 4e 47 54 48 |ne F_COM|PDLENGTH|
|00001840| 20 20 20 39 36 0a 23 64 | 65 66 69 6e 65 20 46 5f | 96.#d|efine F_|
|00001850| 52 53 52 43 43 52 43 20 | 20 20 20 20 20 31 30 30 |RSRCCRC | 100|
|00001860| 0a 23 64 65 66 69 6e 65 | 20 46 5f 44 41 54 41 43 |.#define| F_DATAC|
|00001870| 52 43 20 20 20 20 20 20 | 31 30 32 0a 23 64 65 66 |RC |102.#def|
|00001880| 69 6e 65 20 46 5f 48 44 | 52 43 52 43 20 20 20 20 |ine F_HD|RCRC |
|00001890| 20 20 20 31 31 30 0a 23 | 64 65 66 69 6e 65 20 46 | 110.#|define F|
|000018a0| 49 4c 45 48 44 52 53 49 | 5a 45 20 20 20 20 31 31 |ILEHDRSI|ZE 11|
|000018b0| 32 0a 0a 23 64 65 66 69 | 6e 65 20 46 5f 4e 41 4d |2..#defi|ne F_NAM|
|000018c0| 45 4c 45 4e 20 36 33 0a | 23 69 66 64 65 66 20 53 |ELEN 63.|#ifdef S|
|000018d0| 48 4f 52 54 4e 41 4d 45 | 53 09 09 2f 2a 20 73 68 |HORTNAME|S../* sh|
|000018e0| 6f 72 74 20 66 69 6c 65 | 20 6e 61 6d 65 73 20 2a |ort file| names *|
|000018f0| 2f 0a 23 20 64 65 66 69 | 6e 65 20 49 5f 4e 41 4d |/.# defi|ne I_NAM|
|00001900| 45 4c 45 4e 20 31 35 09 | 09 2f 2a 20 31 34 20 63 |ELEN 15.|./* 14 c|
|00001910| 68 61 72 20 66 69 6c 65 | 20 6e 61 6d 65 73 20 2b |har file| names +|
|00001920| 20 27 5c 30 27 20 74 65 | 72 6d 69 6e 61 74 6f 72 | '\0' te|rminator|
|00001930| 20 2a 2f 0a 23 65 6c 73 | 65 0a 23 20 64 65 66 69 | */.#els|e.# defi|
|00001940| 6e 65 20 49 5f 4e 41 4d | 45 4c 45 4e 20 36 39 09 |ne I_NAM|ELEN 69.|
|00001950| 09 2f 2a 20 36 33 20 2b | 20 73 74 72 6c 65 6e 28 |./* 63 +| strlen(|
|00001960| 22 2e 69 6e 66 6f 22 29 | 20 2b 20 31 20 2a 2f 0a |".info")| + 1 */.|
|00001970| 23 65 6e 64 69 66 0a 0a | 2f 2a 20 54 68 65 20 66 |#endif..|/* The f|
|00001980| 6f 6c 6c 6f 77 69 6e 67 | 20 61 72 65 20 63 6f 70 |ollowing| are cop|
|00001990| 69 65 64 20 6f 75 74 20 | 6f 66 20 6d 61 63 70 75 |ied out |of macpu|
|000019a0| 74 2e 63 2f 6d 61 63 67 | 65 74 2e 63 20 2a 2f 0a |t.c/macg|et.c */.|
|000019b0| 23 64 65 66 69 6e 65 20 | 49 5f 4e 41 4d 45 4f 46 |#define |I_NAMEOF|
|000019c0| 46 20 31 0a 2f 2a 20 36 | 35 20 3c 2d 3e 20 38 30 |F 1./* 6|5 <-> 80|
|000019d0| 20 69 73 20 74 68 65 20 | 46 49 6e 66 6f 20 73 74 | is the |FInfo st|
|000019e0| 72 75 63 74 75 72 65 20 | 2a 2f 0a 23 64 65 66 69 |ructure |*/.#defi|
|000019f0| 6e 65 20 49 5f 54 59 50 | 45 4f 46 46 20 36 35 0a |ne I_TYP|EOFF 65.|
|00001a00| 23 64 65 66 69 6e 65 20 | 49 5f 41 55 54 48 4f 46 |#define |I_AUTHOF|
|00001a10| 46 20 36 39 0a 23 64 65 | 66 69 6e 65 20 49 5f 46 |F 69.#de|fine I_F|
|00001a20| 4c 41 47 4f 46 46 20 37 | 33 0a 23 64 65 66 69 6e |LAGOFF 7|3.#defin|
|00001a30| 65 20 49 5f 4c 4f 43 4b | 4f 46 46 20 38 31 0a 23 |e I_LOCK|OFF 81.#|
|00001a40| 64 65 66 69 6e 65 20 49 | 5f 44 4c 45 4e 4f 46 46 |define I|_DLENOFF|
|00001a50| 20 38 33 0a 23 64 65 66 | 69 6e 65 20 49 5f 52 4c | 83.#def|ine I_RL|
|00001a60| 45 4e 4f 46 46 20 38 37 | 0a 23 64 65 66 69 6e 65 |ENOFF 87|.#define|
|00001a70| 20 49 5f 43 54 49 4d 4f | 46 46 20 39 31 0a 23 64 | I_CTIMO|FF 91.#d|
|00001a80| 65 66 69 6e 65 20 49 5f | 4d 54 49 4d 4f 46 46 20 |efine I_|MTIMOFF |
|00001a90| 39 35 0a 0a 23 64 65 66 | 69 6e 65 20 49 4e 49 54 |95..#def|ine INIT|
|00001aa0| 45 44 5f 42 55 47 0a 23 | 64 65 66 69 6e 65 20 49 |ED_BUG.#|define I|
|00001ab0| 4e 49 54 45 44 5f 4f 46 | 46 09 49 5f 46 4c 41 47 |NITED_OF|F.I_FLAG|
|00001ac0| 4f 46 46 09 2f 2a 20 6f | 66 66 73 65 74 20 74 6f |OFF./* o|ffset to|
|00001ad0| 20 62 79 74 65 20 77 69 | 74 68 20 49 6e 69 74 65 | byte wi|th Inite|
|00001ae0| 64 20 66 6c 61 67 20 2a | 2f 0a 23 64 65 66 69 6e |d flag *|/.#defin|
|00001af0| 65 20 49 4e 49 54 45 44 | 5f 4d 41 53 4b 09 28 7e |e INITED|_MASK.(~|
|00001b00| 31 29 09 09 2f 2a 20 6d | 61 73 6b 20 74 6f 20 27 |1)../* m|ask to '|
|00001b10| 26 27 20 77 69 74 68 20 | 62 79 74 65 20 74 6f 20 |&' with |byte to |
|00001b20| 72 65 73 65 74 20 69 74 | 20 2a 2f 0a 0a 23 64 65 |reset it| */..#de|
|00001b30| 66 69 6e 65 20 54 45 58 | 54 20 30 0a 23 64 65 66 |fine TEX|T 0.#def|
|00001b40| 69 6e 65 20 44 41 54 41 | 20 31 0a 23 64 65 66 69 |ine DATA| 1.#defi|
|00001b50| 6e 65 20 52 53 52 43 20 | 32 0a 23 64 65 66 69 6e |ne RSRC |2.#defin|
|00001b60| 65 20 46 55 4c 4c 20 33 | 0a 23 64 65 66 69 6e 65 |e FULL 3|.#define|
|00001b70| 20 44 55 4d 50 20 34 0a | 0a 23 64 65 66 69 6e 65 | DUMP 4.|.#define|
|00001b80| 20 4e 4f 44 45 43 4f 44 | 45 20 30 0a 23 64 65 66 | NODECOD|E 0.#def|
|00001b90| 69 6e 65 20 44 45 43 4f | 44 45 20 20 20 31 0a 0a |ine DECO|DE 1..|
|00001ba0| 23 64 65 66 69 6e 65 20 | 48 5f 45 52 52 4f 52 20 |#define |H_ERROR |
|00001bb0| 2d 31 0a 23 64 65 66 69 | 6e 65 20 48 5f 45 4f 46 |-1.#defi|ne H_EOF|
|00001bc0| 20 20 20 20 30 0a 23 64 | 65 66 69 6e 65 20 48 5f | 0.#d|efine H_|
|00001bd0| 57 52 49 54 45 20 20 31 | 0a 23 64 65 66 69 6e 65 |WRITE 1|.#define|
|00001be0| 20 48 5f 53 4b 49 50 20 | 20 20 32 0a 0a 73 74 72 | H_SKIP | 2..str|
|00001bf0| 75 63 74 20 6e 6f 64 65 | 20 7b 0a 09 69 6e 74 20 |uct node| {..int |
|00001c00| 66 6c 61 67 2c 20 62 79 | 74 65 3b 0a 09 73 74 72 |flag, by|te;..str|
|00001c10| 75 63 74 20 6e 6f 64 65 | 20 2a 6f 6e 65 2c 20 2a |uct node| *one, *|
|00001c20| 7a 65 72 6f 3b 0a 7d 20 | 6e 6f 64 65 6c 69 73 74 |zero;.} |nodelist|
|00001c30| 5b 35 31 32 5d 2c 20 2a | 6e 6f 64 65 70 74 72 2c |[512], *|nodeptr,|
|00001c40| 20 2a 72 65 61 64 5f 74 | 72 65 65 28 29 3b 09 2f | *read_t|ree();./|
|00001c50| 2a 20 35 31 32 20 73 68 | 6f 75 6c 64 20 62 65 20 |* 512 sh|ould be |
|00001c60| 62 69 67 20 65 6e 6f 75 | 67 68 20 2a 2f 0a 0a 73 |big enou|gh */..s|
|00001c70| 74 72 75 63 74 20 73 69 | 74 48 64 72 20 73 69 74 |truct si|tHdr sit|
|00001c80| 68 64 72 3b 0a 0a 63 68 | 61 72 20 66 5f 69 6e 66 |hdr;..ch|ar f_inf|
|00001c90| 6f 5b 49 5f 4e 41 4d 45 | 4c 45 4e 5d 3b 0a 63 68 |o[I_NAME|LEN];.ch|
|00001ca0| 61 72 20 66 5f 64 61 74 | 61 5b 49 5f 4e 41 4d 45 |ar f_dat|a[I_NAME|
|00001cb0| 4c 45 4e 5d 3b 0a 63 68 | 61 72 20 66 5f 72 73 72 |LEN];.ch|ar f_rsr|
|00001cc0| 63 5b 49 5f 4e 41 4d 45 | 4c 45 4e 5d 3b 0a 0a 63 |c[I_NAME|LEN];..c|
|00001cd0| 68 61 72 20 69 6e 66 6f | 5b 49 4e 46 4f 42 59 54 |har info|[INFOBYT|
|00001ce0| 45 53 5d 3b 0a 63 68 61 | 72 20 6d 6e 61 6d 65 5b |ES];.cha|r mname[|
|00001cf0| 46 5f 4e 41 4d 45 4c 45 | 4e 2b 31 5d 3b 0a 63 68 |F_NAMELE|N+1];.ch|
|00001d00| 61 72 20 75 6e 61 6d 65 | 5b 46 5f 4e 41 4d 45 4c |ar uname|[F_NAMEL|
|00001d10| 45 4e 2b 31 5d 3b 0a 63 | 68 61 72 20 69 6f 62 75 |EN+1];.c|har iobu|
|00001d20| 66 5b 49 4f 42 55 46 53 | 49 5a 5d 3b 0a 0a 69 6e |f[IOBUFS|IZ];..in|
|00001d30| 74 20 6d 6f 64 65 2c 20 | 74 78 74 6d 6f 64 65 2c |t mode, |txtmode,|
|00001d40| 20 6c 69 73 74 6f 6e 6c | 79 2c 20 76 65 72 62 6f | listonl|y, verbo|
|00001d50| 73 65 2c 20 71 75 65 72 | 79 2c 20 66 6c 61 74 74 |se, quer|y, flatt|
|00001d60| 65 6e 3b 0a 69 6e 74 20 | 62 69 74 2c 20 63 68 6b |en;.int |bit, chk|
|00001d70| 63 72 63 2c 20 6e 75 6d | 66 69 6c 65 73 2c 20 64 |crc, num|files, d|
|00001d80| 65 70 74 68 3b 0a 46 49 | 4c 45 20 2a 69 6e 66 70 |epth;.FI|LE *infp|
|00001d90| 3b 0a 0a 6c 6f 6e 67 20 | 67 65 74 34 28 29 3b 0a |;..long |get4();.|
|00001da0| 73 68 6f 72 74 20 67 65 | 74 32 28 29 3b 0a 75 6e |short ge|t2();.un|
|00001db0| 73 69 67 6e 65 64 20 73 | 68 6f 72 74 20 77 72 69 |signed s|hort wri|
|00001dc0| 74 65 5f 66 69 6c 65 28 | 29 3b 0a 0a 6d 61 69 6e |te_file(|);..main|
|00001dd0| 28 61 72 67 63 2c 20 61 | 72 67 76 29 0a 69 6e 74 |(argc, a|rgv).int|
|00001de0| 20 61 72 67 63 3b 0a 63 | 68 61 72 20 2a 61 72 67 | argc;.c|har *arg|
|00001df0| 76 5b 5d 3b 0a 7b 0a 20 | 20 20 20 69 6e 74 20 73 |v[];.{. | int s|
|00001e00| 74 61 74 75 73 3b 0a 20 | 20 20 20 69 6e 74 20 63 |tatus;. | int c|
|00001e10| 3b 0a 20 20 20 20 65 78 | 74 65 72 6e 20 69 6e 74 |;. ex|tern int|
|00001e20| 20 6f 70 74 69 6e 64 3b | 0a 20 20 20 20 65 78 74 | optind;|. ext|
|00001e30| 65 72 6e 20 63 68 61 72 | 20 2a 6f 70 74 61 72 67 |ern char| *optarg|
|00001e40| 3b 0a 20 20 20 20 69 6e | 74 20 65 72 72 66 6c 67 |;. in|t errflg|
|00001e50| 3b 0a 20 20 20 20 69 6e | 74 20 6d 61 63 62 69 6e |;. in|t macbin|
|00001e60| 3b 0a 0a 20 20 20 20 6d | 6f 64 65 20 3d 20 46 55 |;.. m|ode = FU|
|00001e70| 4c 4c 3b 0a 20 20 20 20 | 65 72 72 66 6c 67 20 3d |LL;. |errflg =|
|00001e80| 20 30 3b 0a 20 20 20 20 | 6d 61 63 62 69 6e 20 3d | 0;. |macbin =|
|00001e90| 20 30 3b 0a 20 20 20 20 | 66 6c 61 74 74 65 6e 20 | 0;. |flatten |
|00001ea0| 3d 20 30 3b 0a 20 20 20 | 20 6e 75 6d 66 69 6c 65 |= 0;. | numfile|
|00001eb0| 73 20 3d 20 30 3b 0a 20 | 20 20 20 64 65 70 74 68 |s = 0;. | depth|
|00001ec0| 20 3d 20 30 3b 0a 0a 20 | 20 20 20 77 68 69 6c 65 | = 0;.. | while|
|00001ed0| 20 28 28 63 20 3d 20 67 | 65 74 6f 70 74 28 61 72 | ((c = g|etopt(ar|
|00001ee0| 67 63 2c 20 61 72 67 76 | 2c 20 22 64 66 6c 6d 71 |gc, argv|, "dflmq|
|00001ef0| 72 75 76 78 22 29 29 20 | 21 3d 20 45 4f 46 29 0a |ruvx")) |!= EOF).|
|00001f00| 09 73 77 69 74 63 68 20 | 28 63 29 20 7b 0a 09 20 |.switch |(c) {.. |
|00001f10| 20 63 61 73 65 20 27 72 | 27 3a 0a 09 20 20 20 20 | case 'r|':.. |
|00001f20| 6d 6f 64 65 20 3d 20 52 | 53 52 43 3b 0a 09 20 20 |mode = R|SRC;.. |
|00001f30| 20 20 62 72 65 61 6b 3b | 0a 09 20 20 63 61 73 65 | break;|.. case|
|00001f40| 20 27 64 27 3a 0a 09 20 | 20 20 20 6d 6f 64 65 20 | 'd':.. | mode |
|00001f50| 3d 20 44 41 54 41 3b 0a | 09 20 20 20 20 62 72 65 |= DATA;.|. bre|
|00001f60| 61 6b 3b 0a 09 20 20 63 | 61 73 65 20 27 75 27 3a |ak;.. c|ase 'u':|
|00001f70| 0a 09 20 20 20 20 6d 6f | 64 65 20 3d 20 54 45 58 |.. mo|de = TEX|
|00001f80| 54 3b 0a 09 20 20 20 20 | 62 72 65 61 6b 3b 0a 09 |T;.. |break;..|
|00001f90| 20 20 63 61 73 65 20 27 | 6c 27 3a 0a 09 20 20 20 | case '|l':.. |
|00001fa0| 20 6c 69 73 74 6f 6e 6c | 79 2b 2b 3b 0a 09 20 20 | listonl|y++;.. |
|00001fb0| 20 20 62 72 65 61 6b 3b | 0a 09 20 20 63 61 73 65 | break;|.. case|
|00001fc0| 20 27 71 27 3a 0a 09 20 | 20 20 20 71 75 65 72 79 | 'q':.. | query|
|00001fd0| 2b 2b 3b 0a 09 20 20 20 | 20 62 72 65 61 6b 3b 0a |++;.. | break;.|
|00001fe0| 09 20 20 63 61 73 65 20 | 27 76 27 3a 0a 09 20 20 |. case |'v':.. |
|00001ff0| 20 20 76 65 72 62 6f 73 | 65 2b 2b 3b 0a 09 20 20 | verbos|e++;.. |
|00002000| 20 20 62 72 65 61 6b 3b | 0a 09 20 20 63 61 73 65 | break;|.. case|
|00002010| 20 27 78 27 3a 0a 09 20 | 20 20 20 6d 6f 64 65 20 | 'x':.. | mode |
|00002020| 3d 20 44 55 4d 50 3b 0a | 09 20 20 20 20 62 72 65 |= DUMP;.|. bre|
|00002030| 61 6b 3b 0a 09 20 20 63 | 61 73 65 20 27 6d 27 3a |ak;.. c|ase 'm':|
|00002040| 0a 09 20 20 20 20 6d 61 | 63 62 69 6e 20 3d 20 31 |.. ma|cbin = 1|
|00002050| 3b 0a 09 20 20 20 20 62 | 72 65 61 6b 3b 0a 09 20 |;.. b|reak;.. |
|00002060| 20 63 61 73 65 20 27 66 | 27 3a 0a 09 20 20 20 20 | case 'f|':.. |
|00002070| 66 6c 61 74 74 65 6e 20 | 3d 20 31 3b 0a 09 20 20 |flatten |= 1;.. |
|00002080| 20 20 62 72 65 61 6b 3b | 0a 09 20 20 63 61 73 65 | break;|.. case|
|00002090| 20 27 3f 27 3a 0a 09 20 | 20 20 20 65 72 72 66 6c | '?':.. | errfl|
|000020a0| 67 2b 2b 3b 0a 09 20 20 | 20 20 62 72 65 61 6b 3b |g++;.. | break;|
|000020b0| 0a 09 7d 0a 20 20 20 20 | 69 66 20 28 65 72 72 66 |..}. |if (errf|
|000020c0| 6c 67 29 20 7b 0a 09 75 | 73 61 67 65 28 29 3b 0a |lg) {..u|sage();.|
|000020d0| 09 65 78 69 74 28 31 29 | 3b 0a 20 20 20 20 7d 0a |.exit(1)|;. }.|
|000020e0| 0a 20 20 20 20 69 66 20 | 28 6f 70 74 69 6e 64 20 |. if |(optind |
|000020f0| 3d 3d 20 61 72 67 63 29 | 20 7b 0a 09 75 73 61 67 |== argc)| {..usag|
|00002100| 65 28 29 3b 0a 09 65 78 | 69 74 28 31 29 3b 0a 20 |e();..ex|it(1);. |
|00002110| 20 20 20 7d 0a 20 20 20 | 20 65 6c 73 65 20 7b 0a | }. | else {.|
|00002120| 09 69 66 20 28 28 69 6e | 66 70 20 3d 20 66 6f 70 |.if ((in|fp = fop|
|00002130| 65 6e 28 61 72 67 76 5b | 6f 70 74 69 6e 64 5d 2c |en(argv[|optind],|
|00002140| 20 22 72 22 29 29 20 3d | 3d 20 4e 55 4c 4c 29 20 | "r")) =|= NULL) |
|00002150| 7b 0a 09 20 20 20 20 66 | 70 72 69 6e 74 66 28 73 |{.. f|printf(s|
|00002160| 74 64 65 72 72 2c 22 43 | 61 6e 27 74 20 6f 70 65 |tderr,"C|an't ope|
|00002170| 6e 20 69 6e 70 75 74 20 | 66 69 6c 65 20 5c 22 25 |n input |file \"%|
|00002180| 73 5c 22 5c 6e 22 2c 61 | 72 67 76 5b 6f 70 74 69 |s\"\n",a|rgv[opti|
|00002190| 6e 64 5d 29 3b 0a 09 20 | 20 20 20 65 78 69 74 28 |nd]);.. | exit(|
|000021a0| 31 29 3b 0a 09 7d 0a 20 | 20 20 20 7d 0a 0a 20 20 |1);..}. | }.. |
|000021b0| 20 20 69 66 20 28 6d 61 | 63 62 69 6e 29 20 7b 0a | if (ma|cbin) {.|
|000021c0| 09 69 66 20 28 66 73 65 | 65 6b 28 69 6e 66 70 2c |.if (fse|ek(infp,|
|000021d0| 20 4d 41 43 42 49 4e 48 | 44 52 53 49 5a 45 2c 20 | MACBINH|DRSIZE, |
|000021e0| 30 29 20 3d 3d 20 2d 31 | 29 20 7b 0a 09 20 20 20 |0) == -1|) {.. |
|000021f0| 20 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c | fprintf|(stderr,|
|00002200| 20 22 43 61 6e 27 74 20 | 73 6b 69 70 20 6f 76 65 | "Can't |skip ove|
|00002210| 72 20 4d 61 63 42 69 6e | 61 72 79 20 68 65 61 64 |r MacBin|ary head|
|00002220| 65 72 5c 6e 22 29 3b 0a | 09 20 20 20 20 65 78 69 |er\n");.|. exi|
|00002230| 74 28 31 29 3b 0a 09 7d | 0a 20 20 20 20 7d 0a 0a |t(1);..}|. }..|
|00002240| 20 20 20 20 69 66 20 28 | 72 65 61 64 73 69 74 68 | if (|readsith|
|00002250| 64 72 28 26 73 69 74 68 | 64 72 29 20 3d 3d 20 30 |dr(&sith|dr) == 0|
|00002260| 29 20 7b 0a 09 66 70 72 | 69 6e 74 66 28 73 74 64 |) {..fpr|intf(std|
|00002270| 65 72 72 2c 20 22 43 61 | 6e 27 74 20 72 65 61 64 |err, "Ca|n't read|
|00002280| 20 66 69 6c 65 20 68 65 | 61 64 65 72 5c 6e 22 29 | file he|ader\n")|
|00002290| 3b 0a 09 65 78 69 74 28 | 31 29 3b 0a 20 20 20 20 |;..exit(|1);. |
|000022a0| 7d 0a 20 20 20 20 2f 2a | 20 0a 20 20 20 20 70 72 |}. /*| . pr|
|000022b0| 69 6e 74 66 28 22 6e 75 | 6d 66 69 6c 65 73 3d 25 |intf("nu|mfiles=%|
|000022c0| 64 2c 20 61 72 63 6c 65 | 6e 67 74 68 3d 25 6c 64 |d, arcle|ngth=%ld|
|000022d0| 5c 6e 22 2c 20 73 69 74 | 68 64 72 2e 6e 75 6d 46 |\n", sit|hdr.numF|
|000022e0| 69 6c 65 73 2c 20 73 69 | 74 68 64 72 2e 61 72 63 |iles, si|thdr.arc|
|000022f0| 4c 65 6e 67 74 68 29 3b | 0a 20 20 20 20 2a 2f 0a |Length);|. */.|
|00002300| 09 0a 20 20 20 20 73 74 | 61 74 75 73 20 3d 20 65 |.. st|atus = e|
|00002310| 78 74 72 61 63 74 28 22 | 22 2c 20 30 29 3b 0a 20 |xtract("|", 0);. |
|00002320| 20 20 20 65 78 69 74 28 | 28 73 74 61 74 75 73 20 | exit(|(status |
|00002330| 3c 20 30 29 20 3f 20 31 | 20 3a 20 30 29 3b 0a 7d |< 0) ? 1| : 0);.}|
|00002340| 0a 0a 75 73 61 67 65 28 | 29 0a 7b 0a 20 20 20 20 |..usage(|).{. |
|00002350| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00002360| 22 55 73 61 67 65 3a 20 | 75 6e 73 69 74 20 5b 2d |"Usage: |unsit [-|
|00002370| 72 64 75 6c 76 71 6d 66 | 5d 20 66 69 6c 65 6e 61 |rdulvqmf|] filena|
|00002380| 6d 65 5c 6e 22 29 3b 0a | 7d 0a 0a 2f 2a 0a 20 20 |me\n");.|}../*. |
|00002390| 65 78 74 72 61 63 74 28 | 70 61 72 65 6e 74 2c 20 |extract(|parent, |
|000023a0| 73 6b 69 70 29 20 2d 20 | 45 78 74 72 61 63 74 20 |skip) - |Extract |
|000023b0| 61 6c 6c 20 66 69 6c 65 | 73 20 66 72 6f 6d 20 74 |all file|s from t|
|000023c0| 68 65 20 63 75 72 72 65 | 6e 74 20 66 6f 6c 64 65 |he curre|nt folde|
|000023d0| 72 2e 0a 20 20 63 68 61 | 72 20 2a 70 61 72 65 6e |r.. cha|r *paren|
|000023e0| 74 3b 20 20 20 20 20 20 | 20 20 20 20 20 6e 61 6d |t; | nam|
|000023f0| 65 20 6f 66 20 70 61 72 | 65 6e 74 20 66 6f 6c 64 |e of par|ent fold|
|00002400| 65 72 0a 20 20 69 6e 74 | 20 20 73 6b 69 70 3b 20 |er. int| skip; |
|00002410| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 31 20 74 | | 1 t|
|00002420| 6f 20 73 6b 69 70 20 61 | 6c 6c 20 66 69 6c 65 73 |o skip a|ll files|
|00002430| 20 61 6e 64 20 66 6f 6c | 64 65 72 73 20 69 6e 20 | and fol|ders in |
|00002440| 74 68 69 73 20 6f 6e 65 | 0a 20 20 20 20 20 20 20 |this one|. |
|00002450| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002460| 20 20 20 30 20 74 6f 20 | 65 78 74 72 61 63 74 20 | 0 to |extract |
|00002470| 74 68 65 6d 0a 0a 20 20 | 72 65 74 75 72 6e 73 20 |them.. |returns |
|00002480| 31 20 69 66 20 63 61 6d | 65 20 61 6e 20 65 6e 64 |1 if cam|e an end|
|00002490| 46 6f 6c 64 65 72 20 72 | 65 63 6f 72 64 0a 20 20 |Folder r|ecord. |
|000024a0| 20 20 20 20 20 20 20 20 | 30 20 69 66 20 45 4f 46 | |0 if EOF|
|000024b0| 0a 09 20 2d 31 20 69 66 | 20 65 72 72 6f 72 20 28 |.. -1 if| error (|
|000024c0| 62 61 64 20 66 69 6c 65 | 48 64 72 2c 20 62 61 64 |bad file|Hdr, bad|
|000024d0| 20 66 69 6c 65 2c 20 65 | 74 63 2e 29 0a 2a 2f 0a | file, e|tc.).*/.|
|000024e0| 0a 65 78 74 72 61 63 74 | 28 70 61 72 65 6e 74 2c |.extract|(parent,|
|000024f0| 20 73 6b 69 70 29 0a 63 | 68 61 72 20 2a 70 61 72 | skip).c|har *par|
|00002500| 65 6e 74 3b 0a 69 6e 74 | 20 73 6b 69 70 3b 0a 7b |ent;.int| skip;.{|
|00002510| 0a 20 20 20 20 73 74 72 | 75 63 74 20 66 69 6c 65 |. str|uct file|
|00002520| 48 64 72 20 66 69 6c 65 | 68 64 72 3b 0a 20 20 20 |Hdr file|hdr;. |
|00002530| 20 73 74 72 75 63 74 20 | 73 74 61 74 20 73 62 75 | struct |stat sbu|
|00002540| 66 3b 0a 20 20 20 20 69 | 6e 74 20 73 74 61 74 75 |f;. i|nt statu|
|00002550| 73 2c 20 72 73 74 61 74 | 2c 20 73 73 74 61 74 2c |s, rstat|, sstat,|
|00002560| 20 73 6b 69 70 69 74 3b | 0a 20 20 20 20 63 68 61 | skipit;|. cha|
|00002570| 72 20 6e 61 6d 65 5b 32 | 35 36 5d 3b 0a 0a 20 20 |r name[2|56];.. |
|00002580| 20 20 77 68 69 6c 65 20 | 28 31 29 20 7b 0a 09 72 | while |(1) {..r|
|00002590| 73 74 61 74 20 3d 20 72 | 65 61 64 66 69 6c 65 68 |stat = r|eadfileh|
|000025a0| 64 72 28 26 66 69 6c 65 | 68 64 72 2c 20 73 6b 69 |dr(&file|hdr, ski|
|000025b0| 70 29 3b 0a 09 69 66 20 | 28 72 73 74 61 74 20 3d |p);..if |(rstat =|
|000025c0| 3d 20 48 5f 45 52 52 4f | 52 20 7c 7c 20 72 73 74 |= H_ERRO|R || rst|
|000025d0| 61 74 20 3d 3d 20 48 5f | 45 4f 46 29 20 7b 0a 09 |at == H_|EOF) {..|
|000025e0| 20 20 20 20 73 74 61 74 | 75 73 20 3d 20 72 73 74 | stat|us = rst|
|000025f0| 61 74 3b 0a 09 20 20 20 | 20 62 72 65 61 6b 3b 0a |at;.. | break;.|
|00002600| 09 7d 0a 09 2f 2a 0a 09 | 70 72 69 6e 74 66 28 22 |.}../*..|printf("|
|00002610| 63 6f 6d 70 72 3d 25 64 | 2c 20 63 6f 6d 70 64 3d |compr=%d|, compd=|
|00002620| 25 64 2c 20 72 73 72 63 | 6c 65 6e 3d 25 6c 64 2c |%d, rsrc|len=%ld,|
|00002630| 20 64 61 74 61 6c 65 6e | 3d 25 6c 64 2c 20 72 73 | datalen|=%ld, rs|
|00002640| 72 63 63 72 63 3d 25 64 | 2c 20 64 61 74 61 63 72 |rccrc=%d|, datacr|
|00002650| 63 3d 25 64 5c 6e 22 2c | 0a 09 20 20 20 20 20 20 |c=%d\n",|.. |
|00002660| 20 66 69 6c 65 68 64 72 | 2e 63 6f 6d 70 52 4d 65 | filehdr|.compRMe|
|00002670| 74 68 6f 64 2c 20 66 69 | 6c 65 68 64 72 2e 63 6f |thod, fi|lehdr.co|
|00002680| 6d 70 44 4d 65 74 68 6f | 64 2c 0a 09 20 20 20 20 |mpDMetho|d,.. |
|00002690| 20 20 20 66 69 6c 65 68 | 64 72 2e 63 6f 6d 70 52 | fileh|dr.compR|
|000026a0| 4c 65 6e 67 74 68 2c 20 | 66 69 6c 65 68 64 72 2e |Length, |filehdr.|
|000026b0| 63 6f 6d 70 44 4c 65 6e | 67 74 68 2c 0a 09 20 20 |compDLen|gth,.. |
|000026c0| 20 20 20 20 20 66 69 6c | 65 68 64 72 2e 72 73 72 | fil|ehdr.rsr|
|000026d0| 63 43 52 43 2c 20 66 69 | 6c 65 68 64 72 2e 64 61 |cCRC, fi|lehdr.da|
|000026e0| 74 61 43 52 43 29 3b 0a | 09 2a 2f 0a 0a 09 73 6b |taCRC);.|.*/...sk|
|000026f0| 69 70 69 74 20 3d 20 28 | 72 73 74 61 74 20 3d 3d |ipit = (|rstat ==|
|00002700| 20 48 5f 53 4b 49 50 29 | 20 3f 20 31 20 3a 20 30 | H_SKIP)| ? 1 : 0|
|00002710| 3b 0a 0a 09 69 66 20 28 | 66 69 6c 65 68 64 72 2e |;...if (|filehdr.|
|00002720| 63 6f 6d 70 52 4d 65 74 | 68 6f 64 20 3d 3d 20 65 |compRMet|hod == e|
|00002730| 6e 64 46 6f 6c 64 65 72 | 20 26 26 20 0a 09 20 20 |ndFolder| && .. |
|00002740| 20 20 66 69 6c 65 68 64 | 72 2e 63 6f 6d 70 44 4d | filehd|r.compDM|
|00002750| 65 74 68 6f 64 20 3d 3d | 20 65 6e 64 46 6f 6c 64 |ethod ==| endFold|
|00002760| 65 72 29 20 7b 0a 09 20 | 20 20 20 73 74 61 74 75 |er) {.. | statu|
|00002770| 73 20 3d 20 31 3b 09 09 | 2f 2a 20 66 69 6e 69 73 |s = 1;..|/* finis|
|00002780| 68 65 64 20 77 69 74 68 | 20 74 68 69 73 20 66 6f |hed with| this fo|
|00002790| 6c 64 65 72 20 2a 2f 0a | 09 20 20 20 20 62 72 65 |lder */.|. bre|
|000027a0| 61 6b 3b 0a 09 7d 0a 09 | 65 6c 73 65 20 69 66 20 |ak;..}..|else if |
|000027b0| 28 66 69 6c 65 68 64 72 | 2e 63 6f 6d 70 52 4d 65 |(filehdr|.compRMe|
|000027c0| 74 68 6f 64 20 3d 3d 20 | 73 74 61 72 74 46 6f 6c |thod == |startFol|
|000027d0| 64 65 72 20 26 26 20 0a | 09 09 20 66 69 6c 65 68 |der && .|.. fileh|
|000027e0| 64 72 2e 63 6f 6d 70 44 | 4d 65 74 68 6f 64 20 3d |dr.compD|Method =|
|000027f0| 3d 20 73 74 61 72 74 46 | 6f 6c 64 65 72 29 20 7b |= startF|older) {|
|00002800| 0a 09 20 20 20 20 69 66 | 20 28 21 6c 69 73 74 6f |.. if| (!listo|
|00002810| 6e 6c 79 20 26 26 20 72 | 73 74 61 74 20 3d 3d 20 |nly && r|stat == |
|00002820| 48 5f 57 52 49 54 45 20 | 26 26 20 21 66 6c 61 74 |H_WRITE |&& !flat|
|00002830| 74 65 6e 29 20 7b 0a 09 | 09 73 73 74 61 74 20 3d |ten) {..|.sstat =|
|00002840| 20 73 74 61 74 28 75 6e | 61 6d 65 2c 20 26 73 62 | stat(un|ame, &sb|
|00002850| 75 66 29 3b 0a 09 09 69 | 66 20 28 73 73 74 61 74 |uf);...i|f (sstat|
|00002860| 20 3d 3d 20 2d 31 29 20 | 7b 09 2f 2a 20 64 69 72 | == -1) |{./* dir|
|00002870| 65 63 74 6f 72 79 20 64 | 6f 65 73 6e 27 74 20 65 |ectory d|oesn't e|
|00002880| 78 69 73 74 20 2a 2f 0a | 09 09 20 20 20 20 69 66 |xist */.|.. if|
|00002890| 20 28 6d 6b 64 69 72 28 | 75 6e 61 6d 65 2c 20 30 | (mkdir(|uname, 0|
|000028a0| 37 37 37 29 20 3d 3d 20 | 2d 31 29 20 7b 0a 09 09 |777) == |-1) {...|
|000028b0| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|000028c0| 0a 09 09 09 09 22 43 61 | 6e 27 74 20 63 72 65 61 |....."Ca|n't crea|
|000028d0| 74 65 20 73 75 62 64 69 | 72 65 63 74 6f 72 79 20 |te subdi|rectory |
|000028e0| 25 73 5c 6e 22 2c 20 75 | 6e 61 6d 65 29 3b 0a 09 |%s\n", u|name);..|
|000028f0| 09 09 72 65 74 75 72 6e | 28 2d 31 29 3b 0a 09 09 |..return|(-1);...|
|00002900| 20 20 20 20 7d 0a 09 09 | 7d 0a 09 09 65 6c 73 65 | }...|}...else|
|00002910| 20 7b 09 09 2f 2a 20 73 | 6f 6d 65 74 68 69 6e 67 | {../* s|omething|
|00002920| 20 65 78 69 73 74 73 20 | 77 69 74 68 20 74 68 69 | exists |with thi|
|00002930| 73 20 6e 61 6d 65 20 2a | 2f 0a 09 09 20 20 20 20 |s name *|/... |
|00002940| 69 66 20 28 28 73 62 75 | 66 2e 73 74 5f 6d 6f 64 |if ((sbu|f.st_mod|
|00002950| 65 20 26 20 53 5f 49 46 | 4d 54 29 20 21 3d 20 53 |e & S_IF|MT) != S|
|00002960| 5f 49 46 44 49 52 29 20 | 7b 0a 09 09 09 66 70 72 |_IFDIR) |{....fpr|
|00002970| 69 6e 74 66 28 73 74 64 | 65 72 72 2c 20 22 44 69 |intf(std|err, "Di|
|00002980| 72 65 63 74 6f 72 79 20 | 6e 61 6d 65 20 25 73 20 |rectory |name %s |
|00002990| 61 6c 72 65 61 64 79 20 | 69 6e 20 75 73 65 5c 6e |already |in use\n|
|000029a0| 22 2c 0a 09 09 09 09 75 | 6e 61 6d 65 29 3b 0a 09 |",.....u|name);..|
|000029b0| 09 09 72 65 74 75 72 6e | 28 2d 31 29 3b 0a 09 09 |..return|(-1);...|
|000029c0| 20 20 20 20 7d 0a 09 09 | 7d 0a 09 09 69 66 20 28 | }...|}...if (|
|000029d0| 63 68 64 69 72 28 75 6e | 61 6d 65 29 20 3d 3d 20 |chdir(un|ame) == |
|000029e0| 2d 31 29 20 7b 0a 09 09 | 20 20 20 20 66 70 72 69 |-1) {...| fpri|
|000029f0| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 43 61 6e |ntf(stde|rr, "Can|
|00002a00| 27 74 20 63 68 64 69 72 | 20 74 6f 20 25 73 5c 6e |'t chdir| to %s\n|
|00002a10| 22 2c 20 75 6e 61 6d 65 | 29 3b 0a 09 09 20 20 20 |", uname|);... |
|00002a20| 20 72 65 74 75 72 6e 28 | 2d 31 29 3b 0a 09 09 7d | return(|-1);...}|
|00002a30| 0a 09 09 73 70 72 69 6e | 74 66 28 6e 61 6d 65 2c |...sprin|tf(name,|
|00002a40| 22 25 73 3a 25 73 22 2c | 20 70 61 72 65 6e 74 2c |"%s:%s",| parent,|
|00002a50| 20 75 6e 61 6d 65 29 3b | 0a 09 20 20 20 20 7d 0a | uname);|.. }.|
|00002a60| 09 20 20 20 20 64 65 70 | 74 68 2b 2b 3b 0a 09 20 |. dep|th++;.. |
|00002a70| 20 20 20 73 74 61 74 75 | 73 20 3d 20 65 78 74 72 | statu|s = extr|
|00002a80| 61 63 74 28 6e 61 6d 65 | 2c 20 73 6b 69 70 69 74 |act(name|, skipit|
|00002a90| 29 3b 0a 09 20 20 20 20 | 64 65 70 74 68 2d 2d 3b |);.. |depth--;|
|00002aa0| 0a 09 20 20 20 20 69 66 | 20 28 73 74 61 74 75 73 |.. if| (status|
|00002ab0| 20 21 3d 20 31 29 0a 09 | 09 62 72 65 61 6b 3b 09 | != 1)..|.break;.|
|00002ac0| 09 2f 2a 20 70 72 6f 62 | 6c 65 6d 20 77 69 74 68 |./* prob|lem with|
|00002ad0| 20 66 6f 6c 64 65 72 20 | 2a 2f 0a 09 20 20 20 20 | folder |*/.. |
|00002ae0| 69 66 20 28 64 65 70 74 | 68 20 3d 3d 20 30 29 09 |if (dept|h == 0).|
|00002af0| 2f 2a 20 63 6f 75 6e 74 | 20 68 6f 77 20 6d 61 6e |/* count| how man|
|00002b00| 79 20 74 6f 70 2d 6c 65 | 76 65 6c 20 66 69 6c 65 |y top-le|vel file|
|00002b10| 73 20 64 6f 6e 65 20 2a | 2f 0a 09 09 6e 75 6d 66 |s done *|/...numf|
|00002b20| 69 6c 65 73 2b 2b 3b 0a | 09 20 20 20 20 69 66 20 |iles++;.|. if |
|00002b30| 28 21 66 6c 61 74 74 65 | 6e 29 0a 09 09 63 68 64 |(!flatte|n)...chd|
|00002b40| 69 72 28 22 2e 2e 22 29 | 3b 0a 09 7d 0a 09 65 6c |ir("..")|;..}..el|
|00002b50| 73 65 20 7b 0a 09 20 20 | 20 20 69 66 20 28 28 73 |se {.. | if ((s|
|00002b60| 74 61 74 75 73 20 3d 20 | 65 78 74 72 61 63 74 66 |tatus = |extractf|
|00002b70| 69 6c 65 28 26 66 69 6c | 65 68 64 72 2c 20 73 6b |ile(&fil|ehdr, sk|
|00002b80| 69 70 69 74 29 29 20 21 | 3d 20 31 29 0a 09 09 62 |ipit)) !|= 1)...b|
|00002b90| 72 65 61 6b 3b 0a 09 20 | 20 20 20 69 66 20 28 64 |reak;.. | if (d|
|00002ba0| 65 70 74 68 20 3d 3d 20 | 30 29 09 2f 2a 20 63 6f |epth == |0)./* co|
|00002bb0| 75 6e 74 20 68 6f 77 20 | 6d 61 6e 79 20 74 6f 70 |unt how |many top|
|00002bc0| 2d 6c 65 76 65 6c 20 66 | 69 6c 65 73 20 64 6f 6e |-level f|iles don|
|00002bd0| 65 20 2a 2f 0a 09 09 6e | 75 6d 66 69 6c 65 73 2b |e */...n|umfiles+|
|00002be0| 2b 3b 0a 09 7d 0a 09 69 | 66 20 28 6e 75 6d 66 69 |+;..}..i|f (numfi|
|00002bf0| 6c 65 73 20 3d 3d 20 73 | 69 74 68 64 72 2e 6e 75 |les == s|ithdr.nu|
|00002c00| 6d 46 69 6c 65 73 29 0a | 09 20 20 20 20 62 72 65 |mFiles).|. bre|
|00002c10| 61 6b 3b 0a 20 20 20 20 | 7d 0a 20 20 20 20 72 65 |ak;. |}. re|
|00002c20| 74 75 72 6e 28 73 74 61 | 74 75 73 29 3b 0a 7d 0a |turn(sta|tus);.}.|
|00002c30| 0a 65 78 74 72 61 63 74 | 66 69 6c 65 28 66 68 2c |.extract|file(fh,|
|00002c40| 20 73 6b 69 70 29 0a 73 | 74 72 75 63 74 20 66 69 | skip).s|truct fi|
|00002c50| 6c 65 48 64 72 20 2a 66 | 68 3b 0a 69 6e 74 20 73 |leHdr *f|h;.int s|
|00002c60| 6b 69 70 3b 0a 7b 0a 20 | 20 20 20 75 6e 73 69 67 |kip;.{. | unsig|
|00002c70| 6e 65 64 20 73 68 6f 72 | 74 20 63 72 63 3b 0a 20 |ned shor|t crc;. |
|00002c80| 20 20 20 46 49 4c 45 20 | 2a 66 70 3b 0a 0a 20 20 | FILE |*fp;.. |
|00002c90| 20 20 66 5f 64 61 74 61 | 5b 30 5d 20 3d 20 66 5f | f_data|[0] = f_|
|00002ca0| 72 73 72 63 5b 30 5d 20 | 3d 20 66 5f 69 6e 66 6f |rsrc[0] |= f_info|
|00002cb0| 5b 30 5d 20 3d 20 27 5c | 30 27 3b 20 2f 2a 20 61 |[0] = '\|0'; /* a|
|00002cc0| 73 73 75 6d 65 20 6e 6f | 20 6f 75 74 70 75 74 20 |ssume no| output |
|00002cd0| 66 69 6c 65 73 20 2a 2f | 0a 20 20 20 20 2f 2a 20 |files */|. /* |
|00002ce0| 66 69 67 75 72 65 20 6f | 75 74 20 77 68 61 74 20 |figure o|ut what |
|00002cf0| 66 69 6c 65 20 6e 61 6d | 65 73 20 74 6f 20 75 73 |file nam|es to us|
|00002d00| 65 20 61 6e 64 20 77 68 | 61 74 20 74 6f 20 64 6f |e and wh|at to do|
|00002d10| 20 2a 2f 0a 20 20 20 20 | 69 66 20 28 21 6c 69 73 | */. |if (!lis|
|00002d20| 74 6f 6e 6c 79 20 26 26 | 20 21 73 6b 69 70 29 20 |tonly &&| !skip) |
|00002d30| 7b 0a 09 73 77 69 74 63 | 68 20 28 6d 6f 64 65 29 |{..switc|h (mode)|
|00002d40| 20 7b 0a 09 20 20 63 61 | 73 65 20 46 55 4c 4c 3a | {.. ca|se FULL:|
|00002d50| 09 09 2f 2a 20 64 6f 20 | 62 6f 74 68 20 72 73 72 |../* do |both rsr|
|00002d60| 63 20 61 6e 64 20 64 61 | 74 61 20 66 6f 72 6b 73 |c and da|ta forks|
|00002d70| 20 2a 2f 0a 09 20 20 20 | 20 73 70 72 69 6e 74 66 | */.. | sprintf|
|00002d80| 28 66 5f 64 61 74 61 2c | 20 22 25 2e 2a 73 2e 64 |(f_data,| "%.*s.d|
|00002d90| 61 74 61 22 2c 20 49 5f | 4e 41 4d 45 4c 45 4e 20 |ata", I_|NAMELEN |
|00002da0| 2d 20 36 2c 20 75 6e 61 | 6d 65 29 3b 0a 09 20 20 |- 6, una|me);.. |
|00002db0| 20 20 73 70 72 69 6e 74 | 66 28 66 5f 72 73 72 63 | sprint|f(f_rsrc|
|00002dc0| 2c 20 22 25 2e 2a 73 2e | 72 73 72 63 22 2c 20 49 |, "%.*s.|rsrc", I|
|00002dd0| 5f 4e 41 4d 45 4c 45 4e | 20 2d 20 36 2c 20 75 6e |_NAMELEN| - 6, un|
|00002de0| 61 6d 65 29 3b 0a 09 20 | 20 20 20 73 70 72 69 6e |ame);.. | sprin|
|00002df0| 74 66 28 66 5f 69 6e 66 | 6f 2c 20 22 25 2e 2a 73 |tf(f_inf|o, "%.*s|
|00002e00| 2e 69 6e 66 6f 22 2c 20 | 49 5f 4e 41 4d 45 4c 45 |.info", |I_NAMELE|
|00002e10| 4e 20 2d 20 36 2c 20 75 | 6e 61 6d 65 29 3b 0a 09 |N - 6, u|name);..|
|00002e20| 20 20 20 20 62 72 65 61 | 6b 3b 0a 09 20 20 63 61 | brea|k;.. ca|
|00002e30| 73 65 20 52 53 52 43 3a | 09 09 2f 2a 20 72 73 72 |se RSRC:|../* rsr|
|00002e40| 63 20 66 6f 72 6b 20 6f | 6e 6c 79 20 2a 2f 0a 09 |c fork o|nly */..|
|00002e50| 20 20 20 20 73 70 72 69 | 6e 74 66 28 66 5f 72 73 | spri|ntf(f_rs|
|00002e60| 72 63 2c 20 22 25 2e 2a | 73 2e 72 73 72 63 22 2c |rc, "%.*|s.rsrc",|
|00002e70| 20 49 5f 4e 41 4d 45 4c | 45 4e 20 2d 20 36 2c 20 | I_NAMEL|EN - 6, |
|00002e80| 75 6e 61 6d 65 29 3b 0a | 09 20 20 20 20 62 72 65 |uname);.|. bre|
|00002e90| 61 6b 3b 0a 09 20 20 63 | 61 73 65 20 44 41 54 41 |ak;.. c|ase DATA|
|00002ea0| 3a 09 09 2f 2a 20 64 61 | 74 61 20 66 6f 72 6b 20 |:../* da|ta fork |
|00002eb0| 6f 6e 6c 79 20 2a 2f 0a | 09 20 20 63 61 73 65 20 |only */.|. case |
|00002ec0| 54 45 58 54 3a 0a 09 20 | 20 20 20 73 70 72 69 6e |TEXT:.. | sprin|
|00002ed0| 74 66 28 66 5f 64 61 74 | 61 2c 20 22 25 2e 2a 73 |tf(f_dat|a, "%.*s|
|00002ee0| 22 2c 20 49 5f 4e 41 4d | 45 4c 45 4e 20 2d 20 31 |", I_NAM|ELEN - 1|
|00002ef0| 2c 20 75 6e 61 6d 65 29 | 3b 0a 09 20 20 20 20 62 |, uname)|;.. b|
|00002f00| 72 65 61 6b 3b 0a 09 20 | 20 63 61 73 65 20 44 55 |reak;.. | case DU|
|00002f10| 4d 50 3a 09 09 2f 2a 20 | 66 6f 72 20 64 65 62 75 |MP:../* |for debu|
|00002f20| 67 67 69 6e 67 2c 20 64 | 75 6d 70 20 64 61 74 61 |gging, d|ump data|
|00002f30| 20 61 73 20 69 73 20 2a | 2f 0a 09 20 20 20 20 73 | as is *|/.. s|
|00002f40| 70 72 69 6e 74 66 28 66 | 5f 64 61 74 61 2c 20 22 |printf(f|_data, "|
|00002f50| 25 2e 2a 73 2e 64 64 75 | 6d 70 22 2c 20 49 5f 4e |%.*s.ddu|mp", I_N|
|00002f60| 41 4d 45 4c 45 4e 20 2d | 20 37 2c 20 75 6e 61 6d |AMELEN -| 7, unam|
|00002f70| 65 29 3b 0a 09 20 20 20 | 20 73 70 72 69 6e 74 66 |e);.. | sprintf|
|00002f80| 28 66 5f 72 73 72 63 2c | 20 22 25 2e 2a 73 2e 72 |(f_rsrc,| "%.*s.r|
|00002f90| 64 75 6d 70 22 2c 20 49 | 5f 4e 41 4d 45 4c 45 4e |dump", I|_NAMELEN|
|00002fa0| 20 2d 20 37 2c 20 75 6e | 61 6d 65 29 3b 0a 09 20 | - 7, un|ame);.. |
|00002fb0| 20 20 20 66 68 2d 3e 63 | 6f 6d 70 52 4d 65 74 68 | fh->c|ompRMeth|
|00002fc0| 6f 64 20 3d 20 66 68 2d | 3e 63 6f 6d 70 44 4d 65 |od = fh-|>compDMe|
|00002fd0| 74 68 6f 64 20 3d 20 6e | 6f 43 6f 6d 70 3b 0a 09 |thod = n|oComp;..|
|00002fe0| 20 20 20 20 62 72 65 61 | 6b 3b 0a 09 7d 0a 20 20 | brea|k;..}. |
|00002ff0| 20 20 7d 0a 0a 20 20 20 | 20 69 66 20 28 66 5f 69 | }.. | if (f_i|
|00003000| 6e 66 6f 5b 30 5d 20 21 | 3d 20 27 5c 30 27 20 26 |nfo[0] !|= '\0' &|
|00003010| 26 20 63 68 65 63 6b 5f | 61 63 63 65 73 73 28 66 |& check_|access(f|
|00003020| 5f 69 6e 66 6f 29 20 21 | 3d 20 2d 31 29 20 7b 0a |_info) !|= -1) {.|
|00003030| 09 66 70 20 3d 20 66 6f | 70 65 6e 28 66 5f 69 6e |.fp = fo|pen(f_in|
|00003040| 66 6f 2c 20 22 77 22 29 | 3b 0a 09 69 66 20 28 66 |fo, "w")|;..if (f|
|00003050| 70 20 3d 3d 20 4e 55 4c | 4c 29 20 7b 0a 09 20 20 |p == NUL|L) {.. |
|00003060| 20 20 70 65 72 72 6f 72 | 28 66 5f 69 6e 66 6f 29 | perror|(f_info)|
|00003070| 3b 0a 09 20 20 20 20 65 | 78 69 74 28 31 29 3b 0a |;.. e|xit(1);.|
|00003080| 09 7d 0a 09 66 77 72 69 | 74 65 28 69 6e 66 6f 2c |.}..fwri|te(info,|
|00003090| 20 31 2c 20 49 4e 46 4f | 42 59 54 45 53 2c 20 66 | 1, INFO|BYTES, f|
|000030a0| 70 29 3b 0a 09 66 63 6c | 6f 73 65 28 66 70 29 3b |p);..fcl|ose(fp);|
|000030b0| 0a 20 20 20 20 7d 0a 0a | 20 20 20 20 69 66 20 28 |. }..| if (|
|000030c0| 66 5f 72 73 72 63 5b 30 | 5d 20 21 3d 20 27 5c 30 |f_rsrc[0|] != '\0|
|000030d0| 27 29 20 7b 0a 09 74 78 | 74 6d 6f 64 65 20 3d 20 |') {..tx|tmode = |
|000030e0| 30 3b 0a 09 63 72 63 20 | 3d 20 77 72 69 74 65 5f |0;..crc |= write_|
|000030f0| 66 69 6c 65 28 66 5f 72 | 73 72 63 2c 20 66 68 2d |file(f_r|src, fh-|
|00003100| 3e 63 6f 6d 70 52 4c 65 | 6e 67 74 68 2c 0a 09 09 |>compRLe|ngth,...|
|00003110| 09 20 66 68 2d 3e 72 73 | 72 63 4c 65 6e 67 74 68 |. fh->rs|rcLength|
|00003120| 2c 20 66 68 2d 3e 63 6f | 6d 70 52 4d 65 74 68 6f |, fh->co|mpRMetho|
|00003130| 64 29 3b 0a 09 69 66 20 | 28 63 68 6b 63 72 63 20 |d);..if |(chkcrc |
|00003140| 26 26 20 66 68 2d 3e 72 | 73 72 63 43 52 43 20 21 |&& fh->r|srcCRC !|
|00003150| 3d 20 63 72 63 29 20 7b | 0a 09 20 20 20 20 66 70 |= crc) {|.. fp|
|00003160| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 0a 09 09 |rintf(st|derr,...|
|00003170| 20 20 20 20 22 43 52 43 | 20 65 72 72 6f 72 20 6f | "CRC| error o|
|00003180| 6e 20 72 65 73 6f 75 72 | 63 65 20 66 6f 72 6b 3a |n resour|ce fork:|
|00003190| 20 6e 65 65 64 20 30 78 | 25 30 34 78 2c 20 67 6f | need 0x|%04x, go|
|000031a0| 74 20 30 78 25 30 34 78 | 5c 6e 22 2c 0a 09 09 20 |t 0x%04x|\n",... |
|000031b0| 20 20 20 66 68 2d 3e 72 | 73 72 63 43 52 43 2c 20 | fh->r|srcCRC, |
|000031c0| 63 72 63 29 3b 0a 09 20 | 20 20 20 72 65 74 75 72 |crc);.. | retur|
|000031d0| 6e 28 2d 31 29 3b 0a 09 | 7d 0a 20 20 20 20 7d 0a |n(-1);..|}. }.|
|000031e0| 20 20 20 20 65 6c 73 65 | 20 7b 0a 09 66 73 65 65 | else| {..fsee|
|000031f0| 6b 28 69 6e 66 70 2c 20 | 28 6c 6f 6e 67 29 20 66 |k(infp, |(long) f|
|00003200| 68 2d 3e 63 6f 6d 70 52 | 4c 65 6e 67 74 68 2c 20 |h->compR|Length, |
|00003210| 31 29 3b 0a 20 20 20 20 | 7d 0a 20 20 20 20 69 66 |1);. |}. if|
|00003220| 20 28 66 5f 64 61 74 61 | 5b 30 5d 20 21 3d 20 27 | (f_data|[0] != '|
|00003230| 5c 30 27 29 20 7b 0a 09 | 74 78 74 6d 6f 64 65 20 |\0') {..|txtmode |
|00003240| 3d 20 28 6d 6f 64 65 20 | 3d 3d 20 54 45 58 54 29 |= (mode |== TEXT)|
|00003250| 3b 0a 09 63 72 63 20 3d | 20 77 72 69 74 65 5f 66 |;..crc =| write_f|
|00003260| 69 6c 65 28 66 5f 64 61 | 74 61 2c 20 66 68 2d 3e |ile(f_da|ta, fh->|
|00003270| 63 6f 6d 70 44 4c 65 6e | 67 74 68 2c 0a 09 09 09 |compDLen|gth,....|
|00003280| 20 66 68 2d 3e 64 61 74 | 61 4c 65 6e 67 74 68 2c | fh->dat|aLength,|
|00003290| 20 66 68 2d 3e 63 6f 6d | 70 44 4d 65 74 68 6f 64 | fh->com|pDMethod|
|000032a0| 29 3b 0a 09 69 66 20 28 | 63 68 6b 63 72 63 20 26 |);..if (|chkcrc &|
|000032b0| 26 20 66 68 2d 3e 64 61 | 74 61 43 52 43 20 21 3d |& fh->da|taCRC !=|
|000032c0| 20 63 72 63 29 20 7b 0a | 09 20 20 20 20 66 70 72 | crc) {.|. fpr|
|000032d0| 69 6e 74 66 28 73 74 64 | 65 72 72 2c 0a 09 09 20 |intf(std|err,... |
|000032e0| 20 20 20 22 43 52 43 20 | 65 72 72 6f 72 20 6f 6e | "CRC |error on|
|000032f0| 20 64 61 74 61 20 66 6f | 72 6b 3a 20 6e 65 65 64 | data fo|rk: need|
|00003300| 20 30 78 25 30 34 78 2c | 20 67 6f 74 20 30 78 25 | 0x%04x,| got 0x%|
|00003310| 30 34 78 5c 6e 22 2c 0a | 09 09 20 20 20 20 66 68 |04x\n",.|.. fh|
|00003320| 2d 3e 64 61 74 61 43 52 | 43 2c 20 63 72 63 29 3b |->dataCR|C, crc);|
|00003330| 0a 09 20 20 20 20 72 65 | 74 75 72 6e 28 2d 31 29 |.. re|turn(-1)|
|00003340| 3b 0a 09 7d 0a 20 20 20 | 20 7d 0a 20 20 20 20 65 |;..}. | }. e|
|00003350| 6c 73 65 20 7b 0a 09 66 | 73 65 65 6b 28 69 6e 66 |lse {..f|seek(inf|
|00003360| 70 2c 20 28 6c 6f 6e 67 | 29 20 66 68 2d 3e 63 6f |p, (long|) fh->co|
|00003370| 6d 70 44 4c 65 6e 67 74 | 68 2c 20 31 29 3b 0a 20 |mpDLengt|h, 1);. |
|00003380| 20 20 20 7d 0a 20 20 20 | 20 72 65 74 75 72 6e 28 | }. | return(|
|00003390| 31 29 3b 0a 7d 0a 0a 72 | 65 61 64 73 69 74 68 64 |1);.}..r|eadsithd|
|000033a0| 72 28 73 29 0a 73 74 72 | 75 63 74 20 73 69 74 48 |r(s).str|uct sitH|
|000033b0| 64 72 20 2a 73 3b 0a 7b | 0a 20 20 20 20 63 68 61 |dr *s;.{|. cha|
|000033c0| 72 20 74 65 6d 70 5b 46 | 49 4c 45 48 44 52 53 49 |r temp[F|ILEHDRSI|
|000033d0| 5a 45 5d 3b 0a 20 20 20 | 20 69 6e 74 20 63 6f 75 |ZE];. | int cou|
|000033e0| 6e 74 20 3d 20 30 3b 0a | 0a 20 20 20 20 66 6f 72 |nt = 0;.|. for|
|000033f0| 20 28 3b 3b 29 20 7b 0a | 09 69 66 20 28 66 72 65 | (;;) {.|.if (fre|
|00003400| 61 64 28 74 65 6d 70 2c | 20 31 2c 20 53 49 54 48 |ad(temp,| 1, SITH|
|00003410| 44 52 53 49 5a 45 2c 20 | 69 6e 66 70 29 20 21 3d |DRSIZE, |infp) !=|
|00003420| 20 53 49 54 48 44 52 53 | 49 5a 45 29 20 7b 0a 09 | SITHDRS|IZE) {..|
|00003430| 20 20 20 20 66 70 72 69 | 6e 74 66 28 73 74 64 65 | fpri|ntf(stde|
|00003440| 72 72 2c 20 22 43 61 6e | 27 74 20 72 65 61 64 20 |rr, "Can|'t read |
|00003450| 66 69 6c 65 20 68 65 61 | 64 65 72 5c 6e 22 29 3b |file hea|der\n");|
|00003460| 0a 09 20 20 20 20 72 65 | 74 75 72 6e 28 30 29 3b |.. re|turn(0);|
|00003470| 0a 09 7d 0a 20 20 20 20 | 09 0a 09 69 66 20 28 73 |..}. |...if (s|
|00003480| 74 72 6e 63 6d 70 28 74 | 65 6d 70 20 2b 20 53 5f |trncmp(t|emp + S_|
|00003490| 53 49 47 4e 41 54 55 52 | 45 2c 20 20 22 53 49 54 |SIGNATUR|E, "SIT|
|000034a0| 21 22 2c 20 34 29 20 3d | 3d 20 30 20 26 26 0a 20 |!", 4) =|= 0 &&. |
|000034b0| 20 20 20 09 73 74 72 6e | 63 6d 70 28 74 65 6d 70 | .strn|cmp(temp|
|000034c0| 20 2b 20 53 5f 53 49 47 | 4e 41 54 55 52 45 32 2c | + S_SIG|NATURE2,|
|000034d0| 20 22 72 4c 61 75 22 2c | 20 34 29 20 3d 3d 20 30 | "rLau",| 4) == 0|
|000034e0| 29 20 7b 0a 09 20 20 20 | 20 73 2d 3e 6e 75 6d 46 |) {.. | s->numF|
|000034f0| 69 6c 65 73 20 3d 20 67 | 65 74 32 28 74 65 6d 70 |iles = g|et2(temp|
|00003500| 20 2b 20 53 5f 4e 55 4d | 46 49 4c 45 53 29 3b 0a | + S_NUM|FILES);.|
|00003510| 09 20 20 20 20 73 2d 3e | 61 72 63 4c 65 6e 67 74 |. s->|arcLengt|
|00003520| 68 20 3d 20 67 65 74 34 | 28 74 65 6d 70 20 2b 20 |h = get4|(temp + |
|00003530| 53 5f 41 52 43 4c 45 4e | 47 54 48 29 3b 0a 09 20 |S_ARCLEN|GTH);.. |
|00003540| 20 20 20 72 65 74 75 72 | 6e 28 31 29 3b 0a 09 7d | retur|n(1);..}|
|00003550| 0a 20 20 20 20 0a 09 69 | 66 20 28 2b 2b 63 6f 75 |. ..i|f (++cou|
|00003560| 6e 74 20 3d 3d 20 32 29 | 20 7b 0a 09 20 20 20 20 |nt == 2)| {.. |
|00003570| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00003580| 22 4e 6f 74 20 61 20 53 | 74 75 66 66 49 74 20 66 |"Not a S|tuffIt f|
|00003590| 69 6c 65 5c 6e 22 29 3b | 0a 09 20 20 20 20 72 65 |ile\n");|.. re|
|000035a0| 74 75 72 6e 28 30 29 3b | 0a 09 7d 0a 09 0a 09 69 |turn(0);|..}....i|
|000035b0| 66 20 28 66 72 65 61 64 | 28 26 74 65 6d 70 5b 53 |f (fread|(&temp[S|
|000035c0| 49 54 48 44 52 53 49 5a | 45 5d 2c 20 31 2c 20 46 |ITHDRSIZ|E], 1, F|
|000035d0| 49 4c 45 48 44 52 53 49 | 5a 45 20 2d 20 53 49 54 |ILEHDRSI|ZE - SIT|
|000035e0| 48 44 52 53 49 5a 45 2c | 20 69 6e 66 70 29 20 21 |HDRSIZE,| infp) !|
|000035f0| 3d 0a 09 20 20 20 20 46 | 49 4c 45 48 44 52 53 49 |=.. F|ILEHDRSI|
|00003600| 5a 45 20 2d 20 53 49 54 | 48 44 52 53 49 5a 45 29 |ZE - SIT|HDRSIZE)|
|00003610| 20 7b 0a 09 20 20 20 20 | 66 70 72 69 6e 74 66 28 | {.. |fprintf(|
|00003620| 73 74 64 65 72 72 2c 20 | 22 43 61 6e 27 74 20 72 |stderr, |"Can't r|
|00003630| 65 61 64 20 66 69 6c 65 | 20 68 65 61 64 65 72 5c |ead file| header\|
|00003640| 6e 22 29 3b 0a 09 20 20 | 20 20 72 65 74 75 72 6e |n");.. | return|
|00003650| 28 30 29 3b 0a 09 7d 0a | 20 20 20 20 0a 09 69 66 |(0);..}.| ..if|
|00003660| 20 28 73 74 72 6e 63 6d | 70 28 74 65 6d 70 20 2b | (strncm|p(temp +|
|00003670| 20 49 5f 54 59 50 45 4f | 46 46 2c 20 22 53 49 54 | I_TYPEO|FF, "SIT|
|00003680| 21 22 2c 20 34 29 20 3d | 3d 20 30 20 26 26 0a 09 |!", 4) =|= 0 &&..|
|00003690| 20 20 20 20 73 74 72 6e | 63 6d 70 28 74 65 6d 70 | strn|cmp(temp|
|000036a0| 20 2b 20 49 5f 41 55 54 | 48 4f 46 46 2c 20 22 53 | + I_AUT|HOFF, "S|
|000036b0| 49 54 21 22 2c 20 34 29 | 20 3d 3d 20 30 29 20 7b |IT!", 4)| == 0) {|
|000036c0| 09 2f 2a 20 4d 61 63 42 | 69 6e 61 72 79 20 66 6f |./* MacB|inary fo|
|000036d0| 72 6d 61 74 20 2a 2f 0a | 09 20 20 20 20 66 73 65 |rmat */.|. fse|
|000036e0| 65 6b 28 69 6e 66 70 2c | 20 28 6c 6f 6e 67 29 28 |ek(infp,| (long)(|
|000036f0| 49 4e 46 4f 42 59 54 45 | 53 2d 46 49 4c 45 48 44 |INFOBYTE|S-FILEHD|
|00003700| 52 53 49 5a 45 29 2c 20 | 31 29 3b 09 2f 2a 20 53 |RSIZE), |1);./* S|
|00003710| 6b 69 70 20 6f 76 65 72 | 20 68 65 61 64 65 72 20 |kip over| header |
|00003720| 2a 2f 0a 09 7d 0a 20 20 | 20 20 7d 0a 7d 0a 0a 2f |*/..}. | }.}../|
|00003730| 2a 0a 20 20 72 65 61 64 | 66 69 6c 65 68 64 72 20 |*. read|filehdr |
|00003740| 2d 20 72 65 61 64 73 20 | 74 68 65 20 66 69 6c 65 |- reads |the file|
|00003750| 20 68 65 61 64 65 72 20 | 66 6f 72 20 65 61 63 68 | header |for each|
|00003760| 20 66 69 6c 65 20 61 6e | 64 20 74 68 65 20 66 6f | file an|d the fo|
|00003770| 6c 64 65 72 20 73 74 61 | 72 74 0a 20 20 61 6e 64 |lder sta|rt. and|
|00003780| 20 65 6e 64 20 72 65 63 | 6f 72 64 73 2e 0a 0a 20 | end rec|ords... |
|00003790| 20 72 65 74 75 72 6e 73 | 3a 20 48 5f 45 52 52 4f | returns|: H_ERRO|
|000037a0| 52 20 3d 20 65 72 72 6f | 72 0a 09 20 20 20 48 5f |R = erro|r.. H_|
|000037b0| 45 4f 46 20 20 20 3d 20 | 45 4f 46 0a 09 20 20 20 |EOF = |EOF.. |
|000037c0| 48 5f 57 52 49 54 45 20 | 3d 20 77 72 69 74 65 20 |H_WRITE |= write |
|000037d0| 66 69 6c 65 2f 66 6f 6c | 64 65 72 0a 09 20 20 20 |file/fol|der.. |
|000037e0| 48 5f 53 4b 49 50 20 20 | 3d 20 73 6b 69 70 20 66 |H_SKIP |= skip f|
|000037f0| 69 6c 65 2f 66 6f 6c 64 | 65 72 0a 2a 2f 0a 0a 72 |ile/fold|er.*/..r|
|00003800| 65 61 64 66 69 6c 65 68 | 64 72 28 66 2c 20 73 6b |eadfileh|dr(f, sk|
|00003810| 69 70 29 0a 73 74 72 75 | 63 74 20 66 69 6c 65 48 |ip).stru|ct fileH|
|00003820| 64 72 20 2a 66 3b 0a 69 | 6e 74 20 73 6b 69 70 3b |dr *f;.i|nt skip;|
|00003830| 0a 7b 0a 20 20 20 20 75 | 6e 73 69 67 6e 65 64 20 |.{. u|nsigned |
|00003840| 73 68 6f 72 74 20 63 72 | 63 3b 0a 20 20 20 20 69 |short cr|c;. i|
|00003850| 6e 74 20 69 2c 20 6e 2c | 20 77 72 69 74 65 5f 69 |nt i, n,| write_i|
|00003860| 74 2c 20 69 73 66 6f 6c | 64 65 72 3b 0a 20 20 20 |t, isfol|der;. |
|00003870| 20 63 68 61 72 20 68 64 | 72 5b 46 49 4c 45 48 44 | char hd|r[FILEHD|
|00003880| 52 53 49 5a 45 5d 3b 0a | 20 20 20 20 63 68 61 72 |RSIZE];.| char|
|00003890| 20 63 68 2c 20 2a 6d 70 | 2c 20 2a 75 70 3b 0a 20 | ch, *mp|, *up;. |
|000038a0| 20 20 20 63 68 61 72 20 | 2a 74 70 2c 20 74 65 6d | char |*tp, tem|
|000038b0| 70 5b 31 30 5d 3b 0a 0a | 20 20 20 20 66 6f 72 20 |p[10];..| for |
|000038c0| 28 69 20 3d 20 30 3b 20 | 69 20 3c 20 49 4e 46 4f |(i = 0; |i < INFO|
|000038d0| 42 59 54 45 53 3b 20 69 | 2b 2b 29 0a 09 69 6e 66 |BYTES; i|++)..inf|
|000038e0| 6f 5b 69 5d 20 3d 20 27 | 5c 30 27 3b 0a 0a 20 20 |o[i] = '|\0';.. |
|000038f0| 20 20 2f 2a 20 72 65 61 | 64 20 69 6e 20 74 68 65 | /* rea|d in the|
|00003900| 20 6e 65 78 74 20 66 69 | 6c 65 20 68 65 61 64 65 | next fi|le heade|
|00003910| 72 2c 20 77 68 69 63 68 | 20 63 6f 75 6c 64 20 62 |r, which| could b|
|00003920| 65 20 66 6f 6c 64 65 72 | 20 73 74 61 72 74 2f 65 |e folder| start/e|
|00003930| 6e 64 20 72 65 63 6f 72 | 64 20 2a 2f 0a 20 20 20 |nd recor|d */. |
|00003940| 20 6e 20 3d 20 66 72 65 | 61 64 28 68 64 72 2c 20 | n = fre|ad(hdr, |
|00003950| 31 2c 20 46 49 4c 45 48 | 44 52 53 49 5a 45 2c 20 |1, FILEH|DRSIZE, |
|00003960| 69 6e 66 70 29 3b 0a 20 | 20 20 20 69 66 20 28 6e |infp);. | if (n|
|00003970| 20 3d 3d 20 30 29 09 09 | 09 2f 2a 20 72 65 74 75 | == 0)..|./* retu|
|00003980| 72 6e 20 30 20 6f 6e 20 | 45 4f 46 20 2a 2f 0a 09 |rn 0 on |EOF */..|
|00003990| 72 65 74 75 72 6e 28 48 | 5f 45 4f 46 29 3b 0a 20 |return(H|_EOF);. |
|000039a0| 20 20 20 65 6c 73 65 20 | 69 66 20 28 6e 20 21 3d | else |if (n !=|
|000039b0| 20 46 49 4c 45 48 44 52 | 53 49 5a 45 29 20 7b 0a | FILEHDR|SIZE) {.|
|000039c0| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|000039d0| 20 22 43 61 6e 27 74 20 | 72 65 61 64 20 66 69 6c | "Can't |read fil|
|000039e0| 65 20 68 65 61 64 65 72 | 5c 6e 22 29 3b 0a 09 72 |e header|\n");..r|
|000039f0| 65 74 75 72 6e 28 48 5f | 45 52 52 4f 52 29 3b 0a |eturn(H_|ERROR);.|
|00003a00| 20 20 20 20 7d 0a 0a 20 | 20 20 20 2f 2a 20 63 68 | }.. | /* ch|
|00003a10| 65 63 6b 20 74 68 65 20 | 43 52 43 20 66 6f 72 20 |eck the |CRC for |
|00003a20| 74 68 65 20 66 69 6c 65 | 20 68 65 61 64 65 72 20 |the file| header |
|00003a30| 2a 2f 0a 20 20 20 20 63 | 72 63 20 3d 20 49 4e 49 |*/. c|rc = INI|
|00003a40| 54 5f 43 52 43 3b 0a 20 | 20 20 20 63 72 63 20 3d |T_CRC;. | crc =|
|00003a50| 20 75 70 64 63 72 63 28 | 63 72 63 2c 20 68 64 72 | updcrc(|crc, hdr|
|00003a60| 2c 20 46 49 4c 45 48 44 | 52 53 49 5a 45 20 2d 20 |, FILEHD|RSIZE - |
|00003a70| 32 29 3b 0a 20 20 20 20 | 66 2d 3e 68 64 72 43 52 |2);. |f->hdrCR|
|00003a80| 43 20 3d 20 67 65 74 32 | 28 68 64 72 20 2b 20 46 |C = get2|(hdr + F|
|00003a90| 5f 48 44 52 43 52 43 29 | 3b 0a 20 20 20 20 69 66 |_HDRCRC)|;. if|
|00003aa0| 20 28 66 2d 3e 68 64 72 | 43 52 43 20 21 3d 20 63 | (f->hdr|CRC != c|
|00003ab0| 72 63 29 20 7b 0a 09 66 | 70 72 69 6e 74 66 28 73 |rc) {..f|printf(s|
|00003ac0| 74 64 65 72 72 2c 20 22 | 48 65 61 64 65 72 20 43 |tderr, "|Header C|
|00003ad0| 52 43 20 6d 69 73 6d 61 | 74 63 68 3a 20 67 6f 74 |RC misma|tch: got|
|00003ae0| 20 30 78 25 30 34 78 2c | 20 6e 65 65 64 20 30 78 | 0x%04x,| need 0x|
|00003af0| 25 30 34 78 5c 6e 22 2c | 0a 09 09 66 2d 3e 68 64 |%04x\n",|...f->hd|
|00003b00| 72 43 52 43 2c 20 63 72 | 63 29 3b 0a 09 72 65 74 |rCRC, cr|c);..ret|
|00003b10| 75 72 6e 28 48 5f 45 52 | 52 4f 52 29 3b 0a 20 20 |urn(H_ER|ROR);. |
|00003b20| 20 20 7d 0a 0a 20 20 20 | 20 2f 2a 20 67 72 61 62 | }.. | /* grab|
|00003b30| 20 74 68 65 20 6e 61 6d | 65 20 6f 66 20 74 68 65 | the nam|e of the|
|00003b40| 20 66 69 6c 65 20 6f 72 | 20 66 6f 6c 64 65 72 20 | file or| folder |
|00003b50| 2a 2f 0a 20 20 20 20 6e | 20 3d 20 68 64 72 5b 46 |*/. n| = hdr[F|
|00003b60| 5f 46 4e 41 4d 45 5d 20 | 26 20 42 59 54 45 4d 41 |_FNAME] |& BYTEMA|
|00003b70| 53 4b 3b 0a 20 20 20 20 | 69 66 20 28 6e 20 3e 20 |SK;. |if (n > |
|00003b80| 46 5f 4e 41 4d 45 4c 45 | 4e 29 0a 09 6e 20 3d 20 |F_NAMELE|N)..n = |
|00003b90| 46 5f 4e 41 4d 45 4c 45 | 4e 3b 0a 20 20 20 20 69 |F_NAMELE|N;. i|
|00003ba0| 6e 66 6f 5b 49 5f 4e 41 | 4d 45 4f 46 46 5d 20 3d |nfo[I_NA|MEOFF] =|
|00003bb0| 20 6e 3b 0a 20 20 20 20 | 63 6f 70 79 28 69 6e 66 | n;. |copy(inf|
|00003bc0| 6f 20 2b 20 49 5f 4e 41 | 4d 45 4f 46 46 20 2b 20 |o + I_NA|MEOFF + |
|00003bd0| 31 2c 20 68 64 72 20 2b | 20 46 5f 46 4e 41 4d 45 |1, hdr +| F_FNAME|
|00003be0| 20 2b 20 31 2c 20 6e 29 | 3b 0a 20 20 20 20 73 74 | + 1, n)|;. st|
|00003bf0| 72 6e 63 70 79 28 6d 6e | 61 6d 65 2c 20 68 64 72 |rncpy(mn|ame, hdr|
|00003c00| 20 2b 20 46 5f 46 4e 41 | 4d 45 20 2b 20 31 2c 20 | + F_FNA|ME + 1, |
|00003c10| 6e 29 3b 0a 20 20 20 20 | 6d 6e 61 6d 65 5b 6e 5d |n);. |mname[n]|
|00003c20| 20 3d 20 27 5c 30 27 3b | 0a 20 20 20 20 2f 2a 20 | = '\0';|. /* |
|00003c30| 63 6f 70 79 20 74 6f 20 | 61 20 73 74 72 69 6e 67 |copy to |a string|
|00003c40| 20 77 69 74 68 20 6e 6f | 20 69 6c 6c 65 67 61 6c | with no| illegal|
|00003c50| 20 55 6e 69 78 20 63 68 | 61 72 61 63 74 65 72 73 | Unix ch|aracters|
|00003c60| 20 69 6e 20 74 68 65 20 | 66 69 6c 65 20 6e 61 6d | in the |file nam|
|00003c70| 65 20 2a 2f 0a 20 20 20 | 20 6d 70 20 3d 20 6d 6e |e */. | mp = mn|
|00003c80| 61 6d 65 3b 0a 20 20 20 | 20 75 70 20 3d 20 75 6e |ame;. | up = un|
|00003c90| 61 6d 65 3b 0a 20 20 20 | 20 77 68 69 6c 65 20 28 |ame;. | while (|
|00003ca0| 28 63 68 20 3d 20 2a 6d | 70 2b 2b 29 20 21 3d 20 |(ch = *m|p++) != |
|00003cb0| 27 5c 30 27 29 20 7b 0a | 09 69 66 20 28 63 68 20 |'\0') {.|.if (ch |
|00003cc0| 3c 3d 20 27 20 27 20 7c | 7c 20 63 68 20 3e 20 27 |<= ' ' ||| ch > '|
|00003cd0| 7e 27 20 7c 7c 20 69 6e | 64 65 78 28 22 2f 21 28 |~' || in|dex("/!(|
|00003ce0| 29 5b 5d 2a 3c 3e 3f 5c | 5c 5c 22 24 5c 27 3b 26 |)[]*<>?\|\\"$\';&|
|00003cf0| 60 22 2c 20 63 68 29 20 | 21 3d 20 4e 55 4c 4c 29 |`", ch) |!= NULL)|
|00003d00| 0a 09 20 20 20 20 63 68 | 20 3d 20 27 5f 27 3b 0a |.. ch| = '_';.|
|00003d10| 09 2a 75 70 2b 2b 20 3d | 20 63 68 3b 0a 20 20 20 |.*up++ =| ch;. |
|00003d20| 20 7d 0a 20 20 20 20 2a | 75 70 20 3d 20 27 5c 30 | }. *|up = '\0|
|00003d30| 27 3b 0a 0a 20 20 20 20 | 2f 2a 20 67 65 74 20 6c |';.. |/* get l|
|00003d40| 6f 74 73 20 6f 66 20 6f | 74 68 65 72 20 73 74 75 |ots of o|ther stu|
|00003d50| 66 66 20 66 72 6f 6d 20 | 74 68 65 20 68 65 61 64 |ff from |the head|
|00003d60| 65 72 20 2a 2f 0a 20 20 | 20 20 66 2d 3e 63 6f 6d |er */. | f->com|
|00003d70| 70 52 4d 65 74 68 6f 64 | 20 3d 20 68 64 72 5b 46 |pRMethod| = hdr[F|
|00003d80| 5f 43 4f 4d 50 52 4d 45 | 54 48 4f 44 5d 3b 0a 20 |_COMPRME|THOD];. |
|00003d90| 20 20 20 66 2d 3e 63 6f | 6d 70 44 4d 65 74 68 6f | f->co|mpDMetho|
|00003da0| 64 20 3d 20 68 64 72 5b | 46 5f 43 4f 4d 50 44 4d |d = hdr[|F_COMPDM|
|00003db0| 45 54 48 4f 44 5d 3b 0a | 20 20 20 20 66 2d 3e 72 |ETHOD];.| f->r|
|00003dc0| 73 72 63 4c 65 6e 67 74 | 68 20 3d 20 67 65 74 34 |srcLengt|h = get4|
|00003dd0| 28 68 64 72 20 2b 20 46 | 5f 52 53 52 43 4c 45 4e |(hdr + F|_RSRCLEN|
|00003de0| 47 54 48 29 3b 0a 20 20 | 20 20 66 2d 3e 64 61 74 |GTH);. | f->dat|
|00003df0| 61 4c 65 6e 67 74 68 20 | 3d 20 67 65 74 34 28 68 |aLength |= get4(h|
|00003e00| 64 72 20 2b 20 46 5f 44 | 41 54 41 4c 45 4e 47 54 |dr + F_D|ATALENGT|
|00003e10| 48 29 3b 0a 20 20 20 20 | 66 2d 3e 63 6f 6d 70 52 |H);. |f->compR|
|00003e20| 4c 65 6e 67 74 68 20 3d | 20 67 65 74 34 28 68 64 |Length =| get4(hd|
|00003e30| 72 20 2b 20 46 5f 43 4f | 4d 50 52 4c 45 4e 47 54 |r + F_CO|MPRLENGT|
|00003e40| 48 29 3b 0a 20 20 20 20 | 66 2d 3e 63 6f 6d 70 44 |H);. |f->compD|
|00003e50| 4c 65 6e 67 74 68 20 3d | 20 67 65 74 34 28 68 64 |Length =| get4(hd|
|00003e60| 72 20 2b 20 46 5f 43 4f | 4d 50 44 4c 45 4e 47 54 |r + F_CO|MPDLENGT|
|00003e70| 48 29 3b 0a 20 20 20 20 | 66 2d 3e 72 73 72 63 43 |H);. |f->rsrcC|
|00003e80| 52 43 20 3d 20 67 65 74 | 32 28 68 64 72 20 2b 20 |RC = get|2(hdr + |
|00003e90| 46 5f 52 53 52 43 43 52 | 43 29 3b 0a 20 20 20 20 |F_RSRCCR|C);. |
|00003ea0| 66 2d 3e 64 61 74 61 43 | 52 43 20 3d 20 67 65 74 |f->dataC|RC = get|
|00003eb0| 32 28 68 64 72 20 2b 20 | 46 5f 44 41 54 41 43 52 |2(hdr + |F_DATACR|
|00003ec0| 43 29 3b 0a 0a 20 20 20 | 20 2f 2a 20 69 66 20 69 |C);.. | /* if i|
|00003ed0| 74 27 73 20 61 6e 20 65 | 6e 64 20 66 6f 6c 64 65 |t's an e|nd folde|
|00003ee0| 72 20 72 65 63 6f 72 64 | 2c 20 64 6f 6e 27 74 20 |r record|, don't |
|00003ef0| 6e 65 65 64 20 74 6f 20 | 64 6f 20 61 6e 79 20 6d |need to |do any m|
|00003f00| 6f 72 65 20 2a 2f 0a 20 | 20 20 20 69 66 20 28 66 |ore */. | if (f|
|00003f10| 2d 3e 63 6f 6d 70 52 4d | 65 74 68 6f 64 20 3d 3d |->compRM|ethod ==|
|00003f20| 20 65 6e 64 46 6f 6c 64 | 65 72 20 26 26 20 66 2d | endFold|er && f-|
|00003f30| 3e 63 6f 6d 70 44 4d 65 | 74 68 6f 64 20 3d 3d 20 |>compDMe|thod == |
|00003f40| 65 6e 64 46 6f 6c 64 65 | 72 29 0a 09 72 65 74 75 |endFolde|r)..retu|
|00003f50| 72 6e 28 48 5f 57 52 49 | 54 45 29 3b 0a 0a 20 20 |rn(H_WRI|TE);.. |
|00003f60| 20 20 2f 2a 20 70 72 65 | 70 61 72 65 20 61 6e 20 | /* pre|pare an |
|00003f70| 69 6e 66 6f 20 66 69 6c | 65 20 69 6e 20 63 61 73 |info fil|e in cas|
|00003f80| 65 20 69 74 73 20 6e 65 | 65 64 65 64 20 2a 2f 0a |e its ne|eded */.|
|00003f90| 0a 20 20 20 20 63 6f 70 | 79 28 69 6e 66 6f 20 2b |. cop|y(info +|
|00003fa0| 20 49 5f 54 59 50 45 4f | 46 46 2c 20 68 64 72 20 | I_TYPEO|FF, hdr |
|00003fb0| 2b 20 46 5f 46 54 59 50 | 45 2c 20 34 29 3b 0a 20 |+ F_FTYP|E, 4);. |
|00003fc0| 20 20 20 63 6f 70 79 28 | 69 6e 66 6f 20 2b 20 49 | copy(|info + I|
|00003fd0| 5f 41 55 54 48 4f 46 46 | 2c 20 68 64 72 20 2b 20 |_AUTHOFF|, hdr + |
|00003fe0| 46 5f 43 52 45 41 54 4f | 52 2c 20 34 29 3b 0a 20 |F_CREATO|R, 4);. |
|00003ff0| 20 20 20 63 6f 70 79 28 | 69 6e 66 6f 20 2b 20 49 | copy(|info + I|
|00004000| 5f 46 4c 41 47 4f 46 46 | 2c 20 68 64 72 20 2b 20 |_FLAGOFF|, hdr + |
|00004010| 46 5f 46 4e 44 52 46 4c | 41 47 53 2c 20 32 29 3b |F_FNDRFL|AGS, 2);|
|00004020| 0a 23 69 66 64 65 66 20 | 49 4e 49 54 45 44 5f 42 |.#ifdef |INITED_B|
|00004030| 55 47 0a 20 20 20 20 69 | 6e 66 6f 5b 49 4e 49 54 |UG. i|nfo[INIT|
|00004040| 45 44 5f 4f 46 46 5d 20 | 26 3d 20 49 4e 49 54 45 |ED_OFF] |&= INITE|
|00004050| 44 5f 4d 41 53 4b 3b 20 | 2f 2a 20 72 65 73 65 74 |D_MASK; |/* reset|
|00004060| 20 69 6e 69 74 20 62 69 | 74 20 2a 2f 0a 23 65 6e | init bi|t */.#en|
|00004070| 64 69 66 0a 20 20 20 20 | 63 6f 70 79 28 69 6e 66 |dif. |copy(inf|
|00004080| 6f 20 2b 20 49 5f 44 4c | 45 4e 4f 46 46 2c 20 68 |o + I_DL|ENOFF, h|
|00004090| 64 72 20 2b 20 46 5f 44 | 41 54 41 4c 45 4e 47 54 |dr + F_D|ATALENGT|
|000040a0| 48 2c 20 34 29 3b 0a 20 | 20 20 20 63 6f 70 79 28 |H, 4);. | copy(|
|000040b0| 69 6e 66 6f 20 2b 20 49 | 5f 52 4c 45 4e 4f 46 46 |info + I|_RLENOFF|
|000040c0| 2c 20 68 64 72 20 2b 20 | 46 5f 52 53 52 43 4c 45 |, hdr + |F_RSRCLE|
|000040d0| 4e 47 54 48 2c 20 34 29 | 3b 0a 20 20 20 20 63 6f |NGTH, 4)|;. co|
|000040e0| 70 79 28 69 6e 66 6f 20 | 2b 20 49 5f 43 54 49 4d |py(info |+ I_CTIM|
|000040f0| 4f 46 46 2c 20 68 64 72 | 20 2b 20 46 5f 43 52 45 |OFF, hdr| + F_CRE|
|00004100| 41 54 49 4f 4e 44 41 54 | 45 2c 20 34 29 3b 0a 20 |ATIONDAT|E, 4);. |
|00004110| 20 20 20 63 6f 70 79 28 | 69 6e 66 6f 20 2b 20 49 | copy(|info + I|
|00004120| 5f 4d 54 49 4d 4f 46 46 | 2c 20 68 64 72 20 2b 20 |_MTIMOFF|, hdr + |
|00004130| 46 5f 4d 4f 44 44 41 54 | 45 2c 20 34 29 3b 0a 0a |F_MODDAT|E, 4);..|
|00004140| 20 20 20 20 69 73 66 6f | 6c 64 65 72 20 3d 20 66 | isfo|lder = f|
|00004150| 2d 3e 63 6f 6d 70 52 4d | 65 74 68 6f 64 20 3d 3d |->compRM|ethod ==|
|00004160| 20 73 74 61 72 74 46 6f | 6c 64 65 72 20 26 26 20 | startFo|lder && |
|00004170| 66 2d 3e 63 6f 6d 70 44 | 4d 65 74 68 6f 64 20 3d |f->compD|Method =|
|00004180| 3d 20 73 74 61 72 74 46 | 6f 6c 64 65 72 3b 0a 09 |= startF|older;..|
|00004190| 0a 20 20 20 20 2f 2a 20 | 6c 69 73 74 20 74 68 65 |. /* |list the|
|000041a0| 20 66 69 6c 65 20 6e 61 | 6d 65 20 69 66 20 76 65 | file na|me if ve|
|000041b0| 72 62 6f 73 65 20 6f 72 | 20 6c 69 73 74 6f 6e 6c |rbose or| listonl|
|000041c0| 79 20 6d 6f 64 65 2c 20 | 61 6c 73 6f 20 69 66 20 |y mode, |also if |
|000041d0| 71 75 65 72 79 20 6d 6f | 64 65 20 2a 2f 0a 20 20 |query mo|de */. |
|000041e0| 20 20 69 66 20 28 73 6b | 69 70 29 09 09 09 2f 2a | if (sk|ip).../*|
|000041f0| 20 73 6b 69 70 20 3d 20 | 31 20 69 66 20 73 6b 69 | skip = |1 if ski|
|00004200| 70 70 69 6e 67 20 61 6c | 6c 20 69 6e 20 74 68 69 |pping al|l in thi|
|00004210| 73 20 66 6f 6c 64 65 72 | 20 2a 2f 0a 09 77 72 69 |s folder| */..wri|
|00004220| 74 65 5f 69 74 20 3d 20 | 30 3b 0a 20 20 20 20 65 |te_it = |0;. e|
|00004230| 6c 73 65 20 7b 0a 09 77 | 72 69 74 65 5f 69 74 20 |lse {..w|rite_it |
|00004240| 3d 20 31 3b 0a 09 69 66 | 20 28 6c 69 73 74 6f 6e |= 1;..if| (liston|
|00004250| 6c 79 20 7c 7c 20 76 65 | 72 62 6f 73 65 20 7c 7c |ly || ve|rbose |||
|00004260| 20 71 75 65 72 79 29 20 | 7b 0a 09 20 20 20 20 66 | query) |{.. f|
|00004270| 6f 72 20 28 69 20 3d 20 | 30 3b 20 69 20 3c 20 64 |or (i = |0; i < d|
|00004280| 65 70 74 68 3b 20 69 2b | 2b 29 0a 09 09 70 75 74 |epth; i+|+)...put|
|00004290| 63 68 61 72 28 27 20 27 | 29 3b 0a 09 20 20 20 20 |char(' '|);.. |
|000042a0| 69 66 20 28 69 73 66 6f | 6c 64 65 72 29 0a 09 09 |if (isfo|lder)...|
|000042b0| 70 72 69 6e 74 66 28 22 | 46 6f 6c 64 65 72 3a 20 |printf("|Folder: |
|000042c0| 5c 22 25 73 5c 22 22 2c | 20 75 6e 61 6d 65 29 3b |\"%s\"",| uname);|
|000042d0| 0a 09 20 20 20 20 65 6c | 73 65 0a 09 09 70 72 69 |.. el|se...pri|
|000042e0| 6e 74 66 28 22 6e 61 6d | 65 3d 5c 22 25 73 5c 22 |ntf("nam|e=\"%s\"|
|000042f0| 2c 20 74 79 70 65 3d 25 | 34 2e 34 73 2c 20 61 75 |, type=%|4.4s, au|
|00004300| 74 68 6f 72 3d 25 34 2e | 34 73 2c 20 64 61 74 61 |thor=%4.|4s, data|
|00004310| 3d 25 6c 64 2c 20 72 73 | 72 63 3d 25 6c 64 22 2c |=%ld, rs|rc=%ld",|
|00004320| 0a 09 09 20 20 20 20 20 | 20 20 75 6e 61 6d 65 2c |... | uname,|
|00004330| 20 68 64 72 20 2b 20 46 | 5f 46 54 59 50 45 2c 20 | hdr + F|_FTYPE, |
|00004340| 68 64 72 20 2b 20 46 5f | 43 52 45 41 54 4f 52 2c |hdr + F_|CREATOR,|
|00004350| 0a 09 09 20 20 20 20 20 | 20 20 66 2d 3e 64 61 74 |... | f->dat|
|00004360| 61 4c 65 6e 67 74 68 2c | 20 66 2d 3e 72 73 72 63 |aLength,| f->rsrc|
|00004370| 4c 65 6e 67 74 68 29 3b | 0a 09 20 20 20 20 69 66 |Length);|.. if|
|00004380| 20 28 71 75 65 72 79 29 | 20 7b 09 2f 2a 20 69 66 | (query)| {./* if|
|00004390| 20 71 75 65 72 79 69 6e | 67 2c 20 63 68 65 63 6b | queryin|g, check|
|000043a0| 20 77 69 74 68 20 74 68 | 65 20 62 6f 73 73 20 2a | with th|e boss *|
|000043b0| 2f 0a 09 09 70 72 69 6e | 74 66 28 22 20 3f 20 22 |/...prin|tf(" ? "|
|000043c0| 29 3b 0a 09 09 66 67 65 | 74 73 28 74 65 6d 70 2c |);...fge|ts(temp,|
|000043d0| 20 73 69 7a 65 6f 66 28 | 74 65 6d 70 29 20 2d 20 | sizeof(|temp) - |
|000043e0| 31 2c 20 73 74 64 69 6e | 29 3b 0a 09 09 74 70 20 |1, stdin|);...tp |
|000043f0| 3d 20 74 65 6d 70 3b 0a | 09 09 77 72 69 74 65 5f |= temp;.|..write_|
|00004400| 69 74 20 3d 20 30 3b 0a | 09 09 77 68 69 6c 65 20 |it = 0;.|..while |
|00004410| 28 2a 74 70 20 21 3d 20 | 27 5c 30 27 29 20 7b 0a |(*tp != |'\0') {.|
|00004420| 09 09 20 20 20 20 69 66 | 20 28 2a 74 70 20 3d 3d |.. if| (*tp ==|
|00004430| 20 27 79 27 20 7c 7c 20 | 2a 74 70 20 3d 3d 20 27 | 'y' || |*tp == '|
|00004440| 59 27 29 20 7b 0a 09 09 | 09 77 72 69 74 65 5f 69 |Y') {...|.write_i|
|00004450| 74 20 3d 20 31 3b 0a 09 | 09 09 62 72 65 61 6b 3b |t = 1;..|..break;|
|00004460| 0a 09 09 20 20 20 20 7d | 0a 09 09 20 20 20 20 65 |... }|... e|
|00004470| 6c 73 65 0a 09 09 09 74 | 70 2b 2b 3b 0a 09 09 7d |lse....t|p++;...}|
|00004480| 0a 09 20 20 20 20 7d 0a | 09 20 20 20 20 65 6c 73 |.. }.|. els|
|00004490| 65 09 09 2f 2a 20 6f 74 | 68 65 72 77 69 73 65 2c |e../* ot|herwise,|
|000044a0| 20 74 65 72 6d 69 6e 61 | 74 65 20 74 68 65 20 6c | termina|te the l|
|000044b0| 69 6e 65 20 2a 2f 0a 09 | 09 70 75 74 63 68 61 72 |ine */..|.putchar|
|000044c0| 28 27 5c 6e 27 29 3b 0a | 09 7d 0a 20 20 20 20 7d |('\n');.|.}. }|
|000044d0| 0a 20 20 20 20 72 65 74 | 75 72 6e 28 77 72 69 74 |. ret|urn(writ|
|000044e0| 65 5f 69 74 20 3f 20 48 | 5f 57 52 49 54 45 20 3a |e_it ? H|_WRITE :|
|000044f0| 20 48 5f 53 4b 49 50 29 | 3b 0a 7d 0a 0a 63 68 65 | H_SKIP)|;.}..che|
|00004500| 63 6b 5f 61 63 63 65 73 | 73 28 66 6e 61 6d 65 29 |ck_acces|s(fname)|
|00004510| 09 2f 2a 20 72 65 74 75 | 72 6e 20 30 20 69 66 20 |./* retu|rn 0 if |
|00004520| 4f 4b 20 74 6f 20 77 72 | 69 74 65 20 6f 6e 20 66 |OK to wr|ite on f|
|00004530| 69 6c 65 20 66 6e 61 6d | 65 2c 20 2d 31 20 6f 74 |ile fnam|e, -1 ot|
|00004540| 68 65 72 77 69 73 65 20 | 2a 2f 0a 63 68 61 72 20 |herwise |*/.char |
|00004550| 2a 66 6e 61 6d 65 3b 0a | 7b 0a 20 20 20 20 63 68 |*fname;.|{. ch|
|00004560| 61 72 20 74 65 6d 70 5b | 31 30 5d 2c 20 2a 74 70 |ar temp[|10], *tp|
|00004570| 3b 0a 0a 20 20 20 20 69 | 66 20 28 61 63 63 65 73 |;.. i|f (acces|
|00004580| 73 28 66 6e 61 6d 65 2c | 20 30 29 20 3d 3d 20 2d |s(fname,| 0) == -|
|00004590| 31 29 20 7b 0a 09 72 65 | 74 75 72 6e 28 30 29 3b |1) {..re|turn(0);|
|000045a0| 0a 20 20 20 20 7d 0a 20 | 20 20 20 65 6c 73 65 20 |. }. | else |
|000045b0| 7b 0a 09 70 72 69 6e 74 | 66 28 22 25 73 20 65 78 |{..print|f("%s ex|
|000045c0| 69 73 74 73 2e 20 20 4f | 76 65 72 77 72 69 74 65 |ists. O|verwrite|
|000045d0| 3f 20 22 2c 20 66 6e 61 | 6d 65 29 3b 0a 09 66 67 |? ", fna|me);..fg|
|000045e0| 65 74 73 28 74 65 6d 70 | 2c 20 73 69 7a 65 6f 66 |ets(temp|, sizeof|
|000045f0| 28 74 65 6d 70 29 20 2d | 20 31 2c 20 73 74 64 69 |(temp) -| 1, stdi|
|00004600| 6e 29 3b 0a 09 74 70 20 | 3d 20 74 65 6d 70 3b 0a |n);..tp |= temp;.|
|00004610| 09 77 68 69 6c 65 20 28 | 2a 74 70 20 21 3d 20 27 |.while (|*tp != '|
|00004620| 5c 30 27 29 20 7b 0a 09 | 20 20 20 20 69 66 20 28 |\0') {..| if (|
|00004630| 2a 74 70 20 3d 3d 20 27 | 79 27 20 7c 7c 20 2a 74 |*tp == '|y' || *t|
|00004640| 70 20 3d 3d 20 27 59 27 | 29 20 7b 0a 09 09 72 65 |p == 'Y'|) {...re|
|00004650| 74 75 72 6e 28 30 29 3b | 0a 09 20 20 20 20 7d 0a |turn(0);|.. }.|
|00004660| 09 20 20 20 20 65 6c 73 | 65 0a 09 09 74 70 2b 2b |. els|e...tp++|
|00004670| 3b 0a 09 7d 0a 20 20 20 | 20 7d 0a 20 20 20 20 72 |;..}. | }. r|
|00004680| 65 74 75 72 6e 28 2d 31 | 29 3b 0a 7d 0a 0a 75 6e |eturn(-1|);.}..un|
|00004690| 73 69 67 6e 65 64 20 73 | 68 6f 72 74 20 77 72 69 |signed s|hort wri|
|000046a0| 74 65 5f 66 69 6c 65 28 | 66 6e 61 6d 65 2c 20 69 |te_file(|fname, i|
|000046b0| 62 79 74 65 73 2c 20 6f | 62 79 74 65 73 2c 20 74 |bytes, o|bytes, t|
|000046c0| 79 70 65 29 0a 63 68 61 | 72 20 2a 66 6e 61 6d 65 |ype).cha|r *fname|
|000046d0| 3b 0a 75 6e 73 69 67 6e | 65 64 20 6c 6f 6e 67 20 |;.unsign|ed long |
|000046e0| 69 62 79 74 65 73 2c 20 | 6f 62 79 74 65 73 3b 0a |ibytes, |obytes;.|
|000046f0| 75 6e 73 69 67 6e 65 64 | 20 63 68 61 72 20 74 79 |unsigned| char ty|
|00004700| 70 65 3b 0a 7b 0a 20 20 | 20 20 75 6e 73 69 67 6e |pe;.{. | unsign|
|00004710| 65 64 20 73 68 6f 72 74 | 20 63 72 63 3b 0a 20 20 |ed short| crc;. |
|00004720| 20 20 69 6e 74 20 69 2c | 20 6e 2c 20 63 68 2c 20 | int i,| n, ch, |
|00004730| 6c 61 73 74 63 68 3b 0a | 20 20 20 20 46 49 4c 45 |lastch;.| FILE|
|00004740| 20 2a 6f 75 74 66 3b 0a | 20 20 20 20 63 68 61 72 | *outf;.| char|
|00004750| 20 74 65 6d 70 5b 32 35 | 36 5d 3b 0a 0a 20 20 20 | temp[25|6];.. |
|00004760| 20 63 72 63 20 3d 20 49 | 4e 49 54 5f 43 52 43 3b | crc = I|NIT_CRC;|
|00004770| 0a 20 20 20 20 63 68 6b | 63 72 63 20 3d 20 31 3b |. chk|crc = 1;|
|00004780| 09 09 09 2f 2a 20 75 73 | 75 61 6c 6c 79 20 63 61 |.../* us|ually ca|
|00004790| 6e 20 63 68 65 63 6b 20 | 74 68 65 20 43 52 43 20 |n check |the CRC |
|000047a0| 2a 2f 0a 0a 20 20 20 20 | 69 66 20 28 63 68 65 63 |*/.. |if (chec|
|000047b0| 6b 5f 61 63 63 65 73 73 | 28 66 6e 61 6d 65 29 20 |k_access|(fname) |
|000047c0| 3d 3d 20 2d 31 29 20 7b | 0a 09 66 73 65 65 6b 28 |== -1) {|..fseek(|
|000047d0| 69 6e 66 70 2c 20 69 62 | 79 74 65 73 2c 20 31 29 |infp, ib|ytes, 1)|
|000047e0| 3b 0a 09 63 68 6b 63 72 | 63 20 3d 20 30 3b 09 09 |;..chkcr|c = 0;..|
|000047f0| 2f 2a 20 69 6e 68 69 62 | 69 74 20 63 72 63 20 63 |/* inhib|it crc c|
|00004800| 68 65 63 6b 20 69 66 20 | 66 69 6c 65 20 6e 6f 74 |heck if |file not|
|00004810| 20 77 72 69 74 74 65 6e | 20 2a 2f 0a 20 20 20 20 | written| */. |
|00004820| 09 72 65 74 75 72 6e 28 | 2d 31 29 3b 0a 20 20 20 |.return(|-1);. |
|00004830| 20 7d 0a 09 0a 20 20 20 | 20 73 77 69 74 63 68 20 | }... | switch |
|00004840| 28 74 79 70 65 29 20 7b | 0a 20 20 20 20 20 20 63 |(type) {|. c|
|00004850| 61 73 65 20 6e 6f 43 6f | 6d 70 3a 09 09 2f 2a 20 |ase noCo|mp:../* |
|00004860| 6e 6f 20 63 6f 6d 70 72 | 65 73 73 69 6f 6e 20 2a |no compr|ession *|
|00004870| 2f 0a 09 6f 75 74 66 20 | 3d 20 66 6f 70 65 6e 28 |/..outf |= fopen(|
|00004880| 66 6e 61 6d 65 2c 20 22 | 77 22 29 3b 0a 09 69 66 |fname, "|w");..if|
|00004890| 20 28 6f 75 74 66 20 3d | 3d 20 4e 55 4c 4c 29 20 | (outf =|= NULL) |
|000048a0| 7b 0a 09 20 20 20 20 70 | 65 72 72 6f 72 28 66 6e |{.. p|error(fn|
|000048b0| 61 6d 65 29 3b 0a 09 20 | 20 20 20 65 78 69 74 28 |ame);.. | exit(|
|000048c0| 31 29 3b 0a 09 7d 0a 09 | 77 68 69 6c 65 20 28 69 |1);..}..|while (i|
|000048d0| 62 79 74 65 73 20 3e 20 | 30 29 20 7b 0a 09 20 20 |bytes > |0) {.. |
|000048e0| 20 20 6e 20 3d 20 28 69 | 62 79 74 65 73 20 3e 20 | n = (i|bytes > |
|000048f0| 49 4f 42 55 46 53 49 5a | 29 20 3f 20 49 4f 42 55 |IOBUFSIZ|) ? IOBU|
|00004900| 46 53 49 5a 20 3a 20 69 | 62 79 74 65 73 3b 0a 09 |FSIZ : i|bytes;..|
|00004910| 20 20 20 20 6e 20 3d 20 | 66 72 65 61 64 28 69 6f | n = |fread(io|
|00004920| 62 75 66 2c 20 31 2c 20 | 6e 2c 20 69 6e 66 70 29 |buf, 1, |n, infp)|
|00004930| 3b 0a 09 20 20 20 20 69 | 66 20 28 6e 20 3d 3d 20 |;.. i|f (n == |
|00004940| 30 29 0a 09 09 62 72 65 | 61 6b 3b 0a 09 20 20 20 |0)...bre|ak;.. |
|00004950| 20 63 72 63 20 3d 20 75 | 70 64 63 72 63 28 63 72 | crc = u|pdcrc(cr|
|00004960| 63 2c 20 69 6f 62 75 66 | 2c 20 6e 29 3b 0a 09 20 |c, iobuf|, n);.. |
|00004970| 20 20 20 6f 75 74 63 28 | 69 6f 62 75 66 2c 20 6e | outc(|iobuf, n|
|00004980| 2c 20 6f 75 74 66 29 3b | 0a 09 20 20 20 20 69 62 |, outf);|.. ib|
|00004990| 79 74 65 73 20 2d 3d 20 | 6e 3b 0a 09 7d 0a 09 66 |ytes -= |n;..}..f|
|000049a0| 63 6c 6f 73 65 28 6f 75 | 74 66 29 3b 0a 09 62 72 |close(ou|tf);..br|
|000049b0| 65 61 6b 3b 0a 20 20 20 | 20 20 20 63 61 73 65 20 |eak;. | case |
|000049c0| 72 6c 65 43 6f 6d 70 3a | 09 09 2f 2a 20 72 75 6e |rleComp:|../* run|
|000049d0| 20 6c 65 6e 67 74 68 20 | 65 6e 63 6f 64 69 6e 67 | length |encoding|
|000049e0| 20 2a 2f 0a 09 6f 75 74 | 66 20 3d 20 66 6f 70 65 | */..out|f = fope|
|000049f0| 6e 28 66 6e 61 6d 65 2c | 20 22 77 22 29 3b 0a 09 |n(fname,| "w");..|
|00004a00| 69 66 20 28 6f 75 74 66 | 20 3d 3d 20 4e 55 4c 4c |if (outf| == NULL|
|00004a10| 29 20 7b 0a 09 20 20 20 | 20 70 65 72 72 6f 72 28 |) {.. | perror(|
|00004a20| 66 6e 61 6d 65 29 3b 0a | 09 20 20 20 20 65 78 69 |fname);.|. exi|
|00004a30| 74 28 31 29 3b 0a 09 7d | 0a 09 77 68 69 6c 65 20 |t(1);..}|..while |
|00004a40| 28 69 62 79 74 65 73 20 | 3e 20 30 29 20 7b 0a 09 |(ibytes |> 0) {..|
|00004a50| 20 20 20 20 63 68 20 3d | 20 67 65 74 63 28 69 6e | ch =| getc(in|
|00004a60| 66 70 29 20 26 20 30 78 | 66 66 3b 0a 09 20 20 20 |fp) & 0x|ff;.. |
|00004a70| 20 69 62 79 74 65 73 2d | 2d 3b 0a 09 20 20 20 20 | ibytes-|-;.. |
|00004a80| 69 66 20 28 63 68 20 3d | 3d 20 30 78 39 30 29 20 |if (ch =|= 0x90) |
|00004a90| 7b 09 2f 2a 20 73 65 65 | 20 69 66 20 69 74 73 20 |{./* see| if its |
|00004aa0| 74 68 65 20 72 65 70 65 | 61 74 20 6d 61 72 6b 65 |the repe|at marke|
|00004ab0| 72 20 2a 2f 0a 09 09 6e | 20 3d 20 67 65 74 63 28 |r */...n| = getc(|
|00004ac0| 69 6e 66 70 29 20 26 20 | 30 78 66 66 3b 20 2f 2a |infp) & |0xff; /*|
|00004ad0| 20 67 65 74 20 74 68 65 | 20 72 65 70 65 61 74 20 | get the| repeat |
|00004ae0| 63 6f 75 6e 74 20 2a 2f | 0a 09 09 69 62 79 74 65 |count */|...ibyte|
|00004af0| 73 2d 2d 3b 0a 09 09 69 | 66 20 28 6e 20 3d 3d 20 |s--;...i|f (n == |
|00004b00| 30 29 20 7b 20 2f 2a 20 | 30 78 39 30 20 77 61 73 |0) { /* |0x90 was|
|00004b10| 20 72 65 61 6c 6c 79 20 | 61 6e 20 30 78 39 30 20 | really |an 0x90 |
|00004b20| 2a 2f 0a 09 09 20 20 20 | 20 69 6f 62 75 66 5b 30 |*/... | iobuf[0|
|00004b30| 5d 20 3d 20 30 78 39 30 | 3b 0a 09 09 20 20 20 20 |] = 0x90|;... |
|00004b40| 63 72 63 20 3d 20 75 70 | 64 63 72 63 28 63 72 63 |crc = up|dcrc(crc|
|00004b50| 2c 20 69 6f 62 75 66 2c | 20 31 29 3b 0a 09 09 20 |, iobuf,| 1);... |
|00004b60| 20 20 20 6f 75 74 63 28 | 69 6f 62 75 66 2c 20 31 | outc(|iobuf, 1|
|00004b70| 2c 20 6f 75 74 66 29 3b | 0a 09 09 7d 0a 09 09 65 |, outf);|...}...e|
|00004b80| 6c 73 65 20 7b 0a 09 09 | 20 20 20 20 6e 2d 2d 3b |lse {...| n--;|
|00004b90| 0a 09 09 20 20 20 20 66 | 6f 72 20 28 69 20 3d 20 |... f|or (i = |
|00004ba0| 30 3b 20 69 20 3c 20 6e | 3b 20 69 2b 2b 29 0a 09 |0; i < n|; i++)..|
|00004bb0| 09 09 69 6f 62 75 66 5b | 69 5d 20 3d 20 6c 61 73 |..iobuf[|i] = las|
|00004bc0| 74 63 68 3b 0a 09 09 20 | 20 20 20 63 72 63 20 3d |tch;... | crc =|
|00004bd0| 20 75 70 64 63 72 63 28 | 63 72 63 2c 20 69 6f 62 | updcrc(|crc, iob|
|00004be0| 75 66 2c 20 6e 29 3b 0a | 09 09 20 20 20 20 6f 75 |uf, n);.|.. ou|
|00004bf0| 74 63 28 69 6f 62 75 66 | 2c 20 6e 2c 20 6f 75 74 |tc(iobuf|, n, out|
|00004c00| 66 29 3b 0a 09 09 7d 0a | 09 20 20 20 20 7d 0a 09 |f);...}.|. }..|
|00004c10| 20 20 20 20 65 6c 73 65 | 20 7b 0a 09 09 69 6f 62 | else| {...iob|
|00004c20| 75 66 5b 30 5d 20 3d 20 | 63 68 3b 0a 09 09 63 72 |uf[0] = |ch;...cr|
|00004c30| 63 20 3d 20 75 70 64 63 | 72 63 28 63 72 63 2c 20 |c = updc|rc(crc, |
|00004c40| 69 6f 62 75 66 2c 20 31 | 29 3b 0a 09 09 6c 61 73 |iobuf, 1|);...las|
|00004c50| 74 63 68 20 3d 20 63 68 | 3b 0a 09 09 6f 75 74 63 |tch = ch|;...outc|
|00004c60| 28 69 6f 62 75 66 2c 20 | 31 2c 20 6f 75 74 66 29 |(iobuf, |1, outf)|
|00004c70| 3b 0a 09 20 20 20 20 7d | 0a 09 7d 0a 09 66 63 6c |;.. }|..}..fcl|
|00004c80| 6f 73 65 28 6f 75 74 66 | 29 3b 0a 09 62 72 65 61 |ose(outf|);..brea|
|00004c90| 6b 3b 0a 20 20 20 20 20 | 20 63 61 73 65 20 6c 7a |k;. | case lz|
|00004ca0| 77 43 6f 6d 70 3a 09 09 | 2f 2a 20 4c 5a 57 20 63 |wComp:..|/* LZW c|
|00004cb0| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 2a 2f 0a 09 73 |ompressi|on */..s|
|00004cc0| 70 72 69 6e 74 66 28 74 | 65 6d 70 2c 20 22 25 73 |printf(t|emp, "%s|
|00004cd0| 25 73 22 2c 20 43 4f 4d | 50 52 45 53 53 2c 20 22 |%s", COM|PRESS, "|
|00004ce0| 20 2d 64 20 2d 63 20 2d | 6e 20 2d 62 20 31 34 20 | -d -c -|n -b 14 |
|00004cf0| 22 29 3b 0a 09 69 66 20 | 28 74 78 74 6d 6f 64 65 |");..if |(txtmode|
|00004d00| 29 20 7b 0a 09 20 20 20 | 20 73 74 72 63 61 74 28 |) {.. | strcat(|
|00004d10| 74 65 6d 70 2c 20 22 7c | 20 74 72 20 5c 27 5c 5c |temp, "|| tr \'\\|
|00004d20| 30 31 35 5c 27 20 5c 27 | 5c 5c 30 31 32 5c 27 20 |015\' \'|\\012\' |
|00004d30| 22 29 3b 0a 09 20 20 20 | 20 63 68 6b 63 72 63 20 |");.. | chkcrc |
|00004d40| 3d 20 30 3b 09 09 2f 2a | 20 63 61 6e 27 74 20 63 |= 0;../*| can't c|
|00004d50| 68 65 63 6b 20 43 52 43 | 20 69 6e 20 74 68 69 73 |heck CRC| in this|
|00004d60| 20 63 61 73 65 20 2a 2f | 0a 09 7d 0a 09 73 74 72 | case */|..}..str|
|00004d70| 63 61 74 28 74 65 6d 70 | 2c 20 22 3e 20 27 22 29 |cat(temp|, "> '")|
|00004d80| 3b 0a 09 73 74 72 63 61 | 74 28 74 65 6d 70 2c 20 |;..strca|t(temp, |
|00004d90| 66 6e 61 6d 65 29 3b 0a | 09 73 74 72 63 61 74 28 |fname);.|.strcat(|
|00004da0| 74 65 6d 70 2c 20 22 27 | 22 29 3b 0a 09 6f 75 74 |temp, "'|");..out|
|00004db0| 66 20 3d 20 70 6f 70 65 | 6e 28 74 65 6d 70 2c 20 |f = pope|n(temp, |
|00004dc0| 22 77 22 29 3b 0a 09 69 | 66 20 28 6f 75 74 66 20 |"w");..i|f (outf |
|00004dd0| 3d 3d 20 4e 55 4c 4c 29 | 20 7b 0a 09 20 20 20 20 |== NULL)| {.. |
|00004de0| 70 65 72 72 6f 72 28 66 | 6e 61 6d 65 29 3b 0a 09 |perror(f|name);..|
|00004df0| 20 20 20 20 65 78 69 74 | 28 31 29 3b 0a 09 7d 0a | exit|(1);..}.|
|00004e00| 09 77 68 69 6c 65 20 28 | 69 62 79 74 65 73 20 3e |.while (|ibytes >|
|00004e10| 20 30 29 20 7b 0a 09 20 | 20 20 20 6e 20 3d 20 28 | 0) {.. | n = (|
|00004e20| 69 62 79 74 65 73 20 3e | 20 49 4f 42 55 46 53 49 |ibytes >| IOBUFSI|
|00004e30| 5a 29 20 3f 20 49 4f 42 | 55 46 53 49 5a 20 3a 20 |Z) ? IOB|UFSIZ : |
|00004e40| 69 62 79 74 65 73 3b 0a | 09 20 20 20 20 6e 20 3d |ibytes;.|. n =|
|00004e50| 20 66 72 65 61 64 28 69 | 6f 62 75 66 2c 20 31 2c | fread(i|obuf, 1,|
|00004e60| 20 6e 2c 20 69 6e 66 70 | 29 3b 0a 09 20 20 20 20 | n, infp|);.. |
|00004e70| 69 66 20 28 6e 20 3d 3d | 20 30 29 0a 09 09 62 72 |if (n ==| 0)...br|
|00004e80| 65 61 6b 3b 0a 09 20 20 | 20 20 66 77 72 69 74 65 |eak;.. | fwrite|
|00004e90| 28 69 6f 62 75 66 2c 20 | 31 2c 20 6e 2c 20 6f 75 |(iobuf, |1, n, ou|
|00004ea0| 74 66 29 3b 0a 09 20 20 | 20 20 69 62 79 74 65 73 |tf);.. | ibytes|
|00004eb0| 20 2d 3d 20 6e 3b 0a 09 | 7d 0a 09 70 63 6c 6f 73 | -= n;..|}..pclos|
|00004ec0| 65 28 6f 75 74 66 29 3b | 0a 09 69 66 20 28 63 68 |e(outf);|..if (ch|
|00004ed0| 6b 63 72 63 29 20 7b 0a | 09 20 20 20 20 6f 75 74 |kcrc) {.|. out|
|00004ee0| 66 20 3d 20 66 6f 70 65 | 6e 28 66 6e 61 6d 65 2c |f = fope|n(fname,|
|00004ef0| 20 22 72 22 29 3b 20 2f | 2a 20 72 65 61 64 20 74 | "r"); /|* read t|
|00004f00| 68 65 20 66 69 6c 65 20 | 74 6f 20 67 65 74 20 43 |he file |to get C|
|00004f10| 52 43 20 76 61 6c 75 65 | 20 2a 2f 0a 09 20 20 20 |RC value| */.. |
|00004f20| 20 69 66 20 28 6f 75 74 | 66 20 3d 3d 20 4e 55 4c | if (out|f == NUL|
|00004f30| 4c 29 20 7b 0a 09 09 70 | 65 72 72 6f 72 28 66 6e |L) {...p|error(fn|
|00004f40| 61 6d 65 29 3b 0a 09 09 | 65 78 69 74 28 31 29 3b |ame);...|exit(1);|
|00004f50| 0a 09 20 20 20 20 7d 0a | 09 20 20 20 20 77 68 69 |.. }.|. whi|
|00004f60| 6c 65 20 28 31 29 20 7b | 0a 09 09 6e 20 3d 20 66 |le (1) {|...n = f|
|00004f70| 72 65 61 64 28 69 6f 62 | 75 66 2c 20 31 2c 20 49 |read(iob|uf, 1, I|
|00004f80| 4f 42 55 46 53 49 5a 2c | 20 6f 75 74 66 29 3b 0a |OBUFSIZ,| outf);.|
|00004f90| 09 09 69 66 20 28 6e 20 | 3d 3d 20 30 29 0a 09 09 |..if (n |== 0)...|
|00004fa0| 20 20 20 20 62 72 65 61 | 6b 3b 0a 09 09 63 72 63 | brea|k;...crc|
|00004fb0| 20 3d 20 75 70 64 63 72 | 63 28 63 72 63 2c 20 69 | = updcr|c(crc, i|
|00004fc0| 6f 62 75 66 2c 20 6e 29 | 3b 0a 09 20 20 20 20 7d |obuf, n)|;.. }|
|00004fd0| 0a 09 20 20 20 20 66 63 | 6c 6f 73 65 28 6f 75 74 |.. fc|lose(out|
|00004fe0| 66 29 3b 0a 09 7d 0a 09 | 62 72 65 61 6b 3b 0a 20 |f);..}..|break;. |
|00004ff0| 20 20 20 20 20 63 61 73 | 65 20 68 75 66 43 6f 6d | cas|e hufCom|
|00005000| 70 3a 09 09 2f 2a 20 48 | 75 66 66 6d 61 6e 20 63 |p:../* H|uffman c|
|00005010| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 2a 2f 0a 09 6f |ompressi|on */..o|
|00005020| 75 74 66 20 3d 20 66 6f | 70 65 6e 28 66 6e 61 6d |utf = fo|pen(fnam|
|00005030| 65 2c 20 22 77 22 29 3b | 0a 09 69 66 20 28 6f 75 |e, "w");|..if (ou|
|00005040| 74 66 20 3d 3d 20 4e 55 | 4c 4c 29 20 7b 0a 09 20 |tf == NU|LL) {.. |
|00005050| 20 20 20 70 65 72 72 6f | 72 28 66 6e 61 6d 65 29 | perro|r(fname)|
|00005060| 3b 0a 09 20 20 20 20 65 | 78 69 74 28 31 29 3b 0a |;.. e|xit(1);.|
|00005070| 09 7d 0a 09 6e 6f 64 65 | 70 74 72 20 3d 20 6e 6f |.}..node|ptr = no|
|00005080| 64 65 6c 69 73 74 3b 0a | 09 62 69 74 20 3d 20 30 |delist;.|.bit = 0|
|00005090| 3b 09 09 2f 2a 20 70 75 | 74 20 75 73 20 6f 6e 20 |;../* pu|t us on |
|000050a0| 61 20 62 79 74 65 20 62 | 6f 75 6e 64 61 72 79 20 |a byte b|oundary |
|000050b0| 2a 2f 0a 09 72 65 61 64 | 5f 74 72 65 65 28 29 3b |*/..read|_tree();|
|000050c0| 0a 09 77 68 69 6c 65 20 | 28 6f 62 79 74 65 73 20 |..while |(obytes |
|000050d0| 3e 20 30 29 20 7b 0a 09 | 20 20 20 20 6e 20 3d 20 |> 0) {..| n = |
|000050e0| 28 6f 62 79 74 65 73 20 | 3e 20 49 4f 42 55 46 53 |(obytes |> IOBUFS|
|000050f0| 49 5a 29 20 3f 20 49 4f | 42 55 46 53 49 5a 20 3a |IZ) ? IO|BUFSIZ :|
|00005100| 20 6f 62 79 74 65 73 3b | 0a 09 20 20 20 20 66 6f | obytes;|.. fo|
|00005110| 72 20 28 69 20 3d 20 30 | 3b 20 69 20 3c 20 6e 3b |r (i = 0|; i < n;|
|00005120| 20 69 2b 2b 29 0a 09 09 | 69 6f 62 75 66 5b 69 5d | i++)...|iobuf[i]|
|00005130| 20 3d 20 67 65 74 68 75 | 66 66 62 79 74 65 28 44 | = gethu|ffbyte(D|
|00005140| 45 43 4f 44 45 29 3b 0a | 09 20 20 20 20 63 72 63 |ECODE);.|. crc|
|00005150| 20 3d 20 75 70 64 63 72 | 63 28 63 72 63 2c 20 69 | = updcr|c(crc, i|
|00005160| 6f 62 75 66 2c 20 6e 29 | 3b 0a 09 20 20 20 20 6f |obuf, n)|;.. o|
|00005170| 75 74 63 28 69 6f 62 75 | 66 2c 20 6e 2c 20 6f 75 |utc(iobu|f, n, ou|
|00005180| 74 66 29 3b 0a 09 20 20 | 20 20 6f 62 79 74 65 73 |tf);.. | obytes|
|00005190| 20 2d 3d 20 6e 3b 0a 09 | 7d 0a 09 66 63 6c 6f 73 | -= n;..|}..fclos|
|000051a0| 65 28 6f 75 74 66 29 3b | 0a 09 62 72 65 61 6b 3b |e(outf);|..break;|
|000051b0| 0a 20 20 20 20 20 20 64 | 65 66 61 75 6c 74 3a 0a |. d|efault:.|
|000051c0| 09 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c |.fprintf|(stderr,|
|000051d0| 20 22 55 6e 6b 6e 6f 77 | 6e 20 63 6f 6d 70 72 65 | "Unknow|n compre|
|000051e0| 73 73 69 6f 6e 20 6d 65 | 74 68 6f 64 5c 6e 22 29 |ssion me|thod\n")|
|000051f0| 3b 0a 09 63 68 6b 63 72 | 63 20 3d 20 30 3b 09 09 |;..chkcr|c = 0;..|
|00005200| 2f 2a 20 69 6e 68 69 62 | 69 74 20 63 72 63 20 63 |/* inhib|it crc c|
|00005210| 68 65 63 6b 20 69 66 20 | 66 69 6c 65 20 6e 6f 74 |heck if |file not|
|00005220| 20 77 72 69 74 74 65 6e | 20 2a 2f 0a 09 72 65 74 | written| */..ret|
|00005230| 75 72 6e 28 2d 31 29 3b | 0a 20 20 20 20 7d 0a 0a |urn(-1);|. }..|
|00005240| 20 20 20 20 72 65 74 75 | 72 6e 28 63 72 63 20 26 | retu|rn(crc &|
|00005250| 20 30 78 66 66 66 66 29 | 3b 0a 7d 0a 0a 6f 75 74 | 0xffff)|;.}..out|
|00005260| 63 28 70 2c 20 6e 2c 20 | 66 70 29 0a 63 68 61 72 |c(p, n, |fp).char|
|00005270| 20 2a 70 3b 0a 69 6e 74 | 20 6e 3b 0a 46 49 4c 45 | *p;.int| n;.FILE|
|00005280| 20 2a 66 70 3b 0a 7b 0a | 20 20 20 20 72 65 67 69 | *fp;.{.| regi|
|00005290| 73 74 65 72 20 63 68 61 | 72 20 2a 70 31 3b 0a 20 |ster cha|r *p1;. |
|000052a0| 20 20 20 72 65 67 69 73 | 74 65 72 20 69 6e 74 20 | regis|ter int |
|000052b0| 69 3b 0a 20 20 20 20 69 | 66 20 28 74 78 74 6d 6f |i;. i|f (txtmo|
|000052c0| 64 65 29 20 7b 0a 09 66 | 6f 72 20 28 69 20 3d 20 |de) {..f|or (i = |
|000052d0| 30 2c 20 70 31 20 3d 20 | 70 3b 20 69 20 3c 20 6e |0, p1 = |p; i < n|
|000052e0| 3b 20 69 2b 2b 2c 20 70 | 31 2b 2b 29 0a 09 20 20 |; i++, p|1++).. |
|000052f0| 20 20 69 66 20 28 28 2a | 70 31 20 26 20 42 59 54 | if ((*|p1 & BYT|
|00005300| 45 4d 41 53 4b 29 20 3d | 3d 20 27 5c 72 27 29 0a |EMASK) =|= '\r').|
|00005310| 09 09 2a 70 31 20 3d 20 | 27 5c 6e 27 3b 0a 20 20 |..*p1 = |'\n';. |
|00005320| 20 20 7d 0a 20 20 20 20 | 66 77 72 69 74 65 28 70 | }. |fwrite(p|
|00005330| 2c 20 31 2c 20 6e 2c 20 | 66 70 29 3b 0a 7d 0a 0a |, 1, n, |fp);.}..|
|00005340| 6c 6f 6e 67 20 67 65 74 | 34 28 62 70 29 0a 63 68 |long get|4(bp).ch|
|00005350| 61 72 20 2a 62 70 3b 0a | 7b 0a 20 20 20 20 72 65 |ar *bp;.|{. re|
|00005360| 67 69 73 74 65 72 20 69 | 6e 74 20 69 3b 0a 20 20 |gister i|nt i;. |
|00005370| 20 20 6c 6f 6e 67 20 76 | 61 6c 75 65 20 3d 20 30 | long v|alue = 0|
|00005380| 3b 0a 0a 20 20 20 20 66 | 6f 72 20 28 69 20 3d 20 |;.. f|or (i = |
|00005390| 30 3b 20 69 20 3c 20 34 | 3b 20 69 2b 2b 29 20 7b |0; i < 4|; i++) {|
|000053a0| 0a 09 76 61 6c 75 65 20 | 3c 3c 3d 20 38 3b 0a 09 |..value |<<= 8;..|
|000053b0| 76 61 6c 75 65 20 7c 3d | 20 28 2a 62 70 20 26 20 |value |=| (*bp & |
|000053c0| 42 59 54 45 4d 41 53 4b | 29 3b 0a 09 62 70 2b 2b |BYTEMASK|);..bp++|
|000053d0| 3b 0a 20 20 20 20 7d 0a | 20 20 20 20 72 65 74 75 |;. }.| retu|
|000053e0| 72 6e 28 76 61 6c 75 65 | 29 3b 0a 7d 0a 0a 73 68 |rn(value|);.}..sh|
|000053f0| 6f 72 74 20 67 65 74 32 | 28 62 70 29 0a 63 68 61 |ort get2|(bp).cha|
|00005400| 72 20 2a 62 70 3b 0a 7b | 0a 20 20 20 20 72 65 67 |r *bp;.{|. reg|
|00005410| 69 73 74 65 72 20 69 6e | 74 20 69 3b 0a 20 20 20 |ister in|t i;. |
|00005420| 20 69 6e 74 20 76 61 6c | 75 65 20 3d 20 30 3b 0a | int val|ue = 0;.|
|00005430| 0a 20 20 20 20 66 6f 72 | 20 28 69 20 3d 20 30 3b |. for| (i = 0;|
|00005440| 20 69 20 3c 20 32 3b 20 | 69 2b 2b 29 20 7b 0a 09 | i < 2; |i++) {..|
|00005450| 76 61 6c 75 65 20 3c 3c | 3d 20 38 3b 0a 09 76 61 |value <<|= 8;..va|
|00005460| 6c 75 65 20 7c 3d 20 28 | 2a 62 70 20 26 20 42 59 |lue |= (|*bp & BY|
|00005470| 54 45 4d 41 53 4b 29 3b | 0a 09 62 70 2b 2b 3b 0a |TEMASK);|..bp++;.|
|00005480| 20 20 20 20 7d 0a 20 20 | 20 20 72 65 74 75 72 6e | }. | return|
|00005490| 28 76 61 6c 75 65 29 3b | 0a 7d 0a 0a 63 6f 70 79 |(value);|.}..copy|
|000054a0| 28 70 31 2c 20 70 32 2c | 20 6e 29 0a 63 68 61 72 |(p1, p2,| n).char|
|000054b0| 20 2a 70 31 2c 20 2a 70 | 32 3b 0a 69 6e 74 20 6e | *p1, *p|2;.int n|
|000054c0| 3b 0a 7b 0a 09 77 68 69 | 6c 65 20 28 6e 2d 2d 20 |;.{..whi|le (n-- |
|000054d0| 3e 20 30 29 0a 09 09 2a | 70 31 2b 2b 20 3d 20 2a |> 0)...*|p1++ = *|
|000054e0| 70 32 2b 2b 3b 0a 7d 0a | 0a 2f 2a 20 54 68 69 73 |p2++;.}.|./* This|
|000054f0| 20 72 6f 75 74 69 6e 65 | 20 72 65 63 75 72 73 69 | routine| recursi|
|00005500| 76 65 6c 79 20 72 65 61 | 64 73 20 74 68 65 20 48 |vely rea|ds the H|
|00005510| 75 66 66 6d 61 6e 20 65 | 6e 63 6f 64 69 6e 67 20 |uffman e|ncoding |
|00005520| 74 61 62 6c 65 20 61 6e | 64 20 62 75 69 6c 64 73 |table an|d builds|
|00005530| 0a 20 20 20 61 6e 64 20 | 64 65 63 6f 64 69 6e 67 |. and |decoding|
|00005540| 20 74 72 65 65 2e 20 2a | 2f 0a 0a 73 74 72 75 63 | tree. *|/..struc|
|00005550| 74 20 6e 6f 64 65 20 2a | 72 65 61 64 5f 74 72 65 |t node *|read_tre|
|00005560| 65 28 29 0a 7b 0a 09 73 | 74 72 75 63 74 20 6e 6f |e().{..s|truct no|
|00005570| 64 65 20 2a 6e 70 3b 0a | 09 6e 70 20 3d 20 6e 6f |de *np;.|.np = no|
|00005580| 64 65 70 74 72 2b 2b 3b | 0a 09 69 66 20 28 67 65 |deptr++;|..if (ge|
|00005590| 74 62 69 74 28 29 20 3d | 3d 20 31 29 20 7b 0a 09 |tbit() =|= 1) {..|
|000055a0| 09 6e 70 2d 3e 66 6c 61 | 67 20 3d 20 31 3b 0a 09 |.np->fla|g = 1;..|
|000055b0| 09 6e 70 2d 3e 62 79 74 | 65 20 3d 20 67 65 74 68 |.np->byt|e = geth|
|000055c0| 75 66 66 62 79 74 65 28 | 4e 4f 44 45 43 4f 44 45 |uffbyte(|NODECODE|
|000055d0| 29 3b 0a 09 7d 0a 09 65 | 6c 73 65 20 7b 0a 09 09 |);..}..e|lse {...|
|000055e0| 6e 70 2d 3e 66 6c 61 67 | 20 3d 20 30 3b 0a 09 09 |np->flag| = 0;...|
|000055f0| 6e 70 2d 3e 7a 65 72 6f | 20 3d 20 72 65 61 64 5f |np->zero| = read_|
|00005600| 74 72 65 65 28 29 3b 0a | 09 09 6e 70 2d 3e 6f 6e |tree();.|..np->on|
|00005610| 65 20 20 3d 20 72 65 61 | 64 5f 74 72 65 65 28 29 |e = rea|d_tree()|
|00005620| 3b 0a 09 7d 0a 09 72 65 | 74 75 72 6e 28 6e 70 29 |;..}..re|turn(np)|
|00005630| 3b 0a 7d 0a 0a 2f 2a 20 | 54 68 69 73 20 72 6f 75 |;.}../* |This rou|
|00005640| 74 69 6e 65 20 72 65 74 | 75 72 6e 73 20 74 68 65 |tine ret|urns the|
|00005650| 20 6e 65 78 74 20 62 69 | 74 20 69 6e 20 74 68 65 | next bi|t in the|
|00005660| 20 69 6e 70 75 74 20 73 | 74 72 65 61 6d 20 28 4d | input s|tream (M|
|00005670| 53 42 20 66 69 72 73 74 | 29 20 2a 2f 0a 0a 67 65 |SB first|) */..ge|
|00005680| 74 62 69 74 28 29 0a 7b | 0a 09 73 74 61 74 69 63 |tbit().{|..static|
|00005690| 20 63 68 61 72 20 62 3b | 0a 09 69 66 20 28 62 69 | char b;|..if (bi|
|000056a0| 74 20 3d 3d 20 30 29 20 | 7b 0a 09 09 62 20 3d 20 |t == 0) |{...b = |
|000056b0| 67 65 74 63 28 69 6e 66 | 70 29 20 26 20 30 78 66 |getc(inf|p) & 0xf|
|000056c0| 66 3b 0a 09 09 62 69 74 | 20 3d 20 38 3b 0a 09 7d |f;...bit| = 8;..}|
|000056d0| 0a 09 62 69 74 2d 2d 3b | 0a 09 72 65 74 75 72 6e |..bit--;|..return|
|000056e0| 28 28 62 20 3e 3e 20 62 | 69 74 29 20 26 20 31 29 |((b >> b|it) & 1)|
|000056f0| 3b 0a 7d 0a 0a 2f 2a 20 | 54 68 69 73 20 72 6f 75 |;.}../* |This rou|
|00005700| 74 69 6e 65 20 72 65 74 | 75 72 6e 73 20 74 68 65 |tine ret|urns the|
|00005710| 20 6e 65 78 74 20 38 20 | 62 69 74 73 2e 20 20 49 | next 8 |bits. I|
|00005720| 66 20 64 65 63 6f 64 69 | 6e 67 20 69 73 20 6f 6e |f decodi|ng is on|
|00005730| 2c 20 69 74 20 66 69 6e | 64 73 20 74 68 65 0a 62 |, it fin|ds the.b|
|00005740| 79 74 65 20 69 6e 20 74 | 68 65 20 64 65 63 6f 64 |yte in t|he decod|
|00005750| 69 6e 67 20 74 72 65 65 | 20 62 61 73 65 64 20 6f |ing tree| based o|
|00005760| 6e 20 74 68 65 20 62 69 | 74 73 20 66 72 6f 6d 20 |n the bi|ts from |
|00005770| 74 68 65 20 69 6e 70 75 | 74 20 73 74 72 65 61 6d |the inpu|t stream|
|00005780| 2e 20 20 49 66 0a 64 65 | 63 6f 64 69 6e 67 20 69 |. If.de|coding i|
|00005790| 73 20 6e 6f 74 20 6f 6e | 2c 20 69 74 20 65 69 74 |s not on|, it eit|
|000057a0| 68 65 72 20 67 65 74 73 | 20 69 74 20 64 69 72 65 |her gets| it dire|
|000057b0| 63 74 6c 79 20 66 72 6f | 6d 20 74 68 65 20 69 6e |ctly fro|m the in|
|000057c0| 70 75 74 20 73 74 72 65 | 61 6d 20 6f 72 0a 70 75 |put stre|am or.pu|
|000057d0| 74 73 20 69 74 20 74 6f | 67 65 74 68 65 72 20 66 |ts it to|gether f|
|000057e0| 72 6f 6d 20 38 20 63 61 | 6c 6c 73 20 74 6f 20 67 |rom 8 ca|lls to g|
|000057f0| 65 74 62 69 74 28 29 2c | 20 64 65 70 65 6e 64 69 |etbit(),| dependi|
|00005800| 6e 67 20 6f 6e 20 77 68 | 65 74 68 65 72 20 6f 72 |ng on wh|ether or|
|00005810| 20 6e 6f 74 20 77 65 0a | 61 72 65 20 63 75 72 72 | not we.|are curr|
|00005820| 65 6e 74 6c 79 20 6f 6e | 20 61 20 62 79 74 65 20 |ently on| a byte |
|00005830| 62 6f 75 6e 64 61 72 79 | 0a 2a 2f 0a 67 65 74 68 |boundary|.*/.geth|
|00005840| 75 66 66 62 79 74 65 28 | 64 65 63 6f 64 65 29 0a |uffbyte(|decode).|
|00005850| 69 6e 74 20 64 65 63 6f | 64 65 3b 0a 7b 0a 09 72 |int deco|de;.{..r|
|00005860| 65 67 69 73 74 65 72 20 | 73 74 72 75 63 74 20 6e |egister |struct n|
|00005870| 6f 64 65 20 2a 6e 70 3b | 0a 09 72 65 67 69 73 74 |ode *np;|..regist|
|00005880| 65 72 20 69 6e 74 20 69 | 2c 20 62 3b 0a 09 69 66 |er int i|, b;..if|
|00005890| 20 28 64 65 63 6f 64 65 | 20 3d 3d 20 44 45 43 4f | (decode| == DECO|
|000058a0| 44 45 29 20 7b 0a 09 09 | 6e 70 20 3d 20 6e 6f 64 |DE) {...|np = nod|
|000058b0| 65 6c 69 73 74 3b 0a 09 | 09 77 68 69 6c 65 20 28 |elist;..|.while (|
|000058c0| 6e 70 2d 3e 66 6c 61 67 | 20 3d 3d 20 30 29 0a 09 |np->flag| == 0)..|
|000058d0| 09 09 6e 70 20 3d 20 28 | 67 65 74 62 69 74 28 29 |..np = (|getbit()|
|000058e0| 29 20 3f 20 6e 70 2d 3e | 6f 6e 65 20 3a 20 6e 70 |) ? np->|one : np|
|000058f0| 2d 3e 7a 65 72 6f 3b 0a | 09 09 62 20 3d 20 6e 70 |->zero;.|..b = np|
|00005900| 2d 3e 62 79 74 65 3b 0a | 09 7d 0a 09 65 6c 73 65 |->byte;.|.}..else|
|00005910| 20 7b 0a 09 09 69 66 20 | 28 62 69 74 20 3d 3d 20 | {...if |(bit == |
|00005920| 30 29 09 2f 2a 20 6f 6e | 20 62 79 74 65 20 62 6f |0)./* on| byte bo|
|00005930| 75 6e 64 61 72 79 3f 20 | 2a 2f 0a 09 09 09 62 20 |undary? |*/....b |
|00005940| 3d 20 67 65 74 63 28 69 | 6e 66 70 29 20 26 20 30 |= getc(i|nfp) & 0|
|00005950| 78 66 66 3b 0a 09 09 65 | 6c 73 65 20 7b 09 09 2f |xff;...e|lse {../|
|00005960| 2a 20 6e 6f 2c 20 70 75 | 74 20 61 20 62 79 74 65 |* no, pu|t a byte|
|00005970| 20 74 6f 67 65 74 68 65 | 72 20 2a 2f 0a 09 09 09 | togethe|r */....|
|00005980| 62 20 3d 20 30 3b 0a 09 | 09 09 66 6f 72 20 28 69 |b = 0;..|..for (i|
|00005990| 20 3d 20 38 3b 20 69 20 | 3e 20 30 3b 20 69 2d 2d | = 8; i |> 0; i--|
|000059a0| 29 20 7b 0a 09 09 09 09 | 62 20 3d 20 28 62 20 3c |) {.....|b = (b <|
|000059b0| 3c 20 31 29 20 2b 20 67 | 65 74 62 69 74 28 29 3b |< 1) + g|etbit();|
|000059c0| 0a 09 09 09 7d 0a 09 09 | 7d 0a 09 7d 0a 09 72 65 |....}...|}..}..re|
|000059d0| 74 75 72 6e 28 62 29 3b | 0a 7d 0a 53 48 41 52 5f |turn(b);|.}.SHAR_|
|000059e0| 45 4f 46 0a 66 69 20 23 | 20 65 6e 64 20 6f 66 20 |EOF.fi #| end of |
|000059f0| 6f 76 65 72 77 72 69 74 | 69 6e 67 20 63 68 65 63 |overwrit|ing chec|
|00005a00| 6b 0a 69 66 20 74 65 73 | 74 20 2d 66 20 27 73 74 |k.if tes|t -f 'st|
|00005a10| 75 66 66 69 74 2e 68 27 | 0a 74 68 65 6e 0a 09 65 |uffit.h'|.then..e|
|00005a20| 63 68 6f 20 73 68 61 72 | 3a 20 77 69 6c 6c 20 6e |cho shar|: will n|
|00005a30| 6f 74 20 6f 76 65 72 2d | 77 72 69 74 65 20 65 78 |ot over-|write ex|
|00005a40| 69 73 74 69 6e 67 20 66 | 69 6c 65 20 22 27 73 74 |isting f|ile "'st|
|00005a50| 75 66 66 69 74 2e 68 27 | 22 0a 65 6c 73 65 0a 63 |uffit.h'|".else.c|
|00005a60| 61 74 20 3c 3c 20 5c 53 | 48 41 52 5f 45 4f 46 20 |at << \S|HAR_EOF |
|00005a70| 3e 20 27 73 74 75 66 66 | 69 74 2e 68 27 0a 2f 2a |> 'stuff|it.h'./*|
|00005a80| 20 53 74 75 66 66 49 74 | 2e 68 3a 20 63 6f 6e 74 | StuffIt|.h: cont|
|00005a90| 61 69 6e 73 20 64 65 63 | 6c 61 72 61 74 69 6f 6e |ains dec|laration|
|00005aa0| 73 20 66 6f 72 20 53 49 | 54 20 68 65 61 64 65 72 |s for SI|T header|
|00005ab0| 73 20 2a 2f 0a 0a 74 79 | 70 65 64 65 66 20 73 74 |s */..ty|pedef st|
|00005ac0| 72 75 63 74 20 73 69 74 | 48 64 72 20 7b 09 09 09 |ruct sit|Hdr {...|
|00005ad0| 2f 2a 20 32 32 20 62 79 | 74 65 73 20 2a 2f 0a 09 |/* 22 by|tes */..|
|00005ae0| 4f 53 54 79 70 65 09 73 | 69 67 6e 61 74 75 72 65 |OSType.s|ignature|
|00005af0| 3b 20 09 09 2f 2a 20 3d | 20 27 53 49 54 21 27 20 |; ../* =| 'SIT!' |
|00005b00| 2d 2d 20 66 6f 72 20 76 | 65 72 69 66 69 63 61 74 |-- for v|erificat|
|00005b10| 69 6f 6e 20 2a 2f 0a 09 | 75 6e 73 69 67 6e 65 64 |ion */..|unsigned|
|00005b20| 20 73 68 6f 72 74 09 6e | 75 6d 46 69 6c 65 73 3b | short.n|umFiles;|
|00005b30| 09 2f 2a 20 6e 75 6d 62 | 65 72 20 6f 66 20 66 69 |./* numb|er of fi|
|00005b40| 6c 65 73 20 69 6e 20 61 | 72 63 68 69 76 65 20 2a |les in a|rchive *|
|00005b50| 2f 0a 09 75 6e 73 69 67 | 6e 65 64 20 6c 6f 6e 67 |/..unsig|ned long|
|00005b60| 09 61 72 63 4c 65 6e 67 | 74 68 3b 09 2f 2a 20 6c |.arcLeng|th;./* l|
|00005b70| 65 6e 67 74 68 20 6f 66 | 20 65 6e 74 69 72 65 20 |ength of| entire |
|00005b80| 61 72 63 68 69 76 65 20 | 69 6e 63 6c 2e 0a 09 09 |archive |incl....|
|00005b90| 09 09 09 09 68 64 72 2e | 20 2d 2d 20 66 6f 72 20 |....hdr.| -- for |
|00005ba0| 76 65 72 69 66 69 63 61 | 74 69 6f 6e 20 2a 2f 0a |verifica|tion */.|
|00005bb0| 09 4f 53 54 79 70 65 09 | 73 69 67 6e 61 74 75 72 |.OSType.|signatur|
|00005bc0| 65 32 3b 09 09 2f 2a 20 | 3d 20 27 72 4c 61 75 27 |e2;../* |= 'rLau'|
|00005bd0| 20 2d 2d 20 66 6f 72 20 | 76 65 72 69 66 69 63 61 | -- for |verifica|
|00005be0| 74 69 6f 6e 20 2a 2f 0a | 09 75 6e 73 69 67 6e 65 |tion */.|.unsigne|
|00005bf0| 64 20 63 68 61 72 09 76 | 65 72 73 69 6f 6e 3b 09 |d char.v|ersion;.|
|00005c00| 2f 2a 20 76 65 72 73 69 | 6f 6e 20 6e 75 6d 62 65 |/* versi|on numbe|
|00005c10| 72 20 2a 2f 0a 09 63 68 | 61 72 20 72 65 73 65 72 |r */..ch|ar reser|
|00005c20| 76 65 64 5b 37 5d 3b 0a | 7d 3b 0a 0a 74 79 70 65 |ved[7];.|};..type|
|00005c30| 64 65 66 20 73 74 72 75 | 63 74 20 66 69 6c 65 48 |def stru|ct fileH|
|00005c40| 64 72 20 7b 09 09 2f 2a | 20 31 31 32 20 62 79 74 |dr {../*| 112 byt|
|00005c50| 65 73 20 2a 2f 0a 09 75 | 6e 73 69 67 6e 65 64 20 |es */..u|nsigned |
|00005c60| 63 68 61 72 09 63 6f 6d | 70 52 4d 65 74 68 6f 64 |char.com|pRMethod|
|00005c70| 3b 09 2f 2a 20 72 73 72 | 63 20 66 6f 72 6b 20 63 |;./* rsr|c fork c|
|00005c80| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 6d 65 74 68 6f |ompressi|on metho|
|00005c90| 64 20 2a 2f 0a 09 75 6e | 73 69 67 6e 65 64 20 63 |d */..un|signed c|
|00005ca0| 68 61 72 09 63 6f 6d 70 | 44 4d 65 74 68 6f 64 3b |har.comp|DMethod;|
|00005cb0| 09 2f 2a 20 64 61 74 61 | 20 66 6f 72 6b 20 63 6f |./* data| fork co|
|00005cc0| 6d 70 72 65 73 73 69 6f | 6e 20 6d 65 74 68 6f 64 |mpressio|n method|
|00005cd0| 20 2a 2f 0a 09 75 6e 73 | 69 67 6e 65 64 20 63 68 | */..uns|igned ch|
|00005ce0| 61 72 09 66 4e 61 6d 65 | 5b 36 34 5d 3b 09 2f 2a |ar.fName|[64];./*|
|00005cf0| 20 61 20 53 54 52 36 33 | 20 2a 2f 0a 09 4f 53 54 | a STR63| */..OST|
|00005d00| 79 70 65 09 66 54 79 70 | 65 3b 09 09 09 2f 2a 20 |ype.fTyp|e;.../* |
|00005d10| 66 69 6c 65 20 74 79 70 | 65 20 2a 2f 0a 09 4f 53 |file typ|e */..OS|
|00005d20| 54 79 70 65 09 66 43 72 | 65 61 74 6f 72 3b 09 09 |Type.fCr|eator;..|
|00005d30| 2f 2a 20 65 72 2e 2e 2e | 20 2a 2f 0a 09 73 68 6f |/* er...| */..sho|
|00005d40| 72 74 20 46 6e 64 72 46 | 6c 61 67 73 3b 09 09 2f |rt FndrF|lags;../|
|00005d50| 2a 20 63 6f 70 79 20 6f | 66 20 46 69 6e 64 65 72 |* copy o|f Finder|
|00005d60| 20 66 6c 61 67 73 2e 20 | 20 46 6f 72 20 6f 75 72 | flags. | For our|
|00005d70| 0a 09 09 09 09 09 09 70 | 75 72 70 6f 73 65 73 2c |.......p|urposes,|
|00005d80| 20 77 65 20 63 61 6e 20 | 63 6c 65 61 72 3a 0a 09 | we can |clear:..|
|00005d90| 09 09 09 09 09 62 75 73 | 79 2c 6f 6e 44 65 73 6b |.....bus|y,onDesk|
|00005da0| 20 2a 2f 0a 09 75 6e 73 | 69 67 6e 65 64 20 6c 6f | */..uns|igned lo|
|00005db0| 6e 67 09 63 72 65 61 74 | 69 6f 6e 44 61 74 65 3b |ng.creat|ionDate;|
|00005dc0| 0a 09 75 6e 73 69 67 6e | 65 64 20 6c 6f 6e 67 09 |..unsign|ed long.|
|00005dd0| 6d 6f 64 44 61 74 65 3b | 09 2f 2a 20 21 72 65 73 |modDate;|./* !res|
|00005de0| 74 6f 72 65 64 2d 63 6f | 6d 70 61 74 20 77 2f 62 |tored-co|mpat w/b|
|00005df0| 61 63 6b 75 70 20 70 72 | 67 6d 73 20 2a 2f 0a 09 |ackup pr|gms */..|
|00005e00| 75 6e 73 69 67 6e 65 64 | 20 6c 6f 6e 67 09 72 73 |unsigned| long.rs|
|00005e10| 72 63 4c 65 6e 67 74 68 | 3b 09 2f 2a 20 64 65 63 |rcLength|;./* dec|
|00005e20| 6f 6d 70 72 65 73 73 65 | 64 20 6c 65 6e 67 74 68 |ompresse|d length|
|00005e30| 73 20 2a 2f 0a 09 75 6e | 73 69 67 6e 65 64 20 6c |s */..un|signed l|
|00005e40| 6f 6e 67 09 64 61 74 61 | 4c 65 6e 67 74 68 3b 0a |ong.data|Length;.|
|00005e50| 09 75 6e 73 69 67 6e 65 | 64 20 6c 6f 6e 67 09 63 |.unsigne|d long.c|
|00005e60| 6f 6d 70 52 4c 65 6e 67 | 74 68 3b 09 2f 2a 20 63 |ompRLeng|th;./* c|
|00005e70| 6f 6d 70 72 65 73 73 65 | 64 20 6c 65 6e 67 74 68 |ompresse|d length|
|00005e80| 73 20 2a 2f 0a 09 75 6e | 73 69 67 6e 65 64 20 6c |s */..un|signed l|
|00005e90| 6f 6e 67 09 63 6f 6d 70 | 44 4c 65 6e 67 74 68 3b |ong.comp|DLength;|
|00005ea0| 0a 09 75 6e 73 69 67 6e | 65 64 20 73 68 6f 72 74 |..unsign|ed short|
|00005eb0| 20 72 73 72 63 43 52 43 | 3b 09 09 2f 2a 20 63 72 | rsrcCRC|;../* cr|
|00005ec0| 63 20 6f 66 20 72 73 72 | 63 20 66 6f 72 6b 20 2a |c of rsr|c fork *|
|00005ed0| 2f 0a 09 75 6e 73 69 67 | 6e 65 64 20 73 68 6f 72 |/..unsig|ned shor|
|00005ee0| 74 20 64 61 74 61 43 52 | 43 3b 09 09 2f 2a 20 63 |t dataCR|C;../* c|
|00005ef0| 72 63 20 6f 66 20 64 61 | 74 61 20 66 6f 72 6b 20 |rc of da|ta fork |
|00005f00| 2a 2f 0a 09 63 68 61 72 | 20 72 65 73 65 72 76 65 |*/..char| reserve|
|00005f10| 64 5b 36 5d 3b 0a 09 75 | 6e 73 69 67 6e 65 64 20 |d[6];..u|nsigned |
|00005f20| 73 68 6f 72 74 20 68 64 | 72 43 52 43 3b 09 09 2f |short hd|rCRC;../|
|00005f30| 2a 20 63 72 63 20 6f 66 | 20 66 69 6c 65 20 68 65 |* crc of| file he|
|00005f40| 61 64 65 72 20 2a 2f 0a | 7d 3b 0a 0a 0a 2f 2a 20 |ader */.|};.../* |
|00005f50| 66 69 6c 65 20 66 6f 72 | 6d 61 74 20 69 73 3a 0a |file for|mat is:.|
|00005f60| 09 73 69 74 41 72 63 68 | 69 76 65 48 64 72 0a 09 |.sitArch|iveHdr..|
|00005f70| 09 66 69 6c 65 31 48 64 | 72 0a 09 09 09 66 69 6c |.file1Hd|r....fil|
|00005f80| 65 31 52 73 72 63 46 6f | 72 6b 0a 09 09 09 66 69 |e1RsrcFo|rk....fi|
|00005f90| 6c 65 31 44 61 74 61 46 | 6f 72 6b 0a 09 09 66 69 |le1DataF|ork...fi|
|00005fa0| 6c 65 32 48 64 72 0a 09 | 09 09 66 69 6c 65 32 52 |le2Hdr..|..file2R|
|00005fb0| 73 72 63 46 6f 72 6b 0a | 09 09 09 66 69 6c 65 32 |srcFork.|...file2|
|00005fc0| 44 61 74 61 46 6f 72 6b | 0a 09 09 2e 0a 09 09 2e |DataFork|........|
|00005fd0| 0a 09 09 2e 0a 09 09 66 | 69 6c 65 4e 48 64 72 0a |.......f|ileNHdr.|
|00005fe0| 09 09 09 66 69 6c 65 4e | 52 73 72 63 46 6f 72 6b |...fileN|RsrcFork|
|00005ff0| 0a 09 09 09 66 69 6c 65 | 4e 44 61 74 61 46 6f 72 |....file|NDataFor|
|00006000| 6b 0a 2a 2f 0a 0a 0a 0a | 2f 2a 20 63 6f 6d 70 72 |k.*/....|/* compr|
|00006010| 65 73 73 69 6f 6e 20 6d | 65 74 68 6f 64 73 20 2a |ession m|ethods *|
|00006020| 2f 0a 23 64 65 66 69 6e | 65 20 6e 6f 43 6f 6d 70 |/.#defin|e noComp|
|00006030| 20 09 30 09 2f 2a 20 6a | 75 73 74 20 72 65 61 64 | .0./* j|ust read|
|00006040| 20 65 61 63 68 20 62 79 | 74 65 20 61 6e 64 20 77 | each by|te and w|
|00006050| 72 69 74 65 20 69 74 20 | 74 6f 20 61 72 63 68 69 |rite it |to archi|
|00006060| 76 65 20 2a 2f 0a 23 64 | 65 66 69 6e 65 20 72 6c |ve */.#d|efine rl|
|00006070| 65 43 6f 6d 70 20 31 09 | 2f 2a 20 52 4c 45 20 63 |eComp 1.|/* RLE c|
|00006080| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 2a 2f 0a 23 64 |ompressi|on */.#d|
|00006090| 65 66 69 6e 65 20 6c 7a | 77 43 6f 6d 70 20 32 09 |efine lz|wComp 2.|
|000060a0| 2f 2a 20 4c 5a 57 20 63 | 6f 6d 70 72 65 73 73 69 |/* LZW c|ompressi|
|000060b0| 6f 6e 20 2a 2f 0a 23 64 | 65 66 69 6e 65 20 68 75 |on */.#d|efine hu|
|000060c0| 66 43 6f 6d 70 20 33 09 | 2f 2a 20 48 75 66 66 6d |fComp 3.|/* Huffm|
|000060d0| 61 6e 20 63 6f 6d 70 72 | 65 73 73 69 6f 6e 20 2a |an compr|ession *|
|000060e0| 2f 0a 0a 23 64 65 66 69 | 6e 65 20 65 6e 63 72 79 |/..#defi|ne encry|
|000060f0| 70 74 65 64 20 31 36 09 | 2f 2a 20 62 69 74 20 73 |pted 16.|/* bit s|
|00006100| 65 74 20 69 66 20 65 6e | 63 72 79 70 74 65 64 2e |et if en|crypted.|
|00006110| 20 20 65 78 3a 20 65 6e | 63 72 79 70 74 65 64 2b | ex: en|crypted+|
|00006120| 6c 70 7a 43 6f 6d 70 20 | 2a 2f 0a 0a 23 64 65 66 |lpzComp |*/..#def|
|00006130| 69 6e 65 20 73 74 61 72 | 74 46 6f 6c 64 65 72 20 |ine star|tFolder |
|00006140| 33 32 09 2f 2a 20 6d 61 | 72 6b 73 20 73 74 61 72 |32./* ma|rks star|
|00006150| 74 20 6f 66 20 61 20 6e | 65 77 20 66 6f 6c 64 65 |t of a n|ew folde|
|00006160| 72 20 2a 2f 0a 23 64 65 | 66 69 6e 65 20 65 6e 64 |r */.#de|fine end|
|00006170| 46 6f 6c 64 65 72 20 33 | 33 09 2f 2a 20 6d 61 72 |Folder 3|3./* mar|
|00006180| 6b 73 20 65 6e 64 20 6f | 66 20 74 68 65 20 6c 61 |ks end o|f the la|
|00006190| 73 74 20 66 6f 6c 64 65 | 72 20 22 73 74 61 72 74 |st folde|r "start|
|000061a0| 65 64 22 20 2a 2f 0a 0a | 2f 2a 20 61 6c 6c 20 6f |ed" */..|/* all o|
|000061b0| 74 68 65 72 20 6e 75 6d | 62 65 72 73 20 61 72 65 |ther num|bers are|
|000061c0| 20 72 65 73 65 72 76 65 | 64 20 2a 2f 0a 53 48 41 | reserve|d */.SHA|
|000061d0| 52 5f 45 4f 46 0a 66 69 | 20 23 20 65 6e 64 20 6f |R_EOF.fi| # end o|
|000061e0| 66 20 6f 76 65 72 77 72 | 69 74 69 6e 67 20 63 68 |f overwr|iting ch|
|000061f0| 65 63 6b 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |eck.if t|est -f '|
|00006200| 75 70 64 63 72 63 2e 63 | 27 0a 74 68 65 6e 0a 09 |updcrc.c|'.then..|
|00006210| 65 63 68 6f 20 73 68 61 | 72 3a 20 77 69 6c 6c 20 |echo sha|r: will |
|00006220| 6e 6f 74 20 6f 76 65 72 | 2d 77 72 69 74 65 20 65 |not over|-write e|
|00006230| 78 69 73 74 69 6e 67 20 | 66 69 6c 65 20 22 27 75 |xisting |file "'u|
|00006240| 70 64 63 72 63 2e 63 27 | 22 0a 65 6c 73 65 0a 63 |pdcrc.c'|".else.c|
|00006250| 61 74 20 3c 3c 20 5c 53 | 48 41 52 5f 45 4f 46 20 |at << \S|HAR_EOF |
|00006260| 3e 20 27 75 70 64 63 72 | 63 2e 63 27 0a 2f 2a 20 |> 'updcr|c.c'./* |
|00006270| 75 70 64 63 72 63 28 33 | 29 2c 20 63 72 63 28 31 |updcrc(3|), crc(1|
|00006280| 29 20 2d 20 63 61 6c 63 | 75 6c 61 74 65 20 63 72 |) - calc|ulate cr|
|00006290| 63 20 70 6f 6c 79 6e 6f | 6d 69 61 6c 73 0a 20 2a |c polyno|mials. *|
|000062a0| 0a 20 2a 20 43 61 6c 63 | 75 6c 61 74 65 2c 20 69 |. * Calc|ulate, i|
|000062b0| 6e 74 65 6c 6c 69 67 65 | 6e 74 6c 79 2c 20 74 68 |ntellige|ntly, th|
|000062c0| 65 20 43 52 43 20 6f 66 | 20 61 20 64 61 74 61 73 |e CRC of| a datas|
|000062d0| 65 74 20 69 6e 63 72 65 | 6d 65 6e 74 61 6c 6c 79 |et incre|mentally|
|000062e0| 20 67 69 76 65 6e 20 61 | 20 0a 20 2a 20 62 75 66 | given a| . * buf|
|000062f0| 66 65 72 20 66 75 6c 6c | 20 61 74 20 61 20 74 69 |fer full| at a ti|
|00006300| 6d 65 2e 0a 20 2a 20 0a | 20 2a 20 55 73 61 67 65 |me.. * .| * Usage|
|00006310| 3a 0a 20 2a 20 09 6e 65 | 77 63 72 63 20 3d 20 75 |:. * .ne|wcrc = u|
|00006320| 70 64 63 72 63 28 20 6f | 6c 64 63 72 63 2c 20 62 |pdcrc( o|ldcrc, b|
|00006330| 75 66 61 64 72 2c 20 62 | 75 66 6c 65 6e 20 29 0a |ufadr, b|uflen ).|
|00006340| 20 2a 20 09 09 75 6e 73 | 69 67 6e 65 64 20 69 6e | * ..uns|igned in|
|00006350| 74 20 6f 6c 64 63 72 63 | 2c 20 62 75 66 6c 65 6e |t oldcrc|, buflen|
|00006360| 3b 0a 20 2a 20 09 09 63 | 68 61 72 20 2a 62 75 66 |;. * ..c|har *buf|
|00006370| 61 64 72 3b 0a 20 2a 0a | 20 2a 20 43 6f 6d 70 69 |adr;. *.| * Compi|
|00006380| 6c 69 6e 67 20 77 69 74 | 68 20 2d 44 54 45 53 54 |ling wit|h -DTEST|
|00006390| 20 63 72 65 61 74 65 73 | 20 61 20 70 72 6f 67 72 | creates| a progr|
|000063a0| 61 6d 20 74 6f 20 70 72 | 69 6e 74 20 74 68 65 20 |am to pr|int the |
|000063b0| 43 52 43 20 6f 66 20 73 | 74 64 69 6e 20 74 6f 20 |CRC of s|tdin to |
|000063c0| 73 74 64 6f 75 74 2e 0a | 20 2a 20 43 6f 6d 70 69 |stdout..| * Compi|
|000063d0| 6c 65 20 77 69 74 68 20 | 2d 44 4d 41 4b 45 54 41 |le with |-DMAKETA|
|000063e0| 42 20 74 6f 20 70 72 69 | 6e 74 20 76 61 6c 75 65 |B to pri|nt value|
|000063f0| 73 20 66 6f 72 20 63 72 | 63 74 61 62 20 74 6f 20 |s for cr|ctab to |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.