Message handlers should return void.

Also fix up some return values and stuff to use bool (or void if
nothing). I just did it whilst I was here.

According to jilles, the return value used to signify whether or not the
client had exited. This was error-prone and was fixed a long, long time
ago, but the return value was left int for historical reasons.

Since the return type is not used (and has no clear use case anyway),
it's safe to just get rid of it.
This commit is contained in:
Elizabeth Myers 2016-03-09 01:37:03 -06:00
parent eeabf33a7c
commit 3c7d6fcce7
99 changed files with 1339 additions and 1691 deletions

View file

@ -48,8 +48,8 @@
static const char ban_desc[] = "Provides the TS6 BAN command for propagating network-wide bans";
static int m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
static int ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
static void m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
static void ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message ban_msgtab = {
"BAN", 0, 0, 0, 0,
@ -60,14 +60,13 @@ mapi_clist_av1 ban_clist[] = { &ban_msgtab, NULL };
DECLARE_MODULE_AV2(ban, NULL, NULL, ban_clist, NULL, NULL, NULL, NULL, ban_desc);
static int
static void
m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
sendto_one_notice(source_p, ":The BAN command is not user-accessible.");
sendto_one_notice(source_p, ":To ban a user from a channel, see /QUOTE HELP CMODE");
if (IsOper(source_p))
sendto_one_notice(source_p, ":To ban a user from a server or from the network, see /QUOTE HELP KLINE");
return 0;
}
/* ms_ban()
@ -81,7 +80,7 @@ m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
* parv[7] - oper or *
* parv[8] - reason (possibly with |operreason)
*/
static int
static void
ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
rb_dlink_node *ptr;
@ -99,7 +98,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Unknown BAN type %s from %s",
parv[1], source_p->name);
return 0;
return;
}
switch (parv[1][0])
{
@ -120,7 +119,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Unknown BAN type %s from %s",
parv[1], source_p->name);
return 0;
return;
}
created = atol(parv[4]);
hold = created + atoi(parv[5]);
@ -145,7 +144,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
aconf->user ? aconf->user : "",
aconf->user ? "@" : "",
aconf->host);
return 0;
return;
}
/* act indicates if something happened (from the oper's
* point of view). This is the case if the ban was
@ -158,7 +157,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
aconf->lifetime = lifetime;
/* already expired, hmm */
if (aconf->lifetime <= now)
return 0;
return;
/* Deactivate, it will be reactivated later if appropriate. */
deactivate_conf(aconf, ptr, now);
rb_free(aconf->user);
@ -336,5 +335,4 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
parv[6],
parv[7],
parv[parc - 1]);
return 0;
}

View file

@ -38,9 +38,9 @@
static const char die_desc[] = "Provides the DIE command to allow an operator to shutdown a server";
static int mo_die(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int me_die(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int do_die(struct Client *, const char *);
static void mo_die(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void me_die(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void do_die(struct Client *, const char *);
static struct Message die_msgtab = {
"DIE", 0, 0, 0, 0,
@ -54,19 +54,19 @@ DECLARE_MODULE_AV2(die, NULL, NULL, die_clist, NULL, NULL, NULL, NULL, die_desc)
/*
* mo_die - DIE command handler
*/
static int
static void
mo_die(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struct Client *source_p, int parc, const char *parv[])
{
if(!IsOperDie(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "die");
return 0;
return;
}
if(parc < 2 || EmptyString(parv[1]))
{
sendto_one_notice(source_p, ":Need server name /die %s", me.name);
return 0;
return;
}
if(parc > 2)
@ -76,42 +76,40 @@ mo_die(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struc
if (!server_p)
{
sendto_one_numeric(source_p, ERR_NOSUCHSERVER, form_str(ERR_NOSUCHSERVER), parv[2]);
return 0;
return;
}
if (!IsMe(server_p))
{
sendto_one(server_p, ":%s ENCAP %s DIE %s", source_p->name, parv[2], parv[1]);
return 0;
return;
}
}
return do_die(source_p, parv[1]);
do_die(source_p, parv[1]);
}
static int
static void
me_die(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struct Client *source_p, int parc, const char *parv[])
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_DIE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block to "
"remotely shut down this server.");
return 0;
return;
}
return do_die(source_p, parv[1]);
do_die(source_p, parv[1]);
}
static int
static void
do_die(struct Client *source_p, const char *servername)
{
if(irccmp(servername, me.name))
{
sendto_one_notice(source_p, ":Mismatch on /die %s", me.name);
return 0;
return;
}
ircd_shutdown(get_client_name(source_p, HIDE_IP));
return 0;
}

View file

@ -36,8 +36,8 @@
static const char error_desc[] =
"Provides the ERROR command for clients and servers";
static int m_error(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_error(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_error(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_error(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message error_msgtab = {
"ERROR", 0, 0, 0, 0,
@ -51,34 +51,34 @@ mapi_clist_av1 error_clist[] = {
DECLARE_MODULE_AV2(error, NULL, NULL, error_clist, NULL, NULL, NULL, NULL, error_desc);
/* Determine whether an ERROR message is safe to show (no IP address in it) */
static int
static bool
is_safe_error(const char *message)
{
char prefix2[100];
const char *p;
if (!strncmp(message, "Closing Link: 127.0.0.1 (", 25))
return 1;
return true;
snprintf(prefix2, sizeof prefix2,
"Closing Link: 127.0.0.1 %s (", me.name);
if (!strncmp(message, prefix2, strlen(prefix2)))
return 1;
return true;
if (!strncmp(message, "Restart by ", 11))
return 1;
return true;
if (!strncmp(message, "Terminated by ", 14))
return 1;
return true;
if (!ircncmp(message, "Closing Link", 12))
return 0;
return false;
if (strchr(message, '['))
return 0;
return false;
p = strchr(message, '.');
if (p != NULL && p[1] != '\0')
return 0;
return false;
if (strchr(message, ':'))
return 0;
return false;
return 1;
return true;
}
/*
@ -88,7 +88,7 @@ is_safe_error(const char *message)
*
* parv[*] = parameters
*/
int
static void
m_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
const char *para;
@ -117,11 +117,9 @@ m_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
}
exit_client(client_p, source_p, source_p, "ERROR");
return 0;
}
static int
static void
ms_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
const char *para;
@ -135,7 +133,7 @@ ms_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
if(is_safe_error(para))
hideit = 0;
if(hideit == 2)
return 0;
return;
if(client_p == source_p)
{
@ -147,6 +145,4 @@ ms_error(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
sendto_realops_snomask(SNO_GENERAL, hideit ? L_ADMIN : L_ALL, "ERROR :from %s via %s -- %s",
source_p->name, client_p->name, para);
}
return 0;
}

View file

@ -44,9 +44,9 @@
static const char join_desc[] = "Provides the JOIN and TS6 SJOIN commands to facilitate joining and creating channels";
static int m_join(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_join(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_sjoin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_join(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_join(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_sjoin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int h_can_create_channel;
static int h_channel_join;
@ -72,7 +72,7 @@ mapi_hlist_av1 join_hlist[] = {
DECLARE_MODULE_AV2(join, NULL, NULL, join_clist, join_hlist, NULL, NULL, NULL, join_desc);
static void do_join_0(struct Client *client_p, struct Client *source_p);
static int check_channel_name_loc(struct Client *source_p, const char *name);
static bool check_channel_name_loc(struct Client *source_p, const char *name);
static void send_join_error(struct Client *source_p, int numeric, const char *name);
static void set_final_mode(struct Mode *mode, struct Mode *oldmode);
@ -138,7 +138,7 @@ check_forward(struct Client *source_p, struct Channel *chptr,
* parv[1] = channel
* parv[2] = channel password (key)
*/
static int
static void
m_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static char jbuf[BUFSIZE];
@ -380,8 +380,6 @@ m_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
hook_info.key = key;
call_hook(h_channel_join, &hook_info);
}
return 0;
}
/*
@ -391,7 +389,7 @@ m_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
* parv[3] = "+", formerly channel modes but now unused
* alternatively, a single "0" parameter parts all channels
*/
static int
static void
ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
@ -399,32 +397,32 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
time_t oldts;
time_t newts;
int isnew;
int keep_our_modes = YES;
bool keep_our_modes = true;
rb_dlink_node *ptr, *next_ptr;
/* special case for join 0 */
if((parv[1][0] == '0') && (parv[1][1] == '\0') && parc == 2)
{
do_join_0(client_p, source_p);
return 0;
return;
}
if(parc < 4)
return 0;
return;
if(!IsChannelName(parv[2]) || !check_channel_name(parv[2]))
return 0;
return;
/* joins for local channels cant happen. */
if(parv[2][0] == '&')
return 0;
return;
mbuf = modebuf;
mode.key[0] = mode.forward[0] = '\0';
mode.mode = mode.limit = mode.join_num = mode.join_time = 0;
if((chptr = get_or_create_channel(source_p, parv[2], &isnew)) == NULL)
return 0;
return;
newts = atol(parv[1]);
oldts = chptr->channelts;
@ -458,7 +456,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
;
else if(newts < oldts)
{
keep_our_modes = NO;
keep_our_modes = false;
chptr->channelts = newts;
}
@ -508,10 +506,9 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s JOIN %ld %s +",
source_p->id, (long) chptr->channelts, chptr->chname);
return 0;
}
static int
static void
ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static char buf_uid[BUFSIZE];
@ -523,8 +520,8 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
static struct Mode mode, *oldmode;
const char *modes;
int args = 0;
int keep_our_modes = 1;
int keep_new_modes = 1;
bool keep_our_modes = true;
bool keep_new_modes = true;
int fl;
int isnew;
int mlen_uid;
@ -539,14 +536,14 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
rb_dlink_node *ptr, *next_ptr;
if(parc < 5)
return 0;
return;
if(!IsChannelName(parv[2]) || !check_channel_name(parv[2]))
return 0;
return;
/* SJOIN's for local channels can't happen. */
if(*parv[2] == '&')
return 0;
return;
modebuf[0] = parabuf[0] = mode.key[0] = mode.forward[0] = '\0';
pargs = mode.mode = mode.limit = mode.join_num = mode.join_time = 0;
@ -569,7 +566,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
rb_strlcpy(mode.forward, parv[4 + args], sizeof(mode.forward));
args++;
if(parc < 5 + args)
return 0;
return;
break;
case 'j':
sscanf(parv[4 + args], "%d:%d", &joinc, &timeslice);
@ -577,19 +574,19 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
mode.join_num = joinc;
mode.join_time = timeslice;
if(parc < 5 + args)
return 0;
return;
break;
case 'k':
rb_strlcpy(mode.key, parv[4 + args], sizeof(mode.key));
args++;
if(parc < 5 + args)
return 0;
return;
break;
case 'l':
mode.limit = atoi(parv[4 + args]);
args++;
if(parc < 5 + args)
return 0;
return;
break;
default:
if(chmode_flags[(int) *s] != 0)
@ -611,7 +608,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
s = "";
if((chptr = get_or_create_channel(source_p, parv[2], &isnew)) == NULL)
return 0; /* channel name too long? */
return; /* channel name too long? */
oldts = chptr->channelts;
@ -684,16 +681,16 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
{
/* Channel was emptied, create a new one */
if((chptr = get_or_create_channel(source_p, parv[2], &isnew)) == NULL)
return 0; /* oops! */
return; /* oops! */
oldmode = &chptr->mode;
}
}
keep_our_modes = NO;
keep_our_modes = false;
chptr->channelts = newts;
}
else
keep_new_modes = NO;
keep_new_modes = false;
if(!keep_new_modes)
mode = *oldmode;
@ -936,7 +933,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
{
destroy_channel(chptr);
return 0;
return;
}
/* Keep the colon if we're sending an SJOIN without nicks -- jilles */
@ -946,8 +943,6 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
}
sendto_server(client_p->from, NULL, CAP_TS6, NOCAPS, "%s", buf_uid);
return 0;
}
/*
@ -986,21 +981,21 @@ do_join_0(struct Client *client_p, struct Client *source_p)
}
}
static int
static bool
check_channel_name_loc(struct Client *source_p, const char *name)
{
const char *p;
s_assert(name != NULL);
if(EmptyString(name))
return 0;
return false;
if(ConfigFileEntry.disable_fake_channels && !IsOper(source_p))
{
for(p = name; *p; ++p)
{
if(!IsChanChar(*p) || IsFakeChanChar(*p))
return 0;
return false;
}
}
else
@ -1008,7 +1003,7 @@ check_channel_name_loc(struct Client *source_p, const char *name)
for(p = name; *p; ++p)
{
if(!IsChanChar(*p))
return 0;
return false;
}
}
@ -1016,10 +1011,10 @@ check_channel_name_loc(struct Client *source_p, const char *name)
{
for(p = name; *p; ++p)
if(*p < 33 || *p > 126)
return 0;
return false;
}
return 1;
return true;
}
/* send_join_error()

View file

@ -39,7 +39,7 @@
static const char kick_desc[] = "Provides the KICK command to remove a user from a channel";
static int m_kick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_kick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
#define mg_kick { m_kick, 3 }
struct Message kick_msgtab = {
@ -57,7 +57,7 @@ DECLARE_MODULE_AV2(kick, NULL, NULL, kick_clist, NULL, NULL, NULL, NULL, kick_de
** parv[2] = client to kick
** parv[3] = kick comment
*/
static int
static void
m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct membership *msptr;
@ -83,7 +83,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if(chptr == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
return;
}
if(!IsServer(source_p))
@ -94,7 +94,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), name);
return 0;
return;
}
if(get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) < CHFL_CHANOP)
@ -103,7 +103,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, name);
return 0;
return;
}
/* If its a TS 0 channel, do it the old way */
@ -124,7 +124,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if(!(who = find_chasing(source_p, user, &chasing)))
{
return 0;
return;
}
msptr = find_channel_membership(chptr, who);
@ -135,7 +135,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
sendto_one(source_p, form_str(ERR_ISCHANSERVICE),
me.name, source_p->name, who->name, chptr->chname);
return 0;
return;
}
if(MyClient(source_p))
@ -152,7 +152,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
call_hook(h_can_kick, &hookdata);
if (!hookdata.approved)
return 0;
return;
}
comment = LOCAL_COPY((EmptyString(parv[3])) ? who->name : parv[3]);
@ -183,6 +183,4 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
else if (MyClient(source_p))
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), user, name);
return 0;
}

View file

@ -43,8 +43,8 @@ static const char kill_desc[] = "Provides the KILL command to remove a user from
static int h_can_kill;
static char buf[BUFSIZE];
static int ms_kill(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int mo_kill(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_kill(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void mo_kill(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void relay_kill(struct Client *, struct Client *, struct Client *,
const char *, const char *);
@ -67,7 +67,7 @@ DECLARE_MODULE_AV2(kill, NULL, NULL, kill_clist, kill_hlist, NULL, NULL, NULL, k
** parv[1] = kill victim
** parv[2] = kill path
*/
static int
static void
mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -81,7 +81,7 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
if(!IsOperLocalKill(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "local_kill");
return 0;
return;
}
if(!EmptyString(parv[2]))
@ -109,7 +109,7 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
else
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), user);
return 0;
return;
}
sendto_one_notice(source_p, ":KILL changed from %s to %s", user, target_p->name);
}
@ -119,7 +119,7 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
sendto_one_notice(source_p, ":Nick %s is not on your server "
"and you do not have the global_kill flag",
target_p->name);
return 0;
return;
}
/* Last chance to stop the kill */
@ -130,7 +130,7 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
if (moduledata.approved == 0)
/* The callee should have sent a message. */
return 0;
return;
if(MyConnect(target_p))
sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
@ -168,8 +168,6 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
sprintf(buf, "Killed (%s (%s))", source_p->name, reason);
exit_client(client_p, target_p, source_p, buf);
return 0;
}
/*
@ -177,7 +175,7 @@ mo_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
* parv[1] = kill victim
* parv[2] = kill path and reason
*/
static int
static void
ms_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -225,7 +223,7 @@ ms_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
{
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), IsDigit(*user) ? "*" : user);
return 0;
return;
}
sendto_one_notice(source_p, ":KILL changed from %s to %s", user, target_p->name);
}
@ -233,7 +231,7 @@ ms_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
if(IsServer(target_p) || IsMe(target_p))
{
sendto_one_numeric(source_p, ERR_CANTKILLSERVER, form_str(ERR_CANTKILLSERVER));
return 0;
return;
}
if(MyConnect(target_p))
@ -287,8 +285,6 @@ ms_kill(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
sprintf(buf, "Killed (%s %s)", source_p->name, reason);
exit_client(client_p, target_p, source_p, buf);
return 0;
}
static void

View file

@ -47,9 +47,9 @@
static const char message_desc[] =
"Provides the PRIVMSG and NOTICE commands to send messages to users and channels";
static int m_message(enum message_type, struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int m_privmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int m_notice(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_message(enum message_type, struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_privmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_notice(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void expire_tgchange(void *unused);
static struct ev_entry *expire_tgchange_event;
@ -92,7 +92,7 @@ static int build_target_list(enum message_type msgtype,
struct Client *client_p,
struct Client *source_p, const char *nicks_channels, const char *text);
static int flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p);
static bool flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p);
/* Fifteen seconds should be plenty for a client to reply a ctcp */
#define LARGE_CTCP_TIME 15
@ -106,7 +106,7 @@ static int flood_attack_client(enum message_type msgtype, struct Client *source_
static struct entity targets[512];
static int ntargets = 0;
static int duplicate_ptr(void *);
static bool duplicate_ptr(void *);
static void msg_channel(enum message_type msgtype,
struct Client *client_p,
@ -152,16 +152,16 @@ const char *cmdname[MESSAGE_TYPE_COUNT] = {
[MESSAGE_TYPE_NOTICE] = "NOTICE",
};
static int
static void
m_privmsg(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
return m_message(MESSAGE_TYPE_PRIVMSG, msgbuf_p, client_p, source_p, parc, parv);
m_message(MESSAGE_TYPE_PRIVMSG, msgbuf_p, client_p, source_p, parc, parv);
}
static int
static void
m_notice(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
return m_message(MESSAGE_TYPE_NOTICE, msgbuf_p, client_p, source_p, parc, parv);
m_message(MESSAGE_TYPE_NOTICE, msgbuf_p, client_p, source_p, parc, parv);
}
/*
@ -170,7 +170,7 @@ m_notice(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
* - pointer to source_p
* - pointer to channel
*/
static int
static void
m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
@ -181,14 +181,14 @@ m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
if(msgtype != MESSAGE_TYPE_NOTICE)
sendto_one(source_p, form_str(ERR_NORECIPIENT), me.name,
source_p->name, cmdname[msgtype]);
return 0;
return;
}
if(parc < 3 || EmptyString(parv[2]))
{
if(msgtype != MESSAGE_TYPE_NOTICE)
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
return 0;
return;
}
/* Finish the flood grace period if theyre not messaging themselves
@ -199,7 +199,7 @@ m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
if(build_target_list(msgtype, client_p, source_p, parv[1], parv[2]) < 0)
{
return 0;
return;
}
for(i = 0; i < ntargets; i++)
@ -228,8 +228,6 @@ m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
break;
}
}
return 0;
}
/*
@ -447,18 +445,18 @@ build_target_list(enum message_type msgtype, struct Client *client_p,
* inputs - pointer to check
* - pointer to table of entities
* - number of valid entities so far
* output - YES if duplicate pointer in table, NO if not.
* output - true if duplicate pointer in table, false if not.
* note, this does the canonize using pointers
* side effects - NONE
*/
static int
static bool
duplicate_ptr(void *ptr)
{
int i;
for(i = 0; i < ntargets; i++)
if(targets[i].ptr == ptr)
return YES;
return NO;
return true;
return false;
}
/*
@ -879,13 +877,13 @@ msg_client(enum message_type msgtype,
/*
* flood_attack_client
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
* say NOTICE must not auto reply
* says NOTICE must not auto reply
* - pointer to source Client
* - pointer to target Client
* output - 1 if target is under flood attack
* output - true if target is under flood attack
* side effects - check for flood attack on target target_p
*/
static int
static bool
flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p)
{
int delta;
@ -927,13 +925,13 @@ flood_attack_client(enum message_type msgtype, struct Client *source_p, struct C
sendto_one(source_p,
":%s NOTICE %s :*** Message to %s throttled due to flooding",
me.name, source_p->name, target_p->name);
return 1;
return true;
}
else
target_p->received_number_of_privmsgs++;
}
return 0;
return false;
}
/*

View file

@ -43,11 +43,11 @@
static const char mode_desc[] =
"Provides the MODE and MLOCK client and server commands, and TS6 server-to-server TMODE and BMASK commands";
static int m_mode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_mode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_tmode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_mlock(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_bmask(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_mode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_mode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_tmode(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_mlock(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_bmask(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message mode_msgtab = {
"MODE", 0, 0, 0, 0,
@ -74,7 +74,7 @@ DECLARE_MODULE_AV2(mode, NULL, NULL, mode_clist, NULL, NULL, NULL, NULL, mode_de
* m_mode - MODE command handler
* parv[1] - channel
*/
static int
static void
m_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr = NULL;
@ -94,7 +94,7 @@ m_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
me.name, source_p->name, "MODE");
return 0;
return;
}
}
@ -103,13 +103,13 @@ m_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
/* if here, it has to be a non-channel name */
user_mode(client_p, source_p, parc, parv);
return 0;
return;
}
if(!check_channel_name(dest))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[1]);
return 0;
return;
}
chptr = find_channel(dest);
@ -118,7 +118,7 @@ m_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
return;
}
/* Now know the channel exists */
@ -147,11 +147,9 @@ m_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
set_channel_mode(client_p, source_p, chptr, msptr, parc - n, parv + n);
}
return 0;
}
static int
static void
ms_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
@ -162,15 +160,13 @@ ms_mode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
return;
}
set_channel_mode(client_p, source_p, chptr, NULL, parc - 2, parv + 2);
return 0;
}
static int
static void
ms_tmode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr = NULL;
@ -180,7 +176,7 @@ ms_tmode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2]);
return 0;
return;
}
chptr = find_channel(parv[2]);
@ -189,12 +185,12 @@ ms_tmode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[2]);
return 0;
return;
}
/* TS is higher, drop it. */
if(atol(parv[1]) > chptr->channelts)
return 0;
return;
if(IsServer(source_p))
{
@ -206,11 +202,9 @@ ms_tmode(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
set_channel_mode(client_p, source_p, chptr, msptr, parc - 3, parv + 3);
}
return 0;
}
static int
static void
ms_mlock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr = NULL;
@ -219,7 +213,7 @@ ms_mlock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2]);
return 0;
return;
}
chptr = find_channel(parv[2]);
@ -228,17 +222,15 @@ ms_mlock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[2]);
return 0;
return;
}
/* TS is higher, drop it. */
if(atol(parv[1]) > chptr->channelts)
return 0;
return;
if(IsServer(source_p))
set_channel_mlock(client_p, source_p, chptr, parv[3], true);
return 0;
}
static void
@ -270,7 +262,7 @@ possibly_remove_lower_forward(struct Client *fakesource_p, int mems,
}
}
static int
static void
ms_bmask(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static char modebuf[BUFSIZE];
@ -292,14 +284,14 @@ ms_bmask(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
struct Client *fakesource_p;
if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2]))
return 0;
return;
if((chptr = find_channel(parv[2])) == NULL)
return 0;
return;
/* TS is higher, drop it. */
if(atol(parv[1]) > chptr->channelts)
return 0;
return;
switch (parv[3][0])
{
@ -331,7 +323,7 @@ ms_bmask(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
/* maybe we should just blindly propagate this? */
default:
return 0;
return;
}
parabuf[0] = '\0';
@ -432,5 +424,4 @@ ms_bmask(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
sendto_server(client_p, chptr, CAP_TS6 | needcap, NOCAPS, ":%s BMASK %ld %s %s :%s",
source_p->id, (long) chptr->channelts, chptr->chname, parv[3], parv[4]);
return 0;
}

View file

@ -54,16 +54,31 @@
*/
#define SAVE_NICKTS 100
static int mr_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int m_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int mc_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_uid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_euid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_save(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int can_save(struct Client *);
static void mr_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void mc_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_nick(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_uid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_euid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_save(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static bool can_save(struct Client *);
static void save_user(struct Client *, struct Client *, struct Client *);
static void bad_nickname(struct Client *, const char *);
static void change_remote_nick(struct Client *, struct Client *, time_t,
const char *, int);
static bool clean_username(const char *);
static bool clean_host(const char *);
static bool clean_uid(const char *uid, const char *sid);
static void set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick);
static void change_local_nick(struct Client *client_p, struct Client *source_p, char *nick, int);
static void register_client(struct Client *client_p, struct Client *server,
const char *nick, time_t newts, int parc, const char *parv[]);
static void perform_nick_collides(struct Client *, struct Client *,
struct Client *, int, const char **,
time_t, const char *, const char *);
static void perform_nickchange_collides(struct Client *, struct Client *,
struct Client *, int, const char **, time_t, const char *);
struct Message nick_msgtab = {
"NICK", 0, 0, 0, 0,
@ -90,28 +105,10 @@ static const char nick_desc[] =
DECLARE_MODULE_AV2(nick, NULL, NULL, nick_clist, NULL, NULL, NULL, NULL, nick_desc);
static int change_remote_nick(struct Client *, struct Client *, time_t,
const char *, int);
static int clean_username(const char *);
static int clean_host(const char *);
static int clean_uid(const char *uid, const char *sid);
static void set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick);
static void change_local_nick(struct Client *client_p, struct Client *source_p, char *nick, int);
static int register_client(struct Client *client_p, struct Client *server,
const char *nick, time_t newts, int parc, const char *parv[]);
static int perform_nick_collides(struct Client *, struct Client *,
struct Client *, int, const char **,
time_t, const char *, const char *);
static int perform_nickchange_collides(struct Client *, struct Client *,
struct Client *, int, const char **, time_t, const char *);
/* mr_nick()
* parv[1] = nickname
*/
static int
static void
mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -120,14 +117,14 @@ mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
if (strlen(client_p->id) == 3)
{
exit_client(client_p, client_p, client_p, "Mixing client and server protocol");
return 0;
return;
}
if(parc < 2 || EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
me.name, EmptyString(source_p->name) ? "*" : source_p->name);
return 0;
return;
}
/* copy the nick and terminate it */
@ -138,7 +135,7 @@ mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, parv[1]);
return 0;
return;
}
/* check if the nick is resv'd */
@ -146,14 +143,14 @@ mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
return 0;
return;
}
if(rb_dictionary_find(nd_dict, nick))
{
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
return 0;
return;
}
if((target_p = find_named_client(nick)) == NULL)
@ -162,14 +159,12 @@ mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
strcpy(source_p->name, nick);
else
sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*", nick);
return 0;
}
/* m_nick()
* parv[1] = nickname
*/
static int
static void
m_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -178,7 +173,7 @@ m_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if(parc < 2 || EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, source_p->name);
return 0;
return;
}
/* mark end of grace period, to prevent nickflooding */
@ -192,20 +187,20 @@ m_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if(!clean_nick(nick, 1))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick);
return 0;
return;
}
if(!IsExemptResv(source_p) && find_nick_resv(nick))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick);
return 0;
return;
}
if(rb_dictionary_find(nd_dict, nick))
{
sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
return 0;
return;
}
if((target_p = find_named_client(nick)))
@ -230,12 +225,10 @@ m_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
else
sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, source_p->name, nick);
return 0;
return;
}
else
change_local_nick(client_p, source_p, nick, 1);
return 0;
}
/* mc_nick()
@ -244,7 +237,7 @@ m_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
* parv[1] = nickname
* parv[2] = TS when nick change
*/
static int
static void
mc_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -254,7 +247,7 @@ mc_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
if(!clean_nick(parv[1], 0))
{
bad_nickname(client_p, parv[1]);
return 0;
return;
}
newts = atol(parv[2]);
@ -280,11 +273,9 @@ mc_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
else
perform_nickchange_collides(source_p, client_p, target_p,
parc, parv, newts, parv[1]);
return 0;
}
static int
static void
ms_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
const char *nick, *server;
@ -302,8 +293,6 @@ ms_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
client_p->name, nick, server);
exit_client(client_p, client_p, &me, "TS5 nickname introduced");
return 0;
}
/* ms_uid()
@ -317,7 +306,7 @@ ms_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
* parv[8] - UID
* parv[9] - gecos
*/
static int
static void
ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -337,14 +326,14 @@ ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"Excess parameters (%d) to %s command, expecting %d",
parc, "UID", 10);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
return;
}
/* if nicks erroneous, or too long, kill */
if(!clean_nick(parv[1], 0))
{
bad_nickname(client_p, parv[1]);
return 0;
return;
}
if(!clean_uid(parv[8], source_p->id))
@ -353,7 +342,7 @@ ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"Invalid UID %s for nick %s on %s/%s",
parv[8], parv[1], source_p->name, source_p->id);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
return;
}
if(!clean_username(parv[5]) || !clean_host(parv[6]))
@ -363,7 +352,7 @@ ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"Bad user@host: %s@%s From: %s(via %s)",
parv[5], parv[6], source_p->name, client_p->name);
sendto_one(client_p, ":%s KILL %s :%s (Bad user@host)", me.id, parv[8], me.name);
return 0;
return;
}
/* check length of clients gecos */
@ -391,8 +380,6 @@ ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
else
perform_nick_collides(source_p, client_p, target_p, parc, parv,
newts, parv[1], parv[8]);
return 0;
}
/* ms_euid()
@ -408,7 +395,7 @@ ms_uid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
* parv[10] - account
* parv[11] - gecos
*/
static int
static void
ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -428,14 +415,14 @@ ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
"Excess parameters (%d) to %s command, expecting %d",
parc, "EUID", 12);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
return;
}
/* if nicks erroneous, or too long, kill */
if(!clean_nick(parv[1], 0))
{
bad_nickname(client_p, parv[1]);
return 0;
return;
}
if(!clean_uid(parv[8], source_p->id))
@ -444,7 +431,7 @@ ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
"Invalid UID %s for nick %s on %s/%s",
parv[8], parv[1], source_p->name, source_p->id);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
return;
}
if(!clean_username(parv[5]) || !clean_host(parv[6]))
@ -454,7 +441,7 @@ ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
"Bad user@host: %s@%s From: %s(via %s)",
parv[5], parv[6], source_p->name, client_p->name);
sendto_one(client_p, ":%s KILL %s :%s (Bad user@host)", me.id, parv[8], me.name);
return 0;
return;
}
if(strcmp(parv[9], "*") && !clean_host(parv[9]))
@ -464,7 +451,7 @@ ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
"Bad realhost: %s From: %s(via %s)",
parv[9], source_p->name, client_p->name);
sendto_one(client_p, ":%s KILL %s :%s (Bad user@host)", me.id, parv[8], me.name);
return 0;
return;
}
/* check length of clients gecos */
@ -492,22 +479,20 @@ ms_euid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
else
perform_nick_collides(source_p, client_p, target_p, parc, parv,
newts, parv[1], parv[8]);
return 0;
}
/* ms_save()
* parv[1] - UID
* parv[2] - TS
*/
static int
static void
ms_save(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
target_p = find_id(parv[1]);
if (target_p == NULL)
return 0;
return;
if (!IsPerson(target_p))
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Ignored SAVE message for non-person %s from %s",
@ -522,16 +507,15 @@ ms_save(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Ignored SAVE message for %s from %s",
target_p->name, source_p->name);
return 0;
}
/* clean_username()
*
* input - username to check
* output - 0 if erroneous, else 0
* output - false if erroneous, else true
* side effects -
*/
static int
static bool
clean_username(const char *username)
{
int len = 0;
@ -541,22 +525,22 @@ clean_username(const char *username)
len++;
if(!IsUserChar(*username))
return 0;
return false;
}
if(len > USERLEN)
return 0;
return false;
return 1;
return true;
}
/* clean_host()
*
* input - host to check
* output - 0 if erroneous, else 0
* output - false if erroneous, else true
* side effects -
*/
static int
static bool
clean_host(const char *host)
{
int len = 0;
@ -566,38 +550,38 @@ clean_host(const char *host)
len++;
if(!IsHostChar(*host))
return 0;
return false;
}
if(len > HOSTLEN)
return 0;
return false;
return 1;
return true;
}
static int
static bool
clean_uid(const char *uid, const char *sid)
{
int len = 1;
if(strncmp(uid, sid, strlen(sid)))
return 0;
return false;
if(!IsDigit(*uid++))
return 0;
return false;
for(; *uid; uid++)
{
len++;
if(!IsIdChar(*uid))
return 0;
return false;
}
if(len != IDLEN - 1)
return 0;
return false;
return 1;
return true;
}
static void
@ -727,7 +711,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
/*
* change_remote_nick()
*/
static int
static void
change_remote_nick(struct Client *client_p, struct Client *source_p,
time_t newts, const char *nick, int dosend)
{
@ -768,11 +752,9 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
/* remove all accepts pointing to the client */
del_all_accepts(source_p);
return 0;
}
static int
static void
perform_nick_collides(struct Client *source_p, struct Client *client_p,
struct Client *target_p, int parc, const char *parv[],
time_t newts, const char *nick, const char *uid)
@ -820,7 +802,7 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
target_p->flags |= FLAGS_KILLED;
exit_client(client_p, target_p, &me, "Nick collision (new)");
}
return 0;
return;
}
/* the timestamps are different */
else
@ -846,7 +828,7 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
sendto_one(client_p,
":%s KILL %s :%s (Nick collision (new))",
me.id, uid, me.name);
return 0;
return;
}
else
{
@ -882,14 +864,12 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
register_client(client_p, source_p,
nick, newts, parc, parv);
return 0;
}
}
}
static int
static void
perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
struct Client *target_p, int parc,
const char *parv[], time_t newts, const char *nick)
@ -937,7 +917,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
source_p->flags |= FLAGS_KILLED;
exit_client(client_p, source_p, &me, "Nick collision(old)");
}
return 0;
return;
}
else
{
@ -988,7 +968,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
else
exit_client(client_p, source_p, &me, "Nick collision(new)");
}
return 0;
return;
}
else
{
@ -1025,11 +1005,9 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
}
change_remote_nick(client_p, source_p, newts, nick, 1);
return 0;
}
static int
static void
register_client(struct Client *client_p, struct Client *server,
const char *nick, time_t newts, int parc, const char *parv[])
{
@ -1139,25 +1117,24 @@ register_client(struct Client *client_p, struct Client *server,
call_hook(h_new_remote_user, source_p);
introduce_client(client_p, source_p, user, nick, parc == 12);
return 0;
}
/* Check if we can do SAVE. target_p can be a client to save or a
* server introducing a client -- jilles */
static int
static bool
can_save(struct Client *target_p)
{
struct Client *serv_p;
if (MyClient(target_p))
return 1;
return true;
if (!has_id(target_p))
return 0;
return false;
serv_p = IsServer(target_p) ? target_p : target_p->servptr;
while (serv_p != NULL && serv_p != &me)
{
if (!(serv_p->serv->caps & CAP_SAVE))
return 0;
return false;
serv_p = serv_p->servptr;
}
return serv_p == &me;

View file

@ -42,7 +42,7 @@
static const char part_desc[] = "Provides the PART command to leave a channel";
static int m_part(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_part(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message part_msgtab = {
"PART", 0, 0, 0, 0,
@ -56,8 +56,8 @@ DECLARE_MODULE_AV2(part, NULL, NULL, part_clist, NULL, NULL, NULL, NULL, part_de
static void part_one_client(struct Client *client_p,
struct Client *source_p, char *name,
const char *reason);
static int can_send_part(struct Client *source_p, struct Channel *chptr, struct membership *msptr);
static int do_message_hook(struct Client *source_p, struct Channel *chptr, const char **reason);
static bool can_send_part(struct Client *source_p, struct Channel *chptr, struct membership *msptr);
static bool do_message_hook(struct Client *source_p, struct Channel *chptr, const char **reason);
/*
@ -65,7 +65,7 @@ static int do_message_hook(struct Client *source_p, struct Channel *chptr, const
** parv[1] = channel
** parv[2] = reason
*/
static int
static void
m_part(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *p, *name;
@ -88,7 +88,6 @@ m_part(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
part_one_client(client_p, source_p, name, reason);
name = rb_strtok_r(NULL, ",", &p);
}
return 0;
}
/*
@ -158,19 +157,19 @@ part_one_client(struct Client *client_p, struct Client *source_p, char *name, co
* - channel being parted
* - membership pointer
* outputs:
* - 1 if message allowed
* - 0 if message denied
* - true if message allowed
* - false if message denied
* side effects:
* - none.
*/
static int
static bool
can_send_part(struct Client *source_p, struct Channel *chptr, struct membership *msptr)
{
if (!can_send(chptr, source_p, msptr))
return 0;
return false;
/* Allow chanops to bypass anti_spam_exit_message_time for part messages. */
if (is_chanop(msptr))
return 1;
return true;
return (source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time();
}
@ -182,12 +181,12 @@ can_send_part(struct Client *source_p, struct Channel *chptr, struct membership
* - channel being parted
* - pointer to reason
* outputs:
* - 1 if message is allowed
* - 0 if message is denied or message is now empty
* - true if message is allowed
* - false if message is denied or message is now empty
* side effects:
* - reason may be modified.
*/
static int
static bool
do_message_hook(struct Client *source_p, struct Channel *chptr, const char **reason)
{
hook_data_privmsg_channel hdata;

View file

@ -36,8 +36,8 @@
static const char quit_desc[] = "Provides the QUIT command to allow a user to leave the network";
static int m_quit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_quit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_quit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_quit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message quit_msgtab = {
"QUIT", 0, 0, 0, 0,
@ -52,7 +52,7 @@ DECLARE_MODULE_AV2(quit, NULL, NULL, quit_clist, NULL, NULL, NULL, NULL, quit_de
** m_quit
** parv[1] = comment
*/
static int
static void
m_quit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name);
@ -76,19 +76,17 @@ m_quit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
rb_current_time())
{
exit_client(client_p, source_p, source_p, "Client Quit");
return 0;
return;
}
exit_client(client_p, source_p, source_p, comment);
return 0;
}
/*
** ms_quit
** parv[1] = comment
*/
static int
static void
ms_quit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name);
@ -98,6 +96,4 @@ ms_quit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
comment[REASONLEN] = '\0';
exit_client(client_p, source_p, source_p, comment);
return 0;
}

View file

@ -43,9 +43,13 @@
static const char server_desc[] =
"Provides the TS6 commands to introduce a new server to the network";
static int mr_server(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_server(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int ms_sid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void mr_server(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_server(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_sid(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static bool bogus_host(const char *host);
static void set_server_gecos(struct Client *, const char *);
struct Message server_msgtab = {
"SERVER", 0, 0, 0, 0,
{{mr_server, 4}, mg_reg, mg_ignore, {ms_server, 4}, mg_ignore, mg_reg}
@ -59,16 +63,13 @@ mapi_clist_av1 server_clist[] = { &server_msgtab, &sid_msgtab, NULL };
DECLARE_MODULE_AV2(server, NULL, NULL, server_clist, NULL, NULL, NULL, NULL, server_desc);
int bogus_host(const char *host);
static int set_server_gecos(struct Client *, const char *);
/*
* mr_server - SERVER message handler
* parv[1] = servername
* parv[2] = serverinfo/hopcount
* parv[3] = serverinfo
*/
static int
static void
mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char info[REALLEN + 1];
@ -90,7 +91,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
ilog(L_SERVER, "Server %s has unexpected name %s",
log_client_name(client_p, SHOW_IP), name);
exit_client(client_p, client_p, client_p, "Server name mismatch");
return 0;
return;
}
/*
@ -101,13 +102,13 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Link %s dropped, non-TS server",
client_p->name);
exit_client(client_p, client_p, client_p, "Non-TS server");
return 0;
return;
}
if(bogus_host(name))
{
exit_client(client_p, client_p, client_p, "Bogus server name");
return 0;
return;
}
/* Now we just have to call check_server and everything should be
@ -128,7 +129,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
}
exit_client(client_p, client_p, client_p, "Invalid servername.");
return 0;
return;
/* NOT REACHED */
break;
@ -143,7 +144,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
log_client_name(client_p, SHOW_IP));
exit_client(client_p, client_p, client_p, "Invalid credentials.");
return 0;
return;
/* NOT REACHED */
break;
@ -158,7 +159,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
log_client_name(client_p, SHOW_IP));
exit_client(client_p, client_p, client_p, "Invalid host.");
return 0;
return;
/* NOT REACHED */
break;
@ -171,7 +172,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
log_client_name(client_p, SHOW_IP));
exit_client(client_p, client_p, client_p, "Invalid servername.");
return 0;
return;
/* NOT REACHED */
break;
case -5:
@ -182,7 +183,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
log_client_name(client_p, SHOW_IP));
exit_client(client_p, client_p, client_p, "Access denied, requires SSL/TLS but is plaintext");
return 0;
return;
}
/* require TS6 for direct links */
@ -191,7 +192,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"Link %s dropped, TS6 protocol is required", name);
exit_client(client_p, client_p, client_p, "Incompatible TS version");
return 0;
return;
}
/* check to ensure any "required" caps are set. --nenolod */
@ -213,7 +214,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
sendto_one(client_p, "ERROR :Missing required CAPABs (%s)", missing);
exit_client(client_p, client_p, client_p, "Missing required CAPABs");
return 0;
return;
}
if((target_p = find_server(NULL, name)))
@ -248,7 +249,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
sendto_one(client_p, "ERROR :Server already exists.");
}
exit_client(client_p, client_p, client_p, "Server Exists");
return 0;
return;
}
if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
@ -266,7 +267,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
sendto_one(client_p, "ERROR :SID already exists.");
exit_client(client_p, client_p, client_p, "SID Exists");
return 0;
return;
}
/*
@ -278,8 +279,6 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
set_server_gecos(client_p, info);
client_p->hopcount = hop;
server_estab(client_p);
return 0;
}
/*
@ -288,7 +287,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
* parv[2] = serverinfo/hopcount
* parv[3] = serverinfo
*/
static int
static void
ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char info[REALLEN + 1];
@ -334,7 +333,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
"Server %s already exists",
name);
exit_client(client_p, client_p, &me, squitreason);
return 0;
return;
}
/*
@ -356,7 +355,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
client_p->name, name);
exit_client(client_p, client_p, client_p, "Nick as Server");
return 0;
return;
}
/*
@ -420,7 +419,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
"No matching hub_mask for %s",
name);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
/* Check for the new server being leafed behind this HUB */
@ -437,7 +436,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
"Matching leaf_mask for %s",
name);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
@ -451,7 +450,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
client_p->name, name);
exit_client(NULL, client_p, &me, "Invalid servername introduced.");
return 0;
return;
}
target_p = make_client(client_p);
@ -487,11 +486,9 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
hdata.client = source_p;
hdata.target = target_p;
call_hook(h_server_introduced, &hdata);
return 0;
}
static int
static void
ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -512,7 +509,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"Server %s already exists",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
/* collision on the SID? */
@ -531,7 +528,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"SID %s for %s already in use by %s",
parv[3], parv[1], target_p->name);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
if(bogus_host(parv[1]) || strlen(parv[1]) > HOSTLEN)
@ -544,7 +541,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
client_p->name, parv[1]);
exit_client(NULL, client_p, &me, "Bogus server name");
return 0;
return;
}
if(!IsDigit(parv[3][0]) || !IsIdChar(parv[3][1]) ||
@ -558,7 +555,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
client_p->name, parv[3]);
exit_client(NULL, client_p, &me, "Bogus SID");
return 0;
return;
}
/* for the directly connected server:
@ -591,7 +588,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"No matching hub_mask for %s",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
/* matching leaf_mask */
@ -607,7 +604,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
"Matching leaf_mask for %s",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);
return 0;
return;
}
/* ok, alls good */
@ -645,8 +642,6 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
hdata.client = source_p;
hdata.target = target_p;
call_hook(h_server_introduced, &hdata);
return 0;
}
/* set_server_gecos()
@ -655,7 +650,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
* output - none
* side effects - servers gecos field is set
*/
static int
static void
set_server_gecos(struct Client *client_p, const char *info)
{
/* check the info for [IP] */
@ -709,27 +704,25 @@ set_server_gecos(struct Client *client_p, const char *info)
if(s && (*s != '\0'))
{
rb_strlcpy(client_p->info, s, sizeof(client_p->info));
return 1;
return;
}
}
}
rb_strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
return 1;
}
/*
* bogus_host
*
* inputs - hostname
* output - 1 if a bogus hostname input, 0 if its valid
* output - true if a bogus hostname input, false if its valid
* side effects - none
*/
int
static bool
bogus_host(const char *host)
{
int bogus_server = 0;
bool bogus_server = false;
const char *s;
int dots = 0;
@ -737,7 +730,7 @@ bogus_host(const char *host)
{
if(!IsServChar(*s))
{
bogus_server = 1;
bogus_server = true;
break;
}
if('.' == *s)
@ -745,7 +738,7 @@ bogus_host(const char *host)
}
if(!dots || bogus_server)
return 1;
return true;
return 0;
return false;
}

View file

@ -40,8 +40,8 @@
static const char squit_desc[] = "Provides the SQUIT command to cause a server to quit";
static int ms_squit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static int mo_squit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void ms_squit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void mo_squit(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message squit_msgtab = {
"SQUIT", 0, 0, 0, 0,
@ -67,7 +67,7 @@ static struct squit_parms *find_squit(struct Client *client_p,
* parv[1] = server name
* parv[2] = comment
*/
static int
static void
mo_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct squit_parms *found_squit;
@ -89,18 +89,16 @@ mo_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "remote");
return 0;
return;
}
exit_client(client_p, found_squit->target_p, source_p, comment);
return 0;
return;
}
else
{
sendto_one_numeric(source_p, ERR_NOSUCHSERVER, form_str(ERR_NOSUCHSERVER), parv[1]);
}
return 0;
}
/*
@ -108,7 +106,7 @@ mo_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
* parv[1] = server name
* parv[2] = comment
*/
static int
static void
ms_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
@ -119,12 +117,12 @@ ms_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
else
{
if((target_p = find_server(NULL, parv[1])) == NULL)
return 0;
return;
if(IsMe(target_p))
target_p = client_p;
if(!IsServer(target_p))
return 0;
return;
}
/* Server is closing its link */
@ -149,7 +147,6 @@ ms_squit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
ilog(L_SERVER, "SQUIT From %s : %s (%s)", source_p->name, target_p->name, comment);
}
exit_client(client_p, target_p, source_p, comment);
return 0;
}