From bf62ecb9c4912fc51896d5a6cbd5501d0063434a Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Tue, 2 Oct 2012 10:22:49 +0200 Subject: [PATCH] add function guid_cmp() to compare guids --- 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 13d37de202..40e1ec2739 100644 --- a/epan/guid-utils.c +++ b/epan/guid-utils.c @@ -201,3 +201,19 @@ guids_resolve_guid_to_str(e_guid_t *guid) guid->data4[6], guid->data4[7]); } +int guid_cmp(e_guid_t *g1, 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); +} diff --git a/epan/guid-utils.h b/epan/guid-utils.h index 87df9d919c..132cb5d95e 100644 --- a/epan/guid-utils.h +++ b/epan/guid-utils.h @@ -62,4 +62,6 @@ WS_DLL_PUBLIC const gchar* guids_resolve_guid_to_str(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(e_guid_t *g1, e_guid_t *g2); + #endif /* __GUID_UTILS_H__ */ -- 2.11.4.GIT