diff options
| -rw-r--r-- | src/pklib/explode.c | 31 | ||||
| -rw-r--r-- | src/pklib/implode.c | 7 | ||||
| -rw-r--r-- | src/pklib/pklib.h | 16 | 
3 files changed, 25 insertions, 29 deletions
diff --git a/src/pklib/explode.c b/src/pklib/explode.c index 0f551d8..35210fb 100644 --- a/src/pklib/explode.c +++ b/src/pklib/explode.c @@ -31,7 +31,7 @@ char CopyrightPkware[] = "PKWARE Data Compression Library for Win32\r\n"  //-----------------------------------------------------------------------------  // Tables -unsigned char DistBits[0x40] = +const unsigned char DistBits[0x40] =  {      0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,      0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, @@ -39,7 +39,7 @@ unsigned char DistBits[0x40] =      0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08  }; -unsigned char DistCode[0x40] = +const unsigned char DistCode[0x40] =  {      0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A,      0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, @@ -47,28 +47,28 @@ unsigned char DistCode[0x40] =      0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00  }; -unsigned char ExLenBits[0x10] = +const unsigned char ExLenBits[0x10] =  {      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08  }; -unsigned short LenBase[0x10] = +const unsigned short LenBase[0x10] =  {      0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,      0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106  }; -unsigned char LenBits[0x10] = +const unsigned char LenBits[0x10] =  {      0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07  }; -unsigned char LenCode[0x10] = +const unsigned char LenCode[0x10] =  {      0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00  }; -unsigned char ChBitsAsc[0x100] = +const unsigned char ChBitsAsc[0x100] =  {      0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C,      0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, @@ -88,7 +88,7 @@ unsigned char ChBitsAsc[0x100] =      0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D  }; -unsigned short ChCodeAsc[0x100] = +const unsigned short ChCodeAsc[0x100] =  {      0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0,      0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, @@ -128,10 +128,10 @@ unsigned short ChCodeAsc[0x100] =  // Local functions  static void GenDecodeTabs( -    unsigned char * positions,          // [out] Table of positions -    unsigned char * start_indexes,      // [in] Table of start indexes -    unsigned char * length_bits,        // [in] Table of lengths. Each length is stored as number of bits -    size_t elements)                    // [in] Number of elements in start_indexes and length_bits +    unsigned char * positions,           // [out] Table of positions +    const unsigned char * start_indexes, // [in] Table of start indexes +    const unsigned char * length_bits,   // [in] Table of lengths. Each length is stored as number of bits +    size_t elements)                     // [in] Number of elements in start_indexes and length_bits  {      unsigned int index;      unsigned int length; @@ -150,7 +150,7 @@ static void GenDecodeTabs(  static void GenAscTabs(TDcmpStruct * pWork)  { -    unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; +    const unsigned short * pChCodeAsc = &ChCodeAsc[0xFF];      unsigned int  acc, add;      unsigned short count; @@ -479,7 +479,6 @@ unsigned int PKEXPORT explode(      TDcmpStruct * pWork = (TDcmpStruct *)work_buf;      // Initialize work struct and load compressed data -    // Note: The caller must zero the "work_buff" before passing it to explode      pWork->read_buf   = read_buf;      pWork->write_buf  = write_buf;      pWork->param      = param; @@ -510,11 +509,11 @@ unsigned int PKEXPORT explode(      }      memcpy(pWork->LenBits, LenBits, sizeof(pWork->LenBits)); -    GenDecodeTabs(pWork->LengthCodes, LenCode, pWork->LenBits, sizeof(pWork->LenBits)); +    GenDecodeTabs(pWork->LengthCodes, LenCode, LenBits, sizeof(LenBits));      memcpy(pWork->ExLenBits, ExLenBits, sizeof(pWork->ExLenBits));      memcpy(pWork->LenBase, LenBase, sizeof(pWork->LenBase));      memcpy(pWork->DistBits, DistBits, sizeof(pWork->DistBits)); -    GenDecodeTabs(pWork->DistPosCodes, DistCode, pWork->DistBits, sizeof(pWork->DistBits)); +    GenDecodeTabs(pWork->DistPosCodes, DistCode, DistBits, sizeof(DistBits));      if(Expand(pWork) != 0x306)          return CMP_NO_ERROR; diff --git a/src/pklib/implode.c b/src/pklib/implode.c index 1484ee2..96baf98 100644 --- a/src/pklib/implode.c +++ b/src/pklib/implode.c @@ -599,13 +599,11 @@ unsigned int PKEXPORT implode(      unsigned int *dsize)  {      TCmpStruct * pWork = (TCmpStruct *)work_buf; -    unsigned int nChCode;      unsigned int nCount;      unsigned int i;      int nCount2;      // Fill the work buffer information -    // Note: The caller must zero the "work_buff" before passing it to implode      pWork->read_buf    = read_buf;      pWork->write_buf   = write_buf;      pWork->dsize_bytes = *dsize; @@ -638,11 +636,10 @@ unsigned int PKEXPORT implode(      switch(*type)      {          case CMP_BINARY: // We will compress data with binary compression type -            for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++) +            for(nCount = 0; nCount < 0x100; nCount++)              {                  pWork->nChBits[nCount]  = 9; -                pWork->nChCodes[nCount] = (unsigned short)nChCode; -                nChCode = (nChCode & 0x0000FFFF) + 2; +                pWork->nChCodes[nCount] = nCount * 2;              }              break; diff --git a/src/pklib/pklib.h b/src/pklib/pklib.h index d9b2a70..c1e328d 100644 --- a/src/pklib/pklib.h +++ b/src/pklib/pklib.h @@ -116,14 +116,14 @@ typedef struct  //-----------------------------------------------------------------------------  // Tables (in explode.c) -extern unsigned char DistBits[0x40]; -extern unsigned char DistCode[0x40]; -extern unsigned char ExLenBits[0x10]; -extern unsigned short LenBase[0x10]; -extern unsigned char LenBits[0x10]; -extern unsigned char LenCode[0x10]; -extern unsigned char ChBitsAsc[0x100]; -extern unsigned short ChCodeAsc[0x100]; +extern const unsigned char DistBits[0x40]; +extern const unsigned char DistCode[0x40]; +extern const unsigned char ExLenBits[0x10]; +extern const unsigned short LenBase[0x10]; +extern const unsigned char LenBits[0x10]; +extern const unsigned char LenCode[0x10]; +extern const unsigned char ChBitsAsc[0x100]; +extern const unsigned short ChCodeAsc[0x100];  //-----------------------------------------------------------------------------  // Public functions  | 
