}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
}
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
}
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
}
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
}
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
}
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i != MAXCHANS; i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
BanItem b;
if ((!user) || (!dest) || (!chan))
return NULL;
- int l = strlen(dest);
+ unsigned int l = strlen(dest);
if (strchr(dest,'!')==0)
return NULL;
if (strchr(dest,'@')==0)
return NULL;
- for (int i = 0; i < l; i++)
+ for (unsigned int i = 0; i < l; i++)
if (dest[i] < 32)
return NULL;
- for (int i = 0; i < l; i++)
+ for (unsigned int i = 0; i < l; i++)
if (dest[i] > 126)
return NULL;
int c = 0;
- for (int i = 0; i < l; i++)
+ for (unsigned int i = 0; i < l; i++)
if (dest[i] == '!')
c++;
if (c>1)
return NULL;
c = 0;
- for (int i = 0; i < l; i++)
+ for (unsigned int i = 0; i < l; i++)
if (dest[i] == '@')
c++;
if (c>1)
return NULL;
long maxbans = GetMaxBans(chan->name);
- if (chan->bans.size() > maxbans)
+ if ((unsigned)chan->bans.size() > (unsigned)maxbans)
{
WriteServ(user->fd,"478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans);
return NULL;
{
int counts[127];
bool active[127];
- int delta = 1;
memset(counts,0,sizeof(counts));
memset(active,0,sizeof(active));
log(DEBUG,"compress_modes: %s",modes.c_str());
- for (int i = 0; i < modes.length(); i++)
+ for (unsigned int i = 0; i < modes.length(); i++)
{
if ((modes[i] == '+') || (modes[i] == '-'))
continue;
break;
previously_set_l = true;
bool invalid = false;
- for (int i = 0; i < strlen(parameters[param]); i++)
+ for (unsigned int i = 0; i < strlen(parameters[param]); i++)
{
if ((parameters[param][i] < '0') || (parameters[param][i] > '9'))
{
if (!silent)
{
WriteChannelWithServ(ServerName,chan,"MODE %s %s",chan->name,outstr);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"M %s %s",chan->name, outstr);
- NetSendToAll(buffer);
}
}
if (!silent)
{
WriteChannel(chan,user,"MODE %s %s",chan->name,outstr);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick,chan->name, outstr);
- NetSendToAll(buffer);
}
}
}
// based on sourcemodes, return true or false to determine if umode is a valid mode a user may set on themselves or others.
-bool allowed_umode(char umode, char* sourcemodes,bool adding)
+bool allowed_umode(char umode, char* sourcemodes,bool adding,bool serveroverride)
{
log(DEBUG,"Allowed_umode: %c %s",umode,sourcemodes);
+ // Servers can +o and -o arbitrarily
+ if ((serveroverride == true) && (umode == 'o'))
+ {
+ return true;
+ }
// RFC1459 specified modes
if ((umode == 'w') || (umode == 's') || (umode == 'i'))
{
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
return;
- for (int i = 0; i < strlen(parameters[1]); i++)
+ for (unsigned int i = 0; i < strlen(parameters[1]); i++)
{
if (parameters[1][i] == ' ')
continue;
}
else
{
- if ((parameters[1][i] == 'i') || (parameters[1][i] == 'w') || (parameters[1][i] == 's') || (allowed_umode(parameters[1][i],user->modes,direction)))
+ if ((parameters[1][i] == 'i') || (parameters[1][i] == 'w') || (parameters[1][i] == 's') || (allowed_umode(parameters[1][i],user->modes,direction,false)))
{
can_change = 1;
}
{
if (direction == 1)
{
- if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true)))
+ if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true,false)))
{
char umode = parameters[1][i];
if ((process_module_umode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o'))
}
else
{
- if ((allowed_umode(parameters[1][i],user->modes,false)) && (strchr(dmodes,parameters[1][i])))
+ if ((allowed_umode(parameters[1][i],user->modes,false,false)) && (strchr(dmodes,parameters[1][i])))
{
char umode = parameters[1][i];
if ((process_module_umode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o'))
{
- int q = 0;
+ unsigned int q = 0;
char temp[MAXBUF];
char moo[MAXBUF];
- int r = strlen(outpars);
+ unsigned int r = strlen(outpars);
outpars[r+1]='\0';
outpars[r] = parameters[1][i];
{
char b[MAXBUF];
strlcpy(b,"",MAXBUF);
- int z = 0;
- int i = 0;
+ unsigned int z = 0;
+ unsigned int i = 0;
while (i < strlen (outpars))
{
b[z++] = outpars[i++];
if (strcmp(b,""))
{
WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick, dest->nick, b);
- NetSendToAll(buffer);
}
if (strlen(dmodes)>MAXMODES)
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
return;
- for (int i = 0; i < strlen(parameters[1]); i++)
+ for (unsigned int i = 0; i < strlen(parameters[1]); i++)
{
if (parameters[1][i] == ' ')
continue;
if (direction == 1)
{
log(DEBUG,"umode %c being added",parameters[1][i]);
- if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true)))
+ if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true,true)))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
{
// can only remove a mode they already have
log(DEBUG,"umode %c being removed",parameters[1][i]);
- if ((allowed_umode(parameters[1][i],user->modes,false)) && (strchr(dmodes,parameters[1][i])))
+ if ((allowed_umode(parameters[1][i],user->modes,false,true)) && (strchr(dmodes,parameters[1][i])))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
if ((process_module_umode(umode, user, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o'))
{
- int q = 0;
+ unsigned int q = 0;
char temp[MAXBUF];
char moo[MAXBUF];
- int v1 = strlen(outpars);
+ unsigned int v1 = strlen(outpars);
outpars[v1+1]='\0';
outpars[v1] = parameters[1][i];
{
char b[MAXBUF];
strlcpy(b,"",MAXBUF);
- int z = 0;
- int i = 0;
+ unsigned int z = 0;
+ unsigned int i = 0;
while (i < strlen (outpars))
{
b[z++] = outpars[i++];
if (strcmp(b,""))
{
WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- // M token for a usermode must go to all servers
- char buffer[MAXBUF];
- snprintf(buffer,MAXBUF,"m %s %s %s",user->nick, dest->nick, b);
- NetSendToAll(buffer);
}
if (strlen(dmodes)>MAXMODES)
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
return;
- for (int i = 0; i < strlen(parameters[1]); i++)
+ for (unsigned int i = 0; i < strlen(parameters[1]); i++)
{
if (parameters[1][i] == ' ')
continue;
if (direction == 1)
{
log(DEBUG,"umode %c being added",parameters[1][i]);
- if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],"o",true)))
+ if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],"o",true,true)))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
{
// can only remove a mode they already have
log(DEBUG,"umode %c being removed",parameters[1][i]);
- if ((allowed_umode(parameters[1][i],"o",false)) && (strchr(dmodes,parameters[1][i])))
+ if ((allowed_umode(parameters[1][i],"o",false,true)) && (strchr(dmodes,parameters[1][i])))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
if ((process_module_umode(umode, NULL, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o'))
{
- int q = 0;
+ unsigned int q = 0;
char temp[MAXBUF];
char moo[MAXBUF];
- int v1 = strlen(outpars);
+ unsigned int v1 = strlen(outpars);
outpars[v1+1]='\0';
outpars[v1] = parameters[1][i];
{
char b[MAXBUF];
strcpy(b,"");
- int z = 0;
- int i = 0;
+ unsigned int z = 0;
+ unsigned int i = 0;
while (i < strlen (outpars))
{
b[z++] = outpars[i++];
if ((parameters[1][0] != '+') && (parameters[1][0] != '-'))
return;
- for (int i = 0; i < strlen(parameters[1]); i++)
+ for (unsigned int i = 0; i < strlen(parameters[1]); i++)
{
if (parameters[1][i] == ' ')
continue;
if (direction == 1)
{
log(DEBUG,"umode %c being added",parameters[1][i]);
- if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true)))
+ if ((!strchr(dmodes,parameters[1][i])) && (allowed_umode(parameters[1][i],user->modes,true,false)))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
{
// can only remove a mode they already have
log(DEBUG,"umode %c being removed",parameters[1][i]);
- if ((allowed_umode(parameters[1][i],user->modes,false)) && (strchr(dmodes,parameters[1][i])))
+ if ((allowed_umode(parameters[1][i],user->modes,false,false)) && (strchr(dmodes,parameters[1][i])))
{
char umode = parameters[1][i];
log(DEBUG,"umode %c is an allowed umode",umode);
if ((process_module_umode(umode, NULL, dest, direction)) || (umode == 'i') || (umode == 's') || (umode == 'w') || (umode == 'o'))
{
- int q = 0;
+ unsigned int q = 0;
char temp[MAXBUF];
char moo[MAXBUF];
- int v1 = strlen(outpars);
+ unsigned int v1 = strlen(outpars);
outpars[v1+1]='\0';
outpars[v1] = parameters[1][i];
{
char b[MAXBUF];
strcpy(b,"");
- int z = 0;
- int i = 0;
+ unsigned int z = 0;
+ unsigned int i = 0;
while (i < strlen (outpars))
{
b[z++] = outpars[i++];
log(DEBUG,"merge_mode2: found channel %s",Ptr->name);
if (Ptr)
{
- if ((cstatus(user,Ptr) < STATUS_HOP) && (!is_uline(user->server)))
- {
- return;
- }
+ //if ((cstatus(user,Ptr) < STATUS_HOP) && (!is_uline(user->server)))
+ //{
+ // return;
+ //}
process_modes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,true);
}
}