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.

183 lines
5.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1997 **/
  4. /**********************************************************************/
  5. /*
  6. ripstrm.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "ripstrm.h"
  11. #include "xstream.h"
  12. /*!--------------------------------------------------------------------------
  13. RipConfigStream::RipConfigStream
  14. -
  15. Author: KennT
  16. ---------------------------------------------------------------------------*/
  17. RipConfigStream::RipConfigStream()
  18. {
  19. m_nVersionAdmin = 0x00020000;
  20. m_nVersion = 0x00020000;
  21. }
  22. /*!--------------------------------------------------------------------------
  23. RipConfigStream::InitNew
  24. -
  25. Author: KennT
  26. ---------------------------------------------------------------------------*/
  27. HRESULT RipConfigStream::InitNew()
  28. {
  29. // Setup the appropriate defaults
  30. // m_nVersionAdmin = 0x00020000;
  31. // m_nVersion = 0x00020000;
  32. // m_stName.Empty();
  33. return hrOK;
  34. }
  35. /*!--------------------------------------------------------------------------
  36. RipConfigStream::SaveTo
  37. -
  38. Author: KennT
  39. ---------------------------------------------------------------------------*/
  40. HRESULT RipConfigStream::SaveTo(IStream *pstm)
  41. {
  42. return XferVersion0(pstm, XferStream::MODE_WRITE, NULL);
  43. }
  44. /*!--------------------------------------------------------------------------
  45. RipConfigStream::SaveAs
  46. -
  47. Author: KennT
  48. ---------------------------------------------------------------------------*/
  49. HRESULT RipConfigStream::SaveAs(UINT nVersion, IStream *pstm)
  50. {
  51. return XferVersion0(pstm, XferStream::MODE_WRITE, NULL);
  52. }
  53. /*!--------------------------------------------------------------------------
  54. RipConfigStream::LoadFrom
  55. -
  56. Author: KennT
  57. ---------------------------------------------------------------------------*/
  58. HRESULT RipConfigStream::LoadFrom(IStream *pstm)
  59. {
  60. return XferVersion0(pstm, XferStream::MODE_READ, NULL);
  61. }
  62. /*!--------------------------------------------------------------------------
  63. RipConfigStream::GetSize
  64. -
  65. Author: KennT
  66. ---------------------------------------------------------------------------*/
  67. HRESULT RipConfigStream::GetSize(ULONG *pcbSize)
  68. {
  69. return XferVersion0(NULL, XferStream::MODE_SIZE, NULL);
  70. }
  71. /*!--------------------------------------------------------------------------
  72. RipConfigStream::GetVersionInfo
  73. -
  74. Author: KennT
  75. ---------------------------------------------------------------------------*/
  76. HRESULT RipConfigStream::GetVersionInfo(DWORD *pdwVersion, DWORD *pdwAdminVersion)
  77. {
  78. if (pdwVersion)
  79. *pdwVersion = m_nVersion;
  80. if (pdwAdminVersion)
  81. *pdwAdminVersion = m_nVersionAdmin;
  82. return hrOK;
  83. }
  84. /*!--------------------------------------------------------------------------
  85. RipConfigStream::XferVersion0
  86. -
  87. Author: KennT
  88. ---------------------------------------------------------------------------*/
  89. struct _ViewInfoEntry
  90. {
  91. ULONG m_ulId;
  92. ULONG m_idSort;
  93. ULONG m_idAscending;
  94. ULONG m_idColumns;
  95. ULONG m_idPos;
  96. };
  97. static const _ViewInfoEntry s_rgRIPAdminViewInfo[] =
  98. {
  99. { RIPSTRM_STATS_RIPPARAMS,
  100. RIPSTRM_TAG_STATS_RIPPARAMS_SORT,
  101. RIPSTRM_TAG_STATS_RIPPARAMS_ASCENDING,
  102. RIPSTRM_TAG_STATS_RIPPARAMS_COLUMNS,
  103. RIPSTRM_TAG_STATS_RIPPARAMS_POSITION },
  104. };
  105. HRESULT RipConfigStream::XferVersion0(IStream *pstm, XferStream::Mode mode, ULONG *pcbSize)
  106. {
  107. XferStream xstm(pstm, mode);
  108. HRESULT hr = hrOK;
  109. int i;
  110. CORg( xstm.XferDWORD( RIPSTRM_TAG_VERSION, &m_nVersion ) );
  111. CORg( xstm.XferDWORD( RIPSTRM_TAG_VERSIONADMIN, &m_nVersionAdmin ) );
  112. for ( i=0; i<DimensionOf(s_rgRIPAdminViewInfo); i++)
  113. {
  114. CORg( m_rgViewInfo[s_rgRIPAdminViewInfo[i].m_ulId].Xfer(&xstm,
  115. s_rgRIPAdminViewInfo[i].m_idSort,
  116. s_rgRIPAdminViewInfo[i].m_idAscending,
  117. s_rgRIPAdminViewInfo[i].m_idColumns) );
  118. CORg( xstm.XferRect( s_rgRIPAdminViewInfo[i].m_idPos,
  119. &m_prgrc[s_rgRIPAdminViewInfo[i].m_ulId]) );
  120. }
  121. if (pcbSize)
  122. *pcbSize = xstm.GetSize();
  123. Error:
  124. return hr;
  125. }
  126. /*---------------------------------------------------------------------------
  127. RipComponentConfigStream implementation
  128. ---------------------------------------------------------------------------*/
  129. enum RIPCOMPSTRM_TAG
  130. {
  131. RIPCOMPSTRM_TAG_VERSION = XFER_TAG(1, XFER_DWORD),
  132. RIPCOMPSTRM_TAG_VERSIONADMIN = XFER_TAG(2, XFER_DWORD),
  133. RIPCOMPSTRM_TAG_SUMMARY_COLUMNS = XFER_TAG(3, XFER_COLUMNDATA_ARRAY),
  134. RIPCOMPSTRM_TAG_SUMMARY_SORT_COLUMN = XFER_TAG(4, XFER_DWORD),
  135. RIPCOMPSTRM_TAG_SUMMARY_SORT_ASCENDING = XFER_TAG(5, XFER_DWORD),
  136. };
  137. HRESULT RipComponentConfigStream::XferVersion0(IStream *pstm, XferStream::Mode mode, ULONG *pcbSize)
  138. {
  139. XferStream xstm(pstm, mode);
  140. HRESULT hr = hrOK;
  141. CORg( xstm.XferDWORD( RIPCOMPSTRM_TAG_VERSION, &m_nVersion ) );
  142. CORg( xstm.XferDWORD( RIPCOMPSTRM_TAG_VERSIONADMIN, &m_nVersionAdmin ) );
  143. CORg( m_rgViewInfo[RIP_COLUMNS].Xfer(&xstm,
  144. RIPCOMPSTRM_TAG_SUMMARY_SORT_COLUMN,
  145. RIPCOMPSTRM_TAG_SUMMARY_SORT_ASCENDING,
  146. RIPCOMPSTRM_TAG_SUMMARY_COLUMNS) );
  147. if (pcbSize)
  148. *pcbSize = xstm.GetSize();
  149. Error:
  150. return hr;
  151. }