1 /*
2  * $Id: externs.c,v 1.7 2004/06/18 16:19:37 andrew_belov Exp $
3  * ---------------------------------------------------------------------------
4  * All uninitialized  and initialized  variables that are  used by two or more
5  * modules are defined here. Note that no separation is done for those used by
6  * ARJ, ARJSFXV and so on...
7  *
8  */
9 
10 #include "arj.h"
11 
12 DEBUGHDR(__FILE__)                      /* Debug information block */
13 
14 /* Auto-initializing variables */
15 
16 #if SFX_LEVEL>=ARJSFXV
17  #define AUTOINIT
18 #else
19  #define AUTOINIT =0
20 #endif
21 
22 /* Shared data, mostly the duplicate strings */
23 
24 char nullstr[]="";                      /* Used instead of "" */
25 char strform[]="%s";                    /* printf(strform, str) */
26 char path_separators[]=PATH_SEPARATORS;
27 #if TARGET!=UNIX
28  char switch_chars[]="-/";
29 #else
30  char switch_chars[]="-";
31 #endif
32 #if SFX_LEVEL>=ARJ
33 char cmd_ac[]="AC";                     /* Chapter commands */
34 char cmd_cc[]="CC";
35 char cmd_dc[]="DC";
36 char arjtemp_spec[]="ARJTEMP.$%02d";    /* For all temporary files created */
37 char le_prompt[]="%02d> ";              /* String entry prompt */
38 #endif
39 #if SFX_LEVEL>=ARJSFXV
40 char vd_space[]="  ";                   /* ...after the filename */
41 #endif
42 
43 /* Exported data */
44 
45 #if SFX_LEVEL>=ARJ||defined(REARJ)
46 
47 unsigned char regdata[]={'a', 'R', 'j', ' ', 's', 'O', 'f', 'T', 'w', 'A', 'r',
48                          'E', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57                          '[', '/', '.', ',', ']', '$', '*', '(', '#', '@', '^',
58                          '&', '*', '%', '#', '(', ')', 0};
59 #endif
60 
61 #if SFX_LEVEL>=ARJSFXV
62 struct flist_root flist_order;          /* Order of files */
63 struct flist_root flist_archive;        /* Archives to be processed */
64 #endif
65 #if SFX_LEVEL>=ARJSFXV||defined(REARJ)
66 struct flist_root flist_main;           /* Files to be processed */
67 struct flist_root flist_exclusion;      /* Files to be excluded */
68 #endif
69 #if SFX_LEVEL>=ARJ&&defined(HAVE_EAS)
70 struct flist_root flist_ea;             /* EAs to include */
71 struct flist_root flist_xea;            /* EAs to exclude */
72 #endif
73 #if SFX_LEVEL>=ARJ&&TARGET==UNIX
74 struct l_entries l_entries;
75 struct l_entries sl_entries;
76 #endif
77 int win32_platform;                     /* 1 if the archiver has been compiled
78                                            for Win32 */
79 int display_totals;                     /* 1 if the total archive statistics
80                                            can be shown in display_indicator() */
81 int switch_char AUTOINIT;               /* 1st switch character */
82 unsigned int file_attr_mask;            /* For optimization */
83 int pattern_found;                      /* 1 once the search pattern was found
84                                            (m_w command) */
85 #if SFX_LEVEL>=ARJSFXV||defined(REARJ)
86 int is_registered;                      /* 1 if the archiver is registered
87                                            (this switch is inverted at the
88                                            beginning to disallow hacking) */
89 int in_key;                             /* 1 = use the stored key */
90 #endif
91 #if SFX_LEVEL>=ARJ
92 int is_commercial;                      /* 1 if commercial version (in
93                                            open-source world, means nothing) */
94 #endif
95 int lfn_supported AUTOINIT;             /* 1 if yes; set by detect_lfns */
96 int ext_hdr_flags;                      /* Extended flags, used in main ARJ
97                                            archive header */
98 int file_garbled;                       /* 1 if the GARBLED_FLAG is set */
99 int arch_wildcard_allowed;              /* 1 if multiple archives can be
100                                            processed */
101 int file_args AUTOINIT;                 /* Number of file arguments */
102 int volume_flag_set;                    /* 1 if the VOLUME_FLAG is set in the
103                                            header */
104 #if SFX_LEVEL>=ARJ
105 int tmp_archive_used;                   /* Indicates that a temporary archive
106                                            file was built */
107 int method_specifier;                   /* Number of the custom method */
108 int primary_file_type;                  /* Default type */
109 int identical_filedata;                 /* 1 if the files in archive are
110                                            identical with the disk files */
111 #endif
112 #if SFX_LEVEL>=ARJSFXV
113 int ctrlc_not_busy;                     /* Ctrl+C handler can proceed */
114 int ignore_errors;                      /* 1 if everything is ignored (-hr) */
115 int ctrlc_processing;                   /* Ctrl+C is raised */
116 int supply_comment_file;                /* Supply file for comment (-jz) */
117 #endif
118 #if SFX_LEVEL>=ARJ
119 int use_comment;                        /* Supply archive comment (-z) */
120 #endif
121 int assume_yes;                         /* -jy option presence flag */
122 int extract_to_file;                    /* Extract to a single file (-jw) */
123 #if SFX_LEVEL>=ARJ
124 int assign_work_directory;              /* Set temporary directory (-w) */
125 #endif
126 int multivolume_option;                 /* 1 if the "-v" switch is issued */
127 #if SFX_LEVEL>=ARJ
128 int allow_mv_update;                    /* Allow update of multivolume archives */
129 int beep_between_volumes;               /* Beep between volumes (-vv) */
130 int chk_arj_version;                    /* -hv */
131 #endif
132 int verbose_display AUTOINIT;           /* State of verbose display (-jv) */
133 int update_criteria AUTOINIT;           /* Update option (-u), one of UC_* */
134 #if SFX_LEVEL>=ARJ
135 int translate_unix_paths;               /* Translate "/" path separators */
136 int type_override;                      /* File type override (-t) */
137 int timestamp_override;                 /* Archive time override (-s, ATO_*) */
138 int test_archive_crc;                   /* Test CRC (-jt, one of TC_*) */
139 int store_by_suffix;                    /* Store *.ZIP, *.ARJ, etc. */
140 #endif
141 int skip_ts_check AUTOINIT;             /* Skip timestamp check (-c) */
142 #if SFX_LEVEL>=ARJ
143 int comment_display;                    /* Comment display settings */
144 int lfn_mode;                           /* LFN handling mode (-hf) */
145 int create_sfx;                         /* !0 if the output file will be a SFX
146                                            (the SFXCRT_* constants define the
147                                            type of SFX) */
148 int filter_attrs;                       /* 1 if file are selected depending
149                                            on their attributes (-hb) */
150 int select_backup_files;                /* Select backup files (-jg) */
151 int search_mode;                        /* File search logging level (-hw) */
152 #endif
153 int keep_tmp_file;                      /* Keep unprocessed file */
154 #if SFX_LEVEL>=ARJ
155 int hollow_mode;                        /* Create "hollow" archives (-j#) */
156 int restart_at_filename;                /* Restart volumes on filename (-jn) */
157 #endif
158 int quiet_mode AUTOINIT;                /* 1 or 2 if prompting is suppressed
159                                            (registered ARJ only) */
160 int recurse_subdirs;                    /* Recurse thru subdirectories (-r) */
161 int ignore_crc_errors;                  /* One of ICE_* (-jr) */
162 #if SFX_LEVEL>=ARJ
163 int set_string_parameter;               /* Set command-line parameters */
164 int query_for_each_file;                /* 1 if yes (-q) */
165 int protfile_option;                    /* 1 if .XRJ file must be built (-hk) */
166 int arjprot_tail;                       /* Indicates presence of recovery
167                                            record */
168 int prot_blocks;                        /* # of ARJ-PROTECT blocks */
169 #endif
170 int arjdisp_enabled AUTOINIT;           /* 1 if the ARJ$DISP interface is
171                                            enabled (-hp) */
172 int prompt_for_more;                    /* 1 if the user is to be prompted
173                                            when scrolling */
174 #if SFX_LEVEL>=ARJ
175 int marksym_expansion;                  /* Toggles expansion (see MISC.C) */
176 #endif
177 int fnm_matching AUTOINIT;              /* Filename matching mode, (FMM_*) */
178 int rsp_per_line;                       /* Set per-line RSP mode (-@) */
179 int gost_cipher;                        /* Garble via GOST 28147-89 (v 2.55+) */
180 int filter_older;                       /* Same and newer files are thrown away */
181 int filter_same_or_newer;               /* Older files are thrown away */
182 int new_files_only AUTOINIT;            /* Only the nonexistent files are OK */
183 int nonexist_filespec;                  /* Specify non-existing file (-hn) */
184 int skip_switch_processing AUTOINIT;    /* Set after "--" option */
185 int disable_sharing;                    /* 1 if SAA extended subs are used */
186 int yes_on_all_queries AUTOINIT;        /* 1 if all queries are skipped */
187 int indicator_style AUTOINIT;           /* -i indicator style (no enums) */
188 int disable_arj_sw;                     /* Disable ARJ_SW (-+) */
189 int skip_time_attrs;                    /* 1 to skip DTA/DTC handling (-j$) */
190 int custom_method;                      /* The value of -m, or 0 */
191 int max_compression;                    /* Maximal compression mode (-jm) */
192 int filelist_storage;                   /* Desired filelist storage method */
193 int create_list_file;                   /* -l */
194 int listfile_err_opt;                   /* Return error for list file error (-hhl) */
195 int listchars_allowed;                  /* 1 if yes */
196 int handle_labels;                      /* Should the labels be [re]stored
197                                            (-$) */
198 int sign_with_arjsec;                   /* 1 if the archive must be sealed */
199 int keep_tmp_archive;                   /* Keep ARJTEMP on error (-jk) */
200 int keep_bak;                           /* Keep backup file (-k) */
201 int create_index;                       /* 1 if yes (-ji) */
202 int detailed_index;                     /* 1 if detailed index is to be built
203                                            (-hi) */
204 int ignore_archive_errors;              /* 1 if an error like "Bad header" will
205                                            not cause a termination */
206 int ignore_open_errors;                 /* Should the archive open errors on
207                                            add operation be ignored? (-hq) */
208 int clear_archive_bit;                  /* 1 if chmod operations are used and
209                                            all bits of file are set to 0 */
210 int jh_enabled;                         /* Nonzero if the "-jh" is used */
211 int help_issued AUTOINIT;               /* Help (-?) is issued by the user */
212 int garble_enabled;                     /* Garble with password */
213 int lowercase_names AUTOINIT;           /* Convert filenames being added or
214                                            extracted to lower case */
215 int validate_style;                     /* VALIDATE_ALL, VALIDATE_NOTHING,
216                                            or VALIDATE_DRIVESPEC */
217 int freshen_criteria AUTOINIT;          /* Freshen option (-f), one of FC_* */
218 int chk_free_space;                     /* Check space before extraction */
219 int force_lfn;                          /* Force LFN support (-h$) */
220 int select_by_number;                   /* Select files by number (-#) */
221 int show_filenames_only;                /* (-jl) Simplified display */
222 int override_archive_exts;              /* Set default archive extensions */
223 int extm_mode;                          /* Extract files w/matches (-ho) */
224 int exit_after_count;                   /* Exit after N files (-jc) */
225 int start_at_ext_pos;                   /* 1 if the -jx option was issued */
226 #if SFX_LEVEL>=ARJ
227 int start_with_seek;                    /* 1 if the -2i option was issued */
228 #endif
229 int exclude_paths;                      /* Exclude paths from filenames (-e) */
230 int exclude_files;                      /* Exclude selected files (-x) */
231 int arjsec_opt;                         /* -he options */
232 int run_cmd_at_start;                   /* Execute command on start (-hc) */
233 int delete_processed;                   /* Delete processed files (-d) */
234 int debug_enabled;                      /* 1 if yes */
235 int install_errhdl;                     /* Install critical error handler (-&) */
236 int chapter_mode;                       /* 0 - do not create chapters
237                                            1 - create/process a chapter archive
238                                            2 - dismiss chapter archive */
239 int set_target_directory;               /* Set target directory (-ht) */
240 int serialize_exts;                     /* Serialize extensions (-jo/-jo1) */
241 int allow_any_attrs;                    /* Allow any file attributes (-a) */
242 int filter_fa_arch;                     /* Store only files with 0x20 bit set */
243 int append_curtime;                     /* Append current date/time to archive
244                                            filename (-h#) */
245 char *time_str;                         /* Time string to append */
246 int use_ansi_cp;                        /* Use ANSI codepage (-hy) */
247 #if SFX_LEVEL>=ARJ
248 int queries_assume_no[TOTAL_QUERIES];   /* 1 if NO is assumed as reply */
249 int queries_assume_yes[TOTAL_QUERIES];  /* 1 if YES is assumed as reply */
250 #endif
251 int accept_shortcut_keys;               /* Never used and defaults to 0 */
252 int skip_next_vol_query;                /* Skip "next volume...?" query */
253 int skip_scanned_query;                 /* Skip "scanned enough?" (-jys) */
254 int overwrite_existing AUTOINIT;        /* 1 if no prompt for overwriting an
255                                            existing file is to be displayed */
256 int skip_rename_prompt;                 /* Skip "New name...?" prompt */
257 int skip_space_query;                   /* Skip free disk space query */
258 int query_delete;                       /* 1 if the user is to be queried when
259                                            a set of files is to be deleted */
260 #if SFX_LEVEL>=ARJSFXV
261 int prompt_for_mkdir;                   /* 1 if yes (overrides -y) */
262 int skip_append_query;                  /* Skip "Append @ position..." query */
263 int kbd_cleanup_on_input;               /* Defaults to 0 */
264 #endif
265 #if SFX_LEVEL>=ARJSFXV
266 int use_sfxstub;                        /* Create multivolume stubbed
267                                            packages */
268 #endif
269 #if SFX_LEVEL>=ARJ
270 int whole_files_in_mv;                  /* Store whole files in volumes (-vw) */
271 int pause_between_volumes;              /* Pause after completing volume
272                                            (-vp) */
273 int inhibit_change_test;                /* Inhibit diskette change test (-vi) */
274 int mv_cmd_state;                       /* -vs/vz/vd commands -> MVC_* */
275 int ignore_pcase;                       /* Ignore case of search pattern */
276 #endif
277 #if SFX_LEVEL>=ARJ||defined(REARJ)
278 int no_file_activity;                   /* 1 if file writes can be ignored
279                                            (-hdn in ARJ, -z in REARJ) */
280 #endif
281 int std_list_cmd AUTOINIT;              /* 1 if the standard (non-verbose) list
282                                            is requested */
283 int print_with_more;                    /* Set to 1 if the ARJ P was called and
284                                            the "more?" prompt is enabled */
285 int subdir_extraction;                  /* 1 if the ARJ x command was issued */
286 int execute_cmd;                        /* ARJ B sets this flag */
287 int change_vol_delay;                   /* Delay specified with -p */
288 unsigned int left_trim;                 /* Number of chars to remove from the
289                                            beginning of filename during the
290                                            extraction */
291 char listchar;                          /* Defaults to '!' */
292 int errorlevel;                         /* DOS errorlevel */
293 unsigned int errors AUTOINIT;           /* Number of errors */
294 int lines_per_page;                     /* Lines per screen for using "more" */
295 int lines_scrolled;                     /* Lines scrolled */
296 int secondary_file_type;                /* Type specified with a list */
297 unsigned int file_type;                 /* See DT_* equates */
298 int unpackable;                         /* 1 if the compressed file becomes
299                                            greated than the original one */
300 int fdisp_lines;                        /* Lines to display in m_w command */
301 int reserve_size;                       /* Size of reserved buffer */
302 int bitcount;                           /* Temporary counter */
303 FILE_COUNT av_total_files;              /* Total # of files on all volumes */
304 FILE_COUNT av_total_longnames;          /* Total # of LFNs on all volumes */
305 FILE_COUNT exit_count;                  /* Number of files to exit after */
306 #if SFX_LEVEL>=ARJ
307 FILE_COUNT split_files;                 /* Number of files that span across
308                                            volumes */
309 #endif
310 #if SFX_LEVEL>=ARJ
311 FILE_COUNT FAR *order;                  /* Order of files */
312 int params_max;
313 char **f_arg_array;
314 #else
315 int order[PARAMS_MAX];
316 int params_max=PARAMS_MAX;
317 char *f_arg_array[PARAMS_MAX];          /* Array of filename arguments */
318 #endif
319 char *comment_file;                     /* Global comment file */
320 char *archive_cmt_name;                 /* Archive comment (-z) filename */
321 char *yes_query_list;                   /* List of -jy parameters */
322 char *extraction_filename;              /* Filename specified by -jw */
323 char *swptr_hv;                         /* -hv parameter */
324 char *search_reserve;                   /* For strings that span across block
325                                            boundaries */
326 #if SFX_LEVEL>=ARJ
327 char *search_str[SEARCH_STR_MAX];       /* Search patterns */
328 #endif
329 char *filename_to_restart;              /* Filename specified with -jn */
330 char *string_parameter;                 /* -jq string parameter */
331 char *arjdisp_ptr;                      /* -hp (ARJ$DISP switch) */
332 char *arjcrypt_name;                    /* ARJCRYPT.COM override (-hg) */
333 char *nonexist_name;                    /* Nonexistent filespec (-hn) */
334 unsigned long garble_ftime;             /* Used as a random seed when garbling
335                                            files */
336 char *index_name;                       /* Index (-ji) filename */
337 char *list_file;                        /* -L list file */
338 char *swptr_t;                          /* -t (secondary file type list) */
339 char *cmd_to_exec;                      /* Text of command to be run */
340 char *archive_suffixes;                 /* A list of packed file extensions */
341 char *mv_cmd;                           /* Executed between volumes */
342 #ifndef REARJ
343 char *timestr_older;                    /* "-ob", "-oab", "-ocb" */
344 char *timestr_newer;                    /* "-o", "-ob", "-oc" */
345 #endif
346 char *arj_env_name;                     /* "ARJ_SW" or "ARJ32_SW" */
347 char *swptr_hm;                         /* -hm (file list management) */
348 char *work_directory;                   /* -w (work directory) override */
349 char *target_dir;                       /* Target directory, -ht overrides it */
350 char *tmp_archive_name;                 /* Back-up archive */
351 char *rsp_name;                         /* Response (@) filename */
352 /* Temporary filename storage */
353 #if SFX_LEVEL>=ARJSFXV
354 char *tmp_tmp_filename;
355 #else
356 char tmp_tmp_filename[FILENAME_MAX];
357 #endif
358 /* Archive filename with the extension added. */
359 #if SFX_LEVEL>=ARJSFXV
360 char *archive_name;
361 #else
362 char archive_name[FILENAME_MAX];
363 #endif
364 char *arjsec_env_name;                  /* ARJ-SECURITY envelope filename (-hz)
365                                            Unused in noncommercial version */
366 char password_modifier;                 /* Garble password modifier */
367 char *garble_password;                  /* Pointer to garble password */
368 char *archive_ext_list;                 /* -hx extension list */
369 char *debug_opt;                         /* -hd (debug) */
370 char *start_cmd;                        /* Command to run at start */
371 char *misc_buf;                         /* allocated at main(). General-purpose
372                                            buffer. */
373 char label_drive;                       /* Drive letter (-$A, -$B, etc.) */
374 char *strcpy_buf;                       /* allocated at main() */
375 unsigned char host_os;                  /* Host operating system of archive
376                                            and source files within it. */
377 char *out_buffer;                       /* Temporary storage of encoded data */
378 /* ARJ header storage area */
379 #if SFX_LEVEL>=ARJSFXV
380 char *header;
381 #else
382 char header[HEADERSIZE_MAX];
383 #endif
384 unsigned char byte_buf;                 /* Used for preserving the data read */
385 unsigned char subbitbuf;                /* Backup storage */
386 int user_wants_fail;                    /* -1 if the user has manually
387                                            cancelled the operation */
388 int resume_volume_num;                  /* -jn volume number */
389 unsigned int ext_voldata;               /* Size of additional (non-ARJ) data in
390                                            multivolume archives */
391 int out_avail;                          /* Number of available bytes in
392                                            out_buffer */
393 int out_bytes;                          /* Number of bytes pending */
394 int total_chapters;                     /* Number of chapters in the file */
395 int chapter_to_process;                 /* Number of chapter to be processed */
396 int current_chapter;                    /* Chapter number of current file */
397 FILE_COUNT max_filenames;               /* Initialized with 65000 by default */
398 unsigned int user_bufsiz;               /* The "-jh" value */
399 unsigned int current_bufsiz;            /* Size of the buffer, picked every time
400                                            when the compressor starts */
401 unsigned short bitbuf;                  /* Used directly in the decoding */
402 FILE *new_stderr;                       /* Indicates presence of STDERR
403                                            re-route */
404 FILE *tstream;                          /* Any disk file */
405 #if SFX_LEVEL>=ARJ
406 FILE *idxstream;                        /* Index file */
407 #endif
408 #if SFX_LEVEL>=ARJSFXV
409 FILE *new_stdout;                       /* stdout or stderr */
410 #endif
411 FILE *atstream=NULL;                    /* Temporary handle */
412 #if SFX_LEVEL>=ARJ
413 FILE *aostream;                         /* Archive output file handle */
414 FILE *encstream;                        /* The file being encoded */
415 #endif
416 FILE *aistream;                         /* Archive input file handle */
417 #if SFX_LEVEL>=ARJSFXV
418 unsigned long FAR *arch_hdr_index;      /* Contains offsets of archive files */
419 #endif
420 unsigned long last_hdr_offset;          /* Offset of last archive header */
421 #if SFX_LEVEL>=ARJ
422 long search_occurences[SEARCH_STR_MAX]; /* Number of occurences of each search
423                                            pattern from search_str[] */
424 #endif
425 unsigned long ext_pos;                  /* Offset specified by -jx */
426 #if SFX_LEVEL>=ARJSFXV
427 unsigned long arcv_ext_pos;             /* Offset specified by -2i */
428 #endif
429 long uncompsize;                        /* Size of the file on the disk */
430 unsigned long compsize;                 /* Size of compressed data */
431 unsigned long origsize;                 /* Size of the source file */
432 unsigned long av_uncompressed;          /* Size of uncompressed data on all
433                                            volumes */
434 unsigned long av_compressed;            /* Size of compressed data on all
435                                            volumes */
436 unsigned long total_size;               /* Total size of all files to be
437                                            archived */
438 unsigned long total_written;            /* Total size of all files that are
439                                            archived, excluding the current. */
440 unsigned long minfree;                  /* Minimal disk space for operation
441                                            (-jdxxx) */
442 struct timestamp tested_ftime_older;    /* Time attribute for filtering (<) */
443 struct timestamp tested_ftime_newer;    /* Time attribute for filtering (>=) */
444 unsigned long t_volume_offset;          /* Offset of multivolume data */
445 unsigned long mv_reserve_space;         /* Number of bytes to reserve on the
446                                            first volume */
447 unsigned long volume_limit;             /* Maximum volume size in bytes */
448 struct timestamp secondary_ftime;       /* Used in rare occasions */
449 struct timestamp ftime_max;             /* Most recent timestamp of files
450                                            contained within archive */
451 unsigned long disk_space_used;          /* Space allocated for the files */
452 unsigned long total_compressed AUTOINIT;/* Total size of compressed data */
453 /* Total size of uncompressed data */
454 unsigned long total_uncompressed AUTOINIT;
455 unsigned long arjsec_offset;            /* Offset of ARJ-security envelope */
456 unsigned long secured_size;             /* Original size of ARJ-secured file */
457 unsigned long cur_header_pos;           /* Offset of currently processed header
458                                            within the archive */
459 long main_hdr_offset;                   /* Offset of main archive header
460                                            (nonzero in SFX) */
461 #if SFX_LEVEL>=ARJSFXV
462 char FAR *tmp_filename;                 /* Backup copy of current filename */
463 #endif
464 unsigned long volume_crc;               /* CRC kept for multivolume files */
465 struct timestamp volume_ftime;          /* Multivolume ftime storage */
466 FILE *ofstream;                         /* -jw output file */
467 int recent_chapter;                     /* Chapter to be added, if any */
468 unsigned int alloc_unit_size;           /* Size of allocation unit */
469 FILE_COUNT split_longnames;             /* Number of cross-volume longnames */
470 FILE_COUNT total_longnames;             /* Number of processed files with LFN */
471 FILE_COUNT total_files AUTOINIT;        /* Number of processed files */
472 FILE_COUNT comment_entries;             /* Number of filenames acting as
473                                            comment (e.g., chapter separators) */
474 int max_chapter;                        /* Maximum number of chapter found so
475                                            far */
476 #if SFX_LEVEL>=ARJ
477 int force_volume_flag;                  /* 1 if the file will be marked with
478                                            VOLUME_FLAG even if it is not
479                                            multi-volume */
480 int sfx_desc_word;                      /* Descriptive word of SFX */
481 int add_command;                        /* 1 if the current operation adds any
482                                            external files to the archive */
483 int order_command;                      /* An order command was issued */
484 #endif
485 int no_inarch;                          /* 1 if there's no input archive */
486 int modify_command;                     /* 1 if the current operation modifies
487                                            the archive contents */
488 unsigned int volume_number;             /* .A0x, .Axx volume number */
489 int continued_nextvolume;               /* 1 if the file continues on the next
490                                            volume (the VOLUME_FLAG is set ) */
491 int first_vol_passed;                   /* 1 once the first archive volume has
492                                            been fully processed */
493 int mvfile_type;                        /* Types of multi-volume files */
494 int continued_prevvolume;               /* 1 if the resume_position must be
495                                            taken into account (indicates that
496                                            the file is split from a previous
497                                            volume) */
498 #if SFX_LEVEL>=ARJSFXV
499 int encryption_applied;                 /* Encryption operation will occur */
500 #endif
501 int cmd_verb;                           /* ASCII code of the command issued
502                                            (uppercase) */
503 int security_state AUTOINIT;            /* ARJSEC_* constants may be here */
504 int ansi_codepage;                      /* 1 if the archive filename is in the
505                                            ANSI codepage. */
506 int dual_name AUTOINIT;                 /* 1 if dual-name mode (long filename
507                                            is stored in the comment field, see
508                                            help on "-hf1" for details) */
509 unsigned long archive_size;             /* Size of the whole archive, excluding
510                                            the two terminating 0's */
511 unsigned long resume_position;          /* For multi-volume files, the number
512                                            of bytes to skip. */
513 unsigned long header_crc;               /* CRC of current archive header */
514 unsigned long file_crc;                 /* CRC-32 of uncompressed file */
515 unsigned char chapter_number;           /* Chapter number, 1 to 250. */
516 unsigned char ext_flags;                /* Used for chapter number or extended
517                                            header flags storage */
518 unsigned short host_data;               /* Used for chapter information */
519 unsigned short entry_pos;               /* Entryname position in filename */
520 struct timestamp ctime_stamp;           /* v 2.62+ - creation date/time */
521 struct timestamp atime_stamp;           /* v 2.62+ - last access date/time */
522 struct timestamp ftime_stamp;           /* Last modification date/time */
523 struct file_mode file_mode;             /* File access mode bit-map */
524 unsigned int method;                    /* Packing method */
525 unsigned char arj_flags;                /* Archive flags */
526 unsigned char arj_x_nbr;                /* Minimum version to extract */
527 unsigned char arj_nbr;                  /* Archiver version number */
528 unsigned char first_hdr_size;           /* Size of fixed-length header (30) */
529 unsigned int basic_hdr_size;            /* Size of the basic (not extended)
530                                            header */
531 char *hdr_comment;                      /* Comment stored in the header */
532 char *hdr_filename;                     /* Filename stored in the header */
533 /* Preallocated comment storage area */
534 #if SFX_LEVEL>=ARJSFXV
535 char FAR *comment;
536 #else
537 char comment[COMMENT_MAX];
538 #endif
539 int use_comment;                        /* Supply archive comment (-z) */
540 char filename[FILENAME_MAX];            /* Filename storage buffer */
541 struct file_properties properties;      /* Properties of the current file */
542 int restart_at_filename;                /* Restart volumes on filename (-jn) */
543 #ifndef REARJ
544 unsigned char pt_len[NPT];              /* Prefix table length */
545 unsigned short left[2*NC-1];            /* Huffman tree */
546 unsigned short right[2*NC-1];           /* Huffman tree */
547 unsigned char c_len[NC];                /* Character length */
548 unsigned short cpos;                    /* Position in out_buffer */
549 unsigned int bufsiz;                    /* Size of the Huffman buffer, specified
550                                            by "-jh" and adjusted afterwards */
551 #endif
552 #if SFX_LEVEL>=ARJSFXV
553 unsigned char *dec_text;
554 #elif !defined(REARJ)
555 unsigned char dec_text[DICSIZ];
556 #endif
557 /* The following is an ASR fix -- performance enhancement to 2.76.06 */
558 #if SFX_LEVEL>=ARJ
559 unsigned char *ntext;                   /* decode_f() non-volatile dictionary */
560 #endif
561 
562 /* Missing or obsolete in original ARJ 2.62c */
563 
564 #if SFX_LEVEL>=ARJSFXV
565 int error_occured;                      /* 1 if an error happened and ARJ must
566                                            exit. */
567 #endif
568 int file_packing;                       /* 1 if uncompressed data is a file */
569 char FAR *encblock_ptr;                 /* Uncompressed data pointer */
570 char FAR *packblock_ptr;                /* Compressed data pointer */
571 unsigned int encmem_remain;             /* Amount of uncompressed data */
572 unsigned int packmem_remain;            /* Amount of compressed data */
573 unsigned int encmem_limit;              /* To prevent overruns */
574 #if SFX_LEVEL>=ARJSFXV
575 int ea_supported;                       /* Extended attributes support flag */
576 long ext_hdr_capacity;                  /* Number of RAW bytes to flush when
577                                            writing the extended header on the
578                                            current file portion. Must be
579                                            SIGNED! */
580 struct ext_hdr FAR *eh;                 /* Extended header */
581 unsigned int ea_size;                   /* Size of unpacked EAs */
582 #endif
583 int valid_ext_hdr;                      /* Specifies that the extended header
584                                            data can be processed */
585 char *exe_name;                         /* Name of executable invoked */
586 #if SFX_LEVEL>=ARJ
587 int arcmail_sw;                         /* ARCmail non-overwrite mode */
588 int dos_host;                           /* Use DOS as host OS under OS/2 */
589 struct priority priority;               /* Selectable process priority */
590 int include_eas;                        /* EA inclusion filelist is present */
591 int exclude_eas;                        /* EA exclusion filelist is present */
592 int disable_comment_series;             /* Apply comment to the 1st volume,
593                                            strip it for all others */
594 int skip_century;                       /* Skip centuries in list commands */
595 int fix_longnames;                      /* 1 if .LONGNAME EAs should be
596                                            resolved to filenames in headers */
597 int crit_eas;                           /* 1 if only critical EAs should
598                                            be packed/restored */
599 int symlink_accuracy;                   /* Restore symlink properties */
600 int do_chown;                           /* Query / set the file owner */
601 int suppress_hardlinks;                 /* Store the whole copies */
602 int recursion_order;                    /* Directory recursion order */
603 int encryption_id;                      /* Identifies encryption in header */
604 jmp_buf main_proc;                      /* Entry point of archive processing
605                                            loop */
606 #endif
607 
608 /* ARJSFX data */
609 
610 #if SFX_LEVEL<=ARJSFXV
611 int valid_envelope AUTOINIT;            /* 1 if the archive has a valid
612                                            ARJ-SECURITY envelope */
613 int skip_integrity_test AUTOINIT;       /* Skip virus/security check (-a) */
614 int prompt_for_directory AUTOINIT;      /* Prompt for directory (-b) */
615 int extract_expath AUTOINIT;            /* Extract excluding paths (-e) */
616 int process_lfn_archive AUTOINIT;       /* Process a Windows LFN archive (-j) */
617 int skip_preset_options;                /* Skip preset SFX options (-k) */
618 int list_sfx_cmd AUTOINIT;              /* List SFX contents (-l) */
619 int overwrite_ro;                       /* Overwrite read-only files */
620 int test_sfx_cmd AUTOINIT;              /* Test archive (-t) */
621 int verbose_list AUTOINIT;              /* Verbose list command (-v) */
622 int extract_cmd AUTOINIT;               /* Default extract command (-x) */
623 #if SFX_LEVEL>=ARJSFXV
624 int skip_volumes;                       /* Skip over first volumes (-#) */
625 int first_volume_number;                /* First volume to process */
626 #endif
627 int execute_extr_cmd AUTOINIT;          /* Execute command upon extraction */
628 int skip_extract_query AUTOINIT;        /* Skip file extraction query (-ym) */
629 char *extr_cmd_text;                    /* Command to be run */
630 unsigned short reg_id AUTOINIT;         /* SFX registration signature */
631 int licensed_sfx AUTOINIT;              /* Indicates a licensed (secured) SFX */
632 int logo_shown AUTOINIT;                /* 1 once the ARJSFX logo is shown */
633 #endif
634 
635 #if SFX_LEVEL<=ARJSFX
636 int make_directories AUTOINIT;          /* 1 if directory creation is allowed */
637 int show_ansi_comments AUTOINIT;        /* Display ANSI comments */
638 char *list_adapted_name;                /* Filename used in listing */
639 int test_mode AUTOINIT;                 /* 1 if test_sfx_cmd was issued */
640 int sflist_args AUTOINIT;               /* Simplified filelist -- # of args */
641 char *sflist[SFLIST_MAX];               /* Simplified filelist itself */
642 #endif
643 
644 #ifdef COLOR_OUTPUT
645 int redirected;                         /* 1 if STDOUT was redirected */
646 int no_colors;                          /* 1 if color output was disabled */
647 struct color_hl color_table[]={
648                                {7, 'n'},
649                                {10, 'o'},
650                                {2, 'h'},
651                                {15, 's'},
652                                {12, 'a'},
653                                {3, 'p'},
654                                {0, 0}
655                               };
656 #endif
657