1*6a54128fSAndroid Build Coastguard Worker /* 2*6a54128fSAndroid Build Coastguard Worker * Public include file for the UUID library 3*6a54128fSAndroid Build Coastguard Worker * 4*6a54128fSAndroid Build Coastguard Worker * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. 5*6a54128fSAndroid Build Coastguard Worker * 6*6a54128fSAndroid Build Coastguard Worker * %Begin-Header% 7*6a54128fSAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 8*6a54128fSAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions 9*6a54128fSAndroid Build Coastguard Worker * are met: 10*6a54128fSAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright 11*6a54128fSAndroid Build Coastguard Worker * notice, and the entire permission notice in its entirety, 12*6a54128fSAndroid Build Coastguard Worker * including the disclaimer of warranties. 13*6a54128fSAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright 14*6a54128fSAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the 15*6a54128fSAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution. 16*6a54128fSAndroid Build Coastguard Worker * 3. The name of the author may not be used to endorse or promote 17*6a54128fSAndroid Build Coastguard Worker * products derived from this software without specific prior 18*6a54128fSAndroid Build Coastguard Worker * written permission. 19*6a54128fSAndroid Build Coastguard Worker * 20*6a54128fSAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 21*6a54128fSAndroid Build Coastguard Worker * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22*6a54128fSAndroid Build Coastguard Worker * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF 23*6a54128fSAndroid Build Coastguard Worker * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 24*6a54128fSAndroid Build Coastguard Worker * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25*6a54128fSAndroid Build Coastguard Worker * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26*6a54128fSAndroid Build Coastguard Worker * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27*6a54128fSAndroid Build Coastguard Worker * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28*6a54128fSAndroid Build Coastguard Worker * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*6a54128fSAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 30*6a54128fSAndroid Build Coastguard Worker * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH 31*6a54128fSAndroid Build Coastguard Worker * DAMAGE. 32*6a54128fSAndroid Build Coastguard Worker * %End-Header% 33*6a54128fSAndroid Build Coastguard Worker */ 34*6a54128fSAndroid Build Coastguard Worker 35*6a54128fSAndroid Build Coastguard Worker #ifndef _UUID_UUID_H 36*6a54128fSAndroid Build Coastguard Worker #define _UUID_UUID_H 37*6a54128fSAndroid Build Coastguard Worker 38*6a54128fSAndroid Build Coastguard Worker #include <sys/types.h> 39*6a54128fSAndroid Build Coastguard Worker #ifndef _WIN32 40*6a54128fSAndroid Build Coastguard Worker #include <sys/time.h> 41*6a54128fSAndroid Build Coastguard Worker #endif 42*6a54128fSAndroid Build Coastguard Worker #include <time.h> 43*6a54128fSAndroid Build Coastguard Worker 44*6a54128fSAndroid Build Coastguard Worker typedef unsigned char uuid_t[16]; 45*6a54128fSAndroid Build Coastguard Worker 46*6a54128fSAndroid Build Coastguard Worker /* UUID Variant definitions */ 47*6a54128fSAndroid Build Coastguard Worker #define UUID_VARIANT_NCS 0 48*6a54128fSAndroid Build Coastguard Worker #define UUID_VARIANT_DCE 1 49*6a54128fSAndroid Build Coastguard Worker #define UUID_VARIANT_MICROSOFT 2 50*6a54128fSAndroid Build Coastguard Worker #define UUID_VARIANT_OTHER 3 51*6a54128fSAndroid Build Coastguard Worker 52*6a54128fSAndroid Build Coastguard Worker /* UUID Type definitions */ 53*6a54128fSAndroid Build Coastguard Worker #define UUID_TYPE_DCE_TIME 1 54*6a54128fSAndroid Build Coastguard Worker #define UUID_TYPE_DCE_RANDOM 4 55*6a54128fSAndroid Build Coastguard Worker 56*6a54128fSAndroid Build Coastguard Worker /* Allow UUID constants to be defined */ 57*6a54128fSAndroid Build Coastguard Worker #ifdef __GNUC__ 58*6a54128fSAndroid Build Coastguard Worker #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ 59*6a54128fSAndroid Build Coastguard Worker static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} 60*6a54128fSAndroid Build Coastguard Worker #else 61*6a54128fSAndroid Build Coastguard Worker #define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ 62*6a54128fSAndroid Build Coastguard Worker static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} 63*6a54128fSAndroid Build Coastguard Worker #endif 64*6a54128fSAndroid Build Coastguard Worker 65*6a54128fSAndroid Build Coastguard Worker #ifdef __cplusplus 66*6a54128fSAndroid Build Coastguard Worker extern "C" { 67*6a54128fSAndroid Build Coastguard Worker #endif 68*6a54128fSAndroid Build Coastguard Worker 69*6a54128fSAndroid Build Coastguard Worker /* clear.c */ 70*6a54128fSAndroid Build Coastguard Worker void uuid_clear(uuid_t uu); 71*6a54128fSAndroid Build Coastguard Worker 72*6a54128fSAndroid Build Coastguard Worker /* compare.c */ 73*6a54128fSAndroid Build Coastguard Worker int uuid_compare(const uuid_t uu1, const uuid_t uu2); 74*6a54128fSAndroid Build Coastguard Worker 75*6a54128fSAndroid Build Coastguard Worker /* copy.c */ 76*6a54128fSAndroid Build Coastguard Worker void uuid_copy(uuid_t dst, const uuid_t src); 77*6a54128fSAndroid Build Coastguard Worker 78*6a54128fSAndroid Build Coastguard Worker /* gen_uuid.c */ 79*6a54128fSAndroid Build Coastguard Worker void uuid_generate(uuid_t out); 80*6a54128fSAndroid Build Coastguard Worker void uuid_generate_random(uuid_t out); 81*6a54128fSAndroid Build Coastguard Worker void uuid_generate_time(uuid_t out); 82*6a54128fSAndroid Build Coastguard Worker 83*6a54128fSAndroid Build Coastguard Worker /* isnull.c */ 84*6a54128fSAndroid Build Coastguard Worker int uuid_is_null(const uuid_t uu); 85*6a54128fSAndroid Build Coastguard Worker 86*6a54128fSAndroid Build Coastguard Worker /* parse.c */ 87*6a54128fSAndroid Build Coastguard Worker int uuid_parse(const char *in, uuid_t uu); 88*6a54128fSAndroid Build Coastguard Worker 89*6a54128fSAndroid Build Coastguard Worker /* unparse.c */ 90*6a54128fSAndroid Build Coastguard Worker void uuid_unparse(const uuid_t uu, char *out); 91*6a54128fSAndroid Build Coastguard Worker void uuid_unparse_lower(const uuid_t uu, char *out); 92*6a54128fSAndroid Build Coastguard Worker void uuid_unparse_upper(const uuid_t uu, char *out); 93*6a54128fSAndroid Build Coastguard Worker 94*6a54128fSAndroid Build Coastguard Worker /* uuid_time.c */ 95*6a54128fSAndroid Build Coastguard Worker time_t uuid_time(const uuid_t uu, struct timeval *ret_tv); 96*6a54128fSAndroid Build Coastguard Worker int uuid_type(const uuid_t uu); 97*6a54128fSAndroid Build Coastguard Worker int uuid_variant(const uuid_t uu); 98*6a54128fSAndroid Build Coastguard Worker 99*6a54128fSAndroid Build Coastguard Worker #ifdef __cplusplus 100*6a54128fSAndroid Build Coastguard Worker } 101*6a54128fSAndroid Build Coastguard Worker #endif 102*6a54128fSAndroid Build Coastguard Worker 103*6a54128fSAndroid Build Coastguard Worker #endif /* _UUID_UUID_H */ 104