unrealircd

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

svsmotd.c (2527B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/svsmotd.c
      3  *   (C) 2001 The UnrealIRCd Team
      4  *
      5  *   SVSMOTD 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_svsmotd);
     28 
     29 #define MSG_SVSMOTD 	"SVSMOTD"	
     30 
     31 ModuleHeader MOD_HEADER
     32   = {
     33 	"svsmotd",
     34 	"5.0",
     35 	"command /svsmotd", 
     36 	"UnrealIRCd Team",
     37 	"unrealircd-6",
     38     };
     39 
     40 MOD_INIT()
     41 {
     42 	CommandAdd(modinfo->handle, MSG_SVSMOTD, cmd_svsmotd, 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 
     57 /*
     58 ** cmd_svsmotd
     59 **
     60 */
     61 CMD_FUNC(cmd_svsmotd)
     62 {
     63 	FILE *conf = NULL;
     64 
     65 	if (!IsSvsCmdOk(client))
     66 	{
     67 		sendnumeric(client, ERR_NOPRIVILEGES);
     68 		return;
     69 	}
     70 	if (parc < 2)
     71 	{
     72 		sendnumeric(client, ERR_NEEDMOREPARAMS, "SVSMOTD");
     73 		return;
     74 	}
     75 
     76 	if ((*parv[1] != '!') && parc < 3)
     77 	{
     78 		sendnumeric(client, ERR_NEEDMOREPARAMS, "SVSMOTD");
     79 		return;
     80 	}
     81 
     82 	if (parv[2])
     83 		sendto_server(client, 0, 0, NULL, ":%s SVSMOTD %s :%s", client->id, parv[1], parv[2]);
     84 	else
     85 		sendto_server(client, 0, 0, NULL, ":%s SVSMOTD %s", client->id, parv[1]);
     86 
     87 	switch (*parv[1])
     88 	{
     89 		case '#':
     90 			unreal_log(ULOG_INFO, "svsmotd", "SVSMOTD_ADDED", client,
     91 			           "Services added '$line' to services motd",
     92 			           log_data_string("line", parv[2]));
     93 			conf = fopen(conf_files->svsmotd_file, "a");
     94 			if (conf)
     95 			{
     96 				fprintf(conf, "%s\n", parv[2]);
     97 				fclose(conf);
     98 			}
     99 			break;
    100 		case '!':
    101 			unreal_log(ULOG_INFO, "svsmotd", "SVSMOTD_REMOVED", client,
    102 			           "Services deleted the services motd");
    103 			remove(conf_files->svsmotd_file);
    104 			free_motd(&svsmotd);
    105 			break;
    106 		default:
    107 			return;
    108 	}
    109 
    110 	/* We editted it, so rehash it -- codemastr */
    111 	read_motd(conf_files->svsmotd_file, &svsmotd);
    112 }