diff options
author | Gregor Beck <gbeck@sernet.de> | 2012-10-02 10:22:49 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-07-01 14:55:38 +0000 |
commit | fa2c41fc5871da0789b833dd1755c2cc4ff7b2b8 (patch) | |
tree | 31a3f551a26e72cadd6abe5ac6f3ba085d568af4 | |
parent | 7ee967c2b2dc5137b076373e36e0b21e1ad41dba (diff) | |
download | wireshark-fa2c41fc5871da0789b833dd1755c2cc4ff7b2b8.tar.gz |
add function guid_cmp() to compare guids
Change-Id: I6e34bcfb2205c1647e82dd396a13b0957532c4ae
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-on: https://code.wireshark.org/review/9438
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/guid-utils.c | 16 | ||||
-rw-r--r-- | epan/guid-utils.h | 2 |
2 files changed, 18 insertions, 0 deletions
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__ */ |