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