From fa2c41fc5871da0789b833dd1755c2cc4ff7b2b8 Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Tue, 2 Oct 2012 10:22:49 +0200 Subject: add function guid_cmp() to compare guids Change-Id: I6e34bcfb2205c1647e82dd396a13b0957532c4ae Signed-off-by: Noel Power Reviewed-on: https://code.wireshark.org/review/9438 Reviewed-by: Anders Broman --- epan/guid-utils.c | 16 ++++++++++++++++ epan/guid-utils.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/epan/guid-utils.c b/epan/guid-utils.c index c0a915b31f..8bb95b98b5 100644 --- a/epan/guid-utils.c +++ b/epan/guid-utils.c @@ -198,6 +198,22 @@ guids_resolve_guid_to_str(const e_guid_t *guid) guid->data4[6], guid->data4[7]); } +int guid_cmp(const e_guid_t *g1, const e_guid_t *g2) +{ + if (g1->data1 != g2->data1) { + return (g1->data1 < g2->data1) ? -1 : 1; + } + + if (g1->data2 != g2->data2) { + return (g1->data2 < g2->data2) ? -1 : 1; + } + + if (g1->data3 != g2->data3) { + return (g1->data3 < g2->data3) ? -1 : 1; + } + + return memcmp(&g1->data4[0], &g2->data4[0], 8); +} /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/epan/guid-utils.h b/epan/guid-utils.h index bc4f88ada9..6441b361df 100644 --- a/epan/guid-utils.h +++ b/epan/guid-utils.h @@ -60,4 +60,6 @@ WS_DLL_PUBLIC const gchar* guids_resolve_guid_to_str(const e_guid_t *guid); /* (if you need hex string only, use guid_to_str instead) */ #define guids_resolve_uuid_to_str(uuid) guids_resolve_guid_to_str((e_guid_t *) (uuid)) +extern int guid_cmp(const e_guid_t *g1, const e_guid_t *g2); + #endif /* __GUID_UTILS_H__ */ -- cgit v1.2.1