1223519Shselasky/*- 2223519Shselasky * Copyright (c) 2002,2005 Marcel Moolenaar 3223519Shselasky * Copyright (c) 2002 Hiten Mahesh Pandya 4223519Shselasky * All rights reserved. 5223519Shselasky * 6223519Shselasky * Redistribution and use in source and binary forms, with or without 7223519Shselasky * modification, are permitted provided that the following conditions 8223519Shselasky * are met: 9223519Shselasky * 1. Redistributions of source code must retain the above copyright 10223519Shselasky * notice, this list of conditions and the following disclaimer. 11223519Shselasky * 2. Redistributions in binary form must reproduce the above copyright 12223519Shselasky * notice, this list of conditions and the following disclaimer in the 13223519Shselasky * documentation and/or other materials provided with the distribution. 14223519Shselasky * 15223519Shselasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16233562Shselasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17223519Shselasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18223519Shselasky * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19223519Shselasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20223519Shselasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21223519Shselasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22223519Shselasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23223519Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24223519Shselasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25223519Shselasky * SUCH DAMAGE. 26223519Shselasky * 27233562Shselasky * $FreeBSD$ 28223519Shselasky */ 29223519Shselasky 30223519Shselasky#include <string.h> 31223519Shselasky#include <uuid.h> 32223519Shselasky 33223519Shselasky/* 34223519Shselasky * uuid_equal() - compare for equality. 35223519Shselasky * See also: 36223519Shselasky * http://www.opengroup.org/onlinepubs/009629399/uuid_equal.htm 37223519Shselasky */ 38233562Shselaskyint32_t 39223519Shselaskyuuid_equal(const uuid_t *a, const uuid_t *b, uint32_t *status) 40223519Shselasky{ 41223519Shselasky 42223519Shselasky if (status != NULL) 43223519Shselasky *status = uuid_s_ok; 44223519Shselasky 45223519Shselasky /* Deal with equal or NULL pointers. */ 46223519Shselasky if (a == b) 47223519Shselasky return (1); 48223519Shselasky if (a == NULL) 49233562Shselasky return (uuid_is_nil(b, NULL)); 50223519Shselasky if (b == NULL) 51223519Shselasky return (uuid_is_nil(a, NULL)); 52223519Shselasky 53223519Shselasky /* Do a byte for byte comparison. */ 54223519Shselasky return ((memcmp(a, b, sizeof(uuid_t))) ? 0 : 1); 55223519Shselasky} 56223519Shselasky