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