]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Add server_id_cmp()
authorVolker Lendecke <vl@samba.org>
Sat, 7 Sep 2019 16:55:57 +0000 (18:55 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 17 Sep 2019 22:49:36 +0000 (22:49 +0000)
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>
lib/util/server_id.c
lib/util/server_id.h

index 2904e80319684b2a70e40d0d9d77542333ec5239..ca998116bf40bc0da55da17e4921bb280a18068f 100644 (file)
@@ -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)) {
index 6dda86ced73a78cd9059fd1f5416809b957b18ef..5b723d5cda40d100a36b24fa76f7d548dc0ec58d 100644 (file)
@@ -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);