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#include <string.h>
16
17#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
18
19int uuid_compare(const uuid_t uu1, const uuid_t uu2)
20{
21	struct uuid	uuid1, uuid2;
22
23	uuid_unpack(uu1, &uuid1);
24	uuid_unpack(uu2, &uuid2);
25
26	UUCMP(uuid1.time_low, uuid2.time_low);
27	UUCMP(uuid1.time_mid, uuid2.time_mid);
28	UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
29	UUCMP(uuid1.clock_seq, uuid2.clock_seq);
30	return memcmp(uuid1.node, uuid2.node, 6);
31}
32
33