blob: c1182feb0f7cce2fe3d11f215763ff9dc39baef2 [file] [log] [blame]
Theodore Ts'o1e3472c1997-04-29 14:53:37 +00001/*
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'o19c78dc1997-04-29 16:17:09 +00005 *
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'o1e3472c1997-04-29 14:53:37 +000012 */
13
14#include "uuidP.h"
15
Theodore Ts'offd3af51999-06-17 22:49:23 +000016#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
17
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000018int uuid_compare(uuid_t uu1, uuid_t uu2)
19{
Theodore Ts'offd3af51999-06-17 22:49:23 +000020 struct uuid uuid1, uuid2;
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000021
Theodore Ts'offd3af51999-06-17 22:49:23 +000022 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'o1e3472c1997-04-29 14:53:37 +000030}
31