📄 cb.h
字号:
** Determine the size (in bytes) of the data packet currently resident in
** the ComBuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf
**
** Outputs:
** Return - The current size of the packet in the ComBuf
**
** Usage:
** iSize = CB_GetDataSizeComBuf( pComBuf );
**
**---------------------------------------------------------------------------
*/
#define CB_GetDataSizeComBuf( pComBuf ) ( (pComBuf)->iDataSize )
/*---------------------------------------------------------------------------
**
** CB_NewComBuf()
**
** Allocate memory for a ComBuf, set its buffer dimension, and initialize it
** to the empty state.
**
**---------------------------------------------------------------------------
**
** Inputs:
** iSize - Combuf data buffer size (to be allocated)
**
** Outputs:
** Return - Pointer to the new ComBuf
** NULL if memory allocation failed
**
** Usage:
** pComBuf = CB_NewComBuf( iSize );
**
**---------------------------------------------------------------------------
*/
EXTFUNC CB_ComBufType *CB_NewComBuf( UINT32 iSize ); /* Size changed to make compatable with msvc jjw 9/26/99 */
/*---------------------------------------------------------------------------
**
** CB_PrependComBuf()
**
** Add (prepend) a header segment to a packet in a ComBuf (concatenate at
** the front).
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf
** pSrc - Source data pointer
** iSize - Size of header segment to be prepended
**
** Outputs:
** None
**
** Usage:
** CB_PrependComBuf( pComBuf, pSrc, iSize );
**
**---------------------------------------------------------------------------
*/
#define CB_PrependComBuf( pComBuf, pSrc, iSize ) \
{ \
GS_LogEventIf( (pComBuf)->iDataSize + (iSize) > (pComBuf)->iBufSize, \
CB_OVERFLOW, \
((pComBuf)->iDataSize + (iSize) - (pComBuf)->iBufSize), /* jjw 9/26/99 added parenth for typedef on msvc */ \
(void*)(pComBuf), \
FATAL ); \
(pComBuf)->iDataSize += (iSize); \
(pComBuf)->pData -= (iSize); \
UC_CopyMem( (pComBuf)->pData, (pSrc), (iSize) ); \
}
/*---------------------------------------------------------------------------
**
** CB_ShrinkComBuf()
**
** Delete a header segment from a packet in a ComBuf. The size argument
** specifies how many bytes to delete from the ComBuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf
** iSize - Size of header segment to be stripped
**
** Outputs:
** None
**
** Usage:
** CB_ShrinkComBuf( pComBuf, iSize );
**
**---------------------------------------------------------------------------
*/
#define CB_ShrinkComBuf( pComBuf, iSize ) \
{ \
GS_LogEventIf( (iSize) > (pComBuf)->iDataSize, \
CB_UNDERFLOW, \
((iSize) - (pComBuf)->iDataSize), /* jjw 9/26/99 added parenth for typedef on msvc */ \
(void*)(pComBuf), \
FATAL ); \
(pComBuf)->iDataSize -= (iSize); \
(pComBuf)->pData += (iSize); \
}
/*---------------------------------------------------------------------------
**
** CB_ShrinkOffsetComBuf()
**
** Delete some portion of the data in the middle of a ComBuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf
** iOffset - Byte offset of data to be removed
** iSize - Size of data to be removed
**
** Outputs:
** None
**
** Usage:
** CB_ShrinkOffsetComBuf( pComBuf, iOffset, iSize );
**
**---------------------------------------------------------------------------
*/
#define CB_ShrinkOffsetComBuf( pComBuf, iOffset, iSize ) \
{ \
GS_LogEventIf( (iSize) > (pComBuf)->iDataSize, \
CB_UNDERFLOW, \
((iSize) - (pComBuf)->iDataSize), /* jjw 9/26/99 added parenth for typedef on msvc */ \
(void*)(pComBuf), \
FATAL ); \
if( ( (pComBuf)->iDataSize - (iOffset) - (iSize) ) > 0 ) \
{ \
UC_CopyMem( (pComBuf)->pData + (iOffset), \
(pComBuf)->pData + (iOffset) + (iSize), \
(pComBuf)->iDataSize - (iOffset) - (iSize) ); \
} \
(pComBuf)->iDataSize -= (iSize); \
}
/*---------------------------------------------------------------------------
**
** CB_StripComBuf()
**
** Remove (strip) a header segment from a packet in a ComBuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf
** pDest - Destination data pointer
** iSize - Size of header segment to be stripped
**
** Outputs:
** None
**
** Usage:
** CB_StripComBuf( pComBuf, pDest, iSize );
**
**---------------------------------------------------------------------------
*/
#define CB_StripComBuf( pComBuf, pDest, iSize ) \
{ \
GS_LogEventIf( (iSize) > (pComBuf)->iDataSize, \
CB_UNDERFLOW, \
((iSize) - (pComBuf)->iDataSize), /* jjw 9/26/99 added parenth for typedef on msvc */ \
(void*)(pComBuf), \
FATAL ); \
UC_CopyMem( (pDest), (pComBuf)->pData, (iSize) ); \
(pComBuf)->iDataSize -= (iSize); \
(pComBuf)->pData += (iSize); \
}
/*---------------------------------------------------------------------------
**
** CB_TradeForBigger()
**
** Trade in a combuf for an appropriately sized larger one.
** Ensures there is at least the same amount of header space.
** Returns with the remaining data copied into the new combuf,
** but with the data pointer set to iNewDataSize.
** If a combuf big enough is not available, return NULL but retain
** the original combuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf to check/trade in
** iNewDataSize - Amount of new space needed for data
** Not including the existing data
**
** Outputs:
** Return - Pointer to big enough combuf
** NULL if big enough combuf not available
** (Original combuf still intact)
** Usage:
** pComBufNew = CB_TradeForBigger( pComBuf, 50 );
**
**---------------------------------------------------------------------------
*/
EXTFUNC CB_ComBufType *CB_TradeForBigger( CB_ComBufType *pComBuf,
UINT32 iNewDataSize /* jjw 9/29/99 changed size */
);
/*---------------------------------------------------------------------------
**
** CB_TradeForBiggerClear()
**
** Trade in a combuf for an appropriately sized empty larger one.
** Ensures there is at least the same amount of header space.
** If a combuf big enough is not available, return NULL but retain
** the original combuf.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to ComBuf to check/trade in
** iNewDataSize - Amount of space needed for data
**
** Outputs:
** Return - Pointer to big enough combuf
** NULL if big enough combuf not available
** (Original combuf still intact)
** Usage:
** pComBufNew = CB_TradeForBiggerClear( pComBuf, 50 );
**
**---------------------------------------------------------------------------
*/
EXTFUNC CB_ComBufType *CB_TradeForBiggerClear( CB_ComBufType *pComBuf,
UINT32 iNewDataSize /* jjw 9/29/99 changed size */
);
/*---------------------------------------------------------------------------
**
** CB_WordAlignComBuf()
**
** Ensure that the first active data byte in a combuf is at a word boundary.
** Move all the data 1 byte ahead if misaligned. This is needed only for
** processors that bus fault if they attempt to access word data on an
** odd address. For processors with reasonable bus units, this service
** macros out to nothing.
**
**---------------------------------------------------------------------------
**
** Inputs:
** pComBuf - Pointer to Combuf.
** fMoveData - Move any existing data in the combuf
**
** Outputs:
** None
**
** Usage:
** CB_WordAlignComBuf( pComBuf, TRUE );
**
**---------------------------------------------------------------------------
*/
#ifdef WORD_ALIGN_WORD_DATA
EXTFUNC void CB_WordAlignComBuf( CB_ComBufType *pComBuf, BOOL fMoveData );
#else
#define CB_WordAlignComBuf( pComBuf, fMoveData )
#endif
#endif /* inclusion lock */
/****************************************************************************
**
** End of CB.H
**
*****************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -