about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-01-06 20:05:07 +0100
committerAlexander Barton <alex@barton.de>2012-01-06 20:05:07 +0100
commitf8405b1a4f032a125372b03711f6bed1ecac2bd6 (patch)
tree4083dd986241ac28dca6843cf1803de6716bc64f /src
parentfdfc27265ef27e445de89217d08f9a57219355df (diff)
downloadngircd-f8405b1a4f032a125372b03711f6bed1ecac2bd6.tar.gz
ngircd-f8405b1a4f032a125372b03711f6bed1ecac2bd6.zip
New function IRC_CheckListTooBig() to check size of list replies
It the limit is reached, a NOTICE is sent to the client and list
processing should stop.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc.c31
-rw-r--r--src/ngircd/irc.h5
2 files changed, 34 insertions, 2 deletions
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
index 7a871379..10e3e456 100644
--- a/src/ngircd/irc.c
+++ b/src/ngircd/irc.c
@@ -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 )
 {
diff --git a/src/ngircd/irc.h b/src/ngircd/irc.h
index cdeb7458..c2f9b662 100644
--- a/src/ngircd/irc.h
+++ b/src/ngircd/irc.h
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2008 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
@@ -17,6 +17,9 @@
  * IRC commands (header)
  */
 
+GLOBAL bool IRC_CheckListTooBig PARAMS((CLIENT *From, const int Count,
+					const int Limit, const char *Name));
+
 GLOBAL bool IRC_ERROR PARAMS((CLIENT *Client, REQUEST *Req));
 GLOBAL bool IRC_KILL PARAMS((CLIENT *Client, REQUEST *Req));
 GLOBAL bool IRC_NOTICE PARAMS((CLIENT *Client, REQUEST *Req));