00001 /* 00002 * compare.c --- compare whether or not two UUID's are the same 00003 * 00004 * Returns 0 if the two UUID's are different, and 1 if they are the same. 00005 * 00006 * Copyright (C) 1996, 1997 Theodore Ts'o. 00007 * 00008 * %Begin-Header% 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, and the entire permission notice in its entirety, 00014 * including the disclaimer of warranties. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote 00019 * products derived from this software without specific prior 00020 * written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00024 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF 00025 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 00026 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00027 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00028 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00029 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00032 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH 00033 * DAMAGE. 00034 * %End-Header% 00035 */ 00036 00037 #include "uuidP.h" 00038 #include <string.h> 00039 00040 #define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); 00041 00042 int uuid_compare(const uuid_t uu1, const uuid_t uu2) 00043 { 00044 struct uuid uuid1, uuid2; 00045 00046 uuid_unpack(uu1, &uuid1); 00047 uuid_unpack(uu2, &uuid2); 00048 00049 UUCMP(uuid1.time_low, uuid2.time_low); 00050 UUCMP(uuid1.time_mid, uuid2.time_mid); 00051 UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); 00052 UUCMP(uuid1.clock_seq, uuid2.clock_seq); 00053 return memcmp(uuid1.node, uuid2.node, 6); 00054 } 00055