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.

241 lines
3.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: column.cpp
  7. //
  8. // Contents: Cert Server Database interface implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #include <pch.cpp>
  12. #pragma hdrstop
  13. #include "csprop.h"
  14. #include "column.h"
  15. #include "enum.h"
  16. #include "db.h"
  17. #include "row.h"
  18. #include "dbw.h"
  19. #if DBG
  20. LONG g_cCertDBColumn;
  21. LONG g_cCertDBColumnTotal;
  22. #endif
  23. CEnumCERTDBCOLUMN::CEnumCERTDBCOLUMN()
  24. {
  25. DBGCODE(InterlockedIncrement(&g_cCertDBColumn));
  26. DBGCODE(InterlockedIncrement(&g_cCertDBColumnTotal));
  27. m_pdb = NULL;
  28. m_ielt = 0;
  29. m_dwTable = CVRC_TABLE_REQCERT;
  30. m_cRef = 1;
  31. }
  32. CEnumCERTDBCOLUMN::~CEnumCERTDBCOLUMN()
  33. {
  34. DBGCODE(InterlockedDecrement(&g_cCertDBColumn));
  35. if (NULL != m_pdb)
  36. {
  37. m_pdb->Release();
  38. m_pdb = NULL;
  39. }
  40. }
  41. HRESULT
  42. CEnumCERTDBCOLUMN::Open(
  43. IN DWORD dwTable, // CVRC_TABLE_*
  44. IN ICertDB *pdb)
  45. {
  46. HRESULT hr;
  47. if (NULL == pdb)
  48. {
  49. hr = E_POINTER;
  50. _JumpError(hr, error, "NULL parm");
  51. }
  52. m_dwTable = dwTable;
  53. m_pdb = pdb;
  54. m_pdb->AddRef();
  55. hr = S_OK;
  56. error:
  57. return(hr);
  58. }
  59. STDMETHODIMP
  60. CEnumCERTDBCOLUMN::Next(
  61. /* [in] */ ULONG celt,
  62. /* [out] */ CERTDBCOLUMN *rgelt,
  63. /* [out] */ ULONG *pceltFetched)
  64. {
  65. HRESULT hr;
  66. DWORD ieltNext;
  67. if (NULL == rgelt || NULL == pceltFetched)
  68. {
  69. hr = E_POINTER;
  70. _JumpError(hr, error, "NULL parm");
  71. }
  72. if (NULL == m_pdb)
  73. {
  74. hr = E_UNEXPECTED;
  75. _JumpError(hr, error, "NULL m_pdb");
  76. }
  77. hr = ((CCertDB *) m_pdb)->EnumCertDBColumnNext(
  78. m_dwTable,
  79. m_ielt,
  80. celt,
  81. rgelt,
  82. &ieltNext,
  83. pceltFetched);
  84. if (S_FALSE != hr)
  85. {
  86. _JumpIfError(hr, error, "EnumCertDBColumnNext");
  87. }
  88. m_ielt = ieltNext;
  89. error:
  90. return(hr);
  91. }
  92. STDMETHODIMP
  93. CEnumCERTDBCOLUMN::Skip(
  94. /* [in] */ LONG celt,
  95. /* [out] */ LONG *pielt)
  96. {
  97. HRESULT hr;
  98. if (NULL == pielt)
  99. {
  100. hr = E_POINTER;
  101. _JumpError(hr, error, "NULL parm");
  102. }
  103. m_ielt += celt;
  104. *pielt = m_ielt;
  105. hr = S_OK;
  106. error:
  107. return(hr);
  108. }
  109. STDMETHODIMP
  110. CEnumCERTDBCOLUMN::Reset(VOID)
  111. {
  112. m_ielt = 0;
  113. return(S_OK);
  114. }
  115. STDMETHODIMP
  116. CEnumCERTDBCOLUMN::Clone(
  117. /* [out] */ IEnumCERTDBCOLUMN **ppenum)
  118. {
  119. HRESULT hr;
  120. LONG iDummy;
  121. IEnumCERTDBCOLUMN *penum = NULL;
  122. if (NULL == ppenum)
  123. {
  124. hr = E_POINTER;
  125. _JumpError(hr, error, "NULL parm");
  126. }
  127. hr = m_pdb->EnumCertDBColumn(m_dwTable, &penum);
  128. _JumpIfError(hr, error, "EnumCertDBColumn");
  129. if (0 != m_ielt)
  130. {
  131. penum->Skip(m_ielt, &iDummy);
  132. }
  133. error:
  134. if (NULL != ppenum)
  135. {
  136. *ppenum = penum;
  137. }
  138. return(hr);
  139. }
  140. // IUnknown implementation
  141. STDMETHODIMP
  142. CEnumCERTDBCOLUMN::QueryInterface(const IID& iid, void **ppv)
  143. {
  144. HRESULT hr;
  145. if (NULL == ppv)
  146. {
  147. hr = E_POINTER;
  148. _JumpError(hr, error, "NULL parm");
  149. }
  150. if (iid == IID_IUnknown)
  151. {
  152. *ppv = static_cast<IEnumCERTDBCOLUMN *>(this);
  153. }
  154. else if (iid == IID_IEnumCERTDBCOLUMN)
  155. {
  156. *ppv = static_cast<IEnumCERTDBCOLUMN *>(this);
  157. }
  158. else
  159. {
  160. *ppv = NULL;
  161. hr = E_NOINTERFACE;
  162. _JumpError(hr, error, "IID");
  163. }
  164. reinterpret_cast<IUnknown *>(*ppv)->AddRef();
  165. hr = S_OK;
  166. error:
  167. return(hr);
  168. }
  169. ULONG STDMETHODCALLTYPE
  170. CEnumCERTDBCOLUMN::AddRef()
  171. {
  172. return(InterlockedIncrement(&m_cRef));
  173. }
  174. ULONG STDMETHODCALLTYPE
  175. CEnumCERTDBCOLUMN::Release()
  176. {
  177. ULONG cRef = InterlockedDecrement(&m_cRef);
  178. if (0 == cRef)
  179. {
  180. delete this;
  181. }
  182. return(cRef);
  183. }
  184. #if 0
  185. STDMETHODIMP
  186. CEnumCERTDBCOLUMN::InterfaceSupportsErrorInfo(
  187. IN REFIID riid)
  188. {
  189. static const IID *arr[] =
  190. {
  191. &IID_IEnumCERTDBCOLUMN,
  192. };
  193. for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
  194. {
  195. if (InlineIsEqualGUID(*arr[i], riid))
  196. {
  197. return(S_OK);
  198. }
  199. }
  200. return(S_FALSE);
  201. }
  202. #endif