Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:14

0001 /*
0002  * Public include file for the UUID library
0003  *
0004  * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
0005  *
0006  * %Begin-Header%
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, and the entire permission notice in its entirety,
0012  *    including the disclaimer of warranties.
0013  * 2. Redistributions in binary form must reproduce the above copyright
0014  *    notice, this list of conditions and the following disclaimer in the
0015  *    documentation and/or other materials provided with the distribution.
0016  * 3. The name of the author may not be used to endorse or promote
0017  *    products derived from this software without specific prior
0018  *    written permission.
0019  *
0020  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
0021  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0022  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
0023  * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
0024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
0026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
0027  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0028  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0030  * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
0031  * DAMAGE.
0032  * %End-Header%
0033  */
0034 
0035 #ifndef _UUID_UUID_H
0036 #define _UUID_UUID_H
0037 
0038 #include <sys/types.h>
0039 #ifndef _WIN32
0040 #include <sys/time.h>
0041 #endif
0042 #include <time.h>
0043 
0044 typedef unsigned char uuid_t[16];
0045 
0046 /* UUID Variant definitions */
0047 #define UUID_VARIANT_NCS    0
0048 #define UUID_VARIANT_DCE    1
0049 #define UUID_VARIANT_MICROSOFT  2
0050 #define UUID_VARIANT_OTHER  3
0051 
0052 /* UUID Type definitions */
0053 #define UUID_TYPE_DCE_TIME   1
0054 #define UUID_TYPE_DCE_RANDOM 4
0055 
0056 /* Allow UUID constants to be defined */
0057 #ifdef __GNUC__
0058 #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
0059     static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
0060 #else
0061 #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
0062     static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
0063 #endif
0064 
0065 #ifdef __cplusplus
0066 extern "C" {
0067 #endif
0068 
0069 /* clear.c */
0070 void uuid_clear(uuid_t uu);
0071 
0072 /* compare.c */
0073 int uuid_compare(const uuid_t uu1, const uuid_t uu2);
0074 
0075 /* copy.c */
0076 void uuid_copy(uuid_t dst, const uuid_t src);
0077 
0078 /* gen_uuid.c */
0079 void uuid_generate(uuid_t out);
0080 void uuid_generate_random(uuid_t out);
0081 void uuid_generate_time(uuid_t out);
0082 
0083 /* isnull.c */
0084 int uuid_is_null(const uuid_t uu);
0085 
0086 /* parse.c */
0087 int uuid_parse(const char *in, uuid_t uu);
0088 
0089 /* unparse.c */
0090 void uuid_unparse(const uuid_t uu, char *out);
0091 void uuid_unparse_lower(const uuid_t uu, char *out);
0092 void uuid_unparse_upper(const uuid_t uu, char *out);
0093 
0094 /* uuid_time.c */
0095 time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
0096 int uuid_type(const uuid_t uu);
0097 int uuid_variant(const uuid_t uu);
0098 
0099 #ifdef __cplusplus
0100 }
0101 #endif
0102 
0103 #endif /* _UUID_UUID_H */