uint32 time_low;
uint16 time_mid;
uint16 time_hi_and_version;
- uint16 clock_seq;
+ uint8 clock_seq[2];
uint8 node[6];
};
SIVAL(out, 0, uu->time_low);
SSVAL(out, 4, uu->time_mid);
SSVAL(out, 6, uu->time_hi_and_version);
- SSVAL(out, 8, uu->clock_seq);
+ memcpy(out+8, uu->clock_seq, 2);
memcpy(out+10, uu->node, 6);
}
uu->time_low = IVAL(ptr, 0);
uu->time_mid = SVAL(ptr, 4);
uu->time_hi_and_version = SVAL(ptr, 6);
- uu->clock_seq = SVAL(ptr, 8);
+ memcpy(uu->clock_seq, ptr+8, 2);
memcpy(uu->node, ptr+10, 6);
}
generate_random_buffer(tmp.info, sizeof(tmp.info), True);
uuid_unpack(tmp, &uu);
- uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
+ uu.clock_seq[0] = (uu.clock_seq[0] & 0x3F) | 0x80;
uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000;
uuid_pack(&uu, out);
}
+
+char *uuid_to_string(const GUID in)
+{
+ struct uuid uu;
+ char *out;
+
+ uuid_unpack(in, &uu);
+
+ asprintf(&out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uu.time_low, uu.time_mid, uu.time_hi_and_version,
+ uu.clock_seq[0], uu.clock_seq[1],
+ uu.node[0], uu.node[1], uu.node[2],
+ uu.node[3], uu.node[4], uu.node[5]);
+
+ return out;
+}
+
+const char *uuid_string_static(const GUID in)
+{
+ struct uuid uu;
+ static char out[37];
+
+ uuid_unpack(in, &uu);
+ slprintf(out, sizeof(out) -1,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uu.time_low, uu.time_mid, uu.time_hi_and_version,
+ uu.clock_seq[0], uu.clock_seq[1],
+ uu.node[0], uu.node[1], uu.node[2],
+ uu.node[3], uu.node[4], uu.node[5]);
+ return out;
+}