MCPcopy Create free account
hub / github.com/diasurgical/devilution / implode

Function implode

3rdParty/PKWare/implode.cpp:688–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

686// Main imploding function
687
688unsigned int PKWAREAPI implode(
689 unsigned int (PKWAREAPI *read_buf)(char *buf, unsigned int *size, void *param),
690 void (PKWAREAPI *write_buf)(char *buf, unsigned int *size, void *param),
691 char *work_buf,
692 void *param,
693 unsigned int *type,
694 unsigned int *dsize)
695{
696 TCmpStruct * pWork = (TCmpStruct *)work_buf;
697 unsigned int nChCode;
698 unsigned int nCount;
699 unsigned int i;
700 int nCount2;
701
702 // Fill the work buffer information
703 // Note: The caller must zero the "work_buff" before passing it to implode
704 pWork->read_buf = read_buf;
705 pWork->write_buf = write_buf;
706 pWork->dsize_bytes = *dsize;
707 pWork->ctype = *type;
708 pWork->param = param;
709 pWork->dsize_bits = 4;
710 pWork->dsize_mask = 0x0F;
711
712 // Test dictionary size
713 switch(*dsize)
714 {
715 case CMP_IMPLODE_DICT_SIZE3: // 0x1000 bytes
716 pWork->dsize_bits++;
717 pWork->dsize_mask |= 0x20;
718 // No break here !!!
719
720 case CMP_IMPLODE_DICT_SIZE2: // 0x800 bytes
721 pWork->dsize_bits++;
722 pWork->dsize_mask |= 0x10;
723 // No break here !!!
724
725 case CMP_IMPLODE_DICT_SIZE1: // 0x400
726 break;
727
728 default:
729 return CMP_INVALID_DICTSIZE;
730 }
731
732 // Test the compression type
733 switch(*type)
734 {
735 case CMP_BINARY: // We will compress data with binary compression type
736 for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++)
737 {
738 pWork->nChBits[nCount] = 9;
739 pWork->nChCodes[nCount] = (unsigned short)nChCode;
740 nChCode = (nChCode & 0x0000FFFF) + 2;
741 }
742 break;
743
744
745 case CMP_ASCII: // We will compress data with ASCII compression type

Callers 2

PkwareCompressFunction · 0.85
Compress_PKLIBFunction · 0.85

Calls 1

WriteCmpDataFunction · 0.85

Tested by

no test coverage detected