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.

393 lines
7.4 KiB

  1. /*
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. sdpbstrl.h
  5. Abstract:
  6. Author:
  7. */
  8. #ifndef __SDP_BSTRING_LINE__
  9. #define __SDP_BSTRING_LINE__
  10. #include "sdpcommo.h"
  11. #include <wtypes.h>
  12. #include "sdpdef.h"
  13. #include "sdpgen.h"
  14. #include "sdpcstrl.h"
  15. #include "sdpcset.h"
  16. class _DllDecl SDP_ARRAY_BSTR : public CArray<BSTR, BSTR>
  17. {
  18. public:
  19. virtual ~SDP_ARRAY_BSTR();
  20. };
  21. class _DllDecl SDP_BSTRING : public SDP_CHAR_STRING
  22. {
  23. public:
  24. inline SDP_BSTRING();
  25. virtual void Reset();
  26. inline SDP_CHARACTER_SET GetCharacterSet() const;
  27. inline BOOL SetCharacterSet(IN SDP_CHARACTER_SET CharacterSet);
  28. inline BSTR &GetBstr();
  29. HRESULT GetBstrCopy(IN BSTR *Bstr);
  30. virtual HRESULT GetBstr(IN BSTR *Bstr);
  31. virtual HRESULT SetBstr(IN BSTR Bstr);
  32. virtual ~SDP_BSTRING();
  33. protected:
  34. SDP_CHARACTER_SET m_CharacterSet;
  35. UINT m_CodePage;
  36. BSTR m_Bstr;
  37. virtual BOOL InternalSetCharStrByRef(
  38. IN CHAR *CharacterStringByReference,
  39. IN DWORD Length
  40. );
  41. virtual BOOL InternalSetCharStrByCopy(
  42. IN const CHAR *CharacterStringByCopy,
  43. IN DWORD Length
  44. );
  45. virtual BOOL InternalParseToken(
  46. IN CHAR *Token
  47. );
  48. BOOL ConvertToBstr(
  49. );
  50. };
  51. inline
  52. SDP_BSTRING::SDP_BSTRING(
  53. )
  54. : m_Bstr(NULL),
  55. m_CharacterSet(CS_UTF8),
  56. m_CodePage(CP_UTF8)
  57. {
  58. }
  59. inline SDP_CHARACTER_SET
  60. SDP_BSTRING::GetCharacterSet(
  61. ) const
  62. {
  63. return m_CharacterSet;
  64. }
  65. inline BOOL
  66. SDP_BSTRING::SetCharacterSet(
  67. IN SDP_CHARACTER_SET CharacterSet
  68. )
  69. {
  70. // check if the character set value is acceptable
  71. if ( !IsLegalCharacterSet(CharacterSet, &m_CodePage) )
  72. {
  73. SetLastError(SDP_INTERNAL_ERROR);
  74. return FALSE;
  75. }
  76. m_CharacterSet = CharacterSet;
  77. return TRUE;
  78. }
  79. inline BSTR &
  80. SDP_BSTRING::GetBstr(
  81. )
  82. {
  83. return m_Bstr;
  84. }
  85. // its initially created with the ascii character set and
  86. // it doesn't allow for changing the character set
  87. class _DllDecl SDP_OPTIONAL_BSTRING : public SDP_BSTRING
  88. {
  89. public:
  90. inline SDP_OPTIONAL_BSTRING();
  91. virtual void Reset();
  92. // returns the bstr for the character string
  93. // creates a bstr if required
  94. virtual HRESULT GetBstr(IN BSTR *Bstr);
  95. virtual HRESULT SetBstr(IN BSTR Bstr);
  96. protected:
  97. BOOL m_IsBstrCreated;
  98. virtual BOOL InternalSetCharStrByRef(
  99. IN CHAR *CharacterStringByReference,
  100. IN DWORD Length
  101. );
  102. virtual BOOL InternalSetCharStrByCopy(
  103. IN const CHAR *CharacterStringByCopy,
  104. IN DWORD Length
  105. );
  106. private:
  107. // since the bstr must only be created on demand, parsing must
  108. // be over-ridden such that the bstr is not created during parsing
  109. virtual BOOL InternalParseToken(
  110. IN CHAR *Token
  111. );
  112. // ZoltanS win64 fix: This bogus code was causing warnings.
  113. // Removed these methods so that the compiler will make sure that they
  114. // are never called. (Why it was ever done this way is a real mystery.)
  115. //
  116. // inline BOOL SetCharacterSet(IN SDP_CHARACTER_SET CharacterSet)
  117. // {
  118. // // this is never called
  119. // ASSERT(FALSE);
  120. // return FALSE;
  121. // }
  122. //
  123. // inline BSTR &GetBstr()
  124. // {
  125. // BSTR ReturnValue;
  126. // // this is never called
  127. // ASSERT(FALSE);
  128. // return ReturnValue;
  129. // }
  130. };
  131. inline
  132. SDP_OPTIONAL_BSTRING::SDP_OPTIONAL_BSTRING(
  133. )
  134. : m_IsBstrCreated(FALSE)
  135. {}
  136. class _DllDecl SDP_BSTRING_LINE : public SDP_STRING_LINE
  137. {
  138. public:
  139. inline SDP_BSTRING_LINE(
  140. IN const DWORD ErrorCode,
  141. IN const CHAR *TypeString,
  142. IN SDP_BSTRING &SdpBstring
  143. );
  144. virtual HRESULT GetBstrCopy(IN BSTR *Bstr);
  145. virtual HRESULT SetBstr(IN BSTR Bstr);
  146. inline SDP_BSTRING &GetBstring();
  147. };
  148. inline
  149. SDP_BSTRING_LINE::SDP_BSTRING_LINE(
  150. IN const DWORD ErrorCode,
  151. IN const CHAR *TypeString,
  152. IN SDP_BSTRING &SdpBstring
  153. )
  154. : SDP_STRING_LINE(ErrorCode, TypeString, SdpBstring)
  155. {
  156. }
  157. inline SDP_BSTRING &
  158. SDP_BSTRING_LINE::GetBstring(
  159. )
  160. {
  161. return (SDP_BSTRING &)m_ParseField;
  162. }
  163. class _DllDecl SDP_REQD_BSTRING_LINE : public SDP_BSTRING_LINE
  164. {
  165. public:
  166. inline SDP_REQD_BSTRING_LINE(
  167. IN const DWORD ErrorCode,
  168. IN const CHAR *TypeString
  169. );
  170. private:
  171. SDP_BSTRING m_Bstring;
  172. virtual void InternalReset();
  173. };
  174. inline
  175. SDP_REQD_BSTRING_LINE::SDP_REQD_BSTRING_LINE(
  176. IN const DWORD ErrorCode,
  177. IN const CHAR *TypeString
  178. )
  179. : SDP_BSTRING_LINE(ErrorCode, TypeString, m_Bstring)
  180. {
  181. }
  182. class _DllDecl SDP_CHAR_STRING_LINE : public SDP_BSTRING_LINE
  183. {
  184. public:
  185. inline SDP_CHAR_STRING_LINE(
  186. IN const DWORD ErrorCode,
  187. IN const CHAR *TypeString
  188. );
  189. private:
  190. SDP_OPTIONAL_BSTRING m_SdpOptionalBstring;
  191. virtual void InternalReset();
  192. };
  193. inline
  194. SDP_CHAR_STRING_LINE::SDP_CHAR_STRING_LINE(
  195. IN const DWORD ErrorCode,
  196. IN const CHAR *TypeString
  197. )
  198. : SDP_BSTRING_LINE(ErrorCode, TypeString, m_SdpOptionalBstring)
  199. {
  200. }
  201. class _DllDecl SDP_LIMITED_CHAR_STRING : public SDP_OPTIONAL_BSTRING
  202. {
  203. public:
  204. inline SDP_LIMITED_CHAR_STRING(
  205. IN const CHAR **LegalStrings,
  206. IN DWORD NumStrings
  207. );
  208. HRESULT SetLimitedCharString(
  209. IN CHAR *String
  210. );
  211. protected:
  212. const CHAR **m_LegalStrings;
  213. const DWORD m_NumStrings;
  214. virtual BOOL InternalParseToken(
  215. IN CHAR *Token
  216. );
  217. };
  218. inline
  219. SDP_LIMITED_CHAR_STRING::SDP_LIMITED_CHAR_STRING(
  220. IN const CHAR **LegalStrings,
  221. IN DWORD NumStrings
  222. )
  223. : m_LegalStrings(LegalStrings),
  224. m_NumStrings(NumStrings)
  225. {
  226. }
  227. class _DllDecl SDP_ADDRESS : public SDP_OPTIONAL_BSTRING
  228. {
  229. public:
  230. inline SDP_ADDRESS();
  231. inline BOOL IsMulticast() const;
  232. inline void SetMulticast(
  233. IN BOOL IsMulticastFlag
  234. );
  235. HRESULT SetAddress(
  236. IN BSTR Address
  237. );
  238. // calls SetAddress(Bstr)
  239. virtual HRESULT SetBstr(
  240. IN BSTR Bstr
  241. );
  242. protected:
  243. BOOL m_IsMulticastFlag;
  244. virtual BOOL InternalParseToken(
  245. IN CHAR *Token
  246. );
  247. BOOL IsValidIP4Address(
  248. IN CHAR *Address,
  249. OUT ULONG &Ip4AddressValue
  250. );
  251. };
  252. inline SDP_ADDRESS::SDP_ADDRESS(
  253. )
  254. : m_IsMulticastFlag(FALSE)
  255. {
  256. }
  257. inline BOOL
  258. SDP_ADDRESS::IsMulticast(
  259. ) const
  260. {
  261. return m_IsMulticastFlag;
  262. }
  263. inline void
  264. SDP_ADDRESS::SetMulticast(
  265. IN BOOL IsMulticastFlag
  266. )
  267. {
  268. m_IsMulticastFlag = IsMulticastFlag;
  269. }
  270. #endif // __SDP_BSTRING_LINE__