285 lines
9.5 KiB
C
285 lines
9.5 KiB
C
/****************************************************************************
|
|
|
|
|
| (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc.
|
|
| All Rights Reserved.
|
|
|
|
|
| This program is free software; you can redistribute it and/or
|
|
| modify it under the terms of version 2 of the GNU General Public
|
|
| License as published by the Free Software Foundation.
|
|
|
|
|
| This program is distributed in the hope that it will be useful,
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| GNU General Public License for more details.
|
|
|
|
|
| You should have received a copy of the GNU General Public License
|
|
| along with this program; if not, contact Novell, Inc.
|
|
|
|
|
| To contact Novell about this file by physical or electronic mail,
|
|
| you may find current contact information at www.novell.com
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| Netware file compression algorithm ported to NSS
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: vandana $
|
|
| $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $
|
|
|
|
|
| $RCSfile$
|
|
| $Revision: 1177 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| Module Description:
|
|
|
|
|
+-------------------------------------------------------------------------*/
|
|
#ifndef __CDCOMMON_H__
|
|
#define __CDCOMMON_H__
|
|
|
|
typedef struct compressFileHeader_s {
|
|
|
|
BYTE CompressCode;
|
|
BYTE CompressMajorVersion;
|
|
BYTE CompressMinorVersion;
|
|
BYTE Unused;
|
|
LONG OriginalFileLength;
|
|
LONG CompressedFileLength;
|
|
LONG DataTreeNodes;
|
|
|
|
LONG LengthTreeNodes;
|
|
LONG OffsetTreeNodes;
|
|
LONG NumberOfHoles;
|
|
LONG HeaderCheckSum;
|
|
|
|
} compressFileHeader_t, *compressFileHeader_tp, **compressFileHeader_tpp;
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
typedef struct AlgorithmCustomStats_s {
|
|
|
|
BYTE *Description;
|
|
LONG Value;
|
|
|
|
} COMPRESS_CUSTOM_STATS, *COMPRESS_CUSTOM_STATS_P;
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
typedef struct CompressFileEntry_s {
|
|
|
|
struct CompressFileEntry_s *next;
|
|
|
|
BYTE *FileName; /* Null terminated name */
|
|
LONG Volume;
|
|
LONG PercentageComplete;
|
|
|
|
} COMPRESS_FILE_ENTRY;
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
typedef struct CompressionStats_s {
|
|
|
|
BYTE *CompressionAlgorithmName;
|
|
LONG CompressionAlogrythmCode;
|
|
|
|
LONG NumberOfCompressions;
|
|
LONG UnableToCompressCount;
|
|
LONG TotalSectorsUsedIfNotCompressed;
|
|
LONG TotalSectorsUsedCompressed;
|
|
LONG CompressionTickCount;
|
|
LONG CompressionAbortedCount;
|
|
LONG CompressionMemoryAllocationFailures;
|
|
LONG CompressionIOErrors;
|
|
LONG CompressionFileTooBig;
|
|
LONG CompressionFileTooSmall;
|
|
|
|
COMPRESS_FILE_ENTRY *FilesBeingCompressed;
|
|
COMPRESS_FILE_ENTRY *FilesQueuedToBeCompressed;
|
|
|
|
/* custom statistics */
|
|
|
|
LONG CustomStatsCount;
|
|
|
|
COMPRESS_CUSTOM_STATS_P CustomStats;
|
|
|
|
} COMPRESS_STATS, *COMPRESS_STATS_P;
|
|
|
|
typedef struct DeCompressionStats_s {
|
|
|
|
BYTE *DecompressionAlgorithmName;
|
|
LONG DecompressionAlogrythmCode;
|
|
|
|
LONG TotalDecompressionsDone;
|
|
LONG TotalSectorsDecompressed;
|
|
LONG DecompressionTickCount;
|
|
LONG DecompressionAbortedCount;
|
|
LONG DecompressionMemoryAllocationFailures;
|
|
LONG DecompressionFileCorruptionCount;
|
|
LONG DecompressionIOErrors;
|
|
|
|
COMPRESS_FILE_ENTRY *FilesBeingDecompressed;
|
|
COMPRESS_FILE_ENTRY *FilesQueuedToBeDecompressed;
|
|
|
|
/* custom statistics */
|
|
|
|
LONG CustomStatsCount;
|
|
|
|
COMPRESS_CUSTOM_STATS_P CustomStats;
|
|
|
|
} DECOMPRESS_STATS, *DECOMPRESS_STATS_P;
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
/* things you might want to know:
|
|
1. file name
|
|
2. percent completed
|
|
3. stage
|
|
4. deleted file or not
|
|
5. ratio so far
|
|
6.
|
|
*/
|
|
|
|
/* stage : 0- analyzing file 1-building compressed version */
|
|
|
|
/* in cdcompi.inc and cduncomi.inc also */
|
|
|
|
typedef struct CompressStatus_s {
|
|
LONG directoryNumber;
|
|
LONG compressionStage;
|
|
LONG totalIntermediateBlocks;
|
|
LONG totalCompressedBlocks;
|
|
LONG totalInitialBlocks;
|
|
LONG currentIntermediateBlocks;
|
|
LONG currentCompressedBlocks;
|
|
LONG currentInitialBlocks;
|
|
LONG fileFlags;
|
|
LONG projectedCompressedSize; /* in bits */
|
|
LONG originalSize; /* in bits */
|
|
LONG compressVolume;
|
|
LONG minimumPercentageGain;
|
|
} CompressStatus_t ;
|
|
|
|
/* state : 0- starting 1-building trees 2-decompressing */
|
|
|
|
typedef struct DecompressStatus_s {
|
|
LONG directoryNumber;
|
|
LONG totalBlocksToDecompress;
|
|
LONG currentBlock;
|
|
LONG state;
|
|
LONG decompressVolume;
|
|
} DecompressStatus_t;
|
|
|
|
typedef struct DecompressStatusNode_s {
|
|
struct DecompressStatusNode_s *next;
|
|
struct DecompressStatusNode_s *prev;
|
|
DecompressStatus_t status;
|
|
} DecompressStatusNode_t ;
|
|
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
typedef struct CompressAlgorithm_s {
|
|
struct CompressAlgorithm_s *next;
|
|
LONG (*CompressFile)( IoHandle_t inHandle, IoHandle_t outHandle,
|
|
IoHandle_t tempHandle, LONG inFileSize, LONG volume,
|
|
ADDR *compressionHandle, BYTE *fileName,
|
|
CompressStatus_t *compressStatus );
|
|
void (*GetStats)();
|
|
BYTE CompressionCode;
|
|
struct ResourceTagStructure *ResourceTag;
|
|
} COMPRESS_ALGO, *COMPRESS_ALGO_P;
|
|
|
|
typedef struct DecompressAlgorithm_s {
|
|
struct DecompressAlgorithm_s *next;
|
|
LONG (*DecompressFile)( IoHandle_t inHandle, IoHandle_t outHandle,
|
|
ADDR *decompressHandle, BYTE *fileName, LONG volume,
|
|
LONG directoryEntry );
|
|
void (*GetStats)();
|
|
BYTE DecompressionCode;
|
|
struct ResourceTagStructure *ResourceTag;
|
|
} DECOMPRESS_ALGO, *DECOMPRESS_ALGO_P;
|
|
|
|
|
|
/***************************************************************************
|
|
*
|
|
*
|
|
*
|
|
***************************************************************************/
|
|
|
|
#define SWAP_LONG( x ) (long)\
|
|
(( (unsigned long) ((unsigned long)((unsigned long)(x) & (unsigned long)0xFF000000) >> 24)) \
|
|
| ( (unsigned long) ((unsigned long)((unsigned long)(x) & (unsigned long)0x00FF0000) >> 8 )) \
|
|
| ( (unsigned long) ((unsigned long)((unsigned long)(x) & (unsigned long)0x0000FF00) << 8 )) \
|
|
| ( (unsigned long) ((unsigned long)((unsigned long)(x) & (unsigned long)0x000000FF) << 24)))
|
|
|
|
/************************************************************************
|
|
*
|
|
* Major and minor versions.
|
|
*
|
|
************************************************************************/
|
|
|
|
#define COMPRESS_MAJOR_VERSION 1
|
|
#define COMPRESS_MINOR_VERSION 0
|
|
|
|
/*************************************************************************
|
|
*
|
|
* These bits indicate whether the file was compressed on a low hi
|
|
* machine or a hi-low machine. This bit is on or off in the compressCode
|
|
*
|
|
*************************************************************************/
|
|
|
|
#define NETWARE_COMPRESS_LOHI 0x01
|
|
#define NETWARE_COMPRESS_HILO 0x02
|
|
#define ARJ_COMPRESS_LOHI 0x03
|
|
#define ARJ_COMPRESS_HILO 0x04
|
|
|
|
extern DecompressStatusNode_t *VolumeDecompressFilesTail[];
|
|
extern DecompressStatusNode_t *VolumeDecompressFiles[];
|
|
extern CompressStatus_t *VolumeCurrentCompressingFile[];
|
|
|
|
extern LONG VolumeCompressHighTickHigh[]; /* high order dword of total */
|
|
extern LONG VolumeCompressHighTickCount[];/* high resolution tick count spent in compression */
|
|
extern LONG VolumeCompressByteInCount[];
|
|
extern LONG VolumeCompressByteOutCount[];
|
|
extern LONG VolumeCompressHighByteInCount[];
|
|
extern LONG VolumeCompressHighByteOutCount[];
|
|
|
|
extern LONG VolumeDecompressHighTickHigh[];
|
|
extern LONG VolumeDecompressHighTickCount[];
|
|
extern LONG VolumeDecompressByteInCount[];
|
|
extern LONG VolumeDecompressByteOutCount[];
|
|
extern LONG VolumeDecompressHighByteInCount[];
|
|
extern LONG VolumeDecompressHighByteOutCount[];
|
|
|
|
#define CompressionDisabled 0
|
|
#define CompressionMounting 1
|
|
#define CompressionEnabled 2
|
|
#define CompressionDismounting 3
|
|
|
|
extern BYTE CompressionEnabledTable[];
|
|
|
|
#endif /* __CDCOMMON_H__ */
|
|
|
|
/****************************************************************************/
|
|
/****************************************************************************/
|