Consolidate duplicate channel mode flags tables to one.
This commit is contained in:
parent
34c10ff5f5
commit
7d1f9131fb
4 changed files with 24 additions and 68 deletions
|
@ -102,6 +102,12 @@ struct Ban
|
||||||
dlink_node node;
|
dlink_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mode_letter
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
char letter;
|
||||||
|
};
|
||||||
|
|
||||||
struct ChModeChange
|
struct ChModeChange
|
||||||
{
|
{
|
||||||
char letter;
|
char letter;
|
||||||
|
@ -254,6 +260,8 @@ extern void send_cap_mode_changes(struct Client *client_p, struct Client *source
|
||||||
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
|
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
|
||||||
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
|
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
|
||||||
|
|
||||||
|
extern const struct mode_letter chmode_flags[];
|
||||||
|
|
||||||
extern struct ChannelMode chmode_table[256];
|
extern struct ChannelMode chmode_table[256];
|
||||||
|
|
||||||
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
|
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
|
||||||
|
|
|
@ -584,30 +584,6 @@ check_channel_name_loc(struct Client *source_p, const char *name)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mode_letter
|
|
||||||
{
|
|
||||||
int mode;
|
|
||||||
char letter;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct mode_letter flags[] = {
|
|
||||||
{MODE_NOPRIVMSGS, 'n'},
|
|
||||||
{MODE_TOPICLIMIT, 't'},
|
|
||||||
{MODE_SECRET, 's'},
|
|
||||||
{MODE_MODERATED, 'm'},
|
|
||||||
{MODE_INVITEONLY, 'i'},
|
|
||||||
{MODE_PRIVATE, 'p'},
|
|
||||||
{MODE_REGONLY, 'r'},
|
|
||||||
{MODE_EXLIMIT, 'L'},
|
|
||||||
{MODE_PERMANENT, 'P'},
|
|
||||||
{MODE_NOCOLOR, 'c'},
|
|
||||||
{MODE_FREEINVITE, 'g'},
|
|
||||||
{MODE_OPMODERATE, 'z'},
|
|
||||||
{MODE_FREETARGET, 'F'},
|
|
||||||
{MODE_DISFORWARD, 'Q'},
|
|
||||||
{0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
||||||
{
|
{
|
||||||
|
@ -617,30 +593,30 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ok, first get a list of modes we need to add */
|
/* ok, first get a list of modes we need to add */
|
||||||
for(i = 0; flags[i].letter; i++)
|
for(i = 0; chmode_flags[i].letter; i++)
|
||||||
{
|
{
|
||||||
if((mode->mode & flags[i].mode) && !(oldmode->mode & flags[i].mode))
|
if((mode->mode & chmode_flags[i].mode) && !(oldmode->mode & chmode_flags[i].mode))
|
||||||
{
|
{
|
||||||
if(dir != MODE_ADD)
|
if(dir != MODE_ADD)
|
||||||
{
|
{
|
||||||
*mbuf++ = '+';
|
*mbuf++ = '+';
|
||||||
dir = MODE_ADD;
|
dir = MODE_ADD;
|
||||||
}
|
}
|
||||||
*mbuf++ = flags[i].letter;
|
*mbuf++ = chmode_flags[i].letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now the ones we need to remove. */
|
/* now the ones we need to remove. */
|
||||||
for(i = 0; flags[i].letter; i++)
|
for(i = 0; chmode_flags[i].letter; i++)
|
||||||
{
|
{
|
||||||
if((oldmode->mode & flags[i].mode) && !(mode->mode & flags[i].mode))
|
if((oldmode->mode & chmode_flags[i].mode) && !(mode->mode & chmode_flags[i].mode))
|
||||||
{
|
{
|
||||||
if(dir != MODE_DEL)
|
if(dir != MODE_DEL)
|
||||||
{
|
{
|
||||||
*mbuf++ = '-';
|
*mbuf++ = '-';
|
||||||
dir = MODE_DEL;
|
dir = MODE_DEL;
|
||||||
}
|
}
|
||||||
*mbuf++ = flags[i].letter;
|
*mbuf++ = chmode_flags[i].letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -603,30 +603,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mode_letter
|
|
||||||
{
|
|
||||||
int mode;
|
|
||||||
char letter;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct mode_letter flags[] = {
|
|
||||||
{MODE_NOPRIVMSGS, 'n'},
|
|
||||||
{MODE_TOPICLIMIT, 't'},
|
|
||||||
{MODE_SECRET, 's'},
|
|
||||||
{MODE_MODERATED, 'm'},
|
|
||||||
{MODE_INVITEONLY, 'i'},
|
|
||||||
{MODE_PRIVATE, 'p'},
|
|
||||||
{MODE_REGONLY, 'r'},
|
|
||||||
{MODE_EXLIMIT, 'L'},
|
|
||||||
{MODE_PERMANENT, 'P'},
|
|
||||||
{MODE_NOCOLOR, 'c'},
|
|
||||||
{MODE_FREEINVITE, 'g'},
|
|
||||||
{MODE_OPMODERATE, 'z'},
|
|
||||||
{MODE_FREETARGET, 'F'},
|
|
||||||
{MODE_DISFORWARD, 'Q'},
|
|
||||||
{0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
||||||
{
|
{
|
||||||
|
@ -636,30 +612,30 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ok, first get a list of modes we need to add */
|
/* ok, first get a list of modes we need to add */
|
||||||
for (i = 0; flags[i].letter; i++)
|
for (i = 0; chmode_flags[i].letter; i++)
|
||||||
{
|
{
|
||||||
if((mode->mode & flags[i].mode) && !(oldmode->mode & flags[i].mode))
|
if((mode->mode & chmode_flags[i].mode) && !(oldmode->mode & chmode_flags[i].mode))
|
||||||
{
|
{
|
||||||
if(dir != MODE_ADD)
|
if(dir != MODE_ADD)
|
||||||
{
|
{
|
||||||
*mbuf++ = '+';
|
*mbuf++ = '+';
|
||||||
dir = MODE_ADD;
|
dir = MODE_ADD;
|
||||||
}
|
}
|
||||||
*mbuf++ = flags[i].letter;
|
*mbuf++ = chmode_flags[i].letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now the ones we need to remove. */
|
/* now the ones we need to remove. */
|
||||||
for (i = 0; flags[i].letter; i++)
|
for (i = 0; chmode_flags[i].letter; i++)
|
||||||
{
|
{
|
||||||
if((oldmode->mode & flags[i].mode) && !(mode->mode & flags[i].mode))
|
if((oldmode->mode & chmode_flags[i].mode) && !(mode->mode & chmode_flags[i].mode))
|
||||||
{
|
{
|
||||||
if(dir != MODE_DEL)
|
if(dir != MODE_DEL)
|
||||||
{
|
{
|
||||||
*mbuf++ = '-';
|
*mbuf++ = '-';
|
||||||
dir = MODE_DEL;
|
dir = MODE_DEL;
|
||||||
}
|
}
|
||||||
*mbuf++ = flags[i].letter;
|
*mbuf++ = chmode_flags[i].letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1084,11 +1084,7 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct mode_letter
|
const struct mode_letter chmode_flags[] =
|
||||||
{
|
|
||||||
const unsigned int mode;
|
|
||||||
const unsigned char letter;
|
|
||||||
} flags[] =
|
|
||||||
{
|
{
|
||||||
{MODE_INVITEONLY, 'i'},
|
{MODE_INVITEONLY, 'i'},
|
||||||
{MODE_MODERATED, 'm'},
|
{MODE_MODERATED, 'm'},
|
||||||
|
@ -1129,9 +1125,9 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
|
||||||
*mbuf++ = '+';
|
*mbuf++ = '+';
|
||||||
*pbuf = '\0';
|
*pbuf = '\0';
|
||||||
|
|
||||||
for (i = 0; flags[i].mode; ++i)
|
for (i = 0; chmode_flags[i].mode; ++i)
|
||||||
if(chptr->mode.mode & flags[i].mode)
|
if(chptr->mode.mode & chmode_flags[i].mode)
|
||||||
*mbuf++ = flags[i].letter;
|
*mbuf++ = chmode_flags[i].letter;
|
||||||
|
|
||||||
if(chptr->mode.limit)
|
if(chptr->mode.limit)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue