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.

79 lines
2.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2001.
  5. //
  6. // File: PolicyOID.cpp
  7. //
  8. // Contents: CPolicyOID
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "PolicyOID.h"
  13. CPolicyOID::CPolicyOID (const CString& szOID, const CString& szDisplayName, ADS_INTEGER flags, bool bCanRename)
  14. : m_szOIDW (szOID),
  15. m_szDisplayName (szDisplayName),
  16. m_pszOIDA (0),
  17. m_flags (flags),
  18. m_bCanRename (bCanRename)
  19. {
  20. int nLen = WideCharToMultiByte(
  21. CP_ACP, // code page
  22. 0, // performance and mapping flags
  23. (PCWSTR) m_szOIDW, // wide-character string
  24. (int) wcslen (m_szOIDW), // number of chars in string
  25. 0, // buffer for new string
  26. 0, // size of buffer
  27. 0, // default for unmappable chars
  28. 0); // set when default char used
  29. if ( nLen > 0 )
  30. {
  31. m_pszOIDA = new CHAR[nLen+1];
  32. if ( m_pszOIDA )
  33. {
  34. ZeroMemory (m_pszOIDA, (nLen + 1) *sizeof(CHAR));
  35. nLen = WideCharToMultiByte(
  36. CP_ACP, // code page
  37. 0, // performance and mapping flags
  38. (PCWSTR) m_szOIDW, // wide-character string
  39. (int) wcslen (m_szOIDW), // number of chars in string
  40. m_pszOIDA, // buffer for new string
  41. nLen, // size of buffer
  42. 0, // default for unmappable chars
  43. 0); // set when default char used
  44. if ( !nLen )
  45. {
  46. _TRACE (0, L"WideCharToMultiByte (%s) failed: 0x%x\n",
  47. (PCWSTR) m_szOIDW, GetLastError ());
  48. }
  49. }
  50. }
  51. else
  52. {
  53. _TRACE (0, L"WideCharToMultiByte (%s) failed: 0x%x\n",
  54. (PCWSTR) m_szOIDW, GetLastError ());
  55. }
  56. }
  57. CPolicyOID::~CPolicyOID ()
  58. {
  59. if ( m_pszOIDA )
  60. delete [] m_pszOIDA;
  61. }
  62. bool CPolicyOID::IsIssuanceOID() const
  63. {
  64. return (m_flags == CERT_OID_TYPE_ISSUER_POLICY) ? true : false;
  65. }
  66. bool CPolicyOID::IsApplicationOID() const
  67. {
  68. return (m_flags == CERT_OID_TYPE_APPLICATION_POLICY) ? true : false;
  69. }
  70. void CPolicyOID::SetDisplayName(const CString &szDisplayName)
  71. {
  72. m_szDisplayName = szDisplayName;
  73. }