本文整理汇总了C++中parameterlist类的典型用法代码示例。如果您正苦于以下问题:C++ parameterlist类的具体用法?C++ parameterlist怎么用?C++ parameterlist使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parameterlist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LocalPing
bool TreeSocket::LocalPing(const std::string &prefix, parameterlist ¶ms)
{
if (params.size() < 1)
return true;
if (params.size() == 1)
{
std::string stufftobounce = params[0];
this->WriteLine(":"+ServerInstance->Config->GetSID()+" PONG "+stufftobounce);
return true;
}
else
{
std::string forwardto = params[1];
if (forwardto == ServerInstance->Config->ServerName || forwardto == ServerInstance->Config->GetSID())
{
// this is a ping for us, send back PONG to the requesting server
params[1] = params[0];
params[0] = forwardto;
Utils->DoOneToOne(ServerInstance->Config->GetSID(),"PONG",params,params[1]);
}
else
{
// not for us, pass it on :)
Utils->DoOneToOne(prefix,"PING",params,forwardto);
}
return true;
}
}
示例2: ConstructLine
std::string SpanningTreeUtilities::ConstructLine(const std::string& prefix, const std::string& command, const parameterlist& params)
{
std::string FullLine;
FullLine.reserve(1024);
FullLine = ":" + prefix + " " + command;
for (parameterlist::const_iterator x = params.begin(); x != params.end(); ++x)
{
FullLine.push_back(' ');
FullLine.append(*x);
}
return FullLine;
}
示例3: Inbound_Server
/*
* Someone else is attempting to connect to us if this is called. Validate their credentials etc.
* -- w
*/
bool TreeSocket::Inbound_Server(parameterlist ¶ms)
{
if (params.size() < 5)
{
SendError("Protocol error - Missing SID");
return false;
}
irc::string servername = params[0].c_str();
std::string sname = params[0];
std::string password = params[1];
std::string sid = params[3];
std::string description = params[4];
this->SendCapabilities(2);
if (!ServerInstance->IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
}
for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
{
Link* x = *i;
if (x->Name != servername && x->Name != "*") // open link allowance
continue;
if (!ComparePass(*x, password))
{
ServerInstance->SNO->WriteToSnoMask('l',"Invalid password on link: %s", x->Name.c_str());
continue;
}
if (!CheckDuplicate(sname, sid))
return false;
ServerInstance->SNO->WriteToSnoMask('l',"Verified incoming server connection " + linkID + " ("+description+")");
this->SendCapabilities(2);
// Save these for later, so when they accept our credentials (indicated by BURST) we remember them
this->capab->hidden = x->Hidden;
this->capab->sid = sid;
this->capab->description = description;
this->capab->name = sname;
// Send our details: Our server name and description and hopcount of 0,
// along with the sendpass from this block.
this->WriteLine("SERVER "+ServerInstance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+ServerInstance->Config->GetSID()+" :"+ServerInstance->Config->ServerDesc);
// move to the next state, we are now waiting for THEM.
this->LinkState = WAIT_AUTH_2;
return true;
}
this->SendError("Invalid credentials");
ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, invalid link credentials");
return false;
}
示例4: DelLine
bool TreeSocket::DelLine(const std::string &prefix, parameterlist ¶ms)
{
if (params.size() < 2)
return true;
std::string setter = "<unknown>";
User* user = ServerInstance->FindNick(prefix);
if (user)
setter = user->nick;
else
{
TreeServer* t = Utils->FindServer(prefix);
if (t)
setter = t->GetName();
}
/* NOTE: No check needed on 'user', this function safely handles NULL */
if (ServerInstance->XLines->DelLine(params[1].c_str(), params[0], user))
{
ServerInstance->SNO->WriteToSnoMask('X',"%s removed %s%s on %s", setter.c_str(),
params[0].c_str(), params[0].length() == 1 ? "-line" : "", params[1].c_str());
Utils->DoOneToAllButSender(prefix,"DELLINE", params, prefix);
}
return true;
}
示例5: plist
/** ENCAP */
void TreeSocket::Encap(User* who, parameterlist ¶ms)
{
if (params.size() > 1)
{
if (ServerInstance->Config->GetSID() == params[0] || InspIRCd::Match(ServerInstance->Config->ServerName, params[0]))
{
parameterlist plist(params.begin() + 2, params.end());
ServerInstance->Parser->CallHandler(params[1], plist, who);
// discard return value, ENCAP shall succeed even if the command does not exist
}
params[params.size() - 1] = ":" + params[params.size() - 1];
if (params[0].find_first_of("*?") != std::string::npos)
{
Utils->DoOneToAllButSender(who->uuid, "ENCAP", params, who->server);
}
else
Utils->DoOneToOne(who->uuid, "ENCAP", params, params[0]);
}
}
示例6: SendMode
void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const parameterlist& modedata, const std::vector<TranslateType>& translate)
{
parameterlist params;
if (u)
{
if (u->registered != REG_ALL)
return;
params.push_back(u->uuid);
params.insert(params.end(), modedata.begin(), modedata.end());
Utils->DoOneToMany(source->uuid, "MODE", params);
}
else
{
params.push_back(c->name);
params.push_back(ConvToStr(c->age));
params.push_back(CommandParser::TranslateUIDs(translate, modedata));
Utils->DoOneToMany(source->uuid, "FMODE", params);
}
}
示例7: Away
bool TreeSocket::Away(const std::string &prefix, parameterlist ¶ms)
{
User* u = ServerInstance->FindNick(prefix);
if ((!u) || (IS_SERVER(u)))
return true;
if (params.size())
{
FOREACH_MOD(I_OnSetAway, OnSetAway(u, params[params.size() - 1]));
if (params.size() > 1)
u->awaytime = atoi(params[0].c_str());
else
u->awaytime = ServerInstance->Time();
u->awaymsg = params[params.size() - 1];
params[params.size() - 1] = ":" + params[params.size() - 1];
}
else
{
FOREACH_MOD(I_OnSetAway, OnSetAway(u, ""));
u->awaymsg.clear();
}
Utils->DoOneToAllButSender(prefix,"AWAY",params,u->server);
return true;
}
示例8: RemoteServer
/*
* Some server somewhere in the network introducing another server.
* -- w
*/
bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist ¶ms)
{
if (params.size() < 5)
{
SendError("Protocol error - Not enough parameters for SERVER command");
return false;
}
std::string servername = params[0];
// password is not used for a remote server
// hopcount is not used (ever)
std::string sid = params[3];
std::string description = params[4];
TreeServer* ParentOfThis = Utils->FindServer(prefix);
if (!ParentOfThis)
{
this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
return false;
}
if (!ServerInstance->IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
}
TreeServer* CheckDupe = Utils->FindServer(servername);
if (CheckDupe)
{
this->SendError("Server "+servername+" already exists!");
ServerInstance->SNO->WriteToSnoMask('L', "Server \2"+CheckDupe->GetName()+"\2 being introduced from \2" + ParentOfThis->GetName() + "\2 denied, already exists. Closing link with " + ParentOfThis->GetName());
return false;
}
CheckDupe = Utils->FindServer(sid);
if (CheckDupe)
{
this->SendError("Server ID "+sid+" already exists! You may want to specify the server ID for the server manually with <server:id> so they do not conflict.");
ServerInstance->SNO->WriteToSnoMask('L', "Server \2"+servername+"\2 being introduced from \2" + ParentOfThis->GetName() + "\2 denied, server ID already exists on the network. Closing link with " + ParentOfThis->GetName());
return false;
}
Link* lnk = Utils->FindLink(servername);
TreeServer *Node = new TreeServer(Utils, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false);
ParentOfThis->AddChild(Node);
params[4] = ":" + params[4];
Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+ParentOfThis->GetName()+"\002 introduced server \002"+servername+"\002 ("+description+")");
return true;
}
示例9: Push
bool TreeSocket::Push(const std::string &prefix, parameterlist ¶ms)
{
if (params.size() < 2)
return true;
User* u = ServerInstance->FindNick(params[0]);
if (!u)
return true;
if (IS_LOCAL(u))
{
u->Write(params[1]);
}
else
{
// continue the raw onwards
params[1] = ":" + params[1];
Utils->DoOneToOne(prefix,"PUSH",params,u->server);
}
return true;
}
示例10: Outbound_Reply_Server
/*
* This is used after the other side of a connection has accepted our credentials.
* They are then introducing themselves to us, BEFORE either of us burst. -- w
*/
bool TreeSocket::Outbound_Reply_Server(parameterlist ¶ms)
{
const Link* x = AuthRemote(params);
if (x)
{
/*
* They're in WAIT_AUTH_2 (having accepted our credentials).
* Set our state to CONNECTED (since everything's peachy so far) and send our
* netburst to them, which will trigger their CONNECTED state, and BURST in reply.
*
* While we're at it, create a treeserver object so we know about them.
* -- w
*/
FinishAuth(params[0], params[3], params.back(), x->Hidden);
return true;
}
return false;
}
示例11: ForceNick
/**
* SAVE command - force nick change to UID on timestamp match
*/
bool TreeSocket::ForceNick(const std::string &prefix, parameterlist ¶ms)
{
if (params.size() < 2)
return true;
User* u = ServerInstance->FindNick(params[0]);
time_t ts = atol(params[1].c_str());
if ((u) && (!IS_SERVER(u)) && (u->age == ts))
{
Utils->DoOneToAllButSender(prefix,"SAVE",params,prefix);
if (!u->ForceNickChange(u->uuid.c_str()))
{
ServerInstance->Users->QuitUser(u, "Nickname collision");
}
}
return true;
}
示例12: Inbound_Server
/*
* Someone else is attempting to connect to us if this is called. Validate their credentials etc.
* -- w
*/
bool TreeSocket::Inbound_Server(parameterlist ¶ms)
{
const Link* x = AuthRemote(params);
if (x)
{
// Save these for later, so when they accept our credentials (indicated by BURST) we remember them
this->capab->hidden = x->Hidden;
this->capab->sid = params[3];
this->capab->description = params.back();
this->capab->name = params[0];
// Send our details: Our server name and description and hopcount of 0,
// along with the sendpass from this block.
this->WriteLine("SERVER "+ServerInstance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+ServerInstance->Config->GetSID()+" :"+ServerInstance->Config->ServerDesc);
// move to the next state, we are now waiting for THEM.
this->LinkState = WAIT_AUTH_2;
return true;
}
return false;
}
示例13: Split
void TreeSocket::Split(const std::string& line, std::string& prefix, std::string& command, parameterlist& params)
{
irc::tokenstream tokens(line);
if (!tokens.GetToken(prefix))
return;
if (prefix[0] == ':')
{
prefix = prefix.substr(1);
if (prefix.empty())
{
this->SendError("BUG (?) Empty prefix received: " + line);
return;
}
if (!tokens.GetToken(command))
{
this->SendError("BUG (?) Empty command received: " + line);
return;
}
}
else
{
command = prefix;
prefix.clear();
}
if (command.empty())
this->SendError("BUG (?) Empty command received: " + line);
std::string param;
while (tokens.GetToken(param))
{
params.push_back(param);
}
}
示例14: ProcessConnectedLine
void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, parameterlist& params)
{
User* who = FindSource(prefix, command);
if (!who)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Command '%s' from unknown prefix '%s'! Dropping entire command.", command.c_str(), prefix.c_str());
return;
}
/*
* Check for fake direction here, and drop any instances that are found.
* What is fake direction? Imagine the following server setup:
* 0AA <-> 0AB <-> 0AC
* Fake direction would be 0AC sending a message to 0AB claiming to be from
* 0AA, or something similar. Basically, a message taking a path that *cannot*
* be correct.
*
* When would this be seen?
* Well, hopefully never. It could be caused by race conditions, bugs, or
* "miscreant" servers, though, so let's check anyway. -- w
*
* We also check here for totally invalid prefixes (prefixes that are neither
* a valid SID or a valid UUID, so that invalid UUID or SID never makes it
* to the higher level functions. -- B
*/
TreeServer* const server = TreeServer::Get(who);
if (server->GetSocket() != this)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'", prefix.c_str(), linkID.c_str());
return;
}
// Translate commands coming from servers using an older protocol
if (proto_version < ProtocolVersion)
{
if (!PreProcessOldProtocolMessage(who, command, params))
return;
}
ServerCommand* scmd = Utils->Creator->CmdManager.GetHandler(command);
CommandBase* cmdbase = scmd;
Command* cmd = NULL;
if (!scmd)
{
// Not a special server-to-server command
cmd = ServerInstance->Parser.GetHandler(command);
if (!cmd)
{
if (command == "ERROR")
{
this->Error(params);
return;
}
throw ProtocolException("Unknown command");
}
cmdbase = cmd;
}
if (params.size() < cmdbase->min_params)
throw ProtocolException("Insufficient parameters");
if ((!params.empty()) && (params.back().empty()) && (!cmdbase->allow_empty_last_param))
{
// the last param is empty and the command handler doesn't allow that, check if there will be enough params if we drop the last
if (params.size()-1 < cmdbase->min_params)
return;
params.pop_back();
}
CmdResult res;
if (scmd)
res = scmd->Handle(who, params);
else
{
res = cmd->Handle(params, who);
if (res == CMD_INVALID)
throw ProtocolException("Error in command handler");
}
if (res == CMD_SUCCESS)
Utils->RouteCommand(server->GetRoute(), cmdbase, params, who);
}
示例15: Capab
bool TreeSocket::Capab(const parameterlist ¶ms)
{
if (params.size() < 1)
{
this->SendError("Invalid number of parameters for CAPAB - Mismatched version");
return false;
}
if (params[0] == "START")
{
capab->ModuleList.clear();
capab->OptModuleList.clear();
capab->CapKeys.clear();
if (params.size() > 1)
proto_version = atoi(params[1].c_str());
SendCapabilities(2);
}
else if (params[0] == "END")
{
std::string reason;
/* Compare ModuleList and check CapKeys */
if ((this->capab->ModuleList != this->MyModules(VF_COMMON)) && (this->capab->ModuleList.length()))
{
std::string diffIneed, diffUneed;
ListDifference(this->capab->ModuleList, this->MyModules(VF_COMMON), ' ', diffIneed, diffUneed);
if (diffIneed.length() || diffUneed.length())
{
reason = "Modules incorrectly matched on these servers.";
if (diffIneed.length())
reason += " Not loaded here:" + diffIneed;
if (diffUneed.length())
reason += " Not loaded there:" + diffUneed;
this->SendError("CAPAB negotiation failed: "+reason);
return false;
}
}
if (this->capab->OptModuleList != this->MyModules(VF_OPTCOMMON) && this->capab->OptModuleList.length())
{
std::string diffIneed, diffUneed;
ListDifference(this->capab->OptModuleList, this->MyModules(VF_OPTCOMMON), ' ', diffIneed, diffUneed);
if (diffIneed.length() || diffUneed.length())
{
if (Utils->AllowOptCommon)
{
ServerInstance->SNO->WriteToSnoMask('l',
"Optional module lists do not match, some commands may not work globally.%s%s%s%s",
diffIneed.length() ? " Not loaded here:" : "", diffIneed.c_str(),
diffUneed.length() ? " Not loaded there:" : "", diffUneed.c_str());
}
else
{
reason = "Optional modules incorrectly matched on these servers, and options::allowmismatch not set.";
if (diffIneed.length())
reason += " Not loaded here:" + diffIneed;
if (diffUneed.length())
reason += " Not loaded there:" + diffUneed;
this->SendError("CAPAB negotiation failed: "+reason);
return false;
}
}
}
if (this->capab->CapKeys.find("PROTOCOL") == this->capab->CapKeys.end())
{
reason = "Protocol version not specified";
}
else
{
proto_version = atoi(capab->CapKeys.find("PROTOCOL")->second.c_str());
if (proto_version < MinCompatProtocol)
{
reason = "Server is using protocol version " + ConvToStr(proto_version) +
" which is too old to link with this server (version " + ConvToStr(ProtocolVersion)
+ (ProtocolVersion != MinCompatProtocol ? ", links with " + ConvToStr(MinCompatProtocol) + " and above)" : ")");
}
}
if(this->capab->CapKeys.find("PREFIX") != this->capab->CapKeys.end() && this->capab->CapKeys.find("PREFIX")->second != ServerInstance->Modes->BuildPrefixes())
reason = "One or more of the prefixes on the remote server are invalid on this server.";
if (!capab->ChanModes.empty())
{
if (capab->ChanModes != BuildModeList(MODETYPE_CHANNEL))
{
std::string diffIneed, diffUneed;
ListDifference(capab->ChanModes, BuildModeList(MODETYPE_CHANNEL), ' ', diffIneed, diffUneed);
if (diffIneed.length() || diffUneed.length())
{
reason = "Channel modes not matched on these servers.";
if (diffIneed.length())
reason += " Not loaded here:" + diffIneed;
if (diffUneed.length())
reason += " Not loaded there:" + diffUneed;
}
}
}
else if (this->capab->CapKeys.find("CHANMODES") != this->capab->CapKeys.end())
{
if (this->capab->CapKeys.find("CHANMODES")->second != ServerInstance->Modes->GiveModeList(MASK_CHANNEL))
reason = "One or more of the channel modes on the remote server are invalid on this server.";
}
//.........这里部分代码省略.........