本文整理汇总了C++中anope::string类的典型用法代码示例。如果您正苦于以下问题:C++ string类的具体用法?C++ string怎么用?C++ string使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bot_raw_ban
/* Makes a simple ban and kicks the target
* @param requester The user requesting the kickban
* @param ci The channel
* @param u The user being kicked
* @param reason The reason
*/
void bot_raw_ban(User *requester, ChannelInfo *ci, User *u, const Anope::string &reason)
{
if (!u || !ci)
return;
if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u)
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, ACCESS_DENIED));
return;
}
AccessGroup u_access = ci->AccessFor(u), req_access = ci->AccessFor(requester);
if (ci->HasFlag(CI_PEACE) && u != requester && u_access >= req_access)
return;
if (matches_list(ci->c, u, CMODE_EXCEPT))
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, _("User matches channel except.")));
return;
}
Anope::string mask;
get_idealban(ci, u, mask);
ci->c->SetMode(NULL, CMODE_BAN, mask);
/* Check if we need to do a signkick or not -GD */
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !req_access.HasPriv("SIGNKICK")))
ci->c->Kick(ci->bi, u, "%s (%s)", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str(), requester->nick.c_str());
else
ci->c->Kick(ci->bi, u, "%s", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str());
}
示例2: DoDel
void DoDel(CommandSource &source, NickServ::Account *nc, Anope::string certfp)
{
std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
if (certfp.empty())
{
User *u = source.GetUser();
if (u)
certfp = u->fingerprint;
}
if (certfp.empty())
{
this->OnSyntaxError(source, "DEL");
return;
}
NSCertEntry *cert = FindCert(cl, certfp);
if (!cert)
{
source.Reply(_("\002{0}\002 not found on the certificate list of \002{1}\002."), certfp, nc->GetDisplay());
return;
}
cert->Delete();
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE certificate fingerprint " << certfp << " from " << nc->GetDisplay();
source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), certfp, nc->GetDisplay());
}
示例3: SendChannel
void SendChannel(Channel *c)
{
Anope::string modes = c->GetModes(true, true);
if (modes.empty())
modes = "+";
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
示例4: OnEncrypt
EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
if (!md5)
return EVENT_CONTINUE;
Encryption::Context *context = md5->CreateContext();
context->Update(reinterpret_cast<const unsigned char *>(src.c_str()), src.length());
context->Finalize();
Encryption::Hash hash = context->GetFinalizedHash();
char digest[32], digest2[16];
memset(digest, 0, sizeof(digest));
if (hash.second > sizeof(digest))
throw CoreException("Hash too large");
memcpy(digest, hash.first, hash.second);
for (int i = 0; i < 32; i += 2)
digest2[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]);
Anope::string buf = "oldmd5:" + Anope::Hex(digest2, sizeof(digest2));
Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]";
dest = buf;
delete context;
return EVENT_ALLOW;
}
示例5: DeleteModule
ModuleReturn ModuleManager::DeleteModule(Module *m)
{
if (!m || !m->handle)
return MOD_ERR_PARAMS;
void *handle = m->handle;
Anope::string filename = m->filename;
Log(LOG_DEBUG) << "Unloading module " << m->name;
dlerror();
void (*destroy_func)(Module *m) = function_cast<void (*)(Module *)>(dlsym(m->handle, "AnopeFini"));
const char *err = dlerror();
if (!destroy_func || (err && *err))
{
Log() << "No destroy function found for " << m->name << ", chancing delete...";
delete m; /* we just have to chance they haven't overwrote the delete operator then... */
}
else
destroy_func(m); /* Let the module delete it self, just in case */
if (dlclose(handle))
Log() << dlerror();
if (!filename.empty())
unlink(filename.c_str());
return MOD_ERR_OK;
}
示例6: Run
/*
* RFC 2813, 4.2.2: Njoin Message:
* The NJOIN message is used between servers only.
* It is used when two servers connect to each other to exchange
* the list of channel members for each channel.
*
* Even though the same function can be performed by using a succession
* of JOIN, this message SHOULD be used instead as it is more efficient.
*
* Received: :dev.anope.de NJOIN #test :DukeP2,@DukeP,%test,+test2
*/
void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override
{
std::list<Message::Join::SJoinUser> users;
commasepstream sep(params[1]);
Anope::string buf;
while (sep.GetToken(buf))
{
Message::Join::SJoinUser sju;
/* Get prefixes from the nick */
for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
{
buf.erase(buf.begin());
sju.first.AddMode(ch);
}
sju.second = User::Find(buf);
if (!sju.second)
{
Log(LOG_DEBUG) << "NJOIN for non-existent user " << buf << " on " << params[0];
continue;
}
users.push_back(sju);
}
Message::Join::SJoin(source, params[0], 0, "", users);
}
示例7: DoDelete
void DoDelete(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word)
{
if (!badwords->GetBadWordCount(ci))
{
source.Reply(_("Bad word list for \002{0}\002 is empty."), ci->GetName());
return;
}
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
/* Special case: is it a number/list? Only do search if it isn't. */
if (!word.empty() && isdigit(word[0]) && word.find_first_not_of("1234567890,-") == Anope::string::npos)
{
unsigned int deleted = 0;
NumberList(word, true,
[&](unsigned int num)
{
if (!num || num > badwords->GetBadWordCount(ci))
return;
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badwords->GetBadWord(ci, num - 1)->GetWord();
++deleted;
badwords->EraseBadWord(ci, num - 1);
},
示例8: CleanupRuntimeDirectory
void ModuleManager::CleanupRuntimeDirectory()
{
Anope::string dirbuf = services_dir + "/modules/runtime";
Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait";
DIR *dirp = opendir(dirbuf.c_str());
if (!dirp)
{
Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")";
return;
}
for (dirent *dp; (dp = readdir(dirp));)
{
if (!dp->d_ino)
continue;
if (Anope::string(dp->d_name).equals_cs(".") || Anope::string(dp->d_name).equals_cs(".."))
continue;
Anope::string filebuf = dirbuf + "/" + dp->d_name;
unlink(filebuf.c_str());
}
closedir(dirp);
}
示例9: Check
bool Check(User *u, XLine *x) override
{
if (x->regex)
{
Anope::string uh = u->GetIdent() + "@" + u->host, nuhr = u->nick + "!" + uh + "#" + u->realname;
return std::regex_match(uh.str(), *x->regex) || std::regex_match(nuhr.str(), *x->regex);
}
if (!x->GetNick().empty() && !Anope::Match(u->nick, x->GetNick()))
return false;
if (!x->GetUser().empty() && !Anope::Match(u->GetIdent(), x->GetUser()))
return false;
if (!x->GetReal().empty() && !Anope::Match(u->realname, x->GetReal()))
return false;
if (x->c && x->c->match(u->ip))
return true;
if (x->GetHost().empty() || Anope::Match(u->host, x->GetHost()) || Anope::Match(u->ip.addr(), x->GetHost()))
return true;
return false;
}
示例10: Parse
void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope::string &command, std::vector<Anope::string> ¶ms)
{
spacesepstream sep(buffer);
if (buffer[0] == ':')
{
sep.GetToken(source);
source.erase(0, 1);
}
sep.GetToken(command);
for (Anope::string token; sep.GetToken(token);)
{
if (token[0] == ':')
{
if (!sep.StreamEnd())
params.push_back(token.substr(1) + " " + sep.GetRemaining());
else
params.push_back(token.substr(1));
break;
}
else
params.push_back(token);
}
}
示例11: InitLanguages
void Language::InitLanguages()
{
#if GETTEXT_FOUND
Log(LOG_DEBUG) << "Initializing Languages...";
Languages.clear();
if (!bindtextdomain("anope", Anope::LocaleDir.c_str()))
Log() << "Error calling bindtextdomain, " << Anope::LastError();
else
Log(LOG_DEBUG) << "Successfully bound anope to " << Anope::LocaleDir;
setlocale(LC_ALL, "");
spacesepstream sep(Config->GetBlock("options")->Get<Anope::string>("languages"));
Anope::string language;
while (sep.GetToken(language))
{
const Anope::string &lang_name = Translate(language.c_str(), _("English"));
if (lang_name == "English")
{
Log() << "Unable to use language " << language;
continue;
}
Log(LOG_DEBUG) << "Found language " << language;
Languages.push_back(language);
}
#else
Log() << "Unable to initialize languages, gettext is not installed";
#endif
}
示例12:
cidr::cidr(const Anope::string &ip)
{
bool ipv6 = ip.find(':') != Anope::string::npos;
size_t sl = ip.find_last_of('/');
if (sl == Anope::string::npos)
{
this->cidr_ip = ip;
this->cidr_len = ipv6 ? 128 : 32;
this->addr.pton(ipv6 ? AF_INET6 : AF_INET, ip);
}
else
{
Anope::string real_ip = ip.substr(0, sl);
Anope::string cidr_range = ip.substr(sl + 1);
this->cidr_ip = real_ip;
this->cidr_len = ipv6 ? 128 : 32;
try
{
if (cidr_range.is_pos_number_only())
this->cidr_len = convertTo<unsigned int>(cidr_range);
}
catch (const ConvertException &) { }
this->addr.pton(ipv6 ? AF_INET6 : AF_INET, real_ip);
}
}
示例13: pton
void sockaddrs::pton(int type, const Anope::string &address, int pport)
{
this->clear();
switch (type)
{
case AF_INET:
{
int i = inet_pton(type, address.c_str(), &sa4.sin_addr);
if (i <= 0)
this->clear();
else
{
sa4.sin_family = type;
sa4.sin_port = htons(pport);
}
break;
}
case AF_INET6:
{
int i = inet_pton(type, address.c_str(), &sa6.sin6_addr);
if (i <= 0)
this->clear();
else
{
sa6.sin6_family = type;
sa6.sin6_port = htons(pport);
}
break;
}
default:
break;
}
}
示例14: LocalUser
ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), botmodes(bmodes)
{
this->type = UserType::BOT;
this->lastmsg = Anope::CurTime;
this->introduced = false;
bi = botinfo.Create();
bi->bot = this;
bi->SetNick(nnick);
bi->SetUser(nuser);
bi->SetHost(nhost);
bi->SetRealName(nreal);
bi->SetCreated(Anope::CurTime);
Event::OnCreateBot(&Event::CreateBot::OnCreateBot, this);
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : IRCD->DefaultPseudoclientModes;
if (!tmodes.empty())
this->SetModesInternal(this, tmodes.c_str());
//XXX
//XLine x(this->nick, "Reserved for services");
//IRCD->SendSQLine(NULL, &x);
IRCD->SendClientIntroduction(this);
this->introduced = true;
}
}
示例15: DoCheckAuthentication
void DoCheckAuthentication(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
{
Anope::string username = request->data.size() > 0 ? request->data[0] : "";
Anope::string password = request->data.size() > 1 ? request->data[1] : "";
if (username.empty() || password.empty())
request->reply("error", "Invalid parameters");
else
{
NickAlias *na = findnick(username);
if (!na)
request->reply("error", "Invalid account");
else
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(NULL, NULL, std::vector<Anope::string>(), na->nc->display, password));
if (MOD_RESULT == EVENT_ALLOW)
{
request->reply("result", "Success");
request->reply("account", na->nc->display);
}
else
request->reply("error", "Invalid password");
}
}
}