2 #include "util_str_hex.h"
3 #include "lib/util/data_blob.h"
4 #include "librpc/gen_ndr/misc.h"
6 static bool hex_uint16(const char *in
, uint16_t *out
)
9 bool ok
= hex_byte(in
, &hi
) && hex_byte(in
+2, &lo
);
10 *out
= (((uint16_t)hi
)<<8) + lo
;
14 bool hex_uint32(const char *in
, uint32_t *out
)
17 bool ok
= hex_uint16(in
, &hi
) && hex_uint16(in
+4, &lo
);
18 *out
= (((uint32_t)hi
)<<16) + lo
;
22 bool parse_guid_string(const char *s
, struct GUID
*guid
)
26 /* "e12b56b6-0a95-11d1-adbb-00c04fd8d5cd"
29 | | | \_____ clock_seq[2]
30 | | \__________ time_hi_and_version
31 | \_______________ time_mid
32 \_____________________ time_low
35 ok
= hex_uint32(s
, &guid
->time_low
);
36 if (!ok
|| (s
[8] != '-')) {
41 ok
= hex_uint16(s
, &guid
->time_mid
);
42 if (!ok
|| (s
[4] != '-')) {
47 ok
= hex_uint16(s
, &guid
->time_hi_and_version
);
48 if (!ok
|| (s
[4] != '-')) {
53 ok
= hex_byte(s
, &guid
->clock_seq
[0]) &&
54 hex_byte(s
+2, &guid
->clock_seq
[1]);
55 if (!ok
|| (s
[4] != '-')) {
60 for (i
= 0; i
< 6; i
++) {
61 ok
= hex_byte(s
, &guid
->node
[i
]);