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
157 #endif /* SEEK_SET */
168 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
172 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
176 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
180 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
184 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
188 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
192 #define LONG_MIN (LONG_MAX-ULONG_MAX)
196 # define fseeko fseek
199 # define ftello ftell
202 #endif /* HAVE_LIMITS_H */
204 #include "lha_macro.h"
206 struct encode_option {
207 #if defined(__STDC__) || defined(AIX)
209 void (*encode_start) ();
210 void (*encode_end) ();
213 int (*encode_start) ();
214 int (*encode_end) ();
218 struct decode_option {
219 unsigned short (*decode_c) ();
220 unsigned short (*decode_p) ();
221 #if defined(__STDC__) || defined(AIX)
222 void (*decode_start) ();
224 int (*decode_start) ();
228 /* ------------------------------------------------------------------------ */
229 /* LHa File Type Definition */
230 /* ------------------------------------------------------------------------ */
231 typedef int boolean; /* TRUE or FALSE */
240 typedef struct LzHeader {
242 int size_field_length;
243 char method[METHOD_TYPE_STORAGE];
246 unsigned char attribute;
247 unsigned char header_level;
248 char name[FILENAME_LENGTH];
249 char realname[FILENAME_LENGTH];/* real name for symbolic link */
250 unsigned int crc; /* file CRC */
251 boolean has_crc; /* file CRC */
252 unsigned int header_crc; /* header CRC */
253 unsigned char extend_type;
254 unsigned char minor_version;
256 /* extend_type == EXTEND_UNIX and convert from other type. */
257 time_t unix_last_modified_stamp;
258 unsigned short unix_mode;
259 unsigned short unix_uid;
260 unsigned short unix_gid;
276 /* ------------------------------------------------------------------------ */
277 /* Option switch variable */
278 /* ------------------------------------------------------------------------ */
282 #define EXTERN extern
285 /* command line options (common options) */
286 EXTERN boolean quiet;
287 EXTERN boolean text_mode;
288 EXTERN boolean verbose;
289 EXTERN boolean noexec; /* debugging option */
290 EXTERN boolean force;
292 EXTERN boolean delete_after_append;
293 EXTERN int compress_method;
294 EXTERN int header_level;
295 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
297 EXTERN boolean euc_mode;
300 /* list command flags */
301 EXTERN boolean verbose_listing;
303 /* extract/print command flags */
304 EXTERN boolean output_to_stdout;
306 /* add/update/delete command flags */
307 EXTERN boolean new_archive;
308 EXTERN boolean update_if_newer;
309 EXTERN boolean generic_format;
311 EXTERN boolean remove_temporary_at_error;
312 EXTERN boolean recover_archive_when_interrupt;
313 EXTERN boolean remove_extracting_file_when_interrupt;
314 EXTERN boolean get_filename_from_stdin;
315 EXTERN boolean ignore_directory;
316 EXTERN char **exclude_files;
317 EXTERN boolean verify_mode;
320 EXTERN int quiet_mode;
322 EXTERN boolean backup_old_archive;
323 /* ------------------------------------------------------------------------ */
324 /* Globale Variable */
325 /* ------------------------------------------------------------------------ */
326 EXTERN char **cmd_filev;
327 EXTERN int cmd_filec;
329 EXTERN char *archive_name;
330 EXTERN char temporary_name[FILENAME_LENGTH];
331 EXTERN char backup_archive_name[FILENAME_LENGTH];
333 EXTERN char *extract_directory;
334 EXTERN char *reading_filename, *writing_filename;
336 EXTERN int archive_file_mode;
337 EXTERN int archive_file_gid;
339 EXTERN struct interfacing interface;
341 EXTERN int noconvertcase; /* 2000.10.6 */
344 EXTERN int unpackable;
345 EXTERN size_t origsize, compsize;
346 EXTERN unsigned short dicbit;
347 EXTERN unsigned short maxmatch;
348 EXTERN size_t decode_count;
349 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
350 EXTERN unsigned char *text;
353 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
354 EXTERN unsigned short left[], right[];
355 EXTERN unsigned char c_len[], pt_len[];
356 EXTERN unsigned short c_freq[], c_table[], c_code[];
357 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
361 #ifdef NEED_INCREMENTAL_INDICATOR
362 EXTERN size_t indicator_count;
363 EXTERN long indicator_threshold;
367 EXTERN FILE *infile, *outfile;
368 EXTERN unsigned short bitbuf;
371 EXTERN unsigned int crctable[UCHAR_MAX + 1];
375 EXTERN unsigned int n_max;
378 EXTERN int temporary_fd;
380 /* ------------------------------------------------------------------------ */
382 /* ------------------------------------------------------------------------ */
383 #include "prototypes.h"