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.

254 lines
8.2 KiB

  1. /*
  2. * Microsoft Confidential
  3. * Copyright (C) Microsoft Corporation 1993,1994
  4. * All Rights Reserved.
  5. *
  6. * MCI.H - Diamond Memory Compression Interface (MCI)
  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 MCI_MEMORY type.
  15. * 24-Feb-1994 msliger Changed alloc,free to common typedefs.
  16. * Changed HANDLE to MHANDLE.
  17. * Changed MCI_MEMORY to MI_MEMORY.
  18. * 15-Mar-1994 msliger Changes for 32 bits.
  19. * 22-Mar-1994 msliger Changed !INT32 to BIT16.
  20. * Changed interface USHORT to UINT.
  21. *
  22. * Functions:
  23. * MCICreateCompression - Create and reset an MCI compression context
  24. * MCICloneCompression - Make a copy of a compression context
  25. * MCICompress - Compress a block of data
  26. * MCIResetCompression - Reset compression context
  27. * MCIDestroyCompression - Destroy MCI compression context
  28. *
  29. * Types:
  30. * MCI_CONTEXT_HANDLE - Handle to an MCI compression context
  31. * PFNALLOC - Memory allocation function for MCI
  32. * PFNFREE - Free memory function for MCI
  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. /* --- MCI-defined types -------------------------------------------------- */
  77. /* MCI_CONTEXT_HANDLE - Handle to an MCI compression context */
  78. typedef MHANDLE MCI_CONTEXT_HANDLE; /* hmc */
  79. /*** PFNALLOC - Memory allocation function for MCI
  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 MCI
  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. /*** MCICreateCompression - Create MCI compression context
  108. *
  109. * Entry:
  110. * pcbDataBlockMax *largest uncompressed data block size desired,
  111. * gets largest uncompressed data block allowed
  112. * pfnma memory allocation function pointer
  113. * pfnmf memory free function pointer
  114. * pcbDstBufferMin gets required compressed data buffer size
  115. * pmchHandle gets newly-created context's handle
  116. *
  117. * Exit-Success:
  118. * Returns MCI_ERROR_NO_ERROR;
  119. * *pcbDataBlockMax, *pcbDstBufferMin, *pmchHandle filled in.
  120. *
  121. * Exit-Failure:
  122. * MCI_ERROR_NOT_ENOUGH_MEMORY, could not allocate enough memory.
  123. * MCI_ERROR_BAD_PARAMETERS, something wrong with parameters.
  124. */
  125. int FAR DIAMONDAPI MCICreateCompression(
  126. UINT FAR * pcbDataBlockMax, /* max uncompressed data block size */
  127. PFNALLOC pfnma, /* Memory allocation function ptr */
  128. PFNFREE pfnmf, /* Memory free function ptr */
  129. UINT FAR * pcbDstBufferMin, /* gets required output buffer size */
  130. MCI_CONTEXT_HANDLE FAR *pmchHandle); /* gets newly-created handle */
  131. /*** MCICloneCompression - Make a copy of a compression context
  132. *
  133. * Entry:
  134. * hmc handle to current compression context
  135. * pmchHandle gets newly-created handle
  136. *
  137. * Exit-Success:
  138. * Returns MCI_ERROR_NO_ERROR;
  139. * *pmchHandle filled in.
  140. *
  141. * Exit-Failure:
  142. * Returns:
  143. * MCI_ERROR_BAD_PARAMETERS, something wrong with parameters.
  144. * MCI_ERROR_NOT_ENOUGH_MEMORY, could not allocate enough memory.
  145. *
  146. * NOTES:
  147. * (1) This API is intended to permit "roll-back" of a sequence of
  148. * of MCICompress() calls. Before starting a sequence that may need
  149. * to be rolled-back, use MCICloneCompression() to save the state of
  150. * the compression context, then do the MCICompress() calls. If the
  151. * sequence is successful, the "cloned" hmc can be destroyed with
  152. * MCIDestroyCompression(). If the sequence is *not* successful, then
  153. * the original hmc can be destroyed, and the cloned one can be used
  154. * to restart as if the sequence of MCICompress() calls had never
  155. * occurred.
  156. */
  157. int FAR DIAMONDAPI MCICloneCompression(
  158. MCI_CONTEXT_HANDLE hmc, /* current compression context */
  159. MCI_CONTEXT_HANDLE *pmchHandle); /* gets newly-created handle */
  160. /*** MCICompress - Compress a block of data
  161. *
  162. * Entry:
  163. * hmc handle to compression context
  164. * pbSrc source buffer (uncompressed data)
  165. * cbSrc size of data to be compressed
  166. * pbDst destination buffer (for compressed data)
  167. * cbDst size of destination buffer
  168. * pcbResult receives compressed size of data
  169. *
  170. * Exit-Success:
  171. * Returns MCI_ERROR_NO_ERROR;
  172. * *pcbResult has size of compressed data in pbDst.
  173. * Compression context possibly updated.
  174. *
  175. * Exit-Failure:
  176. * MCI_ERROR_BAD_PARAMETERS, something wrong with parameters.
  177. */
  178. int FAR DIAMONDAPI MCICompress(
  179. MCI_CONTEXT_HANDLE hmc, /* compression context */
  180. void FAR * pbSrc, /* source buffer */
  181. UINT cbSrc, /* source buffer size */
  182. void FAR * pbDst, /* target buffer */
  183. UINT cbDst, /* target buffer size */
  184. UINT FAR * pcbResult); /* gets target data size */
  185. /*** MCIResetCompression - Reset compression history (if any)
  186. *
  187. * De-compression can only be started on a block which was compressed
  188. * immediately following a MCICreateCompression() or MCIResetCompression()
  189. * call. This function forces such a new "compression boundary" to be
  190. * created (only by causing the compressor to ignore history, can the data
  191. * output be decompressed without history.)
  192. *
  193. * Entry:
  194. * hmc - handle to compression context
  195. *
  196. * Exit-Success:
  197. * Returns MCI_ERROR_NO_ERROR;
  198. * Compression context reset.
  199. *
  200. * Exit-Failure:
  201. * Returns MCI_ERROR_BAD_PARAMETERS, invalid context handle.
  202. */
  203. int FAR DIAMONDAPI MCIResetCompression(MCI_CONTEXT_HANDLE hmc);
  204. /*** MCIDestroyCompression - Destroy MCI compression context
  205. *
  206. * Entry:
  207. * hmc - handle to compression context
  208. *
  209. * Exit-Success:
  210. * Returns MCI_ERROR_NO_ERROR;
  211. * Compression context destroyed.
  212. *
  213. * Exit-Failure:
  214. * Returns MCI_ERROR_BAD_PARAMETERS, invalid context handle.
  215. */
  216. int FAR DIAMONDAPI MCIDestroyCompression(MCI_CONTEXT_HANDLE hmc);
  217. /* --- constants ---------------------------------------------------------- */
  218. /* return codes */
  219. #define MCI_ERROR_NO_ERROR 0
  220. #define MCI_ERROR_NOT_ENOUGH_MEMORY 1
  221. #define MCI_ERROR_BAD_PARAMETERS 2
  222. #define MCI_ERROR_BUFFER_OVERFLOW 3
  223. #define MCI_ERROR_FAILED 4
  224. /* ----------------------------------------------------------------------- */