From 92c6e47b4a6e1af25485a9494ffaee0015b120c8 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sat, 7 Nov 2020 16:45:12 -0800 Subject: [PATCH] Clean up duplication in ChannelModeFunc prototypes (#52) --- extensions/chm_operonly_compat.c | 3 +-- extensions/chm_quietunreg_compat.c | 3 +-- extensions/chm_sslonly_compat.c | 3 +-- include/channel.h | 4 ++-- include/chmode.h | 36 ++++++++++-------------------- ircd/chmode.c | 2 +- 6 files changed, 18 insertions(+), 33 deletions(-) diff --git a/extensions/chm_operonly_compat.c b/extensions/chm_operonly_compat.c index 3d88a203..719e66ef 100644 --- a/extensions/chm_operonly_compat.c +++ b/extensions/chm_operonly_compat.c @@ -14,8 +14,7 @@ static const char chm_operonly_compat[] = static int _modinit(void); static void _moddeinit(void); -static void chm_operonly(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); +static ChannelModeFunc chm_operonly; DECLARE_MODULE_AV2(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_operonly_compat); diff --git a/extensions/chm_quietunreg_compat.c b/extensions/chm_quietunreg_compat.c index 1e176c09..fd08e570 100644 --- a/extensions/chm_quietunreg_compat.c +++ b/extensions/chm_quietunreg_compat.c @@ -15,8 +15,7 @@ static const char chm_quietunreg_compat_desc[] = static int _modinit(void); static void _moddeinit(void); -static void chm_quietunreg(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); +static ChannelModeFunc chm_quietunreg; DECLARE_MODULE_AV2(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_quietunreg_compat_desc); diff --git a/extensions/chm_sslonly_compat.c b/extensions/chm_sslonly_compat.c index 3dca2834..be9d178b 100644 --- a/extensions/chm_sslonly_compat.c +++ b/extensions/chm_sslonly_compat.c @@ -14,8 +14,7 @@ static const char chm_sslonly_compat_desc[] = static int _modinit(void); static void _moddeinit(void); -static void chm_sslonly(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); +static ChannelModeFunc chm_sslonly; DECLARE_MODULE_AV2(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_sslonly_compat_desc); diff --git a/include/channel.h b/include/channel.h index bb1da83f..e666279a 100644 --- a/include/channel.h +++ b/include/channel.h @@ -121,7 +121,7 @@ struct ChModeChange int mems; }; -typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr, +typedef void ChannelModeFunc(struct Client *source_p, struct Channel *chptr, int alevel, const char *arg, int *errors, int dir, char c, long mode_type); enum chm_flags @@ -136,7 +136,7 @@ enum chm_flags struct ChannelMode { - ChannelModeFunc set_func; + ChannelModeFunc *set_func; long mode_type; enum chm_flags flags; }; diff --git a/include/chmode.h b/include/chmode.h index 850864a2..2ead3df9 100644 --- a/include/chmode.h +++ b/include/chmode.h @@ -34,30 +34,18 @@ extern int chmode_flags[256]; -extern void chm_nosuch(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_orphaned(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_simple(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_ban(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_hidden(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_staff(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_forward(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_throttle(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_key(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_limit(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_op(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); -extern void chm_voice(struct Client *source_p, struct Channel *chptr, - int alevel, const char *arg, int *errors, int dir, char c, long mode_type); +extern ChannelModeFunc chm_nosuch; +extern ChannelModeFunc chm_orphaned; +extern ChannelModeFunc chm_simple; +extern ChannelModeFunc chm_ban; +extern ChannelModeFunc chm_hidden; +extern ChannelModeFunc chm_staff; +extern ChannelModeFunc chm_forward; +extern ChannelModeFunc chm_throttle; +extern ChannelModeFunc chm_key; +extern ChannelModeFunc chm_limit; +extern ChannelModeFunc chm_op; +extern ChannelModeFunc chm_voice; extern unsigned int cflag_add(char c, ChannelModeFunc function); extern void cflag_orphan(char c); diff --git a/ircd/chmode.c b/ircd/chmode.c index 585c4363..8ed74ded 100644 --- a/ircd/chmode.c +++ b/ircd/chmode.c @@ -1512,7 +1512,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p, for (ms = modesets; ms < mend; ms++) { - ChannelModeFunc set_func = ms->cm->set_func; + ChannelModeFunc *set_func = ms->cm->set_func; if (set_func == NULL) set_func = chm_nosuch; set_func(fakesource_p, chptr, alevel, ms->arg, &errors, ms->dir, ms->mode, ms->cm->mode_type);