From 178c1b072ad41f7d67ee14be924c45c7d23f5fc5 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch 
Date: Wed, 17 Jun 2015 21:19:09 +0200
Subject: degesch: parse MODES from RPL_ISUPPORT
---
 degesch.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/degesch.c b/degesch.c
index 6f4a536..4e47a1d 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1073,6 +1073,8 @@ struct server
 	char *irc_chanuser_prefixes;        ///< Channel user prefixes
 	char *irc_chanuser_modes;           ///< Channel user modes
 
+	unsigned irc_max_modes;             ///< Max parametrized modes per command
+
 	// Events:
 
 	struct poller_timer ping_tmr;       ///< We should send a ping
@@ -1111,6 +1113,8 @@ server_init (struct server *self, struct poller *poller)
 	self->irc_chanuser_prefixes = xstrdup ("@+");
 	self->irc_chanuser_modes    = xstrdup ("ov");
 
+	self->irc_max_modes = 3;
+
 	str_map_init (&self->irc_users);
 	self->irc_users.key_xfrm = irc_strxfrm;
 	str_map_init (&self->irc_channels);
@@ -5127,6 +5131,16 @@ irc_handle_isupport_chanmodes (struct server *s, char *value)
 	str_vector_free (&v);
 }
 
+static void
+irc_handle_isupport_modes (struct server *s, char *value)
+{
+	unsigned long modes;
+	if (!*value)
+		s->irc_max_modes = UINT_MAX;
+	else if (xstrtoul (&modes, value, 10) && modes && modes <= UINT_MAX)
+		s->irc_max_modes = modes;
+}
+
 static void
 unescape_isupport_value (const char *value, struct str *output)
 {
@@ -5175,8 +5189,10 @@ irc_handle_rpl_isupport (struct server *s, const struct irc_message *msg)
 			irc_handle_isupport_statusmsg   (s, value_unescaped.str);
 		else if (!strcmp (param, "CHANMODES"))
 			irc_handle_isupport_chanmodes   (s, value_unescaped.str);
+		else if (!strcmp (param, "MODES"))
+			irc_handle_isupport_modes       (s, value_unescaped.str);
 
-		// TODO: also parse MODES, TARGMAX and make use of them
+		// TODO: also parse TARGMAX and make use of it
 		//   to split client commands as necessary
 
 		str_free (&value_unescaped);
-- 
cgit v1.2.3-70-g09d2