1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 23:43:13 +02:00

Made set::modes-on-join work with extcmodes

This commit is contained in:
codemastr
2004-03-10 03:49:04 +00:00
parent 6717b75911
commit 2f64d946b4
4 changed files with 119 additions and 16 deletions
+4
View File
@@ -3022,3 +3022,7 @@ seen. gmtime warning still there
- spamfilter.conf: added soex trojan. Sig provided by Jay.
- Fixed a spamfilter memory leak
- Added '__' -> '_' decoding for spamfilter reason field.
- Made it so set::modes-on-join correctly works with extcmodes. Note: to
correctly work with modes created by modules, the module _must_ call CmodeAdd
from Mod_Test (#0001624) reported by thunderbirdjl
+5 -1
View File
@@ -52,8 +52,12 @@ enum UHAllowed { UHALLOW_ALWAYS, UHALLOW_NOCHANS, UHALLOW_REJOIN, UHALLOW_NEVER
struct ChMode {
long mode;
#ifdef EXTCMODE
long extmodes;
char *extparams[EXTCMODETABLESZ];
#endif
#ifdef NEWCHFLOODPROT
ChanFloodProt floodprot;
ChanFloodProt floodprot;
#else
unsigned short msgs;
unsigned short per;
+21 -1
View File
@@ -3678,8 +3678,28 @@ void join_channel(aChannel *chptr, aClient *cptr, aClient *sptr, int flags)
sptr->name, chptr->chname, chptr->topic_nick,
chptr->topic_time);
}
if (chptr->users == 1 && MODES_ON_JOIN)
if (chptr->users == 1 && (MODES_ON_JOIN
#ifdef EXTCMODE
|| iConf.modes_on_join.extmodes)
#endif
)
{
#ifdef EXTCMODE
int i;
chptr->mode.extmode = iConf.modes_on_join.extmodes;
/* Param fun */
for (i = 0; i <= Channelmode_highest; i++)
{
if (!Channelmode_Table[i].flag || !Channelmode_Table[i].paracount)
continue;
if (chptr->mode.extmode & Channelmode_Table[i].mode)
{
CmodeParam *p;
p = Channelmode_Table[i].put_param(NULL, iConf.modes_on_join.extparams[i]);
AddListItem(p, chptr->mode.extmodeparam);
}
}
#endif
chptr->mode.mode = MODES_ON_JOIN;
#ifdef NEWCHFLOODPROT
if (iConf.modes_on_join.floodprot.per)
+89 -14
View File
@@ -614,9 +614,16 @@ long config_checkval(char *orig, unsigned short flags) {
void set_channelmodes(char *modes, struct ChMode *store, int warn)
{
aCtab *tab;
char *param = strchr(modes, ' ');
if (param)
param++;
char *params = strchr(modes, ' ');
char *parambuf = NULL;
char *param = NULL;
if (params)
{
params++;
parambuf = MyMalloc(strlen(params)+1);
strcpy(parambuf, params);
param = strtok(parambuf, " ");
}
for (; *modes && *modes != ' '; modes++)
{
@@ -636,13 +643,18 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn)
case 'f':
{
#ifdef NEWCHFLOODPROT
char *myparam = param;
/* TODO */
ChanFloodProt newf;
memset(&newf, 0, sizeof(newf));
if (!param)
if (!myparam)
break;
if (param[0] != '[')
/* Go to next parameter */
param = strtok(NULL, " ");
if (myparam[0] != '[')
{
if (warn)
config_status("set::modes-on-join: please use the new +f format: '10:5' becomes '[10t]:5' "
@@ -655,7 +667,7 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn)
unsigned char r;
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
strlcpy(xbuf, param, sizeof(xbuf));
strlcpy(xbuf, myparam, sizeof(xbuf));
p2 = strchr(xbuf+1, ']');
if (!p2)
break;
@@ -776,15 +788,19 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn)
break;
}
#else
char *myparam = param;
char kmode = 0;
char *xp;
int msgs=0, per=0;
int hascolon = 0;
if (!param)
if (!myparam)
break;
if (*param == '*')
/* Go to next parameter */
param = strtok(NULL, " ");
if (*myparam == '*')
kmode = 1;
for (xp = param; *xp; xp++)
for (xp = myparam; *xp; xp++)
{
if (*xp == ':')
{
@@ -793,14 +809,14 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn)
}
if (((*xp < '0') || (*xp > '9')) && *xp != '*')
break;
if (*xp == '*' && *param != '*')
if (*xp == '*' && *myparam != '*')
break;
}
if (hascolon != 1)
break;
xp = strchr(param, ':');
xp = strchr(myparam, ':');
*xp = 0;
msgs = atoi((*param == '*') ? (param+1) : param);
msgs = atoi((*myparam == '*') ? (myparam+1) : myparam);
xp++;
per = atoi(xp);
xp--;
@@ -818,15 +834,47 @@ void set_channelmodes(char *modes, struct ChMode *store, int warn)
for (tab = &cFlagTab[0]; tab->mode; tab++)
{
if (tab->flag == *modes)
{
store->mode |= tab->mode;
break;
}
}
#ifdef EXTCMODE
/* Try extcmodes */
if (!tab->mode)
{
int i;
for (i=0; i <= Channelmode_highest; i++)
{
if (!(Channelmode_Table[i].flag))
continue;
if (*modes == Channelmode_Table[i].flag)
{
if (Channelmode_Table[i].paracount)
{
if (!param)
break;
store->extparams[i] = strdup(Channelmode_Table[i].conv_param(param));
/* Get next parameter */
param = strtok(NULL, " ");
}
store->extmodes |= Channelmode_Table[i].mode;
break;
}
}
}
#endif
}
}
if (parambuf)
free(parambuf);
}
void chmode_str(struct ChMode modes, char *mbuf, char *pbuf)
{
aCtab *tab;
int i;
*pbuf = 0;
*mbuf++ = '+';
for (tab = &cFlagTab[0]; tab->mode; tab++)
{
@@ -836,17 +884,36 @@ void chmode_str(struct ChMode modes, char *mbuf, char *pbuf)
*mbuf++ = tab->flag;
}
}
#ifdef EXTCMODE
for (i=0; i <= Channelmode_highest; i++)
{
if (!(Channelmode_Table[i].flag))
continue;
if (modes.extmodes & Channelmode_Table[i].mode)
*mbuf++ = Channelmode_Table[i].flag;
if (Channelmode_Table[i].paracount)
{
strcat(pbuf, modes.extparams[i]);
strcat(pbuf, " ");
}
}
#endif
#ifdef NEWCHFLOODPROT
if (modes.floodprot.per)
{
*mbuf++ = 'f';
sprintf(pbuf, "%s", channel_modef_string(&modes.floodprot));
strcat(pbuf, channel_modef_string(&modes.floodprot));
}
#else
if (modes.per)
{
*mbuf++ = 'f';
sprintf(pbuf, "%s%d:%d", modes.kmode ? "*" : "", modes.msgs, modes.per);
if (modes.kmode)
strcat(pbuf, "*");
strcat(pbuf, my_itoa(modes.msgs));
strcat(pbuf, ":");
strcat(pbuf, my_itoa(modes.per));
}
#endif
*mbuf++=0;
@@ -1593,6 +1660,7 @@ void config_rehash()
ListStruct *next, *next2;
aTKline *tk, *tk_next;
SpamExcept *spamex_ptr;
int i;
USE_BAN_VERSION = 0;
/* clean out stuff that we don't use */
@@ -1906,6 +1974,13 @@ void config_rehash()
ircfree(of_ptr->topic);
MyFree(of_ptr);
}
#ifdef EXTCMODE
for (i = 0; i < EXTCMODETABLESZ; i++)
{
if (iConf.modes_on_join.extparams[i])
free(iConf.modes_on_join.extparams[i]);
}
#endif
conf_offchans = NULL;
}