summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-09-07 18:55:57 +0200
committerJeremy Allison <jra@samba.org>2019-09-17 22:49:36 +0000
commitd9ce9c42cb6abd3263d639d6474a92b85776ba8d (patch)
tree4931048162dc77b762655124c3b8413df98fa77a /lib/util
parentba1234d877b3364be3b2f6793e3a6fe6c238da0f (diff)
downloadsamba-d9ce9c42cb6abd3263d639d6474a92b85776ba8d.tar.gz
lib: Add server_id_cmp()
Will be used later for sorting the share mode array Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/server_id.c17
-rw-r--r--lib/util/server_id.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index 2904e803196..ca998116bf4 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -30,6 +30,23 @@ bool server_id_same_process(const struct server_id *p1,
return ((p1->pid == p2->pid) && (p1->vnn == p2->vnn));
}
+int server_id_cmp(const struct server_id *p1, const struct server_id *p2)
+{
+ if (p1->vnn != p2->vnn) {
+ return (p1->vnn < p2->vnn) ? -1 : 1;
+ }
+ if (p1->pid != p2->pid) {
+ return (p1->pid < p2->pid) ? -1 : 1;
+ }
+ if (p1->task_id != p2->task_id) {
+ return (p1->task_id < p2->task_id) ? -1 : 1;
+ }
+ if (p1->unique_id != p2->unique_id) {
+ return (p1->unique_id < p2->unique_id) ? -1 : 1;
+ }
+ return 0;
+}
+
bool server_id_equal(const struct server_id *p1, const struct server_id *p2)
{
if (!server_id_same_process(p1, p2)) {
diff --git a/lib/util/server_id.h b/lib/util/server_id.h
index 6dda86ced73..5b723d5cda4 100644
--- a/lib/util/server_id.h
+++ b/lib/util/server_id.h
@@ -28,6 +28,7 @@ struct server_id_buf { char buf[48]; }; /* probably a bit too large ... */
bool server_id_same_process(const struct server_id *p1,
const struct server_id *p2);
+int server_id_cmp(const struct server_id *p1, const struct server_id *p2);
bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen);