10ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/*
20ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * Public include file for the UUID library
30ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *
40ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
50ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *
60ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * %Begin-Header%
70ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * Redistribution and use in source and binary forms, with or without
80ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * modification, are permitted provided that the following conditions
90ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * are met:
100ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * 1. Redistributions of source code must retain the above copyright
110ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    notice, and the entire permission notice in its entirety,
120ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    including the disclaimer of warranties.
130ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * 2. Redistributions in binary form must reproduce the above copyright
140ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    notice, this list of conditions and the following disclaimer in the
150ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    documentation and/or other materials provided with the distribution.
160ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * 3. The name of the author may not be used to endorse or promote
170ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    products derived from this software without specific prior
180ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *    written permission.
190ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey *
200ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
210ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
220ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
230ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
240ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
250ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
260ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
270ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
280ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
290ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
300ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
310ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * DAMAGE.
320ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey * %End-Header%
330ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey */
340ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
350ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#ifndef _UUID_UUID_H
360ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define _UUID_UUID_H
370ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
380ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#include <sys/types.h>
390ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#ifndef _WIN32
400ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#include <sys/time.h>
410ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#endif
420ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#include <time.h>
430ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
440ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeytypedef unsigned char uuid_t[16];
450ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
460ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* UUID Variant definitions */
470ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_VARIANT_NCS 	0
480ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_VARIANT_DCE 	1
490ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_VARIANT_MICROSOFT	2
500ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_VARIANT_OTHER	3
510ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
520ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* UUID Type definitions */
530ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_TYPE_DCE_TIME   1
540ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_TYPE_DCE_RANDOM 4
550ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
560ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* Allow UUID constants to be defined */
570ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#ifdef __GNUC__
580ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
590ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey	static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
600ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#else
610ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
620ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey	static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
630ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#endif
640ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
650ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#ifdef __cplusplus
660ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyextern "C" {
670ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#endif
680ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
690ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* clear.c */
700ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_clear(uuid_t uu);
710ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
720ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* compare.c */
730ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyint uuid_compare(const uuid_t uu1, const uuid_t uu2);
740ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
750ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* copy.c */
760ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_copy(uuid_t dst, const uuid_t src);
770ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
780ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* gen_uuid.c */
790ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_generate(uuid_t out);
800ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_generate_random(uuid_t out);
810ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_generate_time(uuid_t out);
820ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
830ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* isnull.c */
840ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyint uuid_is_null(const uuid_t uu);
850ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
860ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* parse.c */
870ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyint uuid_parse(const char *in, uuid_t uu);
880ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
890ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* unparse.c */
900ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_unparse(const uuid_t uu, char *out);
910ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_unparse_lower(const uuid_t uu, char *out);
920ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyvoid uuid_unparse_upper(const uuid_t uu, char *out);
930ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
940ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey/* uuid_time.c */
950ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeytime_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
960ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyint uuid_type(const uuid_t uu);
970ce8844d681b935caad893db8ff740400262ec8bJeff Sharkeyint uuid_variant(const uuid_t uu);
980ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
990ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#ifdef __cplusplus
1000ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey}
1010ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#endif
1020ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey
1030ce8844d681b935caad893db8ff740400262ec8bJeff Sharkey#endif /* _UUID_UUID_H */
104