aboutsummaryrefslogtreecommitdiffstats
path: root/src/uuid/uuid.h
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2023-12-24 04:26:00 -0600
committerLibravatar bigfoot547 <[email protected]>2023-12-24 04:26:00 -0600
commit20d9fc5b5356a1054cb104ba6651b77184abf0db (patch)
tree5f115d8051dad73069d3a632a6f2c260cf7efdac /src/uuid/uuid.h
initial commit
Diffstat (limited to 'src/uuid/uuid.h')
-rw-r--r--src/uuid/uuid.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/uuid/uuid.h b/src/uuid/uuid.h
new file mode 100644
index 0000000..740fa17
--- /dev/null
+++ b/src/uuid/uuid.h
@@ -0,0 +1,27 @@
+#ifndef L2SU_UUID_H_INCLUDED
+#define L2SU_UUID_H_INCLUDED
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/* A 128-bit GUID as specified by RFC 4122.
+ * NOTE: halves[0] is the least significant half of the GUID. */
+typedef union tag_uuid_t {
+ uint8_t bytes[16];
+ uint64_t halves[2];
+} uuid_t;
+
+#define UUID_NULL_INIT { { 0 } }
+
+#define UUID_STRLEN (36u)
+#define UUID_STRLEN_SHORT (32u)
+
+void l2_uuid_random(uuid_t *id);
+
+void l2_uuid_to_string(const uuid_t *id, char *out);
+void l2_uuid_to_string_short(const uuid_t *id, char *out);
+
+bool l2_uuid_from_string(uuid_t *id, const char *str);
+bool l2_uuid_from_string_short(uuid_t *id, const char *str);
+
+#endif /* include guard */