1unzoo.c                     Tools                        Martin Schoenert
2
3@(#)$Id: unzoo.c,v 4.4 2000/05/29 08:56:57 sal Exp $
4
5This file is in the Public Domain.
6
7SYNTAX
8
9'unzoo'
10'unzoo [-l] [-v] <archive>[.zoo] [<file>..]'
11'unzoo -x [-abnpo] <archive>[.zoo] [<file>..]'
12
13DESCRIPTION
14
15'unzoo' is  a zoo  archive extractor.   A zoo archive   is  a  file  that
16contains several files, called its members, usually in compressed form to
17save space.  'unzoo' can list all or  selected members or  extract all or
18selected members, i.e.,  uncompress them and write   them  to files.   It
19cannot add new members or  delete  members.  For this   you need the  zoo
20archiver, called 'zoo', written by Rahul Dhesi.
21
22If you call 'unzoo'  with no arguments, it will  first print a summary of
23the commands and  then prompt for  command lines interactively, until you
24enter an empty line.  This is useful  on systems  that do not support the
25notion of command line arguments such as the Macintosh.
26
27If you call  'unzoo' with the  '-l' option,  it lists the  members in the
28archive <archive>.   For each member 'unzoo'   prints  the size  that the
29extracted file  would  have, the  compression factor,  the  size that the
30member occupies in the archive (not  counting  the  space needed to store
31the attributes such as the path name of the file), the date and time when
32the files were last modified, and finally  the path name itself.  Finally
33'unzoo' prints a grand total for the  file sizes, the compression factor,
34and the member sizes.
35
36The '-v' suboption causes 'unzoo' to append to each path name,  separated
37by a ';', the generation number of the member,  where higher numbers mean
38later generations.  Members for which generations are disabled are listed
39with  ';0'.  Also 'unzoo'   will print the  comments associated  with the
40archive itself or the members, preceeded by the string '# '.
41
42If you call 'unzoo' with the '-x' option,  it extracts the  members  from
43the archive <archive>.  Members are  stored with a  full path name in the
44archive and if the operating system supports this, they will be extracted
45into   appropriate subdirectories,   which will   be  created on  demand.
46The members are usually  extracted as binary files,  with no translation.
47However, if a member has a  comment that starts with the string '!TEXT!',
48it is  extracted as a  text file, i.e.,  it will be  translated from  the
49universal text file format (with <lf> as line separator as under UNIX) to
50the local text file format (e.g., with <cr>/<lf> as separator under DOS).
51If the archive  itself has a  comment that starts with  '!TEXT!' then all
52members will be extracted as text files, even those that have no comment.
53For each member the name is printed followed by  '-- extracted as binary'
54or '-- extracted as text' when the member has been completely extracted.
55
56The '-a' suboption causes  'unzoo' to extract all members  as text files,
57even if they have no comment starting with  '!TEXT!'.
58
59The '-b' suboption causes 'unzoo' to extract all members as binary files,
60even if they have a comment starting with  '!TEXT!'.
61
62The '-n' suboption causes 'unzoo' to suppress writing the files.  You use
63this suboption  to test the integrity  of the archive  without extracting
64the members.  For each member the name is printed followed by '-- tested'
65if the member is intact or by '-- error, CRC failed' if it is not.
66
67The '-p' suboption causes 'unzoo' to print the files to stdout instead of
68writing them to files.
69
70The '-o'  suboption causes 'unzoo'   to overwrite existing  files without
71asking  you for confirmation.   The  default is  to ask for  confirmation
72'<file> exists, overwrite it? (Yes/No/All/Ren)'.   To this you can answer
73with 'y' to overwrite the  file, 'n' to skip  extraction of the file, 'a'
74to overwrite this and all following files, or 'r' to enter a new name for
75the file.  'unzoo' will never overwrite existing read-only files.
76
77The '-j <prefix>' suboption causes 'unzoo' to prepend the string <prefix>
78to  all path names for  the members  before  they  are extracted.  So for
79example if an archive contains absolute  path names under  UNIX,  '-j ./'
80can be used to convert them to relative pathnames.   This option  is also
81useful  on  the Macintosh where   you start 'unzoo' by clicking,  because
82then the current directory will be the one where 'unzoo' is,  not the one
83where the  archive is.   Note  that the  directory  <prefix> must  exist,
84'unzoo' will not create it on demand.
85
86If no  <files>  argument is given all members  are  listed or  extracted.
87If  one or  more <files>  arguments are given,  only members whose  names
88match at least one of  the  <files> patterns  are  listed  or  extracted.
89<files> can  contain the wildcard   '?', which  matches any character  in
90names, and '*', which  matches any number  of characters  in names.  When
91you pass the <files> arguments on the command  line you will usually have
92to quote them to keep the shell from trying to expand them.
93
94Usually 'unzoo' will  only list or extract the  latest generation of each
95member.  But if you append ';<nr>' to a path  name pattern the generation
96with the number <nr> is listed or extracted.  <nr> itself can contain the
97wildcard characters '?' and '*', so appending ';*' to a path name pattern
98causes all generations to be listed or extracted.
99
100
101COMPATIBILITY
102
103'unzoo'  is based heavily on the 'booz' archive extractor by Rahul Dhesi.
104I basically stuffed everything in one file (so  no 'Makefile' is needed),
105cleaned it up (so that it is now more portable and  a little bit faster),
106and added the  support for  long file names,  directories,  and comments.
107
108'unzoo' differs in some details from  'booz' and the zoo archiver  'zoo'.
109
110'unzoo' can  only list  and extract members   from archives, like 'booz'.
111'zoo' can also add members, delete members, etc.
112
113'unzoo' can extract members as text files, converting from universal text
114format to the local text format,  if the '-a' option is given or the '-b'
115option is not given and the  member has a comment starting with '!TEXT!'.
116So in the absence of the '-a' option and comments starting with '!TEXT!',
117'unzoo' behaves like  'zoo' and 'booz',  which always extract as  binary.
118But  'unzoo' can  correctly extract  text files from  archives that  were
119created under UNIX (or other systems using the universal text format) and
120extended with '!TEXT!' comments on systems such as DOS, VMS, Macintosh.
121
122'unzoo' can handle  long names, which it converts  in  a system dependent
123manner to local  names, like  'zoo'  (this may not   be available on  all
124systems).  'booz' always uses the short DOS format names.
125
126'unzoo' extracts  members  into  subdirectories, which  it  automatically
127creates, like 'zoo' (this  may not be available on  all systems).  'booz'
128always extracts all members into the current directory.
129
130'unzoo'  can handle comments and generations in the  archive, like 'zoo'.
131'booz' ignores all comments and generations.
132
133'unzoo' cannot handle  members compressed with  the old method, only with
134the new  high method or  not compressed  at all.   'zoo' and  'booz' also
135handle members compress with the old method.  This shall be fixed soon.
136
137'unzoo' can handle archives in  binary format under  VMS, i.e., it is not
138necessary to convert  them to stream linefeed  format  with 'bilf' first.
139'zoo' and 'booz' require this conversion.
140
141'unzoo' is somewhat faster than 'zoo' and 'booz'.
142
143'unzoo' should be much easier to port than both 'zoo' and 'booz'.
144
145ACKNOWLEDGMENTS
146
147Rahul Dhesi  wrote the  'zoo' archiver and the  'booz' archive extractor.
148Haruhiko Okumura  wrote the  LZH code (originally for his 'ar' archiver).
149David Schwaderer provided the CRC-16 calculation in PC Tech Journal 4/85.
150Jeff Damens  wrote the name match code in 'booz' (originally for Kermit).
151Harald Boegeholz  ported 'unzoo' to OS/2 with the emx development system.
152Dave Bayer ported 'unzoo' to the Macintosh,  including Macbinary support.
153