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.

374 lines
6.0 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbreg.h
  5. Abstract:
  6. Author:
  7. */
  8. #ifndef __SDP_BLOB_REGISTRY__
  9. #define __SDP_BLOB_REGISTRY__
  10. #include <windows.h>
  11. #include <tchar.h>
  12. #include <winreg.h>
  13. // maximum length of a DNS host name
  14. const BYTE MAXHOSTNAME = 255;
  15. const TCHAR TCHAR_EOS = _T('\0');
  16. const DWORD MAX_REG_TSTR_SIZE = 100;
  17. const DWORD MAX_BLOB_TEMPLATE_SIZE = 2000;
  18. const DWORD NUM_DEF_ATTRIBUTES = 5;
  19. #define TIME_TEMPLATE _T("TimeTemplate")
  20. #define MEDIA_TEMPLATE _T("MediaTemplate")
  21. #define CONFERENCE_BLOB_TEMPLATE _T("SdpTemplate")
  22. #define START_TIME_OFFSET _T("startTimeOffset")
  23. #define STOP_TIME_OFFSET _T("stopTimeOffset")
  24. typedef struct
  25. {
  26. TCHAR *msz_ValueName;
  27. USHORT m_MaxSize;
  28. USHORT *m_TstrLen;
  29. TCHAR *msz_Tstr;
  30. } REG_INFO;
  31. extern REG_INFO g_ConfInstInfoArray[];
  32. class KEY_WRAP
  33. {
  34. public:
  35. inline KEY_WRAP(
  36. IN HKEY Key
  37. );
  38. inline ~KEY_WRAP();
  39. protected:
  40. HKEY m_Key;
  41. };
  42. inline
  43. KEY_WRAP::KEY_WRAP(
  44. IN HKEY Key
  45. )
  46. : m_Key(Key)
  47. {
  48. }
  49. inline
  50. KEY_WRAP::~KEY_WRAP(
  51. )
  52. {
  53. RegCloseKey(m_Key);
  54. }
  55. class REG_READER
  56. {
  57. public:
  58. inline static DWORD GetErrorCode();
  59. protected:
  60. static DWORD ms_ErrorCode;
  61. static BOOL ReadRegValues(
  62. IN HKEY Key,
  63. IN DWORD NumValues,
  64. IN REG_INFO const RegInfoArray[]
  65. );
  66. };
  67. inline DWORD
  68. REG_READER::GetErrorCode(
  69. )
  70. {
  71. return ms_ErrorCode;
  72. }
  73. class IP_ADDRESS
  74. {
  75. public:
  76. inline IP_ADDRESS();
  77. inline IP_ADDRESS(
  78. IN DWORD HostOrderIpAddress
  79. );
  80. inline BOOL IsValid() const;
  81. inline void SetIpAddress(
  82. IN DWORD HostOrderIpAddress
  83. );
  84. inline TCHAR *GetTstr() const;
  85. static BOOL GetLocalIpAddress(
  86. OUT DWORD &LocalIpAddress
  87. );
  88. protected:
  89. TCHAR m_IpAddressTstr[16];
  90. };
  91. inline
  92. IP_ADDRESS::IP_ADDRESS(
  93. )
  94. {
  95. // only needed for the static host ip address instance
  96. }
  97. inline
  98. IP_ADDRESS::IP_ADDRESS(
  99. IN DWORD HostOrderIpAddress
  100. )
  101. {
  102. SetIpAddress(HostOrderIpAddress);
  103. }
  104. inline BOOL
  105. IP_ADDRESS::IsValid(
  106. ) const
  107. {
  108. // if the ip address string is empty, the instance is invalid
  109. return (TCHAR_EOS != m_IpAddressTstr[0]);
  110. }
  111. inline void
  112. IP_ADDRESS::SetIpAddress(
  113. IN DWORD HostOrderIpAddress
  114. )
  115. {
  116. // format the four bytes in the dword into an ip address string
  117. // check for success (use verify)
  118. VERIFY(0 != _stprintf(m_IpAddressTstr, _T("%d.%d.%d.%d"),HIBYTE(HIWORD(HostOrderIpAddress)),LOBYTE(HIWORD(HostOrderIpAddress)),HIBYTE(LOWORD(HostOrderIpAddress)),LOBYTE(LOWORD(HostOrderIpAddress)) ) );
  119. }
  120. inline TCHAR *
  121. IP_ADDRESS::GetTstr(
  122. ) const
  123. {
  124. ASSERT(IsValid());
  125. return (TCHAR *)m_IpAddressTstr;
  126. }
  127. class SDP_REG_READER : public REG_READER
  128. {
  129. public:
  130. static TCHAR ms_TimeTemplate[MAX_REG_TSTR_SIZE];
  131. static TCHAR ms_MediaTemplate[MAX_REG_TSTR_SIZE];
  132. static TCHAR ms_ConfBlobTemplate[MAX_BLOB_TEMPLATE_SIZE];
  133. static USHORT ms_TimeTemplateLen;
  134. static USHORT ms_MediaTemplateLen;
  135. static USHORT ms_ConfBlobTemplateLen;
  136. static DWORD ms_StartTimeOffset;
  137. static DWORD ms_StopTimeOffset;
  138. inline static TCHAR *GetTimeTemplate();
  139. inline static USHORT GetTimeTemplateLen();
  140. inline static TCHAR *GetMediaTemplate();
  141. inline static USHORT GetMediaTemplateLen();
  142. inline static TCHAR *GetConfBlobTemplate();
  143. inline static USHORT GetConfBlobTemplateLen();
  144. inline static DWORD GetStartTimeOffset();
  145. inline static DWORD GetStopTimeOffset();
  146. inline static TCHAR *GetHostIpAddress();
  147. static BOOL IsWinsockStarted() { return ms_fWinsockStarted; }
  148. inline static BOOL IsValid();
  149. protected:
  150. static BOOL ms_fInitCalled;
  151. static BOOL ms_fWinsockStarted;
  152. static IP_ADDRESS ms_HostIpAddress;
  153. static BOOL CheckIfCorrectVersion();
  154. static BOOL ReadTimeValues(
  155. IN HKEY ConfInstKey
  156. );
  157. static void Init();
  158. static void AddCharacterSetAttribute();
  159. };
  160. inline TCHAR *
  161. SDP_REG_READER::GetTimeTemplate(
  162. )
  163. {
  164. if (!ms_fInitCalled)
  165. {
  166. Init();
  167. }
  168. return ms_TimeTemplate;
  169. }
  170. inline USHORT
  171. SDP_REG_READER::GetTimeTemplateLen(
  172. )
  173. {
  174. if (!ms_fInitCalled)
  175. {
  176. Init();
  177. }
  178. return ms_TimeTemplateLen;
  179. }
  180. inline TCHAR *
  181. SDP_REG_READER::GetMediaTemplate(
  182. )
  183. {
  184. if (!ms_fInitCalled)
  185. {
  186. Init();
  187. }
  188. return ms_MediaTemplate;
  189. }
  190. inline USHORT
  191. SDP_REG_READER::GetMediaTemplateLen(
  192. )
  193. {
  194. if (!ms_fInitCalled)
  195. {
  196. Init();
  197. }
  198. return ms_MediaTemplateLen;
  199. }
  200. inline TCHAR *
  201. SDP_REG_READER::GetConfBlobTemplate(
  202. )
  203. {
  204. if (!ms_fInitCalled)
  205. {
  206. Init();
  207. }
  208. return ms_ConfBlobTemplate;
  209. }
  210. inline USHORT
  211. SDP_REG_READER::GetConfBlobTemplateLen(
  212. )
  213. {
  214. if (!ms_fInitCalled)
  215. {
  216. Init();
  217. }
  218. return ms_ConfBlobTemplateLen;
  219. }
  220. inline DWORD
  221. SDP_REG_READER::GetStartTimeOffset(
  222. )
  223. {
  224. if (!ms_fInitCalled)
  225. {
  226. Init();
  227. }
  228. return ms_StartTimeOffset;
  229. }
  230. inline DWORD
  231. SDP_REG_READER::GetStopTimeOffset(
  232. )
  233. {
  234. if (!ms_fInitCalled)
  235. {
  236. Init();
  237. }
  238. return ms_StopTimeOffset;
  239. }
  240. inline TCHAR *
  241. SDP_REG_READER::GetHostIpAddress(
  242. )
  243. {
  244. if (!ms_fInitCalled)
  245. {
  246. Init();
  247. }
  248. return ms_HostIpAddress.GetTstr();
  249. }
  250. inline BOOL
  251. SDP_REG_READER::IsValid(
  252. )
  253. {
  254. if (!ms_fInitCalled)
  255. {
  256. Init();
  257. }
  258. return (ERROR_SUCCESS == ms_ErrorCode)? TRUE: FALSE;
  259. }
  260. #endif // __SDP_BLOB_REGISTRY__