1178476Sjb/* $OpenBSD: uuid_equal.c,v 1.2 2015/09/10 18:13:46 guenther Exp $ */ 2178476Sjb/* $NetBSD: uuid_equal.c,v 1.2 2008/04/23 07:52:32 plunky Exp $ */ 3178476Sjb 4178476Sjb/* 5178476Sjb * Copyright (c) 2002 Marcel Moolenaar 6178476Sjb * Copyright (c) 2002 Hiten Mahesh Pandya 7178476Sjb * All rights reserved. 8178476Sjb * 9178476Sjb * Redistribution and use in source and binary forms, with or without 10178476Sjb * modification, are permitted provided that the following conditions 11178476Sjb * are met: 12178476Sjb * 1. Redistributions of source code must retain the above copyright 13178476Sjb * notice, this list of conditions and the following disclaimer. 14178476Sjb * 2. Redistributions in binary form must reproduce the above copyright 15178476Sjb * notice, this list of conditions and the following disclaimer in the 16178476Sjb * documentation and/or other materials provided with the distribution. 17178476Sjb * 18178476Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19178476Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20178476Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21178476Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22178476Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23178476Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24178476Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25178476Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26178476Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27178476Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28178476Sjb * SUCH DAMAGE. 29178476Sjb * 30178476Sjb * $FreeBSD: src/lib/libc/uuid/uuid_equal.c,v 1.2 2003/08/08 19:18:43 marcel Exp $ 31178476Sjb */ 32178476Sjb 33178476Sjb#include <string.h> 34178476Sjb#include <uuid.h> 35178476Sjb 36178476Sjb/* 37178476Sjb * uuid_equal() - compare for equality. 38178476Sjb * See also: 39178476Sjb * http://www.opengroup.org/onlinepubs/009629399/uuid_equal.htm 40178476Sjb */ 41178476Sjbint32_t 42178476Sjbuuid_equal(const uuid_t *a, const uuid_t *b, uint32_t *status) 43178476Sjb{ 44178476Sjb if (status != NULL) 45178476Sjb *status = uuid_s_ok; 46178476Sjb 47178476Sjb /* Deal with equal or NULL pointers. */ 48178476Sjb if (a == b) 49178476Sjb return (1); 50178476Sjb if (a == NULL) 51178476Sjb return (uuid_is_nil(b, NULL)); 52178476Sjb if (b == NULL) 53178476Sjb return (uuid_is_nil(a, NULL)); 54178476Sjb 55178476Sjb /* Do a byte for byte comparison. */ 56 return ((memcmp(a, b, sizeof(uuid_t))) ? 0 : 1); 57} 58