18cb1c0efSmrg/* 28cb1c0efSmrg * compare.c --- compare whether or not two UUIDs are the same 38cb1c0efSmrg * 48cb1c0efSmrg * Returns 0 if the two UUIDs are different, and 1 if they are the same. 58cb1c0efSmrg * 68cb1c0efSmrg * Copyright (C) 1996, 1997 Theodore Ts'o. 78cb1c0efSmrg * 88cb1c0efSmrg * %Begin-Header% 98cb1c0efSmrg * Redistribution and use in source and binary forms, with or without 108cb1c0efSmrg * modification, are permitted provided that the following conditions 118cb1c0efSmrg * are met: 128cb1c0efSmrg * 1. Redistributions of source code must retain the above copyright 138cb1c0efSmrg * notice, and the entire permission notice in its entirety, 148cb1c0efSmrg * including the disclaimer of warranties. 158cb1c0efSmrg * 2. Redistributions in binary form must reproduce the above copyright 168cb1c0efSmrg * notice, this list of conditions and the following disclaimer in the 178cb1c0efSmrg * documentation and/or other materials provided with the distribution. 188cb1c0efSmrg * 3. The name of the author may not be used to endorse or promote 198cb1c0efSmrg * products derived from this software without specific prior 208cb1c0efSmrg * written permission. 218cb1c0efSmrg * 228cb1c0efSmrg * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 238cb1c0efSmrg * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 248cb1c0efSmrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF 258cb1c0efSmrg * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 268cb1c0efSmrg * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 278cb1c0efSmrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 288cb1c0efSmrg * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 298cb1c0efSmrg * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 308cb1c0efSmrg * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 318cb1c0efSmrg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 328cb1c0efSmrg * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH 338cb1c0efSmrg * DAMAGE. 348cb1c0efSmrg * %End-Header% 358cb1c0efSmrg */ 368cb1c0efSmrg 378cb1c0efSmrg#include "uuidP.h" 388cb1c0efSmrg#include <string.h> 398cb1c0efSmrg 408cb1c0efSmrg#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); 418cb1c0efSmrg 428cb1c0efSmrgint uuid_compare(const uuid_t uu1, const uuid_t uu2) 438cb1c0efSmrg{ 448cb1c0efSmrg struct uuid uuid1, uuid2; 458cb1c0efSmrg 468cb1c0efSmrg uuid_unpack(uu1, &uuid1); 478cb1c0efSmrg uuid_unpack(uu2, &uuid2); 488cb1c0efSmrg 498cb1c0efSmrg UUCMP(uuid1.time_low, uuid2.time_low); 508cb1c0efSmrg UUCMP(uuid1.time_mid, uuid2.time_mid); 518cb1c0efSmrg UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); 528cb1c0efSmrg UUCMP(uuid1.clock_seq, uuid2.clock_seq); 538cb1c0efSmrg return memcmp(uuid1.node, uuid2.node, 6); 548cb1c0efSmrg} 558cb1c0efSmrg 56