home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / ARCHIVE / REDATE2.ZIP / ARCHDR.H next >
Encoding:
C/C++ Source or Header  |  1991-05-13  |  15.8 KB  |  406 lines

  1. #ifndef fallthrough        /* "fallthrough" is in opus.h */
  2. typedef unsigned    char    byte;
  3. typedef unsigned    int     word;
  4. #endif
  5.  
  6.  
  7. /****** General purpose Symbolic constants:  *********/
  8. #define TRUE    1        /* general purpose true truth value */
  9. #define FALSE    0        /* general purpose false truth value */
  10. #define ERROR    -1        /* General "on error" return value */
  11. #define OK    0        /* General "no error" return value */
  12. #define EOS    '\0'        /* standard end of string */
  13.  
  14. #define MAX_PATH    78        /* max. length of full pathname        */
  15. #define MAX_DIR     66        /* max. length of full directory name    */
  16.  
  17. #define FOSSIL      0x0001        /* running remotely */
  18. #define MORE        0x0002        /* User wants More? prompts */
  19. #define WANTS_MORE  0x0004        /* User has more in User.BBS */
  20. #define VIEW        0x0008        /* View text files inside archive */
  21. #define    WATCH        0x0010        /* Use FOSSIL watchdog */
  22.  
  23. #define ARC         0x1000        /* ARC/PAK file */
  24. #define ZIP         0x2000        /* PKZIP file */
  25. #define ZOO         0x4000        /* ZOO File */
  26. #define DWC         0x8000        /* DWC File */
  27. #define ARJ         0x0200        /* ARJ File */
  28. /*----------------------------------------------------------------------*/
  29. /*         Information for file date conversion            */
  30. /*----------------------------------------------------------------------*/
  31. #define MONTH_SHIFT     5
  32. #define MONTH_MASK      0x0F
  33. #define DAY_MASK    0x1F
  34. #define YEAR_SHIFT      9
  35. #define DOS_EPOCH       80
  36. #define HOUR_SHIFT      11
  37. #define HOUR_MASK       0x1F
  38. #define MINUTE_SHIFT    5
  39. #define MINUTE_MASK     0x3F
  40.  
  41.  
  42. /*----------------------------------------------------------------------*/
  43. /*              archive list junk                */
  44. /*----------------------------------------------------------------------*/
  45. #define ARCMARK 26    /* special archive marker */
  46. #define ARCVER 10    /* highest compression code used */
  47.  
  48. #pragma pack(1)        /* req'd by MSC to keep struct byte aligned */ 
  49. struct heads        /* archive entry header format */
  50. {   
  51.     char mbrname[13];    /* file name */
  52.     long mbrsize;    /* size of file in archive, bytes */
  53.     unsigned mbrdate;    /* creation date */
  54.     unsigned mbrtime;    /* creation time */
  55.     int mbrcrc;        /* cyclic redundancy check */
  56.     long mbrlen;    /* true file size, bytes */
  57. };
  58. #pragma pack()        /* we now return to our regular programming */
  59.  
  60.  
  61. /*--------------------------------------------------------------------------*/
  62. /* Garbage for ZOO listing                                                  */
  63. /*--------------------------------------------------------------------------*/
  64.  
  65. #define MAJOR_VER 1        /* needed to manipulate archive */
  66. #define MINOR_VER 4
  67.  
  68. #define MAJOR_EXT_VER 1    /* needed to extract file */
  69. #define MINOR_EXT_VER 0
  70.  
  71. #define CTRL_Z 26
  72. #define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
  73. #define TEXT "ZOO 1.50 Archive.\032"   /* Header text for archive. */
  74. #define SIZ_TEXT  20                   /* Size of header text */
  75.  
  76. #define PATHSIZE 256                   /* Max length of pathname */
  77. #define FNAMESIZE 13                   /* Size of DOS filename */
  78. #define LFNAMESIZE 256                 /* Size of long filename */
  79. #define ROOTSIZE 8                     /* Size of fname without extension */
  80. #define EXTLEN 3                       /* Size of extension */
  81. #define FILE_LEADER  "@)#("            /* Allowing location of file data */
  82. #define SIZ_FLDR  5                    /* 4 chars plus null */
  83. #define MAX_PACK 1                     /* max packing method we can handle */
  84. #define BACKUP_EXT ".bak"              /* extension of backup file */
  85.  
  86. #ifdef OOZ
  87. #define FIRST_ARG 2
  88. #endif
  89.  
  90. #ifdef ZOO
  91. #define FIRST_ARG 3        /* argument position of filename list */
  92. #endif
  93.  
  94. /* WARNING:  Static initialization in zooadd.c or zooext.c depends on the 
  95.    order of fields in struct zoo_header */
  96. struct zoo_header {
  97.    char text[SIZ_TEXT];       /* archive header text */
  98.    unsigned long zoo_tag;     /* identifies archives           */
  99.    long zoo_start;            /* where the archive's data starts        */
  100.    long zoo_minus;      /* for consistency checking of zoo_start  */
  101.    char major_ver;
  102.    char minor_ver;            /* minimum version to extract all files   */
  103. };
  104.  
  105. /* Note:  Microsoft C aligns data at word boundaries.  So, to keep things
  106.    compact, always try to pair up character fields. */
  107. struct direntry {
  108.    unsigned long zoo_tag;     /* tag -- redundancy check */
  109.    char type;                 /* type of directory entry.  always 1 for now */
  110.    char packing_method;       /* 0 = no packing, 1 = normal LZW */
  111.    long next;                 /* pos'n of next directory entry */
  112.    long offset;               /* position of this file */
  113.    unsigned int date;         /* DOS format date */
  114.    unsigned int time;         /* DOS format time */
  115.    unsigned int file_crc;     /* CRC of this file */
  116.    long org_size;
  117.    long size_now;
  118.    char major_ver;
  119.    char minor_ver;            /* minimum version needed to extract */
  120.    char deleted;              /* will be 1 if deleted, 0 if not */
  121.    char struc;                /* file structure if any */
  122.    long comment;              /* points to comment;  zero if none */
  123.    unsigned int cmt_size; /* length of comment, 0 if none */
  124.    char fname[FNAMESIZE]; /* filename */
  125.  
  126.    int var_dir_len;           /* length of variable part of dir entry */
  127.    char tz;                   /* timezone where file was archived */
  128.    unsigned int dir_crc;      /* CRC of directory entry */
  129.  
  130.    /* fields for variable part of directory entry follow */
  131.    char namlen;               /* length of long filename */
  132.    char dirlen;               /* length of directory name */
  133.    char lfname[LFNAMESIZE];   /* long filename */
  134.    char dirname[PATHSIZE];    /* directory name */
  135.    int system_id;             /* Filesystem ID */
  136. };
  137.  
  138. /* Values for direntry.system_id */
  139. #define SYSID_NIX       0     /* UNIX and similar filesystems */
  140. #define SYSID_MS        1     /* MS-DOS filesystem */
  141. #define SYSID_PORTABLE  2     /* Portable syntax */
  142.  
  143. /*-End of Zoo stuff---------------------------------------------------------*/
  144. /*-Start of DWC stuff-------------------------------------------------------*/
  145. #pragma pack(1)        /* req'd by MSC to keep struct byte aligned    */ 
  146.  
  147. /* ENTRY - information that is stored for each file in the DWC archive.      */
  148.  
  149. struct dwc_entry {
  150.    char     name[13];      /* ... File name, Note: path is not saved here    */
  151.    long     size;          /* ... Size of file before compression in bytes   */
  152.    long     time;          /* ... Time stamp on file before added to archive */
  153.    long     new_size;      /* ... Size of compressed file                    */
  154.    long     pos;           /* ... Position of file in archive file           */
  155.    char     method;        /* ... Method of compression used on file         */
  156.    char     sz_c;          /* ... Size of comment added to file              */
  157.    char     sz_d;          /* ... Size of directory name recorded on add     */
  158.    unsigned crc;           /* ... CRC value computed for this file           */
  159. };
  160.  
  161. /* ARCHIVE - information that is stored at the end of every achive.          */
  162.  
  163. struct dwc_arc {
  164.    unsigned size;          /* ... Size of archive structure, future expansion*/
  165.    char     ent_sz;        /* ... Size of directory entry, future expansion  */
  166.    char     header[13];    /* ... Name of Header file to print on listings   */
  167.    long     time;          /* ... Time stamp of last modification to archive */
  168.    long     entries;       /* ... Number of entries in archive               */
  169.    char     id[3];         /* ... the string "DWC" to identify archive       */
  170. };
  171. #pragma pack()
  172. /*-End of DWC stuff---------------------------------------------------------*/
  173.  
  174. /*--------------------------------------------------------------------------*/
  175. /* PKZIP (Phil Katz)                                                        */
  176. /*--------------------------------------------------------------------------*/
  177.  
  178. struct ID_Hdr {
  179.     word    PK_ID;        /* Always = PK = 0x4B50  */
  180.     word    Head_Type;        /* Identifiles which type of header this is */
  181. };
  182.  
  183. #define     LOCAL_HEADER    0x0403        /* PK local header 0x04034B50 */
  184. #define     CENTRAL_DIR     0x0201        /* "Central header"towards end of file */
  185. #define     CENTRAL_REC     0x0605        /* Last header in file */
  186.  
  187. struct Local_Hdr {
  188.     word    extract_ver;    /* check program ver needed to unpack */
  189.     word    GP_flags;        /* General purpose flags, see below */
  190.     word    compression;    /* Compression method */
  191.     word    mod_time;        /* Modification time */
  192.     word    mod_date;        /* Modification date */
  193.     long    crc;            /* File's CRC */
  194.     long    size_now;       /* compressed size */
  195.     long    real_size;        /* un-compressed file size */
  196.     word    name_length;        /* FileName length */
  197.     word    Xfield_length;        /* Extra field length */
  198. };
  199.  
  200. /* Filename follows, no null terminator! */
  201. /* Extra field, no null terminator. */
  202.  
  203. /*--------------------------------------------------------------------------*/
  204. /* Flags used with extract_ver                                              */
  205. /*--------------------------------------------------------------------------*/
  206. #define     IBM     0x0001        /* MS-DOS version of PKZIP */
  207. #define     AMIGA   0x0002        /* Amiga version of PKZIP */
  208. #define     VMS     0x0004        /* VMS version of PKZIP */
  209. #define     UNIX    0x0008        /* UNIX version of PKZIP (C) Bell Labs */
  210.  
  211. /*--------------------------------------------------------------------------*/
  212. /* Flags used with general purpose flags                                    */
  213. /*--------------------------------------------------------------------------*/
  214. #define     ENCRYPT 0x0001        /* File is encrypted */
  215.   
  216. struct  Central_File {
  217.     word    extract_ver;    /* check program ver needed to unpack */
  218.     word    GP_flags;        /* General purpose flags, see below */
  219.     word    compression;    /* Compression method */
  220.     word    mod_time;        /* Modification time */
  221.     word    mod_date;        /* Modification date */
  222.     long    crc;            /* File's CRC */
  223.     long    size_now;       /* compressed size */
  224.     long    real_size;        /* un-compressed file size */
  225.     word    name_length;        /* FileName length */
  226.     word    Xfield_length;        /* Extra field length */
  227.     word    comment_length;        /* File comment length */
  228.     word    disk_start;        /* "Number of disk on which this file begins" */
  229.     word    int_attrib;        /* See internal flags below */
  230.     long    ext_attrib;        /* file's original attributes */
  231.     long    rel_offset;        /* Offset from start of disk/ZIP to local header */
  232. };
  233. /* File Name    */
  234. /* Extra Field  */
  235. /* Comment      */
  236.  
  237. /*--------------------------------------------------------------------------*/
  238. /* Internal Flags                                                           */
  239. /*--------------------------------------------------------------------------*/
  240.  
  241. #define     IS_TEXT     0x0001        /* This file is probably text */
  242.  
  243. struct  Central_Directory {
  244.     word    disk_number;        /* Number of this disk */
  245.     word    center_disk;        /* Number of disk where Central Dir starts */
  246.     word    total_disk;            /* Total # of entries on this disk */
  247.     word    total_entry;        /* Total # of files in this Zipfile */
  248.     long    central_size;        /* Size of the entire central directory */
  249.     long    start_offset;        /*  */
  250.     word    zip_cmnt_len;        /* Length of comment for entire file */
  251. };
  252.  
  253. /* Zipfile comment */
  254.  
  255. /*--------------------------------------------------------------------------*/
  256. /* LHARC                                                                    */
  257. /*--------------------------------------------------------------------------*/
  258.  
  259. struct dostime {
  260.    word    time;
  261.    word    date;
  262. };
  263.  
  264. union _orig {
  265.    struct  dostime  dtime;
  266.    long utc;
  267. };
  268.  
  269. #pragma pack(1)
  270. struct Lharc_Hdr {
  271.     int     size_header;        /* No. bytes in header - 2 (0 = EOF) */
  272.     char    type[5];        /* Compression type, no NULL terminator! */
  273.     long    size_now;        /* Size of compressed file */
  274.     long    orig_size;        /* Original size of file */
  275.    union   _orig   orig;
  276.     byte    attrib;        /* file attribute */
  277.     byte    level;
  278. };
  279. /*  char    file_name;   Not terminated!                                                   */
  280. /*  char    crc_char[2]; */
  281.  
  282.  
  283. /*----------------------------------------------------------------------*/
  284. /* COLORS for BIOS display                                              */
  285. /*----------------------------------------------------------------------*/
  286. #define    BLUE        1
  287. #define    GREEN        2
  288. #define    RED            4
  289. #define    INTENSE        8
  290. #define    BLUE_BACK    16
  291. #define GREEN_BACK    32
  292. #define RED_BACK    64
  293. #define BLINK        128
  294. #define CYAN        BLUE|GREEN
  295. #define MAGENTA     BLUE|RED
  296. #define YELLOW      RED|GREEN
  297. #define WHITE       RED|GREEN|BLUE
  298. #define WHITE_BACK  BLUE_BACK|RED_BACK|GREEN_BACK
  299.  
  300. #define REG         WHITE
  301. #define REV         WHITE_BACK
  302. #define BRIGHT      INTENSE|WHITE
  303.  
  304.  
  305. #define FOSSIL_INT   0x14
  306.  
  307. /*---------------------------------------------------------------------*/
  308. /* comm fossil line and modem status in AX.  Status bits returned are: */
  309. /*---------------------------------------------------------------------*/
  310.                      /* In AH: */
  311. #define RDA  0x0100  /* input data is available in buffer */
  312. #define OVRN 0x0200  /* the input buffer has been overrun */
  313. #define THRE 0x2000  /* room is available in output buffer */
  314. #define TSRE 0x4000  /* output buffer is empty */
  315.                      /* In AL: */
  316. #define FRDY 0x0008  /* fossil ready - Always 1 */
  317. #define DCD  0x0080  /* carrier detect */
  318.  
  319.  
  320. /* StuffIt.h: contains declarations for SIT headers */
  321.  
  322. typedef struct sitHdr {       /* 22 bytes */
  323.     char  signature[4];     /* = 'SIT!' -- for verification */
  324.    unsigned short numFiles;   /* number of files in archive */
  325.    unsigned long  arcLength;  /* length of entire archive incl.
  326.                   hdr. -- for verification */
  327.     char  signature2[4];    /* = 'rLau' -- for verification */
  328.    unsigned char  version; /* version number */
  329.    char reserved[7];
  330. };
  331.  
  332. typedef struct fileHdr {      /* 112 bytes */
  333.    unsigned char  compRMethod;   /* rsrc fork compression method */
  334.    unsigned char  compDMethod;   /* data fork compression method */
  335.    unsigned char  fName[64];  /* a STR63 */
  336.     char   fType[4];         /* file type */
  337.     char   fCreator[4];      /* er... */
  338.    short FndrFlags;     /* copy of Finder flags.  For our
  339.                   purposes, we can clear:
  340.                   busy,onDesk */
  341.    unsigned long  creationDate;
  342.    unsigned long  modDate; /* !restored-compat w/backup prgms */
  343.    unsigned long  rsrcLength; /* decompressed lengths */
  344.    unsigned long  dataLength;
  345.    unsigned long  compRLength;   /* compressed lengths */
  346.    unsigned long  compDLength;
  347.    unsigned short rsrcCRC;    /* crc of rsrc fork */
  348.    unsigned short dataCRC;    /* crc of data fork */
  349.    char reserved[6];
  350.    unsigned short hdrCRC;     /* crc of file header */
  351. };
  352.  
  353.  
  354. /* file format is:
  355.    sitArchiveHdr
  356.       file1Hdr
  357.          file1RsrcFork
  358.          file1DataFork
  359.       file2Hdr
  360.          file2RsrcFork
  361.          file2DataFork
  362.       .
  363.       .
  364.       .
  365.       fileNHdr
  366.          fileNRsrcFork
  367.          fileNDataFork
  368. */
  369.  
  370.  
  371.  
  372. /* compression methods */
  373. #define noComp    0  /* just read each byte and write it to archive */
  374. #define repComp 1 /* RLE compression */
  375. #define lpzComp 2 /* LZW compression */
  376. #define hufComp 3 /* Huffman compression */
  377.  
  378. /* all other numbers are reserved */
  379.  
  380.  
  381. struct _ARJ_stamp {
  382.    word    time;
  383.    word    date;
  384. }; 
  385.  
  386. struct _ARJ_main {
  387.    word    base_size;
  388.    byte    first_size;
  389.    byte    arc_vers;
  390.    byte    min_vers;
  391.    byte    host_OS;
  392.    byte    arj_flag;
  393.    byte    method;
  394.    byte    type;
  395.    byte    reserved;
  396.    struct  _ARJ_stamp stamp; 
  397. /*   long    stamp; */
  398.    long    c_size;
  399.    long    o_size;
  400.    long    crc;
  401.    word    pos;
  402.    word    mode;
  403.    word    host_data;        /* 34 bytes */
  404. };
  405.  
  406.