Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_uuid.h
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
27 #ifndef GLOBUS_UUID_H
28 #define GLOBUS_UUID_H
29 
30 #include "globus_common_include.h"
31 #include "globus_libc.h"
32 
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define GLOBUS_UUID_TEXTLEN 36
39 
40 #define GLOBUS_UUID_VERSION(uuid) ((uuid).binary.bytes[6] >> 4)
41 #define GLOBUS_UUID_VERSION_TIME 1
42 #define GLOBUS_UUID_VERSION_DCE 2
43 #define GLOBUS_UUID_VERSION_NAME 3
44 #define GLOBUS_UUID_VERSION_RANDOM 4
45 
46 #define GLOBUS_UUID_MATCH(u1, u2) \
47  (memcmp((u1).binary.bytes, (u2).binary.bytes, 16) == 0)
48 
49 typedef struct
50 {
51  uint32_t time_low;
52  uint16_t time_mid;
53  uint16_t time_hi_and_version;
54  uint8_t clock_seq_hi_and_reserved;
55  uint8_t clock_seq_low;
56  uint8_t node[6];
57 } globus_uuid_fields_t;
58 
59 typedef struct
60 {
61  union
62  {
63  uint8_t bytes[16];
64  /* all multibyte fields in network byte order */
65  globus_uuid_fields_t fields;
66  } binary;
67 
68  char text[GLOBUS_UUID_TEXTLEN + 1];
69 } globus_uuid_t;
70 
77 int
79  globus_uuid_t * uuid);
80 
91 int
93  globus_uuid_t * uuid,
94  const char * str);
95 
105 int
107  globus_uuid_t * uuid,
108  globus_uuid_fields_t * uuid_fields);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* GLOBUS_UUID_H */
int globus_uuid_create(globus_uuid_t *uuid)
Create UUIDCreates a time based, Leach-Salz variant uuid, using the mac address when available...
Definition: globus_uuid.c:217
int globus_uuid_import(globus_uuid_t *uuid, const char *str)
Import a UUIDImport a string in the text UUID format into a globus_uuid_t value.
Definition: globus_uuid.c:285
int globus_uuid_fields(globus_uuid_t *uuid, globus_uuid_fields_t *uuid_fields)
Extract fields from UUIDCopy the fields from uuid to uuid_fields in host byte order.
Definition: globus_uuid.c:344
Thread-safe libc macros, function prototypes.
Include System Headers.