mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
Moved IRC files from src/protocols/irc to src/plugins/irc (IRC is now a "plugin", not a "protocol")
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2003-2007 FlashCode <flashcode@flashtux.org>
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
SET(LIB_IRC_SRC irc.h irc-commands.c irc-send.c irc-recv.c irc-server.c
|
||||
irc-channel.c irc-nick.c irc-mode.c irc-dcc.c irc-ignore.c irc-display.c)
|
||||
|
||||
CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
|
||||
CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC)
|
||||
CHECK_FUNCTION_EXISTS(uname HAVE_UNAME)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
ADD_LIBRARY(weechat_irc STATIC ${LIB_IRC_SRC})
|
||||
@@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2003-2007 FlashCode <flashcode@flashtux.org>
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GNUTLS_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = lib_weechat_irc.a
|
||||
|
||||
lib_weechat_irc_a_SOURCES = irc.h \
|
||||
irc-commands.c \
|
||||
irc-send.c \
|
||||
irc-recv.c \
|
||||
irc-server.c \
|
||||
irc-channel.c \
|
||||
irc-nick.c \
|
||||
irc-mode.c \
|
||||
irc-dcc.c \
|
||||
irc-ignore.c \
|
||||
irc-display.c
|
||||
@@ -0,0 +1,469 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-channel.c: manages a chat (channel or private chat) */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_channel_new: allocate a new channel for a server and add it to the
|
||||
* server queue
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
{
|
||||
t_irc_channel *new_channel;
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = (t_irc_channel *) malloc (sizeof (t_irc_channel))) == NULL)
|
||||
{
|
||||
fprintf (stderr, _("%s cannot allocate new channel"), WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
new_channel->name = strdup (channel_name);
|
||||
new_channel->topic = NULL;
|
||||
new_channel->modes = NULL;
|
||||
new_channel->limit = 0;
|
||||
new_channel->key = NULL;
|
||||
new_channel->nicks_count = 0;
|
||||
new_channel->checking_away = 0;
|
||||
new_channel->away_message = NULL;
|
||||
new_channel->cycle = 0;
|
||||
new_channel->close = 0;
|
||||
new_channel->display_creation_date = 0;
|
||||
new_channel->nick_completion_reset = 0;
|
||||
new_channel->nicks = NULL;
|
||||
new_channel->last_nick = NULL;
|
||||
new_channel->buffer = NULL;
|
||||
new_channel->nicks_speaking = NULL;
|
||||
new_channel->last_nick_speaking = NULL;
|
||||
|
||||
/* add new channel to queue */
|
||||
new_channel->prev_channel = server->last_channel;
|
||||
new_channel->next_channel = NULL;
|
||||
if (server->channels)
|
||||
server->last_channel->next_channel = new_channel;
|
||||
else
|
||||
server->channels = new_channel;
|
||||
server->last_channel = new_channel;
|
||||
|
||||
/* all is ok, return address of new channel */
|
||||
return new_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_free: free a channel and remove it from channels queue
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_free (t_irc_server *server, t_irc_channel *channel)
|
||||
{
|
||||
t_irc_channel *new_channels;
|
||||
|
||||
if (!server || !channel)
|
||||
return;
|
||||
|
||||
/* close DCC CHAT */
|
||||
if (channel->dcc_chat)
|
||||
{
|
||||
((t_irc_dcc *)(channel->dcc_chat))->channel = NULL;
|
||||
if (!IRC_DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status))
|
||||
{
|
||||
irc_dcc_close ((t_irc_dcc *)(channel->dcc_chat), IRC_DCC_ABORTED);
|
||||
irc_dcc_redraw (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove channel from queue */
|
||||
if (server->last_channel == channel)
|
||||
server->last_channel = channel->prev_channel;
|
||||
if (channel->prev_channel)
|
||||
{
|
||||
(channel->prev_channel)->next_channel = channel->next_channel;
|
||||
new_channels = server->channels;
|
||||
}
|
||||
else
|
||||
new_channels = channel->next_channel;
|
||||
|
||||
if (channel->next_channel)
|
||||
(channel->next_channel)->prev_channel = channel->prev_channel;
|
||||
|
||||
/* free data */
|
||||
if (channel->name)
|
||||
free (channel->name);
|
||||
if (channel->topic)
|
||||
free (channel->topic);
|
||||
if (channel->modes)
|
||||
free (channel->modes);
|
||||
if (channel->key)
|
||||
free (channel->key);
|
||||
irc_nick_free_all (channel);
|
||||
if (channel->away_message)
|
||||
free (channel->away_message);
|
||||
if (channel->nicks_speaking)
|
||||
weelist_remove_all (&(channel->nicks_speaking),
|
||||
&(channel->last_nick_speaking));
|
||||
free (channel);
|
||||
server->channels = new_channels;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_free_all: free all allocated channels
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_free_all (t_irc_server *server)
|
||||
{
|
||||
/* remove all channels for the server */
|
||||
while (server->channels)
|
||||
irc_channel_free (server, server->channels);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_search: returns pointer on a channel with name
|
||||
* WARNING: DCC chat channels are not returned by this function
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_search (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type != IRC_CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_search_any: returns pointer on a channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_search_any (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ascii_strcasecmp (ptr_channel->name, channel_name) == 0)
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_search_any_without_buffer: returns pointer on a channel with name
|
||||
* looks only for channels without buffer
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_search_any_without_buffer (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (!ptr_channel->buffer
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_search_dcc: returns pointer on a DCC chat channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_search_dcc (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_is_channel: returns 1 if string is channel
|
||||
*/
|
||||
|
||||
int
|
||||
irc_channel_is_channel (char *string)
|
||||
{
|
||||
char first_char[2];
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
first_char[0] = string[0];
|
||||
first_char[1] = '\0';
|
||||
return (strpbrk (first_char, IRC_CHANNEL_PREFIX)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_remove_away: remove away for all nicks on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_remove_away (t_irc_channel *channel)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
IRC_NICK_SET_FLAG(ptr_nick, 0, IRC_NICK_AWAY);
|
||||
}
|
||||
gui_nicklist_draw (channel->buffer, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_check_away: check for away on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
|
||||
{
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
if (force || (cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= cfg_irc_away_check_max_nicks))
|
||||
{
|
||||
channel->checking_away++;
|
||||
irc_server_sendf (server, "WHO %s", channel->name);
|
||||
}
|
||||
else
|
||||
irc_channel_remove_away (channel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_set_away: set/unset away status for a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_set_away (t_irc_channel *channel, char *nick, int is_away)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick);
|
||||
if (ptr_nick)
|
||||
irc_nick_set_away (channel, ptr_nick, is_away);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_create_dcc: create DCC CHAT channel
|
||||
*/
|
||||
|
||||
int
|
||||
irc_channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
ptr_channel = irc_channel_search_dcc (ptr_dcc->server, ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
ptr_channel = irc_channel_new (ptr_dcc->server,
|
||||
IRC_CHANNEL_TYPE_DCC_CHAT,
|
||||
ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
GUI_BUFFER_TYPE_STANDARD, 0);
|
||||
}
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
(!IRC_DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
|
||||
return 0;
|
||||
|
||||
ptr_channel->dcc_chat = ptr_dcc;
|
||||
ptr_dcc->channel = ptr_channel;
|
||||
gui_window_redraw_buffer (ptr_channel->buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_get_notify_level: get channel notify level
|
||||
*/
|
||||
|
||||
int
|
||||
irc_channel_get_notify_level (t_irc_server *server, t_irc_channel *channel)
|
||||
{
|
||||
char *name, *pos, *pos2;
|
||||
int server_default_notify, notify;
|
||||
|
||||
if ((!server) || (!channel))
|
||||
return GUI_NOTIFY_LEVEL_DEFAULT;
|
||||
|
||||
if ((!server->notify_levels) || (!server->notify_levels[0]))
|
||||
return GUI_NOTIFY_LEVEL_DEFAULT;
|
||||
|
||||
server_default_notify = irc_server_get_default_notify_level (server);
|
||||
if ((channel->type != IRC_CHANNEL_TYPE_CHANNEL)
|
||||
&& (server_default_notify == 1))
|
||||
server_default_notify = 2;
|
||||
|
||||
name = (char *) malloc (strlen (channel->name) + 2);
|
||||
strcpy (name, channel->name);
|
||||
strcat (name, ":");
|
||||
pos = strstr (server->notify_levels, name);
|
||||
free (name);
|
||||
if (!pos)
|
||||
return server_default_notify;
|
||||
|
||||
pos2 = pos + strlen (channel->name);
|
||||
if (pos2[0] != ':')
|
||||
return server_default_notify;
|
||||
pos2++;
|
||||
if (!pos2[0])
|
||||
return server_default_notify;
|
||||
|
||||
notify = (int)(pos2[0] - '0');
|
||||
if ((notify >= GUI_NOTIFY_LEVEL_MIN) && (notify <= GUI_NOTIFY_LEVEL_MAX))
|
||||
return notify;
|
||||
|
||||
return server_default_notify;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_set_notify_level: set channel notify level
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_set_notify_level (t_irc_server *server, t_irc_channel *channel,
|
||||
int notify)
|
||||
{
|
||||
char level_string[2];
|
||||
|
||||
if ((!server) || (!channel))
|
||||
return;
|
||||
|
||||
level_string[0] = notify + '0';
|
||||
level_string[1] = '\0';
|
||||
config_option_list_set (&(server->notify_levels), channel->name, level_string);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_add_nick_speaking: add a nick speaking on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_add_nick_speaking (t_irc_channel *channel, char *nick)
|
||||
{
|
||||
int size, to_remove, i;
|
||||
|
||||
weelist_add (&(channel->nicks_speaking), &(channel->last_nick_speaking),
|
||||
nick, WEELIST_POS_END);
|
||||
|
||||
size = weelist_get_size (channel->nicks_speaking);
|
||||
if (size > IRC_CHANNEL_NICKS_SPEAKING_LIMIT)
|
||||
{
|
||||
to_remove = size - IRC_CHANNEL_NICKS_SPEAKING_LIMIT;
|
||||
for (i = 0; i < to_remove; i++)
|
||||
{
|
||||
weelist_remove (&(channel->nicks_speaking),
|
||||
&(channel->last_nick_speaking),
|
||||
channel->nicks_speaking);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_print_log: print channel infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_print_log (t_irc_channel *channel)
|
||||
{
|
||||
weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel);
|
||||
weechat_log_printf (" type . . . . . . . . : %d\n", channel->type);
|
||||
weechat_log_printf (" dcc_chat . . . . . . : 0x%X\n", channel->dcc_chat);
|
||||
weechat_log_printf (" topic. . . . . . . . : '%s'\n", channel->topic);
|
||||
weechat_log_printf (" modes. . . . . . . . : '%s'\n", channel->modes);
|
||||
weechat_log_printf (" limit. . . . . . . . : %d\n", channel->limit);
|
||||
weechat_log_printf (" key. . . . . . . . . : '%s'\n", channel->key);
|
||||
weechat_log_printf (" checking_away. . . . : %d\n", channel->checking_away);
|
||||
weechat_log_printf (" away_message . . . . : '%s'\n", channel->away_message);
|
||||
weechat_log_printf (" cycle. . . . . . . . : %d\n", channel->cycle);
|
||||
weechat_log_printf (" close. . . . . . . . : %d\n", channel->close);
|
||||
weechat_log_printf (" display_creation_date: %d\n", channel->close);
|
||||
weechat_log_printf (" nicks. . . . . . . . : 0x%X\n", channel->nicks);
|
||||
weechat_log_printf (" last_nick. . . . . . : 0x%X\n", channel->last_nick);
|
||||
weechat_log_printf (" buffer . . . . . . . : 0x%X\n", channel->buffer);
|
||||
weechat_log_printf (" nicks_speaking . . . : 0x%X\n", channel->nicks_speaking);
|
||||
weechat_log_printf (" last_nick_speaking . : 0x%X\n", channel->last_nick_speaking);
|
||||
weechat_log_printf (" prev_channel . . . . : 0x%X\n", channel->prev_channel);
|
||||
weechat_log_printf (" next_channel . . . . : 0x%X\n", channel->next_channel);
|
||||
if (channel->nicks_speaking)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
weelist_print_log (channel->nicks_speaking,
|
||||
"channel nick speaking element");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,514 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-commands.c: implementation of IRC commands, according to
|
||||
RFC 1459,2810,2811,2812 */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/command.h"
|
||||
|
||||
|
||||
t_irc_command irc_commands[] =
|
||||
{ { "admin", N_("find information about the administrator of the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_admin, NULL },
|
||||
{ "ame", N_("send a CTCP action to all channels of all connected servers"),
|
||||
N_("message"),
|
||||
N_("message: message to send"),
|
||||
"", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_ame, NULL },
|
||||
{ "amsg", N_("send message to all channels of all connected servers"),
|
||||
N_("text"),
|
||||
N_("text: text to send"),
|
||||
"", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_amsg, NULL },
|
||||
{ "away", N_("toggle away status"),
|
||||
N_("[-all] [message]"),
|
||||
N_(" -all: toggle away status on all connected servers\n"
|
||||
"message: message for away (if no message is given, away status is removed)"),
|
||||
"-all", 0, MAX_ARGS, 1, 0, NULL, irc_send_cmd_away, NULL },
|
||||
{ "ban", N_("bans nicks or hosts"),
|
||||
N_("[channel] [nickname [nickname ...]]"),
|
||||
N_(" channel: channel for ban\n"
|
||||
"nickname: user or host to ban"),
|
||||
"%N", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_ban, NULL },
|
||||
{ "ctcp", N_("send a CTCP message (Client-To-Client Protocol)"),
|
||||
N_("receiver type [arguments]"),
|
||||
N_(" receiver: nick or channel to send CTCP to\n"
|
||||
" type: CTCP type (examples: \"version\", \"ping\", ..)\n"
|
||||
"arguments: arguments for CTCP"),
|
||||
"%c|%n action|ping|version", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_ctcp, NULL },
|
||||
{ "cycle", N_("leave and rejoin a channel"),
|
||||
N_("[channel[,channel]] [part_message]"),
|
||||
N_(" channel: channel name for cycle\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_cycle, NULL },
|
||||
{ "dehalfop", N_("removes half channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_dehalfop, NULL, NULL },
|
||||
{ "deop", N_("removes channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_deop, NULL, NULL },
|
||||
{ "devoice", N_("removes voice from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_devoice, NULL, NULL },
|
||||
{ "die", N_("shutdown the server"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_die, NULL },
|
||||
{ "error", N_("error received from IRC server"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "halfop", N_("gives half channel operator status to nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_halfop, NULL, NULL },
|
||||
{ "info", N_("get information describing the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_info, NULL },
|
||||
{ "invite", N_("invite a nick on a channel"),
|
||||
N_("nickname channel"),
|
||||
N_("nickname: nick to invite\n"
|
||||
" channel: channel to invite"),
|
||||
"%n %c", 1, 2, 0, 1, irc_send_cmd_invite, NULL, irc_recv_cmd_invite },
|
||||
{ "ison", N_("check if a nickname is currently on IRC"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_ison, NULL },
|
||||
{ "join", N_("join a channel"),
|
||||
N_("channel[,channel] [key[,key]]"),
|
||||
N_("channel: channel name to join\n"
|
||||
" key: key to join the channel"),
|
||||
"%C", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_join, irc_recv_cmd_join },
|
||||
{ "kick", N_("forcibly remove a user from a channel"),
|
||||
N_("[channel] nickname [comment]"),
|
||||
N_(" channel: channel where user is\n"
|
||||
"nickname: nickname to kick\n"
|
||||
" comment: comment for kick"),
|
||||
"%n %-", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kick, irc_recv_cmd_kick },
|
||||
{ "kickban", N_("kicks and bans a nick from a channel"),
|
||||
N_("[channel] nickname [comment]"),
|
||||
N_(" channel: channel where user is\n"
|
||||
"nickname: nickname to kick and ban\n"
|
||||
" comment: comment for kick"),
|
||||
"%n %-", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kickban, NULL },
|
||||
{ "kill", N_("close client-server connection"),
|
||||
N_("nickname comment"),
|
||||
N_("nickname: nickname\n"
|
||||
" comment: comment for kill"),
|
||||
"%n %-", 2, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kill, irc_recv_cmd_kill },
|
||||
{ "links", N_("list all servernames which are known by the server answering the query"),
|
||||
N_("[[server] server_mask]"),
|
||||
N_(" server: this server should answer the query\n"
|
||||
"server_mask: list of servers must match this mask"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_links, NULL },
|
||||
{ "list", N_("list channels and their topic"),
|
||||
N_("[channel[,channel] [server]]"),
|
||||
N_("channel: channel to list (a regexp is allowed)\nserver: server name"),
|
||||
NULL, 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_list, NULL },
|
||||
{ "lusers", N_("get statistics about the size of the IRC network"),
|
||||
N_("[mask [target]]"),
|
||||
N_(" mask: servers matching the mask only\n"
|
||||
"target: server for forwarding request"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_lusers, NULL },
|
||||
{ "me", N_("send a CTCP action to the current channel"),
|
||||
N_("message"),
|
||||
N_("message: message to send"),
|
||||
"", 0, MAX_ARGS, 1, 1, NULL, irc_send_cmd_me, NULL },
|
||||
{ "mode", N_("change channel or user mode"),
|
||||
N_("{ channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask] } | "
|
||||
"{ nickname {[+|-]|i|w|s|o} }"),
|
||||
N_("channel modes:\n"
|
||||
" channel: channel name to modify\n"
|
||||
" o: give/take channel operator privileges\n"
|
||||
" p: private channel flag\n"
|
||||
" s: secret channel flag\n"
|
||||
" i: invite-only channel flag\n"
|
||||
" t: topic settable by channel operator only flag\n"
|
||||
" n: no messages to channel from clients on the outside\n"
|
||||
" m: moderated channel\n"
|
||||
" l: set the user limit to channel\n"
|
||||
" b: set a ban mask to keep users out\n"
|
||||
" e: set exception mask\n"
|
||||
" v: give/take the ability to speak on a moderated channel\n"
|
||||
" k: set a channel key (password)\n"
|
||||
"user modes:\n"
|
||||
" nickname: nickname to modify\n"
|
||||
" i: mark a user as invisible\n"
|
||||
" s: mark a user for receive server notices\n"
|
||||
" w: user receives wallops\n"
|
||||
" o: operator flag"),
|
||||
"%c|%m", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_mode, irc_recv_cmd_mode },
|
||||
{ "motd", N_("get the \"Message Of The Day\""),
|
||||
N_("[target]"),
|
||||
N_("target: server name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_motd, NULL },
|
||||
{ "msg", N_("send message to a nick or channel"),
|
||||
N_("receiver[,receiver] text"),
|
||||
N_("receiver: nick or channel (may be mask, '*' = current channel)\n"
|
||||
"text: text to send"),
|
||||
"", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_msg, NULL },
|
||||
{ "names", N_("list nicknames on channels"),
|
||||
N_("[channel[,channel]]"),
|
||||
N_("channel: channel name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_names, NULL },
|
||||
{ "nick", N_("change current nickname"),
|
||||
N_("[-all] nickname"),
|
||||
N_(" -all: set new nickname for all connected servers\n"
|
||||
"nickname: new nickname"),
|
||||
"-all", 1, 2, 0, 0, irc_send_cmd_nick, NULL, irc_recv_cmd_nick },
|
||||
{ "notice", N_("send notice message to user"),
|
||||
N_("nickname text"),
|
||||
N_("nickname: user to send notice to\n"
|
||||
" text: text to send"),
|
||||
"%n %-", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_notice, irc_recv_cmd_notice },
|
||||
{ "op", N_("gives channel operator status to nickname(s)"),
|
||||
N_("nickname [nickname]"), "",
|
||||
"", 1, MAX_ARGS, 0, 1, irc_send_cmd_op, NULL, NULL },
|
||||
{ "oper", N_("get operator privileges"),
|
||||
N_("user password"),
|
||||
N_("user/password: used to get privileges on current IRC server"),
|
||||
NULL, 2, 2, 0, 1, NULL, irc_send_cmd_oper, NULL },
|
||||
{ "part", N_("leave a channel"),
|
||||
N_("[channel[,channel]] [part_message]"),
|
||||
N_(" channel: channel name to leave\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_part, irc_recv_cmd_part },
|
||||
{ "ping", N_("ping server"),
|
||||
N_("server1 [server2]"),
|
||||
N_("server1: server to ping\nserver2: forward ping to this server"),
|
||||
NULL, 1, 2, 0, 1, NULL, irc_send_cmd_ping, irc_recv_cmd_ping },
|
||||
{ "pong", N_("answer to a ping message"),
|
||||
N_("daemon [daemon2]"),
|
||||
N_(" daemon: daemon who has responded to Ping message\n"
|
||||
"daemon2: forward message to this daemon"),
|
||||
NULL, 1, 2, 0, 1, NULL, irc_send_cmd_pong, irc_recv_cmd_pong },
|
||||
{ "privmsg", N_("message received"), "", "",
|
||||
"", 0, 0, 1, 1, NULL, NULL, irc_recv_cmd_privmsg },
|
||||
{ "query", N_("send a private message to a nick"),
|
||||
N_("nickname [text]"),
|
||||
N_("nickname: nickname for private conversation\n"
|
||||
" text: text to send"),
|
||||
"%n %-", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_query, NULL },
|
||||
{ "quit", N_("close all connections and quit"),
|
||||
N_("[quit_message]"),
|
||||
N_("quit_message: quit message (displayed to other users)"),
|
||||
"%q", 0, MAX_ARGS, 1, 0, NULL, irc_send_cmd_quit, irc_recv_cmd_quit },
|
||||
{ "quote", N_("send raw data to server without parsing"),
|
||||
N_("data"),
|
||||
N_("data: raw data to send"),
|
||||
"", 1, MAX_ARGS, 1, 0, NULL, irc_send_cmd_quote, NULL },
|
||||
{ "rehash", N_("tell the server to reload its config file"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_rehash, NULL },
|
||||
{ "restart", N_("tell the server to restart itself"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_restart, NULL },
|
||||
{ "service", N_("register a new service"),
|
||||
N_("nickname reserved distribution type reserved info"),
|
||||
N_("distribution: visibility of service\n"
|
||||
" type: reserved for future usage"),
|
||||
NULL, 6, 6, 0, 1, NULL, irc_send_cmd_service, NULL },
|
||||
{ "servlist", N_("list services currently connected to the network"),
|
||||
N_("[mask [type]]"),
|
||||
N_("mask: list only services matching this mask\n"
|
||||
"type: list only services of this type"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_servlist, NULL },
|
||||
{ "squery", N_("deliver a message to a service"),
|
||||
N_("service text"),
|
||||
N_("service: name of service\ntext: text to send"),
|
||||
NULL, 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_squery, NULL },
|
||||
{ "squit", N_("disconnect server links"),
|
||||
N_("server comment"),
|
||||
N_( "server: server name\n"
|
||||
"comment: comment for quit"),
|
||||
NULL, 2, 2, 1, 1, NULL, irc_send_cmd_squit, NULL },
|
||||
{ "stats", N_("query statistics about server"),
|
||||
N_("[query [server]]"),
|
||||
N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n"
|
||||
"server: server name"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_stats, NULL },
|
||||
{ "summon", N_("give users who are on a host running an IRC server a message "
|
||||
"asking them to please join IRC"),
|
||||
N_("user [target [channel]]"),
|
||||
N_(" user: username\ntarget: server name\n"
|
||||
"channel: channel name"),
|
||||
NULL, 1, 3, 0, 1, NULL, irc_send_cmd_summon, NULL },
|
||||
{ "time", N_("query local time from server"),
|
||||
N_("[target]"),
|
||||
N_("target: query time from specified server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_time, NULL },
|
||||
{ "topic", N_("get/set channel topic"),
|
||||
N_("[channel] [topic]"),
|
||||
N_("channel: channel name\ntopic: new topic for channel "
|
||||
"(if topic is \"-delete\" then topic is deleted)"),
|
||||
"%t|-delete %-", 0, MAX_ARGS, 1, 1, NULL, irc_send_cmd_topic, irc_recv_cmd_topic },
|
||||
{ "trace", N_("find the route to specific server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_trace, NULL },
|
||||
{ "unban", N_("unbans nicks or hosts"),
|
||||
N_("[channel] nickname [nickname ...]"),
|
||||
N_(" channel: channel for unban\n"
|
||||
"nickname: user or host to unban"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_unban, NULL },
|
||||
{ "userhost", N_("return a list of information about nicknames"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
"%n", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_userhost, NULL },
|
||||
{ "users", N_("list of users logged into the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_users, NULL },
|
||||
{ "version", N_("gives the version info of nick or server (current or specified)"),
|
||||
N_("[server | nickname]"),
|
||||
N_(" server: server name\n"
|
||||
"nickname: nickname"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_version, NULL },
|
||||
{ "voice", N_("gives voice to nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_voice, NULL, NULL },
|
||||
{ "wallops", N_("send a message to all currently connected users who have "
|
||||
"set the 'w' user mode for themselves"),
|
||||
N_("text"),
|
||||
N_("text to send"),
|
||||
NULL, 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_wallops, irc_recv_cmd_wallops },
|
||||
{ "who", N_("generate a query which returns a list of information"),
|
||||
N_("[mask [\"o\"]]"),
|
||||
N_("mask: only information which match this mask\n"
|
||||
" o: only operators are returned according to the mask supplied"),
|
||||
"%C", 0, 2, 0, 1, NULL, irc_send_cmd_who, NULL },
|
||||
{ "whois", N_("query information about user(s)"),
|
||||
N_("[server] nickname[,nickname]"),
|
||||
N_(" server: server name\n"
|
||||
"nickname: nickname (may be a mask)"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_whois, NULL },
|
||||
{ "whowas", N_("ask for information about a nickname which no longer exists"),
|
||||
N_("nickname [,nickname [,nickname ...]] [count [target]]"),
|
||||
N_("nickname: nickname to search\n"
|
||||
" count: number of replies to return (full search if negative number)\n"
|
||||
" target: reply should match this mask"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_whowas, NULL },
|
||||
{ "001", N_("a server message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_001 },
|
||||
{ "005", N_("a server message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_005 },
|
||||
{ "221", N_("user mode string"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_221 },
|
||||
{ "301", N_("away message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_301 },
|
||||
{ "302", N_("userhost"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_302 },
|
||||
{ "303", N_("ison"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_303 },
|
||||
{ "305", N_("unaway"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_305 },
|
||||
{ "306", N_("now away"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_306 },
|
||||
{ "307", N_("whois (registered nick)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "310", N_("whois (help mode)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_310 },
|
||||
{ "311", N_("whois (user)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_311 },
|
||||
{ "312", N_("whois (server)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_312 },
|
||||
{ "313", N_("whois (operator)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "314", N_("whowas"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_314 },
|
||||
{ "315", N_("end of /who list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_315 },
|
||||
{ "317", N_("whois (idle)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_317 },
|
||||
{ "318", N_("whois (end)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "319", N_("whois (channels)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_319 },
|
||||
{ "320", N_("whois (identified user)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "321", N_("/list start"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_321 },
|
||||
{ "322", N_("channel (for /list)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_322 },
|
||||
{ "323", N_("/list end"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_323 },
|
||||
{ "324", N_("channel mode"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_324 },
|
||||
{ "326", N_("whois (has oper privs)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "327", N_("whois (host)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_327 },
|
||||
{ "329", N_("channel creation date"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_329 },
|
||||
{ "331", N_("no topic for channel"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_331 },
|
||||
{ "332", N_("topic of channel"),
|
||||
N_("channel :topic"),
|
||||
N_("channel: name of channel\n"
|
||||
" topic: topic of the channel"),
|
||||
NULL, 2, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_332 },
|
||||
{ "333", N_("infos about topic (nick and date changed)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_333 },
|
||||
{ "338", N_("whois (host)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_338 },
|
||||
{ "341", N_("inviting"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_341 },
|
||||
{ "344", N_("channel reop"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_344 },
|
||||
{ "345", N_("end of channel reop list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_345 },
|
||||
{ "348", N_("channel exception list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_348 },
|
||||
{ "349", N_("end of channel exception list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_349 },
|
||||
{ "351", N_("server version"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_351 },
|
||||
{ "352", N_("who"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_352 },
|
||||
{ "353", N_("list of nicks on channel"),
|
||||
N_("channel :[[@|+]nick ...]"),
|
||||
N_("channel: name of channel\n"
|
||||
" nick: nick on the channel"),
|
||||
NULL, 2, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_353 },
|
||||
{ "366", N_("end of /names list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_366 },
|
||||
{ "367", N_("banlist"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_367 },
|
||||
{ "368", N_("end of banlist"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_368 },
|
||||
{ "378", N_("whois (connecting from)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "379", N_("whois (using modes)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "401", N_("no such nick/channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "402", N_("no such server"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "403", N_("no such channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "404", N_("cannot send to channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "405", N_("too many channels"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "406", N_("was no such nick"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "407", N_("was no such nick"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "409", N_("no origin"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "410", N_("no services"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "411", N_("no recipient"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "412", N_("no text to send"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "413", N_("no toplevel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "414", N_("wilcard in toplevel domain"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "421", N_("unknown command"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "422", N_("MOTD is missing"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "423", N_("no administrative info"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "424", N_("file error"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "431", N_("no nickname given"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "432", N_("erroneous nickname"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_432 },
|
||||
{ "433", N_("nickname already in use"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_433 },
|
||||
{ "436", N_("nickname collision"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "437", N_("resource unavailable"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "438", N_("not authorized to change nickname"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_438 },
|
||||
{ "441", N_("user not in channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "442", N_("not on channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "443", N_("user already on channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "444", N_("user not logged in"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "445", N_("summon has been disabled"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "446", N_("users has been disabled"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "451", N_("you are not registered"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "461", N_("not enough parameters"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "462", N_("you may not register"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "463", N_("your host isn't among the privileged"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "464", N_("password incorrect"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "465", N_("you are banned from this server"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "467", N_("channel key already set"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "470", N_("forwarding to another channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "471", N_("channel is already full"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "472", N_("unknown mode char to me"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "473", N_("cannot join channel (invite only)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "474", N_("cannot join channel (banned from channel)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "475", N_("cannot join channel (bad channel key)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "476", N_("bad channel mask"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "477", N_("channel doesn't support modes"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "481", N_("you're not an IRC operator"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "482", N_("you're not channel operator"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "483", N_("you can't kill a server!"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "484", N_("your connection is restricted!"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "485", N_("user is immune from kick/deop"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "487", N_("network split"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "491", N_("no O-lines for your host"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "501", N_("unknown mode flag"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "502", N_("can't change mode for other users"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "671", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_671 },
|
||||
{ "973", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ "974", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ "975", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, NULL }
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,487 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-display.c: display functions for IRC */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_display_hide_password: hide IRC password(s) in a string
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
char *pos_nickserv, *pos, *pos_pwd;
|
||||
|
||||
pos = string;
|
||||
while (1)
|
||||
{
|
||||
if (look_for_nickserv)
|
||||
{
|
||||
pos_nickserv = strstr (pos, "nickserv ");
|
||||
if (!pos_nickserv)
|
||||
return;
|
||||
pos = pos_nickserv + 9;
|
||||
while (pos[0] == ' ')
|
||||
pos++;
|
||||
if ((strncmp (pos, "identify ", 9) == 0)
|
||||
|| (strncmp (pos, "register ", 9) == 0))
|
||||
pos_pwd = pos + 9;
|
||||
else
|
||||
pos_pwd = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_pwd = strstr (pos, "identify ");
|
||||
if (!pos_pwd)
|
||||
pos_pwd = strstr (pos, "register ");
|
||||
if (!pos_pwd)
|
||||
return;
|
||||
pos_pwd += 9;
|
||||
}
|
||||
|
||||
if (pos_pwd)
|
||||
{
|
||||
while (pos_pwd[0] == ' ')
|
||||
pos_pwd++;
|
||||
|
||||
while (pos_pwd[0] && (pos_pwd[0] != ';') && (pos_pwd[0] != ' ')
|
||||
&& (pos_pwd[0] != '"'))
|
||||
{
|
||||
pos_pwd[0] = '*';
|
||||
pos_pwd++;
|
||||
}
|
||||
pos = pos_pwd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_prefix: display a prefix for action/info/error msg
|
||||
* prefix must be 3 chars length
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_prefix (t_irc_server *server, t_gui_buffer *buffer, char *prefix)
|
||||
{
|
||||
int type;
|
||||
char format[32];
|
||||
|
||||
type = GUI_MSG_TYPE_INFO | GUI_MSG_TYPE_PREFIX;
|
||||
|
||||
if (!cfg_log_plugin_msg && (strcmp (prefix, GUI_PREFIX_PLUGIN) == 0))
|
||||
type |= GUI_MSG_TYPE_NOLOG;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
if (cfg_look_align_other
|
||||
&& (GUI_BUFFER_IS_CHANNEL(buffer) || GUI_BUFFER_IS_PRIVATE(buffer)))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", cfg_look_align_size - 2);
|
||||
gui_printf_type (buffer, GUI_MSG_TYPE_NICK, format, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix[0] == prefix[2])
|
||||
{
|
||||
gui_printf_type (buffer, type, "%s%c%s%c%s%c ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1),
|
||||
prefix[0],
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX2),
|
||||
prefix[1],
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1),
|
||||
prefix[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (prefix, GUI_PREFIX_JOIN) == 0)
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_JOIN), prefix);
|
||||
else if (strcmp (prefix, GUI_PREFIX_PART) == 0)
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PART), prefix);
|
||||
else
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1), prefix);
|
||||
}
|
||||
if (server && (server->buffer == buffer) && buffer->all_servers)
|
||||
{
|
||||
gui_printf_type (buffer, type, "%s[%s%s%s] ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER), server->name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
}
|
||||
gui_printf_type (buffer, type, GUI_NO_COLOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_nick: display nick in chat window
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
int type, int display_around, int force_color, int no_nickmode)
|
||||
{
|
||||
char format[32], *ptr_nickname;
|
||||
int max_align, i, nickname_length, external_nick, length, spaces;
|
||||
int disable_prefix_suffix;
|
||||
|
||||
max_align = (cfg_look_align_size_max >= cfg_look_align_size) ?
|
||||
cfg_look_align_size_max : cfg_look_align_size;
|
||||
|
||||
ptr_nickname = strdup ((nick) ? nick->nick : nickname);
|
||||
if (!ptr_nickname)
|
||||
return;
|
||||
nickname_length = utf8_width_screen (ptr_nickname);
|
||||
external_nick = (!nick && !GUI_BUFFER_IS_PRIVATE(buffer));
|
||||
disable_prefix_suffix = ((cfg_look_align_nick != CFG_LOOK_ALIGN_NICK_NONE)
|
||||
&& ((int)strlen (cfg_look_nick_prefix) +
|
||||
(int)strlen (cfg_look_nick_suffix) > max_align - 4));
|
||||
|
||||
/* calculate length to display, to truncate it if too long */
|
||||
length = nickname_length;
|
||||
if (!disable_prefix_suffix && cfg_look_nick_prefix)
|
||||
length += strlen (cfg_look_nick_prefix);
|
||||
if (external_nick)
|
||||
length += 2;
|
||||
if (nick && cfg_look_nickmode)
|
||||
{
|
||||
if (nick->flags & (IRC_NICK_CHANOWNER | IRC_NICK_CHANADMIN |
|
||||
IRC_NICK_CHANADMIN2 | IRC_NICK_OP | IRC_NICK_HALFOP |
|
||||
IRC_NICK_VOICE | IRC_NICK_CHANUSER))
|
||||
length += 1;
|
||||
else if (cfg_look_nickmode_empty && !no_nickmode)
|
||||
length += 1;
|
||||
}
|
||||
if (!disable_prefix_suffix && cfg_look_nick_suffix)
|
||||
length += strlen (cfg_look_nick_suffix);
|
||||
|
||||
/* calculate number of spaces to insert before or after nick */
|
||||
spaces = 0;
|
||||
if (cfg_look_align_nick != CFG_LOOK_ALIGN_NICK_NONE)
|
||||
{
|
||||
if (length > max_align)
|
||||
spaces = max_align - length;
|
||||
else if (length > cfg_look_align_size)
|
||||
spaces = 0;
|
||||
else
|
||||
spaces = cfg_look_align_size - length;
|
||||
}
|
||||
|
||||
/* display prefix */
|
||||
if (display_around && !disable_prefix_suffix
|
||||
&& cfg_look_nick_prefix && cfg_look_nick_prefix[0])
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
cfg_look_nick_prefix);
|
||||
|
||||
/* display spaces before nick, if needed */
|
||||
if (display_around
|
||||
&& (cfg_look_align_nick == CFG_LOOK_ALIGN_NICK_RIGHT)
|
||||
&& (spaces > 0))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", spaces);
|
||||
gui_printf_type (buffer, type, format, " ");
|
||||
}
|
||||
|
||||
/* display nick mode */
|
||||
if (nick && cfg_look_nickmode)
|
||||
{
|
||||
if (nick->flags & IRC_NICK_CHANOWNER)
|
||||
gui_printf_type (buffer, type, "%s~",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN)
|
||||
gui_printf_type (buffer, type, "%s&",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN2)
|
||||
gui_printf_type (buffer, type, "%s!",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
else if (nick->flags & IRC_NICK_OP)
|
||||
gui_printf_type (buffer, type, "%s@",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
else if (nick->flags & IRC_NICK_HALFOP)
|
||||
gui_printf_type (buffer, type, "%s%%",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_HALFOP));
|
||||
else if (nick->flags & IRC_NICK_VOICE)
|
||||
gui_printf_type (buffer, type, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_VOICE));
|
||||
else if (nick->flags & IRC_NICK_CHANUSER)
|
||||
gui_printf_type (buffer, type, "%s-",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_CHANUSER));
|
||||
else if (cfg_look_nickmode_empty && !no_nickmode)
|
||||
gui_printf_type (buffer, type, "%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
}
|
||||
|
||||
/* display nick */
|
||||
if (external_nick)
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
"(");
|
||||
if (display_around && (spaces < 0))
|
||||
{
|
||||
i = nickname_length + spaces - 1;
|
||||
if (i < 3)
|
||||
{
|
||||
if (nickname_length < 3)
|
||||
i = nickname_length;
|
||||
else
|
||||
i = 3;
|
||||
}
|
||||
ptr_nickname[i] = '\0';
|
||||
}
|
||||
if (display_around)
|
||||
gui_printf_type_nick (buffer, type,
|
||||
(nick) ? nick->nick : nickname,
|
||||
"%s%s",
|
||||
(force_color >= 0) ?
|
||||
GUI_COLOR(force_color) :
|
||||
GUI_COLOR((nick) ? nick->color : GUI_COLOR_WIN_CHAT),
|
||||
ptr_nickname);
|
||||
else
|
||||
gui_printf_type (buffer, type,
|
||||
"%s%s",
|
||||
(force_color >= 0) ?
|
||||
GUI_COLOR(force_color) :
|
||||
GUI_COLOR((nick) ? nick->color : GUI_COLOR_WIN_CHAT),
|
||||
ptr_nickname);
|
||||
if (display_around && (spaces < 0))
|
||||
gui_printf_type (buffer, type, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_MORE));
|
||||
if (external_nick)
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
")");
|
||||
|
||||
/* display spaces after nick, if needed */
|
||||
if (display_around
|
||||
&& (cfg_look_align_nick == CFG_LOOK_ALIGN_NICK_LEFT)
|
||||
&& (spaces > 0))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", spaces);
|
||||
gui_printf_type (buffer, type, format, " ");
|
||||
}
|
||||
|
||||
/* display suffix */
|
||||
if (display_around && !disable_prefix_suffix
|
||||
&& cfg_look_nick_suffix && cfg_look_nick_suffix[0])
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
cfg_look_nick_suffix);
|
||||
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_NO_COLOR,
|
||||
(display_around) ? " " : "");
|
||||
free (ptr_nickname);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_away: display away on all channels of all servers
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_away (t_irc_server *server, char *string1, char *string2)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
char format[32];
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
if (cfg_look_align_other)
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", cfg_look_align_size + 1);
|
||||
gui_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK,
|
||||
format, " ");
|
||||
}
|
||||
gui_printf_nolog (ptr_channel->buffer,
|
||||
"%s[%s%s%s %s: %s%s]\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
server->nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
string1,
|
||||
string2,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_mode: display IRC message for mode change
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_mode (t_irc_server *server, t_gui_buffer *buffer,
|
||||
char *channel_name, char *nick_name, char set_flag,
|
||||
char *symbol, char *nick_host, char *message, char *param)
|
||||
{
|
||||
irc_display_prefix (server, buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (buffer, "%s[%s%s%s/%s%c%s%s] %s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
(channel_name) ?
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL) :
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
(channel_name) ? channel_name : nick_name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
set_flag,
|
||||
symbol,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick_host);
|
||||
if (param)
|
||||
gui_printf (buffer, " %s%s %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
message,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
param);
|
||||
else
|
||||
gui_printf (buffer, " %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
message);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_server: display server description
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_server (t_irc_server *server, int with_detail)
|
||||
{
|
||||
char *string;
|
||||
int num_channels, num_pv;
|
||||
|
||||
if (with_detail)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
|
||||
server->name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
|
||||
gui_printf (NULL, " server_autoconnect . . . . : %s%s\n",
|
||||
(server->autoconnect) ? _("on") : _("off"),
|
||||
(server->temp_server) ?
|
||||
_(" (temporary server, will not be saved)") : "");
|
||||
gui_printf (NULL, " server_autoreconnect . . . : %s\n",
|
||||
(server->autoreconnect) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_autoreconnect_delay : %d %s\n",
|
||||
server->autoreconnect_delay,
|
||||
_("seconds"));
|
||||
gui_printf (NULL, " server_address . . . . . . : %s\n",
|
||||
server->address);
|
||||
gui_printf (NULL, " server_port . . . . . . . : %d\n",
|
||||
server->port);
|
||||
gui_printf (NULL, " server_ipv6 . . . . . . . : %s\n",
|
||||
(server->ipv6) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_ssl . . . . . . . . : %s\n",
|
||||
(server->ssl) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_password . . . . . : %s\n",
|
||||
(server->password && server->password[0]) ?
|
||||
_("(hidden)") : "");
|
||||
gui_printf (NULL, " server_nick1/2/3 . . . . . : %s %s/ %s%s %s/ %s%s\n",
|
||||
server->nick1,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
server->nick2,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
server->nick3);
|
||||
gui_printf (NULL, " server_username . . . . . : %s\n",
|
||||
server->username);
|
||||
gui_printf (NULL, " server_realname . . . . . : %s\n",
|
||||
server->realname);
|
||||
gui_printf (NULL, " server_hostname . . . . . : %s\n",
|
||||
(server->hostname) ? server->hostname : "");
|
||||
if (server->command && server->command[0])
|
||||
string = strdup (server->command);
|
||||
else
|
||||
string = NULL;
|
||||
if (string)
|
||||
{
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
irc_display_hide_password (string, 1);
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
string);
|
||||
free (string);
|
||||
}
|
||||
else
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
gui_printf (NULL, " server_command_delay . . . : %d %s\n",
|
||||
server->command_delay,
|
||||
_("seconds"));
|
||||
gui_printf (NULL, " server_autojoin . . . . . : %s\n",
|
||||
(server->autojoin && server->autojoin[0]) ?
|
||||
server->autojoin : "");
|
||||
gui_printf (NULL, " server_notify_levels . . . : %s\n",
|
||||
(server->notify_levels && server->notify_levels[0]) ?
|
||||
server->notify_levels : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (NULL, " %s %s%s ",
|
||||
(server->is_connected) ? "*" : " ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
|
||||
server->name);
|
||||
gui_printf (NULL, "%s[%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"));
|
||||
if (server->is_connected)
|
||||
{
|
||||
num_channels = irc_server_get_channel_count (server);
|
||||
num_pv = irc_server_get_pv_count (server);
|
||||
gui_printf (NULL, ", ");
|
||||
gui_printf (NULL, NG_("%d channel", "%d channels", num_channels),
|
||||
num_channels);
|
||||
gui_printf (NULL, ", ");
|
||||
gui_printf (NULL, _("%d pv"), num_pv);
|
||||
}
|
||||
gui_printf (NULL, "%s]%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->temp_server) ? _(" (temporary)") : "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-ignore.c: manages IRC ignore list */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/command.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/util.h"
|
||||
|
||||
|
||||
t_irc_ignore *irc_ignore = NULL;
|
||||
t_irc_ignore *last_irc_ignore = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_ignore_check_mask: return 1 is mask1 and mask2 are the same host
|
||||
* anyone or both strings may have user and/or host after
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_check_mask (char *mask1, char *mask2)
|
||||
{
|
||||
char *m1, *m2, *pos;
|
||||
int match;
|
||||
|
||||
if (!mask1 || !mask1[0] || !mask2 || !mask2[0])
|
||||
return 0;
|
||||
|
||||
m1 = strdup (mask1);
|
||||
m2 = strdup (mask2);
|
||||
|
||||
pos = strchr (m1, '!');
|
||||
if (!pos)
|
||||
{
|
||||
/* remove '!' from m2 */
|
||||
pos = strchr (m2, '!');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
}
|
||||
pos = strchr (m2, '!');
|
||||
if (!pos)
|
||||
{
|
||||
/* remove '!' from m1 */
|
||||
pos = strchr (m1, '!');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
}
|
||||
|
||||
/* TODO: use regexp to match both masks */
|
||||
match = ascii_strcasecmp (m1, m2);
|
||||
|
||||
free (m1);
|
||||
free (m2);
|
||||
|
||||
return (match == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_match: check if pointed ignore matches with arguments
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_match (t_irc_ignore *ptr_ignore, char *mask, char *type,
|
||||
char *channel_name, char *server_name)
|
||||
{
|
||||
/* check mask */
|
||||
if ((strcmp (mask, "*") != 0) && (strcmp (ptr_ignore->mask, "*") != 0)
|
||||
&& (!irc_ignore_check_mask (ptr_ignore->mask, mask)))
|
||||
return 0;
|
||||
|
||||
/* mask is matching, go on with type */
|
||||
if ((strcmp (type, "*") != 0) && (strcmp (ptr_ignore->type, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->type, type) != 0))
|
||||
return 0;
|
||||
|
||||
/* mask and type matching, go on with server */
|
||||
if (server_name && server_name[0])
|
||||
{
|
||||
if ((strcmp (server_name, "*") != 0) && (strcmp (ptr_ignore->server_name, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->server_name, server_name) != 0))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (ptr_ignore->server_name, "*") != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* mask, type and server matching, go on with channel */
|
||||
if (channel_name && channel_name[0])
|
||||
{
|
||||
if ((strcmp (channel_name, "*") != 0) && (strcmp (ptr_ignore->channel_name, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->channel_name, channel_name) != 0))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (ptr_ignore->channel_name, "*") != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* all is matching => we find a ignore! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_check: check if an ignore is set for arguments
|
||||
* return 1 if at least one ignore exists (message should NOT be displayed)
|
||||
* 0 if no ignore found (message will be displayed)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_check (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
if (!mask || !mask[0] || !type || !type[0])
|
||||
return 0;
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (irc_ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* no ignore found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search: search for an ignore
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_search (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if ((ascii_strcasecmp (ptr_ignore->mask, mask) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->type, type) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->channel_name, channel_name) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->server_name, server_name) == 0))
|
||||
return ptr_ignore;
|
||||
}
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_add: add an ignore in list
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_add (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
int type_index;
|
||||
t_irc_command *command_ptr;
|
||||
t_irc_ignore *new_ignore;
|
||||
|
||||
if (!mask || !mask[0] || !type || !type[0] || !channel_name || !channel_name[0]
|
||||
|| !server_name || !server_name[0])
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s too few arguments for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
weechat_log_printf ("Adding ignore: mask:'%s', type:'%s', channel:'%s', "
|
||||
"server:'%s'\n",
|
||||
mask, type, channel_name, server_name);
|
||||
#endif
|
||||
|
||||
type_index = -1;
|
||||
command_ptr = NULL;
|
||||
|
||||
if ((strcmp (mask, "*") == 0) && (strcmp (type, "*") == 0))
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s mask or type/command should be non generic value for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (irc_ignore_search (mask, type, channel_name, server_name))
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s ignore already exists\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create new ignore */
|
||||
new_ignore = (t_irc_ignore *) malloc (sizeof (t_irc_ignore));
|
||||
if (new_ignore)
|
||||
{
|
||||
new_ignore->mask = strdup (mask);
|
||||
new_ignore->type = strdup (type);
|
||||
new_ignore->server_name = strdup (server_name);
|
||||
new_ignore->channel_name = strdup (channel_name);
|
||||
|
||||
/* add new ignore to queue */
|
||||
new_ignore->prev_ignore = last_irc_ignore;
|
||||
new_ignore->next_ignore = NULL;
|
||||
if (irc_ignore)
|
||||
last_irc_ignore->next_ignore = new_ignore;
|
||||
else
|
||||
irc_ignore = new_ignore;
|
||||
last_irc_ignore = new_ignore;
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s not enough memory to create ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_add_from_config: add an ignore to list, read from config file
|
||||
* (comma serparated values)
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_add_from_config (char *string)
|
||||
{
|
||||
t_irc_ignore *new_ignore;
|
||||
char *string2;
|
||||
char *pos_mask, *pos_type, *pos_channel, *pos_server;
|
||||
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
new_ignore = NULL;
|
||||
string2 = strdup (string);
|
||||
|
||||
pos_mask = string2;
|
||||
pos_type = strchr (pos_mask, ',');
|
||||
if (pos_type)
|
||||
{
|
||||
pos_type[0] = '\0';
|
||||
pos_type++;
|
||||
pos_channel = strchr (pos_type, ',');
|
||||
if (pos_channel)
|
||||
{
|
||||
pos_channel[0] = '\0';
|
||||
pos_channel++;
|
||||
pos_server = strchr (pos_channel, ',');
|
||||
if (pos_server)
|
||||
{
|
||||
pos_server[0] = '\0';
|
||||
pos_server++;
|
||||
new_ignore = irc_ignore_add (pos_mask, pos_type, pos_channel, pos_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (string2);
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_free: free an ignore
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_free (t_irc_ignore *ptr_ignore)
|
||||
{
|
||||
t_irc_ignore *new_irc_ignore;
|
||||
|
||||
/* free data */
|
||||
if (ptr_ignore->mask)
|
||||
free (ptr_ignore->mask);
|
||||
if (ptr_ignore->type)
|
||||
free (ptr_ignore->type);
|
||||
if (ptr_ignore->channel_name)
|
||||
free (ptr_ignore->channel_name);
|
||||
if (ptr_ignore->server_name)
|
||||
free (ptr_ignore->server_name);
|
||||
|
||||
/* remove ignore from queue */
|
||||
if (last_irc_ignore == ptr_ignore)
|
||||
last_irc_ignore = ptr_ignore->prev_ignore;
|
||||
if (ptr_ignore->prev_ignore)
|
||||
{
|
||||
(ptr_ignore->prev_ignore)->next_ignore = ptr_ignore->next_ignore;
|
||||
new_irc_ignore = irc_ignore;
|
||||
}
|
||||
else
|
||||
new_irc_ignore = ptr_ignore->next_ignore;
|
||||
|
||||
if (ptr_ignore->next_ignore)
|
||||
(ptr_ignore->next_ignore)->prev_ignore = ptr_ignore->prev_ignore;
|
||||
|
||||
free (ptr_ignore);
|
||||
irc_ignore = new_irc_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_free_all: free all ignores
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_free_all ()
|
||||
{
|
||||
while (irc_ignore)
|
||||
irc_ignore_free (irc_ignore);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search_free: search and free ignore(s)
|
||||
* return: number of ignore found and deleted
|
||||
* 0 if no ignore found
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_search_free (char *mask, char *type,
|
||||
char *channel_name, char *server_name)
|
||||
{
|
||||
int found;
|
||||
t_irc_ignore *ptr_ignore, *next_ignore;
|
||||
|
||||
found = 0;
|
||||
ptr_ignore = irc_ignore;
|
||||
while (ptr_ignore)
|
||||
{
|
||||
if (irc_ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
{
|
||||
found++;
|
||||
if (found == 1)
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
next_ignore = ptr_ignore->next_ignore;
|
||||
irc_ignore_free (ptr_ignore);
|
||||
ptr_ignore = next_ignore;
|
||||
}
|
||||
else
|
||||
ptr_ignore = ptr_ignore->next_ignore;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search_free_by_number: search and free ignore(s) by number
|
||||
* return: 1 if ignore found and deleted
|
||||
* 0 if ignore not found
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_search_free_by_number (int number)
|
||||
{
|
||||
int i;
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
if (number < 1)
|
||||
return 0;
|
||||
|
||||
i = 0;
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
i++;
|
||||
if (i == number)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
irc_ignore_free (ptr_ignore);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ignore number not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_print_log: print ignore list in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_print_log ()
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
weechat_log_printf ("[ignore list]\n");
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" -> ignore at 0x%X:\n", ptr_ignore);
|
||||
weechat_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask);
|
||||
weechat_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type);
|
||||
weechat_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name);
|
||||
weechat_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name);
|
||||
weechat_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore);
|
||||
weechat_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-mode.c: IRC channel/user modes management */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_mode_channel_set_nick: set a mode for a nick on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_mode_channel_set_nick (t_irc_channel *channel, char *nick,
|
||||
char set_flag, int flag)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
if (nick)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
IRC_NICK_SET_FLAG(ptr_nick, (set_flag == '+'), flag);
|
||||
irc_nick_resort (channel, ptr_nick);
|
||||
gui_nicklist_draw (channel->buffer, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_channel_get_flag: search for flag before current position
|
||||
*/
|
||||
|
||||
char
|
||||
irc_mode_channel_get_flag (char *str, char *pos)
|
||||
{
|
||||
char set_flag;
|
||||
|
||||
set_flag = '+';
|
||||
pos--;
|
||||
while (pos >= str)
|
||||
{
|
||||
if (pos[0] == '-')
|
||||
return '-';
|
||||
if (pos[0] == '+')
|
||||
return '+';
|
||||
pos--;
|
||||
}
|
||||
return set_flag;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_channel_set: set channel modes
|
||||
*/
|
||||
|
||||
void
|
||||
irc_mode_channel_set (t_irc_server *server, t_irc_channel *channel,
|
||||
char *modes)
|
||||
{
|
||||
char *pos_args, set_flag, **argv, *pos, *ptr_arg;
|
||||
int argc, current_arg;
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
current_arg = 0;
|
||||
pos_args = strchr (modes, ' ');
|
||||
if (pos_args)
|
||||
{
|
||||
pos_args[0] = '\0';
|
||||
pos_args++;
|
||||
while (pos_args[0] == ' ')
|
||||
pos_args++;
|
||||
argv = explode_string (pos_args, " ", 0, &argc);
|
||||
if (argc > 0)
|
||||
current_arg = argc - 1;
|
||||
}
|
||||
|
||||
if (modes && modes[0])
|
||||
{
|
||||
set_flag = '+';
|
||||
pos = modes + strlen (modes) - 1;
|
||||
while (pos >= modes)
|
||||
{
|
||||
switch (pos[0])
|
||||
{
|
||||
case ':':
|
||||
case ' ':
|
||||
case '+':
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
set_flag = irc_mode_channel_get_flag (modes, pos);
|
||||
switch (pos[0])
|
||||
{
|
||||
case 'a': /* channel admin (unrealircd specific flag) */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '~'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_CHANADMIN);
|
||||
break;
|
||||
case 'b': /* ban (ignored) */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
break;
|
||||
case 'h': /* half-op */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '%'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_HALFOP);
|
||||
break;
|
||||
case 'k': /* channel key */
|
||||
if (channel->key)
|
||||
{
|
||||
free (channel->key);
|
||||
channel->key = NULL;
|
||||
}
|
||||
if (set_flag == '+')
|
||||
{
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (ptr_arg)
|
||||
channel->key = strdup (ptr_arg);
|
||||
}
|
||||
break;
|
||||
case 'l': /* channel limit */
|
||||
if (set_flag == '-')
|
||||
channel->limit = 0;
|
||||
if (set_flag == '+')
|
||||
{
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (ptr_arg)
|
||||
channel->limit = atoi (ptr_arg);
|
||||
}
|
||||
break;
|
||||
case 'o': /* op */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '@'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_OP);
|
||||
break;
|
||||
case 'q': /* channel owner (unrealircd specific flag) */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '~'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_CHANOWNER);
|
||||
break;
|
||||
case 'u': /* channel user */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '-'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_CHANUSER);
|
||||
break;
|
||||
case 'v': /* voice */
|
||||
ptr_arg = ((argc > 0) && (current_arg >= 0)) ?
|
||||
argv[current_arg--] : NULL;
|
||||
if (irc_mode_nick_prefix_allowed (server, '+'))
|
||||
irc_mode_channel_set_nick (channel, ptr_arg,
|
||||
set_flag, IRC_NICK_VOICE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
if (argv)
|
||||
free_exploded_string (argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_user_add: add a user mode
|
||||
*/
|
||||
|
||||
void
|
||||
irc_mode_user_add (t_irc_server *server, char mode)
|
||||
{
|
||||
char str_mode[2];
|
||||
|
||||
str_mode[0] = mode;
|
||||
str_mode[1] = '\0';
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
if (!strchr (server->nick_modes, mode))
|
||||
{
|
||||
server->nick_modes = (char *) realloc (server->nick_modes,
|
||||
strlen (server->nick_modes) + 1 + 1);
|
||||
strcat (server->nick_modes, str_mode);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
server->nick_modes = (char *) malloc (2);
|
||||
strcpy (server->nick_modes, str_mode);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_user_remove: remove a user mode
|
||||
*/
|
||||
|
||||
void
|
||||
irc_mode_user_remove (t_irc_server *server, char mode)
|
||||
{
|
||||
char *pos;
|
||||
int new_size;
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
pos = strchr (server->nick_modes, mode);
|
||||
if (pos)
|
||||
{
|
||||
new_size = strlen (server->nick_modes);
|
||||
memmove (pos, pos + 1, strlen (pos + 1) + 1);
|
||||
server->nick_modes = (char *) realloc (server->nick_modes,
|
||||
new_size);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_user_set: set user modes
|
||||
*/
|
||||
|
||||
void
|
||||
irc_mode_user_set (t_irc_server *server, char *modes)
|
||||
{
|
||||
char set_flag;
|
||||
|
||||
set_flag = '+';
|
||||
while (modes && modes[0])
|
||||
{
|
||||
switch (modes[0])
|
||||
{
|
||||
case ':':
|
||||
case ' ':
|
||||
break;
|
||||
case '+':
|
||||
set_flag = '+';
|
||||
break;
|
||||
case '-':
|
||||
set_flag = '-';
|
||||
break;
|
||||
default:
|
||||
if (set_flag == '+')
|
||||
irc_mode_user_add (server, modes[0]);
|
||||
else
|
||||
irc_mode_user_remove (server, modes[0]);
|
||||
break;
|
||||
}
|
||||
modes++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_mode_nick_prefix_allowed: return <> 0 if nick prefix is allowed by server
|
||||
* for example :
|
||||
* IRC: 005 (...) PREFIX=(ov)@+
|
||||
* => allowed prefixes: @+
|
||||
*/
|
||||
|
||||
int
|
||||
irc_mode_nick_prefix_allowed (t_irc_server *server, char prefix)
|
||||
{
|
||||
char str[2];
|
||||
|
||||
/* if server did not send any prefix info, then use default prefixes */
|
||||
if (!server->prefix)
|
||||
{
|
||||
str[0] = prefix;
|
||||
str[1] = '\0';
|
||||
return (strpbrk (str, IRC_DEFAULT_PREFIXES_LIST)) ? 1 : 0;
|
||||
}
|
||||
|
||||
return (strchr (server->prefix, prefix) != NULL);
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-nick.c: manages nick list for channels */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_nick_find_color: find a color for a nick (according to nick letters)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_find_color (t_irc_nick *nick)
|
||||
{
|
||||
int i, color;
|
||||
|
||||
color = 0;
|
||||
for (i = strlen (nick->nick) - 1; i >= 0; i--)
|
||||
{
|
||||
color += (int)(nick->nick[i]);
|
||||
}
|
||||
color = (color % cfg_look_color_nicks_number);
|
||||
|
||||
return GUI_COLOR_WIN_NICK_1 + color;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_score_for_sort: return score for sorting nick, according to privileges
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_score_for_sort (t_irc_nick *nick)
|
||||
{
|
||||
if (nick->flags & IRC_NICK_CHANOWNER)
|
||||
return -128;
|
||||
if (nick->flags & IRC_NICK_CHANADMIN)
|
||||
return -64;
|
||||
if (nick->flags & IRC_NICK_CHANADMIN2)
|
||||
return -32;
|
||||
if (nick->flags & IRC_NICK_OP)
|
||||
return -16;
|
||||
if (nick->flags & IRC_NICK_HALFOP)
|
||||
return -8;
|
||||
if (nick->flags & IRC_NICK_VOICE)
|
||||
return -4;
|
||||
if (nick->flags & IRC_NICK_CHANUSER)
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_compare: compare two nicks
|
||||
* return: -1 is nick1 < nick2
|
||||
* 0 if nick1 = nick2
|
||||
* +1 if nick1 > nick2
|
||||
* status sort: operator > voice > normal nick
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_compare (t_irc_nick *nick1, t_irc_nick *nick2)
|
||||
{
|
||||
int score1, score2, comp;
|
||||
|
||||
score1 = irc_nick_score_for_sort (nick1);
|
||||
score2 = irc_nick_score_for_sort (nick2);
|
||||
|
||||
comp = ascii_strcasecmp (nick1->nick, nick2->nick);
|
||||
if (comp > 0)
|
||||
score1++;
|
||||
if (comp < 0)
|
||||
score2++;
|
||||
|
||||
/* nick1 > nick2 */
|
||||
if (score1 > score2)
|
||||
return 1;
|
||||
/* nick1 < nick2 */
|
||||
if (score1 < score2)
|
||||
return -1;
|
||||
/* nick1 == nick2 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_find_pos: find position for a nick (for sorting nick list)
|
||||
*/
|
||||
|
||||
t_irc_nick *
|
||||
irc_nick_find_pos (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (irc_nick_compare (nick, ptr_nick) < 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_insert_sorted: insert nick into sorted list
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_insert_sorted (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
t_irc_nick *pos_nick;
|
||||
|
||||
if (channel->nicks)
|
||||
{
|
||||
pos_nick = irc_nick_find_pos (channel, nick);
|
||||
|
||||
if (pos_nick)
|
||||
{
|
||||
/* insert nick into the list (before nick found) */
|
||||
nick->prev_nick = pos_nick->prev_nick;
|
||||
nick->next_nick = pos_nick;
|
||||
if (pos_nick->prev_nick)
|
||||
pos_nick->prev_nick->next_nick = nick;
|
||||
else
|
||||
channel->nicks = nick;
|
||||
pos_nick->prev_nick = nick;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add nick to the end */
|
||||
nick->prev_nick = channel->last_nick;
|
||||
nick->next_nick = NULL;
|
||||
channel->last_nick->next_nick = nick;
|
||||
channel->last_nick = nick;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nick->prev_nick = NULL;
|
||||
nick->next_nick = NULL;
|
||||
channel->nicks = nick;
|
||||
channel->last_nick = nick;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_resort: resort nick in the list
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_resort (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
/* temporarly remove nick from list */
|
||||
if (nick == channel->nicks)
|
||||
channel->nicks = nick->next_nick;
|
||||
else
|
||||
nick->prev_nick->next_nick = nick->next_nick;
|
||||
if (nick->next_nick)
|
||||
nick->next_nick->prev_nick = nick->prev_nick;
|
||||
if (nick == channel->last_nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
|
||||
/* insert again nick into sorted list */
|
||||
irc_nick_insert_sorted (channel, nick);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_new: allocate a new nick for a channel and add it to the nick list
|
||||
*/
|
||||
|
||||
t_irc_nick *
|
||||
irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
|
||||
int is_chanowner, int is_chanadmin, int is_chanadmin2, int is_op,
|
||||
int is_halfop, int has_voice, int is_chanuser)
|
||||
{
|
||||
t_irc_nick *new_nick;
|
||||
|
||||
/* nick already exists on this channel? */
|
||||
if ((new_nick = irc_nick_search (channel, nick_name)))
|
||||
{
|
||||
/* update nick */
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanowner, IRC_NICK_CHANOWNER);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanadmin, IRC_NICK_CHANADMIN);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanadmin2, IRC_NICK_CHANADMIN2);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_op, IRC_NICK_OP);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
|
||||
IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
|
||||
irc_nick_resort (channel, new_nick);
|
||||
return new_nick;
|
||||
}
|
||||
|
||||
/* alloc memory for new nick */
|
||||
if ((new_nick = (t_irc_nick *) malloc (sizeof (t_irc_nick))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* initialize new nick */
|
||||
new_nick->nick = strdup (nick_name);
|
||||
new_nick->host = NULL;
|
||||
new_nick->flags = 0;
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanowner, IRC_NICK_CHANOWNER);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanadmin, IRC_NICK_CHANADMIN);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanadmin2, IRC_NICK_CHANADMIN2);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_op, IRC_NICK_OP);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
|
||||
IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
|
||||
if (ascii_strcasecmp (new_nick->nick, server->nick) == 0)
|
||||
new_nick->color = GUI_COLOR_WIN_NICK_SELF;
|
||||
else
|
||||
new_nick->color = irc_nick_find_color (new_nick);
|
||||
|
||||
irc_nick_insert_sorted (channel, new_nick);
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_change: change nickname and move it if necessary (list is sorted)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_change (t_irc_channel *channel, t_irc_nick *nick, char *new_nick)
|
||||
{
|
||||
int nick_is_me;
|
||||
t_weelist *ptr_weelist;
|
||||
|
||||
nick_is_me = (strcmp (nick->nick, GUI_SERVER(channel->buffer)->nick) == 0) ? 1 : 0;
|
||||
|
||||
if (!nick_is_me && channel->nicks_speaking)
|
||||
{
|
||||
ptr_weelist = weelist_search (channel->nicks_speaking, nick->nick);
|
||||
if (ptr_weelist && ptr_weelist->data)
|
||||
{
|
||||
free (ptr_weelist->data);
|
||||
ptr_weelist->data = strdup (new_nick);
|
||||
}
|
||||
}
|
||||
|
||||
/* change nickname */
|
||||
if (nick->nick)
|
||||
free (nick->nick);
|
||||
nick->nick = strdup (new_nick);
|
||||
if (nick_is_me)
|
||||
nick->color = GUI_COLOR_WIN_NICK_SELF;
|
||||
else
|
||||
nick->color = irc_nick_find_color (nick);
|
||||
|
||||
/* insert again nick into sorted list */
|
||||
irc_nick_resort (channel, nick);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_free: free a nick and remove it from nicks queue
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_free (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
t_irc_nick *new_nicks;
|
||||
|
||||
if (!channel || !nick)
|
||||
return;
|
||||
|
||||
/* remove nick from queue */
|
||||
if (channel->last_nick == nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
if (nick->prev_nick)
|
||||
{
|
||||
(nick->prev_nick)->next_nick = nick->next_nick;
|
||||
new_nicks = channel->nicks;
|
||||
}
|
||||
else
|
||||
new_nicks = nick->next_nick;
|
||||
|
||||
if (nick->next_nick)
|
||||
(nick->next_nick)->prev_nick = nick->prev_nick;
|
||||
|
||||
channel->nicks_count--;
|
||||
|
||||
/* free data */
|
||||
if (nick->nick)
|
||||
free (nick->nick);
|
||||
if (nick->host)
|
||||
free (nick->host);
|
||||
free (nick);
|
||||
channel->nicks = new_nicks;
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_free_all: free all allocated nicks for a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_free_all (t_irc_channel *channel)
|
||||
{
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
/* remove all nicks for the channel */
|
||||
while (channel->nicks)
|
||||
irc_nick_free (channel, channel->nicks);
|
||||
|
||||
/* sould be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_search: returns pointer on a nick
|
||||
*/
|
||||
|
||||
t_irc_nick *
|
||||
irc_nick_search (t_irc_channel *channel, char *nickname)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
if (!nickname)
|
||||
return NULL;
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (ascii_strcasecmp (ptr_nick->nick, nickname) == 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_count: returns number of nicks (total, op, halfop, voice) on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_count (t_irc_channel *channel, int *total, int *count_op,
|
||||
int *count_halfop, int *count_voice, int *count_normal)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
(*total) = 0;
|
||||
(*count_op) = 0;
|
||||
(*count_halfop) = 0;
|
||||
(*count_voice) = 0;
|
||||
(*count_normal) = 0;
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
(*total)++;
|
||||
if ((ptr_nick->flags & IRC_NICK_CHANOWNER) ||
|
||||
(ptr_nick->flags & IRC_NICK_CHANADMIN) ||
|
||||
(ptr_nick->flags & IRC_NICK_CHANADMIN2) ||
|
||||
(ptr_nick->flags & IRC_NICK_OP))
|
||||
(*count_op)++;
|
||||
else
|
||||
{
|
||||
if (ptr_nick->flags & IRC_NICK_HALFOP)
|
||||
(*count_halfop)++;
|
||||
else
|
||||
{
|
||||
if (ptr_nick->flags & IRC_NICK_VOICE)
|
||||
(*count_voice)++;
|
||||
else
|
||||
(*count_normal)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_get_max_length: returns longer nickname on a channel
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_get_max_length (t_irc_channel *channel)
|
||||
{
|
||||
int length, max_length;
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
max_length = 0;
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
length = utf8_width_screen (ptr_nick->nick);
|
||||
if (length > max_length)
|
||||
max_length = length;
|
||||
}
|
||||
return max_length;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_set_away: set/unset away status for a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
|
||||
{
|
||||
if ((cfg_irc_away_check > 0)
|
||||
&& ((cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= cfg_irc_away_check_max_nicks)))
|
||||
{
|
||||
if (((is_away) && (!(nick->flags & IRC_NICK_AWAY))) ||
|
||||
((!is_away) && (nick->flags & IRC_NICK_AWAY)))
|
||||
{
|
||||
IRC_NICK_SET_FLAG(nick, is_away, IRC_NICK_AWAY);
|
||||
gui_nicklist_draw (channel->buffer, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_print_log: print nick infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_print_log (t_irc_nick *nick)
|
||||
{
|
||||
weechat_log_printf ("=> nick %s (addr:0x%X)]\n", nick->nick, nick);
|
||||
weechat_log_printf (" host . . . . . : %s\n", nick->host);
|
||||
weechat_log_printf (" flags. . . . . : %d\n", nick->flags);
|
||||
weechat_log_printf (" color. . . . . : %d\n", nick->color);
|
||||
weechat_log_printf (" prev_nick. . . : 0x%X\n", nick->prev_nick);
|
||||
weechat_log_printf (" next_nick. . . : 0x%X\n", nick->next_nick);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,613 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_H
|
||||
#define __WEECHAT_IRC_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 256
|
||||
#endif
|
||||
|
||||
#define IRC_DEFAULT_PORT 6667
|
||||
#define IRC_DEFAULT_PREFIXES_LIST "@%+~&!-"
|
||||
|
||||
/* nick types */
|
||||
|
||||
#define IRC_NICK_CHANOWNER 1
|
||||
#define IRC_NICK_CHANADMIN 2
|
||||
#define IRC_NICK_OP 4
|
||||
#define IRC_NICK_HALFOP 8
|
||||
#define IRC_NICK_VOICE 16
|
||||
#define IRC_NICK_AWAY 32
|
||||
#define IRC_NICK_CHANADMIN2 64
|
||||
#define IRC_NICK_CHANUSER 128
|
||||
#define IRC_NICK_SET_FLAG(nick, set, flag) \
|
||||
if (set) \
|
||||
nick->flags |= flag; \
|
||||
else \
|
||||
nick->flags &= 0xFFFF - flag;
|
||||
|
||||
#define irc_server_sendf_queued(server, fmt, argz...) \
|
||||
if (server) \
|
||||
{ \
|
||||
server->queue_msg = 1; \
|
||||
irc_server_sendf (server, fmt, ##argz); \
|
||||
server->queue_msg = 0; \
|
||||
}
|
||||
|
||||
typedef struct t_irc_nick t_irc_nick;
|
||||
|
||||
struct t_irc_nick
|
||||
{
|
||||
char *nick; /* nickname */
|
||||
char *host; /* full hostname */
|
||||
int flags; /* chanowner/chanadmin (unrealircd), */
|
||||
/* op, halfop, voice, away */
|
||||
int color; /* color for nickname in chat window */
|
||||
t_irc_nick *prev_nick; /* link to previous nick on the channel */
|
||||
t_irc_nick *next_nick; /* link to next nick on the channel */
|
||||
};
|
||||
|
||||
#define IRC_CHANNEL_PREFIX "#&+!"
|
||||
|
||||
/* channel types */
|
||||
#define IRC_CHANNEL_TYPE_UNKNOWN -1
|
||||
#define IRC_CHANNEL_TYPE_CHANNEL 0
|
||||
#define IRC_CHANNEL_TYPE_PRIVATE 1
|
||||
#define IRC_CHANNEL_TYPE_DCC_CHAT 2
|
||||
|
||||
#define IRC_CHANNEL_NICKS_SPEAKING_LIMIT 32
|
||||
|
||||
typedef struct t_irc_channel t_irc_channel;
|
||||
|
||||
struct t_irc_channel
|
||||
{
|
||||
int type; /* channel type */
|
||||
void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
|
||||
char *name; /* name of channel (exemple: "#abc") */
|
||||
char *topic; /* topic of channel (host for private) */
|
||||
char *modes; /* channel modes */
|
||||
int limit; /* user limit (0 is limit not set) */
|
||||
char *key; /* channel key (NULL if no key is set) */
|
||||
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
|
||||
int checking_away; /* = 1 if checking away with WHO cmd */
|
||||
char *away_message; /* to display away only once in private */
|
||||
int cycle; /* currently cycling (/part then /join) */
|
||||
int close; /* close request (/buffer close) */
|
||||
int display_creation_date; /* 1 if creation date should be displayed */
|
||||
int nick_completion_reset; /* 1 if nick completion should be rebuilt */
|
||||
/* there was some join/part on channel */
|
||||
t_irc_nick *nicks; /* nicks on the channel */
|
||||
t_irc_nick *last_nick; /* last nick on the channel */
|
||||
t_weelist *nicks_speaking; /* nicks speaking (for smart completion) */
|
||||
t_weelist *last_nick_speaking; /* last nick speaking */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for channel */
|
||||
t_irc_channel *prev_channel; /* link to previous channel */
|
||||
t_irc_channel *next_channel; /* link to next channel */
|
||||
};
|
||||
|
||||
/* server types */
|
||||
|
||||
typedef struct t_irc_outqueue t_irc_outqueue;
|
||||
|
||||
struct t_irc_outqueue
|
||||
{
|
||||
char *message_before_mod; /* message before any modifier */
|
||||
char *message_after_mod; /* message after modifier(s) */
|
||||
int modified; /* message was modified by modifier(s) */
|
||||
t_irc_outqueue *next_outqueue; /* pointer to next message in queue */
|
||||
t_irc_outqueue *prev_outqueue; /* pointer to previous message in queue */
|
||||
};
|
||||
|
||||
typedef struct t_irc_server t_irc_server;
|
||||
|
||||
struct t_irc_server
|
||||
{
|
||||
/* user choices */
|
||||
char *name; /* internal name of server */
|
||||
int autoconnect; /* = 1 if auto connect at startup */
|
||||
int autoreconnect; /* = 1 if auto reco when disconnected */
|
||||
int autoreconnect_delay; /* delay before trying again reconnect */
|
||||
int temp_server; /* server is temporary (will not be saved)*/
|
||||
char *address; /* address of server (IP or name) */
|
||||
int port; /* port for server (6667 by default) */
|
||||
int ipv6; /* use IPv6 protocol */
|
||||
int ssl; /* SSL protocol */
|
||||
char *password; /* password for server */
|
||||
char *nick1; /* first nickname for the server */
|
||||
char *nick2; /* alternate nickname */
|
||||
char *nick3; /* 2nd alternate nickname */
|
||||
char *username; /* user name */
|
||||
char *realname; /* real name */
|
||||
char *hostname; /* custom hostname */
|
||||
char *command; /* command to run once connected */
|
||||
int command_delay; /* delay after execution of command */
|
||||
char *autojoin; /* channels to automatically join */
|
||||
int autorejoin; /* auto rejoin channels when kicked */
|
||||
char *notify_levels; /* channels notify levels */
|
||||
|
||||
/* internal vars */
|
||||
pid_t child_pid; /* pid of child process (connecting) */
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
int sock; /* socket for server (IPv4 or IPv6) */
|
||||
int is_connected; /* 1 if WeeChat is connected to server */
|
||||
int ssl_connected; /* = 1 if connected with SSL */
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */
|
||||
#endif
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
char *nick; /* current nickname */
|
||||
char *nick_modes; /* nick modes */
|
||||
char *prefix; /* nick prefix allowed (from msg 005) */
|
||||
time_t reconnect_start; /* this time + delay = reconnect time */
|
||||
time_t command_time; /* this time + command_delay = time to */
|
||||
/* autojoin channels */
|
||||
int reconnect_join; /* 1 if channels opened to rejoin */
|
||||
int disable_autojoin; /* 1 if user asked to not autojoin chans */
|
||||
int is_away; /* 1 is user is marked as away */
|
||||
char *away_message; /* away message, NULL if not away */
|
||||
time_t away_time; /* time() when user marking as away */
|
||||
int lag; /* lag (in milliseconds) */
|
||||
struct timeval lag_check_time; /* last time lag was checked (ping sent) */
|
||||
time_t lag_next_check; /* time for next check */
|
||||
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
|
||||
int queue_msg; /* set to 1 when queue (out) is required */
|
||||
time_t last_user_message; /* time of last user message (anti flood) */
|
||||
t_irc_outqueue *outqueue; /* queue for outgoing user messages */
|
||||
t_irc_outqueue *last_outqueue; /* last outgoing user message */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for server */
|
||||
t_gui_buffer *saved_buffer; /* channel before jumping to next server */
|
||||
t_irc_channel *channels; /* opened channels on server */
|
||||
t_irc_channel *last_channel; /* last opened channal on server */
|
||||
t_irc_server *prev_server; /* link to previous server */
|
||||
t_irc_server *next_server; /* link to next server */
|
||||
};
|
||||
|
||||
/* irc commands */
|
||||
|
||||
typedef int (t_irc_recv_func)(t_irc_server *, char *, char *, char *);
|
||||
|
||||
typedef struct t_irc_command t_irc_command;
|
||||
|
||||
struct t_irc_command
|
||||
{
|
||||
char *command_name; /* IRC command name */
|
||||
char *command_description; /* command description (for /help) */
|
||||
char *arguments; /* command arguments (for /help) */
|
||||
char *arguments_description; /* arguments description (for /help) */
|
||||
char *completion_template; /* template for completion */
|
||||
/* NULL=no completion, ""=default (nick) */
|
||||
int min_arg, max_arg; /* min & max number of arguments */
|
||||
int conversion; /* = 1 if cmd args are converted (charset */
|
||||
/* and color) before sending to server */
|
||||
int needs_connection; /* = 1 if cmd needs server connection */
|
||||
int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **);
|
||||
/* function called when user enters cmd */
|
||||
int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *);
|
||||
/* function called when user enters cmd */
|
||||
t_irc_recv_func *recv_function; /* function called when cmd is received */
|
||||
};
|
||||
|
||||
/* irc messages */
|
||||
|
||||
typedef struct t_irc_message t_irc_message;
|
||||
|
||||
struct t_irc_message
|
||||
{
|
||||
t_irc_server *server; /* server pointer for received msg */
|
||||
char *data; /* message content */
|
||||
t_irc_message *next_message; /* link to next message */
|
||||
};
|
||||
|
||||
/* DCC types */
|
||||
|
||||
#define IRC_DCC_CHAT_RECV 0 /* receiving DCC chat */
|
||||
#define IRC_DCC_CHAT_SEND 1 /* sending DCC chat */
|
||||
#define IRC_DCC_FILE_RECV 2 /* incoming DCC file */
|
||||
#define IRC_DCC_FILE_SEND 3 /* sending DCC file */
|
||||
|
||||
/* DCC status */
|
||||
|
||||
#define IRC_DCC_WAITING 0 /* waiting for host answer */
|
||||
#define IRC_DCC_CONNECTING 1 /* connecting to host */
|
||||
#define IRC_DCC_ACTIVE 2 /* sending/receiving data */
|
||||
#define IRC_DCC_DONE 3 /* transfer done */
|
||||
#define IRC_DCC_FAILED 4 /* DCC failed */
|
||||
#define IRC_DCC_ABORTED 5 /* DCC aborted by user */
|
||||
|
||||
/* DCC blocksize (for file) */
|
||||
|
||||
#define IRC_DCC_MIN_BLOCKSIZE 1024 /* min DCC block size when sending file */
|
||||
#define IRC_DCC_MAX_BLOCKSIZE 102400 /* max DCC block size when sending file */
|
||||
|
||||
/* DCC errors (for file) */
|
||||
|
||||
#define IRC_DCC_NO_ERROR 0 /* no error to report, all ok! */
|
||||
#define IRC_DCC_ERROR_READ_LOCAL 1 /* unable to read local file */
|
||||
#define IRC_DCC_ERROR_SEND_BLOCK 2 /* unable to send block to receiver */
|
||||
#define IRC_DCC_ERROR_READ_ACK 3 /* unable to read ACK from receiver */
|
||||
#define IRC_DCC_ERROR_CONNECT_SENDER 4 /* unable to connect to sender */
|
||||
#define IRC_DCC_ERROR_RECV_BLOCK 5 /* unable to recv block from sender */
|
||||
#define IRC_DCC_ERROR_WRITE_LOCAL 6 /* unable to write to local file */
|
||||
|
||||
/* DCC macros for type */
|
||||
|
||||
#define IRC_DCC_IS_CHAT(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_CHAT_SEND))
|
||||
#define IRC_DCC_IS_FILE(type) ((type == IRC_DCC_FILE_RECV) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
#define IRC_DCC_IS_RECV(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_FILE_RECV))
|
||||
#define IRC_DCC_IS_SEND(type) ((type == IRC_DCC_CHAT_SEND) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
|
||||
/* DCC macro for status */
|
||||
|
||||
#define IRC_DCC_ENDED(status) ((status == IRC_DCC_DONE) || \
|
||||
(status == IRC_DCC_FAILED) || \
|
||||
(status == IRC_DCC_ABORTED))
|
||||
|
||||
typedef struct t_irc_dcc t_irc_dcc;
|
||||
|
||||
struct t_irc_dcc
|
||||
{
|
||||
t_irc_server *server; /* irc server */
|
||||
t_irc_channel *channel; /* irc channel (for DCC chat only) */
|
||||
int type; /* DCC type (file/chat, send/receive) */
|
||||
int status; /* DCC status (waiting, sending, ..) */
|
||||
time_t start_time; /* the time when DCC started */
|
||||
time_t start_transfer; /* the time when DCC transfer started */
|
||||
unsigned long addr; /* IP address */
|
||||
int port; /* port */
|
||||
char *nick; /* remote nick */
|
||||
int sock; /* socket for connection */
|
||||
pid_t child_pid; /* pid of child process (sending/recving) */
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
int fast_send; /* fase send for files: does not wait ACK */
|
||||
int file; /* local file (for reading or writing) */
|
||||
char *filename; /* filename (given by sender) */
|
||||
char *local_filename; /* local filename (with path) */
|
||||
int filename_suffix; /* suffix (.1 for ex) if renaming file */
|
||||
int blocksize; /* block size for sending file */
|
||||
unsigned long size; /* file size */
|
||||
unsigned long pos; /* number of bytes received/sent */
|
||||
unsigned long ack; /* number of bytes received OK */
|
||||
unsigned long start_resume; /* start of resume (in bytes) */
|
||||
time_t last_check_time; /* last time we looked at bytes sent/recv */
|
||||
unsigned long last_check_pos; /* bytes sent/recv at last check */
|
||||
time_t last_activity; /* time of last byte received/sent */
|
||||
unsigned long bytes_per_sec; /* bytes per second */
|
||||
unsigned long eta; /* estimated time of arrival */
|
||||
t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */
|
||||
t_irc_dcc *next_dcc; /* link to next dcc file/chat */
|
||||
};
|
||||
|
||||
/* ignore types */
|
||||
|
||||
/* pre-defined ignore types, all other types are made with IRC commands */
|
||||
/* for example: part join quit notice invite ... */
|
||||
|
||||
#define IRC_IGNORE_ACTION "action"
|
||||
#define IRC_IGNORE_CTCP "ctcp"
|
||||
#define IRC_IGNORE_DCC "dcc"
|
||||
#define IRC_IGNORE_PRIVATE "pv"
|
||||
|
||||
typedef struct t_irc_ignore t_irc_ignore;
|
||||
|
||||
struct t_irc_ignore
|
||||
{
|
||||
char *mask; /* nickname or mask */
|
||||
char *type; /* type of ignore */
|
||||
char *channel_name; /* name of channel, "*" == all */
|
||||
char *server_name; /* name of server, "*" == all */
|
||||
t_irc_ignore *prev_ignore; /* pointer to previous ignore */
|
||||
t_irc_ignore *next_ignore; /* pointer to next ignore */
|
||||
};
|
||||
|
||||
/* variables */
|
||||
|
||||
extern t_irc_command irc_commands[];
|
||||
extern t_irc_server *irc_servers;
|
||||
#ifdef HAVE_GNUTLS
|
||||
extern const int gnutls_cert_type_prio[];
|
||||
extern const int gnutls_prot_prio[];
|
||||
#endif
|
||||
extern t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
|
||||
extern int irc_check_away;
|
||||
extern t_irc_dcc *irc_dcc_list;
|
||||
extern t_irc_dcc *irc_last_dcc;
|
||||
extern char *irc_dcc_status_string[6];
|
||||
extern t_irc_ignore *irc_ignore;
|
||||
extern t_irc_ignore *irc_last_ignore;
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
extern void irc_server_init (t_irc_server *);
|
||||
extern int irc_server_init_with_url (char *, t_irc_server *);
|
||||
extern t_irc_server *irc_server_alloc ();
|
||||
extern void irc_server_outqueue_free_all (t_irc_server *);
|
||||
extern void irc_server_destroy (t_irc_server *);
|
||||
extern void irc_server_free (t_irc_server *);
|
||||
extern void irc_server_free_all ();
|
||||
extern t_irc_server *irc_server_new (char *, int, int, int, int, char *, int, int, int,
|
||||
char *, char *, char *, char *, char *, char *,
|
||||
char *, char *, int, char *, int, char *);
|
||||
extern t_irc_server *irc_server_duplicate (t_irc_server *, char *);
|
||||
extern int irc_server_rename (t_irc_server *, char *);
|
||||
extern int irc_server_send (t_irc_server *, char *, int);
|
||||
extern void irc_server_outqueue_send (t_irc_server *);
|
||||
extern void irc_server_sendf (t_irc_server *, char *, ...);
|
||||
extern void irc_server_parse_message (char *, char **, char **, char **);
|
||||
extern void irc_server_recv (t_irc_server *);
|
||||
extern void irc_server_child_read (t_irc_server *);
|
||||
extern void irc_server_convbase64_8x3_to_6x4 (char *, char*);
|
||||
extern void irc_server_base64encode (char *, char *);
|
||||
extern int irc_server_pass_httpproxy (int, char*, int);
|
||||
extern int irc_server_resolve (char *, char *, int *);
|
||||
extern int irc_server_pass_socks4proxy (int, char*, int, char*);
|
||||
extern int irc_server_pass_socks5proxy (int, char*, int);
|
||||
extern int irc_server_pass_proxy (int, char*, int, char*);
|
||||
extern int irc_server_connect (t_irc_server *, int);
|
||||
extern void irc_server_reconnect (t_irc_server *);
|
||||
extern void irc_server_auto_connect (int, int);
|
||||
extern void irc_server_disconnect (t_irc_server *, int);
|
||||
extern void irc_server_disconnect_all ();
|
||||
extern void irc_server_autojoin_channels ();
|
||||
extern t_irc_server *irc_server_search (char *);
|
||||
extern int irc_server_get_number_connected ();
|
||||
extern void irc_server_get_number_buffer (t_irc_server *, int *, int *);
|
||||
extern int irc_server_name_already_exists (char *);
|
||||
extern int irc_server_get_channel_count (t_irc_server *);
|
||||
extern int irc_server_get_pv_count (t_irc_server *);
|
||||
extern void irc_server_remove_away ();
|
||||
extern void irc_server_check_away ();
|
||||
extern void irc_server_set_away (t_irc_server *, char *, int);
|
||||
extern int irc_server_get_default_notify_level (t_irc_server *);
|
||||
extern void irc_server_set_default_notify_level (t_irc_server *, int);
|
||||
extern void irc_server_print_log (t_irc_server *);
|
||||
|
||||
/* channel functions (irc-channel.c) */
|
||||
|
||||
extern t_irc_channel *irc_channel_new (t_irc_server *, int, char *);
|
||||
extern void irc_channel_free (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_free_all (t_irc_server *);
|
||||
extern t_irc_channel *irc_channel_search (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any_without_buffer (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_dcc (t_irc_server *, char *);
|
||||
extern int irc_channel_is_channel (char *);
|
||||
extern void irc_channel_remove_away (t_irc_channel *);
|
||||
extern void irc_channel_check_away (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_set_away (t_irc_channel *, char *, int);
|
||||
extern int irc_channel_create_dcc (t_irc_dcc *);
|
||||
extern int irc_channel_get_notify_level (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_add_nick_speaking (t_irc_channel *, char *);
|
||||
extern void irc_channel_print_log (t_irc_channel *);
|
||||
|
||||
/* nick functions (irc-nick.c) */
|
||||
|
||||
extern int irc_nick_find_color (t_irc_nick *);
|
||||
extern t_irc_nick *irc_nick_new (t_irc_server *, t_irc_channel *, char *,
|
||||
int, int, int, int, int, int, int);
|
||||
extern void irc_nick_resort (t_irc_channel *, t_irc_nick *);
|
||||
extern void irc_nick_change (t_irc_channel *, t_irc_nick *, char *);
|
||||
extern void irc_nick_free (t_irc_channel *, t_irc_nick *);
|
||||
extern void irc_nick_free_all (t_irc_channel *);
|
||||
extern t_irc_nick *irc_nick_search (t_irc_channel *, char *);
|
||||
extern void irc_nick_count (t_irc_channel *, int *, int *, int *, int *, int *);
|
||||
extern int irc_nick_get_max_length (t_irc_channel *);
|
||||
extern void irc_nick_set_away (t_irc_channel *, t_irc_nick *, int);
|
||||
extern void irc_nick_print_log (t_irc_nick *);
|
||||
|
||||
/* mode functions (irc-mode.c) */
|
||||
|
||||
extern void irc_mode_channel_set (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_mode_user_set (t_irc_server *, char *);
|
||||
extern int irc_mode_nick_prefix_allowed (t_irc_server *, char);
|
||||
|
||||
/* DCC functions (irc-dcc.c) */
|
||||
|
||||
extern void irc_dcc_redraw (int);
|
||||
extern void irc_dcc_free (t_irc_dcc *);
|
||||
extern void irc_dcc_close (t_irc_dcc *, int);
|
||||
extern void irc_dcc_chat_remove_channel (t_irc_channel *);
|
||||
extern void irc_dcc_accept (t_irc_dcc *);
|
||||
extern void irc_dcc_accept_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern void irc_dcc_start_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern t_irc_dcc *irc_dcc_alloc ();
|
||||
extern t_irc_dcc *irc_dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
|
||||
char *, char *, unsigned long);
|
||||
extern void irc_dcc_send_request (t_irc_server *, int, char *, char *);
|
||||
extern void irc_dcc_chat_sendf (t_irc_dcc *, char *, ...);
|
||||
extern void irc_dcc_file_send_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_file_recv_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_handle ();
|
||||
extern void irc_dcc_end ();
|
||||
extern void irc_dcc_print_log ();
|
||||
|
||||
/* IRC display (irc-diplay.c) */
|
||||
|
||||
extern void irc_display_hide_password (char *, int);
|
||||
extern void irc_display_prefix (t_irc_server *, t_gui_buffer *, char *);
|
||||
extern void irc_display_nick (t_gui_buffer *, t_irc_nick *, char *, int,
|
||||
int, int, int);
|
||||
extern void irc_display_away (t_irc_server *, char *, char *);
|
||||
extern void irc_display_mode (t_irc_server *, t_gui_buffer *, char *, char *,
|
||||
char, char *, char *, char *, char *);
|
||||
extern void irc_display_server (t_irc_server *ptr_server, int);
|
||||
|
||||
/* IRC commands issued by user (irc-send.c) */
|
||||
|
||||
extern void irc_send_login (t_irc_server *);
|
||||
extern int irc_send_cmd_admin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ame (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_amsg (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_away (t_irc_server *, char *);
|
||||
extern int irc_send_cmd_away (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ctcp (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_cycle (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_deop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_devoice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_die (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_halfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_info (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_invite (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_ison (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_join (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kick (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kickban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kill (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_links (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_list (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_lusers (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_me (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_mode (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_mode_nicks (t_irc_server *, char *, char *, char *, int, char **);
|
||||
extern int irc_send_cmd_motd (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_msg (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_names (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_nick (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_notice (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_op (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_oper (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_part (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ping (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_pong (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_query (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_quit_server (t_irc_server *, char *);
|
||||
extern int irc_send_cmd_quit (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_quote (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_rehash (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_restart (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_service (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_servlist (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_squery (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_squit (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_stats (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_summon (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_time (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_topic (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_trace (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_unban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_userhost (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_users (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_version (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_voice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_wallops (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_who (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_whois (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_whowas (t_irc_server *, t_irc_channel *, char *);
|
||||
|
||||
/* IRC commands executed when received from server (irc-recv.c) */
|
||||
|
||||
extern int irc_recv_is_highlight (char *, char *);
|
||||
extern int irc_recv_command (t_irc_server *, char *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_error (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_invite (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_join (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_kick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_kill (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_mode (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_nick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_notice (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_part (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_ping (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_pong (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_privmsg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_quit (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_mode_reason (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_reply (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_topic (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_wallops (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_001 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_005 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_221 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_301 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_302 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_303 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_305 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_306 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_whois_nick_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_310 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_311 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_312 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_314 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_315 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_317 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_319 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_321 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_322 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_323 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_324 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_327 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_329 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_331 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_332 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_333 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_338 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_341 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_344 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_345 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_348 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_349 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_351 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_352 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_353 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_365 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_366 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_367 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_368 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_432 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_433 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_438 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_671 (t_irc_server *, char *, char *, char *);
|
||||
|
||||
/* ignore functions (irc-ignore.c) */
|
||||
|
||||
extern int irc_ignore_check (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *irc_ignore_add (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *irc_ignore_add_from_config (char *);
|
||||
extern void irc_ignore_free_all ();
|
||||
extern int irc_ignore_search_free (char *, char *, char *, char *);
|
||||
extern int irc_ignore_search_free_by_number (int);
|
||||
extern void irc_ignore_print_log ();
|
||||
|
||||
#endif /* irc.h */
|
||||
Reference in New Issue
Block a user