Stop using chm_nosuch as a sentinel value (#53)

Remove chmode compat modules

This removes the need for chm_nosuch as well. Unknown mode detection happens in mode parsing now.
This commit is contained in:
Eric Mertens 2020-11-08 09:50:17 -08:00 committed by GitHub
parent 4a8bd0b2fb
commit d295a3986d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 2 additions and 168 deletions

View file

@ -9,9 +9,6 @@
/* Extensions */
#loadmodule "extensions/chm_nonotice";
#loadmodule "extensions/chm_operonly_compat";
#loadmodule "extensions/chm_quietunreg_compat";
#loadmodule "extensions/chm_sslonly_compat";
#loadmodule "extensions/chm_operpeace";
#loadmodule "extensions/createauthonly";
#loadmodule "extensions/extb_account";

View file

@ -47,9 +47,6 @@
* Channel mode +-T (blocks notices) -- chm_nonotice
* Channel mode +-O (oper only) -- chm_operonly
* Channel mode +-S (ssl only) -- chm_sslonly
* Emulates channel mode +-O (oper only) (+-iI $o) -- chm_operonly_compat
* Emulates channel mode +-R (quiet unreg) (+-q $~a) -- chm_quietunreg_compat
* Emulates channel mode +-S (ssl only) (+-b $~z) -- chm_sslonly_compat
* Channel mode +-M (disallow KICK on IRC ops) -- chm_operpeace
* Restrict channel creation to logged in users -- createauthonly
* Account bans (+b $a[:mask]) -- extb_account
@ -84,9 +81,6 @@
#loadmodule "extensions/chm_nonotice";
#loadmodule "extensions/chm_operonly";
#loadmodule "extensions/chm_sslonly";
#loadmodule "extensions/chm_operonly_compat";
#loadmodule "extensions/chm_quietunreg_compat";
#loadmodule "extensions/chm_sslonly_compat";
#loadmodule "extensions/chm_operpeace";
#loadmodule "extensions/createauthonly";
#loadmodule "extensions/extb_account";

View file

@ -12,13 +12,10 @@ extension_LTLIBRARIES = \
chantype_dummy.la \
chm_adminonly.la \
chm_operonly.la \
chm_operonly_compat.la \
chm_insecure.la \
chm_nonotice.la \
chm_operpeace.la \
chm_quietunreg_compat.la \
chm_sslonly.la \
chm_sslonly_compat.la \
createauthonly.la \
createoperonly.la \
extb_account.la \

View file

@ -1,46 +0,0 @@
/*
* Treat cmode +-O as +-iI $o.
*/
#include "stdinc.h"
#include "modules.h"
#include "client.h"
#include "hook.h"
#include "ircd.h"
#include "chmode.h"
static const char chm_operonly_compat[] =
"Adds an emulated channel mode +O which is converted into mode +i and +I $o";
static int _modinit(void);
static void _moddeinit(void);
static ChannelModeFunc chm_operonly;
DECLARE_MODULE_AV2(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_operonly_compat);
static int
_modinit(void)
{
chmode_table['O'] = (struct ChannelMode){chm_operonly, 0, 0};
return 0;
}
static void
_moddeinit(void)
{
chmode_table['O'] = (struct ChannelMode){chm_nosuch, 0, 0};
}
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)
{
if (MyClient(source_p)) {
chm_simple(source_p, chptr, alevel, NULL,
errors, dir, 'i', MODE_INVITEONLY);
chm_ban(source_p, chptr, alevel, "$o",
errors, dir, 'I', CHFL_INVEX);
} else
chm_nosuch(source_p, chptr, alevel, NULL,
errors, dir, c, mode_type);
}

View file

@ -1,45 +0,0 @@
/*
* Treat cmode +-R as +-q $~a.
* -- jilles
*/
#include "stdinc.h"
#include "modules.h"
#include "client.h"
#include "hook.h"
#include "ircd.h"
#include "chmode.h"
static const char chm_quietunreg_compat_desc[] =
"Adds an emulated channel mode +R which is converted into mode +q $~a";
static int _modinit(void);
static void _moddeinit(void);
static ChannelModeFunc chm_quietunreg;
DECLARE_MODULE_AV2(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_quietunreg_compat_desc);
static int
_modinit(void)
{
chmode_table['R'] = (struct ChannelMode){ chm_quietunreg, 0, 0 };
return 0;
}
static void
_moddeinit(void)
{
chmode_table['R'] = (struct ChannelMode){ chm_nosuch, 0, 0 };
}
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)
{
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, "$~a",
errors, dir, 'q', CHFL_QUIET);
else
chm_nosuch(source_p, chptr, alevel, NULL,
errors, dir, c, mode_type);
}

View file

@ -1,44 +0,0 @@
/*
* Treat cmode +-S as +-b $~z.
*/
#include "stdinc.h"
#include "modules.h"
#include "client.h"
#include "hook.h"
#include "ircd.h"
#include "chmode.h"
static const char chm_sslonly_compat_desc[] =
"Adds an emulated channel mode +S which is converted into mode +b $~z";
static int _modinit(void);
static void _moddeinit(void);
static ChannelModeFunc chm_sslonly;
DECLARE_MODULE_AV2(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_sslonly_compat_desc);
static int
_modinit(void)
{
chmode_table['S'] = (struct ChannelMode){ chm_sslonly, 0, 0 };
return 0;
}
static void
_moddeinit(void)
{
chmode_table['S'] = (struct ChannelMode){ chm_nosuch, 0, 0 };
}
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)
{
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, "$~z",
errors, dir, 'b', CHFL_BAN);
else
chm_nosuch(source_p, chptr, alevel, NULL,
errors, dir, c, mode_type);
}

View file

@ -34,7 +34,6 @@
extern int chmode_flags[256];
extern ChannelModeFunc chm_nosuch;
extern ChannelModeFunc chm_orphaned;
extern ChannelModeFunc chm_simple;
extern ChannelModeFunc chm_ban;

View file

@ -118,7 +118,6 @@ construct_cflags_strings(void)
/* Should we leave orphaned check here? -- dwr */
if (chmode_table[i].set_func != NULL &&
chmode_table[i].set_func != chm_nosuch &&
chmode_table[i].set_func != chm_orphaned)
{
*ptr2++ = (char) i;
@ -157,11 +156,10 @@ cflag_add(char c_, ChannelModeFunc function)
int c = (unsigned char)c_;
if (chmode_table[c].set_func != NULL &&
chmode_table[c].set_func != chm_nosuch &&
chmode_table[c].set_func != chm_orphaned)
return 0;
if (chmode_table[c].set_func == NULL || chmode_table[c].set_func == chm_nosuch)
if (chmode_table[c].set_func == NULL)
chmode_table[c].mode_type = find_cflag_slot();
if (chmode_table[c].mode_type == 0)
return 0;
@ -575,20 +573,6 @@ fix_key_remote(char *arg)
return arg;
}
/* chm_*()
*
* The handlers for each specific mode.
*/
void
chm_nosuch(struct Client *source_p, struct Channel *chptr,
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
{
if(*errors & SM_ERR_UNKNOWN)
return;
*errors |= SM_ERR_UNKNOWN;
sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c);
}
void
chm_simple(struct Client *source_p, struct Channel *chptr,
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
@ -1434,7 +1418,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
bool use_arg = dir == MODE_ADD ? cm->flags & CHM_ARG_SET :
dir == MODE_DEL ? cm->flags & CHM_ARG_DEL :
false;
if (cm->set_func == NULL || cm->set_func == chm_nosuch)
if (cm->set_func == NULL)
{
sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c);
return;
@ -1513,8 +1497,6 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
for (ms = modesets; ms < mend; ms++)
{
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);
}