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.

229 lines
5.3 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. ClbMisc
  5. Abstract:
  6. This header file describes the miscellaneous services of the Calais Library.
  7. Author:
  8. Doug Barlow (dbarlow) 7/16/1996
  9. Environment:
  10. Win32, C++ w/ Exceptions
  11. Notes:
  12. --*/
  13. #ifndef _CLBMISC_H_
  14. #define _CLBMISC_H_
  15. #define PLATFORM_UNKNOWN 0
  16. #define PLATFORM_WIN95 ((VER_PLATFORM_WIN32_WINDOWS << 16) + (4 << 8))
  17. #define PLATFORM_WIN98 ((VER_PLATFORM_WIN32_WINDOWS << 16) + (4 << 8)) + 10
  18. #define PLATFORM_WINNT40 ((VER_PLATFORM_WIN32_NT << 16) + (4 << 8))
  19. #define PLATFORM_WINNT50 ((VER_PLATFORM_WIN32_NT << 16) + (5 << 8))
  20. #define IsWinNT (VER_PLATFORM_WIN32_NT == (GetPlatform() >> 16))
  21. //
  22. // Miscellaneous definitions.
  23. //
  24. extern DWORD
  25. GetPlatform( // Get the current operating system.
  26. void);
  27. extern int
  28. MemCompare( // Non CRTL memory compare routine.
  29. IN LPCBYTE pbOne,
  30. IN LPCBYTE pbTwo,
  31. IN DWORD cbLength);
  32. extern DWORD
  33. MStrAdd( // Add an ANSI string to a multistring.
  34. IN OUT CBuffer &bfMsz,
  35. IN LPCSTR szAdd);
  36. extern DWORD
  37. MStrAdd( // Add a wide string to a multistring.
  38. IN OUT CBuffer &bfMsz,
  39. IN LPCWSTR szAdd);
  40. extern DWORD
  41. MStrLen( // Return the length of an ANSI Multistring, in chars.
  42. LPCSTR mszString);
  43. extern DWORD
  44. MStrLen( // Return the length of a wide Multistring, in chars.
  45. LPCWSTR mszString);
  46. extern LPCTSTR
  47. FirstString( // Return first string segment in a multistring.
  48. IN LPCTSTR szMultiString);
  49. extern LPCTSTR
  50. NextString( // Return next string segment in a multistring.
  51. IN LPCTSTR szMultiString);
  52. extern LPCTSTR
  53. StringIndex( // Return n'th string segment in a multistring.
  54. IN LPCTSTR szMultiString,
  55. IN DWORD dwIndex);
  56. extern DWORD
  57. MStringCount(
  58. LPCTSTR mszInString); // count strings in multistring
  59. extern DWORD
  60. MStringSort( // Sort multistring, removing duplicates.
  61. LPCTSTR mszInString,
  62. CBuffer &bfOutString);
  63. extern DWORD
  64. MStringMerge( // Merge two multistrings, eliminating duplicates.
  65. LPCTSTR mszOne,
  66. LPCTSTR mszTwo,
  67. CBuffer &bfOutString);
  68. extern DWORD
  69. MStringCommon( // Get the intersection of two multistrings.
  70. LPCTSTR mszOne,
  71. LPCTSTR mszTwo,
  72. CBuffer &bfOutString);
  73. extern DWORD
  74. MStringRemove( // Remove 2nd string entries from 1st string.
  75. LPCTSTR mszOne,
  76. LPCTSTR mszTwo,
  77. CBuffer &bfOutString);
  78. extern BOOL
  79. ParseAtr( // Parse a smartcard ATR string.
  80. LPCBYTE pbAtr,
  81. LPDWORD pdwAtrLen = NULL,
  82. LPDWORD pdwHistOffset = NULL,
  83. LPDWORD pcbHistory = NULL,
  84. DWORD cbMaxLen = 33);
  85. extern BOOL
  86. AtrCompare( // Compare an ATR to an ATR/Mask pair.
  87. LPCBYTE pbAtr1,
  88. LPCBYTE pbAtr2,
  89. LPCBYTE pbMask, // = NULL
  90. DWORD cbAtr2); // = 0
  91. extern DWORD
  92. MoveString( // Move an ANSI string into a buffer, converting to
  93. CBuffer &bfDst, // TCHARs.
  94. LPCSTR szSrc,
  95. DWORD dwLength = (DWORD)(-1));
  96. extern DWORD
  97. MoveString( // Move a UNICODE string into a buffer, converting to
  98. CBuffer &bfDst, // TCHARs.
  99. LPCWSTR szSrc,
  100. DWORD dwLength = (DWORD)(-1));
  101. extern DWORD
  102. MoveToAnsiString( // Move a string into a UNICODE buffer, converting from
  103. LPSTR szDst, // TCHARs.
  104. LPCTSTR szSrc,
  105. DWORD cchLength);
  106. extern DWORD
  107. MoveToUnicodeString( // Move a string into an ANSI buffer, converting from
  108. LPWSTR szDst, // TCHARs.
  109. LPCTSTR szSrc,
  110. DWORD cchLength);
  111. extern DWORD
  112. MoveToAnsiMultiString( // Move a multistring into an ANSI buffer, converting
  113. LPSTR mszDst, // from TCHARs.
  114. LPCTSTR mszSrc,
  115. DWORD cchLength);
  116. extern DWORD
  117. MoveToUnicodeMultiString( // Move a multistring into a UNICODE buffer,
  118. LPWSTR mszDst, // converting from TCHARs.
  119. LPCTSTR mszSrc,
  120. DWORD cchLength);
  121. extern LPCTSTR
  122. ErrorString( // Convert an error code into a string.
  123. DWORD dwErrorCode);
  124. extern void
  125. FreeErrorString( // Free the string returned from ErrorString.
  126. LPCTSTR szErrorString);
  127. extern DWORD
  128. SelectString( // Index a given string against a list of possible
  129. LPCTSTR szSource, // strings. Last parameter is NULL.
  130. ...);
  131. extern void
  132. StringFromGuid(
  133. IN LPCGUID pguidResult, // GUID to convert to text
  134. OUT LPTSTR szGuid); // 39+ character buffer to receive GUID as text.
  135. //
  136. //==============================================================================
  137. //
  138. // CErrorString
  139. //
  140. // A trivial class to simplify the use of the ErrorString service.
  141. //
  142. class CErrorString
  143. {
  144. public:
  145. // Constructors & Destructor
  146. CErrorString(DWORD dwError = 0)
  147. {
  148. m_szErrorString = NULL;
  149. SetError(dwError);
  150. };
  151. ~CErrorString()
  152. {
  153. FreeErrorString(m_szErrorString);
  154. };
  155. // Properties
  156. // Methods
  157. void SetError(DWORD dwError)
  158. {
  159. m_dwError = dwError;
  160. };
  161. LPCTSTR Value(void)
  162. {
  163. FreeErrorString(m_szErrorString);
  164. m_szErrorString = ErrorString(m_dwError);
  165. return m_szErrorString;
  166. };
  167. // Operators
  168. operator LPCTSTR(void)
  169. {
  170. return Value();
  171. };
  172. protected:
  173. // Properties
  174. DWORD m_dwError;
  175. LPCTSTR m_szErrorString;
  176. // Methods
  177. };
  178. #endif // _CLBMISC_H_