/*
 *  ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
 *  m_banfix.c: banfixs a server.
 *
 *  Copyright (C) 2002 by the past and present ircd coders, and others.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 *  USA
 *
 *  $Id: m_banfix.c,v 1.43 2002/11/21 21:18:20 leeh Exp $
 */

#include "stdinc.h"
#include "tools.h"
#include "irc_string.h"
#include "sprintf_irc.h"
#include "handlers.h"
#include "channel.h"
#include "client.h"
#include "ircd.h"
#include "numeric.h"
#include "s_log.h"
#include "s_serv.h"
#include "send.h"
#include "whowas.h"
#include "irc_string.h"
#include "hash.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
#include "class.h"
#include "common.h"
#include "event.h"
#include "channel_mode.h"

static void mo_banfix(struct Client *client_p, struct Client *source_p,
		 int parc, char *parv[]);

struct Message banfix_msgtab = {
  "BANFIX", 0, 0, 0, 0, MFLG_SLOW, 0,
  {m_unregistered, m_not_oper, m_ignore, mo_banfix}
};

#ifndef STATIC_MODULES
void
_modinit(void)
{
  mod_add_cmd(&banfix_msgtab);
}

void
_moddeinit(void)
{
  mod_del_cmd(&banfix_msgtab);
}

const char *_version = "$Revision: 1.43 $";
#endif

/*
** mo_banfix
**      parv[0] = sender prefix
**      parv[1] = server we're juping
**      parv[2] = reason for banfix
*/
static void mo_banfix(struct Client *client_p, struct Client *source_p,
                    int parc, char *parv[])
{
	struct Channel *chptr;
	dlink_node *ptr;
	int my_mask;

	DLINK_FOREACH(ptr, global_channel_list.head)
	{
		chptr = ptr->data;

		my_mask = dlink_list_length(&chptr->banlist) +
			  dlink_list_length(&chptr->exceptlist) +
			  dlink_list_length(&chptr->invexlist);

		if(my_mask != chptr->num_mask)
		{
			sendto_realops_flags(UMODE_ALL, L_ALL,
					"Uneven mask count on %s (%d != %d)",
					chptr->chname, my_mask, chptr->num_mask);
			chptr->num_mask = my_mask;
		}
	}
}


