unrealircd

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

swhois.c (2462B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/swhois.c
      3  *   (C) 2001 The UnrealIRCd Team
      4  *
      5  *   SWHOIS command
      6  *
      7  *   See file AUTHORS in IRC package for additional names of
      8  *   the programmers.
      9  *
     10  *   This program is free software; you can redistribute it and/or modify
     11  *   it under the terms of the GNU General Public License as published by
     12  *   the Free Software Foundation; either version 1, or (at your option)
     13  *   any later version.
     14  *
     15  *   This program is distributed in the hope that it will be useful,
     16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18  *   GNU General Public License for more details.
     19  *
     20  *   You should have received a copy of the GNU General Public License
     21  *   along with this program; if not, write to the Free Software
     22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     23  */
     24 
     25 #include "unrealircd.h"
     26 
     27 CMD_FUNC(cmd_swhois);
     28 
     29 #define MSG_SWHOIS 	"SWHOIS"	
     30 
     31 ModuleHeader MOD_HEADER
     32   = {
     33 	"swhois",
     34 	"5.0",
     35 	"command /swhois", 
     36 	"UnrealIRCd Team",
     37 	"unrealircd-6",
     38     };
     39 
     40 MOD_INIT()
     41 {
     42 	CommandAdd(modinfo->handle, MSG_SWHOIS, cmd_swhois, MAXPARA, CMD_SERVER);
     43 	MARK_AS_OFFICIAL_MODULE(modinfo);
     44 	return MOD_SUCCESS;
     45 }
     46 
     47 MOD_LOAD()
     48 {
     49 	return MOD_SUCCESS;
     50 }
     51 
     52 MOD_UNLOAD()
     53 {
     54 	return MOD_SUCCESS;
     55 }
     56 /** SWHOIS: add or delete additional whois titles to user.
     57  * Old syntax:
     58  * parv[1] = nickname
     59  * parv[2] = new swhois
     60  * New syntax (since July 2015, by Syzop):
     61  * parv[1] = nickname
     62  * parv[2] = + or -
     63  * parv[3] = added-by tag
     64  * parv[4] = priority
     65  * parv[5] = swhois
     66  */
     67 CMD_FUNC(cmd_swhois)
     68 {
     69 	Client *target;
     70 	char tag[HOSTLEN+1];
     71 	char swhois[SWHOISLEN+1];
     72 	int add;
     73 	int priority = 0;
     74 
     75 	*tag = *swhois = '\0';
     76 
     77 	if (parc < 3)
     78 		return;
     79 
     80 	target = find_user(parv[1], NULL);
     81 	if (!target)
     82 		return;
     83 
     84 	if ((parc > 5) && !BadPtr(parv[5]))
     85 	{
     86 		/* New syntax */
     87 		add = (*parv[2] == '+') ? 1 : 0;
     88 		strlcpy(tag, parv[3], sizeof(tag));
     89 		priority = atoi(parv[4]);
     90 		strlcpy(swhois, parv[5], sizeof(swhois));
     91 	} else {
     92 		/* Old syntax */
     93 		strlcpy(tag, client->name, sizeof(tag));
     94 		if (BadPtr(parv[2]))
     95 		{
     96 			/* Delete. Hmmmm. Let's just delete anything with that tag. */
     97 			strcpy(swhois, "*");
     98 			add = 0;
     99 		} else {
    100 			/* Add */
    101 			add = 1;
    102 			strlcpy(swhois, parv[2], sizeof(swhois));
    103 		}
    104 	}
    105 
    106 	if (add)
    107 		swhois_add(target, tag, priority, swhois, client, client);
    108 	else
    109 		swhois_delete(target, tag, swhois, client, client);
    110 }