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;
104 typedef long ssize_t;
107 #if TIME_WITH_SYS_TIME
108 # include <sys/time.h>
112 # include <sys/time.h>
125 int utime(const char *, struct utimbuf *);
130 # define NAMLEN(dirent) strlen((dirent)->d_name)
132 # define dirent direct
133 # define NAMLEN(dirent) (dirent)->d_namlen
135 # include <sys/ndir.h>
138 # include <sys/dir.h>
143 # ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */
149 # include <fnmatch.h>
151 int fnmatch(const char *pattern, const char *string, int flags);
152 # define FNM_PATHNAME 1
153 # define FNM_NOESCAPE 2
154 # define FNM_PERIOD 4
161 #endif /* SEEK_SET */
172 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
176 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
180 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
184 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
188 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
192 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
196 #define LONG_MIN (LONG_MAX-ULONG_MAX)
199 #endif /* HAVE_LIMITS_H */
201 #include "lha_macro.h"
203 struct encode_option {
204 #if defined(__STDC__) || defined(AIX)
206 void (*encode_start) ();
207 void (*encode_end) ();
210 int (*encode_start) ();
211 int (*encode_end) ();
215 struct decode_option {
216 unsigned short (*decode_c) ();
217 unsigned short (*decode_p) ();
218 #if defined(__STDC__) || defined(AIX)
219 void (*decode_start) ();
221 int (*decode_start) ();
225 /* ------------------------------------------------------------------------ */
226 /* LHa File Type Definition */
227 /* ------------------------------------------------------------------------ */
228 typedef int boolean; /* TRUE or FALSE */
237 typedef struct LzHeader {
239 int size_field_length;
240 char method[METHOD_TYPE_STORAGE];
243 unsigned char attribute;
244 unsigned char header_level;
245 char name[FILENAME_LENGTH];
246 char realname[FILENAME_LENGTH];/* real name for symbolic link */
247 unsigned int crc; /* file CRC */
248 boolean has_crc; /* file CRC */
249 unsigned int header_crc; /* header CRC */
250 unsigned char extend_type;
251 unsigned char minor_version;
253 /* extend_type == EXTEND_UNIX and convert from other type. */
254 time_t unix_last_modified_stamp;
255 unsigned short unix_mode;
256 unsigned short unix_uid;
257 unsigned short unix_gid;
265 unsigned long original;
266 unsigned long packed;
272 /* ------------------------------------------------------------------------ */
273 /* Option switch variable */
274 /* ------------------------------------------------------------------------ */
278 #define EXTERN extern
281 /* command line options (common options) */
282 EXTERN boolean quiet;
283 EXTERN boolean text_mode;
284 EXTERN boolean verbose;
285 EXTERN boolean noexec; /* debugging option */
286 EXTERN boolean force;
288 EXTERN boolean delete_after_append;
289 EXTERN int compress_method;
290 EXTERN int header_level;
291 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
293 EXTERN boolean euc_mode;
296 /* list command flags */
297 EXTERN boolean verbose_listing;
299 /* extract/print command flags */
300 EXTERN boolean output_to_stdout;
302 /* add/update/delete command flags */
303 EXTERN boolean new_archive;
304 EXTERN boolean update_if_newer;
305 EXTERN boolean generic_format;
307 EXTERN boolean remove_temporary_at_error;
308 EXTERN boolean recover_archive_when_interrupt;
309 EXTERN boolean remove_extracting_file_when_interrupt;
310 EXTERN boolean get_filename_from_stdin;
311 EXTERN boolean ignore_directory;
312 EXTERN char **exclude_files;
313 EXTERN boolean verify_mode;
316 EXTERN int quiet_mode;
318 EXTERN boolean backup_old_archive;
319 /* ------------------------------------------------------------------------ */
320 /* Globale Variable */
321 /* ------------------------------------------------------------------------ */
322 EXTERN char **cmd_filev;
323 EXTERN int cmd_filec;
325 EXTERN char *archive_name;
326 EXTERN char temporary_name[FILENAME_LENGTH];
327 EXTERN char backup_archive_name[FILENAME_LENGTH];
329 EXTERN char *extract_directory;
330 EXTERN char *reading_filename, *writing_filename;
332 EXTERN int archive_file_mode;
333 EXTERN int archive_file_gid;
335 EXTERN struct interfacing interface;
337 EXTERN int noconvertcase; /* 2000.10.6 */
340 EXTERN int unpackable;
341 EXTERN unsigned long origsize, compsize;
342 EXTERN unsigned short dicbit;
343 EXTERN unsigned short maxmatch;
344 EXTERN unsigned long decode_count;
345 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
346 EXTERN unsigned char *text;
347 EXTERN int prev_char;
350 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
351 EXTERN unsigned short left[], right[];
352 EXTERN unsigned char c_len[], pt_len[];
353 EXTERN unsigned short c_freq[], c_table[], c_code[];
354 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
358 #ifdef NEED_INCREMENTAL_INDICATOR
359 EXTERN long indicator_count;
360 EXTERN long indicator_threshold;
364 EXTERN FILE *infile, *outfile;
365 EXTERN unsigned short bitbuf;
368 EXTERN unsigned int crctable[UCHAR_MAX + 1];
372 EXTERN unsigned int n_max;
375 EXTERN int temporary_fd;
377 /* ------------------------------------------------------------------------ */
379 /* ------------------------------------------------------------------------ */
380 #include "prototypes.h"