uuid.h
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* \file
* ways to create uuid variant 5. For uuid of variant 1 I use
* the implementation delivered with the core utils.
* But this is wrapped in here, so that the rest of the code
* can use only this implementation...this additionally has the
* advantage that we can implement version 1 here too for systems
* where the coreutils implementation is not available.
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2014 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TR_UUID_H__
#define __TR_UUID_H__
#include <stdint.h>
#include <sys/types.h>
#include <uuid/uuid.h>
#include "trbase.h"
typedef char TR_UuidString[37];
TR_CLASS(TR_Uuid) {
union {
uuid_t value;
struct {
uint32_t time_low;
uint16_t time_mid;
uint16_t time_hi_version;
uint8_t clk_seq_hi_res;
uint8_t clk_seq_low;
unsigned char node[6];
} elements;
} uuid;
};
TR_INSTANCE_INIT(TR_Uuid);
TR_CLASSVARS_DECL(TR_Uuid) {};
extern TR_Uuid TR_uuidZero;
/*
* generator functions...these are not really part of the object
* but generate a uuid object.
*/
TR_Uuid TR_uuidVersion1();
TR_Uuid TR_uuidVersion3(const unsigned char *, size_t, TR_Uuid);
TR_Uuid TR_uuidVersion5(const unsigned char *, size_t, TR_Uuid);
void TR_uuidUnparse(TR_Uuid, TR_UuidString);
TR_Uuid TR_uuidParse(const TR_UuidString);
int TR_uuidCompare(TR_Uuid, TR_Uuid);
#endif // __TR_UUID_H__
// vim: set ts=4 sw=4: