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.

186 lines
5.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1997 **/
  4. /**********************************************************************/
  5. /*
  6. rtrstrm.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "rtrstrm.h"
  11. #include "xstream.h"
  12. #define CURRENT_RTRSTRM_VERSION 0x00020001
  13. /*!--------------------------------------------------------------------------
  14. RouterAdminConfigStream::RouterAdminConfigStream
  15. -
  16. Author: KennT
  17. ---------------------------------------------------------------------------*/
  18. RouterAdminConfigStream::RouterAdminConfigStream()
  19. : m_nVersion(-1), m_fDirty(FALSE)
  20. {
  21. m_nVersionAdmin = 0x00020000;
  22. m_nVersion = CURRENT_RTRSTRM_VERSION;
  23. }
  24. /*!--------------------------------------------------------------------------
  25. RouterAdminConfigStream::InitNew
  26. -
  27. Author: KennT
  28. ---------------------------------------------------------------------------*/
  29. HRESULT RouterAdminConfigStream::InitNew()
  30. {
  31. // Setup the appropriate defaults
  32. // m_nVersionAdmin = 0x00020000;
  33. // m_nVersion = 0x00020000;
  34. // m_fServer = TRUE;
  35. // m_stName.Empty();
  36. return hrOK;
  37. }
  38. /*!--------------------------------------------------------------------------
  39. RouterAdminConfigStream::SaveTo
  40. -
  41. Author: KennT
  42. ---------------------------------------------------------------------------*/
  43. HRESULT RouterAdminConfigStream::SaveTo(IStream *pstm)
  44. {
  45. return XferVersion0(pstm, XferStream::MODE_WRITE, NULL);
  46. }
  47. /*!--------------------------------------------------------------------------
  48. RouterAdminConfigStream::SaveAs
  49. -
  50. Author: KennT
  51. ---------------------------------------------------------------------------*/
  52. HRESULT RouterAdminConfigStream::SaveAs(UINT nVersion, IStream *pstm)
  53. {
  54. return XferVersion0(pstm, XferStream::MODE_WRITE, NULL);
  55. }
  56. /*!--------------------------------------------------------------------------
  57. RouterAdminConfigStream::LoadFrom
  58. -
  59. Author: KennT
  60. ---------------------------------------------------------------------------*/
  61. HRESULT RouterAdminConfigStream::LoadFrom(IStream *pstm)
  62. {
  63. return XferVersion0(pstm, XferStream::MODE_READ, NULL);
  64. }
  65. /*!--------------------------------------------------------------------------
  66. RouterAdminConfigStream::GetSize
  67. -
  68. Author: KennT
  69. ---------------------------------------------------------------------------*/
  70. HRESULT RouterAdminConfigStream::GetSize(ULONG *pcbSize)
  71. {
  72. return XferVersion0(NULL, XferStream::MODE_SIZE, NULL);
  73. }
  74. /*!--------------------------------------------------------------------------
  75. RouterAdminConfigStream::GetVersionInfo
  76. -
  77. Author: KennT
  78. ---------------------------------------------------------------------------*/
  79. HRESULT RouterAdminConfigStream::GetVersionInfo(DWORD *pdwVersion, DWORD *pdwAdminVersion)
  80. {
  81. if (pdwVersion)
  82. *pdwVersion = m_nVersion;
  83. if (pdwAdminVersion)
  84. *pdwAdminVersion = m_nVersionAdmin;
  85. return hrOK;
  86. }
  87. /*!--------------------------------------------------------------------------
  88. RouterAdminConfigStream::GetLocationInfo
  89. -
  90. Author: KennT
  91. ---------------------------------------------------------------------------*/
  92. HRESULT RouterAdminConfigStream::GetLocationInfo(BOOL *pfServer,
  93. CString *pstName, BOOL *pfOverride)
  94. {
  95. if (pfServer)
  96. *pfServer = m_fServer;
  97. if (pstName)
  98. *pstName = m_stName;
  99. if (pfOverride)
  100. *pfOverride = m_fOverride;
  101. return hrOK;
  102. }
  103. /*!--------------------------------------------------------------------------
  104. RouterAdminConfigStream::SetLocationInfo
  105. -
  106. Author: KennT
  107. ---------------------------------------------------------------------------*/
  108. HRESULT RouterAdminConfigStream::SetLocationInfo(BOOL fServer,
  109. LPCTSTR pszName, BOOL fOverride)
  110. {
  111. m_fServer = fServer;
  112. m_stName = pszName;
  113. m_fOverride = fOverride;
  114. SetDirty(TRUE);
  115. return hrOK;
  116. }
  117. /*!--------------------------------------------------------------------------
  118. RouterAdminConfigStream::XferVersion0
  119. -
  120. Author: KennT
  121. ---------------------------------------------------------------------------*/
  122. HRESULT RouterAdminConfigStream::XferVersion0(IStream *pstm, XferStream::Mode mode, ULONG *pcbSize)
  123. {
  124. XferStream xstm(pstm, mode);
  125. HRESULT hr = hrOK;
  126. CORg( xstm.XferDWORD( RTRSTRM_TAG_VERSION, &m_nVersion ) );
  127. AssertSz(m_nVersion == CURRENT_RTRSTRM_VERSION, "Wrong saved console version!");
  128. CORg( xstm.XferDWORD( RTRSTRM_TAG_VERSIONADMIN, &m_nVersionAdmin ) );
  129. CORg( xstm.XferDWORD( RTRSTRM_TAG_SERVER, &m_fServer ) );
  130. CORg( xstm.XferCString( RTRSTRM_TAG_NAME, &m_stName ) );
  131. CORg( xstm.XferDWORD( RTRSTRM_TAG_OVERRIDE, &m_fOverride ) );
  132. if (pcbSize)
  133. *pcbSize = xstm.GetSize();
  134. Error:
  135. return hr;
  136. }
  137. enum
  138. {
  139. INTERFACES_TAG_VERSION = XFER_TAG(1, XFER_DWORD),
  140. INTERFACES_TAG_VERSIONADMIN = XFER_TAG(2, XFER_DWORD),
  141. INTERFACES_TAG_COLUMNS = XFER_TAG(3, XFER_COLUMNDATA_ARRAY),
  142. INTERFACES_TAG_SORT_COLUMN = XFER_TAG(4, XFER_DWORD),
  143. INTERFACES_TAG_SORT_ASCENDING = XFER_TAG(5, XFER_DWORD),
  144. };
  145. HRESULT RouterComponentConfigStream::XferVersion0(IStream *pstm, XferStream::Mode mode, ULONG *pcbSize)
  146. {
  147. XferStream xstm(pstm, mode);
  148. HRESULT hr = hrOK;
  149. CORg( xstm.XferDWORD( INTERFACES_TAG_VERSION, &m_nVersion ) );
  150. CORg( xstm.XferDWORD( INTERFACES_TAG_VERSIONADMIN, &m_nVersionAdmin ) );
  151. CORg( m_rgViewInfo[0].Xfer(&xstm,
  152. INTERFACES_TAG_SORT_COLUMN,
  153. INTERFACES_TAG_SORT_ASCENDING,
  154. INTERFACES_TAG_COLUMNS) );
  155. if (pcbSize)
  156. *pcbSize = xstm.GetSize();
  157. Error:
  158. return hr;
  159. }