Leaked source code of windows server 2003
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.

140 lines
4.1 KiB

  1. /*
  2. ** common.h - housekeeping for Lempel-Ziv compression / expansion DOS
  3. ** command-line programs, DOS static library module, and Windows
  4. ** DLL
  5. **
  6. ** Author: DavidDi
  7. */
  8. // Headers
  9. ///////////
  10. #ifdef LZA_DLL
  11. #include <windows.h>
  12. #include <port1632.h>
  13. #endif
  14. //#include <lzdos.h>
  15. #include "translat.h"
  16. // Set up type for function argument pointers.
  17. #ifdef LZA_DLL
  18. #define ARG_PTR FAR
  19. #else
  20. #define ARG_PTR // nada
  21. #endif
  22. // Constants
  23. /////////////
  24. #define NOTIFY_START_COMPRESS 0 // file processing notifications
  25. #define NOTIFY_START_EXPAND 1 //
  26. #define NOTIFY_START_COPY 2 //
  27. #define BLANK_ERROR 0 // error condition requiring no error
  28. // message display
  29. // Types
  30. /////////
  31. // Callback notification procedure.
  32. typedef BOOL (*NOTIFYPROC)(LPWSTR pszSource, LPWSTR pszDest,
  33. WORD wProcessFlag);
  34. // Flag indicating whether or not rgbyteInBuf[0], which holds the last byte
  35. // from the previous input buffer, should be read as the next input byte.
  36. // (Only used so that at least one unReadUChar() can be done at all input
  37. // buffer positions.)
  38. typedef struct tagLZI {
  39. BYTE *rgbyteRingBuf; // ring buffer for expansion
  40. BYTE *rgbyteInBuf; // input buffer for reads
  41. BYTE *pbyteInBufEnd; // pointer past end of rgbyteInBuf[]
  42. BYTE *pbyteInBuf; // pointer to next byte to read from
  43. BYTE *rgbyteOutBuf; // output buffer for writes
  44. BYTE *pbyteOutBufEnd; // pointer past end of rgbyteOutBuf[]
  45. BYTE *pbyteOutBuf; // pointer to last byte to write from
  46. // Flag indicating whether or not rgbyteInBuf[0], which holds the last byte
  47. // from the previous input buffer, should be read as the next input byte.
  48. // (Only used so that at least one unReadUChar() can be done at all input
  49. // buffer positions.)
  50. BOOL bLastUsed;
  51. // Actually, rgbyteInBuf[] has length (ucbInBufLen + 1) since rgbyteInBuf[0]
  52. // is used when bLastUsed is TRUE.
  53. INT cbMaxMatchLen; // longest match length for current algorithm
  54. LONG cblInSize, // size in bytes of input file
  55. cblOutSize; // size in bytes of output file
  56. DWORD ucbInBufLen, // length of input buffer
  57. ucbOutBufLen; // length of output buffer
  58. DWORD uFlags; // LZ decoding description byte
  59. INT iCurRingBufPos; // ring buffer offset
  60. INT *leftChild; // parents and left and right
  61. INT *rightChild; // children that make up the
  62. INT *parent; // binary search trees
  63. INT iCurMatch, // index of longest match (set by LZInsertNode())
  64. cbCurMatch; // length of longest match (set by LZInsertNode())
  65. } LZINFO;
  66. typedef LZINFO *PLZINFO;
  67. // Macros
  68. //////////
  69. #define FOREVER for(;;)
  70. #ifndef MAX
  71. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  72. #endif
  73. #ifndef MIN
  74. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  75. #endif
  76. // Prototypes
  77. //////////////
  78. // compress.c
  79. extern INT Compress(NOTIFYPROC pfnNotify, LPWSTR pszSource,
  80. LPWSTR pszDest, BYTE byteAlgorithm,
  81. BOOL bDoRename, PLZINFO pLZI);
  82. // expand.c
  83. // dosdir.asm
  84. extern INT GetCurDrive(VOID);
  85. extern INT GetCurDir(LPSTR lpszDirBuf);
  86. extern INT SetDrive(INT wDrive);
  87. extern INT SetDir(LPSTR lpszDirName);
  88. extern INT IsDir(LPSTR lpszDir);
  89. extern INT IsRemoveable(INT wDrive);
  90. extern WCHAR MakeCompressedNameW(LPWSTR pszFileName);
  91. extern INT CopyDateTimeStamp(HANDLE doshFrom, HANDLE doshTo);
  92. LPWSTR ExtractExtensionW(LPWSTR pszFileName);
  93. LPWSTR ExtractFileNameW(LPWSTR pszPathName);
  94. extern BOOL LZIsCharLowerA(char cChar);
  95. extern BOOL LZIsCharUpperA(char cChar);
  96. extern LPSTR LZCharNextA(LPCSTR lpCurrentChar);
  97. extern LPSTR LZCharPrevA(LPCSTR lpStart, LPCSTR lpCurrentChar);
  98. #undef IsCharLower
  99. #undef IsCharUpper
  100. #undef CharNext
  101. #undef CharPrev
  102. #define IsCharLower LZIsCharLowerA
  103. #define IsCharUpper LZIsCharUpperA
  104. #define CharNext LZCharNextA
  105. #define CharPrev LZCharPrevA