Blame


1 dd038bc6 2021-09-21 thomas.ad #include <stdlib.h>
2 dd038bc6 2021-09-21 thomas.ad #include <string.h>
3 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
4 dd038bc6 2021-09-21 thomas.ad #include <uuid/uuid.h>
5 dd038bc6 2021-09-21 thomas.ad
6 dd038bc6 2021-09-21 thomas.ad #include "got_compat.h"
7 dd038bc6 2021-09-21 thomas.ad
8 dd038bc6 2021-09-21 thomas.ad
9 dd038bc6 2021-09-21 thomas.ad int32_t uuid_equal(struct uuid* a, struct uuid* b, uint32_t* unused)
10 dd038bc6 2021-09-21 thomas.ad {
11 dd038bc6 2021-09-21 thomas.ad return (uuid_compare(*(uuid_t *)a, *(uuid_t *)b) == 0);
12 dd038bc6 2021-09-21 thomas.ad }
13 dd038bc6 2021-09-21 thomas.ad int32_t uuid_is_nil(struct uuid* uuid, uint32_t* unused)
14 dd038bc6 2021-09-21 thomas.ad {
15 dd038bc6 2021-09-21 thomas.ad return uuid_is_null(*(uuid_t *)uuid);
16 dd038bc6 2021-09-21 thomas.ad }
17 dd038bc6 2021-09-21 thomas.ad void uuid_create(uuid_t *uuid, uint32_t* status)
18 dd038bc6 2021-09-21 thomas.ad {
19 dd038bc6 2021-09-21 thomas.ad *status = uuid_s_ok;
20 dd038bc6 2021-09-21 thomas.ad return uuid_generate(*(uuid_t *)uuid);
21 dd038bc6 2021-09-21 thomas.ad }
22 dd038bc6 2021-09-21 thomas.ad void uuid_create_nil(struct uuid* uuid, uint32_t* unused)
23 dd038bc6 2021-09-21 thomas.ad {
24 dd038bc6 2021-09-21 thomas.ad return uuid_clear(*(uuid_t *)uuid);
25 dd038bc6 2021-09-21 thomas.ad }
26 dd038bc6 2021-09-21 thomas.ad void uuid_from_string(const char* s, uuid_t *uuid, uint32_t *status)
27 dd038bc6 2021-09-21 thomas.ad {
28 dd038bc6 2021-09-21 thomas.ad *status = uuid_parse(s, *(uuid_t *)uuid);
29 dd038bc6 2021-09-21 thomas.ad }
30 dd038bc6 2021-09-21 thomas.ad void uuid_to_string(uuid_t *uuid, char** s, uint32_t *status)
31 dd038bc6 2021-09-21 thomas.ad {
32 dd038bc6 2021-09-21 thomas.ad *s = malloc(36 + 1); /* 36 byte uuid plus '\0' */
33 dd038bc6 2021-09-21 thomas.ad if (*s == NULL) {
34 dd038bc6 2021-09-21 thomas.ad fprintf(stderr, "uuid_to_string: fatal: malloc\n");
35 dd038bc6 2021-09-21 thomas.ad exit (1);
36 dd038bc6 2021-09-21 thomas.ad }
37 dd038bc6 2021-09-21 thomas.ad uuid_unparse(*(uuid_t *)uuid, *s);
38 dd038bc6 2021-09-21 thomas.ad *status = uuid_s_ok;
39 dd038bc6 2021-09-21 thomas.ad }