]> pd.if.org Git - uuid/blob - pduuid.h
Added test framework
[uuid] / pduuid.h
1 #ifndef PD_UUID_H_
2 #define PD_UUID_H_ 1
3
4 #include <stdint.h>
5
6 struct pd_uuid_state {
7         uint64_t        timestamp, node;
8         uint16_t        clock_sequence;
9         int     available;
10         int     (*get_lock)(void *);
11         int     (*release_lock)(void *);
12         void    *lock_data;
13         int     (*read_state)(struct pd_uuid_state *s);
14         int     (*save_state)(struct pd_uuid_state *s);
15         /* TODO hook for a random number generator? */
16         unsigned long (*random_bytes)(void *out, unsigned long outlen,
17                         void *prng_state);
18         void    *rng_state;
19 };
20
21 struct pd_uuid {
22         uint8_t data[16];
23 };
24 typedef struct pd_uuid pd_uuid_t;
25
26 int pd_uuid_init_state(struct pd_uuid_state *s);
27 int pd_uuid_make_v1(struct pd_uuid_state *s, pd_uuid_t *uuid);
28 int pd_uuid_make_v1mc(struct pd_uuid_state *s, pd_uuid_t *uuid);
29 int pd_uuid_make_v4(struct pd_uuid_state *s, pd_uuid_t *uuid);
30 int pd_uuid_make_v3(struct pd_uuid_state *s, pd_uuid_t *uuid, pd_uuid_t *ns, void *data, int len);
31 int pd_uuid_make_v5(struct pd_uuid_state *s, pd_uuid_t *uuid, pd_uuid_t *ns, void *data, int len);
32
33 int pd_uuid_copy(pd_uuid_t *src, pd_uuid_t *dst);
34 int pd_uuid_cmp(pd_uuid_t *a, pd_uuid_t *b);
35
36 int pd_set_uuid_hash(pd_uuid_t *s, void *hash, int version);
37
38 int pd_uuid_set_string(pd_uuid_t *uuid, char *s);
39
40 unsigned long pd_uuid_rng_get_bytes(unsigned char *out, unsigned long outlen);
41
42 pd_uuid_t pd_uuid_ns_x500;
43 pd_uuid_t pd_uuid_ns_url;
44 pd_uuid_t pd_uuid_ns_dns;
45 pd_uuid_t pd_uuid_ns_oid;
46
47 #endif