home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / zoo141_c.lzh / ZOO.H < prev    next >
C/C++ Source or Header  |  1987-02-07  |  9KB  |  200 lines

  1. /* zoo.h */
  2.  
  3. /*
  4. The contents of this file are hereby released to the public domain.
  5.  
  6.                            -- Rahul Dhesi 1986/11/14
  7. */
  8.  
  9.  
  10. /* Global data structures and also some information about archive structure.
  11.  
  12. Among other things, the archive header contains:  
  13.  
  14. (a) A text message.  In the MS-DOS version this message is terminated by
  15. control Z.  This allows naive users to type the archive to the screen
  16. and see a brief but meaningful message instead of garbage.  The contents of
  17. the text message are however not used by Zoo and they may be anything.  
  18. In particular, the text message may identify the type or archive or the
  19. particular computer system it was created on.  Note:  Due to some untidyness
  20. in Zoo's code, when an archive is packed by any version of Zoo, the text
  21. message is changed to the text messages used by that version.  For example,
  22. if Zoo 1.10 packs an archive created by Zoo 1.31, the text message changes
  23. to "Zoo 1.10 archive.".  In the long run, this should be changed to
  24. preserve the text message, thus identifying the version that created the 
  25. archive, not the version that packed it.
  26.  
  27. (b) A four-byte tag that identifies all Zoo archives.  This helps prevent
  28. arbitrary binary files from being treated as Zoo archives.  The tag value is
  29. arbitrary, but seemed to be unlikely to occur in an executable file.  The
  30. same tag value is used to identify each directory entry.  
  31.  
  32. (c) A long pointer to where in the file the archive starts.  This could be
  33. left out if the archive always started immediately after the header, but I
  34. want to allow room for future additions to the header information without
  35. confusing earlier versions of Zoo.  This pointer is stored along with its
  36. negation for consistency checking.  It is hoped that if the archive is
  37. damaged, both the pointer and its negation won't be damaged and at least
  38. one would still be usable to tell us where the data begins.
  39.  
  40. (d) A two-byte value giving the major and minor version number of the
  41. minimum version of Zoo that is needed to fully manipulate the archive.  
  42. As the archive structure is modified, this version number may increase.
  43. Currently version 1.31 of Zoo creates archives that may be fully manipulated
  44. by version 1.10 onwards.
  45.  
  46. Version numbering:  
  47. The directory entry of each file will contain the minimum version number of
  48. Zoo needed to extract that file.  As far as possible, version 1.00 of Zoo
  49. will be able to extract files from future version archives.
  50. */
  51.  
  52. /* This is version 1.1.  Define major and minor version numbers */
  53.  
  54. #define MAJOR_VER 1        /* needed to manipulate archive */
  55. #define MINOR_VER 4
  56.  
  57. #define MAJOR_EXT_VER 1    /* needed to extract file */
  58. #define MINOR_EXT_VER 0
  59.  
  60. #define CTRL_Z 26
  61. #define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
  62. #define TEXT "ZOO 1.40 Archive.\032"   /* Header text for archive. */
  63. #define SIZ_TEXT  20                   /* Size of header text */
  64.  
  65. #define PATHSIZE 256                   /* Max length of pathname */
  66. #define FNAMESIZE 13                   /* Size of DOS filename */
  67. #define LFNAMESIZE 256                 /* Size of long filename */
  68. #define ROOTSIZE 8                     /* Size of fname without extension */
  69. #define EXTLEN 3                       /* Size of extension */
  70. #define FILE_LEADER  "@)#("            /* Allowing location of file data */
  71. #define SIZ_FLDR  5                    /* 4 chars plus null */
  72. #define MAX_PACK 1                     /* max packing method we can handle */
  73. #define BACKUP_EXT ".bak"              /* extension of backup file */
  74.  
  75. #ifdef OOZ
  76. #define FIRST_ARG 2
  77. #endif
  78.  
  79. #ifdef ZOO
  80. #define FIRST_ARG 3        /* argument position of filename list */
  81. #endif
  82.  
  83. /* WARNING:  Static initialization in zooadd.c or zooext.c depends on the 
  84.    order of fields in struct zoo_header */
  85. struct zoo_header {
  86.    char text[SIZ_TEXT];       /* archive header text */
  87.    unsigned long zoo_tag;     /* identifies archives           */
  88.    long zoo_start;            /* where the archive's data starts        */
  89.    long zoo_minus;      /* for consistency checking of zoo_start  */
  90.    char major_ver;
  91.    char minor_ver;            /* minimum version to extract all files   */
  92. };
  93.  
  94. /* Note:  Microsoft C aligns data at word boundaries.  So, to keep things
  95.    compact, always try to pair up character fields. */
  96. struct direntry {
  97.    unsigned long zoo_tag;     /* tag -- redundancy check */
  98.    char type;                 /* type of directory entry.  always 1 for now */
  99.    char packing_method;       /* 0 = no packing, 1 = normal LZW */
  100.    long next;                 /* pos'n of next directory entry */
  101.    long offset;               /* position of this file */
  102.    unsigned int date;         /* DOS format date */
  103.    unsigned int time;         /* DOS format time */
  104.    unsigned int file_crc;     /* CRC of this file */
  105.    long org_size;
  106.    long size_now;
  107.    char major_ver;
  108.    char minor_ver;            /* minimum version needed to extract */
  109.    char deleted;              /* will be 1 if deleted, 0 if not */
  110.    char struc;                /* file structure if any */
  111.    long comment;              /* points to comment;  zero if none */
  112.    unsigned int cmt_size; /* length of comment, 0 if none */
  113.    char fname[FNAMESIZE]; /* filename */
  114.  
  115.    int var_dir_len;           /* length of variable part of dir entry */
  116.    char tz;                   /* timezone where file was archived */
  117.    unsigned int dir_crc;      /* CRC of directory entry */
  118.  
  119.    /* fields for variable part of directory entry follow */
  120.    char namlen;               /* length of long filename */
  121.    char dirlen;               /* length of directory name */
  122.    char lfname[LFNAMESIZE];   /* long filename */
  123.    char dirname[PATHSIZE];    /* directory name */
  124.    int system_id;             /* Filesystem ID */
  125. };
  126.  
  127. /* Values for direntry.system_id */
  128. #define SYSID_NIX       0     /* UNIX and similar filesystems */
  129. #define SYSID_MS        1     /* MS-DOS filesystem */
  130. #define SYSID_PORTABLE  2     /* Portable syntax */
  131.  
  132. /* Structure of header of small archive containing just one file */
  133.  
  134. #define  TINYTAG     0x07FE   /* magic number */
  135.  
  136. struct tiny_header {          /* one-file small archive */
  137.    int tinytag;               /* magic number */
  138.    char type;                 /* always 1 for now */
  139.    char packing_method;
  140.    unsigned int date;
  141.    unsigned int time;
  142.    unsigned int file_crc;
  143.    long org_size;
  144.    long size_now;
  145.    char major_ver;
  146.    char minor_ver;
  147.    unsigned int cmt_size; /* length of comment, 0 if none */
  148.    char fname[FNAMESIZE];     /* filename */
  149. };
  150.  
  151. /* offsets of items within the canonical zoo archive header */
  152. #define  SIZ_ZOOH 34          /* 34 byte-long archive header */
  153. #define  TEXT_I   0           /* text in header */
  154. #define  ZTAG_I   20          /* zoo tag */
  155. #define  ZST_I    24          /* start offset */
  156. #define  ZSTM_I   28          /* negative of start offset */
  157. #define  MAJV_I   32          /* major version */
  158. #define  MINV_I   33          /* minor version */
  159.  
  160. /* offsets of items within the canonical directory entry structure */
  161. #define  SIZ_DIR  51          /* length of type 1 directory entry */
  162. #define  SIZ_DIRL 56          /* length of type 2 directory entry */
  163. #define  DTAG_I   0           /* tag within directory entry */
  164. #define  DTYP_I   4           /* type of directory entry */
  165. #define  PKM_I    5           /* packing method */
  166. #define  NXT_I    6           /* pos'n of next directory entry */
  167. #define  OFS_I    10          /* position (offset) of this file */
  168. #define  DAT_I    14          /* DOS format date */
  169. #define  TIM_I    16          /* DOS format time */
  170. #define  CRC_I    18          /* CRC of this file */
  171. #define  ORGS_I   20          /* original size */
  172. #define  SIZNOW_I 24          /* size now */
  173. #define  DMAJ_I   28          /* major version number */
  174. #define  DMIN_I   29          /* minor version number */
  175. #define  DEL_I    30          /* deleted or not */
  176. #define  STRUC_I  31          /* file structure */
  177. #define  CMT_I    32          /* comment [offset] */
  178. #define  CMTSIZ_I 36          /* comment size */
  179. #define  FNAME_I  38          /* filename */
  180. #define  VARDIRLEN_I  51      /* length of var. direntry */
  181. #define  TZ_I     53          /* timezone */
  182. #define  DCRC_I   54          /* CRC of directory entry */
  183.  
  184. #define  FNM_SIZ  13          /* size of stored filename */
  185.  
  186. /* Offsets within variable part of directory entry */
  187. #define  NAMLEN_I   (SIZ_DIRL + 0)
  188. #define  DIRLEN_I   (SIZ_DIRL + 1)
  189. #define  LFNAME_I   (SIZ_DIRL + 2)
  190. #define  DIRNAME_I  LFNAME_I  /* plus length of filename */
  191.  
  192. /* total size of fixed plus variable directory recognized currently:
  193. 1 byte each for dirlen and namlen, and 256 each for long filename
  194. and directory name, + fudge factor of 10. */
  195. #define  MAXDIRSIZE  (SIZ_DIRL+1+1+256+256+10)
  196.  
  197. /* Value used to stuff into timezone field if it is not known */
  198. #define  NO_TZ    127
  199.  
  200.