2 Copyright © 2007-2008, The AROS Development Team. All rights reserved.
8 #include <aros/symbolsets.h>
9 #include <aros/debug.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
17 #include "uuid_private.h"
18 #include LC_LIBDEFS_FILE
20 static char value(char chr
)
25 chr
-= isupper(chr
) ? 'A' - 10 : 'a' - 10;
29 AROS_LH2(int, UUID_Parse
,
30 AROS_LHA(const char *, in
, A0
),
31 AROS_LHA(uuid_t
*, uuid
, A1
),
32 struct uuid_base
*, UUIDBase
, 7, UUID
)
37 uuid_t tmp
= {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}};
39 D(bug("[UUID] UUID_Parse(%s, %p)\n", in
, uuid
));
41 if (strlen(in
) == UUID_STRLEN
)
43 for (i
=0; i
< 8; i
++, in
++)
47 tmp
.time_low
= (tmp
.time_low
<< 4) | value(*in
);
55 for (i
=0; i
< 4; i
++, in
++)
59 tmp
.time_mid
= (tmp
.time_mid
<< 4) | value(*in
);
67 for (i
=0; i
< 4; i
++, in
++)
71 tmp
.time_hi_and_version
=
72 (tmp
.time_hi_and_version
<< 4) | value(*in
);
80 if (!(isxdigit(in
[0]) && isxdigit(in
[1])))
83 tmp
.clock_seq_hi_and_reserved
= (value(in
[0]) << 4) | value(in
[1]);
85 if (!(isxdigit(in
[2]) && isxdigit(in
[3])))
88 tmp
.clock_seq_low
= (value(in
[2]) << 4) | value(in
[3]);
94 for (i
=0; i
< 6; i
++, in
+=2)
96 if (!(isxdigit(in
[0]) && isxdigit(in
[1])))
99 tmp
.node
[i
] = (value(in
[0]) << 4) | value(in
[1]);
111 AROS_LH2(void, UUID_Unparse
,
112 AROS_LHA(const uuid_t
*, uuid
, A0
),
113 AROS_LHA(char *, out
, A1
),
114 struct uuid_base
*, UUIDBase
, 8, UUID
)
118 snprintf(out
, UUID_STRLEN
, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
121 uuid
->time_hi_and_version
,
122 uuid
->clock_seq_hi_and_reserved
,
124 uuid
->node
[0],uuid
->node
[1],uuid
->node
[2],
125 uuid
->node
[3],uuid
->node
[4],uuid
->node
[5]);