Implemented UuidFromString[AW] based on CLSIDFromString
implementation.
This commit is contained in:
parent
748425e999
commit
21eb2b5c1e
|
@ -419,22 +419,96 @@ RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, LPSTR* StringUuid)
|
|||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const BYTE hex2bin[] =
|
||||
{
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
|
||||
0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
|
||||
0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
|
||||
0,10,11,12,13,14,15 /* 0x60 */
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* UuidFromStringA (RPCRT4.@)
|
||||
*/
|
||||
RPC_STATUS WINAPI UuidFromStringA(LPSTR str, UUID *uuid)
|
||||
{
|
||||
FIXME("%s %p\n",debugstr_a(str),uuid);
|
||||
BYTE *s = (BYTE *)str;
|
||||
int i;
|
||||
|
||||
if (!s) return UuidCreateNil( uuid );
|
||||
|
||||
if (strlen(s) != 36) return RPC_S_INVALID_STRING_UUID;
|
||||
|
||||
if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
|
||||
return RPC_S_INVALID_STRING_UUID;
|
||||
|
||||
for (i=0; i<36; i++)
|
||||
{
|
||||
if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
|
||||
if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
|
||||
}
|
||||
|
||||
/* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
|
||||
|
||||
uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
|
||||
hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
|
||||
uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
|
||||
uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
|
||||
|
||||
/* these are just sequential bytes */
|
||||
uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
|
||||
uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
|
||||
uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
|
||||
uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
|
||||
uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
|
||||
uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
|
||||
uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
|
||||
uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* UuidFromStringW (RPCRT4.@)
|
||||
*/
|
||||
RPC_STATUS WINAPI UuidFromStringW(LPWSTR str, UUID *uuid)
|
||||
RPC_STATUS WINAPI UuidFromStringW(LPWSTR s, UUID *uuid)
|
||||
{
|
||||
FIXME("%s %p\n",debugstr_w(str),uuid);
|
||||
int i;
|
||||
|
||||
if (!s) return UuidCreateNil( uuid );
|
||||
|
||||
if (strlenW(s) != 36) return RPC_S_INVALID_STRING_UUID;
|
||||
|
||||
if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
|
||||
return RPC_S_INVALID_STRING_UUID;
|
||||
|
||||
for (i=0; i<36; i++)
|
||||
{
|
||||
if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
|
||||
if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
|
||||
}
|
||||
|
||||
/* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
|
||||
|
||||
uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
|
||||
hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
|
||||
uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
|
||||
uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
|
||||
|
||||
/* these are just sequential bytes */
|
||||
uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
|
||||
uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
|
||||
uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
|
||||
uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
|
||||
uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
|
||||
uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
|
||||
uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
|
||||
uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
Loading…
Reference in New Issue