/************************************************************************
* IRC - Internet Relay Chat, modules/operdo/m_operdo_kick.c
*
* Copyright (C) 2000-2003 TR-IRCD Development
*
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Co Center
*
* 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "struct.h"
#include "common.h"
#include "chanmode.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "h.h"
#include "hook.h"
static char modebuf[REALMODEBUFLEN], parabuf[REALMODEBUFLEN];
static int do_operdo_mode(struct hook_data *data);
#ifndef STATIC_MODULES
void _modinit(void)
{
hook_add_hook("load operdo core module", (hookfn *) do_operdo_mode);
}
void _moddeinit(void)
{
hook_del_hook("load operdo core module", (hookfn *) do_operdo_mode);
}
char *_version = "$Revision: 1.3 $";
#else
void m_operdo_mode_init(void)
{
hook_add_hook("load operdo core module", (hookfn *) do_operdo_mode);
}
#endif
static int do_operdo_mode(struct hook_data *data)
{
int link_mode = 0;
int sendtsm = 0;
int parc;
if (irc_strcmp(data->extra, "MODE"))
return 0;
parc = data->parc;
if (parc < 4) {
send_me_numeric(data->source_p, ERR_NEEDMOREPARAMS, MSG_OPERDO);
return 1;
}
SetOperMode(data->source_p);
if (IsChanLinked(data->channel))
link_mode = 1;
sendtsm =
set_mode(data->client_p, data->source_p, data->channel, data->parc - 3, data->parv + 3,
modebuf, parabuf);
if (strlen(modebuf) > (size_t) 1) {
sendto_channel_butserv(data->channel, data->source_p, TOK1_MODE, 0, "%s %s", modebuf,
parabuf);
sendto_match_servs(data->channel, data->client_p, TOK1_MODE, "%s %s", modebuf, parabuf);
sendto_serv_butone(NULL, &me, TOK1_GLOBOPS,
":%C used OPERDO MODE on %H %s%s%s",
data->source_p, data->channel, modebuf, (*parabuf != 0 ? " " : ""),
parabuf);
sendto_ops("from %C: %C used OPERDO MODE on %H %s%s%s", &me, data->source_p, data->channel,
modebuf, (*parabuf != 0 ? " " : ""), parabuf);
}
if (link_mode) {
if (!IsChanLinked(data->channel)) {
remove_user_from_channel(&me, data->channel);
}
} else {
if (IsChanLinked(data->channel)) {
link_add_server_to_channel(&me, data->channel);
link_remove_users_from_channel(data->channel);
link_set_modes_in_channel(data->channel);
}
}
return 1;
}
syntax highlighted by Code2HTML, v. 0.9.1