unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

ison.c (2460B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/ison.c
      3  *   (C) 2004 The UnrealIRCd Team
      4  *
      5  *   See file AUTHORS in IRC package for additional names of
      6  *   the programmers.
      7  *
      8  *   This program is free software; you can redistribute it and/or modify
      9  *   it under the terms of the GNU General Public License as published by
     10  *   the Free Software Foundation; either version 1, or (at your option)
     11  *   any later version.
     12  *
     13  *   This program is distributed in the hope that it will be useful,
     14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  *   GNU General Public License for more details.
     17  *
     18  *   You should have received a copy of the GNU General Public License
     19  *   along with this program; if not, write to the Free Software
     20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21  */
     22 
     23 #include "unrealircd.h"
     24 
     25 CMD_FUNC(cmd_ison);
     26 
     27 #define MSG_ISON 	"ISON"	
     28 
     29 ModuleHeader MOD_HEADER
     30   = {
     31 	"ison",
     32 	"5.0",
     33 	"command /ison", 
     34 	"UnrealIRCd Team",
     35 	"unrealircd-6",
     36     };
     37 
     38 MOD_INIT()
     39 {
     40 	CommandAdd(modinfo->handle, MSG_ISON, cmd_ison, 1, CMD_USER);
     41 	MARK_AS_OFFICIAL_MODULE(modinfo);
     42 	return MOD_SUCCESS;
     43 }
     44 
     45 MOD_LOAD()
     46 {
     47 	return MOD_SUCCESS;
     48 }
     49 
     50 MOD_UNLOAD()
     51 {
     52 	return MOD_SUCCESS;
     53 }
     54 
     55 /*
     56  * cmd_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
     57  * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
     58  * clients. Designed to reduce number of whois requests. Can process
     59  * nicknames in batches as long as the maximum buffer length.
     60  *
     61  * format:
     62  * ISON :nicklist
     63  */
     64 
     65 CMD_FUNC(cmd_ison)
     66 {
     67 	char buf[BUFSIZE];
     68 	char request[BUFSIZE];
     69 	char namebuf[USERLEN + HOSTLEN + 4];
     70 	Client *acptr;
     71 	char *s, *user;
     72 	char *p = NULL;
     73 
     74 	if (!MyUser(client))
     75 		return;
     76 
     77 	if (parc < 2)
     78 	{
     79 		sendnumeric(client, ERR_NEEDMOREPARAMS, "ISON");
     80 		return;
     81 	}
     82 
     83 	ircsnprintf(buf, sizeof(buf), ":%s %d %s :", me.name, RPL_ISON, client->name);
     84 
     85 	strlcpy(request, parv[1], sizeof(request));
     86 	for (s = strtoken(&p, request, " "); s; s = strtoken(&p, NULL, " "))
     87 	{
     88 		if ((user = strchr(s, '!')))
     89 			*user++ = '\0';
     90 		if ((acptr = find_user(s, NULL)))
     91 		{
     92 			if (user)
     93 			{
     94 				ircsnprintf(namebuf, sizeof(namebuf), "%s@%s", acptr->user->username, GetHost(acptr));
     95 				if (!match_simple(user, namebuf)) continue;
     96 				*--user = '!';
     97 			}
     98 
     99 			strlcat(buf, s, sizeof(buf));
    100 			strlcat(buf, " ", sizeof(buf));
    101 		}
    102 	}
    103 
    104 	sendto_one(client, NULL, "%s", buf);
    105 }