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))
59 #define NULL ((char *)0)
68 # define va_init(a,b) va_start(a,b)
71 # define va_init(a,b) va_start(a)
89 # define HAVE_UINT64_T 1
91 typedef unsigned long uint64_t;
93 typedef unsigned long long uint64_t;
100 typedef long ssize_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 ?? */
145 # include <fnmatch.h>
147 int fnmatch(const char *pattern, const char *string, int flags);
148 # define FNM_PATHNAME 1
149 # define FNM_NOESCAPE 2
150 # define FNM_PERIOD 4
153 #if HAVE_LIBAPPLEFILE
154 #include <applefile.h>
159 #endif /* __DJGPP__ */
165 #endif /* SEEK_SET */
176 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
180 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
184 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
188 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
192 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
196 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
200 #define LONG_MIN (LONG_MAX-ULONG_MAX)
203 #endif /* HAVE_LIMITS_H */
206 # define fseeko fseek
209 # define ftello ftell
212 #include "lha_macro.h"
214 #define exit(n) lha_exit(n)
216 struct encode_option {
217 #if defined(__STDC__) || defined(AIX)
219 void (*encode_start) ();
220 void (*encode_end) ();
223 int (*encode_start) ();
224 int (*encode_end) ();
228 struct decode_option {
229 unsigned short (*decode_c) ();
230 unsigned short (*decode_p) ();
231 #if defined(__STDC__) || defined(AIX)
232 void (*decode_start) ();
234 int (*decode_start) ();
238 /* ------------------------------------------------------------------------ */
239 /* LHa File Type Definition */
240 /* ------------------------------------------------------------------------ */
241 typedef int boolean; /* TRUE or FALSE */
250 typedef struct LzHeader {
252 int size_field_length;
253 char method[METHOD_TYPE_STORAGE];
256 unsigned char attribute;
257 unsigned char header_level;
258 char name[FILENAME_LENGTH];
259 char realname[FILENAME_LENGTH];/* real name for symbolic link */
260 unsigned int crc; /* file CRC */
261 boolean has_crc; /* file CRC */
262 unsigned int header_crc; /* header CRC */
263 unsigned char extend_type;
264 unsigned char minor_version;
266 /* extend_type == EXTEND_UNIX and convert from other type. */
267 time_t unix_last_modified_stamp;
268 unsigned short unix_mode;
269 unsigned short unix_uid;
270 unsigned short unix_gid;
286 /* ------------------------------------------------------------------------ */
287 /* Option switch variable */
288 /* ------------------------------------------------------------------------ */
292 #define EXTERN extern
295 /* command line options (common options) */
296 EXTERN boolean quiet;
297 EXTERN boolean text_mode;
298 EXTERN boolean verbose;
299 EXTERN boolean noexec; /* debugging option */
300 EXTERN boolean force;
301 EXTERN boolean delete_after_append;
302 EXTERN int compress_method;
303 EXTERN int header_level;
304 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
306 EXTERN boolean euc_mode;
309 /* list command flags */
310 EXTERN boolean verbose_listing;
312 /* extract/print command flags */
313 EXTERN boolean output_to_stdout;
315 /* add/update/delete command flags */
316 EXTERN boolean new_archive;
317 EXTERN boolean update_if_newer;
318 EXTERN boolean generic_format;
320 EXTERN boolean remove_temporary_at_error;
321 EXTERN boolean recover_archive_when_interrupt;
322 EXTERN boolean remove_extracting_file_when_interrupt;
323 EXTERN boolean get_filename_from_stdin;
324 EXTERN boolean ignore_directory;
325 EXTERN char **exclude_files;
326 EXTERN boolean verify_mode;
329 EXTERN int quiet_mode;
331 EXTERN boolean backup_old_archive;
332 EXTERN boolean extract_broken_archive;
333 EXTERN boolean decode_macbinary_contents;
335 /* ------------------------------------------------------------------------ */
336 /* Globale Variable */
337 /* ------------------------------------------------------------------------ */
338 EXTERN char **cmd_filev;
339 EXTERN int cmd_filec;
341 EXTERN char *archive_name;
342 EXTERN char temporary_name[FILENAME_LENGTH];
343 EXTERN char backup_archive_name[FILENAME_LENGTH];
345 EXTERN char *extract_directory;
346 EXTERN char *reading_filename, *writing_filename;
348 EXTERN int archive_file_mode;
349 EXTERN int archive_file_gid;
351 EXTERN int convertcase; /* 2000.10.6 */
354 EXTERN int unpackable;
355 EXTERN off_t origsize, compsize;
356 EXTERN unsigned short dicbit;
357 EXTERN unsigned short maxmatch;
358 EXTERN off_t decode_count;
359 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
360 EXTERN unsigned char *text;
363 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
364 EXTERN unsigned short left[], right[];
365 EXTERN unsigned char c_len[], pt_len[];
366 EXTERN unsigned short c_freq[], c_table[], c_code[];
367 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
371 EXTERN FILE *infile, *outfile;
372 EXTERN unsigned short bitbuf;
375 EXTERN unsigned int crctable[UCHAR_MAX + 1];
379 EXTERN unsigned int n_max;
382 EXTERN int temporary_fd;
384 /* ------------------------------------------------------------------------ */
386 /* ------------------------------------------------------------------------ */
387 #include "prototypes.h"