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.

262 lines
8.3 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. common.hxx
  5. Abstract:
  6. Header file for SENS configuration tool code.
  7. Author:
  8. Gopal Parupudi <GopalP>
  9. [Notes:]
  10. optional-notes
  11. Revision History:
  12. GopalP 11/12/1997 Start.
  13. --*/
  14. #ifndef __COMMON_HXX__
  15. #define __COMMON_HXX__
  16. //
  17. // Do not turn it on in retail builds accidentally.
  18. //
  19. //#define DETAIL_DEBUG
  20. //
  21. // Include platform independent stuff
  22. //
  23. #include <sysinc.h>
  24. //
  25. // Constants
  26. //
  27. #define SENS_SERVICEA "SENS"
  28. #define SENS_SERVICE SENS_STRING("SENS")
  29. #define SENS_PROTSEQ (SENS_CHAR *) SENS_STRING("ncalrpc")
  30. #define SENS_ENDPOINT (SENS_CHAR *) SENS_STRING("senssvc")
  31. #define SENS_STARTED_EVENT SENS_STRING("SENS Started Event")
  32. #define DEFAULT_LAN_CONNECTION_NAME SENS_BSTR("LAN Connection")
  33. #define DEFAULT_WAN_CONNECTION_NAME SENS_BSTR("WAN Connection")
  34. #define DEFAULT_LAN_BANDWIDTH 10000000 // 10.0 mega-bits/sec
  35. #define DEFAULT_WAN_BANDWIDTH 28800 // 28.8 kilo-bits/sec
  36. #define MAX_DESTINATION_LENGTH 512
  37. #define MAX_QUERY_SIZE 512
  38. // Sens Configuration related constants
  39. #define SENS_REGISTRY_KEY SENS_STRING("SOFTWARE\\Microsoft\\Mobile\\SENS")
  40. #define SENS_AUTOSTART_KEY SENS_STRING("Software\\Microsoft\\Windows\\CurrentVersion\\Webcheck")
  41. #define SENS_AUTOSTART_VALUE SENS_STRING("LoadSENS")
  42. #define SENS_AUTOSTART_ENABLE SENS_STRING("Yes")
  43. #define SENS_AUTOSTART_DISABLE SENS_STRING("No")
  44. #define SENS_AUTOSTART_BINARY SENS_STRING("LoadWc.exe /M") // M for Mobile
  45. #define SENS_CONFIGURATION_DLL SENS_STRING("SensCfg.Dll")
  46. #define IS_SENS_CONFIGURED SENS_STRING("Configured")
  47. #define SENS_DEBUG_LEVEL SENS_STRING("Debug")
  48. #define SENS_REGISTER_FUNCTION "SensRegister"
  49. #define CONFIG_VERSION_CURRENT 0x00000020
  50. #define CONFIG_VERSION_NONE 0x00000000
  51. // Sens Cache related constants
  52. #define SENS_CACHE_NAME SENS_STRING("SENS Information Cache")
  53. #define SENS_CACHE_SIZE 256 // 32 DWORDs
  54. #define SENS_CACHE_VERSION 0x00000002
  55. #define CACHE_VALID_INTERVAL 3*60*1000 // 3 minutes
  56. // Logging Levels
  57. #define SENS_WARN 0x00000001
  58. #define SENS_INFO 0x00000002
  59. #define SENS_MEM 0x00000004
  60. #define SENS_DBG 0x00000008
  61. #define SENS_ERR 0x00000010
  62. #define SENS_ALL 0xFFFFFFFF
  63. #if defined(SENS_CHICAGO)
  64. #define AOL_PLATFORM
  65. #error NOT SUPPORTED IN THE CODE BASE ANY MORE
  66. #endif // SENS_CHICAGO
  67. //
  68. // Forwards
  69. //
  70. #if defined(SENS_CHICAGO)
  71. char *
  72. SensUnicodeStringToAnsi(
  73. unsigned short * StringW
  74. );
  75. unsigned short *
  76. SensAnsiStringToUnicode(
  77. char * StringA
  78. );
  79. #endif // SENS_CHICAGO
  80. #if DBG
  81. ULONG _cdecl
  82. SensDbgPrintA(
  83. CHAR * Format,
  84. ...
  85. );
  86. ULONG _cdecl
  87. SensDbgPrintW(
  88. WCHAR * Format,
  89. ...
  90. );
  91. void
  92. EnableDebugOutputIfNecessary(
  93. void
  94. );
  95. #endif // DBG
  96. //
  97. // Macros
  98. //
  99. /*++
  100. Important Notes:
  101. a. The following variables need to be defined before using these macros:
  102. HRESULT hr;
  103. LPOLESTR strGuid;
  104. b. Also, strGuid needs to be initialized to NULL.
  105. c. The function has to return an HRESULT
  106. d. The function has to have a "Cleanup" label which is the one
  107. (and only one) exit from the function.
  108. e. The function should FreeStr(strGuid); during the cleanup phase.
  109. --*/
  110. #define AllocateBstrFromString(_BSTR_, _STRING_) \
  111. \
  112. _BSTR_ = SysAllocString(_STRING_); \
  113. if (_BSTR_ == NULL) \
  114. { \
  115. SensPrintW(SENS_ERR, (L"SENS: SysAllocString(%s) failed!\n", _STRING_)); \
  116. hr = E_OUTOFMEMORY; \
  117. goto Cleanup; \
  118. }
  119. #define AllocateStrFromGuid(_STR_, _GUID_) \
  120. \
  121. /* Check to see if strGuid is non-NULL. If so, delete it. */ \
  122. if (NULL != strGuid) \
  123. { \
  124. FreeStr(strGuid); \
  125. strGuid = NULL; \
  126. } \
  127. \
  128. hr = StringFromIID(_GUID_, &_STR_); \
  129. if (FAILED(hr)) \
  130. { \
  131. SensPrintA(SENS_ERR, ("SENS: StringFromIID() returned <%x>\n", hr));\
  132. goto Cleanup; \
  133. }
  134. #define AllocateBstrFromGuid(_BSTR_, _GUID_) \
  135. \
  136. AllocateStrFromGuid(strGuid, _GUID_); \
  137. \
  138. AllocateBstrFromString(_BSTR_, strGuid);
  139. #define FreeStr(_STR_) \
  140. \
  141. /* Check to see if _STR_ is non-NULL. If so, delete it. */ \
  142. if (NULL != _STR_) \
  143. { \
  144. CoTaskMemFree(_STR_); \
  145. _STR_ = NULL; \
  146. }
  147. #define FreeBstr(_BSTR_) \
  148. \
  149. SysFreeString(_BSTR_);
  150. #define InitializeBstrVariant(_PVARIANT_, _BSTR_) \
  151. \
  152. VariantInit(_PVARIANT_); \
  153. \
  154. (_PVARIANT_)->vt = VT_BSTR; \
  155. (_PVARIANT_)->bstrVal = _BSTR_;
  156. #define InitializeDwordVariant(_PVARIANT_, _DWORD_) \
  157. \
  158. VariantInit(_PVARIANT_); \
  159. \
  160. (_PVARIANT_)->vt = VT_UI4; \
  161. (_PVARIANT_)->ulVal = _DWORD_;
  162. #define FreeVariant(_PVARIANT_) \
  163. \
  164. VariantClear(_PVARIANT_);
  165. /*++
  166. Notes:
  167. a. This macro can be called only once in a function since it defines a
  168. local variable.
  169. b. If any function in this macro fails, we ignore the error.
  170. --*/
  171. #if DBG
  172. #define DebugTraceGuid(_FUNCTION_NAME_, _REFIID_) \
  173. \
  174. SensPrintA(SENS_INFO, ("\t| " _FUNCTION_NAME_ " called on the following"\
  175. " IID...\n")); \
  176. LPOLESTR lpsz = NULL; \
  177. StringFromIID(_REFIID_, &lpsz); \
  178. if (lpsz != NULL) \
  179. { \
  180. SensPrintW(SENS_INFO, (L"\t| IID is %s\n", lpsz)); \
  181. CoTaskMemFree(lpsz); \
  182. } \
  183. #else // RETAIL
  184. #define DebugTraceGuid(_FUNCTION_NAME_, _REFIID_)
  185. #endif // DBG
  186. #endif // __COMMON_HXX__