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.

148 lines
3.7 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File: dsiface.cxx
  7. //
  8. // Contents: ADs calls for Class Store Property Read/Write
  9. //
  10. //
  11. // History: Sep-Oct 96. DebiM
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "dsbase.hxx"
  15. #pragma warning ( disable : 4018 )
  16. #pragma warning ( disable : 4244 )
  17. //
  18. // From CSPLATFORM to DS datatype
  19. //
  20. void
  21. UnpackPlatform (DWORD *pdwArch,
  22. CSPLATFORM *pPlatform)
  23. {
  24. unsigned char *pc = (unsigned char *)pdwArch;
  25. *(pc) = (unsigned char)pPlatform->dwPlatformId;
  26. *(++pc) = (unsigned char)pPlatform->dwVersionHi;
  27. *(++pc) = (unsigned char)pPlatform->dwVersionLo;
  28. *(++pc) = (unsigned char)pPlatform->dwProcessorArch;
  29. }
  30. //
  31. // From DS datatype to CSPLATFORM
  32. //
  33. void
  34. PackPlatform (DWORD dwArch,
  35. CSPLATFORM *pPlatform)
  36. {
  37. unsigned char *pc = (unsigned char *)&dwArch;
  38. pPlatform->dwPlatformId = *(pc);
  39. pPlatform->dwVersionHi = *(++pc);
  40. pPlatform->dwVersionLo = *(++pc);
  41. pPlatform->dwProcessorArch = *(++pc);
  42. }
  43. //+-------------------------------------------------------------------------
  44. //
  45. // Function: StringFromGUID
  46. //
  47. //--------------------------------------------------------------------------
  48. int StringFromGUID(REFGUID rguid, LPOLESTR lptsz)
  49. {
  50. swprintf(lptsz, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  51. rguid.Data1, rguid.Data2, rguid.Data3,
  52. rguid.Data4[0], rguid.Data4[1],
  53. rguid.Data4[2], rguid.Data4[3],
  54. rguid.Data4[4], rguid.Data4[5],
  55. rguid.Data4[6], rguid.Data4[7]);
  56. return 36;
  57. }
  58. //+-------------------------------------------------------------------------
  59. //
  60. // Function: RdnFromGUID
  61. //
  62. //--------------------------------------------------------------------------
  63. int RdnFromGUID(REFGUID rguid, LPOLESTR lptsz)
  64. {
  65. wcscpy (lptsz, L"CN=");
  66. StringFromGUID(rguid, lptsz+3);
  67. return 3+36;
  68. }
  69. //BUGBUG. This belongs in a common library
  70. void GUIDFromString(
  71. LPOLESTR psz,
  72. GUID *pclsguid)
  73. //
  74. // Converts a Stringified GUID to GUID structure
  75. //
  76. {
  77. WCHAR szC [40];
  78. LPOLESTR szClsId;
  79. LPOLESTR endptr;
  80. memset ((void *)pclsguid, NULL, sizeof (GUID));
  81. if ((!psz) ||
  82. (*psz == NULL))
  83. return;
  84. if (wcslen(psz) < 36)
  85. return;
  86. wcscpy (&szC [0], psz);
  87. szClsId = &szC[0];
  88. *(szClsId+36) = NULL;
  89. pclsguid->Data4[7] = wcstoul (szClsId+34, &endptr, 16);
  90. *(szClsId+34) = NULL;
  91. pclsguid->Data4[6] = wcstoul (szClsId+32, &endptr, 16);
  92. *(szClsId+32) = NULL;
  93. pclsguid->Data4[5] = wcstoul (szClsId+30, &endptr, 16);
  94. *(szClsId+30) = NULL;
  95. pclsguid->Data4[4] = wcstoul (szClsId+28, &endptr, 16);
  96. *(szClsId+28) = NULL;
  97. pclsguid->Data4[3] = wcstoul (szClsId+26, &endptr, 16);
  98. *(szClsId+26) = NULL;
  99. pclsguid->Data4[2] = wcstoul (szClsId+24, &endptr, 16);
  100. *(szClsId+23) = NULL;
  101. pclsguid->Data4[1] = wcstoul (szClsId+21, &endptr, 16);
  102. *(szClsId+21) = NULL;
  103. pclsguid->Data4[0] = wcstoul (szClsId+19, &endptr, 16);
  104. *(szClsId+18) = NULL;
  105. pclsguid->Data3 = wcstoul (szClsId+14, &endptr, 16);
  106. *(szClsId+13) = NULL;
  107. pclsguid->Data2 = wcstoul (szClsId+9, &endptr, 16);
  108. *(szClsId+8) = NULL;
  109. pclsguid->Data1 = wcstoul (szClsId, &endptr, 16);
  110. }
  111. BOOL IsNullGuid(REFGUID rguid)
  112. {
  113. UINT i;
  114. if (rguid.Data1)
  115. return FALSE;
  116. if (rguid.Data2)
  117. return FALSE;
  118. if (rguid.Data3)
  119. return FALSE;
  120. for (i=0; i < 8; ++i)
  121. {
  122. if (rguid.Data4[i])
  123. return FALSE;
  124. }
  125. return TRUE;
  126. }
  127.