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>
31 # define strrchr rindex
33 char *strchr (), *strrchr ();
35 # define memcmp(s1, s2, n) bcmp ((s1), (s2), (n))
36 # define memcpy(d, s, n) bcopy ((s), (d), (n))
37 # define memmove(d, s, n) bcopy ((s), (d), (n))
42 #define strucmp(p,q) strcasecmp((p),(q))
55 #define NULL ((char *)0)
64 # define va_init(a,b) va_start(a,b)
67 # define va_init(a,b) va_start(a)
84 #if TIME_WITH_SYS_TIME
85 # include <sys/time.h>
89 # include <sys/time.h>
101 # define NAMLEN(dirent) strlen((dirent)->d_name)
103 # define dirent direct
104 # define NAMLEN(dirent) (dirent)->d_namlen
106 # include <sys/ndir.h>
109 # include <sys/dir.h>
114 # ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */
119 #ifdef __APPLE__ /* On MacOS X, use CoreFoundation for utf8 conversion */
120 #include <CoreFoundation/CFString.h>
121 #include <CoreFoundation/CFStringEncodingExt.h>
122 #endif /* __APPLE__ */
128 #endif /* SEEK_SET */
139 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
143 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
147 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
151 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
155 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
159 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
163 #define LONG_MIN (LONG_MAX-ULONG_MAX)
166 #endif /* HAVE_LIMITS_H */
168 #include "lha_macro.h"
170 struct encode_option {
171 #if defined(__STDC__) || defined(AIX)
173 void (*encode_start) ();
174 void (*encode_end) ();
177 int (*encode_start) ();
178 int (*encode_end) ();
182 struct decode_option {
183 unsigned short (*decode_c) ();
184 unsigned short (*decode_p) ();
185 #if defined(__STDC__) || defined(AIX)
186 void (*decode_start) ();
188 int (*decode_start) ();
192 /* ------------------------------------------------------------------------ */
193 /* LHa File Type Definition */
194 /* ------------------------------------------------------------------------ */
195 typedef int boolean; /* TRUE or FALSE */
204 typedef struct LzHeader {
205 unsigned char header_size;
206 char method[METHOD_TYPE_STRAGE];
209 long last_modified_stamp;
210 unsigned char attribute;
211 unsigned char header_level;
215 unsigned char extend_type;
216 unsigned char minor_version;
218 /* extend_type == EXTEND_UNIX and convert from other type. */
219 time_t unix_last_modified_stamp;
220 unsigned short unix_mode;
221 unsigned short unix_uid;
222 unsigned short unix_gid;
230 unsigned long original;
231 unsigned long packed;
237 /* ------------------------------------------------------------------------ */
238 /* Option switch variable */
239 /* ------------------------------------------------------------------------ */
240 /* command line options (common options) */
241 EXTERN boolean quiet;
242 EXTERN boolean text_mode;
243 EXTERN boolean verbose;
244 EXTERN boolean noexec; /* debugging option */
245 EXTERN boolean force;
247 EXTERN boolean delete_after_append;
248 EXTERN int compress_method;
249 EXTERN int header_level;
250 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
252 EXTERN boolean euc_mode;
255 /* list command flags */
256 EXTERN boolean verbose_listing;
258 /* extract/print command flags */
259 EXTERN boolean output_to_stdout;
261 /* add/update/delete command flags */
262 EXTERN boolean new_archive;
263 EXTERN boolean update_if_newer;
264 EXTERN boolean generic_format;
266 EXTERN boolean remove_temporary_at_error;
267 EXTERN boolean recover_archive_when_interrupt;
268 EXTERN boolean remove_extracting_file_when_interrupt;
269 EXTERN boolean get_filename_from_stdin;
270 EXTERN boolean ignore_directory;
271 EXTERN boolean verify_mode;
274 EXTERN int quiet_mode;
276 /* ------------------------------------------------------------------------ */
277 /* Globale Variable */
278 /* ------------------------------------------------------------------------ */
279 EXTERN char **cmd_filev;
280 EXTERN int cmd_filec;
282 EXTERN char *archive_name;
283 EXTERN char temporary_name[FILENAME_LENGTH];
284 EXTERN char backup_archive_name[FILENAME_LENGTH];
286 EXTERN char *extract_directory;
287 EXTERN char *reading_filename, *writing_filename;
289 EXTERN int archive_file_mode;
290 EXTERN int archive_file_gid;
292 EXTERN struct interfacing interface;
293 /* EXTERN unsigned short crc; */ /* 1996.8.13 t.okamoto */
295 EXTERN int noconvertcase; /* 2000.10.6 */
298 EXTERN int unpackable;
299 EXTERN unsigned long origsize, compsize;
300 EXTERN unsigned short dicbit;
301 EXTERN unsigned short maxmatch;
302 EXTERN unsigned long count;
303 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
304 EXTERN unsigned char *text;
305 EXTERN int prev_char;
308 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
309 EXTERN unsigned short left[], right[];
310 EXTERN unsigned char c_len[], pt_len[];
311 EXTERN unsigned short c_freq[], c_table[], c_code[];
312 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
316 #ifdef NEED_INCREMENTAL_INDICATOR
317 EXTERN long indicator_count;
318 EXTERN long indicator_threshold;
322 EXTERN FILE *infile, *outfile;
323 EXTERN unsigned short crc, bitbuf;
325 EXTERN long reading_size;
328 EXTERN unsigned int n_max;
331 EXTERN int temporary_fd;
333 /* ------------------------------------------------------------------------ */
335 /* ------------------------------------------------------------------------ */
336 #include "prototypes.h"
338 /* Local Variables: */
342 /* vi: set tabstop=4: */