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.

106 lines
2.0 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: cienum.cpp
  7. //
  8. // Contents: Extension and Attribute enumerator
  9. //
  10. // History: 12-Mar-96 vich created
  11. //
  12. //---------------------------------------------------------------------------
  13. #include <pch.cpp>
  14. #pragma hdrstop
  15. #include "csprop.h"
  16. #include "csdisp.h"
  17. #define __dwFILE__ __dwFILE_CERTSRV_CIENUM_CPP__
  18. HRESULT
  19. CIENUM::EnumSetup(
  20. IN DWORD RequestId,
  21. IN LONG Context,
  22. IN DWORD Flags)
  23. {
  24. HRESULT hr;
  25. EnumClose();
  26. ICertDBRow *prow = NULL;
  27. hr = g_pCertDB->OpenRow(PROPOPEN_READONLY | PROPTABLE_REQCERT, RequestId, NULL, &prow);
  28. _JumpIfError(hr, error, "OpenRow");
  29. hr = prow->EnumCertDBName(~CIE_CALLER_MASK & Flags, &m_penum);
  30. _JumpIfError(hr, error, "EnumCertDBName");
  31. m_Context = Context;
  32. m_Flags = Flags;
  33. error:
  34. if (NULL != prow)
  35. {
  36. prow->Release();
  37. }
  38. return(hr);
  39. }
  40. HRESULT
  41. CIENUM::EnumNext(OUT BSTR *pstrPropertyName)
  42. {
  43. HRESULT hr = E_UNEXPECTED;
  44. CERTDBNAME cdbn;
  45. cdbn.pwszName = NULL;
  46. if (NULL == pstrPropertyName)
  47. {
  48. hr = E_POINTER;
  49. _JumpError(hr, error, "pstrPropertyName NULL");
  50. }
  51. if (NULL != *pstrPropertyName)
  52. {
  53. SysFreeString(*pstrPropertyName);
  54. *pstrPropertyName = NULL;
  55. }
  56. if (NULL != m_penum)
  57. {
  58. ULONG celtFetched;
  59. hr = m_penum->Next(1, &cdbn, &celtFetched);
  60. _JumpIfError2(hr, error, "Next", S_FALSE);
  61. CSASSERT(1 == celtFetched);
  62. CSASSERT(NULL != cdbn.pwszName);
  63. if (!ConvertWszToBstr(pstrPropertyName, cdbn.pwszName, -1))
  64. {
  65. hr = E_OUTOFMEMORY;
  66. goto error;
  67. }
  68. }
  69. error:
  70. if (NULL != cdbn.pwszName)
  71. {
  72. CoTaskMemFree(cdbn.pwszName);
  73. }
  74. return(hr);
  75. }
  76. HRESULT
  77. CIENUM::EnumClose()
  78. {
  79. if (NULL != m_penum)
  80. {
  81. m_penum->Release();
  82. m_penum = NULL;
  83. }
  84. return(S_OK);
  85. }