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.

78 lines
2.5 KiB

  1. /*
  2. ** header.h - Common information used in compressed file header manipulation.
  3. **
  4. ** Author: DavidDi
  5. */
  6. // Constants
  7. /////////////
  8. // compressed file signature: "SZDD��'3"
  9. #define COMP_SIG "SZDD\x88\xf0\x27\x33"
  10. #define COMP_SIG_LEN 8 // length of signature (bytes)
  11. // (no '\0' terminator)
  12. #define ALG_FIRST ((BYTE) 'A') // first version algorithm label for
  13. // Lempel-Ziv
  14. #define ALG_LZ ((BYTE) 'B') // new Lempel-Ziv algorithm label
  15. #define ALG_LZA ((BYTE) 'C') // Lempel-Ziv with arithmetic encoding
  16. // algorithm label
  17. // length of entire compressed file header (used as offset to start of
  18. // compressed data)
  19. #define HEADER_LEN 14
  20. // (14 == cbCompSigLength + algorithm + extension character
  21. // + uncompressed length)
  22. #define BYTE_MASK 0xff // mask used to isolate low-order byte
  23. // Types
  24. /////////
  25. // Declare compressed file header information structure. N.b., the
  26. // compressed file header does not contain the file size of the compressed
  27. // file since this is readily obtainable through filelength() or lseek().
  28. // The file info structure, however, does contain the compressed file size,
  29. // which is used when expanding the file.
  30. typedef struct tagFH
  31. {
  32. BYTE rgbyteMagic[COMP_SIG_LEN]; // array of compressed file signature
  33. // (magic bytes)
  34. BYTE byteAlgorithm; // algorithm label
  35. WCHAR byteExtensionChar; // last extension character
  36. // (always 0 for ALG_FIRST)
  37. // The file sizes are unsigned longs instead of signed longs for backward
  38. // compatibilty with version 1.00.
  39. DWORD cbulUncompSize; // uncompressed file size
  40. DWORD cbulCompSize; // compressed file size (not stored in
  41. // header)
  42. } FH;
  43. typedef struct tagFH *PFH;
  44. // Macros
  45. //////////
  46. #if 0
  47. #define RecognizeCompAlg(chAlg) ((chAlg) == ALG_FIRST || \
  48. (chAlg) == ALG_LZ || \
  49. (chAlg) == ALG_LZA)
  50. #else
  51. #define RecognizeCompAlg(chAlg) ((chAlg) == ALG_FIRST)
  52. #endif
  53. // Prototypes
  54. //////////////
  55. // header.c
  56. extern INT WriteHdr(PFH pFH, HANDLE doshDest, PLZINFO pLZI);
  57. extern BOOL IsCompressed(PFH pFHIn);
  58. extern VOID MakeHeader(PFH pFHBlank, BYTE byteAlgorithm, WCHAR byteExtensionChar,
  59. PLZINFO pLZI);