]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc.c
New function IRC_CheckListTooBig() to check size of list replies
[ngircd-alex.git] / src / ngircd / irc.c
index 7a871379a422543c416a111e6d2eeaafdd661dc5..10e3e45656bdb1cc996ef0d92ad2c0a1cd8fab2f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2004 Alexander Barton <alex@barton.de>
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -45,6 +45,35 @@ static bool Send_Message_Mask PARAMS((CLIENT *from, char *command,
                                      bool SendErrors));
 
 
+/**
+ * Check if a list limit is reached and inform client accordingly.
+ *
+ * @param From The client.
+ * @param Count Reply item count.
+ * @param Limit Reply limit.
+ * @param Name Name of the list.
+ * @return true if list limit has been reached; false otherwise.
+ */
+GLOBAL bool
+IRC_CheckListTooBig(CLIENT *From, const int Count, const int Limit,
+                   const char *Name)
+{
+       assert(From != NULL);
+       assert(Count >= 0);
+       assert(Limit > 0);
+       assert(Name != NULL);
+
+       if (Count < Limit)
+               return false;
+
+       (void)IRC_WriteStrClient(From,
+                                "NOTICE %s :%s list limit (%d) reached!",
+                                Client_ID(From), Name, Limit);
+       IRC_SetPenalty(From, 2);
+       return true;
+}
+
+
 GLOBAL bool
 IRC_ERROR( CLIENT *Client, REQUEST *Req )
 {