本文整理汇总了C++中IS_LOCAL函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_LOCAL函数的具体用法?C++ IS_LOCAL怎么用?C++ IS_LOCAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IS_LOCAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveCloneCounts
void UserManager::RemoveCloneCounts(User *user)
{
if (IS_LOCAL(user))
{
clonemap::iterator x = local_clones.find(user->GetCIDRMask());
if (x != local_clones.end())
{
x->second--;
if (!x->second)
{
local_clones.erase(x);
}
}
}
clonemap::iterator y = global_clones.find(user->GetCIDRMask());
if (y != global_clones.end())
{
y->second--;
if (!y->second)
{
global_clones.erase(y);
}
}
}
示例2: checkHoplimit
static bool checkHoplimit(MacInfo_t *info)
{
if (IS_LOCAL(info)) return true; // only for forwarding
if (!info->hoplimit) return true; // hoplimit is optional
if (--info->hoplimit) return true; // shold be larger than zero after decrement
return false;
}
示例3: OnUserJoin
void ModuleSpanningTree::OnUserJoin(userrec* user, chanrec* channel, bool &silent)
{
// Only do this for local users
if (IS_LOCAL(user))
{
if (channel->GetUserCounter() == 1)
{
std::deque<std::string> params;
// set up their permissions and the channel TS with FJOIN.
// All users are FJOINed now, because a module may specify
// new joining permissions for the user.
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->nick));
Utils->DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
/* First user in, sync the modes for the channel */
params.pop_back();
params.push_back(channel->ChanModes(true));
Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
}
else
{
std::deque<std::string> params;
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
Utils->DoOneToMany(user->nick,"JOIN",params);
}
}
}
示例4: HandleSquit
int ModuleSpanningTree::HandleSquit(const char** parameters, int pcnt, userrec* user)
{
TreeServer* s = Utils->FindServerMask(parameters[0]);
if (s)
{
if (s == Utils->TreeRoot)
{
user->WriteServ("NOTICE %s :*** SQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)",user->nick,parameters[0]);
return 1;
}
TreeSocket* sock = s->GetSocket();
if (sock)
{
ServerInstance->SNO->WriteToSnoMask('l',"SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
sock->Squit(s,std::string("Server quit by ") + user->GetFullRealHost());
ServerInstance->SE->DelFd(sock);
sock->Close();
}
else
{
if (IS_LOCAL(user))
user->WriteServ("NOTICE %s :*** WARNING: Using SQUIT to split remote servers is deprecated. Please use RSQUIT instead.",user->nick);
}
}
else
{
user->WriteServ("NOTICE %s :*** SQUIT: The server \002%s\002 does not exist on the network.",user->nick,parameters[0]);
}
return 1;
}
示例5: OnMode
void ModuleSpanningTree::OnMode(userrec* user, void* dest, int target_type, const std::string &text)
{
if ((IS_LOCAL(user)) && (user->registered == REG_ALL))
{
std::deque<std::string> params;
std::string command;
if (target_type == TYPE_USER)
{
userrec* u = (userrec*)dest;
params.push_back(u->nick);
params.push_back(text);
command = "MODE";
}
else
{
chanrec* c = (chanrec*)dest;
params.push_back(c->name);
params.push_back(ConvToStr(c->age));
params.push_back(text);
command = "FMODE";
}
Utils->DoOneToMany(user->nick, command, params);
}
}
示例6: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
if ((dest) && (dest->registered == REG_ALL))
{
if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
}
if (IS_LOCAL(user) && !ServerInstance->IsChannel(parameters[1]))
{
/* we didn't need to check this for each character ;) */
user->WriteNotice("*** Invalid characters in channel name or name too long");
return CMD_FAILURE;
}
/* For local users, we call Channel::JoinUser which may create a channel and set its TS.
* For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
* and then that server will handle the command.
*/
LocalUser* localuser = IS_LOCAL(dest);
if (localuser)
{
Channel* n = Channel::JoinUser(localuser, parameters[1], true);
if (n && n->HasUser(dest))
{
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SAJOIN to make "+dest->nick+" join "+parameters[1]);
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Could not join "+dest->nick+" to "+parameters[1]);
return CMD_FAILURE;
}
}
else
{
return CMD_SUCCESS;
}
}
else
{
user->WriteNotice("*** No such nickname "+parameters[0]);
return CMD_FAILURE;
}
}
示例7: if
void ModuleSpanningTree::OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list)
{
if (target_type == TYPE_USER)
{
userrec* d = (userrec*)dest;
if ((d->GetFd() < 0) && (IS_LOCAL(user)))
{
std::deque<std::string> params;
params.clear();
params.push_back(d->nick);
params.push_back(":"+text);
Utils->DoOneToOne(user->nick,"NOTICE",params,d->server);
}
}
else if (target_type == TYPE_CHANNEL)
{
if (IS_LOCAL(user))
{
chanrec *c = (chanrec*)dest;
if (c)
{
std::string cname = c->name;
if (status)
cname = status + cname;
TreeServerList list;
Utils->GetListOfServersForChannel(c,list,status,exempt_list);
for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
{
TreeSocket* Sock = i->second->GetSocket();
if (Sock)
Sock->WriteLine(":"+std::string(user->nick)+" NOTICE "+cname+" :"+text);
}
}
}
}
else if (target_type == TYPE_SERVER)
{
if (IS_LOCAL(user))
{
char* target = (char*)dest;
std::deque<std::string> par;
par.push_back(target);
par.push_back(":"+text);
Utils->DoOneToMany(user->nick,"NOTICE",par);
}
}
}
示例8: OnModeChange
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
if (adding)
{
if (IS_LOCAL(source))
{
if (!ServerInstance->IsChannel(parameter))
{
source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameter.c_str());
return MODEACTION_DENY;
}
}
if (IS_LOCAL(source) && !source->IsOper())
{
Channel* c = ServerInstance->FindChan(parameter);
if (!c)
{
source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.",parameter.c_str());
return MODEACTION_DENY;
}
else if (c->GetPrefixValue(source) < OP_VALUE)
{
source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.",parameter.c_str());
return MODEACTION_DENY;
}
}
if (channel->GetModeParameter(this) == parameter)
return MODEACTION_DENY;
/*
* We used to do some checking for circular +L here, but there is no real need for this any more especially as we
* now catch +L looping in PreJoin. Remove it, since O(n) logic makes me sad, and we catch it anyway. :) -- w00t
*/
return MODEACTION_ALLOW;
}
else
{
if (channel->IsModeSet(this))
{
return MODEACTION_ALLOW;
}
}
return MODEACTION_DENY;
}
示例9: GetRouting
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
if (IS_LOCAL(user))
// This is handled by the OnUserMessage hook to split the LoopCall pieces
return ROUTE_LOCALONLY;
else
return ROUTE_MESSAGE(parameters[0]);
}
示例10: OnUserPart
virtual void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts)
{
if (!IS_LOCAL(memb->user))
return;
if (memb->chan->GetExtBanStatus(memb->user, 'p') == MOD_RES_DENY)
partmessage.clear();
}
示例11: OnWhois
// :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
virtual void OnWhois(userrec* source, userrec* dest)
{
// Bugfix, only send this numeric for *our* SSL users
if(dest->GetExt("ssl", dummy) || (IS_LOCAL(dest) && isin(dest->GetPort(), listenports)))
{
source->WriteServ("320 %s %s :is using a secure connection", source->nick, dest->nick);
}
}
示例12: OnPostTopicChange
void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std::string &topic)
{
// Drop remote events on the floor.
if (!IS_LOCAL(user))
return;
CommandFTopic::Builder(user, chan).Broadcast();
}
示例13: FIRST_MOD_RESULT
bool User::ChangeName(const std::string& gecos)
{
if (!this->fullname.compare(gecos))
return true;
if (IS_LOCAL(this))
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnChangeLocalUserGECOS, MOD_RESULT, (IS_LOCAL(this),gecos));
if (MOD_RESULT == MOD_RES_DENY)
return false;
FOREACH_MOD(OnChangeName, (this,gecos));
}
this->fullname.assign(gecos, 0, ServerInstance->Config->Limits.MaxGecos);
return true;
}
示例14: OnModeChange
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
if (adding)
{
std::string::size_type colon = parameter.find(':');
if (colon == std::string::npos)
return MODEACTION_DENY;
std::string duration = parameter.substr(colon+1);
if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!IsValidDuration(duration))))
return MODEACTION_DENY;
unsigned int len = ConvToInt(parameter.substr(0, colon));
int time = InspIRCd::Duration(duration);
if (len == 0 || time < 0)
return MODEACTION_DENY;
if (len > maxlines && IS_LOCAL(source))
return MODEACTION_DENY;
if (len > maxlines)
len = maxlines;
if (parameter == channel->GetModeParameter(this))
return MODEACTION_DENY;
HistoryList* history = ext.get(channel);
if (history)
{
// Shrink the list if the new line number limit is lower than the old one
if (len < history->lines.size())
history->lines.erase(history->lines.begin(), history->lines.begin() + (history->lines.size() - len));
history->maxlen = len;
history->maxtime = time;
}
else
{
ext.set(channel, new HistoryList(len, time));
}
}
else
{
if (!channel->IsModeSet(this))
return MODEACTION_DENY;
ext.unset(channel);
}
return MODEACTION_ALLOW;
}
示例15: Handle
/** Handle /MODULES
*/
CmdResult CommandModules::Handle(User* user, const Params& parameters)
{
// Don't ask remote servers about their modules unless the local user asking is an oper
// 2.0 asks anyway, so let's handle that the same way
bool for_us = (parameters.empty() || irc::equals(parameters[0], ServerInstance->Config->ServerName));
if ((!for_us) || (!IS_LOCAL(user)))
{
if (!user->IsOper())
{
user->WriteNotice("*** You cannot check what modules other servers have loaded.");
return CMD_FAILURE;
}
// From an oper and not for us, forward
if (!for_us)
return CMD_SUCCESS;
}
const ModuleManager::ModuleMap& mods = ServerInstance->Modules.GetModules();
for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
{
Module* m = i->second;
Version V = m->GetVersion();
if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
{
std::string flags("VCO");
size_t pos = 0;
for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
if (!(V.Flags & mult))
flags[pos] = '-';
std::string srcrev = m->ModuleDLLManager->GetVersion();
user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev.empty() ? "*" : srcrev, flags, V.description);
}
else
{
user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, '*', '*', V.description);
}
}
user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");
return CMD_SUCCESS;
}