]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_who.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / commands / cmd_who.cpp
index f8926b9f7a473e1ac5835a370cb63d5a91cb5292..82d541a2a7829802df5728fb237b06aa934755a1 100644 (file)
@@ -138,7 +138,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
                        match = InspIRCd::Match(user->awaymsg, matchtext);
                else if (opt_time)
                {
-                       long seconds = ServerInstance->Duration(matchtext);
+                       long seconds = InspIRCd::Duration(matchtext);
 
                        // Okay, so time matching, we want all users connected `seconds' ago
                        if (user->age >= ServerInstance->Time() - seconds)
@@ -197,11 +197,11 @@ void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms,
                wholine.append(ServerInstance->Config->HideWhoisServer);
        else
                wholine.append(u->server);
-       
+
        wholine.append(" " + u->nick + " ");
 
        /* away? */
-       if (IS_AWAY(u))
+       if (u->IsAway())
        {
                wholine.append("G");
        }
@@ -211,7 +211,7 @@ void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms,
        }
 
        /* oper? */
-       if (IS_OPER(u))
+       if (u->IsOper())
        {
                wholine.push_back('*');
        }
@@ -249,33 +249,17 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
        opt_far = false;
        opt_time = false;
 
-       Channel *ch = NULL;
        std::vector<std::string> whoresults;
        std::string initial = "352 " + user->nick + " ";
 
-       char matchtext[MAXBUF];
-       bool usingwildcards = false;
-
        /* Change '0' into '*' so the wildcard matcher can grok it */
-       if (parameters[0] == "0")
-               strlcpy(matchtext, "*", MAXBUF);
-       else
-               strlcpy(matchtext, parameters[0].c_str(), MAXBUF);
+       std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]);
 
-       for (const char* check = matchtext; *check; check++)
-       {
-               if (*check == '*' || *check == '?' || *check == '.')
-               {
-                       usingwildcards = true;
-                       break;
-               }
-       }
+       // WHO flags count as a wildcard
+       bool usingwildcards = ((parameters.size() > 1) || (matchtext.find_first_of("*?.") != std::string::npos));
 
        if (parameters.size() > 1)
        {
-               /* Fix for bug #444, WHO flags count as a wildcard */
-               usingwildcards = true;
-
                for (std::string::const_iterator iter = parameters[1].begin(); iter != parameters[1].end(); ++iter)
                {
                        switch (*iter)
@@ -325,7 +309,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
 
 
        /* who on a channel? */
-       ch = ServerInstance->FindChan(matchtext);
+       Channel* ch = ServerInstance->FindChan(matchtext);
 
        if (ch)
        {
@@ -342,7 +326,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                if (user != i->first)
                                {
                                        /* opers only, please */
-                                       if (opt_viewopersonly && !IS_OPER(i->first))
+                                       if (opt_viewopersonly && !i->first->IsOper())
                                                continue;
 
                                        /* If we're not inside the channel, hide +i users */
@@ -364,7 +348,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                        {
                                User* oper = *i;
 
-                               if (whomatch(user, oper, matchtext))
+                               if (whomatch(user, oper, matchtext.c_str()))
                                {
                                        if (!user->SharesChannelWith(oper))
                                        {
@@ -380,7 +364,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                {
                        for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
                        {
-                               if (whomatch(user, i->second, matchtext))
+                               if (whomatch(user, i->second, matchtext.c_str()))
                                {
                                        if (!user->SharesChannelWith(i->second))
                                        {