- wilds = (strchr(nick, '?') || strchr(nick, '*'));
- /* Do a hash lookup if the nick does not contain wilds */
- if (wilds)
- {
- /*
- * We're no longer allowing remote users to generate requests with wildcards.
- */
- if (!MyConnect(sptr))
- continue;
- for (acptr = GlobalClientList; (acptr = next_client(acptr, nick));
- acptr = acptr->next)
- {
- if (!IsRegistered(acptr) || IsServer(acptr))
- continue;
- /*
- * I'm always last :-) and acptr->next == NULL!!
- */
- if (IsMe(acptr))
- break;
- /*
- * 'Rules' established for sending a WHOIS reply:
- *
- * - if wildcards are being used dont send a reply if
- * the querier isnt any common channels and the
- * client in question is invisible and wildcards are
- * in use (allow exact matches only);
- *
- * - only send replies about common or public channels
- * the target user(s) are on;
- */
- user = acptr->user;
- name = (!*acptr->name) ? "?" : acptr->name;
-
- invis = acptr != sptr && IsInvisible(acptr);
- member = (user && user->channel) ? 1 : 0;
- showperson = (wilds && !invis && !member) || !wilds;
- if (user) {
- struct Membership* chan;
- for (chan = user->channel; chan; chan = chan->next_channel)
- {
- chptr = chan->channel;
- member = find_channel_member(sptr, chptr) ? 1 : 0;
- if (invis && !member)
- continue;
- if (IsZombie(chan))
- continue;
- if (member || (!invis && PubChannel(chptr)))
- {
- showperson = 1;
- break;
- }
- if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
- showperson = 1;
- }
- }
- if (!showperson)
- continue;
-
- if (user)
- {
- a2cptr = user->server;
- sendto_one(sptr, rpl_str(RPL_WHOISUSER), me.name,
- parv[0], name, user->username, user->host, acptr->info);
- }
- else
- {
- a2cptr = &me;
- sendto_one(sptr, rpl_str(RPL_WHOISUSER), me.name,
- parv[0], name, "<unknown>", "<unknown>", "<unknown>");
- }
-
- found = 1;
-
-exact_match:
- if (user && !IsChannelService(acptr))
- {
- struct Membership* chan;
- mlen = strlen(me.name) + strlen(parv[0]) + 12 + strlen(name);
- len = 0;
- *buf = '\0';
- for (chan = user->channel; chan; chan = chan->next_channel)
- {
- chptr = chan->channel;
- if (ShowChannel(sptr, chptr) &&
- (acptr == sptr || !IsZombie(chan)))
- {
- if (len + strlen(chptr->chname) + mlen > BUFSIZE - 5)
- {
- sendto_one(sptr, ":%s %d %s %s :%s",
- me.name, RPL_WHOISCHANNELS, parv[0], name, buf);
- *buf = '\0';
- len = 0;
- }
- if (IsDeaf(acptr))
- *(buf + len++) = '-';
- if (is_chan_op(acptr, chptr))
- *(buf + len++) = '@';
- else if (has_voice(acptr, chptr))
- *(buf + len++) = '+';
- else if (IsZombie(chan))
- *(buf + len++) = '!';
- if (len)
- *(buf + len) = '\0';
- strcpy(buf + len, chptr->chname);
- len += strlen(chptr->chname);
- strcat(buf + len, " ");
- len++;
- }
- }
- if (buf[0] != '\0')
- sendto_one(sptr, rpl_str(RPL_WHOISCHANNELS),
- me.name, parv[0], name, buf);
- }
-
- sendto_one(sptr, rpl_str(RPL_WHOISSERVER), me.name,
- parv[0], name, a2cptr->name, a2cptr->info);
-
- if (user)
- {
- if (user->away)
- sendto_one(sptr, rpl_str(RPL_AWAY), me.name,
- parv[0], name, user->away);
-
- if (IsAnOper(acptr))
- sendto_one(sptr, rpl_str(RPL_WHOISOPERATOR),
- me.name, parv[0], name);