/* * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in * clients. Designed to reduce number of whois requests. Can process * nicknames in batches as long as the maximum buffer length. * * format: * ISON :nicklist */ static int m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; char *nick; char *p; char *current_insert_point, *current_insert_point2; int len; int i; int done = 0; current_insert_point2 = buf2; *buf2 = '\0'; rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name); len = strlen(buf); current_insert_point = buf + len; /* rfc1489 is ambigious about how to handle ISON * this should handle both interpretations. */ for(i = 1; i < parc; i++) { char *cs = LOCAL_COPY(parv[i]); for(nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p)) { target_p = find_named_client(nick); if(target_p != NULL) { len = strlen(target_p->name); if((current_insert_point + (len + 5)) < (buf + sizeof(buf))) { memcpy(current_insert_point, target_p->name, len); current_insert_point += len; *current_insert_point++ = ' '; } else { done = 1; break; } } } if(done) break; } /* current_insert_point--; * Do NOT take out the trailing space, it breaks ircII * --Rodder */ *current_insert_point = '\0'; *current_insert_point2 = '\0'; sendto_one_buffer(source_p, buf); return 0; }
/* * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce * the need for complicated requests like WHOIS. It returns user/host * information only (no spurious AWAY labels or channels). */ static int m_userhost(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; char response[NICKLEN * 2 + USERLEN + HOSTLEN + 30]; char *t; int i; /* loop counter */ int cur_len; int rl; cur_len = rb_sprintf(buf, form_str(RPL_USERHOST), me.name, source_p->name, ""); t = buf + cur_len; for(i = 1; i <= 5; i++) { if(parc < i + 1) break; if((target_p = find_person(parv[i])) != NULL) { /* * Show real IP for USERHOST on yourself. * This is needed for things like mIRC, which do a server-based * lookup (USERHOST) to figure out what the clients' local IP * is. Useful for things like NAT, and dynamic dial-up users. */ if(MyClient(target_p) && (target_p == source_p)) { rl = rb_sprintf(response, "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", (target_p->user->away) ? '-' : '+', target_p->username, target_p->sockhost); } else { rl = rb_sprintf(response, "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", (target_p->user->away) ? '-' : '+', target_p->username, target_p->host); } if((rl + cur_len) < (BUFSIZE - 10)) { rb_sprintf(t, "%s", response); t += rl; cur_len += rl; } else break; } } sendto_one_buffer(source_p, buf); return 0; }