------------------------------------------------------------------------ zip and unzip Original port: Eric Slagter Version 1.1 Second version: Marco Holmer Version 2.0 Third version: Richard Kettlewell Version 2.1 Fourth version: Marco Holmer Version 2.2 Fifth version: Marco Holmer Version 3.0 ------------------------------------------------------------------------ This is the manual to the ZIP suite of programs. These are not pkzip, pkunzip but are supposed to be compatible with them. The zip program gives exceptionally good compaction; savings in excess of 60% are the norm, although it is a bit less efficient for small files. The 'deflate' algorithm used works by examining the compacted data for strings which match parts of the uncompacted data; by storing a reference to these, instead of the full string, you can reduce file size. Output size is further reduced by applying minimum redundancy (Huffman) codes to everything in sight. This is basically 'LZ77' compression, a precursor of 'LZW' compression; however, this algorithm gives better results than most (all?) LZW implementations and is also free of patents. The unzip program can 'inflate' data compacted in this way, and can also reverse the effects of several more primitive compaction algorithms used in earlier versions of zip. COMMENTS to version 2.1 I have made my own alterations too them; this was unavoidable as they supplied versions compiled on my system to produce code that invariably crashed, though the supplied executables were ok. o The last Ql changes before mine arranged for zip and unzip to wait 4 seconds before terminating, and never to wait for a keypress. While there was a good(-ish) reason for this, the usual way of forcing a C program to terminate without any prompting is to execute it with a command like ew zip,#1;'...' so that it is not running in its own window. The 4-second wait feature has been removed, it's extremely irritating in normal use. If you do need to run zip (or unzip) in its own window without a termination keypress being required, use the -W option, like ex zip;'-W ...' The implementation of the -D option has also been tidied up. o The second major change is that the 'deflate' routine for zip has been replaced by an assembly language equivalent, cannibalised from the GNU GZIP package, which uses the same code. This gives slightly faster operation. o Thirdly, I've arranged for the '-r' option of zip to work. This lets you say zip -9r zipfile dirname where dirname is the name of a directory (a real once --- you need level 2 drivers, at least); the contents of that directory are all copied into the zipfile. This works to as many levels as necessary. o Unzip needed a couple of minor adjustments to work well with this; if a zipfile has a directory in it, as above, then it will try to create one when unzipping. It won't complain if it can't, however, so people without level 2 drivers can still use zipfiles containing directories sensibly. o Finally, I have adjusted the source code so that the whole lot goes in a single directory with a single Makefile, instead of splitting over four directories (zip, unzip, zip utils, unzip utils.) The way I've done this could be more elegant but not without some hacking of the source files. Richard Kettlewell. COMMENTS to version 2.2 It has been updated with a new version of C68 (3.06 with corrected localtime function) and adapted for ATP (So that it is possible to zip without default having the extention _zip). Marco Holmer COMMENTS to version 3.0 The wildcard function of unzip (which disappeared) is introduced again. The inflate exeptions are extended with the upper case variants (_ZIP, _ARC, _ZOO, _LZH and _ARJ) The enviroment variables have now the same name syntax ENV_name (ENV_ZIP ENV_UNZIP etc) and are documented now. Marco and Erik. ------------------------------------------------------------------------ Using zip ------------------------------------------------------------------------ zip is the program you use to compact files; you use a command line something like: zip zipfile file1 file2 ... or zip -b ram1_ zipfile file1 file2 ... ...to copy file1, file2 and possibly others into zipfile_zip, using (in the second case) ram1_ to hold temporary files. (The temporary file gets as big as the zipfile ends up, and will be renamed rather than copied if possible.) From SuperBASIC, ew zip,#1;'zipfile file1 file2 ...' ex zip;'zipfile file1 file2 ...' ex zip;'-b ram1_ zipfile file1 file2 ...' etc all work. If you have ptr_gen installed then I recommend the 'ew zip,#1' form since that prevents zip from opening its own window, therefore potentially saving quite a bit of memory (depending.) The full list of options is as follows: zip [-options] [-b path] [-t mmddyy] [-n suffixes] [zipfile file ...] [-x list] -f freshen: only changed files -u update: only changed/new files -d delete entries in zipfile -m move into zipfile, delete files -k simulate PKZIP made zipfile -g allow growing existing zipfile -h show this help -L show software license -r recurse into directories -j junk directory names -0 store only -l translate end-of-line -1 compress faster -9 compress better -q quiet operation -n don't compress these suffixes -c add one-line comments -z add zipfile comment -b use "path" for temp files -t only do files after "mmddyy" -@ read names from stdin -o make zipfile old as latest entry -H do not add Qdos header -D change data directory -W don't wait on exit -x exclude the names that follow from those operated on -f Freshen Copies changed files into the zipfile, but creates no new members. A changed file is one which has an update date more recent than the corresponding zipfile member. -u Update Same as -f but if a file is absent from the zipfile then it is copied into it. -d Delete Remove files from the zipfile and discard them. -m Move (possibly with -f, -u etc) Delete files once they have been copied into the zipfile. -r Recurse Copy directory contents as well as ordinary files. Effectively creates a directory within the zipfile. -0 Store Don't compact at all. -1 ... -9 -1 gives the fastest operation, and -9 gives the smallest output. All of -2 through to -8 work as well. -c Comments Reads comments from the keyboard to put in the zipfile -z Zipfile comment Reads a multi-line comment from the keyboard to put in the zipfile -b Set temporary device Tells zip where to put temporary files; typically a ramdisk. For example, zip -b ram1_tmp_ zipfile file ... -W Don't wait on exit If you run zip in its own window, you will usually get a message 'press a key to exit' when it finishes. -W makes that message go away. Zip add the extension _ZIP when the filename supplied has only one _ in the filename. example, zip ram1_zipfile file ... creates a zipfile called ram1_zipfile_zip When the filename supplied has two _ in the filename then no extension is added. example, zip ram1_zipfile_upt file ... creates a zipfile called ram1_zipfile_upt. This feature is especially usefull when zip is used in a echomail or ATP reader environment. the zip bundles must not have a _zip extension in that case. It is possible now to have predefined options by the aid of an environment variable called ENV_ZIP. example: SETENV "ENV_ZIP=-WDram2_" ------------------------------------------------------------------------ Using unzip ------------------------------------------------------------------------ Unzip complements zip in that it is responsible for extracting files from zipfiles. You might use it as follows unzip zipfile to extract all members; or unzip zipfile file1 file2 ... to extract a selected few. There are a number of options that go before the zipfile name: unzip [ -options[modifiers] ] file[_zip] [filespec...] -x extract files (default) -l list files (short format) -c extract files to stdout/screen (CRT) -v list files (verbose format) -f freshen existing files, create none -p extract to pipe, no messages -u update files, create if necessary -t test archive integrity -D new datadirectory other than default -z display archive comment -W don't wait on exit modifiers: -n never overwrite existing files -o overwrite files WITHOUT prompting -a convert text (CR LF => LF) -j junk paths (don't make directories) -U don't make names lowercase -q quiet mode (-qq => quieter) -V retain VMS version numbers -l List Lists each file along with its (uncompressed) length and update date. -v List Lists extensive information about each file. -c CRT Sends extracted data to the screen (strictly, to stdout, which is usually the screen but may be redirected.) -f, -u Freshen, update Just like -f, -u for zip but in reverse: for -u, files are only uncompacted if the zipped version is more recent, and -f only decompacts where the zipped version is more recent and there is an unzipped version to be overwritten. -t Test Checks that members of the zipfile have not become corrupted. -W Don't wait on exit Same as for zip. It is possible now to have predefined options by the aid of an environment variable called ENV_UNZIP. example: SETENV "ENV_UNZIP=-WDram2_" ------------------------------------------------------------------------ zipinfo, zipsplit, zipnote, funzip ------------------------------------------------------------------------ The other four programs all give a brief summary of the command line options available with commands like zipinfo -h but none of them are of great practical use. zipinfo merely provides extra detail above and beyond 'unzip -v'; zipsplit is used for splitting up very large zipfiles. zipnote adds comments, in a more automated way than 'zip -cz' and funzip extracts a single member (the first) from a zipfile. ------------------------------------------------------------------------ Bug reports for these programs should go to Erik Slagter or Marco Holmer, But several people have each added their own code to the QDOS version. If you want to get in touch with the ones who contributed: Richard Kettlewell 12 Limited Rd Churchill College Bournemouth Cambridge BH9 1SS CB3 0DS (0202) 522467 rjk1002@uk.ac.cam.phx No mail/email to Cambridge after May 1995, please. Marco Holmer J.P. Coenstraat 61 bis, 3531 EN Utrecht Netherlands QLAT-BBS 2:283/508 31-30-962265 Erik Slagter v882022@si.hhs.nl or Erik.Slagter@p2.f503.n281.z2.fidonet.org (preferably) ------------------------------------------------------------------------ Original 'readme' files ------------------------------------------------------------------------ NOTES to zip release 1 (beta) The binary distribution consists of: - read_me - zip The sources distribution consists of: - bits_c - deflate_c - fileio_c - globals_c - qdos_c - trees_c - util_c - zip_c - zipfile_c - zipup_c - revision_c - tailor_c - zip_h - ziperr_h To begin with the bad news: I've lost all documentation to zip and unzip so you'll have to do with this piece of text. I assume that all of you have worked one time or another with some sort of archiver so you'll be familiar with the concepts. The good news. I have serious reasons to assume zip and unzip are working alright at last. Notes to the program. To obtain a short help type ex zip. It is possible to set default options by setting the environment variable ZIPOPT. If zip gets interrupted for some reason it may leave a temporary file like "_ZXXXXXX". It is best to remove this file. For every file a full Qdos header is stored (64 bytes including file type, default dataspace, extra information, file times and the original name. Zip can only make "deflated" zip entries. This is the newest (and best) algorithm. This implies that zipfiles made by zip CANNOT be extracted by PKUNZIP 1.10 (use 1.93a or 2.00 instead) or QLUNZIP (use unzip instead). QLUNZIP and PKUNZIP 1.10 only know of shrinking and imploding. To retain compatibility use -0. This will force compression to be bypassed. THIS MEANS THE FILE WILL NOT BE COMPRESSED AT ALL but only archived. Zip takes several seconds to "come up". This is caused by the huge relocation job of the startup code and is perfectly normal. Notes to the source. Some of the modules require a huge pile of memory to be compiled. Think twice before trying to compile zip on a QL with less than 700 Kb free memory. With less than 600 Kb you won't get zip compiled so be warned. That's why there is no makefile; some modules must be compiled by running cpp, c68 and as68 seperately by hand. Linking is a story of it's own. it will take you 20 minutes (normal QL) to link zip. The linker requires 550 Kb as program buffer (-bufp 550000) so you'll probably have to "empty" your computer first and start ld by hand. This source is compiled using C68K V3.02. I am not sure at all that it will compile on any older version of C68K. For questions and suggestions as always write to: v882022@si.hhs.nl or Erik.Slagter@p2.f503.n281.z2.fidonet.org (preferably) Comments on release 2! The major change of release 2 is the fact that it has been compiled with C68 version 3.05. So crashes on ATARI/QL systems should be over by now. Furthermore release 2 has been slightly amended so it can cope with the automatic operation. (In the future it will be possible then to use ZIPas a packer in conjunction with the QBOX BBS program.) The only disadventage of that modification is that the halt "Press any key to exit" at the end of the operation had to be removed. INstead of that message, the display is halted for 4 seconds after the last message is printed. If you want to consult the inbuild help page for an infinite time you have to ask for it explicitely on the command line by issueing the command -? or -h. *** current version is completely different, see above *** If you want to follow the operation afterwards it's possible to redirect the messages and errors to a log-file. This has to be done conform the C sytax >>&filename . This command (i.e. >>&filename) has to be issued as the first option on the command line. i.e. ex zip;">>&ram1_zip_log unzip_zip win1_unzip_exe" this zip's the file flp1_unzip_exe to the file unzip_zip in the DATAD directory and logs its operation to the file ram1_zip_log. A bonus like sideeffect of the adaptation to the automatic operation is the added possibility to change the default directory (DATAD) where the unzipped files are placed. To archieve that the opption -D is introduced (Case sensitive!!) The syntax of that option is -D (as an example: -DWin1_qbox_sys_). Be aware of the fact that NO space has to be introduced between the D and the filename! The option D must always be the LAST option issued and ALL options have to be issued before the filename(s)! i.e. ex zip;"-oDram3_ unzip flp1_unzip_exe" is allright. ex zip;"-Dram3_ -o unzip flp1_unzip_exe" is wrong. ex zip;"-o -Dram3_ unzip flp1_unzip_exe" is allright. ex zip;"unzip flp1_unzip_exe -Dram3_" is wrong. As before: ex zip;"unzip flp1_unzip_exe" This use the DATAD directory to zip the files to. I hope you enjoy this new release. For comments en bugreports: Marco Holmer 2:283/508. ------------------------------------------------------------------------ NOTES to unzip release 2 (beta on January 1993.) Program. Unfortunately I lost all documentation from unzip. But don't worry, unzip is very easy to use. Just type ex unzip;'zipfile' to extract. For help on additional options use ex unzip without options. Default options may be set by setting the environment variable UNZIP. Unzip extracts ALL zipfiles. These include: zipfiles made by PKZIP 1.10, PKZIP 1.93a, PKZIP 2.00, zip versions 1 to 1.9 and stzip. Zipfiles made by zip on the QL have from all files their full Qdos header restored (file access, file type, default dataspace, extra info, version and times (version and times only on V2 device drivers)). Zipfiles treated with QZ (a utility by Jan Bredenbeek to add short Qdos headers to zipfiles) have their short Qdos header restored (file access, file type, default dataspace and extra info). This option is included for compatibility reasons only and might be removed in future issues. Very rarely unzip chokes on zipfiles made by PKZIP (1.10 and 1.93a) (gives strange errors). In that case the central directory is not complete. It is not at all clear what's causing this problem. I suspect the atr_ device driver very much in this. Therefore I suggest you always make a copy on a QL device first before issueing unzip. If the problem remains issue zipsplit on the file with a very large splitsize (-n 10000000 or something like that). The file that zipsplit makes can be extracted by unzip. Source. No peculiarities in fact. Compile all _c files and link them together, that's all. As always, contact me at: v882022@si.hhs.nl or Erik.Slagter@p2.f503.n281.z2.fidonet.org Comments on release 2! The major change of release 2 is the fact that it has been compiled with C68 version 3.05. So crashes on ATARI/QL systems should be over by now. Furthermore release 2 has been slightly amended so it can cope with the automatic operation in conjunction with the QBOX BBS tosser Tossmail in the future. !!! Be aware of the fact that in conjunction with tossmail 1.19c and earlier versions you cannot use UNZIP. That's because tossmail expect the commandline options in an different order.!!! The only disadventage of that modification is that the halt "Press any key to exit" at the end of the operation had to be removed. Instead of that message, the display is halted for 4 seconds after the last information is printed. If you want to consult the inbuild help page for an infinite time you have to ask for it explicitely on the command line by issueing the command -?. *** current version is completely different, see above *** If you want to follow the operation afterwards it's possible to redirect the messages and errors to a log-file. This has to be done conform the C sytax >>&filename . This command (i.e. >>&filename) has to be issued as the first option on the command line. i.e. ex unzip;">>&ram1_unzip_log flp1_zip_zip" this unzip's the file flp1_zip_zip to the DATAD directory and logs its operation to the file ram1_unzip_log. A bonus like side-effect of the adaptation to the automatic operation is the added possibility to change the default directory (DATAD) where the unzipped files are placed. To archieve that the opption -D is introduced (Case sensitive!!) The syntax of that option is -D (as an example: -DWin1_qbox_sys_). Be aware of the fact that NO space has to be introduced between the D and the filename! The option D must always be the LAST option issued and ALL options have to be issued before the filename(s)! i.e. ex unzip;"-oDram3_ flp1_zip_zip" is allright. ex unzip;"-Dram3_ -o flp1_zip_zip" is wrong. ex unzip;"-o -Dram3_ flp1_zip_zip" is allright. ex unzip;"flp1_zip_zip -Dram3_" is wrong. As before: ex unzip;"flp1_zip_zip" This use the DATAD directory to unzip the files to. I hope you enjoy this new release. For comments en bugreports: Marco Holmer 2:283/508. ------------------------------------------------------------------------ NOTES to zipsplit and zipnote release 1 (beta) PROGRAM Zipsplit Use zipsplit to split a zipfile into several (smaller) zipfiles. You cannot split one entry over several zip files. You might try to use zipsplit on damaged zipfiles. Surprisingly often zipsplit can make a good zipfile out of a damaged one. For this to work well use zipsplit -n 10000000. Zipnote Use zipnote to add comments to a zipfile afterwards. Use zipnote > file to make a file with current comments. Edit this file and then use zipnote -w < file to write them into the zipfile. Do not remove the "@" signs in the file. These serve to distinguish between entries. SOURCE Zipsplit Copy all _h files from zip sources. Copy fileio_c, globals_c, util_c, zipfile_c and zipup_c from zip sources. Compile them with -DUTIL. Link these together with zipsplit_o. Zipnote See zipsplit. Link with zipnote.o. As always write to: v882022@si.hhs.nl or Erik.Slagter@p2.f503.n281.z2.fidonet.org ------------------------------------------------------------------------ NOTES to zipinfo and funzip. PROGRAMS. Funzip. Funzip is a filter that extracts the first entry from stdin to stdout. Not really spectacular, I think. It's pretty small though. Only deflating is supported (maybe that's why). Zipinfo. Zipinfo is a program to inspect zip files. If used with -v it also lists Qdos specific information. Default options may be set using the ZIPINFO environment variable. SOURCES. Funzip. Compile and link with deflate_c from unzip. Remember that unzip_h and zip_h from unzip are included as well. No pecularities. Zipinfo. Zip_c is a very big program. I you have troubles compiling it, try to start cpp, c68 and as68 sequentially from the command line. Copy match_c and misc_c from unzip and recompile them with -DZIPINFO. Link them together with zipinfo_o, envargs_o and qdos_o. Ready ;-) As always contact me at: v882022@si.hhs.nl Erik.Slagter@p2.f503.n281.z2.fidonet.org ------------------------------------------------------------------------ The directions for compiling funzip are wrong, it should be inflate_c and not deflate_c.