summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-12-07 13:12:46 +0100
committerSebastien Helleu <flashcode@flashtux.org>2007-12-07 13:12:46 +0100
commit495e6bd5df9163148676821d610c9ef863326f70 (patch)
tree024adc4a159a888e779dd92520f38b22c1d08ec4 /src/plugins
parent3c8276bc5752a607f3a16e1a4a683b5f73b3db37 (diff)
downloadweechat-495e6bd5df9163148676821d610c9ef863326f70.zip
Many changes in IRC plugin and plugins API
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt15
-rw-r--r--src/plugins/Makefile.am4
-rw-r--r--src/plugins/alias/alias.c154
-rw-r--r--src/plugins/alias/alias.h4
-rw-r--r--src/plugins/aspell/aspell.c53
-rw-r--r--src/plugins/aspell/aspell.h10
-rw-r--r--src/plugins/charset/CMakeLists.txt2
-rw-r--r--src/plugins/charset/Makefile.am2
-rw-r--r--src/plugins/charset/charset.c40
-rw-r--r--src/plugins/demo/CMakeLists.txt2
-rw-r--r--src/plugins/demo/Makefile.am2
-rw-r--r--src/plugins/demo/demo.c80
-rw-r--r--src/plugins/fifo/CMakeLists.txt2
-rw-r--r--src/plugins/fifo/Makefile.am2
-rw-r--r--src/plugins/fifo/fifo.c27
-rw-r--r--src/plugins/fifo/fifo.h27
-rw-r--r--src/plugins/irc/CMakeLists.txt11
-rw-r--r--src/plugins/irc/Makefile.am36
-rw-r--r--src/plugins/irc/irc-buffer.h7
-rw-r--r--src/plugins/irc/irc-channel.c250
-rw-r--r--src/plugins/irc/irc-channel.h22
-rw-r--r--src/plugins/irc/irc-color.h4
-rw-r--r--src/plugins/irc/irc-command.c1071
-rw-r--r--src/plugins/irc/irc-command.h66
-rw-r--r--src/plugins/irc/irc-config.c1219
-rw-r--r--src/plugins/irc/irc-config.h100
-rw-r--r--src/plugins/irc/irc-dcc.c174
-rw-r--r--src/plugins/irc/irc-dcc.h21
-rw-r--r--src/plugins/irc/irc-display.h (renamed from src/plugins/charset/charset.h)21
-rw-r--r--src/plugins/irc/irc-mode.h (renamed from src/plugins/demo/demo.h)13
-rw-r--r--src/plugins/irc/irc-nick.c83
-rw-r--r--src/plugins/irc/irc-nick.h17
-rw-r--r--src/plugins/irc/irc-protocol.c220
-rw-r--r--src/plugins/irc/irc-protocol.h69
-rw-r--r--src/plugins/irc/irc-server.c933
-rw-r--r--src/plugins/irc/irc-server.h47
-rw-r--r--src/plugins/irc/irc.c98
-rw-r--r--src/plugins/irc/irc.h295
-rw-r--r--src/plugins/logger/CMakeLists.txt2
-rw-r--r--src/plugins/logger/logger.c51
-rw-r--r--src/plugins/plugin-api.c658
-rw-r--r--src/plugins/plugin-api.h71
-rw-r--r--src/plugins/plugin-config.c25
-rw-r--r--src/plugins/plugin-infolist.c (renamed from src/plugins/plugin-list.c)298
-rw-r--r--src/plugins/plugin-infolist.h89
-rw-r--r--src/plugins/plugin-list.h89
-rw-r--r--src/plugins/plugin.c66
-rw-r--r--src/plugins/weechat-plugin.h165
48 files changed, 3753 insertions, 2964 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 71364ec9f..ca109d6fc 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -15,7 +15,8 @@
#
SET(LIB_PLUGINS_SRC weechat-plugin.h plugin.c plugin.h plugin-api.c
-plugin-api.h plugin-config.h plugin-config.c plugin-list.c plugin-list.h)
+plugin-api.h plugin-config.h plugin-config.c plugin-infolist.c
+plugin-infolist.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_LIBRARY(weechat_plugins STATIC ${LIB_PLUGINS_SRC})
@@ -47,6 +48,10 @@ IF(NOT DISABLE_CHARSET)
ENDIF(ICONV_FOUND)
ENDIF(NOT DISABLE_CHARSET)
+IF(ENABLE_DEMO)
+ ADD_SUBDIRECTORY( demo )
+ENDIF(ENABLE_DEMO)
+
IF(NOT DISABLE_FIFO)
ADD_SUBDIRECTORY( fifo )
ENDIF(NOT DISABLE_FIFO)
@@ -59,10 +64,6 @@ IF(NOT DISABLE_TRIGGER)
ADD_SUBDIRECTORY( trigger )
ENDIF(NOT DISABLE_TRIGGER)
-IF(NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
+IF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
ADD_SUBDIRECTORY( scripts )
-ENDIF(NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
-
-IF(ENABLE_DEMO)
- ADD_SUBDIRECTORY( demo )
-ENDIF(ENABLE_TRIGGER)
+ENDIF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index b5854a35b..63cd6560f 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -25,8 +25,8 @@ lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
plugin-api.h \
plugin-config.c \
plugin-config.h \
- plugin-list.c \
- plugin-list.h
+ plugin-infolist.c \
+ plugin-infolist.h
if PLUGIN_IRC
irc_dir = irc
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 22d7c8277..cee9e7b22 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -30,21 +30,26 @@
#include "alias.h"
-static struct t_weechat_plugin *weechat_plugin = NULL;
+char plugin_name[] = "alias";
+char plugin_version[] = "0.1";
+char plugin_description[] = "Alias plugin for WeeChat";
-static struct t_config_file *alias_config_file = NULL;
-static struct t_alias *alias_list = NULL;
-static struct t_alias *last_alias = NULL;
-static struct t_hook *alias_command = NULL;
-static struct t_hook *unalias_command = NULL;
-static struct t_hook *config_reload = NULL;
+struct t_weechat_plugin *weechat_alias_plugin = NULL;
+#define weechat_plugin weechat_alias_plugin
+
+struct t_config_file *alias_config_file = NULL;
+struct t_alias *alias_list = NULL;
+struct t_alias *last_alias = NULL;
+struct t_hook *alias_command = NULL;
+struct t_hook *unalias_command = NULL;
+struct t_hook *config_reload = NULL;
/*
* alias_search: search an alias
*/
-static struct t_alias *
+struct t_alias *
alias_search (char *alias_name)
{
struct t_alias *ptr_alias;
@@ -63,7 +68,7 @@ alias_search (char *alias_name)
* This function should NOT be called directly.
*/
-static void
+void
alias_add_word (char **alias, int *length, char *word)
{
int length_word;
@@ -92,7 +97,7 @@ alias_add_word (char **alias, int *length, char *word)
* alias_replace_args: replace arguments ($1, $2, .. or $*) in alias arguments
*/
-static char *
+char *
alias_replace_args (char *alias_args, char *user_args)
{
char **argv, *start, *pos, *res;
@@ -171,7 +176,7 @@ alias_replace_args (char *alias_args, char *user_args)
* alias_cb: callback for alias (called when user uses an alias)
*/
-static int
+int
alias_cb (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
@@ -282,7 +287,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
* alias_new: create new alias and add it to alias list
*/
-static struct t_alias *
+struct t_alias *
alias_new (char *name, char *command)
{
struct t_alias *new_alias, *ptr_alias;
@@ -338,7 +343,7 @@ alias_new (char *name, char *command)
* alias_get_final_command: get final command pointed by an alias
*/
-static char *
+char *
alias_get_final_command (struct t_alias *alias)
{
struct t_alias *ptr_alias;
@@ -371,7 +376,7 @@ alias_get_final_command (struct t_alias *alias)
* alias_free: free an alias and reomve it from list
*/
-static void
+void
alias_free (struct t_alias *alias)
{
struct t_alias *new_alias_list;
@@ -405,7 +410,7 @@ alias_free (struct t_alias *alias)
* alias_free_all: free all alias
*/
-static void
+void
alias_free_all ()
{
while (alias_list)
@@ -421,14 +426,17 @@ alias_config_read_line (void *config_file, char *option_name, char *value)
{
/* make C compiler happy */
(void) config_file;
-
- /* create new alias */
- if (!alias_new (option_name, value))
+
+ if (option_name && value)
{
- weechat_printf (NULL,
- "%sAlias: error creating alias \"%s\" => \"%s\"",
- weechat_prefix ("error"),
- option_name, value);
+ /* create new alias */
+ if (!alias_new (option_name, value))
+ {
+ weechat_printf (NULL,
+ "%sAlias: error creating alias \"%s\" => \"%s\"",
+ weechat_prefix ("error"),
+ option_name, value);
+ }
}
}
@@ -439,25 +447,19 @@ alias_config_read_line (void *config_file, char *option_name, char *value)
*/
void
-alias_config_write_section (void *config_file)
+alias_config_write_section (void *config_file, char *section_name)
{
struct t_alias *ptr_alias;
- char *string;
+
+ weechat_config_write_line (config_file, section_name, NULL);
for (ptr_alias = alias_list; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
- string = (char *)malloc (strlen (ptr_alias->command) + 4);
- if (string)
- {
- strcpy (string, "\"");
- strcat (string, ptr_alias->command);
- strcat (string, "\"");
- weechat_config_write_line (config_file,
- ptr_alias->name,
- string);
- free (string);
- }
+ weechat_config_write_line (config_file,
+ ptr_alias->name,
+ "\"%s\"",
+ ptr_alias->command);
}
}
@@ -466,62 +468,68 @@ alias_config_write_section (void *config_file)
*/
void
-alias_config_write_default_aliases (void *config_file)
+alias_config_write_default_aliases (void *config_file, char *section_name)
{
- weechat_config_write_line (config_file, "SAY", "\"msg *\"");
- weechat_config_write_line (config_file, "BYE", "\"quit\"");
- weechat_config_write_line (config_file, "EXIT", "\"quit\"");
- weechat_config_write_line (config_file, "SIGNOFF", "\"quit\"");
- weechat_config_write_line (config_file, "C", "\"clear\"");
- weechat_config_write_line (config_file, "CL", "\"clear\"");
- weechat_config_write_line (config_file, "CLOSE", "\"buffer close\"");
- weechat_config_write_line (config_file, "CHAT", "\"dcc chat\"");
- weechat_config_write_line (config_file, "IG", "\"ignore\"");
- weechat_config_write_line (config_file, "J", "\"join\"");
- weechat_config_write_line (config_file, "K", "\"kick\"");
- weechat_config_write_line (config_file, "KB", "\"kickban\"");
- weechat_config_write_line (config_file, "LEAVE", "\"part\"");
- weechat_config_write_line (config_file, "M", "\"msg\"");
- weechat_config_write_line (config_file, "MUB", "\"unban *\"");
- weechat_config_write_line (config_file, "N", "\"names\"");
- weechat_config_write_line (config_file, "Q", "\"query\"");
- weechat_config_write_line (config_file, "T", "\"topic\"");
- weechat_config_write_line (config_file, "UB", "\"unban\"");
- weechat_config_write_line (config_file, "UNIG", "\"unignore\"");
- weechat_config_write_line (config_file, "W", "\"who\"");
- weechat_config_write_line (config_file, "WC", "\"window merge\"");
- weechat_config_write_line (config_file, "WI", "\"whois\"");
- weechat_config_write_line (config_file, "WW", "\"whowas\"");
+ weechat_config_write_line (config_file, section_name, NULL);
+
+ weechat_config_write_line (config_file, "SAY", "%s", "\"msg *\"");
+ weechat_config_write_line (config_file, "BYE", "%s", "\"quit\"");
+ weechat_config_write_line (config_file, "EXIT", "%s", "\"quit\"");
+ weechat_config_write_line (config_file, "SIGNOFF", "%s", "\"quit\"");
+ weechat_config_write_line (config_file, "C", "%s", "\"clear\"");
+ weechat_config_write_line (config_file, "CL", "%s", "\"clear\"");
+ weechat_config_write_line (config_file, "CLOSE", "%s", "\"buffer close\"");
+ weechat_config_write_line (config_file, "CHAT", "%s", "\"dcc chat\"");
+ weechat_config_write_line (config_file, "IG", "%s", "\"ignore\"");
+ weechat_config_write_line (config_file, "J", "%s", "\"join\"");
+ weechat_config_write_line (config_file, "K", "%s", "\"kick\"");
+ weechat_config_write_line (config_file, "KB", "%s", "\"kickban\"");
+ weechat_config_write_line (config_file, "LEAVE", "%s", "\"part\"");
+ weechat_config_write_line (config_file, "M", "%s", "\"msg\"");
+ weechat_config_write_line (config_file, "MUB", "%s", "\"unban *\"");
+ weechat_config_write_line (config_file, "N", "%s", "\"names\"");
+ weechat_config_write_line (config_file, "Q", "%s", "\"query\"");
+ weechat_config_write_line (config_file, "T", "%s", "\"topic\"");
+ weechat_config_write_line (config_file, "UB", "%s", "\"unban\"");
+ weechat_config_write_line (config_file, "UNIG", "%s", "\"unignore\"");
+ weechat_config_write_line (config_file, "W", "%s", "\"who\"");
+ weechat_config_write_line (config_file, "WC", "%s", "\"window merge\"");
+ weechat_config_write_line (config_file, "WI", "%s", "\"whois\"");
+ weechat_config_write_line (config_file, "WW", "%s", "\"whowas\"");
}
/*
* alias_config_init: init alias configuration file
+ * return: 1 if ok, 0 if error
*/
-static int
+int
alias_config_init ()
{
struct t_config_section *ptr_section;
alias_config_file = weechat_config_new (ALIAS_CONFIG_FILENAME);
- if (alias_config_file)
+ if (!alias_config_file)
+ return 0;
+
+ ptr_section = weechat_config_new_section (alias_config_file, "alias",
+ alias_config_read_line,
+ alias_config_write_section,
+ alias_config_write_default_aliases);
+ if (!ptr_section)
{
- ptr_section = weechat_config_new_section (alias_config_file, "alias",
- alias_config_read_line,
- alias_config_write_section,
- alias_config_write_default_aliases);
- if (ptr_section)
- return 1;
weechat_config_free (alias_config_file);
+ return 0;
}
- return 0;
+
+ return 1;
}
/*
* alias_config_read: read alias configuration file
*/
-static int
+int
alias_config_read ()
{
return weechat_config_read (alias_config_file);
@@ -531,7 +539,7 @@ alias_config_read ()
* alias_config_reaload_event_cb: reload alias configuration file
*/
-static int
+int
alias_config_reload_event_cb (void *data, char *event, void *pointer)
{
/* make C compiler happy */
@@ -558,7 +566,7 @@ alias_config_reload_event_cb (void *data, char *event, void *pointer)
* alias_config_write: write alias configuration file
*/
-static int
+int
alias_config_write ()
{
return weechat_config_write (alias_config_file);
@@ -568,7 +576,7 @@ alias_config_write ()
* alias_command_cb: display or create alias
*/
-static int
+int
alias_command_cb (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
diff --git a/src/plugins/alias/alias.h b/src/plugins/alias/alias.h
index 1ad13bd3b..bc0206525 100644
--- a/src/plugins/alias/alias.h
+++ b/src/plugins/alias/alias.h
@@ -20,10 +20,6 @@
#ifndef __WEECHAT_ALIAS_H
#define __WEECHAT_ALIAS_H 1
-char plugin_name[] = "alias";
-char plugin_version[] = "0.1";
-char plugin_description[] = "Alias plugin for WeeChat";
-
#define ALIAS_CONFIG_FILENAME "alias.rc"
struct t_alias
diff --git a/src/plugins/aspell/aspell.c b/src/plugins/aspell/aspell.c
index 0e57cb30e..9e771423c 100644
--- a/src/plugins/aspell/aspell.c
+++ b/src/plugins/aspell/aspell.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* weechat-aspell.c: Aspell plugin support for WeeChat */
+/* aspell.c: Aspell plugin support for WeeChat */
#include <stdio.h>
#include <stdlib.h>
@@ -25,17 +25,24 @@
#include <ctype.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
+#include "aspell.h"
+
+char plugin_name[] = "aspell";
+char plugin_version[] = "0.1";
+char plugin_description[] = "Aspell plugin for WeeChat";
+
+struct t_weechat_plugin *weechat_aspell_plugin = NULL;
+#define weechat_plugin weechat_aspell_plugin
aspell_speller_t *aspell_plugin_speller = NULL;
aspell_config_t *aspell_plugin_config = NULL;
aspell_options_t aspell_plugin_options;
-t_weechat_plugin *weechat_aspell_plugin = NULL;
/*
* weechat_aspell_new_speller : create a new speller cell
*/
+
aspell_speller_t *
weechat_aspell_new_speller (void)
{
@@ -61,6 +68,7 @@ weechat_aspell_new_speller (void)
/*
* weechat_aspell_free_speller : free a speller cell
*/
+
void
weechat_aspell_free_speller (aspell_speller_t *s)
{
@@ -80,6 +88,7 @@ weechat_aspell_free_speller (aspell_speller_t *s)
/*
* weechat_aspell_speller_list_search : search a speller cell
*/
+
aspell_speller_t *
weechat_aspell_speller_list_search (char *lang)
{
@@ -100,6 +109,7 @@ weechat_aspell_speller_list_search (char *lang)
/*
* weechat_aspell_speller_list_add : create and add a new speller instance
*/
+
int
weechat_aspell_speller_list_add (char *lang)
{
@@ -145,6 +155,7 @@ weechat_aspell_speller_list_add (char *lang)
/*
* weechat_aspell_speller_list_remove : remove a speller instance
*/
+
int
weechat_aspell_speller_list_remove(char *lang)
{
@@ -186,6 +197,7 @@ weechat_aspell_speller_list_remove(char *lang)
/*
* weechat_aspell_new_config : create a new config cell
*/
+
aspell_config_t *
weechat_aspell_new_config (void)
{
@@ -211,6 +223,7 @@ weechat_aspell_new_config (void)
/*
* weechat_aspell_free_config : free a config cell
*/
+
void
weechat_aspell_free_config (aspell_config_t *c)
{
@@ -228,6 +241,7 @@ weechat_aspell_free_config (aspell_config_t *c)
/*
* weechat_aspell_config_list_search : search a config cell
*/
+
aspell_config_t *
weechat_aspell_config_list_search (char *server, char *channel)
{
@@ -252,7 +266,8 @@ weechat_aspell_config_list_search (char *server, char *channel)
/*
* weechat_aspell_config_list_add : create and add a new config
*/
-int
+
+int
weechat_aspell_config_list_add (char *server, char *channel)
{
aspell_config_t *c;
@@ -275,6 +290,7 @@ weechat_aspell_config_list_add (char *server, char *channel)
/*
* weechat_aspell_config_list_remove : remove a speller config
*/
+
int
weechat_aspell_config_list_remove(char *server, char *channel)
{
@@ -319,6 +335,7 @@ weechat_aspell_config_list_remove(char *server, char *channel)
* in its english full name
*
*/
+
char *
weechat_aspell_iso_to_lang (char *code)
{
@@ -348,6 +365,7 @@ weechat_aspell_iso_to_lang (char *code)
* convert an aspell iso country
* code in its english full name
*/
+
char *
weechat_aspell_iso_to_country (char *code)
{
@@ -376,6 +394,7 @@ weechat_aspell_iso_to_country (char *code)
* return 1 if an aspell dict exists
* for a lang, 0 otherwise
*/
+
int
weechat_aspell_speller_exists (char *lang)
{
@@ -410,6 +429,7 @@ weechat_aspell_speller_exists (char *lang)
* weechat_aspell_speller_list_dicts :
* list all aspell dict installed on system and display them
*/
+
void
weechat_aspell_speller_list_dicts (void)
{
@@ -472,6 +492,7 @@ weechat_aspell_speller_list_dicts (void)
/*
* weechat_aspell_config_show : display plugin settings
*/
+
void
weechat_aspell_config_show (void)
{
@@ -510,6 +531,7 @@ weechat_aspell_config_show (void)
/*
* weechat_aspell_config_addword : adding a word in personnal dictionaries
*/
+
int
weechat_aspell_config_addword(char *word)
{
@@ -551,6 +573,7 @@ weechat_aspell_config_addword(char *word)
/*
* weechat_aspell_config_dump : display debug infos
*/
+
void
weechat_aspell_config_dump (void)
{
@@ -581,6 +604,7 @@ weechat_aspell_config_dump (void)
/*
* weechat_aspell_config_enable_for : internal subroutine
*/
+
void
weechat_aspell_config_enable_for (char *server, char *channel, char *lang)
{
@@ -629,6 +653,7 @@ weechat_aspell_config_enable_for (char *server, char *channel, char *lang)
* weechat_aspell_config_enable :
* enabling given lang spell checking on current server/channel
*/
+
void
weechat_aspell_config_enable (char *lang)
{
@@ -661,6 +686,7 @@ weechat_aspell_config_enable (char *lang)
* weechat_aspell_config_disable :
* disabling spell checking on current server/channel
*/
+
void
weechat_aspell_config_disable (void)
{
@@ -710,6 +736,7 @@ weechat_aspell_config_disable (void)
/*
* weechat_aspell_config_set : setting options values
*/
+
int
weechat_aspell_config_set(char *option, char *value)
{
@@ -760,6 +787,7 @@ weechat_aspell_config_set(char *option, char *value)
/*
* weechat_aspell_config_save : saving plugin config
*/
+
int
weechat_aspell_config_save (void)
{
@@ -851,6 +879,7 @@ weechat_aspell_config_save (void)
/*
* weechat_aspell_config_load : loading plugin config
*/
+
int
weechat_aspell_config_load(void)
{
@@ -910,6 +939,7 @@ weechat_aspell_config_load(void)
/*
* weechat_aspell_options_save : saving plugin options
*/
+
int
weechat_aspell_options_save(void)
{
@@ -930,6 +960,7 @@ weechat_aspell_options_save(void)
/*
* weechat_aspell_options_load : loading plugin options
*/
+
int
weechat_aspell_options_load(void)
{
@@ -985,6 +1016,7 @@ weechat_aspell_options_load(void)
/*
* weechat_aspell_speller_command : manage "/aspell" uses
*/
+
int
weechat_aspell_speller_command (t_weechat_plugin *p,
int argc, char **argv,
@@ -1072,6 +1104,7 @@ weechat_aspell_speller_command (t_weechat_plugin *p,
* weechat_aspell_nick_in_server_channel :
* check presence of a nick in a server/channel
*/
+
int
weechat_aspell_nick_in_channel (char *nick, char *server, char *channel)
{
@@ -1104,6 +1137,7 @@ weechat_aspell_nick_in_channel (char *nick, char *server, char *channel)
* weechat_aspell_clean_word :
* strip punct chars at the begining and at the end of a word
*/
+
char *
weechat_aspell_clean_word (char *word, int *offset)
{
@@ -1156,6 +1190,7 @@ weechat_aspell_clean_word (char *word, int *offset)
* weechat_aspell_is_simili_number :
* detect if a word is made of chars and punctation
*/
+
int
weechat_aspell_is_simili_number (char *word)
{
@@ -1183,6 +1218,7 @@ weechat_aspell_is_simili_number (char *word)
* weechat_aspell_is_url :
* detect if a word is an url
*/
+
int
weechat_aspell_is_url (char *word)
{
@@ -1215,6 +1251,7 @@ weechat_aspell_is_url (char *word)
/*
* weechat_aspell_keyb_check : handler to check spelling on input line
*/
+
int
weechat_aspell_keyb_check (t_weechat_plugin *p, int argc, char **argv,
char *handler_args, void *handler_pointer)
@@ -1332,7 +1369,9 @@ weechat_aspell_keyb_check (t_weechat_plugin *p, int argc, char **argv,
/*
* weechat_plugin_init : init function, called when plugin is loaded
*/
-int weechat_plugin_init (t_weechat_plugin *plugin)
+
+int
+weechat_plugin_init (t_weechat_plugin *plugin)
{
char help[1024];
aspell_plugin_speller = NULL;
@@ -1375,7 +1414,9 @@ int weechat_plugin_init (t_weechat_plugin *plugin)
/*
* weechat_plugin_end : end function, called when plugin is unloaded
*/
-void weechat_plugin_end (t_weechat_plugin *p)
+
+void
+weechat_plugin_end (t_weechat_plugin *p)
{
aspell_speller_t *s, *t;
aspell_config_t *c, *d;
diff --git a/src/plugins/aspell/aspell.h b/src/plugins/aspell/aspell.h
index f17857d1b..e83804c56 100644
--- a/src/plugins/aspell/aspell.h
+++ b/src/plugins/aspell/aspell.h
@@ -23,16 +23,6 @@
#include <aspell.h>
-#define _PLUGIN_NAME "Aspell"
-#define _PLUGIN_VERSION "0.1"
-#define _PLUGIN_DESC "Aspell plugin for WeeChat"
-#define _PLUGIN_COMMAND "aspell"
-
-char plugin_name[] = _PLUGIN_NAME;
-char plugin_version[] = _PLUGIN_VERSION;
-char plugin_description[] = _PLUGIN_DESC;
-char plugin_command[] = _PLUGIN_COMMAND;
-
#define _PLUGIN_OPTION_WORD_SIZE 2
#define _PLUGIN_OPTION_CHECK_SYNC 0
#define _PLUGIN_OPTION_COLOR "red"
diff --git a/src/plugins/charset/CMakeLists.txt b/src/plugins/charset/CMakeLists.txt
index cf5f1da74..40501e1da 100644
--- a/src/plugins/charset/CMakeLists.txt
+++ b/src/plugins/charset/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(charset MODULE charset.c charset.h)
+ADD_LIBRARY(charset MODULE charset.c)
SET_TARGET_PROPERTIES(charset PROPERTIES PREFIX "")
IF(ICONV_FOUND)
diff --git a/src/plugins/charset/Makefile.am b/src/plugins/charset/Makefile.am
index fe7fd8b12..8f1476832 100644
--- a/src/plugins/charset/Makefile.am
+++ b/src/plugins/charset/Makefile.am
@@ -20,6 +20,6 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = charset.la
-charset_la_SOURCES = charset.c charset.h
+charset_la_SOURCES = charset.c
charset_la_LDFLAGS = -module
charset_la_LIBADD = $(CHARSET_LFLAGS)
diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c
index b24a4bc82..aa5dc1a0e 100644
--- a/src/plugins/charset/charset.c
+++ b/src/plugins/charset/charset.c
@@ -26,14 +26,20 @@
#include <iconv.h>
#include "../weechat-plugin.h"
-#include "charset.h"
-static char *weechat_charset_terminal = NULL;
-static char *weechat_charset_internal = NULL;
+char plugin_name[] = "charset";
+char plugin_version[] = "0.1";
+char plugin_description[] = "Charset plugin for WeeChat";
+
+struct t_weechat_plugin *weechat_charset_plugin = NULL;
+#define weechat_plugin weechat_charset_plugin
+
+char *weechat_charset_terminal = NULL;
+char *weechat_charset_internal = NULL;
/* set to 1 by /charset debug (hidden option) */
-static int weechat_charset_debug = 0;
+int weechat_charset_debug = 0;
/*
@@ -41,7 +47,7 @@ static int weechat_charset_debug = 0;
* (FreeBSD and maybe other)
*/
-static char *
+char *
weechat_charset_strndup (char *string, int length)
{
char *result;
@@ -63,7 +69,7 @@ weechat_charset_strndup (char *string, int length)
* weechat_charset_default_decode: set "global.decode" option if needed
*/
-static void
+void
weechat_charset_default_decode (t_weechat_plugin *plugin)
{
char *global_decode;
@@ -106,7 +112,7 @@ weechat_charset_default_decode (t_weechat_plugin *plugin)
* if a charset is NULL, internal charset is used
*/
-static int
+int
weechat_charset_check (char *charset)
{
iconv_t cd;
@@ -127,7 +133,7 @@ weechat_charset_check (char *charset)
* we first in this order: channel, server, global
*/
-static char *
+char *
weechat_charset_get_config (t_weechat_plugin *plugin,
char *type, char *server, char *channel)
{
@@ -173,7 +179,7 @@ weechat_charset_get_config (t_weechat_plugin *plugin,
* weechat_charset_set_config: set a charset in config file
*/
-static void
+void
weechat_charset_set_config (t_weechat_plugin *plugin,
char *type, char *server, char *channel,
char *value)
@@ -196,7 +202,7 @@ weechat_charset_set_config (t_weechat_plugin *plugin,
* of arguments in IRC message
*/
-static void
+void
weechat_charset_parse_irc_msg (char *message, char **nick, char **command,
char **channel, char **pos_args)
{
@@ -292,7 +298,7 @@ weechat_charset_parse_irc_msg (char *message, char **nick, char **command,
* convert from any charset to WeeChat internal
*/
-static char *
+char *
weechat_charset_irc_in (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
@@ -341,7 +347,7 @@ weechat_charset_irc_in (t_weechat_plugin *plugin, int argc, char **argv,
* convert from WeeChat internal charset to other
*/
-static char *
+char *
weechat_charset_irc_out (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
@@ -389,7 +395,7 @@ weechat_charset_irc_out (t_weechat_plugin *plugin, int argc, char **argv,
* weechat_charset_display: display charsets (global/server/channel)
*/
-static void
+void
weechat_charset_display (t_weechat_plugin *plugin,
int display_on_server, char *server, char *channel)
{
@@ -479,7 +485,7 @@ weechat_charset_display (t_weechat_plugin *plugin,
* weechat_charset_cmd: /charset command
*/
-static int
+int
weechat_charset_cmd (t_weechat_plugin *plugin,
int cmd_argc, char **cmd_argv,
char *handler_args, void *handler_pointer)
@@ -602,12 +608,14 @@ weechat_charset_cmd (t_weechat_plugin *plugin,
* weechat_plugin_init: init charset plugin
*/
-static int
+int
weechat_plugin_init (t_weechat_plugin *plugin)
{
t_plugin_modifier *msg_irc_in, *msg_irc_out;
t_plugin_handler *cmd_handler;
+ weechat_plugin = plugin;
+
/* get terminal & internal charsets */
weechat_charset_terminal = plugin->get_info (plugin, "charset_terminal",
NULL);
@@ -662,7 +670,7 @@ weechat_plugin_init (t_weechat_plugin *plugin)
* weechat_plugin_end: end charset plugin
*/
-static void
+void
weechat_plugin_end (t_weechat_plugin *plugin)
{
/* make C compiler happy */
diff --git a/src/plugins/demo/CMakeLists.txt b/src/plugins/demo/CMakeLists.txt
index a8ed8da0a..bbeb32ddf 100644
--- a/src/plugins/demo/CMakeLists.txt
+++ b/src/plugins/demo/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(demo MODULE demo.c demo.h)
+ADD_LIBRARY(demo MODULE demo.c)
SET_TARGET_PROPERTIES(demo PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(demo)
diff --git a/src/plugins/demo/Makefile.am b/src/plugins/demo/Makefile.am
index 1947a77f8..b1eca3a6c 100644
--- a/src/plugins/demo/Makefile.am
+++ b/src/plugins/demo/Makefile.am
@@ -20,6 +20,6 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = demo.la
-demo_la_SOURCES = demo.c demo.h
+demo_la_SOURCES = demo.c
demo_la_LDFLAGS = -module
demo_la_LIBADD = $(DEMO_LFLAGS)
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index fb8b51eb9..907dcb431 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -33,17 +33,21 @@
#include <time.h>
#include "../weechat-plugin.h"
-#include "demo.h"
-static struct t_weechat_plugin *weechat_plugin = NULL;
+char plugin_name[] = "demo";
+char plugin_version[] = "0.1";
+char plugin_description[] = "Demo plugin for WeeChat";
+
+struct t_weechat_plugin *weechat_demo_plugin = NULL;
+#define weechat_plugin weechat_demo_plugin
/*
* demo_printf_command_cb: demo command for printf
*/
-static int
+int
demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
@@ -81,7 +85,7 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
* demo_buffer_input_data_cb: callback for input data on buffer
*/
-static void
+void
demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data)
{
weechat_printf (buffer, "buffer input_data_cb: data = '%s'", data);
@@ -91,7 +95,7 @@ demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data)
* demo_buffer_command_cb: demo command for creatig new buffer
*/
-static int
+int
demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
@@ -114,21 +118,21 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
}
/*
- * demo_print_list: display a list
+ * demo_infolist_print: display an infolist
*/
-static void
-demo_print_list (void *list, char *item_name)
+void
+demo_infolist_print (void *infolist, char *item_name)
{
char *fields, **argv;
int i, j, argc;
time_t date;
i = 1;
- while (weechat_list_next (list))
+ while (weechat_infolist_next (infolist))
{
weechat_printf (NULL, "--- %s #%d ---", item_name, i);
- fields = weechat_list_fields (list);
+ fields = weechat_infolist_fields (infolist);
if (fields)
{
argv = weechat_string_explode (fields, ",", 0, 0, &argc);
@@ -141,23 +145,23 @@ demo_print_list (void *list, char *item_name)
case 'i':
weechat_printf (NULL, " %s: %d",
argv[j] + 2,
- weechat_list_integer (list,
- argv[j] + 2));
+ weechat_infolist_integer (infolist,
+ argv[j] + 2));
break;
case 's':
weechat_printf (NULL, " %s: %s",
argv[j] + 2,
- weechat_list_string (list,
- argv[j] + 2));
+ weechat_infolist_string (infolist,
+ argv[j] + 2));
break;
case 'p':
weechat_printf (NULL, " %s: %X",
argv[j] + 2,
- weechat_list_pointer (list,
- argv[j] + 2));
+ weechat_infolist_pointer (infolist,
+ argv[j] + 2));
break;
case 't':
- date = weechat_list_time (list, argv[j] + 2);
+ date = weechat_infolist_time (infolist, argv[j] + 2);
weechat_printf (NULL, " %s: (%ld) %s",
argv[j] + 2,
date, ctime (&date));
@@ -174,14 +178,14 @@ demo_print_list (void *list, char *item_name)
}
/*
- * demo_list_command_cb: demo command for list
+ * demo_infolist_command_cb: demo command for list
*/
-static int
-demo_list_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+int
+demo_infolist_command_cb (void *data, void *buffer, int argc, char **argv,
+ char **argv_eol)
{
- struct t_plugin_list *list;
+ struct t_plugin_infolist *infolist;
/* make C compiler happy */
(void) data;
@@ -192,29 +196,29 @@ demo_list_command_cb (void *data, void *buffer, int argc, char **argv,
{
if (weechat_strcasecmp (argv[1], "buffer") == 0)
{
- list = weechat_list_get ("buffer", NULL);
- if (list)
+ infolist = weechat_infolist_get ("buffer", NULL);
+ if (infolist)
{
- demo_print_list (list, "buffer");
- weechat_list_free (list);
+ demo_infolist_print (infolist, "buffer");
+ weechat_infolist_free (infolist);
}
return PLUGIN_RC_SUCCESS;
}
if (weechat_strcasecmp (argv[1], "buffer_lines") == 0)
{
- list = weechat_list_get ("buffer_lines", NULL);
- if (list)
+ infolist = weechat_infolist_get ("buffer_lines", NULL);
+ if (infolist)
{
- demo_print_list (list, "buffer_line");
- weechat_list_free (list);
+ demo_infolist_print (infolist, "buffer_line");
+ weechat_infolist_free (infolist);
}
return PLUGIN_RC_SUCCESS;
}
}
weechat_printf (NULL,
- "Demo: missing argument for /demo_list command "
- "(try /help demo_list)");
+ "Demo: missing argument for /demo_infolist command "
+ "(try /help demo_infolist)");
return PLUGIN_RC_SUCCESS;
}
@@ -223,7 +227,7 @@ demo_list_command_cb (void *data, void *buffer, int argc, char **argv,
* demo_info_command_cb: demo command for info_get
*/
-static int
+int
demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
@@ -249,7 +253,7 @@ demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
* demo_event_cb: callback for event hook
*/
-static int
+int
demo_event_cb (void *data, char *event, void *pointer)
{
/* make C compiler happy */
@@ -280,12 +284,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
"",
demo_buffer_command_cb, NULL);
- weechat_hook_command ("demo_list", "demo command: get and display list",
- "list",
- "list: list to display (values: buffer, "
+ weechat_hook_command ("demo_infolist", "demo command: get and display list",
+ "infolist",
+ "infolist: infolist to display (values: buffer, "
"buffer_lines)",
"buffer|buffer_lines",
- demo_list_command_cb, NULL);
+ demo_infolist_command_cb, NULL);
weechat_hook_command ("demo_info", "demo command: get and display info",
"info",
diff --git a/src/plugins/fifo/CMakeLists.txt b/src/plugins/fifo/CMakeLists.txt
index c20a87a75..ae7cf4545 100644
--- a/src/plugins/fifo/CMakeLists.txt
+++ b/src/plugins/fifo/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(fifo MODULE fifo.c fifo.h)
+ADD_LIBRARY(fifo MODULE fifo.c)
SET_TARGET_PROPERTIES(fifo PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(fifo)
diff --git a/src/plugins/fifo/Makefile.am b/src/plugins/fifo/Makefile.am
index 3a5686cda..c2d0d49fa 100644
--- a/src/plugins/fifo/Makefile.am
+++ b/src/plugins/fifo/Makefile.am
@@ -20,6 +20,6 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = fifo.la
-fifo_la_SOURCES = fifo.c fifo.h
+fifo_la_SOURCES = fifo.c
fifo_la_LDFLAGS = -module
fifo_la_LIBADD = $(FIFO_LFLAGS)
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c
index 032c18a44..fcb74a857 100644
--- a/src/plugins/fifo/fifo.c
+++ b/src/plugins/fifo/fifo.c
@@ -32,21 +32,26 @@
#include <fcntl.h>
#include "../weechat-plugin.h"
-#include "fifo.h"
-static struct t_weechat_plugin *weechat_plugin = NULL;
-static int fifo_fd = -1;
-static struct t_hook *fifo_fd_hook = NULL;
-static char *fifo_filename;
-static char *fifo_unterminated = NULL;
+char plugin_name[] = "fifo";
+char plugin_version[] = "0.1";
+char plugin_description[] = "Fifo plugin for WeeChat";
+
+struct t_weechat_plugin *weechat_fifo_plugin = NULL;
+#define weechat_plugin weechat_fifo_plugin
+
+int fifo_fd = -1;
+struct t_hook *fifo_fd_hook = NULL;
+char *fifo_filename;
+char *fifo_unterminated = NULL;
/*
* fifo_create: create FIFO pipe for remote control
*/
-static void
+void
fifo_create ()
{
int filename_length;
@@ -113,7 +118,7 @@ fifo_create ()
* fifo_remove: remove FIFO pipe
*/
-static void
+void
fifo_remove ()
{
if (fifo_fd != -1)
@@ -148,7 +153,7 @@ fifo_remove ()
* fifo_exec: execute a command/text received by FIFO pipe
*/
-static void
+void
fifo_exec (char *text)
{
char *pos_msg, *pos;
@@ -211,7 +216,7 @@ fifo_exec (char *text)
* fifo_read: read data in FIFO pipe
*/
-static int
+int
fifo_read ()
{
static char buffer[4096 + 2];
@@ -298,7 +303,7 @@ fifo_read ()
* fifo_config_cb: fifo config callback (called when fifo option is changed)
*/
-static int
+int
fifo_config_cb (void *data, char *type, char *option, char *value)
{
/* make C compiler happy */
diff --git a/src/plugins/fifo/fifo.h b/src/plugins/fifo/fifo.h
deleted file mode 100644
index a166e9fbd..000000000
--- a/src/plugins/fifo/fifo.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
- * See README for License detail, AUTHORS for developers list.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __WEECHAT_FIFO_H
-#define __WEECHAT_FIFO_H 1
-
-char plugin_name[] = "fifo";
-char plugin_version[] = "0.1";
-char plugin_description[] = "Fifo plugin for WeeChat";
-
-#endif /* fifo.h */
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt
index 8292edcc6..5a676dec7 100644
--- a/src/plugins/irc/CMakeLists.txt
+++ b/src/plugins/irc/CMakeLists.txt
@@ -14,10 +14,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-SET(LIB_PROTOCOL_IRC_SRC irc.c irc.h irc-buffer.c irc-buffer.h irc-channel.c
-irc-channel.h irc-command.c irc-command.h irc-color.c irc-color.h irc-config.c
-irc-config.h irc-dcc.c irc-dcc.h irc-display.c irc-input.c irc-log.c irc-mode.c
-irc-nick.c irc-nick.h irc-protocol.c irc-protocol.h irc-server.c irc-server.h)
+SET(LIB_PROTOCOL_IRC_SRC irc.c irc.h irc-channel.c irc-channel.h irc-config.c
+irc-config.h irc-server.c irc-server.h)
+
+#SET(LIB_PROTOCOL_IRC_SRC irc.c irc.h irc-buffer.c irc-buffer.h irc-channel.c
+#irc-channel.h irc-command.c irc-command.h irc-color.c irc-color.h irc-config.c
+#irc-config.h irc-dcc.c irc-dcc.h irc-display.c irc-input.c irc-log.c irc-mode.c
+#irc-nick.c irc-nick.h irc-protocol.c irc-protocol.h irc-server.c irc-server.h)
CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC)
diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am
index 0f6864e2f..0e5a1a4e4 100644
--- a/src/plugins/irc/Makefile.am
+++ b/src/plugins/irc/Makefile.am
@@ -22,27 +22,31 @@ lib_LTLIBRARIES = irc.la
irc_la_SOURCES = irc.c \
irc.h \
- irc-buffer.c \
- irc-buffer.h \
irc-channel.c \
irc-channel.h \
- irc-command.c \
- irc-command.h \
- irc-color.c \
- irc-color.h \
irc-config.c \
irc-config.h \
- irc-dcc.c \
- irc-dcc.h \
- irc-display.c \
- irc-input.c \
- irc-log.c \
- irc-mode.c \
- irc-nick.c \
- irc-nick.h \
- irc-protocol.c \
- irc-protocol.h \
irc-server.c \
irc-server.h
+
+# irc.c \
+# irc.h \
+# irc-buffer.c \
+# irc-buffer.h \
+# irc-command.c \
+# irc-command.h \
+# irc-color.c \
+# irc-color.h \
+# irc-dcc.c \
+# irc-dcc.h \
+# irc-display.c \
+# irc-input.c \
+# irc-log.c \
+# irc-mode.c \
+# irc-nick.c \
+# irc-nick.h \
+# irc-protocol.c \
+# irc-protocol.h
+
irc_la_LDFLAGS = -module
irc_la_LIBADD = $(GNUTLS_LFLAGS)
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index 6b527005c..88bd8eafa 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -35,8 +35,6 @@
t_irc_server *ptr_server = IRC_BUFFER_SERVER(buffer); \
t_irc_channel *ptr_channel = IRC_BUFFER_CHANNEL(buffer)
-/* protocol data for GUI buffers */
-
struct t_irc_buffer_data
{
struct t_irc_server *server;
@@ -44,4 +42,9 @@ struct t_irc_buffer_data
int all_servers;
};
+extern struct t_irc_buffer_data *irc_buffer_data_create (struct t_irc_server *);
+extern void irc_buffer_data_free (struct t_gui_buffer *);
+extern void irc_buffer_merge_servers (struct t_gui_window *);
+extern void irc_buffer_split_server (struct t_gui_window *);
+
#endif /* irc-buffer.h */
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 262ccd6f3..c57fac6d4 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -27,13 +27,12 @@
#include <unistd.h>
#include <string.h>
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/log.h"
-#include "../../core/utf8.h"
-#include "../../core/util.h"
-#include "../../core/weechat-config.h"
-#include "../../gui/gui.h"
+#include "irc-channel.h"
+#include "irc-config.h"
+#include "irc-dcc.h"
+#include "irc-nick.h"
+#include "irc-server.h"
/*
@@ -41,55 +40,31 @@
* list
*/
-t_irc_channel *
-irc_channel_new (t_irc_server *server, int channel_type, char *channel_name,
- int switch_to_channel)
+struct t_irc_channel *
+irc_channel_new (struct t_irc_server *server, int channel_type,
+ char *channel_name, int switch_to_channel)
{
- t_irc_channel *new_channel;
- t_gui_buffer *new_buffer;
- int attribs, log_buffer;
- char *log_filename;
+ struct t_irc_channel *new_channel;
+ struct t_gui_buffer *new_buffer;
/* alloc memory for new channel */
- if ((new_channel = (t_irc_channel *) malloc (sizeof (t_irc_channel))) == NULL)
+ if ((new_channel = (struct t_irc_channel *) malloc (sizeof (struct t_irc_channel))) == NULL)
{
- fprintf (stderr, _("%s cannot allocate new channel"), WEECHAT_ERROR);
+ weechat_printf (NULL,
+ _("%sIrc: cannot allocate new channel"),
+ weechat_prefix ("error"));
return NULL;
}
-
- log_buffer = 0;
- attribs = GUI_BUFFER_ATTRIB_TEXT | GUI_BUFFER_ATTRIB_INPUT |
- GUI_BUFFER_ATTRIB_NICKS;
- switch (channel_type)
- {
- case IRC_CHANNEL_TYPE_CHANNEL:
- if (irc_cfg_log_auto_channel)
- log_buffer = 1;
- attribs |= GUI_BUFFER_ATTRIB_NICKLIST;
- break;
- case IRC_CHANNEL_TYPE_PRIVATE:
- case IRC_CHANNEL_TYPE_DCC_CHAT:
- if (irc_cfg_log_auto_private)
- log_buffer = 1;
- break;
- }
- log_filename = irc_log_get_filename (server->name, channel_name,
- (channel_type == IRC_CHANNEL_TYPE_DCC_CHAT));
- new_buffer = gui_buffer_new (gui_current_window, 0,
- server->name, channel_name,
- attribs,
- irc_protocol,
- irc_buffer_data_create (server),
- &irc_buffer_data_free,
- GUI_NOTIFY_LEVEL_DEFAULT,
- channel_name, server->nick,
- log_buffer, log_filename,
- switch_to_channel);
- if (log_filename)
- free (log_filename);
+ /* create buffer for channel */
+ new_buffer = weechat_buffer_new (server->name, channel_name, NULL);
if (!new_buffer)
+ {
+ free (new_channel);
return NULL;
+ }
+ if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
+ weechat_buffer_set (new_buffer, "nicklist", "1");
/* initialize new channel */
new_channel->type = channel_type;
@@ -110,20 +85,20 @@ irc_channel_new (t_irc_server *server, int channel_type, char *channel_name,
new_channel->last_nick = NULL;
new_channel->buffer = new_buffer;
new_channel->nicks_speaking = NULL;
- new_channel->last_nick_speaking = NULL;
-
- IRC_BUFFER_CHANNEL(new_buffer) = new_channel;
- new_buffer->notify_level = irc_channel_get_notify_level (server, new_channel);
+ //new_buffer->notify_level = irc_channel_get_notify_level (server, new_channel);
/* add new channel to channels list */
- new_channel->prev_channel = server->last_channel;
+ new_channel->prev_channel = ((struct t_irc_server *)server)->last_channel;
new_channel->next_channel = NULL;
if (server->channels)
- server->last_channel->next_channel = new_channel;
+ (server->last_channel)->next_channel = new_channel;
else
server->channels = new_channel;
server->last_channel = new_channel;
+ if (switch_to_channel)
+ weechat_buffer_set (new_buffer, "display", "1");
+
/* all is ok, return address of new channel */
return new_channel;
}
@@ -133,9 +108,9 @@ irc_channel_new (t_irc_server *server, int channel_type, char *channel_name,
*/
void
-irc_channel_free (t_irc_server *server, t_irc_channel *channel)
+irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
{
- t_irc_channel *new_channels;
+ struct t_irc_channel *new_channels;
if (!server || !channel)
return;
@@ -143,12 +118,13 @@ irc_channel_free (t_irc_server *server, t_irc_channel *channel)
/* close DCC CHAT */
if (channel->dcc_chat)
{
- ((t_irc_dcc *)(channel->dcc_chat))->channel = NULL;
- if (!IRC_DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status))
+ channel->dcc_chat->channel = NULL;
+ /*if (!IRC_DCC_ENDED(channel->dcc_chat->status))
{
- irc_dcc_close ((t_irc_dcc *)(channel->dcc_chat), IRC_DCC_ABORTED);
+ irc_dcc_close (channel->dcc_chat, IRC_DCC_ABORTED);
irc_dcc_redraw (1);
}
+ */
}
/* remove channel from channels list */
@@ -174,12 +150,11 @@ irc_channel_free (t_irc_server *server, t_irc_channel *channel)
free (channel->modes);
if (channel->key)
free (channel->key);
- irc_nick_free_all (channel);
+ //irc_nick_free_all (channel);
if (channel->away_message)
free (channel->away_message);
if (channel->nicks_speaking)
- weelist_remove_all (&(channel->nicks_speaking),
- &(channel->last_nick_speaking));
+ weechat_list_free (channel->nicks_speaking);
free (channel);
server->channels = new_channels;
}
@@ -189,7 +164,7 @@ irc_channel_free (t_irc_server *server, t_irc_channel *channel)
*/
void
-irc_channel_free_all (t_irc_server *server)
+irc_channel_free_all (struct t_irc_server *server)
{
/* remove all channels for the server */
while (server->channels)
@@ -201,10 +176,10 @@ irc_channel_free_all (t_irc_server *server)
* WARNING: DCC chat channels are not returned by this function
*/
-t_irc_channel *
-irc_channel_search (t_irc_server *server, char *channel_name)
+struct t_irc_channel *
+irc_channel_search (struct t_irc_server *server, char *channel_name)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (!server || !channel_name)
return NULL;
@@ -223,10 +198,10 @@ irc_channel_search (t_irc_server *server, char *channel_name)
* irc_channel_search_any: returns pointer on a channel with name
*/
-t_irc_channel *
-irc_channel_search_any (t_irc_server *server, char *channel_name)
+struct t_irc_channel *
+irc_channel_search_any (struct t_irc_server *server, char *channel_name)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (!server || !channel_name)
return NULL;
@@ -245,10 +220,11 @@ irc_channel_search_any (t_irc_server *server, char *channel_name)
* looks only for channels without buffer
*/
-t_irc_channel *
-irc_channel_search_any_without_buffer (t_irc_server *server, char *channel_name)
+struct t_irc_channel *
+irc_channel_search_any_without_buffer (struct t_irc_server *server,
+ char *channel_name)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (!server || !channel_name)
return NULL;
@@ -267,10 +243,10 @@ irc_channel_search_any_without_buffer (t_irc_server *server, char *channel_name)
* irc_channel_search_dcc: returns pointer on a DCC chat channel with name
*/
-t_irc_channel *
-irc_channel_search_dcc (t_irc_server *server, char *channel_name)
+struct t_irc_channel *
+irc_channel_search_dcc (struct t_irc_server *server, char *channel_name)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (!server || !channel_name)
return NULL;
@@ -307,9 +283,9 @@ irc_channel_is_channel (char *string)
*/
void
-irc_channel_remove_away (t_irc_channel *channel)
+irc_channel_remove_away (struct t_irc_channel *channel)
{
- t_irc_nick *ptr_nick;
+ struct t_irc_nick *ptr_nick;
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
@@ -317,7 +293,7 @@ irc_channel_remove_away (t_irc_channel *channel)
{
IRC_NICK_SET_FLAG(ptr_nick, 0, IRC_NICK_AWAY);
}
- gui_nicklist_draw (channel->buffer, 0, 0);
+ //gui_nicklist_draw (channel->buffer, 0, 0);
}
}
@@ -326,12 +302,14 @@ irc_channel_remove_away (t_irc_channel *channel)
*/
void
-irc_channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
+irc_channel_check_away (struct t_irc_server *server,
+ struct t_irc_channel *channel, int force)
{
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- if (force || (irc_cfg_irc_away_check_max_nicks == 0) ||
- (channel->nicks_count <= irc_cfg_irc_away_check_max_nicks))
+ if (force
+ || (weechat_config_integer (irc_config_irc_away_check_max_nicks) == 0)
+ || (channel->nicks_count <= weechat_config_integer (irc_config_irc_away_check_max_nicks)))
{
channel->checking_away++;
irc_server_sendf (server, "WHO %s", channel->name);
@@ -346,9 +324,13 @@ irc_channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
*/
void
-irc_channel_set_away (t_irc_channel *channel, char *nick, int is_away)
+irc_channel_set_away (struct t_irc_channel *channel, char *nick, int is_away)
{
- t_irc_nick *ptr_nick;
+ (void) channel;
+ (void) nick;
+ (void) is_away;
+
+ /*struct t_irc_nick *ptr_nick;
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
@@ -356,6 +338,7 @@ irc_channel_set_away (t_irc_channel *channel, char *nick, int is_away)
if (ptr_nick)
irc_nick_set_away (channel, ptr_nick, is_away);
}
+ */
}
/*
@@ -363,27 +346,28 @@ irc_channel_set_away (t_irc_channel *channel, char *nick, int is_away)
*/
int
-irc_channel_create_dcc (t_irc_dcc *ptr_dcc)
+irc_channel_create_dcc (void *dcc)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
- ptr_channel = irc_channel_search_dcc (ptr_dcc->server, ptr_dcc->nick);
+ ptr_channel = irc_channel_search_dcc (((struct t_irc_dcc *)dcc)->server,
+ ((struct t_irc_dcc *)dcc)->nick);
if (!ptr_channel)
{
- ptr_channel = irc_channel_new (ptr_dcc->server,
+ ptr_channel = irc_channel_new (((struct t_irc_dcc *)dcc)->server,
IRC_CHANNEL_TYPE_DCC_CHAT,
- ptr_dcc->nick, 0);
+ ((struct t_irc_dcc *)dcc)->nick, 0);
if (!ptr_channel)
return 0;
}
if (ptr_channel->dcc_chat &&
- (!IRC_DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
+ (!IRC_DCC_ENDED(ptr_channel->dcc_chat->status)))
return 0;
- ptr_channel->dcc_chat = ptr_dcc;
- ptr_dcc->channel = ptr_channel;
- gui_window_redraw_buffer (ptr_channel->buffer);
+ ptr_channel->dcc_chat = dcc;
+ ((struct t_irc_dcc *)dcc)->channel = ptr_channel;
+ //gui_window_redraw_buffer (ptr_channel->buffer);
return 1;
}
@@ -392,9 +376,12 @@ irc_channel_create_dcc (t_irc_dcc *ptr_dcc)
*/
int
-irc_channel_get_notify_level (t_irc_server *server, t_irc_channel *channel)
+irc_channel_get_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel)
{
- char *name, *pos, *pos2;
+ (void) server;
+ (void) channel;
+ /*char *name, *pos, *pos2;
int server_default_notify, notify;
if ((!server) || (!channel))
@@ -428,6 +415,8 @@ irc_channel_get_notify_level (t_irc_server *server, t_irc_channel *channel)
return notify;
return server_default_notify;
+ */
+ return 0;
}
/*
@@ -435,10 +424,14 @@ irc_channel_get_notify_level (t_irc_server *server, t_irc_channel *channel)
*/
void
-irc_channel_set_notify_level (t_irc_server *server, t_irc_channel *channel,
- int notify)
+irc_channel_set_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel, int notify)
{
- char level_string[2];
+ (void) server;
+ (void) channel;
+ (void) notify;
+
+ /*char level_string[2];
if ((!server) || (!channel))
return;
@@ -446,6 +439,7 @@ irc_channel_set_notify_level (t_irc_server *server, t_irc_channel *channel,
level_string[0] = notify + '0';
level_string[1] = '\0';
config_option_list_set (&(server->notify_levels), channel->name, level_string);
+ */
}
/*
@@ -453,22 +447,20 @@ irc_channel_set_notify_level (t_irc_server *server, t_irc_channel *channel,
*/
void
-irc_channel_add_nick_speaking (t_irc_channel *channel, char *nick)
+irc_channel_add_nick_speaking (struct t_irc_channel *channel, char *nick)
{
int size, to_remove, i;
- weelist_add (&(channel->nicks_speaking), &(channel->last_nick_speaking),
- nick, WEELIST_POS_END);
+ weechat_list_add (channel->nicks_speaking, nick, "end");
- size = weelist_get_size (channel->nicks_speaking);
+ size = weechat_list_size (channel->nicks_speaking);
if (size > IRC_CHANNEL_NICKS_SPEAKING_LIMIT)
{
to_remove = size - IRC_CHANNEL_NICKS_SPEAKING_LIMIT;
for (i = 0; i < to_remove; i++)
{
- weelist_remove (&(channel->nicks_speaking),
- &(channel->last_nick_speaking),
- channel->nicks_speaking);
+ weechat_list_remove (channel->nicks_speaking,
+ weechat_list_get (channel->nicks_speaking, 0));
}
}
}
@@ -478,31 +470,39 @@ irc_channel_add_nick_speaking (t_irc_channel *channel, char *nick)
*/
void
-irc_channel_print_log (t_irc_channel *channel)
+irc_channel_print_log (struct t_irc_channel *channel)
{
- weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel);
- weechat_log_printf (" type . . . . . . . . : %d\n", channel->type);
- weechat_log_printf (" dcc_chat . . . . . . : 0x%X\n", channel->dcc_chat);
- weechat_log_printf (" topic. . . . . . . . : '%s'\n", channel->topic);
- weechat_log_printf (" modes. . . . . . . . : '%s'\n", channel->modes);
- weechat_log_printf (" limit. . . . . . . . : %d\n", channel->limit);
- weechat_log_printf (" key. . . . . . . . . : '%s'\n", channel->key);
- weechat_log_printf (" checking_away. . . . : %d\n", channel->checking_away);
- weechat_log_printf (" away_message . . . . : '%s'\n", channel->away_message);
- weechat_log_printf (" cycle. . . . . . . . : %d\n", channel->cycle);
- weechat_log_printf (" close. . . . . . . . : %d\n", channel->close);
- weechat_log_printf (" display_creation_date: %d\n", channel->display_creation_date);
- weechat_log_printf (" nicks. . . . . . . . : 0x%X\n", channel->nicks);
- weechat_log_printf (" last_nick. . . . . . : 0x%X\n", channel->last_nick);
- weechat_log_printf (" buffer . . . . . . . : 0x%X\n", channel->buffer);
- weechat_log_printf (" nicks_speaking . . . : 0x%X\n", channel->nicks_speaking);
- weechat_log_printf (" last_nick_speaking . : 0x%X\n", channel->last_nick_speaking);
- weechat_log_printf (" prev_channel . . . . : 0x%X\n", channel->prev_channel);
- weechat_log_printf (" next_channel . . . . : 0x%X\n", channel->next_channel);
+ struct t_weelist_item *ptr_item;
+ int i;
+
+ weechat_log_printf ("=> channel %s (addr:0x%X)]", channel->name, channel);
+ weechat_log_printf (" type . . . . . . . . : %d", channel->type);
+ weechat_log_printf (" dcc_chat . . . . . . : 0x%X", channel->dcc_chat);
+ weechat_log_printf (" topic. . . . . . . . : '%s'", channel->topic);
+ weechat_log_printf (" modes. . . . . . . . : '%s'", channel->modes);
+ weechat_log_printf (" limit. . . . . . . . : %d", channel->limit);
+ weechat_log_printf (" key. . . . . . . . . : '%s'", channel->key);
+ weechat_log_printf (" checking_away. . . . : %d", channel->checking_away);
+ weechat_log_printf (" away_message . . . . : '%s'", channel->away_message);
+ weechat_log_printf (" cycle. . . . . . . . : %d", channel->cycle);
+ weechat_log_printf (" close. . . . . . . . : %d", channel->close);
+ weechat_log_printf (" display_creation_date: %d", channel->display_creation_date);
+ weechat_log_printf (" nicks. . . . . . . . : 0x%X", channel->nicks);
+ weechat_log_printf (" last_nick. . . . . . : 0x%X", channel->last_nick);
+ weechat_log_printf (" buffer . . . . . . . : 0x%X", channel->buffer);
+ weechat_log_printf (" nicks_speaking . . . : 0x%X", channel->nicks_speaking);
+ weechat_log_printf (" prev_channel . . . . : 0x%X", channel->prev_channel);
+ weechat_log_printf (" next_channel . . . . : 0x%X", channel->next_channel);
if (channel->nicks_speaking)
{
- weechat_log_printf ("\n");
- weelist_print_log (channel->nicks_speaking,
- "channel nick speaking element");
+ weechat_log_printf ("");
+ i = 0;
+ for (ptr_item = weechat_list_get (channel->nicks_speaking, 0);
+ ptr_item; ptr_item = weechat_list_next (ptr_item))
+ {
+ weechat_log_printf (" nick speaking %d: '%s'",
+ i, weechat_list_string (ptr_item));
+ i++;
+ }
}
}
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index 673a60379..eecce10c6 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_IRC_CHANNEL_H
#define __WEECHAT_IRC_CHANNEL_H 1
+#include "irc-server.h"
+
#define IRC_CHANNEL_PREFIX "#&+!"
/* channel types */
@@ -33,7 +35,7 @@
struct t_irc_channel
{
int type; /* channel type */
- void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
+ struct t_irc_dcc *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
char *name; /* name of channel (exemple: "#abc") */
char *topic; /* topic of channel (host for private) */
char *modes; /* channel modes */
@@ -50,10 +52,26 @@ struct t_irc_channel
struct t_irc_nick *nicks; /* nicks on the channel */
struct t_irc_nick *last_nick; /* last nick on the channel */
struct t_weelist *nicks_speaking; /* for smart completion */
- struct t_weelist *last_nick_speaking; /* last nick speaking */
struct t_gui_buffer *buffer; /* buffer allocated for channel */
struct t_irc_channel *prev_channel; /* link to previous channel */
struct t_irc_channel *next_channel; /* link to next channel */
};
+extern struct t_irc_channel *irc_channel_new (struct t_irc_server *, int, char *, int);
+extern void irc_channel_free (struct t_irc_server *, struct t_irc_channel *);
+extern void irc_channel_free_all (struct t_irc_server *);
+extern struct t_irc_channel *irc_channel_search (struct t_irc_server *, char *);
+extern struct t_irc_channel *irc_channel_search_any (struct t_irc_server *, char *);
+extern struct t_irc_channel *irc_channel_search_any_without_buffer (struct t_irc_server *, char *);
+extern struct t_irc_channel *irc_channel_search_dcc (struct t_irc_server *, char *);
+extern int irc_channel_is_channel (char *);
+extern void irc_channel_remove_away (struct t_irc_channel *);
+extern void irc_channel_check_away (struct t_irc_server *, struct t_irc_channel *, int);
+extern void irc_channel_set_away (struct t_irc_channel *, char *, int);
+extern int irc_channel_create_dcc (void *);
+extern int irc_channel_get_notify_level (struct t_irc_server *, struct t_irc_channel *);
+extern void irc_channel_set_notify_level (struct t_irc_server *, struct t_irc_channel *, int);
+extern void irc_channel_add_nick_speaking (struct t_irc_channel *, char *);
+extern void irc_channel_print_log (struct t_irc_channel *);
+
#endif /* irc-channel.h */
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index 7b153595c..bee7f1426 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -51,4 +51,8 @@
#define IRC_COLOR_UNDERLINE_CHAR '\x1F'
#define IRC_COLOR_UNDERLINE_STR "\x1F"
+extern unsigned char *irc_color_decode (unsigned char *, int, int);
+extern unsigned char *irc_color_decode_for_user_entry (unsigned char *);
+extern unsigned char *irc_color_encode (unsigned char *, int);
+
#endif /* irc-color.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 528bdda31..5d91a0d00 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -39,26 +39,26 @@ t_weechat_command irc_commands[] =
{ { "admin", N_("find information about the administrator of the server"),
N_("[target]"),
N_("target: server"),
- NULL, 0, 1, 0, irc_cmd_admin },
+ NULL, 0, 1, 0, irc_command_admin },
{ "ame", N_("send a CTCP action to all channels of all connected servers"),
N_("message"),
N_("message: message to send"),
- "", 1, MAX_ARGS, 1, irc_cmd_ame },
+ "", 1, MAX_ARGS, 1, irc_command_ame },
{ "amsg", N_("send message to all channels of all connected servers"),
N_("text"),
N_("text: text to send"),
- "", 1, MAX_ARGS, 1, irc_cmd_amsg },
+ "", 1, MAX_ARGS, 1, irc_command_amsg },
{ "away", N_("toggle away status"),
N_("[-all] [message]"),
N_(" -all: toggle away status on all connected servers\n"
"message: message for away (if no message is given, away status is "
"removed)"),
- "-all", 0, MAX_ARGS, 1, irc_cmd_away },
+ "-all", 0, MAX_ARGS, 1, irc_command_away },
{ "ban", N_("bans nicks or hosts"),
N_("[channel] [nickname [nickname ...]]"),
N_(" channel: channel for ban\n"
"nickname: user or host to ban"),
- "%N", 0, MAX_ARGS, 0, irc_cmd_ban },
+ "%N", 0, MAX_ARGS, 0, irc_command_ban },
{ "connect", N_("connect to server(s)"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin] | hostname "
"[-port port] [-ipv6] [-ssl]]"),
@@ -70,98 +70,98 @@ t_weechat_command irc_commands[] =
" port: port for server (integer, default is 6667)\n"
" ipv6: use IPv6 protocol\n"
" ssl: use SSL protocol"),
- "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, irc_cmd_connect },
+ "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, irc_command_connect },
{ "ctcp", N_("send a CTCP message (Client-To-Client Protocol)"),
N_("receiver type [arguments]"),
N_(" receiver: nick or channel to send CTCP to\n"
" type: CTCP type (examples: \"version\", \"ping\", ..)\n"
"arguments: arguments for CTCP"),
- "%c|%n action|ping|version", 2, MAX_ARGS, 1, irc_cmd_ctcp },
+ "%c|%n action|ping|version", 2, MAX_ARGS, 1, irc_command_ctcp },
{ "cycle", N_("leave and rejoin a channel"),
N_("[channel[,channel]] [part_message]"),
N_(" channel: channel name for cycle\n"
"part_message: part message (displayed to other users)"),
- "%p", 0, MAX_ARGS, 0, irc_cmd_cycle },
+ "%p", 0, MAX_ARGS, 0, irc_command_cycle },
{ "dcc", N_("starts DCC (file or chat) or close chat"),
N_("action [nickname [file]]"),
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
"nickname: nickname to send file or chat\n"
" file: filename (on local host)"),
- "chat|send|close %n %f", 1, MAX_ARGS, 0, irc_cmd_dcc },
+ "chat|send|close %n %f", 1, MAX_ARGS, 0, irc_command_dcc },
{ "dehalfop", N_("removes half channel operator status from nickname(s)"),
N_("[nickname [nickname]]"), "",
- "", 0, MAX_ARGS, 0, irc_cmd_dehalfop },
+ "", 0, MAX_ARGS, 0, irc_command_dehalfop },
{ "deop", N_("removes channel operator status from nickname(s)"),
N_("[nickname [nickname]]"), "",
- "", 0, MAX_ARGS, 0, irc_cmd_deop },
+ "", 0, MAX_ARGS, 0, irc_command_deop },
{ "devoice", N_("removes voice from nickname(s)"),
N_("[nickname [nickname]]"), "",
- "", 0, MAX_ARGS, 0, irc_cmd_devoice },
+ "", 0, MAX_ARGS, 0, irc_command_devoice },
{ "die", N_("shutdown the server"), "", "",
- NULL, 0, 0, 0, irc_cmd_die },
+ NULL, 0, 0, 0, irc_command_die },
{ "disconnect", N_("disconnect from server(s)"),
N_("[-all | servername [servername ...]]"),
N_(" -all: disconnect from all servers\n"
"servername: server name to disconnect"),
- "%S|-all", 0, MAX_ARGS, 0, irc_cmd_disconnect },
+ "%S|-all", 0, MAX_ARGS, 0, irc_command_disconnect },
{ "halfop", N_("gives half channel operator status to nickname(s)"),
N_("[nickname [nickname]]"), "",
- "", 0, MAX_ARGS, 0, irc_cmd_halfop },
+ "", 0, MAX_ARGS, 0, irc_command_halfop },
{ "info", N_("get information describing the server"),
N_("[target]"),
N_("target: server name"),
- NULL, 0, 1, 0, irc_cmd_info },
+ NULL, 0, 1, 0, irc_command_info },
{ "invite", N_("invite a nick on a channel"),
N_("nickname channel"),
N_("nickname: nick to invite\n"
" channel: channel to invite"),
- "%n %c", 1, 2, 0, irc_cmd_invite },
+ "%n %c", 1, 2, 0, irc_command_invite },
{ "ison", N_("check if a nickname is currently on IRC"),
N_("nickname [nickname ...]"),
N_("nickname: nickname"),
- "", 1, MAX_ARGS, 0, irc_cmd_ison },
+ "", 1, MAX_ARGS, 0, irc_command_ison },
{ "join", N_("join a channel"),
N_("channel[,channel] [key[,key]]"),
N_("channel: channel name to join\n"
" key: key to join the channel"),
- "%C", 1, MAX_ARGS, 0, irc_cmd_join },
+ "%C", 1, MAX_ARGS, 0, irc_command_join },
{ "kick", N_("forcibly remove a user from a channel"),
N_("[channel] nickname [comment]"),
N_(" channel: channel where user is\n"
"nickname: nickname to kick\n"
" comment: comment for kick"),
- "%n %-", 1, MAX_ARGS, 0, irc_cmd_kick },
+ "%n %-", 1, MAX_ARGS, 0, irc_command_kick },
{ "kickban", N_("kicks and bans a nick from a channel"),
N_("[channel] nickname [comment]"),
N_(" channel: channel where user is\n"
"nickname: nickname to kick and ban\n"
" comment: comment for kick"),
- "%n %-", 1, MAX_ARGS, 0, irc_cmd_kickban },
+ "%n %-", 1, MAX_ARGS, 0, irc_command_kickban },
{ "kill", N_("close client-server connection"),
N_("nickname comment"),
N_("nickname: nickname\n"
" comment: comment for kill"),
- "%n %-", 2, MAX_ARGS, 0, irc_cmd_kill },
+ "%n %-", 2, MAX_ARGS, 0, irc_command_kill },
{ "links",
N_("list all servernames which are known by the server answering "
"the query"),
N_("[[server] server_mask]"),
N_(" server: this server should answer the query\n"
"server_mask: list of servers must match this mask"),
- NULL, 0, 2, 0, irc_cmd_links },
+ NULL, 0, 2, 0, irc_command_links },
{ "list", N_("list channels and their topic"),
N_("[channel[,channel] [server]]"),
N_("channel: channel to list (a regexp is allowed)\nserver: server name"),
- NULL, 0, MAX_ARGS, 0, irc_cmd_list },
+ NULL, 0, MAX_ARGS, 0, irc_command_list },
{ "lusers", N_("get statistics about the size of the IRC network"),
N_("[mask [target]]"),
N_(" mask: servers matching the mask only\n"
"target: server for forwarding request"),
- NULL, 0, 2, 0, irc_cmd_lusers },
+ NULL, 0, 2, 0, irc_command_lusers },
{ "me", N_("send a CTCP action to the current channel"),
N_("message"),
N_("message: message to send"),
- "", 0, MAX_ARGS, 1, irc_cmd_me },
+ "", 0, MAX_ARGS, 1, irc_command_me },
{ "mode", N_("change channel or user mode"),
N_("{ channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask] } | "
"{ nickname {[+|-]|i|w|s|o} }"),
@@ -185,80 +185,80 @@ t_weechat_command irc_commands[] =
" s: mark a user for receive server notices\n"
" w: user receives wallops\n"
" o: operator flag"),
- "%c|%m", 1, MAX_ARGS, 0, irc_cmd_mode },
+ "%c|%m", 1, MAX_ARGS, 0, irc_command_mode },
{ "motd", N_("get the \"Message Of The Day\""),
N_("[target]"),
N_("target: server name"),
- NULL, 0, 1, 0, irc_cmd_motd },
+ NULL, 0, 1, 0, irc_command_motd },
{ "msg", N_("send message to a nick or channel"),
N_("receiver[,receiver] text"),
N_("receiver: nick or channel (may be mask, '*' = current channel)\n"
"text: text to send"),
- "", 2, MAX_ARGS, 1, irc_cmd_msg },
+ "", 2, MAX_ARGS, 1, irc_command_msg },
{ "names", N_("list nicknames on channels"),
N_("[channel[,channel]]"),
N_("channel: channel name"),
- NULL, 0, 1, 0, irc_cmd_names },
+ NULL, 0, 1, 0, irc_command_names },
{ "nick", N_("change current nickname"),
N_("[-all] nickname"),
N_(" -all: set new nickname for all connected servers\n"
"nickname: new nickname"),
- "-all", 1, 2, 0, irc_cmd_nick },
+ "-all", 1, 2, 0, irc_command_nick },
{ "notice", N_("send notice message to user"),
N_("nickname text"),
N_("nickname: user to send notice to\n"
" text: text to send"),
- "%n %-", 2, MAX_ARGS, 1, irc_cmd_notice },
+ "%n %-", 2, MAX_ARGS, 1, irc_command_notice },
{ "op", N_("gives channel operator status to nickname(s)"),
N_("nickname [nickname]"), "",
- "", 1, MAX_ARGS, 0, irc_cmd_op },
+ "", 1, MAX_ARGS, 0, irc_command_op },
{ "oper", N_("get operator privileges"),
N_("user password"),
N_("user/password: used to get privileges on current IRC server"),
- NULL, 2, 2, 0, irc_cmd_oper },
+ NULL, 2, 2, 0, irc_command_oper },
{ "part", N_("leave a channel"),
N_("[channel[,channel]] [part_message]"),
N_(" channel: channel name to leave\n"
"part_message: part message (displayed to other users)"),
- "%p", 0, MAX_ARGS, 0, irc_cmd_part },
+ "%p", 0, MAX_ARGS, 0, irc_command_part },
{ "ping", N_("ping server"),
N_("server1 [server2]"),
N_("server1: server to ping\nserver2: forward ping to this server"),
- NULL, 1, 2, 0, irc_cmd_ping },
+ NULL, 1, 2, 0, irc_command_ping },
{ "pong", N_("answer to a ping message"),
N_("daemon [daemon2]"),
N_(" daemon: daemon who has responded to Ping message\n"
"daemon2: forward message to this daemon"),
- NULL, 1, 2, 0, irc_cmd_pong },
+ NULL, 1, 2, 0, irc_command_pong },
{ "query", N_("send a private message to a nick"),
N_("nickname [text]"),
N_("nickname: nickname for private conversation\n"
" text: text to send"),
- "%n %-", 1, MAX_ARGS, 1, irc_cmd_query },
+ "%n %-", 1, MAX_ARGS, 1, irc_command_query },
{ "quit", N_("close all connections and quit"),
N_("[quit_message]"),
N_("quit_message: quit message (displayed to other users)"),
- "%q", 0, MAX_ARGS, 1, irc_cmd_quit },
+ "%q", 0, MAX_ARGS, 1, irc_command_quit },
{ "quote", N_("send raw data to server without parsing"),
N_("data"),
N_("data: raw data to send"),
- "", 1, MAX_ARGS, 1, irc_cmd_quote },
+ "", 1, MAX_ARGS, 1, irc_command_quote },
{ "reconnect", N_("reconnect to server(s)"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin]]"),
N_(" -all: reconnect to all servers\n"
"servername: server name to reconnect\n"
" -nojoin: do not join any channel (even if autojoin is enabled on "
"server)"),
- "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, irc_cmd_reconnect },
+ "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, irc_command_reconnect },
{ "rehash", N_("tell the server to reload its config file"), "", "",
- NULL, 0, 0, 0, irc_cmd_rehash },
+ NULL, 0, 0, 0, irc_command_rehash },
{ "restart", N_("tell the server to restart itself"), "", "",
- NULL, 0, 0, 0, irc_cmd_restart },
+ NULL, 0, 0, 0, irc_command_restart },
{ "service", N_("register a new service"),
N_("nickname reserved distribution type reserved info"),
N_("distribution: visibility of service\n"
" type: reserved for future usage"),
- NULL, 6, 6, 0, irc_cmd_service },
+ NULL, 6, 6, 0, irc_command_service },
{ "server", N_("list, add or remove servers"),
N_("[list [servername]] | [listfull [servername]] | [add servername "
"hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] "
@@ -291,83 +291,83 @@ t_weechat_command irc_commands[] =
" deloutq: delete messages out queue for all servers (all messages "
"WeeChat is currently sending)"),
"add|copy|rename|keep|del|deloutq|list|listfull %S %S",
- 0, MAX_ARGS, 0, irc_cmd_server },
+ 0, MAX_ARGS, 0, irc_command_server },
{ "servlist", N_("list services currently connected to the network"),
N_("[mask [type]]"),
N_("mask: list only services matching this mask\n"
"type: list only services of this type"),
- NULL, 0, 2, 0, irc_cmd_servlist },
+ NULL, 0, 2, 0, irc_command_servlist },
{ "squery", N_("deliver a message to a service"),
N_("service text"),
N_("service: name of service\ntext: text to send"),
- NULL, 2, MAX_ARGS, 1, irc_cmd_squery },
+ NULL, 2, MAX_ARGS, 1, irc_command_squery },
{ "squit", N_("disconnect server links"),
N_("server comment"),
N_( "server: server name\n"
"comment: comment for quit"),
- NULL, 2, 2, 1, irc_cmd_squit },
+ NULL, 2, 2, 1, irc_command_squit },
{ "stats", N_("query statistics about server"),
N_("[query [server]]"),
N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n"
"server: server name"),
- NULL, 0, 2, 0, irc_cmd_stats },
+ NULL, 0, 2, 0, irc_command_stats },
{ "summon",
N_("give users who are on a host running an IRC server a message "
"asking them to please join IRC"),
N_("user [target [channel]]"),
N_(" user: username\ntarget: server name\n"
"channel: channel name"),
- NULL, 1, 3, 0, irc_cmd_summon },
+ NULL, 1, 3, 0, irc_command_summon },
{ "time", N_("query local time from server"),
N_("[target]"),
N_("target: query time from specified server"),
- NULL, 0, 1, 0, irc_cmd_time },
+ NULL, 0, 1, 0, irc_command_time },
{ "topic", N_("get/set channel topic"),
N_("[channel] [topic]"),
N_("channel: channel name\ntopic: new topic for channel "
"(if topic is \"-delete\" then topic is deleted)"),
- "%t|-delete %-", 0, MAX_ARGS, 1, irc_cmd_topic },
+ "%t|-delete %-", 0, MAX_ARGS, 1, irc_command_topic },
{ "trace", N_("find the route to specific server"),
N_("[target]"),
N_("target: server"),
- NULL, 0, 1, 0, irc_cmd_trace },
+ NULL, 0, 1, 0, irc_command_trace },
{ "unban", N_("unbans nicks or hosts"),
N_("[channel] nickname [nickname ...]"),
N_(" channel: channel for unban\n"
"nickname: user or host to unban"),
- "", 1, MAX_ARGS, 0, irc_cmd_unban },
+ "", 1, MAX_ARGS, 0, irc_command_unban },
{ "userhost", N_("return a list of information about nicknames"),
N_("nickname [nickname ...]"),
N_("nickname: nickname"),
- "%n", 1, MAX_ARGS, 0, irc_cmd_userhost },
+ "%n", 1, MAX_ARGS, 0, irc_command_userhost },
{ "users", N_("list of users logged into the server"),
N_("[target]"),
N_("target: server"),
- NULL, 0, 1, 0, irc_cmd_users },
+ NULL, 0, 1, 0, irc_command_users },
{ "version",
N_("gives the version info of nick or server (current or specified)"),
N_("[server | nickname]"),
N_(" server: server name\n"
"nickname: nickname"),
- "%n", 0, 1, 0, irc_cmd_version },
+ "%n", 0, 1, 0, irc_command_version },
{ "voice", N_("gives voice to nickname(s)"),
N_("[nickname [nickname]]"), "",
- "", 0, MAX_ARGS, 0, irc_cmd_voice },
+ "", 0, MAX_ARGS, 0, irc_command_voice },
{ "wallops", N_("send a message to all currently connected users who have "
"set the 'w' user mode for themselves"),
N_("text"),
N_("text to send"),
- NULL, 1, MAX_ARGS, 1, irc_cmd_wallops },
+ NULL, 1, MAX_ARGS, 1, irc_command_wallops },
{ "who", N_("generate a query which returns a list of information"),
N_("[mask [\"o\"]]"),
N_("mask: only information which match this mask\n"
" o: only operators are returned according to the mask supplied"),
- "%C", 0, 2, 0, irc_cmd_who },
+ "%C", 0, 2, 0, irc_command_who },
{ "whois", N_("query information about user(s)"),
N_("[server] nickname[,nickname]"),
N_(" server: server name\n"
"nickname: nickname (may be a mask)"),
- "", 1, MAX_ARGS, 0, irc_cmd_whois },
+ "", 1, MAX_ARGS, 0, irc_command_whois },
{ "whowas",
N_("ask for information about a nickname which no longer exists"),
N_("nickname [,nickname [,nickname ...]] [count [target]]"),
@@ -375,18 +375,18 @@ t_weechat_command irc_commands[] =
" count: number of replies to return "
"(full search if negative number)\n"
" target: reply should match this mask"),
- "", 1, MAX_ARGS, 0, irc_cmd_whowas },
+ "", 1, MAX_ARGS, 0, irc_command_whowas },
{ NULL, NULL, NULL, NULL, NULL, 0, 0, 0, NULL }
};
/*
- * irc_cmd_admin: find information about the administrator of the server
+ * irc_command_admin: find information about the administrator of the server
*/
int
-irc_cmd_admin (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_admin (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -404,12 +404,12 @@ irc_cmd_admin (t_gui_window *window,
}
/*
- * irc_cmd_me_channel: send a ctcp action to a channel
+ * irc_command_me_channel: send a ctcp action to a channel
*/
int
-irc_cmd_me_channel (t_irc_server *server, t_irc_channel *channel,
- char *arguments)
+irc_command_me_channel (t_irc_server *server, t_irc_channel *channel,
+ char *arguments)
{
char *string;
@@ -430,11 +430,11 @@ irc_cmd_me_channel (t_irc_server *server, t_irc_channel *channel,
}
/*
- * irc_cmd_me_all_channels: send a ctcp action to all channels of a server
+ * irc_command_me_all_channels: send a ctcp action to all channels of a server
*/
int
-irc_cmd_me_all_channels (t_irc_server *server, char *arguments)
+irc_command_me_all_channels (t_irc_server *server, char *arguments)
{
t_irc_channel *ptr_channel;
@@ -442,18 +442,18 @@ irc_cmd_me_all_channels (t_irc_server *server, char *arguments)
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- irc_cmd_me_channel (server, ptr_channel, arguments);
+ irc_command_me_channel (server, ptr_channel, arguments);
}
return 0;
}
/*
- * irc_cmd_mode_nicks: send mode change for many nicks on a channel
+ * irc_command_mode_nicks: send mode change for many nicks on a channel
*/
void
-irc_cmd_mode_nicks (t_irc_server *server, char *channel,
- char *set, char *mode, int argc, char **argv)
+irc_command_mode_nicks (t_irc_server *server, char *channel,
+ char *set, char *mode, int argc, char **argv)
{
int i, length;
char *command;
@@ -479,12 +479,12 @@ irc_cmd_mode_nicks (t_irc_server *server, char *channel,
}
/*
- * irc_cmd_ame: send a ctcp action to all channels of all connected servers
+ * irc_command_ame: send a ctcp action to all channels of all connected servers
*/
int
-irc_cmd_ame (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_ame (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -504,7 +504,7 @@ irc_cmd_ame (t_gui_window *window,
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- irc_cmd_me_channel (ptr_server, ptr_channel, arguments);
+ irc_command_me_channel (ptr_server, ptr_channel, arguments);
}
}
}
@@ -513,12 +513,12 @@ irc_cmd_ame (t_gui_window *window,
}
/*
- * irc_cmd_amsg: send message to all channels of all connected servers
+ * irc_command_amsg: send message to all channels of all connected servers
*/
int
-irc_cmd_amsg (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_amsg (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -578,11 +578,11 @@ irc_cmd_amsg (t_gui_window *window,
}
/*
- * irc_cmd_away_server: toggle away status for one server
+ * irc_command_away_server: toggle away status for one server
*/
void
-irc_cmd_away_server (t_irc_server *server, char *arguments)
+irc_command_away_server (t_irc_server *server, char *arguments)
{
char *string, buffer[4096];
t_gui_window *ptr_window;
@@ -616,7 +616,7 @@ irc_cmd_away_server (t_irc_server *server, char *arguments)
{
snprintf (buffer, sizeof (buffer), "is away: %s",
(string) ? string : arguments);
- irc_cmd_me_all_channels (server, buffer);
+ irc_command_me_all_channels (server, buffer);
}
if (string)
free (string);
@@ -683,7 +683,7 @@ irc_cmd_away_server (t_irc_server *server, char *arguments)
(long int)(elapsed / 3600),
(long int)((elapsed / 60) % 60),
(long int)(elapsed % 60));
- irc_cmd_me_all_channels (server, buffer);
+ irc_command_me_all_channels (server, buffer);
}
}
}
@@ -703,12 +703,12 @@ irc_cmd_away_server (t_irc_server *server, char *arguments)
}
/*
- * irc_cmd_away: toggle away status
+ * irc_command_away: toggle away status
*/
int
-irc_cmd_away (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_away (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos;
@@ -733,11 +733,11 @@ irc_cmd_away (t_gui_window *window,
ptr_server = ptr_server->next_server)
{
if (ptr_server->is_connected)
- irc_cmd_away_server (ptr_server, pos);
+ irc_command_away_server (ptr_server, pos);
}
}
else
- irc_cmd_away_server (ptr_server, arguments);
+ irc_command_away_server (ptr_server, arguments);
gui_status_draw (window->buffer, 1);
gui_add_hotlist = 1;
@@ -745,12 +745,12 @@ irc_cmd_away (t_gui_window *window,
}
/*
- * irc_cmd_ban: bans nicks or hosts
+ * irc_command_ban: bans nicks or hosts
*/
int
-irc_cmd_ban (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_ban (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_channel, *pos, *pos2;
@@ -833,12 +833,12 @@ irc_cmd_ban (t_gui_window *window,
}
/*
- * irc_cmd_connect_one_server: connect to one server
+ * irc_command_connect_one_server: connect to one server
* return 0 if error, 1 if ok
*/
int
-irc_cmd_connect_one_server (t_irc_server *server, int no_join)
+irc_command_connect_one_server (t_irc_server *server, int no_join)
{
if (!server)
return 0;
@@ -871,12 +871,12 @@ irc_cmd_connect_one_server (t_irc_server *server, int no_join)
}
/*
- * irc_cmd_connect: connect to server(s)
+ * irc_command_connect: connect to server(s)
*/
int
-irc_cmd_connect (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_connect (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
t_irc_server server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
@@ -932,7 +932,7 @@ irc_cmd_connect (t_gui_window *window,
nb_connect++;
if (!ptr_server->is_connected && (ptr_server->child_pid == 0))
{
- if (!irc_cmd_connect_one_server (ptr_server, no_join))
+ if (!irc_command_connect_one_server (ptr_server, no_join))
connect_ok = 0;
}
}
@@ -947,7 +947,7 @@ irc_cmd_connect (t_gui_window *window,
ptr_server = irc_server_search (argv[i]);
if (ptr_server)
{
- if (!irc_cmd_connect_one_server (ptr_server, no_join))
+ if (!irc_command_connect_one_server (ptr_server, no_join))
connect_ok = 0;
}
else
@@ -988,7 +988,7 @@ irc_cmd_connect (t_gui_window *window,
GUI_COLOR(GUI_COLOR_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(GUI_COLOR_CHAT));
- if (!irc_cmd_connect_one_server (ptr_server, 0))
+ if (!irc_command_connect_one_server (ptr_server, 0))
connect_ok = 0;
}
else
@@ -1009,7 +1009,7 @@ irc_cmd_connect (t_gui_window *window,
}
if (nb_connect == 0)
- connect_ok = irc_cmd_connect_one_server (ptr_server, no_join);
+ connect_ok = irc_command_connect_one_server (ptr_server, no_join);
if (!connect_ok)
return -1;
@@ -1018,12 +1018,12 @@ irc_cmd_connect (t_gui_window *window,
}
/*
- * irc_cmd_ctcp: send a ctcp message
+ * irc_command_ctcp: send a ctcp message
*/
int
-irc_cmd_ctcp (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_ctcp (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_type, *pos_args, *pos;
struct timeval tv;
@@ -1102,12 +1102,12 @@ irc_cmd_ctcp (t_gui_window *window,
}
/*
- * irc_cmd_cycle: leave and rejoin a channel
+ * irc_command_cycle: leave and rejoin a channel
*/
int
-irc_cmd_cycle (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_cycle (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *channel_name, *pos_args, *ptr_arg, *buf;
char **channels;
@@ -1209,12 +1209,12 @@ irc_cmd_cycle (t_gui_window *window,
}
/*
- * irc_cmd_dcc: DCC control (file or chat)
+ * irc_command_dcc: DCC control (file or chat)
*/
int
-irc_cmd_dcc (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_dcc (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_nick, *pos_file;
@@ -1301,12 +1301,12 @@ irc_cmd_dcc (t_gui_window *window,
}
/*
- * irc_cmd_dehalfop: remove half operator privileges from nickname(s)
+ * irc_command_dehalfop: remove half operator privileges from nickname(s)
*/
int
-irc_cmd_dehalfop (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_dehalfop (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1322,8 +1322,8 @@ irc_cmd_dehalfop (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "-", "h", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "-", "h", argc, argv);
}
else
{
@@ -1336,11 +1336,11 @@ irc_cmd_dehalfop (t_gui_window *window,
}
/*
- * irc_cmd_deop: remove operator privileges from nickname(s)
+ * irc_command_deop: remove operator privileges from nickname(s)
*/
int
-irc_cmd_deop (t_gui_window *window,
+irc_command_deop (t_gui_window *window,
char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
@@ -1357,8 +1357,8 @@ irc_cmd_deop (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "-", "o", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "-", "o", argc, argv);
}
else
{
@@ -1371,12 +1371,12 @@ irc_cmd_deop (t_gui_window *window,
}
/*
- * irc_cmd_devoice: remove voice from nickname(s)
+ * irc_command_devoice: remove voice from nickname(s)
*/
int
-irc_cmd_devoice (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_devoice (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1392,8 +1392,8 @@ irc_cmd_devoice (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "-", "v", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "-", "v", argc, argv);
}
else
{
@@ -1407,12 +1407,12 @@ irc_cmd_devoice (t_gui_window *window,
}
/*
- * irc_cmd_die: shotdown the server
+ * irc_command_die: shotdown the server
*/
int
-irc_cmd_die (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_die (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1428,11 +1428,11 @@ irc_cmd_die (t_gui_window *window,
}
/*
- * irc_cmd_quit_server: send QUIT to a server
+ * irc_command_quit_server: send QUIT to a server
*/
void
-irc_cmd_quit_server (t_irc_server *server, char *arguments)
+irc_command_quit_server (t_irc_server *server, char *arguments)
{
char *ptr_arg, *buf;
@@ -1459,12 +1459,12 @@ irc_cmd_quit_server (t_irc_server *server, char *arguments)
}
/*
- * irc_cmd_disconnect_one_server: disconnect from a server
+ * irc_command_disconnect_one_server: disconnect from a server
* return 0 if error, 1 if ok
*/
int
-irc_cmd_disconnect_one_server (t_irc_server *server)
+irc_command_disconnect_one_server (t_irc_server *server)
{
if (!server)
return 0;
@@ -1482,7 +1482,7 @@ irc_cmd_disconnect_one_server (t_irc_server *server)
gui_chat_printf_info (server->buffer,
_("Auto-reconnection is cancelled\n"));
}
- irc_cmd_quit_server (server, NULL);
+ irc_command_quit_server (server, NULL);
irc_server_disconnect (server, 0);
gui_status_draw (server->buffer, 1);
@@ -1491,11 +1491,11 @@ irc_cmd_disconnect_one_server (t_irc_server *server)
}
/*
- * irc_cmd_disconnect: disconnect from server(s)
+ * irc_command_disconnect: disconnect from server(s)
*/
int
-irc_cmd_disconnect (t_gui_window *window,
+irc_command_disconnect (t_gui_window *window,
char *arguments, int argc, char **argv)
{
int i, disconnect_ok;
@@ -1506,7 +1506,7 @@ irc_cmd_disconnect (t_gui_window *window,
(void) arguments;
if (argc == 0)
- disconnect_ok = irc_cmd_disconnect_one_server (ptr_server);
+ disconnect_ok = irc_command_disconnect_one_server (ptr_server);
else
{
disconnect_ok = 1;
@@ -1519,7 +1519,7 @@ irc_cmd_disconnect (t_gui_window *window,
if ((ptr_server->is_connected) || (ptr_server->child_pid != 0)
|| (ptr_server->reconnect_start != 0))
{
- if (!irc_cmd_disconnect_one_server (ptr_server))
+ if (!irc_command_disconnect_one_server (ptr_server))
disconnect_ok = 0;
}
}
@@ -1531,7 +1531,7 @@ irc_cmd_disconnect (t_gui_window *window,
ptr_server = irc_server_search (argv[i]);
if (ptr_server)
{
- if (!irc_cmd_disconnect_one_server (ptr_server))
+ if (!irc_command_disconnect_one_server (ptr_server))
disconnect_ok = 0;
}
else
@@ -1552,12 +1552,12 @@ irc_cmd_disconnect (t_gui_window *window,
}
/*
- * irc_cmd_halfop: give half operator privileges to nickname(s)
+ * irc_command_halfop: give half operator privileges to nickname(s)
*/
int
-irc_cmd_halfop (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_halfop (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1573,8 +1573,8 @@ irc_cmd_halfop (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "+", "h", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "+", "h", argc, argv);
}
else
{
@@ -1588,12 +1588,12 @@ irc_cmd_halfop (t_gui_window *window,
}
/*
- * irc_cmd_info: get information describing the server
+ * irc_command_info: get information describing the server
*/
int
-irc_cmd_info (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_info (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1611,12 +1611,12 @@ irc_cmd_info (t_gui_window *window,
}
/*
- * irc_cmd_invite: invite a nick on a channel
+ * irc_command_invite: invite a nick on a channel
*/
int
-irc_cmd_invite (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_invite (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1646,12 +1646,12 @@ irc_cmd_invite (t_gui_window *window,
}
/*
- * irc_cmd_ison: check if a nickname is currently on IRC
+ * irc_command_ison: check if a nickname is currently on IRC
*/
int
-irc_cmd_ison (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_ison (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1666,11 +1666,11 @@ irc_cmd_ison (t_gui_window *window,
}
/*
- * irc_cmd_join_server: send JOIN command on a server
+ * irc_command_join_server: send JOIN command on a server
*/
void
-irc_cmd_join_server (t_irc_server *server, char *arguments)
+irc_command_join_server (t_irc_server *server, char *arguments)
{
if (irc_channel_is_channel (arguments))
irc_server_sendf (server, "JOIN %s", arguments);
@@ -1679,12 +1679,12 @@ irc_cmd_join_server (t_irc_server *server, char *arguments)
}
/*
- * irc_cmd_join: join a new channel
+ * irc_command_join: join a new channel
*/
int
-irc_cmd_join (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_join (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1694,18 +1694,18 @@ irc_cmd_join (t_gui_window *window,
(void) argc;
(void) argv;
- irc_cmd_join_server (ptr_server, arguments);
+ irc_command_join_server (ptr_server, arguments);
return 0;
}
/*
- * irc_cmd_kick: forcibly remove a user from a channel
+ * irc_command_kick: forcibly remove a user from a channel
*/
int
-irc_cmd_kick (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_kick (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1771,12 +1771,12 @@ irc_cmd_kick (t_gui_window *window,
}
/*
- * irc_cmd_kickban: forcibly remove a user from a channel and ban it
+ * irc_command_kickban: forcibly remove a user from a channel and ban it
*/
int
-irc_cmd_kickban (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_kickban (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1844,12 +1844,12 @@ irc_cmd_kickban (t_gui_window *window,
}
/*
- * irc_cmd_kill: close client-server connection
+ * irc_command_kill: close client-server connection
*/
int
-irc_cmd_kill (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_kill (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos;
@@ -1878,13 +1878,13 @@ irc_cmd_kill (t_gui_window *window,
}
/*
- * irc_cmd_links: list all servernames which are known by the server
+ * irc_command_links: list all servernames which are known by the server
* answering the query
*/
int
-irc_cmd_links (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_links (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1902,12 +1902,12 @@ irc_cmd_links (t_gui_window *window,
}
/*
- * irc_cmd_list: close client-server connection
+ * irc_command_list: close client-server connection
*/
int
-irc_cmd_list (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_list (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char buf[512];
int ret;
@@ -1961,12 +1961,12 @@ irc_cmd_list (t_gui_window *window,
}
/*
- * irc_cmd_lusers: get statistics about ths size of the IRC network
+ * irc_command_lusers: get statistics about ths size of the IRC network
*/
int
-irc_cmd_lusers (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_lusers (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1984,12 +1984,12 @@ irc_cmd_lusers (t_gui_window *window,
}
/*
- * irc_cmd_me: send a ctcp action to the current channel
+ * irc_command_me: send a ctcp action to the current channel
*/
int
-irc_cmd_me (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_me (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2007,27 +2007,27 @@ irc_cmd_me (t_gui_window *window,
WEECHAT_ERROR, "me");
return -1;
}
- irc_cmd_me_channel (ptr_server, ptr_channel, arguments);
+ irc_command_me_channel (ptr_server, ptr_channel, arguments);
return 0;
}
/*
- * irc_cmd_mode_server! send MODE command on a server
+ * irc_command_mode_server! send MODE command on a server
*/
void
-irc_cmd_mode_server (t_irc_server *server, char *arguments)
+irc_command_mode_server (t_irc_server *server, char *arguments)
{
irc_server_sendf (server, "MODE %s", arguments);
}
/*
- * irc_cmd_mode: change mode for channel/nickname
+ * irc_command_mode: change mode for channel/nickname
*/
int
-irc_cmd_mode (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_mode (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2037,18 +2037,18 @@ irc_cmd_mode (t_gui_window *window,
(void) argc;
(void) argv;
- irc_cmd_mode_server (ptr_server, arguments);
+ irc_command_mode_server (ptr_server, arguments);
return 0;
}
/*
- * irc_cmd_motd: get the "Message Of The Day"
+ * irc_command_motd: get the "Message Of The Day"
*/
int
-irc_cmd_motd (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_motd (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2066,12 +2066,12 @@ irc_cmd_motd (t_gui_window *window,
}
/*
- * irc_cmd_msg: send a message to a nick or channel
+ * irc_command_msg: send a message to a nick or channel
*/
int
-irc_cmd_msg (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_msg (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos, *pos_comma;
char *msg_pwd_hidden;
@@ -2257,12 +2257,12 @@ irc_cmd_msg (t_gui_window *window,
}
/*
- * irc_cmd_names: list nicknames on channels
+ * irc_command_names: list nicknames on channels
*/
int
-irc_cmd_names (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_names (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2320,12 +2320,12 @@ irc_send_nick_server (t_irc_server *server, char *nickname)
}
/*
- * irc_cmd_nick: change nickname
+ * irc_command_nick: change nickname
*/
int
-irc_cmd_nick (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_nick (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server)
@@ -2357,12 +2357,12 @@ irc_cmd_nick (t_gui_window *window,
}
/*
- * irc_cmd_notice: send notice message
+ * irc_command_notice: send notice message
*/
int
-irc_cmd_notice (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_notice (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos, *string;
@@ -2407,12 +2407,12 @@ irc_cmd_notice (t_gui_window *window,
}
/*
- * irc_cmd_op: give operator privileges to nickname(s)
+ * irc_command_op: give operator privileges to nickname(s)
*/
int
-irc_cmd_op (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_op (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2428,8 +2428,8 @@ irc_cmd_op (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "+", "o", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "+", "o", argc, argv);
}
else
{
@@ -2443,12 +2443,12 @@ irc_cmd_op (t_gui_window *window,
}
/*
- * irc_cmd_oper: get oper privileges
+ * irc_command_oper: get oper privileges
*/
int
-irc_cmd_oper (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_oper (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2463,12 +2463,12 @@ irc_cmd_oper (t_gui_window *window,
}
/*
- * irc_cmd_part: leave a channel or close a private window
+ * irc_command_part: leave a channel or close a private window
*/
int
-irc_cmd_part (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_part (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *channel_name, *pos_args, *ptr_arg, *buf;
@@ -2552,12 +2552,12 @@ irc_cmd_part (t_gui_window *window,
}
/*
- * irc_cmd_ping: ping a server
+ * irc_command_ping: ping a server
*/
int
-irc_cmd_ping (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_ping (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2572,12 +2572,12 @@ irc_cmd_ping (t_gui_window *window,
}
/*
- * irc_cmd_pong: send pong answer to a daemon
+ * irc_command_pong: send pong answer to a daemon
*/
int
-irc_cmd_pong (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_pong (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server)
@@ -2592,12 +2592,12 @@ irc_cmd_pong (t_gui_window *window,
}
/*
- * irc_cmd_query: start private conversation with a nick
+ * irc_command_query: start private conversation with a nick
*/
int
-irc_cmd_query (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_query (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos, *string;
@@ -2667,12 +2667,12 @@ irc_cmd_query (t_gui_window *window,
}
/*
- * irc_cmd_quit: disconnect from all servers and quit WeeChat
+ * irc_command_quit: disconnect from all servers and quit WeeChat
*/
int
-irc_cmd_quit (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_quit (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
t_irc_server *ptr_server;
@@ -2684,19 +2684,19 @@ irc_cmd_quit (t_gui_window *window,
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- irc_cmd_quit_server (ptr_server, arguments);
+ irc_command_quit_server (ptr_server, arguments);
}
quit_weechat = 1;
return 0;
}
/*
- * irc_cmd_quote: send raw data to server
+ * irc_command_quote: send raw data to server
*/
int
-irc_cmd_quote (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_quote (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2719,12 +2719,12 @@ irc_cmd_quote (t_gui_window *window,
}
/*
- * irc_cmd_reconnect_one_server: reconnect to a server
+ * irc_command_reconnect_one_server: reconnect to a server
* return 0 if error, 1 if ok
*/
int
-irc_cmd_reconnect_one_server (t_irc_server *server, int no_join)
+irc_command_reconnect_one_server (t_irc_server *server, int no_join)
{
if (!server)
return 0;
@@ -2736,7 +2736,7 @@ irc_cmd_reconnect_one_server (t_irc_server *server, int no_join)
WEECHAT_ERROR, server->name);
return 0;
}
- irc_cmd_quit_server (server, NULL);
+ irc_command_quit_server (server, NULL);
irc_server_disconnect (server, 0);
if (irc_server_connect (server, no_join))
{
@@ -2750,12 +2750,12 @@ irc_cmd_reconnect_one_server (t_irc_server *server, int no_join)
}
/*
- * irc_cmd_reconnect: reconnect to server(s)
+ * irc_command_reconnect: reconnect to server(s)
*/
int
-irc_cmd_reconnect (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_reconnect (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
int i, nb_reconnect, reconnect_ok, all_servers, no_join;
@@ -2785,7 +2785,7 @@ irc_cmd_reconnect (t_gui_window *window,
nb_reconnect++;
if ((ptr_server->is_connected) || (ptr_server->child_pid != 0))
{
- if (!irc_cmd_reconnect_one_server (ptr_server, no_join))
+ if (!irc_command_reconnect_one_server (ptr_server, no_join))
reconnect_ok = 0;
}
}
@@ -2800,7 +2800,7 @@ irc_cmd_reconnect (t_gui_window *window,
ptr_server = irc_server_search (argv[i]);
if (ptr_server)
{
- if (!irc_cmd_reconnect_one_server (ptr_server, no_join))
+ if (!irc_command_reconnect_one_server (ptr_server, no_join))
reconnect_ok = 0;
}
else
@@ -2815,7 +2815,7 @@ irc_cmd_reconnect (t_gui_window *window,
}
if (nb_reconnect == 0)
- reconnect_ok = irc_cmd_reconnect_one_server (ptr_server, no_join);
+ reconnect_ok = irc_command_reconnect_one_server (ptr_server, no_join);
if (!reconnect_ok)
return -1;
@@ -2824,12 +2824,12 @@ irc_cmd_reconnect (t_gui_window *window,
}
/*
- * irc_cmd_rehash: tell the server to reload its config file
+ * irc_command_rehash: tell the server to reload its config file
*/
int
-irc_cmd_rehash (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_rehash (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2845,12 +2845,12 @@ irc_cmd_rehash (t_gui_window *window,
}
/*
- * irc_cmd_restart: tell the server to restart itself
+ * irc_command_restart: tell the server to restart itself
*/
int
-irc_cmd_restart (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_restart (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2866,12 +2866,12 @@ irc_cmd_restart (t_gui_window *window,
}
/*
- * irc_cmd_server: manage IRC servers
+ * irc_command_server: manage IRC servers
*/
int
-irc_cmd_server (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_server (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
int i, detailed_list, one_server_found;
t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
@@ -3353,12 +3353,12 @@ irc_cmd_server (t_gui_window *window,
}
/*
- * irc_cmd_service: register a new service
+ * irc_command_service: register a new service
*/
int
-irc_cmd_service (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_service (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3373,12 +3373,12 @@ irc_cmd_service (t_gui_window *window,
}
/*
- * irc_cmd_servlist: list services currently connected to the network
+ * irc_command_servlist: list services currently connected to the network
*/
int
-irc_cmd_servlist (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_servlist (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3396,12 +3396,12 @@ irc_cmd_servlist (t_gui_window *window,
}
/*
- * irc_cmd_squery: deliver a message to a service
+ * irc_command_squery: deliver a message to a service
*/
int
-irc_cmd_squery (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_squery (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos;
@@ -3431,12 +3431,12 @@ irc_cmd_squery (t_gui_window *window,
}
/*
- * irc_cmd_squit: disconnect server links
+ * irc_command_squit: disconnect server links
*/
int
-irc_cmd_squit (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_squit (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3451,12 +3451,12 @@ irc_cmd_squit (t_gui_window *window,
}
/*
- * irc_cmd_stats: query statistics about server
+ * irc_command_stats: query statistics about server
*/
int
-irc_cmd_stats (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_stats (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3474,13 +3474,13 @@ irc_cmd_stats (t_gui_window *window,
}
/*
- * irc_cmd_summon: give users who are on a host running an IRC server
+ * irc_command_summon: give users who are on a host running an IRC server
* a message asking them to please join IRC
*/
int
-irc_cmd_summon (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_summon (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3495,12 +3495,12 @@ irc_cmd_summon (t_gui_window *window,
}
/*
- * irc_cmd_time: query local time from server
+ * irc_command_time: query local time from server
*/
int
-irc_cmd_time (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_time (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3518,12 +3518,12 @@ irc_cmd_time (t_gui_window *window,
}
/*
- * irc_cmd_topic: get/set topic for a channel
+ * irc_command_topic: get/set topic for a channel
*/
int
-irc_cmd_topic (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_topic (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *channel_name, *new_topic, *pos;
@@ -3589,12 +3589,12 @@ irc_cmd_topic (t_gui_window *window,
}
/*
- * irc_cmd_trace: find the route to specific server
+ * irc_command_trace: find the route to specific server
*/
int
-irc_cmd_trace (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_trace (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3612,12 +3612,12 @@ irc_cmd_trace (t_gui_window *window,
}
/*
- * irc_cmd_unban: unbans nicks or hosts
+ * irc_command_unban: unbans nicks or hosts
*/
int
-irc_cmd_unban (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_unban (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
char *pos_channel, *pos, *pos2;
@@ -3697,12 +3697,12 @@ irc_cmd_unban (t_gui_window *window,
}
/*
- * irc_cmd_userhost: return a list of information about nicknames
+ * irc_command_userhost: return a list of information about nicknames
*/
int
-irc_cmd_userhost (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_userhost (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3717,12 +3717,12 @@ irc_cmd_userhost (t_gui_window *window,
}
/*
- * irc_cmd_users: list of users logged into the server
+ * irc_command_users: list of users logged into the server
*/
int
-irc_cmd_users (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_users (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3740,12 +3740,12 @@ irc_cmd_users (t_gui_window *window,
}
/*
- * irc_cmd_version: gives the version info of nick or server (current or specified)
+ * irc_command_version: gives the version info of nick or server (current or specified)
*/
int
-irc_cmd_version (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_version (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3777,12 +3777,12 @@ irc_cmd_version (t_gui_window *window,
}
/*
- * irc_cmd_voice: give voice to nickname(s)
+ * irc_command_voice: give voice to nickname(s)
*/
int
-irc_cmd_voice (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_voice (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3798,8 +3798,8 @@ irc_cmd_voice (t_gui_window *window,
ptr_channel->name,
ptr_server->nick);
else
- irc_cmd_mode_nicks (ptr_server, ptr_channel->name,
- "+", "v", argc, argv);
+ irc_command_mode_nicks (ptr_server, ptr_channel->name,
+ "+", "v", argc, argv);
}
else
{
@@ -3813,13 +3813,13 @@ irc_cmd_voice (t_gui_window *window,
}
/*
- * irc_cmd_wallops: send a message to all currently connected users who
+ * irc_command_wallops: send a message to all currently connected users who
* have set the 'w' user mode for themselves
*/
int
-irc_cmd_wallops (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_wallops (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3834,12 +3834,12 @@ irc_cmd_wallops (t_gui_window *window,
}
/*
- * irc_cmd_who: generate a query which returns a list of information
+ * irc_command_who: generate a query which returns a list of information
*/
int
-irc_cmd_who (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_who (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3857,12 +3857,12 @@ irc_cmd_who (t_gui_window *window,
}
/*
- * irc_cmd_whois: query information about user(s)
+ * irc_command_whois: query information about user(s)
*/
int
-irc_cmd_whois (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_whois (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3877,12 +3877,12 @@ irc_cmd_whois (t_gui_window *window,
}
/*
- * irc_cmd_whowas: ask for information about a nickname which no longer exists
+ * irc_command_whowas: ask for information about a nickname which no longer exists
*/
int
-irc_cmd_whowas (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_whowas (t_gui_window *window,
+ char *arguments, int argc, char **argv)
{
IRC_BUFFER_GET_SERVER(window->buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3895,3 +3895,470 @@ irc_cmd_whowas (t_gui_window *window,
irc_server_sendf (ptr_server, "WHOWAS %s", arguments);
return 0;
}
+
+/*
+ * irc_command_init: init IRC commands (create hooks)
+ */
+
+void
+irc_command_init ()
+{
+ weechat_hook_command ("admin",
+ N_("find information about the administrator of the "
+ "server"),
+ N_("[target]"),
+ N_("target: server"),
+ NULL, irc_command_admin);
+ weechat_hook_command ("ame",
+ N_("send a CTCP action to all channels of all "
+ "connected servers"),
+ N_("message"),
+ N_("message: message to send"),
+ NULL, irc_command_ame);
+ weechat_hook_command ("amsg",
+ N_("send message to all channels of all connected "
+ "servers"),
+ N_("text"),
+ N_("text: text to send"),
+ NULL, irc_command_amsg);
+ weechat_hook_command ("away",
+ N_("toggle away status"),
+ N_("[-all] [message]"),
+ N_(" -all: toggle away status on all connected "
+ "servers\n"
+ "message: message for away (if no message is "
+ "given, away status is removed)"),
+ "-all", irc_command_away);
+ weechat_hook_command ("ban",
+ N_("bans nicks or hosts"),
+ N_("[channel] [nickname [nickname ...]]"),
+ N_(" channel: channel for ban\n"
+ "nickname: user or host to ban"),
+ "%N", irc_command_ban);
+ weechat_hook_command ("connect",
+ N_("connect to server(s)"),
+ N_("[-all [-nojoin] | servername [servername ...] "
+ "[-nojoin] | hostname [-port port] [-ipv6] "
+ "[-ssl]]"),
+ N_(" -all: connect to all servers\n"
+ "servername: internal server name to connect\n"
+ " -nojoin: do not join any channel (even if "
+ "autojoin is enabled on server)\n"
+ " hostname: hostname to connect, creating "
+ "temporary server\n"
+ " port: port for server (integer, default "
+ "is 6667)\n"
+ " ipv6: use IPv6 protocol\n"
+ " ssl: use SSL protocol"),
+ "%S|-all|-nojoin|%*", irc_command_connect);
+ weechat_hook_command ("ctcp",
+ N_("send a CTCP message (Client-To-Client Protocol)"),
+ N_("receiver type [arguments]"),
+ N_(" receiver: nick or channel to send CTCP to\n"
+ " type: CTCP type (examples: \"version\", "
+ "\"ping\", ..)\n"
+ "arguments: arguments for CTCP"),
+ "%c|%n action|ping|version", irc_command_ctcp);
+ weechat_hook_command ("cycle",
+ N_("leave and rejoin a channel"),
+ N_("[channel[,channel]] [part_message]"),
+ N_(" channel: channel name for cycle\n"
+ "part_message: part message (displayed to other "
+ "users)"),
+ "%p", irc_command_cycle);
+ weechat_hook_command ("dcc",
+ N_("starts DCC (file or chat) or close chat"),
+ N_("action [nickname [file]]"),
+ N_(" action: 'send' (file) or 'chat' or 'close' "
+ "(chat)\n"
+ "nickname: nickname to send file or chat\n"
+ " file: filename (on local host)"),
+ "chat|send|close %n %f", irc_command_dcc);
+ weechat_hook_command ("dehalfop",
+ N_("removes half channel operator status from "
+ "nickname(s)"),
+ N_("[nickname [nickname]]"),
+ "",
+ NULL, irc_command_dehalfop);
+ weechat_hook_command ("deop",
+ N_("removes channel operator status from "
+ "nickname(s)"),
+ N_("[nickname [nickname]]"),
+ "",
+ NULL, irc_command_deop);
+ weechat_hook_command ("devoice",
+ N_("removes voice from nickname(s)"),
+ N_("[nickname [nickname]]"),
+ "",
+ NULL, irc_command_devoice);
+ weechat_hook_command ("die",
+ N_("shutdown the server"),
+ "",
+ "",
+ NULL, irc_command_die);
+ weechat_hook_command ("disconnect",
+ N_("disconnect from server(s)"),
+ N_("[-all | servername [servername ...]]"),
+ N_(" -all: disconnect from all servers\n"
+ "servername: server name to disconnect"),
+ "%S|-all", irc_command_disconnect);
+ weechat_hook_command ("halfop",
+ N_("gives half channel operator status to "
+ "nickname(s)"),
+ N_("[nickname [nickname]]"),
+ "",
+ NULL, irc_command_halfop);
+ weechat_hook_command ("info",
+ N_("get information describing the server"),
+ N_("[target]"),
+ N_("target: server name"),
+ NULL, irc_command_info);
+ weechat_hook_command ("invite",
+ N_("invite a nick on a channel"),
+ N_("nickname channel"),
+ N_("nickname: nick to invite\n"
+ " channel: channel to invite"),
+ "%n %c", irc_command_invite);
+ weechat_hook_command ("ison",
+ N_("check if a nickname is currently on IRC"),
+ N_("nickname [nickname ...]"),
+ N_("nickname: nickname"),
+ NULL, irc_command_ison);
+ weechat_hook_command ("join",
+ N_("join a channel"),
+ N_("channel[,channel] [key[,key]]"),
+ N_("channel: channel name to join\n"
+ " key: key to join the channel"),
+ "%C", irc_command_join);
+ weechat_hook_command ("kick",
+ N_("forcibly remove a user from a channel"),
+ N_("[channel] nickname [comment]"),
+ N_(" channel: channel where user is\n"
+ "nickname: nickname to kick\n"
+ " comment: comment for kick"),
+ "%n %-", irc_command_kick);
+ weechat_hook_command ("kickban",
+ N_("kicks and bans a nick from a channel"),
+ N_("[channel] nickname [comment]"),
+ N_(" channel: channel where user is\n"
+ "nickname: nickname to kick and ban\n"
+ " comment: comment for kick"),
+ "%n %-", irc_command_kickban);
+ weechat_hook_command ("kill",
+ N_("close client-server connection"),
+ N_("nickname comment"),
+ N_("nickname: nickname\n"
+ " comment: comment for kill"),
+ "%n %-", irc_command_kill);
+ weechat_hook_command ("links",
+ N_("list all servernames which are known by the "
+ "server answering the query"),
+ N_("[[server] server_mask]"),
+ N_(" server: this server should answer the "
+ "query\n"
+ "server_mask: list of servers must match this "
+ "mask"),
+ NULL, irc_command_links);
+ weechat_hook_command ("list",
+ N_("list channels and their topic"),
+ N_("[channel[,channel] [server]]"),
+ N_("channel: channel to list (a regexp is allowed)\n"
+ "server: server name"),
+ NULL, irc_command_list);
+ weechat_hook_command ("lusers",
+ N_("get statistics about the size of the IRC "
+ "network"),
+ N_("[mask [target]]"),
+ N_(" mask: servers matching the mask only\n"
+ "target: server for forwarding request"),
+ NULL, irc_command_lusers);
+ weechat_hook_command ("me",
+ N_("send a CTCP action to the current channel"),
+ N_("message"),
+ N_("message: message to send"),
+ NULL, irc_command_me);
+ weechat_hook_command ("mode",
+ N_("change channel or user mode"),
+ N_("{ channel {[+|-]|o|p|s|i|t|n|b|v} [limit] "
+ "[user] [ban mask] } | { nickname "
+ "{[+|-]|i|w|s|o} }"),
+ N_("channel modes:\n"
+ " channel: channel name to modify\n"
+ " o: give/take channel operator privileges\n"
+ " p: private channel flag\n"
+ " s: secret channel flag\n"
+ " i: invite-only channel flag\n"
+ " t: topic settable by channel operator only "
+ "flag\n"
+ " n: no messages to channel from clients on the "
+ "outside\n"
+ " m: moderated channel\n"
+ " l: set the user limit to channel\n"
+ " b: set a ban mask to keep users out\n"
+ " e: set exception mask\n"
+ " v: give/take the ability to speak on a "
+ "moderated channel\n"
+ " k: set a channel key (password)\n"
+ "user modes:\n"
+ " nickname: nickname to modify\n"
+ " i: mark a user as invisible\n"
+ " s: mark a user for receive server notices\n"
+ " w: user receives wallops\n"
+ " o: operator flag"),
+ "%c|%m", irc_command_mode);
+ weechat_hook_command ("motd",
+ N_("get the \"Message Of The Day\""),
+ N_("[target]"),
+ N_("target: server name"),
+ NULL, irc_command_motd);
+ weechat_hook_command ("msg",
+ N_("send message to a nick or channel"),
+ N_("receiver[,receiver] text"),
+ N_("receiver: nick or channel (may be mask, '*' = "
+ "current channel)\n"
+ "text: text to send"),
+ NULL, irc_command_msg);
+ weechat_hook_command ("names",
+ N_("list nicknames on channels"),
+ N_("[channel[,channel]]"),
+ N_("channel: channel name"),
+ "%C|%*", irc_command_names);
+ weechat_hook_command ("nick",
+ N_("change current nickname"),
+ N_("[-all] nickname"),
+ N_(" -all: set new nickname for all connected "
+ "servers\n"
+ "nickname: new nickname"),
+ "-all", irc_command_nick);
+ weechat_hook_command ("notice",
+ N_("send notice message to user"),
+ N_("nickname text"),
+ N_("nickname: user to send notice to\n"
+ " text: text to send"),
+ "%n %-", irc_command_notice);
+ weechat_hook_command ("op",
+ N_("gives channel operator status to nickname(s)"),
+ N_("nickname [nickname]"),
+ "",
+ NULL, irc_command_op);
+ weechat_hook_command ("oper",
+ N_("get operator privileges"),
+ N_("user password"),
+ N_("user/password: used to get privileges on "
+ "current IRC server"),
+ NULL, irc_command_oper);
+ weechat_hook_command ("part",
+ N_("leave a channel"),
+ N_("[channel[,channel]] [part_message]"),
+ N_(" channel: channel name to leave\n"
+ "part_message: part message (displayed to other "
+ "users)"),
+ "%p", irc_command_part);
+ weechat_hook_command ("ping",
+ N_("ping server"),
+ N_("server1 [server2]"),
+ N_("server1: server to ping\nserver2: forward ping "
+ "to this server"),
+ NULL, irc_command_ping);
+ weechat_hook_command ("pong",
+ N_("answer to a ping message"),
+ N_("daemon [daemon2]"),
+ N_(" daemon: daemon who has responded to Ping "
+ "message\n"
+ "daemon2: forward message to this daemon"),
+ NULL, irc_command_pong);
+ weechat_hook_command ("query",
+ N_("send a private message to a nick"),
+ N_("nickname [text]"),
+ N_("nickname: nickname for private conversation\n"
+ " text: text to send"),
+ "%n %-", irc_command_query);
+ weechat_hook_command ("quit",
+ N_("close all connections and quit"),
+ N_("[quit_message]"),
+ N_("quit_message: quit message (displayed to other "
+ "users)"),
+ "%q", irc_command_quit);
+ weechat_hook_command ("quote",
+ N_("send raw data to server without parsing"),
+ N_("data"),
+ N_("data: raw data to send"),
+ NULL, irc_command_quote);
+ weechat_hook_command ("reconnect",
+ N_("reconnect to server(s)"),
+ N_("[-all [-nojoin] | servername [servername ...] "
+ "[-nojoin]]"),
+ N_(" -all: reconnect to all servers\n"
+ "servername: server name to reconnect\n"
+ " -nojoin: do not join any channel (even if "
+ "autojoin is enabled on server)"),
+ "%S|-all|-nojoin|%*", irc_command_reconnect);
+ weechat_hook_command ("rehash",
+ N_("tell the server to reload its config file"),
+ "",
+ "",
+ NULL, irc_command_rehash);
+ weechat_hook_command ("restart",
+ N_("tell the server to restart itself"),
+ "",
+ "",
+ NULL, irc_command_restart);
+ weechat_hook_command ("service",
+ N_("register a new service"),
+ N_("nickname reserved distribution type reserved "
+ "info"),
+ N_("distribution: visibility of service\n"
+ " type: reserved for future usage"),
+ NULL, irc_command_service);
+ weechat_hook_command ("server",
+ N_("list, add or remove servers"),
+ N_("[list [servername]] | [listfull [servername]] | "
+ "[add servername hostname [-port port] [-temp] "
+ "[-auto | -noauto] [-ipv6] [-ssl] [-pwd password] "
+ "[-nicks nick1 nick2 nick3] [-username username] "
+ "[-realname realname] [-command command] "
+ "[-autojoin channel[,channel]] ] | [copy "
+ "servername newservername] | [rename servername "
+ "newservername] | [keep servername] | [del "
+ "servername]"),
+ N_(" list: list servers (no parameter implies "
+ "this list)\n"
+ " listfull: list servers with detailed info for "
+ "each server\n"
+ " add: create a new server\n"
+ "servername: server name, for internal and "
+ "display use\n"
+ " hostname: name or IP address of server\n"
+ " port: port for server (integer, default "
+ "is 6667)\n"
+ " temp: create temporary server (not saved "
+ "in config file)\n"
+ " auto: automatically connect to server "
+ "when WeeChat starts\n"
+ " noauto: do not connect to server when "
+ "WeeChat starts (default)\n"
+ " ipv6: use IPv6 protocol\n"
+ " ssl: use SSL protocol\n"
+ " password: password for server\n"
+ " nick1: first nick for server\n"
+ " nick2: alternate nick for server\n"
+ " nick3: second alternate nick for server\n"
+ " username: user name\n"
+ " realname: real name of user\n"
+ " copy: duplicate a server\n"
+ " rename: rename a server\n"
+ " keep: keep server in config file (for "
+ "temporary servers only)\n"
+ " del: delete a server\n"
+ " deloutq: delete messages out queue for all "
+ "servers (all messages "
+ "WeeChat is currently sending)"),
+ "add|copy|rename|keep|del|deloutq|list|listfull %S %S",
+ irc_command_server);
+ weechat_hook_command ("servlist",
+ N_("list services currently connected to the "
+ "network"),
+ N_("[mask [type]]"),
+ N_("mask: list only services matching this mask\n"
+ "type: list only services of this type"),
+ NULL, irc_command_servlist);
+ weechat_hook_command ("squery",
+ N_("deliver a message to a service"),
+ N_("service text"),
+ N_("service: name of service\ntext: text to send"),
+ NULL, irc_command_squery);
+ weechat_hook_command ("squit",
+ N_("disconnect server links"),
+ N_("server comment"),
+ N_( "server: server name\n"
+ "comment: comment for quit"),
+ NULL, irc_command_squit);
+ weechat_hook_command ("stats",
+ N_("query statistics about server"),
+ N_("[query [server]]"),
+ N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n"
+ "server: server name"),
+ NULL, irc_command_stats);
+ weechat_hook_command ("summon",
+ N_("give users who are on a host running an IRC "
+ "server a message asking them to please join "
+ "IRC"),
+ N_("user [target [channel]]"),
+ N_(" user: username\ntarget: server name\n"
+ "channel: channel name"),
+ NULL, irc_command_summon);
+ weechat_hook_command ("time",
+ N_("query local time from server"),
+ N_("[target]"),
+ N_("target: query time from specified server"),
+ NULL, irc_command_time);
+ weechat_hook_command ("topic",
+ N_("get/set channel topic"),
+ N_("[channel] [topic]"),
+ N_("channel: channel name\ntopic: new topic for "
+ "channel (if topic is \"-delete\" then topic "
+ "is deleted)"),
+ "%t|-delete %-", irc_command_topic);
+ weechat_hook_command ("trace",
+ N_("find the route to specific server"),
+ N_("[target]"),
+ N_("target: server"),
+ NULL, irc_command_trace);
+ weechat_hook_command ("unban",
+ N_("[channel] nickname [nickname ...]"),
+ N_(" channel: channel for unban\n"
+ "nickname: user or host to unban"),
+ NULL, irc_command_unban);
+ weechat_hook_command ("userhost",
+ N_("return a list of information about nicknames"),
+ N_("nickname [nickname ...]"),
+ N_("nickname: nickname"),
+ "%n", irc_command_userhost);
+ weechat_hook_command ("users",
+ N_("list of users logged into the server"),
+ N_("[target]"),
+ N_("target: server"),
+ NULL, irc_command_users);
+ weechat_hook_command ("version",
+ N_("gives the version info of nick or server "
+ "(current or specified)"),
+ N_("[server | nickname]"),
+ N_(" server: server name\n"
+ "nickname: nickname"),
+ "%n", irc_command_version);
+ weechat_hook_command ("voice",
+ N_("gives voice to nickname(s)"),
+ N_("[nickname [nickname]]"),
+ "",
+ NULL, irc_command_voice);
+ weechat_hook_command ("wallops",
+ N_("send a message to all currently connected users "
+ "who have set the 'w' user mode for themselves"),
+ N_("text"),
+ N_("text to send"),
+ NULL, irc_command_wallops);
+ weechat_hook_command ("who",
+ N_("generate a query which returns a list of "
+ "information"),
+ N_("[mask [\"o\"]]"),
+ N_("mask: only information which match this mask\n"
+ " o: only operators are returned according to "
+ "the mask supplied"),
+ "%C", irc_command_who);
+ weechat_hook_command ("whois",
+ N_("query information about user(s)"),
+ N_("[server] nickname[,nickname]"),
+ N_(" server: server name\n"
+ "nickname: nickname (may be a mask)"),
+ NULL, irc_command_whois);
+ weechat_hook_command ("whowas",
+ N_("ask for information about a nickname which no "
+ "longer exists"),
+ N_("nickname [,nickname [,nickname ...]] [count "
+ "[target]]"),
+ N_("nickname: nickname to search\n"
+ " count: number of replies to return "
+ "(full search if negative number)\n"
+ " target: reply should match this mask"),
+ NULL, irc_command_whowas);
+}
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index f73f2e74f..ed5fe489f 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -20,70 +20,6 @@
#ifndef __WEECHAT_IRC_COMMAND_H
#define __WEECHAT_IRC_COMMAND_H 1
-extern t_weechat_command irc_commands[];
-
-extern int irc_cmd_admin (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ame (t_gui_window *, char *, int, char **);
-extern int irc_cmd_amsg (t_gui_window *, char *, int, char **);
-extern int irc_cmd_away (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_connect (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ctcp (t_gui_window *, char *, int, char **);
-extern int irc_cmd_cycle (t_gui_window *, char *, int, char **);
-extern int irc_cmd_dcc (t_gui_window *, char *, int, char **);
-extern int irc_cmd_dehalfop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_deop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_devoice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_die (t_gui_window *, char *, int, char **);
-extern int irc_cmd_disconnect (t_gui_window *, char *, int, char **);
-extern int irc_cmd_halfop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_info (t_gui_window *, char *, int, char **);
-extern int irc_cmd_invite (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ison (t_gui_window *, char *, int, char **);
-extern int irc_cmd_join (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kick (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kickban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kill (t_gui_window *, char *, int, char **);
-extern int irc_cmd_links (t_gui_window *, char *, int, char **);
-extern int irc_cmd_list (t_gui_window *, char *, int, char **);
-extern int irc_cmd_lusers (t_gui_window *, char *, int, char **);
-extern int irc_cmd_me (t_gui_window *, char *, int, char **);
-extern int irc_cmd_mode (t_gui_window *, char *, int, char **);
-extern int irc_cmd_motd (t_gui_window *, char *, int, char **);
-extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
-extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
-extern int irc_cmd_names (t_gui_window *, char *, int, char **);
-extern int irc_cmd_nick (t_gui_window *, char *, int, char **);
-extern int irc_cmd_notice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_op (t_gui_window *, char *, int, char **);
-extern int irc_cmd_oper (t_gui_window *, char *, int, char **);
-extern int irc_cmd_part (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ping (t_gui_window *, char *, int, char **);
-extern int irc_cmd_pong (t_gui_window *, char *, int, char **);
-extern int irc_cmd_query (t_gui_window *, char *, int, char **);
-extern int irc_cmd_quit (t_gui_window *, char *, int, char **);
-extern int irc_cmd_quote (t_gui_window *, char *, int, char **);
-extern int irc_cmd_reconnect (t_gui_window *, char *, int, char **);
-extern int irc_cmd_rehash (t_gui_window *, char *, int, char **);
-extern int irc_cmd_restart (t_gui_window *, char *, int, char **);
-extern int irc_cmd_service (t_gui_window *, char *, int, char **);
-extern int irc_cmd_server (t_gui_window *, char *, int, char **);
-extern int irc_cmd_servlist (t_gui_window *, char *, int, char **);
-extern int irc_cmd_squery (t_gui_window *, char *, int, char **);
-extern int irc_cmd_squit (t_gui_window *, char *, int, char **);
-extern int irc_cmd_stats (t_gui_window *, char *, int, char **);
-extern int irc_cmd_summon (t_gui_window *, char *, int, char **);
-extern int irc_cmd_time (t_gui_window *, char *, int, char **);
-extern int irc_cmd_topic (t_gui_window *, char *, int, char **);
-extern int irc_cmd_trace (t_gui_window *, char *, int, char **);
-extern int irc_cmd_unban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_userhost (t_gui_window *, char *, int, char **);
-extern int irc_cmd_users (t_gui_window *, char *, int, char **);
-extern int irc_cmd_version (t_gui_window *, char *, int, char **);
-extern int irc_cmd_voice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_wallops (t_gui_window *, char *, int, char **);
-extern int irc_cmd_who (t_gui_window *, char *, int, char **);
-extern int irc_cmd_whois (t_gui_window *, char *, int, char **);
-extern int irc_cmd_whowas (t_gui_window *, char *, int, char **);
+extern void irc_command_init ();
#endif /* irc-command.h */
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 27819e262..5ec7ce3bd 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -29,357 +29,84 @@
#include <limits.h>
#include <pwd.h>
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/config-option.h"
-#include "../../core/config-file.h"
-#include "../../core/hook.h"
-#include "../../core/util.h"
+#include "irc-config.h"
+#include "irc-dcc.h"
+#include "irc-server.h"
+struct t_config_file *irc_config_file = NULL;
+struct t_config_section *irc_config_section_server = NULL;
+
/* config, irc section */
-int irc_cfg_irc_one_server_buffer;
-int irc_cfg_irc_open_near_server;
-char *irc_cfg_irc_nick_prefix;
-char *irc_cfg_irc_nick_suffix;
-int irc_cfg_irc_display_away;
-int irc_cfg_irc_show_away_once;
-char *irc_cfg_irc_display_away_values[] =
-{ "off", "local", "channel", NULL };
-char *irc_cfg_irc_default_msg_part;
-char *irc_cfg_irc_default_msg_quit;
-int irc_cfg_irc_notice_as_pv;
-int irc_cfg_irc_away_check;
-int irc_cfg_irc_away_check_max_nicks;
-int irc_cfg_irc_lag_check;
-int irc_cfg_irc_lag_min_show;
-int irc_cfg_irc_lag_disconnect;
-int irc_cfg_irc_anti_flood;
-char *irc_cfg_irc_highlight;
-int irc_cfg_irc_colors_receive;
-int irc_cfg_irc_colors_send;
-int irc_cfg_irc_send_unknown_commands;
-
-t_config_option irc_options_irc[] =
-{ { "irc_one_server_buffer",
- N_("use same buffer for all servers"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_irc_one_server_buffer, NULL, irc_config_change_one_server_buffer },
- { "irc_open_near_server",
- N_("open new channels/privates near server"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_irc_open_near_server, NULL, irc_config_change_noop },
- { "irc_nick_prefix",
- N_("text to display before nick in chat window"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &irc_cfg_irc_nick_prefix, irc_config_change_noop },
- { "irc_nick_suffix",
- N_("text to display after nick in chat window"),
- OPTION_TYPE_STRING, 0, 0, 0, " |", NULL,
- NULL, &irc_cfg_irc_nick_suffix, irc_config_change_noop },
- { "irc_display_away",
- N_("display message when (un)marking as away"),
- OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "off", irc_cfg_irc_display_away_values,
- &irc_cfg_irc_display_away, NULL, irc_config_change_noop },
- { "irc_show_away_once",
- N_("show remote away message only once in private"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_irc_show_away_once, NULL, irc_config_change_noop },
- { "irc_default_msg_part",
- N_("default part message (leaving channel) ('%v' will be replaced by "
- "WeeChat version in string)"),
- OPTION_TYPE_STRING, 0, 0, 0, "WeeChat %v", NULL,
- NULL, &irc_cfg_irc_default_msg_part, irc_config_change_noop },
- { "irc_default_msg_quit",
- N_("default quit message ('%v' will be replaced by WeeChat version in "
- "string)"),
- OPTION_TYPE_STRING, 0, 0, 0, "WeeChat %v", NULL,
- NULL, &irc_cfg_irc_default_msg_quit, irc_config_change_noop },
- { "irc_notice_as_pv",
- N_("display notices as private messages"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_irc_notice_as_pv, NULL, irc_config_change_noop },
- { "irc_away_check",
- N_("interval between two checks for away (in minutes, 0 = never check)"),
- OPTION_TYPE_INT, 0, INT_MAX, 0, NULL, NULL,
- &irc_cfg_irc_away_check, NULL, irc_config_change_away_check },
- { "irc_away_check_max_nicks",
- N_("do not check away nicks on channels with high number of nicks (0 = unlimited)"),
- OPTION_TYPE_INT, 0, INT_MAX, 0, NULL, NULL,
- &irc_cfg_irc_away_check_max_nicks, NULL, irc_config_change_away_check },
- { "irc_lag_check",
- N_("interval between two checks for lag (in seconds)"),
- OPTION_TYPE_INT, 30, INT_MAX, 60, NULL, NULL,
- &irc_cfg_irc_lag_check, NULL, irc_config_change_noop },
- { "irc_lag_min_show",
- N_("minimum lag to show (in seconds)"),
- OPTION_TYPE_INT, 0, INT_MAX, 1, NULL, NULL,
- &irc_cfg_irc_lag_min_show, NULL, irc_config_change_noop },
- { "irc_lag_disconnect",
- N_("disconnect after important lag (in minutes, 0 = never disconnect)"),
- OPTION_TYPE_INT, 0, INT_MAX, 5, NULL, NULL,
- &irc_cfg_irc_lag_disconnect, NULL, irc_config_change_noop },
- { "irc_anti_flood",
- N_("anti-flood: # seconds between two user messages (0 = no anti-flood)"),
- OPTION_TYPE_INT, 0, 5, 2, NULL, NULL,
- &irc_cfg_irc_anti_flood, NULL, irc_config_change_noop },
- { "irc_highlight",
- N_("comma separated list of words to highlight (case insensitive comparison, "
- "words may begin or end with \"*\" for partial match)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &irc_cfg_irc_highlight, irc_config_change_noop },
- { "irc_colors_receive",
- N_("when off, colors codes are ignored in incoming messages"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_irc_colors_receive, NULL, irc_config_change_noop },
- { "irc_colors_send",
- N_("allow user to send colors with special codes (^Cb=bold, ^Ccxx=color, "
- "^Ccxx,yy=color+background, ^Cu=underline, ^Cr=reverse)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_irc_colors_send, NULL, irc_config_change_noop },
- { "irc_send_unknown_commands",
- N_("send unknown commands to IRC server"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_irc_send_unknown_commands, NULL, irc_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *irc_config_irc_one_server_buffer;
+struct t_config_option *irc_config_irc_open_near_server;
+struct t_config_option *irc_config_irc_nick_prefix;
+struct t_config_option *irc_config_irc_nick_suffix;
+struct t_config_option *irc_config_irc_display_away;
+struct t_config_option *irc_config_irc_show_away_once;
+struct t_config_option *irc_config_irc_default_msg_part;
+struct t_config_option *irc_config_irc_default_msg_quit;
+struct t_config_option *irc_config_irc_notice_as_pv;
+struct t_config_option *irc_config_irc_away_check;
+struct t_config_option *irc_config_irc_away_check_max_nicks;
+struct t_config_option *irc_config_irc_lag_check;
+struct t_config_option *irc_config_irc_lag_min_show;
+struct t_config_option *irc_config_irc_lag_disconnect;
+struct t_config_option *irc_config_irc_anti_flood;
+struct t_config_option *irc_config_irc_highlight;
+struct t_config_option *irc_config_irc_colors_receive;
+struct t_config_option *irc_config_irc_colors_send;
+struct t_config_option *irc_config_irc_send_unknown_commands;
/* config, dcc section */
-int irc_cfg_dcc_auto_accept_files;
-int irc_cfg_dcc_auto_accept_chats;
-int irc_cfg_dcc_timeout;
-int irc_cfg_dcc_blocksize;
-int irc_cfg_dcc_fast_send;
-char *irc_cfg_dcc_port_range;
-char *irc_cfg_dcc_own_ip;
-char *irc_cfg_dcc_download_path;
-char *irc_cfg_dcc_upload_path;
-int irc_cfg_dcc_convert_spaces;
-int irc_cfg_dcc_auto_rename;
-int irc_cfg_dcc_auto_resume;
-
-t_config_option irc_options_dcc[] =
-{ { "dcc_auto_accept_files",
- N_("automatically accept incoming dcc files"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_dcc_auto_accept_files, NULL, irc_config_change_noop },
- { "dcc_auto_accept_chats",
- N_("automatically accept dcc chats (use carefully!)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_dcc_auto_accept_chats, NULL, irc_config_change_noop },
- { "dcc_timeout",
- N_("timeout for dcc request (in seconds)"),
- OPTION_TYPE_INT, 5, INT_MAX, 300, NULL, NULL,
- &irc_cfg_dcc_timeout, NULL, irc_config_change_noop },
- { "dcc_blocksize",
- N_("block size for dcc packets in bytes (default: 65536)"),
- OPTION_TYPE_INT, IRC_DCC_MIN_BLOCKSIZE, IRC_DCC_MAX_BLOCKSIZE, 65536, NULL, NULL,
- &irc_cfg_dcc_blocksize, NULL, irc_config_change_noop },
- { "dcc_fast_send",
- N_("does not wait for ACK when sending file"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_dcc_fast_send, NULL, irc_config_change_noop },
- { "dcc_port_range",
- N_("restricts outgoing dcc to use only ports in the given range "
- "(useful for NAT) (syntax: a single port, ie. 5000 or a port "
- "range, ie. 5000-5015, empty value means any port)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &irc_cfg_dcc_port_range, irc_config_change_noop },
- { "dcc_own_ip",
- N_("IP or DNS address used for outgoing dcc "
- "(if empty, local interface IP is used)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &irc_cfg_dcc_own_ip, irc_config_change_noop },
- { "dcc_download_path",
- N_("path for writing incoming files with dcc (default: user home)"),
- OPTION_TYPE_STRING, 0, 0, 0, "%h/dcc", NULL,
- NULL, &irc_cfg_dcc_download_path, irc_config_change_noop },
- { "dcc_upload_path",
- N_("path for reading files when sending thru dcc (when no path is "
- "specified)"),
- OPTION_TYPE_STRING, 0, 0, 0, "~", NULL,
- NULL, &irc_cfg_dcc_upload_path, irc_config_change_noop },
- { "dcc_convert_spaces",
- N_("convert spaces to underscores when sending files"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_dcc_convert_spaces, NULL, irc_config_change_noop },
- { "dcc_auto_rename",
- N_("rename incoming files if already exists (add '.1', '.2', ...)"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_dcc_auto_rename, NULL, irc_config_change_noop },
- { "dcc_auto_resume",
- N_("automatically resume dcc transfer if connection with remote host is "
- "loosed"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_dcc_auto_resume, NULL, irc_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
+struct t_config_option *irc_config_dcc_auto_accept_files;
+struct t_config_option *irc_config_dcc_auto_accept_chats;
+struct t_config_option *irc_config_dcc_timeout;
+struct t_config_option *irc_config_dcc_blocksize;
+struct t_config_option *irc_config_dcc_fast_send;
+struct t_config_option *irc_config_dcc_port_range;
+struct t_config_option *irc_config_dcc_own_ip;
+struct t_config_option *irc_config_dcc_download_path;
+struct t_config_option *irc_config_dcc_upload_path;
+struct t_config_option *irc_config_dcc_convert_spaces;
+struct t_config_option *irc_config_dcc_auto_rename;
+struct t_config_option *irc_config_dcc_auto_resume;
/* config, log section */
-int irc_cfg_log_auto_server;
-int irc_cfg_log_auto_channel;
-int irc_cfg_log_auto_private;
-int irc_cfg_log_hide_nickserv_pwd;
-
-t_config_option irc_options_log[] =
-{ { "log_auto_server",
- N_("automatically log server messages"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_log_auto_server, NULL, irc_config_change_log },
- { "log_auto_channel",
- N_("automatically log channel chats"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_log_auto_channel, NULL, irc_config_change_log },
- { "log_auto_private",
- N_("automatically log private chats"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &irc_cfg_log_auto_private, NULL, irc_config_change_log },
- { "log_hide_nickserv_pwd",
- N_("hide password displayed by nickserv"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &irc_cfg_log_hide_nickserv_pwd, NULL, irc_config_change_noop },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
-
-/* config, server section */
+struct t_config_option *irc_config_log_auto_server;
+struct t_config_option *irc_config_log_auto_channel;
+struct t_config_option *irc_config_log_auto_private;
+struct t_config_option *irc_config_log_hide_nickserv_pwd;
-static t_irc_server cfg_server;
-
-t_config_option irc_options_server[] =
-{ { "server_name",
- N_("name associated to IRC server (for display only)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.name), NULL },
- { "server_autoconnect",
- N_("automatically connect to server when WeeChat is starting"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &(cfg_server.autoconnect), NULL, NULL },
- { "server_autoreconnect",
- N_("automatically reconnect to server when disconnected"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &(cfg_server.autoreconnect), NULL, NULL },
- { "server_autoreconnect_delay",
- N_("delay (in seconds) before trying again to reconnect to server"),
- OPTION_TYPE_INT, 0, 65535, 30, NULL, NULL,
- &(cfg_server.autoreconnect_delay), NULL, NULL },
- { "server_address",
- N_("IP address or hostname of IRC server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.address), NULL },
- { "server_port",
- N_("port for connecting to server"),
- OPTION_TYPE_INT, 0, 65535, 6667, NULL, NULL,
- &(cfg_server.port), NULL, NULL },
- { "server_ipv6",
- N_("use IPv6 protocol for server communication"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &(cfg_server.ipv6), NULL, NULL },
- { "server_ssl",
- N_("use SSL for server communication"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
- &(cfg_server.ssl), NULL, NULL },
- { "server_password",
- N_("password for IRC server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.password), NULL },
- { "server_nick1",
- N_("nickname to use on IRC server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.nick1), NULL },
- { "server_nick2",
- N_("alternate nickname to use on IRC server (if nickname is already used)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.nick2), NULL },
- { "server_nick3",
- N_("2nd alternate nickname to use on IRC server (if alternate nickname is "
- "already used)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.nick3), NULL },
- { "server_username",
- N_("user name to use on IRC server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.username), NULL },
- { "server_realname",
- N_("real name to use on IRC server"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.realname), NULL },
- { "server_hostname",
- N_("custom hostname/IP for server (optional, if empty local hostname is "
- "used)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.hostname), NULL },
- { "server_command",
- N_("command(s) to run when connected to server (many commands should be "
- "separated by ';', use '\\;' for a semicolon, special variables $nick, "
- "$channel and $server are replaced by their value)"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.command), NULL },
- { "server_command_delay",
- N_("delay (in seconds) after command was executed (example: give some time "
- "for authentication)"),
- OPTION_TYPE_INT, 0, 3600, 0, NULL, NULL,
- &(cfg_server.command_delay), NULL, NULL },
- { "server_autojoin",
- N_("comma separated list of channels to join when connected to server "
- "(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.autojoin), NULL },
- { "server_autorejoin",
- N_("automatically rejoin channels when kicked"),
- OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
- &(cfg_server.autorejoin), NULL, NULL },
- { "server_notify_levels",
- N_("comma separated list of notify levels for channels of this server "
- "(format: #channel:1,..), a channel name '*' is reserved for server "
- "default notify level"),
- OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
- NULL, &(cfg_server.notify_levels), irc_config_change_notify_levels },
- { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
-};
-
-char *weechat_protocol_config_sections[] =
-{ "irc", "dcc",
- "log", "server",
- NULL
-};
-
-t_config_option *weechat_protocol_config_options[] =
-{ irc_options_irc, irc_options_dcc,
- irc_options_log, NULL,
- NULL };
-
-t_config_func_read_option *irc_config_read_functions[] =
-{ config_file_read_option, config_file_read_option,
- config_file_read_option, irc_config_read_server,
- NULL
-};
-
-t_config_func_write_options *irc_config_write_functions[] =
-{ config_file_write_options, config_file_write_options,
- config_file_write_options, irc_config_write_servers,
- NULL
-};
-
-t_config_func_write_options *irc_config_write_default_functions[] =
-{ config_file_write_options_default_values, config_file_write_options_default_values,
- config_file_write_options_default_values, irc_config_write_servers_default_values,
- NULL
-};
+/* config, server section */
+struct t_config_option *irc_config_server_name;
+struct t_config_option *irc_config_server_autoconnect;
+struct t_config_option *irc_config_server_autoreconnect;
+struct t_config_option *irc_config_server_autoreconnect_delay;
+struct t_config_option *irc_config_server_address;
+struct t_config_option *irc_config_server_port;
+struct t_config_option *irc_config_server_ipv6;
+struct t_config_option *irc_config_server_ssl;
+struct t_config_option *irc_config_server_password;
+struct t_config_option *irc_config_server_nick1;
+struct t_config_option *irc_config_server_nick2;
+struct t_config_option *irc_config_server_nick3;
+struct t_config_option *irc_config_server_username;
+struct t_config_option *irc_config_server_realname;
+struct t_config_option *irc_config_server_hostname;
+struct t_config_option *irc_config_server_command;
+struct t_config_option *irc_config_server_command_delay;
+struct t_config_option *irc_config_server_autojoin;
+struct t_config_option *irc_config_server_autorejoin;
+struct t_config_option *irc_config_server_notify_levels;
+
+struct t_irc_server *irc_config_server = NULL;
-/*
- * irc_config_change_noop: called when an option is changed by /set command
- * and that no special action is needed after that
- */
-
-void
-irc_config_change_noop ()
-{
- /* do nothing */
-}
/*
* irc_config_change_one_server_buffer: called when the "one server buffer"
@@ -389,10 +116,11 @@ irc_config_change_noop ()
void
irc_config_change_one_server_buffer ()
{
- if (irc_cfg_irc_one_server_buffer)
+ /*if (irc_config_irc_one_server_buffer)
irc_buffer_merge_servers (gui_current_window);
else
irc_buffer_split_server (gui_current_window);
+ */
}
/*
@@ -402,19 +130,21 @@ irc_config_change_one_server_buffer ()
void
irc_config_change_away_check ()
{
- if (irc_hook_timer_check_away)
+ if (irc_timer_check_away)
{
- weechat_hook_remove (irc_hook_timer_check_away);
- irc_hook_timer_check_away = NULL;
+ weechat_unhook (irc_timer_check_away);
+ irc_timer_check_away = NULL;
}
- if (irc_cfg_irc_away_check == 0)
+ if (weechat_config_integer (irc_config_irc_away_check) == 0)
{
/* reset away flag for all nicks/chans/servers */
- irc_server_remove_away ();
+ //irc_server_remove_away ();
}
- weechat_hook_add_timer (irc_cfg_irc_away_check * 60 * 1000,
- irc_server_timer_check_away,
- NULL);
+ /*irc_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_irc_away_check) * 60 * 1000,
+ 0,
+ irc_server_timer_check_away,
+ NULL);
+ */
}
/*
@@ -425,7 +155,7 @@ irc_config_change_away_check ()
void
irc_config_change_log ()
{
- t_gui_buffer *ptr_buffer;
+ /*t_gui_buffer *ptr_buffer;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -439,30 +169,31 @@ irc_config_change_log ()
if (ptr_server && !ptr_channel)
{
- if (irc_cfg_log_auto_server && !ptr_buffer->log_file)
+ if (irc_config_log_auto_server && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
- else if (!irc_cfg_log_auto_server && ptr_buffer->log_file)
+ else if (!irc_config_log_auto_server && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
if (ptr_server && ptr_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- if (irc_cfg_log_auto_channel && !ptr_buffer->log_file)
+ if (irc_config_log_auto_channel && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
- else if (!irc_cfg_log_auto_channel && ptr_buffer->log_file)
+ else if (!irc_config_log_auto_channel && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
else
{
- if (irc_cfg_log_auto_private && !ptr_buffer->log_file)
+ if (irc_config_log_auto_private && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
- else if (!irc_cfg_log_auto_private && ptr_buffer->log_file)
+ else if (!irc_config_log_auto_private && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
}
}
}
+ */
}
/*
@@ -475,243 +206,495 @@ irc_config_change_notify_levels ()
}
/*
- * irc_config_create_dirs: create configuratoin directories (read from configuration file)
+ * irc_config_read_server_line: read a server line in configuration file
*/
void
-irc_config_create_dirs ()
+irc_config_read_server_line (void *config_file, char *option_name, char *value)
{
- char *dir1, *dir2;
+ struct t_config_option *ptr_option;
+ int rc;
- /* create DCC download directory */
- dir1 = weechat_strreplace (irc_cfg_dcc_download_path, "~", getenv ("HOME"));
- dir2 = weechat_strreplace (dir1, "%h", weechat_home);
- (void) weechat_create_dir (dir2, 0700);
- if (dir1)
- free (dir1);
- if (dir2)
- free (dir2);
+ /* make C compiler happy */
+ (void) config_file;
+
+ if (option_name && value)
+ {
+ if (irc_config_server)
+ {
+ ptr_option = weechat_config_search_option (irc_config_file,
+ irc_config_section_server,
+ option_name);
+ if (ptr_option)
+ {
+ rc = weechat_config_option_set (ptr_option, value);
+ switch (rc)
+ {
+ case 2:
+ break;
+ case 1:
+ break;
+ case 0:
+ weechat_printf (NULL,
+ _("%sIrc: warning, failed to set option "
+ "\"%s\" with value \"%s\""),
+ weechat_prefix ("error"),
+ option_name, value);
+ break;
+ }
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%sIrc: warning, option not found in config "
+ "file: \"%s\""),
+ weechat_prefix ("error"),
+ option_name);
+ }
+ }
+ }
+ else
+ {
+ /* beginning of [server] section: save current server and create new
+ with default values for filling with next lines in file */
+ if (irc_config_server)
+ {
+ irc_server_init_with_config_options (irc_config_server,
+ irc_config_section_server);
+ }
+ irc_config_server = irc_server_alloc ();
+ if (!irc_config_server)
+ {
+ weechat_printf (NULL,
+ _("%sIrc: error creating server for reading "
+ "config file"),
+ weechat_prefix ("error"));
+ }
+ }
}
/*
- * irc_config_get_server_option_ptr: get a pointer to a server configuration option
+ * irc_config_write_servers: write servers in configuration file
*/
-void *
-irc_config_get_server_option_ptr (t_irc_server *server, char *option_name)
+void
+irc_config_write_servers (void *config_file, char *section_name)
{
- if (weechat_strcasecmp (option_name, "server_name") == 0)
- return (void *)(&server->name);
- if (weechat_strcasecmp (option_name, "server_autoconnect") == 0)
- return (void *)(&server->autoconnect);
- if (weechat_strcasecmp (option_name, "server_autoreconnect") == 0)
- return (void *)(&server->autoreconnect);
- if (weechat_strcasecmp (option_name, "server_autoreconnect_delay") == 0)
- return (void *)(&server->autoreconnect_delay);
- if (weechat_strcasecmp (option_name, "server_address") == 0)
- return (void *)(&server->address);
- if (weechat_strcasecmp (option_name, "server_port") == 0)
- return (void *)(&server->port);
- if (weechat_strcasecmp (option_name, "server_ipv6") == 0)
- return (void *)(&server->ipv6);
- if (weechat_strcasecmp (option_name, "server_ssl") == 0)
- return (void *)(&server->ssl);
- if (weechat_strcasecmp (option_name, "server_password") == 0)
- return (void *)(&server->password);
- if (weechat_strcasecmp (option_name, "server_nick1") == 0)
- return (void *)(&server->nick1);
- if (weechat_strcasecmp (option_name, "server_nick2") == 0)
- return (void *)(&server->nick2);
- if (weechat_strcasecmp (option_name, "server_nick3") == 0)
- return (void *)(&server->nick3);
- if (weechat_strcasecmp (option_name, "server_username") == 0)
- return (void *)(&server->username);
- if (weechat_strcasecmp (option_name, "server_realname") == 0)
- return (void *)(&server->realname);
- if (weechat_strcasecmp (option_name, "server_hostname") == 0)
- return (void *)(&server->hostname);
- if (weechat_strcasecmp (option_name, "server_command") == 0)
- return (void *)(&server->command);
- if (weechat_strcasecmp (option_name, "server_command_delay") == 0)
- return (void *)(&server->command_delay);
- if (weechat_strcasecmp (option_name, "server_autojoin") == 0)
- return (void *)(&server->autojoin);
- if (weechat_strcasecmp (option_name, "server_autorejoin") == 0)
- return (void *)(&server->autorejoin);
- if (weechat_strcasecmp (option_name, "server_notify_levels") == 0)
- return (void *)(&server->notify_levels);
- /* option not found */
- return NULL;
+ struct t_irc_server *ptr_server;
+
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ if (!ptr_server->temp_server)
+ {
+ weechat_config_write_line (config_file, section_name, NULL);
+ weechat_config_write_line (config_file, "server_name", "\"%s\"",
+ ptr_server->name);
+ weechat_config_write_line (config_file, "server_autoconnect", "%s",
+ (ptr_server->autoconnect) ? "on" : "off");
+ weechat_config_write_line (config_file, "server_autoreconnect", "%s",
+ (ptr_server->autoreconnect) ? "on" : "off");
+ weechat_config_write_line (config_file, "server_autoreconnect_delay", "%d",
+ ptr_server->autoreconnect_delay);
+ weechat_config_write_line (config_file, "server_address", "\"%s\"", ptr_server->address);
+ weechat_config_write_line (config_file, "server_port", "%d", ptr_server->port);
+ weechat_config_write_line (config_file, "server_ipv6", "%s",
+ (ptr_server->ipv6) ? "on" : "off");
+ weechat_config_write_line (config_file, "server_ssl", "%s",
+ (ptr_server->ssl) ? "on" : "off");
+ weechat_config_write_line (config_file, "server_password", "\"%s\"",
+ (ptr_server->password) ? ptr_server->password : "");
+ weechat_config_write_line (config_file, "server_nick1", "\"%s\"",
+ ptr_server->nick1);
+ weechat_config_write_line (config_file, "server_nick2", "\"%s\"",
+ ptr_server->nick2);
+ weechat_config_write_line (config_file, "server_nick3", "\"%s\"",
+ ptr_server->nick3);
+ weechat_config_write_line (config_file, "server_username", "\"%s\"",
+ ptr_server->username);
+ weechat_config_write_line (config_file, "server_realname", "\"%s\"",
+ ptr_server->realname);
+ weechat_config_write_line (config_file, "server_hostname", "\"%s\"",
+ (ptr_server->hostname) ? ptr_server->hostname : "");
+ weechat_config_write_line (config_file, "server_command", "\"%s\"",
+ (ptr_server->command) ? ptr_server->command : "");
+ weechat_config_write_line (config_file, "server_command_delay", "%d",
+ ptr_server->command_delay);
+ weechat_config_write_line (config_file, "server_autojoin", "\"%s\"",
+ (ptr_server->autojoin) ? ptr_server->autojoin : "");
+ weechat_config_write_line (config_file, "server_autorejoin", "%s",
+ (ptr_server->autorejoin) ? "on" : "off");
+ weechat_config_write_line (config_file, "server_notify_levels", "\"%s\"",
+ (ptr_server->notify_levels) ? ptr_server->notify_levels : "");
+ }
+ }
}
/*
- * irc_config_set_server_value: set new value for an option of a server
- * return: 0 if success
- * -1 if option not found
- * -2 if bad value
+ * irc_config_write_server_default: write default server in configuration file
*/
-int
-irc_config_set_server_value (t_irc_server *server, char *option_name,
- char *value)
+void
+irc_config_write_server_default (void *config_file, char *section_name)
{
- t_config_option *ptr_option;
- int i;
- void *ptr_data;
- int int_value;
+ struct passwd *my_passwd;
+ char *realname, *pos;
+
+ weechat_config_write_line (config_file, section_name, NULL);
- ptr_data = irc_config_get_server_option_ptr (server, option_name);
- if (!ptr_data)
- return -1;
+ weechat_config_write_line (config_file, "server_name", "%s", "\"freenode\"");
+ weechat_config_write_line (config_file, "server_autoconnect", "%s", "off");
+ weechat_config_write_line (config_file, "server_autoreconnect", "%s", "on");
+ weechat_config_write_line (config_file, "server_autoreconnect_delay", "%s", "30");
+ weechat_config_write_line (config_file, "server_address", "%s", "\"irc.freenode.net\"");
+ weechat_config_write_line (config_file, "server_port", "%s", "6667");
+ weechat_config_write_line (config_file, "server_ipv6", "%s", "off");
+ weechat_config_write_line (config_file, "server_ssl", "%s", "off");
+ weechat_config_write_line (config_file, "server_password", "%s", "\"\"");
- ptr_option = NULL;
- for (i = 0; irc_options_server[i].name; i++)
+ /* Get the user's name from /etc/passwd */
+ if ((my_passwd = getpwuid (geteuid ())) != NULL)
{
- /* if option found, return pointer */
- if (weechat_strcasecmp (irc_options_server[i].name, option_name) == 0)
+ weechat_config_write_line (config_file, "server_nick1", "\"%s\"", my_passwd->pw_name);
+ weechat_config_write_line (config_file, "server_nick2", "\"%s1\"", my_passwd->pw_name);
+ weechat_config_write_line (config_file, "server_nick3", "\"%s2\"", my_passwd->pw_name);
+ weechat_config_write_line (config_file, "server_username", "\"%s\"", my_passwd->pw_name);
+ if ((!my_passwd->pw_gecos)
+ || (my_passwd->pw_gecos[0] == '\0')
+ || (my_passwd->pw_gecos[0] == ',')
+ || (my_passwd->pw_gecos[0] == ' '))
+ weechat_config_write_line (config_file, "server_realname", "\"%s\"", my_passwd->pw_name);
+ else
{
- ptr_option = &irc_options_server[i];
- break;
+ realname = strdup (my_passwd->pw_gecos);
+ pos = strchr (realname, ',');
+ if (pos)
+ pos[0] = '\0';
+ weechat_config_write_line (config_file, "server_realname", "\"%s\"",
+ realname);
+ if (pos)
+ pos[0] = ',';
+ free (realname);
}
}
- if (!ptr_option)
- return -1;
-
- switch (ptr_option->type)
+ else
{
- case OPTION_TYPE_BOOLEAN:
- int_value = config_option_option_get_boolean_value (value);
- switch (int_value)
- {
- case BOOL_TRUE:
- *((int *)(ptr_data)) = BOOL_TRUE;
- break;
- case BOOL_FALSE:
- *((int *)(ptr_data)) = BOOL_FALSE;
- break;
- default:
- return -2;
- }
- break;
- case OPTION_TYPE_INT:
- int_value = atoi (value);
- if ((int_value < ptr_option->min) || (int_value > ptr_option->max))
- return -2;
- *((int *)(ptr_data)) = int_value;
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- int_value = config_option_get_pos_array_values (ptr_option->array_values,
- value);
- if (int_value < 0)
- return -2;
- *((int *)(ptr_data)) = int_value;
- break;
- case OPTION_TYPE_COLOR:
- if (!gui_color_assign ((int *)ptr_data, value))
- return -2;
- break;
- case OPTION_TYPE_STRING:
- if (*((char **)ptr_data))
- free (*((char **)ptr_data));
- *((char **)ptr_data) = strdup (value);
- break;
+ /* default values if /etc/passwd can't be read */
+ weechat_config_write_line (config_file, "server_nick1", "%s", "\"weechat1\"");
+ weechat_config_write_line (config_file, "server_nick2", "%s", "\"weechat2\"");
+ weechat_config_write_line (config_file, "server_nick3", "%s", "\"weechat3\"");
+ weechat_config_write_line (config_file, "server_username", "%s", "\"weechat\"");
+ weechat_config_write_line (config_file, "server_realname", "%s", "\"weechat\"");
}
- if (ptr_option->handler_change != NULL)
- (void) (ptr_option->handler_change());
- return 0;
+
+ weechat_config_write_line (config_file, "server_hostname", "%s", "\"\"");
+ weechat_config_write_line (config_file, "server_command", "%s", "\"\"");
+ weechat_config_write_line (config_file, "server_command_delay", "%s", "0");
+ weechat_config_write_line (config_file, "server_autojoin", "%s", "\"\"");
+ weechat_config_write_line (config_file, "server_autorejoin", "%s", "on");
+ weechat_config_write_line (config_file, "server_notify_levels", "%s", "\"\"");
}
/*
- * irc_config_allocate_server: allocate a new server
+ * irc_config_init: init IRC configuration file
+ * return: 1 if ok, 0 if error
*/
int
-irc_config_allocate_server (char *filename, int line_number)
+irc_config_init ()
{
- if (!cfg_server.name
- || !cfg_server.address
- || cfg_server.port < 0
- || !cfg_server.nick1
- || !cfg_server.nick2
- || !cfg_server.nick3
- || !cfg_server.username
- || !cfg_server.realname)
- {
- irc_server_free_all ();
- gui_chat_printf (NULL,
- _("%s %s, line %d: new server, but previous was "
- "incomplete\n"),
- WEECHAT_WARNING, filename, line_number);
+ struct t_config_section *ptr_section;
+
+ irc_config_file = weechat_config_new (IRC_CONFIG_FILENAME);
+ if (!irc_config_file)
return 0;
-
- }
- if (irc_server_name_already_exists (cfg_server.name))
+
+ ptr_section = weechat_config_new_section (irc_config_file, "irc",
+ NULL, NULL, NULL);
+ if (!ptr_section)
{
- irc_server_free_all ();
- gui_chat_printf (NULL,
- _("%s %s, line %d: server '%s' already exists\n"),
- WEECHAT_WARNING, filename, line_number,
- cfg_server.name);
+ weechat_config_free (irc_config_file);
return 0;
}
- if (!irc_server_new (cfg_server.name,
- cfg_server.autoconnect, cfg_server.autoreconnect,
- cfg_server.autoreconnect_delay, 0, cfg_server.address,
- cfg_server.port, cfg_server.ipv6, cfg_server.ssl,
- cfg_server.password, cfg_server.nick1,
- cfg_server.nick2, cfg_server.nick3,
- cfg_server.username, cfg_server.realname,
- cfg_server.hostname, cfg_server.command,
- cfg_server.command_delay, cfg_server.autojoin,
- cfg_server.autorejoin, cfg_server.notify_levels))
+
+ irc_config_irc_one_server_buffer = weechat_config_new_option (
+ ptr_section, "irc_one_server_buffer", "boolean",
+ N_("use same buffer for all servers"),
+ NULL, 0, 0, "off", &irc_config_change_one_server_buffer);
+ irc_config_irc_open_near_server = weechat_config_new_option (
+ ptr_section, "irc_open_near_server", "boolean",
+ N_("open new channels/privates near server"),
+ NULL, 0, 0, "off", NULL);
+ irc_config_irc_nick_prefix = weechat_config_new_option (
+ ptr_section, "irc_nick_prefix", "string",
+ N_("text to display before nick in chat window"),
+ NULL, 0, 0, "", NULL);
+ irc_config_irc_nick_suffix = weechat_config_new_option (
+ ptr_section, "irc_nick_suffix", "string",
+ N_("text to display after nick in chat window"),
+ NULL, 0, 0, "", NULL);
+ irc_config_irc_display_away = weechat_config_new_option (
+ ptr_section, "irc_display_away", "integer",
+ N_("display message when (un)marking as away"),
+ "off|local|channel", 0, 0, "local", NULL);
+ irc_config_irc_show_away_once = weechat_config_new_option (
+ ptr_section, "irc_show_away_once", "boolean",
+ N_("show remote away message only once in private"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_irc_default_msg_part = weechat_config_new_option (
+ ptr_section, "irc_default_msg_part", "string",
+ N_("default part message (leaving channel) ('%v' will be replaced by "
+ "WeeChat version in string)"),
+ NULL, 0, 0, "WeeChat %v", NULL);
+ irc_config_irc_default_msg_quit = weechat_config_new_option (
+ ptr_section, "irc_default_msg_quit", "string",
+ N_("default quit message ('%v' will be replaced by WeeChat version in "
+ "string)"),
+ NULL, 0, 0, "WeeChat %v", NULL);
+ irc_config_irc_notice_as_pv = weechat_config_new_option (
+ ptr_section, "irc_notice_as_pv", "boolean",
+ N_("display notices as private messages"),
+ NULL, 0, 0, "off", NULL);
+ irc_config_irc_away_check = weechat_config_new_option (
+ ptr_section, "irc_away_check", "integer",
+ N_("interval between two checks for away (in minutes, 0 = never "
+ "check)"),
+ NULL, 0, INT_MAX, "0", &irc_config_change_away_check);
+ irc_config_irc_away_check_max_nicks = weechat_config_new_option (
+ ptr_section, "irc_away_check_max_nicks", "integer",
+ N_("do not check away nicks on channels with high number of nicks "
+ "(0 = unlimited)"),
+ NULL, 0, INT_MAX, "0", &irc_config_change_away_check);
+ irc_config_irc_lag_check = weechat_config_new_option (
+ ptr_section, "irc_lag_check", "integer",
+ N_("interval between two checks for lag (in seconds, 0 = never "
+ "check)"),
+ NULL, 0, INT_MAX, "60", NULL);
+ irc_config_irc_lag_min_show = weechat_config_new_option (
+ ptr_section, "irc_lag_min_show", "integer",
+ N_("minimum lag to show (in seconds)"),
+ NULL, 0, INT_MAX, "1", NULL);
+ irc_config_irc_lag_disconnect = weechat_config_new_option (
+ ptr_section, "irc_lag_disconnect", "integer",
+ N_("disconnect after important lag (in minutes, 0 = never "
+ "disconnect)"),
+ NULL, 0, INT_MAX, "5", NULL);
+ irc_config_irc_anti_flood = weechat_config_new_option (
+ ptr_section, "irc_anti_flood", "integer",
+ N_("anti-flood: # seconds between two user messages (0 = no "
+ "anti-flood)"),
+ NULL, 0, 5, "2", NULL);
+ irc_config_irc_highlight = weechat_config_new_option (
+ ptr_section, "irc_highlight", "string",
+ N_("comma separated list of words to highlight (case insensitive "
+ "comparison, words may begin or end with \"*\" for partial match)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_irc_colors_receive = weechat_config_new_option (
+ ptr_section, "irc_colors_receive", "boolean",
+ N_("when off, colors codes are ignored in incoming messages"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_irc_colors_send = weechat_config_new_option (
+ ptr_section, "irc_colors_send", "boolean",
+ N_("allow user to send colors with special codes (^Cb=bold, "
+ "^Ccxx=color, ^Ccxx,yy=color+background, ^Cu=underline, "
+ "^Cr=reverse)"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_irc_send_unknown_commands = weechat_config_new_option (
+ ptr_section, "irc_send_unknown_commands", "boolean",
+ N_("send unknown commands to IRC server"),
+ NULL, 0, 0, "off", NULL);
+
+ ptr_section = weechat_config_new_section (irc_config_file, "dcc",
+ NULL, NULL, NULL);
+ if (!ptr_section)
{
- irc_server_free_all ();
- gui_chat_printf (NULL,
- _("%s %s, line %d: unable to create server\n"),
- WEECHAT_WARNING, filename, line_number);
+ weechat_config_free (irc_config_file);
return 0;
}
- irc_server_destroy (&cfg_server);
- irc_server_init (&cfg_server);
-
- return 1;
-}
-
-/*
- * irc_config_read_server: read a server option in configuration file
- * Return: 0 = successful
- * -1 = option not found
- * -2 = bad format/value
- */
-
-int
-irc_config_read_server (t_config_option *options,
- char *option_name, char *value)
-{
- /* make C compiler happy */
- (void) options;
+ irc_config_dcc_auto_accept_files = weechat_config_new_option (
+ ptr_section, "dcc_auto_accept_files", "boolean",
+ N_("automatically accept incoming dcc files (use carefully!)"),
+ NULL, 0, 0, "off", NULL);
+ irc_config_dcc_auto_accept_chats = weechat_config_new_option (
+ ptr_section, "dcc_auto_accept_chats", "boolean",
+ N_("automatically accept dcc chats (use carefully!)"),
+ NULL, 0, 0, "off", NULL);
+ irc_config_dcc_timeout = weechat_config_new_option (
+ ptr_section, "dcc_timeout", "integer",
+ N_("timeout for dcc request (in seconds)"),
+ NULL, 5, INT_MAX, "300", NULL);
+ irc_config_dcc_blocksize = weechat_config_new_option (
+ ptr_section, "dcc_blocksize", "integer",
+ N_("block size for dcc packets in bytes"),
+ NULL, IRC_DCC_MIN_BLOCKSIZE, IRC_DCC_MAX_BLOCKSIZE, "65536",
+ NULL);
+ irc_config_dcc_fast_send = weechat_config_new_option (
+ ptr_section, "dcc_fast_send", "boolean",
+ N_("does not wait for ACK when sending file"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_dcc_port_range = weechat_config_new_option (
+ ptr_section, "dcc_port_range", "string",
+ N_("restricts outgoing dcc to use only ports in the given range "
+ "(useful for NAT) (syntax: a single port, ie. 5000 or a port "
+ "range, ie. 5000-5015, empty value means any port)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_dcc_own_ip = weechat_config_new_option (
+ ptr_section, "dcc_own_ip", "string",
+ N_("IP or DNS address used for outgoing dcc "
+ "(if empty, local interface IP is used)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_dcc_download_path = weechat_config_new_option (
+ ptr_section, "dcc_download_path", "string",
+ N_("path for writing incoming files with dcc"),
+ NULL, 0, 0, "%h/dcc", NULL);
+ irc_config_dcc_upload_path = weechat_config_new_option (
+ ptr_section, "dcc_upload_path", "string",
+ N_("path for reading files when sending thru dcc (when no path is "
+ "specified)"),
+ NULL, 0, 0, "~", NULL);
+ irc_config_dcc_convert_spaces = weechat_config_new_option (
+ ptr_section, "dcc_convert_spaces", "boolean",
+ N_("convert spaces to underscores when sending files"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_dcc_auto_rename = weechat_config_new_option (
+ ptr_section, "dcc_auto_rename", "boolean",
+ N_("rename incoming files if already exists (add '.1', '.2', ...)"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_dcc_auto_resume = weechat_config_new_option (
+ ptr_section, "dcc_auto_resume", "boolean",
+ N_("automatically resume dcc transfer if connection with remote host "
+ "is loosed"),
+ NULL, 0, 0, "on", NULL);
- if (option_name)
+ ptr_section = weechat_config_new_section (irc_config_file, "log",
+ NULL, NULL, NULL);
+ if (!ptr_section)
{
- if (value[0])
- {
- /* bind key (overwrite any binding with same key) */
- gui_keyboard_bind (option_name, value);
- }
- else
- {
- /* unbin key if no value given */
- gui_keyboard_unbind (option_name);
- }
+ weechat_config_free (irc_config_file);
+ return 0;
}
- else
+
+ irc_config_log_auto_server = weechat_config_new_option (
+ ptr_section, "log_auto_server", "boolean",
+ N_("automatically log server messages"),
+ NULL, 0, 0, "off", &irc_config_change_log);
+ irc_config_log_auto_channel = weechat_config_new_option (
+ ptr_section, "log_auto_channel", "boolean",
+ N_("automatically log channel chats"),
+ NULL, 0, 0, "off", &irc_config_change_log);
+ irc_config_log_auto_private = weechat_config_new_option (
+ ptr_section, "log_auto_private", "boolean",
+ N_("automatically log private chats"),
+ NULL, 0, 0, "off", &irc_config_change_log);
+ irc_config_log_hide_nickserv_pwd = weechat_config_new_option (
+ ptr_section, "log_hide_nickserv_pwd", "boolean",
+ N_("hide password displayed by nickserv"),
+ NULL, 0, 0, "on", &irc_config_change_log);
+
+ ptr_section = weechat_config_new_section (irc_config_file, "server",
+ irc_config_read_server_line,
+ irc_config_write_servers,
+ irc_config_write_server_default);
+ if (!ptr_section)
{
- /* does nothing for new [key] section */
+ weechat_config_free (irc_config_file);
+ return 0;
}
- /* all ok */
- return 0;
+ irc_config_section_server = ptr_section;
+
+ irc_config_server_name = weechat_config_new_option (
+ ptr_section, "server_name", "string",
+ N_("name associated to IRC server (for display only)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_autoconnect = weechat_config_new_option (
+ ptr_section, "server_autoconnect", "boolean",
+ N_("automatically connect to server when WeeChat is starting"),
+ NULL, 0, 0, "off", NULL);
+ irc_config_server_autoreconnect = weechat_config_new_option (
+ ptr_section, "server_autoreconnect", "boolean",
+ N_("automatically reconnect to server when disconnected"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_server_autoreconnect_delay = weechat_config_new_option (
+ ptr_section, "server_autoreconnect_delay", "integer",
+ N_("delay (in seconds) before trying again to reconnect to server"),
+ NULL, 0, 65535, "30", NULL);
+ irc_config_server_address = weechat_config_new_option (
+ ptr_section, "server_address", "string",
+ N_("IP address or hostname of IRC server"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_port = weechat_config_new_option (
+ ptr_section, "server_port", "integer",
+ N_("port for connecting to server"),
+ NULL, 0, 65535, "6667", NULL);
+ irc_config_server_ipv6 = weechat_config_new_option (
+ ptr_section, "server_ipv6", "boolean",
+ N_("use IPv6 protocol for server communication"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_server_ssl = weechat_config_new_option (
+ ptr_section, "server_ssl", "boolean",
+ N_("use SSL for server communication"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_server_password = weechat_config_new_option (
+ ptr_section, "server_password", "string",
+ N_("password for IRC server"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_nick1 = weechat_config_new_option (
+ ptr_section, "server_nick1", "string",
+ N_("nickname to use on IRC server"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_nick2 = weechat_config_new_option (
+ ptr_section, "server_nick2", "string",
+ N_("alternate nickname to use on IRC server (if nickname is already "
+ "used)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_nick3 = weechat_config_new_option (
+ ptr_section, "server_nick3", "string",
+ N_("2nd alternate nickname to use on IRC server (if alternate "
+ "nickname is already used)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_username = weechat_config_new_option (
+ ptr_section, "server_username", "string",
+ N_("user name to use on IRC server"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_realname = weechat_config_new_option (
+ ptr_section, "server_realname", "string",
+ N_("real name to use on IRC server"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_hostname = weechat_config_new_option (
+ ptr_section, "server_hostname", "string",
+ N_("custom hostname/IP for server (optional, if empty local hostname "
+ "is used)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_command = weechat_config_new_option (
+ ptr_section, "server_command", "string",
+ N_("command(s) to run when connected to server (many commands should "
+ "be separated by ';', use '\\;' for a semicolon, special variables "
+ "$nick, $channel and $server are replaced by their value)"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_command_delay = weechat_config_new_option (
+ ptr_section, "server_command_delay", "integer",
+ N_("delay (in seconds) after command was executed (example: give some "
+ "time for authentication)"),
+ NULL, 0, 3600, "0", NULL);
+ irc_config_server_autojoin = weechat_config_new_option (
+ ptr_section, "server_autojoin", "string",
+ N_("comma separated list of channels to join when connected to server "
+ "(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
+ NULL, 0, 0, "", NULL);
+ irc_config_server_autorejoin = weechat_config_new_option (
+ ptr_section, "server_autorejoin", "string",
+ N_("automatically rejoin channels when kicked"),
+ NULL, 0, 0, "on", NULL);
+ irc_config_server_notify_levels = weechat_config_new_option (
+ ptr_section, "server_notify_levels", "string",
+ N_("comma separated list of notify levels for channels of this server "
+ "(format: #channel:1,..), a channel name '*' is reserved for "
+ "server default notify level"),
+ NULL, 0, 0, "", NULL);
+
+ return 1;
}
/*
@@ -724,147 +707,30 @@ irc_config_read_server (t_config_option *options,
int
irc_config_read ()
{
- irc_server_init (&cfg_server);
+ int rc;
- return config_file_read (weechat_protocol_config_sections,
- weechat_protocol_config_options,
- irc_config_read_functions,
- irc_config_write_default_functions,
- IRC_CONFIG_NAME);
-}
+ irc_config_server = NULL;
-/*
- * irc_config_write_servers: write servers sections in configuration file
- * Return: 0 = successful
- * -1 = write error
- */
+ rc = weechat_config_read (irc_config_file);
-int
-irc_config_write_servers (FILE *file, char *section_name,
- t_config_option *options)
-{
- t_irc_server *ptr_server;
-
- /* make C compiler happy */
- (void) options;
+ if (irc_config_server)
+ irc_server_init_with_config_options (irc_config_server,
+ irc_config_section_server);
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (!ptr_server->temp_server)
- {
- weechat_iconv_fprintf (file, "\n[%s]\n", section_name);
- weechat_iconv_fprintf (file, "server_name = \"%s\"\n", ptr_server->name);
- weechat_iconv_fprintf (file, "server_autoconnect = %s\n",
- (ptr_server->autoconnect) ? "on" : "off");
- weechat_iconv_fprintf (file, "server_autoreconnect = %s\n",
- (ptr_server->autoreconnect) ? "on" : "off");
- weechat_iconv_fprintf (file, "server_autoreconnect_delay = %d\n",
- ptr_server->autoreconnect_delay);
- weechat_iconv_fprintf (file, "server_address = \"%s\"\n", ptr_server->address);
- weechat_iconv_fprintf (file, "server_port = %d\n", ptr_server->port);
- weechat_iconv_fprintf (file, "server_ipv6 = %s\n",
- (ptr_server->ipv6) ? "on" : "off");
- weechat_iconv_fprintf (file, "server_ssl = %s\n",
- (ptr_server->ssl) ? "on" : "off");
- weechat_iconv_fprintf (file, "server_password = \"%s\"\n",
- (ptr_server->password) ? ptr_server->password : "");
- weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->nick1);
- weechat_iconv_fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->nick2);
- weechat_iconv_fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
- weechat_iconv_fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
- weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
- weechat_iconv_fprintf (file, "server_hostname = \"%s\"\n",
- (ptr_server->hostname) ? ptr_server->hostname : "");
- weechat_iconv_fprintf (file, "server_command = \"%s\"\n",
- (ptr_server->command) ? ptr_server->command : "");
- weechat_iconv_fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
- weechat_iconv_fprintf (file, "server_autojoin = \"%s\"\n",
- (ptr_server->autojoin) ? ptr_server->autojoin : "");
- weechat_iconv_fprintf (file, "server_autorejoin = %s\n",
- (ptr_server->autorejoin) ? "on" : "off");
- weechat_iconv_fprintf (file, "server_notify_levels = \"%s\"\n",
- (ptr_server->notify_levels) ? ptr_server->notify_levels : "");
- }
- }
-
- /* all ok */
- return 0;
+ return rc;
}
/*
- * irc_config_write_server_default_values: write server section with default values
- * in configuration file
- * Return: 0 = successful
- * -1 = write error
+ * irc_config_reload: read IRC configuration file
+ * return: 0 = successful
+ * -1 = configuration file file not found
+ * -2 = error in configuration file
*/
int
-irc_config_write_server_default_values (FILE *file, char *section_name,
- t_config_option *options)
+irc_config_reload ()
{
- /* make C compiler happy */
- (void) options;
-
- struct passwd *my_passwd;
- char *realname, *pos;
-
- weechat_iconv_fprintf (file, "\n[%s]\n", section_name);
-
- weechat_iconv_fprintf (file, "server_name = \"freenode\"\n");
- weechat_iconv_fprintf (file, "server_autoconnect = on\n");
- weechat_iconv_fprintf (file, "server_autoreconnect = on\n");
- weechat_iconv_fprintf (file, "server_autoreconnect_delay = 30\n");
- weechat_iconv_fprintf (file, "server_address = \"irc.freenode.net\"\n");
- weechat_iconv_fprintf (file, "server_port = 6667\n");
- weechat_iconv_fprintf (file, "server_ipv6 = off\n");
- weechat_iconv_fprintf (file, "server_ssl = off\n");
- weechat_iconv_fprintf (file, "server_password = \"\"\n");
-
- /* Get the user's name from /etc/passwd */
- if ((my_passwd = getpwuid (geteuid ())) != NULL)
- {
- weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", my_passwd->pw_name);
- weechat_iconv_fprintf (file, "server_nick2 = \"%s1\"\n", my_passwd->pw_name);
- weechat_iconv_fprintf (file, "server_nick3 = \"%s2\"\n", my_passwd->pw_name);
- weechat_iconv_fprintf (file, "server_username = \"%s\"\n", my_passwd->pw_name);
- if ((!my_passwd->pw_gecos)
- || (my_passwd->pw_gecos[0] == '\0')
- || (my_passwd->pw_gecos[0] == ',')
- || (my_passwd->pw_gecos[0] == ' '))
- weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", my_passwd->pw_name);
- else
- {
- realname = strdup (my_passwd->pw_gecos);
- pos = strchr (realname, ',');
- if (pos)
- pos[0] = '\0';
- weechat_iconv_fprintf (file, "server_realname = \"%s\"\n",
- realname);
- if (pos)
- pos[0] = ',';
- free (realname);
- }
- }
- else
- {
- /* default values if /etc/passwd can't be read */
- weechat_iconv_fprintf (file, "server_nick1 = \"weechat1\"\n");
- weechat_iconv_fprintf (file, "server_nick2 = \"weechat2\"\n");
- weechat_iconv_fprintf (file, "server_nick3 = \"weechat3\"\n");
- weechat_iconv_fprintf (file, "server_username = \"weechat\"\n");
- weechat_iconv_fprintf (file, "server_realname = \"weechat\"\n");
- }
-
- weechat_iconv_fprintf (file, "server_hostname = \"\"\n");
- weechat_iconv_fprintf (file, "server_command = \"\"\n");
- weechat_iconv_fprintf (file, "server_command_delay = 0\n");
- weechat_iconv_fprintf (file, "server_autojoin = \"\"\n");
- weechat_iconv_fprintf (file, "server_autorejoin = on\n");
- weechat_iconv_fprintf (file, "server_notify_levels = \"\"\n");
-
- /* all ok */
- return 0;
+ return weechat_config_reload (irc_config_file);
}
/*
@@ -876,8 +742,5 @@ irc_config_write_server_default_values (FILE *file, char *section_name,
int
irc_config_write ()
{
- return config_file_write (weechat_protocol_config_sections,
- weechat_protocol_config_options,
- irc_config_write_functions,
- IRC_CONFIG_NAME);
+ return weechat_config_write (irc_config_file);
}
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 1d3efedb4..6dc336005 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -20,62 +20,60 @@
#ifndef __WEECHAT_IRC_CONFIG_H
#define __WEECHAT_IRC_CONFIG_H 1
-#include "../../core/config-option.h"
+#define IRC_CONFIG_FILENAME "irc.rc"
-#define IRC_CONFIG_NAME "irc.rc"
+#define IRC_CONFIG_DISPLAY_AWAY_OFF 0
+#define IRC_CONFIG_DISPLAY_AWAY_LOCAL 1
+#define IRC_CONFIG_DISPLAY_AWAY_CHANNEL 2
-#define CFG_IRC_DISPLAY_AWAY_OFF 0
-#define CFG_IRC_DISPLAY_AWAY_LOCAL 1
-#define CFG_IRC_DISPLAY_AWAY_CHANNEL 2
+struct t_config_file *irc_config;
-extern int irc_cfg_irc_one_server_buffer;
-extern int irc_cfg_irc_open_near_server;
-extern char *irc_cfg_irc_nick_prefix;
-extern char *irc_cfg_irc_nick_suffix;
-extern int irc_cfg_irc_display_away;
-extern int irc_cfg_irc_show_away_once;
-extern char *irc_cfg_irc_default_msg_part;
-extern char *irc_cfg_irc_default_msg_quit;
-extern int irc_cfg_irc_notice_as_pv;
-extern int irc_cfg_irc_away_check;
-extern int irc_cfg_irc_away_check_max_nicks;
-extern int irc_cfg_irc_lag_check;
-extern int irc_cfg_irc_lag_min_show;
-extern int irc_cfg_irc_lag_disconnect;
-extern int irc_cfg_irc_anti_flood;
-extern char *irc_cfg_irc_highlight;
-extern int irc_cfg_irc_colors_receive;
-extern int irc_cfg_irc_colors_send;
-extern int irc_cfg_irc_send_unknown_commands;
+struct t_config_option *irc_config_irc_one_server_buffer;
+struct t_config_option *irc_config_irc_open_near_server;
+struct t_config_option *irc_config_irc_nick_prefix;
+struct t_config_option *irc_config_irc_nick_suffix;
+struct t_config_option *irc_config_irc_display_away;
+struct t_config_option *irc_config_irc_show_away_once;
+struct t_config_option *irc_config_irc_default_msg_part;
+struct t_config_option *irc_config_irc_default_msg_quit;
+struct t_config_option *irc_config_irc_notice_as_pv;
+struct t_config_option *irc_config_irc_away_check;
+struct t_config_option *irc_config_irc_away_check_max_nicks;
+struct t_config_option *irc_config_irc_lag_check;
+struct t_config_option *irc_config_irc_lag_min_show;
+struct t_config_option *irc_config_irc_lag_disconnect;
+struct t_config_option *irc_config_irc_anti_flood;
+struct t_config_option *irc_config_irc_highlight;
+struct t_config_option *irc_config_irc_colors_receive;
+struct t_config_option *irc_config_irc_colors_send;
+struct t_config_option *irc_config_irc_send_unknown_commands;
-extern int irc_cfg_dcc_auto_accept_files;
-extern int irc_cfg_dcc_auto_accept_chats;
-extern int irc_cfg_dcc_timeout;
-extern int irc_cfg_dcc_blocksize;
-extern int irc_cfg_dcc_fast_send;
-extern char *irc_cfg_dcc_port_range;
-extern char *irc_cfg_dcc_own_ip;
-extern char *irc_cfg_dcc_download_path;
-extern char *irc_cfg_dcc_upload_path;
-extern int irc_cfg_dcc_convert_spaces;
-extern int irc_cfg_dcc_auto_rename;
-extern int irc_cfg_dcc_auto_resume;
+struct t_config_option *irc_config_dcc_auto_accept_files;
+struct t_config_option *irc_config_dcc_auto_accept_chats;
+struct t_config_option *irc_config_dcc_timeout;
+struct t_config_option *irc_config_dcc_blocksize;
+struct t_config_option *irc_config_dcc_fast_send;
+struct t_config_option *irc_config_dcc_port_range;
+struct t_config_option *irc_config_dcc_own_ip;
+struct t_config_option *irc_config_dcc_download_path;
+struct t_config_option *irc_config_dcc_upload_path;
+struct t_config_option *irc_config_dcc_convert_spaces;
+struct t_config_option *irc_config_dcc_auto_rename;
+struct t_config_option *irc_config_dcc_auto_resume;
-extern int irc_cfg_log_auto_server;
-extern int irc_cfg_log_auto_channel;
-extern int irc_cfg_log_auto_private;
-extern int irc_cfg_log_hide_nickserv_pwd;
+struct t_config_option *irc_config_log_auto_server;
+struct t_config_option *irc_config_log_auto_channel;
+struct t_config_option *irc_config_log_auto_private;
+struct t_config_option *irc_config_log_hide_nickserv_pwd;
-extern void irc_config_change_noop ();
-extern void irc_config_change_one_server_buffer ();
-extern void irc_config_change_away_check ();
-extern void irc_config_change_log ();
-extern void irc_config_change_notify_levels ();
-extern int irc_config_read_server (t_config_option *, char *, char *);
-extern int irc_config_read ();
-extern int irc_config_write_servers (FILE *, char *, t_config_option *);
-extern int irc_config_write_servers_default_values (FILE *, char *,
- t_config_option *);
-extern int irc_config_write ();
+void irc_config_change_noop ();
+void irc_config_change_one_server_buffer ();
+void irc_config_change_away_check ();
+void irc_config_change_log ();
+void irc_config_change_notify_levels ();
+int irc_config_init ();
+int irc_config_read ();
+int irc_config_reload ();
+int irc_config_write ();
#endif /* irc-config.h */
diff --git a/src/plugins/irc/irc-dcc.c b/src/plugins/irc/irc-dcc.c
index 9d5cd76de..3c6b130e4 100644
--- a/src/plugins/irc/irc-dcc.c
+++ b/src/plugins/irc/irc-dcc.c
@@ -39,17 +39,15 @@
#include <arpa/inet.h>
#include <netdb.h>
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/log.h"
-#include "../../core/util.h"
-#include "../../core/weechat-config.h"
-#include "../../gui/gui.h"
+#include "irc-dcc.h"
+#include "irc-config.h"
-t_irc_dcc *irc_dcc_list = NULL; /* DCC files & chat list */
-t_irc_dcc *irc_last_dcc = NULL; /* last DCC in list */
-char *irc_dcc_status_string[] = /* strings for DCC status */
+struct t_irc_dcc *irc_dcc_list = NULL; /* DCC files & chat list */
+struct t_irc_dcc *irc_last_dcc = NULL; /* last DCC in list */
+
+char *irc_dcc_status_string[] = /* strings for DCC status */
{ N_("Waiting"), N_("Connecting"), N_("Active"), N_("Done"), N_("Failed"),
N_("Aborted") };
@@ -61,7 +59,8 @@ char *irc_dcc_status_string[] = /* strings for DCC status */
void
irc_dcc_redraw (int highlight)
{
- t_gui_buffer *ptr_buffer;
+ (void) highlight;
+ /*struct t_gui_buffer *ptr_buffer;
ptr_buffer = gui_buffer_get_dcc (gui_current_window);
gui_window_redraw_buffer (ptr_buffer);
@@ -70,16 +69,17 @@ irc_dcc_redraw (int highlight)
gui_hotlist_add (highlight, NULL, ptr_buffer, 0);
gui_status_draw (gui_current_window->buffer, 0);
}
+ */
}
/*
* irc_dcc_search: search a DCC
*/
-t_irc_dcc *
-irc_dcc_search (t_irc_server *server, int type, int status, int port)
+struct t_irc_dcc *
+irc_dcc_search (struct t_irc_server *server, int type, int status, int port)
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
{
@@ -102,7 +102,7 @@ irc_dcc_search (t_irc_server *server, int type, int status, int port)
int
irc_dcc_port_in_use (int port)
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
/* skip any currently used ports */
for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
@@ -120,7 +120,7 @@ irc_dcc_port_in_use (int port)
*/
int
-irc_dcc_file_is_resumable (t_irc_dcc *ptr_dcc, char *filename)
+irc_dcc_file_is_resumable (struct t_irc_dcc *ptr_dcc, char *filename)
{
struct stat st;
@@ -152,7 +152,7 @@ irc_dcc_file_is_resumable (t_irc_dcc *ptr_dcc, char *filename)
*/
void
-irc_dcc_find_filename (t_irc_dcc *ptr_dcc)
+irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
{
char *dir1, *dir2, *filename2;
@@ -236,7 +236,7 @@ irc_dcc_find_filename (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_calculate_speed (t_irc_dcc *ptr_dcc, int ended)
+irc_dcc_calculate_speed (struct t_irc_dcc *ptr_dcc, int ended)
{
time_t local_time, elapsed;
unsigned long bytes_per_sec_total;
@@ -280,7 +280,7 @@ irc_dcc_calculate_speed (t_irc_dcc *ptr_dcc, int ended)
*/
int
-irc_dcc_connect_to_sender (t_irc_dcc *ptr_dcc)
+irc_dcc_connect_to_sender (struct t_irc_dcc *ptr_dcc)
{
struct sockaddr_in addr;
struct hostent *hostent;
@@ -324,7 +324,7 @@ irc_dcc_connect_to_sender (t_irc_dcc *ptr_dcc)
*/
int
-irc_dcc_connect (t_irc_dcc *ptr_dcc)
+irc_dcc_connect (struct t_irc_dcc *ptr_dcc)
{
if (ptr_dcc->type == IRC_DCC_CHAT_SEND)
ptr_dcc->status = IRC_DCC_WAITING;
@@ -367,9 +367,9 @@ irc_dcc_connect (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_free (t_irc_dcc *ptr_dcc)
+irc_dcc_free (struct t_irc_dcc *ptr_dcc)
{
- t_irc_dcc *new_dcc_list;
+ struct t_irc_dcc *new_dcc_list;
if (!ptr_dcc)
return;
@@ -380,7 +380,7 @@ irc_dcc_free (t_irc_dcc *ptr_dcc)
{
/* check if channel is used for another active DCC CHAT */
if (!ptr_dcc->channel->dcc_chat
- || (IRC_DCC_ENDED(((t_irc_dcc *)(ptr_dcc->channel->dcc_chat))->status)))
+ || (IRC_DCC_ENDED(((struct t_irc_dcc *)(ptr_dcc->channel->dcc_chat))->status)))
{
gui_buffer_free (ptr_dcc->channel->buffer, 1);
if (ptr_dcc->channel)
@@ -418,7 +418,7 @@ irc_dcc_free (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_kill (t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_kill (struct t_irc_dcc *ptr_dcc)
{
/* kill process */
if (ptr_dcc->child_pid > 0)
@@ -446,7 +446,7 @@ irc_dcc_file_child_kill (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_close (t_irc_dcc *ptr_dcc, int status)
+irc_dcc_close (struct t_irc_dcc *ptr_dcc, int status)
{
t_gui_buffer *ptr_buffer;
struct stat st;
@@ -541,7 +541,7 @@ irc_dcc_close (t_irc_dcc *ptr_dcc, int status)
*/
void
-irc_dcc_channel_for_chat (t_irc_dcc *ptr_dcc)
+irc_dcc_channel_for_chat (struct t_irc_dcc *ptr_dcc)
{
if (!irc_channel_create_dcc (ptr_dcc))
{
@@ -576,9 +576,9 @@ irc_dcc_channel_for_chat (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_chat_remove_channel (t_irc_channel *channel)
+irc_dcc_chat_remove_channel (struct t_irc_channel *channel)
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
if (!channel)
return;
@@ -595,7 +595,7 @@ irc_dcc_chat_remove_channel (t_irc_channel *channel)
*/
void
-irc_dcc_recv_connect_init (t_irc_dcc *ptr_dcc)
+irc_dcc_recv_connect_init (struct t_irc_dcc *ptr_dcc)
{
if (!irc_dcc_connect (ptr_dcc))
{
@@ -625,7 +625,7 @@ irc_dcc_recv_connect_init (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_accept (t_irc_dcc *ptr_dcc)
+irc_dcc_accept (struct t_irc_dcc *ptr_dcc)
{
if (IRC_DCC_IS_FILE(ptr_dcc->type) && (ptr_dcc->start_resume > 0))
{
@@ -647,10 +647,10 @@ irc_dcc_accept (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_accept_resume (t_irc_server *server, char *filename, int port,
+irc_dcc_accept_resume (struct t_irc_server *server, char *filename, int port,
unsigned long pos_start)
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_SEND, IRC_DCC_CONNECTING,
port);
@@ -688,10 +688,10 @@ irc_dcc_accept_resume (t_irc_server *server, char *filename, int port,
*/
void
-irc_dcc_start_resume (t_irc_server *server, char *filename, int port,
+irc_dcc_start_resume (struct t_irc_server *server, char *filename, int port,
unsigned long pos_start)
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_RECV, IRC_DCC_CONNECTING,
port);
@@ -714,13 +714,13 @@ irc_dcc_start_resume (t_irc_server *server, char *filename, int port,
* irc_dcc_alloc: allocate a new DCC file
*/
-t_irc_dcc *
+struct t_irc_dcc *
irc_dcc_alloc ()
{
- t_irc_dcc *new_dcc;
+ struct t_irc_dcc *new_dcc;
/* create new DCC struct */
- if ((new_dcc = (t_irc_dcc *) malloc (sizeof (t_irc_dcc))) == NULL)
+ if ((new_dcc = (struct t_irc_dcc *) malloc (sizeof (struct t_irc_dcc))) == NULL)
return NULL;
/* default values */
@@ -769,11 +769,11 @@ irc_dcc_alloc ()
* irc_dcc_add: add a DCC file to queue
*/
-t_irc_dcc *
-irc_dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nick,
+struct t_irc_dcc *
+irc_dcc_add (struct t_irc_server *server, int type, unsigned long addr, int port, char *nick,
int sock, char *filename, char *local_filename, unsigned long size)
{
- t_irc_dcc *new_dcc;
+ struct t_irc_dcc *new_dcc;
new_dcc = irc_dcc_alloc ();
if (!new_dcc)
@@ -937,7 +937,7 @@ irc_dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char
*/
void
-irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename)
+irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *filename)
{
char *dir1, *dir2, *filename2, *short_filename, *pos;
int spaces, args, port_start, port_end;
@@ -948,7 +948,7 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
struct sockaddr_in addr;
socklen_t length;
unsigned long local_addr;
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
filename2 = NULL;
short_filename = NULL;
@@ -1177,7 +1177,7 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
*/
int
-irc_dcc_chat_send (t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
+irc_dcc_chat_send (struct t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
{
if (!ptr_dcc)
return -1;
@@ -1190,7 +1190,7 @@ irc_dcc_chat_send (t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
*/
void
-irc_dcc_chat_sendf (t_irc_dcc *ptr_dcc, char *fmt, ...)
+irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
{
va_list args;
static char buffer[4096];
@@ -1231,7 +1231,7 @@ irc_dcc_chat_sendf (t_irc_dcc *ptr_dcc, char *fmt, ...)
*/
void
-irc_dcc_chat_recv (t_irc_dcc *ptr_dcc)
+irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1348,7 +1348,7 @@ irc_dcc_chat_recv (t_irc_dcc *ptr_dcc)
*/
int
-irc_dcc_file_create_pipe (t_irc_dcc *ptr_dcc)
+irc_dcc_file_create_pipe (struct t_irc_dcc *ptr_dcc)
{
int child_pipe[2];
@@ -1372,7 +1372,7 @@ irc_dcc_file_create_pipe (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_write_pipe (t_irc_dcc *ptr_dcc, int status, int error)
+irc_dcc_file_write_pipe (struct t_irc_dcc *ptr_dcc, int status, int error)
{
char buffer[1 + 1 + 12 + 1]; /* status + error + pos + \0 */
@@ -1386,7 +1386,7 @@ irc_dcc_file_write_pipe (t_irc_dcc *ptr_dcc, int status, int error)
*/
void
-irc_dcc_file_send_child (t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
{
int num_read, num_sent;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1472,7 +1472,7 @@ irc_dcc_file_send_child (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_child (t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
{
int num_read;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1546,7 +1546,7 @@ irc_dcc_file_recv_child (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_read (t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1650,7 +1650,7 @@ irc_dcc_file_child_read (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_send_fork (t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_fork (struct t_irc_dcc *ptr_dcc)
{
pid_t pid;
@@ -1685,7 +1685,7 @@ irc_dcc_file_send_fork (t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_fork (t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
{
pid_t pid;
@@ -1728,7 +1728,7 @@ irc_dcc_file_recv_fork (t_irc_dcc *ptr_dcc)
void
irc_dcc_handle ()
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
fd_set read_fd;
static struct timeval timeout;
int sock;
@@ -1867,14 +1867,14 @@ irc_dcc_handle ()
void
irc_dcc_end ()
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
{
if (ptr_dcc->sock >= 0)
{
if (ptr_dcc->status == IRC_DCC_ACTIVE)
- weechat_log_printf (_("Aborting active DCC: \"%s\" from %s\n"),
+ weechat_log_printf (_("Aborting active DCC: \"%s\" from %s"),
ptr_dcc->filename, ptr_dcc->nick);
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
}
@@ -1888,42 +1888,42 @@ irc_dcc_end ()
void
irc_dcc_print_log ()
{
- t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *ptr_dcc;
for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
{
- weechat_log_printf ("\n");
- weechat_log_printf ("[DCC (addr:0x%X)]\n", ptr_dcc);
- weechat_log_printf (" server. . . . . . . : 0x%X\n", ptr_dcc->server);
- weechat_log_printf (" channel . . . . . . : 0x%X\n", ptr_dcc->channel);
- weechat_log_printf (" type. . . . . . . . : %d\n", ptr_dcc->type);
- weechat_log_printf (" status. . . . . . . : %d\n", ptr_dcc->status);
- weechat_log_printf (" start_time. . . . . : %ld\n", ptr_dcc->start_time);
- weechat_log_printf (" start_transfer. . . : %ld\n", ptr_dcc->start_transfer);
- weechat_log_printf (" addr. . . . . . . . : %lu\n", ptr_dcc->addr);
- weechat_log_printf (" port. . . . . . . . : %d\n", ptr_dcc->port);
- weechat_log_printf (" nick. . . . . . . . : '%s'\n", ptr_dcc->nick);
- weechat_log_printf (" sock. . . . . . . . : %d\n", ptr_dcc->sock);
- weechat_log_printf (" child_pid . . . . . : %d\n", ptr_dcc->child_pid);
- weechat_log_printf (" child_read. . . . . : %d\n", ptr_dcc->child_read);
- weechat_log_printf (" child_write . . . . : %d\n", ptr_dcc->child_write);
- weechat_log_printf (" unterminated_message: '%s'\n", ptr_dcc->unterminated_message);
- weechat_log_printf (" fast_send . . . . . : %d\n", ptr_dcc->fast_send);
- weechat_log_printf (" file. . . . . . . . : %d\n", ptr_dcc->file);
- weechat_log_printf (" filename. . . . . . : '%s'\n", ptr_dcc->filename);
- weechat_log_printf (" local_filename. . . : '%s'\n", ptr_dcc->local_filename);
- weechat_log_printf (" filename_suffix . . : %d\n", ptr_dcc->filename_suffix);
- weechat_log_printf (" blocksize . . . . . : %d\n", ptr_dcc->blocksize);
- weechat_log_printf (" size. . . . . . . . : %lu\n", ptr_dcc->size);
- weechat_log_printf (" pos . . . . . . . . : %lu\n", ptr_dcc->pos);
- weechat_log_printf (" ack . . . . . . . . : %lu\n", ptr_dcc->ack);
- weechat_log_printf (" start_resume. . . . : %lu\n", ptr_dcc->start_resume);
- weechat_log_printf (" last_check_time . . : %ld\n", ptr_dcc->last_check_time);
- weechat_log_printf (" last_check_pos. . . : %lu\n", ptr_dcc->last_check_pos);
- weechat_log_printf (" last_activity . . . : %ld\n", ptr_dcc->last_activity);
- weechat_log_printf (" bytes_per_sec . . . : %lu\n", ptr_dcc->bytes_per_sec);
- weechat_log_printf (" eta . . . . . . . . : %lu\n", ptr_dcc->eta);
- weechat_log_printf (" prev_dcc. . . . . . : 0x%X\n", ptr_dcc->prev_dcc);
- weechat_log_printf (" next_dcc. . . . . . : 0x%X\n", ptr_dcc->next_dcc);
+ weechat_log_printf ("");
+ weechat_log_printf ("[DCC (addr:0x%X)]", ptr_dcc);
+ weechat_log_printf (" server. . . . . . . : 0x%X", ptr_dcc->server);
+ weechat_log_printf (" channel . . . . . . : 0x%X", ptr_dcc->channel);
+ weechat_log_printf (" type. . . . . . . . : %d", ptr_dcc->type);
+ weechat_log_printf (" status. . . . . . . : %d", ptr_dcc->status);
+ weechat_log_printf (" start_time. . . . . : %ld", ptr_dcc->start_time);
+ weechat_log_printf (" start_transfer. . . : %ld", ptr_dcc->start_transfer);
+ weechat_log_printf (" addr. . . . . . . . : %lu", ptr_dcc->addr);
+ weechat_log_printf (" port. . . . . . . . : %d", ptr_dcc->port);
+ weechat_log_printf (" nick. . . . . . . . : '%s'", ptr_dcc->nick);
+ weechat_log_printf (" sock. . . . . . . . : %d", ptr_dcc->sock);
+ weechat_log_printf (" child_pid . . . . . : %d", ptr_dcc->child_pid);
+ weechat_log_printf (" child_read. . . . . : %d", ptr_dcc->child_read);
+ weechat_log_printf (" child_write . . . . : %d", ptr_dcc->child_write);
+ weechat_log_printf (" unterminated_message: '%s'", ptr_dcc->unterminated_message);
+ weechat_log_printf (" fast_send . . . . . : %d", ptr_dcc->fast_send);
+ weechat_log_printf (" file. . . . . . . . : %d", ptr_dcc->file);
+ weechat_log_printf (" filename. . . . . . : '%s'", ptr_dcc->filename);
+ weechat_log_printf (" local_filename. . . : '%s'", ptr_dcc->local_filename);
+ weechat_log_printf (" filename_suffix . . : %d", ptr_dcc->filename_suffix);
+ weechat_log_printf (" blocksize . . . . . : %d", ptr_dcc->blocksize);
+ weechat_log_printf (" size. . . . . . . . : %lu", ptr_dcc->size);
+ weechat_log_printf (" pos . . . . . . . . : %lu", ptr_dcc->pos);
+ weechat_log_printf (" ack . . . . . . . . : %lu", ptr_dcc->ack);
+ weechat_log_printf (" start_resume. . . . : %lu", ptr_dcc->start_resume);
+ weechat_log_printf (" last_check_time . . : %ld", ptr_dcc->last_check_time);
+ weechat_log_printf (" last_check_pos. . . : %lu", ptr_dcc->last_check_pos);
+ weechat_log_printf (" last_activity . . . : %ld", ptr_dcc->last_activity);
+ weechat_log_printf (" bytes_per_sec . . . : %lu", ptr_dcc->bytes_per_sec);
+ weechat_log_printf (" eta . . . . . . . . : %lu", ptr_dcc->eta);
+ weechat_log_printf (" prev_dcc. . . . . . : 0x%X", ptr_dcc->prev_dcc);
+ weechat_log_printf (" next_dcc. . . . . . : 0x%X", ptr_dcc->next_dcc);
}
}
diff --git a/src/plugins/irc/irc-dcc.h b/src/plugins/irc/irc-dcc.h
index 27cab49bb..af8f0baf7 100644
--- a/src/plugins/irc/irc-dcc.h
+++ b/src/plugins/irc/irc-dcc.h
@@ -20,6 +20,9 @@
#ifndef __WEECHAT_IRC_DCC_H
#define __WEECHAT_IRC_DCC_H 1
+#include "irc-server.h"
+#include "irc-channel.h"
+
/* DCC types */
#define IRC_DCC_CHAT_RECV 0 /* receiving DCC chat */
@@ -107,4 +110,22 @@ extern struct t_irc_dcc *irc_dcc_list;
extern struct t_irc_dcc *irc_last_dcc;
extern char *irc_dcc_status_string[6];
+extern void irc_dcc_redraw (int);
+extern void irc_dcc_free (struct t_irc_dcc *);
+extern void irc_dcc_close (struct t_irc_dcc *, int);
+extern void irc_dcc_chat_remove_channel (struct t_irc_channel *);
+extern void irc_dcc_accept (struct t_irc_dcc *);
+extern void irc_dcc_accept_resume (struct t_irc_server *, char *, int, unsigned long);
+extern void irc_dcc_start_resume (struct t_irc_server *, char *, int, unsigned long);
+extern struct t_irc_dcc *irc_dcc_alloc ();
+extern struct t_irc_dcc *irc_dcc_add (struct t_irc_server *, int, unsigned long, int, char *, int,
+ char *, char *, unsigned long);
+extern void irc_dcc_send_request (struct t_irc_server *, int, char *, char *);
+extern void irc_dcc_chat_sendf (struct t_irc_dcc *, char *, ...);
+extern void irc_dcc_file_send_fork (struct t_irc_dcc *);
+extern void irc_dcc_file_recv_fork (struct t_irc_dcc *);
+extern void irc_dcc_handle ();
+extern void irc_dcc_end ();
+extern void irc_dcc_print_log ();
+
#endif /* irc-dcc.h */
diff --git a/src/plugins/charset/charset.h b/src/plugins/irc/irc-display.h
index b4bcaec53..778eea778 100644
--- a/src/plugins/charset/charset.h
+++ b/src/plugins/irc/irc-display.h
@@ -16,17 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* weechat-charset.h: Charset plugin support for WeeChat */
-#ifndef WEECHAT_CHARSET__H
-#define WEECHAT_CHARSET__H 1
+#ifndef __WEECHAT_IRC_DISPLAY_H
+#define __WEECHAT_IRC_DISPLAY_H 1
-#define _PLUGIN_NAME "charset"
-#define _PLUGIN_VERSION "0.1"
-#define _PLUGIN_DESC "Charset plugin for WeeChat"
+extern void irc_display_hide_password (char *, int);
+extern void irc_display_nick (struct t_gui_buffer *, struct t_irc_nick *,
+ char *, int, int, char *, int);
+extern void irc_display_away (struct t_irc_server *, char *, char *);
+extern void irc_display_mode (struct t_gui_buffer *, char *, char *,
+ char, char *, char *, char *, char *);
+extern void irc_display_server (struct t_irc_server *, int);
-char plugin_name[] = _PLUGIN_NAME;
-char plugin_version[] = _PLUGIN_VERSION;
-char plugin_description[] = _PLUGIN_DESC;
-
-#endif /* WEECHAT_CHARSET__H */
+#endif /* irc-display.h */
diff --git a/src/plugins/demo/demo.h b/src/plugins/irc/irc-mode.h
index c55ece428..814788e52 100644
--- a/src/plugins/demo/demo.h
+++ b/src/plugins/irc/irc-mode.h
@@ -17,11 +17,12 @@
*/
-#ifndef __WEECHAT_DEMO_H
-#define __WEECHAT_DEMO_H 1
+#ifndef __WEECHAT_IRC_MODE_H
+#define __WEECHAT_IRC_MODE_H 1
-char plugin_name[] = "demo";
-char plugin_version[] = "0.1";
-char plugin_description[] = "Demo plugin for WeeChat";
+extern void irc_mode_channel_set (struct t_irc_server *, struct t_irc_channel *,
+ char *);
+extern void irc_mode_user_set (struct t_irc_server *, char *);
+extern int irc_mode_nick_prefix_allowed (struct t_irc_server *, char);
-#endif /* demo.h */
+#endif /* irc-mode.h */
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 2357c8833..db56a16ba 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -27,12 +27,10 @@
#include <string.h>
#include <limits.h>
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/log.h"
-#include "../../core/utf8.h"
-#include "../../core/util.h"
-#include "../../core/weechat-config.h"
+#include "irc-nick.h"
+#include "irc-server.h"
+#include "irc-channel.h"
/*
@@ -40,7 +38,7 @@
*/
int
-irc_nick_find_color (t_irc_nick *nick)
+irc_nick_find_color (struct t_irc_nick *nick)
{
int i, color;
@@ -49,9 +47,9 @@ irc_nick_find_color (t_irc_nick *nick)
{
color += (int)(nick->nick[i]);
}
- color = (color % cfg_look_color_nicks_number);
+ color = (color % weechat_config_integer (weechat_config_get ("look_color_nicks_number")));
- return GUI_COLOR_CHAT_NICK1 + color;
+ return color;
}
/*
@@ -60,56 +58,56 @@ irc_nick_find_color (t_irc_nick *nick)
*/
void
-irc_nick_get_gui_infos (t_irc_nick *nick,
+irc_nick_get_gui_infos (struct t_irc_nick *nick,
int *sort_index, char *prefix, int *color_prefix)
{
if (nick->flags & IRC_NICK_CHANOWNER)
{
*sort_index = 1;
*prefix = '~';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
+ *color_prefix = 1;
}
else if (nick->flags & IRC_NICK_CHANADMIN)
{
*sort_index = 2;
*prefix = '&';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
+ *color_prefix = 1;
}
else if (nick->flags & IRC_NICK_CHANADMIN2)
{
*sort_index = 3;
*prefix = '!';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
+ *color_prefix = 1;
}
else if (nick->flags & IRC_NICK_OP)
{
*sort_index = 4;
*prefix = '@';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
+ *color_prefix = 1;
}
else if (nick->flags & IRC_NICK_HALFOP)
{
*sort_index = 5;
*prefix = '%';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX2;
+ *color_prefix = 2;
}
else if (nick->flags & IRC_NICK_VOICE)
{
*sort_index = 6;
*prefix = '+';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX3;
+ *color_prefix = 3;
}
else if (nick->flags & IRC_NICK_CHANUSER)
{
*sort_index = 7;
*prefix = '-';
- *color_prefix = GUI_COLOR_NICKLIST_PREFIX4;
+ *color_prefix = 4;
}
else
{
*sort_index = 8;
*prefix = ' ';
- *color_prefix = GUI_COLOR_NICKLIST;
+ *color_prefix = 0;
}
}
@@ -117,13 +115,14 @@ irc_nick_get_gui_infos (t_irc_nick *nick,
* irc_nick_new: allocate a new nick for a channel and add it to the nick list
*/
-t_irc_nick *
-irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
- int is_chanowner, int is_chanadmin, int is_chanadmin2, int is_op,
- int is_halfop, int has_voice, int is_chanuser)
+struct t_irc_nick *
+irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
+ char *nick_name, int is_chanowner, int is_chanadmin,
+ int is_chanadmin2, int is_op, int is_halfop, int has_voice,
+ int is_chanuser)
{
- t_irc_nick *new_nick;
- t_gui_nick *ptr_gui_nick;
+ struct t_irc_nick *new_nick;
+ struct t_gui_nick *ptr_gui_nick;
int sort_index, color_prefix;
char prefix;
@@ -151,7 +150,7 @@ irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
}
/* alloc memory for new nick */
- if ((new_nick = (t_irc_nick *) malloc (sizeof (t_irc_nick))) == NULL)
+ if ((new_nick = (struct t_irc_nick *) malloc (sizeof (struct t_irc_nick))) == NULL)
return NULL;
/* initialize new nick */
@@ -197,8 +196,8 @@ irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
*/
void
-irc_nick_change (t_irc_server *server, t_irc_channel *channel,
- t_irc_nick *nick, char *new_nick)
+irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
+ struct t_irc_nick *nick, char *new_nick)
{
int nick_is_me;
t_weelist *ptr_weelist;
@@ -240,9 +239,9 @@ irc_nick_change (t_irc_server *server, t_irc_channel *channel,
*/
void
-irc_nick_free (t_irc_channel *channel, t_irc_nick *nick)
+irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick)
{
- t_irc_nick *new_nicks;
+ struct t_irc_nick *new_nicks;
if (!channel || !nick)
return;
@@ -282,7 +281,7 @@ irc_nick_free (t_irc_channel *channel, t_irc_nick *nick)
*/
void
-irc_nick_free_all (t_irc_channel *channel)
+irc_nick_free_all (struct t_irc_channel *channel)
{
if (!channel)
return;
@@ -299,10 +298,10 @@ irc_nick_free_all (t_irc_channel *channel)
* irc_nick_search: returns pointer on a nick
*/
-t_irc_nick *
-irc_nick_search (t_irc_channel *channel, char *nickname)
+struct t_irc_nick *
+irc_nick_search (struct t_irc_channel *channel, char *nickname)
{
- t_irc_nick *ptr_nick;
+ struct t_irc_nick *ptr_nick;
if (!nickname)
return NULL;
@@ -321,10 +320,10 @@ irc_nick_search (t_irc_channel *channel, char *nickname)
*/
void
-irc_nick_count (t_irc_channel *channel, int *total, int *count_op,
+irc_nick_count (struct t_irc_channel *channel, int *total, int *count_op,
int *count_halfop, int *count_voice, int *count_normal)
{
- t_irc_nick *ptr_nick;
+ struct t_irc_nick *ptr_nick;
(*total) = 0;
(*count_op) = 0;
@@ -360,7 +359,7 @@ irc_nick_count (t_irc_channel *channel, int *total, int *count_op,
*/
void
-irc_nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
+irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick, int is_away)
{
t_gui_nick *ptr_nick;
@@ -390,12 +389,12 @@ irc_nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
*/
void
-irc_nick_print_log (t_irc_nick *nick)
+irc_nick_print_log (struct t_irc_nick *nick)
{
- weechat_log_printf ("=> nick %s (addr:0x%X):\n", nick->nick, nick);
- weechat_log_printf (" host . . . . . : %s\n", nick->host);
- weechat_log_printf (" flags. . . . . : %d\n", nick->flags);
- weechat_log_printf (" color. . . . . : %d\n", nick->color);
- weechat_log_printf (" prev_nick. . . : 0x%X\n", nick->prev_nick);
- weechat_log_printf (" next_nick. . . : 0x%X\n", nick->next_nick);
+ weechat_log_printf ("=> nick %s (addr:0x%X):", nick->nick, nick);
+ weechat_log_printf (" host . . . . . : %s", nick->host);
+ weechat_log_printf (" flags. . . . . : %d", nick->flags);
+ weechat_log_printf (" color. . . . . : %d", nick->color);
+ weechat_log_printf (" prev_nick. . . : 0x%X", nick->prev_nick);
+ weechat_log_printf (" next_nick. . . : 0x%X", nick->next_nick);
}
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 230f49503..9f66002e4 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -20,6 +20,9 @@
#ifndef __WEECHAT_IRC_NICK_H
#define __WEECHAT_IRC_NICK_H 1
+#include "irc-server.h"
+#include "irc-channel.h"
+
#define IRC_NICK_DEFAULT_PREFIXES_LIST "@%+~&!-"
#define IRC_NICK_CHANOWNER 1
@@ -47,4 +50,18 @@ struct t_irc_nick
struct t_irc_nick *next_nick; /* link to next nick on channel */
};
+extern int irc_nick_find_color (struct t_irc_nick *);
+extern void irc_nick_get_gui_infos (struct t_irc_nick *, int *, char *, int *);
+extern struct t_irc_nick *irc_nick_new (struct t_irc_server *,
+ struct t_irc_channel *, char *,
+ int, int, int, int, int, int, int);
+extern void irc_nick_change (struct t_irc_server *, struct t_irc_channel *,
+ struct t_irc_nick *, char *);
+extern void irc_nick_free (struct t_irc_channel *, struct t_irc_nick *);
+extern void irc_nick_free_all (struct t_irc_channel *);
+extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *, char *);
+extern void irc_nick_count (struct t_irc_channel *, int *, int *, int *, int *, int *);
+extern void irc_nick_set_away (struct t_irc_channel *, struct t_irc_nick *, int);
+extern void irc_nick_print_log (struct t_irc_nick *);
+
#endif /* irc-nick.h */
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 6e985125a..3a219768b 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -39,7 +39,7 @@
#include "../../core/weechat-config.h"
-t_irc_protocol_msg irc_protocol_messages[] =
+struct t_irc_protocol_msg irc_protocol_messages[] =
{ { "error", N_("error received from IRC server"), irc_protocol_cmd_error },
{ "invite", N_("invite a nick on a channel"), irc_protocol_cmd_invite },
{ "join", N_("join a channel"), irc_protocol_cmd_join },
@@ -338,7 +338,7 @@ irc_protocol_is_highlight (char *message, char *nick)
*/
char *
-irc_protocol_replace_vars (t_irc_server *server, t_irc_channel *channel, char *string)
+irc_protocol_replace_vars (struct t_irc_server *server, struct t_irc_channel *channel, char *string)
{
char *var_nick, *var_channel, *var_server;
char empty_string[1] = { '\0' };
@@ -381,13 +381,13 @@ irc_protocol_replace_vars (t_irc_server *server, t_irc_channel *channel, char *s
*/
int
-irc_protocol_recv_command (t_irc_server *server, char *entire_line,
+irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
char *host, char *command, char *arguments)
{
int i, cmd_found, return_code, ignore, highlight;
char *pos, *nick;
char *dup_entire_line, *dup_host, *dup_arguments, *irc_message;
- t_irc_recv_func *cmd_recv_func;
+ struct t_irc_recv_func *cmd_recv_func;
char *cmd_name;
if (!command)
@@ -474,13 +474,13 @@ irc_protocol_recv_command (t_irc_server *server, char *entire_line,
*/
int
-irc_protocol_cmd_error (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
int first;
- t_gui_buffer *ptr_buffer;
- t_irc_channel *ptr_channel;
+ struct t_gui_buffer *ptr_buffer;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -557,7 +557,7 @@ irc_protocol_cmd_error (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_invite (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel;
@@ -614,11 +614,11 @@ irc_protocol_cmd_invite (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_join (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
char *pos;
/* make C compiler happy */
@@ -697,12 +697,12 @@ irc_protocol_cmd_join (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_kick (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_comment;
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
/* make C compiler happy */
(void) irc_message;
@@ -795,11 +795,11 @@ irc_protocol_cmd_kick (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_kill (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_kill (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_host2, *pos_comment;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -871,11 +871,11 @@ irc_protocol_cmd_kill (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_mode (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_mode (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_modes, *pos;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -970,13 +970,13 @@ irc_protocol_cmd_mode (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_nick (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_nick (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
int nick_is_me;
- t_gui_window *ptr_window;
+ struct t_gui_window *ptr_window;
/* make C compiler happy */
(void) irc_message;
@@ -1070,13 +1070,13 @@ irc_protocol_cmd_nick (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_notice (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *host2, *pos, *pos2, *pos_usec;
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
int highlight_displayed;
/* make C compiler happy */
@@ -1282,13 +1282,13 @@ irc_protocol_cmd_notice (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_part (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos_args, *join_string;
int join_length;
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
/* make C compiler happy */
(void) irc_message;
@@ -1412,7 +1412,7 @@ irc_protocol_cmd_part (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_ping (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_ping (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -1441,7 +1441,7 @@ irc_protocol_cmd_ping (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_pong (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_pong (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
struct timeval tv;
@@ -1477,12 +1477,12 @@ irc_protocol_cmd_pong (t_irc_server *server, char *irc_message, char *host,
*/
void
-irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
+irc_cmd_reply_version (struct t_irc_server *server, struct t_irc_channel *channel,
char *nick, char *message, int ignore)
{
char *pos;
struct utsname *buf;
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
ptr_buffer = (channel) ? channel->buffer : server->buffer;
@@ -1540,13 +1540,13 @@ irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
*/
int
-irc_protocol_cmd_privmsg (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2, *host2;
char *pos_file, *pos_addr, *pos_port, *pos_size, *pos_start_resume; /* for DCC */
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
int highlight_displayed;
/* make C compiler happy */
@@ -2302,12 +2302,12 @@ irc_protocol_cmd_privmsg (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_quit (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
/* make C compiler happy */
(void) irc_message;
@@ -2372,7 +2372,7 @@ irc_protocol_cmd_quit (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_server_mode_reason (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *ptr_msg;
@@ -2416,7 +2416,7 @@ irc_protocol_cmd_server_mode_reason (t_irc_server *server, char *irc_message, ch
*/
int
-irc_protocol_cmd_server_msg (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_server_msg (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
/* make C compiler happy */
@@ -2452,12 +2452,12 @@ irc_protocol_cmd_server_msg (t_irc_server *server, char *irc_message, char *host
*/
int
-irc_protocol_cmd_topic (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
- t_irc_channel *ptr_channel;
- t_gui_buffer *buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *buffer;
/* make C compiler happy */
(void) irc_message;
@@ -2531,7 +2531,7 @@ irc_protocol_cmd_topic (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_wallops (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_wallops (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
/* make C compiler happy */
@@ -2559,7 +2559,7 @@ irc_protocol_cmd_wallops (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_001 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -2630,7 +2630,7 @@ irc_protocol_cmd_001 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_005 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_005 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2;
@@ -2667,7 +2667,7 @@ irc_protocol_cmd_005 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_221 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_221 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_mode;
@@ -2716,12 +2716,12 @@ irc_protocol_cmd_221 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_301 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_301 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_message;
- t_irc_channel *ptr_channel;
- t_gui_buffer *ptr_buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) server;
@@ -2778,7 +2778,7 @@ irc_protocol_cmd_301 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_302 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_302 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_host, *ptr_next;
@@ -2839,7 +2839,7 @@ irc_protocol_cmd_302 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_303 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_303 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *ptr_next;
@@ -2889,10 +2889,10 @@ irc_protocol_cmd_303 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_305 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
- t_gui_window *ptr_window;
+ struct t_gui_window *ptr_window;
/* make C compiler happy */
(void) irc_message;
@@ -2929,10 +2929,10 @@ irc_protocol_cmd_305 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_306 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
- t_gui_window *ptr_window;
+ struct t_gui_window *ptr_window;
/* make C compiler happy */
(void) irc_message;
@@ -2975,7 +2975,7 @@ irc_protocol_cmd_306 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_whois_nick_msg (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_msg;
@@ -3021,7 +3021,7 @@ irc_protocol_cmd_whois_nick_msg (t_irc_server *server, char *irc_message, char *
*/
int
-irc_protocol_cmd_310 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_310 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick;
@@ -3057,7 +3057,7 @@ irc_protocol_cmd_310 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_311 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_311 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_user, *pos_host, *pos_realname;
@@ -3128,7 +3128,7 @@ irc_protocol_cmd_311 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_312 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_312 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_server, *pos_serverinfo;
@@ -3187,7 +3187,7 @@ irc_protocol_cmd_312 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_314 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_314 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_user, *pos_host, *pos_realname;
@@ -3261,11 +3261,11 @@ irc_protocol_cmd_314 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_315 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_315 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -3315,7 +3315,7 @@ irc_protocol_cmd_315 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_317 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_317 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_idle, *pos_signon, *pos_message;
@@ -3405,7 +3405,7 @@ irc_protocol_cmd_317 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_319 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_channel, *pos;
@@ -3502,7 +3502,7 @@ irc_protocol_cmd_319 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_321 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_321 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -3536,7 +3536,7 @@ irc_protocol_cmd_321 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_322 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_322 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -3576,7 +3576,7 @@ irc_protocol_cmd_322 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_323 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_323 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -3610,11 +3610,11 @@ irc_protocol_cmd_323 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_324 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_modes, *pos;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -3681,7 +3681,7 @@ irc_protocol_cmd_324 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_327 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_327 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_host1, *pos_host2, *pos_other;
@@ -3750,11 +3750,11 @@ irc_protocol_cmd_327 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_329 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_329 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_date;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
time_t datetime;
/* make C compiler happy */
@@ -3820,11 +3820,11 @@ irc_protocol_cmd_329 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_331 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_331 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) irc_message;
@@ -3869,12 +3869,12 @@ irc_protocol_cmd_331 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_332 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2;
- t_irc_channel *ptr_channel;
- t_gui_buffer *ptr_buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) irc_message;
@@ -3935,12 +3935,12 @@ irc_protocol_cmd_332 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_333 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_333 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_nick, *pos_date;
- t_irc_channel *ptr_channel;
- t_gui_buffer *ptr_buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *ptr_buffer;
time_t datetime;
/* make C compiler happy */
@@ -4006,7 +4006,7 @@ irc_protocol_cmd_333 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_338 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_338 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_host, *pos_message;
@@ -4065,7 +4065,7 @@ irc_protocol_cmd_338 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_341 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_341 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_channel;
@@ -4134,7 +4134,7 @@ irc_protocol_cmd_341 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_344 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_344 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_host;
@@ -4178,7 +4178,7 @@ irc_protocol_cmd_344 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_345 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_345 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos;
@@ -4223,12 +4223,12 @@ irc_protocol_cmd_345 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_348 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_exception, *pos_user, *pos_date, *pos;
- t_irc_channel *ptr_channel;
- t_gui_buffer *buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *buffer;
time_t datetime;
/* make C compiler happy */
@@ -4342,12 +4342,12 @@ irc_protocol_cmd_348 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_349 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_msg;
- t_irc_channel *ptr_channel;
- t_gui_buffer *buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *buffer;
/* make C compiler happy */
(void) irc_message;
@@ -4405,7 +4405,7 @@ irc_protocol_cmd_349 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_351 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_351 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2;
@@ -4448,14 +4448,14 @@ irc_protocol_cmd_351 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_352 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_user, *pos_host, *pos_server, *pos_nick;
char *pos_attr, *pos_hopcount, *pos_realname;
int length;
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
/* make C compiler happy */
(void) irc_message;
@@ -4576,15 +4576,15 @@ irc_protocol_cmd_352 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_353 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos_nick;
int is_chanowner, is_chanadmin, is_chanadmin2, is_op, is_halfop;
int has_voice, is_chanuser;
int prefix_found, color;
- t_irc_channel *ptr_channel;
- t_gui_buffer *ptr_buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) irc_message;
@@ -4762,12 +4762,12 @@ irc_protocol_cmd_353 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_366 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2;
- t_irc_channel *ptr_channel;
- t_irc_nick *ptr_nick;
+ struct t_irc_channel *ptr_channel;
+ struct t_irc_nick *ptr_nick;
int num_nicks, num_op, num_halfop, num_voice, num_normal;
/* make C compiler happy */
@@ -4873,12 +4873,12 @@ irc_protocol_cmd_366 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_367 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_ban, *pos_user, *pos_date, *pos;
- t_irc_channel *ptr_channel;
- t_gui_buffer *buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *buffer;
time_t datetime;
/* make C compiler happy */
@@ -5000,12 +5000,12 @@ irc_protocol_cmd_367 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_368 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_channel, *pos_msg;
- t_irc_channel *ptr_channel;
- t_gui_buffer *buffer;
+ struct t_irc_channel *ptr_channel;
+ struct t_gui_buffer *buffer;
/* make C compiler happy */
(void) irc_message;
@@ -5063,7 +5063,7 @@ irc_protocol_cmd_368 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_432 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
/* Note: this IRC command can not be ignored */
@@ -5123,7 +5123,7 @@ irc_protocol_cmd_432 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_433 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
/* Note: this IRC command can not be ignored */
@@ -5186,7 +5186,7 @@ irc_protocol_cmd_433 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_438 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_438 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos, *pos2;
@@ -5231,7 +5231,7 @@ irc_protocol_cmd_438 (t_irc_server *server, char *irc_message, char *host,
*/
int
-irc_protocol_cmd_671 (t_irc_server *server, char *irc_message, char *host,
+irc_protocol_cmd_671 (struct t_irc_server *server, char *irc_message, char *host,
char *nick, char *arguments, int ignore, int highlight)
{
char *pos_nick, *pos_message;
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 4c1e324f8..55e02ba40 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -20,8 +20,10 @@
#ifndef __WEECHAT_IRC_PROTOCOL_H
#define __WEECHAT_IRC_PROTOCOL_H 1
-typedef int (t_irc_recv_func)(t_irc_server *, char *, char *, char *, char *,
- int, int);
+#include "irc-server.h"
+
+typedef int (t_irc_recv_func)(struct t_irc_server *, char *, char *, char *,
+ char *, int, int);
struct t_irc_protocol_msg
{
@@ -30,4 +32,67 @@ struct t_irc_protocol_msg
t_irc_recv_func *recv_function; /* function called when msg is received */
};
+extern int irc_protocol_is_highlight (char *, char *);
+extern int irc_protocol_recv_command (struct t_irc_server *, char *, char *, char *, char *);
+extern int irc_protocol_cmd_error (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_invite (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_join (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_kick (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_kill (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_mode (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_nick (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_notice (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_part (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_ping (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_pong (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_privmsg (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_quit (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_server_mode_reason (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_server_msg (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_server_reply (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_topic (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_wallops (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_001 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_005 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_221 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_301 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_302 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_303 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_305 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_306 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_whois_nick_msg (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_310 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_311 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_312 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_314 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_315 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_317 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_319 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_321 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_322 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_323 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_324 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_327 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_329 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_331 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_332 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_333 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_338 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_341 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_344 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_345 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_348 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_349 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_351 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_352 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_353 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_365 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_366 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_367 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_368 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_432 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_433 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_438 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_671 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+
#endif /* irc-protocol.h */
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 2e751eb95..38a76a457 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -32,8 +32,10 @@
#include <string.h>
#include <pwd.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -42,21 +44,18 @@
#include <gnutls/gnutls.h>
#endif
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/hook.h"
-#include "../../core/log.h"
-#include "../../core/util.h"
-#include "../../core/weechat-config.h"
-#include "../../gui/gui.h"
-#include "../../plugins/plugins.h"
+#include "irc-server.h"
+#include "irc-channel.h"
+#include "irc-config.h"
+#include "irc-nick.h"
-t_irc_server *irc_servers = NULL;
-t_irc_server *last_irc_server = NULL;
+struct t_irc_server *irc_servers = NULL;
+struct t_irc_server *last_irc_server = NULL;
-t_irc_message *irc_recv_msgq = NULL;
-t_irc_message *irc_msgq_last_msg = NULL;
+struct t_irc_message *irc_recv_msgq = NULL;
+struct t_irc_message *irc_msgq_last_msg = NULL;
#ifdef HAVE_GNUTLS
const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
@@ -75,7 +74,7 @@ const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
*/
void
-irc_server_init (t_irc_server *server)
+irc_server_init (struct t_irc_server *server)
{
/* user choices */
server->name = NULL;
@@ -122,7 +121,8 @@ irc_server_init (t_irc_server *server)
server->lag = 0;
server->lag_check_time.tv_sec = 0;
server->lag_check_time.tv_usec = 0;
- server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check;
+ server->lag_next_check = time (NULL) +
+ weechat_config_integer (irc_config_irc_lag_check);
server->cmd_list_regexp = NULL;
server->queue_msg = 0;
server->last_user_message = 0;
@@ -141,7 +141,7 @@ irc_server_init (t_irc_server *server)
*/
int
-irc_server_init_with_url (char *irc_url, t_irc_server *server)
+irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
{
char *url, *pos_server, *pos_channel, *pos, *pos2;
int ipv6, ssl;
@@ -199,10 +199,10 @@ irc_server_init_with_url (char *irc_url, t_irc_server *server)
server->nick1 = strdup (my_passwd->pw_name);
else
{
- weechat_iconv_fprintf (stderr, "%s: %s (%s).",
- WEECHAT_WARNING,
- _("Unable to get user's name"),
- strerror (errno));
+ weechat_printf (NULL,
+ _("%sIrc: error retrieving user's name: %s"),
+ weechat_prefix ("error"),
+ strerror (errno));
free (url);
return -1;
}
@@ -258,26 +258,118 @@ irc_server_init_with_url (char *irc_url, t_irc_server *server)
}
/*
+ * irc_server_init_with_config_options: init a server with config options
+ * (called when reading config file)
+ */
+
+void
+irc_server_init_with_config_options (struct t_irc_server *server,
+ void *section)
+{
+ struct t_config_option *ptr_option;
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_name");
+ if (ptr_option)
+ server->name = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_autoconnect");
+ if (ptr_option)
+ server->autoconnect = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_autoreconnect");
+ if (ptr_option)
+ server->autoreconnect = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_autoreconnect_delay");
+ if (ptr_option)
+ server->autoreconnect_delay = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_address");
+ if (ptr_option)
+ server->address = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_port");
+ if (ptr_option)
+ server->port = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_ipv6");
+ if (ptr_option)
+ server->ipv6 = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_ssl");
+ if (ptr_option)
+ server->ssl = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_password");
+ if (ptr_option)
+ server->password = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_nick1");
+ if (ptr_option)
+ server->nick1 = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_nick2");
+ if (ptr_option)
+ server->nick2 = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_nick3");
+ if (ptr_option)
+ server->nick3 = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_username");
+ if (ptr_option)
+ server->username = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_realname");
+ if (ptr_option)
+ server->realname = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_hostname");
+ if (ptr_option)
+ server->hostname = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_command");
+ if (ptr_option)
+ server->command = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_command_delay");
+ if (ptr_option)
+ server->command_delay = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_autojoin");
+ if (ptr_option)
+ server->autojoin = strdup (weechat_config_string (ptr_option));
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_autorejoin");
+ if (ptr_option)
+ server->autorejoin = weechat_config_integer (ptr_option);
+
+ ptr_option = weechat_config_search_option (NULL, section, "server_notify_levels");
+ if (ptr_option)
+ server->notify_levels = strdup (weechat_config_string (ptr_option));
+}
+
+/*
* irc_server_alloc: allocate a new server and add it to the servers queue
*/
-t_irc_server *
+struct t_irc_server *
irc_server_alloc ()
{
- t_irc_server *new_server;
+ struct t_irc_server *new_server;
/* alloc memory for new server */
- if ((new_server = (t_irc_server *) malloc (sizeof (t_irc_server))) == NULL)
+ if ((new_server = (struct t_irc_server *) malloc (sizeof (struct t_irc_server))) == NULL)
{
- weechat_iconv_fprintf (stderr,
- _("%s cannot allocate new server\n"),
- WEECHAT_ERROR);
+ weechat_printf (NULL,
+ _("%sIrc: error when allocating new server"),
+ weechat_prefix ("error"));
return NULL;
}
-
+
/* initialize new server */
irc_server_init (new_server);
-
+
/* add new server to queue */
new_server->prev_server = last_irc_server;
new_server->next_server = NULL;
@@ -296,12 +388,12 @@ irc_server_alloc ()
*/
void
-irc_server_outqueue_add (t_irc_server *server, char *msg1, char *msg2,
+irc_server_outqueue_add (struct t_irc_server *server, char *msg1, char *msg2,
int modified)
{
- t_irc_outqueue *new_outqueue;
+ struct t_irc_outqueue *new_outqueue;
- new_outqueue = (t_irc_outqueue *)malloc (sizeof (t_irc_outqueue));
+ new_outqueue = (struct t_irc_outqueue *)malloc (sizeof (struct t_irc_outqueue));
if (new_outqueue)
{
new_outqueue->message_before_mod = (msg1) ? strdup (msg1) : NULL;
@@ -323,9 +415,10 @@ irc_server_outqueue_add (t_irc_server *server, char *msg1, char *msg2,
*/
void
-irc_server_outqueue_free (t_irc_server *server, t_irc_outqueue *outqueue)
+irc_server_outqueue_free (struct t_irc_server *server,
+ struct t_irc_outqueue *outqueue)
{
- t_irc_outqueue *new_outqueue;
+ struct t_irc_outqueue *new_outqueue;
/* remove outqueue message */
if (server->last_outqueue == outqueue)
@@ -354,7 +447,7 @@ irc_server_outqueue_free (t_irc_server *server, t_irc_outqueue *outqueue)
*/
void
-irc_server_outqueue_free_all (t_irc_server *server)
+irc_server_outqueue_free_all (struct t_irc_server *server)
{
while (server->outqueue)
irc_server_outqueue_free (server, server->outqueue);
@@ -365,7 +458,7 @@ irc_server_outqueue_free_all (t_irc_server *server)
*/
void
-irc_server_destroy (t_irc_server *server)
+irc_server_destroy (struct t_irc_server *server)
{
if (!server)
return;
@@ -416,9 +509,9 @@ irc_server_destroy (t_irc_server *server)
*/
void
-irc_server_free (t_irc_server *server)
+irc_server_free (struct t_irc_server *server)
{
- t_irc_server *new_irc_servers;
+ struct t_irc_server *new_irc_servers;
if (!server)
return;
@@ -462,7 +555,7 @@ irc_server_free_all ()
* irc_server_new: creates a new server, and initialize it
*/
-t_irc_server *
+struct t_irc_server *
irc_server_new (char *name, int autoconnect, int autoreconnect,
int autoreconnect_delay, int temp_server, char *address,
int port, int ipv6, int ssl, char *password,
@@ -470,7 +563,7 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
char *realname, char *hostname, char *command, int command_delay,
char *autojoin, int autorejoin, char *notify_levels)
{
- t_irc_server *new_server;
+ struct t_irc_server *new_server;
if (!name || !address || (port < 0))
return NULL;
@@ -479,7 +572,7 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
weechat_log_printf ("Creating new server (name:%s, address:%s, port:%d, pwd:%s, "
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
"hostname: %s, command:%s, autojoin:%s, autorejoin:%s, "
- "notify_levels:%s)\n",
+ "notify_levels:%s)",
name, address, port, (password) ? password : "",
(nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
(username) ? username : "", (realname) ? realname : "",
@@ -528,10 +621,10 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
* return: pointer to new server, NULL if error
*/
-t_irc_server *
-irc_server_duplicate (t_irc_server *server, char *new_name)
+struct t_irc_server *
+irc_server_duplicate (struct t_irc_server *server, char *new_name)
{
- t_irc_server *new_server;
+ struct t_irc_server *new_server;
/* check if another server exists with this name */
if (irc_server_search (new_name))
@@ -569,7 +662,7 @@ irc_server_duplicate (t_irc_server *server, char *new_name)
*/
int
-irc_server_rename (t_irc_server *server, char *new_name)
+irc_server_rename (struct t_irc_server *server, char *new_name)
{
char *str;
@@ -595,27 +688,26 @@ irc_server_rename (t_irc_server *server, char *new_name)
*/
int
-irc_server_send (t_irc_server *server, char *buffer, int size_buf)
+irc_server_send (struct t_irc_server *server, char *buffer, int size_buf)
{
int rc;
if (!server)
{
- gui_chat_printf_error (NULL,
- _("%s error sending data to IRC server: null "
- "pointer (please report problem to "
- "developers)"),
- WEECHAT_ERROR);
+ weechat_printf (NULL,
+ _("%sIrc: error sending data to IRC server: null "
+ "pointer (please report problem to developers)"),
+ weechat_prefix ("error"));
return 0;
}
if (size_buf <= 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s error sending data to IRC server: empty "
- "buffer (please report problem to "
- "developers)"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: error sending data to IRC server: empty "
+ "buffer (please report problem to "
+ "developers)"),
+ weechat_prefix ("error"));
return 0;
}
@@ -628,9 +720,10 @@ irc_server_send (t_irc_server *server, char *buffer, int size_buf)
if (rc < 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s error sending data to IRC server (%s)"),
- WEECHAT_ERROR, strerror (errno));
+ weechat_printf (server->buffer,
+ _("%sIrc: error sending data to IRC server (%s)"),
+ weechat_prefix ("error"),
+ strerror (errno));
}
return rc;
@@ -641,7 +734,7 @@ irc_server_send (t_irc_server *server, char *buffer, int size_buf)
*/
void
-irc_server_outqueue_send (t_irc_server *server)
+irc_server_outqueue_send (struct t_irc_server *server)
{
time_t time_now;
char *pos;
@@ -649,15 +742,16 @@ irc_server_outqueue_send (t_irc_server *server)
if (server->outqueue)
{
time_now = time (NULL);
- if (time_now >= server->last_user_message + irc_cfg_irc_anti_flood)
+ if (time_now >= server->last_user_message +
+ weechat_config_integer (irc_config_irc_anti_flood))
{
if (server->outqueue->message_before_mod)
{
pos = strchr (server->outqueue->message_before_mod, '\r');
if (pos)
pos[0] = '\0';
- gui_chat_printf_raw_data (server, 1, 0,
- server->outqueue->message_before_mod);
+ //gui_chat_printf_raw_data (server, 1, 0,
+ // server->outqueue->message_before_mod);
if (pos)
pos[0] = '\r';
}
@@ -666,18 +760,18 @@ irc_server_outqueue_send (t_irc_server *server)
pos = strchr (server->outqueue->message_after_mod, '\r');
if (pos)
pos[0] = '\0';
- gui_chat_printf_raw_data (server, 1, server->outqueue->modified,
- server->outqueue->message_after_mod);
+ //gui_chat_printf_raw_data (server, 1, server->outqueue->modified,
+ // server->outqueue->message_after_mod);
if (pos)
pos[0] = '\r';
}
if (irc_server_send (server, server->outqueue->message_after_mod,
strlen (server->outqueue->message_after_mod)) < 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s error sending data to IRC "
- "server\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: error sending data to IRC "
+ "server"),
+ weechat_prefix ("error"));
}
server->last_user_message = time_now;
irc_server_outqueue_free (server, server->outqueue);
@@ -690,7 +784,7 @@ irc_server_outqueue_send (t_irc_server *server)
*/
int
-irc_server_send_one_msg (t_irc_server *server, char *message)
+irc_server_send_one_msg (struct t_irc_server *server, char *message)
{
static char buffer[4096];
char *new_msg, *ptr_msg, *pos;
@@ -700,12 +794,13 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
rc = 1;
#ifdef DEBUG
- gui_chat_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n",
- message);
+ weechat_printf (server->buffer,
+ "[DEBUG] Sending to server >>> %s",
+ message);
#endif
- new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
+ /*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
server->name,
- message);
+ message);*/
/* no changes in new message */
if (new_msg && (strcmp (buffer, new_msg) == 0))
@@ -733,8 +828,9 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
queue = 0;
if ((server->queue_msg)
&& ((server->outqueue)
- || ((irc_cfg_irc_anti_flood > 0)
- && (time_now - server->last_user_message < irc_cfg_irc_anti_flood))))
+ || ((weechat_config_integer (irc_config_irc_anti_flood) > 0)
+ && (time_now - server->last_user_message <
+ weechat_config_integer (irc_config_irc_anti_flood)))))
queue = 1;
/* if queue, then only queue message and send nothing now */
@@ -747,16 +843,16 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
}
else
{
- if (first_message)
- gui_chat_printf_raw_data (server, 1, 0, message);
- if (new_msg)
- gui_chat_printf_raw_data (server, 1, 1, ptr_msg);
+ //if (first_message)
+ // gui_chat_printf_raw_data (server, 1, 0, message);
+ //if (new_msg)
+ // gui_chat_printf_raw_data (server, 1, 1, ptr_msg);
if (irc_server_send (server, buffer, strlen (buffer)) <= 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s error sending data to IRC "
- "server\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: error sending data to IRC "
+ "server"),
+ weechat_prefix ("error"));
rc = 0;
}
else
@@ -776,8 +872,8 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
first_message = 0;
}
}
- else
- gui_chat_printf_raw_data (server, 1, 1, _("(message dropped)"));
+ //else
+ // gui_chat_printf_raw_data (server, 1, 1, _("(message dropped)"));
if (new_msg)
free (new_msg);
@@ -790,7 +886,7 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
*/
void
-irc_server_sendf (t_irc_server *server, char *fmt, ...)
+irc_server_sendf (struct t_irc_server *server, char *fmt, ...)
{
va_list args;
static char buffer[4096];
@@ -875,20 +971,20 @@ irc_server_parse_message (char *message, char **host, char **command, char **arg
*/
void
-irc_server_msgq_add_msg (t_irc_server *server, char *msg)
+irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
{
- t_irc_message *message;
+ struct t_irc_message *message;
if (!server->unterminated_message && !msg[0])
return;
- message = (t_irc_message *) malloc (sizeof (t_irc_message));
+ message = (struct t_irc_message *) malloc (sizeof (struct t_irc_message));
if (!message)
{
- gui_chat_printf_error (server->buffer,
- _("%s not enough memory for received IRC "
- "message\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: not enough memory for received IRC "
+ "message"),
+ weechat_prefix ("error"));
return;
}
message->server = server;
@@ -898,10 +994,10 @@ irc_server_msgq_add_msg (t_irc_server *server, char *msg)
strlen (msg) + 1);
if (!message->data)
{
- gui_chat_printf_error (server->buffer,
- _("%s not enough memory for received IRC "
- "message\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: not enough memory for received IRC "
+ "message"),
+ weechat_prefix ("error"));
}
else
{
@@ -932,7 +1028,7 @@ irc_server_msgq_add_msg (t_irc_server *server, char *msg)
*/
void
-irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
+irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
{
if (!string[0])
return;
@@ -945,10 +1041,10 @@ irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
strlen (string) + 1);
if (!server->unterminated_message)
{
- gui_chat_printf_error (server->buffer,
- _("%s not enough memory for received IRC "
- "message\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: not enough memory for received IRC "
+ "message"),
+ weechat_prefix ("error"));
}
else
strcat (server->unterminated_message, string);
@@ -958,10 +1054,10 @@ irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
server->unterminated_message = strdup (string);
if (!server->unterminated_message)
{
- gui_chat_printf_error (server->buffer,
- _("%s not enough memory for received IRC "
- "message\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: not enough memory for received IRC "
+ "message"),
+ weechat_prefix ("error"));
}
}
}
@@ -971,7 +1067,7 @@ irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
*/
void
-irc_server_msgq_add_buffer (t_irc_server *server, char *buffer)
+irc_server_msgq_add_buffer (struct t_irc_server *server, char *buffer)
{
char *pos_cr, *pos_lf;
@@ -1011,7 +1107,7 @@ irc_server_msgq_add_buffer (t_irc_server *server, char *buffer)
void
irc_server_msgq_flush ()
{
- t_irc_message *next;
+ struct t_irc_message *next;
char *ptr_data, *new_msg, *ptr_msg, *pos;
char *host, *command, *args;
@@ -1020,9 +1116,9 @@ irc_server_msgq_flush ()
if (irc_recv_msgq->data)
{
#ifdef DEBUG
- gui_chat_printf (gui_current_window->buffer,
- "[DEBUG] %s\n",
- irc_recv_msgq->data);
+ weechat_printf (weechat_current_buffer,
+ "[DEBUG] %s",
+ irc_recv_msgq->data);
#endif
ptr_data = irc_recv_msgq->data;
while (ptr_data[0] == ' ')
@@ -1030,16 +1126,16 @@ irc_server_msgq_flush ()
if (ptr_data[0])
{
- gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 0,
- ptr_data);
+ //gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 0,
+ // ptr_data);
#ifdef DEBUG
- gui_chat_printf (NULL,
- "[DEBUG] data received from server: %s\n",
- ptr_data);
+ weechat_printf (NULL,
+ "[DEBUG] data received from server: %s",
+ ptr_data);
#endif
- new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
+ /*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
irc_recv_msgq->server->name,
- ptr_data);
+ ptr_data);*/
/* no changes in new message */
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
{
@@ -1059,39 +1155,41 @@ irc_server_msgq_flush ()
if (pos)
pos[0] = '\0';
- if (new_msg)
- gui_chat_printf_raw_data (irc_recv_msgq->server,
- 0, 1, ptr_msg);
+ //if (new_msg)
+ // gui_chat_printf_raw_data (irc_recv_msgq->server,
+ // 0, 1, ptr_msg);
irc_server_parse_message (ptr_msg, &host,
&command, &args);
- switch (irc_protocol_recv_command (irc_recv_msgq->server,
+ /*switch (irc_protocol_recv_command (irc_recv_msgq->server,
ptr_msg,
host, command, args))
{
case -1:
- gui_chat_printf_error (irc_recv_msgq->server->buffer,
- _("%s Command \"%s\" "
- "failed!\n"),
- WEECHAT_ERROR, command);
+ weechat_printf (irc_recv_msgq->server->buffer,
+ _("%sIrc: command \"%s\" "
+ "failed!"),
+ weechat_prefix ("error"),
+ command);
break;
case -2:
- gui_chat_printf_error (irc_recv_msgq->server->buffer,
- _("%s No command to "
- "execute!\n"),
- WEECHAT_ERROR);
+ weechat_printf (irc_recv_msgq->server->buffer,
+ _("%sIrc: no command to "
+ "execute!"),
+ weechat_prefix ("error"));
break;
case -3:
- gui_chat_printf_error (irc_recv_msgq->server->buffer,
- _("%s Unknown command: "
- "cmd=\"%s\", "
- "host=\"%s\", "
- "args=\"%s\"\n"),
- WEECHAT_WARNING,
- command, host, args);
+ weechat_printf (irc_recv_msgq->server->buffer,
+ _("%sIrc: unknown command: "
+ "cmd=\"%s\", "
+ "host=\"%s\", "
+ "args=\"%s\""),
+ weechat_prefix ("error"),
+ command, host, args);
break;
}
+ */
if (host)
free (host);
if (command)
@@ -1108,9 +1206,9 @@ irc_server_msgq_flush ()
ptr_msg = NULL;
}
}
- else
- gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 1,
- _("(message dropped)"));
+ //else
+ // gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 1,
+ // _("(message dropped)"));
if (new_msg)
free (new_msg);
}
@@ -1129,18 +1227,18 @@ irc_server_msgq_flush ()
* irc_server_recv: receive data from an irc server
*/
-void
+int
irc_server_recv (void *arg_server)
{
- t_irc_server *server;
+ struct t_irc_server *server;
- server = (t_irc_server *)arg_server;
+ server = (struct t_irc_server *)arg_server;
static char buffer[4096 + 2];
int num_read;
if (!server)
- return;
+ return PLUGIN_RC_FAILED;
#ifdef HAVE_GNUTLS
if (server->ssl_connected)
@@ -1158,12 +1256,14 @@ irc_server_recv (void *arg_server)
}
else
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot read data from socket, "
- "disconnecting from server...\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot read data from socket, "
+ "disconnecting from server..."),
+ weechat_prefix ("error"));
irc_server_disconnect (server, 1);
}
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1174,7 +1274,7 @@ irc_server_recv (void *arg_server)
void
irc_server_timer (void *empty)
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
time_t new_time;
static struct timeval tv;
int diff;
@@ -1216,18 +1316,18 @@ irc_server_timer (void *empty)
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
- && (irc_cfg_irc_lag_disconnect > 0))
+ && (weechat_config_integer (irc_config_irc_lag_disconnect) > 0))
{
gettimeofday (&tv, NULL);
- diff = (int) weechat_get_timeval_diff (&(ptr_server->lag_check_time),
- &tv);
- if (diff / 1000 > irc_cfg_irc_lag_disconnect * 60)
+ diff = (int) weechat_timeval_diff (&(ptr_server->lag_check_time),
+ &tv);
+ if (diff / 1000 > weechat_config_integer (irc_config_irc_lag_disconnect) * 60)
{
- gui_chat_printf_error (ptr_server->buffer,
- _("%s lag is high, "
- "disconnecting from "
- "server...\n"),
- WEECHAT_WARNING);
+ weechat_printf (ptr_server->buffer,
+ _("%sIrc: lag is high, "
+ "disconnecting from "
+ "server..."),
+ weechat_prefix ("info"));
irc_server_disconnect (ptr_server, 1);
}
}
@@ -1246,7 +1346,7 @@ irc_server_timer_check_away (void *empty)
{
(void) empty;
- if (irc_cfg_irc_away_check > 0)
+ if (weechat_config_integer (irc_config_irc_away_check) > 0)
irc_server_check_away ();
}
@@ -1255,7 +1355,7 @@ irc_server_timer_check_away (void *empty)
*/
void
-irc_server_child_kill (t_irc_server *server)
+irc_server_child_kill (struct t_irc_server *server)
{
/* kill process */
if (server->child_pid > 0)
@@ -1284,7 +1384,7 @@ irc_server_child_kill (t_irc_server *server)
*/
void
-irc_server_close_connection (t_irc_server *server)
+irc_server_close_connection (struct t_irc_server *server)
{
irc_server_child_kill (server);
@@ -1321,14 +1421,15 @@ irc_server_close_connection (t_irc_server *server)
*/
void
-irc_server_reconnect_schedule (t_irc_server *server)
+irc_server_reconnect_schedule (struct t_irc_server *server)
{
if (server->autoreconnect)
{
server->reconnect_start = time (NULL);
- gui_chat_printf_info (server->buffer,
- _("%s: Reconnecting to server in %d seconds\n"),
- PACKAGE_NAME, server->autoreconnect_delay);
+ weechat_printf (server->buffer,
+ _("%sIrc: reconnecting to server in %d seconds"),
+ weechat_prefix ("info"),
+ server->autoreconnect_delay);
}
else
server->reconnect_start = 0;
@@ -1339,7 +1440,7 @@ irc_server_reconnect_schedule (t_irc_server *server)
*/
void
-irc_server_login (t_irc_server *server)
+irc_server_login (struct t_irc_server *server)
{
if ((server->password) && (server->password[0]))
irc_server_sendf (server, "PASS %s", server->password);
@@ -1351,25 +1452,27 @@ irc_server_login (t_irc_server *server)
"USER %s %s %s :%s",
server->nick, server->username, server->username,
server->address, server->realname);
- gui_input_draw (gui_current_window->buffer, 1);
+ //gui_input_draw (weechat_current_buffer, 1);
}
/*
* irc_server_child_read: read connection progress from child process
*/
-void
+int
irc_server_child_read (void *arg_server)
{
- t_irc_server *server;
+ struct t_irc_server *server;
char buffer[1];
int num_read;
+ int config_proxy_use;
- server = (t_irc_server *)arg_server;
+ server = (struct t_irc_server *)arg_server;
num_read = read (server->child_read, buffer, sizeof (buffer));
if (num_read > 0)
{
+ config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
switch (buffer[0])
{
/* connection OK */
@@ -1382,78 +1485,76 @@ irc_server_child_read (void *arg_server)
(gnutls_transport_ptr) ((unsigned long) server->sock));
if (gnutls_handshake (server->gnutls_sess) < 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s GnuTLS handshake "
- "failed\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: GnuTLS handshake failed"),
+ weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
- return;
+ return PLUGIN_RC_SUCCESS;
}
}
#endif
/* kill child and login to server */
irc_server_child_kill (server);
irc_server_login (server);
- weechat_hook_remove (server->hook_fd);
- server->hook_fd = weechat_hook_add_fd (server->sock,
- WEECHAT_HOOK_FD_READ,
- irc_server_recv,
- server);
+ weechat_unhook (server->hook_fd);
+ server->hook_fd = weechat_hook_fd (server->sock,
+ 1, 0, 0,
+ irc_server_recv,
+ server);
break;
/* adress not found */
case '1':
- gui_chat_printf_error (server->buffer,
- (cfg_proxy_use) ?
- _("%s proxy address \"%s\" not "
- "found\n") :
- _("%s address \"%s\" not found\n"),
- WEECHAT_ERROR, server->address);
+ weechat_printf (server->buffer,
+ (config_proxy_use) ?
+ _("%sIrc: proxy address \"%s\" not found") :
+ _("%sIrc: address \"%s\" not found"),
+ weechat_prefix ("error"),
+ server->address);
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
break;
/* IP address not found */
case '2':
- gui_chat_printf_error (server->buffer,
- (cfg_proxy_use) ?
- _("%s proxy IP address not found\n") :
- _("%s IP address not found\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ (config_proxy_use) ?
+ _("%sIrc: proxy IP address not found") :
+ _("%sIrc: IP address not found"),
+ weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
break;
/* connection refused */
case '3':
- gui_chat_printf_error (server->buffer,
- (cfg_proxy_use) ?
- _("%s proxy connection refused\n") :
- _("%s connection refused\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ (config_proxy_use) ?
+ _("%sIrc: proxy connection refused") :
+ _("%sIrc: connection refused"),
+ weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
break;
/* proxy fails to connect to server */
case '4':
- gui_chat_printf_error (server->buffer,
- _("%s proxy fails to establish "
- "connection to "
- "server (check username/password if "
- "used)\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: proxy fails to establish "
+ "connection to server "
+ "(check username/password if used)"),
+ weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
break;
/* fails to set local hostname/IP */
case '5':
- gui_chat_printf_error (server->buffer,
- _("%s unable to set local "
- "hostname/IP\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: unable to set local hostname/IP"),
+ weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
break;
}
}
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1527,16 +1628,19 @@ int
irc_server_pass_httpproxy (int sock, char *address, int port)
{
- char buffer[256];
- char authbuf[128];
- char authbuf_base64[196];
+ char buffer[256], authbuf[128], authbuf_base64[196];
+ char *config_proxy_username, *config_proxy_password;
int n, m;
+
+ config_proxy_username = weechat_config_string (weechat_config_get ("proxy_username"));
+ config_proxy_username = weechat_config_string (weechat_config_get ("proxy_password"));
- if (cfg_proxy_username && cfg_proxy_username[0])
+ if (config_proxy_username && config_proxy_username[0])
{
/* authentification */
snprintf (authbuf, sizeof (authbuf), "%s:%s",
- cfg_proxy_username, cfg_proxy_password);
+ config_proxy_username,
+ (config_proxy_password) ? config_proxy_password : "");
irc_server_base64encode (authbuf, authbuf_base64);
n = snprintf (buffer, sizeof (buffer),
"CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n",
@@ -1677,11 +1781,15 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
unsigned char buffer[288];
int username_len, password_len, addr_len, addr_buffer_len;
unsigned char *addr_buffer;
+ char *config_proxy_username, *config_proxy_password;
socks5.version = 5;
socks5.nmethods = 1;
- if (cfg_proxy_username && cfg_proxy_username[0])
+ config_proxy_username = weechat_config_string (weechat_config_get ("proxy_username"));
+ config_proxy_username = weechat_config_string (weechat_config_get ("proxy_password"));
+
+ if (config_proxy_username && config_proxy_username[0])
socks5.method = 2; /* with authentication */
else
socks5.method = 0; /* without authentication */
@@ -1691,7 +1799,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
if (recv (sock, buffer, 2, 0) != 2)
return 1;
- if (cfg_proxy_username && cfg_proxy_username[0])
+ if (config_proxy_username && config_proxy_username[0])
{
/* with authentication */
/* -> socks server must respond with :
@@ -1703,15 +1811,15 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
return 1;
/* authentication as in RFC 1929 */
- username_len = strlen(cfg_proxy_username);
- password_len = strlen(cfg_proxy_password);
+ username_len = strlen (config_proxy_username);
+ password_len = strlen (config_proxy_password);
/* make username/password buffer */
buffer[0] = 1;
buffer[1] = (unsigned char) username_len;
- memcpy(buffer + 2, cfg_proxy_username, username_len);
+ memcpy(buffer + 2, config_proxy_username, username_len);
buffer[2 + username_len] = (unsigned char) password_len;
- memcpy (buffer + 3 + username_len, cfg_proxy_password, password_len);
+ memcpy (buffer + 3 + username_len, config_proxy_password, password_len);
send (sock, buffer, 3 + username_len + password_len, 0);
@@ -1759,7 +1867,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
return 1;
/* buffer[3] = address type */
- switch(buffer[3])
+ switch (buffer[3])
{
case 1 :
/* ipv4
@@ -1805,15 +1913,23 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
int
irc_server_pass_proxy (int sock, char *address, int port, char *username)
-{
- if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
- return irc_server_pass_httpproxy (sock, address, port);
- if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
- return irc_server_pass_socks4proxy (sock, address, port, username);
- if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
- return irc_server_pass_socks5proxy (sock, address, port);
+{
+ int rc;
+ char *config_proxy_type;
- return 1;
+ config_proxy_type = weechat_config_string (weechat_config_get ("proxy_type"));
+
+ rc = 1;
+ if (config_proxy_type)
+ {
+ if (weechat_strcasecmp (config_proxy_type, "http") == 0)
+ rc = irc_server_pass_httpproxy (sock, address, port);
+ if (weechat_strcasecmp (config_proxy_type, "socks4") == 0)
+ rc = irc_server_pass_socks4proxy (sock, address, port, username);
+ if (weechat_strcasecmp (config_proxy_type, "socks5") == 0)
+ rc = irc_server_pass_socks5proxy (sock, address, port);
+ }
+ return rc;
}
/*
@@ -1821,54 +1937,61 @@ irc_server_pass_proxy (int sock, char *address, int port, char *username)
*/
int
-irc_server_child (t_irc_server *server)
+irc_server_child (struct t_irc_server *server)
{
struct addrinfo hints, *res, *res_local;
int rc;
+ int config_proxy_use, config_proxy_ipv6, config_proxy_port;
+ char *config_proxy_address;
res = NULL;
res_local = NULL;
+
+ config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_integer (weechat_config_get ("proxy_ipv6"));
+ config_proxy_port = weechat_config_integer (weechat_config_get ("proxy_port"));
+ config_proxy_address = weechat_config_string (weechat_config_get ("proxy_address"));
- if (cfg_proxy_use)
+ if (config_proxy_use)
{
/* get info about server */
memset (&hints, 0, sizeof (hints));
- hints.ai_family = (cfg_proxy_ipv6) ? AF_INET6 : AF_INET;
+ hints.ai_family = (config_proxy_ipv6) ? AF_INET6 : AF_INET;
hints.ai_socktype = SOCK_STREAM;
- if (getaddrinfo (cfg_proxy_address, NULL, &hints, &res) !=0)
+ if (getaddrinfo (config_proxy_address, NULL, &hints, &res) !=0)
{
- write(server->child_write, "1", 1);
+ write (server->child_write, "1", 1);
return 0;
}
if (!res)
{
- write(server->child_write, "1", 1);
+ write (server->child_write, "1", 1);
return 0;
}
- if ((cfg_proxy_ipv6 && (res->ai_family != AF_INET6))
- || ((!cfg_proxy_ipv6 && (res->ai_family != AF_INET))))
+ if ((config_proxy_ipv6 && (res->ai_family != AF_INET6))
+ || ((!config_proxy_ipv6 && (res->ai_family != AF_INET))))
{
write (server->child_write, "2", 1);
freeaddrinfo (res);
return 0;
}
- if (cfg_proxy_ipv6)
- ((struct sockaddr_in6 *)(res->ai_addr))->sin6_port = htons (cfg_proxy_port);
+ if (config_proxy_ipv6)
+ ((struct sockaddr_in6 *)(res->ai_addr))->sin6_port = htons (config_proxy_port);
else
- ((struct sockaddr_in *)(res->ai_addr))->sin_port = htons (cfg_proxy_port);
+ ((struct sockaddr_in *)(res->ai_addr))->sin_port = htons (config_proxy_port);
/* connect to server */
if (connect (server->sock, res->ai_addr, res->ai_addrlen) != 0)
{
- write(server->child_write, "3", 1);
+ write (server->child_write, "3", 1);
freeaddrinfo (res);
return 0;
}
if (irc_server_pass_proxy (server->sock, server->address, server->port, server->username))
{
- write(server->child_write, "4", 1);
+ write (server->child_write, "4", 1);
freeaddrinfo (res);
return 0;
}
@@ -1955,30 +2078,24 @@ irc_server_child (t_irc_server *server)
*/
int
-irc_server_connect (t_irc_server *server, int disable_autojoin)
+irc_server_connect (struct t_irc_server *server, int disable_autojoin)
{
int child_pipe[2], set;
#ifndef __CYGWIN__
pid_t pid;
#endif
- char *log_filename;
+ char *config_proxy_type, *config_proxy_address;
+ int config_proxy_use, config_proxy_ipv6, config_proxy_port;
+
+ config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_boolean (weechat_config_get ("proxy_ipv6"));
+ config_proxy_type = weechat_config_string (weechat_config_get ("proxy_type"));
+ config_proxy_address = weechat_config_string (weechat_config_get ("proxy_address"));
+ config_proxy_port = weechat_config_integer (weechat_config_get ("proxy_port"));
if (!server->buffer)
{
- log_filename = irc_log_get_filename (server->name, NULL, 0);
- server->buffer = gui_buffer_new (gui_current_window, 0,
- server->name, server->name,
- GUI_BUFFER_ATTRIB_TEXT | GUI_BUFFER_ATTRIB_INPUT |
- GUI_BUFFER_ATTRIB_NICKS,
- irc_protocol,
- irc_buffer_data_create (server),
- &irc_buffer_data_free,
- GUI_NOTIFY_LEVEL_DEFAULT,
- NULL, server->nick,
- irc_cfg_log_auto_server, log_filename,
- 1);
- if (log_filename)
- free (log_filename);
+ server->buffer = weechat_buffer_new ("irc", server->name, NULL);
if (!server->buffer)
return 0;
}
@@ -1986,41 +2103,43 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
#ifndef HAVE_GNUTLS
if (server->ssl)
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot connect with SSL since WeeChat "
- "was not built with GnuTLS support\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot connect with SSL since WeeChat "
+ "was not built with GnuTLS support"),
+ weechat_prefix ("error"));
return 0;
}
#endif
- if (cfg_proxy_use)
- {
- gui_chat_printf_info (server->buffer,
- _("%s: connecting to server %s:%d%s%s via %s "
- "proxy %s:%d%s...\n"),
- PACKAGE_NAME, server->address, server->port,
- (server->ipv6) ? " (IPv6)" : "",
- (server->ssl) ? " (SSL)" : "",
- cfg_proxy_type_values[cfg_proxy_type],
- cfg_proxy_address, cfg_proxy_port,
- (cfg_proxy_ipv6) ? " (IPv6)" : "");
+ if (config_proxy_use)
+ {
+ weechat_printf (server->buffer,
+ _("%sIrc: connecting to server %s:%d%s%s via %s "
+ "proxy %s:%d%s..."),
+ weechat_prefix ("info"),
+ server->address, server->port,
+ (server->ipv6) ? " (IPv6)" : "",
+ (server->ssl) ? " (SSL)" : "",
+ config_proxy_type,
+ config_proxy_address, config_proxy_port,
+ (config_proxy_ipv6) ? " (IPv6)" : "");
weechat_log_printf (_("Connecting to server %s:%d%s%s via %s proxy "
- "%s:%d%s...\n"),
+ "%s:%d%s..."),
server->address, server->port,
(server->ipv6) ? " (IPv6)" : "",
(server->ssl) ? " (SSL)" : "",
- cfg_proxy_type_values[cfg_proxy_type],
- cfg_proxy_address, cfg_proxy_port,
- (cfg_proxy_ipv6) ? " (IPv6)" : "");
+ config_proxy_type,
+ config_proxy_address, config_proxy_port,
+ (config_proxy_ipv6) ? " (IPv6)" : "");
}
else
{
- gui_chat_printf_info (server->buffer,
- _("%s: connecting to server %s:%d%s%s...\n"),
- PACKAGE_NAME, server->address, server->port,
- (server->ipv6) ? " (IPv6)" : "",
- (server->ssl) ? " (SSL)" : "");
- weechat_log_printf (_("Connecting to server %s:%d%s%s...\n"),
+ weechat_printf (server->buffer,
+ _("%sIrc: connecting to server %s:%d%s%s..."),
+ weechat_prefix ("info"),
+ server->address, server->port,
+ (server->ipv6) ? " (IPv6)" : "",
+ (server->ssl) ? " (SSL)" : "");
+ weechat_log_printf (_("Irc: caonnecting to server %s:%d%s%s..."),
server->address, server->port,
(server->ipv6) ? " (IPv6)" : "",
(server->ssl) ? " (SSL)" : "");
@@ -2036,9 +2155,9 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
{
if (gnutls_init (&server->gnutls_sess, GNUTLS_CLIENT) != 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s GnuTLS init error\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: GnuTLS init error"),
+ weechat_prefix ("error"));
return 0;
}
gnutls_set_default_priority (server->gnutls_sess);
@@ -2054,24 +2173,24 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
/* create pipe for child process */
if (pipe (child_pipe) < 0)
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot create pipe\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot create pipe"),
+ weechat_prefix ("error"));
return 0;
}
server->child_read = child_pipe[0];
server->child_write = child_pipe[1];
/* create socket and set options */
- if (cfg_proxy_use)
- server->sock = socket ((cfg_proxy_ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
+ if (config_proxy_use)
+ server->sock = socket ((config_proxy_ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
else
server->sock = socket ((server->ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
if (server->sock == -1)
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot create socket\n"),
- WEECHAT_ERROR);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot create socket"),
+ weechat_prefix ("error"));
return 0;
}
@@ -2080,10 +2199,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
if (setsockopt (server->sock, SOL_SOCKET, SO_REUSEADDR,
(void *) &set, sizeof (set)) == -1)
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot set socket option "
- "\"SO_REUSEADDR\"\n"),
- WEECHAT_WARNING);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot set socket option "
+ "\"SO_REUSEADDR\""),
+ weechat_prefix ("error"));
}
/* set SO_KEEPALIVE option for socket */
@@ -2091,10 +2210,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
if (setsockopt (server->sock, SOL_SOCKET, SO_KEEPALIVE,
(void *) &set, sizeof (set)) == -1)
{
- gui_chat_printf_error (server->buffer,
- _("%s cannot set socket option "
- "\"SO_KEEPALIVE\"\n"),
- WEECHAT_WARNING);
+ weechat_printf (server->buffer,
+ _("%sIrc: cannot set socket option "
+ "\"SO_KEEPALIVE\""),
+ weechat_prefix ("error"));
}
#ifdef __CYGWIN__
@@ -2120,10 +2239,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
}
/* parent process */
server->child_pid = pid;
- server->hook_fd = weechat_hook_add_fd (server->child_read,
- WEECHAT_HOOK_FD_READ,
- irc_server_child_read,
- server);
+ server->hook_fd = weechat_hook_fd (server->child_read,
+ 1, 0, 0,
+ irc_server_child_read,
+ server);
#endif
server->disable_autojoin = disable_autojoin;
@@ -2136,10 +2255,11 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
*/
void
-irc_server_reconnect (t_irc_server *server)
+irc_server_reconnect (struct t_irc_server *server)
{
- gui_chat_printf_info (server->buffer,
- _("Reconnecting to server...\n"));
+ weechat_printf (server->buffer,
+ _("%sIrc: reconnecting to server..."),
+ weechat_prefix ("info"));
server->reconnect_start = 0;
if (irc_server_connect (server, 0))
@@ -2155,7 +2275,7 @@ irc_server_reconnect (t_irc_server *server)
void
irc_server_auto_connect (int auto_connect, int temp_server)
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -2174,9 +2294,9 @@ irc_server_auto_connect (int auto_connect, int temp_server)
*/
void
-irc_server_disconnect (t_irc_server *server, int reconnect)
+irc_server_disconnect (struct t_irc_server *server, int reconnect)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (server->is_connected)
{
@@ -2184,19 +2304,21 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- irc_nick_free_all (ptr_channel);
- gui_chat_printf_info (ptr_channel->buffer,
- _("Disconnected from server!\n"));
- gui_nicklist_draw (ptr_channel->buffer, 1, 1);
- gui_status_draw (ptr_channel->buffer, 1);
+ //irc_nick_free_all (ptr_channel);
+ weechat_printf (ptr_channel->buffer,
+ _("%sIrc: disconnected from server!"),
+ weechat_prefix ("info"));
+ //gui_nicklist_draw (ptr_channel->buffer, 1, 1);
+ //gui_status_draw (ptr_channel->buffer, 1);
}
}
irc_server_close_connection (server);
if (server->buffer)
- gui_chat_printf_info (server->buffer,
- _("Disconnected from server!\n"));
+ weechat_printf (server->buffer,
+ _("%sIrc: disconnected from server!"),
+ weechat_prefix ("info"));
if (server->nick_modes)
{
@@ -2213,7 +2335,8 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
server->lag = 0;
server->lag_check_time.tv_sec = 0;
server->lag_check_time.tv_usec = 0;
- server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check;
+ server->lag_next_check = time (NULL) +
+ weechat_config_integer (irc_config_irc_lag_check);
if ((reconnect) && (server->autoreconnect))
irc_server_reconnect_schedule (server);
@@ -2227,7 +2350,7 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
server->nick = NULL;
}
- gui_window_redraw_buffer (gui_current_window->buffer);
+ //gui_window_redraw_buffer (weechat_current_buffer);
}
/*
@@ -2237,7 +2360,7 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
void
irc_server_disconnect_all ()
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
irc_server_disconnect (ptr_server, 0);
@@ -2248,9 +2371,9 @@ irc_server_disconnect_all ()
*/
void
-irc_server_autojoin_channels (t_irc_server *server)
+irc_server_autojoin_channels (struct t_irc_server *server)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
/* auto-join after disconnection (only rejoins opened channels) */
if (!server->disable_autojoin && server->reconnect_join && server->channels)
@@ -2273,8 +2396,8 @@ irc_server_autojoin_channels (t_irc_server *server)
else
{
/* auto-join when connecting to server for first time */
- if (!server->disable_autojoin && server->autojoin && server->autojoin[0])
- irc_cmd_join_server (server, server->autojoin);
+ //if (!server->disable_autojoin && server->autojoin && server->autojoin[0])
+ // irc_cmd_join_server (server, server->autojoin);
}
server->disable_autojoin = 0;
@@ -2284,10 +2407,10 @@ irc_server_autojoin_channels (t_irc_server *server)
* irc_server_search: return pointer on a server with a name
*/
-t_irc_server *
+struct t_irc_server *
irc_server_search (char *servername)
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
if (!servername)
return NULL;
@@ -2308,7 +2431,7 @@ irc_server_search (char *servername)
int
irc_server_get_number_connected ()
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
int number;
number = 0;
@@ -2326,10 +2449,10 @@ irc_server_get_number_connected ()
*/
void
-irc_server_get_number_buffer (t_irc_server *server,
+irc_server_get_number_buffer (struct t_irc_server *server,
int *server_pos, int *server_total)
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
*server_pos = 0;
*server_total = 0;
@@ -2353,7 +2476,7 @@ irc_server_get_number_buffer (t_irc_server *server,
int
irc_server_name_already_exists (char *name)
{
- t_irc_server *ptr_server;
+ struct t_irc_server *ptr_server;
if (!name)
return 0;
@@ -2371,10 +2494,10 @@ irc_server_name_already_exists (char *name)
*/
int
-irc_server_get_channel_count (t_irc_server *server)
+irc_server_get_channel_count (struct t_irc_server *server)
{
int count;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
count = 0;
for (ptr_channel = server->channels; ptr_channel;
@@ -2391,10 +2514,10 @@ irc_server_get_channel_count (t_irc_server *server)
*/
int
-irc_server_get_pv_count (t_irc_server *server)
+irc_server_get_pv_count (struct t_irc_server *server)
{
int count;
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
count = 0;
for (ptr_channel = server->channels; ptr_channel;
@@ -2413,8 +2536,8 @@ irc_server_get_pv_count (t_irc_server *server)
void
irc_server_remove_away ()
{
- t_irc_server *ptr_server;
- t_irc_channel *ptr_channel;
+ struct t_irc_server *ptr_server;
+ struct t_irc_channel *ptr_channel;
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
{
@@ -2436,8 +2559,8 @@ irc_server_remove_away ()
void
irc_server_check_away ()
{
- t_irc_server *ptr_server;
- t_irc_channel *ptr_channel;
+ struct t_irc_server *ptr_server;
+ struct t_irc_channel *ptr_channel;
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
{
@@ -2457,9 +2580,9 @@ irc_server_check_away ()
*/
void
-irc_server_set_away (t_irc_server *server, char *nick, int is_away)
+irc_server_set_away (struct t_irc_server *server, char *nick, int is_away)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel)
{
@@ -2476,9 +2599,11 @@ irc_server_set_away (t_irc_server *server, char *nick, int is_away)
*/
int
-irc_server_get_default_notify_level (t_irc_server *server)
+irc_server_get_default_notify_level (struct t_irc_server *server)
{
- int notify, value;
+ (void) server;
+
+ /*int notify, value;
char *pos;
notify = GUI_NOTIFY_LEVEL_DEFAULT;
@@ -2499,7 +2624,8 @@ irc_server_get_default_notify_level (t_irc_server *server)
}
}
- return notify;
+ return notify;*/
+ return 0;
}
/*
@@ -2507,9 +2633,12 @@ irc_server_get_default_notify_level (t_irc_server *server)
*/
void
-irc_server_set_default_notify_level (t_irc_server *server, int notify)
+irc_server_set_default_notify_level (struct t_irc_server *server, int notify)
{
- char level_string[2];
+ (void) server;
+ (void) notify;
+
+ /*char level_string[2];
if (server)
{
@@ -2517,6 +2646,7 @@ irc_server_set_default_notify_level (t_irc_server *server, int notify)
level_string[1] = '\0';
config_option_list_set (&(server->notify_levels), "*", level_string);
}
+ */
}
/*
@@ -2524,61 +2654,68 @@ irc_server_set_default_notify_level (t_irc_server *server, int notify)
*/
void
-irc_server_print_log (t_irc_server *server)
+irc_server_print_log ()
{
- weechat_log_printf ("[server %s (addr:0x%X)]\n", server->name, server);
- weechat_log_printf (" autoconnect . . . . : %d\n", server->autoconnect);
- weechat_log_printf (" autoreconnect . . . : %d\n", server->autoreconnect);
- weechat_log_printf (" autoreconnect_delay : %d\n", server->autoreconnect_delay);
- weechat_log_printf (" temp_server . . . . : %d\n", server->temp_server);
- weechat_log_printf (" address . . . . . . : '%s'\n", server->address);
- weechat_log_printf (" port. . . . . . . . : %d\n", server->port);
- weechat_log_printf (" ipv6. . . . . . . . : %d\n", server->ipv6);
- weechat_log_printf (" ssl . . . . . . . . : %d\n", server->ssl);
- weechat_log_printf (" password. . . . . . : '%s'\n",
- (server->password && server->password[0]) ?
- "(hidden)" : server->password);
- weechat_log_printf (" nick1 . . . . . . . : '%s'\n", server->nick1);
- weechat_log_printf (" nick2 . . . . . . . : '%s'\n", server->nick2);
- weechat_log_printf (" nick3 . . . . . . . : '%s'\n", server->nick3);
- weechat_log_printf (" username. . . . . . : '%s'\n", server->username);
- weechat_log_printf (" realname. . . . . . : '%s'\n", server->realname);
- weechat_log_printf (" command . . . . . . : '%s'\n",
- (server->command && server->command[0]) ?
- "(hidden)" : server->command);
- weechat_log_printf (" command_delay . . . : %d\n", server->command_delay);
- weechat_log_printf (" autojoin. . . . . . : '%s'\n", server->autojoin);
- weechat_log_printf (" autorejoin. . . . . : %d\n", server->autorejoin);
- weechat_log_printf (" notify_levels . . . : %s\n", server->notify_levels);
- weechat_log_printf (" child_pid . . . . . : %d\n", server->child_pid);
- weechat_log_printf (" child_read . . . . : %d\n", server->child_read);
- weechat_log_printf (" child_write . . . . : %d\n", server->child_write);
- weechat_log_printf (" sock. . . . . . . . : %d\n", server->sock);
- weechat_log_printf (" hook_fd . . . . . . : 0x%X\n", server->hook_fd);
- weechat_log_printf (" is_connected. . . . : %d\n", server->is_connected);
- weechat_log_printf (" ssl_connected . . . : %d\n", server->ssl_connected);
- weechat_log_printf (" unterminated_message: '%s'\n", server->unterminated_message);
- weechat_log_printf (" nick. . . . . . . . : '%s'\n", server->nick);
- weechat_log_printf (" nick_modes. . . . . : '%s'\n", server->nick_modes);
- weechat_log_printf (" prefix. . . . . . . : '%s'\n", server->prefix);
- weechat_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start);
- weechat_log_printf (" command_time. . . . : %ld\n", server->command_time);
- weechat_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join);
- weechat_log_printf (" disable_autojoin. . : %d\n", server->disable_autojoin);
- weechat_log_printf (" is_away . . . . . . : %d\n", server->is_away);
- weechat_log_printf (" away_message. . . . : '%s'\n", server->away_message);
- weechat_log_printf (" away_time . . . . . : %ld\n", server->away_time);
- weechat_log_printf (" lag . . . . . . . . : %d\n", server->lag);
- weechat_log_printf (" lag_check_time. . . : tv_sec:%d, tv_usec:%d\n",
- server->lag_check_time.tv_sec,
- server->lag_check_time.tv_usec);
- weechat_log_printf (" lag_next_check. . . : %ld\n", server->lag_next_check);
- weechat_log_printf (" last_user_message . : %ld\n", server->last_user_message);
- weechat_log_printf (" outqueue. . . . . . : 0x%X\n", server->outqueue);
- weechat_log_printf (" last_outqueue . . . : 0x%X\n", server->last_outqueue);
- weechat_log_printf (" buffer. . . . . . . : 0x%X\n", server->buffer);
- weechat_log_printf (" channels. . . . . . : 0x%X\n", server->channels);
- weechat_log_printf (" last_channel. . . . : 0x%X\n", server->last_channel);
- weechat_log_printf (" prev_server . . . . : 0x%X\n", server->prev_server);
- weechat_log_printf (" next_server . . . . : 0x%X\n", server->next_server);
+ struct t_irc_server *ptr_server;
+
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ weechat_log_printf ("");
+ weechat_log_printf ("[server %s (addr:0x%X)]", ptr_server->name, ptr_server);
+ weechat_log_printf (" autoconnect . . . . : %d", ptr_server->autoconnect);
+ weechat_log_printf (" autoreconnect . . . : %d", ptr_server->autoreconnect);
+ weechat_log_printf (" autoreconnect_delay : %d", ptr_server->autoreconnect_delay);
+ weechat_log_printf (" temp_server . . . . : %d", ptr_server->temp_server);
+ weechat_log_printf (" address . . . . . . : '%s'", ptr_server->address);
+ weechat_log_printf (" port. . . . . . . . : %d", ptr_server->port);
+ weechat_log_printf (" ipv6. . . . . . . . : %d", ptr_server->ipv6);
+ weechat_log_printf (" ssl . . . . . . . . : %d", ptr_server->ssl);
+ weechat_log_printf (" password. . . . . . : '%s'",
+ (ptr_server->password && ptr_server->password[0]) ?
+ "(hidden)" : ptr_server->password);
+ weechat_log_printf (" nick1 . . . . . . . : '%s'", ptr_server->nick1);
+ weechat_log_printf (" nick2 . . . . . . . : '%s'", ptr_server->nick2);
+ weechat_log_printf (" nick3 . . . . . . . : '%s'", ptr_server->nick3);
+ weechat_log_printf (" username. . . . . . : '%s'", ptr_server->username);
+ weechat_log_printf (" realname. . . . . . : '%s'", ptr_server->realname);
+ weechat_log_printf (" command . . . . . . : '%s'",
+ (ptr_server->command && ptr_server->command[0]) ?
+ "(hidden)" : ptr_server->command);
+ weechat_log_printf (" command_delay . . . : %d", ptr_server->command_delay);
+ weechat_log_printf (" autojoin. . . . . . : '%s'", ptr_server->autojoin);
+ weechat_log_printf (" autorejoin. . . . . : %d", ptr_server->autorejoin);
+ weechat_log_printf (" notify_levels . . . : %s", ptr_server->notify_levels);
+ weechat_log_printf (" child_pid . . . . . : %d", ptr_server->child_pid);
+ weechat_log_printf (" child_read . . . . : %d", ptr_server->child_read);
+ weechat_log_printf (" child_write . . . . : %d", ptr_server->child_write);
+ weechat_log_printf (" sock. . . . . . . . : %d", ptr_server->sock);
+ weechat_log_printf (" hook_fd . . . . . . : 0x%X", ptr_server->hook_fd);
+ weechat_log_printf (" is_connected. . . . : %d", ptr_server->is_connected);
+ weechat_log_printf (" ssl_connected . . . : %d", ptr_server->ssl_connected);
+ weechat_log_printf (" unterminated_message: '%s'", ptr_server->unterminated_message);
+ weechat_log_printf (" nick. . . . . . . . : '%s'", ptr_server->nick);
+ weechat_log_printf (" nick_modes. . . . . : '%s'", ptr_server->nick_modes);
+ weechat_log_printf (" prefix. . . . . . . : '%s'", ptr_server->prefix);
+ weechat_log_printf (" reconnect_start . . : %ld", ptr_server->reconnect_start);
+ weechat_log_printf (" command_time. . . . : %ld", ptr_server->command_time);
+ weechat_log_printf (" reconnect_join. . . : %d", ptr_server->reconnect_join);
+ weechat_log_printf (" disable_autojoin. . : %d", ptr_server->disable_autojoin);
+ weechat_log_printf (" is_away . . . . . . : %d", ptr_server->is_away);
+ weechat_log_printf (" away_message. . . . : '%s'", ptr_server->away_message);
+ weechat_log_printf (" away_time . . . . . : %ld", ptr_server->away_time);
+ weechat_log_printf (" lag . . . . . . . . : %d", ptr_server->lag);
+ weechat_log_printf (" lag_check_time. . . : tv_sec:%d, tv_usec:%d",
+ ptr_server->lag_check_time.tv_sec,
+ ptr_server->lag_check_time.tv_usec);
+ weechat_log_printf (" lag_next_check. . . : %ld", ptr_server->lag_next_check);
+ weechat_log_printf (" last_user_message . : %ld", ptr_server->last_user_message);
+ weechat_log_printf (" outqueue. . . . . . : 0x%X", ptr_server->outqueue);
+ weechat_log_printf (" last_outqueue . . . : 0x%X", ptr_server->last_outqueue);
+ weechat_log_printf (" buffer. . . . . . . : 0x%X", ptr_server->buffer);
+ weechat_log_printf (" channels. . . . . . : 0x%X", ptr_server->channels);
+ weechat_log_printf (" last_channel. . . . : 0x%X", ptr_server->last_channel);
+ weechat_log_printf (" prev_server . . . . : 0x%X", ptr_server->prev_server);
+ weechat_log_printf (" next_server . . . . : 0x%X", ptr_server->next_server);
+ }
}
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index e759877a9..733b3b110 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -131,4 +131,51 @@ extern const int gnutls_prot_prio[];
#endif
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
+extern void irc_server_init (struct t_irc_server *);
+extern int irc_server_init_with_url (struct t_irc_server *, char *);
+extern void irc_server_init_with_config_options (struct t_irc_server *, void *);
+extern struct t_irc_server *irc_server_alloc ();
+extern void irc_server_outqueue_free_all (struct t_irc_server *);
+extern void irc_server_destroy (struct t_irc_server *);
+extern void irc_server_free (struct t_irc_server *);
+extern void irc_server_free_all ();
+extern struct t_irc_server *irc_server_new (char *, int, int, int, int, char *, int, int, int,
+ char *, char *, char *, char *, char *, char *,
+ char *, char *, int, char *, int, char *);
+extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *, char *);
+extern int irc_server_rename (struct t_irc_server *, char *);
+extern int irc_server_send (struct t_irc_server *, char *, int);
+extern void irc_server_outqueue_send (struct t_irc_server *);
+extern void irc_server_sendf (struct t_irc_server *, char *, ...);
+extern void irc_server_parse_message (char *, char **, char **, char **);
+extern int irc_server_recv (void *);
+extern void irc_server_timer (void *);
+extern void irc_server_timer_check_away (void *);
+extern int irc_server_child_read (void *);
+extern void irc_server_convbase64_8x3_to_6x4 (char *, char*);
+extern void irc_server_base64encode (char *, char *);
+extern int irc_server_pass_httpproxy (int, char*, int);
+extern int irc_server_resolve (char *, char *, int *);
+extern int irc_server_pass_socks4proxy (int, char*, int, char*);
+extern int irc_server_pass_socks5proxy (int, char*, int);
+extern int irc_server_pass_proxy (int, char*, int, char*);
+extern int irc_server_connect (struct t_irc_server *, int);
+extern void irc_server_reconnect (struct t_irc_server *);
+extern void irc_server_auto_connect (int, int);
+extern void irc_server_disconnect (struct t_irc_server *, int);
+extern void irc_server_disconnect_all ();
+extern void irc_server_autojoin_channels ();
+extern struct t_irc_server *irc_server_search (char *);
+extern int irc_server_get_number_connected ();
+extern void irc_server_get_number_buffer (struct t_irc_server *, int *, int *);
+extern int irc_server_name_already_exists (char *);
+extern int irc_server_get_channel_count (struct t_irc_server *);
+extern int irc_server_get_pv_count (struct t_irc_server *);
+extern void irc_server_remove_away ();
+extern void irc_server_check_away ();
+extern void irc_server_set_away (struct t_irc_server *, char *, int);
+extern int irc_server_get_default_notify_level (struct t_irc_server *);
+extern void irc_server_set_default_notify_level (struct t_irc_server *, int);
+extern void irc_server_print_log ();
+
#endif /* irc-server.h */
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index e2cae9b9d..31d4010c2 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -23,22 +23,28 @@
#include "config.h"
#endif
+#include <stdlib.h>
+
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#endif
-#include "../../core/weechat.h"
#include "irc.h"
-#include "../../core/log.h"
-#include "../../gui/gui.h"
+#include "irc-config.h"
+#include "irc-server.h"
+
+char plugin_name[] = "irc";
+char plugin_version[] = "0.1";
+char plugin_description[] = "IRC (Internet Relay Chat)";
-static struct t_weechat_plugin *weechat_plugin = NULL;
-static struct t_hook *irc_hook_timer = NULL;
-static struct t_hook *irc_hook_timer_check_away = NULL;
+struct t_weechat_plugin *weechat_irc_plugin = NULL;
+
+struct t_hook *irc_timer = NULL;
+struct t_hook *irc_timer_check_away = NULL;
#ifdef HAVE_GNUTLS
-gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
+gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
#endif
@@ -46,7 +52,7 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
* irc_dump: dump IRC data in WeeChat log file
*/
-static int
+/*int
irc_dump ()
{
struct t_irc_server *ptr_server;
@@ -56,19 +62,19 @@ irc_dump ()
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- weechat_log_printf ("\n");
+ weechat_log_printf ("");
irc_server_print_log (ptr_server);
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- weechat_log_printf ("\n");
+ weechat_log_printf ("");
irc_channel_print_log (ptr_channel);
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- weechat_log_printf ("\n");
+ weechat_log_printf ("");
irc_nick_print_log (ptr_nick);
}
}
@@ -78,7 +84,34 @@ irc_dump ()
return PLUGIN_RC_SUCCESS;
}
-
+*/
+
+/*
+ * irc_create_directories: create directories for IRC plugin
+ */
+
+void
+irc_create_directories ()
+{
+ char *weechat_dir, *dir1, *dir2;
+
+ /* create DCC download directory */
+ weechat_dir = weechat_info_get ("weechat_dir");
+ if (weechat_dir)
+ {
+ dir1 = weechat_string_replace (weechat_config_string (irc_config_dcc_download_path),
+ "~", getenv ("HOME"));
+ dir2 = weechat_string_replace (dir1, "%h", weechat_dir);
+ if (dir2)
+ (void) weechat_mkdir (dir2, 0700);
+ if (dir1)
+ free (dir1);
+ if (dir2)
+ free (dir2);
+ free (weechat_dir);
+ }
+}
+
/*
* weechat_plugin_init: initialize IRC plugin
*/
@@ -95,17 +128,24 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
gnutls_certificate_set_x509_trust_file (gnutls_xcred, "ca.pem", GNUTLS_X509_FMT_PEM);
#endif
- irc_config_read ();
+ if (!irc_config_init ())
+ return PLUGIN_RC_FAILED;
+
+ if (irc_config_read () < 0)
+ return PLUGIN_RC_FAILED;
+
+ irc_create_directories ();
- irc_server_auto_connect (1, 0);
+ //irc_server_auto_connect (1, 0);
- irc_hook_timer = weechat_hook_add_timer (1 * 1000,
- irc_server_timer,
- NULL);
+ /*irc_timer = weechat_hook_timer (1 * 1000, 0,
+ irc_server_timer,
+ NULL);
if (irc_cfg_irc_away_check != 0)
- weechat_hook_timer (irc_cfg_irc_away_check * 60 * 1000,
- irc_server_timer_check_away,
- NULL);
+ irc_timer_check_away = weechat_hook_timer (irc_cfg_irc_away_check * 60 * 1000,
+ 0,
+ irc_server_timer_check_away,
+ NULL);*/
return PLUGIN_RC_SUCCESS;
}
@@ -117,20 +157,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
int
weechat_plugin_end ()
{
- if (irc_hook_timer)
+ if (irc_timer)
{
- weechat_unhook (irc_hook_timer);
- irc_hook_timer = NULL;
+ weechat_unhook (irc_timer);
+ irc_timer = NULL;
}
- if (irc_hook_timer_check_away)
+ if (irc_timer_check_away)
{
- weechat_unhook (irc_hook_timer_check_away);
- irc_hook_timer_check_away = NULL;
+ weechat_unhook (irc_timer_check_away);
+ irc_timer_check_away = NULL;
}
- irc_server_disconnect_all ();
- irc_dcc_end ();
- irc_server_free_all ();
+ //irc_server_disconnect_all ();
+ //irc_dcc_end ();
+ //irc_server_free_all ();
irc_config_write ();
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index 7d29c71e5..b9ba65a03 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -20,297 +20,18 @@
#ifndef __WEECHAT_IRC_H
#define __WEECHAT_IRC_H 1
-#include "irc-buffer.h"
-#include "irc-color.h"
-#include "irc-command.h"
-#include "irc-config.h"
-#include "irc-server.h"
-#include "irc-channel.h"
-#include "irc-nick.h"
-#include "irc-dcc.h"
-#include "irc-protocol.h"
+#ifdef HAVE_GNUTLS
+#include <gnutls/gnutls.h>
+#endif
-#include "../protocol.h"
+#include "../weechat-plugin.h"
-char plugin_name[] = "irc";
-char plugin_version[] = "0.1";
-char plugin_description[] = "IRC (Internet Relay Chat)";
+#define weechat_plugin weechat_irc_plugin
extern struct t_weechat_plugin *weechat_plugin;
-extern struct t_hook *irc_hook_timer, *irc_hook_timer_check_away;
-
-/* buffer functions (irc-buffer.c) */
-
-extern t_irc_buffer_data *irc_buffer_data_create (t_irc_server *);
-extern void irc_buffer_data_free (t_gui_buffer *);
-extern void irc_buffer_merge_servers (t_gui_window *);
-extern void irc_buffer_split_server (t_gui_window *);
-
-/* channel functions (irc-channel.c) */
-
-extern t_irc_channel *irc_channel_new (t_irc_server *, int, char *, int);
-extern void irc_channel_free (t_irc_server *, t_irc_channel *);
-extern void irc_channel_free_all (t_irc_server *);
-extern t_irc_channel *irc_channel_search (t_irc_server *, char *);
-extern t_irc_channel *irc_channel_search_any (t_irc_server *, char *);
-extern t_irc_channel *irc_channel_search_any_without_buffer (t_irc_server *, char *);
-extern t_irc_channel *irc_channel_search_dcc (t_irc_server *, char *);
-extern int irc_channel_is_channel (char *);
-extern void irc_channel_remove_away (t_irc_channel *);
-extern void irc_channel_check_away (t_irc_server *, t_irc_channel *, int);
-extern void irc_channel_set_away (t_irc_channel *, char *, int);
-extern int irc_channel_create_dcc (t_irc_dcc *);
-extern int irc_channel_get_notify_level (t_irc_server *, t_irc_channel *);
-extern void irc_channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
-extern void irc_channel_add_nick_speaking (t_irc_channel *, char *);
-extern void irc_channel_print_log (t_irc_channel *);
-
-/* color functions (irc-color.c) */
-
-extern unsigned char *irc_color_decode (unsigned char *, int, int);
-extern unsigned char *irc_color_decode_for_user_entry (unsigned char *);
-extern unsigned char *irc_color_encode (unsigned char *, int);
-
-/* IRC commands (irc-command.c) */
-
-extern int irc_cmd_admin (t_gui_window *, char *, int, char **);
-extern void irc_cmd_mode_nicks (t_irc_server *, char *, char *, char *, int, char **);
-extern int irc_cmd_ame (t_gui_window *, char *, int, char **);
-extern int irc_cmd_amsg (t_gui_window *, char *, int, char **);
-extern void irc_cmd_away_server (t_irc_server *, char *);
-extern int irc_cmd_away (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ctcp (t_gui_window *, char *, int, char **);
-extern int irc_cmd_cycle (t_gui_window *, char *, int, char **);
-extern int irc_cmd_dehalfop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_deop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_devoice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_die (t_gui_window *, char *, int, char **);
-extern int irc_cmd_halfop (t_gui_window *, char *, int, char **);
-extern int irc_cmd_info (t_gui_window *, char *, int, char **);
-extern int irc_cmd_invite (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ison (t_gui_window *, char *, int, char **);
-extern void irc_cmd_join_server (t_irc_server *, char *);
-extern int irc_cmd_join (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kick (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kickban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_kill (t_gui_window *, char *, int, char **);
-extern int irc_cmd_links (t_gui_window *, char *, int, char **);
-extern int irc_cmd_list (t_gui_window *, char *, int, char **);
-extern int irc_cmd_lusers (t_gui_window *, char *, int, char **);
-extern int irc_cmd_me (t_gui_window *, char *, int, char **);
-extern void irc_cmd_mode_server (t_irc_server *, char *);
-extern int irc_cmd_mode (t_gui_window *, char *, int, char **);
-extern int irc_cmd_motd (t_gui_window *, char *, int, char **);
-extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
-extern int irc_cmd_names (t_gui_window *, char *, int, char **);
-extern int irc_cmd_nick (t_gui_window *, char *, int, char **);
-extern int irc_cmd_notice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_op (t_gui_window *, char *, int, char **);
-extern int irc_cmd_oper (t_gui_window *, char *, int, char **);
-extern int irc_cmd_part (t_gui_window *, char *, int, char **);
-extern int irc_cmd_ping (t_gui_window *, char *, int, char **);
-extern int irc_cmd_pong (t_gui_window *, char *, int, char **);
-extern int irc_cmd_query (t_gui_window *, char *, int, char **);
-extern int irc_cmd_quit (t_gui_window *, char *, int, char **);
-extern int irc_cmd_quote (t_gui_window *, char *, int, char **);
-extern int irc_cmd_rehash (t_gui_window *, char *, int, char **);
-extern int irc_cmd_restart (t_gui_window *, char *, int, char **);
-extern int irc_cmd_service (t_gui_window *, char *, int, char **);
-extern int irc_cmd_servlist (t_gui_window *, char *, int, char **);
-extern int irc_cmd_squery (t_gui_window *, char *, int, char **);
-extern int irc_cmd_squit (t_gui_window *, char *, int, char **);
-extern int irc_cmd_stats (t_gui_window *, char *, int, char **);
-extern int irc_cmd_summon (t_gui_window *, char *, int, char **);
-extern int irc_cmd_time (t_gui_window *, char *, int, char **);
-extern int irc_cmd_topic (t_gui_window *, char *, int, char **);
-extern int irc_cmd_trace (t_gui_window *, char *, int, char **);
-extern int irc_cmd_unban (t_gui_window *, char *, int, char **);
-extern int irc_cmd_userhost (t_gui_window *, char *, int, char **);
-extern int irc_cmd_users (t_gui_window *, char *, int, char **);
-extern int irc_cmd_version (t_gui_window *, char *, int, char **);
-extern int irc_cmd_voice (t_gui_window *, char *, int, char **);
-extern int irc_cmd_wallops (t_gui_window *, char *, int, char **);
-extern int irc_cmd_who (t_gui_window *, char *, int, char **);
-extern int irc_cmd_whois (t_gui_window *, char *, int, char **);
-extern int irc_cmd_whowas (t_gui_window *, char *, int, char **);
-
-/* config functions (irc-config.c) */
-
-extern void irc_config_create_dirs ();
-extern void *irc_config_get_server_option_ptr (t_irc_server *, char *);
-extern int irc_config_set_server_value (t_irc_server *, char *, char *);
-extern int irc_config_read ();
-extern int irc_config_write ();
-
-/* DCC functions (irc-dcc.c) */
-
-extern void irc_dcc_redraw (int);
-extern void irc_dcc_free (t_irc_dcc *);
-extern void irc_dcc_close (t_irc_dcc *, int);
-extern void irc_dcc_chat_remove_channel (t_irc_channel *);
-extern void irc_dcc_accept (t_irc_dcc *);
-extern void irc_dcc_accept_resume (t_irc_server *, char *, int, unsigned long);
-extern void irc_dcc_start_resume (t_irc_server *, char *, int, unsigned long);
-extern t_irc_dcc *irc_dcc_alloc ();
-extern t_irc_dcc *irc_dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
- char *, char *, unsigned long);
-extern void irc_dcc_send_request (t_irc_server *, int, char *, char *);
-extern void irc_dcc_chat_sendf (t_irc_dcc *, char *, ...);
-extern void irc_dcc_file_send_fork (t_irc_dcc *);
-extern void irc_dcc_file_recv_fork (t_irc_dcc *);
-extern void irc_dcc_handle ();
-extern void irc_dcc_end ();
-extern void irc_dcc_print_log ();
-
-/* display functions (irc-diplay.c) */
-
-extern void irc_display_hide_password (char *, int);
-extern void irc_display_nick (t_gui_buffer *, t_irc_nick *, char *, int,
- int, char *, int);
-extern void irc_display_away (t_irc_server *, char *, char *);
-extern void irc_display_mode (t_gui_buffer *, char *, char *,
- char, char *, char *, char *, char *);
-extern void irc_display_server (t_irc_server *ptr_server, int);
-
-/* input functions (irc-input.c) */
-
-extern int irc_input_data (t_gui_window *, char *);
-
-/* log functions (irc-log.c) */
-extern char *irc_log_get_filename (char *, char *, int);
-
-/* mode functions (irc-mode.c) */
-
-extern void irc_mode_channel_set (t_irc_server *, t_irc_channel *, char *);
-extern void irc_mode_user_set (t_irc_server *, char *);
-extern int irc_mode_nick_prefix_allowed (t_irc_server *, char);
-
-/* nick functions (irc-nick.c) */
-
-extern int irc_nick_find_color (t_irc_nick *);
-extern void irc_nick_get_gui_infos (t_irc_nick *, int *, char *, int *);
-extern t_irc_nick *irc_nick_new (t_irc_server *, t_irc_channel *, char *,
- int, int, int, int, int, int, int);
-extern void irc_nick_change (t_irc_server *, t_irc_channel *, t_irc_nick *, char *);
-extern void irc_nick_free (t_irc_channel *, t_irc_nick *);
-extern void irc_nick_free_all (t_irc_channel *);
-extern t_irc_nick *irc_nick_search (t_irc_channel *, char *);
-extern void irc_nick_count (t_irc_channel *, int *, int *, int *, int *, int *);
-extern void irc_nick_set_away (t_irc_channel *, t_irc_nick *, int);
-extern void irc_nick_print_log (t_irc_nick *);
-
-/* IRC protocol (irc-protocol.c) */
-
-extern int irc_protocol_is_highlight (char *, char *);
-extern int irc_protocol_recv_command (t_irc_server *, char *, char *, char *, char *);
-extern int irc_protocol_cmd_error (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_invite (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_join (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_kick (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_kill (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_mode (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_nick (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_notice (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_part (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_ping (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_pong (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_privmsg (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_quit (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_mode_reason (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_msg (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_reply (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_topic (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_wallops (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_001 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_005 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_221 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_301 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_302 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_303 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_305 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_306 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_whois_nick_msg (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_310 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_311 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_312 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_314 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_315 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_317 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_319 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_321 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_322 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_323 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_324 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_327 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_329 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_331 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_332 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_333 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_338 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_341 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_344 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_345 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_348 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_349 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_351 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_352 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_353 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_365 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_366 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_367 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_368 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_432 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_433 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_438 (t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_671 (t_irc_server *, char *, char *, char *, char *, int, int);
-
-/* server functions (irc-server.c) */
+extern struct t_weechat_plugin *weechat_plugin;
+extern struct t_hook *irc_timer_check_away;
-extern void irc_server_init (t_irc_server *);
-extern int irc_server_init_with_url (char *, t_irc_server *);
-extern t_irc_server *irc_server_alloc ();
-extern void irc_server_outqueue_free_all (t_irc_server *);
-extern void irc_server_destroy (t_irc_server *);
-extern void irc_server_free (t_irc_server *);
-extern void irc_server_free_all ();
-extern t_irc_server *irc_server_new (char *, int, int, int, int, char *, int, int, int,
- char *, char *, char *, char *, char *, char *,
- char *, char *, int, char *, int, char *);
-extern t_irc_server *irc_server_duplicate (t_irc_server *, char *);
-extern int irc_server_rename (t_irc_server *, char *);
-extern int irc_server_send (t_irc_server *, char *, int);
-extern void irc_server_outqueue_send (t_irc_server *);
-extern void irc_server_sendf (t_irc_server *, char *, ...);
-extern void irc_server_parse_message (char *, char **, char **, char **);
-extern void irc_server_recv (void *);
-extern void irc_server_timer (void *);
-extern void irc_server_timer_check_away (void *);
-extern void irc_server_child_read (void *);
-extern void irc_server_convbase64_8x3_to_6x4 (char *, char*);
-extern void irc_server_base64encode (char *, char *);
-extern int irc_server_pass_httpproxy (int, char*, int);
-extern int irc_server_resolve (char *, char *, int *);
-extern int irc_server_pass_socks4proxy (int, char*, int, char*);
-extern int irc_server_pass_socks5proxy (int, char*, int);
-extern int irc_server_pass_proxy (int, char*, int, char*);
-extern int irc_server_connect (t_irc_server *, int);
-extern void irc_server_reconnect (t_irc_server *);
-extern void irc_server_auto_connect (int, int);
-extern void irc_server_disconnect (t_irc_server *, int);
-extern void irc_server_disconnect_all ();
-extern void irc_server_autojoin_channels ();
-extern t_irc_server *irc_server_search (char *);
-extern int irc_server_get_number_connected ();
-extern void irc_server_get_number_buffer (t_irc_server *, int *, int *);
-extern int irc_server_name_already_exists (char *);
-extern int irc_server_get_channel_count (t_irc_server *);
-extern int irc_server_get_pv_count (t_irc_server *);
-extern void irc_server_remove_away ();
-extern void irc_server_check_away ();
-extern void irc_server_set_away (t_irc_server *, char *, int);
-extern int irc_server_get_default_notify_level (t_irc_server *);
-extern void irc_server_set_default_notify_level (t_irc_server *, int);
-extern void irc_server_print_log (t_irc_server *);
+extern gnutls_certificate_credentials gnutls_xcred;
#endif /* irc.h */
diff --git a/src/plugins/logger/CMakeLists.txt b/src/plugins/logger/CMakeLists.txt
index 3f2943b83..ef4c1984c 100644
--- a/src/plugins/logger/CMakeLists.txt
+++ b/src/plugins/logger/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(logger MODULE logger.c logger.h logger-buffer.c logger-buffer.h)
+ADD_LIBRARY(logger MODULE logger.c logger-buffer.c logger-buffer.h)
SET_TARGET_PROPERTIES(logger PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(logger)
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 9fd6db6ed..950ba350e 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -42,16 +42,18 @@ char plugin_name[] = "logger";
char plugin_version[] = "0.1";
char plugin_description[] = "Logger plugin for WeeChat";
-struct t_weechat_plugin *weechat_plugin = NULL;
-char *logger_path = NULL;
-char *logger_time_format = NULL;
+struct t_weechat_plugin *weechat_logger_plugin = NULL;
+#define weechat_plugin weechat_logger_plugin
+
+static char *logger_path = NULL;
+static char *logger_time_format = NULL;
/*
* logger_config_read: read config options for logger plugin
*/
-void
+static void
logger_config_read ()
{
if (logger_path)
@@ -78,7 +80,7 @@ logger_config_read ()
* return 1 if success, 0 if failed
*/
-int
+static int
logger_create_directory ()
{
int rc;
@@ -122,10 +124,10 @@ logger_create_directory ()
* logger_get_filename: build log filename for a buffer
*/
-char *
+static char *
logger_get_filename (void *buffer)
{
- struct t_plugin_list *ptr_list;
+ struct t_plugin_infolist *ptr_infolist;
char *res;
char *dir_separator, *weechat_dir, *log_path, *log_path2;
char *category, *category2, *name, *name2;
@@ -140,17 +142,17 @@ logger_get_filename (void *buffer)
if (dir_separator && weechat_dir && log_path && log_path2)
{
- ptr_list = weechat_list_get ("buffer", buffer);
- if (ptr_list)
+ ptr_infolist = weechat_infolist_get ("buffer", buffer);
+ if (ptr_infolist)
{
category2 = NULL;
name2 = NULL;
- if (weechat_list_next (ptr_list))
+ if (weechat_infolist_next (ptr_infolist))
{
- category = weechat_list_string (ptr_list, "category");
+ category = weechat_infolist_string (ptr_infolist, "category");
category2 = (category) ?
weechat_string_replace (category, dir_separator, "_") : NULL;
- name = weechat_list_string (ptr_list, "name");
+ name = weechat_infolist_string (ptr_infolist, "name");
name2 = (name) ?
weechat_string_replace (name, dir_separator, "_") : NULL;
}
@@ -180,7 +182,7 @@ logger_get_filename (void *buffer)
free (category2);
if (name2)
free (name2);
- weechat_list_free (ptr_list);
+ weechat_infolist_free (ptr_infolist);
}
}
@@ -200,7 +202,7 @@ logger_get_filename (void *buffer)
* logger_write_line: write a line to log file
*/
-void
+static void
logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
{
va_list argptr;
@@ -268,7 +270,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
* logger_start_buffer: start a log for a buffer
*/
-void
+static void
logger_start_buffer (void *buffer)
{
struct t_logger_buffer *ptr_logger_buffer;
@@ -303,15 +305,16 @@ logger_start_buffer (void *buffer)
* logger_start_buffer_all: start log buffer for all buffers
*/
-void
+static void
logger_start_buffer_all ()
{
- struct t_plugin_list *ptr_list;
+ struct t_plugin_infolist *ptr_infolist;
- ptr_list = weechat_list_get ("buffer", NULL);
- while (weechat_list_next (ptr_list))
+ ptr_infolist = weechat_infolist_get ("buffer", NULL);
+ while (weechat_infolist_next (ptr_infolist))
{
- logger_start_buffer (weechat_list_pointer (ptr_list, "pointer"));
+ logger_start_buffer (weechat_infolist_pointer (ptr_infolist,
+ "pointer"));
}
}
@@ -319,7 +322,7 @@ logger_start_buffer_all ()
* logger_end: end log for a logger buffer
*/
-void
+static void
logger_end (struct t_logger_buffer *logger_buffer)
{
time_t seconds;
@@ -350,7 +353,7 @@ logger_end (struct t_logger_buffer *logger_buffer)
* logger_end_all: end log for all buffers
*/
-void
+static void
logger_end_all ()
{
struct t_logger_buffer *ptr_logger_buffer;
@@ -366,7 +369,7 @@ logger_end_all ()
* logger_event_cb: callback for event hook
*/
-int
+static int
logger_event_cb (void *data, char *event, void *pointer)
{
/* make C compiler happy */
@@ -389,7 +392,7 @@ logger_event_cb (void *data, char *event, void *pointer)
* logger_print_cb: callback for print hook
*/
-int
+static int
logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
char *message)
{
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 513f7307d..88b712983 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -35,6 +35,7 @@
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
#include "../core/wee-input.h"
+#include "../core/wee-list.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
@@ -49,7 +50,7 @@
#include "../gui/gui-window.h"
#include "plugin.h"
#include "plugin-config.h"
-#include "plugin-list.h"
+#include "plugin-infolist.h"
/*
@@ -77,7 +78,10 @@ char *
plugin_api_iconv_to_internal (struct t_weechat_plugin *plugin,
char *charset, char *string)
{
- if (!plugin || !string)
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (!string)
return NULL;
return string_iconv_to_internal (charset, string);
@@ -92,7 +96,10 @@ char *
plugin_api_iconv_from_internal (struct t_weechat_plugin *plugin,
char *charset, char *string)
{
- if (!plugin || !string)
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (!string)
return NULL;
return string_iconv_from_internal (charset, string);
@@ -177,7 +184,10 @@ plugin_api_string_explode (struct t_weechat_plugin *plugin, char *string,
char *separators, int keep_eol,
int num_items_max, int *num_items)
{
- if (!plugin || !string || !separators || !num_items)
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (!string || !separators || !num_items)
return NULL;
return string_explode (string, separators, keep_eol,
@@ -231,7 +241,8 @@ plugin_api_string_free_splitted_command (struct t_weechat_plugin *plugin,
*/
int
-plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory)
+plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory,
+ int mode)
{
char *dir_name;
int dir_length;
@@ -251,7 +262,7 @@ plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory)
snprintf (dir_name, dir_length, "%s/%s", weechat_home, directory);
- if (mkdir (dir_name, 0755) < 0)
+ if (mkdir (dir_name, mode) < 0)
{
if (errno != EEXIST)
{
@@ -265,6 +276,29 @@ plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory)
}
/*
+ * plugin_api_mkdir: create a directory
+ */
+
+int
+plugin_api_mkdir (struct t_weechat_plugin *plugin, char *directory,
+ int mode)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (!directory)
+ return 0;
+
+ if (mkdir (directory, mode) < 0)
+ {
+ if (errno != EEXIST)
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
* plugin_api_exec_on_files: find files in a directory and execute a
* function on each file
*/
@@ -281,6 +315,219 @@ plugin_api_exec_on_files (struct t_weechat_plugin *plugin, char *directory,
}
/*
+ * plugin_api_timeval_diff: calculates difference between two times (return in
+ * milliseconds)
+ */
+
+long
+plugin_api_timeval_diff (struct t_weechat_plugin *plugin,
+ void *timeval1, void *timeval2)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ return util_timeval_diff (timeval1, timeval2);
+}
+
+/*
+ * plugin_api_list_new: create a new list
+ */
+
+struct t_weelist *
+plugin_api_list_new (struct t_weechat_plugin *plugin)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ return weelist_new ();
+}
+
+/*
+ * plugin_api_list_add: add a new item in a list
+ */
+
+struct t_weelist_item *
+plugin_api_list_add (struct t_weechat_plugin *plugin, void *list, char *data,
+ char *where)
+{
+ int position;
+
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list && data && where)
+ {
+ position = WEELIST_POS_SORT;
+ if (string_strcasecmp (where, "sort") == 0)
+ position = WEELIST_POS_SORT;
+ else if (string_strcasecmp (where, "beginning") == 0)
+ position = WEELIST_POS_BEGINNING;
+ else if (string_strcasecmp (where, "end") == 0)
+ position = WEELIST_POS_END;
+
+ return weelist_add (list, data, position);
+ }
+ return NULL;
+}
+
+/*
+ * plugin_api_list_search: search an item in a list (case sensitive)
+ */
+
+struct t_weelist_item *
+plugin_api_list_search (struct t_weechat_plugin *plugin, void *list,
+ char *data)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list && data)
+ return weelist_search (list, data);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_casesearch: search an item in a list (case unsensitive)
+ */
+
+struct t_weelist_item *
+plugin_api_list_casesearch (struct t_weechat_plugin *plugin, void *list,
+ char *data)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list && data)
+ return weelist_casesearch (list, data);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_get: get an item with position in list
+ */
+
+struct t_weelist_item *
+plugin_api_list_get (struct t_weechat_plugin *plugin, void *list, int position)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list)
+ return weelist_get (list, position);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_next: get next item
+ */
+
+struct t_weelist_item *
+plugin_api_list_next (struct t_weechat_plugin *plugin, void *item)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (item)
+ return ((struct t_weelist_item *)item)->next_item;
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_prev: get previous item
+ */
+
+struct t_weelist_item *
+plugin_api_list_prev (struct t_weechat_plugin *plugin, void *item)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (item)
+ return ((struct t_weelist_item *)item)->prev_item;
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_string: get string value of an item
+ */
+
+char *
+plugin_api_list_string (struct t_weechat_plugin *plugin, void *item)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (item)
+ return (char *)(((struct t_weelist_item *)item)->data);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_list_size: get size of a list (number of items)
+ */
+
+int
+plugin_api_list_size (struct t_weechat_plugin *plugin, void *list)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list)
+ return ((struct t_weelist *)list)->size;
+ else
+ return 0;
+}
+
+/*
+ * plugin_api_list_remove: remove an item from a list
+ */
+
+void
+plugin_api_list_remove (struct t_weechat_plugin *plugin, void *list,
+ void *item)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list && item)
+ weelist_remove (list, item);
+}
+
+/*
+ * plugin_api_list_remove_all: remove all item from a list
+ */
+
+void
+plugin_api_list_remove_all (struct t_weechat_plugin *plugin, void *list)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list)
+ weelist_remove_all (list);
+}
+
+/*
+ * plugin_api_list_free: get size of a list (number of items)
+ */
+
+void
+plugin_api_list_free (struct t_weechat_plugin *plugin, void *list)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ if (list)
+ weelist_free (list);
+}
+
+/*
* plugin_api_config_new: create new config file structure
*/
@@ -298,14 +545,28 @@ struct t_config_section *
plugin_api_config_new_section (struct t_weechat_plugin *plugin,
void *config_file, char *name,
void (*callback_read)(void *, char *, char *),
- void (*callback_write)(void *),
- void (*callback_write_default)(void *))
+ void (*callback_write)(void *, char *),
+ void (*callback_write_default)(void *, char *))
{
- /* make C compiler happy */
- (void) plugin;
-
- return config_file_new_section (config_file, name, callback_read,
- callback_write, callback_write_default);
+ if (plugin && config_file_valid_for_plugin (plugin, config_file))
+ return config_file_new_section (config_file, name, callback_read,
+ callback_write, callback_write_default);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_config_search_section: search a section in a config
+ */
+
+struct t_config_section *
+plugin_api_config_search_section (struct t_weechat_plugin *plugin,
+ void *config_file, char *name)
+{
+ if (plugin && config_file_valid_for_plugin (plugin, config_file))
+ return config_file_search_section (config_file, name);
+ else
+ return NULL;
}
/*
@@ -320,52 +581,70 @@ plugin_api_config_new_option (struct t_weechat_plugin *plugin,
void (*callback_change)())
{
- long number;
- char *error;
-
- /* make C compiler happy */
- (void) plugin;
+ if (plugin && config_file_section_valid_for_plugin (plugin, section))
+ return config_file_new_option (section, name, type, description,
+ string_values, min, max, default_value,
+ callback_change);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_config_search_option: search an option in a config or section
+ */
+
+struct t_config_option *
+plugin_api_config_search_option (struct t_weechat_plugin *plugin,
+ void *config_file, void *section, char *name)
+{
+ if (plugin
+ && (!config_file || config_file_valid_for_plugin (plugin, config_file))
+ && (!section || config_file_section_valid_for_plugin (plugin, section)))
+ return config_file_search_option (config_file, section, name);
+ else
+ return NULL;
+}
+
+/*
+ * plugin_api_config_option_set: set new value for an option
+ * return: 2 if ok (value changed)
+ * 1 if ok (value is the same)
+ * 0 if failed
+ */
+
+int
+plugin_api_config_option_set (struct t_weechat_plugin *plugin,
+ void *option, char *new_value)
+{
+ int rc;
- if (string_strcasecmp (type, "boolean") == 0)
- {
- return config_file_new_option_boolean (
- section, name, description,
- (config_file_string_boolean_value (default_value) == CONFIG_BOOLEAN_TRUE) ?
- CONFIG_BOOLEAN_TRUE : CONFIG_BOOLEAN_FALSE,
- callback_change);
- }
- if (string_strcasecmp (type, "integer") == 0)
+ if (plugin && config_file_option_valid_for_plugin (plugin, option))
{
- error = NULL;
- number = strtol (default_value, &error, 10);
- if (error && (error[0] == '\0'))
- {
- if (string_values && string_values[0])
- return config_file_new_option_integer_with_string (
- section, name, description, string_values, number,
- callback_change);
- return config_file_new_option_integer (
- section, name, description, min, max, number,
- callback_change);
- }
- else
- return NULL;
- }
- if (string_strcasecmp (type, "string") == 0)
- {
- return config_file_new_option_string (
- section, name, description, min, max, default_value,
- callback_change);
- }
- if (string_strcasecmp (type, "color") == 0)
- {
- return config_file_new_option_color (
- section, name, description, min, default_value,
- callback_change);
+ rc = config_file_option_set (option, new_value);
+ if ((rc == 2) && (((struct t_config_option *)option)->callback_change))
+ (void) (((struct t_config_option *)option)->callback_change) ();
+ if (rc == 0)
+ return 0;
+ return 1;
}
+ return 0;
+}
+
+/*
+ * plugin_api_config_string_to_boolean: return boolean value of a string
+ */
+
+char
+plugin_api_config_string_to_boolean (struct t_weechat_plugin *plugin,
+ char *string)
+{
+ /* make C compiler happy */
+ (void) plugin;
- /* unknown option type */
- return NULL;
+ if (config_file_string_to_boolean (string) == CONFIG_OPTION_BOOLEAN)
+ return CONFIG_BOOLEAN_TRUE;
+ else
+ return CONFIG_BOOLEAN_FALSE;
}
/*
@@ -389,11 +668,23 @@ plugin_api_config_boolean (struct t_weechat_plugin *plugin, void *option)
int
plugin_api_config_integer (struct t_weechat_plugin *plugin, void *option)
{
- if (plugin && config_file_option_valid_for_plugin (plugin, option)
- && (((struct t_config_option *)option)->type == CONFIG_OPTION_INTEGER))
- return CONFIG_INTEGER((struct t_config_option *)option);
- else
- return 0;
+ if (plugin && config_file_option_valid_for_plugin (plugin, option))
+ {
+ switch (((struct t_config_option *)option)->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ if (CONFIG_BOOLEAN((struct t_config_option *)option) == CONFIG_BOOLEAN_TRUE)
+ return 1;
+ else
+ return 0;
+ case CONFIG_OPTION_INTEGER:
+ case CONFIG_OPTION_COLOR:
+ return CONFIG_INTEGER((struct t_config_option *)option);
+ case CONFIG_OPTION_STRING:
+ return 0;
+ }
+ }
+ return 0;
}
/*
@@ -403,11 +694,16 @@ plugin_api_config_integer (struct t_weechat_plugin *plugin, void *option)
char *
plugin_api_config_string (struct t_weechat_plugin *plugin, void *option)
{
- if (plugin && config_file_option_valid_for_plugin (plugin, option)
- && (((struct t_config_option *)option)->type == CONFIG_OPTION_STRING))
- return CONFIG_STRING((struct t_config_option *)option);
- else
- return NULL;
+ if (plugin && config_file_option_valid_for_plugin (plugin, option))
+ {
+ if (((struct t_config_option *)option)->type == CONFIG_OPTION_STRING)
+ return CONFIG_STRING((struct t_config_option *)option);
+ if ((((struct t_config_option *)option)->type == CONFIG_OPTION_INTEGER)
+ && (((struct t_config_option *)option)->string_values))
+ return ((struct t_config_option *)option)->
+ string_values[CONFIG_INTEGER(((struct t_config_option *)option))];
+ }
+ return NULL;
}
/*
@@ -470,11 +766,19 @@ plugin_api_config_write (struct t_weechat_plugin *plugin, void *config_file)
void
plugin_api_config_write_line (struct t_weechat_plugin *plugin,
void *config_file, char *option_name,
- char *value)
+ char *value, ...)
{
+ char buf[4096];
+ va_list argptr;
+
if (plugin && config_file_valid_for_plugin (plugin, config_file))
+ {
+ va_start (argptr, value);
+ vsnprintf (buf, sizeof (buf) - 1, value, argptr);
+ va_end (argptr);
config_file_write_line ((struct t_config_file *)config_file,
- option_name, value);
+ option_name, buf);
+ }
}
/*
@@ -527,21 +831,14 @@ plugin_api_get_config_str_value (struct t_config_option *option)
* plugin_api_config_get: get value of a WeeChat config option
*/
-char *
+struct t_config_option *
plugin_api_config_get (struct t_weechat_plugin *plugin, char *option_name)
{
- struct t_config_option *ptr_option;
-
/* make C compiler happy */
(void) plugin;
-
- /* search WeeChat config option */
- ptr_option = config_file_search_option (weechat_config, NULL, option_name);
- if (ptr_option)
- return plugin_api_get_config_str_value (ptr_option);
- /* option not found */
- return NULL;
+ return config_file_search_option (weechat_config_file, NULL,
+ option_name);
}
/*
@@ -562,7 +859,8 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
return 0;
/* search and set WeeChat config option if found */
- ptr_option = config_file_search_option (weechat_config, NULL, option_name);
+ ptr_option = config_file_search_option (weechat_config_file, NULL,
+ option_name);
if (ptr_option)
{
rc = config_file_option_set (ptr_option, value);
@@ -1177,92 +1475,92 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
}
/*
- * plugin_api_list_get_add_buffer: add a buffer in a list
- * return 1 if ok, 0 if error
+ * plugin_api_infolist_get_add_buffer: add a buffer in a list
+ * return 1 if ok, 0 if error
*/
int
-plugin_api_list_get_add_buffer (struct t_plugin_list *list,
- struct t_gui_buffer *buffer)
+plugin_api_infolist_get_add_buffer (struct t_plugin_infolist *infolist,
+ struct t_gui_buffer *buffer)
{
- struct t_plugin_list_item *ptr_item;
+ struct t_plugin_infolist_item *ptr_item;
- if (!list || !buffer)
+ if (!infolist || !buffer)
return 0;
- ptr_item = plugin_list_new_item (list);
+ ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
- if (!plugin_list_new_var_pointer (ptr_item, "pointer", buffer))
+ if (!plugin_infolist_new_var_pointer (ptr_item, "pointer", buffer))
return 0;
- if (!plugin_list_new_var_integer (ptr_item, "number", buffer->number))
+ if (!plugin_infolist_new_var_integer (ptr_item, "number", buffer->number))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "category", buffer->category))
+ if (!plugin_infolist_new_var_string (ptr_item, "category", buffer->category))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "name", buffer->name))
+ if (!plugin_infolist_new_var_string (ptr_item, "name", buffer->name))
return 0;
- if (!plugin_list_new_var_integer (ptr_item, "type", buffer->type))
+ if (!plugin_infolist_new_var_integer (ptr_item, "type", buffer->type))
return 0;
- if (!plugin_list_new_var_integer (ptr_item, "notify_level", buffer->notify_level))
+ if (!plugin_infolist_new_var_integer (ptr_item, "notify_level", buffer->notify_level))
return 0;
- if (!plugin_list_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
+ if (!plugin_infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "title", buffer->title))
+ if (!plugin_infolist_new_var_string (ptr_item, "title", buffer->title))
return 0;
- if (!plugin_list_new_var_integer (ptr_item, "input", buffer->input))
+ if (!plugin_infolist_new_var_integer (ptr_item, "input", buffer->input))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "input_nick", buffer->input_nick))
+ if (!plugin_infolist_new_var_string (ptr_item, "input_nick", buffer->input_nick))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "input_string", buffer->input_buffer))
+ if (!plugin_infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
return 0;
return 1;
}
/*
- * plugin_api_list_get_add_buffer_line: add a buffer line in a list
- * return 1 if ok, 0 if error
+ * plugin_api_infolist_get_add_buffer_line: add a buffer line in a list
+ * return 1 if ok, 0 if error
*/
int
-plugin_api_list_get_add_buffer_line (struct t_plugin_list *list,
- struct t_gui_line *line)
+plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
+ struct t_gui_line *line)
{
- struct t_plugin_list_item *ptr_item;
+ struct t_plugin_infolist_item *ptr_item;
- if (!list || !line)
+ if (!infolist || !line)
return 0;
- ptr_item = plugin_list_new_item (list);
+ ptr_item = plugin_infolist_new_item (infolist);
if (!ptr_item)
return 0;
- if (!plugin_list_new_var_time (ptr_item, "date", line->date))
+ if (!plugin_infolist_new_var_time (ptr_item, "date", line->date))
return 0;
- if (!plugin_list_new_var_time (ptr_item, "date_printed", line->date))
+ if (!plugin_infolist_new_var_time (ptr_item, "date_printed", line->date))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "str_time", line->str_time))
+ if (!plugin_infolist_new_var_string (ptr_item, "str_time", line->str_time))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "prefix", line->prefix))
+ if (!plugin_infolist_new_var_string (ptr_item, "prefix", line->prefix))
return 0;
- if (!plugin_list_new_var_string (ptr_item, "message", line->message))
+ if (!plugin_infolist_new_var_string (ptr_item, "message", line->message))
return 0;
return 1;
}
/*
- * plugin_api_list_get: get list with infos about WeeChat structures
- * WARNING: caller has to free string returned
- * by this function after use, with weechat_list_free()
+ * plugin_api_infolist_get: get list with infos about WeeChat structures
+ * WARNING: caller has to free string returned
+ * by this function after use, with weechat_list_free()
*/
-struct t_plugin_list *
-plugin_api_list_get (struct t_weechat_plugin *plugin, char *name,
- void *pointer)
+struct t_plugin_infolist *
+plugin_api_infolist_get (struct t_weechat_plugin *plugin, char *name,
+ void *pointer)
{
- struct t_plugin_list *ptr_list;
+ struct t_plugin_infolist *ptr_infolist;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
@@ -1272,22 +1570,21 @@ plugin_api_list_get (struct t_weechat_plugin *plugin, char *name,
if (string_strcasecmp (name, "buffer") == 0)
{
/* invalid buffer pointer ? */
- if (pointer && (!gui_buffer_valid ((struct t_gui_buffer *)pointer)))
+ if (pointer && (!gui_buffer_valid (pointer)))
return NULL;
- ptr_list = plugin_list_new ();
- if (ptr_list)
+ ptr_infolist = plugin_infolist_new ();
+ if (ptr_infolist)
{
if (pointer)
{
/* build list with only one buffer */
- if (!plugin_api_list_get_add_buffer (ptr_list,
- (struct t_gui_buffer *)pointer))
+ if (!plugin_api_infolist_get_add_buffer (ptr_infolist, pointer))
{
- plugin_list_free (ptr_list);
+ plugin_infolist_free (ptr_infolist);
return NULL;
}
- return ptr_list;
+ return ptr_infolist;
}
else
{
@@ -1295,14 +1592,14 @@ plugin_api_list_get (struct t_weechat_plugin *plugin, char *name,
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (!plugin_api_list_get_add_buffer (ptr_list,
- ptr_buffer))
+ if (!plugin_api_infolist_get_add_buffer (ptr_infolist,
+ ptr_buffer))
{
- plugin_list_free (ptr_list);
+ plugin_infolist_free (ptr_infolist);
return NULL;
}
}
- return ptr_list;
+ return ptr_infolist;
}
}
}
@@ -1313,24 +1610,24 @@ plugin_api_list_get (struct t_weechat_plugin *plugin, char *name,
else
{
/* invalid buffer pointer ? */
- if (!gui_buffer_valid ((struct t_gui_buffer *)pointer))
+ if (!gui_buffer_valid (pointer))
return NULL;
}
- ptr_list = plugin_list_new ();
- if (ptr_list)
+ ptr_infolist = plugin_infolist_new ();
+ if (ptr_infolist)
{
for (ptr_line = ((struct t_gui_buffer *)pointer)->lines; ptr_line;
ptr_line = ptr_line->next_line)
{
- if (!plugin_api_list_get_add_buffer_line (ptr_list,
- ptr_line))
+ if (!plugin_api_infolist_get_add_buffer_line (ptr_infolist,
+ ptr_line))
{
- plugin_list_free (ptr_list);
+ plugin_infolist_free (ptr_infolist);
return NULL;
}
}
- return ptr_list;
+ return ptr_infolist;
}
}
@@ -1339,124 +1636,117 @@ plugin_api_list_get (struct t_weechat_plugin *plugin, char *name,
}
/*
- * plugin_api_list_next: move item pointer to next item in a list
- * return 1 if pointer is still ok
- * 0 if end of list was reached
+ * plugin_api_infolist_next: move item pointer to next item in a list
+ * return 1 if pointer is still ok
+ * 0 if end of list was reached
*/
int
-plugin_api_list_next (struct t_weechat_plugin *plugin, void *list)
+plugin_api_infolist_next (struct t_weechat_plugin *plugin, void *infolist)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list))
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist))
return 0;
- return (plugin_list_next_item ((struct t_plugin_list *)list)) ? 1 : 0;
+ return (plugin_infolist_next_item (infolist)) ? 1 : 0;
}
/*
- * plugin_api_list_prev: move item pointer to previous item in a list
- * return 1 if pointer is still ok
- * 0 if beginning of list was reached
+ * plugin_api_infolist_prev: move item pointer to previous item in a list
+ * return 1 if pointer is still ok
+ * 0 if beginning of list was reached
*/
int
-plugin_api_list_prev (struct t_weechat_plugin *plugin, void *list)
+plugin_api_infolist_prev (struct t_weechat_plugin *plugin, void *infolist)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list))
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist))
return 0;
- return (plugin_list_prev_item ((struct t_plugin_list *)list)) ? 1 : 0;
+ return (plugin_infolist_prev_item (infolist)) ? 1 : 0;
}
/*
- * plugin_api_list_fields: get list of fields for current list item
+ * plugin_api_infolist_fields: get list of fields for current list item
*/
char *
-plugin_api_list_fields (struct t_weechat_plugin *plugin, void *list)
+plugin_api_infolist_fields (struct t_weechat_plugin *plugin, void *infolist)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list))
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist))
return NULL;
- return plugin_list_get_fields ((struct t_plugin_list *)list);
+ return plugin_infolist_get_fields (infolist);
}
/*
- * plugin_api_list_integer: get an integer variable value in current list item
+ * plugin_api_infolist_integer: get an integer variable value in current list item
*/
int
-plugin_api_list_integer (struct t_weechat_plugin *plugin, void *list,
- char *var)
+plugin_api_infolist_integer (struct t_weechat_plugin *plugin, void *infolist,
+ char *var)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list)
- || !((struct t_plugin_list *)list)->ptr_item)
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ || !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
- return plugin_list_get_integer ((struct t_plugin_list *)list, var);
+ return plugin_infolist_get_integer (infolist, var);
}
/*
- * plugin_api_list_string: get a string variable value in current list item
+ * plugin_api_infolist_string: get a string variable value in current list item
*/
char *
-plugin_api_list_string (struct t_weechat_plugin *plugin, void *list,
- char *var)
+plugin_api_infolist_string (struct t_weechat_plugin *plugin, void *infolist,
+ char *var)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list)
- || !((struct t_plugin_list *)list)->ptr_item)
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ || !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
- return plugin_list_get_string ((struct t_plugin_list *)list, var);
+ return plugin_infolist_get_string (infolist, var);
}
/*
- * plugin_api_list_pointer: get a pointer variable value in current list item
+ * plugin_api_infolist_pointer: get a pointer variable value in current list item
*/
void *
-plugin_api_list_pointer (struct t_weechat_plugin *plugin, void *list,
- char *var)
+plugin_api_infolist_pointer (struct t_weechat_plugin *plugin, void *infolist,
+ char *var)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list)
- || !((struct t_plugin_list *)list)->ptr_item)
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ || !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
- return plugin_list_get_pointer ((struct t_plugin_list *)list, var);
+ return plugin_infolist_get_pointer (infolist, var);
}
/*
- * plugin_api_list_time: get a time variable value in current list item
+ * plugin_api_infolist_time: get a time variable value in current list item
*/
time_t
-plugin_api_list_time (struct t_weechat_plugin *plugin, void *list,
- char *var)
+plugin_api_infolist_time (struct t_weechat_plugin *plugin, void *infolist,
+ char *var)
{
- if (!plugin || !list
- || !plugin_list_valid ((struct t_plugin_list *)list)
- || !((struct t_plugin_list *)list)->ptr_item)
+ if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ || !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
- return plugin_list_get_time ((struct t_plugin_list *)list, var);
+ return plugin_infolist_get_time (infolist, var);
}
/*
- * plugin_api_list_free: free a list
+ * plugin_api_infolist_free: free an infolist
*/
void
-plugin_api_list_free (struct t_weechat_plugin *plugin, void *list)
+plugin_api_infolist_free (struct t_weechat_plugin *plugin, void *infolist)
{
- if (plugin && list && plugin_list_valid ((struct t_plugin_list *)list))
- plugin_list_free ((struct t_plugin_list *)list);
+ if (plugin && infolist && plugin_infolist_valid (infolist))
+ plugin_infolist_free (infolist);
}
/*
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index 308ec330e..d1ceda88d 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -44,24 +44,57 @@ extern void plugin_api_string_free_splitted_command (struct t_weechat_plugin *,
char **);
/* directories */
-extern int plugin_api_mkdir_home (struct t_weechat_plugin *, char *);
+extern int plugin_api_mkdir_home (struct t_weechat_plugin *, char *, int);
+extern int plugin_api_mkdir (struct t_weechat_plugin *, char *, int);
extern void plugin_api_exec_on_files (struct t_weechat_plugin *, char *,
int (*)(char *));
+/* util */
+extern long plugin_api_timeval_diff (struct t_weechat_plugin *, void *, void *);;
+
+/* lists */
+extern struct t_weelist *plugin_api_list_new( struct t_weechat_plugin *);
+extern char *plugin_api_list_add (struct t_weechat_plugin *, void *, char *,
+ char *);
+extern struct t_weelist_item *plugin_api_list_search (struct t_weechat_plugin *,
+ void *, char *);
+extern struct t_weelist_item *plugin_api_list_casesearch (struct t_weechat_plugin *,
+ void *, char *);
+extern struct t_weelist_item *plugin_api_list_get (struct t_weechat_plugin *,
+ void *, int);
+extern struct t_weelist_item *plugin_api_list_next (struct t_weechat_plugin *,
+ void *);
+extern struct t_weelist_item *plugin_api_list_prev (struct t_weechat_plugin *,
+ void *);
+extern char *plugin_api_list_string (struct t_weechat_plugin *, void *);
+extern int plugin_api_list_size (struct t_weechat_plugin *, void *);
+extern void plugin_api_list_remove (struct t_weechat_plugin *, void *, void *);
+extern void plugin_api_list_remove_all (struct t_weechat_plugin *, void *);
+extern void plugin_api_list_free (struct t_weechat_plugin *, void *);
+
/* config */
extern struct t_config_file *plugin_api_config_new (struct t_weechat_plugin *,
char *);
extern struct t_config_section *plugin_api_config_new_section (struct t_weechat_plugin *,
void *, char *,
void (*)(void *, char *, char *),
- void (*)(void *),
- void (*)(void *));
+ void (*)(void *, char *),
+ void (*)(void *, char *));
+extern struct t_config_section *plugin_api_config_search_section (struct t_weechat_plugin *,
+ void *, char *);
extern struct t_config_option *plugin_api_config_new_option (struct t_weechat_plugin *,
void *, char *,
char *, char *,
char *, int, int,
char *,
void (*)());
+extern struct t_config_option *plugin_api_config_search_option (struct t_weechat_plugin *,
+ void *, void *,
+ char *);
+extern int plugin_api_config_option_set (struct t_weechat_plugin *, void *,
+ char *);
+extern char plugin_api_config_string_to_boolean (struct t_weechat_plugin *,
+ char *);
extern char plugin_api_config_boolean (struct t_weechat_plugin *, void *);
extern int plugin_api_config_integer (struct t_weechat_plugin *, void *);
extern char *plugin_api_config_string (struct t_weechat_plugin *, void *);
@@ -70,10 +103,10 @@ extern int plugin_api_config_read (struct t_weechat_plugin *, void *);
extern int plugin_api_config_reload (struct t_weechat_plugin *, void *);
extern int plugin_api_config_write (struct t_weechat_plugin *, void *);
extern void plugin_api_config_write_line (struct t_weechat_plugin *, void *,
- char *, char *);
+ char *, char *, ...);
extern void plugin_api_config_free (struct t_weechat_plugin *, void *);
-extern char *plugin_api_config_get (struct t_weechat_plugin *, char *);
-extern int plugin_api_config_set (struct t_weechat_plugin *, char *, char *);
+extern struct t_config_option *plugin_api_config_get (struct t_weechat_plugin *,
+ char *);
extern char *plugin_api_plugin_config_get (struct t_weechat_plugin *, char *);
extern int plugin_api_plugin_config_set (struct t_weechat_plugin *, char *,
char *);
@@ -135,19 +168,19 @@ extern void plugin_api_command (struct t_weechat_plugin *, void *, char *);
/* infos */
extern char *plugin_api_info_get (struct t_weechat_plugin *, char *);
-/* lists */
-extern struct t_plugin_list *plugin_api_list_get (struct t_weechat_plugin *,
- char *, void *);
-extern int plugin_api_list_next (struct t_weechat_plugin *,
- void *);
-extern int plugin_api_list_prev (struct t_weechat_plugin *,
- void *);
-extern char *plugin_api_list_fields (struct t_weechat_plugin *, void *);
-extern int plugin_api_list_integer (struct t_weechat_plugin *, void *, char *);
-extern char *plugin_api_list_string (struct t_weechat_plugin *, void *, char *);
-extern void *plugin_api_list_pointer (struct t_weechat_plugin *, void *, char *);
-extern time_t plugin_api_list_time (struct t_weechat_plugin *, void *, char *);
-extern void plugin_api_list_free (struct t_weechat_plugin *, void *);
+/* infolists */
+extern struct t_plugin_infolist *plugin_api_infolist_get (struct t_weechat_plugin *,
+ char *, void *);
+extern int plugin_api_infolist_next (struct t_weechat_plugin *,
+ void *);
+extern int plugin_api_infolist_prev (struct t_weechat_plugin *,
+ void *);
+extern char *plugin_api_infolist_fields (struct t_weechat_plugin *, void *);
+extern int plugin_api_infolist_integer (struct t_weechat_plugin *, void *, char *);
+extern char *plugin_api_infolist_string (struct t_weechat_plugin *, void *, char *);
+extern void *plugin_api_infolist_pointer (struct t_weechat_plugin *, void *, char *);
+extern time_t plugin_api_infolist_time (struct t_weechat_plugin *, void *, char *);
+extern void plugin_api_infolist_free (struct t_weechat_plugin *, void *);
/* log */
extern void plugin_api_log (struct t_weechat_plugin *, char *, char *,
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c
index c0c391e87..5ff41be75 100644
--- a/src/plugins/plugin-config.c
+++ b/src/plugins/plugin-config.c
@@ -295,12 +295,15 @@ plugin_config_read_option (void *config_file, char *option_name, char *value)
/* make C compiler happy */
(void) config_file;
-
- value2 = string_iconv_to_internal (NULL, value);
- plugin_config_set_internal (option_name,
- (value2) ? value2 : value);
- if (value2)
- free (value2);
+
+ if (option_name && value)
+ {
+ value2 = string_iconv_to_internal (NULL, value);
+ plugin_config_set_internal (option_name,
+ (value2) ? value2 : value);
+ if (value2)
+ free (value2);
+ }
}
/*
@@ -308,16 +311,18 @@ plugin_config_read_option (void *config_file, char *option_name, char *value)
*/
void
-plugin_config_write_options (void *config_file)
+plugin_config_write_options (void *config_file, char *section_name)
{
struct t_config_option *ptr_option;
+ config_file_write_line (config_file, section_name, NULL);
+
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
config_file_write_line (config_file,
ptr_option->name,
- ptr_option->value);
+ "%s", ptr_option->value);
}
}
@@ -331,7 +336,7 @@ plugin_config_init ()
plugin_config = config_file_new (NULL, PLUGIN_CONFIG_FILENAME);
if (plugin_config)
{
- config_file_new_section (plugin_config, "plugin",
+ config_file_new_section (plugin_config, "plugins",
&plugin_config_read_option,
&plugin_config_write_options,
NULL);
@@ -377,6 +382,6 @@ plugin_config_reload ()
int
plugin_config_write ()
{
- log_printf (_("Saving plugins configuration to disk\n"));
+ log_printf (_("Saving plugins configuration to disk"));
return config_file_write (plugin_config, 0);
}
diff --git a/src/plugins/plugin-list.c b/src/plugins/plugin-infolist.c
index 243041eb8..a12d4c379 100644
--- a/src/plugins/plugin-list.c
+++ b/src/plugins/plugin-infolist.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* plugin-list.c: manages plugin info lists */
+/* plugin-infolist.c: manages plugin info lists */
#ifdef HAVE_CONFIG_H
@@ -29,51 +29,51 @@
#include "../core/weechat.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
-#include "plugin-list.h"
+#include "plugin-infolist.h"
-struct t_plugin_list *plugin_lists = NULL;
-struct t_plugin_list *last_plugin_list = NULL;
+struct t_plugin_infolist *plugin_infolists = NULL;
+struct t_plugin_infolist *last_plugin_infolist = NULL;
/*
* plugin_list_new: create a new plugin list
*/
-struct t_plugin_list *
-plugin_list_new ()
+struct t_plugin_infolist *
+plugin_infolist_new ()
{
- struct t_plugin_list *new_list;
+ struct t_plugin_infolist *new_infolist;
- new_list = (struct t_plugin_list *)malloc (sizeof (struct t_plugin_list));
- if (new_list)
+ new_infolist = (struct t_plugin_infolist *)malloc (sizeof (struct t_plugin_infolist));
+ if (new_infolist)
{
- new_list->items = NULL;
- new_list->last_item = NULL;
- new_list->ptr_item = NULL;
+ new_infolist->items = NULL;
+ new_infolist->last_item = NULL;
+ new_infolist->ptr_item = NULL;
- new_list->prev_list = last_plugin_list;
- new_list->next_list = NULL;
- if (plugin_lists)
- last_plugin_list->next_list = new_list;
+ new_infolist->prev_infolist = last_plugin_infolist;
+ new_infolist->next_infolist = NULL;
+ if (plugin_infolists)
+ last_plugin_infolist->next_infolist = new_infolist;
else
- plugin_lists = new_list;
- last_plugin_list = new_list;
+ plugin_infolists = new_infolist;
+ last_plugin_infolist = new_infolist;
}
- return new_list;
+ return new_infolist;
}
/*
- * plugin_list_new_item: create a new item in a plugin list
+ * plugin_infolist_new_item: create a new item in a plugin list
*/
-struct t_plugin_list_item *
-plugin_list_new_item (struct t_plugin_list *list)
+struct t_plugin_infolist_item *
+plugin_infolist_new_item (struct t_plugin_infolist *list)
{
- struct t_plugin_list_item *new_item;
+ struct t_plugin_infolist_item *new_item;
- new_item = (struct t_plugin_list_item *)malloc (sizeof (struct t_plugin_list_item));
+ new_item = (struct t_plugin_infolist_item *)malloc (sizeof (struct t_plugin_infolist_item));
if (new_item)
{
new_item->vars = NULL;
@@ -93,23 +93,23 @@ plugin_list_new_item (struct t_plugin_list *list)
}
/*
- * plugin_list_new_var_integer: create a new integer variable in an item
+ * plugin_infolist_new_var_integer: create a new integer variable in an item
*/
-struct t_plugin_list_var *
-plugin_list_new_var_integer (struct t_plugin_list_item *item,
+struct t_plugin_infolist_var *
+plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
char *name, int value)
{
- struct t_plugin_list_var *new_var;
+ struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
- new_var = (struct t_plugin_list_var *)malloc (sizeof (struct t_plugin_list_var));
+ new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
if (new_var)
{
new_var->name = strdup (name);
- new_var->type = PLUGIN_LIST_VAR_INTEGER;
+ new_var->type = PLUGIN_INFOLIST_INTEGER;
new_var->value = malloc (sizeof (int));
*((int *)new_var->value) = value;
@@ -126,23 +126,23 @@ plugin_list_new_var_integer (struct t_plugin_list_item *item,
}
/*
- * plugin_list_new_var_string: create a new string variable in an item
+ * plugin_infolist_new_var_string: create a new string variable in an item
*/
-struct t_plugin_list_var *
-plugin_list_new_var_string (struct t_plugin_list_item *item,
+struct t_plugin_infolist_var *
+plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
char *name, char *value)
{
- struct t_plugin_list_var *new_var;
+ struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
- new_var = (struct t_plugin_list_var *)malloc (sizeof (struct t_plugin_list_var));
+ new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
if (new_var)
{
new_var->name = strdup (name);
- new_var->type = PLUGIN_LIST_VAR_STRING;
+ new_var->type = PLUGIN_INFOLIST_STRING;
new_var->value = (value) ? strdup (value) : NULL;
new_var->prev_var = item->last_var;
@@ -158,23 +158,23 @@ plugin_list_new_var_string (struct t_plugin_list_item *item,
}
/*
- * plugin_list_new_var_pointer: create a new pointer variable in an item
+ * plugin_infolist_new_var_pointer: create a new pointer variable in an item
*/
-struct t_plugin_list_var *
-plugin_list_new_var_pointer (struct t_plugin_list_item *item,
+struct t_plugin_infolist_var *
+plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
char *name, void *pointer)
{
- struct t_plugin_list_var *new_var;
+ struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
- new_var = (struct t_plugin_list_var *)malloc (sizeof (struct t_plugin_list_var));
+ new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
if (new_var)
{
new_var->name = strdup (name);
- new_var->type = PLUGIN_LIST_VAR_POINTER;
+ new_var->type = PLUGIN_INFOLIST_POINTER;
new_var->value = pointer;
new_var->prev_var = item->last_var;
@@ -190,23 +190,23 @@ plugin_list_new_var_pointer (struct t_plugin_list_item *item,
}
/*
- * plugin_list_new_var_time: create a new time variable in an item
+ * plugin_infolist_new_var_time: create a new time variable in an item
*/
-struct t_plugin_list_var *
-plugin_list_new_var_time (struct t_plugin_list_item *item,
+struct t_plugin_infolist_var *
+plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
char *name, time_t time)
{
- struct t_plugin_list_var *new_var;
+ struct t_plugin_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
- new_var = (struct t_plugin_list_var *)malloc (sizeof (struct t_plugin_list_var));
+ new_var = (struct t_plugin_infolist_var *)malloc (sizeof (struct t_plugin_infolist_var));
if (new_var)
{
new_var->name = strdup (name);
- new_var->type = PLUGIN_LIST_VAR_TIME;
+ new_var->type = PLUGIN_INFOLIST_TIME;
new_var->value = malloc (sizeof (time_t));
*((time_t *)new_var->value) = time;
@@ -223,20 +223,20 @@ plugin_list_new_var_time (struct t_plugin_list_item *item,
}
/*
- * plugin_list_valid: check if a list pointer exists
- * return 1 if list exists
- * 0 if list is not found
+ * plugin_infolist_valid: check if a list pointer exists
+ * return 1 if list exists
+ * 0 if list is not found
*/
int
-plugin_list_valid (struct t_plugin_list *list)
+plugin_infolist_valid (struct t_plugin_infolist *list)
{
- struct t_plugin_list *ptr_list;
+ struct t_plugin_infolist *ptr_infolist;
- for (ptr_list = plugin_lists; ptr_list;
- ptr_list = ptr_list->next_list)
+ for (ptr_infolist = plugin_infolists; ptr_infolist;
+ ptr_infolist = ptr_infolist->next_infolist)
{
- if (ptr_list == list)
+ if (ptr_infolist == list)
return 1;
}
@@ -245,13 +245,13 @@ plugin_list_valid (struct t_plugin_list *list)
}
/*
- * plugin_list_next_item: return next item for a list
- * if current item pointer is NULL,
- * then return first item of list
+ * plugin_infolist_next_item: return next item for a list
+ * if current item pointer is NULL,
+ * then return first item of list
*/
-struct t_plugin_list_item *
-plugin_list_next_item (struct t_plugin_list *list)
+struct t_plugin_infolist_item *
+plugin_infolist_next_item (struct t_plugin_infolist *list)
{
if (!list->ptr_item)
{
@@ -263,13 +263,13 @@ plugin_list_next_item (struct t_plugin_list *list)
}
/*
- * plugin_list_prev_item: return previous item for a list
- * if current item pointer is NULL,
- * then return last item of list
+ * plugin_infolist_prev_item: return previous item for a list
+ * if current item pointer is NULL,
+ * then return last item of list
*/
-struct t_plugin_list_item *
-plugin_list_prev_item (struct t_plugin_list *list)
+struct t_plugin_infolist_item *
+plugin_infolist_prev_item (struct t_plugin_infolist *list)
{
if (!list->ptr_item)
{
@@ -281,13 +281,13 @@ plugin_list_prev_item (struct t_plugin_list *list)
}
/*
- * plugin_list_get_fields: get list of fields for current list item
+ * plugin_infolist_get_fields: get list of fields for current list item
*/
char *
-plugin_list_get_fields (struct t_plugin_list *list)
+plugin_infolist_get_fields (struct t_plugin_infolist *list)
{
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist_var *ptr_var;
int length;
if (!list || !list->ptr_item)
@@ -312,16 +312,16 @@ plugin_list_get_fields (struct t_plugin_list *list)
{
switch (ptr_var->type)
{
- case PLUGIN_LIST_VAR_INTEGER:
+ case PLUGIN_INFOLIST_INTEGER:
strcat (list->ptr_item->fields, "i:");
break;
- case PLUGIN_LIST_VAR_STRING:
+ case PLUGIN_INFOLIST_STRING:
strcat (list->ptr_item->fields, "s:");
break;
- case PLUGIN_LIST_VAR_POINTER:
+ case PLUGIN_INFOLIST_POINTER:
strcat (list->ptr_item->fields, "p:");
break;
- case PLUGIN_LIST_VAR_TIME:
+ case PLUGIN_INFOLIST_TIME:
strcat (list->ptr_item->fields, "t:");
break;
}
@@ -334,13 +334,13 @@ plugin_list_get_fields (struct t_plugin_list *list)
}
/*
- * plugin_list_get_integer: get an integer variable value in current list item
+ * plugin_infolist_get_integer: get an integer variable value in current list item
*/
int
-plugin_list_get_integer (struct t_plugin_list *list, char *var)
+plugin_infolist_get_integer (struct t_plugin_infolist *list, char *var)
{
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return 0;
@@ -349,7 +349,7 @@ plugin_list_get_integer (struct t_plugin_list *list, char *var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
- if (ptr_var->type == PLUGIN_LIST_VAR_INTEGER)
+ if (ptr_var->type == PLUGIN_INFOLIST_INTEGER)
return *((int *)ptr_var->value);
else
return 0;
@@ -361,13 +361,13 @@ plugin_list_get_integer (struct t_plugin_list *list, char *var)
}
/*
- * plugin_list_get_string: get a string variable value in current list item
+ * plugin_infolist_get_string: get a string variable value in current list item
*/
char *
-plugin_list_get_string (struct t_plugin_list *list, char *var)
+plugin_infolist_get_string (struct t_plugin_infolist *list, char *var)
{
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return NULL;
@@ -376,7 +376,7 @@ plugin_list_get_string (struct t_plugin_list *list, char *var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
- if (ptr_var->type == PLUGIN_LIST_VAR_STRING)
+ if (ptr_var->type == PLUGIN_INFOLIST_STRING)
return (char *)ptr_var->value;
else
return NULL;
@@ -388,13 +388,13 @@ plugin_list_get_string (struct t_plugin_list *list, char *var)
}
/*
- * plugin_list_get_pointer: get a pointer variable value in current list item
+ * plugin_infolist_get_pointer: get a pointer variable value in current list item
*/
void *
-plugin_list_get_pointer (struct t_plugin_list *list, char *var)
+plugin_infolist_get_pointer (struct t_plugin_infolist *list, char *var)
{
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return NULL;
@@ -403,7 +403,7 @@ plugin_list_get_pointer (struct t_plugin_list *list, char *var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
- if (ptr_var->type == PLUGIN_LIST_VAR_POINTER)
+ if (ptr_var->type == PLUGIN_INFOLIST_POINTER)
return ptr_var->value;
else
return NULL;
@@ -415,13 +415,13 @@ plugin_list_get_pointer (struct t_plugin_list *list, char *var)
}
/*
- * plugin_list_get_time: get a time variable value in current list item
+ * plugin_infolist_get_time: get a time variable value in current list item
*/
time_t
-plugin_list_get_time (struct t_plugin_list *list, char *var)
+plugin_infolist_get_time (struct t_plugin_infolist *list, char *var)
{
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist_var *ptr_var;
if (!list || !list->ptr_item || !var || !var[0])
return 0;
@@ -430,7 +430,7 @@ plugin_list_get_time (struct t_plugin_list *list, char *var)
{
if (string_strcasecmp (ptr_var->name, var) == 0)
{
- if (ptr_var->type == PLUGIN_LIST_VAR_TIME)
+ if (ptr_var->type == PLUGIN_INFOLIST_TIME)
return *((time_t *)ptr_var->value);
else
return 0;
@@ -442,14 +442,14 @@ plugin_list_get_time (struct t_plugin_list *list, char *var)
}
/*
- * plugin_list_var_free: free a plugin list variable
+ * plugin_infolist_var_free: free a plugin list variable
*/
void
-plugin_list_var_free (struct t_plugin_list_item *item,
- struct t_plugin_list_var *var)
+plugin_infolist_var_free (struct t_plugin_infolist_item *item,
+ struct t_plugin_infolist_var *var)
{
- struct t_plugin_list_var *new_vars;
+ struct t_plugin_infolist_var *new_vars;
/* remove var */
if (item->last_var == var)
@@ -468,9 +468,9 @@ plugin_list_var_free (struct t_plugin_list_item *item,
/* free data */
if (var->name)
free (var->name);
- if (((var->type == PLUGIN_LIST_VAR_INTEGER)
- || (var->type == PLUGIN_LIST_VAR_STRING)
- || (var->type == PLUGIN_LIST_VAR_TIME))
+ if (((var->type == PLUGIN_INFOLIST_INTEGER)
+ || (var->type == PLUGIN_INFOLIST_STRING)
+ || (var->type == PLUGIN_INFOLIST_TIME))
&& var->value)
{
free (var->value);
@@ -480,14 +480,14 @@ plugin_list_var_free (struct t_plugin_list_item *item,
}
/*
- * plugin_list_item_free: free a plugin list item
+ * plugin_infolist_item_free: free a plugin list item
*/
void
-plugin_list_item_free (struct t_plugin_list *list,
- struct t_plugin_list_item *item)
+plugin_infolist_item_free (struct t_plugin_infolist *list,
+ struct t_plugin_infolist_item *item)
{
- struct t_plugin_list_item *new_items;
+ struct t_plugin_infolist_item *new_items;
/* remove var */
if (list->last_item == item)
@@ -506,7 +506,7 @@ plugin_list_item_free (struct t_plugin_list *list,
/* free data */
while (item->vars)
{
- plugin_list_var_free (item, item->vars);
+ plugin_infolist_var_free (item, item->vars);
}
if (item->fields)
free (item->fields);
@@ -515,93 +515,93 @@ plugin_list_item_free (struct t_plugin_list *list,
}
/*
- * plugin_list_free: free a plugin list
+ * plugin_infolist_free: free a plugin list
*/
void
-plugin_list_free (struct t_plugin_list *list)
+plugin_infolist_free (struct t_plugin_infolist *list)
{
- struct t_plugin_list *new_plugin_lists;
+ struct t_plugin_infolist *new_plugin_infolists;
/* remove list */
- if (last_plugin_list == list)
- last_plugin_list = list->prev_list;
- if (list->prev_list)
+ if (last_plugin_infolist == list)
+ last_plugin_infolist = list->prev_infolist;
+ if (list->prev_infolist)
{
- (list->prev_list)->next_list = list->next_list;
- new_plugin_lists = plugin_lists;
+ (list->prev_infolist)->next_infolist = list->next_infolist;
+ new_plugin_infolists = plugin_infolists;
}
else
- new_plugin_lists = list->next_list;
+ new_plugin_infolists = list->next_infolist;
- if (list->next_list)
- (list->next_list)->prev_list = list->prev_list;
+ if (list->next_infolist)
+ (list->next_infolist)->prev_infolist = list->prev_infolist;
/* free data */
while (list->items)
{
- plugin_list_item_free (list, list->items);
+ plugin_infolist_item_free (list, list->items);
}
- plugin_lists = new_plugin_lists;
+ plugin_infolists = new_plugin_infolists;
}
/*
- * plugin_list_print_log: print plugin lists infos in log (usually for crash dump)
+ * plugin_infolist_print_log: print plugin lists infos in log (usually for crash dump)
*/
void
-plugin_list_print_log ()
+plugin_infolist_print_log ()
{
- struct t_plugin_list *ptr_list;
- struct t_plugin_list_item *ptr_item;
- struct t_plugin_list_var *ptr_var;
+ struct t_plugin_infolist *ptr_infolist;
+ struct t_plugin_infolist_item *ptr_item;
+ struct t_plugin_infolist_var *ptr_var;
- for (ptr_list = plugin_lists; ptr_list;
- ptr_list = ptr_list->next_list)
+ for (ptr_infolist = plugin_infolists; ptr_infolist;
+ ptr_infolist = ptr_infolist->next_infolist)
{
- log_printf ("\n");
- log_printf ("[plugin list (addr:0x%X)]\n", ptr_list);
- log_printf (" items. . . . . . . . . : 0x%X\n", ptr_list->items);
- log_printf (" last_item. . . . . . . : 0x%X\n", ptr_list->last_item);
- log_printf (" ptr_item . . . . . . . : 0x%X\n", ptr_list->ptr_item);
- log_printf (" prev_list. . . . . . . : 0x%X\n", ptr_list->prev_list);
- log_printf (" next_list. . . . . . . : 0x%X\n", ptr_list->next_list);
+ log_printf ("");
+ log_printf ("[plugin infolist (addr:0x%X)]", ptr_infolist);
+ log_printf (" items. . . . . . . . . : 0x%X", ptr_infolist->items);
+ log_printf (" last_item. . . . . . . : 0x%X", ptr_infolist->last_item);
+ log_printf (" ptr_item . . . . . . . : 0x%X", ptr_infolist->ptr_item);
+ log_printf (" prev_infolist. . . . . : 0x%X", ptr_infolist->prev_infolist);
+ log_printf (" next_infolist. . . . . : 0x%X", ptr_infolist->next_infolist);
- for (ptr_item = ptr_list->items; ptr_item;
+ for (ptr_item = ptr_infolist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
- log_printf ("\n");
- log_printf (" [item (addr:0x%X)]\n", ptr_item);
- log_printf (" vars . . . . . . . . . : 0x%X\n", ptr_item->vars);
- log_printf (" last_var . . . . . . . : 0x%X\n", ptr_item->last_var);
- log_printf (" prev_item. . . . . . . : 0x%X\n", ptr_item->prev_item);
- log_printf (" next_item. . . . . . . : 0x%X\n", ptr_item->next_item);
+ log_printf ("");
+ log_printf (" [item (addr:0x%X)]", ptr_item);
+ log_printf (" vars . . . . . . . . . : 0x%X", ptr_item->vars);
+ log_printf (" last_var . . . . . . . : 0x%X", ptr_item->last_var);
+ log_printf (" prev_item. . . . . . . : 0x%X", ptr_item->prev_item);
+ log_printf (" next_item. . . . . . . : 0x%X", ptr_item->next_item);
for (ptr_var = ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
- log_printf ("\n");
- log_printf (" [var (addr:0x%X)]\n", ptr_var);
- log_printf (" name . . . . . . . . : '%s'\n", ptr_var->name);
- log_printf (" type . . . . . . . . : %d\n", ptr_var->type);
+ log_printf ("");
+ log_printf (" [var (addr:0x%X)]", ptr_var);
+ log_printf (" name . . . . . . . . : '%s'", ptr_var->name);
+ log_printf (" type . . . . . . . . : %d", ptr_var->type);
switch (ptr_var->type)
{
- case PLUGIN_LIST_VAR_INTEGER:
- log_printf (" value (integer). . . : %d\n", *((int *)ptr_var->value));
+ case PLUGIN_INFOLIST_INTEGER:
+ log_printf (" value (integer). . . : %d", *((int *)ptr_var->value));
break;
- case PLUGIN_LIST_VAR_STRING:
- log_printf (" value (string) . . . : '%s'\n", (char *)ptr_var->value);
+ case PLUGIN_INFOLIST_STRING:
+ log_printf (" value (string) . . . : '%s'", (char *)ptr_var->value);
break;
- case PLUGIN_LIST_VAR_POINTER:
- log_printf (" value (pointer). . . : 0x%X\n", ptr_var->value);
+ case PLUGIN_INFOLIST_POINTER:
+ log_printf (" value (pointer). . . : 0x%X", ptr_var->value);
break;
- case PLUGIN_LIST_VAR_TIME:
- log_printf (" value (time) . . . . : %ld\n", *((time_t *)ptr_var->value));
+ case PLUGIN_INFOLIST_TIME:
+ log_printf (" value (time) . . . . : %ld", *((time_t *)ptr_var->value));
break;
}
- log_printf (" prev_var . . . . . . : 0x%X\n", ptr_var->prev_var);
- log_printf (" next_var . . . . . . : 0x%X\n", ptr_var->next_var);
+ log_printf (" prev_var . . . . . . : 0x%X", ptr_var->prev_var);
+ log_printf (" next_var . . . . . . : 0x%X", ptr_var->next_var);
}
}
}
diff --git a/src/plugins/plugin-infolist.h b/src/plugins/plugin-infolist.h
new file mode 100644
index 000000000..567c8b9b0
--- /dev/null
+++ b/src/plugins/plugin-infolist.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_PLUGIN_INFOLIST_H
+#define __WEECHAT_PLUGIN_INFOLIST_H 1
+
+/* list structures */
+
+enum t_plugin_infolist_type
+{
+ PLUGIN_INFOLIST_INTEGER = 0,
+ PLUGIN_INFOLIST_STRING,
+ PLUGIN_INFOLIST_POINTER,
+ PLUGIN_INFOLIST_TIME,
+};
+
+struct t_plugin_infolist_var
+{
+ char *name; /* variable name */
+ enum t_plugin_infolist_type type; /* type: integer, string, time */
+ void *value; /* pointer to value */
+ struct t_plugin_infolist_var *prev_var; /* link to previous variable */
+ struct t_plugin_infolist_var *next_var; /* link to next variable */
+};
+
+struct t_plugin_infolist_item
+{
+ struct t_plugin_infolist_var *vars; /* item variables */
+ struct t_plugin_infolist_var *last_var; /* last variable */
+ char *fields; /* fields list (NULL if never */
+ /* asked) */
+ struct t_plugin_infolist_item *prev_item; /* link to previous item */
+ struct t_plugin_infolist_item *next_item; /* link to next item */
+};
+
+struct t_plugin_infolist
+{
+ struct t_plugin_infolist_item *items; /* link to items */
+ struct t_plugin_infolist_item *last_item; /* last variable */
+ struct t_plugin_infolist_item *ptr_item; /* pointer to current item */
+ struct t_plugin_infolist *prev_infolist; /* link to previous list */
+ struct t_plugin_infolist *next_infolist; /* link to next list */
+};
+
+/* list variables */
+
+extern struct t_plugin_infolist *plugin_infolists;
+extern struct t_plugin_infolist *last_plugin_infolist;
+
+/* list functions */
+
+extern struct t_plugin_infolist *plugin_infolist_new ();
+extern struct t_plugin_infolist_item *plugin_infolist_new_item (struct t_plugin_infolist *);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_integer (struct t_plugin_infolist_item *,
+ char *, int);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_string (struct t_plugin_infolist_item *,
+ char *, char *);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *,
+ char *, void *);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_time (struct t_plugin_infolist_item *,
+ char *, time_t);
+extern int plugin_infolist_valid (struct t_plugin_infolist *);
+extern struct t_plugin_infolist_item *plugin_infolist_next_item (struct t_plugin_infolist *);
+extern struct t_plugin_infolist_item *plugin_infolist_prev_item (struct t_plugin_infolist *);
+extern char *plugin_infolist_get_fields (struct t_plugin_infolist *);
+extern int plugin_infolist_get_integer (struct t_plugin_infolist *, char *);
+extern char *plugin_infolist_get_string (struct t_plugin_infolist *, char *);
+extern void *plugin_infolist_get_pointer (struct t_plugin_infolist *, char *);
+extern time_t plugin_infolist_get_time (struct t_plugin_infolist *, char *);
+extern void plugin_infolist_free (struct t_plugin_infolist *);
+extern void plugin_infolist_print_log ();
+
+#endif /* plugin-infolist.h */
diff --git a/src/plugins/plugin-list.h b/src/plugins/plugin-list.h
deleted file mode 100644
index b415d4f71..000000000
--- a/src/plugins/plugin-list.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
- * See README for License detail, AUTHORS for developers list.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __WEECHAT_PLUGIN_LIST_H
-#define __WEECHAT_PLUGIN_LIST_H 1
-
-/* list structures */
-
-enum t_plugin_var_type
-{
- PLUGIN_LIST_VAR_INTEGER = 0,
- PLUGIN_LIST_VAR_STRING,
- PLUGIN_LIST_VAR_POINTER,
- PLUGIN_LIST_VAR_TIME,
-};
-
-struct t_plugin_list_var
-{
- char *name; /* variable name */
- enum t_plugin_var_type type; /* type: integer, string, time */
- void *value; /* pointer to value */
- struct t_plugin_list_var *prev_var; /* link to previous variable */
- struct t_plugin_list_var *next_var; /* link to next variable */
-};
-
-struct t_plugin_list_item
-{
- struct t_plugin_list_var *vars; /* item variables */
- struct t_plugin_list_var *last_var; /* last variable */
- char *fields; /* fields list (NULL if never */
- /* asked) */
- struct t_plugin_list_item *prev_item; /* link to previous item */
- struct t_plugin_list_item *next_item; /* link to next item */
-};
-
-struct t_plugin_list
-{
- struct t_plugin_list_item *items; /* link to items */
- struct t_plugin_list_item *last_item; /* last variable */
- struct t_plugin_list_item *ptr_item; /* pointer to current item */
- struct t_plugin_list *prev_list; /* link to previous list */
- struct t_plugin_list *next_list; /* link to next list */
-};
-
-/* list variables */
-
-extern struct t_plugin_list *plugin_lists;
-extern struct t_plugin_list *last_plugin_list;
-
-/* list functions */
-
-extern struct t_plugin_list *plugin_list_new ();
-extern struct t_plugin_list_item *plugin_list_new_item (struct t_plugin_list *);
-extern struct t_plugin_list_var *plugin_list_new_var_integer (struct t_plugin_list_item *,
- char *, int);
-extern struct t_plugin_list_var *plugin_list_new_var_string (struct t_plugin_list_item *,
- char *, char *);
-extern struct t_plugin_list_var *plugin_list_new_var_pointer (struct t_plugin_list_item *,
- char *, void *);
-extern struct t_plugin_list_var *plugin_list_new_var_time (struct t_plugin_list_item *,
- char *, time_t);
-extern int plugin_list_valid (struct t_plugin_list *);
-extern struct t_plugin_list_item *plugin_list_next_item (struct t_plugin_list *);
-extern struct t_plugin_list_item *plugin_list_prev_item (struct t_plugin_list *);
-extern char *plugin_list_get_fields (struct t_plugin_list *);
-extern int plugin_list_get_integer (struct t_plugin_list *, char *);
-extern char *plugin_list_get_string (struct t_plugin_list *, char *);
-extern void *plugin_list_get_pointer (struct t_plugin_list *, char *);
-extern time_t plugin_list_get_time (struct t_plugin_list *, char *);
-extern void plugin_list_free (struct t_plugin_list *);
-extern void plugin_list_print_log ();
-
-#endif /* plugin-list.h */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index c25ff870a..09b481734 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -43,7 +43,7 @@
#include "plugin.h"
#include "plugin-api.h"
#include "plugin-config.h"
-#include "plugin-list.h"
+#include "plugin-infolist.h"
struct t_weechat_plugin *weechat_plugins = NULL;
@@ -237,11 +237,31 @@ plugin_load (char *filename)
new_plugin->string_free_splitted_command = &plugin_api_string_free_splitted_command;
new_plugin->mkdir_home = &plugin_api_mkdir_home;
+ new_plugin->mkdir = &plugin_api_mkdir;
new_plugin->exec_on_files = &plugin_api_exec_on_files;
-
+
+ new_plugin->timeval_diff = &plugin_api_timeval_diff;
+
+ new_plugin->list_new = &plugin_api_list_new;
+ new_plugin->list_add = &plugin_api_list_add;
+ new_plugin->list_search = &plugin_api_list_search;
+ new_plugin->list_casesearch = &plugin_api_list_casesearch;
+ new_plugin->list_get = &plugin_api_list_get;
+ new_plugin->list_next = &plugin_api_list_next;
+ new_plugin->list_prev = &plugin_api_list_prev;
+ new_plugin->list_string = &plugin_api_list_string;
+ new_plugin->list_size = &plugin_api_list_size;
+ new_plugin->list_remove = &plugin_api_list_remove;
+ new_plugin->list_remove_all = &plugin_api_list_remove_all;
+ new_plugin->list_free = &plugin_api_list_free;
+
new_plugin->config_new = &plugin_api_config_new;
new_plugin->config_new_section = &plugin_api_config_new_section;
+ new_plugin->config_search_section = &plugin_api_config_search_section;
new_plugin->config_new_option = &plugin_api_config_new_option;
+ new_plugin->config_search_option = &plugin_api_config_search_option;
+ new_plugin->config_option_set = &plugin_api_config_option_set;
+ new_plugin->config_string_to_boolean = &plugin_api_config_string_to_boolean;
new_plugin->config_boolean = &plugin_api_config_boolean;
new_plugin->config_integer = &plugin_api_config_integer;
new_plugin->config_string = &plugin_api_config_string;
@@ -252,7 +272,6 @@ plugin_load (char *filename)
new_plugin->config_write_line = &plugin_api_config_write_line;
new_plugin->config_free = &plugin_api_config_free;
new_plugin->config_get = &plugin_api_config_get;
- new_plugin->config_set = &plugin_api_config_set;
new_plugin->plugin_config_get = &plugin_api_plugin_config_get;
new_plugin->plugin_config_set = &plugin_api_plugin_config_set;
@@ -260,6 +279,7 @@ plugin_load (char *filename)
new_plugin->color = &plugin_api_color;
new_plugin->printf = &plugin_api_printf;
new_plugin->printf_date = &plugin_api_printf_date;
+ new_plugin->log_printf = &plugin_api_log_printf;
new_plugin->print_infobar = &plugin_api_print_infobar;
new_plugin->infobar_remove = &plugin_api_infobar_remove;
@@ -283,15 +303,15 @@ plugin_load (char *filename)
new_plugin->info_get = &plugin_api_info_get;
- new_plugin->list_get = &plugin_api_list_get;
- new_plugin->list_next = &plugin_api_list_next;
- new_plugin->list_prev = &plugin_api_list_prev;
- new_plugin->list_fields = &plugin_api_list_fields;
- new_plugin->list_integer = &plugin_api_list_integer;
- new_plugin->list_string = &plugin_api_list_string;
- new_plugin->list_pointer = &plugin_api_list_pointer;
- new_plugin->list_time = &plugin_api_list_time;
- new_plugin->list_free = &plugin_api_list_free;
+ new_plugin->infolist_get = &plugin_api_infolist_get;
+ new_plugin->infolist_next = &plugin_api_infolist_next;
+ new_plugin->infolist_prev = &plugin_api_infolist_prev;
+ new_plugin->infolist_fields = &plugin_api_infolist_fields;
+ new_plugin->infolist_integer = &plugin_api_infolist_integer;
+ new_plugin->infolist_string = &plugin_api_infolist_string;
+ new_plugin->infolist_pointer = &plugin_api_infolist_pointer;
+ new_plugin->infolist_time = &plugin_api_infolist_time;
+ new_plugin->infolist_free = &plugin_api_infolist_free;
new_plugin->log = &plugin_api_log;
@@ -616,17 +636,17 @@ plugin_print_log ()
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
- log_printf ("\n");
- log_printf ("[plugin (addr:0x%X)]\n", ptr_plugin);
- log_printf (" filename . . . . . . . : '%s'\n", ptr_plugin->filename);
- log_printf (" handle . . . . . . . . : 0x%X\n", ptr_plugin->handle);
- log_printf (" name . . . . . . . . . : '%s'\n", ptr_plugin->name);
- log_printf (" description. . . . . . : '%s'\n", ptr_plugin->description);
- log_printf (" version. . . . . . . . : '%s'\n", ptr_plugin->version);
- log_printf (" charset. . . . . . . . : '%s'\n", ptr_plugin->charset);
- log_printf (" prev_plugin. . . . . . : 0x%X\n", ptr_plugin->prev_plugin);
- log_printf (" next_plugin. . . . . . : 0x%X\n", ptr_plugin->next_plugin);
+ log_printf ("");
+ log_printf ("[plugin (addr:0x%X)]", ptr_plugin);
+ log_printf (" filename . . . . . . . : '%s'", ptr_plugin->filename);
+ log_printf (" handle . . . . . . . . : 0x%X", ptr_plugin->handle);
+ log_printf (" name . . . . . . . . . : '%s'", ptr_plugin->name);
+ log_printf (" description. . . . . . : '%s'", ptr_plugin->description);
+ log_printf (" version. . . . . . . . : '%s'", ptr_plugin->version);
+ log_printf (" charset. . . . . . . . : '%s'", ptr_plugin->charset);
+ log_printf (" prev_plugin. . . . . . : 0x%X", ptr_plugin->prev_plugin);
+ log_printf (" next_plugin. . . . . . : 0x%X", ptr_plugin->next_plugin);
}
- plugin_list_print_log ();
+ plugin_infolist_print_log ();
}
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 07357f250..115c9f032 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -71,21 +71,48 @@ struct t_weechat_plugin
void (*string_free_splitted_command) (struct t_weechat_plugin *, char **);
/* directories */
- int (*mkdir_home) (struct t_weechat_plugin *, char *);
+ int (*mkdir_home) (struct t_weechat_plugin *, char *, int);
+ int (*mkdir) (struct t_weechat_plugin *, char *, int);
void (*exec_on_files) (struct t_weechat_plugin *, char *,
int (*)(char *));
+ /* util */
+ long (*timeval_diff) (struct t_weechat_plugin *, void *, void *);
+
+ /* sorted list */
+ struct t_weelist *(*list_new) (struct t_weechat_plugin *);
+ char *(*list_add) (struct t_weechat_plugin *, void *, char *,
+ char *);
+ struct t_weelist_item *(*list_search) (struct t_weechat_plugin *, void *,
+ char *);
+ struct t_weelist_item *(*list_casesearch) (struct t_weechat_plugin *, void *,
+ char *);
+ struct t_weelist_item *(*list_get) (struct t_weechat_plugin *, void *, int);
+ struct t_weelist_item *(*list_next) (struct t_weechat_plugin *, void *);
+ struct t_weelist_item *(*list_prev) (struct t_weechat_plugin *, void *);
+ char *(*list_string) (struct t_weechat_plugin *, void *);
+ int (*list_size) (struct t_weechat_plugin *, void *);
+ void (*list_remove) (struct t_weechat_plugin *, void *, void *);
+ void (*list_remove_all) (struct t_weechat_plugin *, void *);
+ void (*list_free) (struct t_weechat_plugin *, void *);
+
/* config files */
struct t_config_file *(*config_new) (struct t_weechat_plugin *, char *);
struct t_config_section *(*config_new_section) (struct t_weechat_plugin *,
void *, char *,
void (*)(void *, char *, char *),
- void (*)(void *),
- void (*)(void *));
+ void (*)(void *, char *),
+ void (*)(void *, char *));
+ struct t_config_section *(*config_search_section) (struct t_weechat_plugin *,
+ void *, char *);
struct t_config_option *(*config_new_option) (struct t_weechat_plugin *,
void *, char *, char *,
char *, char *, int, int,
char *, void (*)());
+ struct t_config_option *(*config_search_option) (struct t_weechat_plugin *,
+ void *, void *, char *);
+ int (*config_option_set) (struct t_weechat_plugin *, void *, char *);
+ char (*config_string_to_boolean) (struct t_weechat_plugin *, char *);
char (*config_boolean) (struct t_weechat_plugin *, void *);
int (*config_integer) (struct t_weechat_plugin *, void *);
char *(*config_string) (struct t_weechat_plugin *, void *);
@@ -94,10 +121,9 @@ struct t_weechat_plugin
int (*config_reload) (struct t_weechat_plugin *, void *);
int (*config_write) (struct t_weechat_plugin *, void *);
void (*config_write_line) (struct t_weechat_plugin *, void *,
- char *, char *);
+ char *, char *, ...);
void (*config_free) (struct t_weechat_plugin *, void *);
- char *(*config_get) (struct t_weechat_plugin *, char *);
- int (*config_set) (struct t_weechat_plugin *, char *, char *);
+ struct t_config_option *(*config_get) (struct t_weechat_plugin *, char *);
char *(*plugin_config_get) (struct t_weechat_plugin *, char *);
int (*plugin_config_set) (struct t_weechat_plugin *, char *, char *);
@@ -150,17 +176,17 @@ struct t_weechat_plugin
/* infos */
char *(*info_get) (struct t_weechat_plugin *, char *);
- /* lists */
- struct t_plugin_list *(*list_get) (struct t_weechat_plugin *, char *,
- void *);
- int (*list_next) (struct t_weechat_plugin *, void *);
- int (*list_prev) (struct t_weechat_plugin *, void *);
- char *(*list_fields) (struct t_weechat_plugin *, void *);
- int (*list_integer) (struct t_weechat_plugin *, void *, char *);
- char *(*list_string) (struct t_weechat_plugin *, void *, char *);
- void *(*list_pointer) (struct t_weechat_plugin *, void *, char *);
- time_t (*list_time) (struct t_weechat_plugin *, void *, char *);
- void (*list_free) (struct t_weechat_plugin *, void *);
+ /* infolists */
+ struct t_plugin_infolist *(*infolist_get) (struct t_weechat_plugin *,
+ char *, void *);
+ int (*infolist_next) (struct t_weechat_plugin *, void *);
+ int (*infolist_prev) (struct t_weechat_plugin *, void *);
+ char *(*infolist_fields) (struct t_weechat_plugin *, void *);
+ int (*infolist_integer) (struct t_weechat_plugin *, void *, char *);
+ char *(*infolist_string) (struct t_weechat_plugin *, void *, char *);
+ void *(*infolist_pointer) (struct t_weechat_plugin *, void *, char *);
+ time_t (*infolist_time) (struct t_weechat_plugin *, void *, char *);
+ void (*infolist_free) (struct t_weechat_plugin *, void *);
/* log */
void (*log) (struct t_weechat_plugin *, char *, char *, char *, ...);
@@ -208,12 +234,44 @@ struct t_weechat_plugin
__array_str)
/* directories */
-#define weechat_mkdir_home(__directory) \
- weechat_plugin->mkdir_home(weechat_plugin, __directory)
+#define weechat_mkdir_home(__directory, __mode) \
+ weechat_plugin->mkdir_home(weechat_plugin, __directory, __mode)
+#define weechat_mkdir(__directory, __mode) \
+ weechat_plugin->mkdir(weechat_plugin, __directory, __mode)
#define weechat_exec_on_files(__directory, __callback) \
weechat_plugin->exec_on_files(weechat_plugin, __directory, \
__callback)
+/* util */
+#define weechat_timeval_diff(__time1, __time2) \
+ weechat_plugin->timeval_diff(weechat_plugin, __time1, __time2)
+
+/* sorted list */
+#define weechat_list_new() \
+ weechat_plugin->list_new(weechat_plugin)
+#define weechat_list_add(__list, __string, __sort) \
+ weechat_plugin->list_add(weechat_plugin, __list, __string, __sort)
+#define weechat_list_search(__list, __string) \
+ weechat_plugin->list_search(weechat_plugin, __list, __string)
+#define weechat_list_casesearch(__list, __string) \
+ weechat_plugin->list_casesearch(weechat_plugin, __list, __string)
+#define weechat_list_get(__list, __index) \
+ weechat_plugin->list_get(weechat_plugin, __list, __index)
+#define weechat_list_next(__item) \
+ weechat_plugin->list_next(weechat_plugin, __item)
+#define weechat_list_prev(__item) \
+ weechat_plugin->list_prev(weechat_plugin, __item)
+#define weechat_list_string(__item) \
+ weechat_plugin->list_string(weechat_plugin, __item)
+#define weechat_list_size(__list) \
+ weechat_plugin->list_size(weechat_plugin, __list)
+#define weechat_list_remove(__list, __item) \
+ weechat_plugin->list_remove(weechat_plugin, __list, __item)
+#define weechat_list_remove_all(__list) \
+ weechat_plugin->list_remove_all(weechat_plugin, __list)
+#define weechat_list_free(__list) \
+ weechat_plugin->list_free(weechat_plugin, __list)
+
/* config files */
#define weechat_config_new(__filename) \
weechat_plugin->config_new(weechat_plugin, __filename)
@@ -222,16 +280,28 @@ struct t_weechat_plugin
weechat_plugin->config_new_section(weechat_plugin, \
__config, __name, __cb_read, \
__cb_write_std, __cb_write_def)
-#define weechat_config_new_option(__section, __name, __desc, \
+#define weechat_config_search_section(__config, __name) \
+ weechat_plugin->config_search_section(weechat_plugin, \
+ __config, __name)
+#define weechat_config_new_option(__section, __name, __type, __desc, \
__string_values, __min, __max, \
__default, __callback) \
weechat_plugin->config_new_option(weechat_plugin, \
- __section, __name, __desc, \
- __string_values, __min, __max, \
- __default, __callback)
+ __section, __name, __type, \
+ __desc, __string_values, \
+ __min, __max, __default, \
+ __callback)
+#define weechat_config_search_option(__config, __section, __name) \
+ weechat_plugin->config_search_option(weechat_plugin, \
+ __config, __section, __name)
+#define weechat_config_option_set(__option, __value) \
+ weechat_plugin->config_option_set(weechat_plugin, __option, \
+ __value)
+#define weechat_config_string_to_boolean(__string) \
+ weechat_plugin->config_string_to_boolean(weechat_plugin, __string)
#define weechat_config_boolean(__option) \
weechat_plugin->config_boolean(weechat_plugin, __option)
-#define weechat_config_integer(__option) \
+#define weechat_config_integer(__option) \
weechat_plugin->config_integer(weechat_plugin, __option)
#define weechat_config_string(__option) \
weechat_plugin->config_string(weechat_plugin, __option)
@@ -243,16 +313,15 @@ struct t_weechat_plugin
weechat_plugin->config_reload(weechat_plugin, __config)
#define weechat_config_write(__config) \
weechat_plugin->config_write(weechat_plugin, __config)
-#define weechat_config_write_line(__config, __option, __value) \
+#define weechat_config_write_line(__config, __option, \
+ __value...) \
weechat_plugin->config_write_line(weechat_plugin, \
__config, __option, \
- __value)
+ ##__value)
#define weechat_config_free(__config) \
weechat_plugin->config_free(weechat_plugin, __config)
#define weechat_config_get(__option) \
weechat_plugin->config_get(weechat_plugin, __option)
-#define weechat_config_set(__option, __value) \
- weechat_plugin->config_set(weechat_plugin, __option, __value)
#define weechat_plugin_config_get(__option) \
weechat_plugin->plugin_config_get(weechat_plugin, __option)
#define weechat_plugin_config_set(__option, __value) \
@@ -268,7 +337,7 @@ struct t_weechat_plugin
#define weechat_printf_date(__buffer, __datetime, __argz...) \
weechat_plugin->printf_date(weechat_plugin, __buffer, __datetime, \
##__argz)
-#define weechat2_log_printf(__argz...) \
+#define weechat_log_printf(__argz...) \
weechat_plugin->log_printf(weechat_plugin, ##__argz)
/* hooks */
@@ -322,24 +391,24 @@ struct t_weechat_plugin
#define weechat_info_get(__name) \
weechat_plugin->info_get(weechat_plugin, __name)
-/* lists */
-#define weechat_list_get(__name, __pointer) \
- weechat_plugin->list_get(weechat_plugin, __name, __pointer)
-#define weechat_list_next(__list) \
- weechat_plugin->list_next(weechat_plugin, __list)
-#define weechat_list_prev(__list) \
- weechat_plugin->list_prev(weechat_plugin, __list)
-#define weechat_list_fields(__list) \
- weechat_plugin->list_fields(weechat_plugin, __list)
-#define weechat_list_integer(__item, __var) \
- weechat_plugin->list_integer(weechat_plugin, __item, __var)
-#define weechat_list_string(__item, __var) \
- weechat_plugin->list_string(weechat_plugin, __item, __var)
-#define weechat_list_pointer(__item, __var) \
- weechat_plugin->list_pointer(weechat_plugin, __item, __var)
-#define weechat_list_time(__item, __var) \
- weechat_plugin->list_time(weechat_plugin, __item, __var)
-#define weechat_list_free(__list) \
- weechat_plugin->list_free(weechat_plugin, __list)
+/* infolists */
+#define weechat_infolist_get(__name, __pointer) \
+ weechat_plugin->infolist_get(weechat_plugin, __name, __pointer)
+#define weechat_infolist_next(__list) \
+ weechat_plugin->infolist_next(weechat_plugin, __list)
+#define weechat_infolist_prev(__list) \
+ weechat_plugin->infolist_prev(weechat_plugin, __list)
+#define weechat_infolist_fields(__list) \
+ weechat_plugin->infolist_fields(weechat_plugin, __list)
+#define weechat_infolist_integer(__item, __var) \
+ weechat_plugin->infolist_integer(weechat_plugin, __item, __var)
+#define weechat_infolist_string(__item, __var) \
+ weechat_plugin->infolist_string(weechat_plugin, __item, __var)
+#define weechat_infolist_pointer(__item, __var) \
+ weechat_plugin->infolist_pointer(weechat_plugin, __item, __var)
+#define weechat_infolist_time(__item, __var) \
+ weechat_plugin->infolist_time(weechat_plugin, __item, __var)
+#define weechat_infolist_free(__list) \
+ weechat_plugin->infolist_free(weechat_plugin, __list)
#endif /* weechat-plugin.h */