portable: release 0.84
[got-portable.git] / compat / uuid.c
bloba414fb2d276993a728b2857a8ee2ce9bc6a0fea6
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdint.h>
4 #include <uuid/uuid.h>
6 #include "got_compat.h"
9 int32_t uuid_equal(struct uuid* a, struct uuid* b, uint32_t* unused)
11 return (uuid_compare(*(uuid_t *)a, *(uuid_t *)b) == 0);
13 int32_t uuid_is_nil(struct uuid* uuid, uint32_t* unused)
15 return uuid_is_null(*(uuid_t *)uuid);
17 void uuid_create(uuid_t *uuid, uint32_t* status)
19 *status = uuid_s_ok;
20 return uuid_generate(*(uuid_t *)uuid);
22 void uuid_create_nil(struct uuid* uuid, uint32_t* unused)
24 return uuid_clear(*(uuid_t *)uuid);
26 void uuid_from_string(const char* s, uuid_t *uuid, uint32_t *status)
28 *status = uuid_parse(s, *(uuid_t *)uuid);
30 void uuid_to_string(uuid_t *uuid, char** s, uint32_t *status)
32 *s = malloc(36 + 1); /* 36 byte uuid plus '\0' */
33 if (*s == NULL) {
34 fprintf(stderr, "uuid_to_string: fatal: malloc\n");
35 exit (1);
37 uuid_unparse(*(uuid_t *)uuid, *s);
38 *status = uuid_s_ok;