unrealircd

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

svsnline.c (3670B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/svsnline.c
      3  *   (C) 2001 The UnrealIRCd Team
      4  *
      5  *   SVSNLINE 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_svsnline);
     28 
     29 #define MSG_SVSNLINE 	"SVSNLINE"	/* svsnline */
     30 
     31 ModuleHeader MOD_HEADER
     32   = {
     33 	"svsnline",	/* Name of module */
     34 	"5.0", /* Version */
     35 	"command /svsnline", /* Short description of module */
     36 	"UnrealIRCd Team",
     37 	"unrealircd-6",
     38     };
     39 
     40 /* This is called on module init, before Server Ready */
     41 MOD_INIT()
     42 {
     43 	CommandAdd(modinfo->handle, MSG_SVSNLINE, cmd_svsnline, MAXPARA, CMD_SERVER);
     44 	MARK_AS_OFFICIAL_MODULE(modinfo);
     45 	return MOD_SUCCESS;
     46 }
     47 
     48 /* Is first run when server is 100% ready */
     49 MOD_LOAD()
     50 {
     51 	return MOD_SUCCESS;
     52 }
     53 
     54 /* Called when module is unloaded */
     55 MOD_UNLOAD()
     56 {
     57 	return MOD_SUCCESS;
     58 }
     59 
     60 void wipe_svsnlines(void)
     61 {
     62 	ConfigItem_ban *bconf, *next;
     63 	
     64 	for (bconf = conf_ban; bconf; bconf = next)
     65 	{
     66 		next = bconf->next;
     67 		if ((bconf->flag.type == CONF_BAN_REALNAME) &&
     68 			(bconf->flag.type2 == CONF_BAN_TYPE_AKILL))
     69 		{
     70 			DelListItem(bconf, conf_ban);
     71 			safe_free(bconf->mask);
     72 			safe_free(bconf->reason);
     73 			safe_free(bconf);
     74 		}
     75 	}
     76 }
     77 
     78 /*
     79  * cmd_svsnline
     80  * SVSNLINE + reason_where_is_space :realname mask with spaces
     81  * SVSNLINE - :realname mask
     82  * SVSNLINE *     Wipes
     83  * -Stskeeps
     84 */
     85 CMD_FUNC(cmd_svsnline)
     86 {
     87 	ConfigItem_ban *bconf;
     88 	char		*s;
     89 
     90 	if (parc < 2)
     91 		return;
     92 
     93 	switch (*parv[1])
     94 	{
     95 		  /* Allow non-U-Lines to send ONLY SVSNLINE +, but don't send it out
     96 		   * unless it is from a U-Line -- codemastr */
     97 	  case '+':
     98 	  {
     99 		  if (parc < 4)
    100 			  return;
    101 		 
    102 		  if (!find_banEx(NULL, parv[3], CONF_BAN_REALNAME, CONF_BAN_TYPE_AKILL))
    103 		  {
    104 			bconf = safe_alloc(sizeof(ConfigItem_ban));
    105 			bconf->flag.type = CONF_BAN_REALNAME;
    106 			safe_strdup(bconf->mask, parv[3]);
    107 			safe_strdup(bconf->reason, parv[2]);
    108 			for (s = bconf->reason; *s; s++)
    109 				if (*s == '_')
    110 					*s = ' ';
    111 			bconf->flag.type2 = CONF_BAN_TYPE_AKILL;
    112 			AddListItem(bconf, conf_ban);
    113 		  } 
    114 		 
    115 		  if (IsSvsCmdOk(client))
    116 			sendto_server(client, 0, 0, NULL, ":%s SVSNLINE + %s :%s",
    117 			    client->id, parv[2], parv[3]);
    118 		  break;
    119 	  }
    120 	  case '-':
    121 	  {
    122 		  if (!IsSvsCmdOk(client))
    123 			  return;
    124 		  if (parc < 3)
    125 			  return;
    126 		  
    127 		  for (bconf = conf_ban; bconf; bconf = bconf->next)
    128 		  {
    129 			if (bconf->flag.type != CONF_BAN_REALNAME)
    130 				continue;
    131 			if (bconf->flag.type2 != CONF_BAN_TYPE_AKILL)
    132 				continue;
    133 			if (!strcasecmp(bconf->mask, parv[2]))
    134 				break;
    135 		  }
    136 		  if (bconf)
    137 		  {
    138 		  	DelListItem(bconf, conf_ban);
    139 	  		safe_free(bconf->mask);
    140 	  		safe_free(bconf->reason);
    141 		  	safe_free(bconf);
    142 		  	
    143 		  }
    144 		  sendto_server(client, 0, 0, NULL, ":%s SVSNLINE - %s", client->id, parv[2]);
    145 		  break;
    146 	  }
    147 	  case '*':
    148 	  {
    149 		  if (!IsSvsCmdOk(client))
    150 			  return;
    151 	          wipe_svsnlines();
    152 		  sendto_server(client, 0, 0, NULL, ":%s SVSNLINE *", client->id);
    153 		  break;
    154 	  }
    155 
    156 	}
    157 }