unrealircd

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

svssno.c (2605B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/svssno.c
      3  *   (C) 2004 Dominick Meglio (codemastr) and 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_svssno);
     26 CMD_FUNC(cmd_svs2sno);
     27 
     28 #define MSG_SVSSNO 	"SVSSNO"	
     29 #define MSG_SVS2SNO 	"SVS2SNO"	
     30 
     31 ModuleHeader MOD_HEADER
     32   = {
     33 	"svssno",
     34 	"5.0",
     35 	"command /svssno", 
     36 	"UnrealIRCd Team",
     37 	"unrealircd-6",
     38     };
     39 
     40 MOD_INIT()
     41 {
     42 	CommandAdd(modinfo->handle, MSG_SVSSNO, cmd_svssno, MAXPARA, CMD_USER|CMD_SERVER);
     43 	CommandAdd(modinfo->handle, MSG_SVS2SNO, cmd_svs2sno, MAXPARA, CMD_USER|CMD_SERVER);
     44 	MARK_AS_OFFICIAL_MODULE(modinfo);
     45 	return MOD_SUCCESS;
     46 }
     47 
     48 MOD_LOAD()
     49 {
     50 	return MOD_SUCCESS;
     51 }
     52 
     53 MOD_UNLOAD()
     54 {
     55 	return MOD_SUCCESS;
     56 }
     57 
     58 /*
     59  * do_svssno() 
     60  * parv[1] - username to change snomask for
     61  * parv[2] - snomasks to change
     62  * show_change determines whether to show the change to the user
     63  */
     64 void do_svssno(Client *client, MessageTag *recv_mtags, int parc, const char *parv[], int show_change)
     65 {
     66 	const char *p;
     67 	Client *target;
     68 	int what = MODE_ADD, i;
     69 
     70 	if (!IsSvsCmdOk(client))
     71 		return;
     72 
     73 	if (parc < 2)
     74 		return;
     75 
     76 	if (parv[1][0] == '#') 
     77 		return;
     78 
     79 	if (!(target = find_user(parv[1], NULL)))
     80 		return;
     81 
     82 	if (hunt_server(client, recv_mtags, show_change ? "SVS2SNO" : "SVSSNO", 1, parc, parv) != HUNTED_ISME)
     83 		return;
     84 
     85 	if (MyUser(target))
     86 	{
     87 		if (parc == 2)
     88 			set_snomask(target, NULL);
     89 		else
     90 			set_snomask(target, parv[2]);
     91 	}
     92 
     93 	if (show_change && target->user->snomask)
     94 	{
     95 		MessageTag *mtags = NULL;
     96 		new_message(client, recv_mtags, &mtags);
     97 		// TODO: sendnumeric has no mtags support :D
     98 		sendnumeric(target, RPL_SNOMASK, target->user->snomask);
     99 		safe_free_message_tags(mtags);
    100 	}
    101 }
    102 
    103 CMD_FUNC(cmd_svssno)
    104 {
    105 	do_svssno(client, recv_mtags, parc, parv, 0);
    106 }
    107 
    108 CMD_FUNC(cmd_svs2sno)
    109 {
    110 	do_svssno(client, recv_mtags, parc, parv, 1);
    111 }