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.

164 lines
4.2 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 "cstore.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. (void) StringCchPrintf(lptsz,
  51. 40,
  52. L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  53. rguid.Data1, rguid.Data2, rguid.Data3,
  54. rguid.Data4[0], rguid.Data4[1],
  55. rguid.Data4[2], rguid.Data4[3],
  56. rguid.Data4[4], rguid.Data4[5],
  57. rguid.Data4[6], rguid.Data4[7]);
  58. return 36;
  59. }
  60. //+-------------------------------------------------------------------------
  61. //
  62. // Function: RdnFromGUID
  63. //
  64. //--------------------------------------------------------------------------
  65. int RDNFromGUID(REFGUID rguid, LPOLESTR lptsz)
  66. {
  67. (void) StringCchCopy (lptsz, 4, L"CN=");
  68. StringFromGUID(rguid, lptsz+3);
  69. return 3+36;
  70. }
  71. //
  72. // This converts string guids to the guid structure -- note that
  73. // the string guid does NOT contain brace chars ('{','}') at
  74. // the beginning and end
  75. //
  76. void GUIDFromString(
  77. LPOLESTR psz,
  78. GUID *pclsguid)
  79. //
  80. // Converts a Stringified GUID to GUID structure
  81. //
  82. {
  83. WCHAR szC [40];
  84. LPOLESTR szClsId;
  85. LPOLESTR endptr;
  86. memset ((void *)pclsguid, NULL, sizeof (GUID));
  87. if ((!psz) ||
  88. (*psz == NULL))
  89. return;
  90. if (wcslen(psz) < 36)
  91. return;
  92. wcsncpy (&szC [0], psz, 36);
  93. szC[36] = L'\0';
  94. szClsId = &szC[0];
  95. *(szClsId+36) = NULL;
  96. pclsguid->Data4[7] = wcstoul (szClsId+34, &endptr, 16);
  97. *(szClsId+34) = NULL;
  98. pclsguid->Data4[6] = wcstoul (szClsId+32, &endptr, 16);
  99. *(szClsId+32) = NULL;
  100. pclsguid->Data4[5] = wcstoul (szClsId+30, &endptr, 16);
  101. *(szClsId+30) = NULL;
  102. pclsguid->Data4[4] = wcstoul (szClsId+28, &endptr, 16);
  103. *(szClsId+28) = NULL;
  104. pclsguid->Data4[3] = wcstoul (szClsId+26, &endptr, 16);
  105. *(szClsId+26) = NULL;
  106. pclsguid->Data4[2] = wcstoul (szClsId+24, &endptr, 16);
  107. *(szClsId+23) = NULL;
  108. pclsguid->Data4[1] = wcstoul (szClsId+21, &endptr, 16);
  109. *(szClsId+21) = NULL;
  110. pclsguid->Data4[0] = wcstoul (szClsId+19, &endptr, 16);
  111. *(szClsId+18) = NULL;
  112. pclsguid->Data3 = wcstoul (szClsId+14, &endptr, 16);
  113. *(szClsId+13) = NULL;
  114. pclsguid->Data2 = wcstoul (szClsId+9, &endptr, 16);
  115. *(szClsId+8) = NULL;
  116. pclsguid->Data1 = wcstoul (szClsId, &endptr, 16);
  117. }
  118. BOOL IsNullGuid(REFGUID rguid)
  119. {
  120. UINT i;
  121. if (rguid.Data1)
  122. return FALSE;
  123. if (rguid.Data2)
  124. return FALSE;
  125. if (rguid.Data3)
  126. return FALSE;
  127. for (i=0; i < 8; ++i)
  128. {
  129. if (rguid.Data4[i])
  130. return FALSE;
  131. }
  132. return TRUE;
  133. }
  134.