home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
yagirc-0.51.tar.gz
/
yagirc-0.51.tar
/
yagirc-0.51
/
ctcp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-05-08
|
3KB
|
116 lines
/*
ctcp.c : Functions handling CTCP events
Copyright (C) 1998 Timo Sirainen
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "os.h"
#include "txt.h"
#include "dcc.h"
#include "irc.h"
#include "version.h"
#include "events.h"
/* CTCP version */
int ctcp_version(char *sender, char *target, char *data)
{
char tmp[100];
g_return_val_if_fail(sender != NULL, 1);
sprintf(tmp, "NOTICE %s :\001VERSION %s\001", sender, IRC_VERSION);
irc_send_cmd(eserver, tmp);
return 1;
}
/* CTCP ping */
int ctcp_ping(char *sender, char *target, char *data)
{
char tmp[512];
g_return_val_if_fail(sender != NULL, 1);
g_return_val_if_fail(data != NULL, 1);
sprintf(tmp, "NOTICE %s :\001PING %s\001", sender, data);
irc_send_cmd(eserver, tmp);
return 1;
}
/* CTCP action = /ME command */
int ctcp_action(char *sender, char *target, char *data)
{
CHAN_REC *chan;
g_return_val_if_fail(sender != NULL, 1);
g_return_val_if_fail(target != NULL, 1);
g_return_val_if_fail(data != NULL, 1);
if (*target != '#' && *target != '&')
drawtext(edefwin, TXT_TYPE_DEFAULT, "%7 (*) %s %8%s\n", sender, data); /* private */
else
{
chan = channel_joined(eserver, target);
if (chan != NULL && chan->window->curchan != NULL &&
strcasecmp(target, chan->window->curchan->name) == 0)
drawtext(chan->window, TXT_TYPE_DEFAULT, "%7 * %s %8%s\n", sender, data); /* current channel */
else
drawtext(chan == NULL ? edefwin : chan->window, TXT_TYPE_DEFAULT, "%7 * %s%n:%2%s %8%s\n", sender, target, data); /* some channel */
if (chan != NULL && !chan->new_data && chan->window != curwin)
{
chan->new_data = 1;
gui_channel_hilight(chan);
}
}
return 0;
}
/* CTCP DCC */
int ctcp_dcc(char *sender, char *target, char *data)
{
g_return_val_if_fail(sender != NULL, 1);
g_return_val_if_fail(data != NULL, 1);
return dcc_handle_ctcp(sender, data);
}
/* CTCP reply */
int ctcp_reply(char *sender, char *data)
{
char *ptr;
g_return_val_if_fail(sender != NULL, 0);
g_return_val_if_fail(data != NULL, 0);
ptr = strchr(data, ' ');
if (ptr != NULL) *ptr++ = '\0'; else ptr = "";
if (strcmp(data, "DCC") == 0)
return dcc_reply(sender, ptr);
drawtext(edefwin, TXT_TYPE_DEFAULT, IRCTXT_CTCP_REPLY, data, sender, ptr);
return 1;
}