diff -Pu uuid-null/Makefile uuid/Makefile --- uuid-null/Makefile Thu Jan 1 01:00:00 1970 +++ uuid/Makefile Thu Oct 17 15:19:02 2002 @@ -0,0 +1,23 @@ +# $FreeBSD: src/lib/libfetch/Makefile,v 1.31 2002/06/21 09:56:38 des Exp $ + +MAINTAINER= hiten@unixdaemons.com +LIB= uuid +CFLAGS+= -I. -ggdb +SRCS= uuid_clear.c uuid_compare.c uuid_create.c uuid_equal.c \ + uuid_isnull.c +INCS= uuid.h +MAN= uuid.3 +#CLEANFILES= uuid.h + +NO_WERROR= yes + +SHLIB_MAJOR= 3 +SHLIB_MINOR= 0 + +MLINKS+= uuid.3 uuid_clear.3 +MLINKS+= uuid.3 uuid_compare.3 +MLINKS+= uuid.3 uuid_create.3 +MLINKS+= uuid.3 uuid_equal.3 +MLINKS+= uuid.3 uuid_isnull.c + +.include diff -Pu uuid-null/Makefile.inc uuid/Makefile.inc --- uuid-null/Makefile.inc Thu Jan 1 01:00:00 1970 +++ uuid/Makefile.inc Thu Oct 17 15:00:13 2002 @@ -0,0 +1,10 @@ +# $FreeBSD$ + +# DCE/RPC UUID Implementation sources +.PATH: ${.CURDIR}/../libc/uuid + +SRCS+= uuid_create.c uuid_compare.c uuid_clear.c uuid_equal.c uuid_isnull.c + +MAN+= uuid.3 + +MLINKS+=uuid.3 diff -Pu uuid-null/test.c uuid/test.c --- uuid-null/test.c Thu Jan 1 01:00:00 1970 +++ uuid/test.c Thu Oct 17 14:53:21 2002 @@ -0,0 +1,36 @@ +#include +#include +#include + +static void +uuid_print(uuid_t *uuid) +{ + printf("%08x-%04x-%04x-%02x%02x-", uuid->time_low, uuid->time_mid, + uuid->time_hi_and_version, uuid->clock_seq_hi_and_reserved, + uuid->clock_seq_low); + printf("%02x%02x%02x%02x%02x%02x\n", uuid->node[0], uuid->node[1], + uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]); +} + +int main() +{ + struct uuid u, uu; + uint32_t status; + + printf("Entered test\n\n"); + + uuid_create(&u, 1, &status); + + printf("Status: %d\n", status); + uuid_print(&u); + + uuid_isnull(&uu, &status); + + printf("Status (after uuid_isnull): %d\n", status); + if (status == 0) + printf("It works!\n"); + else if (status == -1) + printf("Oh no!\n"); + + return; +} diff -Pu uuid-null/uuid.3 uuid/uuid.3 --- uuid-null/uuid.3 Thu Jan 1 01:00:00 1970 +++ uuid/uuid.3 Thu Oct 17 15:27:01 2002 @@ -0,0 +1,194 @@ +.\" --nroff-mode-- +.\" Copyright (c) 2002 Hiten Pandya +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 11, 2002 +.Dt UUID 3 +.Os +.Sh NAME +.Nm uuid +.Nd Universally Unique Identifiers (UUIDs) +.Sh SYNOPSIS +.In sys/types.h +.In uuid.h +.Ft int +.Fn uuid_compare "struct uuid *a" "struct uuid *b" "uint32_t *status" +.Ft void +.Fn uuid_clear "struct uuid *uu" +.Ft int +.Fn uuid_create "struct uuid *store" "int count" "uint32_t *status" +.Ft int +.Fn uuid_equal "struct uuid *a" "struct uuid *b" "uint32_t *status" +.Ft int +.Fn uuid_isnull "struct uuid *uuid" "uint32_t *status" +.Ft uint64_t +.Fn uuid_time "void" +.Sh DESCRIPTION +Universally Unique Identifiers (UUID) are 128 bit that may be generated +independently on seperate nodes (hosts), which, result in globally unique +strings without requiring the hosts to be in communication with each other +to ensure uniqueness. +.Pp +The mechanism used to guarantee that UUIDs are unique is through a combination +of hardware addresses, time stamps and random seeds. There is a reference in +the UUID to the MAC address of the first Network Interface Card (NIC) on the +node which generated the UUID; this ensures the uniqueness, as MAC address of +every NIC is assigned by a single "global" authority. +.Pp +When an IEE 802 address is unavailable, a random multicast address is used. +Please refer to +.Xr uuidgen 2 , +for more information on the semantics. +.Pp +UUIDs are a part of the DCE specification. They have been reimplemented +in FreeBSD, but in accordance to the DCE specification. A UUID is +represented by the +.Em uuid +data structure (DCE 1.1 compatible). +.Bd -literal + struct uuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint8_t clock_seq_hi_and_reserved; + uint8_t clock_seq_low; + uint8_t node[_UUID_NODE_LEN]; + }; + + typedef struct uuid uuid_t; +.Ed +.Pp +The size of the +.Sy UUID +data structure is 16 octets (128 bits), and does not contain padding between +the fields. All fields in the UUID data structure are unsigned types. +.Em time_low +is the low field of the timestamp, +.Em time_mid +is the middle field of the timestamp, +.Em time_hi_and_reserved +is the high field of the timestamp multiplexed with the version number, +.Em clock_seq_hi_and_reserved +is the high field of the clock sequence multiplexed with the variant, +.Em clock_seq_low +is the low field of the clock sequence +and +.Em node +is the spatially unique node identifier. Refer to the DCE specification +for more information about the fields in the UUID data stucture. +.Pp +Special subroutines exist for manipulating the UUID data structure. Most +store their return values in a +.Em status +parameter, which is a pointer to +.Em uint32_t . +.Pp +.Nm uuid_compare +compares +.Em a +with +.Em b +and stores the return value in +.Em status . +The +.Em status +parameter will contain -1 if +.Em a +preceeds +.Em b , +0 if +.Em a +is equal to +.Em b +and 1 if +.Em a +follows +.Em b . +.Pp +.Nm uuid_clear +is used to reset the uuid structure pointed by +.Em uu , +.Em uu +can then be used to reset other UUIDs. Nothing is returned. +.Pp +.Nm uuid_create +generates +.Em count +UUIDs and stores the return values in +.Em status . +The return value will be 0 upon successful completion, otherwise -1 is +returned and the global variable +.Em errno +is set to indicate the error. This function is a wrapper to the +.Xr uuidgen 2 +system call. +.Pp +.Nm uuid_equal +checks +.Em a +and +.Em b +for equality, and stores the return value in +.Em status . +The value 0 is stored and returned upon successful completion, otherwise a +non-zero value is stored and returned. +.Pp +.Nm uuid_isnull +is used to check if +.Em uuid +is null, and store the return value in +.Em status . +The value 1 is returned if +.Em uuid +is null +and 0 if +.Em uuid +is not null. +.Sh RETURN VALUES +Return values differ for each subroutine. Refer to the individual subroutine +for more information on their return values. +.Sh COMPATIBILITY +.Pp +API compatible with the DCE/RPC specification. +.Sh SEE ALSO +.Xr uuidgen 2 , +.Xr uuidgen 1 +.Pp +Alternatively, please check the following World Wide Web addresses for +more information about Universally Unique Identifiers (UUIDs): + + http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt + http://www.opengroup.org/onlinepubs/009629399/apdxa.html + http://www.dsps.net/uuid.html +.Sh AUTHORS +The +.Nm +library is written by Hiten Pandya and Marcel Moolenaar. +.Sh BUGS +.Pp +There are no known bugs in this implementation of UUIDs for +.Fx . If you discover a bug, please submit a PR, or +alternativally email Hiten Pandya. diff -Pu uuid-null/uuid.h uuid/uuid.h --- uuid-null/uuid.h Thu Jan 1 01:00:00 1970 +++ uuid/uuid.h Thu Oct 17 15:05:09 2002 @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef _UUID_H_ +#define _UUID_H_ + +#ifndef _SYS_PARAM_H_ +#include +#endif /* _SYS_PARAM_H_ */ + +#include + +/* + * Universal Unique Identifiers (UUIDs) are bit strings that + * may be generated independently on seperate nodes (hosts) + * such that globally unique strings result without requiring + * the hosts to be in communication with each other to ensure + * uniqueness. + * + * This implementation is API compatible with the DCE + * specification. + */ + +void uuid_clear(struct uuid *); +int uuid_compare(struct uuid *, struct uuid *, uint32_t *); +int uuid_create(struct uuid *, int, uint32_t *); +int uuid_equal(struct uuid *, struct uuid *, uint32_t *); +int uuid_isnull(struct uuid *, uint32_t *); + +#endif /* _UUID_H_ */ diff -Pu uuid-null/uuid_clear.c uuid/uuid_clear.c --- uuid-null/uuid_clear.c Thu Jan 1 01:00:00 1970 +++ uuid/uuid_clear.c Thu Oct 17 15:25:01 2002 @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +/* + * uuid_clear() + * Reset the UUID. + */ +void +uuid_clear(struct uuid *uu) +{ + + bzero(uu, sizeof *uu); +} diff -Pu uuid-null/uuid_compare.c uuid/uuid_compare.c --- uuid-null/uuid_compare.c Thu Jan 1 01:00:00 1970 +++ uuid/uuid_compare.c Thu Oct 17 15:28:22 2002 @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + + +/* + * uuid_compare() + * + * Compare two UUID's. + * Return values: + * + * -1: The @a argument precedes the @b argument + * 0: The @a is equal to the @b argument + * 1: The @a argument follows the @b argument + */ +int +uuid_compare(struct uuid *a, struct uuid *b, uint32_t *status) +{ + int64_t res; + *status = 0; + + if (status) + *status = 0; + res = a->time_low - b->time_low; + if (res) + return ((res < 0) ? -1 : 1); + res = a->time_mid - b->time_mid; + if (res) + return ((res < 0) ? -1 : 1); + res = a->time_hi_and_version - b->time_hi_and_version; + if (res) + return ((res < 0) ? -1 : 1); + res = a->clock_seq_hi_and_reserved - b->clock_seq_hi_and_reserved; + if (res) + return ((res < 0) ? -1 : 1); + res = a->clock_seq_low - b->clock_seq_low; + if (res) + return ((res < 0) ? -1 : 1); + res = bcmp(a->node, b->node, sizeof(a->node)); + if (res) + return ((res < 0) ? -1 : 1); + return 0; +} diff -Pu uuid-null/uuid_create.c uuid/uuid_create.c --- uuid-null/uuid_create.c Thu Jan 1 01:00:00 1970 +++ uuid/uuid_create.c Thu Oct 17 14:14:38 2002 @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include "uuid.h" + +#include +__FBSDID("$Id: uuid_create.c,v 1.2 2002/06/06 19:56:46 hitenp Exp $"); + + +/* + * Universally Unique Identifiers (UUID) are bit strings that + * may be generated independently on seperate nodes (hosts) + * such that globally unique strings result without requiring + * the hosts to be in communication with each other to ensure + * uniqueness. + * + * This implementation is API compatible with the DCE + * specification. Please refer to the following URLs for more + * information: + * + * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt + * http://www.opengroup.org/onlinepubs/009629399/apdxa.htm + * + */ + +/* + * uuid_create() + * Create a Universally Unique Identifier (UUID) + * uuid_create() is wrapper for the uuidgen(2) system call. + */ +int +uuid_create(struct uuid *store, int count, uint32_t *status) +{ + int err = 0; + + err = uuidgen(store, count); + if (err == -1) { + printf("We failed!\n"); + *status = -1; + } + + return (*status = err); +} diff -Pu uuid-null/uuid_equal.c uuid/uuid_equal.c --- uuid-null/uuid_equal.c Thu Jan 1 01:00:00 1970 +++ uuid/uuid_equal.c Thu Oct 17 15:27:42 2002 @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include "uuid.h" + +/* + * uuid_equal() + * Check if the provided UUIDs are equal/same. + */ +int +uuid_equal(struct uuid *a, struct uuid *b, uint32_t *status) +{ + u_int error; + error = bcmp(a, b, sizeof(struct uuid)); + + if (error) + *status = error; + return (error); +} diff -Pu uuid-null/uuid_isnull.c uuid/uuid_isnull.c --- uuid-null/uuid_isnull.c Thu Jan 1 01:00:00 1970 +++ uuid/uuid_isnull.c Thu Oct 17 14:57:49 2002 @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2002 Hiten Mahesh Pandya + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HITEN MAHESH PANDYA ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL HITEN MAHESH PANDYA BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +/* + * uuid_isnull() + * Check if the provided UUID is null. + * Return value: 1 if null and 0 if not null. + */ +int +uuid_isnull(struct uuid *uuid, uint32_t *status) +{ + int i; + u_char *p; + + for (i = 0; i < (signed)(sizeof (struct uuid)); i++) + if (uuid++) + return (*status = 0); + +#if 0 + for (i=0, *p = uuid; i < (sizeof (struct uuid)); i++) { + if (*p++) + return (*status = 0); + } +#endif + return (*status = 1); +}