本文整理汇总了C++中XLine::SetCreateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ XLine::SetCreateTime方法的具体用法?C++ XLine::SetCreateTime怎么用?C++ XLine::SetCreateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLine
的用法示例。
在下文中一共展示了XLine::SetCreateTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Handle
CmdResult CommandAddLine::Handle(User* usr, std::vector<std::string>& params)
{
XLineFactory* xlf = ServerInstance->XLines->GetFactory(params[0]);
const std::string& setter = usr->nick;
if (!xlf)
{
ServerInstance->SNO->WriteToSnoMask('d',"%s sent me an unknown ADDLINE type (%s).",setter.c_str(),params[0].c_str());
return CMD_FAILURE;
}
XLine* xl = NULL;
try
{
xl = xlf->Generate(ServerInstance->Time(), ConvToInt(params[4]), params[2], params[5], params[1]);
}
catch (ModuleException &e)
{
ServerInstance->SNO->WriteToSnoMask('d',"Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason().c_str());
return CMD_FAILURE;
}
xl->SetCreateTime(ConvToInt(params[3]));
if (ServerInstance->XLines->AddLine(xl, NULL))
{
if (xl->duration)
{
std::string timestr = InspIRCd::TimeString(xl->expiry);
ServerInstance->SNO->WriteToSnoMask('X',"%s added %s%s on %s to expire on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "",
params[1].c_str(), timestr.c_str(), params[5].c_str());
}
else
{
ServerInstance->SNO->WriteToSnoMask('X',"%s added permanent %s%s on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "",
params[1].c_str(),params[5].c_str());
}
TreeServer* remoteserver = TreeServer::Get(usr);
if (!remoteserver->IsBursting())
{
ServerInstance->XLines->ApplyLines();
}
return CMD_SUCCESS;
}
else
{
delete xl;
return CMD_FAILURE;
}
}
示例2: ReadDatabase
bool ReadDatabase()
{
// If the xline database doesn't exist then we don't need to load it.
if (!FileSystem::FileExists(xlinedbpath))
return true;
std::ifstream stream(xlinedbpath.c_str());
if (!stream.is_open())
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Cannot read database! %s (%d)", strerror(errno), errno);
ServerInstance->SNO->WriteToSnoMask('a', "database: cannot read db: %s (%d)", strerror(errno), errno);
return false;
}
std::string line;
while (std::getline(stream, line))
{
// Inspired by the command parser. :)
irc::tokenstream tokens(line);
int items = 0;
std::string command_p[7];
std::string tmp;
while (tokens.GetToken(tmp) && (items < 7))
{
command_p[items] = tmp;
items++;
}
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Processing %s", line.c_str());
if (command_p[0] == "VERSION")
{
if (command_p[1] != "1")
{
stream.close();
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "I got database version %s - I don't understand it", command_p[1].c_str());
ServerInstance->SNO->WriteToSnoMask('a', "database: I got a database version (%s) I don't understand", command_p[1].c_str());
return false;
}
}
else if (command_p[0] == "LINE")
{
// Mercilessly stolen from spanningtree
XLineFactory* xlf = ServerInstance->XLines->GetFactory(command_p[1]);
if (!xlf)
{
ServerInstance->SNO->WriteToSnoMask('a', "database: Unknown line type (%s).", command_p[1].c_str());
continue;
}
XLine* xl = xlf->Generate(ServerInstance->Time(), atoi(command_p[5].c_str()), command_p[3], command_p[6], command_p[2]);
xl->SetCreateTime(atoi(command_p[4].c_str()));
if (ServerInstance->XLines->AddLine(xl, NULL))
{
ServerInstance->SNO->WriteToSnoMask('x', "database: Added a line of type %s", command_p[1].c_str());
}
else
delete xl;
}
}
stream.close();
return true;
}