aboutsummaryrefslogtreecommitdiffstats
path: root/src/uuid/uuid.c
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2023-12-25 06:05:40 -0600
committerLibravatar bigfoot547 <[email protected]>2023-12-25 06:05:40 -0600
commit6d1d4d0a5506dce90c833ef8dd141058fea3c33a (patch)
tree12a95579dbf04c4310e5b42ad8cae399d81f1189 /src/uuid/uuid.c
parentinitial commit (diff)
[WIP] Add instances
still need to do the following: - check if the folder exists - try and find some way to canonicalize the path name
Diffstat (limited to 'src/uuid/uuid.c')
-rw-r--r--src/uuid/uuid.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/uuid/uuid.c b/src/uuid/uuid.c
index 0d49f0b..0dfcfbd 100644
--- a/src/uuid/uuid.c
+++ b/src/uuid/uuid.c
@@ -11,8 +11,8 @@ void l2_uuid__set_version(uuid_t *id, unsigned version)
{
version &= 0x0F;
- id->halves[1] &= ~(UINT64_C(0x0F) << 12);
- id->halves[1] |= (uint64_t)version << 12;
+ id->uuid_ms &= ~(UINT64_C(0x0F) << 12);
+ id->uuid_ms |= (uint64_t)version << 12;
}
void l2_uuid__set_variant(uuid_t *id, unsigned variant, unsigned bits)
@@ -21,8 +21,8 @@ void l2_uuid__set_variant(uuid_t *id, unsigned variant, unsigned bits)
uint64_t lvariant = (uint64_t)variant << (64 - bits);
lvariant &= ~mask;
- id->halves[0] &= mask;
- id->halves[0] |= lvariant;
+ id->uuid_ls &= mask;
+ id->uuid_ls |= lvariant;
}
void l2_uuid_random(uuid_t *id)
@@ -35,11 +35,11 @@ void l2_uuid_random(uuid_t *id)
void l2_uuid_to_string(const uuid_t *id, char *out)
{
snprintf(out, UUID_STRLEN + 1, "%08" PRIx64 "-%04" PRIx64 "-%04" PRIx64 "-%04" PRIx64 "-%012" PRIx64,
- id->halves[1] >> 32, /* time-low */
- id->halves[1] >> 16 & 0xffff, /* time-mid */
- id->halves[1] & 0xffff, /* time-high-and-version */
- id->halves[0] >> 48, /* clock-seq-and-reserved, clock-seq-low */
- id->halves[0] & UINT64_C(0xffffffffffff)); /* node */
+ id->uuid_ms >> 32, /* time-low */
+ id->uuid_ms >> 16 & 0xffff, /* time-mid */
+ id->uuid_ms & 0xffff, /* time-high-and-version */
+ id->uuid_ls >> 48, /* clock-seq-and-reserved, clock-seq-low */
+ id->uuid_ls & UINT64_C(0xffffffffffff)); /* node */
}
void l2_uuid_to_string_short(const uuid_t *id, char *out)
@@ -78,6 +78,11 @@ bool l2_uuid_from_string_short(uuid_t *id, const char *str)
return true;
}
+int l2_uuid_compare(const uuid_t *c1, const uuid_t *c2)
+{
+ return memcmp(c1, c2, sizeof(uuid_t));
+}
+
/* This function exists because there's not a portable way to do this.
* Don't suggest strtoull, because uint64_t may not be a ulonglong. */
bool l2__str_to_uint64(uint64_t *out, const char *str)