"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "lha-114i/src/lha.h" of archive lha-114i.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
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 #include <stdio.h>
14 #include <errno.h>
15 #include <ctype.h>
16 #include <sys/types.h>
17 #include <sys/file.h>
18 #include <sys/stat.h>
19
20 #include <signal.h>
21
22 #include "lha_macro.h"
23
24 struct encode_option {
25 #if defined(__STDC__) || defined(AIX)
26 void (*output) ();
27 void (*encode_start) ();
28 void (*encode_end) ();
29 #else
30 int (*output) ();
31 int (*encode_start) ();
32 int (*encode_end) ();
33 #endif
34 };
35
36 struct decode_option {
37 unsigned short (*decode_c) ();
38 unsigned short (*decode_p) ();
39 #if defined(__STDC__) || defined(AIX)
40 void (*decode_start) ();
41 #else
42 int (*decode_start) ();
43 #endif
44 };
45
46 /* ------------------------------------------------------------------------ */
47 /* LHa File Type Definition */
48 /* ------------------------------------------------------------------------ */
49 struct string_pool {
50 int used;
51 int size;
52 int n;
53 char *buffer;
54 };
55
56 typedef struct LzHeader {
57 unsigned char header_size;
58 char method[METHOD_TYPE_STRAGE];
59 long packed_size;
60 long original_size;
61 long last_modified_stamp;
62 unsigned char attribute;
63 unsigned char header_level;
64 char name[256];
65 unsigned short crc;
66 boolean has_crc;
67 unsigned char extend_type;
68 unsigned char minor_version;
69
70 /* extend_type == EXTEND_UNIX and convert from other type. */
71 time_t unix_last_modified_stamp;
72 unsigned short unix_mode;
73 unsigned short unix_uid;
74 unsigned short unix_gid;
75 } LzHeader;
76
77 struct interfacing {
78 FILE *infile;
79 FILE *outfile;
80 unsigned long original;
81 unsigned long packed;
82 int dicbit;
83 int method;
84 };
85
86
87 /* ------------------------------------------------------------------------ */
88 /* Option switch variable */
89 /* ------------------------------------------------------------------------ */
90 /* command line options (common options) */
91 EXTERN boolean quiet;
92 EXTERN boolean text_mode;
93 EXTERN boolean verbose;
94 EXTERN boolean noexec; /* debugging option */
95 EXTERN boolean force;
96 EXTERN boolean prof;
97 EXTERN boolean delete_after_append;
98 EXTERN int compress_method;
99 EXTERN int header_level;
100 /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */
101 #ifdef EUC
102 EXTERN boolean euc_mode;
103 #endif
104
105 /* list command flags */
106 EXTERN boolean verbose_listing;
107
108 /* extract/print command flags */
109 EXTERN boolean output_to_stdout;
110
111 /* add/update/delete command flags */
112 EXTERN boolean new_archive;
113 EXTERN boolean update_if_newer;
114 EXTERN boolean generic_format;
115
116 EXTERN boolean remove_temporary_at_error;
117 EXTERN boolean recover_archive_when_interrupt;
118 EXTERN boolean remove_extracting_file_when_interrupt;
119 EXTERN boolean get_filename_from_stdin;
120 EXTERN boolean ignore_directory;
121 EXTERN boolean verify_mode;
122
123 /* Indicator flag */
124 EXTERN int quiet_mode;
125
126 /* ------------------------------------------------------------------------ */
127 /* Globale Variable */
128 /* ------------------------------------------------------------------------ */
129 EXTERN char **cmd_filev;
130 EXTERN int cmd_filec;
131
132 EXTERN char *archive_name;
133 EXTERN char expanded_archive_name[FILENAME_LENGTH];
134 EXTERN char temporary_name[FILENAME_LENGTH];
135 EXTERN char backup_archive_name[FILENAME_LENGTH];
136
137 EXTERN char *reading_filename, *writting_filename;
138
139 /* 1996.8.13 t.okamoto */
140 #if 0
141 EXTERN boolean remove_temporary_at_error;
142 EXTERN boolean recover_archive_when_interrupt;
143 EXTERN boolean remove_extracting_file_when_interrupt;
144 #endif
145
146 EXTERN int archive_file_mode;
147 EXTERN int archive_file_gid;
148
149 EXTERN struct interfacing interface;
150 EXTERN node *next;
151 /* EXTERN unsigned short crc; */ /* 1996.8.13 t.okamoto */
152
153 EXTERN int noconvertcase; /* 2000.10.6 */
154
155 /* slide.c */
156 EXTERN int unpackable;
157 EXTERN unsigned long origsize, compsize;
158 EXTERN unsigned short dicbit;
159 EXTERN unsigned short maxmatch;
160 EXTERN unsigned long count;
161 EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */
162 EXTERN unsigned char *text;
163 EXTERN int prev_char;
164
165 /* huf.c */
166 #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */
167 EXTERN unsigned short left[], right[];
168 EXTERN unsigned char c_len[], pt_len[];
169 EXTERN unsigned short c_freq[], c_table[], c_code[];
170 EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[];
171 #endif
172
173 /* append.c */
174 #ifdef NEED_INCREMENTAL_INDICATOR
175 EXTERN long indicator_count;
176 EXTERN long indicator_threshold;
177 #endif
178
179 /* crcio.c */
180 EXTERN FILE *infile, *outfile;
181 EXTERN unsigned short crc, bitbuf;
182 EXTERN int dispflg;
183 EXTERN long reading_size;
184
185 /* from dhuf.c */
186 EXTERN unsigned int n_max;
187
188 /* lhadd.c */
189 EXTERN FILE *temporary_fp;
190
191 /* ------------------------------------------------------------------------ */
192 /* Functions */
193 /* ------------------------------------------------------------------------ */
194 /* from lharc.c */
195 extern int patmatch();
196
197 extern void interrupt();
198
199 extern void message();
200 extern void warning();
201 extern void error();
202 extern void fatal_error();
203
204 extern boolean need_file();
205 extern int inquire();
206 extern FILE *xfopen();
207
208 extern boolean find_files();
209 extern void free_files();
210
211 extern void init_sp();
212 extern void add_sp();
213 extern void finish_sp();
214 extern void free_sp();
215 extern void cleaning_files();
216
217 extern void build_temporary_name();
218 extern void build_backup_file_name();
219 extern void build_standard_archive_name();
220
221 extern FILE *open_old_archive();
222 extern void init_header();
223 extern boolean get_header();
224 extern boolean archive_is_msdos_sfx1();
225 extern boolean skip_msdos_sfx1_code();
226 extern void write_header();
227 extern void write_archive_tail();
228 extern void copy_old_one();
229 extern unsigned char *convdelim();
230 extern long copyfile();
231
232 extern void cmd_list(), cmd_extract(), cmd_add(), cmd_delete();
233
234 extern boolean ignore_directory;
235 extern boolean compress_method;
236 extern boolean verify_mode;
237
238 extern char *extract_directory;
239
240 /* from slide.c */
241
242 extern int encode_alloc();
243 extern void encode();
244 extern void decode();
245
246 /* from append.c */
247 extern void start_indicator();
248 extern void finish_indicator();
249 extern void finish_indicator2();
250
251 /* slide.c */
252 extern void output_st1();
253 extern unsigned char *alloc_buf();
254 extern void encode_start_st1();
255 extern void encode_end_st1();
256 extern unsigned short decode_c_st1();
257 extern unsigned short decode_p_st1();
258 extern void decode_start_st1();
259
260 /* from shuf.c */
261 extern void decode_start_st0();
262 extern void encode_p_st0( /* unsigned short j */ );
263 extern void encode_start_fix();
264 extern void decode_start_fix();
265 extern unsigned short decode_c_st0();
266 extern unsigned short decode_p_st0();
267
268 /* from dhuf.c */
269 extern void start_c_dyn();
270 extern void decode_start_dyn();
271 extern unsigned short decode_c_dyn();
272 extern unsigned short decode_p_dyn();
273 extern void output_dyn( /* int code, unsigned int pos */ );
274 extern void encode_end_dyn();
275
276 extern int decode_lzhuf();
277
278 /* from larc.c */
279
280 extern unsigned short decode_c_lzs();
281 extern unsigned short decode_p_lzs();
282 extern unsigned short decode_c_lz5();
283 extern unsigned short decode_p_lz5();
284 extern void decode_start_lzs();
285 extern void decode_start_lz5();
286
287 extern void make_table( /* int nchar, uchar bitlen[], int tablebits,
288 ushort table[] */ );
289
290 /* from maketree.c */
291 /*
292 * void make_code(short n, uchar len[], ushort code[]); short make_tree(short
293 * nparm, ushort freqparm[], uchar lenparm[], ushort codeparam[]);
294 */
295 extern void make_code( /* int n, uchar len[], ushort code[] */ );
296 extern short make_tree( /* int nparm, ushort freqparm[], uchar lenparm[],
297 ushort codeparam[] */ );
298
299 /* from crcio.c */
300 extern void make_crctable();
301 extern unsigned short calccrc( /* uchar *p, uint n */ );
302 extern void fillbuf( /* uchar n */ );
303 extern unsigned short getbits( /* uchar n */ );
304 extern void putcode( /* uchar n, ushort x */ );
305 extern void putbits( /* uchar n, ushort x */ );
306 extern int fread_crc( /* uchar *p, int n, FILE *f */ );
307 extern void fwrite_crc( /* uchar *p, int n, FILE *f */ );
308 extern void init_getbits();
309 extern void init_putbits();
310 extern void make_crctable();
311 extern unsigned short calccrc();
312
313 /* from lhadd.c */
314 extern int encode_lzhuf();
315 extern int encode_stored_crc();
316
317 /* Local Variables: */
318 /* mode:c */
319 /* tab-width:4 */
320 /* End: */
321
322