OSDN Git Service

82b6e404934dd468caca36782c7cd7c8b43f975a
[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 <stdarg.h>
28 # define va_init(a,b) va_start(a,b)
29 #else
30 # include <varargs.h>
31 # define va_init(a,b) va_start(a)
32 #endif
33
34 #if HAVE_PWD_H
35 # include <pwd.h>
36 #endif
37 #if HAVE_GRP_H
38 # include <grp.h>
39 #endif
40
41 #if !HAVE_UID_T
42 typedef int uid_t;
43 #endif
44 #if !HAVE_GID_T
45 typedef int gid_t;
46 #endif
47
48 #include "lha_macro.h"
49
50 struct encode_option {
51 #if defined(__STDC__) || defined(AIX)
52         void            (*output) ();
53         void            (*encode_start) ();
54         void            (*encode_end) ();
55 #else
56         int             (*output) ();
57         int             (*encode_start) ();
58         int             (*encode_end) ();
59 #endif
60 };
61
62 struct decode_option {
63         unsigned short  (*decode_c) ();
64         unsigned short  (*decode_p) ();
65 #if defined(__STDC__) || defined(AIX)
66         void            (*decode_start) ();
67 #else
68         int             (*decode_start) ();
69 #endif
70 };
71
72 /* ------------------------------------------------------------------------ */
73 /*      LHa File Type Definition                                                                                                */
74 /* ------------------------------------------------------------------------ */
75 struct string_pool {
76         int             used;
77         int             size;
78         int             n;
79         char           *buffer;
80 };
81
82 typedef struct LzHeader {
83         unsigned char   header_size;
84         char            method[METHOD_TYPE_STRAGE];
85         long            packed_size;
86         long            original_size;
87         long            last_modified_stamp;
88         unsigned char   attribute;
89         unsigned char   header_level;
90         char            name[256];
91         unsigned short  crc;
92         boolean         has_crc;
93         unsigned char   extend_type;
94         unsigned char   minor_version;
95
96         /* extend_type == EXTEND_UNIX  and convert from other type. */
97         time_t          unix_last_modified_stamp;
98         unsigned short  unix_mode;
99         unsigned short  unix_uid;
100         unsigned short  unix_gid;
101     char            user[256];
102     char            group[256];
103 }  LzHeader;
104
105 struct interfacing {
106         FILE                    *infile;
107         FILE                    *outfile;
108         unsigned long   original;
109         unsigned long   packed;
110         int             dicbit;
111         int             method;
112 };
113
114
115 /* ------------------------------------------------------------------------ */
116 /*      Option switch variable                                                                                                  */
117 /* ------------------------------------------------------------------------ */
118 /* command line options (common options) */
119 EXTERN boolean  quiet;
120 EXTERN boolean  text_mode;
121 EXTERN boolean  verbose;
122 EXTERN boolean  noexec;         /* debugging option */
123 EXTERN boolean  force;
124 EXTERN boolean  prof;
125 EXTERN boolean  delete_after_append;
126 EXTERN int              compress_method;
127 EXTERN int              header_level;
128 /* EXTERN int           quiet_mode; */   /* 1996.8.13 t.okamoto */
129 #ifdef EUC
130 EXTERN boolean  euc_mode;
131 #endif
132
133 /* list command flags */
134 EXTERN boolean  verbose_listing;
135
136 /* extract/print command flags */
137 EXTERN boolean  output_to_stdout;
138
139 /* add/update/delete command flags */
140 EXTERN boolean  new_archive;
141 EXTERN boolean  update_if_newer;
142 EXTERN boolean  generic_format;
143
144 EXTERN boolean  remove_temporary_at_error;
145 EXTERN boolean  recover_archive_when_interrupt;
146 EXTERN boolean  remove_extracting_file_when_interrupt;
147 EXTERN boolean  get_filename_from_stdin;
148 EXTERN boolean  ignore_directory;
149 EXTERN boolean  verify_mode;
150
151 /* Indicator flag */
152 EXTERN int              quiet_mode;
153
154 /* ------------------------------------------------------------------------ */
155 /*      Globale Variable                                                                                                                */
156 /* ------------------------------------------------------------------------ */
157 EXTERN char             **cmd_filev;
158 EXTERN int      cmd_filec;
159
160 EXTERN char             *archive_name;
161 EXTERN char     temporary_name[FILENAME_LENGTH];
162 EXTERN char     backup_archive_name[FILENAME_LENGTH];
163
164 extern char             *extract_directory;
165 EXTERN char             *reading_filename, *writting_filename;
166
167 /* 1996.8.13 t.okamoto */
168 #if 0
169 EXTERN boolean  remove_temporary_at_error;
170 EXTERN boolean  recover_archive_when_interrupt;
171 EXTERN boolean  remove_extracting_file_when_interrupt;
172 #endif
173
174 EXTERN int      archive_file_mode;
175 EXTERN int      archive_file_gid;
176
177 EXTERN struct   interfacing interface;
178 EXTERN node             *next;
179 /* EXTERN unsigned short crc; */  /* 1996.8.13 t.okamoto */
180
181 EXTERN int      noconvertcase; /* 2000.10.6 */
182
183 /* slide.c */
184 EXTERN int      unpackable;
185 EXTERN unsigned long origsize, compsize;
186 EXTERN unsigned short dicbit;
187 EXTERN unsigned short maxmatch;
188 EXTERN unsigned long count;
189 EXTERN unsigned long loc;                       /* short -> long .. Changed N.Watazaki */
190 EXTERN unsigned char *text;
191 EXTERN int              prev_char;
192
193 /* huf.c */
194 #ifndef LHA_MAIN_SRC  /* t.okamoto 96/2/20 */
195 EXTERN unsigned short left[], right[];
196 EXTERN unsigned char c_len[], pt_len[];
197 EXTERN unsigned short c_freq[], c_table[], c_code[];
198 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
199 #endif
200
201 /* append.c */
202 #ifdef NEED_INCREMENTAL_INDICATOR
203 EXTERN long             indicator_count;
204 EXTERN long             indicator_threshold;
205 #endif
206
207 /* crcio.c */
208 EXTERN FILE             *infile, *outfile;
209 EXTERN unsigned short crc, bitbuf;
210 EXTERN int      dispflg;
211 EXTERN long             reading_size;
212
213 /* from dhuf.c */
214 EXTERN unsigned int n_max;
215
216 /* lhadd.c */
217 EXTERN int temporary_fd;
218
219 /* ------------------------------------------------------------------------ */
220 /*      Functions                                                                                                                               */
221 /* ------------------------------------------------------------------------ */
222 #include "prototypes.h"
223
224 /* Local Variables: */
225 /* mode:c */
226 /* tab-width:4 */
227 /* End: */
228 /* vi: set tabstop=4: */