Whamcloud - gitweb
Many files:
[tools/e2fsprogs.git] / lib / uuid / compare.c
1 /*
2  * compare.c --- compare whether or not two UUID's are the same
3  *
4  * Returns 0 if the two UUID's are different, and 1 if they are the same.
5  * 
6  * Copyright (C) 1996, 1997 Theodore Ts'o.
7  *
8  * %Begin-Header%
9  * This file may be redistributed under the terms of the GNU 
10  * Library General Public License.
11  * %End-Header%
12  */
13
14 #include "uuidP.h"
15
16 #define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
17
18 int uuid_compare(uuid_t uu1, uuid_t uu2)
19 {
20         struct uuid     uuid1, uuid2;
21
22         uuid_unpack(uu1, &uuid1);
23         uuid_unpack(uu2, &uuid2);
24
25         UUCMP(uuid1.time_low, uuid2.time_low);
26         UUCMP(uuid1.time_mid, uuid2.time_mid);
27         UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
28         UUCMP(uuid1.clock_seq, uuid2.clock_seq);
29         return memcmp(uuid1.node, uuid2.node, 6);
30 }
31