00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdio.h>
00011
00012
00013
00014
00015
00016
00017
00018 ULONG crc,
00019 bhold;
00020
00021 long rsize,
00022 last_kpal,
00023 total_size,
00024 total_csize;
00025
00026 int rc = 1,
00027 pos_count,
00028 sf_count,
00029 e_count,
00030 total_files;
00031
00032 UINT sb_size= 0;
00033
00034 BYTE bsize,
00035 *sb=NULL, *sbp=NULL, *sbe=NULL;
00036
00037 char *init_path,
00038 **pos_parms,
00039 spin,
00040 zfn[MAX_PATH_ZIPINFO],
00041 output_path[MAX_PATH_ZIPINFO],
00042 sw_dirs,
00043 sw_freshen,
00044 sw_new,
00045 sw_overwrite,
00046 sw_test,
00047 sw_view,
00048 sw_extract,
00049 *sw_exclude;
00050
00051 FILE *ifile,
00052 *ofile;
00053
00054
00055
00056
00057
00058
00059
00060
00061 char copyright[] = "PCDEZIP v1.00 þþ Copyright (c) 1994, "
00062 "Bob Flanders and Michael Holmes\n"
00063 "First Published in PC Magazine "
00064 "January 11, 1994\n\n",
00065 help[] = "usage: PCDEZIP [switches] zipfile "
00066 "[target\\] [filespec [...]]\n\n"
00067 "switches: -f freshen existing files\n"
00068 "\t -n extract new and updated files\n"
00069 "\t -o do not prompt on overwrite\n"
00070 "\t -v view ZIP directory\n"
00071 "\t -d create directories\n"
00072 "\t -t test file integrity\n\n"
00073 "zipfile is source .ZIP file\n\n"
00074 "target\\ is the target directory;"
00075 " trailing backslash required\n\n"
00076 "filenames are files to be extracted;"
00077 " wildcards supported\n\n",
00078 bad_op[] = "Invalid parameter -%s\n",
00079 bad_value[] = "Missing value for -%c parameter\n",
00080 bad_switch[] = "Invalid syntax at %s\n",
00081 no_memory[] = "No memory available\n",
00082 no_zip_found[] = "ZIP file: %s was not found\n",
00083 done[] = "PCDEZIP completed normally\n",
00084 stop_here[] = "\nStopping at user's request\n",
00085 *compress_msg[10] = { "unknown", "stored", "shrunk", "reduce1",
00086 "reduce2", "reduce3", "reduce4",
00087 "imploded", "tokenized", "deflated" },
00088 *decompr_msg[10] = { "unknown", "copy", "unshrink", "expand",
00089 "expand", "expand", "expand",
00090 "explod", "", "inflat" },
00091 view_hdr[] = "Processing: %s\n\n"
00092 " Length Method Size Ratio Date Time Name\n"
00093 " ------ -------- ------ ----- -------- ----- ----\n",
00094 view_line[] = "%8ld %8.8s%7ld %3d%% %s %c%s%s\n",
00095 view_nextline[]= "\n\t\t",
00096 view_trailer[] = " ------ ------ ----- ----\n"
00097 "%8ld%9.9s%8ld %3d%%%16.16s%5d\n\n%s",
00098 view_encrypt[] = "?Marks encrypted files\n",
00099 view_none[] = "\nNo files were selected\n",
00100 not_supported[]= "File type not supported\n",
00101 extract_msg[] = "Extracting from",
00102 extract_test[] = "Testing",
00103 extract_hdr[] = "%s: %s\n\n",
00104 extract_line[] = "%11.11sing: %s ",
00105 extract_skip[] = "Bypassing unknown compress type\n",
00106 extract_encr[] = "Encrypted File: %s * Bypassed *\n",
00107 extract_ec[] = "Extraction",
00108 extract_tc[] = "Testing",
00109 extract_done[] = " \n%s Complete: %d files processed\n",
00110 extract_none[] = "\nNothing extracted\n",
00111 old_file[] = " %s\n Existing:%8ld %s ",
00112 new_file[] = "Zip:%8ld %s\n",
00113 overwrite_q[] = " Overwrite existing file? (Y/n/all/stop) ",
00114 kpal_msg[] = "%c\b",
00115 spin_char[] = "/-\\|",
00116 dir_error[] = "Output directory not available\n",
00117 invalid_dir[] = "Unable to create output directory\n",
00118 open_error[] = "Error opening output file\n",
00119 read_error[] = "Error reading ZIP file\n",
00120 write_error[] = "Error writing output file\n",
00121 data_error[] = "Data integrity error -- run stopped\n",
00122 overflow_msg[] = "Decode stack overflow while unshrinking\n",
00123 crc_error[] = "CRC error -- run stopped\n",
00124 test_ok[] = "Tested ok\n";
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 struct cmd_parm
00136 {
00137 char cp_ltr,
00138 *cp_entry,
00139 cp_flag;
00140
00141
00142 };
00143
00144 struct cmd_parm parm_table[] =
00145 {
00146 { 'D', &sw_dirs, 0 },
00147 { 'F', &sw_freshen, 0 },
00148 { 'N', &sw_new, 0 },
00149 { 'O', &sw_overwrite, 0 },
00150 { 'T', &sw_test, 0 },
00151 { 'V', &sw_view, 0 },
00152 { 'E', &sw_extract, 0 }
00153
00154 };
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 struct split_filename
00166 {
00167 char path[MAX_PATH_ZIPINFO],
00168 drv[3],
00169 dir[MAX_PATH_ZIPINFO],
00170 fname[10],
00171 ext[5];
00172 };
00173
00174 typedef struct split_filename SFS;
00175
00176 #define SPLIT(x) fnsplit(x.path, \
00177 x.drv, x.dir, \
00178 x.fname, x.ext);
00179
00180 SFS *sf,
00181 wf,
00182 ef;
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 UINT bll[] =
00196 {
00197 16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
00198 11, 4, 12, 3, 13, 2, 14, 1, 15
00199 };
00200
00201 UINT cll[] =
00202 {
00203 3, 4, 5, 6, 7, 8, 9, 10, 11, 13,
00204 15, 17, 19, 23, 27, 31, 35, 43,
00205 51, 59, 67, 83, 99, 115, 131, 163,
00206 195, 227, 258, 0, 0
00207 };
00208
00209 UINT cle[] =
00210 {
00211 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
00212 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
00213 4, 4, 5, 5, 5, 5, 0, 99, 99
00214 };
00215
00216 UINT cdo[] =
00217 {
00218 1, 2, 3, 4, 5, 7, 9, 13, 17, 25,
00219 33, 49, 65, 97, 129, 193, 257, 385,
00220 513, 769, 1025, 1537, 2049, 3073,
00221 4097, 6145, 8193, 12289, 16385, 24577
00222 };
00223
00224 UINT cde[] =
00225 {
00226 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4,
00227 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
00228 11, 11, 12, 12, 13, 13
00229 };
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 void *malloc_chk(int n)
00240 {
00241 void *s;
00242 if (NOT (s = appMalloc(n)))
00243
00244
00245 memset((char *) s,0,(long) n);
00246 return(s);
00247
00248 }
00249
00250
00251
00252
00253
00254
00255 void quit_with( char *error )
00256 {
00257 printf("UNZIP_globals.h [%s]\n",error);
00258
00259 }
00260
00261