/v3/tools/Wix/sdk/inc/strutil.h

http://mb-unit.googlecode.com/ · C Header · 211 lines · 180 code · 14 blank · 17 comment · 4 complexity · 71ea5a593be4c561b45595e5feb57593 MD5 · raw file

  1. #pragma once
  2. //-------------------------------------------------------------------------------------------------
  3. // <copyright file="strutil.h" company="Microsoft">
  4. // Copyright (c) Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are covered by the
  7. // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
  8. // which can be found in the file CPL.TXT at the root of this distribution.
  9. // By using this software in any fashion, you are agreeing to be bound by
  10. // the terms of this license.
  11. //
  12. // You must not remove this notice, or any other, from this software.
  13. // </copyright>
  14. //
  15. // <summary>
  16. // Header for string helper functions.
  17. // </summary>
  18. //-------------------------------------------------------------------------------------------------
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define ReleaseStr(pwz) if (pwz) { StrFree(pwz); }
  23. #define ReleaseNullStr(pwz) if (pwz) { StrFree(pwz); pwz = NULL; }
  24. #define ReleaseBSTR(bstr) if (bstr) { ::SysFreeString(bstr); }
  25. #define ReleaseNullBSTR(bstr) if (bstr) { ::SysFreeString(bstr); bstr = NULL; }
  26. #define DeclareConstBSTR(bstr_const, wz) const WCHAR bstr_const[] = { 0x00, 0x00, sizeof(wz)-sizeof(WCHAR), 0x00, wz }
  27. #define UseConstBSTR(bstr_const) const_cast<BSTR>(bstr_const + 4)
  28. HRESULT DAPI StrAlloc(
  29. __deref_out_ecount_part(cch, 0) LPWSTR* ppwz,
  30. __in DWORD_PTR cch
  31. );
  32. HRESULT DAPI StrAnsiAlloc(
  33. __deref_out_ecount_part(cch, 0) LPSTR* ppz,
  34. __in DWORD_PTR cch
  35. );
  36. HRESULT DAPI StrAllocString(
  37. __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz,
  38. __in LPCWSTR wzSource,
  39. __in DWORD_PTR cchSource
  40. );
  41. HRESULT DAPI StrAnsiAllocString(
  42. __deref_out_ecount_z(cchSource+1) LPSTR* ppsz,
  43. __in LPCWSTR wzSource,
  44. __in DWORD_PTR cchSource,
  45. __in UINT uiCodepage
  46. );
  47. HRESULT DAPI StrAllocStringAnsi(
  48. __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz,
  49. __in LPCSTR szSource,
  50. __in DWORD_PTR cchSource,
  51. __in UINT uiCodepage
  52. );
  53. HRESULT DAPI StrAllocPrefix(
  54. __deref_out_z LPWSTR* ppwz,
  55. __in LPCWSTR wzPrefix,
  56. __in DWORD_PTR cchPrefix
  57. );
  58. HRESULT DAPI StrAllocConcat(
  59. __deref_out_z LPWSTR* ppwz,
  60. __in LPCWSTR wzSource,
  61. __in DWORD_PTR cchSource
  62. );
  63. HRESULT DAPI StrAnsiAllocConcat(
  64. __deref_out_z LPSTR* ppz,
  65. __in LPCSTR pzSource,
  66. __in DWORD_PTR cchSource
  67. );
  68. HRESULT __cdecl StrAllocFormatted(
  69. __deref_out_z LPWSTR* ppwz,
  70. __in __format_string LPCWSTR wzFormat,
  71. ...
  72. );
  73. HRESULT __cdecl StrAnsiAllocFormatted(
  74. __deref_out_z LPSTR* ppsz,
  75. __in __format_string LPCSTR szFormat,
  76. ...
  77. );
  78. HRESULT DAPI StrAllocFormattedArgs(
  79. __deref_out_z LPWSTR* ppwz,
  80. __in __format_string LPCWSTR wzFormat,
  81. __in va_list args
  82. );
  83. HRESULT DAPI StrAnsiAllocFormattedArgs(
  84. __deref_out_z LPSTR* ppsz,
  85. __in __format_string LPCSTR szFormat,
  86. __in va_list args
  87. );
  88. HRESULT DAPI StrMaxLength(
  89. __in LPVOID p,
  90. __out DWORD_PTR* pcch
  91. );
  92. HRESULT DAPI StrSize(
  93. __in LPVOID p,
  94. __out DWORD_PTR* pcb
  95. );
  96. HRESULT DAPI StrFree(
  97. __in LPVOID p
  98. );
  99. HRESULT DAPI StrCurrentTime(
  100. __deref_out_z LPWSTR* ppwz,
  101. __in BOOL fGMT
  102. );
  103. HRESULT DAPI StrCurrentDateTime(
  104. __deref_out_z LPWSTR* ppwz,
  105. __in BOOL fGMT
  106. );
  107. HRESULT DAPI StrReplaceStringAll(
  108. __inout LPWSTR* ppwzOriginal,
  109. __in LPCWSTR wzOldSubString,
  110. __in LPCWSTR wzNewSubString
  111. );
  112. HRESULT DAPI StrReplaceString(
  113. __inout LPWSTR* ppwzOriginal,
  114. __inout DWORD* dwStartIndex,
  115. __in LPCWSTR wzOldSubString,
  116. __in LPCWSTR wzNewSubString
  117. );
  118. HRESULT DAPI StrHexEncode(
  119. __in_ecount(cbSource) const BYTE* pbSource,
  120. __in DWORD_PTR cbSource,
  121. __out_ecount(cchDest) LPWSTR wzDest,
  122. __in DWORD_PTR cchDest
  123. );
  124. HRESULT DAPI StrHexDecode(
  125. __in LPCWSTR wzSource,
  126. __out_bcount(cbDest) BYTE* pbDest,
  127. __in DWORD_PTR cbDest
  128. );
  129. HRESULT DAPI StrAllocBase85Encode(
  130. __in_bcount(cbSource) const BYTE* pbSource,
  131. __in DWORD_PTR cbSource,
  132. __deref_out_z LPWSTR* pwzDest
  133. );
  134. HRESULT DAPI StrAllocBase85Decode(
  135. __in LPCWSTR wzSource,
  136. __deref_out_bcount(*pcbDest) BYTE** hbDest,
  137. __out DWORD_PTR* pcbDest
  138. );
  139. HRESULT DAPI MultiSzLen(
  140. __in LPCWSTR pwzMultiSz,
  141. __out DWORD_PTR* pcch
  142. );
  143. HRESULT DAPI MultiSzPrepend(
  144. __deref_inout_z LPWSTR* ppwzMultiSz,
  145. __inout_opt DWORD_PTR *pcchMultiSz,
  146. __in LPCWSTR pwzInsert
  147. );
  148. HRESULT DAPI MultiSzFindSubstring(
  149. __in LPCWSTR pwzMultiSz,
  150. __in LPCWSTR pwzSubstring,
  151. __out_opt DWORD_PTR* pdwIndex,
  152. __deref_opt_out_z LPCWSTR* ppwzFoundIn
  153. );
  154. HRESULT DAPI MultiSzFindString(
  155. __in LPCWSTR pwzMultiSz,
  156. __in LPCWSTR pwzString,
  157. __out_opt DWORD_PTR* pdwIndex,
  158. __deref_opt_out_z LPCWSTR* ppwzFound
  159. );
  160. HRESULT DAPI MultiSzRemoveString(
  161. __deref_inout_z LPWSTR* ppwzMultiSz,
  162. __in DWORD_PTR dwIndex
  163. );
  164. HRESULT DAPI MultiSzInsertString(
  165. __deref_inout_z LPWSTR* ppwzMultiSz,
  166. __inout_opt DWORD_PTR *pcchMultiSz,
  167. __in DWORD_PTR dwIndex,
  168. __in LPCWSTR pwzInsert
  169. );
  170. HRESULT DAPI MultiSzReplaceString(
  171. __deref_inout_z LPWSTR* ppwzMultiSz,
  172. __in DWORD_PTR dwIndex,
  173. __in LPCWSTR pwzString
  174. );
  175. LPCWSTR wcsistr(
  176. __in LPCWSTR wzString,
  177. __in LPCWSTR wzCharSet
  178. );
  179. HRESULT DAPI StrStringToUInt16(
  180. __in_z LPCWSTR wzIn,
  181. __in DWORD cchIn,
  182. __out USHORT* pusOut
  183. );
  184. HRESULT DAPI StrStringToInt64(
  185. __in_z LPCWSTR wzIn,
  186. __in DWORD cchIn,
  187. __out LONGLONG* pllOut
  188. );
  189. void DAPI StrStringToUpper(
  190. __inout_z LPWSTR wzIn
  191. );
  192. void DAPI StrStringToLower(
  193. __inout_z LPWSTR wzIn
  194. );
  195. #ifdef __cplusplus
  196. }
  197. #endif