aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-09 01:28:52 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-09 01:36:19 +0200
commitf57cc7923db6698fb7bb7a906da52cf3b952a15c (patch)
treef8845fbe3002b3fb181a95d9e3c3a3ab5190ce78
parent1ba6db50b6004417108aeb451f07cabb9299c841 (diff)
downloadxK-f57cc7923db6698fb7bb7a906da52cf3b952a15c.tar.gz
xK-f57cc7923db6698fb7bb7a906da52cf3b952a15c.tar.xz
xK-f57cc7923db6698fb7bb7a906da52cf3b952a15c.zip
degesch: clean up irc_handle_irc_isupport()
-rw-r--r--degesch.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/degesch.c b/degesch.c
index fdfab28..556c149 100644
--- a/degesch.c
+++ b/degesch.c
@@ -5764,6 +5764,24 @@ unescape_isupport_value (const char *value, struct str *output)
}
static void
+dispatch_isupport (struct server *s, const char *name, char *value)
+{
+#define MATCH(from, to) if (!strcmp (name, (from))) { (to) (s, value); return; }
+
+ // TODO: also make use of TARGMAX to split client commands as necessary
+
+ MATCH ("PREFIX", irc_handle_isupport_prefix);
+ MATCH ("CASEMAPPING", irc_handle_isupport_casemapping);
+ MATCH ("CHANTYPES", irc_handle_isupport_chantypes);
+ MATCH ("IDCHAN", irc_handle_isupport_idchan);
+ MATCH ("STATUSMSG", irc_handle_isupport_statusmsg);
+ MATCH ("CHANMODES", irc_handle_isupport_chanmodes);
+ MATCH ("MODES", irc_handle_isupport_modes);
+
+#undef MATCH
+}
+
+static void
irc_handle_rpl_isupport (struct server *s, const struct irc_message *msg)
{
if (msg->params.len < 2)
@@ -5779,25 +5797,7 @@ irc_handle_rpl_isupport (struct server *s, const struct irc_message *msg)
struct str value_unescaped;
str_init (&value_unescaped);
unescape_isupport_value (value, &value_unescaped);
-
- if (!strcmp (param, "PREFIX"))
- irc_handle_isupport_prefix (s, value_unescaped.str);
- else if (!strcmp (param, "CASEMAPPING"))
- irc_handle_isupport_casemapping (s, value_unescaped.str);
- else if (!strcmp (param, "CHANTYPES"))
- irc_handle_isupport_chantypes (s, value_unescaped.str);
- else if (!strcmp (param, "IDCHAN"))
- irc_handle_isupport_idchan (s, value_unescaped.str);
- else if (!strcmp (param, "STATUSMSG"))
- 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 TARGMAX and make use of it
- // to split client commands as necessary
-
+ dispatch_isupport (s, param, value_unescaped.str);
str_free (&value_unescaped);
}
}