1 /* ------------------------------------------------------------------------ */
2 /* LHa for UNIX Archiver Driver macro define */
4 /* Modified Nobutaka Watazaki */
6 /* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */
7 /* Ver. 1.14g modified 2000.05.06 T.OKAMOTO */
8 /* ------------------------------------------------------------------------ */
13 #define FILENAME_LENGTH 1024
15 #if defined __MINGW32__
17 # define chown(file, uid, gid) 0
18 # define kill(pid, sig) 0
21 /* ------------------------------------------------------------------------ */
22 /* YOUR CUSTOMIZIES */
23 /* ------------------------------------------------------------------------ */
25 #ifndef ARCHIVENAME_EXTENTION
26 #define ARCHIVENAME_EXTENTION ".lzh"
28 #ifndef BACKUPNAME_EXTENTION
29 #define BACKUPNAME_EXTENTION ".bak"
32 #define SJIS_FIRST_P(c) \
33 (((unsigned char)(c) >= 0x80 && (unsigned char)(c) < 0xa0) || \
34 ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) < 0xfd))
35 #define SJIS_SECOND_P(c) \
36 (((unsigned char)(c) >= 0x40 && (unsigned char)(c) < 0xfd) && \
37 (unsigned char)(c) != 0x7f)
39 #define X0201_KANA_P(c)\
40 (0xa0 < (unsigned char)(c) && (unsigned char)(c) < 0xe0)
42 /* for filename conversion */
50 /* ------------------------------------------------------------------------ */
51 /* LHa File Definitions */
52 /* ------------------------------------------------------------------------ */
59 #define LZHUFF0_METHOD "-lh0-"
60 #define LZHUFF1_METHOD "-lh1-"
61 #define LZHUFF2_METHOD "-lh2-"
62 #define LZHUFF3_METHOD "-lh3-"
63 #define LZHUFF4_METHOD "-lh4-"
64 #define LZHUFF5_METHOD "-lh5-"
65 #define LZHUFF6_METHOD "-lh6-"
66 #define LZHUFF7_METHOD "-lh7-"
67 #define LARC_METHOD "-lzs-"
68 #define LARC5_METHOD "-lz5-"
69 #define LARC4_METHOD "-lz4-"
70 #define LZHDIRS_METHOD "-lhd-"
72 #define METHOD_TYPE_STORAGE 5
74 /* Added N.Watazaki ..V */
75 #define LZHUFF0_METHOD_NUM 0
76 #define LZHUFF1_METHOD_NUM 1
77 #define LZHUFF2_METHOD_NUM 2
78 #define LZHUFF3_METHOD_NUM 3
79 #define LZHUFF4_METHOD_NUM 4
80 #define LZHUFF5_METHOD_NUM 5
81 #define LZHUFF6_METHOD_NUM 6
82 #define LZHUFF7_METHOD_NUM 7
83 #define LARC_METHOD_NUM 8
84 #define LARC5_METHOD_NUM 9
85 #define LARC4_METHOD_NUM 10
86 #define LZHDIRS_METHOD_NUM 11
87 /* Added N.Watazaki ..^ */
89 #define LZHUFF0_DICBIT 0 /* no compress */
90 #define LZHUFF1_DICBIT 12 /* 2^12 = 4k sliding dictionary */
91 #define LZHUFF2_DICBIT 13 /* 2^13 = 8k sliding dictionary */
92 #define LZHUFF3_DICBIT 13 /* 2^13 = 8k sliding dictionary */
93 #define LZHUFF4_DICBIT 12 /* 2^12 = 4k sliding dictionary */
94 #define LZHUFF5_DICBIT 13 /* 2^13 = 8k sliding dictionary */
95 #define LZHUFF6_DICBIT 15 /* 2^15 = 32k sliding dictionary */
96 #define LZHUFF7_DICBIT 16 /* 2^16 = 64k sliding dictionary */
97 #define LARC_DICBIT 11 /* 2^11 = 2k sliding dictionary */
98 #define LARC5_DICBIT 12 /* 2^12 = 4k sliding dictionary */
99 #define LARC4_DICBIT 0 /* no compress */
101 #define EXTEND_GENERIC 0
102 #define EXTEND_UNIX 'U'
103 #define EXTEND_MSDOS 'M'
104 #define EXTEND_MACOS 'm'
105 #define EXTEND_OS9 '9'
106 #define EXTEND_OS2 '2'
107 #define EXTEND_OS68K 'K'
108 #define EXTEND_OS386 '3' /* OS-9000??? */
109 #define EXTEND_HUMAN 'H'
110 #define EXTEND_CPM 'C'
111 #define EXTEND_FLEX 'F'
112 #define EXTEND_RUNSER 'R'
114 /* this OS type is not official */
116 #define EXTEND_TOWNSOS 'T'
117 #define EXTEND_XOSK 'X' /* OS-9 for X68000 (?) */
118 #define EXTEND_JAVA 'J'
120 /*---------------------------------------------------------------------------*/
122 #define GENERIC_ATTRIBUTE 0x20
123 #define GENERIC_DIRECTORY_ATTRIBUTE 0x10
124 #define HEADER_LEVEL0 0x00
125 #define HEADER_LEVEL1 0x01
126 #define HEADER_LEVEL2 0x02
128 #define CURRENT_UNIX_MINOR_VERSION 0x00
130 #define LHA_PATHSEP 0xff /* path separator of the
131 filename in lha header.
132 it should compare with
133 `unsigned char' or `int',
134 that is not '\xff', but 0xff. */
136 #define OSK_RW_RW_RW 0000033
137 #define OSK_FILE_REGULAR 0000000
138 #define OSK_DIRECTORY_PERM 0000200
139 #define OSK_SHARED_PERM 0000100
140 #define OSK_OTHER_EXEC_PERM 0000040
141 #define OSK_OTHER_WRITE_PERM 0000020
142 #define OSK_OTHER_READ_PERM 0000010
143 #define OSK_OWNER_EXEC_PERM 0000004
144 #define OSK_OWNER_WRITE_PERM 0000002
145 #define OSK_OWNER_READ_PERM 0000001
147 #define UNIX_FILE_TYPEMASK 0170000
148 #define UNIX_FILE_REGULAR 0100000
149 #define UNIX_FILE_DIRECTORY 0040000
150 #define UNIX_FILE_SYMLINK 0120000
151 #define UNIX_SETUID 0004000
152 #define UNIX_SETGID 0002000
153 #define UNIX_STICKYBIT 0001000
154 #define UNIX_OWNER_READ_PERM 0000400
155 #define UNIX_OWNER_WRITE_PERM 0000200
156 #define UNIX_OWNER_EXEC_PERM 0000100
157 #define UNIX_GROUP_READ_PERM 0000040
158 #define UNIX_GROUP_WRITE_PERM 0000020
159 #define UNIX_GROUP_EXEC_PERM 0000010
160 #define UNIX_OTHER_READ_PERM 0000004
161 #define UNIX_OTHER_WRITE_PERM 0000002
162 #define UNIX_OTHER_EXEC_PERM 0000001
163 #define UNIX_RW_RW_RW 0000666
165 #define LZHEADER_STORAGE 4096
167 #define MAX_INDICATOR_COUNT 64
169 /* ------------------------------------------------------------------------ */
171 /* ------------------------------------------------------------------------ */
172 #define is_directory(statp) (((statp)->st_mode & S_IFMT) == S_IFDIR)
173 #define is_symlink(statp) (((statp)->st_mode & S_IFMT) == S_IFLNK)
174 #define is_regularfile(statp) (((statp)->st_mode & S_IFMT) == S_IFREG)
176 #if 1 /* assume that fopen() will accepts "b" as binary mode on all system. */
177 #define WRITE_BINARY "wb"
178 #define READ_BINARY "rb"
180 #define WRITE_BINARY "w"
181 #define READ_BINARY "r"
184 /* ------------------------------------------------------------------------ */
185 /* Individual macro define */
186 /* ------------------------------------------------------------------------ */
189 #define CRCPOLY 0xA001 /* CRC-16 (x^16+x^15+x^2+1) */
190 #define INITIALIZE_CRC(crc) ((crc) = 0)
191 #define UPDATE_CRC(crc, c) \
192 (crctable[((crc) ^ (c)) & 0xFF] ^ ((crc) >> CHAR_BIT))
195 #define N_CHAR (256 + 60 - THRESHOLD + 1)
196 #define TREESIZE_C (N_CHAR * 2)
197 #define TREESIZE_P (128 * 2)
198 #define TREESIZE (TREESIZE_C + TREESIZE_P)
200 #define ROOT_P TREESIZE_C
203 #define NP (MAX_DICBIT + 1)
204 #define NT (USHRT_BIT + 3)
206 #define PBIT 4 /* smallest integer such that (1 << PBIT) > * NP */
207 #define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */
210 #define PBIT 5 /* smallest integer such that (1 << PBIT) > * NP */
211 #define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */
213 #define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
215 /* #if NT > NP #define NPT NT #else #define NPT NP #endif */
223 #define CMD_UNKNOWN 0
224 #define CMD_EXTRACT 1
229 #define STREQU(a,b) (((a)[0] == (b)[0]) ? (strcmp ((a),(b)) == 0) : FALSE)
232 #define N1 286 /* alphabet size */
233 #define N2 (2 * N1 - 1) /* # of nodes in Huffman tree */
234 #define EXTRABITS 8 /* >= log2(F-THRESHOLD+258-N1) */
235 #define BUFBITS 16 /* >= log2(MAXBUF) */
236 #define LENFIELD 4 /* bit size of length field for tree output */
239 #define BUFFERSIZE 2048
245 #define HASH(p, c) ((p) + ((c) << hash1) + hash2)
250 #define MAX_DICBIT LZHUFF7_DICBIT /* lh7 use 16bits */
254 #define MAX_DICBIT LZHUFF6_DICBIT /* lh6 use 15bits */
257 #define MAX_DICSIZ (1 << MAX_DICBIT)
258 #define MATCHBIT 8 /* bits for MAXMATCH - THRESHOLD */
259 #define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */
260 #define THRESHOLD 3 /* choose optimal value */
264 /* alphabet = {0, 1, 2, ..., NC - 1} */
265 #define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */
266 #define USHRT_BIT 16 /* (CHAR_BIT * sizeof(ushort)) */
268 /* Local Variables: */
272 /* vi: set tabstop=4: */