home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / disk / archive / nspark_1 / nspark-1.7.5 / spark.h < prev    next >
C/C++ Source or Header  |  1994-12-13  |  4KB  |  191 lines

  1. /*
  2.  * defines types used in nspark
  3.  *
  4.  * $Header: spark.h 1.7 94/11/09 $
  5.  * $Log:    spark.h,v $
  6.  * Revision 1.7  94/11/09  10:36:00  auj
  7.  * Added Windows NT support.
  8.  *
  9.  * Revision 1.6  93/04/05  12:34:56  arb
  10.  * Added RISC OS support.
  11.  *
  12.  * Revision 1.5  92/11/04  16:57:32  duplain
  13.  * Completed CT_xxx types.
  14.  * 
  15.  * Revision 1.4  92/10/23  14:06:57  duplain
  16.  * Added test for Sys V.4 when defining Sys V file and path name lengths.
  17.  * 
  18.  * Revision 1.3  92/10/06  12:22:11  duplain
  19.  * Removed "days_since_1900" from struct date.
  20.  * 
  21.  * Revision 1.2  92/09/30  10:28:13  duplain
  22.  * Added W_OPENMODE and R_OPENMODE.
  23.  * 
  24.  * Revision 1.1  92/09/29  18:02:41  duplain
  25.  * Initial revision
  26.  * 
  27.  */
  28.  
  29. #ifndef __SPARK_H
  30. #define __SPARK_H
  31.  
  32. /*
  33.  * globalise system-type defines...
  34.  */
  35. #if defined(BSD42) || defined(BSD43) || defined(BSD44)
  36. #define UNIX
  37. #define BSD
  38. #endif
  39. #if defined(SYSV2) || defined(SYSV3) || defined (SYSV4)
  40. #define UNIX
  41. #define SYSV
  42. #endif
  43. #if defined(RISCOS2) || defined(RISCOS3)
  44. #define RISCOS
  45. #define LITTLE_ENDIAN
  46. #endif
  47. #if defined(MSDOS2) || defined(MSDOS3) || defined(MSDOS4) || defined(MSDOS5) || defined(WINNT)
  48. #define MSDOS
  49. #define LITTLE_ENDIAN
  50. #endif
  51.  
  52. /*
  53.  * "Word" must be a 4-byte type.
  54.  * "Halfword" must be a 2-byte type.
  55.  * "Byte" must be a 1-byte type.
  56.  */
  57. #if defined (MSDOS) && !defined(WINNT)
  58. typedef unsigned long    Word;
  59. typedef    unsigned int    Halfword;
  60. typedef unsigned char    Byte;
  61. #else /* not MSDOS */
  62. typedef unsigned int    Word;
  63. typedef unsigned short    Halfword;
  64. typedef unsigned char    Byte;
  65. #endif /* MSDOS */
  66.  
  67. /*
  68.  * define the path seperator character, and file open mode string.
  69.  */
  70. #if defined(UNIX)
  71. #define PATHSEP    '/'
  72. #define PATHSEPSTR    "/"
  73. #define W_OPENMODE    "w"
  74. #define R_OPENMODE    "r"
  75. #endif
  76. #if defined(RISCOS)
  77. #define PATHSEP    '.'
  78. #define PATHSEPSTR    "."
  79. #define W_OPENMODE    "w"
  80. #define R_OPENMODE    "r"
  81. #endif
  82. #if defined(MSDOS)
  83. #if defined(WINNT)
  84. #define PATHSEP   '/'       /* Win NT uses \ as the seperator, but MSC
  85.                                allows /, so use that as it makes life
  86.                                easier in filename translation. */
  87. #define PATHSEPSTR    "/"
  88. #else
  89. #define PATHSEP    '\\'
  90. #define PATHSEPSTR    "\\"
  91. #endif
  92. #define W_OPENMODE    "wb"
  93. #define R_OPENMODE    "rb"
  94. #endif
  95.  
  96. /*
  97.  * define maximum filename and pathname length
  98.  */
  99. #if defined(BSD) || defined(SYSV4)
  100. #define FILENAMELEN    256
  101. #define PATHNAMELEN    1024
  102. #endif
  103. #if defined(SYSV) && !defined(SYSV4)
  104. #define FILENAMELEN    14
  105. #define PATHNAMELEN    256
  106. #endif
  107. #if defined (RISCOS)
  108. #define FILENAMELEN    10
  109. #define PATHNAMELEN    256
  110. #endif
  111. #if defined (MSDOS)
  112. #if defined (WINNT)
  113. #define FILENAMELEN 256
  114. #define PATHNAMELEN 1024
  115. #else
  116. #define FILENAMELEN    12        /* including dot */
  117. #define PATHNAMELEN    256
  118. #endif
  119. #endif
  120.  
  121. /*
  122.  * stream error enumeration
  123.  */
  124. typedef enum {FNOERR, FEND, FRWERR} Ferror;
  125.  
  126. /*
  127.  * file type
  128.  */
  129. typedef enum {NOEXIST, ISFILE, ISDIR } Ftype;
  130.  
  131. /*
  132.  * un-archiving status
  133.  */
  134. typedef enum {NOERR, RERR, WERR, CRCERR } Status;
  135.  
  136. /*
  137.  * compressed file header
  138.  */
  139. typedef struct {
  140.     Byte comptype;        /* compression type */
  141.     char name[14];        /* name of file */
  142.     Word complen;        /* compressed length */
  143.     Halfword date;        /* file creation date */
  144.     Halfword time;        /* file creation time */
  145.     Halfword crc;        /* Cyclic Redundancy Check */
  146.     Word origlen;        /* original length */
  147.     Word load;        /* load address */
  148.     Word exec;        /* exec address */
  149.     Word attr;        /* file attributes */
  150. } Header;
  151.  
  152. /*
  153.  * universal date structure
  154.  */
  155. typedef struct {
  156.     int second;
  157.     int minute;
  158.     int hour;
  159.     int day;
  160.     int month;
  161.     int year;
  162. } Date;
  163.         
  164. /*
  165.  * compress type (passed to uncompress())
  166.  */
  167. typedef enum { COMPRESS, SQUASH, CRUNCH } CompType;
  168.  
  169. /*
  170.  * compression types
  171.  */
  172. #define CT_NOTCOMP    (Byte)0x01    /* not compressed (old) */
  173. #define CT_NOTCOMP2    (Byte)0x02    /* not compressed (new) */
  174. #define CT_PACK        (Byte)0x03    /* run length */
  175. #define CT_PACKSQUEEZE    (Byte)0x04    /* run length + Huffman squeezing */
  176. #define CT_LZOLD    (Byte)0x05    /* Lempel-Ziv (old) */
  177. #define CT_LZNEW    (Byte)0x06    /* Lempel-Ziv (new) */
  178. #define CT_LZW        (Byte)0x07    /* Lempel-Ziv Welch */
  179. #define CT_CRUNCH    (Byte)0x08    /* Dynamic LZW with adaptive reset */
  180. #define CT_SQUASH    (Byte)0x09    /* PKARC squashing */
  181. #define CT_COMP        (Byte)0x7f    /* UNIX compress */
  182.  
  183. /*
  184.  * other spark defines
  185.  */
  186. #define STARTBYTE    (Byte)0x1a    /* start of archive marker */
  187. #define RUNMARK        (Byte)0x90    /* start of run (pack/unpack) */
  188. #define ARCHPACK    (Byte)0x80    /* bit-7 set in comptype if Archie */
  189.  
  190. #endif /* __SPARK_H */
  191.