18cb1c0efSmrg/*
28cb1c0efSmrg * Public include file for the UUID library
38cb1c0efSmrg *
48cb1c0efSmrg * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
58cb1c0efSmrg *
68cb1c0efSmrg * %Begin-Header%
78cb1c0efSmrg * Redistribution and use in source and binary forms, with or without
88cb1c0efSmrg * modification, are permitted provided that the following conditions
98cb1c0efSmrg * are met:
108cb1c0efSmrg * 1. Redistributions of source code must retain the above copyright
118cb1c0efSmrg *    notice, and the entire permission notice in its entirety,
128cb1c0efSmrg *    including the disclaimer of warranties.
138cb1c0efSmrg * 2. Redistributions in binary form must reproduce the above copyright
148cb1c0efSmrg *    notice, this list of conditions and the following disclaimer in the
158cb1c0efSmrg *    documentation and/or other materials provided with the distribution.
168cb1c0efSmrg * 3. The name of the author may not be used to endorse or promote
178cb1c0efSmrg *    products derived from this software without specific prior
188cb1c0efSmrg *    written permission.
198cb1c0efSmrg *
208cb1c0efSmrg * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
218cb1c0efSmrg * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
228cb1c0efSmrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
238cb1c0efSmrg * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
248cb1c0efSmrg * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
258cb1c0efSmrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
268cb1c0efSmrg * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
278cb1c0efSmrg * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
288cb1c0efSmrg * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
298cb1c0efSmrg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
308cb1c0efSmrg * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
318cb1c0efSmrg * DAMAGE.
328cb1c0efSmrg * %End-Header%
338cb1c0efSmrg */
348cb1c0efSmrg
358cb1c0efSmrg#ifndef _UUID_UUID_H
368cb1c0efSmrg#define _UUID_UUID_H
378cb1c0efSmrg
388cb1c0efSmrg#include <sys/types.h>
398cb1c0efSmrg#ifndef _WIN32
408cb1c0efSmrg#include <sys/time.h>
418cb1c0efSmrg#endif
428cb1c0efSmrg#include <time.h>
438cb1c0efSmrg
448cb1c0efSmrgtypedef unsigned char uuid_t[16];
458cb1c0efSmrg
468cb1c0efSmrg/* UUID Variant definitions */
478cb1c0efSmrg#define UUID_VARIANT_NCS	0
488cb1c0efSmrg#define UUID_VARIANT_DCE	1
498cb1c0efSmrg#define UUID_VARIANT_MICROSOFT	2
508cb1c0efSmrg#define UUID_VARIANT_OTHER	3
518cb1c0efSmrg
528cb1c0efSmrg#define UUID_VARIANT_SHIFT	5
538cb1c0efSmrg#define UUID_VARIANT_MASK     0x7
548cb1c0efSmrg
558cb1c0efSmrg/* UUID Type definitions */
568cb1c0efSmrg#define UUID_TYPE_DCE_TIME   1
578cb1c0efSmrg#define UUID_TYPE_DCE_SECURITY 2
588cb1c0efSmrg#define UUID_TYPE_DCE_MD5    3
598cb1c0efSmrg#define UUID_TYPE_DCE_RANDOM 4
608cb1c0efSmrg#define UUID_TYPE_DCE_SHA1   5
618cb1c0efSmrg
628cb1c0efSmrg#define UUID_TYPE_SHIFT      4
638cb1c0efSmrg#define UUID_TYPE_MASK     0xf
648cb1c0efSmrg
658cb1c0efSmrg#define UUID_STR_LEN	37
668cb1c0efSmrg
678cb1c0efSmrg/* Allow UUID constants to be defined */
688cb1c0efSmrg#ifdef __GNUC__
698cb1c0efSmrg#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
708cb1c0efSmrg	static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
718cb1c0efSmrg#else
728cb1c0efSmrg#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
738cb1c0efSmrg	static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
748cb1c0efSmrg#endif
758cb1c0efSmrg
768cb1c0efSmrg#ifdef __cplusplus
778cb1c0efSmrgextern "C" {
788cb1c0efSmrg#endif
798cb1c0efSmrg
808cb1c0efSmrg/* clear.c */
818cb1c0efSmrgextern void uuid_clear(uuid_t uu);
828cb1c0efSmrg
838cb1c0efSmrg/* compare.c */
848cb1c0efSmrgextern int uuid_compare(const uuid_t uu1, const uuid_t uu2);
858cb1c0efSmrg
868cb1c0efSmrg/* copy.c */
878cb1c0efSmrgextern void uuid_copy(uuid_t dst, const uuid_t src);
888cb1c0efSmrg
898cb1c0efSmrg/* gen_uuid.c */
908cb1c0efSmrgextern void uuid_generate(uuid_t out);
918cb1c0efSmrgextern void uuid_generate_random(uuid_t out);
928cb1c0efSmrgextern int uuid_generate_time_safe(uuid_t out);
938cb1c0efSmrg
948cb1c0efSmrg/* isnull.c */
958cb1c0efSmrgextern int uuid_is_null(const uuid_t uu);
968cb1c0efSmrg
978cb1c0efSmrg/* parse.c */
988cb1c0efSmrgextern int uuid_parse(const char *in, uuid_t uu);
998cb1c0efSmrg
1008cb1c0efSmrg/* unparse.c */
1018cb1c0efSmrgextern void uuid_unparse(const uuid_t uu, char *out);
1028cb1c0efSmrgextern void uuid_unparse_lower(const uuid_t uu, char *out);
1038cb1c0efSmrgextern void uuid_unparse_upper(const uuid_t uu, char *out);
1048cb1c0efSmrg
1058cb1c0efSmrg/* uuid_time.c */
1068cb1c0efSmrgextern time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
1078cb1c0efSmrgextern int uuid_type(const uuid_t uu);
1088cb1c0efSmrgextern int uuid_variant(const uuid_t uu);
1098cb1c0efSmrg
1108cb1c0efSmrg/* predefined.c */
1118cb1c0efSmrgextern const uuid_t *uuid_get_template(const char *alias);
1128cb1c0efSmrg
1138cb1c0efSmrg#ifdef __cplusplus
1148cb1c0efSmrg}
1158cb1c0efSmrg#endif
1168cb1c0efSmrg
1178cb1c0efSmrg#endif /* _UUID_UUID_H */
118