1997-04-29 18:53:37 +04:00
|
|
|
/*
|
|
|
|
* compare.c --- compare whether or not two UUID's are the same
|
|
|
|
*
|
|
|
|
* Returns 0 if the two UUID's are different, and 1 if they are the same.
|
1997-04-29 20:17:09 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-29 18:53:37 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "uuidP.h"
|
|
|
|
|
1999-06-18 02:49:23 +04:00
|
|
|
#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
|
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
int uuid_compare(uuid_t uu1, uuid_t uu2)
|
|
|
|
{
|
1999-06-18 02:49:23 +04:00
|
|
|
struct uuid uuid1, uuid2;
|
|
|
|
|
|
|
|
uuid_unpack(uu1, &uuid1);
|
|
|
|
uuid_unpack(uu2, &uuid2);
|
1997-04-29 18:53:37 +04:00
|
|
|
|
1999-06-18 02:49:23 +04:00
|
|
|
UUCMP(uuid1.time_low, uuid2.time_low);
|
|
|
|
UUCMP(uuid1.time_mid, uuid2.time_mid);
|
|
|
|
UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
|
|
|
|
UUCMP(uuid1.clock_seq, uuid2.clock_seq);
|
|
|
|
return memcmp(uuid1.node, uuid2.node, 6);
|
1997-04-29 18:53:37 +04:00
|
|
|
}
|
|
|
|
|