Changeset 9741 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Jun 16, 2008 10:46:46 PM (17 years ago)
- Location:
- trunk/src/VBox/Runtime/r3/win
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/RTUuidCreate-win.cpp
r9740 r9741 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT UUID (unique identifiers) handling (win32 host).3 * IPRT - UUID, Windows RTUuidCreate implementation. 4 4 */ 5 5 … … 38 38 #include <iprt/uuid.h> 39 39 #include <iprt/assert.h> 40 #include <iprt/string.h>41 40 #include <iprt/err.h> 42 41 … … 57 56 } 58 57 59 60 RTDECL(int) RTUuidClear(PRTUUID pUuid)61 {62 /* check params */63 AssertPtrReturn(pUuid, VERR_INVALID_POINTER);64 65 return RTErrConvertFromWin32(UuidCreateNil((UUID *)pUuid));66 }67 68 69 RTDECL(bool) RTUuidIsNull(PCRTUUID pUuid)70 {71 /* check params */72 AssertPtrReturn(pUuid, true);73 74 RPC_STATUS status;75 return !!UuidIsNil((UUID *)pUuid, &status);76 }77 78 79 RTDECL(int) RTUuidCompare(PCRTUUID pUuid1, PCRTUUID pUuid2)80 {81 /* check params */82 AssertPtrReturn(pUuid1, -1);83 AssertPtrReturn(pUuid1, 1);84 85 RPC_STATUS status;86 return UuidCompare((UUID *)pUuid1, (UUID *)pUuid2, &status);87 }88 89 90 RTDECL(int) RTUuidCompareStr(PCRTUUID pUuid1, const char *pszString)91 {92 /* check params */93 AssertPtrReturn(pUuid1, -1);94 AssertPtrReturn(pszString, 1);95 96 /*97 * Try convert the string to a UUID and then compare the two.98 */99 RTUUID Uuid2;100 int rc = RTUuidFromStr(&Uuid2, pszString);101 AssertRCReturn(rc, 1);102 103 return RTUuidCompare(pUuid1, &Uuid2);104 }105 106 107 RTDECL(int) RTUuidToStr(PCRTUUID pUuid, char *pszString, size_t cchString)108 {109 /* check params */110 AssertPtrReturn(pUuid, VERR_INVALID_POINTER);111 AssertPtrReturn(pszString, VERR_INVALID_POINTER);112 AssertReturn(cchString >= RTUUID_STR_LENGTH, VERR_INVALID_PARAMETER);113 114 /*115 * Try convert it.116 *117 * The API allocates a new string buffer for us, so we can do our own118 * buffer overflow handling.119 */120 RPC_STATUS Status;121 unsigned char *pszTmpStr = NULL;122 #ifdef RPC_UNICODE_SUPPORTED123 /* always use ASCII version! */124 Status = UuidToStringA((UUID *)pUuid, &pszTmpStr);125 #else126 Status = UuidToString((UUID *)pUuid, &pszTmpStr);127 #endif128 if (Status != RPC_S_OK)129 return RTErrConvertFromWin32(Status);130 131 /* copy it. */132 int rc = VINF_SUCCESS;133 size_t cchTmpStr = strlen((char *)pszTmpStr);134 if (cchTmpStr < cchString)135 memcpy(pszString, pszTmpStr, cchTmpStr + 1);136 else137 {138 AssertFailed();139 rc = ERROR_BUFFER_OVERFLOW;140 }141 142 /* free buffer */143 #ifdef RPC_UNICODE_SUPPORTED144 /* always use ASCII version! */145 RpcStringFreeA(&pszTmpStr);146 #else147 RpcStringFree(&pszTmpStr);148 #endif149 150 /* all done */151 return rc;152 }153 154 155 RTDECL(int) RTUuidFromStr(PRTUUID pUuid, const char *pszString)156 {157 /* check params */158 AssertPtrReturn(pUuid, VERR_INVALID_POINTER);159 AssertPtrReturn(pszString, VERR_INVALID_POINTER);160 161 RPC_STATUS rc;162 #ifdef RPC_UNICODE_SUPPORTED163 /* always use ASCII version! */164 rc = UuidFromStringA((unsigned char *)pszString, (UUID *)pUuid);165 #else166 rc = UuidFromString((unsigned char *)pszString, (UUID *)pUuid);167 #endif168 169 return RTErrConvertFromWin32(rc);170 }171 172 -
trunk/src/VBox/Runtime/r3/win/uuid-win.cpp
r9740 r9741 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT UUID (unique identifiers) handling (win32 host).3 * IPRT - UUID, Windows implementation. 4 4 */ 5 5 … … 40 40 #include <iprt/string.h> 41 41 #include <iprt/err.h> 42 43 44 /** @todo split out this guy */45 RTDECL(int) RTUuidCreate(PRTUUID pUuid)46 {47 /* check params */48 AssertPtrReturn(pUuid, VERR_INVALID_POINTER);49 50 RPC_STATUS rc = UuidCreate((UUID *)pUuid);51 if ( rc == RPC_S_OK52 || rc == RPC_S_UUID_LOCAL_ONLY)53 return VINF_SUCCESS;54 55 /* error exit */56 return RTErrConvertFromWin32(rc);57 }58 42 59 43
Note:
See TracChangeset
for help on using the changeset viewer.