/************************************************************************
* IRC - Internet Relay Chat, modules/operdo/m_operdo_topic.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 topic[TOPICLEN];
static int do_operdo_topic(struct hook_data *data);
#ifndef STATIC_MODULES
void _modinit(void)
{
hook_add_hook("load operdo core module", (hookfn *) do_operdo_topic);
}
void _moddeinit(void)
{
hook_del_hook("load operdo core module", (hookfn *) do_operdo_topic);
}
char *_version = "$Revision: 1.4 $";
#else
void m_operdo_topic_init(void)
{
hook_add_hook("load operdo core module", (hookfn *) do_operdo_topic);
}
#endif
static int do_operdo_topic(struct hook_data *data)
{
aChannel *chptr = NULL;
aClient *sptr = NULL;
char **parv;
time_t ts;
int i;
chptr = data->channel;
sptr = data->source_p;
parv = data->parv;
if (irc_strcmp(data->extra, "TOPIC"))
return 0;
if (data->parc < 4) {
send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_OPERDO);
return 1;
}
sendto_ops("param count %d, %s", data->parc, parv[3]);
memset((char *) &topic, 0, TOPICLEN);
i = 4;
strncat((char *) &topic, (const char *) parv[3], strlen(parv[3]));
while (parv[i]) {
strncat((char *) &topic, " ", 1);
strncat((char *) &topic, (const char *) parv[i], strlen(parv[i]));
i++;
}
ts = timeofday;
strlcpy_irc(chptr->topic, (char *) &topic, TOPICLEN);
strcpy(chptr->topic_nick, sptr->name);
chptr->topic_time = ts;
sendto_match_servs(chptr, &me, TOK1_TOPIC, "%s %lu :%s",
chptr->topic_nick, chptr->topic_time, chptr->topic);
sendto_channel_butserv(chptr, sptr, TOK1_TOPIC, 0, ":%s", chptr->topic);
sendto_serv_butone(NULL, &me, TOK1_GLOBOPS, ":%C used OPERDO TOPIC on %H", sptr, chptr);
sendto_ops("from %C: %C used OPERDO TOPIC on %H", &me, sptr, chptr);
return 1;
}
syntax highlighted by Code2HTML, v. 0.9.1