home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-08-16 | 39.5 KB | 1,113 lines |
- Path: uunet!rs
- From: rs@uunet.UU.NET (Rich Salz)
- Newsgroups: comp.sources.unix
- Subject: v11i014: File archive program, Part05/07
- Message-ID: <969@uunet.UU.NET>
- Date: 18 Aug 87 02:02:42 GMT
- Organization: UUNET Communications Services, Arlington, VA
- Lines: 1102
- Approved: rs@uunet.UU.NET
-
- Submitted-by: iuvax!bsu-cs!dhesi@seismo.CSS.GOV (Rahul Dhesi)
- Posting-number: Volume 11, Issue 14
- Archive-name: zoo/Part05
-
- #! /bin/sh
- #
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # zoo.c
- # zoo.h
- # zoo.man
- export PATH; PATH=/bin:/usr/bin:$PATH
- if test -f 'zoo.c'
- then
- echo shar: "will not over-write existing file 'zoo.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'zoo.c'
- X#ifndef LINT
- X/* @(#) zoo.c 1.19 87/05/30 15:03:53 */
- Xstatic char sccsid[]="@(#) zoo.c 1.19 87/05/30 15:03:53";
- X#endif /* LINT */
- X
- Xextern char version[];
- X
- X/*
- XCopyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
- X*/
- X#include "options.h"
- X#include <stdio.h>
- X#include "various.h"
- X
- X#include "zoo.h"
- X#include "zoofns.h"
- X
- X#include "errors.i"
- X#include "zoomem.h"
- X
- X#ifdef DEBUG
- Xint verbose = 0;
- X#endif
- X
- Xchar *out_buf_adr; /* points to memory allocated for output buffer(s) */
- Xchar *in_buf_adr; /* points to memory allocated for input buffer */
- X
- X/* static declarations */
- Xint quiet = 0; /* whether to be quiet */
- Xint next_arg = FIRST_ARG; /* filenames start at this position */
- Xint arg_count; /* count of arguments supplied to program */
- Xchar **arg_vector; /* vector of arguments supplied to program */
- X
- X/* Suppress loading of some Microsoft C library routines. */
- X#ifdef NDEBUG
- X#ifndef PORTABLE
- X_nullcheck() {} /* prevent loading of Microsoft's null ptr check */
- X#endif
- X#endif
- X
- X#ifndef PORTABLE
- X_setenvp() {} /* prevent loading of Microsoft's _setenvp */
- X#endif
- X
- Xmain(argc,argv)
- Xregister int argc;
- Xregister char **argv;
- X{
- X char *zooname; /* synonym for argv[2] -- to make life easier */
- X#ifndef OOZ
- X static char incorrect_args[] = "Incorrect number of arguments.\n";
- X int filecount; /* how many filespecs supplied */
- X#endif /* OOZ */
- X
- X#ifdef OOZ
- X#else
- X/* else not OOZ */
- X static char usage[] = "Usage: zoo {acDelLPTuUvx}[acdEfInMNoOpPquz1:/.] archive file (\"zoo h\" for help)\n";
- X static char nov_usage[] =
- X "\nNovice usage: zoo -cmd archive[.zoo] file... where -cmd is one of these:\n";
- X char *option;
- X
- X static char nov_cmds[] =
- X /* ADD=0EXT=5 MOV=14TES=20PRI=26 DEL=33 LIS=41UPD=47 FRE=55 COMMENT=64 */
- X "-add -extract -move -test -print -delete -list -update -freshen -comment\n";
- X
- X#ifdef NOENUM
- X#define NONE -1
- X#define ADD 0
- X#define EXTRACT 5
- X#define MOVE 14
- X#define TEST 20
- X#define PRINT 26
- X#define DELETE 33
- X#define LIST 41
- X#define UPDATE 47
- X#define FRESHEN 55
- X#define COMMENT 64
- X
- Xint cmd = NONE;
- X
- X#else
- X enum choice {
- X NONE=-1, ADD=0, EXTRACT=5, MOVE=14, TEST=20, PRINT=26,
- X DELETE=33, LIST=41, UPDATE=47, FRESHEN=55, COMMENT=64
- X };
- X enum choice cmd = NONE; /* assume no Novice command */
- X#endif
- X
- X#endif /* end of not OOZ */
- X
- X arg_count = argc;
- X arg_vector = argv;
- X zooname = argv[FIRST_ARG-1]; /* points to name or archive */
- X
- X#ifdef OOZ
- X if (argc < 2) {
- X putstr (usage1);
- X putstr (usage2);
- X exit (1);
- X }
- X#else
- X/* else not OOZ */
- X if (argc < 2)
- X goto show_usage;
- X filecount = argc - 3;
- X option = strdup(argv[1]);
- X
- X#ifdef DEBUG
- X if (*option == ':') { /* for debugging output */
- X verbose++;
- X option++; /* hide the $ from other functions */
- X }
- X#endif
- X
- X if (*option == 'h' || *option == 'H')
- X goto bigusage;
- X if (strchr("-acDelLPTuUvx", *option) == NULL)
- X goto give_list;
- X
- X if (*option == '-') {
- X
- X#ifdef NOENUM
- X cmd = instr (nov_cmds, strlwr(option));
- X#else
- X cmd = (enum choice) instr (nov_cmds, strlwr(option));
- X#endif
- X
- X if (strlen(option) < 2 || cmd == NONE)
- X goto show_usage;
- X if ( ((cmd == ADD || cmd == MOVE || cmd == FRESHEN ||
- X cmd == UPDATE || cmd == DELETE) && argc < 4) ||
- X ((cmd == EXTRACT || cmd == TEST || cmd == LIST ||
- X cmd == PRINT || cmd == COMMENT) && argc < 3)) {
- X fprintf (stderr, incorrect_args);
- X goto show_usage;
- X }
- X } else {
- X char *wheresI; /* will be null if I option not supplied */
- X if (
- X (
- X strchr("au",*option) &&
- X (
- X ((wheresI = strchr(option,'I')) && argc != 3) ||
- X wheresI==NULL && argc < 4
- X )
- X ) ||
- X strchr("DU",*option) && argc < 4 ||
- X strchr("cexlvL",*option) && argc < 3 ||
- X strchr("TP",*option) && argc != 3
- X ) {
- X fprintf (stderr, incorrect_args);
- X goto show_usage;
- X }
- X }
- X#endif /* end of not OOZ */
- X
- X#ifndef OOZ
- X /* if not doing a list and no extension in archive name, add default
- X extension */
- X if (cmd != LIST && strchr("lvL", *option) == NULL &&
- X strchr(nameptr (zooname), EXT_CH) == NULL)
- X zooname = newcat (zooname, EXT_DFLT);
- X#endif
- X
- X#ifndef PORTABLE
- X#ifndef OOZ
- X/* only need to ensure integrity of created archive */
- X break_off(); /* break = off -- specific to MSDOS */
- X#endif
- X#endif
- X
- X/*
- XHere we allocate a large block of memory for the duration of the program.
- Xlzc() and lzd() will use half of it each. Routine getfile() will use all
- Xof it.
- X*/
- X/* fudge factor to avoid off-by-one errors */
- X#define FUDGE 10
- X
- X/* fudge/2 fudge/2
- X** [______________||________________|]
- X** output buffer input buffer
- X*/
- X
- X out_buf_adr = emalloc (OUT_BUF_SIZE + IN_BUF_SIZE + FUDGE);
- X
- X /* input buffer is in top of allocated block */
- X in_buf_adr = out_buf_adr + OUT_BUF_SIZE + (FUDGE/2);
- X
- X#ifdef OOZ
- Xzooext(zooname, "\0"); /* just extract -- no fancy stuff */
- Xexit (0); /* and exit normally */
- X#else
- X/* else not OOZ -- parse command line and invoke a routine */
- X if (cmd != NONE) {
- X switch (cmd) {
- X
- X case ADD: zooadd (zooname, filecount, &argv[3], "aP:"); break;
- X case FRESHEN: zooadd (zooname, filecount, &argv[3], "auP:"); break;
- X case UPDATE: zooadd (zooname, filecount, &argv[3], "aunP:"); break;
- X case MOVE: zooadd (zooname, filecount, &argv[3], "aMP:"); break;
- X
- X case EXTRACT: zooext (zooname, "x"); break;
- X case TEST: zooext (zooname, "xNd"); break;
- X case PRINT: zooext (zooname, "xp"); break;
- X
- X case DELETE: zoodel (zooname, "DP",1); break;
- X case LIST: zoolist (&argv[2], "v", argc-2); break;
- X case COMMENT: comment (zooname, "c"); break;
- X default: goto show_usage;
- X }
- X } else
- X switch (*option) {
- X case 'a':
- X case 'u':
- X case 'T':
- X zooadd (zooname, filecount, &argv[3], option); break;
- X case 'D':
- X zoodel (zooname, option, 1); break;
- X case 'U':
- X zoodel (zooname, option, 0); break;
- X case 'v':
- X case 'l':
- X zoolist(&argv[2], option, 1); break;
- X case 'L':
- X zoolist(&argv[2], option, argc-2); break;
- X case 'e':
- X case 'x':
- X zooext(zooname, option); break;
- X case 'P':
- X zoopack (zooname, option); break;
- X case 'c':
- X comment (zooname, option); break;
- X default:
- X goto give_list;
- X }
- Xexit (0); /* don't fall through */
- X
- X/* usage list including Novice commands */
- Xshow_usage:
- X fprintf (stderr, "%s%s%s", usage, nov_usage, nov_cmds); exit (1);
- X
- X/* brief usage list */
- Xgive_list:
- X fprintf (stderr, usage); exit (1);
- X
- X/* help screen */
- Xbigusage:
- X
- Xprintf ("Zoo archiver, %s\n", version);
- Xprintf("(C) Copyright 1986, 1987 Rahul Dhesi -- Noncommercial use permitted\n");
- X
- Xprintf (usage);
- Xprintf ("\nChoose a command from within {} and zero or more modifiers from within []\n");
- X
- Xprintf ("E.g.: `zoo a save /bin/*' will archive all files in /bin into save.zoo\n\n");
- X
- Xprintf (" Commands in {} mean: |Modifiers in [] mean:\n");
- X
- Xprintf (" a add files | a show archive name(s) in listing\n");
- Xprintf (" c update comments | c add/list comments\n");
- Xprintf (" D delete stored files | d extract/list deleted files too\n");
- Xprintf (" e,x extract files | dd extract/list only deleted files\n");
- Xprintf (" l,v,L list filenames | E erase backup after packing\n");
- Xprintf (" P pack archive | f fast add (no compression) or list\n");
- Xprintf (" T fix archive datestamp | M move when adding (erase original)\n");
- Xprintf (" u add only newer files | n add only files not already in archive\n");
- Xprintf (" U undelete stored files | N send extracted data to Neverland\n");
- Xprintf (" ----------------------------- O,oo don't ask \"Overwrite?\"\n");
- Xprintf (" q be quiet p pipe extracted data to standard output\n");
- Xprintf (" : don't store dir names /,// extract full pathnames\n");
- Xprintf (" . pack to current dir I add filenames read from stdin\n");
- X
- X#ifdef PORTABLE
- Xprintf (" P pack after adding @n start extract/list at position n\n");
- X/* nothing */
- X#else
- Xprintf (" z add/extract Z format @n start extract/list at position n\n");
- X#endif /* ndef PORTABLE */
- X
- X
- Xprintf (nov_usage);
- Xprintf (nov_cmds);
- X#endif /* end of not OOZ */
- X
- X/* NOTE: if allowed to fall through and return without an exit() statement,
- X it was printing garbage--corrupted stack? Why--bug in Microsoft C? */
- Xexit (1);
- X}
- SHAR_EOF
- fi
- if test -f 'zoo.h'
- then
- echo shar: "will not over-write existing file 'zoo.h'"
- else
- sed 's/^X//' << \SHAR_EOF > 'zoo.h'
- X/* @(#) zoo.h 1.3 87/05/30 14:13:42 */
- X
- X/*
- XThe contents of this file are hereby released to the public domain.
- X
- X -- Rahul Dhesi 1986/11/14
- X*/
- X
- X
- X/* Global data structures and also some information about archive structure.
- X
- XAmong other things, the archive header contains:
- X
- X(a) A text message. In the MS-DOS version this message is terminated by
- Xcontrol Z. This allows naive users to type the archive to the screen
- Xand see a brief but meaningful message instead of garbage. The contents of
- Xthe text message are however not used by Zoo and they may be anything.
- XIn particular, the text message may identify the type or archive or the
- Xparticular computer system it was created on. Note: Due to some untidyness
- Xin Zoo's code, when an archive is packed by any version of Zoo, the text
- Xmessage is changed to the text messages used by that version. For example,
- Xif Zoo 1.10 packs an archive created by Zoo 1.31, the text message changes
- Xto "Zoo 1.10 archive.". In the long run, this should be changed to
- Xpreserve the text message, thus identifying the version that created the
- Xarchive, not the version that packed it.
- X
- X(b) A four-byte tag that identifies all Zoo archives. This helps prevent
- Xarbitrary binary files from being treated as Zoo archives. The tag value is
- Xarbitrary, but seemed to be unlikely to occur in an executable file. The
- Xsame tag value is used to identify each directory entry.
- X
- X(c) A long pointer to where in the file the archive starts. This could be
- Xleft out if the archive always started immediately after the header, but I
- Xwant to allow room for future additions to the header information without
- Xconfusing earlier versions of Zoo. This pointer is stored along with its
- Xnegation for consistency checking. It is hoped that if the archive is
- Xdamaged, both the pointer and its negation won't be damaged and at least
- Xone would still be usable to tell us where the data begins.
- X
- X(d) A two-byte value giving the major and minor version number of the
- Xminimum version of Zoo that is needed to fully manipulate the archive.
- XAs the archive structure is modified, this version number may increase.
- XCurrently version 1.31 of Zoo creates archives that may be fully manipulated
- Xby version 1.10 onwards.
- X
- XVersion numbering:
- XThe directory entry of each file will contain the minimum version number of
- XZoo needed to extract that file. As far as possible, version 1.00 of Zoo
- Xwill be able to extract files from future version archives.
- X*/
- X
- X/* This is version 1.1. Define major and minor version numbers */
- X
- X#define MAJOR_VER 1 /* needed to manipulate archive */
- X#define MINOR_VER 4
- X
- X#define MAJOR_EXT_VER 1 /* needed to extract file */
- X#define MINOR_EXT_VER 0
- X
- X#define CTRL_Z 26
- X#define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
- X#define TEXT "ZOO 1.50 Archive.\032" /* Header text for archive. */
- X#define SIZ_TEXT 20 /* Size of header text */
- X
- X#define PATHSIZE 256 /* Max length of pathname */
- X#define FNAMESIZE 13 /* Size of DOS filename */
- X#define LFNAMESIZE 256 /* Size of long filename */
- X#define ROOTSIZE 8 /* Size of fname without extension */
- X#define EXTLEN 3 /* Size of extension */
- X#define FILE_LEADER "@)#(" /* Allowing location of file data */
- X#define SIZ_FLDR 5 /* 4 chars plus null */
- X#define MAX_PACK 1 /* max packing method we can handle */
- X#define BACKUP_EXT ".bak" /* extension of backup file */
- X
- X#ifdef OOZ
- X#define FIRST_ARG 2
- X#endif
- X
- X#ifdef ZOO
- X#define FIRST_ARG 3 /* argument position of filename list */
- X#endif
- X
- X/* WARNING: Static initialization in zooadd.c or zooext.c depends on the
- X order of fields in struct zoo_header */
- Xstruct zoo_header {
- X char text[SIZ_TEXT]; /* archive header text */
- X unsigned long zoo_tag; /* identifies archives */
- X long zoo_start; /* where the archive's data starts */
- X long zoo_minus; /* for consistency checking of zoo_start */
- X char major_ver;
- X char minor_ver; /* minimum version to extract all files */
- X};
- X
- X/* Note: Microsoft C aligns data at word boundaries. So, to keep things
- X compact, always try to pair up character fields. */
- Xstruct direntry {
- X unsigned long zoo_tag; /* tag -- redundancy check */
- X char type; /* type of directory entry. always 1 for now */
- X char packing_method; /* 0 = no packing, 1 = normal LZW */
- X long next; /* pos'n of next directory entry */
- X long offset; /* position of this file */
- X unsigned int date; /* DOS format date */
- X unsigned int time; /* DOS format time */
- X unsigned int file_crc; /* CRC of this file */
- X long org_size;
- X long size_now;
- X char major_ver;
- X char minor_ver; /* minimum version needed to extract */
- X char deleted; /* will be 1 if deleted, 0 if not */
- X char struc; /* file structure if any */
- X long comment; /* points to comment; zero if none */
- X unsigned int cmt_size; /* length of comment, 0 if none */
- X char fname[FNAMESIZE]; /* filename */
- X
- X int var_dir_len; /* length of variable part of dir entry */
- X char tz; /* timezone where file was archived */
- X unsigned int dir_crc; /* CRC of directory entry */
- X
- X /* fields for variable part of directory entry follow */
- X char namlen; /* length of long filename */
- X char dirlen; /* length of directory name */
- X char lfname[LFNAMESIZE]; /* long filename */
- X char dirname[PATHSIZE]; /* directory name */
- X int system_id; /* Filesystem ID */
- X};
- X
- X/* Values for direntry.system_id */
- X#define SYSID_NIX 0 /* UNIX and similar filesystems */
- X#define SYSID_MS 1 /* MS-DOS filesystem */
- X#define SYSID_PORTABLE 2 /* Portable syntax */
- X
- X/* Structure of header of small archive containing just one file */
- X
- X#define TINYTAG 0x07FE /* magic number */
- X
- Xstruct tiny_header { /* one-file small archive */
- X int tinytag; /* magic number */
- X char type; /* always 1 for now */
- X char packing_method;
- X unsigned int date;
- X unsigned int time;
- X unsigned int file_crc;
- X long org_size;
- X long size_now;
- X char major_ver;
- X char minor_ver;
- X unsigned int cmt_size; /* length of comment, 0 if none */
- X char fname[FNAMESIZE]; /* filename */
- X};
- X
- X/* offsets of items within the canonical zoo archive header */
- X#define SIZ_ZOOH 34 /* 34 byte-long archive header */
- X#define TEXT_I 0 /* text in header */
- X#define ZTAG_I 20 /* zoo tag */
- X#define ZST_I 24 /* start offset */
- X#define ZSTM_I 28 /* negative of start offset */
- X#define MAJV_I 32 /* major version */
- X#define MINV_I 33 /* minor version */
- X
- X/* offsets of items within the canonical directory entry structure */
- X#define SIZ_DIR 51 /* length of type 1 directory entry */
- X#define SIZ_DIRL 56 /* length of type 2 directory entry */
- X#define DTAG_I 0 /* tag within directory entry */
- X#define DTYP_I 4 /* type of directory entry */
- X#define PKM_I 5 /* packing method */
- X#define NXT_I 6 /* pos'n of next directory entry */
- X#define OFS_I 10 /* position (offset) of this file */
- X#define DAT_I 14 /* DOS format date */
- X#define TIM_I 16 /* DOS format time */
- X#define CRC_I 18 /* CRC of this file */
- X#define ORGS_I 20 /* original size */
- X#define SIZNOW_I 24 /* size now */
- X#define DMAJ_I 28 /* major version number */
- X#define DMIN_I 29 /* minor version number */
- X#define DEL_I 30 /* deleted or not */
- X#define STRUC_I 31 /* file structure */
- X#define CMT_I 32 /* comment [offset] */
- X#define CMTSIZ_I 36 /* comment size */
- X#define FNAME_I 38 /* filename */
- X#define VARDIRLEN_I 51 /* length of var. direntry */
- X#define TZ_I 53 /* timezone */
- X#define DCRC_I 54 /* CRC of directory entry */
- X
- X#define FNM_SIZ 13 /* size of stored filename */
- X
- X/* Offsets within variable part of directory entry */
- X#define NAMLEN_I (SIZ_DIRL + 0)
- X#define DIRLEN_I (SIZ_DIRL + 1)
- X#define LFNAME_I (SIZ_DIRL + 2)
- X#define DIRNAME_I LFNAME_I /* plus length of filename */
- X
- X/* total size of fixed plus variable directory recognized currently:
- X1 byte each for dirlen and namlen, and 256 each for long filename
- Xand directory name, + fudge factor of 10. */
- X#define MAXDIRSIZE (SIZ_DIRL+1+1+256+256+10)
- X
- X/* Value used to stuff into timezone field if it is not known */
- X#define NO_TZ 127
- X
- SHAR_EOF
- fi
- if test -f 'zoo.man'
- then
- echo shar: "will not over-write existing file 'zoo.man'"
- else
- sed 's/^X//' << \SHAR_EOF > 'zoo.man'
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- XNAME
- X zoo - manipulate archives of files in compressed form
- X
- XSYNOPSIS
- X zoo {acDehlLPTuUvx}[cdEfInMNoOpPquv1:./@] archive [file] ...
- X zoo -command archive [file] ...
- X zoo h
- X
- XDESCRIPTION
- X Zoo is used to create and maintain collections of files in
- X compressed form. It uses a Lempel-Ziv compression algorithm
- X that gives space savings in the range of 20% to 80% depend-
- X ing on the type of file data.
- X
- X The command zoo h gives summary of commands.
- X
- X Zoo will not add an archive to itself, nor add the archive's
- X backup (with .bak extension to the filename) to the archive.
- X
- X Zoo has two types of commands: Expert commands, which con-
- X sist of one command letter followed by zero or more modifier
- X characters, and Novice commands, which consist of a hyphen
- X (`-') followed by a command word that may be abbreviated.
- X Expert commands are case-sensitive but Novice commands are
- X not.
- X
- X When zoo adds a file to an existing archive, it marks as
- X deleted any already-archived file with the same name.
- X (Directory prefixes are significant in this comparison if
- X and only if directory names are being stored.) Deleted files
- X may be later undeleted. Archives may be packed to recover
- X space occupied by deleted files.
- X
- X All commands assume that the archive name ends with the
- X characters .zoo unless a different extension is supplied.
- X
- X Novice commands
- X
- X Novice commands may be abbreviated to a hyphen followed by
- X at least one command character. Each Novice command works
- X in two stages. First, the command does its intended work.
- X Then, if the result was that one or more files were deleted
- X in the specified archive, the archive is packed. If packing
- X occurs, the original unpacked archive is always left behind
- X with an extension of .bak.
- X
- X No Novice command ever stores the directory prefix of a
- X file. When a Novice command is used to add a file to an
- X archive, any already-archived file with the same name,
- X regardless of the directory prefix, is marked deleted.
- X
- X
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 1
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X The Novice commands are as follows.
- X
- X -add Adds the specified files to the archive.
- X
- X -freshen
- X Adds a specified file to the archive if and only if an
- X older file by the same name already exists in the
- X archive.
- X
- X -delete
- X Deletes the specified files from the archive.
- X
- X -update
- X Adds a specified file to the archive either: if an
- X older file by the same name already exists in the
- X archive or: if a file by the same name does not
- X already exist in the archive.
- X
- X -extract
- X Extracts the specified files from the archive. If no
- X file is specified all files are extracted.
- X
- X -move
- X Equivalent to -add except that source files are deleted
- X after addition.
- X
- X -print
- X Equivalent to -extract except that extracted data are
- X sent to standard output.
- X
- X -list
- X Gives information about the specified archived files
- X including any attached comments. If no files are
- X specified all files are listed. Deleted files are not
- X listed.
- X
- X -test
- X Equivalent to -extract except that the extracted data
- X are not saved but any errors encountered are reported.
- X
- X -comment
- X Allows the user to add or update comments attached to
- X archived files. When prompted, the user may: type a
- X carriage return to skip the file, leaving any current
- X comment unchanged; or type a (possibly null) comment
- X of up to 65,535 characters terminated by /end (case-
- X insensitive) on a separate line; or type the end-of-
- X file character (normally control D) to skip all remain-
- X ing files.
- X
- X -delete
- X Deletes the specified files.
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 2
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X The correspondence between Novice and Expert commands is as follows.
- X
- X Novice Equivalent
- X Command Description Expert Command
- X _______________________________________________________________________
- X -add add files to archive aP:
- X -extract extract files from archive x
- X -move move files to archive aMP:
- X -test test archive integrity xNd
- X -print extract files and send to standard output xp
- X -delete delete files from archive DP
- X -list list information about archived files v
- X -update update archive by adding new or newer files aunP:
- X -freshen freshen archive by adding newer files auP:
- X -comment allows user to attach comments to files c
- X
- X Expert commands
- X
- X The general format of expert commands is:
- X
- X zoo {acDehlPTuUvx}[cdEfInMNoOpPquv1:./@] archive [file] ...
- X
- X The characters enclosed within {} are commands. Choose any
- X one of these. The characters enclosed within [] just to the
- X right of the {} are modifiers and zero or more of these may
- X immediately follow the command character. All combinations
- X of command and modifier characters may not be valid.
- X
- X Files are added to an archive with the command:
- X
- X zoo {au}[cfIMnPqu:] archive [file] ...
- X
- X Command characters are:
- X
- X a Add each specified file to archive. Any already-
- X archived file with the same name is marked as deleted.
- X
- X u Do an update of the archive. A specified file is added
- X to the archive only if a copy of it is already in the
- X archive and the copy being added is newer than the copy
- X already in the archive.
- X
- X The following modifiers are specific to these commands.
- X
- X M Move files to archive. This makes zoo delete (unlink)
- X the original files after they have been added to the
- X archive. Files are deleted after addition of all files
- X to the archive is complete and after any requested
- X packing of the archive has been done, and only if zoo
- X detected no errors.
- X
- X
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 3
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X n Add new files only. A specified file is added only if
- X it isn't already in the archive.
- X
- X P Pack archive after files have been added.
- X
- X u Applied to the a command, this modifier makes it behave
- X identically to the u command.
- X
- X The combination of the n modifier with the u modifier
- X or u command causes addition of a file to the archive
- X either if the file is not already in the archive, or if
- X the file is already in the archive but the archived
- X copy is older than the copy being added.
- X
- X : Do not store directory names. In the absence of this
- X modifier zoo stores the full pathname of each archived
- X file.
- X
- X I Read filenames to be archived from standard input. Zoo
- X will read its standard input and assume that each line
- X of text contains a filename. Under the **IX family,
- X the entire line is used. Under MS-DOS and AmigaDOS,
- X zoo assumes that the filename is terminated by a blank,
- X tab, or newline; thus it is permissible for the line of
- X text to contain more than one field separated by white
- X space, and only the first field will be used.
- X
- X Under the **IX family of operating systems, zoo can be
- X used as follows in a pipeline:
- X
- X find . -print | zoo aI sources
- X
- X
- X
- X If the I modifier is specified, no filenames may be
- X supplied on the command line itself.
- X
- X Files are extracted from an archive with the command:
- X
- X zoo {ex}[dNoOpq./@] archive [file] ...
- X
- X The e and x commands are synonymous. If no file was speci-
- X fied, all files are extracted from the archive.
- X
- X The following modifiers are specific to the e and x com-
- X mands:
- X
- X N Do not save extracted data but report any errors
- X encountered.
- X
- X O Overwrite files. Normally, if a file being extracted
- X would overwrite an already-existing file of the same
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 4
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X name, zoo asks you if you really want to overwrite it.
- X You may answer the question with `y', which means yes,
- X overwrite; or `n', which means no, don't overwrite; or
- X `a', which means assume the answer is `y' for this and
- X all subsequent files. The O modifier makes zoo assume
- X that files may always be overwritten.
- X
- X The O, N, and p modifiers are mutually exclusive.
- X
- X o This is equivalent to the O modifier if and only if it
- X is given at least twice. It is otherwise ignored.
- X
- X p Pipe extracted data to standard output. Error messages
- X are piped to standard output as well. However, if a
- X bad CRC is detected, an error message is sent both to
- X standard error and to standard output.
- X
- X / Extract to original pathname. Any needed directories
- X must already exist. In the absence of this modifier
- X all files are extracted into the current directory. If
- X this modifier is doubled as //, needed directories need
- X not exist and are created if necessary.
- X
- X Archived files are listed with the command:
- X
- X zoo {lLv}[adfv@] archive[.zoo] [file] ...
- X
- X l Information presented includes the date and time of
- X each file, its original and current (compressed) sizes,
- X and the percentage size decrease due to compression
- X (labelled CF or compression factor). If no filename is
- X supplied all files are listed except deleted files.
- X
- X L This is identical to the l command except that all sup-
- X plied arguments must be archives and the contents of
- X each are listed.
- X
- X v This causes a verbose listing, which additionally shows
- X any comment attached to each file. Using the v modif-
- X ier with the l command has the same effect.
- X
- X The following modifier is specific to the archive list com-
- X mands:
- X
- X a This gives a single-line format containing both each
- X filename and the name of the archive, sorted by archive
- X name. It is especially useful with the L command,
- X since the result can be further sorted on any field to
- X give a master listing of the entire contents of a set
- X of archives.
- X
- X
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 5
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X Files may be deleted and undeleted from an archive with the
- X following commands:
- X
- X zoo {DU}[Pq1] archive file ...
- X
- X The D command deletes the specified files and the U command
- X undeletes the specified files. The 1 modifier (the digit
- X one, not the letter ell) forces deletion or undeletion of at
- X most one file. If multiple instances of the same file exist
- X in an archive, use of the 1 modifier may allow selective
- X extraction of one of these.
- X
- X Comments may be added to an archive with the command:
- X
- X zoo c archive
- X
- X This behaves identically to the -comment command.
- X
- X The timestamp of an archive may be adjusted with the com-
- X mand:
- X
- X zoo T[q] archive
- X
- X Zoo normally attempts to maintain the timestamp of an
- X archive to reflect the age of the newest file stored in it.
- X Should the timestamp ever be incorrect it can be fixed with
- X the T command.
- X
- X An archive may be packed with the command:
- X
- X zoo P[EPq] archive
- X
- X If the backup copy of the archive already exists, zoo will
- X refuse to pack the archive unless the P modifier is also
- X given. The E modifier causes zoo not to save a backup copy
- X of the original archive after packing. A unique temporary
- X file in the current directory is used to initially hold the
- X packed archive. This file will be left behind if packing is
- X interrupted or if for some reason this file cannot be
- X renamed to the name of the original archive when packing is
- X complete.
- X
- X Packing removes any garbage data appended to an archive
- X because of Xmodem file transfer and also recovers space used
- X by comments that were replaced.
- X
- X General modifiers
- X
- X The following modifiers are applicable to several commands:
- X
- X c Applied to the a and u commands, this causes the user
- X to be prompted for a comment for each file added to the
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 6
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X archive. If the file being added has replaced a file
- X already in the archive, any comment attached to the
- X replaced file is shown to the user and becomes attached
- X to the newly-added file unless the user changes it.
- X Possible user responses are as described for the -com-
- X ment command. Applied to the archive list command l,
- X the c modifier causes the listing of any comments
- X attached to archived files.
- X
- X . In conjunction with / or // this modifier causes any
- X extracted pathname beginning with `/' to be interpreted
- X relative to the current directory, resulting in the
- X possible creation of a subtree rooted at the current
- X directory. In conjunction with the command P the .
- X modifier causes the packed archive to be created in the
- X current directory. This is intended to allow users
- X with limited disk space but multiple disk drives to
- X pack large archives.
- X
- X d Most commands that act on an archive act only on files
- X that are not deleted. The d modifier makes commands
- X act on both normal and deleted files. If doubled as
- X dd, this modifier forces selection only of deleted
- X files.
- X
- X f Applied to the a and u commands, the f modifier causes
- X fast archiving by adding files without compression.
- X Applied to l it causes a fast listing of files in a
- X multicolumn format.
- X
- X q Be quiet. Normally zoo lists the name of each file and
- X what action it is performing. The q modifier
- X suppresses this. When files are being extracted to
- X standard output, the q modifier suppresses the header
- X preceding each file.
- X
- X Error messages are never suppressed.
- X
- X @ Extract or list beginning at position n, where n is a
- X decimal number following the @ sign without any inter-
- X vening spaces. This may be used to recover data from a
- X damaged archive by skipping the damaged part. The
- X number specified must be the position within the
- X archive of an undamaged directory entry. This position
- X is usually obtained from fiz(1).
- X
- X Wildcard handling
- X
- X Under the **IX family of operating systems, the shell nor-
- X mally expands wildcards to a list of matching files. Wild-
- X cards that are meant to match files within an archive must
- X therefore be escaped or quoted. When selecting files to be
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 7
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X added to an archive, wildcard conventions are as defined for
- X the shell. When selecting files from within an archive,
- X wildcard handling is done by zoo as described below.
- X
- X Under MS-DOS and AmigaDOS, quoting of wildcards is not
- X needed. All wildcard expansion of filenames is done by zoo,
- X and wildcards inside directory names are expanded only when
- X listing or extracting files but not when adding them.
- X
- X The wildcard syntax interpreted by zoo is limited to the
- X following characters.
- X
- X * Matches any sequence of zero or more characters.
- X
- X ? Matches any single character.
- X
- X Arbitrary combinations of * and ? are allowed.
- X
- X / If a supplied pattern contains a slash anywhere in it,
- X then the slash separating any directory prefix from the
- X filename must be matched explicitly. If a supplied
- X pattern contains no slashes, the match is selective
- X only on the filename.
- X
- X c-c Two characters separated by a hyphen specify a charac-
- X ter range. All filenames beginning with those charac-
- X ters will match. The character range is meaningful
- X only by itself or preceded by a directory name. It is
- X not specially interpreted if it is part of a filename.
- X
- X MS-DOS users should note that zoo does not treat the dot as
- X a special character, and it does not ignore characters fol-
- X lowing an asterisk. Thus * matches all filenames; *.*
- X matches filenames containing a dot; *_* matches filenames
- X containing an underscore; and *z matches all filenames that
- X end with the character z, whether or not they contain a dot.
- X
- XFILES
- X xXXXXXX - temporary file used during packing
- X archive_name.bak - backup of archive
- X
- XSEE ALSO
- X compress(1), fiz(1)
- X
- XBUGS
- X Standard input cannot be archived nor can a created archive
- X be sent to standard output. Spurious error messages may
- X appear if the filename of an archive is too long.
- X
- X Since zoo never archives any file with the same name as the
- X archive or its backup (regardless of any path prefixes),
- X care should be taken to make sure that a file to be archived
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 8
- X
- X
- X
- XZOO(1) **IX Programmer's Manual ZOO(1)
- X
- X
- X
- X does not coincidentally have the same name as the archive it
- X is being added to. It usually suffices to make sure that no
- X file being archived is itself a zoo archive.
- X
- X Only regular files are archived; directories and devices are
- X not.
- X
- X Early versions of MS-DOS have a bug that prevents "." from
- X referring to the root directory; this leads to anomalous
- X results if the extraction of paths beginning with a dot is
- X attempted.
- X
- X It is not currently possible to create a zoo archive con-
- X taining all zoo archives that do not contain themselves.
- X
- XDIAGNOSTICS
- X Error messages are intended to be self-explanatory and are
- X divided into three categories. WARNINGS are intended to
- X inform the user of an unusual situation, such as a CRC error
- X during extraction, or -freshening of an archive containing a
- X file newer than one specified on the command line. ERRORS
- X are fatal to one file, but execution continues with the next
- X file if any. FATAL errors cause execution to be aborted.
- X The occurrence of any of these causes an exit status of 1.
- X Normal termination without any errors gives an exit status
- X of 0.
- X
- XFUTURE DIRECTIONS
- X A revised version of zoo is in the works which will allow
- X numbering of multiple versions of a file and automatically
- X perform end-of-line conversion for text files moved between
- X dissimilar systems. It will be upward and downward compati-
- X ble with existing versions of zoo.
- X
- XTHANKS
- X Thanks are due to:
- X
- X Paul Homchick, who provided numerous detailed reports about
- X some nasty bugs.
- X
- X Bill Davidsen, who fixed zoo's handling of daylight savings
- X time and also provided changes to make this manual format
- X correctly with troff.
- X
- XAUTHOR
- X Rahul Dhesi
- X
- X
- X
- X
- X
- X
- X
- X
- X
- XPrinted 7/12/87 Jul 12, 1987 9
- X
- SHAR_EOF
- fi
- exit 0
- # End of shell archive
- --
- Rahul Dhesi UUCP: {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi
-
- --
-
- Rich $alz
- Cronus Project, BBN Labs rsalz@bbn.com
- Moderator, comp.sources.unix sources@uunet.uu.net
-