13984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* 23984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * Public include file for the UUID library 33984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 43984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. 53984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 63984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * %Begin-Header% 73984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * Redistribution and use in source and binary forms, with or without 83984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * modification, are permitted provided that the following conditions 93984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * are met: 103984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 1. Redistributions of source code must retain the above copyright 113984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * notice, and the entire permission notice in its entirety, 123984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * including the disclaimer of warranties. 133984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 2. Redistributions in binary form must reproduce the above copyright 143984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * notice, this list of conditions and the following disclaimer in the 153984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * documentation and/or other materials provided with the distribution. 163984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 3. The name of the author may not be used to endorse or promote 173984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * products derived from this software without specific prior 183984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * written permission. 193984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * 203984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 213984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 223984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF 233984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 243984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 253984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 263984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 273984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 283984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 293984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 303984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH 313984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * DAMAGE. 323984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt * %End-Header% 333984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt */ 343984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 353984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#ifndef _UUID_UUID_H 363984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define _UUID_UUID_H 373984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 383984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#include <sys/types.h> 393984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#ifndef _WIN32 403984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#include <sys/time.h> 413984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#endif 423984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#include <time.h> 433984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 443984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidttypedef unsigned char uuid_t[16]; 453984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 463984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* UUID Variant definitions */ 473984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_VARIANT_NCS 0 483984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_VARIANT_DCE 1 493984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_VARIANT_MICROSOFT 2 503984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_VARIANT_OTHER 3 513984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 523984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* UUID Type definitions */ 533984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_TYPE_DCE_TIME 1 543984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_TYPE_DCE_RANDOM 4 553984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 563984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* Allow UUID constants to be defined */ 573984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#ifdef __GNUC__ 583984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ 593984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} 603984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#else 613984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ 623984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} 633984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#endif 643984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 653984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#ifdef __cplusplus 663984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtextern "C" { 673984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#endif 683984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 693984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* clear.c */ 703984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_clear(uuid_t uu); 713984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 723984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* compare.c */ 733984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtint uuid_compare(const uuid_t uu1, const uuid_t uu2); 743984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 753984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* copy.c */ 763984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_copy(uuid_t dst, const uuid_t src); 773984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 783984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* gen_uuid.c */ 793984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_generate(uuid_t out); 803984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_generate_random(uuid_t out); 813984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_generate_time(uuid_t out); 823984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 833984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* isnull.c */ 843984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtint uuid_is_null(const uuid_t uu); 853984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 863984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* parse.c */ 873984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtint uuid_parse(const char *in, uuid_t uu); 883984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 893984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* unparse.c */ 903984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_unparse(const uuid_t uu, char *out); 913984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_unparse_lower(const uuid_t uu, char *out); 923984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtvoid uuid_unparse_upper(const uuid_t uu, char *out); 933984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 943984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt/* uuid_time.c */ 953984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidttime_t uuid_time(const uuid_t uu, struct timeval *ret_tv); 963984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtint uuid_type(const uuid_t uu); 973984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidtint uuid_variant(const uuid_t uu); 983984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 993984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#ifdef __cplusplus 1003984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt} 1013984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#endif 1023984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt 1033984b61df41c68966bdfbb2a5e5a45ef4b9a536cDmitry Shmidt#endif /* _UUID_UUID_H */ 104