Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.7 KiB

  1. typedef struct tagLZI {
  2. BYTE *rgbyteRingBuf; // ring buffer for expansion
  3. BYTE *rgbyteInBuf; // input buffer for reads
  4. BYTE *pbyteInBufEnd; // pointer past end of rgbyteInBuf[]
  5. BYTE *pbyteInBuf; // pointer to next byte to read from
  6. BYTE *rgbyteOutBuf; // output buffer for writes
  7. BYTE *pbyteOutBufEnd; // pointer past end of rgbyteOutBuf[]
  8. BYTE *pbyteOutBuf; // pointer to last byte to write from
  9. // Flag indicating whether or not rgbyteInBuf[0], which holds the last byte
  10. // from the previous input buffer, should be read as the next input byte.
  11. // (Only used so that at least one unReadUChar() can be done at all input
  12. // buffer positions.)
  13. BOOL bLastUsed;
  14. // Actually, rgbyteInBuf[] has length (ucbInBufLen + 1) since rgbyteInBuf[0]
  15. // is used when bLastUsed is TRUE.
  16. INT cbMaxMatchLen; // longest match length for current algorithm
  17. LONG cblInSize, // size in bytes of input file
  18. cblOutSize; // size in bytes of output file
  19. DWORD ucbInBufLen, // length of input buffer
  20. ucbOutBufLen; // length of output buffer
  21. DWORD uFlags; // LZ decoding description byte
  22. INT iCurRingBufPos; // ring buffer offset
  23. INT *leftChild; // parents and left and right
  24. INT *rightChild; // children that make up the
  25. INT *parent; // binary search trees
  26. INT iCurMatch, // index of longest match (set by LZInsertNode())
  27. cbCurMatch; // length of longest match (set by LZInsertNode())
  28. } LZINFO;
  29. typedef LZINFO *PLZINFO;
  30. typedef struct _dcx {
  31. INT dcxDiamondLastIoError;
  32. HFDI dcxFdiContext;
  33. ERF dcxFdiError;
  34. } DIAMOND_CONTEXT;
  35. typedef DIAMOND_CONTEXT *PDIAMOND_CONTEXT;
  36. extern DWORD itlsDiamondContext;
  37. #define ITLS_ERROR (0xFFFFFFFF)
  38. #define GotDmdTlsSlot() (itlsDiamondContext != ITLS_ERROR)
  39. #define GotDmdContext() (TlsGetValue(itlsDiamondContext) != NULL)
  40. #define FdiContext (((GotDmdTlsSlot() && GotDmdContext()) ? ((PDIAMOND_CONTEXT)(TlsGetValue(itlsDiamondContext)))->dcxFdiContext : NULL))
  41. #define SetFdiContext(v) (((PDIAMOND_CONTEXT)(TlsGetValue(itlsDiamondContext)))->dcxFdiContext = (v))
  42. #define FdiError (((PDIAMOND_CONTEXT)(TlsGetValue(itlsDiamondContext)))->dcxFdiError)
  43. #define DiamondLastIoError (((PDIAMOND_CONTEXT)(TlsGetValue(itlsDiamondContext)))->dcxDiamondLastIoError)
  44. DWORD
  45. InitDiamond(
  46. VOID
  47. );
  48. VOID
  49. TermDiamond(
  50. VOID
  51. );
  52. BOOL
  53. IsDiamondFile(
  54. IN PSTR FileName
  55. );
  56. INT
  57. ExpandDiamondFile(
  58. IN PSTR SourceFileName, // Because LZOpen ... returns ASCII!
  59. IN PTSTR TargetFileName,
  60. IN BOOL RenameTarget,
  61. OUT PLZINFO pLZI
  62. );