mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 07:46:38 +02:00
Added /ignore and /unignore commands
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-09-03
|
||||
ChangeLog - 2005-09-04
|
||||
|
||||
|
||||
Version 0.1.5 (under dev!):
|
||||
* added /ignore and /unignore commands
|
||||
* fixed bug with strings comparison (str[n]casecmp) and some locales
|
||||
(like turkish), now using ASCII comparison (thanks to roktas)
|
||||
* signal SIGQUIT is now ignored
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2005-08-16
|
||||
TODO - 2005-09-04
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -30,6 +30,7 @@ v0.1.5:
|
||||
* WeeChat commands
|
||||
- be able to bind a key on more than one command
|
||||
- be able to make an alias running more than one command
|
||||
# /ignore and /unignore commands
|
||||
|
||||
* Configuration:
|
||||
- be able to launch more than one command when connecting to server
|
||||
@@ -42,8 +43,6 @@ Future versions:
|
||||
- customizable CTCP version reply
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
nick/host
|
||||
- when we're away, WeeChat should log all the lines begenning by our nick.
|
||||
When we come back from our away it should print it to the current window
|
||||
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
./src/irc/irc-send.c
|
||||
./src/irc/irc-recv.c
|
||||
./src/irc/irc-dcc.c
|
||||
./src/irc/irc-ignore.c
|
||||
./src/irc/irc.h
|
||||
./src/plugins/perl/wee-perl.c
|
||||
./src/plugins/perl/wee-perl.h
|
||||
|
||||
+734
-627
File diff suppressed because it is too large
Load Diff
+180
-4
@@ -72,6 +72,16 @@ t_weechat_command weechat_commands[] =
|
||||
{ "help", N_("display help about commands"),
|
||||
N_("[command]"), N_("command: name of a WeeChat or IRC command"),
|
||||
0, 1, weechat_cmd_help, NULL },
|
||||
{ "ignore", N_("ignore IRC messages and/or hosts"),
|
||||
N_("[mask [[type | command] [channel [server]]]]"),
|
||||
N_(" mask: nick or host mask to ignore\n"
|
||||
" type: type of message to ignore (action, ctcp, dcc, pv)\n"
|
||||
"command: IRC command\n"
|
||||
"channel: name of channel for ignore\n"
|
||||
" server: name of server for ignore\n\n"
|
||||
"For each argument, '*' means all.\n"
|
||||
"Without argument, /ignore command lists all defined ignore."),
|
||||
0, 4, weechat_cmd_ignore, NULL },
|
||||
{ "key", N_("bind/unbind keys"),
|
||||
N_("[key function/command] [unbind key] [functions] [reset -yes]"),
|
||||
N_("key: bind this key to an internal function or a command (beginning by \"/\")\n"
|
||||
@@ -81,17 +91,17 @@ t_weechat_command weechat_commands[] =
|
||||
0, MAX_ARGS, NULL, weechat_cmd_key },
|
||||
{ "perl", N_("list/load/unload Perl scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Perl script (file) to load\n"
|
||||
N_("filename: Perl script (file) to load\n\n"
|
||||
"Without argument, /perl command lists all loaded Perl scripts."),
|
||||
0, 2, weechat_cmd_perl, NULL },
|
||||
{ "python", N_("list/load/unload Python scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Python script (file) to load\n"
|
||||
N_("filename: Python script (file) to load\n\n"
|
||||
"Without argument, /python command lists all loaded Python scripts."),
|
||||
0, 2, weechat_cmd_python, NULL },
|
||||
{ "ruby", N_("list/load/unload Ruby scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Ruby script (file) to load\n"
|
||||
N_("filename: Ruby script (file) to load\n\n"
|
||||
"Without argument, /ruby command lists all loaded Ruby scripts."),
|
||||
0, 2, weechat_cmd_ruby, NULL },
|
||||
{ "server", N_("list, add or remove servers"),
|
||||
@@ -121,6 +131,17 @@ t_weechat_command weechat_commands[] =
|
||||
{ "unalias", N_("remove an alias"),
|
||||
N_("alias_name"), N_("alias_name: name of alias to remove"),
|
||||
1, 1, NULL, weechat_cmd_unalias },
|
||||
{ "unignore", N_("unignore IRC messages and/or hosts"),
|
||||
N_("[number | [mask [[type | command] [channel [server]]]]]"),
|
||||
N_(" number: # of ignore to unignore (number is displayed by list of ignore)\n"
|
||||
" mask: nick or host mask to unignore\n"
|
||||
" type: type of message to unignore (action, ctcp, dcc, pv)\n"
|
||||
"command: IRC command\n"
|
||||
"channel: name of channel for unignore\n"
|
||||
" server: name of server for unignore\n\n"
|
||||
"For each argument, '*' means all.\n"
|
||||
"Without argument, /unignore command lists all defined ignore."),
|
||||
0, 4, weechat_cmd_unignore, NULL },
|
||||
{ "window", N_("manage windows"),
|
||||
N_("[list | splith | splitv | [merge [down | up | left | right | all]]]"),
|
||||
N_("list: list opened windows (no parameter implies this list)\n"
|
||||
@@ -874,6 +895,11 @@ weechat_cmd_buffer_display_info (t_gui_buffer *buffer)
|
||||
"%s", SERVER(buffer)->name);
|
||||
gui_printf (NULL, ")\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (NULL, _("not connected"));
|
||||
gui_printf (NULL, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1351,6 +1377,93 @@ weechat_cmd_help (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_ignore_display: display an ignore entry
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_cmd_ignore_display (char *text, t_irc_ignore *ptr_ignore)
|
||||
{
|
||||
if (text)
|
||||
gui_printf (NULL, "%s ", text);
|
||||
|
||||
gui_printf (NULL, _("on"));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", ptr_ignore->server_name);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "/");
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->channel_name);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ":");
|
||||
gui_printf (NULL, _(" ignoring "));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->type);
|
||||
gui_printf (NULL, _(" from "));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, "%s\n", ptr_ignore->mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_ignore: ignore IRC commands and/or hosts
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_ignore (int argc, char **argv)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
int i;
|
||||
|
||||
ptr_ignore = NULL;
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
/* List all ignore */
|
||||
if (irc_ignore)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("List of ignore:\n"));
|
||||
i = 0;
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
i++;
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "[");
|
||||
gui_printf (NULL, "%d", i);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "] ");
|
||||
weechat_cmd_ignore_display (NULL, ptr_ignore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
gui_printf (NULL, _("No ignore defined.\n"));
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
ptr_ignore = ignore_add (argv[0], "*", "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 2:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 3:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], argv[2],
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 4:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
}
|
||||
if (ptr_ignore)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
weechat_cmd_ignore_display (_("New ignore:"), ptr_ignore);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_key_display: display a key binding
|
||||
*/
|
||||
@@ -2410,7 +2523,7 @@ weechat_cmd_set (char *arguments)
|
||||
{
|
||||
section_displayed = 0;
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -2519,6 +2632,69 @@ weechat_cmd_unalias (char *arguments)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_unignore: unignore IRC commands and/or hosts
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_unignore (int argc, char **argv)
|
||||
{
|
||||
char *error;
|
||||
int number, ret;
|
||||
|
||||
ret = 0;
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
/* List all ignore */
|
||||
weechat_cmd_ignore (argc, argv);
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
error = NULL;
|
||||
number = strtol (argv[0], &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
ret = ignore_search_free_by_number (number);
|
||||
else
|
||||
ret = ignore_search_free (argv[0], "*", "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 2:
|
||||
ret = ignore_search_free (argv[0], argv[1], "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 3:
|
||||
ret = ignore_search_free (argv[0], argv[1], argv[2],
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 4:
|
||||
ret = ignore_search_free (argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%d ", ret);
|
||||
if (ret > 1)
|
||||
gui_printf (NULL, _("ignore were removed.\n"));
|
||||
else
|
||||
gui_printf (NULL, _("ignore was removed.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL, _("%s no ignore found\n"),
|
||||
WEECHAT_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_window: manage windows
|
||||
*/
|
||||
|
||||
@@ -69,6 +69,8 @@ extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_debug (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern void weechat_cmd_ignore_display (char *, t_irc_ignore *);
|
||||
extern int weechat_cmd_ignore (int, char **);
|
||||
extern int weechat_cmd_key (char *);
|
||||
extern int weechat_cmd_perl (int, char **);
|
||||
extern int weechat_cmd_python (int, char **);
|
||||
@@ -77,6 +79,7 @@ extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_set (char *);
|
||||
extern int weechat_cmd_unalias (char *);
|
||||
extern int weechat_cmd_unignore (int, char **);
|
||||
extern int weechat_cmd_unset (char *);
|
||||
extern int weechat_cmd_window (int, char **);
|
||||
|
||||
|
||||
+84
-1
@@ -102,6 +102,7 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
int i, j;
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
char *pos, option_name[256], *string;
|
||||
t_weechat_alias *ptr_alias;
|
||||
t_config_option *option;
|
||||
@@ -201,6 +202,88 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ascii_strcasecmp (completion->base_command, "ignore") == 0)
|
||||
{
|
||||
/* arg 1: nicks of current channel and "*" */
|
||||
if (completion->base_command_arg == 1)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (channel)
|
||||
{
|
||||
if (((t_irc_channel *)channel)->type == CHAT_CHANNEL)
|
||||
{
|
||||
for (ptr_nick = ((t_irc_channel *)channel)->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
ptr_nick->nick);
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)channel)->type == CHAT_PRIVATE)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
((t_irc_channel *)channel)->name);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 2: type / command and "*" */
|
||||
if (completion->base_command_arg == 2)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
i = 0;
|
||||
while (ignore_types[i])
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
ignore_types[i]);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (irc_commands[i].command_name)
|
||||
{
|
||||
if (irc_commands[i].recv_function)
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
irc_commands[i].command_name);
|
||||
i++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 3: channel and "*" */
|
||||
if (completion->base_command_arg == 3)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (((t_irc_channel *)channel)->type == CHAT_CHANNEL)
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
((t_irc_channel *)channel)->name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 4: server */
|
||||
if (completion->base_command_arg == 4)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (SERVER(gui_current_window->buffer))
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
SERVER(gui_current_window->buffer)->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ascii_strcasecmp (completion->base_command, "key") == 0)
|
||||
{
|
||||
if (completion->base_command_arg == 1)
|
||||
@@ -254,7 +337,7 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
|
||||
@@ -844,6 +844,9 @@ wee_dump (int crash)
|
||||
wee_log_printf ("\n");
|
||||
gui_buffer_print_log (ptr_buffer);
|
||||
}
|
||||
|
||||
wee_log_printf ("\n");
|
||||
ignore_print_log ();
|
||||
|
||||
wee_log_printf ("\n");
|
||||
wee_log_printf ("****** End of dump ******\n");
|
||||
|
||||
+39
-11
@@ -55,6 +55,7 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
|
||||
{ CONFIG_SECTION_PROXY, "proxy" },
|
||||
{ CONFIG_SECTION_KEYS, "keys" },
|
||||
{ CONFIG_SECTION_ALIAS, "alias" },
|
||||
{ CONFIG_SECTION_IGNORE, "ignore" },
|
||||
{ CONFIG_SECTION_SERVER, "server" }
|
||||
};
|
||||
|
||||
@@ -758,7 +759,7 @@ t_config_option weechat_options_server[] =
|
||||
t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
|
||||
{ weechat_options_look, weechat_options_colors, weechat_options_history,
|
||||
weechat_options_log, weechat_options_irc, weechat_options_dcc,
|
||||
weechat_options_proxy, NULL, NULL, weechat_options_server
|
||||
weechat_options_proxy, NULL, NULL, NULL, weechat_options_server
|
||||
};
|
||||
|
||||
|
||||
@@ -795,7 +796,7 @@ config_get_section (t_config_option *ptr_option)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1090,7 +1091,7 @@ config_option_search (char *option_name)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1254,7 +1255,7 @@ config_default_values ()
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1428,6 +1429,21 @@ config_read ()
|
||||
if (alias_new (line, pos))
|
||||
weelist_add (&index_commands, &last_index_command, line);
|
||||
}
|
||||
else if (section == CONFIG_SECTION_IGNORE)
|
||||
{
|
||||
/* create new ignore */
|
||||
if (ascii_strcasecmp (line, "ignore") != 0)
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, line);
|
||||
else
|
||||
{
|
||||
if (!ignore_add_from_config (pos))
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid ignore options \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
option_number = -1;
|
||||
@@ -1571,7 +1587,7 @@ config_create_default ()
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1623,7 +1639,6 @@ config_create_default ()
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
/* TODO: remove comments when missing commands will be ok */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
fprintf (file, "SAY=msg *\n");
|
||||
fprintf (file, "BYE=quit\n");
|
||||
@@ -1633,12 +1648,10 @@ config_create_default ()
|
||||
fprintf (file, "CL=clear\n");
|
||||
fprintf (file, "CLOSE=buffer close\n");
|
||||
fprintf (file, "CHAT=dcc chat\n");
|
||||
fprintf (file, "# GET=dcc get\n");
|
||||
fprintf (file, "# IG=ignore\n");
|
||||
fprintf (file, "IG=ignore\n");
|
||||
fprintf (file, "J=join\n");
|
||||
fprintf (file, "K=kick\n");
|
||||
fprintf (file, "KB=kickban\n");
|
||||
fprintf (file, "# KN=knockout\n");
|
||||
fprintf (file, "LEAVE=part\n");
|
||||
fprintf (file, "M=msg\n");
|
||||
fprintf (file, "MUB=unban *\n");
|
||||
@@ -1646,12 +1659,14 @@ config_create_default ()
|
||||
fprintf (file, "Q=query\n");
|
||||
fprintf (file, "T=topic\n");
|
||||
fprintf (file, "UB=unban\n");
|
||||
fprintf (file, "# UNIG=unignore\n");
|
||||
fprintf (file, "UNIG=unignore\n");
|
||||
fprintf (file, "W=who\n");
|
||||
fprintf (file, "WC=part\n");
|
||||
fprintf (file, "WI=whois\n");
|
||||
fprintf (file, "WW=whowas\n");
|
||||
|
||||
/* no ignore by default */
|
||||
|
||||
/* default server is freenode */
|
||||
fprintf (file, "\n[server]\n");
|
||||
fprintf (file, "server_name=freenode\n");
|
||||
@@ -1730,6 +1745,7 @@ config_write (char *config_name)
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
t_weechat_alias *ptr_alias;
|
||||
t_irc_ignore *ptr_ignore;
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name, *function_name;
|
||||
|
||||
@@ -1765,7 +1781,7 @@ config_write (char *config_name)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1842,6 +1858,18 @@ config_write (char *config_name)
|
||||
ptr_alias->alias_name, ptr_alias->alias_command + 1);
|
||||
}
|
||||
|
||||
/* ignore section */
|
||||
fprintf (file, "\n[ignore]\n");
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
fprintf (file, "ignore=%s,%s,%s,%s\n",
|
||||
ptr_ignore->mask,
|
||||
ptr_ignore->type,
|
||||
ptr_ignore->channel_name,
|
||||
ptr_ignore->server_name);
|
||||
}
|
||||
|
||||
/* server section */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
#define CONFIG_SECTION_PROXY 6
|
||||
#define CONFIG_SECTION_KEYS 7
|
||||
#define CONFIG_SECTION_ALIAS 8
|
||||
#define CONFIG_SECTION_SERVER 9
|
||||
#define CONFIG_NUMBER_SECTIONS 10
|
||||
#define CONFIG_SECTION_IGNORE 9
|
||||
#define CONFIG_SECTION_SERVER 10
|
||||
#define CONFIG_NUMBER_SECTIONS 11
|
||||
|
||||
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
|
||||
#define OPTION_TYPE_INT 2 /* values: from min to max */
|
||||
|
||||
@@ -27,4 +27,5 @@ lib_weechat_irc_a_SOURCES = irc.h \
|
||||
irc-channel.c \
|
||||
irc-nick.c \
|
||||
irc-dcc.c \
|
||||
irc-ignore.c \
|
||||
irc-display.c
|
||||
|
||||
@@ -143,7 +143,10 @@ t_irc_channel *
|
||||
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)
|
||||
{
|
||||
@@ -162,6 +165,9 @@ string_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, CHANNEL_PREFIX)) ? 1 : 0;
|
||||
|
||||
@@ -384,8 +384,6 @@ t_irc_command irc_commands[] =
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "406", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "406", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "407", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "409", N_("no origin"),
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* 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"
|
||||
|
||||
|
||||
char *ignore_types[] =
|
||||
{ IGNORE_ACTION, IGNORE_CTCP, IGNORE_DCC, IGNORE_PRIVATE, NULL };
|
||||
|
||||
t_irc_ignore *irc_ignore = NULL;
|
||||
t_irc_ignore *last_irc_ignore = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* ignore_check_mask: returns 1 is mask1 and mask2 are the same host
|
||||
* anyone or both strings may have user and/or host after
|
||||
*/
|
||||
|
||||
int
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_match: check if pointed ignore matches with arguments
|
||||
*/
|
||||
|
||||
int
|
||||
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)
|
||||
&& (!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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_check: check if an ignore is set for arguments
|
||||
* returns 1 if at least one ignore exists (message should NOT be displayed)
|
||||
* 0 if no ignore found (message will be displayed)
|
||||
*/
|
||||
|
||||
int
|
||||
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 (ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* no ignore found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_search: search for an ignore
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_add: add an ignore in list
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
ignore_add (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
int i, 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])
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s too few arguments for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
wee_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, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s mask or type/command should be non generic value for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ignore_search (mask, type, channel_name, server_name))
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s ignore already exists\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (type, "*") != 0)
|
||||
{
|
||||
/* look for type in pre-defined ignore types */
|
||||
for (i = 0; ignore_types[i]; i++)
|
||||
{
|
||||
if (ascii_strcasecmp (type, ignore_types[i]) == 0)
|
||||
{
|
||||
type_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* not a pre-defined ignore type, so it MUST be an IRC command */
|
||||
if (type_index < 0)
|
||||
{
|
||||
for (i = 0; irc_commands[i].command_name; i++)
|
||||
{
|
||||
if (irc_commands[i].recv_function &&
|
||||
(ascii_strcasecmp (type, irc_commands[i].command_name) == 0))
|
||||
{
|
||||
command_ptr = &irc_commands[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* not a pre-defined command and not an IRC command => error */
|
||||
if ((type_index < 0) && (!command_ptr))
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s unknown type or IRC command \"%s\" for ignore\n"),
|
||||
WEECHAT_ERROR, type);
|
||||
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, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s not enough memory to create ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_add_from_config: add an ignore to list, read from config file
|
||||
* (comma serparated values)
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
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 = ignore_add (pos_mask, pos_type, pos_channel, pos_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (string2);
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_free: free an ignore
|
||||
*/
|
||||
|
||||
void
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_free_all: free all ignores
|
||||
*/
|
||||
|
||||
void
|
||||
ignore_free_all ()
|
||||
{
|
||||
while (irc_ignore)
|
||||
ignore_free (irc_ignore);
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_search_free: search and free ignore(s)
|
||||
* return: number of ignore found and deleted
|
||||
* 0 if no ignore found
|
||||
*/
|
||||
|
||||
int
|
||||
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 (ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
{
|
||||
found++;
|
||||
if (found == 1)
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
next_ignore = ptr_ignore->next_ignore;
|
||||
ignore_free (ptr_ignore);
|
||||
ptr_ignore = next_ignore;
|
||||
}
|
||||
else
|
||||
ptr_ignore = ptr_ignore->next_ignore;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
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, PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
ignore_free (ptr_ignore);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ignore number not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_print_log: print ignore list in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
ignore_print_log ()
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
wee_log_printf ("[ignore list]\n");
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
wee_log_printf ("\n");
|
||||
wee_log_printf (" -> ignore at 0x%X:\n", ptr_ignore);
|
||||
wee_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask);
|
||||
wee_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type);
|
||||
wee_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name);
|
||||
wee_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name);
|
||||
wee_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore);
|
||||
wee_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -314,7 +314,10 @@ t_irc_nick *
|
||||
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)
|
||||
{
|
||||
|
||||
+1612
-1385
File diff suppressed because it is too large
Load Diff
+222
-212
@@ -900,12 +900,12 @@ void
|
||||
convbase64_8x3_to_6x4(char *from, char* to)
|
||||
{
|
||||
|
||||
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
|
||||
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
|
||||
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
|
||||
to[3] = base64_table [ from[2] & 0x3f ];
|
||||
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
|
||||
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
|
||||
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
|
||||
to[3] = base64_table [ from[2] & 0x3f ];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -916,91 +916,92 @@ void
|
||||
base64encode(char *from, char *to)
|
||||
{
|
||||
|
||||
char *f, *t;
|
||||
int from_len;
|
||||
char *f, *t;
|
||||
int from_len;
|
||||
|
||||
from_len = strlen(from);
|
||||
from_len = strlen(from);
|
||||
|
||||
f = from;
|
||||
t = to;
|
||||
f = from;
|
||||
t = to;
|
||||
|
||||
while(from_len >= 3)
|
||||
while(from_len >= 3)
|
||||
{
|
||||
convbase64_8x3_to_6x4(f, t);
|
||||
f += 3 * sizeof(*f);
|
||||
t += 4 * sizeof(*t);
|
||||
from_len -= 3;
|
||||
convbase64_8x3_to_6x4(f, t);
|
||||
f += 3 * sizeof(*f);
|
||||
t += 4 * sizeof(*t);
|
||||
from_len -= 3;
|
||||
}
|
||||
|
||||
if (from_len > 0)
|
||||
if (from_len > 0)
|
||||
{
|
||||
char rest[3] = { 0, 0, 0 };
|
||||
switch(from_len)
|
||||
char rest[3] = { 0, 0, 0 };
|
||||
switch(from_len)
|
||||
{
|
||||
case 1 :
|
||||
rest[0] = f[0];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[2] = t[3] = '=';
|
||||
break;
|
||||
rest[0] = f[0];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[2] = t[3] = '=';
|
||||
break;
|
||||
case 2 :
|
||||
rest[0] = f[0];
|
||||
rest[1] = f[1];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[3] = '=';
|
||||
break;
|
||||
rest[0] = f[0];
|
||||
rest[1] = f[1];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[3] = '=';
|
||||
break;
|
||||
}
|
||||
t[4] = 0;
|
||||
t[4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_httpproxy: establish connection/authentification to an http proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_httpproxy(int sock, char *address, int port)
|
||||
{
|
||||
|
||||
char buffer[256];
|
||||
char authbuf[128]; // seems to be enougth to store username + password
|
||||
char authbuf_base64[196]; // enougth to store base64 encoded authbuf
|
||||
int n, m;
|
||||
char buffer[256];
|
||||
char authbuf[128]; // seems to be enougth to store username + password
|
||||
char authbuf_base64[196]; // enougth to store base64 encoded authbuf
|
||||
int n, m;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
{
|
||||
// authentification
|
||||
snprintf(authbuf, sizeof(authbuf), "%s:%s", cfg_proxy_username, cfg_proxy_password);
|
||||
base64encode(authbuf, authbuf_base64);
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n", address, port, authbuf_base64);
|
||||
// authentification
|
||||
snprintf(authbuf, sizeof(authbuf), "%s:%s", cfg_proxy_username, cfg_proxy_password);
|
||||
base64encode(authbuf, authbuf_base64);
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n", address, port, authbuf_base64);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// no authentification
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
|
||||
// no authentification
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
|
||||
}
|
||||
|
||||
m = send (sock, buffer, n, 0);
|
||||
if (n != m)
|
||||
return 1;
|
||||
m = send (sock, buffer, n, 0);
|
||||
if (n != m)
|
||||
return 1;
|
||||
|
||||
n = recv(sock, buffer, sizeof(buffer), 0);
|
||||
n = recv(sock, buffer, sizeof(buffer), 0);
|
||||
|
||||
/* success result must be like : "HTTP/1.0 200 OK" */
|
||||
if (n < 12)
|
||||
return 1;
|
||||
/* success result must be like : "HTTP/1.0 200 OK" */
|
||||
if (n < 12)
|
||||
return 1;
|
||||
|
||||
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
|
||||
return 1;
|
||||
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* resolve: resolve hostname on its IP address
|
||||
* (works with ipv4 and ipv6)
|
||||
* return :
|
||||
* return :
|
||||
* - 0 if resolution was successful
|
||||
* - 1 if resolution fails
|
||||
*/
|
||||
@@ -1042,207 +1043,210 @@ resolve (char *hostname, char *ip, int *version)
|
||||
|
||||
/*
|
||||
* pass_socks4proxy: establish connection/authentification throw a socks4 proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_socks4proxy(int sock, char *address, int port, char *username)
|
||||
{
|
||||
/*
|
||||
* socks4 protocol is explain here:
|
||||
* http://archive.socks.permeo.com/protocol/socks4.protocol
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* socks4 protocol is explain here:
|
||||
* http://archive.socks.permeo.com/protocol/socks4.protocol
|
||||
*
|
||||
*/
|
||||
|
||||
struct s_socks4
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char method; /* 1 byte */ /* socks method : connect (1) or bind (2) */
|
||||
unsigned short port; /* 2 bytes */ /* destination port */
|
||||
unsigned long address; /* 4 bytes */ /* destination address */
|
||||
char user[64]; /* username (64 characters seems to be enought) */
|
||||
} socks4;
|
||||
unsigned char buffer[24];
|
||||
char ip_addr[NI_MAXHOST];
|
||||
struct s_socks4
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char method; /* 1 byte */ /* socks method : connect (1) or bind (2) */
|
||||
unsigned short port; /* 2 bytes */ /* destination port */
|
||||
unsigned long address; /* 4 bytes */ /* destination address */
|
||||
char user[64]; /* username (64 characters seems to be enought) */
|
||||
} socks4;
|
||||
unsigned char buffer[24];
|
||||
char ip_addr[NI_MAXHOST];
|
||||
|
||||
socks4.version = 4;
|
||||
socks4.method = 1;
|
||||
socks4.port = htons (port);
|
||||
resolve(address, ip_addr, NULL);
|
||||
socks4.address = inet_addr (ip_addr);
|
||||
strncpy (socks4.user, username, sizeof(socks4.user) - 1);
|
||||
socks4.version = 4;
|
||||
socks4.method = 1;
|
||||
socks4.port = htons (port);
|
||||
resolve(address, ip_addr, NULL);
|
||||
socks4.address = inet_addr (ip_addr);
|
||||
strncpy (socks4.user, username, sizeof(socks4.user) - 1);
|
||||
|
||||
send (sock, (char *) &socks4, 8 + strlen(socks4.user) + 1, 0);
|
||||
recv (sock, buffer, sizeof(buffer), 0);
|
||||
send (sock, (char *) &socks4, 8 + strlen(socks4.user) + 1, 0);
|
||||
recv (sock, buffer, sizeof(buffer), 0);
|
||||
|
||||
if (buffer[0] == 0 && buffer[1] == 90)
|
||||
return 0;
|
||||
if (buffer[0] == 0 && buffer[1] == 90)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_socks5proxy: establish connection/authentification throw a socks5 proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_socks5proxy(int sock, char *address, int port)
|
||||
{
|
||||
/*
|
||||
* socks5 protocol is explained in RFC 1928
|
||||
* socks5 authentication with username/pass is explained in RFC 1929
|
||||
*/
|
||||
/*
|
||||
* socks5 protocol is explained in RFC 1928
|
||||
* socks5 authentication with username/pass is explained in RFC 1929
|
||||
*/
|
||||
|
||||
struct s_sock5
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char nmethods; /* 1 byte */ /* size in byte(s) of field 'method', here 1 byte */
|
||||
char method; /* 1-255 bytes */ /* socks method : noauth (0), auth(user/pass) (2), ... */
|
||||
} socks5;
|
||||
unsigned char buffer[288];
|
||||
int username_len, password_len, addr_len, addr_buffer_len;
|
||||
unsigned char *addr_buffer;
|
||||
|
||||
socks5.version = 5;
|
||||
socks5.nmethods = 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
/* with authentication */
|
||||
socks5.method = 2;
|
||||
else
|
||||
/* without authentication */
|
||||
socks5.method = 0;
|
||||
|
||||
send (sock, (char *) &socks5, sizeof(socks5), 0);
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
struct s_sock5
|
||||
{
|
||||
/* with authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 2 => authentication
|
||||
*/
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char nmethods; /* 1 byte */ /* size in byte(s) of field 'method', here 1 byte */
|
||||
char method; /* 1-255 bytes */ /* socks method : noauth (0), auth(user/pass) (2), ... */
|
||||
} socks5;
|
||||
unsigned char buffer[288];
|
||||
int username_len, password_len, addr_len, addr_buffer_len;
|
||||
unsigned char *addr_buffer;
|
||||
|
||||
socks5.version = 5;
|
||||
socks5.nmethods = 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
/* with authentication */
|
||||
socks5.method = 2;
|
||||
else
|
||||
/* without authentication */
|
||||
socks5.method = 0;
|
||||
|
||||
send (sock, (char *) &socks5, sizeof(socks5), 0);
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
{
|
||||
/* with authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 2 => authentication
|
||||
*/
|
||||
|
||||
//if (!(buffer[0] == 5 && buffer[1] == 2))
|
||||
if (buffer[0] != 5 || buffer[1] != 2)
|
||||
return 1;
|
||||
//if (!(buffer[0] == 5 && buffer[1] == 2))
|
||||
if (buffer[0] != 5 || buffer[1] != 2)
|
||||
return 1;
|
||||
|
||||
/* authentication as in RFC 1929 */
|
||||
username_len = strlen(cfg_proxy_username);
|
||||
password_len = strlen(cfg_proxy_password);
|
||||
/* authentication as in RFC 1929 */
|
||||
username_len = strlen(cfg_proxy_username);
|
||||
password_len = strlen(cfg_proxy_password);
|
||||
|
||||
/* make username/password buffer */
|
||||
buffer[0] = 1;
|
||||
buffer[1] = (unsigned char) username_len;
|
||||
memcpy(buffer + 2, cfg_proxy_username, username_len);
|
||||
buffer[2 + username_len] = (unsigned char) password_len;
|
||||
memcpy(buffer + 3 + username_len, cfg_proxy_password, password_len);
|
||||
/* make username/password buffer */
|
||||
buffer[0] = 1;
|
||||
buffer[1] = (unsigned char) username_len;
|
||||
memcpy(buffer + 2, cfg_proxy_username, username_len);
|
||||
buffer[2 + username_len] = (unsigned char) password_len;
|
||||
memcpy(buffer + 3 + username_len, cfg_proxy_password, password_len);
|
||||
|
||||
send (sock, buffer, 3 + username_len + password_len, 0);
|
||||
send (sock, buffer, 3 + username_len + password_len, 0);
|
||||
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
/* buffer[1] = auth state, must be 0 for success */
|
||||
if (buffer[1] != 0)
|
||||
return 1;
|
||||
/* buffer[1] = auth state, must be 0 for success */
|
||||
if (buffer[1] != 0)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* without authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 0 => no authentication
|
||||
*/
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
/* without authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 0 => no authentication
|
||||
*/
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
addr_buffer = (unsigned char *) malloc ( addr_buffer_len * sizeof(*addr_buffer));
|
||||
if (!addr_buffer)
|
||||
return 1;
|
||||
addr_buffer[0] = 5; /* version 5 */
|
||||
addr_buffer[1] = 1; /* command: 1 for connect */
|
||||
addr_buffer[2] = 0; /* reserved */
|
||||
addr_buffer[3] = 3; /* address type : ipv4 (1), domainname (3), ipv6 (4) */
|
||||
addr_buffer[4] = (unsigned char) addr_len;
|
||||
memcpy (addr_buffer + 5, address, addr_len); /* server address */
|
||||
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
|
||||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
addr_buffer = (unsigned char *) malloc ( addr_buffer_len * sizeof(*addr_buffer));
|
||||
if (!addr_buffer)
|
||||
return 1;
|
||||
addr_buffer[0] = 5; /* version 5 */
|
||||
addr_buffer[1] = 1; /* command: 1 for connect */
|
||||
addr_buffer[2] = 0; /* reserved */
|
||||
addr_buffer[3] = 3; /* address type : ipv4 (1), domainname (3), ipv6 (4) */
|
||||
addr_buffer[4] = (unsigned char) addr_len;
|
||||
memcpy (addr_buffer + 5, address, addr_len); /* server address */
|
||||
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
|
||||
|
||||
send (sock, addr_buffer, addr_buffer_len, 0);
|
||||
free(addr_buffer);
|
||||
send (sock, addr_buffer, addr_buffer_len, 0);
|
||||
free(addr_buffer);
|
||||
|
||||
/* dialog with proxy server */
|
||||
if (recv (sock, buffer, 4, 0) != 4)
|
||||
return 1;
|
||||
/* dialog with proxy server */
|
||||
if (recv (sock, buffer, 4, 0) != 4)
|
||||
return 1;
|
||||
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
|
||||
switch(buffer[3]) {
|
||||
/* buffer[3] = address type */
|
||||
case 1 :
|
||||
/* ipv4
|
||||
* server socks return server bound address and port
|
||||
* address of 4 bytes and port of 2 bytes (= 6 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 6, 0) != 6)
|
||||
return 1;
|
||||
break;
|
||||
case 3:
|
||||
/* domainname
|
||||
* server socks return server bound address and port
|
||||
*/
|
||||
/* reading address length */
|
||||
if (recv (sock, buffer, 1, 0) != 1)
|
||||
return 1;
|
||||
addr_len = buffer[0];
|
||||
/* reading address + port = addr_len + 2 */
|
||||
if (recv (sock, buffer, addr_len + 2, 0) != (addr_len + 2))
|
||||
return 1;
|
||||
break;
|
||||
case 4 :
|
||||
/* ipv6
|
||||
* server socks return server bound address and port
|
||||
* address of 16 bytes and port of 2 bytes (= 18 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 18, 0) != 18)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
switch(buffer[3]) {
|
||||
/* buffer[3] = address type */
|
||||
case 1 :
|
||||
/* ipv4
|
||||
* server socks return server bound address and port
|
||||
* address of 4 bytes and port of 2 bytes (= 6 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 6, 0) != 6)
|
||||
return 1;
|
||||
break;
|
||||
case 3:
|
||||
/* domainname
|
||||
* server socks return server bound address and port
|
||||
*/
|
||||
/* reading address length */
|
||||
if (recv (sock, buffer, 1, 0) != 1)
|
||||
return 1;
|
||||
addr_len = buffer[0];
|
||||
/* reading address + port = addr_len + 2 */
|
||||
if (recv (sock, buffer, addr_len + 2, 0) != (addr_len + 2))
|
||||
return 1;
|
||||
break;
|
||||
case 4 :
|
||||
/* ipv6
|
||||
* server socks return server bound address and port
|
||||
* address of 16 bytes and port of 2 bytes (= 18 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 18, 0) != 18)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_proxy: establish connection/authentification to a proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_proxy(int sock, char *address, int port, char *username)
|
||||
{
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
|
||||
return pass_httpproxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
|
||||
return pass_socks4proxy(sock, address, port, username);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
|
||||
return pass_socks5proxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
|
||||
return pass_httpproxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
|
||||
return pass_socks4proxy(sock, address, port, username);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
|
||||
return pass_socks5proxy(sock, address, port);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1586,6 +1590,9 @@ server_search (char *servername)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (!servername)
|
||||
return NULL;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -1624,6 +1631,9 @@ server_name_already_exists (char *name)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (strcmp (ptr_server->name, name) == 0)
|
||||
|
||||
+91
-54
@@ -203,7 +203,7 @@ struct t_irc_command
|
||||
/* function called when user enters cmd */
|
||||
int (*cmd_function_1arg)(t_irc_server *, char *);
|
||||
/* function called when user enters cmd */
|
||||
int (*recv_function)(t_irc_server *, char *, char *);
|
||||
int (*recv_function)(t_irc_server *, char *, char *, char *);
|
||||
/* function called when cmd is received */
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ struct t_irc_message
|
||||
t_irc_message *next_message; /* link to next message */
|
||||
};
|
||||
|
||||
/* DCC */
|
||||
/* DCC types */
|
||||
|
||||
typedef struct t_irc_dcc t_irc_dcc;
|
||||
|
||||
@@ -251,6 +251,30 @@ struct t_irc_dcc
|
||||
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 IGNORE_ACTION "action"
|
||||
#define IGNORE_CTCP "ctcp"
|
||||
#define IGNORE_DCC "dcc"
|
||||
#define 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;
|
||||
extern t_irc_message *recv_msgq, *msgq_last_msg;
|
||||
@@ -258,6 +282,9 @@ extern int check_away;
|
||||
extern t_irc_dcc *dcc_list;
|
||||
extern char *dcc_status_string[6];
|
||||
extern char *channel_modes;
|
||||
extern char *ignore_types[];
|
||||
extern t_irc_ignore *irc_ignore;
|
||||
extern t_irc_ignore *irc_last_ignore;
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
@@ -414,57 +441,67 @@ extern int irc_cmd_send_who (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_whois (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_whowas (t_irc_server *, char *);
|
||||
/* IRC commands executed when received from server */
|
||||
extern int irc_cmd_recv_error (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_invite (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_join (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_kick (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_kill (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_mode (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_nick (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_notice (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_part (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_ping (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_pong (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_privmsg (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_quit (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_server_msg (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_server_reply (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_topic (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_001 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_004 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_301 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_302 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_303 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_305 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_306 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_307 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_311 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_312 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_313 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_314 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_315 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_317 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_318 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_319 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_320 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_321 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_341 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_351 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_352 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_353 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_365 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_366 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_367 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_368 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_433 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_438 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_671 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_error (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_invite (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_join (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_kick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_kill (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_mode (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_nick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_notice (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_part (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_ping (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_pong (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_privmsg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_quit (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_server_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_server_reply (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_topic (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_001 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_004 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_301 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_302 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_303 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_305 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_306 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_307 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_311 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_312 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_313 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_314 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_315 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_317 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_318 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_319 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_320 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_321 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_341 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_351 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_352 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_353 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_365 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_366 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_367 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_368 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_433 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_438 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_671 (t_irc_server *, char *, char *, char *);
|
||||
|
||||
/* ignore functions (irc-ignore.c) */
|
||||
|
||||
extern int ignore_check (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *ignore_add (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *ignore_add_from_config (char *);
|
||||
extern void ignore_free_all ();
|
||||
extern int ignore_search_free (char *, char *, char *, char *);
|
||||
extern int ignore_search_free_by_number (int);
|
||||
extern void ignore_print_log ();
|
||||
|
||||
#endif /* irc.h */
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-09-03
|
||||
ChangeLog - 2005-09-04
|
||||
|
||||
|
||||
Version 0.1.5 (under dev!):
|
||||
* added /ignore and /unignore commands
|
||||
* fixed bug with strings comparison (str[n]casecmp) and some locales
|
||||
(like turkish), now using ASCII comparison (thanks to roktas)
|
||||
* signal SIGQUIT is now ignored
|
||||
|
||||
+2
-3
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2005-08-16
|
||||
TODO - 2005-09-04
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -30,6 +30,7 @@ v0.1.5:
|
||||
* WeeChat commands
|
||||
- be able to bind a key on more than one command
|
||||
- be able to make an alias running more than one command
|
||||
# /ignore and /unignore commands
|
||||
|
||||
* Configuration:
|
||||
- be able to launch more than one command when connecting to server
|
||||
@@ -42,8 +43,6 @@ Future versions:
|
||||
- customizable CTCP version reply
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
nick/host
|
||||
- when we're away, WeeChat should log all the lines begenning by our nick.
|
||||
When we come back from our away it should print it to the current window
|
||||
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
./src/irc/irc-send.c
|
||||
./src/irc/irc-recv.c
|
||||
./src/irc/irc-dcc.c
|
||||
./src/irc/irc-ignore.c
|
||||
./src/irc/irc.h
|
||||
./src/plugins/perl/wee-perl.c
|
||||
./src/plugins/perl/wee-perl.h
|
||||
|
||||
+730
-613
File diff suppressed because it is too large
Load Diff
+753
-613
File diff suppressed because it is too large
Load Diff
+734
-627
File diff suppressed because it is too large
Load Diff
@@ -72,6 +72,16 @@ t_weechat_command weechat_commands[] =
|
||||
{ "help", N_("display help about commands"),
|
||||
N_("[command]"), N_("command: name of a WeeChat or IRC command"),
|
||||
0, 1, weechat_cmd_help, NULL },
|
||||
{ "ignore", N_("ignore IRC messages and/or hosts"),
|
||||
N_("[mask [[type | command] [channel [server]]]]"),
|
||||
N_(" mask: nick or host mask to ignore\n"
|
||||
" type: type of message to ignore (action, ctcp, dcc, pv)\n"
|
||||
"command: IRC command\n"
|
||||
"channel: name of channel for ignore\n"
|
||||
" server: name of server for ignore\n\n"
|
||||
"For each argument, '*' means all.\n"
|
||||
"Without argument, /ignore command lists all defined ignore."),
|
||||
0, 4, weechat_cmd_ignore, NULL },
|
||||
{ "key", N_("bind/unbind keys"),
|
||||
N_("[key function/command] [unbind key] [functions] [reset -yes]"),
|
||||
N_("key: bind this key to an internal function or a command (beginning by \"/\")\n"
|
||||
@@ -81,17 +91,17 @@ t_weechat_command weechat_commands[] =
|
||||
0, MAX_ARGS, NULL, weechat_cmd_key },
|
||||
{ "perl", N_("list/load/unload Perl scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Perl script (file) to load\n"
|
||||
N_("filename: Perl script (file) to load\n\n"
|
||||
"Without argument, /perl command lists all loaded Perl scripts."),
|
||||
0, 2, weechat_cmd_perl, NULL },
|
||||
{ "python", N_("list/load/unload Python scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Python script (file) to load\n"
|
||||
N_("filename: Python script (file) to load\n\n"
|
||||
"Without argument, /python command lists all loaded Python scripts."),
|
||||
0, 2, weechat_cmd_python, NULL },
|
||||
{ "ruby", N_("list/load/unload Ruby scripts"),
|
||||
N_("[load filename] | [autoload] | [reload] | [unload]"),
|
||||
N_("filename: Ruby script (file) to load\n"
|
||||
N_("filename: Ruby script (file) to load\n\n"
|
||||
"Without argument, /ruby command lists all loaded Ruby scripts."),
|
||||
0, 2, weechat_cmd_ruby, NULL },
|
||||
{ "server", N_("list, add or remove servers"),
|
||||
@@ -121,6 +131,17 @@ t_weechat_command weechat_commands[] =
|
||||
{ "unalias", N_("remove an alias"),
|
||||
N_("alias_name"), N_("alias_name: name of alias to remove"),
|
||||
1, 1, NULL, weechat_cmd_unalias },
|
||||
{ "unignore", N_("unignore IRC messages and/or hosts"),
|
||||
N_("[number | [mask [[type | command] [channel [server]]]]]"),
|
||||
N_(" number: # of ignore to unignore (number is displayed by list of ignore)\n"
|
||||
" mask: nick or host mask to unignore\n"
|
||||
" type: type of message to unignore (action, ctcp, dcc, pv)\n"
|
||||
"command: IRC command\n"
|
||||
"channel: name of channel for unignore\n"
|
||||
" server: name of server for unignore\n\n"
|
||||
"For each argument, '*' means all.\n"
|
||||
"Without argument, /unignore command lists all defined ignore."),
|
||||
0, 4, weechat_cmd_unignore, NULL },
|
||||
{ "window", N_("manage windows"),
|
||||
N_("[list | splith | splitv | [merge [down | up | left | right | all]]]"),
|
||||
N_("list: list opened windows (no parameter implies this list)\n"
|
||||
@@ -874,6 +895,11 @@ weechat_cmd_buffer_display_info (t_gui_buffer *buffer)
|
||||
"%s", SERVER(buffer)->name);
|
||||
gui_printf (NULL, ")\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (NULL, _("not connected"));
|
||||
gui_printf (NULL, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1351,6 +1377,93 @@ weechat_cmd_help (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_ignore_display: display an ignore entry
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_cmd_ignore_display (char *text, t_irc_ignore *ptr_ignore)
|
||||
{
|
||||
if (text)
|
||||
gui_printf (NULL, "%s ", text);
|
||||
|
||||
gui_printf (NULL, _("on"));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", ptr_ignore->server_name);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "/");
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->channel_name);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ":");
|
||||
gui_printf (NULL, _(" ignoring "));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->type);
|
||||
gui_printf (NULL, _(" from "));
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, "%s\n", ptr_ignore->mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_ignore: ignore IRC commands and/or hosts
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_ignore (int argc, char **argv)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
int i;
|
||||
|
||||
ptr_ignore = NULL;
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
/* List all ignore */
|
||||
if (irc_ignore)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("List of ignore:\n"));
|
||||
i = 0;
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
i++;
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "[");
|
||||
gui_printf (NULL, "%d", i);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "] ");
|
||||
weechat_cmd_ignore_display (NULL, ptr_ignore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
gui_printf (NULL, _("No ignore defined.\n"));
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
ptr_ignore = ignore_add (argv[0], "*", "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 2:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 3:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], argv[2],
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 4:
|
||||
ptr_ignore = ignore_add (argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
}
|
||||
if (ptr_ignore)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
weechat_cmd_ignore_display (_("New ignore:"), ptr_ignore);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_key_display: display a key binding
|
||||
*/
|
||||
@@ -2410,7 +2523,7 @@ weechat_cmd_set (char *arguments)
|
||||
{
|
||||
section_displayed = 0;
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -2519,6 +2632,69 @@ weechat_cmd_unalias (char *arguments)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_unignore: unignore IRC commands and/or hosts
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_unignore (int argc, char **argv)
|
||||
{
|
||||
char *error;
|
||||
int number, ret;
|
||||
|
||||
ret = 0;
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
/* List all ignore */
|
||||
weechat_cmd_ignore (argc, argv);
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
error = NULL;
|
||||
number = strtol (argv[0], &error, 10);
|
||||
if ((error) && (error[0] == '\0'))
|
||||
ret = ignore_search_free_by_number (number);
|
||||
else
|
||||
ret = ignore_search_free (argv[0], "*", "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 2:
|
||||
ret = ignore_search_free (argv[0], argv[1], "*",
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 3:
|
||||
ret = ignore_search_free (argv[0], argv[1], argv[2],
|
||||
(SERVER(gui_current_window->buffer)) ?
|
||||
SERVER(gui_current_window->buffer)->name : "*");
|
||||
break;
|
||||
case 4:
|
||||
ret = ignore_search_free (argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%d ", ret);
|
||||
if (ret > 1)
|
||||
gui_printf (NULL, _("ignore were removed.\n"));
|
||||
else
|
||||
gui_printf (NULL, _("ignore was removed.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL, _("%s no ignore found\n"),
|
||||
WEECHAT_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_window: manage windows
|
||||
*/
|
||||
|
||||
@@ -69,6 +69,8 @@ extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_debug (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern void weechat_cmd_ignore_display (char *, t_irc_ignore *);
|
||||
extern int weechat_cmd_ignore (int, char **);
|
||||
extern int weechat_cmd_key (char *);
|
||||
extern int weechat_cmd_perl (int, char **);
|
||||
extern int weechat_cmd_python (int, char **);
|
||||
@@ -77,6 +79,7 @@ extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_set (char *);
|
||||
extern int weechat_cmd_unalias (char *);
|
||||
extern int weechat_cmd_unignore (int, char **);
|
||||
extern int weechat_cmd_unset (char *);
|
||||
extern int weechat_cmd_window (int, char **);
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
int i, j;
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
char *pos, option_name[256], *string;
|
||||
t_weechat_alias *ptr_alias;
|
||||
t_config_option *option;
|
||||
@@ -201,6 +202,88 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ascii_strcasecmp (completion->base_command, "ignore") == 0)
|
||||
{
|
||||
/* arg 1: nicks of current channel and "*" */
|
||||
if (completion->base_command_arg == 1)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (channel)
|
||||
{
|
||||
if (((t_irc_channel *)channel)->type == CHAT_CHANNEL)
|
||||
{
|
||||
for (ptr_nick = ((t_irc_channel *)channel)->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
ptr_nick->nick);
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)channel)->type == CHAT_PRIVATE)
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
((t_irc_channel *)channel)->name);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 2: type / command and "*" */
|
||||
if (completion->base_command_arg == 2)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
i = 0;
|
||||
while (ignore_types[i])
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
ignore_types[i]);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (irc_commands[i].command_name)
|
||||
{
|
||||
if (irc_commands[i].recv_function)
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
irc_commands[i].command_name);
|
||||
i++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 3: channel and "*" */
|
||||
if (completion->base_command_arg == 3)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (((t_irc_channel *)channel)->type == CHAT_CHANNEL)
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
((t_irc_channel *)channel)->name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* arg 4: server */
|
||||
if (completion->base_command_arg == 4)
|
||||
{
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"*");
|
||||
if (SERVER(gui_current_window->buffer))
|
||||
weelist_add(&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
SERVER(gui_current_window->buffer)->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ascii_strcasecmp (completion->base_command, "key") == 0)
|
||||
{
|
||||
if (completion->base_command_arg == 1)
|
||||
@@ -254,7 +337,7 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
|
||||
@@ -844,6 +844,9 @@ wee_dump (int crash)
|
||||
wee_log_printf ("\n");
|
||||
gui_buffer_print_log (ptr_buffer);
|
||||
}
|
||||
|
||||
wee_log_printf ("\n");
|
||||
ignore_print_log ();
|
||||
|
||||
wee_log_printf ("\n");
|
||||
wee_log_printf ("****** End of dump ******\n");
|
||||
|
||||
@@ -55,6 +55,7 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
|
||||
{ CONFIG_SECTION_PROXY, "proxy" },
|
||||
{ CONFIG_SECTION_KEYS, "keys" },
|
||||
{ CONFIG_SECTION_ALIAS, "alias" },
|
||||
{ CONFIG_SECTION_IGNORE, "ignore" },
|
||||
{ CONFIG_SECTION_SERVER, "server" }
|
||||
};
|
||||
|
||||
@@ -758,7 +759,7 @@ t_config_option weechat_options_server[] =
|
||||
t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
|
||||
{ weechat_options_look, weechat_options_colors, weechat_options_history,
|
||||
weechat_options_log, weechat_options_irc, weechat_options_dcc,
|
||||
weechat_options_proxy, NULL, NULL, weechat_options_server
|
||||
weechat_options_proxy, NULL, NULL, NULL, weechat_options_server
|
||||
};
|
||||
|
||||
|
||||
@@ -795,7 +796,7 @@ config_get_section (t_config_option *ptr_option)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1090,7 +1091,7 @@ config_option_search (char *option_name)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1254,7 +1255,7 @@ config_default_values ()
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -1428,6 +1429,21 @@ config_read ()
|
||||
if (alias_new (line, pos))
|
||||
weelist_add (&index_commands, &last_index_command, line);
|
||||
}
|
||||
else if (section == CONFIG_SECTION_IGNORE)
|
||||
{
|
||||
/* create new ignore */
|
||||
if (ascii_strcasecmp (line, "ignore") != 0)
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, line);
|
||||
else
|
||||
{
|
||||
if (!ignore_add_from_config (pos))
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid ignore options \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
option_number = -1;
|
||||
@@ -1571,7 +1587,7 @@ config_create_default ()
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1623,7 +1639,6 @@ config_create_default ()
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
/* TODO: remove comments when missing commands will be ok */
|
||||
fprintf (file, "\n[alias]\n");
|
||||
fprintf (file, "SAY=msg *\n");
|
||||
fprintf (file, "BYE=quit\n");
|
||||
@@ -1633,12 +1648,10 @@ config_create_default ()
|
||||
fprintf (file, "CL=clear\n");
|
||||
fprintf (file, "CLOSE=buffer close\n");
|
||||
fprintf (file, "CHAT=dcc chat\n");
|
||||
fprintf (file, "# GET=dcc get\n");
|
||||
fprintf (file, "# IG=ignore\n");
|
||||
fprintf (file, "IG=ignore\n");
|
||||
fprintf (file, "J=join\n");
|
||||
fprintf (file, "K=kick\n");
|
||||
fprintf (file, "KB=kickban\n");
|
||||
fprintf (file, "# KN=knockout\n");
|
||||
fprintf (file, "LEAVE=part\n");
|
||||
fprintf (file, "M=msg\n");
|
||||
fprintf (file, "MUB=unban *\n");
|
||||
@@ -1646,12 +1659,14 @@ config_create_default ()
|
||||
fprintf (file, "Q=query\n");
|
||||
fprintf (file, "T=topic\n");
|
||||
fprintf (file, "UB=unban\n");
|
||||
fprintf (file, "# UNIG=unignore\n");
|
||||
fprintf (file, "UNIG=unignore\n");
|
||||
fprintf (file, "W=who\n");
|
||||
fprintf (file, "WC=part\n");
|
||||
fprintf (file, "WI=whois\n");
|
||||
fprintf (file, "WW=whowas\n");
|
||||
|
||||
/* no ignore by default */
|
||||
|
||||
/* default server is freenode */
|
||||
fprintf (file, "\n[server]\n");
|
||||
fprintf (file, "server_name=freenode\n");
|
||||
@@ -1730,6 +1745,7 @@ config_write (char *config_name)
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
t_weechat_alias *ptr_alias;
|
||||
t_irc_ignore *ptr_ignore;
|
||||
t_gui_key *ptr_key;
|
||||
char *expanded_name, *function_name;
|
||||
|
||||
@@ -1765,7 +1781,7 @@ config_write (char *config_name)
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
|
||||
&& (i != CONFIG_SECTION_SERVER))
|
||||
&& (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
@@ -1842,6 +1858,18 @@ config_write (char *config_name)
|
||||
ptr_alias->alias_name, ptr_alias->alias_command + 1);
|
||||
}
|
||||
|
||||
/* ignore section */
|
||||
fprintf (file, "\n[ignore]\n");
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
fprintf (file, "ignore=%s,%s,%s,%s\n",
|
||||
ptr_ignore->mask,
|
||||
ptr_ignore->type,
|
||||
ptr_ignore->channel_name,
|
||||
ptr_ignore->server_name);
|
||||
}
|
||||
|
||||
/* server section */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
#define CONFIG_SECTION_PROXY 6
|
||||
#define CONFIG_SECTION_KEYS 7
|
||||
#define CONFIG_SECTION_ALIAS 8
|
||||
#define CONFIG_SECTION_SERVER 9
|
||||
#define CONFIG_NUMBER_SECTIONS 10
|
||||
#define CONFIG_SECTION_IGNORE 9
|
||||
#define CONFIG_SECTION_SERVER 10
|
||||
#define CONFIG_NUMBER_SECTIONS 11
|
||||
|
||||
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
|
||||
#define OPTION_TYPE_INT 2 /* values: from min to max */
|
||||
|
||||
@@ -27,4 +27,5 @@ lib_weechat_irc_a_SOURCES = irc.h \
|
||||
irc-channel.c \
|
||||
irc-nick.c \
|
||||
irc-dcc.c \
|
||||
irc-ignore.c \
|
||||
irc-display.c
|
||||
|
||||
@@ -143,7 +143,10 @@ t_irc_channel *
|
||||
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)
|
||||
{
|
||||
@@ -162,6 +165,9 @@ string_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, CHANNEL_PREFIX)) ? 1 : 0;
|
||||
|
||||
@@ -384,8 +384,6 @@ t_irc_command irc_commands[] =
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "406", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "406", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "407", N_("was no such nick"),
|
||||
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
|
||||
{ "409", N_("no origin"),
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* 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"
|
||||
|
||||
|
||||
char *ignore_types[] =
|
||||
{ IGNORE_ACTION, IGNORE_CTCP, IGNORE_DCC, IGNORE_PRIVATE, NULL };
|
||||
|
||||
t_irc_ignore *irc_ignore = NULL;
|
||||
t_irc_ignore *last_irc_ignore = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* ignore_check_mask: returns 1 is mask1 and mask2 are the same host
|
||||
* anyone or both strings may have user and/or host after
|
||||
*/
|
||||
|
||||
int
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_match: check if pointed ignore matches with arguments
|
||||
*/
|
||||
|
||||
int
|
||||
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)
|
||||
&& (!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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_check: check if an ignore is set for arguments
|
||||
* returns 1 if at least one ignore exists (message should NOT be displayed)
|
||||
* 0 if no ignore found (message will be displayed)
|
||||
*/
|
||||
|
||||
int
|
||||
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 (ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* no ignore found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_search: search for an ignore
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_add: add an ignore in list
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
ignore_add (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
int i, 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])
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s too few arguments for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
wee_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, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s mask or type/command should be non generic value for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ignore_search (mask, type, channel_name, server_name))
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s ignore already exists\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (type, "*") != 0)
|
||||
{
|
||||
/* look for type in pre-defined ignore types */
|
||||
for (i = 0; ignore_types[i]; i++)
|
||||
{
|
||||
if (ascii_strcasecmp (type, ignore_types[i]) == 0)
|
||||
{
|
||||
type_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* not a pre-defined ignore type, so it MUST be an IRC command */
|
||||
if (type_index < 0)
|
||||
{
|
||||
for (i = 0; irc_commands[i].command_name; i++)
|
||||
{
|
||||
if (irc_commands[i].recv_function &&
|
||||
(ascii_strcasecmp (type, irc_commands[i].command_name) == 0))
|
||||
{
|
||||
command_ptr = &irc_commands[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* not a pre-defined command and not an IRC command => error */
|
||||
if ((type_index < 0) && (!command_ptr))
|
||||
{
|
||||
irc_display_prefix (NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s unknown type or IRC command \"%s\" for ignore\n"),
|
||||
WEECHAT_ERROR, type);
|
||||
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, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s not enough memory to create ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_add_from_config: add an ignore to list, read from config file
|
||||
* (comma serparated values)
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
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 = ignore_add (pos_mask, pos_type, pos_channel, pos_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (string2);
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_free: free an ignore
|
||||
*/
|
||||
|
||||
void
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_free_all: free all ignores
|
||||
*/
|
||||
|
||||
void
|
||||
ignore_free_all ()
|
||||
{
|
||||
while (irc_ignore)
|
||||
ignore_free (irc_ignore);
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_search_free: search and free ignore(s)
|
||||
* return: number of ignore found and deleted
|
||||
* 0 if no ignore found
|
||||
*/
|
||||
|
||||
int
|
||||
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 (ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
{
|
||||
found++;
|
||||
if (found == 1)
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
next_ignore = ptr_ignore->next_ignore;
|
||||
ignore_free (ptr_ignore);
|
||||
ptr_ignore = next_ignore;
|
||||
}
|
||||
else
|
||||
ptr_ignore = ptr_ignore->next_ignore;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
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, PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
ignore_free (ptr_ignore);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ignore number not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ignore_print_log: print ignore list in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
ignore_print_log ()
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
wee_log_printf ("[ignore list]\n");
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
wee_log_printf ("\n");
|
||||
wee_log_printf (" -> ignore at 0x%X:\n", ptr_ignore);
|
||||
wee_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask);
|
||||
wee_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type);
|
||||
wee_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name);
|
||||
wee_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name);
|
||||
wee_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore);
|
||||
wee_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore);
|
||||
}
|
||||
}
|
||||
@@ -314,7 +314,10 @@ t_irc_nick *
|
||||
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)
|
||||
{
|
||||
|
||||
+1612
-1385
File diff suppressed because it is too large
Load Diff
+222
-212
@@ -900,12 +900,12 @@ void
|
||||
convbase64_8x3_to_6x4(char *from, char* to)
|
||||
{
|
||||
|
||||
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
|
||||
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
|
||||
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
|
||||
to[3] = base64_table [ from[2] & 0x3f ];
|
||||
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
|
||||
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
|
||||
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
|
||||
to[3] = base64_table [ from[2] & 0x3f ];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -916,91 +916,92 @@ void
|
||||
base64encode(char *from, char *to)
|
||||
{
|
||||
|
||||
char *f, *t;
|
||||
int from_len;
|
||||
char *f, *t;
|
||||
int from_len;
|
||||
|
||||
from_len = strlen(from);
|
||||
from_len = strlen(from);
|
||||
|
||||
f = from;
|
||||
t = to;
|
||||
f = from;
|
||||
t = to;
|
||||
|
||||
while(from_len >= 3)
|
||||
while(from_len >= 3)
|
||||
{
|
||||
convbase64_8x3_to_6x4(f, t);
|
||||
f += 3 * sizeof(*f);
|
||||
t += 4 * sizeof(*t);
|
||||
from_len -= 3;
|
||||
convbase64_8x3_to_6x4(f, t);
|
||||
f += 3 * sizeof(*f);
|
||||
t += 4 * sizeof(*t);
|
||||
from_len -= 3;
|
||||
}
|
||||
|
||||
if (from_len > 0)
|
||||
if (from_len > 0)
|
||||
{
|
||||
char rest[3] = { 0, 0, 0 };
|
||||
switch(from_len)
|
||||
char rest[3] = { 0, 0, 0 };
|
||||
switch(from_len)
|
||||
{
|
||||
case 1 :
|
||||
rest[0] = f[0];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[2] = t[3] = '=';
|
||||
break;
|
||||
rest[0] = f[0];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[2] = t[3] = '=';
|
||||
break;
|
||||
case 2 :
|
||||
rest[0] = f[0];
|
||||
rest[1] = f[1];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[3] = '=';
|
||||
break;
|
||||
rest[0] = f[0];
|
||||
rest[1] = f[1];
|
||||
convbase64_8x3_to_6x4(rest, t);
|
||||
t[3] = '=';
|
||||
break;
|
||||
}
|
||||
t[4] = 0;
|
||||
t[4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_httpproxy: establish connection/authentification to an http proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_httpproxy(int sock, char *address, int port)
|
||||
{
|
||||
|
||||
char buffer[256];
|
||||
char authbuf[128]; // seems to be enougth to store username + password
|
||||
char authbuf_base64[196]; // enougth to store base64 encoded authbuf
|
||||
int n, m;
|
||||
char buffer[256];
|
||||
char authbuf[128]; // seems to be enougth to store username + password
|
||||
char authbuf_base64[196]; // enougth to store base64 encoded authbuf
|
||||
int n, m;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
{
|
||||
// authentification
|
||||
snprintf(authbuf, sizeof(authbuf), "%s:%s", cfg_proxy_username, cfg_proxy_password);
|
||||
base64encode(authbuf, authbuf_base64);
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n", address, port, authbuf_base64);
|
||||
// authentification
|
||||
snprintf(authbuf, sizeof(authbuf), "%s:%s", cfg_proxy_username, cfg_proxy_password);
|
||||
base64encode(authbuf, authbuf_base64);
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n", address, port, authbuf_base64);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// no authentification
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
|
||||
// no authentification
|
||||
n = snprintf(buffer, sizeof(buffer), "CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
|
||||
}
|
||||
|
||||
m = send (sock, buffer, n, 0);
|
||||
if (n != m)
|
||||
return 1;
|
||||
m = send (sock, buffer, n, 0);
|
||||
if (n != m)
|
||||
return 1;
|
||||
|
||||
n = recv(sock, buffer, sizeof(buffer), 0);
|
||||
n = recv(sock, buffer, sizeof(buffer), 0);
|
||||
|
||||
/* success result must be like : "HTTP/1.0 200 OK" */
|
||||
if (n < 12)
|
||||
return 1;
|
||||
/* success result must be like : "HTTP/1.0 200 OK" */
|
||||
if (n < 12)
|
||||
return 1;
|
||||
|
||||
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
|
||||
return 1;
|
||||
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* resolve: resolve hostname on its IP address
|
||||
* (works with ipv4 and ipv6)
|
||||
* return :
|
||||
* return :
|
||||
* - 0 if resolution was successful
|
||||
* - 1 if resolution fails
|
||||
*/
|
||||
@@ -1042,207 +1043,210 @@ resolve (char *hostname, char *ip, int *version)
|
||||
|
||||
/*
|
||||
* pass_socks4proxy: establish connection/authentification throw a socks4 proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_socks4proxy(int sock, char *address, int port, char *username)
|
||||
{
|
||||
/*
|
||||
* socks4 protocol is explain here:
|
||||
* http://archive.socks.permeo.com/protocol/socks4.protocol
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* socks4 protocol is explain here:
|
||||
* http://archive.socks.permeo.com/protocol/socks4.protocol
|
||||
*
|
||||
*/
|
||||
|
||||
struct s_socks4
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char method; /* 1 byte */ /* socks method : connect (1) or bind (2) */
|
||||
unsigned short port; /* 2 bytes */ /* destination port */
|
||||
unsigned long address; /* 4 bytes */ /* destination address */
|
||||
char user[64]; /* username (64 characters seems to be enought) */
|
||||
} socks4;
|
||||
unsigned char buffer[24];
|
||||
char ip_addr[NI_MAXHOST];
|
||||
struct s_socks4
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char method; /* 1 byte */ /* socks method : connect (1) or bind (2) */
|
||||
unsigned short port; /* 2 bytes */ /* destination port */
|
||||
unsigned long address; /* 4 bytes */ /* destination address */
|
||||
char user[64]; /* username (64 characters seems to be enought) */
|
||||
} socks4;
|
||||
unsigned char buffer[24];
|
||||
char ip_addr[NI_MAXHOST];
|
||||
|
||||
socks4.version = 4;
|
||||
socks4.method = 1;
|
||||
socks4.port = htons (port);
|
||||
resolve(address, ip_addr, NULL);
|
||||
socks4.address = inet_addr (ip_addr);
|
||||
strncpy (socks4.user, username, sizeof(socks4.user) - 1);
|
||||
socks4.version = 4;
|
||||
socks4.method = 1;
|
||||
socks4.port = htons (port);
|
||||
resolve(address, ip_addr, NULL);
|
||||
socks4.address = inet_addr (ip_addr);
|
||||
strncpy (socks4.user, username, sizeof(socks4.user) - 1);
|
||||
|
||||
send (sock, (char *) &socks4, 8 + strlen(socks4.user) + 1, 0);
|
||||
recv (sock, buffer, sizeof(buffer), 0);
|
||||
send (sock, (char *) &socks4, 8 + strlen(socks4.user) + 1, 0);
|
||||
recv (sock, buffer, sizeof(buffer), 0);
|
||||
|
||||
if (buffer[0] == 0 && buffer[1] == 90)
|
||||
return 0;
|
||||
if (buffer[0] == 0 && buffer[1] == 90)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_socks5proxy: establish connection/authentification throw a socks5 proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_socks5proxy(int sock, char *address, int port)
|
||||
{
|
||||
/*
|
||||
* socks5 protocol is explained in RFC 1928
|
||||
* socks5 authentication with username/pass is explained in RFC 1929
|
||||
*/
|
||||
/*
|
||||
* socks5 protocol is explained in RFC 1928
|
||||
* socks5 authentication with username/pass is explained in RFC 1929
|
||||
*/
|
||||
|
||||
struct s_sock5
|
||||
{
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char nmethods; /* 1 byte */ /* size in byte(s) of field 'method', here 1 byte */
|
||||
char method; /* 1-255 bytes */ /* socks method : noauth (0), auth(user/pass) (2), ... */
|
||||
} socks5;
|
||||
unsigned char buffer[288];
|
||||
int username_len, password_len, addr_len, addr_buffer_len;
|
||||
unsigned char *addr_buffer;
|
||||
|
||||
socks5.version = 5;
|
||||
socks5.nmethods = 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
/* with authentication */
|
||||
socks5.method = 2;
|
||||
else
|
||||
/* without authentication */
|
||||
socks5.method = 0;
|
||||
|
||||
send (sock, (char *) &socks5, sizeof(socks5), 0);
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
struct s_sock5
|
||||
{
|
||||
/* with authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 2 => authentication
|
||||
*/
|
||||
char version; /* 1 byte */ /* socks version : 4 or 5 */
|
||||
char nmethods; /* 1 byte */ /* size in byte(s) of field 'method', here 1 byte */
|
||||
char method; /* 1-255 bytes */ /* socks method : noauth (0), auth(user/pass) (2), ... */
|
||||
} socks5;
|
||||
unsigned char buffer[288];
|
||||
int username_len, password_len, addr_len, addr_buffer_len;
|
||||
unsigned char *addr_buffer;
|
||||
|
||||
socks5.version = 5;
|
||||
socks5.nmethods = 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
/* with authentication */
|
||||
socks5.method = 2;
|
||||
else
|
||||
/* without authentication */
|
||||
socks5.method = 0;
|
||||
|
||||
send (sock, (char *) &socks5, sizeof(socks5), 0);
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
if (strlen(cfg_proxy_username) > 0)
|
||||
{
|
||||
/* with authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 2 => authentication
|
||||
*/
|
||||
|
||||
//if (!(buffer[0] == 5 && buffer[1] == 2))
|
||||
if (buffer[0] != 5 || buffer[1] != 2)
|
||||
return 1;
|
||||
//if (!(buffer[0] == 5 && buffer[1] == 2))
|
||||
if (buffer[0] != 5 || buffer[1] != 2)
|
||||
return 1;
|
||||
|
||||
/* authentication as in RFC 1929 */
|
||||
username_len = strlen(cfg_proxy_username);
|
||||
password_len = strlen(cfg_proxy_password);
|
||||
/* authentication as in RFC 1929 */
|
||||
username_len = strlen(cfg_proxy_username);
|
||||
password_len = strlen(cfg_proxy_password);
|
||||
|
||||
/* make username/password buffer */
|
||||
buffer[0] = 1;
|
||||
buffer[1] = (unsigned char) username_len;
|
||||
memcpy(buffer + 2, cfg_proxy_username, username_len);
|
||||
buffer[2 + username_len] = (unsigned char) password_len;
|
||||
memcpy(buffer + 3 + username_len, cfg_proxy_password, password_len);
|
||||
/* make username/password buffer */
|
||||
buffer[0] = 1;
|
||||
buffer[1] = (unsigned char) username_len;
|
||||
memcpy(buffer + 2, cfg_proxy_username, username_len);
|
||||
buffer[2 + username_len] = (unsigned char) password_len;
|
||||
memcpy(buffer + 3 + username_len, cfg_proxy_password, password_len);
|
||||
|
||||
send (sock, buffer, 3 + username_len + password_len, 0);
|
||||
send (sock, buffer, 3 + username_len + password_len, 0);
|
||||
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 1;
|
||||
|
||||
/* buffer[1] = auth state, must be 0 for success */
|
||||
if (buffer[1] != 0)
|
||||
return 1;
|
||||
/* buffer[1] = auth state, must be 0 for success */
|
||||
if (buffer[1] != 0)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* without authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 0 => no authentication
|
||||
*/
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
/* without authentication */
|
||||
/* -> socks server must respond with :
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 0 => no authentication
|
||||
*/
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
addr_buffer = (unsigned char *) malloc ( addr_buffer_len * sizeof(*addr_buffer));
|
||||
if (!addr_buffer)
|
||||
return 1;
|
||||
addr_buffer[0] = 5; /* version 5 */
|
||||
addr_buffer[1] = 1; /* command: 1 for connect */
|
||||
addr_buffer[2] = 0; /* reserved */
|
||||
addr_buffer[3] = 3; /* address type : ipv4 (1), domainname (3), ipv6 (4) */
|
||||
addr_buffer[4] = (unsigned char) addr_len;
|
||||
memcpy (addr_buffer + 5, address, addr_len); /* server address */
|
||||
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
|
||||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
addr_buffer = (unsigned char *) malloc ( addr_buffer_len * sizeof(*addr_buffer));
|
||||
if (!addr_buffer)
|
||||
return 1;
|
||||
addr_buffer[0] = 5; /* version 5 */
|
||||
addr_buffer[1] = 1; /* command: 1 for connect */
|
||||
addr_buffer[2] = 0; /* reserved */
|
||||
addr_buffer[3] = 3; /* address type : ipv4 (1), domainname (3), ipv6 (4) */
|
||||
addr_buffer[4] = (unsigned char) addr_len;
|
||||
memcpy (addr_buffer + 5, address, addr_len); /* server address */
|
||||
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
|
||||
|
||||
send (sock, addr_buffer, addr_buffer_len, 0);
|
||||
free(addr_buffer);
|
||||
send (sock, addr_buffer, addr_buffer_len, 0);
|
||||
free(addr_buffer);
|
||||
|
||||
/* dialog with proxy server */
|
||||
if (recv (sock, buffer, 4, 0) != 4)
|
||||
return 1;
|
||||
/* dialog with proxy server */
|
||||
if (recv (sock, buffer, 4, 0) != 4)
|
||||
return 1;
|
||||
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
if (!(buffer[0] == 5 && buffer[1] == 0))
|
||||
return 1;
|
||||
|
||||
switch(buffer[3]) {
|
||||
/* buffer[3] = address type */
|
||||
case 1 :
|
||||
/* ipv4
|
||||
* server socks return server bound address and port
|
||||
* address of 4 bytes and port of 2 bytes (= 6 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 6, 0) != 6)
|
||||
return 1;
|
||||
break;
|
||||
case 3:
|
||||
/* domainname
|
||||
* server socks return server bound address and port
|
||||
*/
|
||||
/* reading address length */
|
||||
if (recv (sock, buffer, 1, 0) != 1)
|
||||
return 1;
|
||||
addr_len = buffer[0];
|
||||
/* reading address + port = addr_len + 2 */
|
||||
if (recv (sock, buffer, addr_len + 2, 0) != (addr_len + 2))
|
||||
return 1;
|
||||
break;
|
||||
case 4 :
|
||||
/* ipv6
|
||||
* server socks return server bound address and port
|
||||
* address of 16 bytes and port of 2 bytes (= 18 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 18, 0) != 18)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
switch(buffer[3]) {
|
||||
/* buffer[3] = address type */
|
||||
case 1 :
|
||||
/* ipv4
|
||||
* server socks return server bound address and port
|
||||
* address of 4 bytes and port of 2 bytes (= 6 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 6, 0) != 6)
|
||||
return 1;
|
||||
break;
|
||||
case 3:
|
||||
/* domainname
|
||||
* server socks return server bound address and port
|
||||
*/
|
||||
/* reading address length */
|
||||
if (recv (sock, buffer, 1, 0) != 1)
|
||||
return 1;
|
||||
addr_len = buffer[0];
|
||||
/* reading address + port = addr_len + 2 */
|
||||
if (recv (sock, buffer, addr_len + 2, 0) != (addr_len + 2))
|
||||
return 1;
|
||||
break;
|
||||
case 4 :
|
||||
/* ipv6
|
||||
* server socks return server bound address and port
|
||||
* address of 16 bytes and port of 2 bytes (= 18 bytes)
|
||||
*/
|
||||
if (recv (sock, buffer, 18, 0) != 18)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* pass_proxy: establish connection/authentification to a proxy
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
* return :
|
||||
* - 0 if connexion throw proxy was successful
|
||||
* - 1 if connexion fails
|
||||
*/
|
||||
|
||||
int
|
||||
pass_proxy(int sock, char *address, int port, char *username)
|
||||
{
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
|
||||
return pass_httpproxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
|
||||
return pass_socks4proxy(sock, address, port, username);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
|
||||
return pass_socks5proxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
|
||||
return pass_httpproxy(sock, address, port);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
|
||||
return pass_socks4proxy(sock, address, port, username);
|
||||
if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
|
||||
return pass_socks5proxy(sock, address, port);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1586,6 +1590,9 @@ server_search (char *servername)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (!servername)
|
||||
return NULL;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -1624,6 +1631,9 @@ server_name_already_exists (char *name)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (strcmp (ptr_server->name, name) == 0)
|
||||
|
||||
+91
-54
@@ -203,7 +203,7 @@ struct t_irc_command
|
||||
/* function called when user enters cmd */
|
||||
int (*cmd_function_1arg)(t_irc_server *, char *);
|
||||
/* function called when user enters cmd */
|
||||
int (*recv_function)(t_irc_server *, char *, char *);
|
||||
int (*recv_function)(t_irc_server *, char *, char *, char *);
|
||||
/* function called when cmd is received */
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ struct t_irc_message
|
||||
t_irc_message *next_message; /* link to next message */
|
||||
};
|
||||
|
||||
/* DCC */
|
||||
/* DCC types */
|
||||
|
||||
typedef struct t_irc_dcc t_irc_dcc;
|
||||
|
||||
@@ -251,6 +251,30 @@ struct t_irc_dcc
|
||||
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 IGNORE_ACTION "action"
|
||||
#define IGNORE_CTCP "ctcp"
|
||||
#define IGNORE_DCC "dcc"
|
||||
#define 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;
|
||||
extern t_irc_message *recv_msgq, *msgq_last_msg;
|
||||
@@ -258,6 +282,9 @@ extern int check_away;
|
||||
extern t_irc_dcc *dcc_list;
|
||||
extern char *dcc_status_string[6];
|
||||
extern char *channel_modes;
|
||||
extern char *ignore_types[];
|
||||
extern t_irc_ignore *irc_ignore;
|
||||
extern t_irc_ignore *irc_last_ignore;
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
@@ -414,57 +441,67 @@ extern int irc_cmd_send_who (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_whois (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_whowas (t_irc_server *, char *);
|
||||
/* IRC commands executed when received from server */
|
||||
extern int irc_cmd_recv_error (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_invite (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_join (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_kick (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_kill (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_mode (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_nick (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_notice (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_part (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_ping (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_pong (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_privmsg (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_quit (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_server_msg (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_server_reply (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_topic (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_001 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_004 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_301 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_302 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_303 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_305 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_306 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_307 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_311 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_312 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_313 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_314 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_315 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_317 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_318 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_319 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_320 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_321 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_341 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_351 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_352 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_353 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_365 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_366 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_367 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_368 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_433 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_438 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_671 (t_irc_server *, char *, char *);
|
||||
extern int irc_cmd_recv_error (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_invite (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_join (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_kick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_kill (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_mode (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_nick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_notice (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_part (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_ping (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_pong (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_privmsg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_quit (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_server_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_server_reply (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_topic (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_001 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_004 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_301 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_302 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_303 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_305 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_306 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_307 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_311 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_312 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_313 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_314 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_315 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_317 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_318 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_319 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_320 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_321 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_341 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_351 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_352 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_353 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_365 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_366 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_367 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_368 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_433 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_438 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_cmd_recv_671 (t_irc_server *, char *, char *, char *);
|
||||
|
||||
/* ignore functions (irc-ignore.c) */
|
||||
|
||||
extern int ignore_check (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *ignore_add (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *ignore_add_from_config (char *);
|
||||
extern void ignore_free_all ();
|
||||
extern int ignore_search_free (char *, char *, char *, char *);
|
||||
extern int ignore_search_free_by_number (int);
|
||||
extern void ignore_print_log ();
|
||||
|
||||
#endif /* irc.h */
|
||||
|
||||
Reference in New Issue
Block a user