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.

238 lines
9.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-1999.
  5. //
  6. // File: N O T I F V A L . H
  7. //
  8. // Contents: Validation routines for the INetCfgNotify interfaces.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 11 Mar 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NOTIFVAL_H_
  17. #define _NOTIFVAL_H_
  18. #include "ncvalid.h"
  19. #include "netcfgn.h"
  20. //+---------------------------------------------------------------------------
  21. // INetCfgNotify
  22. //
  23. BOOL FBadArgs_INetCfgNotify_Initialize(INetCfgComponent* a, INetCfg* b, BOOL c);
  24. #define Validate_INetCfgNotify_Initialize(a, b, c) \
  25. if (FBadArgs_INetCfgNotify_Initialize(a, b, c)) \
  26. { \
  27. TraceError("Validate_INetCfgNotify_Initialize", E_INVALIDARG); \
  28. return E_INVALIDARG; \
  29. }
  30. #define Validate_INetCfgNotify_Initialize_Return(hr) \
  31. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Initialize");
  32. BOOL FBadArgs_INetCfgNotify_ReadAnswerFile(PCWSTR c, PCWSTR d);
  33. #define Validate_INetCfgNotify_ReadAnswerFile(c, d) \
  34. if (FBadArgs_INetCfgNotify_ReadAnswerFile(c, d)) \
  35. { \
  36. TraceError("Validate_INetCfgNotify_ReadAnswerFile", E_INVALIDARG); \
  37. return E_INVALIDARG; \
  38. }
  39. #define Validate_INetCfgNotify_ReadAnswerFile_Return(hr) \
  40. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_ReadAnswerFile");
  41. #define Validate_INetCfgNotify_Install(a)
  42. #define Validate_INetCfgNotify_Install_Return(hr) \
  43. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Install");
  44. #define Validate_INetCfgNotify_Upgrade(a,b)
  45. #define Validate_INetCfgNotify_Upgrade_Return(hr) \
  46. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Upgrade");
  47. #define Validate_INetCfgNotify_Removing_Return(hr) \
  48. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Removing");
  49. #define Validate_INetCfgNotify_Validate_Return(hr) \
  50. AssertSz ((S_OK == hr) || (S_FALSE == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Validate");
  51. #define Validate_INetCfgNotify_Cancel_Return(hr) \
  52. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Cancel");
  53. #define Validate_INetCfgNotify_Apply_Return(hr) \
  54. AssertSz ((S_OK == hr) || (S_FALSE == hr) || (NETCFG_S_REBOOT == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgNotify_Apply");
  55. //+---------------------------------------------------------------------------
  56. // INetCfgProperties
  57. //
  58. BOOL FBadArgs_INetCfgProperties_MergePropPages(DWORD* a, LPBYTE* b, UINT* c, HWND hwnd, PCWSTR *psz);
  59. #define Validate_INetCfgProperties_MergePropPages(a, b, c, hwnd, psz) \
  60. if (FBadArgs_INetCfgProperties_MergePropPages(a, b, c, hwnd, psz)) \
  61. { \
  62. TraceError("Validate_INetCfgProperties_MergePropPages", E_INVALIDARG); \
  63. return E_INVALIDARG; \
  64. }
  65. #define Validate_INetCfgProperties_MergePropPages_Return(hr) \
  66. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgProperties_MergePropPages");
  67. BOOL FBadArgs_INetCfgProperties_ValidateProperties(HWND a);
  68. #define Validate_INetCfgProperties_ValidateProperties(a) \
  69. if (FBadArgs_INetCfgProperties_ValidateProperties(a)) \
  70. { \
  71. TraceError("Validate_INetCfgProperties_ValidateProperties", E_INVALIDARG); \
  72. return E_INVALIDARG; \
  73. }
  74. #define Validate_INetCfgProperties_ValidateProperties_Return(hr) \
  75. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgProperties_ValidateProperties");
  76. #define Validate_INetCfgProperties_CancelProperties_Return(hr) \
  77. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgProperties_CancelProperties");
  78. #define Validate_INetCfgProperties_ApplyProperties_Return(hr) \
  79. AssertSz ((S_OK == hr) || (S_FALSE == hr) || FAILED(hr), "Invalid HRESULT returned from INetCfgProperties_ApplyProperties");
  80. //+---------------------------------------------------------------------------
  81. // INetCfgBindNotify
  82. //
  83. inline BOOL FBadNotifyFlags (DWORD a)
  84. {
  85. return
  86. // Can't have pairs of flags at the same time that mean the opposite.
  87. ((a & NCN_ADD ) && (a & NCN_REMOVE )) ||
  88. ((a & NCN_ENABLE) && (a & NCN_DISABLE)) ||
  89. // Can't remove and enable at the same time.
  90. ((a & NCN_REMOVE) && (a & NCN_ENABLE)) ||
  91. // Can't add without an enable or disable.
  92. ((a & NCN_ADD) && !(a & (NCN_ENABLE | NCN_DISABLE)));
  93. }
  94. inline BOOL FBadArgs_INetCfgBindNotify_QueryBindingPath(DWORD a, INetCfgBindingPath* b)
  95. {
  96. return FBadNotifyFlags(a) || FBadInPtr(b);
  97. }
  98. #define Validate_INetCfgBindNotify_QueryBindingPath(a, b) \
  99. if (FBadArgs_INetCfgBindNotify_QueryBindingPath(a, b)) \
  100. { \
  101. TraceError("Validate_INetCfgBindNotify_QueryBindingPath", E_INVALIDARG); \
  102. return E_INVALIDARG; \
  103. }
  104. #define Validate_INetCfgBindNotify_QueryBindingPath_Return(hr) \
  105. AssertSz ((S_OK == hr) || (NETCFG_S_DISABLE_QUERY == hr) || (NETCFG_S_VETO_QUERY == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgBindNotify_QueryBindingPath");
  106. inline BOOL FBadArgs_INetCfgBindNotify_NotifyBindingPath(DWORD a, INetCfgBindingPath* b)
  107. {
  108. return FBadNotifyFlags(a) || FBadInPtr(b);
  109. }
  110. #define Validate_INetCfgBindNotify_NotifyBindingPath(a, b) \
  111. if (FBadArgs_INetCfgBindNotify_NotifyBindingPath(a, b)) \
  112. { \
  113. TraceError("Validate_INetCfgBindNotify_NotifyBindingPath", E_INVALIDARG); \
  114. return E_INVALIDARG; \
  115. }
  116. #define Validate_INetCfgBindNotify_NotifyBindingPath_Return(hr) \
  117. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgBindNotify_NotifyBindingPath");
  118. //+---------------------------------------------------------------------------
  119. // INetCfgSystemNotify
  120. //
  121. BOOL FBadArgs_INetCfgSystemNotify_GetSupportedNotifications(DWORD* a);
  122. #define Validate_INetCfgSystemNotify_GetSupportedNotifications(a) \
  123. if (FBadArgs_INetCfgSystemNotify_GetSupportedNotifications(a)) \
  124. { \
  125. TraceError("Validate_INetCfgSystemNotify_GetSupportedNotifications", E_INVALIDARG); \
  126. return E_INVALIDARG; \
  127. }
  128. #define Validate_INetCfgSystemNotify_GetSupportedNotifications_Return(hr) \
  129. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgSystemNotify_GetSupportedNotifications");
  130. inline BOOL FBadArgs_INetCfgSystemNotify_SysQueryBindingPath(DWORD a, INetCfgBindingPath* b)
  131. {
  132. return FBadNotifyFlags(a) || FBadInPtr(b);
  133. }
  134. #define Validate_INetCfgSystemNotify_SysQueryBindingPath(a, b) \
  135. if (FBadArgs_INetCfgSystemNotify_SysQueryBindingPath(a, b)) \
  136. { \
  137. TraceError("Validate_INetCfgSystemNotify_SysQueryBindingPath", E_INVALIDARG); \
  138. return E_INVALIDARG; \
  139. }
  140. #define Validate_INetCfgSystemNotify_SysQueryBindingPath_Return(hr) \
  141. AssertSz ((S_OK == hr) || (NETCFG_S_DISABLE_QUERY == hr) || (NETCFG_S_VETO_QUERY == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgSystemNotify_SysQueryBindingPath");
  142. inline BOOL FBadArgs_INetCfgSystemNotify_SysQueryComponent(DWORD a, INetCfgComponent* b)
  143. {
  144. return FBadInPtr(b);
  145. }
  146. #define Validate_INetCfgSystemNotify_SysQueryComponent(a, b) \
  147. if (FBadArgs_INetCfgSystemNotify_SysQueryComponent(a, b)) \
  148. { \
  149. TraceError("Validate_INetCfgSystemNotify_SysQueryComponent", E_INVALIDARG); \
  150. return E_INVALIDARG; \
  151. }
  152. #define Validate_INetCfgSystemNotify_SysQueryComponent_Return(hr) \
  153. AssertSz ((S_OK == hr) || (NETCFG_S_VETO_QUERY == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgSystemNotify_SysQueryComponent");
  154. inline BOOL FBadArgs_INetCfgSystemNotify_SysNotifyBindingPath(DWORD a, INetCfgBindingPath* b)
  155. {
  156. return FBadNotifyFlags(a) || FBadInPtr(b);
  157. }
  158. #define Validate_INetCfgSystemNotify_SysNotifyBindingPath(a, b) \
  159. if (FBadArgs_INetCfgSystemNotify_SysNotifyBindingPath(a, b)) \
  160. { \
  161. TraceError("Validate_INetCfgSystemNotify_SysNotifyBindingPath", E_INVALIDARG); \
  162. return E_INVALIDARG; \
  163. }
  164. #define Validate_INetCfgSystemNotify_SysNotifyBindingPath_Return(hr) \
  165. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgSystemNotify_SysNotifyBindingPath");
  166. inline BOOL FBadArgs_INetCfgSystemNotify_SysNotifyComponent(DWORD a, INetCfgComponent* b)
  167. {
  168. return FBadInPtr(b);
  169. }
  170. #define Validate_INetCfgSystemNotify_SysNotifyComponent(a, b) \
  171. if (FBadArgs_INetCfgSystemNotify_SysNotifyComponent(a, b)) \
  172. { \
  173. TraceError("Validate_INetCfgSystemNotify_SysNotifyComponent", E_INVALIDARG); \
  174. return E_INVALIDARG; \
  175. }
  176. #define Validate_INetCfgSystemNotify_SysNotifyComponent_Return(hr) \
  177. AssertSz ((S_OK == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_INetCfgSystemNotify_SysNotifyComponent");
  178. // ISupportErrorInfo
  179. inline BOOL FBadArgs_ISupportErrorInfo_InterfaceSupportsErrorInfo(REFIID a)
  180. {
  181. return FBadInRefiid(a);
  182. }
  183. #define Validate_ISupportErrorInfo_InterfaceSupportsErrorInfo(a) \
  184. if (FBadArgs_ISupportErrorInfo_InterfaceSupportsErrorInfo(a)) \
  185. { \
  186. TraceError("Validate_ISupportErrorInfo_InterfaceSupportsErrorInfo", E_INVALIDARG); \
  187. return E_INVALIDARG; \
  188. }
  189. #define Validate_ISupportErrorInfo_InterfaceSupportsErrorInfo_Return(hr) \
  190. AssertSz ((S_OK == hr) || (S_FALSE == hr) || FAILED(hr), "Invalid HRESULT returned from Validate_ISupportErrorInfo_InterfaceSupportsErrorInfo");
  191. #endif // _NOTIFVAL_H_