+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
+ {
+ ucrec* temp = (ucrec*)*v;
+
+ if (temp->channel)
+ {
+ if (!temp->channel->IsModeSet('s'))
+ return temp->channel->name;
+ }
+ }
+
+ return "*";
+}
+
+bool whomatch(userrec* user, const char* matchtext, bool opt_realname, bool opt_showrealhost)
+{
+ bool realhost = false;
+ bool realname = false;
+
+ if (user->registered != REG_ALL)
+ return false;
+
+ if (opt_realname)
+ realname = match(user->fullname, matchtext);
+
+ if (opt_showrealhost)
+ realhost = match(user->host, matchtext);
+
+ return ((realname) || (realhost) || (match(user->dhost, matchtext)) || (match(user->nick, matchtext)) || (match(user->server, matchtext)));
+}
+
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_who(Instance);
+}
+
+CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
+{
+ /*
+ * XXX - RFC says:
+ * The <name> passed to WHO is matched against users' host, server, real
+ * name and nickname
+ * Currently, we support WHO #chan, WHO nick, WHO 0, WHO *, and the addition of a 'o' flag, as per RFC.
+ */
+
+ /* WHO options */
+ bool opt_viewopersonly = false;
+ bool opt_showrealhost = false;
+ bool opt_unlimit = false;
+ bool opt_realname = false;
+
+ chanrec *ch = NULL;
+ std::vector<std::string> whoresults;
+ std::string initial = "352 " + std::string(user->nick) + " ";
+
+ const char* matchtext = NULL;
+
+ /* Change '0' into '*' so the wildcard matcher can grok it */
+ matchtext = parameters[0];
+ if (!strcmp(matchtext,"0"))
+ matchtext = "*";
+
+ if (pcnt > 1)