From f57cc7923db6698fb7bb7a906da52cf3b952a15c Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 9 Jul 2015 01:28:52 +0200 Subject: degesch: clean up irc_handle_irc_isupport() --- degesch.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/degesch.c b/degesch.c index fdfab28..556c149 100644 --- a/degesch.c +++ b/degesch.c @@ -5763,6 +5763,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) { @@ -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); } } -- cgit v1.2.3-70-g09d2