Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 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. |
Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame] | 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 Public |
| 10 | * License. |
| 11 | * %End-Header% |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include "uuidP.h" |
| 15 | |
Theodore Ts'o | ffd3af5 | 1999-06-17 22:49:23 +0000 | [diff] [blame] | 16 | #define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); |
| 17 | |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 18 | int uuid_compare(uuid_t uu1, uuid_t uu2) |
| 19 | { |
Theodore Ts'o | ffd3af5 | 1999-06-17 22:49:23 +0000 | [diff] [blame] | 20 | struct uuid uuid1, uuid2; |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 21 | |
Theodore Ts'o | ffd3af5 | 1999-06-17 22:49:23 +0000 | [diff] [blame] | 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); |
Theodore Ts'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 30 | } |
| 31 | |