Skip to content

replace chm_staff and chm_hidden with cmode->priv and CHM_HIDDEN #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions extensions/chm_adminonly.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ mapi_hfn_list_av1 adminonly_hfnlist[] = {
{ NULL, NULL }
};

static unsigned int mymode;
static struct ChannelMode *mymode;

static int
_modinit(void)
{
mymode = cflag_add('A', chm_staff);
if (mymode == 0)
mymode = cflag_add('A', chm_simple);
if (mymode == NULL)
return -1;
else
mymode->priv = "oper:cmodes";

return 0;
}
Expand All @@ -47,7 +49,7 @@ h_can_join(void *data_)
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;

if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
if((chptr->mode.mode & mymode->mode_type) && !IsAdmin(source_p)) {
sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
data->approved = ERR_CUSTOM;
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/chm_insecure.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ mapi_hfn_list_av1 sslonly_hfnlist[] = {
{ NULL, NULL }
};

static unsigned int mymode;
static struct ChannelMode *mymode;

static int
_modinit(void)
{
mymode = cflag_add('U', chm_simple);
if (mymode == 0)
if (mymode == NULL)
return -1;

return 0;
Expand All @@ -49,7 +49,7 @@ h_can_join(void *data_)
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;

if(!(chptr->mode.mode & mymode) && !IsSecureClient(source_p)) {
if(!(chptr->mode.mode & mymode->mode_type) && !IsSecureClient(source_p)) {
/* XXX This is equal to ERR_THROTTLE */
sendto_one_numeric(source_p, 480, "%s :Cannot join channel (-U) - SSL/TLS required", chptr->chname);
data->approved = ERR_CUSTOM;
Expand Down
6 changes: 3 additions & 3 deletions extensions/chm_nonotice.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static const char chm_nonotice_desc[] =
"Adds channel mode +T which blocks notices to the channel.";

static unsigned int mode_nonotice;
static struct ChannelMode *mode_nonotice;

static void chm_nonotice_process(void *);

Expand All @@ -57,7 +57,7 @@ chm_nonotice_process(void *data_)
return;

/* block all notices except CTCPs; use chm_noctcp to block CTCPs. */
if (data->chptr->mode.mode & mode_nonotice && *data->text != '\001')
if (data->chptr->mode.mode & mode_nonotice->mode_type && *data->text != '\001')
{
sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOCHAN, form_str(ERR_CANNOTSENDTOCHAN), data->chptr->chname);
data->approved = ERR_CANNOTSENDTOCHAN;
Expand All @@ -69,7 +69,7 @@ static int
_modinit(void)
{
mode_nonotice = cflag_add('T', chm_simple);
if (mode_nonotice == 0)
if (mode_nonotice == NULL)
return -1;

return 0;
Expand Down
10 changes: 6 additions & 4 deletions extensions/chm_operonly.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ mapi_hfn_list_av1 operonly_hfnlist[] = {
{ NULL, NULL }
};

static unsigned int mymode;
static struct ChannelMode *mymode;

static int
_modinit(void)
{
mymode = cflag_add('O', chm_staff);
if (mymode == 0)
mymode = cflag_add('O', chm_simple);
if (mymode == NULL)
return -1;
else
mymode->priv = "oper:cmodes";

return 0;
}
Expand All @@ -48,7 +50,7 @@ h_can_join(void *data_)
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;

if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
if((chptr->mode.mode & mymode->mode_type) && !IsOper(source_p)) {
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
data->approved = ERR_CUSTOM;
}
Expand Down
13 changes: 9 additions & 4 deletions extensions/chm_operpeace.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ mapi_hfn_list_av1 chm_operpeace_hfnlist[] = {
{ NULL, NULL }
};

static unsigned int mymode;
static struct ChannelMode *mymode;

static int
_modinit(void)
{
mymode = cflag_add('M', chm_hidden);
if (mymode == 0)
mymode = cflag_add('M', chm_simple);
if (mymode == NULL)
return -1;
else
{
mymode->priv = "oper:cmodes";
mymode->flags |= CHM_HIDDEN;
}

return 0;
}
Expand All @@ -59,7 +64,7 @@ hdl_can_kick(void *data_)
if(IsOper(source_p))
return;

if((chptr->mode.mode & mymode) && HasPrivilege(who, "oper:receive_immunity"))
if((chptr->mode.mode & mymode->mode_type) && HasPrivilege(who, "oper:receive_immunity"))
{
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (which is +M)",
source_p->name, who->name, chptr->chname);
Expand Down
6 changes: 3 additions & 3 deletions extensions/chm_regmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static const char chm_regmsg_desc[] =
"Adds channel mode +R, which blocks messagess from unregistered users";

static unsigned int mode_regmsg;
static struct ChannelMode *mode_regmsg;

static void chm_regmsg_process(void *);

Expand All @@ -58,7 +58,7 @@ chm_regmsg_process(void *data_)
return;

/* mode is unset, accept */
if (!(data->chptr->mode.mode & mode_regmsg))
if (!(data->chptr->mode.mode & mode_regmsg->mode_type))
return;

/* user is identified, accept */
Expand All @@ -79,7 +79,7 @@ static int
_modinit(void)
{
mode_regmsg = cflag_add('R', chm_simple);
if (mode_regmsg == 0) {
if (mode_regmsg == NULL) {
ierror("chm_regmsg: unable to allocate cmode slot for +R, unloading module");
return -1;
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/chm_sslonly.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ mapi_hfn_list_av1 sslonly_hfnlist[] = {
{ NULL, NULL }
};

static unsigned int mymode;
static struct ChannelMode *mymode;

static int
_modinit(void)
{
mymode = cflag_add('S', chm_simple);
if (mymode == 0)
if (mymode == NULL)
return -1;

return 0;
Expand All @@ -47,7 +47,7 @@ h_can_join(void *data_)
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;

if((chptr->mode.mode & mymode) && !IsSecureClient(source_p)) {
if((chptr->mode.mode & mymode->mode_type) && !IsSecureClient(source_p)) {
/* XXX This is equal to ERR_THROTTLE */
sendto_one_numeric(source_p, 480, "%s :Cannot join channel (+S) - SSL/TLS required", chptr->chname);
data->approved = ERR_CUSTOM;
Expand Down
5 changes: 3 additions & 2 deletions extensions/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ enum filter_state {
static enum filter_state state = FILTER_EMPTY;
static char check_str[21] = "";

static unsigned filter_chmode, filter_umode;
static struct ChannelMode *filter_chmode;
static unsigned filter_umode;

mapi_hfn_list_av1 filter_hfnlist[] = {
{ "privmsg_user", filter_msg_user },
Expand Down Expand Up @@ -432,7 +433,7 @@ filter_msg_channel(void *data_)
if (IsOper(s)) {
return;
}
if (data->chptr->mode.mode & filter_chmode) {
if (data->chptr->mode.mode & filter_chmode->mode_type) {
return;
}
char *text = strcpy(clean_buffer, data->text);
Expand Down
2 changes: 2 additions & 0 deletions include/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ enum chm_flags
CHM_OPS_QUERY = 1 << 1,
CHM_ARG_SET = 1 << 2,
CHM_ARG_DEL = 1 << 3,
CHM_HIDDEN = 1 << 4,
CHM_ARGS = CHM_ARG_SET | CHM_ARG_DEL,
CHM_QUERYABLE = CHM_ARGS | CHM_CAN_QUERY,
};
Expand All @@ -140,6 +141,7 @@ struct ChannelMode
ChannelModeFunc *set_func;
long mode_type;
enum chm_flags flags;
const char *priv;
};

typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
Expand Down
4 changes: 1 addition & 3 deletions include/chmode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ extern int chmode_flags[256];
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 struct ChannelMode * cflag_add(char c, ChannelModeFunc function);
extern void cflag_orphan(char c);
extern void construct_cflags_strings(void);
extern char cflagsbuf[256];
Expand Down
2 changes: 1 addition & 1 deletion ircd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)

for (i = 0; i < 256; i++)
{
if(chmode_table[i].set_func == chm_hidden && (!HasPrivilege(client_p, "auspex:cmodes") || !IsClient(client_p)))
if(chmode_table[i].flags & CHM_HIDDEN && (!HasPrivilege(client_p, "auspex:cmodes") || !IsClient(client_p)))
continue;
if(chptr->mode.mode & chmode_flags[i])
*mbuf++ = i;
Expand Down
Loading