]> arthur.barton.de Git - ngircd-alex.git/commitdiff
New function Lists_CheckReason() to get reason of list entries
authorAlexander Barton <alex@barton.de>
Sun, 22 Jan 2012 17:11:24 +0000 (18:11 +0100)
committerAlexander Barton <alex@barton.de>
Sun, 22 Jan 2012 17:11:24 +0000 (18:11 +0100)
src/ngircd/lists.c
src/ngircd/lists.h

index c082f1c4c0b767713608355004cb6b41ae3fa14a..4f57ca73521f6b65f568d0aefa9c60b844a685c6 100644 (file)
@@ -320,7 +320,20 @@ Lists_MakeMask(const char *Pattern)
  * @return true if client is listed, false if not.
  */
 bool
-Lists_Check( struct list_head *h, CLIENT *Client)
+Lists_Check(struct list_head *h, CLIENT *Client)
+{
+       return Lists_CheckReason(h, Client) != NULL;
+}
+
+/**
+ * Check if a client is listed in a list and return the "reason".
+ *
+ * @param h List head.
+ * @param Client Client to check.
+ * @return true if client is listed, false if not.
+ */
+char *
+Lists_CheckReason(struct list_head *h, CLIENT *Client)
 {
        struct list_elem *e, *last, *next;
 
@@ -338,13 +351,13 @@ Lists_Check( struct list_head *h, CLIENT *Client)
                                         e->mask);
                                Lists_Unlink(h, last, e);
                        }
-                       return true;
+                       return e->reason ? e->reason : "";
                }
                last = e;
                e = next;
        }
 
-       return false;
+       return NULL;
 }
 
 /**
index cb2e2c1a188a5dd81ec2aa7f8cd50b51aeba6f82..24504dfab9d11860a2c8459b12e7ff5e22a211b0 100644 (file)
@@ -30,6 +30,7 @@ GLOBAL struct list_elem *Lists_GetFirst PARAMS((const struct list_head *));
 GLOBAL struct list_elem *Lists_GetNext PARAMS((const struct list_elem *));
 
 GLOBAL bool Lists_Check PARAMS((struct list_head *head, CLIENT *client));
+GLOBAL char *Lists_CheckReason PARAMS((struct list_head *head, CLIENT *client));
 GLOBAL struct list_elem *Lists_CheckDupeMask PARAMS((const struct list_head *head,
                                        const char *mask));