home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / ZOO21E.EXE / ZOO.H < prev    next >
C/C++ Source or Header  |  1991-07-11  |  10KB  |  243 lines

  1. /* derived from: zoo.h 2.16 88/01/27 23:21:36 */
  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.  When an archive is packed
  20. by any version of Zoo, the text message is changed to the text message
  21. used by that version.  For example, if Zoo 1.10 packs an archive created
  22. by Zoo 1.31, the text message changes to "Zoo 1.10 archive.".  This
  23. was once considered a shortcoming, but it is now an essential feature,
  24. because packing will also update an old archiver header structure
  25. into a new one.
  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 pointer
  33. is stored along with its negation for consistency checking.  It is hoped
  34. that if the archive is damaged, both the pointer and its negation won't
  35. be damaged and at least one would still be usable to tell us where the
  36. data begins.
  37.  
  38. (d) A two-byte value giving the major and minor version number of the
  39. minimum version of Zoo that is needed to fully manipulate the archive.
  40. As the archive structure is modified, this version number may increase.
  41. Currently version 1.71 of Zoo creates archives that may be fully manipulated
  42. by version 1.40 onwards.
  43.  
  44. (e) With zoo 2.00 addtional fields have been added in the archive
  45. header to store information about the archive comment and generation
  46. limit.
  47.  
  48. Version numbering:
  49. The directory entry of each file will contain the minimum version number of
  50. Zoo needed to extract that file.  As far as possible, version 1.00 of Zoo
  51. will be able to extract files from future version archives.
  52. */
  53.  
  54. #define H_TYPE    1                /* archive header type */
  55.  
  56. /* Define major and minor version numbers */
  57. #define MAJOR_VER 2        /* needed to manipulate archive */
  58. #define MINOR_VER 0
  59.  
  60. /* version needed to extract packing method 1 */
  61. #define MAJOR_EXT_VER 1
  62. #define MINOR_EXT_VER 0
  63.  
  64. /* version needed to extract packing method 2 */
  65. #define MAJOR_LZH_VER    2
  66. #define MINOR_LZH_VER    1
  67.  
  68. #define CTRL_Z 26
  69.  
  70. /* should be 0xFDC4A7DCUL but many c compilers don't recognize UL at end */
  71. #define ZOO_TAG ((unsigned long) 0xFDC4A7DCL) /* A random choice */
  72. #define TEXT "ZOO 2.10 Archive.\032"   /* Header text for archive. */
  73. #define SIZ_TEXT  20                   /* Size of header text */
  74.  
  75. #define PATHSIZE 256                   /* Max length of pathname */
  76. #define FNAMESIZE 13                   /* Size of DOS filename */
  77. #define LFNAMESIZE 256                 /* Size of long filename */
  78. #define ROOTSIZE 8                     /* Size of fname without extension */
  79. #define EXTLEN 3                       /* Size of extension */
  80. #define FILE_LEADER  "@)#("            /* Allowing location of file data */
  81. #define SIZ_FLDR  5                    /* 4 chars plus null */
  82. #define MAX_PACK 2                     /* max packing method we can handle */
  83. #define BACKUP_EXT ".bak"              /* extension of backup file */
  84.  
  85. #ifdef OOZ
  86. #define FIRST_ARG 2
  87. #endif
  88.  
  89. #ifdef ZOO
  90. #define FIRST_ARG 3        /* argument position of filename list */
  91. #endif
  92.  
  93. typedef unsigned char uchar;
  94.  
  95. /* WARNING:  Static initialization in zooadd.c or zooext.c depends on the
  96.    order of fields in struct zoo_header */
  97. struct zoo_header {
  98.    char text[SIZ_TEXT];       /* archive header text */
  99.    unsigned long zoo_tag;     /* identifies archives */
  100.    long zoo_start;            /* where the archive's data starts */
  101.    long zoo_minus;              /* for consistency checking of zoo_start */
  102.    uchar major_ver;
  103.    uchar minor_ver;           /* minimum version to extract all files   */
  104.     uchar type;                        /* type of archive header */
  105.     long acmt_pos;                    /* position of archive comment */
  106.     unsigned int acmt_len;        /* length of archive comment */
  107.     unsigned int vdata;            /* byte in archive;  data about versions */
  108. };
  109.  
  110. struct direntry {
  111.    unsigned long zoo_tag;     /* tag -- redundancy check */
  112.    uchar type;                 /* type of directory entry.  always 1 for now */
  113.    uchar packing_method;       /* 0 = no packing, 1 = normal LZW */
  114.    long next;                 /* pos'n of next directory entry */
  115.    long offset;               /* position of this file */
  116.    unsigned int date;         /* DOS format date */
  117.    unsigned int time;         /* DOS format time */
  118.    unsigned int file_crc;     /* CRC of this file */
  119.    long org_size;
  120.    long size_now;
  121.    uchar major_ver;
  122.    uchar minor_ver;            /* minimum version needed to extract */
  123.    uchar deleted;              /* will be 1 if deleted, 0 if not */
  124.    uchar struc;                /* file structure if any */
  125.    long comment;              /* points to comment;  zero if none */
  126.    unsigned int cmt_size;         /* length of comment, 0 if none */
  127.    char fname[FNAMESIZE];         /* filename */
  128.  
  129.    int var_dir_len;           /* length of variable part of dir entry */
  130.    uchar tz;                   /* timezone where file was archived */
  131.    unsigned int dir_crc;      /* CRC of directory entry */
  132.  
  133.    /* fields for variable part of directory entry follow */
  134.    uchar namlen;               /* length of long filename */
  135.    uchar dirlen;               /* length of directory name */
  136.    char lfname[LFNAMESIZE];   /* long filename */
  137.    char dirname[PATHSIZE];    /* directory name */
  138.    unsigned int system_id;    /* Filesystem ID */
  139.     unsigned long fattr;            /* File attributes -- 24 bits */
  140.     unsigned int vflag;            /* version flag bits -- one byte in archive */
  141.     unsigned int version_no;    /* file version number if any */
  142. };
  143.  
  144. /* Values for direntry.system_id */
  145. #define SYSID_NIX       0     /* UNIX and similar filesystems */
  146. #define SYSID_MS        1     /* MS-DOS filesystem */
  147. #define SYSID_PORTABLE  2     /* Portable syntax */
  148.  
  149. /* Structure of header of small archive containing just one file */
  150.  
  151. #define  TINYTAG     0x07FE   /* magic number */
  152.  
  153. #ifndef PORTABLE
  154. struct tiny_header {          /* one-file small archive */
  155.    int tinytag;               /* magic number */
  156.    char type;                 /* always 1 for now */
  157.    char packing_method;
  158.    unsigned int date;
  159.    unsigned int time;
  160.    unsigned int file_crc;
  161.    long org_size;
  162.    long size_now;
  163.    char major_ver;
  164.    char minor_ver;
  165.    unsigned int cmt_size; /* length of comment, 0 if none */
  166.    char fname[FNAMESIZE];     /* filename */
  167. };
  168. #endif /* ifndef PORTABLE */
  169.  
  170. #define    FIXED_OFFSET 34        /* zoo_start in old archives */
  171. #define    MINZOOHSIZ 34            /* minimum size of archive header */
  172. #define  SIZ_ZOOH  42            /* length of current archive header */
  173.  
  174. /* offsets of items within the canonical zoo archive header */
  175. #define  TEXT_I    0           /* text in header */
  176. #define  ZTAG_I    20          /* zoo tag */
  177. #define  ZST_I     24          /* start offset */
  178. #define  ZSTM_I    28          /* negative of start offset */
  179. #define  MAJV_I    32          /* major version */
  180. #define  MINV_I    33          /* minor version */
  181. #define    HTYPE_I     34            /* archive header type */
  182. #define    ACMTPOS_I 35            /* position of archive comment */
  183. #define    ACMTLEN_I 39            /* length of archive comment */
  184. #define    HVDATA_I     41            /* version data */
  185.  
  186. /* offsets of items within the canonical directory entry structure */
  187. #define  SIZ_DIR  51          /* length of type 1 directory entry */
  188. #define  SIZ_DIRL 56          /* length of type 2 directory entry */
  189. #define  DTAG_I   0           /* tag within directory entry */
  190. #define  DTYP_I   4           /* type of directory entry */
  191. #define  PKM_I    5           /* packing method */
  192. #define  NXT_I    6           /* pos'n of next directory entry */
  193. #define  OFS_I    10          /* position (offset) of this file */
  194. #define  DAT_I    14          /* DOS format date */
  195. #define  TIM_I    16          /* DOS format time */
  196. #define  CRC_I    18          /* CRC of this file */
  197. #define  ORGS_I   20          /* original size */
  198. #define  SIZNOW_I 24          /* size now */
  199. #define  DMAJ_I   28          /* major version number */
  200. #define  DMIN_I   29          /* minor version number */
  201. #define  DEL_I    30          /* deleted or not */
  202. #define  STRUC_I  31          /* file structure */
  203. #define  CMT_I    32          /* comment [offset] */
  204. #define  CMTSIZ_I 36          /* comment size */
  205. #define  FNAME_I  38          /* filename */
  206. #define  VARDIRLEN_I  51      /* length of var. direntry */
  207. #define  TZ_I     53          /* timezone */
  208. #define  DCRC_I   54          /* CRC of directory entry */
  209.  
  210. #define  FNM_SIZ  13          /* size of stored filename */
  211.  
  212. /* Offsets within variable part of directory entry */
  213. #define  NAMLEN_I   (SIZ_DIRL + 0)
  214. #define  DIRLEN_I   (SIZ_DIRL + 1)
  215. #define  LFNAME_I   (SIZ_DIRL + 2)
  216. #define  DIRNAME_I  LFNAME_I  /* plus length of filename */
  217.  
  218. /*
  219. Total size of fixed plus variable directory recognized currently:
  220. One byte each for dirlen and namlen, 256 each for long filename and
  221. directory name, 2 for system id, 3 for file attributes, 1 for
  222. version flag, 2 for version number, plus a fudge factor of 5.
  223. */
  224. #define  MAXDIRSIZE  (SIZ_DIRL+1+1+256+256+2+3+1+2+5)
  225.  
  226. /* Value used to stuff into timezone field if it is not known */
  227. #define  NO_TZ    127
  228.  
  229. /* Value for no file attributes */
  230. #define    NO_FATTR        0L
  231.  
  232. /* version flag bits */
  233. #define    VFL_ON    0x80        /* enable version numbering */
  234. #define    VFL_GEN    0x0f        /* generation count */
  235. #define    VFL_LAST 0x40        /* last generation of this file */
  236.  
  237. /* default generation value for archive */
  238. #define    GEN_DEFAULT            3
  239. /* max generation count, file or archive */
  240. #define    MAXGEN                0x0f
  241. /* version mask to prune down to correct size on large-word machines */
  242. #define VER_MASK                0xffff
  243.