OSDN Git Service

* src/lha.h, src/header.c: CoreFoundation header inclusion moved to
[lha/lha.git] / src / lha.h
1 /* ------------------------------------------------------------------------ */
2 /* LHa for UNIX    Archiver Driver                                                                                      */
3 /*                                                                                                                                                      */
4 /*              Modified                        Nobutaka Watazaki                                                       */
5 /*                                                                                                                                                      */
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 /* ------------------------------------------------------------------------ */
9 /*
10         Included...
11                 lharc.h         interface.h             slidehuf.h
12 */
13
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
17
18 #include <stdio.h>
19 #include <errno.h>
20 #include <ctype.h>
21 #include <sys/types.h>
22 #include <sys/file.h>
23 #include <sys/stat.h>
24 #include <signal.h>
25
26 #if STDC_HEADERS
27 # include <string.h>
28 #else
29 # if !HAVE_STRCHR
30 #  define strchr index
31 #  define strrchr rindex
32 # endif
33 char *strchr (), *strrchr ();
34 # if !HAVE_MEMCPY
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))
38 # endif
39 #endif
40
41 #if HAVE_STRCASECMP
42 #define strucmp(p,q)    strcasecmp((p),(q))
43 #endif
44
45 #if STDC_HEADERS
46 # include <stdlib.h>
47 # include <stddef.h>
48 #else
49 # if HAVE_STDLIB_H
50 #  include <stdlib.h>
51 # endif
52 #endif
53
54 #ifndef NULL
55 #define NULL ((char *)0)
56 #endif
57
58 #if HAVE_UNISTD_H
59 #include <unistd.h>
60 #endif
61
62 #if STDC_HEADERS
63 # include <stdarg.h>
64 # define va_init(a,b) va_start(a,b)
65 #else
66 # include <varargs.h>
67 # define va_init(a,b) va_start(a)
68 #endif
69
70 #if HAVE_PWD_H
71 # include <pwd.h>
72 #endif
73 #if HAVE_GRP_H
74 # include <grp.h>
75 #endif
76
77 #if !HAVE_UID_T
78 typedef int uid_t;
79 #endif
80 #if !HAVE_GID_T
81 typedef int gid_t;
82 #endif
83
84 #if TIME_WITH_SYS_TIME
85 # include <sys/time.h>
86 # include <time.h>
87 #else
88 # if HAVE_SYS_TIME_H
89 #  include <sys/time.h>
90 # else
91 #  include <time.h>
92 # endif
93 #endif
94
95 #if HAVE_UTIME_H
96 #include <utime.h>
97 #endif
98
99 #if HAVE_DIRENT_H
100 # include <dirent.h>
101 # define NAMLEN(dirent) strlen((dirent)->d_name)
102 #else
103 # define dirent direct
104 # define NAMLEN(dirent) (dirent)->d_namlen
105 # if HAVE_SYS_NDIR_H
106 #  include <sys/ndir.h>
107 # endif
108 # if HAVE_SYS_DIR_H
109 #  include <sys/dir.h>
110 # endif
111 # if HAVE_NDIR_H
112 #  include <ndir.h>
113 # endif
114 # ifdef NONSYSTEM_DIR_LIBRARY                   /* no use ?? */
115 #  include "lhdir.h"
116 # endif
117 #endif
118
119 #ifndef SEEK_SET
120 #define SEEK_SET                0
121 #define SEEK_CUR                1
122 #define SEEK_END                2
123 #endif  /* SEEK_SET */
124
125 #if HAVE_LIMITS_H
126 #include <limits.h>
127 #else
128
129 #ifndef CHAR_BIT
130 #define CHAR_BIT 8
131 #endif
132
133 #ifndef UCHAR_MAX
134 #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
135 #endif
136
137 #ifndef USHRT_MAX
138 #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
139 #endif
140
141 #ifndef SHRT_MAX
142 #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
143 #endif
144
145 #ifndef SHRT_MIN
146 #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
147 #endif
148
149 #ifndef ULONG_MAX
150 #define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1)
151 #endif
152
153 #ifndef LONG_MAX
154 #define LONG_MAX ((1<<(sizeof(long)*8-1))-1)
155 #endif
156
157 #ifndef LONG_MIN
158 #define LONG_MIN (LONG_MAX-ULONG_MAX)
159 #endif
160
161 #endif /* HAVE_LIMITS_H */
162
163 #include "lha_macro.h"
164
165 struct encode_option {
166 #if defined(__STDC__) || defined(AIX)
167         void            (*output) ();
168         void            (*encode_start) ();
169         void            (*encode_end) ();
170 #else
171         int             (*output) ();
172         int             (*encode_start) ();
173         int             (*encode_end) ();
174 #endif
175 };
176
177 struct decode_option {
178         unsigned short  (*decode_c) ();
179         unsigned short  (*decode_p) ();
180 #if defined(__STDC__) || defined(AIX)
181         void            (*decode_start) ();
182 #else
183         int             (*decode_start) ();
184 #endif
185 };
186
187 /* ------------------------------------------------------------------------ */
188 /*      LHa File Type Definition                                                                                                */
189 /* ------------------------------------------------------------------------ */
190 typedef int boolean;            /* TRUE or FALSE */
191
192 struct string_pool {
193         int             used;
194         int             size;
195         int             n;
196         char           *buffer;
197 };
198
199 typedef struct LzHeader {
200         unsigned char   header_size;
201         char            method[METHOD_TYPE_STRAGE];
202         long            packed_size;
203         long            original_size;
204         long            last_modified_stamp;
205         unsigned char   attribute;
206         unsigned char   header_level;
207         char            name[256];
208         unsigned short  crc;
209         boolean         has_crc;
210         unsigned char   extend_type;
211         unsigned char   minor_version;
212
213         /* extend_type == EXTEND_UNIX  and convert from other type. */
214         time_t          unix_last_modified_stamp;
215         unsigned short  unix_mode;
216         unsigned short  unix_uid;
217         unsigned short  unix_gid;
218     char            user[256];
219     char            group[256];
220 }  LzHeader;
221
222 struct interfacing {
223         FILE                    *infile;
224         FILE                    *outfile;
225         unsigned long   original;
226         unsigned long   packed;
227         int             dicbit;
228         int             method;
229 };
230
231
232 /* ------------------------------------------------------------------------ */
233 /*      Option switch variable                                                                                                  */
234 /* ------------------------------------------------------------------------ */
235 /* command line options (common options) */
236 EXTERN boolean  quiet;
237 EXTERN boolean  text_mode;
238 EXTERN boolean  verbose;
239 EXTERN boolean  noexec;         /* debugging option */
240 EXTERN boolean  force;
241 EXTERN boolean  prof;
242 EXTERN boolean  delete_after_append;
243 EXTERN int              compress_method;
244 EXTERN int              header_level;
245 /* EXTERN int           quiet_mode; */   /* 1996.8.13 t.okamoto */
246 #ifdef EUC
247 EXTERN boolean  euc_mode;
248 #endif
249
250 /* list command flags */
251 EXTERN boolean  verbose_listing;
252
253 /* extract/print command flags */
254 EXTERN boolean  output_to_stdout;
255
256 /* add/update/delete command flags */
257 EXTERN boolean  new_archive;
258 EXTERN boolean  update_if_newer;
259 EXTERN boolean  generic_format;
260
261 EXTERN boolean  remove_temporary_at_error;
262 EXTERN boolean  recover_archive_when_interrupt;
263 EXTERN boolean  remove_extracting_file_when_interrupt;
264 EXTERN boolean  get_filename_from_stdin;
265 EXTERN boolean  ignore_directory;
266 EXTERN boolean  verify_mode;
267
268 /* Indicator flag */
269 EXTERN int              quiet_mode;
270
271 /* ------------------------------------------------------------------------ */
272 /*      Globale Variable                                                                                                                */
273 /* ------------------------------------------------------------------------ */
274 EXTERN char             **cmd_filev;
275 EXTERN int      cmd_filec;
276
277 EXTERN char             *archive_name;
278 EXTERN char     temporary_name[FILENAME_LENGTH];
279 EXTERN char     backup_archive_name[FILENAME_LENGTH];
280
281 EXTERN char             *extract_directory;
282 EXTERN char             *reading_filename, *writing_filename;
283
284 EXTERN int      archive_file_mode;
285 EXTERN int      archive_file_gid;
286
287 EXTERN struct   interfacing interface;
288 /* EXTERN unsigned short crc; */  /* 1996.8.13 t.okamoto */
289
290 EXTERN int      noconvertcase; /* 2000.10.6 */
291
292 /* slide.c */
293 EXTERN int      unpackable;
294 EXTERN unsigned long origsize, compsize;
295 EXTERN unsigned short dicbit;
296 EXTERN unsigned short maxmatch;
297 EXTERN unsigned long count;
298 EXTERN unsigned long loc;                       /* short -> long .. Changed N.Watazaki */
299 EXTERN unsigned char *text;
300 EXTERN int              prev_char;
301
302 /* huf.c */
303 #ifndef LHA_MAIN_SRC  /* t.okamoto 96/2/20 */
304 EXTERN unsigned short left[], right[];
305 EXTERN unsigned char c_len[], pt_len[];
306 EXTERN unsigned short c_freq[], c_table[], c_code[];
307 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
308 #endif
309
310 /* append.c */
311 #ifdef NEED_INCREMENTAL_INDICATOR
312 EXTERN long             indicator_count;
313 EXTERN long             indicator_threshold;
314 #endif
315
316 /* crcio.c */
317 EXTERN FILE             *infile, *outfile;
318 EXTERN unsigned short crc, bitbuf;
319 EXTERN int      dispflg;
320 EXTERN long             reading_size;
321
322 /* from dhuf.c */
323 EXTERN unsigned int n_max;
324
325 /* lhadd.c */
326 EXTERN int temporary_fd;
327
328 /* ------------------------------------------------------------------------ */
329 /*      Functions                                                                                                                               */
330 /* ------------------------------------------------------------------------ */
331 #include "prototypes.h"
332
333 /* Local Variables: */
334 /* mode:c */
335 /* tab-width:4 */
336 /* End: */
337 /* vi: set tabstop=4: */