home *** CD-ROM | disk | FTP | other *** search
- From: dhesi@bsu-cs.bsu.edu (Rahul Dhesi)
- Newsgroups: alt.sources
- Subject: zoo 2.1 source part 11/15
- Message-ID: <12778@bsu-cs.bsu.edu>
- Date: 10 Jul 91 11:05:04 GMT
-
- Checksum: 317039834 (verify with "brik -cv")
- Submitted-by: dhesi@bsu-cs.bsu.edu
- Archive-name: zoo210/part11
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # This is part 11 of zoo210
- # ============= zoo.c ==============
- if test -f 'zoo.c' -a X"$1" != X"-c"; then
- echo 'x - skipping zoo.c (File already exists)'
- else
- echo 'x - extracting zoo.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'zoo.c' &&
- #ifndef LINT
- /* derived from: zoo.c 2.24 88/01/29 00:55:09 */
- static char sccsid[]="$Id: zoo.c,v 1.21 91/07/09 02:36:40 dhesi Exp $";
- #endif /* LINT */
- X
- #if 0
- #define TRACEI(item) printf("line %d: %s= %d\n", __LINE__, #item, item)
- #define TRACES(item) printf("line %d: %s= [%s]\n", __LINE__, #item, item)
- #endif
- X
- extern char version[];
- X
- /*
- Copyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
- (C) Copyright 1988 Rahul Dhesi -- All rights reserved
- (C) Copyright 1991 Rahul Dhesi -- All rights reserved
- */
- #include "options.h"
- #include "zooio.h"
- #include "various.h"
- X
- #include "zoo.h"
- #include "zoofns.h"
- X
- #include "errors.i"
- #include "zoomem.h"
- X
- static void ms_help();
- static void wait_return();
- X
- #ifdef TRACE_IO
- int verbose = 0;
- #endif
- X
- int instr PARMS ((char *, char *));
- X
- char *out_buf_adr; /* points to memory allocated for output buffer(s) */
- char *in_buf_adr; /* points to memory allocated for input buffer */
- X
- /* static declarations */
- int quiet = 0; /* whether to be quiet */
- int next_arg = FIRST_ARG; /* filenames start at this position */
- int arg_count; /* count of arguments supplied to program */
- char **arg_vector; /* vector of arguments supplied to program */
- X
- main(argc,argv)
- register int argc;
- register char **argv;
- {
- X char *zooname; /* synonym for argv[2] -- to make life easier */
- #ifndef OOZ
- X static char incorrect_args[] = "Incorrect number of arguments.\n";
- X int filecount; /* how many filespecs supplied */
- #endif /* OOZ */
- X
- #ifdef OOZ
- #else
- /* else not OOZ */
- X static char usage[] = "Usage: zoo {acDeglLPTuUvx}[aAcCdEfInmMNoOpPqu1:/.@n] archive file\n(\"zoo h\" for help, \"zoo H\" for extended 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
- #ifdef NOENUM
- #define NONE -1
- #define ADD 0
- #define EXTRACT 5
- #define MOVE 14
- #define TEST 20
- #define PRINT 26
- #define DELETE 33
- #define LIST 41
- #define UPDATE 47
- #define FRESHEN 55
- #define COMMENT 64
- X
- int cmd = NONE;
- 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 */
- #endif
- X
- #endif /* end of not OOZ */
- X
- #ifdef SPECINIT
- X void spec_init PARMS ((void));
- X spec_init(); /* system-specific startup code */
- #endif
- X
- X /* make sure T_UINT16 is an unsigned 16-bit type, exactly. This
- X code is included only if T_UINT16 was defined by default at the
- X end of options.h. */
- #ifdef CHECK_TUINT
- X {
- X T_UINT16 i;
- X int status = 0;
- X i = ((unsigned) 1) << 15;
- X if (i < 0)
- X status = 1;
- X if (i != ((unsigned) 1) << 15)
- X status = 1;
- X i *= 2;
- X if (i != 0)
- X status = 1;
- X if (status != 0)
- X prterror('w', "Configuration problem: T_UINT16 is not 16 bits\n");
- X }
- #endif
- X
- X arg_count = argc;
- X arg_vector = argv;
- X zooname = argv[FIRST_ARG-1]; /* points to name or archive */
- X
- #ifdef OOZ
- X if (argc < 2) {
- X putstr (usage1);
- X putstr (usage2);
- X zooexit (1);
- X }
- #else
- /* else not OOZ */
- X if (argc < 2)
- X goto show_usage;
- X filecount = argc - 3;
- X option = str_dup(argv[1]);
- X
- #ifdef TRACE_IO
- X if (*option == ':') { /* for debugging output */
- X verbose++;
- X option++; /* hide the : from other functions */
- X }
- #endif
- X
- #ifdef WAIT_PROMPT
- X if (*option == 'w') {
- X option++; /* hide w from other functions */
- X wait_return();
- X }
- #endif /* WAIT_PROMPT */
- X
- X if (*option == 'H') ms_help(option);
- X if (*option == 'h' || *option == 'H')
- X goto bigusage;
- X if (strchr("-acDegflLPTuUvVx", *option) == NULL)
- X goto give_list;
- X
- X if (*option == '-') {
- X
- #ifdef NOENUM
- X cmd = instr (nov_cmds, str_lwr(option));
- #else
- X cmd = (enum choice) instr (nov_cmds, str_lwr(option));
- #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')) != 0) &&
- X argc != 3) ||
- X wheresI==NULL && argc < 4
- X )
- X ) ||
- X strchr("DU",*option) && argc < 4 ||
- X strchr("cexlvVL",*option) && argc < 3 ||
- X strchr("TP",*option) && argc != 3 ||
- X (*option == 'f' && argc != 2) ||
- X (*option == 'g' &&
- X (strchr(option,'A') == NULL && argc < 4 ||
- X strchr(option,'A') != NULL && argc != 3
- X )
- X )
- X ) {
- X fprintf (stderr, incorrect_args);
- X goto show_usage;
- X }
- X }
- #endif /* end of not OOZ */
- X
- #ifndef OOZ
- X /* if not doing a list and no extension in archive name, add default
- X extension */
- X if (*option != 'f' && cmd != LIST && strchr("lvVL", *option) == NULL &&
- X strchr(nameptr (zooname), EXT_CH) == NULL)
- X zooname = newcat (zooname, EXT_DFLT);
- #endif
- X
- /*
- Here we allocate a large block of memory for the duration of the program.
- lzc() and lzd() will use half of it each. Routine getfile() will use all
- of it. Routine decode() will use the first 8192 bytes of it. Routine
- encode() will use all of it. */
- X
- /* fudge/2 fudge/2
- ** [______________||________________|]
- ** output buffer input buffer
- */
- X out_buf_adr = ealloc (MEM_BLOCK_SIZE);
- X in_buf_adr = out_buf_adr + OUT_BUF_SIZE + (FUDGE/2);
- X
- #ifdef OOZ
- zooext(zooname, "\0"); /* just extract -- no fancy stuff */
- zooexit (0); /* and exit normally */
- #else
- /* 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], "VC", argc-2); break;
- X case COMMENT: comment (zooname, "c"); break;
- X default: goto show_usage;
- X }
- X } else
- X switch (*option) {
- X
- X case 'a':
- X case 'u':
- X case 'T':
- X zooadd (zooname, filecount, &argv[3], option); break;
- #ifdef FILTER
- X case 'f':
- X zoofilt (option); break;
- #endif /* FILTER */
- X case 'D':
- X zoodel (zooname, option, 1); break;
- X case 'U':
- X zoodel (zooname, option, 0); break;
- X case 'g':
- X zoodel (zooname, option, 2); break;
- X case 'v':
- 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 }
- zooexit (0); /* don't fall through */
- X
- /* usage list including Novice commands */
- show_usage:
- X fprintf (stderr, "%s\n\n%s%s%s", version, usage, nov_usage, nov_cmds);
- X zooexit (1);
- X
- /* brief usage list */
- give_list:
- X fprintf (stderr, usage); zooexit (1);
- X
- /* help screen */
- bigusage:
- printf("\n\n\n\n\n\n\n\n");
- printf ("Zoo archiver, %s\n", version);
- printf("(C) Copyright 1991 Rahul Dhesi -- Noncommercial use permitted\n");
- X
- printf (usage);
- printf ("\nChoose a command from within {} and zero or more modifiers from within [].\n");
- X
- printf ("E.g.: `zoo a save /bin/*' will archive all files in /bin into save.zoo.\n");
- printf ("(Please see the user manual for a complete description of commands.)\n\n");
- printf (nov_usage);
- printf (nov_cmds);
- printf ("\n\n\n\n");
- wait_return(); /* print msg & wait for RETURN */
- X
- printf ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- printf (usage);
- X
- printf (" Commands in {} mean: |Modifiers in [] mean:\n");
- X
- printf (" a add files | a show archive name(s) in listing\n");
- printf (" c update comments | A apply g or c to archive\n");
- printf (" D delete stored files | c add/list comments\n");
- printf (" e,x extract files | d extract/list deleted files too\n");
- printf (" g adj. gen. limit/count | dd extract/list only deleted files\n");
- printf (" l,L,v,V list filenames | E erase backup after packing\n");
- printf (" P pack archive | f fast add (no compression) or list\n");
- printf (" T fix archive datestamp | M move when adding (erase original)\n");
- printf (" u add only newer files | n add only files not already in archive\n");
- printf (" U undelete stored files | N send extracted data to Nowhere\n");
- #ifdef FILTER
- printf (" f act as filter | c/u compress/uncompress as filter\n");
- #endif /* FILTER */
- printf (" ----------------------------- O don't ask \"Overwrite?\"\n");
- printf (" q be quiet p pipe extracted data to standard output\n");
- printf (" : don't store dir names /,// extract full pathnames\n");
- printf (" . pack to current dir I add filenames read from stdin\n");
- printf (" C show file CRC value +/- enable/disable generations\n");
- printf (" S overwrite newer files g list generation limits\n");
- printf (" P pack after adding @n start extract/list at position n\n");
- X
- #ifdef FATTR
- printf (" m list file modes OO overwrite read-only files\n");
- #endif /* FATTR */
- printf (" C change archive cmnt h use high-compression method\n");
- #endif /* end of not OOZ */
- 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? */
- zooexit (1);
- return 1; /* keep lint & compilers happy */
- }
- X
- /* multi-screen help facility thanks to Bill Davidsen */
- X
- /* help screens */
- static char *scrn1[] = {
- X "",
- X "command line format:",
- X " zoo {command}[options] archive files(s)",
- X "",
- X "Commands:",
- X " a add files",
- X " u - update, replace only if file is newer than saved version",
- X " n - new, add if file is not in archive",
- X " f - fast, don't compress at all",
- X " h - high performance compressor, slower than default",
- X " M - move files to archive, delete after saving",
- X " c - add a comment to each file added",
- X " C - add a comment to the archive as a whole",
- X " : - strip directory names, save filenames only",
- X " q - quiet (qq suppresses warnings, qqq suppresses nonfatal errors too)",
- X " P - pack after adding, remove overwritten or deleted files",
- X " (leaves a .bak file, use PP to overwrite it)",
- X " I - read filenames from standard input",
- X " + - enable generations",
- X (char *)NULL
- };
- X
- static char *scrn2[] = {
- X "",
- X " e extract files",
- X " x extract files",
- X " : - extract to current directory (ignore pathnames)",
- X " . - make absolute pathnames relative to current directory",
- X " (name /etc/hosts becomes ./etc/hosts)",
- X " / - extract to subdirs, // create subdirs as needed - default",
- X " (the sequence :/ may be used to use but not create subdirs)",
- X " q - quiet",
- X " d - extract deleted files, too. dd extract *only* deleted files",
- X " N - extract to nowhere. Used to test the archive with xN or xNq",
- X " p - extract for pipe to standard output. Use q to avoid header",
- X "",
- #ifdef FATTR
- X " O - overwrite without asking, OO overwrites readonly files",
- #else
- X " O - overwrite without asking",
- #endif
- X " S - overwrite superceded (newer) files",
- X (char *)NULL
- };
- X
- static char *scrn3[] = {
- X "",
- X " l list archive info",
- X " L list info for multiple archives",
- X " v list verbose file info and archive comment",
- X " V list verbose file info, archive and file comments",
- X " v - verbose (same as v command, used with L for multiple files",
- X " V - verbose with file comments",
- X " C - show CRC",
- X " a - show archive name in file listing (useful with L)",
- #ifdef FATTR
- X " m - mode, show file modes in octal",
- #endif
- X " d - show deleted files",
- X " q - quiet, shows only file info, no comments or headers",
- X " f - fast, lists only filename, no pathname, multiple columns",
- X " 1 - one column output (for the f option)",
- X "",
- X " c comment changes, change or add comments to listed files",
- X " (changes all file comments if no files given)",
- X " A - only change archive comment",
- X (char *)NULL
- };
- X
- static char *scrn4[] = {
- X "",
- X " P pack archive, remove deleted or overwritten files",
- X " E - erase the .bak file when done",
- X "",
- X " D delete files by name",
- X " P - pack after deletion, use PP if .bak file exists",
- X " q - quiet",
- X "",
- X " T timestamp adjust, make archive age of newest file",
- X "",
- X " g generation commands",
- X " l - set generation limit on files",
- X " A - apply limit to archive rather than a file (with gl)",
- X "",
- X " f filter, copy stdin to stdout with [de]compression",
- X " c - compress",
- X " u - uncompress",
- X " h - use the high compression method",
- X (char *)NULL
- };
- X
- static char *scrn5[] = {
- X "",
- X "Examples:",
- X "",
- X "# just add a few files",
- X " zoo a arch file1 files",
- X "# add C source files in subdirectories",
- X " zoo a test part1/*.c part2/*.c",
- X "# add documentation files with high compression",
- X " zoo ah test *.doc",
- X "",
- X "# extract all files",
- X " zoo x test",
- X "# extract files into the current directory",
- X " zoo x: test",
- X "# extract a single file and sort before listing",
- X " zoo xp test users.lst | sort",
- X "",
- X "# list the contents and archive comments",
- X " zoo v arch",
- X "# list all files in all archives",
- X " zoo L xxx.zoo /doc/*.zoo ../*.zoo",
- X (char *)NULL
- };
- X
- static char **screens[] = {
- X scrn1, /* intro and add */
- X scrn2, /* extract */
- X scrn3, /* list commands */
- X scrn4, /* other commands */
- X scrn5, /* add and extract examples */
- X (char **)NULL
- };
- X
- /* multi-screen help routine */
- static void ms_help(options)
- char *options;
- {
- #ifndef SZ_SCREEN /* screen size can be overridden in options.h */
- # define SZ_SCREEN 24
- #endif
- X int scrnlen = SZ_SCREEN;
- X char ***curscreen, **curline;
- X int linecount;
- X
- X /* if "Hnn" output in nn line format */
- X if (++options) sscanf(options, "%d", &scrnlen);
- X if (scrnlen < 2)
- X scrnlen = SZ_SCREEN;
- X
- X /* loop thru screens */
- X for (curscreen = screens; *curscreen != NULL; ++curscreen) {
- X printf("\n\n\n\n");
- X linecount = scrnlen;
- X curline = *curscreen;
- X while (*curline != NULL) {
- X printf("%s\n", *(curline++));
- X --linecount;
- X }
- X
- X /* slew page */
- X while (--linecount != 0) putchar('\n');
- X wait_return(); /* print msg & wait for RETURN */
- X }
- X
- X exit(0);
- }
- X
- /* wait_return prints a message, then waits until user hits RETURN key,
- then returns. Special cases: (a) if not interactive (as tested with
- isatty() if available), it returns immediately; (b) while waiting for
- RETURN, if EOF occurs, it causes zooexit(0) */
- X
- static void wait_return()
- {
- #ifdef HAVE_ISATTY
- X if (!isatty(fileno(stdout)) || !isatty(fileno(stdin)))
- X return;
- #endif
- X (void) printf("Hit RETURN (or ENTER) key to continue...");
- X for ( ; ;) {
- X int key;
- X key = getchar();
- X if (key == EOF)
- X zooexit(0);
- X if (key == '\n' || key == '\r')
- X return;
- X }
- }
- SHAR_EOF
- chmod 0644 zoo.c ||
- echo 'restore of zoo.c failed'
- Wc_c="`wc -c < 'zoo.c'`"
- test 16090 -eq "$Wc_c" ||
- echo 'zoo.c: original size 16090, current size' "$Wc_c"
- fi
- # ============= zoo.h ==============
- if test -f 'zoo.h' -a X"$1" != X"-c"; then
- echo 'x - skipping zoo.h (File already exists)'
- else
- echo 'x - extracting zoo.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'zoo.h' &&
- /* derived from: zoo.h 2.16 88/01/27 23:21:36 */
- X
- /*
- The contents of this file are hereby released to the public domain.
- X
- X -- Rahul Dhesi 1986/11/14
- */
- X
- X
- /* Global data structures and also some information about archive structure.
- X
- Among other things, the archive header contains:
- X
- (a) A text message. In the MS-DOS version this message is terminated by
- control Z. This allows naive users to type the archive to the screen
- and see a brief but meaningful message instead of garbage. The contents of
- the text message are however not used by Zoo and they may be anything.
- In particular, the text message may identify the type or archive or the
- particular computer system it was created on. When an archive is packed
- by any version of Zoo, the text message is changed to the text message
- used by that version. For example, if Zoo 1.10 packs an archive created
- by Zoo 1.31, the text message changes to "Zoo 1.10 archive.". This
- was once considered a shortcoming, but it is now an essential feature,
- because packing will also update an old archiver header structure
- into a new one.
- X
- (b) A four-byte tag that identifies all Zoo archives. This helps prevent
- arbitrary binary files from being treated as Zoo archives. The tag value is
- arbitrary, but seemed to be unlikely to occur in an executable file. The
- same tag value is used to identify each directory entry.
- X
- (c) A long pointer to where in the file the archive starts. This pointer
- is stored along with its negation for consistency checking. It is hoped
- that if the archive is damaged, both the pointer and its negation won't
- be damaged and at least one would still be usable to tell us where the
- data begins.
- X
- (d) A two-byte value giving the major and minor version number of the
- minimum version of Zoo that is needed to fully manipulate the archive.
- As the archive structure is modified, this version number may increase.
- Currently version 1.71 of Zoo creates archives that may be fully manipulated
- by version 1.40 onwards.
- X
- (e) With zoo 2.00 addtional fields have been added in the archive
- header to store information about the archive comment and generation
- limit.
- X
- Version numbering:
- The directory entry of each file will contain the minimum version number of
- Zoo needed to extract that file. As far as possible, version 1.00 of Zoo
- will be able to extract files from future version archives.
- */
- X
- #define H_TYPE 1 /* archive header type */
- X
- /* Define major and minor version numbers */
- #define MAJOR_VER 2 /* needed to manipulate archive */
- #define MINOR_VER 0
- X
- /* version needed to extract packing method 1 */
- #define MAJOR_EXT_VER 1
- #define MINOR_EXT_VER 0
- X
- /* version needed to extract packing method 2 */
- #define MAJOR_LZH_VER 2
- #define MINOR_LZH_VER 1
- X
- #define CTRL_Z 26
- X
- /* should be 0xFDC4A7DCUL but many c compilers don't recognize UL at end */
- #define ZOO_TAG ((unsigned long) 0xFDC4A7DCL) /* A random choice */
- #define TEXT "ZOO 2.10 Archive.\032" /* Header text for archive. */
- #define SIZ_TEXT 20 /* Size of header text */
- X
- #define PATHSIZE 256 /* Max length of pathname */
- #define FNAMESIZE 13 /* Size of DOS filename */
- #define LFNAMESIZE 256 /* Size of long filename */
- #define ROOTSIZE 8 /* Size of fname without extension */
- #define EXTLEN 3 /* Size of extension */
- #define FILE_LEADER "@)#(" /* Allowing location of file data */
- #define SIZ_FLDR 5 /* 4 chars plus null */
- #define MAX_PACK 2 /* max packing method we can handle */
- #define BACKUP_EXT ".bak" /* extension of backup file */
- X
- #ifdef OOZ
- #define FIRST_ARG 2
- #endif
- X
- #ifdef ZOO
- #define FIRST_ARG 3 /* argument position of filename list */
- #endif
- X
- typedef unsigned char uchar;
- X
- /* WARNING: Static initialization in zooadd.c or zooext.c depends on the
- X order of fields in struct zoo_header */
- struct 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 uchar major_ver;
- X uchar minor_ver; /* minimum version to extract all files */
- X uchar type; /* type of archive header */
- X long acmt_pos; /* position of archive comment */
- X unsigned int acmt_len; /* length of archive comment */
- X unsigned int vdata; /* byte in archive; data about versions */
- };
- X
- struct direntry {
- X unsigned long zoo_tag; /* tag -- redundancy check */
- X uchar type; /* type of directory entry. always 1 for now */
- X uchar 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 uchar major_ver;
- X uchar minor_ver; /* minimum version needed to extract */
- X uchar deleted; /* will be 1 if deleted, 0 if not */
- X uchar 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 uchar 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 uchar namlen; /* length of long filename */
- X uchar dirlen; /* length of directory name */
- X char lfname[LFNAMESIZE]; /* long filename */
- X char dirname[PATHSIZE]; /* directory name */
- X unsigned int system_id; /* Filesystem ID */
- X unsigned long fattr; /* File attributes -- 24 bits */
- X unsigned int vflag; /* version flag bits -- one byte in archive */
- X unsigned int version_no; /* file version number if any */
- };
- X
- /* Values for direntry.system_id */
- #define SYSID_NIX 0 /* UNIX and similar filesystems */
- #define SYSID_MS 1 /* MS-DOS filesystem */
- #define SYSID_PORTABLE 2 /* Portable syntax */
- X
- /* Structure of header of small archive containing just one file */
- X
- #define TINYTAG 0x07FE /* magic number */
- X
- #ifndef PORTABLE
- struct 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 */
- };
- #endif /* ifndef PORTABLE */
- X
- #define FIXED_OFFSET 34 /* zoo_start in old archives */
- #define MINZOOHSIZ 34 /* minimum size of archive header */
- #define SIZ_ZOOH 42 /* length of current archive header */
- X
- /* offsets of items within the canonical zoo archive header */
- #define TEXT_I 0 /* text in header */
- #define ZTAG_I 20 /* zoo tag */
- #define ZST_I 24 /* start offset */
- #define ZSTM_I 28 /* negative of start offset */
- #define MAJV_I 32 /* major version */
- #define MINV_I 33 /* minor version */
- #define HTYPE_I 34 /* archive header type */
- #define ACMTPOS_I 35 /* position of archive comment */
- #define ACMTLEN_I 39 /* length of archive comment */
- #define HVDATA_I 41 /* version data */
- X
- /* offsets of items within the canonical directory entry structure */
- #define SIZ_DIR 51 /* length of type 1 directory entry */
- #define SIZ_DIRL 56 /* length of type 2 directory entry */
- #define DTAG_I 0 /* tag within directory entry */
- #define DTYP_I 4 /* type of directory entry */
- #define PKM_I 5 /* packing method */
- #define NXT_I 6 /* pos'n of next directory entry */
- #define OFS_I 10 /* position (offset) of this file */
- #define DAT_I 14 /* DOS format date */
- #define TIM_I 16 /* DOS format time */
- #define CRC_I 18 /* CRC of this file */
- #define ORGS_I 20 /* original size */
- #define SIZNOW_I 24 /* size now */
- #define DMAJ_I 28 /* major version number */
- #define DMIN_I 29 /* minor version number */
- #define DEL_I 30 /* deleted or not */
- #define STRUC_I 31 /* file structure */
- #define CMT_I 32 /* comment [offset] */
- #define CMTSIZ_I 36 /* comment size */
- #define FNAME_I 38 /* filename */
- #define VARDIRLEN_I 51 /* length of var. direntry */
- #define TZ_I 53 /* timezone */
- #define DCRC_I 54 /* CRC of directory entry */
- X
- #define FNM_SIZ 13 /* size of stored filename */
- X
- /* Offsets within variable part of directory entry */
- #define NAMLEN_I (SIZ_DIRL + 0)
- #define DIRLEN_I (SIZ_DIRL + 1)
- #define LFNAME_I (SIZ_DIRL + 2)
- #define DIRNAME_I LFNAME_I /* plus length of filename */
- X
- /*
- Total size of fixed plus variable directory recognized currently:
- One byte each for dirlen and namlen, 256 each for long filename and
- directory name, 2 for system id, 3 for file attributes, 1 for
- version flag, 2 for version number, plus a fudge factor of 5.
- */
- #define MAXDIRSIZE (SIZ_DIRL+1+1+256+256+2+3+1+2+5)
- X
- /* Value used to stuff into timezone field if it is not known */
- #define NO_TZ 127
- X
- /* Value for no file attributes */
- #define NO_FATTR 0L
- X
- /* version flag bits */
- #define VFL_ON 0x80 /* enable version numbering */
- #define VFL_GEN 0x0f /* generation count */
- #define VFL_LAST 0x40 /* last generation of this file */
- X
- /* default generation value for archive */
- #define GEN_DEFAULT 3
- /* max generation count, file or archive */
- #define MAXGEN 0x0f
- /* version mask to prune down to correct size on large-word machines */
- #define VER_MASK 0xffff
- SHAR_EOF
- chmod 0644 zoo.h ||
- echo 'restore of zoo.h failed'
- Wc_c="`wc -c < 'zoo.h'`"
- test 10237 -eq "$Wc_c" ||
- echo 'zoo.h: original size 10237, current size' "$Wc_c"
- fi
- true || echo 'restore of zoo.man failed'
- echo End of part 11, continue with part 12
- exit 0
-