globus_uuid.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00027 #ifndef GLOBUS_UUID_H
00028 #define GLOBUS_UUID_H
00029 
00030 #include "globus_common_include.h"
00031 #include "globus_libc.h"
00032 
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 #define GLOBUS_UUID_TEXTLEN 36
00039 
00040 #define GLOBUS_UUID_VERSION(uuid) ((uuid).binary.bytes[6] >> 4)
00041 #define GLOBUS_UUID_VERSION_TIME 1
00042 #define GLOBUS_UUID_VERSION_DCE 2
00043 #define GLOBUS_UUID_VERSION_NAME 3
00044 #define GLOBUS_UUID_VERSION_RANDOM 4
00045 
00046 #define GLOBUS_UUID_MATCH(u1, u2)                                           \
00047     (memcmp((u1).binary.bytes, (u2).binary.bytes, 16) == 0)
00048 
00049 typedef struct
00050 {
00051     uint32_t                    time_low;
00052     uint16_t                    time_mid;
00053     uint16_t                    time_hi_and_version;
00054     uint8_t                     clock_seq_hi_and_reserved;
00055     uint8_t                     clock_seq_low;
00056     uint8_t                     node[6];
00057 } globus_uuid_fields_t;
00058 
00059 typedef struct
00060 {
00061     union
00062     {
00063         uint8_t                         bytes[16];
00064         /* all multibyte fields in network byte order */
00065         globus_uuid_fields_t            fields;
00066     } binary;
00067     
00068     char                                text[GLOBUS_UUID_TEXTLEN + 1];
00069 } globus_uuid_t;
00070 
00077 int
00078 globus_uuid_create(
00079     globus_uuid_t *                     uuid);
00080 
00091 int
00092 globus_uuid_import(
00093     globus_uuid_t *                     uuid,
00094     const char *                        str);
00095 
00105 int
00106 globus_uuid_fields(
00107     globus_uuid_t *                     uuid,
00108     globus_uuid_fields_t *              uuid_fields);
00109 
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113 
00114 #endif /* GLOBUS_UUID_H */

Generated on 20 Jun 2015 for globus_common by  doxygen 1.4.7