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.

65 lines
1.9 KiB

  1. //
  2. // infinit.c
  3. //
  4. // Inflate initialisation
  5. //
  6. #include <stdio.h>
  7. #include <crtdbg.h>
  8. #include "inflate.h"
  9. #include "maketbl.h"
  10. //
  11. // Generate global tables for decoding static blocks
  12. //
  13. static VOID CreateStaticDecodingTables(VOID)
  14. {
  15. SHORT StaticDistanceTreeLeft[MAX_DIST_TREE_ELEMENTS*2]; // temporary: not exported
  16. SHORT StaticDistanceTreeRight[MAX_DIST_TREE_ELEMENTS*2]; // temporary: not exported
  17. SHORT StaticLiteralTreeLeft[MAX_LITERAL_TREE_ELEMENTS*2]; // temporary: not exported
  18. SHORT StaticLiteralTreeRight[MAX_LITERAL_TREE_ELEMENTS*2]; // temporary: not exported
  19. SHORT TempStaticDistanceTreeTable[STATIC_BLOCK_DISTANCE_TABLE_SIZE];
  20. BYTE TempStaticDistanceTreeLength[MAX_DIST_TREE_ELEMENTS];
  21. int i;
  22. _ASSERT(STATIC_BLOCK_LITERAL_TABLE_BITS == 9);
  23. _ASSERT(STATIC_BLOCK_DISTANCE_TABLE_BITS == 5);
  24. // The Table[] and Left/Right arrays are for the decoder only
  25. // We don't output Left/Right because they are not used; everything
  26. // fits in the lookup table, since max code length is 9, and tablebits
  27. // > 9.
  28. makeTable(
  29. MAX_LITERAL_TREE_ELEMENTS,
  30. STATIC_BLOCK_LITERAL_TABLE_BITS,
  31. g_StaticLiteralTreeLength,
  32. g_StaticLiteralTreeTable,
  33. StaticLiteralTreeLeft,
  34. StaticLiteralTreeRight);
  35. for (i = 0; i < MAX_DIST_TREE_ELEMENTS; i++)
  36. TempStaticDistanceTreeLength[i] = 5;
  37. makeTable(
  38. MAX_DIST_TREE_ELEMENTS,
  39. STATIC_BLOCK_DISTANCE_TABLE_BITS,
  40. TempStaticDistanceTreeLength,
  41. TempStaticDistanceTreeTable,
  42. StaticDistanceTreeLeft,
  43. StaticDistanceTreeRight);
  44. // Since all values are < 256, use a BYTE array
  45. for (i = 0; i < STATIC_BLOCK_DISTANCE_TABLE_SIZE; i++)
  46. g_StaticDistanceTreeTable[i] = TempStaticDistanceTreeTable[i];
  47. }
  48. VOID inflateInit(VOID)
  49. {
  50. InitStaticBlock();
  51. CreateStaticDecodingTables();
  52. }