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.

152 lines
4.8 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 chEXTENSION_CHAR '_'
  25. #define pszEXTENSION_STR "_"
  26. #define pszNULL_EXTENSION "._"
  27. #define NOTIFY_START_COMPRESS 0 // file processing notifications
  28. #define NOTIFY_START_EXPAND 1 //
  29. #define NOTIFY_START_COPY 2 //
  30. #define BLANK_ERROR 0 // error condition requiring no error
  31. // message display
  32. // Types
  33. /////////
  34. // Callback notification procedure.
  35. typedef BOOL (*NOTIFYPROC)(CHAR ARG_PTR *pszSource, CHAR ARG_PTR *pszDest,
  36. WORD wProcessFlag);
  37. // Flag indicating whether or not rgbyteInBuf[0], which holds the last byte
  38. // from the previous input buffer, should be read as the next input byte.
  39. // (Only used so that at least one unReadUChar() can be done at all input
  40. // buffer positions.)
  41. typedef struct tagLZI {
  42. BYTE *rgbyteRingBuf; // ring buffer for expansion
  43. BYTE *rgbyteInBuf; // input buffer for reads
  44. BYTE *pbyteInBufEnd; // pointer past end of rgbyteInBuf[]
  45. BYTE *pbyteInBuf; // pointer to next byte to read from
  46. BYTE *rgbyteOutBuf; // output buffer for writes
  47. BYTE *pbyteOutBufEnd; // pointer past end of rgbyteOutBuf[]
  48. BYTE *pbyteOutBuf; // pointer to last byte to write from
  49. // Flag indicating whether or not rgbyteInBuf[0], which holds the last byte
  50. // from the previous input buffer, should be read as the next input byte.
  51. // (Only used so that at least one unReadUChar() can be done at all input
  52. // buffer positions.)
  53. BOOL bLastUsed;
  54. // Actually, rgbyteInBuf[] has length (ucbInBufLen + 1) since rgbyteInBuf[0]
  55. // is used when bLastUsed is TRUE.
  56. INT cbMaxMatchLen; // longest match length for current algorithm
  57. LONG cblInSize, // size in bytes of input file
  58. cblOutSize; // size in bytes of output file
  59. DWORD ucbInBufLen, // length of input buffer
  60. ucbOutBufLen; // length of output buffer
  61. DWORD uFlags; // LZ decoding description byte
  62. INT iCurRingBufPos; // ring buffer offset
  63. INT *leftChild; // parents and left and right
  64. INT *rightChild; // children that make up the
  65. INT *parent; // binary search trees
  66. INT iCurMatch, // index of longest match (set by LZInsertNode())
  67. cbCurMatch; // length of longest match (set by LZInsertNode())
  68. } LZINFO;
  69. typedef LZINFO *PLZINFO;
  70. // Macros
  71. //////////
  72. #define FOREVER for(;;)
  73. #ifndef MAX
  74. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  75. #endif
  76. #ifndef MIN
  77. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  78. #endif
  79. // Prototypes
  80. //////////////
  81. // compress.c
  82. extern INT Compress(NOTIFYPROC pfnNotify, CHAR ARG_PTR *pszSource,
  83. CHAR ARG_PTR *pszDest, BYTE byteAlgorithm,
  84. BOOL bDoRename, PLZINFO pLZI);
  85. // expand.c
  86. extern INT Expand(NOTIFYPROC pfnNotify, CHAR ARG_PTR *pszSource,
  87. CHAR ARG_PTR *pszDest, BOOL bDoRename, PLZINFO pLZI);
  88. extern INT ExpandOrCopyFile(INT doshSource, INT doshDest, PLZINFO pLZI);
  89. // dosdir.asm
  90. extern INT GetCurDrive(VOID);
  91. extern INT GetCurDir(LPSTR lpszDirBuf);
  92. extern INT SetDrive(INT wDrive);
  93. extern INT SetDir(LPSTR lpszDirName);
  94. extern INT IsDir(LPSTR lpszDir);
  95. extern INT IsRemoveable(INT wDrive);
  96. // utils.c
  97. extern CHAR ARG_PTR *ExtractFileName(CHAR ARG_PTR *pszPathName);
  98. extern CHAR ARG_PTR *ExtractExtension(CHAR ARG_PTR *pszFileName);
  99. extern VOID MakePathName(CHAR ARG_PTR *pszPath, CHAR ARG_PTR *pszFileName);
  100. extern CHAR MakeCompressedName(CHAR ARG_PTR *pszFileName);
  101. extern LPWSTR ExtractFileNameW(LPWSTR pszPathName);
  102. extern LPWSTR ExtractExtensionW(LPWSTR pszFileName);
  103. extern WCHAR MakeCompressedNameW(LPWSTR pszFileName);
  104. extern VOID MakeExpandedName(CHAR ARG_PTR *pszFileName,
  105. BYTE byteExtensionChar);
  106. extern INT CopyDateTimeStamp(INT_PTR doshFrom, INT_PTR doshTo);
  107. extern BOOL LZIsCharLowerA(char cChar);
  108. extern BOOL LZIsCharUpperA(char cChar);
  109. extern LPSTR LZCharNextA(LPCSTR lpCurrentChar);
  110. extern LPSTR LZCharPrevA(LPCSTR lpStart, LPCSTR lpCurrentChar);
  111. #undef IsCharLower
  112. #undef IsCharUpper
  113. #undef CharNext
  114. #undef CharPrev
  115. #define IsCharLower LZIsCharLowerA
  116. #define IsCharUpper LZIsCharUpperA
  117. #define CharNext LZCharNextA
  118. #define CharPrev LZCharPrevA