]> pd.if.org Git - uuid/blob - pduuid.h
Add support for gin indexes on uuid arrays.
[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_init(struct pd_uuid_state *s, int f);
28 int pd_uuid_make_v1(struct pd_uuid_state *s, pd_uuid_t *uuid);
29 int pd_uuid_make_v1mc(struct pd_uuid_state *s, pd_uuid_t *uuid);
30 int pd_uuid_make_v4(struct pd_uuid_state *s, pd_uuid_t *uuid);
31 int pd_uuid_make_v3(struct pd_uuid_state *s, pd_uuid_t *uuid, pd_uuid_t *ns, void *data, int len);
32 int pd_uuid_make_v5(struct pd_uuid_state *s, pd_uuid_t *uuid, pd_uuid_t *ns, void *data, int len);
33
34 int pd_uuid_copy(pd_uuid_t *src, pd_uuid_t *dst);
35 int pd_uuid_cmp(pd_uuid_t *a, pd_uuid_t *b);
36
37 int pd_set_uuid_hash(pd_uuid_t *s, void *hash, int version);
38
39 int pd_uuid_set_string(pd_uuid_t *uuid, char *s);
40
41 unsigned long pd_uuid_rng_get_bytes(unsigned char *out, unsigned long outlen);
42
43 pd_uuid_t pd_uuid_ns_x500;
44 pd_uuid_t pd_uuid_ns_url;
45 pd_uuid_t pd_uuid_ns_dns;
46 pd_uuid_t pd_uuid_ns_oid;
47
48 #endif