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.

217 lines
6.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998.
  5. //
  6. // File: parsver.cxx
  7. //
  8. // Contents: IParserVerify implementation
  9. //
  10. // History: 11-06-97 danleg Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #pragma hdrstop
  15. #include <parsver.hxx>
  16. #include <cmdcreat.hxx> // CSimpleCommandCreator
  17. // Constants -----------------------------------------------------------------
  18. static const GUID clsidCICommandCreator = CLSID_CISimpleCommandCreator;
  19. //+-------------------------------------------------------------------------
  20. //
  21. // Member: CImpIParserVerify::CImpIParserVerify, public
  22. //
  23. // Synopsis: Constructor
  24. //
  25. // Arguments:
  26. //
  27. // History: 11-20-97 danleg Created from Monarch
  28. //
  29. //--------------------------------------------------------------------------
  30. CImpIParserVerify::CImpIParserVerify() : _cRef(1)
  31. {
  32. _xISimpleCommandCreator.Set( new CSimpleCommandCreator() );
  33. }
  34. //+-------------------------------------------------------------------------
  35. //
  36. // Member: CImpIParserVerify::QueryInterface, public
  37. //
  38. // Synopsis: Returns a pointer to a specified interface. Callers use
  39. // QueryInterface to determine which interfaces the called
  40. // object supports.
  41. //
  42. // Returns: S_OK Interface is supported and ppvObject is set
  43. // E_NOINTERFACE Interface is not supported
  44. // E_INVALIDARG One or more arguments are invalid
  45. //
  46. // History: 11-20-97 danleg Created from Monarch
  47. //
  48. //--------------------------------------------------------------------------
  49. STDMETHODIMP CImpIParserVerify::QueryInterface
  50. (
  51. REFIID riid, //@parm IN | Interface ID of the interface being queried for.
  52. LPVOID * ppv //@parm OUT | Pointer to interface that was instantiated
  53. )
  54. {
  55. if( ppv == NULL )
  56. return E_INVALIDARG;
  57. if( (riid == IID_IUnknown) ||
  58. (riid == IID_IParserVerify) )
  59. *ppv = (LPVOID)this;
  60. else
  61. *ppv = NULL;
  62. // If we're going to return an interface, AddRef it first
  63. if( *ppv )
  64. {
  65. ((LPUNKNOWN)*ppv)->AddRef();
  66. return NOERROR;
  67. }
  68. return E_NOINTERFACE;
  69. }
  70. //+-------------------------------------------------------------------------
  71. //
  72. // Member: CImpIParserVerify::AddRef, public
  73. //
  74. // Synopsis: Increments a persistence count for the object
  75. //
  76. // History: 11-20-97 danleg Created from Monarch
  77. //
  78. //--------------------------------------------------------------------------
  79. STDMETHODIMP_(ULONG) CImpIParserVerify::AddRef (void)
  80. {
  81. return InterlockedIncrement( (long*) &_cRef);
  82. }
  83. //+-------------------------------------------------------------------------
  84. //
  85. // Member: CImpIParserVerify::Release, public
  86. //
  87. // Synopsis: Decrements the persistence count for the object and if it is 0,
  88. // the object destroys itself.
  89. //
  90. // History: 11-20-97 danleg Created from Monarch
  91. //
  92. //--------------------------------------------------------------------------
  93. STDMETHODIMP_(ULONG) CImpIParserVerify::Release (void)
  94. {
  95. ULONG cRef;
  96. Win4Assert( _cRef > 0 );
  97. if( !(cRef = InterlockedDecrement( (long *) &_cRef)) )
  98. {
  99. delete this;
  100. return 0;
  101. }
  102. return cRef;
  103. }
  104. //+-------------------------------------------------------------------------
  105. //
  106. // Member: CImpIParserVerify::VerifyMachine, public
  107. //
  108. // Synopsis: Called by the parser to verify that the machine name is valid
  109. //
  110. // History: 11-20-97 danleg Created from Monarch
  111. //
  112. //--------------------------------------------------------------------------
  113. STDMETHODIMP CImpIParserVerify::VerifyMachine(
  114. LPCWSTR pcwszMachine
  115. )
  116. {
  117. return _xISimpleCommandCreator->VerifyCatalog(pcwszMachine, NULL);
  118. }
  119. //+-------------------------------------------------------------------------
  120. //
  121. // Member: CImpIParserVerify::VerifyCatalog, public
  122. //
  123. // Synopsis: Called by the parser to verify that the catalog name is valid
  124. //
  125. // History: 11-20-97 danleg Created from Monarch
  126. //
  127. //--------------------------------------------------------------------------
  128. STDMETHODIMP CImpIParserVerify::VerifyCatalog(
  129. LPCWSTR pcwszMachine,
  130. LPCWSTR pcwszCatalog
  131. )
  132. {
  133. return _xISimpleCommandCreator->VerifyCatalog(pcwszMachine, pcwszCatalog);
  134. }
  135. //+-------------------------------------------------------------------------
  136. //
  137. // Member: CImpIParserVerify::GetDefaultCatalog, public
  138. //
  139. // Synopsis: Retrieve the default catalog name
  140. //
  141. // History: 11-20-97 danleg Created from Monarch
  142. //
  143. //--------------------------------------------------------------------------
  144. STDMETHODIMP CImpIParserVerify::GetDefaultCatalog
  145. (
  146. LPWSTR pwszCatalogName,
  147. ULONG cwcIn,
  148. ULONG * pcwcOut
  149. )
  150. {
  151. Win4Assert( !_xISimpleCommandCreator.IsNull() );
  152. return _xISimpleCommandCreator->GetDefaultCatalog( pwszCatalogName,
  153. cwcIn,
  154. pcwcOut );
  155. }
  156. //+-------------------------------------------------------------------------
  157. //
  158. // Member: CImpIParserVerify::GetColMapperCreator, public
  159. //
  160. // Synopsis: Retrieve an IColumnMapperCreator interface pointer
  161. //
  162. // History: 11-20-97 danleg Created from Monarch
  163. //
  164. //--------------------------------------------------------------------------
  165. void CImpIParserVerify::GetColMapCreator
  166. (
  167. IColumnMapperCreator** ppIColMapCreator
  168. )
  169. {
  170. SCODE sc = S_OK;
  171. if ( ppIColMapCreator )
  172. {
  173. *ppIColMapCreator = 0;
  174. sc = _xISimpleCommandCreator->QueryInterface( IID_IColumnMapperCreator,
  175. (void **) ppIColMapCreator );
  176. }
  177. else
  178. sc = E_INVALIDARG;
  179. if ( FAILED(sc) )
  180. THROW( CException(sc) );
  181. }