uuid-win.cpp revision a7a2dfae0fe088f875fe44119084c8329fdc60ac
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * IPRT - UUID, Windows implementation.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Copyright (C) 2006-2007 Sun Microsystems, Inc.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * This file is part of VirtualBox Open Source Edition (OSE), as
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * available from http://www.virtualbox.org. This file is free software;
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * you can redistribute it and/or modify it under the terms of the GNU
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * General Public License (GPL) as published by the Free Software
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Foundation, in version 2 as it comes in the "COPYING" file of the
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * The contents of this file may alternatively be used under the terms
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * of the Common Development and Distribution License Version 1.0
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * VirtualBox OSE distribution, in which case the provisions of the
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * CDDL are applicable instead of those of the GPL.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * You may elect to license modified versions of this file under the
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * terms and conditions of either the GPL or the CDDL or both.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Clara, CA 95054 USA or visit http://www.sun.com if you need
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * additional information or have any questions.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee/*******************************************************************************
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee* Header Files *
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee*******************************************************************************/
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee /* check params */
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee return RTErrConvertFromWin32(UuidCreateNil((UUID *)pUuid));
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee /* check params */
843e19887f64dde75055cf8842fc4db2171eff45johnlevRTDECL(int) RTUuidCompare(PCRTUUID pUuid1, PCRTUUID pUuid2)
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht * Special cases.
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht * Hand the rest to the Windows API.
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht return UuidCompare((UUID *)pUuid1, (UUID *)pUuid2, &status);
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlcleeRTDECL(int) RTUuidCompareStr(PCRTUUID pUuid1, const char *pszString2)
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee /* check params */
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Try convert the string to a UUID and then compare the two.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlcleeRTDECL(int) RTUuidCompare2Strs(const char *pszString1, const char *pszString2)
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee /* check params */
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Try convert the strings to UUIDs and then compare them.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlcleeRTDECL(int) RTUuidToStr(PCRTUUID pUuid, char *pszString, size_t cchString)
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* check params */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht AssertReturn(cchString >= RTUUID_STR_LENGTH, VERR_INVALID_PARAMETER);
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * Try convert it.
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * The API allocates a new string buffer for us, so we can do our own
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee * buffer overflow handling.
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* always use ASCII version! */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* copy it. */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* free buffer */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* always use ASCII version! */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* all done */
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlcleeRTDECL(int) RTUuidFromStr(PRTUUID pUuid, const char *pszString)
3ccda6479cf240cd732ac4b7a8a82fcc1716496dlclee /* check params */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht /* always use ASCII version! */
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht rc = UuidFromStringA((unsigned char *)pszString, (UUID *)pUuid);
e8fb11a1575b42dcd5c49341c588d9f6cd636135shidokht rc = UuidFromString((unsigned char *)pszString, (UUID *)pUuid);