/************************************************************************
* IRC - Internet Relay Chat, modules/rexcom/m_rexcom.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 "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include "chanmode.h"
#include "h.h"
#include "s_conf.h"
#include "hook.h"
static int hookid_rexcom = 0;
static struct Message _msgtab[] = {
{MSG_REXCOM, 0, MAXPARA, M_SLOW, 0L,
m_unregistered, m_permission, o_rexcom, s_rexcom, m_ignore}
};
static char *token = TOK1_REXCOM;
#ifndef STATIC_MODULES
char *_version = "$Revision: 1.4 $";
void _modinit(void)
{
hookid_rexcom = hook_add_event("load rexcom core module");
mod_add_cmd(_msgtab);
tok1_msgtab[(u_char) *token].msg = _msgtab;
}
void _moddeinit(void)
{
hook_del_event("load rexcom core module");
mod_del_cmd(_msgtab);
tok1_msgtab[(u_char) *token].msg = NULL;
}
#else
void m_rexcom_init(void)
{
hookid_rexcom = hook_add_event("load rexcom core module");
mod_add_cmd(_msgtab);
tok1_msgtab[(u_char) *token].msg = _msgtab;
}
#endif
#define REXCOM_ADD 1
#define REXCOM_DEL 2
/* REXCOM +K *@*[0..9]*.com :Banned from this net */
int o_rexcom(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
struct hook_data thisdata;
int len;
if (!ServerOpts.use_regex)
return m_permission(cptr, sptr, parc, parv);
#if 0
if (!OPIsOperdo(sptr)) {
return m_permission(cptr, sptr, parc, parv);
}
#endif
thisdata.client_p = cptr;
thisdata.source_p = sptr;
if(parc < 3) {
send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_REXCOM);
return 0;
}
if (parv[1][0] == '+') {
thisdata.check = REXCOM_ADD;
if (parc < 4) {
send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_REXCOM);
return 0;
} else {
thisdata.data = parv[3];
}
} else if (parv[1][0] == '-') {
thisdata.check = REXCOM_DEL;
} else {
send_me_notice(sptr, "No such REXCOM command");
return 0;
}
if (parv[1][1] != '\0') {
thisdata.statchar = parv[1][1];
} else {
send_me_notice(sptr, "No such REXCOM command");
return 0;
}
len = strlen(parv[2]);
thisdata.len = len;
thisdata.mask = parv[2];
if (!hook_call_event(hookid_rexcom, &thisdata)) {
send_me_notice(sptr, "No such REXCOM command %s", parv[1]);
} else {
logevent_call(LogSys.operevent, MSG_REXCOM, sptr, &parv, parc);
if (thisdata.check == REXCOM_ADD)
sendto_serv_butone(cptr, sptr, TOK1_REXCOM, "%s %d %s :%s",
parv[1], len, parv[2], parv[3]);
else
sendto_serv_butone(cptr, sptr, TOK1_REXCOM, "%s %d %s",
parv[1], len, parv[2]);
}
return 0;
}
/* | +Q 2 a* :Banned */
int s_rexcom(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
struct hook_data thisdata;
int len;
int reason = 0;
if (!ServerOpts.use_regex)
return m_permission(cptr, sptr, parc, parv);
thisdata.client_p = cptr;
thisdata.source_p = sptr;
if(parc < 4)
return 0;
if (parv[1][0] == '+') {
thisdata.check = REXCOM_ADD;
if (parc < 5)
return 0;
else
thisdata.data = parv[4];
reason = 1;
} else if (parv[1][0] == '-') {
thisdata.check = REXCOM_DEL;
} else {
return 0;
}
if (parv[1][1] != '\0')
thisdata.statchar = parv[1][1];
else
return 0;
len = atoi(parv[2]);
thisdata.len = len;
thisdata.mask = parv[3];
hook_call_event(hookid_rexcom, &thisdata);
/* We do REXCOM Bridging */
if (thisdata.check == REXCOM_ADD)
sendto_serv_butone(cptr, sptr, TOK1_REXCOM, "%s %d %s :%s",
parv[1], len, parv[3], parv[4] ? parv[4] : "No-Reason");
else
sendto_serv_butone(cptr, sptr, TOK1_REXCOM, "%s %d %s",
parv[1], len, parv[3]);
return 0;
}
syntax highlighted by Code2HTML, v. 0.9.1