cs sdk v 1.14 released

Home  |  Product  |  Documents  |  Tutorials  |  FAQ |   Download  |   Forum |   Contacts  |   Link  


  Cross Suit

 Cross Suit SDK

 Documents
      classes
 Starting...
           Tutorials

 LUA tutorials

   Support

  Forum
  q&a

 Product parts

 Virtual File system

 Virtual Render
 Virtual Machine
   

  Demo Games

   

 3D Engine

  gvSystem(dx9)

 Link

 

 

unzip_Globals.h

Go to the documentation of this file.
00001 // ******************************************************************** //
00002 //                                                                      //
00003 //  GLOBALS.CPP                                                         //
00004 //  Copyright (c) 1994, Bob Flanders and Michael Holmes                 //
00005 //                                                                      //
00006 //  This module defines global work areas and constant strings for      //
00007 //  PCDEZIP.                                                            //
00008 //                                                                      //
00009 // ******************************************************************** //
00010 #include <stdio.h>
00011 
00012 /* ******************************************************************** *
00013  *
00014  *  Global Variables
00015  *
00016  * ******************************************************************** */
00017 
00018 ULONG   crc,                                // running crc 32 value
00019         bhold;                              // bits hold area
00020 
00021 long    rsize,                              // remaining size to process
00022         last_kpal,                          // keep alive message time
00023         total_size,                         // uncompressed sum
00024         total_csize;                        // compressed sum
00025 
00026 int     rc = 1,                             // errorlevel return code
00027         pos_count,                          // positional parms count
00028         sf_count,                           // select file parms count
00029         e_count,                            // end of data counter/flag
00030         total_files;                        // files processed
00031 
00032 UINT    sb_size= 0;                         // sliding buffer size
00033 
00034 BYTE    bsize,                              // bits left to process
00035        *sb=NULL, *sbp=NULL, *sbe=NULL;      // sliding buffer, ptr, and end
00036 
00037 char   *init_path,                          // start up drive and path
00038       **pos_parms,                          // positional parms array
00039         spin,                               // keep alive character index
00040         zfn[MAX_PATH_ZIPINFO],                      // zip filename and path
00041         output_path[MAX_PATH_ZIPINFO],              // base output path
00042         sw_dirs,                            // create directory switch
00043         sw_freshen,                         // freshen target files switch
00044         sw_new,                             // retrieve newer files switch
00045         sw_overwrite,                       // overwrite files switch
00046         sw_test,                            // test file integrity switch
00047         sw_view,                            // view ZIP directory option
00048         sw_extract,                         // extract file option
00049        *sw_exclude;                         // exclude files option
00050 
00051 FILE   *ifile,                              // input file
00052        *ofile;                              // output file
00053 
00054 
00055 /* ******************************************************************** *
00056  *
00057  *  Messages and Strings
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  *  Command Line Switches
00131  *
00132  * ******************************************************************** */
00133 
00134 //##ModelId=3B9E68D800AB
00135 struct  cmd_parm                            // command line parm entry
00136     {
00137     char cp_ltr,                                // switch letter
00138         *cp_entry,                              // pointer to data
00139          cp_flag;                               // flag
00140                                                 //  0 = switch flag    -x
00141                                                 //  1 = switch w/data  -x999
00142     };
00143 
00144 struct  cmd_parm parm_table[] =             // command line parms
00145     {
00146     { 'D', &sw_dirs,             0 },           // D - create directories
00147     { 'F', &sw_freshen,          0 },           // F - freshen target files
00148     { 'N', &sw_new,              0 },           // N - only newer files
00149     { 'O', &sw_overwrite,        0 },           // O - overwrite files
00150     { 'T', &sw_test,             0 },           // T - test file integrity
00151     { 'V', &sw_view,             0 },           // V - view ZIP directory
00152     { 'E', &sw_extract,          0 }            // E - extract file(s)
00153  // { 'X', (char *) &sw_exclude, 1 }            // X - exclude files
00154     };
00155 
00156 
00157 
00158 /* ******************************************************************** *
00159  *
00160  *  Split Filename Structure
00161  *
00162  * ******************************************************************** */
00163 
00164 //##ModelId=3B9E68D9035B
00165 struct  split_filename                      // split filename entry
00166     {
00167     char path[MAX_PATH_ZIPINFO],                        // full filename
00168          drv[3],                                // drive letter
00169          dir[MAX_PATH_ZIPINFO],                         // directory name
00170          fname[10],                             // filename
00171          ext[5];                                // ..and extension
00172     };
00173 
00174 typedef struct split_filename SFS;          // structure shorthand
00175 
00176 #define SPLIT(x)    fnsplit(x.path,         /* split file into its */   \
00177                         x.drv,  x.dir,      /* basic components    */   \
00178                         x.fname, x.ext);
00179 
00180 SFS *sf,                                    // select files
00181         wf,                                    // working file
00182         ef;                                    // exclude file
00183 
00184 
00185 
00186 /* ******************************************************************** *
00187  *
00188  *  Inflate Constants
00189  *
00190  *  These tables are taken from PKZIP's appnote.txt.
00191  *
00192  * ******************************************************************** */
00193 
00194 
00195 UINT bll[] =                                // bit length code lengths
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[] =                                // copy lengths for literal ..
00202     {                                       // ..codes 257 thru 285
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[] =                                // extra bits for literal
00210     {                                       // ..codes 257 thru 285
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[] =                                // copy distance offsets
00217     {                                       // ..for codes 0 thru 29
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[] =                                // copy extra bits for distance
00225     {                                       // ..codes 0 thru 29
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  *  malloc_chk() -- allocate memory with error processing
00236  *
00237  * ******************************************************************** */
00238 
00239 void   *malloc_chk(int n)                  // size of block
00240 {
00241         void   *s;                                  // temporary pointers
00242         if (NOT (s = appMalloc(n)))                    // q. enough memory?
00243                 //Error("[Unzip] Reservando memoria\n");        // a. no .. give error msg
00244 
00245         memset((char *) s,0,(long) n);             // else .. clear to nulls
00246         return(s);                                // ..and return w/address
00247 
00248 }
00249 
00250 /* ******************************************************************** *
00251  *
00252  *  quit_with( char * )
00253  *
00254  * ******************************************************************** */
00255 void    quit_with( char *error ) 
00256 {
00257         printf("UNZIP_globals.h [%s]\n",error);
00258         //Error( error );
00259 }
00260 
00261 

Copyright(C) gvSystem & GamePlus All Rights Reserved.