summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions.cpp6
-rw-r--r--src/base64.cpp37
-rw-r--r--src/bots.cpp23
-rw-r--r--src/botserv.cpp252
-rw-r--r--src/channels.cpp324
-rw-r--r--src/chanserv.cpp406
-rw-r--r--src/command.cpp9
-rw-r--r--src/commands.cpp50
-rw-r--r--src/compat.cpp26
-rw-r--r--src/config.cpp566
-rw-r--r--src/configreader.cpp12
-rw-r--r--src/core/cs_set_bantype.cpp2
-rw-r--r--src/core/cs_set_description.cpp4
-rw-r--r--src/core/cs_set_email.cpp2
-rw-r--r--src/core/cs_set_entrymsg.cpp2
-rw-r--r--src/core/cs_set_founder.cpp4
-rw-r--r--src/core/cs_set_keeptopic.cpp2
-rw-r--r--src/core/cs_set_mlock.cpp2
-rw-r--r--src/core/cs_set_opnotice.cpp4
-rw-r--r--src/core/cs_set_peace.cpp2
-rw-r--r--src/core/cs_set_persist.cpp6
-rw-r--r--src/core/cs_set_private.cpp2
-rw-r--r--src/core/cs_set_restricted.cpp2
-rw-r--r--src/core/cs_set_secure.cpp2
-rw-r--r--src/core/cs_set_securefounder.cpp2
-rw-r--r--src/core/cs_set_secureops.cpp4
-rw-r--r--src/core/cs_set_signkick.cpp2
-rw-r--r--src/core/cs_set_successor.cpp2
-rw-r--r--src/core/cs_set_topiclock.cpp2
-rw-r--r--src/core/cs_set_url.cpp2
-rw-r--r--src/core/cs_set_xop.cpp4
-rw-r--r--src/core/enc_md5.cpp4
-rw-r--r--src/core/enc_none.cpp6
-rw-r--r--src/core/enc_old.cpp4
-rw-r--r--src/core/enc_sha1.cpp4
-rw-r--r--src/core/enc_sha256.cpp12
-rw-r--r--src/core/ns_group.cpp8
-rw-r--r--src/core/ns_register.cpp6
-rw-r--r--src/core/os_staff.cpp4
-rw-r--r--src/encrypt.cpp20
-rw-r--r--src/hashcomp.cpp9
-rw-r--r--src/hostserv.cpp24
-rw-r--r--src/init.cpp87
-rw-r--r--src/ircd.cpp7
-rw-r--r--src/language.cpp151
-rw-r--r--src/log.cpp51
-rw-r--r--src/mail.cpp31
-rw-r--r--src/main.cpp86
-rw-r--r--src/memory.cpp26
-rw-r--r--src/memoserv.cpp276
-rw-r--r--src/messages.cpp102
-rw-r--r--src/misc.cpp874
-rw-r--r--src/modes.cpp70
-rw-r--r--src/module.cpp29
-rw-r--r--src/modulemanager.cpp143
-rw-r--r--src/modules.cpp158
-rw-r--r--src/modules/hs_request.cpp4
-rw-r--r--src/nickalias.cpp21
-rw-r--r--src/nickcore.cpp18
-rw-r--r--src/nickserv.cpp68
-rw-r--r--src/operserv.cpp73
-rw-r--r--src/opertype.cpp28
-rw-r--r--src/process.cpp148
-rw-r--r--src/regchannel.cpp73
-rw-r--r--src/send.cpp38
-rw-r--r--src/servers.cpp61
-rw-r--r--src/sessions.cpp97
-rw-r--r--src/sockets.cpp37
-rw-r--r--src/threadengine.cpp1
-rw-r--r--src/threadengine_pthread.cpp5
-rw-r--r--src/threadengine_win32.cpp3
-rw-r--r--src/timers.cpp10
-rw-r--r--src/users.cpp153
-rw-r--r--src/wildcard.cpp18
-rw-r--r--src/win32_memory.cpp7
-rw-r--r--src/windows.cpp23
76 files changed, 2240 insertions, 2603 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index 00ed01100..bff5b36fa 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
- *
- *
*/
#include "services.h"
@@ -91,7 +89,7 @@ void common_unban(ChannelInfo *ci, const std::string &nick)
if (!ci->c->bans || !ci->c->bans->count)
return;
- if (u->hostip == NULL)
+ if (!u->hostip)
{
host = host_resolve(u->host);
/* we store the just resolved hostname so we don't
@@ -108,14 +106,12 @@ void common_unban(ChannelInfo *ci, const std::string &nick)
if (ircd->svsmode_unban)
ircdproto->SendBanDel(ci->c, nick);
else
- {
for (ban = ci->c->bans->entries; ban; ban = next)
{
next = ban->next;
if (entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->host, ip) || entry_match(ban, u->nick.c_str(), u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip))
ci->c->RemoveMode(NULL, CMODE_BAN, ban->mask);
}
- }
/* host_resolve() sstrdup us this info so we gotta free it */
if (host)
delete [] host;
diff --git a/src/base64.cpp b/src/base64.cpp
index 3f576e96a..2071ad40a 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
- *
- *
*/
/*
@@ -35,8 +33,7 @@ long base64dec(const char *b64)
return 0;
}
-static const char Base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
@@ -109,7 +106,7 @@ int b64_encode(const char *src, size_t srclength, char *target, size_t targsize)
unsigned char output[4];
size_t i;
- while (2 < srclength)
+ while (srclength > 2)
{
input[0] = *src++;
input[1] = *src++;
@@ -173,14 +170,14 @@ int b64_decode(const char *src, char *target, size_t targsize)
while ((ch = *src++) != '\0')
{
- if (isspace(ch)) /* Skip whitespace anywhere. */
+ if (isspace(ch)) /* Skip whitespace anywhere. */
continue;
if (ch == Pad64)
break;
pos = const_cast<char *>(strchr(Base64, ch));
- if (!pos) /* A non-base64 character. */
+ if (!pos) /* A non-base64 character. */
return -1;
switch (state)
@@ -236,16 +233,16 @@ int b64_decode(const char *src, char *target, size_t targsize)
* on a byte boundary, and/or with erroneous trailing characters.
*/
- if (ch == Pad64) /* We got a pad char. */
+ if (ch == Pad64) /* We got a pad char. */
{
- ch = *src++; /* Skip it, get next. */
+ ch = *src++; /* Skip it, get next. */
switch (state)
{
- case 0: /* Invalid = in first position */
- case 1: /* Invalid = in second position */
+ case 0: /* Invalid = in first position */
+ case 1: /* Invalid = in second position */
return -1;
- case 2: /* Valid, means one byte of info */
+ case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
for (; ch != '\0'; ch = *src++)
if (!isspace(ch))
@@ -253,11 +250,11 @@ int b64_decode(const char *src, char *target, size_t targsize)
/* Make sure there is another trailing = sign. */
if (ch != Pad64)
return -1;
- ch = *src++; /* Skip the = */
+ ch = *src++; /* Skip the = */
/* Fall through to "single trailing =" case. */
/* FALLTHROUGH */
- case 3: /* Valid, means two bytes of info */
+ case 3: /* Valid, means two bytes of info */
/*
* We know this char is an =. Is there anything but
* whitespace after it?
@@ -289,12 +286,12 @@ int b64_decode(const char *src, char *target, size_t targsize)
return tarindex;
}
-const char* encode_ip(unsigned char *ip)
+const char *encode_ip(unsigned char *ip)
{
static char buf[25];
unsigned char *cp;
- struct in_addr ia; /* For IPv4 */
- char *s_ip; /* Signed ip string */
+ struct in_addr ia; /* For IPv4 */
+ char *s_ip; /* Signed ip string */
if (!ip)
return "*";
@@ -319,11 +316,11 @@ int decode_ip(const char *buf)
b64_decode(buf, targ, 25);
ia = *reinterpret_cast<struct in_addr *>(targ);
- if (len == 24) /* IPv6 */
+ if (len == 24) /* IPv6 */
return 0;
- else if (len == 8) /* IPv4 */
+ else if (len == 8) /* IPv4 */
return ia.s_addr;
- else /* Error?? */
+ else /* Error?? */
return 0;
}
diff --git a/src/bots.cpp b/src/bots.cpp
index e9021b188..424120d2d 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -3,9 +3,6 @@
* Copyright (C) 2008-2010 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
- *
- *
- *
*/
#include "services.h"
@@ -35,33 +32,19 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
ci::string ci_nick(nnick.c_str());
if (Config.s_ChanServ && ci_nick == Config.s_ChanServ)
- {
ChanServ = this;
- }
else if (Config.s_BotServ && ci_nick == Config.s_BotServ)
- {
BotServ = this;
- }
else if (Config.s_HostServ && ci_nick == Config.s_HostServ)
- {
HostServ = this;
- }
else if (Config.s_OperServ && ci_nick == Config.s_OperServ)
- {
OperServ = this;
- }
else if (Config.s_MemoServ && ci_nick == Config.s_MemoServ)
- {
MemoServ = this;
- }
else if (Config.s_NickServ && ci_nick == Config.s_NickServ)
- {
NickServ = this;
- }
else if (Config.s_GlobalNoticer && ci_nick == Config.s_GlobalNoticer)
- {
Global = this;
- }
BotListByNick[this->nick.c_str()] = this;
if (!this->uid.empty())
@@ -78,14 +61,12 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
BotInfo::~BotInfo()
{
- for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
if (ci->bi == this)
- {
ci->bi = NULL;
- }
}
BotListByNick.erase(this->nick.c_str());
@@ -105,7 +86,7 @@ void BotInfo::ChangeNick(const char *newnick)
void BotInfo::RejoinAll()
{
- for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 2dd96706d..624d1df83 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -7,8 +7,6 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
- *
- *
*/
/*************************************************************************/
@@ -17,19 +15,20 @@
#include "modules.h"
#include "language.h"
-static UserData *get_user_data(Channel * c, User * u);
+static UserData *get_user_data(Channel *c, User *u);
-static void check_ban(ChannelInfo * ci, User * u, int ttbtype);
-static void bot_kick(ChannelInfo * ci, User * u, int message, ...);
+static void check_ban(ChannelInfo *ci, User *u, int ttbtype);
+static void bot_kick(ChannelInfo *ci, User *u, int message, ...);
E void moduleAddBotServCmds();
/*************************************************************************/
-/* *INDENT-OFF* */
-void moduleAddBotServCmds() {
+
+void moduleAddBotServCmds()
+{
ModuleManager::LoadModuleList(Config.BotServCoreModules);
}
-/* *INDENT-ON* */
+
/*************************************************************************/
/*************************************************************************/
@@ -39,7 +38,7 @@ void get_botserv_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it)
+ for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
{
BotInfo *bi = it->second;
@@ -62,9 +61,8 @@ void get_botserv_stats(long *nrec, long *memuse)
void bs_init()
{
- if (Config.s_BotServ) {
+ if (Config.s_BotServ)
moduleAddBotServCmds();
- }
}
/*************************************************************************/
@@ -75,7 +73,7 @@ void botserv(User *u, BotInfo *bi, const std::string &buf)
{
if (!u || !bi || buf.empty())
return;
-
+
if (buf.find("\1PING ", 0, 6) != std::string::npos && buf[buf.length() - 1] == '\1')
{
std::string command = buf;
@@ -84,23 +82,20 @@ void botserv(User *u, BotInfo *bi, const std::string &buf)
ircdproto->SendCTCP(bi, u->nick.c_str(), "%s", command.c_str());
}
else
- {
mod_run_cmd(bi, u, buf);
- }
}
/*************************************************************************/
/* Handles all messages that are sent to registered channels where a
* bot is on.
- *
*/
void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
{
if (!u || !ci || !ci->c || buf.empty())
return;
-
+
/* Answer to ping if needed */
if (buf.find("\1PING ", 0, 6) != std::string::npos && buf[buf.length() - 1] == '\1')
{
@@ -180,17 +175,16 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
/* Caps kicker */
if (ci->botflags.HasFlag(BS_KICK_CAPS) && realbuf.length() >= ci->capsmin)
{
- int i = 0;
- int l = 0;
+ int i = 0, l = 0;
- for (unsigned j = 0; j < realbuf.length(); ++j)
+ for (unsigned j = 0, end = realbuf.length(); j < end; ++j)
{
if (isupper(realbuf[j]))
++i;
else if (islower(realbuf[j]))
++l;
}
-
+
/* i counts uppercase chars, l counts lowercase chars. Only
* alphabetic chars (so islower || isupper) qualify for the
* percentage of caps to kick for; the rest is ignored. -GD
@@ -212,33 +206,24 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
/* Normalize the buffer */
const char *nbuf = normalizeBuffer(realbuf.c_str());
- for (unsigned i = 0; i < ci->GetBadWordCount(); ++i)
+ for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
{
BadWord *bw = ci->GetBadWord(i);
if (bw->type == BW_ANY && ((Config.BSCaseSensitive && strstr(nbuf, bw->word.c_str())) || (!Config.BSCaseSensitive && stristr(nbuf, bw->word.c_str()))))
- {
mustkick = true;
- }
else if (bw->type == BW_SINGLE)
{
size_t len = bw->word.length();
- if ((Config.BSCaseSensitive && nbuf == bw->word) || (!Config.BSCaseSensitive && (!stricmp(nbuf, bw->word.c_str()))))
- {
+ if ((Config.BSCaseSensitive && nbuf == bw->word) || (!Config.BSCaseSensitive && (!stricmp(nbuf, bw->word.c_str()))))
mustkick = true;
- }
- else if ((strchr(nbuf, ' ') == nbuf + len) && ((Config.BSCaseSensitive && nbuf == bw->word)
- || (!Config.BSCaseSensitive && (stristr(nbuf, bw->word.c_str()) == nbuf))))
- {
+ else if ((strchr(nbuf, ' ') == nbuf + len) && ((Config.BSCaseSensitive && nbuf == bw->word) || (!Config.BSCaseSensitive && (stristr(nbuf, bw->word.c_str()) == nbuf))))
mustkick = true;
- }
else
{
if ((strrchr(nbuf, ' ') == nbuf + strlen(nbuf) - len - 1) && ((Config.BSCaseSensitive && (strstr(nbuf, bw->word.c_str()) == nbuf + strlen(nbuf) - len)) || (!Config.BSCaseSensitive && (stristr(nbuf, bw->word.c_str()) == nbuf + strlen(nbuf) - len))))
- {
mustkick = true;
- }
else
{
char *wordbuf = new char[len + 3];
@@ -248,10 +233,8 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
wordbuf[len + 2] = '\0';
memcpy(wordbuf + 1, bw->word.c_str(), len);
- if ((Config.BSCaseSensitive && (strstr(nbuf, wordbuf))) || (!Config.BSCaseSensitive && (stristr(nbuf, wordbuf))))
- {
+ if ((Config.BSCaseSensitive && strstr(nbuf, wordbuf)) || (!Config.BSCaseSensitive && stristr(nbuf, wordbuf)))
mustkick = true;
- }
delete [] wordbuf;
}
@@ -261,10 +244,8 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
{
size_t len = bw->word.length();
- if ((Config.BSCaseSensitive && (!strncmp(nbuf, bw->word.c_str(), len))) || (!Config.BSCaseSensitive && (!strnicmp(nbuf, bw->word.c_str(), len))))
- {
+ if ((Config.BSCaseSensitive && !strncmp(nbuf, bw->word.c_str(), len)) || (!Config.BSCaseSensitive && !strnicmp(nbuf, bw->word.c_str(), len)))
mustkick = true;
- }
else
{
char *wordbuf = new char[len + 2];
@@ -273,10 +254,8 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
wordbuf[0] = ' ';
wordbuf[len + 1] = '\0';
- if ((Config.BSCaseSensitive && (strstr(nbuf, wordbuf))) || (!Config.BSCaseSensitive && (stristr(nbuf, wordbuf))))
- {
+ if ((Config.BSCaseSensitive && strstr(nbuf, wordbuf)) || (!Config.BSCaseSensitive && stristr(nbuf, wordbuf)))
mustkick = true;
- }
delete [] wordbuf;
}
@@ -285,11 +264,8 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
{
size_t len = bw->word.length();
- if ((Config.BSCaseSensitive && (!strncmp(nbuf + strlen(nbuf) - len, bw->word.c_str(), len)))
- || (!Config.BSCaseSensitive && (!strnicmp(nbuf + strlen(nbuf) - len, bw->word.c_str(), len))))
- {
+ if ((Config.BSCaseSensitive && !strncmp(nbuf + strlen(nbuf) - len, bw->word.c_str(), len)) || (!Config.BSCaseSensitive && !strnicmp(nbuf + strlen(nbuf) - len, bw->word.c_str(), len)))
mustkick = true;
- }
else
{
char *wordbuf = new char[len + 2];
@@ -298,10 +274,8 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
wordbuf[len] = ' ';
wordbuf[len + 1] = '\0';
- if ((Config.BSCaseSensitive && (strstr(nbuf, wordbuf))) || (!Config.BSCaseSensitive && (stristr(nbuf, wordbuf))))
- {
+ if ((Config.BSCaseSensitive && strstr(nbuf, wordbuf)) || (!Config.BSCaseSensitive && stristr(nbuf, wordbuf)))
mustkick = true;
- }
delete [] wordbuf;
}
@@ -341,7 +315,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
ud->lines = 0;
}
- ud->lines++;
+ ++ud->lines;
if (ud->lines >= ci->floodlines)
{
check_ban(ci, u, TTB_FLOOD);
@@ -356,7 +330,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
UserData *ud = get_user_data(ci->c, u);
if (!ud)
return;
-
+
if (ud->lastline && stricmp(ud->lastline, buf.c_str()))
{
delete [] ud->lastline;
@@ -367,7 +341,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
{
if (!ud->lastline)
ud->lastline = sstrdup(buf.c_str());
- ud->times++;
+ ++ud->times;
}
if (ud->times >= ci->repeattimes)
@@ -381,9 +355,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
/* return if the user is on the ignore list */
if (get_ignore(u->nick.c_str()) != NULL)
- {
return;
- }
/* Fantaisist commands */
if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == *Config.BSFantasyCharacter && !was_action)
@@ -391,7 +363,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const std::string &buf)
spacesepstream sep(buf);
std::string token;
- if (sep.GetToken(token) && (token[0] == *Config.BSFantasyCharacter))
+ if (sep.GetToken(token) && token[0] == *Config.BSFantasyCharacter)
{
/* Strip off the fantasy character */
token.erase(token.begin());
@@ -461,13 +433,12 @@ BotInfo *findbot(const ci::string &nick)
return NULL;
}
-
/*************************************************************************/
/* Returns ban data associated with an user if it exists, allocates it
otherwise. */
-static BanData *get_ban_data(Channel * c, User * u)
+static BanData *get_ban_data(Channel *c, User *u)
{
char mask[BUFSIZE];
BanData *bd, *next;
@@ -476,11 +447,12 @@ static BanData *get_ban_data(Channel * c, User * u)
if (!c || !u)
return NULL;
- snprintf(mask, sizeof(mask), "%s@%s", u->GetIdent().c_str(),
- u->GetDisplayedHost().c_str());
+ snprintf(mask, sizeof(mask), "%s@%s", u->GetIdent().c_str(), u->GetDisplayedHost().c_str());
- for (bd = c->bd; bd; bd = next) {
- if (now - bd->last_use > Config.BSKeepData) {
+ for (bd = c->bd; bd; bd = next)
+ {
+ if (now - bd->last_use > Config.BSKeepData)
+ {
if (bd->next)
bd->next->prev = bd->prev;
if (bd->prev)
@@ -493,7 +465,8 @@ static BanData *get_ban_data(Channel * c, User * u)
delete bd;
continue;
}