1
// Copyright (c) 2006, Google Inc.
2
// All rights reserved.
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above
11
// copyright notice, this list of conditions and the following disclaimer
12
// in the documentation and/or other materials provided with the
14
// * Neither the name of Google Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from
16
// this software without specific prior written permission.
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
// guid_string.cc: Convert GUIDs to strings.
32
// See guid_string.h for documentation.
36
#include "common/windows/string_utils-inl.h"
38
#include "common/windows/guid_string.h"
40
namespace google_breakpad {
43
wstring GUIDString::GUIDToWString(GUID *guid) {
44
wchar_t guid_string[37];
46
guid_string, sizeof(guid_string) / sizeof(guid_string[0]),
47
L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
48
guid->Data1, guid->Data2, guid->Data3,
49
guid->Data4[0], guid->Data4[1], guid->Data4[2],
50
guid->Data4[3], guid->Data4[4], guid->Data4[5],
51
guid->Data4[6], guid->Data4[7]);
53
// remove when VC++7.1 is no longer supported
54
guid_string[sizeof(guid_string) / sizeof(guid_string[0]) - 1] = L'\0';
56
return wstring(guid_string);
60
wstring GUIDString::GUIDToSymbolServerWString(GUID *guid) {
61
wchar_t guid_string[33];
63
guid_string, sizeof(guid_string) / sizeof(guid_string[0]),
64
L"%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X",
65
guid->Data1, guid->Data2, guid->Data3,
66
guid->Data4[0], guid->Data4[1], guid->Data4[2],
67
guid->Data4[3], guid->Data4[4], guid->Data4[5],
68
guid->Data4[6], guid->Data4[7]);
70
// remove when VC++7.1 is no longer supported
71
guid_string[sizeof(guid_string) / sizeof(guid_string[0]) - 1] = L'\0';
73
return wstring(guid_string);
76
} // namespace google_breakpad