|
Lines 46-51
a/WebCore/platform/UUID.cpp_sec1
|
| 46 |
|
46 |
|
| 47 |
namespace WebCore { |
47 |
namespace WebCore { |
| 48 |
|
48 |
|
|
|
49 |
static const char uuidVersionRequired = '4'; |
| 50 |
static const int uuidVersionIdentifierIndex = 14; |
| 51 |
|
| 49 |
String createCanonicalUUIDString() |
52 |
String createCanonicalUUIDString() |
| 50 |
{ |
53 |
{ |
| 51 |
#if OS(WINDOWS) |
54 |
#if OS(WINDOWS) |
|
Lines 56-69
String createCanonicalUUIDString()
a/WebCore/platform/UUID.cpp_sec2
|
| 56 |
wchar_t uuidStr[40]; |
59 |
wchar_t uuidStr[40]; |
| 57 |
int num = StringFromGUID2(uuid, reinterpret_cast<LPOLESTR>(uuidStr), ARRAYSIZE(uuidStr)); |
60 |
int num = StringFromGUID2(uuid, reinterpret_cast<LPOLESTR>(uuidStr), ARRAYSIZE(uuidStr)); |
| 58 |
ASSERT(num == 39); |
61 |
ASSERT(num == 39); |
| 59 |
return String(uuidStr + 1, num - 3).lower(); // remove opening and closing bracket and make it lower. |
62 |
String canonicalUuidStr = String(uuidStr + 1, num - 3).lower(); // remove opening and closing bracket and make it lower. |
|
|
63 |
ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired); |
| 64 |
return canonicalUuidStr; |
| 60 |
#elif OS(DARWIN) |
65 |
#elif OS(DARWIN) |
| 61 |
CFUUIDRef uuid = CFUUIDCreate(0); |
66 |
CFUUIDRef uuid = CFUUIDCreate(0); |
| 62 |
CFStringRef uuidStrRef = CFUUIDCreateString(0, uuid); |
67 |
CFStringRef uuidStrRef = CFUUIDCreateString(0, uuid); |
| 63 |
String uuidStr(uuidStrRef); |
68 |
String uuidStr(uuidStrRef); |
| 64 |
CFRelease(uuidStrRef); |
69 |
CFRelease(uuidStrRef); |
| 65 |
CFRelease(uuid); |
70 |
CFRelease(uuid); |
| 66 |
return uuidStr.lower(); // make it lower. |
71 |
String canonicalUuidStr = uuidStr.lower(); // make it lower. |
|
|
72 |
ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired); |
| 73 |
return canonicalUuidStr; |
| 67 |
#elif OS(LINUX) |
74 |
#elif OS(LINUX) |
| 68 |
FILE* fptr = fopen("/proc/sys/kernel/random/uuid", "r"); |
75 |
FILE* fptr = fopen("/proc/sys/kernel/random/uuid", "r"); |
| 69 |
if (!fptr) |
76 |
if (!fptr) |
|
Lines 71-77
String createCanonicalUUIDString()
a/WebCore/platform/UUID.cpp_sec3
|
| 71 |
char uuidStr[37] = {0}; |
78 |
char uuidStr[37] = {0}; |
| 72 |
fgets(uuidStr, sizeof(uuidStr) - 1, fptr); |
79 |
fgets(uuidStr, sizeof(uuidStr) - 1, fptr); |
| 73 |
fclose(fptr); |
80 |
fclose(fptr); |
| 74 |
return String(uuidStr).lower(); // make it lower. |
81 |
String canonicalUuidStr = String(uuidStr).lower(); // make it lower. |
|
|
82 |
ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired); |
| 83 |
return canonicalUuidStr; |
| 75 |
#else |
84 |
#else |
| 76 |
notImplemented(); |
85 |
notImplemented(); |
| 77 |
return String(); |
86 |
return String(); |