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.

253 lines
8.6 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: Convert.h
  5. Content: Declaration of convertion routines.
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __CONVERT_H_
  9. #define __CONVERT_H_
  10. #include "Debug.h"
  11. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12. Function : UnicodeToAnsi
  13. Synopsis : Convert an array of unicode character to ANSI.
  14. Parameter: LPWSTR pwszUnicodeString - Pointer to Unicode string to be
  15. converted to ANSI string.
  16. int cchWideChar - Number of characters, or -1 if
  17. pwszUnicodeString is NULL terminated.
  18. LPSTR * ppszAnsiString - Pointer to LPSTR to received the
  19. converted ANSI string.
  20. int * pcchAnsiChar (Optional) - Pointer to int to receive
  21. the number of characters
  22. translated.
  23. Remark : Caller must call CoTaskMemFree to free the returned ANSI string.
  24. ------------------------------------------------------------------------------*/
  25. HRESULT UnicodeToAnsi (LPWSTR pwszUnicodeString,
  26. int cchWideChar,
  27. LPSTR * ppszAnsiString,
  28. int * pcchAnsiChar);
  29. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  30. Function : AnsiToUnicode
  31. Synopsis : Convert a array of ANSI character to Unicode.
  32. Parameter: LPSTR pszAnsiString - Pointer to ANSI string to be converted to
  33. ANSI string.
  34. DWORD cchAnsiChar - Number of characters, or -1 if pszAnsiString
  35. is NULL terminated.
  36. LPWSTR * ppwszUnicodeString - Pointer to LPWSTR to received the
  37. converted Unicode string.
  38. DWORD * pcchUnicodeChar (Optional) - Pointer to DWORD to receive
  39. the number of characters
  40. translated.
  41. Remark : Caller must call CoTaskMemFree to free the returned Unicode string.
  42. ------------------------------------------------------------------------------*/
  43. HRESULT AnsiToUnicode (LPSTR pszAnsiString,
  44. DWORD cchAnsiChar,
  45. LPWSTR * ppwszUnicodeString,
  46. DWORD * pcchUnicodeChar);
  47. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48. Function : IntBlobToHexString
  49. Synopsis : Convert an interger blob to hex string.
  50. Parameter: BYTE byte - Byte to be converted.
  51. Remark :
  52. ------------------------------------------------------------------------------*/
  53. HRESULT IntBlobToHexString (CRYPT_INTEGER_BLOB * pBlob, BSTR * pbstrHex);
  54. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  55. Function : BinaryToHexString
  56. Synopsis : Convert binary data to hex string.
  57. Parameter: BYTE * pbBytes - Bytes to be converted.
  58. DWORD cBytes - Number of bytes to be converted.
  59. BSTR * pbstrHex - Pointer to BSTR to received converted hex string.
  60. Remark :
  61. ------------------------------------------------------------------------------*/
  62. HRESULT BinaryToHexString (BYTE * pbBytes, DWORD cBytes, BSTR * pbstrHex);
  63. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  64. Function : HexToBinaryString
  65. Synopsis : Convert hex string to binary data.
  66. Parameter: BSTR bstrHex - Hex string to be converted.
  67. BSTR * pbstrBinary - Pointer to BSTR to received converted string.
  68. Remark :
  69. ------------------------------------------------------------------------------*/
  70. HRESULT HexToBinaryString (BSTR bstrHex, BSTR * pbstrBinary);
  71. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  72. Function : StringToBinary
  73. Synopsis : Convert a formatted string to binary value.
  74. Parameter: LPCWSTR pwszString - Pointer to string to be converted.
  75. DWORD cchString - Number of characters in pwszString.
  76. DWORD dwFormat - Conversion format (See WinCrypt.h).
  77. PBYTE * ppbBinary - Pointer to pointer to buffer to hold binary
  78. data.
  79. DWORD * pdwBinary - Number of bytes in the binary buffer.
  80. Remark : Caller free the buffer by calling CoTaskMemFree().
  81. ------------------------------------------------------------------------------*/
  82. HRESULT StringToBinary (LPCWSTR pwszString,
  83. DWORD cchString,
  84. DWORD dwFormat,
  85. PBYTE * ppbBinary,
  86. DWORD * pdwBinary);
  87. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  88. Function : BinaryToString
  89. Synopsis : Convert a binary value to formatted string.
  90. Parameter: PBYTE pbBinary - Pointer to buffer of binary data.
  91. DWORD cbBinary - Number of bytes in the binary buffer.
  92. DWORD dwFormat - Conversion format (See WinCrypt.h).
  93. BSTR * pbstrString - Pointer to BSTR to receive converted
  94. string.
  95. DWORD * pcchString - Number of characters in *pbstrString.
  96. Remark : Caller free the string by calling SysFreeString().
  97. ------------------------------------------------------------------------------*/
  98. HRESULT BinaryToString (PBYTE pbBinary,
  99. DWORD cbBinary,
  100. DWORD dwFormat,
  101. BSTR * pbstrString,
  102. DWORD * pcchString);
  103. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  104. Function : BlobToBstr
  105. Synopsis : Convert a blob to BSTR.
  106. Parameter: DATA_BLOB * pDataBlob - Pointer to blob to be converted to BSTR.
  107. BSTR * lpBstr - Pointer to BSTR to receive the converted BSTR.
  108. Remark : Caller free allocated memory for the returned BSTR.
  109. ------------------------------------------------------------------------------*/
  110. HRESULT BlobToBstr (DATA_BLOB * pDataBlob,
  111. BSTR * lpBstr);
  112. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  113. Function : BstrToBlob
  114. Synopsis : Convert a BSTR to blob.
  115. Parameter: BSTR bstr - BSTR to be converted to blob.
  116. DATA_BLOB * lpBlob - Pointer to DATA_BLOB to receive converted blob.
  117. Remark : Caller free allocated memory for the returned BLOB.
  118. ------------------------------------------------------------------------------*/
  119. HRESULT BstrToBlob (BSTR bstr,
  120. DATA_BLOB * lpBlob);
  121. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  122. Function : ExportData
  123. Synopsis : Export binary data to a BSTR with specified encoding type.
  124. Parameter: DATA_BLOB DataBlob - Binary data blob.
  125. CAPICOM_ENCODING_TYPE EncodingType - Encoding type.
  126. BSTR * pbstrEncoded - Pointer to BSTR to receive the encoded data.
  127. Remark :
  128. ------------------------------------------------------------------------------*/
  129. HRESULT ExportData (DATA_BLOB DataBlob,
  130. CAPICOM_ENCODING_TYPE EncodingType,
  131. BSTR * pbstrEncoded);
  132. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  133. Function : ImportData
  134. Synopsis : Import encoded data.
  135. Parameter: BSTR bstrEncoded - BSTR containing the data to be imported.
  136. CAPICOM_ENCODING_TYPE EncodingType - Encoding type.
  137. DATA_BLOB * pDataBlob - Pointer to DATA_BLOB to receive the
  138. decoded data.
  139. Remark : There is no need for encoding type parameter, as the encoding type
  140. will be determined automatically by this routine.
  141. ------------------------------------------------------------------------------*/
  142. HRESULT ImportData (BSTR bstrEncoded,
  143. CAPICOM_ENCODING_TYPE EncodingType,
  144. DATA_BLOB * pDataBlob);
  145. #endif //__CONVERT_H_