Author: kagula
Date: 2017-12-18
测试环境:VS2017 Update5, MongoDB C Driver 1.8.1
这里直接extract项目中的代码,共两部份:
第一部份,依赖的函数
void string2uuid(const char *src32, unsigned char dest[16])
{
unsigned int index;
for (size_t i = 0, j = 0; i < 16 * 2; i += 2, j++)
{
unsigned char high;
if (src32[i] <= '9')
high = (src32[i] - 0x30);
else if (src32[i] <= 'F')
high = (src32[i] - 0x41) + 10;
else if (src32[i] <= 'f')
high = (src32[i] - 0x61) + 10;
high = high << 4;
index = i + 1;
if (src32[index] <= '9')
dest[j] = (src32[index] - 0x30);
else if (src32[index] <= 'F')
dest[j] = (src32[index] - 0x41) + 10;
else if (src32[index] <= 'f')
dest[j] = (src32[index] - 0x61) + 10;