From 73fb94c55344b6ad788c925bf13325236402891f Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 27 Aug 2010 13:44:30 -0400 Subject: [PATCH] Added an Anope::string::is_pos_number_only function to use everywhere we convertTo unsigned values, and fixed the mail delay error message to give the correct time. --- include/anope.h | 1 + modules/core/db_plain.cpp | 86 ++++++++++++++++----------------- modules/core/os_ignore.cpp | 2 +- modules/core/os_news.cpp | 4 +- modules/extra/db_mysql.cpp | 24 ++++----- modules/extra/hs_request.cpp | 2 +- modules/protocol/bahamut.cpp | 8 +-- modules/protocol/inspircd11.cpp | 10 ++-- modules/protocol/inspircd12.cpp | 8 +-- modules/protocol/inspircd20.cpp | 12 ++--- modules/protocol/ratbox.cpp | 14 +++--- modules/protocol/unreal32.cpp | 14 +++--- src/channels.cpp | 4 +- src/mail.cpp | 4 +- 14 files changed, 97 insertions(+), 96 deletions(-) diff --git a/include/anope.h b/include/anope.h index 84f68ac45..020abd4cd 100644 --- a/include/anope.h +++ b/include/anope.h @@ -198,6 +198,7 @@ namespace Anope * Determine if string consists of only numbers. */ inline bool is_number_only() const { return this->find_first_not_of("0123456789.-") == npos; } + inline bool is_pos_number_only() const { return this->find_first_not_of("0123456789.") == npos; } /** * Replace parts of the string. diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index 9c47306ca..b05a1f896 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -376,9 +376,9 @@ static void LoadNickAlias(const std::vector ¶ms) NickAlias *na = new NickAlias(params[1], nc); - na->time_registered = params[2].is_number_only() ? convertTo(params[2]) : 0; + na->time_registered = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; - na->last_seen = params[3].is_number_only() ? convertTo(params[3]) : 0; + na->last_seen = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; Alog(LOG_DEBUG_2) << "[db_plain}: Loaded nickalias for " << na->nick; } @@ -389,7 +389,7 @@ static void LoadNickRequest(const std::vector ¶ms) nr->passcode = params[1]; nr->password = params[2]; nr->email = params[3]; - nr->requested = params[4].is_number_only() ? convertTo(params[4]) : 0; + nr->requested = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; Alog(LOG_DEBUG_2) << "[db_plain]: Loaded nickrequest for " << nr->nick; } @@ -401,8 +401,8 @@ static void LoadBotInfo(const std::vector ¶ms) bi = new BotInfo(params[0]); bi->SetIdent(params[1]); bi->host = params[2]; - bi->created = params[3].is_number_only() ? convertTo(params[3]) : 0; - bi->chancount = params[4].is_number_only() ? convertTo(params[4]) : 0; + bi->created = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; + bi->chancount = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; bi->realname = params[5]; Alog(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick; @@ -417,9 +417,9 @@ static void LoadChanInfo(const std::vector ¶ms) ci->ClearFlags(); ci->botflags.ClearFlags(); - ci->time_registered = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->time_registered = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; - ci->last_used = params[2].is_number_only() ? convertTo(params[2]) : 0; + ci->last_used = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; Alog(LOG_DEBUG_2) << "[db_plain]: loaded channel " << ci->name; } @@ -428,15 +428,15 @@ static void LoadOperInfo(const std::vector ¶ms) { if (params[0].equals_ci("STATS")) { - maxusercnt = params[1].is_number_only() ? convertTo(params[1]) : 0; - maxusertime = params[2].is_number_only() ? convertTo(params[2]) : 0; + maxusercnt = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; + maxusertime = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; } else if (params[0].equals_ci("SNLINE") || params[0].equals_ci("SQLINE") || params[0].equals_ci("SZLINE")) { Anope::string mask = params[1]; Anope::string by = params[2]; - time_t seton = params[3].is_number_only() ? convertTo(params[3]) : 0; - time_t expires = params[4].is_number_only() ? convertTo(params[4]) : 0; + time_t seton = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; + time_t expires = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; Anope::string reason = params[5]; XLine *x = NULL; @@ -457,8 +457,8 @@ static void LoadOperInfo(const std::vector ¶ms) Anope::string user = params[1]; Anope::string host = params[2]; Anope::string by = params[3]; - time_t seton = params[4].is_number_only() ? convertTo(params[4]) : 0; - time_t expires = params[5].is_number_only() ? convertTo(params[5]) : 0; + time_t seton = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; + time_t expires = params[5].is_pos_number_only() ? convertTo(params[5]) : 0; Anope::string reason = params[6]; XLine *x = SGLine->Add(NULL, NULL, user + "@" + host, expires, reason); @@ -472,10 +472,10 @@ static void LoadOperInfo(const std::vector ¶ms) { Exception *exception = new Exception(); exception->mask = params[1]; - exception->limit = params[2].is_number_only() ? convertTo(params[2]) : 1; + exception->limit = params[2].is_pos_number_only() ? convertTo(params[2]) : 1; exception->who = params[3]; - exception->time = params[4].is_number_only() ? convertTo(params[4]) : 0; - exception->expires = params[5].is_number_only() ? convertTo(params[5]) : 0; + exception->time = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; + exception->expires = params[5].is_pos_number_only() ? convertTo(params[5]) : 0; exception->reason = params[6]; exceptions.push_back(exception); } @@ -604,9 +604,9 @@ class DBPlain : public Module nc->language = LangInfos[i].LanguageId; } else if (key.equals_ci("MEMOMAX")) - nc->memos.memomax = params[0].is_number_only() ? convertTo(params[0]) : 1; + nc->memos.memomax = params[0].is_pos_number_only() ? convertTo(params[0]) : 1; else if (key.equals_ci("CHANCOUNT")) - nc->channelcount = params[0].is_number_only() ? convertTo(params[0]) : 0; + nc->channelcount = params[0].is_pos_number_only() ? convertTo(params[0]) : 0; else if (key.equals_ci("EMAIL")) nc->email = params[0]; else if (key.equals_ci("GREET")) @@ -623,8 +623,8 @@ class DBPlain : public Module else if (key.equals_ci("MI")) { Memo *m = new Memo; - m->number = params[0].is_number_only() ? convertTo(params[0]) : 0; - m->time = params[1].is_number_only() ? convertTo(params[1]) : 0; + m->number = params[0].is_pos_number_only() ? convertTo(params[0]) : 0; + m->time = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; m->sender = params[2]; for (unsigned j = 3; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j) { @@ -661,7 +661,7 @@ class DBPlain : public Module } } else if (key.equals_ci("VHOST")) - na->hostinfo.SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_number_only() ? convertTo(params[1]) : 0); + na->hostinfo.SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_pos_number_only() ? convertTo(params[1]) : 0); return EVENT_CONTINUE; } @@ -679,9 +679,9 @@ class DBPlain : public Module EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, const std::vector ¶ms) { if (key.equals_ci("BANTYPE")) - ci->bantype = params[0].is_number_only() ? convertTo(params[0]) : Config->CSDefBantype; + ci->bantype = params[0].is_pos_number_only() ? convertTo(params[0]) : Config->CSDefBantype; else if (key.equals_ci("MEMOMAX")) - ci->memos.memomax = params[0].is_number_only() ? convertTo(params[0]) : 1; + ci->memos.memomax = params[0].is_pos_number_only() ? convertTo(params[0]) : 1; else if (key.equals_ci("FOUNDER")) { ci->founder = findcore(params[0]); @@ -713,7 +713,7 @@ class DBPlain : public Module else if (key.equals_ci("TOPIC")) { ci->last_topic_setter = params[0]; - ci->last_topic_time = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->last_topic_time = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; ci->last_topic = params[2]; } else if (key.equals_ci("FORBID")) @@ -732,7 +732,7 @@ class DBPlain : public Module } int level = params[1].is_number_only() ? convertTo(params[1]) : 0; - time_t last_seen = params[2].is_number_only() ? convertTo(params[2]) : 0; + time_t last_seen = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; ci->AddAccess(nc, level, params[3], last_seen); } else if (key.equals_ci("AKICK")) @@ -752,9 +752,9 @@ class DBPlain : public Module } AutoKick *ak; if (Nick) - ak = ci->AddAkick(params[3], nc, params.size() > 6 ? params[6] : "", params[4].is_number_only() ? convertTo(params[4]) : 0, params[5].is_number_only() ? convertTo(params[5]) : 0); + ak = ci->AddAkick(params[3], nc, params.size() > 6 ? params[6] : "", params[4].is_pos_number_only() ? convertTo(params[4]) : 0, params[5].is_pos_number_only() ? convertTo(params[5]) : 0); else - ak = ci->AddAkick(params[3], params[2], params.size() > 6 ? params[6] : "", params[4].is_number_only() ? convertTo(params[4]) : 0, params[5].is_number_only() ? convertTo(params[5]) : 0); + ak = ci->AddAkick(params[3], params[2], params.size() > 6 ? params[6] : "", params[4].is_pos_number_only() ? convertTo(params[4]) : 0, params[5].is_pos_number_only() ? convertTo(params[5]) : 0); if (Stuck) ak->SetFlag(AK_STUCK); if (Nick) @@ -781,8 +781,8 @@ class DBPlain : public Module else if (key.equals_ci("MI")) { Memo *m = new Memo; - m->number = params[0].is_number_only() ? convertTo(params[0]) : 0; - m->time = params[1].is_number_only() ? convertTo(params[1]) : 0; + m->number = params[0].is_pos_number_only() ? convertTo(params[0]) : 0; + m->time = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; m->sender = params[2]; for (unsigned j = 3; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j) { @@ -814,35 +814,35 @@ class DBPlain : public Module for (unsigned j = 1, end = params.size(); j < end; j += 2) { if (params[j].equals_ci("BOLDS")) - ci->ttb[0] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[0] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("COLORS")) - ci->ttb[1] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[1] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("REVERSES")) - ci->ttb[2] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[2] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("UNDERLINES")) - ci->ttb[3] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[3] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("BADWORDS")) - ci->ttb[4] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[4] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("CAPS")) - ci->ttb[5] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[5] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("FLOOD")) - ci->ttb[6] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[6] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("REPEAT")) - ci->ttb[7] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[7] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; else if (params[j].equals_ci("ITALICS")) - ci->ttb[8] = params[j + 1].is_number_only() ? convertTo(params[j + 1]) : 0; + ci->ttb[8] = params[j + 1].is_pos_number_only() ? convertTo(params[j + 1]) : 0; } } else if (params[0].equals_ci("CAPSMIN")) - ci->capsmin = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->capsmin = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; else if (params[0].equals_ci("CAPSPERCENT")) - ci->capspercent = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->capspercent = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; else if (params[0].equals_ci("FLOODLINES")) - ci->floodlines = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->floodlines = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; else if (params[0].equals_ci("FLOODSECS")) - ci->floodsecs = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->floodsecs = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; else if (params[0].equals_ci("REPEATTIMES")) - ci->repeattimes = params[1].is_number_only() ? convertTo(params[1]) : 0; + ci->repeattimes = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; else if (params[0].equals_ci("BADWORD")) { BadWordType Type; diff --git a/modules/core/os_ignore.cpp b/modules/core/os_ignore.cpp index 0068691f0..d62b3221a 100644 --- a/modules/core/os_ignore.cpp +++ b/modules/core/os_ignore.cpp @@ -153,7 +153,7 @@ class OSIgnore : public Module { IgnoreData *ign = new IgnoreData(); ign->mask = params[2]; - ign->time = params[3].is_number_only() ? convertTo(params[3]) : 0; + ign->time = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; ignore.push_front(ign); return EVENT_STOP; diff --git a/modules/core/os_news.cpp b/modules/core/os_news.cpp index 8c159b32d..c12f66756 100644 --- a/modules/core/os_news.cpp +++ b/modules/core/os_news.cpp @@ -246,7 +246,7 @@ class NewsBase : public Command } if (!text.equals_ci("ALL")) { - num = text.is_number_only() ? convertTo(text) : 0; + num = text.is_pos_number_only() ? convertTo(text) : 0; if (num > 0 && del_newsitem(num, type)) { notice_lang(Config->s_OperServ, u, msgs[MSG_DELETED], num); @@ -440,7 +440,7 @@ class OSNews : public Module if (params[0].equals_ci("OS") && params.size() >= 7 && params[1].equals_ci("NEWS")) { NewsItem *n = new NewsItem(); - n->num = params[2].is_number_only() ? convertTo(params[2]) : 0; + n->num = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; n->time = params[3].is_number_only() ? convertTo(params[3]) : 0; n->who = params[4]; if (params[5].equals_ci("LOGON")) diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index 4aeac0322..c09c2c336 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -478,8 +478,8 @@ class DBMySQL : public Module na->last_quit = r.Get(i, "last_quit"); na->last_realname = r.Get(i, "last_realname"); na->last_usermask = r.Get(i, "last_usermask"); - na->time_registered = r.Get(i, "time_registered").is_number_only() ? convertTo(r.Get(i, "time_registered")) : time(NULL); - na->last_seen = r.Get(i, "last_seen").is_number_only() ? convertTo(r.Get(i, "last_seen")) : time(NULL); + na->time_registered = r.Get(i, "time_registered").is_pos_number_only() ? convertTo(r.Get(i, "time_registered")) : time(NULL); + na->last_seen = r.Get(i, "last_seen").is_pos_number_only() ? convertTo(r.Get(i, "last_seen")) : time(NULL); spacesepstream sep(r.Get(i, "flags")); Anope::string buf; @@ -520,7 +520,7 @@ class DBMySQL : public Module bi->SetIdent(r.Get(i, "user")); bi->host = r.Get(i, "host"); bi->realname = r.Get(i, "rname"); - bi->created = r.Get(i, "created").is_number_only() ? convertTo(r.Get(i, "creeated")) : time(NULL); + bi->created = r.Get(i, "created").is_pos_number_only() ? convertTo(r.Get(i, "creeated")) : time(NULL); spacesepstream sep(r.Get(i, "flags")); Anope::string buf; @@ -571,8 +571,8 @@ class DBMySQL : public Module if (!r.Get(i, "successor").empty()) ci->successor = findcore(r.Get(i, "successor")); ci->desc = r.Get(i, "descr"); - ci->time_registered = r.Get(i, "time_registered").is_number_only() ? convertTo(r.Get(i, "time_registered")) : time(NULL); - ci->last_used = r.Get(i, "last_used").is_number_only() ? convertTo(r.Get(i, "last_used")) : time(NULL); + ci->time_registered = r.Get(i, "time_registered").is_pos_number_only() ? convertTo(r.Get(i, "time_registered")) : time(NULL); + ci->last_used = r.Get(i, "last_used").is_pos_number_only() ? convertTo(r.Get(i, "last_used")) : time(NULL); ci->last_topic = r.Get(i, "last_topic"); ci->last_topic_setter = r.Get(i, "last_topic_setter"); ci->last_topic_time = r.Get(i, "last_topic_time").is_number_only() ? convertTo(r.Get(i, "last_topic_time")) : time(NULL); @@ -708,7 +708,7 @@ class DBMySQL : public Module continue; } - ci->AddAccess(nc, atoi(r.Get(i, "level").c_str()), r.Get(i, "creator"), (r.Get(i, "last_seen").is_number_only() ? convertTo(r.Get(i, "last_seen")) : time(NULL))); + ci->AddAccess(nc, atoi(r.Get(i, "level").c_str()), r.Get(i, "creator"), (r.Get(i, "last_seen").is_pos_number_only() ? convertTo(r.Get(i, "last_seen")) : time(NULL))); } r = SQL->RunQuery("SELECT * FROM `anope_cs_akick`"); @@ -779,7 +779,7 @@ class DBMySQL : public Module nr->password = r.Get(i, "passcode"); nr->password = r.Get(i, "password"); nr->email = r.Get(i, "email"); - nr->requested = r.Get(i, "requested").is_number_only() ? convertTo(r.Get(i, "requested")) : time(NULL); + nr->requested = r.Get(i, "requested").is_pos_number_only() ? convertTo(r.Get(i, "requested")) : time(NULL); } r = SQL->RunQuery("SELECT * FROM `anope_ms_info`"); @@ -814,7 +814,7 @@ class DBMySQL : public Module } else m->number = 1; - m->time = r.Get(i, "time").is_number_only() ? convertTo(r.Get(i, "time")) : time(NULL); + m->time = r.Get(i, "time").is_pos_number_only() ? convertTo(r.Get(i, "time")) : time(NULL); m->text = r.Get(i, "text"); if (!r.Get(i, "flags").empty()) @@ -845,8 +845,8 @@ class DBMySQL : public Module Anope::string host = r.Get(i, "host"); Anope::string by = r.Get(i, "by"); Anope::string reason = r.Get(i, "reason"); - time_t seton = r.Get(i, "seton").is_number_only() ? convertTo(r.Get(i, "seton")) : time(NULL); - time_t expires = r.Get(i, "expires").is_number_only() ? convertTo(r.Get(i, "expires")) : time(NULL); + time_t seton = r.Get(i, "seton").is_pos_number_only() ? convertTo(r.Get(i, "seton")) : time(NULL); + time_t expires = r.Get(i, "expires").is_pos_number_only() ? convertTo(r.Get(i, "expires")) : time(NULL); XLine *x = SGLine->Add(NULL, NULL, user + "@" + host, expires, reason); if (x) @@ -863,8 +863,8 @@ class DBMySQL : public Module Anope::string mask = r.Get(i, "mask"); Anope::string by = r.Get(i, "xby"); Anope::string reason = r.Get(i, "reason"); - time_t seton = r.Get(i, "seton").is_number_only() ? convertTo(r.Get(i, "seton")) : time(NULL); - time_t expires = r.Get(i, "expires").is_number_only() ? convertTo(r.Get(i, "expires")) : time(NULL); + time_t seton = r.Get(i, "seton").is_pos_number_only() ? convertTo(r.Get(i, "seton")) : time(NULL); + time_t expires = r.Get(i, "expires").is_pos_number_only() ? convertTo(r.Get(i, "expires")) : time(NULL); XLine *x = NULL; if (SNLine && r.Get(i, "type").equals_cs("SNLINE")) diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp index 3920c4b90..cb23b0e11 100644 --- a/modules/extra/hs_request.cpp +++ b/modules/extra/hs_request.cpp @@ -676,7 +676,7 @@ class HSRequest : public Module if (params[0].equals_ci("HS_REQUEST") && params.size() >= 5) { Anope::string vident = params[2].equals_ci("(null)") ? "" : params[2]; - my_add_host_request(params[1], vident, params[3], params[1], params[4].is_number_only() ? convertTo(params[4]) : 0); + my_add_host_request(params[1], vident, params[3], params[1], params[4].is_pos_number_only() ? convertTo(params[4]) : 0); return EVENT_STOP; } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 9c3e107a4..5ac8ff065 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -307,7 +307,7 @@ class BahamutIRCdProto : public IRCDProto int anope_event_sjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[1]); - time_t ts = Anope::string(av[0]).is_number_only() ? convertTo(av[0]) : 0; + time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo(av[0]) : 0; bool keep_their_modes = false; if (!c) @@ -456,7 +456,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, Anope::string(av[8]).is_number_only() ? convertTo(av[8]) : 0, "", ""); + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, Anope::string(av[8]).is_pos_number_only() ? convertTo(av[8]) : 0, "", ""); if (user) { UserSetInternalModes(user, 1, &av[3]); @@ -472,7 +472,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) } } else - do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, 0, "", ""); + do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, 0, "", ""); return MOD_CONT; } @@ -540,7 +540,7 @@ int anope_event_436(const Anope::string &source, int ac, const char **av) /* EVENT : SERVER */ int anope_event_server(const Anope::string &source, int ac, const char **av) { - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[2], ""); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[2], ""); return MOD_CONT; } diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index cc2c99fa6..453be6965 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -372,7 +372,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) /* Checking the TS for validity to avoid desyncs */ if ((c = findchan(av[0]))) { - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; if (c->creation_time > ts) /* Our TS is bigger, we should lower it */ c->creation_time = ts; @@ -403,7 +403,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) int anope_event_fjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[0]); - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; bool keep_their_modes = true; if (!c) @@ -717,7 +717,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) { if (ac == 8) { - time_t ts = Anope::string(av[0]).is_number_only() ? convertTo(av[0]) : 0; + time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo(av[0]) : 0; user = do_nick("", av[1], av[4], av[2], source, av[7], ts, 0, av[3], ""); if (user) @@ -766,7 +766,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) /* EVENT: SERVER */ int anope_event_server(const Anope::string &source, int ac, const char **av) { - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[2], ""); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[2], ""); return MOD_CONT; } @@ -983,7 +983,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) else if (capab.find("MAXMODES=") != std::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircd->maxmodes = maxmodes.is_number_only() ? convertTo(maxmodes) : 3; + ircd->maxmodes = maxmodes.is_pos_number_only() ? convertTo(maxmodes) : 3; } } } diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 55a371700..987590034 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -397,7 +397,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) /* Checking the TS for validity to avoid desyncs */ if ((c = findchan(av[0]))) { - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; if (c->creation_time > ts) /* Our TS is bigger, we should lower it */ c->creation_time = ts; @@ -436,7 +436,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) int anope_event_fjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[0]); - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; bool keep_their_modes = true; if (!c) @@ -809,7 +809,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) */ int anope_event_server(const Anope::string &source, int ac, const char **av) { - do_server(source, av[0], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, av[4], av[3]); + do_server(source, av[0], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, av[4], av[3]); return MOD_CONT; } @@ -1144,7 +1144,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) else if (capab.find("MAXMODES=") != Anope::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircd->maxmodes = maxmodes.is_number_only() ? convertTo(maxmodes) : 3; + ircd->maxmodes = maxmodes.is_pos_number_only() ? convertTo(maxmodes) : 3; } } } diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 8a8748d49..54c30d8df 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -395,7 +395,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) /* Checking the TS for validity to avoid desyncs */ if ((c = findchan(av[0]))) { - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; if (c->creation_time > ts) /* Our TS is bigger, we should lower it */ c->creation_time = ts; @@ -434,7 +434,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) int anope_event_fjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[0]); - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; bool keep_their_modes = true; if (!c) @@ -750,7 +750,7 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av) User *user; NickAlias *na; Server *s = Server::Find(source); - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; /* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using. * If not, validate the user. ~ Viper*/ @@ -806,7 +806,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) */ int anope_event_server(const Anope::string &source, int ac, const char **av) { - do_server(source, av[0], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, av[4], av[3]); + do_server(source, av[0], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, av[4], av[3]); return MOD_CONT; } @@ -852,7 +852,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) { if (!strcasecmp(av[0], "START")) { - if (ac < 2 || (Anope::string(av[1]).is_number_only() ? convertTo(av[1]): 0) < 1202) + if (ac < 2 || (Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]): 0) < 1202) { send_cmd("", "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START"); quitmsg = "Protocol mismatch, no or invalid protocol version given in CAPAB START"; @@ -1124,7 +1124,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) else if (capab.find("MAXMODES=") != Anope::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircd->maxmodes = maxmodes.is_number_only() ? convertTo(maxmodes) : 3; + ircd->maxmodes = maxmodes.is_pos_number_only() ? convertTo(maxmodes) : 3; } } } diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index a26ee9598..dc039682e 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -285,7 +285,7 @@ class RatboxProto : public IRCDTS6Proto int anope_event_sjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[1]); - time_t ts = Anope::string(av[0]).is_number_only() ? convertTo(av[0]) : 0; + time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo(av[0]) : 0; bool keep_their_modes = true; if (!c) @@ -410,7 +410,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) { Server *s = Server::Find(source); /* Source is always the server */ - user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, 0, "*", av[7]); + user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, 0, "*", av[7]); if (user) { UserSetInternalModes(user, 1, &av[3]); @@ -426,7 +426,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) } } else if (ac == 2) - do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, 0, "", ""); + do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, 0, "", ""); return MOD_CONT; } @@ -483,7 +483,7 @@ int anope_event_tburst(const Anope::string &source, int ac, const char **av) Anope::string setter = myStrGetToken(av[2], '!', 0); c = findchan(av[0]); - topic_time = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + topic_time = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; if (!c) { @@ -606,9 +606,9 @@ int anope_event_whois(const Anope::string &source, int ac, const char **av) int anope_event_server(const Anope::string &source, int ac, const char **av) { if (!stricmp(av[1], "1")) - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[2], TS6UPLINK); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[2], TS6UPLINK); else - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[2], ""); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[2], ""); return MOD_CONT; } @@ -617,7 +617,7 @@ int anope_event_sid(const Anope::string &source, int ac, const char **av) /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ Server *s = Server::Find(source); - do_server(s->GetName(), av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[3], av[2]); + do_server(s->GetName(), av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[3], av[2]); return MOD_CONT; } diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp index ff04e87eb..cb1949cb7 100644 --- a/modules/protocol/unreal32.cpp +++ b/modules/protocol/unreal32.cpp @@ -865,11 +865,11 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) it's sent when a nick collision occurs - so we have to leave it around for now -TSL */ - do_nick(source, av[0], av[3], av[4], av[5], av[6], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, 0, "*", ""); + do_nick(source, av[0], av[3], av[4], av[5], av[6], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, 0, "*", ""); } else if (ac == 11) { - user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, ntohl(decode_ip(av[9])), av[8], ""); + user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, ntohl(decode_ip(av[9])), av[8], ""); if (user) { UserSetInternalModes(user, 1, &av[7]); @@ -888,7 +888,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) else { /* NON NICKIP */ - user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0, 0, av[8], ""); + user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0, 0, av[8], ""); if (user) { UserSetInternalModes(user, 1, &av[7]); @@ -906,7 +906,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av) } } else - do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, 0, "", ""); + do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, 0, "", ""); return MOD_CONT; } @@ -936,10 +936,10 @@ int anope_event_server(const Anope::string &source, int ac, const char **av) Anope::string vl = myStrGetToken(av[2], ' ', 0); Anope::string upnumeric = myStrGetToken(vl, '-', 2); Anope::string desc = myStrGetTokenRemainder(av[2], ' ', 1); - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, desc, upnumeric); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, desc, upnumeric); } else - do_server(source, av[0], Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0, av[2], ""); + do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0, av[2], ""); ircdproto->SendPing(Config->ServerName, av[0]); return MOD_CONT; @@ -992,7 +992,7 @@ int anope_event_sdesc(const Anope::string &source, int ac, const char **av) int anope_event_sjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[1]); - time_t ts = Anope::string(av[0]).is_number_only() ? convertTo(av[0]) : 0; + time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo(av[0]) : 0; bool keep_their_modes = true; if (!c) diff --git a/src/channels.cpp b/src/channels.cpp index 65668a6d6..aa2e0affc 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -1145,7 +1145,7 @@ void do_join(const Anope::string &source, int ac, const char **av) /* Join came with a TS */ if (ac == 2) { - time_t ts = Anope::string(av[1]).is_number_only() ? convertTo(av[1]) : 0; + time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo(av[1]) : 0; /* Their time is older, we lose */ if (chan->creation_time > ts) @@ -1309,7 +1309,7 @@ void do_topic(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[0]); ChannelInfo *ci; - time_t topic_time = Anope::string(av[2]).is_number_only() ? convertTo(av[2]) : 0; + time_t topic_time = Anope::string(av[2]).is_pos_number_only() ? convertTo(av[2]) : 0; if (!c) { diff --git a/src/mail.cpp b/src/mail.cpp index 1cfdd6c09..354c7e2e7 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -40,7 +40,7 @@ bool Mail(User *u, NickRequest *nr, const Anope::string &service, const Anope::s if (!Config->UseMail) notice_lang(service, u, MAIL_DISABLED); else if (t - u->lastmail < Config->MailDelay) - notice_lang(service, u, MAIL_DELAYED, t - u->lastmail); + notice_lang(service, u, MAIL_DELAYED, Config->MailDelay - t - u->lastmail); else if (nr->email.empty()) notice_lang(service, u, MAIL_INVALID, nr->nick.c_str()); else @@ -63,7 +63,7 @@ bool Mail(User *u, NickCore *nc, const Anope::string &service, const Anope::stri if (!Config->UseMail) notice_lang(service, u, MAIL_DISABLED); else if (t - u->lastmail < Config->MailDelay) - notice_lang(service, u, MAIL_DELAYED, t - u->lastmail); + notice_lang(service, u, MAIL_DELAYED, Config->MailDelay - t - u->lastmail); else if (nc->email.empty()) notice_lang(service, u, MAIL_INVALID, nc->display.c_str()); else