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)
195 #endif /* HAVE_LIMITS_H */
198 # define fseeko fseek
201 # define ftello ftell
204 #include "lha_macro.h"
206 #define exit(n) lha_exit(n)
208 struct encode_option {
209 #if defined(__STDC__) || defined(AIX)
211 void (*encode_start) ();
212 void (*encode_end) ();
215 int (*encode_start) ();
216 int (*encode_end) ();
220 struct decode_option {
221 unsigned short (*decode_c) ();
222 unsigned short (*decode_p) ();
223 #if defined(__STDC__) || defined(AIX)
224 void (*decode_start) ();
226 int (*decode_start) ();
230 /* ------------------------------------------------------------------------ */
231 /* LHa File Type Definition */
232 /* ------------------------------------------------------------------------ */
233 typedef int boolean; /* TRUE or FALSE */
242 typedef struct LzHeader {
244 int size_field_length;
245 char method[METHOD_TYPE_STORAGE];
247 size_t original_size;
248 unsigned char attribute;
249 unsigned char header_level;
250 char name[FILENAME_LENGTH];
251 char realname[FILENAME_LENGTH];/* real name for symbolic link */
252 unsigned int crc; /* file CRC */
253 boolean has_crc; /* file CRC */
254 unsigned int header_crc; /* header CRC */
255 unsigned char extend_type;
256 unsigned char minor_version;
258 /* extend_type == EXTEND_UNIX and convert from other type. */
259 time_t unix_last_modified_stamp;
260 unsigned short unix_mode;
261 unsigned short unix_uid;
262 unsigned short unix_gid;
278 /* ------------------------------------------------------------------------ */
279 /* Option switch variable */
280 /* ------------------------------------------------------------------------ */
284 #define EXTERN extern
287 /* command line options (common options) */
288 EXTERN boolean quiet;
289 EXTERN boolean text_mode;
290 EXTERN boolean verbose;
291 EXTERN boolean noexec; /* debugging option */
292 EXTERN boolean force;
293 EXTERN boolean delete_after_append;
294 EXTERN int compress_method;
295 EXTERN int header_level;
296 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
298 EXTERN boolean euc_mode;
301 /* list command flags */
302 EXTERN boolean verbose_listing;
304 /* extract/print command flags */
305 EXTERN boolean output_to_stdout;
307 /* add/update/delete command flags */
308 EXTERN boolean new_archive;
309 EXTERN boolean update_if_newer;
310 EXTERN boolean generic_format;
312 EXTERN boolean remove_temporary_at_error;
313 EXTERN boolean recover_archive_when_interrupt;
314 EXTERN boolean remove_extracting_file_when_interrupt;
315 EXTERN boolean get_filename_from_stdin;
316 EXTERN boolean ignore_directory;
317 EXTERN char **exclude_files;
318 EXTERN boolean verify_mode;
321 EXTERN int quiet_mode;
323 EXTERN boolean backup_old_archive;
324 /* ------------------------------------------------------------------------ */
325 /* Globale Variable */
326 /* ------------------------------------------------------------------------ */
327 EXTERN char **cmd_filev;
328 EXTERN int cmd_filec;
330 EXTERN char *archive_name;
331 EXTERN char temporary_name[FILENAME_LENGTH];
332 EXTERN char backup_archive_name[FILENAME_LENGTH];
334 EXTERN char *extract_directory;
335 EXTERN char *reading_filename, *writing_filename;
337 EXTERN int archive_file_mode;
338 EXTERN int archive_file_gid;
340 EXTERN int noconvertcase; /* 2000.10.6 */
343 EXTERN int unpackable;
344 EXTERN size_t origsize, compsize;
345 EXTERN unsigned short dicbit;
346 EXTERN unsigned short maxmatch;
347 EXTERN size_t decode_count;
348 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
349 EXTERN unsigned char *text;
352 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
353 EXTERN unsigned short left[], right[];
354 EXTERN unsigned char c_len[], pt_len[];
355 EXTERN unsigned short c_freq[], c_table[], c_code[];
356 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
360 EXTERN FILE *infile, *outfile;
361 EXTERN unsigned short bitbuf;
364 EXTERN unsigned int crctable[UCHAR_MAX + 1];
368 EXTERN unsigned int n_max;
371 EXTERN int temporary_fd;
373 /* ------------------------------------------------------------------------ */
375 /* ------------------------------------------------------------------------ */
376 #include "prototypes.h"