* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
- *
- * $Id: chmode.c 3580 2007-11-07 23:45:14Z jilles $
*/
#include "stdinc.h"
#include "channel.h"
#include "client.h"
-#include "common.h"
#include "hash.h"
#include "hook.h"
#include "match.h"
* Checks if mlock and chanops permit a mode change.
*
* inputs - client, channel, access level, errors pointer, mode char
- * outputs - 0 on failure, 1 on success
+ * outputs - false on failure, true on success
* side effects - error message sent on failure
*/
-static int
+static bool
allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel,
int *errors, char c)
{
c,
chptr->mode_lock);
*errors |= SM_ERR_MLOCK;
- return 0;
+ return false;
}
if(alevel < CHFL_CHANOP)
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, chptr->chname);
*errors |= SM_ERR_NOOPS;
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/* add_id()
*
* inputs - client, channel, id to add, type, forward
- * outputs - 0 on failure, 1 on success
+ * outputs - false on failure, true on success
* side effects - given id is added to the appropriate list
*/
-int
+bool
add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward,
rb_dlink_list * list, long mode_type)
{
*/
if(MyClient(source_p))
{
- if((rb_dlink_list_length(&chptr->banlist) + rb_dlink_list_length(&chptr->exceptlist) + rb_dlink_list_length(&chptr->invexlist) + rb_dlink_list_length(&chptr->quietlist)) >= (unsigned long)(chptr->mode.mode & MODE_EXLIMIT ? ConfigChannel.max_bans_large : ConfigChannel.max_bans))
+ if((rb_dlink_list_length(&chptr->banlist) + rb_dlink_list_length(&chptr->exceptlist) + rb_dlink_list_length(&chptr->invexlist) + rb_dlink_list_length(&chptr->quietlist)) >= (unsigned long)((chptr->mode.mode & MODE_EXLIMIT) ? ConfigChannel.max_bans_large : ConfigChannel.max_bans))
{
sendto_one(source_p, form_str(ERR_BANLISTFULL),
me.name, source_p->name, chptr->chname, realban);
- return 0;
+ return false;
}
RB_DLINK_FOREACH(ptr, list->head)
{
actualBan = ptr->data;
if(mask_match(actualBan->banstr, realban))
- return 0;
+ return false;
}
}
/* dont let remotes set duplicates */
{
actualBan = ptr->data;
if(!irccmp(actualBan->banstr, realban))
- return 0;
+ return false;
}
}
/* invalidate the can_send() cache */
if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
- chptr->bants++;
+ chptr->bants = rb_current_time();
- return 1;
+ return true;
}
/* del_id()
/* invalidate the can_send() cache */
if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
- chptr->bants++;
+ chptr->bants = rb_current_time();
return banptr;
}
*t = '~';
if (*t == '~')
t++;
- *t = ToLower(*t);
+ *t = irctolower(*t);
return mask_buf + old_mask_pos;
}
* output - true if forwarding should be allowed
* side effects - numeric sent if not allowed
*/
-static int
+static bool
check_forward(struct Client *source_p, struct Channel *chptr,
const char *forward)
{
- struct Channel *targptr;
+ struct Channel *targptr = NULL;
struct membership *msptr;
if(!check_channel_name(forward) ||
(MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward))))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward);
- return 0;
+ return false;
}
/* don't forward to inconsistent target -- jilles */
if(chptr->chname[0] == '#' && forward[0] == '&')
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), forward);
- return 0;
+ return false;
}
if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), forward);
- return 0;
+ return false;
}
if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET))
{
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, targptr->chname);
- return 0;
+ return false;
}
}
- return 1;
+ return true;
}
/* fix_key()
static char *
fix_key(char *arg)
{
- u_char *s, *t, c;
+ unsigned char *s, *t, c;
- for(s = t = (u_char *) arg; (c = *s); s++)
+ for(s = t = (unsigned char *) arg; (c = *s); s++)
{
c &= 0x7f;
if(c != ':' && c != ',' && c > ' ')
static char *
fix_key_remote(char *arg)
{
- u_char *s, *t, c;
+ unsigned char *s, *t, c;
- for(s = t = (u_char *) arg; (c = *s); s++)
+ for(s = t = (unsigned char *) arg; (c = *s); s++)
{
c &= 0x7f;
if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' '))
default:
sendto_realops_snomask(SNO_GENERAL, L_ALL, "chm_ban() called with unknown type!");
return;
- break;
}
if(dir == 0 || parc <= *parn)
* also make sure it will always fit on a line with channel
* name etc.
*/
- if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5))
+ if(strlen(mask) > MIN(BANLEN, MODEBUFLEN - 5))
{
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
*mbuf = '\0';
if(cur_len > mlen)
- sendto_channel_local(flags, chptr, "%s %s", modebuf,
- parabuf);
+ sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p,
+ flags, chptr, "%s %s", modebuf, parabuf);
else
continue;
*mbuf = '\0';
if(cur_len > mlen)
- sendto_channel_local(flags, chptr, "%s %s", modebuf, parabuf);
+ sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p,
+ flags, chptr, "%s %s", modebuf, parabuf);
}
/* only propagate modes originating locally, or if we're hubbing */
*/
void
set_channel_mlock(struct Client *client_p, struct Client *source_p,
- struct Channel *chptr, const char *newmlock, int propagate)
+ struct Channel *chptr, const char *newmlock, bool propagate)
{
rb_free(chptr->mode_lock);
chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;