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.

226 lines
7.2 KiB

  1. /*
  2. * Microsoft Confidential
  3. * Copyright (C) Microsoft Corporation 1993,1994,1995
  4. * All Rights Reserved.
  5. *
  6. * MDI.H - Diamond Memory Decompression Interface (MDI)
  7. *
  8. * History:
  9. * 01-Dec-1993 bens Initial version.
  10. * 16-Jan-1994 msliger Split into MCI, MDI.
  11. * 11-Feb-1994 msliger Changed M*ICreate() to adjust size.
  12. * 13-Feb-1994 msliger revised type names, ie, UINT16 -> UINT.
  13. * changed handles to HANDLEs.
  14. * normalized MDI_MEMORY type.
  15. * 24-Feb-1994 msliger Changed alloc,free to common typedefs.
  16. * Changed HANDLE to MHANDLE.
  17. * Changed MDI_MEMORY to MI_MEMORY.
  18. * 22-Mar-1994 msliger Changed !INT32 to BIT16.
  19. * Changed interface USHORT to UINT.
  20. * 31-Jan-1995 msliger Supported MDICreateDecompression query.
  21. * 25-May-1995 msliger Clarified *pcbResult on entry.
  22. *
  23. * Functions:
  24. * MDICreateDecompression - Create and reset an MDI decompression context
  25. * MDIDecompress - Decompress a block of data
  26. * MDIResetDecompression - Reset MDI decompression context
  27. * MDIDestroyDecompression - Destroy MDI Decompression context
  28. *
  29. * Types:
  30. * MDI_CONTEXT_HANDLE - Handle to an MDI decompression context
  31. * PFNALLOC - Memory allocation function for MDI
  32. * PFNFREE - Free memory function for MDI
  33. */
  34. /* --- types -------------------------------------------------------------- */
  35. #ifndef DIAMONDAPI
  36. #define DIAMONDAPI __cdecl
  37. #endif
  38. #ifndef _BYTE_DEFINED
  39. #define _BYTE_DEFINED
  40. typedef unsigned char BYTE;
  41. #endif
  42. #ifndef _UINT_DEFINED
  43. #define _UINT_DEFINED
  44. typedef unsigned int UINT;
  45. #endif
  46. #ifndef _ULONG_DEFINED
  47. #define _ULONG_DEFINED
  48. typedef unsigned long ULONG;
  49. #endif
  50. #ifndef FAR
  51. #ifdef BIT16
  52. #define FAR far
  53. #else
  54. #define FAR
  55. #endif
  56. #endif
  57. #ifndef HUGE
  58. #ifdef BIT16
  59. #define HUGE huge
  60. #else
  61. #define HUGE
  62. #endif
  63. #endif
  64. #ifndef _MI_MEMORY_DEFINED
  65. #define _MI_MEMORY_DEFINED
  66. typedef void HUGE * MI_MEMORY;
  67. #endif
  68. #ifndef _MHANDLE_DEFINED
  69. #define _MHANDLE_DEFINED
  70. #if defined(_WIN64)
  71. typedef unsigned __int64 MHANDLE;
  72. #else
  73. typedef unsigned long MHANDLE;
  74. #endif
  75. #endif
  76. /* --- MDI-defined types -------------------------------------------------- */
  77. /* MDI_CONTEXT_HANDLE - Handle to an MDI decompression context */
  78. typedef MHANDLE MDI_CONTEXT_HANDLE; /* hmd */
  79. /*** PFNALLOC - Memory allocation function for MDI
  80. *
  81. * Entry:
  82. * cb - Size in bytes of memory block to allocate
  83. *
  84. * Exit-Success:
  85. * Returns !NULL pointer to memory block
  86. *
  87. * Exit-Failure:
  88. * Returns NULL; insufficient memory
  89. */
  90. #ifndef _PFNALLOC_DEFINED
  91. #define _PFNALLOC_DEFINED
  92. typedef MI_MEMORY (FAR DIAMONDAPI *PFNALLOC)(ULONG cb); /* pfnma */
  93. #endif
  94. /*** PFNFREE - Free memory function for MDI
  95. *
  96. * Entry:
  97. * pv - Memory block allocated by matching PFNALLOC function
  98. *
  99. * Exit:
  100. * Memory block freed.
  101. */
  102. #ifndef _PFNFREE_DEFINED
  103. #define _PFNFREE_DEFINED
  104. typedef void (FAR DIAMONDAPI *PFNFREE)(MI_MEMORY pv); /* pfnmf */
  105. #endif
  106. /* --- prototypes --------------------------------------------------------- */
  107. /*** MDICreateDecompression - Create MDI decompression context
  108. *
  109. * Entry:
  110. * pcbDataBlockMax *largest uncompressed data block size expected,
  111. * gets largest uncompressed data block allowed
  112. * pfnma memory allocation function pointer
  113. * pfnmf memory free function pointer
  114. * pcbSrcBufferMin gets max compressed buffer size
  115. * pmdhHandle gets newly-created context's handle
  116. * If pmdhHandle==NULL, *pcbDataBlockMax and
  117. * *pcbSrcBufferMin will be filled in, but no
  118. * context will be created. This query will allow
  119. * the caller to determine required buffer sizes
  120. * before creating a context.
  121. *
  122. * Exit-Success:
  123. * Returns MDI_ERROR_NO_ERROR;
  124. * *pcbDataBlockMax, *pcbSrcBufferMin, *pmdhHandle filled in.
  125. *
  126. * Exit-Failure:
  127. * MDI_ERROR_NOT_ENOUGH_MEMORY, could not allocate enough memory.
  128. * MDI_ERROR_BAD_PARAMETERS, something wrong with parameters.
  129. */
  130. int FAR DIAMONDAPI MDICreateDecompression(
  131. UINT FAR * pcbDataBlockMax, /* max uncompressed data block size */
  132. PFNALLOC pfnma, /* Memory allocation function ptr */
  133. PFNFREE pfnmf, /* Memory free function ptr */
  134. UINT FAR * pcbSrcBufferMin, /* gets max. comp. buffer size */
  135. MDI_CONTEXT_HANDLE *pmdhHandle); /* gets newly-created handle */
  136. /*** MDIDecompress - Decompress a block of data
  137. *
  138. * Entry:
  139. * hmd handle to decompression context
  140. * pbSrc source buffer (compressed data)
  141. * cbSrc compressed data size
  142. * pbDst destination buffer (for decompressed data)
  143. * *pcbResult decompressed data size
  144. *
  145. * Exit-Success:
  146. * Returns MDI_ERROR_NO_ERROR;
  147. * *pcbResult gets actual size of decompressed data in pbDst.
  148. * Decompression context possibly updated.
  149. *
  150. * Exit-Failure:
  151. * MDI_ERROR_BAD_PARAMETERS, something wrong with parameters.
  152. * MDI_ERROR_BUFFER_OVERFLOW, cbDataBlockMax was too small.
  153. */
  154. int FAR DIAMONDAPI MDIDecompress(
  155. MDI_CONTEXT_HANDLE hmd, /* decompression context */
  156. void FAR * pbSrc, /* source buffer */
  157. UINT cbSrc, /* source data size */
  158. void FAR * pbDst, /* target buffer */
  159. UINT FAR * pcbResult); /* gets target data size */
  160. /*** MDIResetDecompression - Reset decompression history (if any)
  161. *
  162. * De-compression can only be started on a block which was compressed
  163. * immediately following a MCICreateCompression() or MCIResetCompression()
  164. * call. This function provides notification to the decompressor that the
  165. * next compressed block begins on a compression boundary.
  166. *
  167. * Entry:
  168. * hmd - handle to decompression context
  169. *
  170. * Exit-Success:
  171. * Returns MDI_ERROR_NO_ERROR;
  172. * Decompression context reset.
  173. *
  174. * Exit-Failure:
  175. * Returns MDI_ERROR_BAD_PARAMETERS, invalid context handle.
  176. */
  177. int FAR DIAMONDAPI MDIResetDecompression(MDI_CONTEXT_HANDLE hmd);
  178. /*** MDIDestroyDecompression - Destroy MDI decompression context
  179. *
  180. * Entry:
  181. * hmd - handle to decompression context
  182. *
  183. * Exit-Success:
  184. * Returns MDI_ERROR_NO_ERROR;
  185. * Decompression context destroyed.
  186. *
  187. * Exit-Failure:
  188. * Returns MDI_ERROR_BAD_PARAMETERS, invalid context handle.
  189. */
  190. int FAR DIAMONDAPI MDIDestroyDecompression(MDI_CONTEXT_HANDLE hmd);
  191. /* --- constants ---------------------------------------------------------- */
  192. /* return codes */
  193. #define MDI_ERROR_NO_ERROR 0
  194. #define MDI_ERROR_NOT_ENOUGH_MEMORY 1
  195. #define MDI_ERROR_BAD_PARAMETERS 2
  196. #define MDI_ERROR_BUFFER_OVERFLOW 3
  197. #define MDI_ERROR_FAILED 4
  198. /* ----------------------------------------------------------------------- */