home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / zoo / part05 < prev    next >
Encoding:
Text File  |  1987-08-16  |  39.5 KB  |  1,113 lines

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v11i014:  File archive program, Part05/07
  5. Message-ID: <969@uunet.UU.NET>
  6. Date: 18 Aug 87 02:02:42 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1102
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: iuvax!bsu-cs!dhesi@seismo.CSS.GOV (Rahul Dhesi)
  12. Posting-number: Volume 11, Issue 14
  13. Archive-name: zoo/Part05
  14.  
  15. #! /bin/sh
  16. #
  17. # This is a shell archive, meaning:
  18. # 1. Remove everything above the #! /bin/sh line.
  19. # 2. Save the resulting text in a file.
  20. # 3. Execute the file with /bin/sh (not csh) to create:
  21. #    zoo.c
  22. #    zoo.h
  23. #    zoo.man
  24. export PATH; PATH=/bin:/usr/bin:$PATH
  25. if test -f 'zoo.c'
  26. then
  27.     echo shar: "will not over-write existing file 'zoo.c'"
  28. else
  29. sed 's/^X//' << \SHAR_EOF > 'zoo.c'
  30. X#ifndef LINT
  31. X/* @(#) zoo.c 1.19 87/05/30 15:03:53 */
  32. Xstatic char sccsid[]="@(#) zoo.c 1.19 87/05/30 15:03:53";
  33. X#endif /* LINT */
  34. X
  35. Xextern char version[];
  36. X
  37. X/*
  38. XCopyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  39. X*/
  40. X#include "options.h"
  41. X#include <stdio.h>
  42. X#include "various.h"
  43. X
  44. X#include "zoo.h"
  45. X#include "zoofns.h"
  46. X
  47. X#include "errors.i"
  48. X#include "zoomem.h"
  49. X
  50. X#ifdef DEBUG
  51. Xint verbose = 0;
  52. X#endif
  53. X
  54. Xchar *out_buf_adr;      /* points to memory allocated for output buffer(s) */
  55. Xchar *in_buf_adr;       /* points to memory allocated for input buffer */
  56. X
  57. X/* static declarations */
  58. Xint quiet = 0;             /* whether to be quiet */
  59. Xint next_arg = FIRST_ARG; /* filenames start at this position */
  60. Xint arg_count;          /* count of arguments supplied to program */
  61. Xchar **arg_vector;      /* vector of arguments supplied to program */
  62. X
  63. X/* Suppress loading of some Microsoft C library routines. */
  64. X#ifdef NDEBUG
  65. X#ifndef PORTABLE
  66. X_nullcheck() {}         /* prevent loading of Microsoft's null ptr check */
  67. X#endif
  68. X#endif
  69. X
  70. X#ifndef PORTABLE
  71. X_setenvp() {}           /* prevent loading of Microsoft's _setenvp */
  72. X#endif
  73. X
  74. Xmain(argc,argv)
  75. Xregister int argc;
  76. Xregister char **argv;
  77. X{
  78. X   char *zooname;          /* synonym for argv[2] -- to make life easier */
  79. X#ifndef OOZ
  80. X   static char incorrect_args[] = "Incorrect number of arguments.\n";
  81. X   int filecount;          /* how many filespecs supplied */
  82. X#endif /* OOZ */
  83. X
  84. X#ifdef OOZ
  85. X#else
  86. X/* else not OOZ */
  87. X      static char usage[] = "Usage: zoo {acDelLPTuUvx}[acdEfInMNoOpPquz1:/.] archive file (\"zoo h\" for help)\n";
  88. X      static char nov_usage[] = 
  89. X          "\nNovice usage:  zoo -cmd archive[.zoo] file...  where -cmd is one of these:\n";
  90. X      char *option;
  91. X
  92. X      static char nov_cmds[] = 
  93. X         /* ADD=0EXT=5    MOV=14TES=20PRI=26 DEL=33  LIS=41UPD=47  FRE=55   COMMENT=64 */
  94. X           "-add -extract -move -test -print -delete -list -update -freshen -comment\n";
  95. X
  96. X#ifdef NOENUM
  97. X#define NONE   -1
  98. X#define ADD    0
  99. X#define EXTRACT 5
  100. X#define MOVE   14
  101. X#define TEST   20
  102. X#define PRINT  26
  103. X#define DELETE 33
  104. X#define LIST   41
  105. X#define UPDATE 47
  106. X#define FRESHEN   55
  107. X#define COMMENT   64
  108. X
  109. Xint cmd = NONE;
  110. X
  111. X#else
  112. X   enum choice {
  113. X      NONE=-1, ADD=0, EXTRACT=5, MOVE=14, TEST=20, PRINT=26, 
  114. X      DELETE=33, LIST=41, UPDATE=47, FRESHEN=55, COMMENT=64
  115. X   };
  116. X   enum choice cmd = NONE;          /* assume no Novice command */
  117. X#endif
  118. X
  119. X#endif /* end of not OOZ */
  120. X
  121. X   arg_count = argc;
  122. X   arg_vector = argv;
  123. X   zooname = argv[FIRST_ARG-1];     /* points to name or archive */
  124. X
  125. X#ifdef OOZ
  126. X   if (argc < 2) {
  127. X      putstr (usage1);
  128. X      putstr (usage2);
  129. X      exit (1);
  130. X   }
  131. X#else
  132. X/* else not OOZ */
  133. X   if (argc < 2)
  134. X      goto show_usage;
  135. X   filecount = argc - 3;
  136. X   option = strdup(argv[1]);
  137. X
  138. X#ifdef DEBUG
  139. X   if (*option == ':') {         /* for debugging output */
  140. X      verbose++;
  141. X      option++;                  /* hide the $ from other functions */
  142. X   }
  143. X#endif
  144. X
  145. X   if (*option == 'h' || *option == 'H')
  146. X      goto bigusage;
  147. X    if (strchr("-acDelLPTuUvx", *option) == NULL)
  148. X        goto give_list;
  149. X
  150. X   if (*option == '-') {
  151. X
  152. X#ifdef NOENUM
  153. X      cmd = instr (nov_cmds, strlwr(option));
  154. X#else
  155. X      cmd = (enum choice) instr (nov_cmds, strlwr(option));
  156. X#endif
  157. X
  158. X      if (strlen(option) < 2 || cmd == NONE)
  159. X         goto show_usage;
  160. X      if (  ((cmd == ADD || cmd == MOVE || cmd == FRESHEN || 
  161. X                  cmd == UPDATE || cmd == DELETE) && argc < 4) ||
  162. X            ((cmd == EXTRACT || cmd == TEST || cmd == LIST ||
  163. X                     cmd == PRINT || cmd == COMMENT) && argc < 3)) {
  164. X         fprintf (stderr, incorrect_args);
  165. X         goto show_usage;
  166. X      }
  167. X   } else {
  168. X        char *wheresI;        /* will be null if I option not supplied */
  169. X        if    (
  170. X                (
  171. X                    strchr("au",*option) && 
  172. X                    (
  173. X                        ((wheresI = strchr(option,'I')) && argc != 3) ||
  174. X                        wheresI==NULL && argc < 4
  175. X                    )
  176. X                ) ||
  177. X                 strchr("DU",*option) && argc < 4 ||
  178. X             strchr("cexlvL",*option) && argc < 3 ||
  179. X             strchr("TP",*option)   && argc != 3
  180. X            ) {
  181. X         fprintf (stderr, incorrect_args);
  182. X         goto show_usage;
  183. X      }
  184. X   }
  185. X#endif /* end of not OOZ */
  186. X
  187. X#ifndef OOZ
  188. X   /* if not doing a list and no extension in archive name, add default 
  189. X   extension */
  190. X   if (cmd != LIST && strchr("lvL", *option) == NULL &&
  191. X         strchr(nameptr (zooname), EXT_CH) == NULL)
  192. X      zooname = newcat (zooname, EXT_DFLT);
  193. X#endif
  194. X
  195. X#ifndef PORTABLE
  196. X#ifndef OOZ
  197. X/* only need to ensure integrity of created archive */
  198. X   break_off();   /* break = off -- specific to MSDOS */
  199. X#endif
  200. X#endif
  201. X
  202. X/* 
  203. XHere we allocate a large block of memory for the duration of the program.
  204. Xlzc() and lzd() will use half of it each.  Routine getfile() will use all
  205. Xof it. 
  206. X*/
  207. X/* fudge factor to avoid off-by-one errors */
  208. X#define  FUDGE    10
  209. X
  210. X/*                          fudge/2           fudge/2
  211. X**             [______________||________________|]
  212. X**               output buffer    input buffer
  213. X*/
  214. X
  215. X   out_buf_adr = emalloc (OUT_BUF_SIZE + IN_BUF_SIZE + FUDGE);
  216. X
  217. X   /* input buffer is in top of allocated block */
  218. X   in_buf_adr = out_buf_adr + OUT_BUF_SIZE + (FUDGE/2);
  219. X
  220. X#ifdef OOZ
  221. Xzooext(zooname, "\0");     /* just extract -- no fancy stuff   */
  222. Xexit (0);                  /* and exit normally                */
  223. X#else
  224. X/* else not OOZ -- parse command line and invoke a routine */
  225. X   if (cmd != NONE) {
  226. X      switch (cmd) {
  227. X
  228. X         case ADD:      zooadd (zooname, filecount, &argv[3], "aP:"); break;
  229. X         case FRESHEN:  zooadd (zooname, filecount, &argv[3], "auP:"); break;
  230. X         case UPDATE:   zooadd (zooname, filecount, &argv[3], "aunP:"); break;
  231. X         case MOVE:     zooadd (zooname, filecount, &argv[3], "aMP:"); break;
  232. X
  233. X         case EXTRACT:  zooext (zooname, "x"); break;
  234. X         case TEST:     zooext (zooname, "xNd"); break;
  235. X         case PRINT:    zooext (zooname, "xp"); break;
  236. X
  237. X         case DELETE:   zoodel (zooname, "DP",1); break;
  238. X         case LIST:     zoolist (&argv[2], "v", argc-2); break;
  239. X         case COMMENT:  comment (zooname, "c"); break;
  240. X         default: goto show_usage;
  241. X      }
  242. X   } else
  243. X      switch (*option) {
  244. X         case 'a': 
  245. X         case 'u':
  246. X         case 'T':   
  247. X            zooadd (zooname, filecount, &argv[3], option); break;
  248. X         case 'D':
  249. X            zoodel (zooname, option, 1); break;
  250. X         case 'U':
  251. X            zoodel (zooname, option, 0); break;
  252. X         case 'v':
  253. X         case 'l': 
  254. X            zoolist(&argv[2], option, 1); break;
  255. X         case 'L': 
  256. X            zoolist(&argv[2], option, argc-2); break;
  257. X         case 'e':
  258. X         case 'x': 
  259. X            zooext(zooname, option); break;
  260. X         case 'P':
  261. X            zoopack (zooname, option); break;
  262. X         case 'c':
  263. X            comment (zooname, option); break;
  264. X         default:
  265. X            goto give_list;
  266. X      }
  267. Xexit (0);      /* don't fall through */
  268. X
  269. X/* usage list including Novice commands */
  270. Xshow_usage:
  271. X   fprintf (stderr, "%s%s%s", usage, nov_usage, nov_cmds); exit (1);
  272. X
  273. X/* brief usage list */
  274. Xgive_list:
  275. X    fprintf (stderr, usage); exit (1);
  276. X
  277. X/* help screen */
  278. Xbigusage:
  279. X
  280. Xprintf ("Zoo archiver, %s\n", version);
  281. Xprintf("(C) Copyright 1986, 1987 Rahul Dhesi -- Noncommercial use permitted\n");
  282. X
  283. Xprintf (usage);
  284. Xprintf ("\nChoose a command from within {} and zero or more modifiers from within []\n");
  285. X
  286. Xprintf ("E.g.:  `zoo a save /bin/*' will archive all files in /bin into save.zoo\n\n");
  287. X
  288. Xprintf (" Commands in {} mean:         |Modifiers in [] mean:\n");
  289. X
  290. Xprintf ("  a     add files             | a     show archive name(s) in listing\n");
  291. Xprintf ("  c     update comments       | c     add/list comments\n");
  292. Xprintf ("  D     delete stored files   | d     extract/list deleted files too\n");
  293. Xprintf ("  e,x   extract files         | dd    extract/list only deleted files\n");
  294. Xprintf ("  l,v,L list filenames        | E     erase backup after packing\n");
  295. Xprintf ("  P     pack archive          | f     fast add (no compression) or list\n");
  296. Xprintf ("  T     fix archive datestamp | M     move when adding (erase original)\n");
  297. Xprintf ("  u     add only newer files  | n     add only files not already in archive\n");
  298. Xprintf ("  U     undelete stored files | N     send extracted data to Neverland\n");
  299. Xprintf (" -----------------------------  O,oo  don't ask \"Overwrite?\"\n");
  300. Xprintf ("  q     be quiet                p     pipe extracted data to standard output\n");
  301. Xprintf ("  :     don't store dir names   /,//  extract full pathnames\n");
  302. Xprintf ("  .     pack to current dir     I     add filenames read from stdin\n");
  303. X
  304. X#ifdef PORTABLE
  305. Xprintf ("  P     pack after adding       @n    start extract/list at position n\n");
  306. X/* nothing */
  307. X#else
  308. Xprintf ("  z     add/extract Z format    @n    start extract/list at position n\n");
  309. X#endif /* ndef PORTABLE */
  310. X
  311. X
  312. Xprintf (nov_usage);
  313. Xprintf (nov_cmds);
  314. X#endif /* end of not OOZ */
  315. X
  316. X/* NOTE:  if allowed to fall through and return without an exit() statement,
  317. X   it was printing garbage--corrupted stack?  Why--bug in Microsoft C? */
  318. Xexit (1);
  319. X}
  320. SHAR_EOF
  321. fi
  322. if test -f 'zoo.h'
  323. then
  324.     echo shar: "will not over-write existing file 'zoo.h'"
  325. else
  326. sed 's/^X//' << \SHAR_EOF > 'zoo.h'
  327. X/* @(#) zoo.h 1.3 87/05/30 14:13:42 */
  328. X
  329. X/*
  330. XThe contents of this file are hereby released to the public domain.
  331. X
  332. X                           -- Rahul Dhesi 1986/11/14
  333. X*/
  334. X
  335. X
  336. X/* Global data structures and also some information about archive structure.
  337. X
  338. XAmong other things, the archive header contains:  
  339. X
  340. X(a) A text message.  In the MS-DOS version this message is terminated by
  341. Xcontrol Z.  This allows naive users to type the archive to the screen
  342. Xand see a brief but meaningful message instead of garbage.  The contents of
  343. Xthe text message are however not used by Zoo and they may be anything.  
  344. XIn particular, the text message may identify the type or archive or the
  345. Xparticular computer system it was created on.  Note:  Due to some untidyness
  346. Xin Zoo's code, when an archive is packed by any version of Zoo, the text
  347. Xmessage is changed to the text messages used by that version.  For example,
  348. Xif Zoo 1.10 packs an archive created by Zoo 1.31, the text message changes
  349. Xto "Zoo 1.10 archive.".  In the long run, this should be changed to
  350. Xpreserve the text message, thus identifying the version that created the 
  351. Xarchive, not the version that packed it.
  352. X
  353. X(b) A four-byte tag that identifies all Zoo archives.  This helps prevent
  354. Xarbitrary binary files from being treated as Zoo archives.  The tag value is
  355. Xarbitrary, but seemed to be unlikely to occur in an executable file.  The
  356. Xsame tag value is used to identify each directory entry.  
  357. X
  358. X(c) A long pointer to where in the file the archive starts.  This could be
  359. Xleft out if the archive always started immediately after the header, but I
  360. Xwant to allow room for future additions to the header information without
  361. Xconfusing earlier versions of Zoo.  This pointer is stored along with its
  362. Xnegation for consistency checking.  It is hoped that if the archive is
  363. Xdamaged, both the pointer and its negation won't be damaged and at least
  364. Xone would still be usable to tell us where the data begins.
  365. X
  366. X(d) A two-byte value giving the major and minor version number of the
  367. Xminimum version of Zoo that is needed to fully manipulate the archive.  
  368. XAs the archive structure is modified, this version number may increase.
  369. XCurrently version 1.31 of Zoo creates archives that may be fully manipulated
  370. Xby version 1.10 onwards.
  371. X
  372. XVersion numbering:  
  373. XThe directory entry of each file will contain the minimum version number of
  374. XZoo needed to extract that file.  As far as possible, version 1.00 of Zoo
  375. Xwill be able to extract files from future version archives.
  376. X*/
  377. X
  378. X/* This is version 1.1.  Define major and minor version numbers */
  379. X
  380. X#define MAJOR_VER 1        /* needed to manipulate archive */
  381. X#define MINOR_VER 4
  382. X
  383. X#define MAJOR_EXT_VER 1    /* needed to extract file */
  384. X#define MINOR_EXT_VER 0
  385. X
  386. X#define CTRL_Z 26
  387. X#define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
  388. X#define TEXT "ZOO 1.50 Archive.\032"   /* Header text for archive. */
  389. X#define SIZ_TEXT  20                   /* Size of header text */
  390. X
  391. X#define PATHSIZE 256                   /* Max length of pathname */
  392. X#define FNAMESIZE 13                   /* Size of DOS filename */
  393. X#define LFNAMESIZE 256                 /* Size of long filename */
  394. X#define ROOTSIZE 8                     /* Size of fname without extension */
  395. X#define EXTLEN 3                       /* Size of extension */
  396. X#define FILE_LEADER  "@)#("            /* Allowing location of file data */
  397. X#define SIZ_FLDR  5                    /* 4 chars plus null */
  398. X#define MAX_PACK 1                     /* max packing method we can handle */
  399. X#define BACKUP_EXT ".bak"              /* extension of backup file */
  400. X
  401. X#ifdef OOZ
  402. X#define FIRST_ARG 2
  403. X#endif
  404. X
  405. X#ifdef ZOO
  406. X#define FIRST_ARG 3        /* argument position of filename list */
  407. X#endif
  408. X
  409. X/* WARNING:  Static initialization in zooadd.c or zooext.c depends on the 
  410. X   order of fields in struct zoo_header */
  411. Xstruct zoo_header {
  412. X   char text[SIZ_TEXT];       /* archive header text */
  413. X   unsigned long zoo_tag;     /* identifies archives           */
  414. X   long zoo_start;            /* where the archive's data starts        */
  415. X   long zoo_minus;      /* for consistency checking of zoo_start  */
  416. X   char major_ver;
  417. X   char minor_ver;            /* minimum version to extract all files   */
  418. X};
  419. X
  420. X/* Note:  Microsoft C aligns data at word boundaries.  So, to keep things
  421. X   compact, always try to pair up character fields. */
  422. Xstruct direntry {
  423. X   unsigned long zoo_tag;     /* tag -- redundancy check */
  424. X   char type;                 /* type of directory entry.  always 1 for now */
  425. X   char packing_method;       /* 0 = no packing, 1 = normal LZW */
  426. X   long next;                 /* pos'n of next directory entry */
  427. X   long offset;               /* position of this file */
  428. X   unsigned int date;         /* DOS format date */
  429. X   unsigned int time;         /* DOS format time */
  430. X   unsigned int file_crc;     /* CRC of this file */
  431. X   long org_size;
  432. X   long size_now;
  433. X   char major_ver;
  434. X   char minor_ver;            /* minimum version needed to extract */
  435. X   char deleted;              /* will be 1 if deleted, 0 if not */
  436. X   char struc;                /* file structure if any */
  437. X   long comment;              /* points to comment;  zero if none */
  438. X   unsigned int cmt_size; /* length of comment, 0 if none */
  439. X   char fname[FNAMESIZE]; /* filename */
  440. X
  441. X   int var_dir_len;           /* length of variable part of dir entry */
  442. X   char tz;                   /* timezone where file was archived */
  443. X   unsigned int dir_crc;      /* CRC of directory entry */
  444. X
  445. X   /* fields for variable part of directory entry follow */
  446. X   char namlen;               /* length of long filename */
  447. X   char dirlen;               /* length of directory name */
  448. X   char lfname[LFNAMESIZE];   /* long filename */
  449. X   char dirname[PATHSIZE];    /* directory name */
  450. X   int system_id;             /* Filesystem ID */
  451. X};
  452. X
  453. X/* Values for direntry.system_id */
  454. X#define SYSID_NIX       0     /* UNIX and similar filesystems */
  455. X#define SYSID_MS        1     /* MS-DOS filesystem */
  456. X#define SYSID_PORTABLE  2     /* Portable syntax */
  457. X
  458. X/* Structure of header of small archive containing just one file */
  459. X
  460. X#define  TINYTAG     0x07FE   /* magic number */
  461. X
  462. Xstruct tiny_header {          /* one-file small archive */
  463. X   int tinytag;               /* magic number */
  464. X   char type;                 /* always 1 for now */
  465. X   char packing_method;
  466. X   unsigned int date;
  467. X   unsigned int time;
  468. X   unsigned int file_crc;
  469. X   long org_size;
  470. X   long size_now;
  471. X   char major_ver;
  472. X   char minor_ver;
  473. X   unsigned int cmt_size; /* length of comment, 0 if none */
  474. X   char fname[FNAMESIZE];     /* filename */
  475. X};
  476. X
  477. X/* offsets of items within the canonical zoo archive header */
  478. X#define  SIZ_ZOOH 34          /* 34 byte-long archive header */
  479. X#define  TEXT_I   0           /* text in header */
  480. X#define  ZTAG_I   20          /* zoo tag */
  481. X#define  ZST_I    24          /* start offset */
  482. X#define  ZSTM_I   28          /* negative of start offset */
  483. X#define  MAJV_I   32          /* major version */
  484. X#define  MINV_I   33          /* minor version */
  485. X
  486. X/* offsets of items within the canonical directory entry structure */
  487. X#define  SIZ_DIR  51          /* length of type 1 directory entry */
  488. X#define  SIZ_DIRL 56          /* length of type 2 directory entry */
  489. X#define  DTAG_I   0           /* tag within directory entry */
  490. X#define  DTYP_I   4           /* type of directory entry */
  491. X#define  PKM_I    5           /* packing method */
  492. X#define  NXT_I    6           /* pos'n of next directory entry */
  493. X#define  OFS_I    10          /* position (offset) of this file */
  494. X#define  DAT_I    14          /* DOS format date */
  495. X#define  TIM_I    16          /* DOS format time */
  496. X#define  CRC_I    18          /* CRC of this file */
  497. X#define  ORGS_I   20          /* original size */
  498. X#define  SIZNOW_I 24          /* size now */
  499. X#define  DMAJ_I   28          /* major version number */
  500. X#define  DMIN_I   29          /* minor version number */
  501. X#define  DEL_I    30          /* deleted or not */
  502. X#define  STRUC_I  31          /* file structure */
  503. X#define  CMT_I    32          /* comment [offset] */
  504. X#define  CMTSIZ_I 36          /* comment size */
  505. X#define  FNAME_I  38          /* filename */
  506. X#define  VARDIRLEN_I  51      /* length of var. direntry */
  507. X#define  TZ_I     53          /* timezone */
  508. X#define  DCRC_I   54          /* CRC of directory entry */
  509. X
  510. X#define  FNM_SIZ  13          /* size of stored filename */
  511. X
  512. X/* Offsets within variable part of directory entry */
  513. X#define  NAMLEN_I   (SIZ_DIRL + 0)
  514. X#define  DIRLEN_I   (SIZ_DIRL + 1)
  515. X#define  LFNAME_I   (SIZ_DIRL + 2)
  516. X#define  DIRNAME_I  LFNAME_I  /* plus length of filename */
  517. X
  518. X/* total size of fixed plus variable directory recognized currently:
  519. X1 byte each for dirlen and namlen, and 256 each for long filename
  520. Xand directory name, + fudge factor of 10. */
  521. X#define  MAXDIRSIZE  (SIZ_DIRL+1+1+256+256+10)
  522. X
  523. X/* Value used to stuff into timezone field if it is not known */
  524. X#define  NO_TZ    127
  525. X
  526. SHAR_EOF
  527. fi
  528. if test -f 'zoo.man'
  529. then
  530.     echo shar: "will not over-write existing file 'zoo.man'"
  531. else
  532. sed 's/^X//' << \SHAR_EOF > 'zoo.man'
  533. X
  534. X
  535. X
  536. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  537. X
  538. X
  539. X
  540. XNAME
  541. X     zoo - manipulate archives of files in compressed form
  542. X
  543. XSYNOPSIS
  544. X     zoo {acDehlLPTuUvx}[cdEfInMNoOpPquv1:./@] archive [file] ...
  545. X     zoo -command archive [file] ...
  546. X     zoo h
  547. X
  548. XDESCRIPTION
  549. X     Zoo is used to create and maintain collections of files in
  550. X     compressed form.  It uses a Lempel-Ziv compression algorithm
  551. X     that gives space savings in the range of 20% to 80% depend-
  552. X     ing on the type of file data.
  553. X
  554. X     The command zoo h gives summary of commands.
  555. X
  556. X     Zoo will not add an archive to itself, nor add the archive's
  557. X     backup (with .bak extension to the filename) to the archive.
  558. X
  559. X     Zoo has two types of commands:  Expert commands, which con-
  560. X     sist of one command letter followed by zero or more modifier
  561. X     characters, and Novice commands, which consist of a hyphen
  562. X     (`-') followed by a command word that may be abbreviated.
  563. X     Expert commands are case-sensitive but Novice commands are
  564. X     not.
  565. X
  566. X     When zoo adds a file to an existing archive, it marks as
  567. X     deleted any already-archived file with the same name.
  568. X     (Directory prefixes are significant in this comparison if
  569. X     and only if directory names are being stored.) Deleted files
  570. X     may be later undeleted.  Archives may be packed to recover
  571. X     space occupied by deleted files.
  572. X
  573. X     All commands assume that the archive name ends with the
  574. X     characters .zoo unless a different extension is supplied.
  575. X
  576. X     Novice commands
  577. X
  578. X     Novice commands may be abbreviated to a hyphen followed by
  579. X     at least one command character.  Each Novice command works
  580. X     in two stages. First, the command does its intended work.
  581. X     Then, if the result was that one or more files were deleted
  582. X     in the specified archive, the archive is packed.  If packing
  583. X     occurs, the original unpacked archive is always left behind
  584. X     with an extension of .bak.
  585. X
  586. X     No Novice command ever stores the directory prefix of a
  587. X     file.  When a Novice command is used to add a file to an
  588. X     archive, any already-archived file with the same name,
  589. X     regardless of the directory prefix, is marked deleted.
  590. X
  591. X
  592. X
  593. X
  594. X
  595. XPrinted 7/12/87           Jul 12, 1987                          1
  596. X
  597. X
  598. X
  599. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  600. X
  601. X
  602. X
  603. X     The Novice commands are as follows.
  604. X
  605. X     -add    Adds the specified files to the archive.
  606. X
  607. X     -freshen
  608. X          Adds a specified file to the archive if and only if an
  609. X          older file by the same name already exists in the
  610. X          archive.
  611. X
  612. X     -delete
  613. X          Deletes the specified files from the archive.
  614. X
  615. X     -update
  616. X          Adds a specified file to the archive either:  if an
  617. X          older file by the same name already exists in the
  618. X          archive or:  if a file by the same name does not
  619. X          already exist in the archive.
  620. X
  621. X     -extract
  622. X          Extracts the specified files from the archive.  If no
  623. X          file is specified all files are extracted.
  624. X
  625. X     -move
  626. X          Equivalent to -add except that source files are deleted
  627. X          after addition.
  628. X
  629. X     -print
  630. X          Equivalent to -extract except that extracted data are
  631. X          sent to standard output.
  632. X
  633. X     -list
  634. X          Gives information about the specified archived files
  635. X          including any attached comments.  If no files are
  636. X          specified all files are listed.  Deleted files are not
  637. X          listed.
  638. X
  639. X     -test
  640. X          Equivalent to -extract except that the extracted data
  641. X          are not saved but any errors encountered are reported.
  642. X
  643. X     -comment
  644. X          Allows the user to add or update comments attached to
  645. X          archived files.  When prompted, the user may:  type a
  646. X          carriage return to skip the file, leaving any current
  647. X          comment unchanged;  or type a (possibly null) comment
  648. X          of up to 65,535 characters terminated by /end (case-
  649. X          insensitive) on a separate line;  or type the end-of-
  650. X          file character (normally control D) to skip all remain-
  651. X          ing files.
  652. X
  653. X     -delete
  654. X          Deletes the specified files.
  655. X
  656. X
  657. X
  658. XPrinted 7/12/87           Jul 12, 1987                          2
  659. X
  660. X
  661. X
  662. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  663. X
  664. X
  665. X
  666. X     The correspondence between Novice and Expert commands is as follows.
  667. X
  668. X   Novice                                                   Equivalent
  669. X   Command    Description                                   Expert Command
  670. X   _______________________________________________________________________
  671. X   -add       add files to archive                          aP:
  672. X   -extract   extract files from archive                    x
  673. X   -move      move files to archive                         aMP:
  674. X   -test      test archive integrity                        xNd
  675. X   -print     extract files and send to standard output     xp
  676. X   -delete    delete files from archive                     DP
  677. X   -list      list information about archived files         v
  678. X   -update    update archive by adding new or newer files   aunP:
  679. X   -freshen   freshen archive by adding newer files         auP:
  680. X   -comment   allows user to attach comments to files       c
  681. X
  682. X     Expert commands
  683. X
  684. X     The general format of expert commands is:
  685. X
  686. X     zoo {acDehlPTuUvx}[cdEfInMNoOpPquv1:./@] archive [file] ...
  687. X
  688. X     The characters enclosed within {} are commands.  Choose any
  689. X     one of these.  The characters enclosed within [] just to the
  690. X     right of the {} are modifiers and zero or more of these may
  691. X     immediately follow the command character.  All combinations
  692. X     of command and modifier characters may not be valid.
  693. X
  694. X     Files are added to an archive with the command:
  695. X
  696. X     zoo {au}[cfIMnPqu:] archive [file] ...
  697. X
  698. X     Command characters are:
  699. X
  700. X     a    Add each specified file to archive.  Any already-
  701. X          archived file with the same name is marked as deleted.
  702. X
  703. X     u    Do an update of the archive.  A specified file is added
  704. X          to the archive only if a copy of it is already in the
  705. X          archive and the copy being added is newer than the copy
  706. X          already in the archive.
  707. X
  708. X     The following modifiers are specific to these commands.
  709. X
  710. X     M    Move files to archive.  This makes zoo delete (unlink)
  711. X          the original files after they have been added to the
  712. X          archive.  Files are deleted after addition of all files
  713. X          to the archive is complete and after any requested
  714. X          packing of the archive has been done, and only if zoo
  715. X          detected no errors.
  716. X
  717. X
  718. X
  719. X
  720. X
  721. XPrinted 7/12/87           Jul 12, 1987                          3
  722. X
  723. X
  724. X
  725. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  726. X
  727. X
  728. X
  729. X     n    Add new files only.  A specified file is added only if
  730. X          it isn't already in the archive.
  731. X
  732. X     P    Pack archive after files have been added.
  733. X
  734. X     u    Applied to the a command, this modifier makes it behave
  735. X          identically to the u command.
  736. X
  737. X          The combination of the n modifier with the u modifier
  738. X          or u command causes addition of a file to the archive
  739. X          either if the file is not already in the archive, or if
  740. X          the file is already in the archive but the archived
  741. X          copy is older than the copy being added.
  742. X
  743. X     :    Do not store directory names.  In the absence of this
  744. X          modifier zoo stores the full pathname of each archived
  745. X          file.
  746. X
  747. X     I    Read filenames to be archived from standard input. Zoo
  748. X          will read its standard input and assume that each line
  749. X          of text contains a filename.  Under the **IX family,
  750. X          the entire line is used.  Under MS-DOS and AmigaDOS,
  751. X          zoo assumes that the filename is terminated by a blank,
  752. X          tab, or newline; thus it is permissible for the line of
  753. X          text to contain more than one field separated by white
  754. X          space, and only the first field will be used.
  755. X
  756. X          Under the **IX family of operating systems, zoo can be
  757. X          used as follows in a pipeline:
  758. X
  759. X               find . -print | zoo aI sources
  760. X
  761. X
  762. X
  763. X          If the I modifier is specified, no filenames may be
  764. X          supplied on the command line itself.
  765. X
  766. X     Files are extracted from an archive with the command:
  767. X
  768. X     zoo {ex}[dNoOpq./@] archive [file] ...
  769. X
  770. X     The e and x commands are synonymous.  If no file was speci-
  771. X     fied, all files are extracted from the archive.
  772. X
  773. X     The following modifiers are specific to the e and x com-
  774. X     mands:
  775. X
  776. X     N    Do not save extracted data but report any errors
  777. X          encountered.
  778. X
  779. X     O    Overwrite files.  Normally, if a file being extracted
  780. X          would overwrite an already-existing file of the same
  781. X
  782. X
  783. X
  784. XPrinted 7/12/87           Jul 12, 1987                          4
  785. X
  786. X
  787. X
  788. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  789. X
  790. X
  791. X
  792. X          name, zoo asks you if you really want to overwrite it.
  793. X          You may answer the question with `y', which means yes,
  794. X          overwrite; or `n', which means no, don't overwrite; or
  795. X          `a', which means assume the answer is `y' for this and
  796. X          all subsequent files.  The O modifier makes zoo assume
  797. X          that files may always be overwritten.
  798. X
  799. X          The O, N, and p modifiers are mutually exclusive.
  800. X
  801. X     o    This is equivalent to the O modifier if and only if it
  802. X          is given at least twice.  It is otherwise ignored.
  803. X
  804. X     p    Pipe extracted data to standard output.  Error messages
  805. X          are piped to standard output as well.  However, if a
  806. X          bad CRC is detected, an error message is sent both to
  807. X          standard error and to standard output.
  808. X
  809. X     /    Extract to original pathname.  Any needed directories
  810. X          must already exist.  In the absence of this modifier
  811. X          all files are extracted into the current directory.  If
  812. X          this modifier is doubled as //, needed directories need
  813. X          not exist and are created if necessary.
  814. X
  815. X     Archived files are listed with the command:
  816. X
  817. X     zoo {lLv}[adfv@] archive[.zoo] [file] ...
  818. X
  819. X     l    Information presented includes the date and time of
  820. X          each file, its original and current (compressed) sizes,
  821. X          and the percentage size decrease due to compression
  822. X          (labelled CF or compression factor).  If no filename is
  823. X          supplied all files are listed except deleted files.
  824. X
  825. X     L    This is identical to the l command except that all sup-
  826. X          plied arguments must be archives and the contents of
  827. X          each are listed.
  828. X
  829. X     v    This causes a verbose listing, which additionally shows
  830. X          any comment attached to each file.  Using the v modif-
  831. X          ier with the l command has the same effect.
  832. X
  833. X     The following modifier is specific to the archive list com-
  834. X     mands:
  835. X
  836. X     a    This gives a single-line format containing both each
  837. X          filename and the name of the archive, sorted by archive
  838. X          name.  It is especially useful with the L command,
  839. X          since the result can be further sorted on any field to
  840. X          give a master listing of the entire contents of a set
  841. X          of archives.
  842. X
  843. X
  844. X
  845. X
  846. X
  847. XPrinted 7/12/87           Jul 12, 1987                          5
  848. X
  849. X
  850. X
  851. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  852. X
  853. X
  854. X
  855. X     Files may be deleted and undeleted from an archive with the
  856. X     following commands:
  857. X
  858. X     zoo {DU}[Pq1] archive file ...
  859. X
  860. X     The D command deletes the specified files and the U command
  861. X     undeletes the specified files.  The 1 modifier (the digit
  862. X     one, not the letter ell) forces deletion or undeletion of at
  863. X     most one file.  If multiple instances of the same file exist
  864. X     in an archive, use of the 1 modifier may allow selective
  865. X     extraction of one of these.
  866. X
  867. X     Comments may be added to an archive with the command:
  868. X
  869. X     zoo c archive
  870. X
  871. X     This behaves identically to the -comment command.
  872. X
  873. X     The timestamp of an archive may be adjusted with the com-
  874. X     mand:
  875. X
  876. X     zoo T[q] archive
  877. X
  878. X     Zoo normally attempts to maintain the timestamp of an
  879. X     archive to reflect the age of the newest file stored in it.
  880. X     Should the timestamp ever be incorrect it can be fixed with
  881. X     the T command.
  882. X
  883. X     An archive may be packed with the command:
  884. X
  885. X     zoo P[EPq] archive
  886. X
  887. X     If the backup copy of the archive already exists, zoo will
  888. X     refuse to pack the archive unless the P modifier is also
  889. X     given.  The E modifier causes zoo not to save a backup copy
  890. X     of the original archive after packing.  A unique temporary
  891. X     file in the current directory is used to initially hold the
  892. X     packed archive.  This file will be left behind if packing is
  893. X     interrupted or if for some reason this file cannot be
  894. X     renamed to the name of the original archive when packing is
  895. X     complete.
  896. X
  897. X     Packing removes any garbage data appended to an archive
  898. X     because of Xmodem file transfer and also recovers space used
  899. X     by comments that were replaced.
  900. X
  901. X     General modifiers
  902. X
  903. X     The following modifiers are applicable to several commands:
  904. X
  905. X     c    Applied to the a and u commands, this causes the user
  906. X          to be prompted for a comment for each file added to the
  907. X
  908. X
  909. X
  910. XPrinted 7/12/87           Jul 12, 1987                          6
  911. X
  912. X
  913. X
  914. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  915. X
  916. X
  917. X
  918. X          archive.  If the file being added has replaced a file
  919. X          already in the archive, any comment attached to the
  920. X          replaced file is shown to the user and becomes attached
  921. X          to the newly-added file unless the user changes it.
  922. X          Possible user responses are as described for the -com-
  923. X          ment command.  Applied to the archive list command l,
  924. X          the c modifier causes the listing of any comments
  925. X          attached to archived files.
  926. X
  927. X     .    In conjunction with / or // this modifier causes any
  928. X          extracted pathname beginning with `/' to be interpreted
  929. X          relative to the current directory, resulting in the
  930. X          possible creation of a subtree rooted at the current
  931. X          directory.  In conjunction with the command P the .
  932. X          modifier causes the packed archive to be created in the
  933. X          current directory.  This is intended to allow users
  934. X          with limited disk space but multiple disk drives to
  935. X          pack large archives.
  936. X
  937. X     d    Most commands that act on an archive act only on files
  938. X          that are not deleted.  The d modifier makes commands
  939. X          act on both normal and deleted files.  If doubled as
  940. X          dd, this modifier forces selection only of deleted
  941. X          files.
  942. X
  943. X     f    Applied to the a and u commands, the f modifier causes
  944. X          fast archiving by adding files without compression.
  945. X          Applied to l it causes a fast listing of files in a
  946. X          multicolumn format.
  947. X
  948. X     q    Be quiet.  Normally zoo lists the name of each file and
  949. X          what action it is performing.  The q modifier
  950. X          suppresses this.  When files are being extracted to
  951. X          standard output, the q modifier suppresses the header
  952. X          preceding each file.
  953. X
  954. X          Error messages are never suppressed.
  955. X
  956. X     @    Extract or list beginning at position n, where n is a
  957. X          decimal number following the @ sign without any inter-
  958. X          vening spaces.  This may be used to recover data from a
  959. X          damaged archive by skipping the damaged part.  The
  960. X          number specified must be the position within the
  961. X          archive of an undamaged directory entry.  This position
  962. X          is usually obtained from fiz(1).
  963. X
  964. X     Wildcard handling
  965. X
  966. X     Under the **IX family of operating systems, the shell nor-
  967. X     mally expands wildcards to a list of matching files.  Wild-
  968. X     cards that are meant to match files within an archive must
  969. X     therefore be escaped or quoted.  When selecting files to be
  970. X
  971. X
  972. X
  973. XPrinted 7/12/87           Jul 12, 1987                          7
  974. X
  975. X
  976. X
  977. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  978. X
  979. X
  980. X
  981. X     added to an archive, wildcard conventions are as defined for
  982. X     the shell.  When selecting files from within an archive,
  983. X     wildcard handling is done by zoo as described below.
  984. X
  985. X     Under MS-DOS and AmigaDOS, quoting of wildcards is not
  986. X     needed.  All wildcard expansion of filenames is done by zoo,
  987. X     and wildcards inside directory names are expanded only when
  988. X     listing or extracting files but not when adding them.
  989. X
  990. X     The wildcard syntax interpreted by zoo is limited to the
  991. X     following characters.
  992. X
  993. X     *    Matches any sequence of zero or more characters.
  994. X
  995. X     ?    Matches any single character.
  996. X
  997. X          Arbitrary combinations of * and ? are allowed.
  998. X
  999. X     /    If a supplied pattern contains a slash anywhere in it,
  1000. X          then the slash separating any directory prefix from the
  1001. X          filename must be matched explicitly.  If a supplied
  1002. X          pattern contains no slashes, the match is selective
  1003. X          only on the filename.
  1004. X
  1005. X     c-c  Two characters separated by a hyphen specify a charac-
  1006. X          ter range.  All filenames beginning with those charac-
  1007. X          ters will match.  The character range is meaningful
  1008. X          only by itself or preceded by a directory name.  It is
  1009. X          not specially interpreted if it is part of a filename.
  1010. X
  1011. X     MS-DOS users should note that zoo does not treat the dot as
  1012. X     a special character, and it does not ignore characters fol-
  1013. X     lowing an asterisk.  Thus * matches all filenames; *.*
  1014. X     matches filenames containing a dot; *_* matches filenames
  1015. X     containing an underscore;  and *z matches all filenames that
  1016. X     end with the character z, whether or not they contain a dot.
  1017. X
  1018. XFILES
  1019. X     xXXXXXX - temporary file used during packing
  1020. X     archive_name.bak - backup of archive
  1021. X
  1022. XSEE ALSO
  1023. X     compress(1), fiz(1)
  1024. X
  1025. XBUGS
  1026. X     Standard input cannot be archived nor can a created archive
  1027. X     be sent to standard output.  Spurious error messages may
  1028. X     appear if the filename of an archive is too long.
  1029. X
  1030. X     Since zoo never archives any file with the same name as the
  1031. X     archive or its backup (regardless of any path prefixes),
  1032. X     care should be taken to make sure that a file to be archived
  1033. X
  1034. X
  1035. X
  1036. XPrinted 7/12/87           Jul 12, 1987                          8
  1037. X
  1038. X
  1039. X
  1040. XZOO(1)              **IX Programmer's Manual               ZOO(1)
  1041. X
  1042. X
  1043. X
  1044. X     does not coincidentally have the same name as the archive it
  1045. X     is being added to. It usually suffices to make sure that no
  1046. X     file being archived is itself a zoo archive.
  1047. X
  1048. X     Only regular files are archived; directories and devices are
  1049. X     not.
  1050. X
  1051. X     Early versions of MS-DOS have a bug that prevents "." from
  1052. X     referring to the root directory;  this leads to anomalous
  1053. X     results if the extraction of paths beginning with a dot is
  1054. X     attempted.
  1055. X
  1056. X     It is not currently possible to create a zoo archive con-
  1057. X     taining all zoo archives that do not contain themselves.
  1058. X
  1059. XDIAGNOSTICS
  1060. X     Error messages are intended to be self-explanatory and are
  1061. X     divided into three categories.  WARNINGS are intended to
  1062. X     inform the user of an unusual situation, such as a CRC error
  1063. X     during extraction, or -freshening of an archive containing a
  1064. X     file newer than one specified on the command line.  ERRORS
  1065. X     are fatal to one file, but execution continues with the next
  1066. X     file if any.  FATAL errors cause execution to be aborted.
  1067. X     The occurrence of any of these causes an exit status of 1.
  1068. X     Normal termination without any errors gives an exit status
  1069. X     of 0.
  1070. X
  1071. XFUTURE DIRECTIONS
  1072. X     A revised version of zoo is in the works which will allow
  1073. X     numbering of multiple versions of a file and automatically
  1074. X     perform end-of-line conversion for text files moved between
  1075. X     dissimilar systems.  It will be upward and downward compati-
  1076. X     ble with existing versions of zoo.
  1077. X
  1078. XTHANKS
  1079. X     Thanks are due to:
  1080. X
  1081. X     Paul Homchick, who provided numerous detailed reports about
  1082. X     some nasty bugs.
  1083. X
  1084. X     Bill Davidsen, who fixed zoo's handling of daylight savings
  1085. X     time and also provided changes to make this manual format
  1086. X     correctly with troff.
  1087. X
  1088. XAUTHOR
  1089. X     Rahul Dhesi
  1090. X
  1091. X
  1092. X
  1093. X
  1094. X
  1095. X
  1096. X
  1097. X
  1098. X
  1099. XPrinted 7/12/87           Jul 12, 1987                          9
  1100. X
  1101. SHAR_EOF
  1102. fi
  1103. exit 0
  1104. #    End of shell archive
  1105. -- 
  1106. Rahul Dhesi         UUCP:  {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi
  1107.  
  1108. -- 
  1109.  
  1110. Rich $alz
  1111. Cronus Project, BBN Labs            rsalz@bbn.com
  1112. Moderator, comp.sources.unix            sources@uunet.uu.net
  1113.