1 /* ------------------------------------------------------------------------ */
2 /* LHa for UNIX Archiver Driver */
4 /* Modified Nobutaka Watazaki */
6 /* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */
7 /* Ver. 1.14i Modified and bug fixed 2000.10.06 t.okamoto */
8 /* ------------------------------------------------------------------------ */
11 lharc.h interface.h slidehuf.h
21 #include <sys/types.h>
27 # include <inttypes.h>
39 # define strrchr rindex
41 char *strchr (), *strrchr ();
43 # define memcmp(s1, s2, n) bcmp ((s1), (s2), (n))
44 # define memcpy(d, s, n) bcopy ((s), (d), (n))
45 # define memmove(d, s, n) bcopy ((s), (d), (n))
50 #define strucmp(p,q) strcasecmp((p),(q))
63 #define NULL ((char *)0)
72 # define va_init(a,b) va_start(a,b)
75 # define va_init(a,b) va_start(a)
93 # define HAVE_UINT64_T 1
95 typedef unsigned long uint64_t;
97 typedef unsigned long long uint64_t;
103 #if TIME_WITH_SYS_TIME
104 # include <sys/time.h>
108 # include <sys/time.h>
121 int utime(const char *, struct utimbuf *);
126 # define NAMLEN(dirent) strlen((dirent)->d_name)
128 # define dirent direct
129 # define NAMLEN(dirent) (dirent)->d_namlen
131 # include <sys/ndir.h>
134 # include <sys/dir.h>
139 # ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */
148 #endif /* SEEK_SET */
159 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
163 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
167 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
171 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
175 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
179 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
183 #define LONG_MIN (LONG_MAX-ULONG_MAX)
186 #endif /* HAVE_LIMITS_H */
188 #include "lha_macro.h"
190 struct encode_option {
191 #if defined(__STDC__) || defined(AIX)
193 void (*encode_start) ();
194 void (*encode_end) ();
197 int (*encode_start) ();
198 int (*encode_end) ();
202 struct decode_option {
203 unsigned short (*decode_c) ();
204 unsigned short (*decode_p) ();
205 #if defined(__STDC__) || defined(AIX)
206 void (*decode_start) ();
208 int (*decode_start) ();
212 /* ------------------------------------------------------------------------ */
213 /* LHa File Type Definition */
214 /* ------------------------------------------------------------------------ */
215 typedef int boolean; /* TRUE or FALSE */
224 typedef struct LzHeader {
226 int size_field_length;
227 char method[METHOD_TYPE_STORAGE];
230 unsigned char attribute;
231 unsigned char header_level;
232 char name[FILENAME_LENGTH];
233 char realname[FILENAME_LENGTH];/* real name for symbolic link */
234 unsigned int crc; /* file CRC */
235 boolean has_crc; /* file CRC */
236 unsigned int header_crc; /* header CRC */
237 unsigned char extend_type;
238 unsigned char minor_version;
240 /* extend_type == EXTEND_UNIX and convert from other type. */
241 time_t unix_last_modified_stamp;
242 unsigned short unix_mode;
243 unsigned short unix_uid;
244 unsigned short unix_gid;
252 unsigned long original;
253 unsigned long packed;
259 /* ------------------------------------------------------------------------ */
260 /* Option switch variable */
261 /* ------------------------------------------------------------------------ */
265 #define EXTERN extern
268 /* command line options (common options) */
269 EXTERN boolean quiet;
270 EXTERN boolean text_mode;
271 EXTERN boolean verbose;
272 EXTERN boolean noexec; /* debugging option */
273 EXTERN boolean force;
275 EXTERN boolean delete_after_append;
276 EXTERN int compress_method;
277 EXTERN int header_level;
278 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
280 EXTERN boolean euc_mode;
283 /* list command flags */
284 EXTERN boolean verbose_listing;
286 /* extract/print command flags */
287 EXTERN boolean output_to_stdout;
289 /* add/update/delete command flags */
290 EXTERN boolean new_archive;
291 EXTERN boolean update_if_newer;
292 EXTERN boolean generic_format;
294 EXTERN boolean remove_temporary_at_error;
295 EXTERN boolean recover_archive_when_interrupt;
296 EXTERN boolean remove_extracting_file_when_interrupt;
297 EXTERN boolean get_filename_from_stdin;
298 EXTERN boolean ignore_directory;
299 EXTERN boolean verify_mode;
302 EXTERN int quiet_mode;
304 EXTERN boolean backup_old_archive;
305 /* ------------------------------------------------------------------------ */
306 /* Globale Variable */
307 /* ------------------------------------------------------------------------ */
308 EXTERN char **cmd_filev;
309 EXTERN int cmd_filec;
311 EXTERN char *archive_name;
312 EXTERN char temporary_name[FILENAME_LENGTH];
313 EXTERN char backup_archive_name[FILENAME_LENGTH];
315 EXTERN char *extract_directory;
316 EXTERN char *reading_filename, *writing_filename;
318 EXTERN int archive_file_mode;
319 EXTERN int archive_file_gid;
321 EXTERN struct interfacing interface;
323 EXTERN int noconvertcase; /* 2000.10.6 */
326 EXTERN int unpackable;
327 EXTERN unsigned long origsize, compsize;
328 EXTERN unsigned short dicbit;
329 EXTERN unsigned short maxmatch;
330 EXTERN unsigned long count;
331 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
332 EXTERN unsigned char *text;
333 EXTERN int prev_char;
336 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
337 EXTERN unsigned short left[], right[];
338 EXTERN unsigned char c_len[], pt_len[];
339 EXTERN unsigned short c_freq[], c_table[], c_code[];
340 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
344 #ifdef NEED_INCREMENTAL_INDICATOR
345 EXTERN long indicator_count;
346 EXTERN long indicator_threshold;
350 EXTERN FILE *infile, *outfile;
351 EXTERN unsigned short bitbuf;
352 EXTERN unsigned int crctable[UCHAR_MAX + 1];
356 EXTERN unsigned int n_max;
359 EXTERN int temporary_fd;
361 /* ------------------------------------------------------------------------ */
363 /* ------------------------------------------------------------------------ */
364 #include "prototypes.h"
366 /* Local Variables: */
370 /* vi: set tabstop=4: */