summaryrefslogtreecommitdiff
path: root/capplets/file-types/libuuid/compare.c
diff options
context:
space:
mode:
Diffstat (limited to 'capplets/file-types/libuuid/compare.c')
-rw-r--r--capplets/file-types/libuuid/compare.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/capplets/file-types/libuuid/compare.c b/capplets/file-types/libuuid/compare.c
new file mode 100644
index 000000000..3d07b5dbc
--- /dev/null
+++ b/capplets/file-types/libuuid/compare.c
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+#include <string.h>
+
+#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
+
+int uuid_compare(uuid_t uu1, uuid_t uu2)
+{
+ struct uuid uuid1, uuid2;
+
+ uuid_unpack(uu1, &uuid1);
+ uuid_unpack(uu2, &uuid2);
+
+ 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);
+}
+