当前位置: 首页>>代码示例>>C++>>正文


C++ FOREACH_MOD函数代码示例

本文整理汇总了C++中FOREACH_MOD函数的典型用法代码示例。如果您正苦于以下问题:C++ FOREACH_MOD函数的具体用法?C++ FOREACH_MOD怎么用?C++ FOREACH_MOD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FOREACH_MOD函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FOREACH_MOD

CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
{
	user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
	std::string parameter;
	std::string old_disabled = ServerInstance->Config->DisabledCommands;
	if (pcnt)
	{
		parameter = parameters[0];
	}
	else
	{
		ServerInstance->WriteOpers("*** %s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
		ServerInstance->CloseLog();
		ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc);
		ServerInstance->RehashUsersAndChans();
		FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
		ServerInstance->Config->Read(false,user);
		ServerInstance->Res->Rehash();
		ServerInstance->ResetMaxBans();
	}
	if (old_disabled != ServerInstance->Config->DisabledCommands)
		InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);

	FOREACH_MOD(I_OnRehash,OnRehash(user, parameter));

	ServerInstance->BuildISupport();

	return CMD_SUCCESS;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:29,代码来源:cmd_rehash.cpp

示例2: Tick

	void Tick(time_t)
	{
		if (!Config->CSExpire || noexpire || readonly)
			return;

		for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; )
		{
			ChannelInfo *ci = it->second;
			++it;

			bool expire = false;

			if (!ci->c && Config->CSExpire && Anope::CurTime - ci->last_used >= Config->CSExpire)
				expire = true;

			if (ci->HasFlag(CI_NO_EXPIRE))
				expire = false;

			FOREACH_MOD(I_OnPreChanExpire, OnPreChanExpire(ci, expire));

			if (expire)
			{
				Anope::string extra;
				if (ci->HasFlag(CI_SUSPENDED))
					extra = "suspended ";

				Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra  << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")";
				FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci));
				delete ci;
			}
		}
	}
开发者ID:xxgrunge,项目名称:anope196,代码行数:32,代码来源:chanserv.cpp

示例3: FOREACH_MOD

bool TreeSocket::Away(const std::string &prefix, parameterlist &params)
{
	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;
}
开发者ID:Shawn-Smith,项目名称:InspIRCd,代码行数:26,代码来源:away.cpp

示例4: DoMsg

	ModResult DoMsg(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list, bool privmsg)
	{
		if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL || status)
			return MOD_RES_PASSTHRU;

		Channel* chan = static_cast<Channel*>(dest);
		ModResult res = ServerInstance->OnCheckExemption(user,chan,"opmoderated");
		if (res == MOD_RES_ALLOW)
			return MOD_RES_PASSTHRU;
		if (!chan->GetExtBanStatus(user, 'u').check(!chan->IsModeSet(&mh)) && chan->GetPrefixValue(user) < VOICE_VALUE)
		{
			FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,text,status,exempt_list));
			chan->WriteAllExcept(user, false, '@', exempt_list, "%s @%s :%s",
				privmsg ? "PRIVMSG" : "NOTICE", chan->name.c_str(), text.c_str());
			if (privmsg)
			{
				FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,'@',exempt_list));
			}
			else
				FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,'@',exempt_list));

			return MOD_RES_DENY;
		}

		return MOD_RES_PASSTHRU;
	}
开发者ID:inspircd,项目名称:inspircd-extras,代码行数:26,代码来源:m_opmoderated.cpp

示例5: FOREACH_MOD

CmdResult cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
{
	if (pcnt >= 3)
	{
		if (strchr(parameters[0],'@') || strchr(parameters[0],'!'))
		{
			user->WriteServ("NOTICE %s :*** You cannot include a username or nickname in a zline, a zline must ban only an IP mask",user->nick);
			return CMD_FAILURE;
		}

		if (ServerInstance->IPMatchesEveryone(parameters[0],user))
			return CMD_FAILURE;

		long duration = ServerInstance->Duration(parameters[1]);
		if (ServerInstance->XLines->add_zline(duration,user->nick,parameters[2],parameters[0]))
		{
			int to_apply = APPLY_ZLINES;

			FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration, user, parameters[2], parameters[0]));
			if (!duration)
			{
				to_apply |= APPLY_PERM_ONLY;
				ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,parameters[0]);
			}
			else
			{
				time_t c_requires_crap = duration + ServerInstance->Time();
				ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,parameters[0],
						ServerInstance->TimeString(c_requires_crap).c_str());
			}
			ServerInstance->XLines->apply_lines(to_apply);
		}
		else
		{
			user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick,parameters[0]);
		}
	}
	else
	{
		if (ServerInstance->XLines->del_zline(parameters[0]))
		{
			FOREACH_MOD(I_OnDelZLine,OnDelZLine(user, parameters[0]));
			ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick,parameters[0]);
		}
		else
		{
			user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]);
			return CMD_FAILURE;
		}
	}

	return CMD_SUCCESS;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:53,代码来源:cmd_zline.cpp

示例6: FOREACH_MOD

void UserManager::QuitUser(User* user, const std::string& quitreason, const std::string* operreason)
{
	if (user->quitting)
	{
		ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: Tried to quit quitting user: " + user->nick);
		return;
	}

	if (IS_SERVER(user))
	{
		ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: Tried to quit server user: " + user->nick);
		return;
	}

	user->quitting = true;

	ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
	user->Write("ERROR :Closing link: (%[email protected]%s) [%s]", user->ident.c_str(), user->host.c_str(), operreason ? operreason->c_str() : quitreason.c_str());

	std::string reason;
	reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit);
	if (!operreason)
		operreason = &reason;

	ServerInstance->GlobalCulls.AddItem(user);

	if (user->registered == REG_ALL)
	{
		FOREACH_MOD(OnUserQuit, (user, reason, *operreason));
		user->WriteCommonQuit(reason, *operreason);
	}
	else
		unregistered_count--;

	if (IS_LOCAL(user))
	{
		LocalUser* lu = IS_LOCAL(user);
		FOREACH_MOD(OnUserDisconnect, (lu));
		lu->eh.Close();

		if (lu->registered == REG_ALL)
			ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", user->GetFullRealHost().c_str(), user->GetIPString().c_str(), operreason->c_str());
	}

	user_hash::iterator iter = this->clientlist->find(user->nick);

	if (iter != this->clientlist->end())
		this->clientlist->erase(iter);
	else
		ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: Nick not found in clientlist, cannot remove: " + user->nick);

	uuidlist->erase(user->uuid);
}
开发者ID:War3Evo,项目名称:inspircd,代码行数:53,代码来源:usermanager.cpp

示例7: FOREACH_MOD

CmdResult cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
{
	if (pcnt >= 3)
	{
		if (ServerInstance->NickMatchesEveryone(parameters[0],user))
			return CMD_FAILURE;

		if (strchr(parameters[0],'@') || strchr(parameters[0],'!') || strchr(parameters[0],'.'))
		{
			user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a [email protected] pattern.",user->nick);
			return CMD_FAILURE;
		}

		long duration = ServerInstance->Duration(parameters[1]);
		if (ServerInstance->XLines->add_qline(duration,user->nick,parameters[2],parameters[0]))
		{
			int to_apply = APPLY_QLINES;
			FOREACH_MOD(I_OnAddQLine,OnAddQLine(duration, user, parameters[2], parameters[0]));
			if (!duration)
			{
				to_apply |= APPLY_PERM_ONLY;
				ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0]);
			}
			else
			{
				time_t c_requires_crap = duration + ServerInstance->Time();
				ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0],
					  ServerInstance->TimeString(c_requires_crap).c_str());
			}
			ServerInstance->XLines->apply_lines(to_apply);
		}
		else
		{
			user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0]);
		}
	}
	else
	{
		if (ServerInstance->XLines->del_qline(parameters[0]))
		{
			FOREACH_MOD(I_OnDelQLine,OnDelQLine(user, parameters[0]));
			ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0]);
		}
		else
		{
			user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]);
			return CMD_FAILURE;
		}
	}

	return CMD_SUCCESS;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:52,代码来源:cmd_qline.cpp

示例8: FOREACH_MOD

CmdResult CommandMetadata::Handle(const std::vector<std::string>& params, User *srcuser)
{
	if (params[0] == "*")
	{
		std::string value = params.size() < 3 ? "" : params[2];
		FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(NULL,params[1],value));
		return CMD_SUCCESS;
	}

	if (params[0][0] == '#')
	{
		// Channel METADATA has an additional parameter: the channel TS
		// :22D METADATA #channel 12345 extname :extdata
		if (params.size() < 3)
			return CMD_INVALID;

		Channel* c = ServerInstance->FindChan(params[0]);
		if (!c)
			return CMD_FAILURE;

		time_t ChanTS = ConvToInt(params[1]);
		if (!ChanTS)
			return CMD_INVALID;

		if (c->age < ChanTS)
			// Their TS is newer than ours, discard this command and do not propagate
			return CMD_FAILURE;

		std::string value = params.size() < 4 ? "" : params[3];

		ExtensionItem* item = ServerInstance->Extensions.GetItem(params[2]);
		if (item)
			item->unserialize(FORMAT_NETWORK, c, value);
		FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(c,params[2],value));
	}
	else
	{
		User* u = ServerInstance->FindUUID(params[0]);
		if ((u) && (!IS_SERVER(u)))
		{
			ExtensionItem* item = ServerInstance->Extensions.GetItem(params[1]);
			std::string value = params.size() < 3 ? "" : params[2];

			if (item)
				item->unserialize(FORMAT_NETWORK, u, value);
			FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(u,params[1],value));
		}
	}

	return CMD_SUCCESS;
}
开发者ID:Paciik,项目名称:inspircd,代码行数:51,代码来源:metadata.cpp

示例9: strlcpy

/** Handle /AWAY
 */
CmdResult cmd_away::Handle (const char** parameters, int pcnt, userrec *user)
{
	if ((pcnt) && (*parameters[0]))
	{
		strlcpy(user->awaymsg,parameters[0],MAXAWAY);
		user->WriteServ("306 %s :You have been marked as being away",user->nick);
		FOREACH_MOD(I_OnSetAway,OnSetAway(user));
	}
	else
	{
		*user->awaymsg = 0;
		user->WriteServ("305 %s :You are no longer marked as being away",user->nick);
		FOREACH_MOD(I_OnCancelAway,OnCancelAway(user));
	}
	return CMD_SUCCESS;
}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:18,代码来源:cmd_away.cpp

示例10: FOREACH_MOD

void Server::Delete(const Anope::string &reason)
{
	this->quit_reason = reason;
	this->quitting = true;
	FOREACH_MOD(OnServerQuit, (this));
	delete this;
}
开发者ID:helixum,项目名称:ircnetwork,代码行数:7,代码来源:servers.cpp

示例11: UnsetExtensibles

NickAlias::~NickAlias()
{
	UnsetExtensibles();

	FOREACH_MOD(OnDelNick, (this));

	/* Accept nicks that have no core, because of database load functions */
	if (this->nc)
	{
		/* Next: see if our core is still useful. */
		std::vector<NickAlias *>::iterator it = std::find(this->nc->aliases->begin(), this->nc->aliases->end(), this);
		if (it != this->nc->aliases->end())
			this->nc->aliases->erase(it);
		if (this->nc->aliases->empty())
		{
			delete this->nc;
			this->nc = NULL;
		}
		else
		{
			/* Display updating stuff */
			if (this->nick.equals_ci(this->nc->display))
				this->nc->SetDisplay(this->nc->aliases->front());
		}
	}

	/* Remove us from the aliases list */
	NickAliasList->erase(this->nick);
}
开发者ID:RanadeepPolavarapu,项目名称:IRCd,代码行数:29,代码来源:nickalias.cpp

示例12: ConvToStr

/** This function is called when we want to send a netburst to a local
 * server. There is a set order we must do this, because for example
 * users require their servers to exist, and channels require their
 * users to exist. You get the idea.
 */
void TreeSocket::DoBurst(TreeServer* s)
{
	ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).",
		s->GetName().c_str(),
		capab->auth_fingerprint ? "SSL Fingerprint and " : "",
		capab->auth_challenge ? "challenge-response" : "plaintext password");
	this->CleanNegotiationInfo();
	this->WriteLine(":" + ServerInstance->Config->GetSID() + " BURST " + ConvToStr(ServerInstance->Time()));
	/* send our version string */
	this->WriteLine(":" + ServerInstance->Config->GetSID() + " VERSION :"+ServerInstance->GetVersionString());
	/* Send server tree */
	this->SendServers(Utils->TreeRoot, s);

	BurstState bs(this);
	/* Send users and their oper status */
	this->SendUsers(bs);

	for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
		SyncChannel(i->second, bs);

	this->SendXLines();
	FOREACH_MOD(OnSyncNetwork, (bs.server));
	this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
	ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
}
开发者ID:GeeksIRC,项目名称:inspircd,代码行数:30,代码来源:netburst.cpp

示例13: FOREACH_MOD

/** send all users and their oper state/modes */
void TreeSocket::SendUsers(BurstState& bs)
{
	ProtocolInterface::Server& piserver = bs.server;
	for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
	{
		User* user = u->second;
		if (user->registered != REG_ALL)
			continue;

		this->WriteLine(CommandUID::Builder(user));

		if (user->IsOper())
			this->WriteLine(CommandOpertype::Builder(user));

		if (user->IsAway())
			this->WriteLine(CommandAway::Builder(user));

		const Extensible::ExtensibleStore& exts = user->GetExtList();
		for (Extensible::ExtensibleStore::const_iterator i = exts.begin(); i != exts.end(); ++i)
		{
			ExtensionItem* item = i->first;
			std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second);
			if (!value.empty())
				this->WriteLine(CommandMetadata::Builder(user, item->name, value));
		}

		FOREACH_MOD(OnSyncUser, (user, piserver));
	}
}
开发者ID:GeeksIRC,项目名称:inspircd,代码行数:30,代码来源:netburst.cpp

示例14: do_whois

void do_whois(InspIRCd* ServerInstance, userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick)
{
	// bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER
	if (dest->registered == REG_ALL)
	{
		user->WriteServ("311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname);
		if ((user == dest) || (*user->oper))
		{
			user->WriteServ("378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->GetIPString());
		}
		std::string cl = dest->ChannelList(user);
		if (cl.length())
		{
			if (cl.length() > 400)
			{
				user->SplitChanList(dest,cl);
			}
			else
			{
				user->WriteServ("319 %s %s :%s",user->nick, dest->nick, cl.c_str());
			}
		}
		if (*ServerInstance->Config->HideWhoisServer && !(*user->oper))
		{
			user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network);
		}
		else
		{
			user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerInstance->GetServerDescription(dest->server).c_str());
		}
		if (*dest->awaymsg)
		{
			user->WriteServ("301 %s %s :%s",user->nick, dest->nick, dest->awaymsg);
		}
		if (*dest->oper)
		{
			user->WriteServ("313 %s %s :is %s %s on %s",user->nick, dest->nick, (strchr("AEIOUaeiou",*dest->oper) ? "an" : "a"),Spacify(dest->oper), ServerInstance->Config->Network);
		}
		if ((!signon) && (!idle))
		{
			FOREACH_MOD(I_OnWhois,OnWhois(user,dest));
		}
		if (!strcasecmp(user->server,dest->server))
		{
			// idle time and signon line can only be sent if youre on the same server (according to RFC)
			user->WriteServ("317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-ServerInstance->Time()), dest->signon);
		}
		else
		{
			if ((idle) || (signon))
				user->WriteServ("317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, idle, signon);
		}
		user->WriteServ("318 %s %s :End of /WHOIS list.",user->nick, dest->nick);
	}
	else
	{
		user->WriteServ("401 %s %s :No such nick/channel",user->nick, *nick ? nick : "*");
		user->WriteServ("318 %s %s :End of /WHOIS list.",user->nick, *nick ? nick : "*");
	}
}
开发者ID:mikebryant,项目名称:inspircd,代码行数:60,代码来源:cmd_whois.cpp

示例15: FOREACH_MOD

bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* user, bool simulate)
{
    ContainerIter x = lookup_lines.find(type);

    if (x == lookup_lines.end())
        return false;

    LookupIter y = x->second.find(hostmask);

    if (y == x->second.end())
        return false;

    if (simulate)
        return true;

    ServerInstance->BanCache->RemoveEntries(y->second->type, true);

    FOREACH_MOD(I_OnDelLine,OnDelLine(user, y->second));

    y->second->Unset();

    std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), y->second);
    if (pptr != pending_lines.end())
        pending_lines.erase(pptr);

    delete y->second;
    x->second.erase(y);

    return true;
}
开发者ID:H7-25,项目名称:inspircd,代码行数:30,代码来源:xline.cpp


注:本文中的FOREACH_MOD函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。