| 68 | } |
| 69 | |
| 70 | int ParseUuid(CUuid *pUuid, const char *pBuffer) |
| 71 | { |
| 72 | if(str_length(pBuffer) + 1 != UUID_MAXSTRSIZE) |
| 73 | { |
| 74 | return 2; |
| 75 | } |
| 76 | char aCopy[UUID_MAXSTRSIZE]; |
| 77 | str_copy(aCopy, pBuffer); |
| 78 | // 01234567-9012-4567-9012-456789012345 |
| 79 | if(aCopy[8] != '-' || aCopy[13] != '-' || aCopy[18] != '-' || aCopy[23] != '-') |
| 80 | { |
| 81 | return 1; |
| 82 | } |
| 83 | aCopy[8] = aCopy[13] = aCopy[18] = aCopy[23] = 0; |
| 84 | if(static_cast<bool>(str_hex_decode(pUuid->m_aData + 0, 4, aCopy + 0)) || |
| 85 | str_hex_decode(pUuid->m_aData + 4, 2, aCopy + 9) || |
| 86 | str_hex_decode(pUuid->m_aData + 6, 2, aCopy + 14) || |
| 87 | str_hex_decode(pUuid->m_aData + 8, 2, aCopy + 19) || |
| 88 | str_hex_decode(pUuid->m_aData + 10, 6, aCopy + 24)) |
| 89 | { |
| 90 | return 1; |
| 91 | } |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | bool CUuid::operator==(const CUuid &Other) const |
| 96 | { |