174 lines
5.1 KiB
C
174 lines
5.1 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
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| NSS Compression Management module
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: taysom $
|
|
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
|
|
|
|
| $RCSfile$
|
|
| $Revision: 465 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| Module Description:
|
|
|
|
|
+-------------------------------------------------------------------------*/
|
|
#ifndef _COMP_FILE_H_
|
|
#define _COMP_FILE_H_
|
|
|
|
#ifndef NBITS
|
|
#define NBITS(_obj_) (sizeof(_obj_) * 8)
|
|
#endif
|
|
|
|
#define CHUNK_STATE_NBITS COMP_STATUS_NBITS
|
|
#define CHUNK_STATE_MASK ((1 << CHUNK_STATE_NBITS) - 1)
|
|
#define NCHUNKS_PER_BYTE (NBITS(BYTE) / CHUNK_STATE_NBITS)
|
|
#define NCHUNKS_PER_PAGE(_beast) ((1 << (_beast)->blkSizeShift) * NCHUNKS_PER_BYTE)
|
|
|
|
/* Made to look identical to the start of Legacy Netware's header */
|
|
typedef struct CompFileLayoutID_s
|
|
{
|
|
BYTE endian;
|
|
BYTE majorVersion;
|
|
BYTE minorVersion;
|
|
BYTE unused;
|
|
} NSS_MEDIA_STRUCTURE(CompFileLayoutID_s,unused) CompFileLayoutID_s;
|
|
#define NW_COMPFILE_MAJOR_VERSION 1
|
|
#define NW_COMPFILE_MINOR_VERSION 0
|
|
|
|
#define NSS_COMPFILE_MAJOR_VERSION 2
|
|
#define NSS_COMPFILE_MINOR_VERSION 0
|
|
extern CompFileLayoutID_s NW_compFileLayout_ID;
|
|
extern CompFileLayoutID_s NSS_compFileLayout_ID;
|
|
|
|
#define IS_COMPFILE_LAYOUT_NETWARE(_layoutId) \
|
|
((_layoutId).majorVersion == NW_COMPFILE_MAJOR_VERSION)
|
|
|
|
#define IS_COMPFILE_LAYOUT_NSS(_layoutId) \
|
|
((_layoutId).majorVersion == NSS_COMPFILE_MAJOR_VERSION)
|
|
|
|
typedef struct CompFileHdr_s
|
|
{
|
|
CompFileLayoutID_s fileLayout_ID;
|
|
BYTE algoID;
|
|
BYTE algoVersion;
|
|
LONG chunkSize; /* 0 means whole file */
|
|
LONG nvalidChunks; /* # of chunks whose state is maintained currently */
|
|
#define DIRECT_CHUNK_VECTOR_BYTES 8
|
|
#define NUM_DIRECT_CHUNKS (DIRECT_CHUNK_VECTOR_BYTES * NCHUNKS_PER_BYTE)
|
|
BYTE chunkStateVector[DIRECT_CHUNK_VECTOR_BYTES];
|
|
/* Bitmap indicating which chunks are compressed */
|
|
} NSS_MEDIA_STRUCTURE(CompFileHdr_s,chunkStateVector[DIRECT_CHUNK_VECTOR_BYTES]) CompFileHdr_s;
|
|
|
|
typedef struct CompChunkHdr_s
|
|
{
|
|
LONG compChunkSize; /* Size of compressed chunk */
|
|
LONG holeVector; /* Bitmap indicating which (4k) blocks in the chunk
|
|
* are holes; limits chunk size to 32 * 4K = 128kbytes */
|
|
BYTE algoID;
|
|
BYTE algoVersion;
|
|
} NSS_MEDIA_STRUCTURE(CompChunkHdr_s,algoVersion) CompChunkHdr_s;
|
|
|
|
STATUS
|
|
initCompDatastream(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *uncompBeast,
|
|
RootBeast_s *compBeast);
|
|
|
|
STATUS
|
|
getCompChunkOffset(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *beast,
|
|
QUAD chunkoffset,
|
|
LONG chunksize,
|
|
QUAD *compChunkOffset); /* out */
|
|
|
|
STATUS
|
|
setCompChunkOffset(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *beast,
|
|
QUAD chunkoffset,
|
|
LONG chunksize,
|
|
QUAD compChunkOffset);
|
|
|
|
STATUS
|
|
getChunkCompStatus(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *compBeast,
|
|
QUAD chunkoffset,
|
|
LONG chunksize,
|
|
NINT *status); /* out */
|
|
|
|
STATUS
|
|
setChunkCompStatus(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *compBeast,
|
|
QUAD chunkoffset,
|
|
LONG chunksize,
|
|
NINT status);
|
|
|
|
STATUS
|
|
CM_tossBeastUncompChunk(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *uncompBeast,
|
|
RootBeast_s *compBeast,
|
|
QUAD offset,
|
|
BOOL forceToss);
|
|
|
|
STATUS
|
|
CM_tossBeastCompChunk(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *uncompBeast,
|
|
RootBeast_s *compBeast,
|
|
QUAD offset,
|
|
BOOL forceToss);
|
|
|
|
#define setCompChunkValidRange(_genMsg, _beast, _chunkOffset, \
|
|
_chunkSize, _dataOffset, _dataSize) \
|
|
setBeastChunkValidRange(_genMsg, _beast, _chunkSize, _dataOffset, \
|
|
_dataSize)
|
|
|
|
STATUS
|
|
setBeastChunkValidRange(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *beast,
|
|
LONG chunksize,
|
|
QUAD dataOffset,
|
|
SLONG dataSize);
|
|
|
|
STATUS
|
|
CM_tossUncompBeastData(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *uncompBeast,
|
|
RootBeast_s *compBeast,
|
|
BOOL recovery);
|
|
|
|
STATUS
|
|
CM_tossCompBeastData(
|
|
GeneralMsg_s *genMsg,
|
|
RootBeast_s *uncompBeast,
|
|
BOOL tossCompBeast);
|
|
|
|
#endif /* _COMP_FILE_H_ */
|