summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/alias/alias.c36
-rw-r--r--src/plugins/aspell/aspell.c18
-rw-r--r--src/plugins/aspell/aspell.h6
-rw-r--r--src/plugins/demo/demo.c29
-rw-r--r--src/plugins/fifo/fifo.c52
-rw-r--r--src/plugins/irc/irc-buffer.h8
-rw-r--r--src/plugins/irc/irc-channel.c18
-rw-r--r--src/plugins/irc/irc-channel.h88
-rw-r--r--src/plugins/irc/irc-color.c3
-rw-r--r--src/plugins/irc/irc-color.h8
-rw-r--r--src/plugins/irc/irc-command.c249
-rw-r--r--src/plugins/irc/irc-command.h14
-rw-r--r--src/plugins/irc/irc-completion.c64
-rw-r--r--src/plugins/irc/irc-completion.h11
-rw-r--r--src/plugins/irc/irc-config.c11
-rw-r--r--src/plugins/irc/irc-config.h5
-rw-r--r--src/plugins/irc/irc-dcc.c517
-rw-r--r--src/plugins/irc/irc-dcc.h32
-rw-r--r--src/plugins/irc/irc-display.h18
-rw-r--r--src/plugins/irc/irc-mode.c10
-rw-r--r--src/plugins/irc/irc-mode.h9
-rw-r--r--src/plugins/irc/irc-nick.c5
-rw-r--r--src/plugins/irc/irc-nick.h39
-rw-r--r--src/plugins/irc/irc-protocol.c16
-rw-r--r--src/plugins/irc/irc-protocol.h125
-rw-r--r--src/plugins/irc/irc-server.c117
-rw-r--r--src/plugins/irc/irc-server.h98
-rw-r--r--src/plugins/irc/irc.c14
-rw-r--r--src/plugins/logger/CMakeLists.txt3
-rw-r--r--src/plugins/logger/Makefile.am7
-rw-r--r--src/plugins/logger/logger-buffer.c25
-rw-r--r--src/plugins/logger/logger-buffer.h10
-rw-r--r--src/plugins/logger/logger-tail.c223
-rw-r--r--src/plugins/logger/logger-tail.h32
-rw-r--r--src/plugins/logger/logger.c278
-rw-r--r--src/plugins/logger/logger.h29
-rw-r--r--src/plugins/plugin-api.c1470
-rw-r--r--src/plugins/plugin-api.h209
-rw-r--r--src/plugins/plugin-config.c8
-rw-r--r--src/plugins/plugin-config.h10
-rw-r--r--src/plugins/plugin-infolist.c12
-rw-r--r--src/plugins/plugin-infolist.h54
-rw-r--r--src/plugins/plugin.c208
-rw-r--r--src/plugins/plugin.h20
-rw-r--r--src/plugins/scripts/lua/lua.c2
-rw-r--r--src/plugins/scripts/perl/perl.c4
-rw-r--r--src/plugins/scripts/python/python.c4
-rw-r--r--src/plugins/scripts/ruby/ruby.c2
-rw-r--r--src/plugins/scripts/script.c58
-rw-r--r--src/plugins/scripts/script.h130
-rw-r--r--src/plugins/trigger/trigger-libc.c14
-rw-r--r--src/plugins/trigger/trigger.c4
-rw-r--r--src/plugins/weechat-plugin.h671
53 files changed, 2069 insertions, 3038 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 0908832da..d8d9f8174 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -79,7 +79,7 @@ alias_add_word (char **alias, int *length, char *word)
if (*alias == NULL)
{
- *alias = (char *) malloc (length_word + 1);
+ *alias = (char *)malloc (length_word + 1);
strcpy (*alias, word);
}
else
@@ -174,7 +174,7 @@ alias_replace_args (char *alias_args, char *user_args)
*/
int
-alias_cb (void *data, void *buffer, int argc, char **argv,
+alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
struct t_alias *ptr_alias;
@@ -219,7 +219,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
weechat_command (buffer, args_replaced);
else
{
- alias_command = (char *) malloc (1 + strlen(args_replaced) + 1);
+ alias_command = (char *)malloc (1 + strlen(args_replaced) + 1);
if (alias_command)
{
strcpy (alias_command, "/");
@@ -239,7 +239,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
length1 = strlen (*ptr_cmd);
length2 = strlen (argv_eol[1]);
- alias_command = (char *) malloc ( 1 + length1 + 1 + length2 + 1);
+ alias_command = (char *)malloc ( 1 + length1 + 1 + length2 + 1);
if (alias_command)
{
if (*ptr_cmd[0] != '/')
@@ -261,7 +261,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
(void) weechat_command(buffer, *ptr_cmd);
else
{
- alias_command = (char *) malloc (1 + strlen (*ptr_cmd) + 1);
+ alias_command = (char *)malloc (1 + strlen (*ptr_cmd) + 1);
if (alias_command)
{
strcpy (alias_command, "/");
@@ -307,7 +307,7 @@ alias_new (char *name, char *command)
return ptr_alias;
}
- if ((new_alias = ((struct t_alias *) malloc (sizeof (struct t_alias)))))
+ if ((new_alias = ((struct t_alias *)malloc (sizeof (struct t_alias)))))
{
new_hook = weechat_hook_command (name, "[alias]", NULL, NULL, NULL,
alias_cb, new_alias);
@@ -419,7 +419,8 @@ alias_free_all ()
*/
void
-alias_config_read_line (void *config_file, char *option_name, char *value)
+alias_config_read_line (struct t_config_file *config_file, char *option_name,
+ char *value)
{
/* make C compiler happy */
(void) config_file;
@@ -444,7 +445,8 @@ alias_config_read_line (void *config_file, char *option_name, char *value)
*/
void
-alias_config_write_section (void *config_file, char *section_name)
+alias_config_write_section (struct t_config_file *config_file,
+ char *section_name)
{
struct t_alias *ptr_alias;
@@ -465,7 +467,8 @@ alias_config_write_section (void *config_file, char *section_name)
*/
void
-alias_config_write_default_aliases (void *config_file, char *section_name)
+alias_config_write_default_aliases (struct t_config_file *config_file,
+ char *section_name)
{
weechat_config_write_line (config_file, section_name, NULL);
@@ -537,12 +540,12 @@ alias_config_read ()
*/
int
-alias_config_reload_signal_cb (void *data, char *signal, void *pointer)
+alias_config_reload_signal_cb (void *data, char *signal, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
- (void) pointer;
+ (void) signal_data;
alias_free_all ();
if (weechat_config_reload (alias_config_file) == 0)
@@ -574,8 +577,8 @@ alias_config_write ()
*/
int
-alias_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *alias_name;
struct t_alias *ptr_alias;
@@ -655,8 +658,8 @@ alias_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-unalias_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *alias_name;
struct t_alias *ptr_alias;
@@ -692,7 +695,8 @@ unalias_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-alias_completion_cb (void *data, char *completion, void *buffer, void *list)
+alias_completion_cb (void *data, char *completion, struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_alias *ptr_alias;
diff --git a/src/plugins/aspell/aspell.c b/src/plugins/aspell/aspell.c
index 9e771423c..4c3774a8a 100644
--- a/src/plugins/aspell/aspell.c
+++ b/src/plugins/aspell/aspell.c
@@ -48,7 +48,7 @@ weechat_aspell_new_speller (void)
{
aspell_speller_t *s;
- s = (aspell_speller_t *) malloc (sizeof (aspell_speller_t));
+ s = (aspell_speller_t *)malloc (sizeof (aspell_speller_t));
if (!s)
{
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
@@ -203,7 +203,7 @@ weechat_aspell_new_config (void)
{
aspell_config_t *c;
- c = (aspell_config_t *) malloc (sizeof (aspell_config_t));
+ c = (aspell_config_t *)malloc (sizeof (aspell_config_t));
if (!c)
{
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
@@ -828,7 +828,7 @@ weechat_aspell_config_save (void)
if (found == 0)
{
n = strlen (servers) + strlen (p->server) + 2;
- servers = (char *) realloc (servers, n * sizeof (char));
+ servers = (char *)realloc (servers, n * sizeof (char));
strcat (servers, " ");
strcat (servers, p->server);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, "servers", servers);
@@ -848,13 +848,13 @@ weechat_aspell_config_save (void)
else
{
n = strlen (channels) + strlen (q->channel) + 2;
- channels = (char *) realloc (channels, n * sizeof (char));
+ channels = (char *)realloc (channels, n * sizeof (char));
strcat (channels, " ");
strcat (channels, q->channel);
}
n = 7 + strlen (p->server) + strlen (q->channel);
- option = (char *) malloc ( n * sizeof (char));
+ option = (char *)malloc (n * sizeof (char));
snprintf (option, n, "lang_%s_%s", p->server, q->channel);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, q->speller->lang);
free (option);
@@ -864,7 +864,7 @@ weechat_aspell_config_save (void)
if (channels)
{
n = 10 + strlen (p->server);
- option = (char *) malloc ( n * sizeof (char));
+ option = (char *)malloc (n * sizeof (char));
snprintf (option, n, "channels_%s", p->server);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, channels);
free (option);
@@ -899,7 +899,7 @@ weechat_aspell_config_load(void)
for (i=0; i<s; i++)
{
n = 10 + strlen (servers_list[i]);
- option_s = (char *) malloc (n * sizeof (char));
+ option_s = (char *)malloc (n * sizeof (char));
snprintf (option_s, n, "channels_%s", servers_list[i]);
channels = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_s);
@@ -911,7 +911,7 @@ weechat_aspell_config_load(void)
for (j=0; j<c; j++)
{
n = 7 + strlen (servers_list[i]) + strlen (channels_list[j]);
- option_l = (char *) malloc (n * sizeof (char));
+ option_l = (char *)malloc (n * sizeof (char));
snprintf (option_l, n, "lang_%s_%s", servers_list[i], channels_list[j]);
lang = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_l);
@@ -1174,7 +1174,7 @@ weechat_aspell_clean_word (char *word, int *offset)
return NULL;
}
- w = (char *) malloc ((len+1) * sizeof(char));
+ w = (char *)malloc ((len+1) * sizeof(char));
if (w) {
memcpy (w, buffer + *offset, len);
diff --git a/src/plugins/aspell/aspell.h b/src/plugins/aspell/aspell.h
index e83804c56..ee31d76a0 100644
--- a/src/plugins/aspell/aspell.h
+++ b/src/plugins/aspell/aspell.h
@@ -18,8 +18,8 @@
/* weechat-aspell.h: Aspell plugin support for WeeChat */
-#ifndef WEECHAT_ASPELL__H
-#define WEECHAT_ASPELL__H 1
+#ifndef __WEECHAT_ASPELL_H
+#define __WEECHAT_ASPELL_H 1
#include <aspell.h>
@@ -192,4 +192,4 @@ cmds_keep_t cmd_tokeep[] =
{ NULL, 0}
};
-#endif /* WEECHAT_ASPELL__H */
+#endif /* aspell.h */
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index dd3ce4161..130585c18 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -48,8 +48,8 @@ struct t_weechat_plugin *weechat_demo_plugin = NULL;
*/
int
-demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -86,8 +86,8 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_infobar_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_infobar_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -116,8 +116,8 @@ demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data)
*/
int
-demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_gui_buffer *new_buffer;
@@ -132,6 +132,7 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
demo_buffer_input_data_cb);
if (new_buffer)
weechat_buffer_set (new_buffer, "display", "1");
+ weechat_hook_signal_send ("logger_backlog", new_buffer);
}
return WEECHAT_RC_OK;
@@ -142,7 +143,7 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
*/
void
-demo_infolist_print (void *infolist, char *item_name)
+demo_infolist_print (struct t_plugin_infolist *infolist, char *item_name)
{
char *fields, **argv;
int i, j, argc;
@@ -202,8 +203,8 @@ demo_infolist_print (void *infolist, char *item_name)
*/
int
-demo_infolist_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_plugin_infolist *infolist;
@@ -250,8 +251,8 @@ demo_infolist_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -278,14 +279,14 @@ demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_signal_cb (void *data, char *signal, void *pointer)
+demo_signal_cb (void *data, char *signal, void *signal_data)
{
/* make C compiler happy */
(void) data;
weechat_printf (NULL,
- _("demo_signal: signal: %s, pointer: %X"),
- signal, pointer);
+ _("demo_signal: signal: %s, signal_data: %X"),
+ signal, signal_data);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c
index f6aaddd12..d894c5c89 100644
--- a/src/plugins/fifo/fifo.c
+++ b/src/plugins/fifo/fifo.c
@@ -49,19 +49,23 @@ char *fifo_unterminated = NULL;
/*
* fifo_create: create FIFO pipe for remote control
+ * return: 1 if ok
+ * 0 if error
*/
-void
+int
fifo_create ()
{
- int filename_length;
+ int rc, filename_length;
char *fifo_option, *weechat_home;
-
- fifo_option = weechat_plugin_config_get ("fifo");
+
+ rc = 0;
+
+ fifo_option = weechat_config_get_plugin ("fifo");
if (!fifo_option)
{
- weechat_plugin_config_set ("fifo", "on");
- fifo_option = weechat_plugin_config_get ("fifo");
+ weechat_config_set_plugin ("fifo", "on");
+ fifo_option = weechat_config_get_plugin ("fifo");
}
weechat_home = weechat_info_get ("weechat_dir");
@@ -75,8 +79,8 @@ fifo_create ()
if (!fifo_filename)
{
filename_length = strlen (weechat_home) + 64;
- fifo_filename = (char *) malloc (filename_length *
- sizeof (char));
+ fifo_filename = (char *)malloc (filename_length *
+ sizeof (char));
snprintf (fifo_filename, filename_length,
"%s/weechat_fifo_%d",
weechat_home, (int) getpid());
@@ -90,9 +94,12 @@ fifo_create ()
/* open FIFO pipe in read-only, non blockingmode */
if ((fifo_fd = open (fifo_filename,
O_RDONLY | O_NONBLOCK)) != -1)
+ {
weechat_printf (NULL,
_("%sFifo: pipe is open\n"),
weechat_prefix ("info"));
+ rc = 1;
+ }
else
weechat_printf (NULL,
_("%sFifo: unable to open pipe (%s) for "
@@ -108,10 +115,10 @@ fifo_create ()
fifo_filename);
}
}
- if (fifo_option)
- free (fifo_option);
if (weechat_home)
free (weechat_home);
+
+ return rc;
}
/*
@@ -168,6 +175,8 @@ fifo_exec (char *text)
{
pos_msg = text + 1;
ptr_buffer = weechat_buffer_search (NULL, NULL);
+ if (!ptr_buffer)
+ ptr_buffer = weechat_current_buffer;
}
else
{
@@ -198,6 +207,8 @@ fifo_exec (char *text)
}
else
ptr_buffer = weechat_buffer_search (NULL, text);
+ if (!ptr_buffer)
+ ptr_buffer = weechat_current_buffer;
}
}
@@ -232,8 +243,8 @@ fifo_read ()
ptr_buf = buffer;
if (fifo_unterminated)
{
- buf2 = (char *) malloc (strlen (fifo_unterminated) +
- strlen (buffer) + 1);
+ buf2 = (char *)malloc (strlen (fifo_unterminated) +
+ strlen (buffer) + 1);
if (buf2)
{
strcpy (buf2, fifo_unterminated);
@@ -292,7 +303,16 @@ fifo_read ()
weechat_unhook (fifo_fd_hook);
close (fifo_fd);
fifo_fd = open (fifo_filename, O_RDONLY | O_NONBLOCK);
- fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, fifo_read, NULL);
+ if (fifo_fd < 0)
+ {
+ weechat_printf (NULL,
+ _("%sFifo: error opening file, closing it"),
+ weechat_prefix ("error"));
+ fifo_remove ();
+ }
+ else
+ fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
+ &fifo_read, NULL);
}
}
@@ -334,9 +354,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
{
weechat_plugin = plugin;
- fifo_create ();
-
- fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, &fifo_read, NULL);
+ if (fifo_create ())
+ fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
+ &fifo_read, NULL);
weechat_hook_config ("plugin", "fifo.fifo", &fifo_config_cb, NULL);
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index 88bd8eafa..600493bf5 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -42,9 +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 *);
+extern struct t_irc_buffer_data *irc_buffer_data_create (struct t_irc_server *server);
+extern void irc_buffer_data_free (struct t_gui_buffer *buffer);
+extern void irc_buffer_merge_servers (struct t_gui_window *window);
+extern void irc_buffer_split_server (struct t_gui_window *window);
#endif /* irc-buffer.h */
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index d3975bbb7..39a9b8ff7 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -48,7 +48,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
struct t_gui_buffer *new_buffer;
/* alloc memory for new channel */
- if ((new_channel = (struct t_irc_channel *) malloc (sizeof (struct t_irc_channel))) == NULL)
+ if ((new_channel = (struct t_irc_channel *)malloc (sizeof (struct t_irc_channel))) == NULL)
{
weechat_printf (NULL,
_("%sirc: cannot allocate new channel"),
@@ -88,7 +88,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
//new_buffer->notify_level = irc_channel_get_notify_level (server, new_channel);
/* add new channel to channels list */
- new_channel->prev_channel = ((struct t_irc_server *)server)->last_channel;
+ new_channel->prev_channel = server->last_channel;
new_channel->next_channel = NULL;
if (server->channels)
(server->last_channel)->next_channel = new_channel;
@@ -346,17 +346,17 @@ irc_channel_set_away (struct t_irc_channel *channel, char *nick, int is_away)
*/
int
-irc_channel_create_dcc (void *dcc)
+irc_channel_create_dcc (struct t_irc_dcc *dcc)
{
struct t_irc_channel *ptr_channel;
- ptr_channel = irc_channel_search_dcc (((struct t_irc_dcc *)dcc)->server,
- ((struct t_irc_dcc *)dcc)->nick);
+ ptr_channel = irc_channel_search_dcc (dcc->server, dcc->nick);
if (!ptr_channel)
{
- ptr_channel = irc_channel_new (((struct t_irc_dcc *)dcc)->server,
+ ptr_channel = irc_channel_new (dcc->server,
IRC_CHANNEL_TYPE_DCC_CHAT,
- ((struct t_irc_dcc *)dcc)->nick, 0);
+ dcc->nick,
+ 0);
if (!ptr_channel)
return 0;
}
@@ -366,7 +366,7 @@ irc_channel_create_dcc (void *dcc)
return 0;
ptr_channel->dcc_chat = dcc;
- ((struct t_irc_dcc *)dcc)->channel = ptr_channel;
+ dcc->channel = ptr_channel;
//gui_window_redraw_buffer (ptr_channel->buffer);
return 1;
}
@@ -395,7 +395,7 @@ irc_channel_get_notify_level (struct t_irc_server *server,
&& (server_default_notify == 1))
server_default_notify = 2;
- name = (char *) malloc (strlen (channel->name) + 2);
+ name = (char *)malloc (strlen (channel->name) + 2);
strcpy (name, channel->name);
strcat (name, ":");
pos = strstr (server->notify_levels, name);
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index eecce10c6..cd3c453e7 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -34,44 +34,58 @@
struct t_irc_channel
{
- int type; /* channel type */
- 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 */
- int limit; /* user limit (0 is limit not set) */
- char *key; /* channel key (NULL if no key is set) */
- int nicks_count; /* # nicks on channel (0 if dcc/pv) */
- int checking_away; /* = 1 if checking away with WHO cmd */
- char *away_message; /* to display away only once in private */
- int cycle; /* currently cycling (/part then /join) */
- int close; /* close request (/buffer close) */
- int display_creation_date; /* 1 if creation date should be displayed*/
- int nick_completion_reset; /* 1 if nick completion should be rebuilt*/
- /* there was some join/part on channel */
- 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_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 */
+ int type; /* channel type */
+ 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 pv) */
+ char *modes; /* channel modes */
+ int limit; /* user limit (0 is limit not set) */
+ char *key; /* channel key (NULL if no key set) */
+ int nicks_count; /* # nicks on channel (0 if dcc/pv) */
+ int checking_away; /* = 1 if checking away with WHO cmd */
+ char *away_message; /* to display away only once in pv */
+ int cycle; /* currently cycling (/part + /join) */
+ int close; /* close request (/buffer close) */
+ int display_creation_date; /* 1 for displaying creation date */
+ int nick_completion_reset; /* 1 for resetting nick completion */
+ /* there was some join/part on chan */
+ 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_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 *);
+extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server,
+ int channel_type,
+ char *channel_name,
+ int switch_to_channel);
+extern void irc_channel_free (struct t_irc_server *server,
+ struct t_irc_channel *channel);
+extern void irc_channel_free_all (struct t_irc_server *server);
+extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_any (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_any_without_buffer (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_dcc (struct t_irc_server *server,
+ char *channel_name);
+extern int irc_channel_is_channel (char *string);
+extern void irc_channel_remove_away (struct t_irc_channel *channel);
+extern void irc_channel_check_away (struct t_irc_server *server,
+ struct t_irc_channel *channel, int force);
+extern void irc_channel_set_away (struct t_irc_channel *channel, char *nick,
+ int is_away);
+extern int irc_channel_create_dcc (struct t_irc_dcc *dcc);
+extern int irc_channel_get_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel);
+extern void irc_channel_set_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ int notify);
+extern void irc_channel_add_nick_speaking (struct t_irc_channel *channel,
+ char *nick);
+extern void irc_channel_print_log (struct t_irc_channel *channel);
#endif /* irc-channel.h */
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index 11fc52c7a..4a604f89a 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -40,7 +40,8 @@
*/
unsigned char *
-irc_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
+irc_color_decode (unsigned char *string, int keep_irc_colors,
+ int keep_weechat_attr)
{
/*unsigned char *out;
int out_length, out_pos, length;
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index bee7f1426..7673bbd95 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -51,8 +51,10 @@
#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);
+extern unsigned char *irc_color_decode (unsigned char *string,
+ int keep_irc_colors,
+ int keep_weechat_attr);
+extern unsigned char *irc_color_decode_for_user_entry (unsigned char *string);
+extern unsigned char *irc_color_encode (unsigned char *string, int keep_colors);
#endif /* irc-color.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a0c064210..8ee43daff 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -45,8 +45,8 @@
*/
int
-irc_command_admin (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -143,8 +143,8 @@ irc_command_mode_nicks (struct t_irc_server *server, char *channel,
*/
int
-irc_command_ame (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ame (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -181,8 +181,8 @@ irc_command_ame (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_amsg (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -261,7 +261,7 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
{
if (server->away_message)
free (server->away_message);
- server->away_message = (char *) malloc (strlen (arguments) + 1);
+ server->away_message = (char *)malloc (strlen (arguments) + 1);
if (server->away_message)
strcpy (server->away_message, arguments);
@@ -376,8 +376,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_away (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_away (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -410,8 +410,8 @@ irc_command_away (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel;
int pos_args;
@@ -522,8 +522,8 @@ irc_command_connect_one_server (struct t_irc_server *server, int no_join)
*/
int
-irc_command_connect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
@@ -672,8 +672,8 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ctcp (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos, *irc_cmd;
struct timeval tv;
@@ -760,8 +760,8 @@ irc_command_ctcp (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_cycle (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *pos_args, *ptr_arg, *buf, *version;
char **channels;
@@ -863,8 +863,8 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_dcc (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -872,6 +872,7 @@ irc_command_dcc (void *data, void *buffer, int argc, char **argv,
/* make compiler happy */
(void) data;
+ (void) argv_eol; // to remove!
if (argc > 1)
{
@@ -928,8 +929,8 @@ irc_command_dcc (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -965,8 +966,8 @@ irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_deop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1002,8 +1003,8 @@ irc_command_deop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_devoice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1039,8 +1040,8 @@ irc_command_devoice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_die (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1129,8 +1130,8 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
*/
int
-irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, disconnect_ok;
@@ -1191,8 +1192,8 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_halfop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1228,8 +1229,8 @@ irc_command_halfop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_info (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_info (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1251,8 +1252,8 @@ irc_command_info (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_invite (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1287,8 +1288,8 @@ irc_command_invite (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ison (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1326,8 +1327,8 @@ irc_command_join_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_join (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1352,8 +1353,8 @@ irc_command_join (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kick (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1418,8 +1419,8 @@ irc_command_kick (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kickban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1486,8 +1487,8 @@ irc_command_kickban (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kill (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1515,8 +1516,8 @@ irc_command_kill (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_links (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_links (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1539,8 +1540,8 @@ irc_command_links (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_list (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char buf[512];
int ret;
@@ -1562,7 +1563,7 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
if (argc > 1)
{
- ptr_server->cmd_list_regexp = (regex_t *) malloc (sizeof (regex_t));
+ ptr_server->cmd_list_regexp = (regex_t *)malloc (sizeof (regex_t));
if (ptr_server->cmd_list_regexp)
{
if ((ret = regcomp (ptr_server->cmd_list_regexp,
@@ -1600,8 +1601,8 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_lusers (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1624,7 +1625,7 @@ irc_command_lusers (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_me (void *data, void *buffer, int argc, char **argv,
+irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -1670,8 +1671,8 @@ irc_command_mode_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_mode (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1696,8 +1697,8 @@ irc_command_mode (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_motd (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1720,8 +1721,8 @@ irc_command_motd (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_msg (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char **targets;
int num_targets, i;
@@ -1895,8 +1896,8 @@ irc_command_msg (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_names (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_names (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1959,8 +1960,8 @@ irc_send_nick_server (struct t_irc_server *server, char *nickname)
*/
int
-irc_command_nick (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -2003,8 +2004,8 @@ irc_command_nick (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_notice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *string;
@@ -2045,7 +2046,7 @@ irc_command_notice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_op (void *data, void *buffer, int argc, char **argv,
+irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -2082,8 +2083,8 @@ irc_command_op (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_oper (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2108,8 +2109,8 @@ irc_command_oper (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_part (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *pos_args, *ptr_arg, *buf, *version;
@@ -2155,7 +2156,7 @@ irc_command_part (void *data, void *buffer, int argc, char **argv,
}
if (!ptr_channel->nicks)
{
- weechat_buffer_close (ptr_channel->buffer);
+ weechat_buffer_close (ptr_channel->buffer, 1);
ptr_channel->buffer = NULL;
irc_channel_free (ptr_server, ptr_channel);
//gui_status_draw (gui_current_window->buffer, 1);
@@ -2194,8 +2195,8 @@ irc_command_part (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ping (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2220,8 +2221,8 @@ irc_command_ping (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_pong (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -2246,8 +2247,8 @@ irc_command_pong (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_query (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *string;
@@ -2310,8 +2311,8 @@ irc_command_query (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_quote (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)// || !ptr_server->is_connected)
@@ -2367,8 +2368,8 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
*/
int
-irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, nb_reconnect, reconnect_ok, all_servers, no_join;
@@ -2442,8 +2443,8 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_rehash (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2465,8 +2466,8 @@ irc_command_rehash (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_restart (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2488,8 +2489,8 @@ irc_command_restart (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_server (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, detailed_list, one_server_found;
struct t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
@@ -2568,7 +2569,7 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server add");
}
- if (irc_server_name_already_exists (argv[2]))
+ if (irc_server_search (argv[2]))
{
weechat_printf (NULL,
_("%sirc: server \"%s\" already exists, "
@@ -2974,8 +2975,8 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_service (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3000,8 +3001,8 @@ irc_command_service (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_servlist (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3024,8 +3025,8 @@ irc_command_servlist (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_squery (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3055,8 +3056,8 @@ irc_command_squery (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_squit (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3081,8 +3082,8 @@ irc_command_squit (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_stats (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3106,8 +3107,8 @@ irc_command_stats (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_summon (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3132,8 +3133,8 @@ irc_command_summon (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_time (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_time (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3156,8 +3157,8 @@ irc_command_time (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_topic (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *new_topic;
@@ -3219,8 +3220,8 @@ irc_command_topic (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_trace (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3243,8 +3244,8 @@ irc_command_trace (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_unban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel;
int pos_args;
@@ -3309,8 +3310,8 @@ irc_command_unban (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_userhost (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3335,8 +3336,8 @@ irc_command_userhost (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_users (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3359,8 +3360,8 @@ irc_command_users (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_version (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3391,8 +3392,8 @@ irc_command_version (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_voice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3429,8 +3430,8 @@ irc_command_voice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_wallops (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3455,8 +3456,8 @@ irc_command_wallops (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_who (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_who (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3479,8 +3480,8 @@ irc_command_who (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_whois (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3505,8 +3506,8 @@ irc_command_whois (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_whowas (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index d4c4eb66a..dd9e98c79 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -20,7 +20,7 @@
#ifndef __WEECHAT_IRC_COMMAND_H
#define __WEECHAT_IRC_COMMAND_H 1
-#include "irc-server.h"
+struct t_irc_server;
#define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \
weechat_printf (__buffer, \
@@ -29,10 +29,14 @@
return WEECHAT_RC_ERROR;
-extern void irc_command_away_server (struct t_irc_server *, char *);
-extern void irc_command_join_server (struct t_irc_server *, char *);
-extern void irc_command_mode_server (struct t_irc_server *, char *);
-extern void irc_command_quit_server (struct t_irc_server *, char *);
+extern void irc_command_away_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_join_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_mode_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_quit_server (struct t_irc_server *server,
+ char *arguments);
extern void irc_command_init ();
#endif /* irc-command.h */
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 3e0eeb99f..82eb4e46f 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -40,8 +40,8 @@
*/
int
-irc_completion_server_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_server_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
IRC_GET_SERVER(buffer);
@@ -61,8 +61,9 @@ irc_completion_server_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_server_nicks_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_server_nicks_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_server *ptr_server2;
struct t_irc_channel *ptr_channel2;
@@ -117,8 +118,8 @@ irc_completion_server_nicks_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_servers_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_servers_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_irc_server *ptr_server;
@@ -141,8 +142,8 @@ irc_completion_servers_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -162,8 +163,9 @@ irc_completion_channel_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_nicks_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_nicks_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_nick *ptr_nick;
char *nick;
@@ -218,8 +220,9 @@ irc_completion_channel_nicks_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_nicks_hosts_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_nick *ptr_nick;
char *buf;
@@ -243,7 +246,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffe
{
length = strlen (ptr_nick->nick) + 1 +
strlen (ptr_nick->host) + 1;
- buf = (char *) malloc (length);
+ buf = (char *)malloc (length);
if (buf)
{
snprintf (buf, length, "%s!%s",
@@ -270,8 +273,9 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffe
*/
int
-irc_completion_channel_topic_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_topic_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -292,8 +296,8 @@ irc_completion_channel_topic_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channels_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channels_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -321,8 +325,8 @@ irc_completion_channels_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_msg_part_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_msg_part_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
/* make C compiler happy */
(void) data;
@@ -339,3 +343,25 @@ irc_completion_msg_part_cb (void *data, char *completion, void *buffer,
return WEECHAT_RC_OK;
}
+
+/*
+ * irc_completion_init: init completion for IRC plugin
+ */
+
+void
+irc_completion_init ()
+{
+ weechat_hook_completion ("irc_server", &irc_completion_server_cb, NULL);
+ weechat_hook_completion ("irc_server_nicks",
+ &irc_completion_server_nicks_cb, NULL);
+ weechat_hook_completion ("irc_servers", &irc_completion_servers_cb, NULL);
+ weechat_hook_completion ("irc_channel", &irc_completion_channel_cb, NULL);
+ weechat_hook_completion ("irc_channel_nicks",
+ &irc_completion_channel_nicks_cb, NULL);
+ weechat_hook_completion ("irc_channel_nicks_hosts",
+ &irc_completion_channel_nicks_hosts_cb, NULL);
+ weechat_hook_completion ("irc_channel_topic",
+ &irc_completion_channel_topic_cb, NULL);
+ weechat_hook_completion ("irc_channels", &irc_completion_channels_cb, NULL);
+ weechat_hook_completion ("irc_msg_part", &irc_completion_msg_part_cb, NULL);
+}
diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h
index c0d2b250c..351c0cc97 100644
--- a/src/plugins/irc/irc-completion.h
+++ b/src/plugins/irc/irc-completion.h
@@ -20,15 +20,6 @@
#ifndef __WEECHAT_IRC_COMPLETION_H
#define __WEECHAT_IRC_COMPLETION_H 1
-extern int irc_completion_server_cb (void *, char *, void *, void *);
-extern int irc_completion_server_nicks_cb (void *, char *, void *, void *);
-extern int irc_completion_servers_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_nicks_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_nicks_hosts_cb (void *, char *, void *,
- void *);
-extern int irc_completion_channel_topic_cb (void *, char *, void *, void *);
-extern int irc_completion_channels_cb (void *, char *, void *, void *);
-extern int irc_completion_msg_part_cb (void *, char *, void *, void *);
+extern void irc_completion_init ();
#endif /* irc-completion.h */
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 7d8f9192d..d3c0ae443 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -211,7 +211,8 @@ irc_config_change_notify_levels ()
*/
void
-irc_config_read_server_line (void *config_file, char *option_name, char *value)
+irc_config_read_server_line (struct t_config_file *config_file,
+ char *option_name, char *value)
{
struct t_config_option *ptr_option;
int rc;
@@ -228,7 +229,7 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
option_name);
if (ptr_option)
{
- rc = weechat_config_option_set (ptr_option, value);
+ rc = weechat_config_option_set (ptr_option, value, 0);
switch (rc)
{
case 2:
@@ -280,7 +281,8 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
*/
void
-irc_config_write_servers (void *config_file, char *section_name)
+irc_config_write_servers (struct t_config_file *config_file,
+ char *section_name)
{
struct t_irc_server *ptr_server;
@@ -337,7 +339,8 @@ irc_config_write_servers (void *config_file, char *section_name)
*/
void
-irc_config_write_server_default (void *config_file, char *section_name)
+irc_config_write_server_default (struct t_config_file *config_file,
+ char *section_name)
{
struct passwd *my_passwd;
char *realname, *pos;
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index b1cf9756e..405f7bb8f 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -67,11 +67,6 @@ 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;
-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_cb ();
diff --git a/src/plugins/irc/irc-dcc.c b/src/plugins/irc/irc-dcc.c
index 01da53991..4c84000aa 100644
--- a/src/plugins/irc/irc-dcc.c
+++ b/src/plugins/irc/irc-dcc.c
@@ -169,9 +169,9 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
return;
}
- ptr_dcc->local_filename = (char *) malloc (strlen (dir2) +
- strlen (ptr_dcc->nick) +
- strlen (ptr_dcc->filename) + 4);
+ ptr_dcc->local_filename = (char *)malloc (strlen (dir2) +
+ strlen (ptr_dcc->nick) +
+ strlen (ptr_dcc->filename) + 4);
if (!ptr_dcc->local_filename)
return;
@@ -201,7 +201,7 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
return;
}
- filename2 = (char *) malloc (strlen (ptr_dcc->local_filename) + 16);
+ filename2 = (char *)malloc (strlen (ptr_dcc->local_filename) + 16);
if (!filename2)
{
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
@@ -367,49 +367,49 @@ irc_dcc_connect (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_free (struct t_irc_dcc *ptr_dcc)
+irc_dcc_free (struct t_irc_dcc *dcc)
{
struct t_irc_dcc *new_dcc_list;
- if (!ptr_dcc)
+ if (!dcc)
return;
/* DCC CHAT with channel => remove channel
(to prevent channel from becoming standard pv) */
- if (ptr_dcc->channel)
+ if (dcc->channel)
{
/* check if channel is used for another active DCC CHAT */
- if (!ptr_dcc->channel->dcc_chat
- || (IRC_DCC_ENDED(ptr_dcc->channel->dcc_chat->status)))
+ if (!dcc->channel->dcc_chat
+ || (IRC_DCC_ENDED(dcc->channel->dcc_chat->status)))
{
- gui_buffer_free (ptr_dcc->channel->buffer, 1);
- if (ptr_dcc->channel)
- irc_channel_free (ptr_dcc->server, ptr_dcc->channel);
+ gui_buffer_free (dcc->channel->buffer, 1);
+ if (dcc->channel)
+ irc_channel_free (dcc->server, dcc->channel);
}
}
/* remove DCC from list */
- if (irc_last_dcc == ptr_dcc)
- irc_last_dcc = ptr_dcc->prev_dcc;
- if (ptr_dcc->prev_dcc)
+ if (irc_last_dcc == dcc)
+ irc_last_dcc = dcc->prev_dcc;
+ if (dcc->prev_dcc)
{
- (ptr_dcc->prev_dcc)->next_dcc = ptr_dcc->next_dcc;
+ (dcc->prev_dcc)->next_dcc = dcc->next_dcc;
new_dcc_list = irc_dcc_list;
}
else
- new_dcc_list = ptr_dcc->next_dcc;
- if (ptr_dcc->next_dcc)
- (ptr_dcc->next_dcc)->prev_dcc = ptr_dcc->prev_dcc;
+ new_dcc_list = dcc->next_dcc;
+ if (dcc->next_dcc)
+ (dcc->next_dcc)->prev_dcc = dcc->prev_dcc;
/* free data */
- if (ptr_dcc->nick)
- free (ptr_dcc->nick);
- if (ptr_dcc->unterminated_message)
- free (ptr_dcc->unterminated_message);
- if (ptr_dcc->filename)
- free (ptr_dcc->filename);
-
- free (ptr_dcc);
+ if (dcc->nick)
+ free (dcc->nick);
+ if (dcc->unterminated_message)
+ free (dcc->unterminated_message);
+ if (dcc->filename)
+ free (dcc->filename);
+
+ free (dcc);
irc_dcc_list = new_dcc_list;
}
@@ -418,26 +418,26 @@ irc_dcc_free (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_kill (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_kill (struct t_irc_dcc *dcc)
{
/* kill process */
- if (ptr_dcc->child_pid > 0)
+ if (dcc->child_pid > 0)
{
- kill (ptr_dcc->child_pid, SIGKILL);
- waitpid (ptr_dcc->child_pid, NULL, 0);
- ptr_dcc->child_pid = 0;
+ kill (dcc->child_pid, SIGKILL);
+ waitpid (dcc->child_pid, NULL, 0);
+ dcc->child_pid = 0;
}
/* close pipe used with child */
- if (ptr_dcc->child_read != -1)
+ if (dcc->child_read != -1)
{
- close (ptr_dcc->child_read);
- ptr_dcc->child_read = -1;
+ close (dcc->child_read);
+ dcc->child_read = -1;
}
- if (ptr_dcc->child_write != -1)
+ if (dcc->child_write != -1)
{
- close (ptr_dcc->child_write);
- ptr_dcc->child_write = -1;
+ close (dcc->child_write);
+ dcc->child_write = -1;
}
}
@@ -446,93 +446,93 @@ irc_dcc_file_child_kill (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_close (struct t_irc_dcc *ptr_dcc, int status)
+irc_dcc_close (struct t_irc_dcc *dcc, int status)
{
t_gui_buffer *ptr_buffer;
struct stat st;
- ptr_dcc->status = status;
+ dcc->status = status;
if ((status == IRC_DCC_DONE) || (status == IRC_DCC_ABORTED)
|| (status == IRC_DCC_FAILED))
{
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
+ if (IRC_DCC_IS_FILE(dcc->type))
{
- gui_chat_printf_info (ptr_dcc->server->buffer,
+ gui_chat_printf_info (dcc->server->buffer,
_("DCC: file %s%s%s"),
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
- ptr_dcc->filename,
+ dcc->filename,
GUI_COLOR(GUI_COLOR_CHAT));
- if (ptr_dcc->local_filename)
- gui_chat_printf (ptr_dcc->server->buffer,
+ if (dcc->local_filename)
+ gui_chat_printf (dcc->server->buffer,
_(" (local filename: %s%s%s)"),
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
- ptr_dcc->local_filename,
+ dcc->local_filename,
GUI_COLOR(GUI_COLOR_CHAT));
- if (ptr_dcc->type == IRC_DCC_FILE_SEND)
- gui_chat_printf (ptr_dcc->server->buffer,
+ if (dcc->type == IRC_DCC_FILE_SEND)
+ gui_chat_printf (dcc->server->buffer,
_(" sent to "));
else
- gui_chat_printf (ptr_dcc->server->buffer,
+ gui_chat_printf (dcc->server->buffer,
_(" received from "));
- gui_chat_printf (ptr_dcc->server->buffer, "%s%s%s: %s\n",
+ gui_chat_printf (dcc->server->buffer, "%s%s%s: %s\n",
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT),
(status == IRC_DCC_DONE) ? _("OK") : _("FAILED"));
- irc_dcc_file_child_kill (ptr_dcc);
+ irc_dcc_file_child_kill (dcc);
}
}
if (status == IRC_DCC_ABORTED)
{
- if (IRC_DCC_IS_CHAT(ptr_dcc->type))
+ if (IRC_DCC_IS_CHAT(dcc->type))
{
- if (ptr_dcc->channel)
- ptr_buffer = ptr_dcc->channel->buffer;
+ if (dcc->channel)
+ ptr_buffer = dcc->channel->buffer;
else
- ptr_buffer = ptr_dcc->server->buffer;
+ ptr_buffer = dcc->server->buffer;
gui_chat_printf_info (ptr_buffer,
_("DCC chat closed with %s%s "
"%s(%s%d.%d.%d.%d%s)\n"),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- ptr_dcc->addr >> 24,
- (ptr_dcc->addr >> 16) & 0xff,
- (ptr_dcc->addr >> 8) & 0xff,
- ptr_dcc->addr & 0xff,
+ dcc->addr >> 24,
+ (dcc->addr >> 16) & 0xff,
+ (dcc->addr >> 8) & 0xff,
+ dcc->addr & 0xff,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
}
}
/* remove empty file if received file failed and nothing was transfered */
if (((status == IRC_DCC_FAILED) || (status == IRC_DCC_ABORTED))
- && IRC_DCC_IS_FILE(ptr_dcc->type)
- && IRC_DCC_IS_RECV(ptr_dcc->type)
- && ptr_dcc->local_filename
- && ptr_dcc->pos == 0)
+ && IRC_DCC_IS_FILE(dcc->type)
+ && IRC_DCC_IS_RECV(dcc->type)
+ && dcc->local_filename
+ && dcc->pos == 0)
{
/* erase file only if really empty on disk */
- if (stat (ptr_dcc->local_filename, &st) != -1)
+ if (stat (dcc->local_filename, &st) != -1)
{
if ((unsigned long) st.st_size == 0)
- unlink (ptr_dcc->local_filename);
+ unlink (dcc->local_filename);
}
}
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
- irc_dcc_calculate_speed (ptr_dcc, 1);
+ if (IRC_DCC_IS_FILE(dcc->type))
+ irc_dcc_calculate_speed (dcc, 1);
- if (ptr_dcc->sock >= 0)
+ if (dcc->sock >= 0)
{
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ close (dcc->sock);
+ dcc->sock = -1;
}
- if (ptr_dcc->file >= 0)
+ if (dcc->file >= 0)
{
- close (ptr_dcc->file);
- ptr_dcc->file = -1;
+ close (dcc->file);
+ dcc->file = -1;
}
}
@@ -541,32 +541,32 @@ irc_dcc_close (struct t_irc_dcc *ptr_dcc, int status)
*/
void
-irc_dcc_channel_for_chat (struct t_irc_dcc *ptr_dcc)
+irc_dcc_channel_for_chat (struct t_irc_dcc *dcc)
{
- if (!irc_channel_create_dcc (ptr_dcc))
+ if (!irc_channel_create_dcc (dcc))
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s can't associate DCC chat with private "
"buffer (maybe private buffer has already "
"DCC CHAT?)\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
}
- gui_chat_printf_type (ptr_dcc->channel->buffer, GUI_MSG_TYPE_MSG,
+ gui_chat_printf_type (dcc->channel->buffer, GUI_MSG_TYPE_MSG,
cfg_look_prefix_info, cfg_col_chat_prefix_info,
_("Connected to %s%s %s(%s%d.%d.%d.%d%s)%s via DCC "
"chat\n"),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- ptr_dcc->addr >> 24,
- (ptr_dcc->addr >> 16) & 0xff,
- (ptr_dcc->addr >> 8) & 0xff,
- ptr_dcc->addr & 0xff,
+ dcc->addr >> 24,
+ (dcc->addr >> 16) & 0xff,
+ (dcc->addr >> 8) & 0xff,
+ dcc->addr & 0xff,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT));
}
@@ -595,26 +595,26 @@ irc_dcc_chat_remove_channel (struct t_irc_channel *channel)
*/
void
-irc_dcc_recv_connect_init (struct t_irc_dcc *ptr_dcc)
+irc_dcc_recv_connect_init (struct t_irc_dcc *dcc)
{
- if (!irc_dcc_connect (ptr_dcc))
+ if (!irc_dcc_connect (dcc))
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
{
/* DCC file => launch child process */
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
+ if (IRC_DCC_IS_FILE(dcc->type))
{
- ptr_dcc->status = IRC_DCC_CONNECTING;
- irc_dcc_file_recv_fork (ptr_dcc);
+ dcc->status = IRC_DCC_CONNECTING;
+ irc_dcc_file_recv_fork (dcc);
}
else
{
/* DCC CHAT => associate DCC with channel */
- ptr_dcc->status = IRC_DCC_ACTIVE;
- irc_dcc_channel_for_chat (ptr_dcc);
+ dcc->status = IRC_DCC_ACTIVE;
+ irc_dcc_channel_for_chat (dcc);
}
}
irc_dcc_redraw (GUI_HOTLIST_MSG);
@@ -625,21 +625,21 @@ irc_dcc_recv_connect_init (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_accept (struct t_irc_dcc *ptr_dcc)
+irc_dcc_accept (struct t_irc_dcc *dcc)
{
- if (IRC_DCC_IS_FILE(ptr_dcc->type) && (ptr_dcc->start_resume > 0))
+ if (IRC_DCC_IS_FILE(dcc->type) && (dcc->start_resume > 0))
{
- ptr_dcc->status = IRC_DCC_CONNECTING;
- irc_server_sendf (ptr_dcc->server,
- (strchr (ptr_dcc->filename, ' ')) ?
+ dcc->status = IRC_DCC_CONNECTING;
+ irc_server_sendf (dcc->server,
+ (strchr (dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01",
- ptr_dcc->nick, ptr_dcc->filename,
- ptr_dcc->port, ptr_dcc->start_resume);
+ dcc->nick, dcc->filename,
+ dcc->port, dcc->start_resume);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
- irc_dcc_recv_connect_init (ptr_dcc);
+ irc_dcc_recv_connect_init (dcc);
}
/*
@@ -720,7 +720,7 @@ irc_dcc_alloc ()
struct t_irc_dcc *new_dcc;
/* create new DCC struct */
- if ((new_dcc = (struct t_irc_dcc *) malloc (sizeof (struct t_irc_dcc))) == NULL)
+ if ((new_dcc = (struct t_irc_dcc *)malloc (sizeof (struct t_irc_dcc))) == NULL)
return NULL;
/* default values */
@@ -937,7 +937,8 @@ irc_dcc_add (struct t_irc_server *server, int type, unsigned long addr, int port
*/
void
-irc_dcc_send_request (struct 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;
@@ -976,8 +977,8 @@ irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *f
free (dir1);
return;
}
- filename2 = (char *) malloc (strlen (dir2) +
- strlen (filename) + 4);
+ filename2 = (char *)malloc (strlen (dir2) +
+ strlen (filename) + 4);
if (!filename2)
{
gui_chat_printf_error (server->buffer,
@@ -1177,12 +1178,12 @@ irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *f
*/
int
-irc_dcc_chat_send (struct t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
+irc_dcc_chat_send (struct t_irc_dcc *dcc, char *buffer, int size_buf)
{
- if (!ptr_dcc)
+ if (!dcc)
return -1;
- return send (ptr_dcc->sock, buffer, size_buf, 0);
+ return send (dcc->sock, buffer, size_buf, 0);
}
/*
@@ -1190,17 +1191,17 @@ irc_dcc_chat_send (struct t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
*/
void
-irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
+irc_dcc_chat_sendf (struct t_irc_dcc *dcc, char *format, ...)
{
va_list args;
static char buffer[4096];
int size_buf;
- if (!ptr_dcc || (ptr_dcc->sock < 0))
+ if (!dcc || (dcc->sock < 0))
return;
- va_start (args, fmt);
- size_buf = vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
+ va_start (args, format);
+ size_buf = vsnprintf (buffer, sizeof (buffer) - 1, format, args);
va_end (args);
if ((size_buf == 0) || (strcmp (buffer, "\r\n") == 0))
@@ -1211,18 +1212,18 @@ irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
size_buf = strlen (buffer);
#ifdef DEBUG
buffer[size_buf - 2] = '\0';
- gui_chat_printf (ptr_dcc->server->buffer,
+ gui_chat_printf (dcc->server->buffer,
"[DEBUG] Sending to remote host (DCC CHAT) >>> %s\n",
buffer);
buffer[size_buf - 2] = '\r';
#endif
- if (irc_dcc_chat_send (ptr_dcc, buffer, strlen (buffer)) <= 0)
+ if (irc_dcc_chat_send (dcc, buffer, strlen (buffer)) <= 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s error sending data to \"%s\" via DCC "
"CHAT\n"),
- WEECHAT_ERROR, ptr_dcc->nick);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ WEECHAT_ERROR, dcc->nick);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
}
}
@@ -1231,7 +1232,7 @@ irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
*/
void
-irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
+irc_dcc_chat_recv (struct t_irc_dcc *dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1240,7 +1241,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
int num_read;
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@@ -1248,29 +1249,29 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) <= 0)
return;
- if (!FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (!FD_ISSET (dcc->sock, &read_fd))
return;
/* there's something to read on socket! */
- num_read = recv (ptr_dcc->sock, buffer, sizeof (buffer) - 2, 0);
+ num_read = recv (dcc->sock, buffer, sizeof (buffer) - 2, 0);
if (num_read > 0)
{
buffer[num_read] = '\0';
buf2 = NULL;
ptr_buf = buffer;
- if (ptr_dcc->unterminated_message)
+ if (dcc->unterminated_message)
{
- buf2 = (char *) malloc (strlen (ptr_dcc->unterminated_message) +
- strlen (buffer) + 1);
+ buf2 = (char *)malloc (strlen (dcc->unterminated_message) +
+ strlen (buffer) + 1);
if (buf2)
{
- strcpy (buf2, ptr_dcc->unterminated_message);
+ strcpy (buf2, dcc->unterminated_message);
strcat (buf2, buffer);
}
ptr_buf = buf2;
- free (ptr_dcc->unterminated_message);
- ptr_dcc->unterminated_message = NULL;
+ free (dcc->unterminated_message);
+ dcc->unterminated_message = NULL;
}
while (ptr_buf && ptr_buf[0])
@@ -1292,7 +1293,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
}
else
{
- ptr_dcc->unterminated_message = strdup (ptr_buf);
+ dcc->unterminated_message = strdup (ptr_buf);
ptr_buf = NULL;
next_ptr_buf = NULL;
}
@@ -1300,28 +1301,28 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
if (ptr_buf)
{
- if (irc_protocol_is_highlight (ptr_buf, ptr_dcc->server->nick))
+ if (irc_protocol_is_highlight (ptr_buf, dcc->server->nick))
{
- irc_display_nick (ptr_dcc->channel->buffer, NULL,
- ptr_dcc->nick,
+ irc_display_nick (dcc->channel->buffer, NULL,
+ dcc->nick,
GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT,
1,
GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), 0);
if ((cfg_look_infobar_delay_highlight > 0)
- && (ptr_dcc->channel->buffer != gui_current_window->buffer))
+ && (dcc->channel->buffer != gui_current_window->buffer))
{
gui_infobar_printf (cfg_look_infobar_delay_highlight,
GUI_COLOR_INFOBAR_HIGHLIGHT,
_("Private %s> %s"),
- ptr_dcc->nick, ptr_buf);
+ dcc->nick, ptr_buf);
}
}
else
- irc_display_nick (ptr_dcc->channel->buffer, NULL,
- ptr_dcc->nick,
+ irc_display_nick (dcc->channel->buffer, NULL,
+ dcc->nick,
GUI_MSG_TYPE_NICK, 1,
GUI_COLOR(GUI_COLOR_CHAT_NICK_OTHER), 0);
- gui_chat_printf_type (ptr_dcc->channel->buffer,
+ gui_chat_printf_type (dcc->channel->buffer,
GUI_MSG_TYPE_MSG,
NULL, -1,
"%s%s\n",
@@ -1337,7 +1338,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
}
else
{
- irc_dcc_close (ptr_dcc, IRC_DCC_ABORTED);
+ irc_dcc_close (dcc, IRC_DCC_ABORTED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
}
@@ -1348,22 +1349,22 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
*/
int
-irc_dcc_file_create_pipe (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_create_pipe (struct t_irc_dcc *dcc)
{
int child_pipe[2];
if (pipe (child_pipe) < 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to create pipe\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return 0;
}
- ptr_dcc->child_read = child_pipe[0];
- ptr_dcc->child_write = child_pipe[1];
+ dcc->child_read = child_pipe[0];
+ dcc->child_write = child_pipe[1];
return 1;
}
@@ -1372,13 +1373,13 @@ irc_dcc_file_create_pipe (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_write_pipe (struct t_irc_dcc *ptr_dcc, int status, int error)
+irc_dcc_file_write_pipe (struct t_irc_dcc *dcc, int status, int error)
{
char buffer[1 + 1 + 12 + 1]; /* status + error + pos + \0 */
snprintf (buffer, sizeof (buffer), "%c%c%012lu",
- status + '0', error + '0', ptr_dcc->pos);
- write (ptr_dcc->child_write, buffer, sizeof (buffer));
+ status + '0', error + '0', dcc->pos);
+ write (dcc->child_write, buffer, sizeof (buffer));
}
/*
@@ -1386,7 +1387,7 @@ irc_dcc_file_write_pipe (struct t_irc_dcc *ptr_dcc, int status, int error)
*/
void
-irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_child (struct t_irc_dcc *dcc)
{
int num_read, num_sent;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1397,28 +1398,28 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
while (1)
{
/* read DCC ACK (sent by receiver) */
- if (ptr_dcc->pos > ptr_dcc->ack)
+ if (dcc->pos > dcc->ack)
{
/* we should receive ACK for packets sent previously */
while (1)
{
- num_read = recv (ptr_dcc->sock, (char *) &ack, 4, MSG_PEEK);
+ num_read = recv (dcc->sock, (char *) &ack, 4, MSG_PEEK);
if ((num_read < 1) &&
((num_read != -1) || (errno != EAGAIN)))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
return;
}
if (num_read == 4)
{
- recv (ptr_dcc->sock, (char *) &ack, 4, 0);
- ptr_dcc->ack = ntohl (ack);
+ recv (dcc->sock, (char *) &ack, 4, 0);
+ dcc->ack = ntohl (ack);
/* DCC send ok? */
- if ((ptr_dcc->pos >= ptr_dcc->size)
- && (ptr_dcc->ack >= ptr_dcc->size))
+ if ((dcc->pos >= dcc->size)
+ && (dcc->ack >= dcc->size))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
return;
}
}
@@ -1428,17 +1429,17 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
}
/* send a block to receiver */
- if ((ptr_dcc->pos < ptr_dcc->size) &&
- (ptr_dcc->fast_send || (ptr_dcc->pos <= ptr_dcc->ack)))
+ if ((dcc->pos < dcc->size) &&
+ (dcc->fast_send || (dcc->pos <= dcc->ack)))
{
- lseek (ptr_dcc->file, ptr_dcc->pos, SEEK_SET);
- num_read = read (ptr_dcc->file, buffer, ptr_dcc->blocksize);
+ lseek (dcc->file, dcc->pos, SEEK_SET);
+ num_read = read (dcc->file, buffer, dcc->blocksize);
if (num_read < 1)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_READ_LOCAL);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_READ_LOCAL);
return;
}
- num_sent = send (ptr_dcc->sock, buffer, num_read, 0);
+ num_sent = send (dcc->sock, buffer, num_read, 0);
if (num_sent < 0)
{
/* socket is temporarily not available (receiver can't receive
@@ -1447,18 +1448,18 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
usleep (1000);
else
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
return;
}
}
if (num_sent > 0)
{
- ptr_dcc->pos += (unsigned long) num_sent;
+ dcc->pos += (unsigned long) num_sent;
new_time = time (NULL);
if (last_sent != new_time)
{
last_sent = new_time;
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
}
}
}
@@ -1472,7 +1473,7 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_child (struct t_irc_dcc *dcc)
{
int num_read;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1480,19 +1481,19 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
time_t last_sent, new_time;
/* first connect to sender (blocking) */
- if (!irc_dcc_connect_to_sender (ptr_dcc))
+ if (!irc_dcc_connect_to_sender (dcc))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_CONNECT_SENDER);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_CONNECT_SENDER);
return;
}
/* connection is ok, change DCC status (inform parent process) */
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
last_sent = time (NULL);
while (1)
{
- num_read = recv (ptr_dcc->sock, buffer, sizeof (buffer), 0);
+ num_read = recv (dcc->sock, buffer, sizeof (buffer), 0);
if (num_read == -1)
{
/* socket is temporarily not available (sender is not fast ?!) */
@@ -1500,7 +1501,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
usleep (1000);
else
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
return;
}
}
@@ -1508,26 +1509,26 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
{
if (num_read == 0)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
return;
}
- if (write (ptr_dcc->file, buffer, num_read) == -1)
+ if (write (dcc->file, buffer, num_read) == -1)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_WRITE_LOCAL);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_WRITE_LOCAL);
return;
}
- ptr_dcc->pos += (unsigned long) num_read;
- pos = htonl (ptr_dcc->pos);
+ dcc->pos += (unsigned long) num_read;
+ pos = htonl (dcc->pos);
/* we don't check return code, not a problem if an ACK send failed */
- send (ptr_dcc->sock, (char *) &pos, 4, 0);
+ send (dcc->sock, (char *) &pos, 4, 0);
/* file received ok? */
- if (ptr_dcc->pos >= ptr_dcc->size)
+ if (dcc->pos >= dcc->size)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
return;
}
@@ -1535,7 +1536,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
if (last_sent != new_time)
{
last_sent = new_time;
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
}
}
}
@@ -1546,7 +1547,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_read (struct t_irc_dcc *dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1555,7 +1556,7 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
char *error;
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->child_read, &read_fd);
+ FD_SET (dcc->child_read, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@@ -1563,55 +1564,55 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) <= 0)
return;
- if (!FD_ISSET (ptr_dcc->child_read, &read_fd))
+ if (!FD_ISSET (dcc->child_read, &read_fd))
return;
/* there's something to read in pipe! */
- num_read = read (ptr_dcc->child_read, bufpipe, sizeof (bufpipe));
+ num_read = read (dcc->child_read, bufpipe, sizeof (bufpipe));
if (num_read > 0)
{
error = NULL;
- ptr_dcc->pos = strtol (bufpipe + 2, &error, 10);
- ptr_dcc->last_activity = time (NULL);
- irc_dcc_calculate_speed (ptr_dcc, 0);
+ dcc->pos = strtol (bufpipe + 2, &error, 10);
+ dcc->last_activity = time (NULL);
+ irc_dcc_calculate_speed (dcc, 0);
/* read error code */
switch (bufpipe[1] - '0')
{
/* errors for sender */
case IRC_DCC_ERROR_READ_LOCAL:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to read local "
"file\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_SEND_BLOCK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to send block to "
"receiver\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_READ_ACK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to read ACK from "
"receiver\n"),
WEECHAT_ERROR);
break;
/* errors for receiver */
case IRC_DCC_ERROR_CONNECT_SENDER:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to connect to "
"sender\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_RECV_BLOCK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to receive block "
"from sender\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_WRITE_LOCAL:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to write local "
"file\n"),
WEECHAT_ERROR);
@@ -1622,23 +1623,23 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
switch (bufpipe[0] - '0')
{
case IRC_DCC_ACTIVE:
- if (ptr_dcc->status == IRC_DCC_CONNECTING)
+ if (dcc->status == IRC_DCC_CONNECTING)
{
/* connection was successful by child, init transfert times */
- ptr_dcc->status = IRC_DCC_ACTIVE;
- ptr_dcc->start_transfer = time (NULL);
- ptr_dcc->last_check_time = time (NULL);
+ dcc->status = IRC_DCC_ACTIVE;
+ dcc->start_transfer = time (NULL);
+ dcc->last_check_time = time (NULL);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
irc_dcc_redraw (GUI_HOTLIST_LOW);
break;
case IRC_DCC_DONE:
- irc_dcc_close (ptr_dcc, IRC_DCC_DONE);
+ irc_dcc_close (dcc, IRC_DCC_DONE);
irc_dcc_redraw (GUI_HOTLIST_MSG);
break;
case IRC_DCC_FAILED:
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
break;
}
@@ -1650,34 +1651,34 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_send_fork (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_fork (struct t_irc_dcc *dcc)
{
pid_t pid;
- if (!irc_dcc_file_create_pipe (ptr_dcc))
+ if (!irc_dcc_file_create_pipe (dcc))
return;
- ptr_dcc->file = open (ptr_dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644);
+ dcc->file = open (dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644);
switch (pid = fork ())
{
/* fork failed */
case -1:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to fork\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
/* child process */
case 0:
setuid (getuid ());
- irc_dcc_file_send_child (ptr_dcc);
+ irc_dcc_file_send_child (dcc);
_exit (EXIT_SUCCESS);
}
/* parent process */
- ptr_dcc->child_pid = pid;
+ dcc->child_pid = pid;
}
/*
@@ -1685,18 +1686,18 @@ irc_dcc_file_send_fork (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_fork (struct t_irc_dcc *dcc)
{
pid_t pid;
- if (!irc_dcc_file_create_pipe (ptr_dcc))
+ if (!irc_dcc_file_create_pipe (dcc))
return;
- if (ptr_dcc->start_resume > 0)
- ptr_dcc->file = open (ptr_dcc->local_filename,
+ if (dcc->start_resume > 0)
+ dcc->file = open (dcc->local_filename,
O_APPEND | O_WRONLY | O_NONBLOCK);
else
- ptr_dcc->file = open (ptr_dcc->local_filename,
+ dcc->file = open (dcc->local_filename,
O_CREAT | O_TRUNC | O_WRONLY | O_NONBLOCK,
0644);
@@ -1704,21 +1705,21 @@ irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
{
/* fork failed */
case -1:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to fork\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
/* child process */
case 0:
setuid (getuid ());
- irc_dcc_file_recv_child (ptr_dcc);
+ irc_dcc_file_recv_child (dcc);
_exit (EXIT_SUCCESS);
}
/* parent process */
- ptr_dcc->child_pid = pid;
+ dcc->child_pid = pid;
}
/*
@@ -1728,134 +1729,134 @@ irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
void
irc_dcc_handle ()
{
- struct t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *dcc;
fd_set read_fd;
static struct timeval timeout;
int sock;
struct sockaddr_in addr;
socklen_t length;
- for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
+ for (dcc = irc_dcc_list; dcc; dcc = dcc->next_dcc)
{
/* check DCC timeout */
- if (IRC_DCC_IS_FILE(ptr_dcc->type) && !IRC_DCC_ENDED(ptr_dcc->status))
+ if (IRC_DCC_IS_FILE(dcc->type) && !IRC_DCC_ENDED(dcc->status))
{
if ((irc_cfg_dcc_timeout != 0)
- && (time (NULL) > ptr_dcc->last_activity + irc_cfg_dcc_timeout))
+ && (time (NULL) > dcc->last_activity + irc_cfg_dcc_timeout))
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: timeout\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
}
- if (ptr_dcc->status == IRC_DCC_CONNECTING)
+ if (dcc->status == IRC_DCC_CONNECTING)
{
- if (ptr_dcc->type == IRC_DCC_FILE_SEND)
+ if (dcc->type == IRC_DCC_FILE_SEND)
{
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/* something to read on socket? */
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
- if (FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (FD_ISSET (dcc->sock, &read_fd))
{
- ptr_dcc->last_activity = time (NULL);
+ dcc->last_activity = time (NULL);
length = sizeof (addr);
- sock = accept (ptr_dcc->sock,
+ sock = accept (dcc->sock,
(struct sockaddr *) &addr, &length);
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ close (dcc->sock);
+ dcc->sock = -1;
if (sock < 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to "
"create socket for "
"sending file\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->sock = sock;
- if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ dcc->sock = sock;
+ if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to set "
"'nonblock' option for "
"socket\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
- ptr_dcc->status = IRC_DCC_ACTIVE;
- ptr_dcc->start_transfer = time (NULL);
+ dcc->addr = ntohl (addr.sin_addr.s_addr);
+ dcc->status = IRC_DCC_ACTIVE;
+ dcc->start_transfer = time (NULL);
irc_dcc_redraw (GUI_HOTLIST_MSG);
- irc_dcc_file_send_fork (ptr_dcc);
+ irc_dcc_file_send_fork (dcc);
}
}
}
- if (ptr_dcc->type == IRC_DCC_FILE_RECV)
+ if (dcc->type == IRC_DCC_FILE_RECV)
{
- if (ptr_dcc->child_read != -1)
- irc_dcc_file_child_read (ptr_dcc);
+ if (dcc->child_read != -1)
+ irc_dcc_file_child_read (dcc);
}
}
- if (ptr_dcc->status == IRC_DCC_WAITING)
+ if (dcc->status == IRC_DCC_WAITING)
{
- if (ptr_dcc->type == IRC_DCC_CHAT_SEND)
+ if (dcc->type == IRC_DCC_CHAT_SEND)
{
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/* something to read on socket? */
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
- if (FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (FD_ISSET (dcc->sock, &read_fd))
{
length = sizeof (addr);
- sock = accept (ptr_dcc->sock, (struct sockaddr *) &addr, &length);
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ sock = accept (dcc->sock, (struct sockaddr *) &addr, &length);
+ close (dcc->sock);
+ dcc->sock = -1;
if (sock < 0)
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->sock = sock;
- if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ dcc->sock = sock;
+ if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
- ptr_dcc->status = IRC_DCC_ACTIVE;
+ dcc->addr = ntohl (addr.sin_addr.s_addr);
+ dcc->status = IRC_DCC_ACTIVE;
irc_dcc_redraw (GUI_HOTLIST_MSG);
- irc_dcc_channel_for_chat (ptr_dcc);
+ irc_dcc_channel_for_chat (dcc);
}
}
}
}
- if (ptr_dcc->status == IRC_DCC_ACTIVE)
+ if (dcc->status == IRC_DCC_ACTIVE)
{
- if (IRC_DCC_IS_CHAT(ptr_dcc->type))
- irc_dcc_chat_recv (ptr_dcc);
+ if (IRC_DCC_IS_CHAT(dcc->type))
+ irc_dcc_chat_recv (dcc);
else
- irc_dcc_file_child_read (ptr_dcc);
+ irc_dcc_file_child_read (dcc);
}
}
}
diff --git a/src/plugins/irc/irc-dcc.h b/src/plugins/irc/irc-dcc.h
index af8f0baf7..f36bb0c51 100644
--- a/src/plugins/irc/irc-dcc.h
+++ b/src/plugins/irc/irc-dcc.h
@@ -110,20 +110,26 @@ 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 void irc_dcc_redraw (int highlight);
+extern void irc_dcc_free (struct t_irc_dcc *dcc);
+extern void irc_dcc_close (struct t_irc_dcc *dcc, int status);
+extern void irc_dcc_chat_remove_channel (struct t_irc_channel *channel);
+extern void irc_dcc_accept (struct t_irc_dcc *dcc);
+extern void irc_dcc_accept_resume (struct t_irc_server *server, char *filename,
+ int port, unsigned long pos_start);
+extern void irc_dcc_start_resume (struct t_irc_server *server, char *filename,
+ int port, unsigned long pos_start);
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 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);
+extern void irc_dcc_send_request (struct t_irc_server *server, int type,
+ char *nick, char *filename);
+extern void irc_dcc_chat_sendf (struct t_irc_dcc *dcc, char *format, ...);
+extern void irc_dcc_file_send_fork (struct t_irc_dcc *dcc);
+extern void irc_dcc_file_recv_fork (struct t_irc_dcc *dcc);
extern void irc_dcc_handle ();
extern void irc_dcc_end ();
extern void irc_dcc_print_log ();
diff --git a/src/plugins/irc/irc-display.h b/src/plugins/irc/irc-display.h
index 778eea778..06aa927c0 100644
--- a/src/plugins/irc/irc-display.h
+++ b/src/plugins/irc/irc-display.h
@@ -20,12 +20,16 @@
#ifndef __WEECHAT_IRC_DISPLAY_H
#define __WEECHAT_IRC_DISPLAY_H 1
-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);
+extern void irc_display_hide_password (char *string, int look_for_nickserv);
+extern void irc_display_nick (struct t_gui_buffer *buffer,
+ struct t_irc_nick *nick, char *nickname,
+ int type, int display_around, char *force_color,
+ int no_nickmode);
+extern void irc_display_away (struct t_irc_server *server, char *string1,
+ char *string2);
+extern void irc_display_mode (struct t_gui_buffer *buffer, char *channel_name,
+ char *nick_name, char set_flag, char *symbol,
+ char *nick_host, char *message, char *param);
+extern void irc_display_server (struct t_irc_server *server, int with_detail);
#endif /* irc-display.h */
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index 97efeb434..433c7e06d 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -239,8 +239,8 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
{
if (!strchr (server->nick_modes, mode))
{
- server->nick_modes = (char *) realloc (server->nick_modes,
- strlen (server->nick_modes) + 1 + 1);
+ server->nick_modes = (char *)realloc (server->nick_modes,
+ strlen (server->nick_modes) + 1 + 1);
strcat (server->nick_modes, str_mode);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
@@ -248,7 +248,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
}
else
{
- server->nick_modes = (char *) malloc (2);
+ server->nick_modes = (char *)malloc (2);
strcpy (server->nick_modes, str_mode);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
@@ -272,8 +272,8 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
{
new_size = strlen (server->nick_modes);
memmove (pos, pos + 1, strlen (pos + 1) + 1);
- server->nick_modes = (char *) realloc (server->nick_modes,
- new_size);
+ server->nick_modes = (char *)realloc (server->nick_modes,
+ new_size);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
}
diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h
index 5e1b958ee..c53612f55 100644
--- a/src/plugins/irc/irc-mode.h
+++ b/src/plugins/irc/irc-mode.h
@@ -22,9 +22,10 @@
#include "irc-server.h"
-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);
+extern void irc_mode_channel_set (struct t_irc_server *server,
+ struct t_irc_channel *channel, char *modes);
+extern void irc_mode_user_set (struct t_irc_server *server, char *modes);
+extern int irc_mode_nick_prefix_allowed (struct t_irc_server *server,
+ char prefix);
#endif /* irc-mode.h */
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index f1c6a6290..d51fde31f 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -49,7 +49,8 @@ irc_nick_find_color (struct t_irc_nick *nick)
{
color += (int)(nick->nick[i]);
}
- color = (color % weechat_config_integer (weechat_config_get ("look_color_nicks_number")));
+ color = (color %
+ weechat_config_integer (weechat_config_get_weechat ("look_color_nicks_number")));
return color;
}
@@ -164,7 +165,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
}
// alloc memory for new nick
- if ((new_nick = (struct t_irc_nick *) malloc (sizeof (struct t_irc_nick))) == NULL)
+ if ((new_nick = (struct t_irc_nick *)malloc (sizeof (struct t_irc_nick))) == NULL)
return NULL;
// initialize new nick
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 698e01437..f0bc5ecd5 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -50,19 +50,30 @@ 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 char *irc_nick_as_prefix (struct t_irc_nick *, char *, char *);
-extern void irc_nick_print_log (struct t_irc_nick *);
+extern int irc_nick_find_color (struct t_irc_nick *nick);
+extern void irc_nick_get_gui_infos (struct t_irc_nick *nick, int *sort_index,
+ char *prefix, int *color_prefix);
+extern 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);
+extern void irc_nick_change (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ struct t_irc_nick *nick, char *new_nick);
+extern void irc_nick_free (struct t_irc_channel *channel,
+ struct t_irc_nick *nick);
+extern void irc_nick_free_all (struct t_irc_channel *channel);
+extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *channel,
+ char *nickname);
+extern void irc_nick_count (struct t_irc_channel *channel, int *total,
+ int *count_op, int *count_halfop, int *count_voice,
+ int *count_normal);
+extern void irc_nick_set_away (struct t_irc_channel *channel,
+ struct t_irc_nick *nick, int is_away);
+extern char *irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname,
+ char *force_color);
+extern void irc_nick_print_log (struct t_irc_nick *nick);
#endif /* irc-nick.h */
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f9169391f..3e657977f 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1177,7 +1177,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *h
(void) irc_message;
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get ("look_infobar_delay_highlight"));
+ weechat_config_get_weechat ("look_infobar_delay_highlight"));
host2 = NULL;
if (host)
@@ -1485,7 +1485,7 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos
}
if (ptr_channel->close)
{
- weechat_buffer_close (ptr_channel->buffer);
+ weechat_buffer_close (ptr_channel->buffer, 1);
ptr_channel->buffer = NULL;
irc_channel_free (server, ptr_channel);
ptr_channel = NULL;
@@ -1608,7 +1608,7 @@ irc_protocol_reply_version (struct t_irc_server *server, struct t_irc_channel *c
pos = NULL;
}
- buf = (struct utsname *) malloc (sizeof (struct utsname));
+ buf = (struct utsname *)malloc (sizeof (struct utsname));
if (buf && (uname (buf) >= 0))
{
irc_server_sendf (server,
@@ -1679,7 +1679,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char *
}
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get ("look_infobar_delay_highlight"));
+ weechat_config_get_weechat ("look_infobar_delay_highlight"));
pos = strchr (host, '!');
if (pos)
@@ -3817,10 +3817,10 @@ irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host
if (pos_modes[0])
{
if (ptr_channel->modes)
- ptr_channel->modes = (char *) realloc (ptr_channel->modes,
- strlen (pos_modes) + 1);
+ ptr_channel->modes = (char *)realloc (ptr_channel->modes,
+ strlen (pos_modes) + 1);
else
- ptr_channel->modes = (char *) malloc (strlen (pos_modes) + 1);
+ ptr_channel->modes = (char *)malloc (strlen (pos_modes) + 1);
strcpy (ptr_channel->modes, pos_modes);
irc_mode_channel_set (server, ptr_channel, pos_modes);
}
@@ -4715,7 +4715,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host
if (ptr_nick->host)
free (ptr_nick->host);
length = strlen (pos_user) + 1 + strlen (pos_host) + 1;
- ptr_nick->host = (char *) malloc (length);
+ ptr_nick->host = (char *)malloc (length);
if (ptr_nick->host)
snprintf (ptr_nick->host, length, "%s@%s", pos_user, pos_host);
irc_nick_set_away (ptr_channel, ptr_nick,
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 55e02ba40..d76911657 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -22,8 +22,9 @@
#include "irc-server.h"
-typedef int (t_irc_recv_func)(struct t_irc_server *, char *, char *, char *,
- char *, int, int);
+typedef int (t_irc_recv_func)(struct t_irc_server *server, char *irc_message,
+ char *host, char *nick, char *arguments,
+ int ignore, int highlight);
struct t_irc_protocol_msg
{
@@ -34,65 +35,65 @@ struct t_irc_protocol_msg
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);
+extern int irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_kill (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_mode (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_nick (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_ping (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_pong (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_msg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_reply (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_wallops (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_005 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_221 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_301 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_302 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_303 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_310 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_311 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_312 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_314 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_315 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_317 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_321 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_322 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_323 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_327 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_329 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_331 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_333 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_338 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_341 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_344 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_345 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_351 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_365 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_438 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_671 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
#endif /* irc-protocol.h */
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 9461f4baf..0b9ac0906 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -235,7 +235,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
server->autojoin = strdup (pos_channel);
else
{
- server->autojoin = (char *) malloc (strlen (pos_channel) + 2);
+ server->autojoin = (char *)malloc (strlen (pos_channel) + 2);
strcpy (server->autojoin, "#");
strcat (server->autojoin, pos_channel);
}
@@ -249,10 +249,10 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
/* some default values */
if (server->port < 0)
server->port = IRC_SERVER_DEFAULT_PORT;
- server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
+ server->nick2 = (char *)malloc (strlen (server->nick1) + 2);
strcpy (server->nick2, server->nick1);
server->nick2 = strcat (server->nick2, "1");
- server->nick3 = (char *) malloc (strlen (server->nick1) + 2);
+ server->nick3 = (char *)malloc (strlen (server->nick1) + 2);
strcpy (server->nick3, server->nick1);
server->nick3 = strcat (server->nick3, "2");
@@ -266,7 +266,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
void
irc_server_init_with_config_options (struct t_irc_server *server,
- void *section,
+ struct t_config_section *section,
int config_reload)
{
struct t_config_option *ptr_option;
@@ -423,7 +423,7 @@ irc_server_alloc ()
struct t_irc_server *new_server;
/* alloc memory for new server */
- if ((new_server = (struct t_irc_server *) malloc (sizeof (struct t_irc_server))) == NULL)
+ if ((new_server = (struct t_irc_server *)malloc (sizeof (struct t_irc_server))) == NULL)
{
weechat_printf (NULL,
_("%sirc: error when allocating new server"),
@@ -952,7 +952,7 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
*/
void
-irc_server_sendf (struct t_irc_server *server, char *fmt, ...)
+irc_server_sendf (struct t_irc_server *server, char *format, ...)
{
va_list args;
static char buffer[4096];
@@ -962,8 +962,8 @@ irc_server_sendf (struct t_irc_server *server, char *fmt, ...)
if (!server)
return;
- va_start (args, fmt);
- vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
+ va_start (args, format);
+ vsnprintf (buffer, sizeof (buffer) - 1, format, args);
va_end (args);
ptr_buf = buffer;
@@ -1044,7 +1044,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
if (!server->unterminated_message && !msg[0])
return;
- message = (struct t_irc_message *) malloc (sizeof (struct t_irc_message));
+ message = (struct t_irc_message *)malloc (sizeof (struct t_irc_message));
if (!message)
{
weechat_printf (server->buffer,
@@ -1056,8 +1056,8 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
message->server = server;
if (server->unterminated_message)
{
- message->data = (char *) malloc (strlen (server->unterminated_message) +
- strlen (msg) + 1);
+ message->data = (char *)malloc (strlen (server->unterminated_message) +
+ strlen (msg) + 1);
if (!message->data)
{
weechat_printf (server->buffer,
@@ -1102,9 +1102,9 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
if (server->unterminated_message)
{
server->unterminated_message =
- (char *) realloc (server->unterminated_message,
- strlen (server->unterminated_message) +
- strlen (string) + 1);
+ (char *)realloc (server->unterminated_message,
+ strlen (server->unterminated_message) +
+ strlen (string) + 1);
if (!server->unterminated_message)
{
weechat_printf (server->buffer,
@@ -1292,11 +1292,11 @@ irc_server_msgq_flush ()
}
/*
- * irc_server_recv: receive data from an irc server
+ * irc_server_recv_cb: receive data from an irc server
*/
int
-irc_server_recv (void *arg_server)
+irc_server_recv_cb (void *arg_server)
{
struct t_irc_server *server;
@@ -1335,12 +1335,12 @@ irc_server_recv (void *arg_server)
}
/*
- * irc_server_timer: timer called each second to perform some operations
- * on servers
+ * irc_server_timer_cb: timer called each second to perform some operations
+ * on servers
*/
void
-irc_server_timer (void *empty)
+irc_server_timer_cb (void *empty)
{
struct t_irc_server *ptr_server;
time_t new_time;
@@ -1540,7 +1540,8 @@ irc_server_child_read (void *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"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
switch (buffer[0])
{
/* connection OK */
@@ -1568,7 +1569,7 @@ irc_server_child_read (void *arg_server)
weechat_unhook (server->hook_fd);
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
- irc_server_recv,
+ irc_server_recv_cb,
server);
break;
/* adress not found */
@@ -1630,7 +1631,7 @@ irc_server_child_read (void *arg_server)
*/
void
-irc_server_convbase64_8x3_to_6x4 (char *from, char* to)
+irc_server_convbase64_8x3_to_6x4 (char *from, char *to)
{
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -1700,8 +1701,10 @@ irc_server_pass_httpproxy (int sock, char *address, int port)
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"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_username"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_password"));
if (config_proxy_username && config_proxy_username[0])
{
@@ -1854,8 +1857,10 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
socks5.version = 5;
socks5.nmethods = 1;
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_username"));
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_password"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_username"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_password"));
if (config_proxy_username && config_proxy_username[0])
socks5.method = 2; /* with authentication */
@@ -1913,7 +1918,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
/* authentication successful then giving address/port to connect */
addr_len = strlen(address);
addr_buffer_len = 4 + 1 + addr_len + 2;
- addr_buffer = (unsigned char *) malloc (addr_buffer_len * sizeof(*addr_buffer));
+ addr_buffer = (unsigned char *)malloc (addr_buffer_len * sizeof(*addr_buffer));
if (!addr_buffer)
return 1;
addr_buffer[0] = 5; /* version 5 */
@@ -1985,7 +1990,8 @@ irc_server_pass_proxy (int sock, char *address, int port, char *username)
int rc;
char *config_proxy_type;
- config_proxy_type = weechat_config_string (weechat_config_get ("proxy_type"));
+ config_proxy_type = weechat_config_string (
+ weechat_config_get_weechat ("proxy_type"));
rc = 1;
if (config_proxy_type)
@@ -2015,10 +2021,14 @@ irc_server_child (struct t_irc_server *server)
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"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_ipv6"));
+ config_proxy_port = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_port"));
+ config_proxy_address = weechat_config_string (
+ weechat_config_get_weechat ("proxy_address"));
if (config_proxy_use)
{
@@ -2155,11 +2165,16 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
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"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_ipv6"));
+ config_proxy_type = weechat_config_string (
+ weechat_config_get_weechat ("proxy_type"));
+ config_proxy_address = weechat_config_string (
+ weechat_config_get_weechat ("proxy_address"));
+ config_proxy_port = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_port"));
if (!server->buffer)
{
@@ -2167,6 +2182,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
+ weechat_hook_signal_send ("logger_backlog", server->buffer);
}
#ifndef HAVE_GNUTLS
@@ -2477,17 +2493,17 @@ irc_server_autojoin_channels (struct t_irc_server *server)
*/
struct t_irc_server *
-irc_server_search (char *servername)
+irc_server_search (char *server_name)
{
struct t_irc_server *ptr_server;
- if (!servername)
+ if (!server_name)
return NULL;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- if (strcmp (ptr_server->name, servername) == 0)
+ if (strcmp (ptr_server->name, server_name) == 0)
return ptr_server;
}
return NULL;
@@ -2538,27 +2554,6 @@ irc_server_get_number_buffer (struct t_irc_server *server,
}
/*
- * irc_server_name_already_exists: return 1 if server name already exists
- * otherwise return 0
- */
-
-int
-irc_server_name_already_exists (char *name)
-{
- struct t_irc_server *ptr_server;
-
- if (!name)
- return 0;
-
- for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
- {
- if (strcmp (ptr_server->name, name) == 0)
- return 1;
- }
- return 0;
-}
-
-/*
* irc_server_get_channel_count: return number of channels for server
*/
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index c610f53f9..2c70d9b43 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -132,54 +132,70 @@ 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 *,
- int);
+extern void irc_server_init (struct t_irc_server *server);
+extern int irc_server_init_with_url (struct t_irc_server *server, char *irc_url);
+extern void irc_server_init_with_config_options (struct t_irc_server *server,
+ struct t_config_section *section,
+ int config_reload);
extern struct t_irc_server *irc_server_alloc ();
-extern void irc_server_outqueue_free_all (struct t_irc_server *);
-extern void irc_server_free_data (struct t_irc_server *);
-extern void irc_server_free (struct t_irc_server *);
+extern void irc_server_outqueue_free_all (struct t_irc_server *server);
+extern void irc_server_free_data (struct t_irc_server *server);
+extern void irc_server_free (struct t_irc_server *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 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, char *nick1,
+ char *nick2, char *nick3,
+ char *username, char *realname,
+ char *hostname, char *command,
+ int command_delay, char *autojoin,
+ int autorejoin,
+ char *notify_levels);
+extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *server,
+ char *new_name);
+extern int irc_server_rename (struct t_irc_server *server, char *new_name);
+extern int irc_server_send (struct t_irc_server *server, char *buffer,
+ int size_buf);
+extern void irc_server_outqueue_send (struct t_irc_server *server);
+extern void irc_server_sendf (struct t_irc_server *server, char *format, ...);
+extern void irc_server_parse_message (char *message, char **host,
+ char **command, char **args);
+extern int irc_server_recv_cb (void *arg_server);
+extern void irc_server_timer_cb (void *empty);
+extern void irc_server_timer_check_away (void *empty);
+extern int irc_server_child_read (void *arg_server);
+extern void irc_server_convbase64_8x3_to_6x4 (char *from, char *to);
+extern void irc_server_base64encode (char *from, char *to);
+extern int irc_server_pass_httpproxy (int sock, char *address, int port);
+extern int irc_server_resolve (char *hostname, char *ip, int *version);
+extern int irc_server_pass_socks4proxy (int sock, char *address, int port,
+ char *username);
+extern int irc_server_pass_socks5proxy (int sock, char *address, int port);
+extern int irc_server_pass_proxy (int sock, char *address, int port,
+ char *username);
+extern int irc_server_connect (struct t_irc_server *server,
+ int disable_autojoin);
+extern void irc_server_reconnect (struct t_irc_server *server);
+extern void irc_server_auto_connect (int auto_connect, int temp_server);
+extern void irc_server_disconnect (struct t_irc_server *server, int reconnect);
extern void irc_server_disconnect_all ();
extern void irc_server_autojoin_channels ();
-extern struct t_irc_server *irc_server_search (char *);
+extern struct t_irc_server *irc_server_search (char *server_name);
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_get_number_buffer (struct t_irc_server *server,
+ int *server_pos, int *server_total);
+extern int irc_server_get_channel_count (struct t_irc_server *server);
+extern int irc_server_get_pv_count (struct t_irc_server *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_set_away (struct t_irc_server *server, char *nick,
+ int is_away);
+extern int irc_server_get_default_notify_level (struct t_irc_server *server);
+extern void irc_server_set_default_notify_level (struct t_irc_server *server,
+ int notify);
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 ab99c55dc..cc808eb0f 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -180,19 +180,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("quit", &irc_quit_cb, NULL);
/* hook completions */
- weechat_hook_completion ("irc_server", &irc_completion_server_cb, NULL);
- weechat_hook_completion ("irc_server_nicks",
- &irc_completion_server_nicks_cb, NULL);
- weechat_hook_completion ("irc_servers", &irc_completion_servers_cb, NULL);
- weechat_hook_completion ("irc_channel", &irc_completion_channel_cb, NULL);
- weechat_hook_completion ("irc_channel_nicks",
- &irc_completion_channel_nicks_cb, NULL);
- weechat_hook_completion ("irc_channel_nicks_hosts",
- &irc_completion_channel_nicks_hosts_cb, NULL);
- weechat_hook_completion ("irc_channel_topic",
- &irc_completion_channel_topic_cb, NULL);
- weechat_hook_completion ("irc_channels", &irc_completion_channels_cb, NULL);
- weechat_hook_completion ("irc_msg_part", &irc_completion_msg_part_cb, NULL);
+ irc_completion_init ();
//irc_server_auto_connect (1, 0);
diff --git a/src/plugins/logger/CMakeLists.txt b/src/plugins/logger/CMakeLists.txt
index ef4c1984c..e9000e9a8 100644
--- a/src/plugins/logger/CMakeLists.txt
+++ b/src/plugins/logger/CMakeLists.txt
@@ -14,7 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(logger MODULE logger.c logger-buffer.c logger-buffer.h)
+ADD_LIBRARY(logger MODULE logger.c logger.h logger-buffer.c logger-buffer.h
+logger-tail.c logger-tail.h)
SET_TARGET_PROPERTIES(logger PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(logger)
diff --git a/src/plugins/logger/Makefile.am b/src/plugins/logger/Makefile.am
index 2b94c5b2d..ddf0adb09 100644
--- a/src/plugins/logger/Makefile.am
+++ b/src/plugins/logger/Makefile.am
@@ -20,6 +20,11 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = logger.la
-logger_la_SOURCES = logger.c logger-buffer.c logger-buffer.h
+logger_la_SOURCES = logger.c \
+ logger.h \
+ logger-buffer.c \
+ logger-buffer.h \
+ logger-tail.c \
+ logger-tail.h
logger_la_LDFLAGS = -module
logger_la_LIBADD = $(LOGGER_LFLAGS)
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index e50acf5ee..929b68bce 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -39,7 +39,7 @@ struct t_logger_buffer *last_logger_buffer = NULL;
*/
struct t_logger_buffer *
-logger_buffer_add (void *buffer, char *log_filename)
+logger_buffer_add (struct t_gui_buffer *buffer, char *log_filename)
{
struct t_logger_buffer *new_logger_buffer;
@@ -52,6 +52,7 @@ logger_buffer_add (void *buffer, char *log_filename)
new_logger_buffer->buffer = buffer;
new_logger_buffer->log_filename = strdup (log_filename);
new_logger_buffer->log_file = NULL;
+ new_logger_buffer->log_enabled = 1;
new_logger_buffer->prev_buffer = last_logger_buffer;
new_logger_buffer->next_buffer = NULL;
@@ -70,14 +71,14 @@ logger_buffer_add (void *buffer, char *log_filename)
*/
struct t_logger_buffer *
-logger_buffer_search (void *buffer)
+logger_buffer_search (struct t_gui_buffer *buffer)
{
struct t_logger_buffer *ptr_logger_buffer;
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
{
- if (ptr_logger_buffer->buffer == (struct t_gui_buffer *)buffer)
+ if (ptr_logger_buffer->buffer == buffer)
return ptr_logger_buffer;
}
@@ -116,25 +117,11 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
}
/*
- * logger_buffer_remove: remove a buffer from list
+ * logger_buffer_free_all: remove all buffers from list
*/
void
-logger_buffer_remove (void *buffer)
-{
- struct t_logger_buffer *ptr_logger_buffer;
-
- ptr_logger_buffer = logger_buffer_search (buffer);
- if (ptr_logger_buffer)
- logger_buffer_free (ptr_logger_buffer);
-}
-
-/*
- * logger_buffer_remove_all: remove all buffers from list
- */
-
-void
-logger_buffer_remove_all ()
+logger_buffer_free_all ()
{
while (logger_buffers)
{
diff --git a/src/plugins/logger/logger-buffer.h b/src/plugins/logger/logger-buffer.h
index 1d7ee8225..e01e71d9c 100644
--- a/src/plugins/logger/logger-buffer.h
+++ b/src/plugins/logger/logger-buffer.h
@@ -25,6 +25,7 @@ struct t_logger_buffer
struct t_gui_buffer *buffer; /* pointer to buffer */
char *log_filename; /* log filename */
FILE *log_file; /* log file */
+ int log_enabled; /* log enabled ? */
struct t_logger_buffer *prev_buffer; /* link to previous buffer */
struct t_logger_buffer *next_buffer; /* link to next buffer */
};
@@ -32,9 +33,10 @@ struct t_logger_buffer
extern struct t_logger_buffer *logger_buffers;
extern struct t_logger_buffer *last_logger_buffer;
-extern struct t_logger_buffer *logger_buffer_add (void *, char *);
-extern struct t_logger_buffer *logger_buffer_search (void *);
-extern void logger_buffer_remove (void *);
-extern void logger_buffer_remove_all ();
+extern struct t_logger_buffer *logger_buffer_add (struct t_gui_buffer *,
+ char *log_filename);
+extern struct t_logger_buffer *logger_buffer_search (struct t_gui_buffer *buffer);
+extern void logger_buffer_free (struct t_logger_buffer *logger_buffer);
+extern void logger_buffer_free_all ();
#endif /* logger-buffer.h */
diff --git a/src/plugins/logger/logger-tail.c b/src/plugins/logger/logger-tail.c
new file mode 100644
index 000000000..47504cd4a
--- /dev/null
+++ b/src/plugins/logger/logger-tail.c
@@ -0,0 +1,223 @@
+/*
+ * 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/>.
+ */
+
+/* logger-tail.c: return last lines of a file */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "logger.h"
+#include "logger-tail.h"
+
+
+#define LOGGER_TAIL_BUFSIZE 4096
+
+
+/*
+ * logger_tail_last_eol: find last eol in a string
+ */
+
+char *
+logger_tail_last_eol (char *string_start, char *string_ptr)
+{
+ while (string_ptr >= string_start)
+ {
+ if ((string_ptr[0] == '\n') || (string_ptr[0] == '\r'))
+ return string_ptr;
+ string_ptr--;
+ }
+
+ /* no end-of-line found in string */
+ return NULL;
+}
+
+/*
+ * logger_tail_file: return last lines of a file
+ */
+
+struct t_logger_line *
+logger_tail_file (char *filename, int n_lines)
+{
+ int fd;
+ off_t file_length, file_pos;
+ size_t to_read;
+ ssize_t bytes_read;
+ char buf[LOGGER_TAIL_BUFSIZE + 1];
+ char *ptr_buf, *pos_eol, *part_of_line, *new_part_of_line;
+ struct t_logger_line *ptr_line, *new_line;
+
+ /* open file */
+ fd = open (filename, O_RDONLY);
+ if (fd == -1)
+ return NULL;
+
+ /* seek to the end of file */
+ file_length = lseek (fd, (off_t)0, SEEK_END);
+ if (file_length <= 0)
+ {
+ close (fd);
+ return NULL;
+ }
+ to_read = file_length;
+ file_pos = file_length - LOGGER_TAIL_BUFSIZE;
+ if (file_pos < 0)
+ file_pos = 0;
+ else
+ to_read = LOGGER_TAIL_BUFSIZE;
+ lseek (fd, file_pos, SEEK_SET);
+
+ /* loop until we have "n_lines" lines in list */
+ part_of_line = NULL;
+ ptr_line = NULL;
+ while (n_lines > 0)
+ {
+ lseek (fd, file_pos, SEEK_SET);
+ bytes_read = read (fd, buf, to_read);
+ if (bytes_read <= 0)
+ {
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ buf[bytes_read] = '\0';
+ ptr_buf = buf + bytes_read - 1;
+ while (ptr_buf && (ptr_buf >= buf))
+ {
+ pos_eol = logger_tail_last_eol (buf, ptr_buf);
+ if ((pos_eol && pos_eol[1]) || (!pos_eol && (file_pos == 0)))
+ {
+ /* use data and part_of_line (if existing) to build a new line */
+ if (!pos_eol)
+ {
+ ptr_buf = NULL;
+ pos_eol = buf;
+ }
+ else
+ {
+ ptr_buf = pos_eol - 1;
+ pos_eol[0] = '\0';
+ pos_eol++;
+ }
+ new_line = (struct t_logger_line *)malloc (sizeof (struct t_logger_line));
+ if (!new_line)
+ {
+ logger_tail_free (ptr_line);
+ ptr_line = NULL;
+ break;
+ }
+ if (part_of_line)
+ {
+ new_line->data = (char *)malloc (strlen (pos_eol) +
+ strlen (part_of_line) + 1);
+ if (!new_line->data)
+ {
+ free (part_of_line);
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ strcpy (new_line->data, pos_eol);
+ strcat (new_line->data, part_of_line);
+ free (part_of_line);
+ part_of_line = NULL;
+ }
+ else
+ {
+ new_line->data = strdup (pos_eol);
+ }
+ new_line->next_line = ptr_line;
+ ptr_line = new_line;
+ n_lines--;
+ if (n_lines <= 0)
+ break;
+ }
+ else if (!pos_eol)
+ {
+ /* beginning of read buffer reached without EOL, then we
+ add string to part_of_line, we'll use that later */
+ if (part_of_line)
+ {
+ new_part_of_line = (char *)malloc (strlen (buf) +
+ strlen (part_of_line) + 1);
+ if (!new_part_of_line)
+ {
+ free (part_of_line);
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ strcpy (new_part_of_line, buf);
+ strcat (new_part_of_line, part_of_line);
+ free (part_of_line);
+ part_of_line = new_part_of_line;
+ }
+ else
+ {
+ part_of_line = (char *)malloc (strlen (buf) + 1);
+ strcpy (part_of_line, buf);
+ }
+ ptr_buf = NULL;
+ }
+ else
+ ptr_buf = pos_eol - 1;
+ }
+ if (file_pos == 0)
+ break;
+ to_read = file_pos;
+ file_pos -= LOGGER_TAIL_BUFSIZE;
+ if (file_pos < 0)
+ file_pos = 0;
+ else
+ to_read = LOGGER_TAIL_BUFSIZE;
+ }
+
+ if (part_of_line)
+ free (part_of_line);
+
+ close (fd);
+
+ return ptr_line;
+}
+
+/*
+ * logger_tail_free: free structure returned by "logger_tail_file" function
+ */
+
+void
+logger_tail_free (struct t_logger_line *lines)
+{
+ if (!lines)
+ return;
+
+ while (lines->next_line)
+ {
+ if (lines->data)
+ free (lines->data);
+ lines = lines->next_line;
+ }
+ free (lines);
+}
diff --git a/src/plugins/logger/logger-tail.h b/src/plugins/logger/logger-tail.h
new file mode 100644
index 000000000..55feb2d1c
--- /dev/null
+++ b/src/plugins/logger/logger-tail.h
@@ -0,0 +1,32 @@
+/*
+ * 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_LOGGER_TAIL_H
+#define __WEECHAT_LOGGER_TAIL_H 1
+
+struct t_logger_line
+{
+ char *data; /* line content */
+ struct t_logger_line *next_line; /* link to next line */
+};
+
+extern struct t_logger_line *logger_tail_file (char *filename, int n_lines);
+extern void logger_tail_free (struct t_logger_line *lines);
+
+#endif /* logger-tail.h */
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 7a0eb8041..922c38409 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -34,8 +34,9 @@
#include <fcntl.h>
#include <time.h>
-#include "../weechat-plugin.h"
+#include "logger.h"
#include "logger-buffer.h"
+#include "logger-tail.h"
char plugin_name[] = "logger";
@@ -43,36 +44,74 @@ char plugin_version[] = "0.1";
char plugin_description[] = "Logger plugin for WeeChat";
struct t_weechat_plugin *weechat_logger_plugin = NULL;
-#define weechat_plugin weechat_logger_plugin
-char *logger_path = NULL;
-char *logger_time_format = NULL;
+#define LOGGER_OPTION_PATH "path"
+#define LOGGER_OPTION_TIME_FORMAT "time_format"
+#define LOGGER_OPTION_INFO_LINES "info_lines"
+#define LOGGER_OPTION_BACKLOG "backlog"
+
+char *logger_option_path = NULL;
+char *logger_option_time_format = NULL;
+int logger_option_info_lines;
+int logger_option_backlog;
/*
* logger_config_read: read config options for logger plugin
+ * return: 1 if ok
+ * 0 if error
*/
-void
+int
logger_config_read ()
{
- if (logger_path)
- free (logger_path);
- logger_path = weechat_plugin_config_get ("path");
- if (!logger_path)
+ long number;
+ char *string, *error;
+
+ logger_option_path = weechat_config_get_plugin (LOGGER_OPTION_PATH);
+ if (!logger_option_path)
{
- weechat_plugin_config_set ("path", "%h/logs/");
- logger_path = weechat_plugin_config_get ("path");
+ weechat_config_set_plugin (LOGGER_OPTION_PATH, "%h/logs/");
+ logger_option_path = weechat_config_get_plugin ("path");
}
-
- if (logger_time_format)
- free (logger_time_format);
- logger_time_format = weechat_plugin_config_get ("time_format");
- if (!logger_time_format)
+
+ logger_option_time_format = weechat_config_get_plugin (LOGGER_OPTION_TIME_FORMAT);
+ if (!logger_option_time_format)
{
- weechat_plugin_config_set ("time_format", "%Y %b %d %H:%M:%S");
- logger_time_format = weechat_plugin_config_get ("time_format");
+ weechat_config_set_plugin (LOGGER_OPTION_TIME_FORMAT,
+ "%Y %b %d %H:%M:%S");
+ logger_option_time_format = weechat_config_get_plugin (LOGGER_OPTION_TIME_FORMAT);
}
+
+ string = weechat_config_get_plugin (LOGGER_OPTION_INFO_LINES);
+ if (!string)
+ {
+ weechat_config_set_plugin (LOGGER_OPTION_INFO_LINES, "off");
+ string = weechat_config_get_plugin (LOGGER_OPTION_INFO_LINES);
+ }
+ if (string && (weechat_config_string_to_boolean (string) > 0))
+ logger_option_info_lines = 1;
+ else
+ logger_option_info_lines = 0;
+
+ string = weechat_config_get_plugin (LOGGER_OPTION_BACKLOG);
+ if (!string)
+ {
+ weechat_config_set_plugin (LOGGER_OPTION_BACKLOG, "20");
+ string = weechat_config_get_plugin (LOGGER_OPTION_BACKLOG);
+ }
+ logger_option_backlog = 20;
+ if (string)
+ {
+ error = NULL;
+ number = strtol (string, &error, 10);
+ if (error && (error[0] == '\0'))
+ logger_option_backlog = number;
+ }
+ if (logger_option_path && logger_option_time_format && logger_option_backlog)
+ return 1;
+ else
+ return 0;
}
/*
@@ -88,7 +127,7 @@ logger_create_directory ()
rc = 1;
- dir1 = weechat_string_replace (logger_path, "~", getenv ("HOME"));
+ dir1 = weechat_string_replace (logger_option_path, "~", getenv ("HOME"));
if (dir1)
{
weechat_dir = weechat_info_get ("weechat_dir");
@@ -99,7 +138,8 @@ logger_create_directory ()
{
if (mkdir (dir2, 0755) < 0)
{
- if (errno != EEXIST) rc = 0;
+ if (errno != EEXIST)
+ rc = 0;
}
else
chmod (dir2, 0700);
@@ -124,7 +164,7 @@ logger_create_directory ()
*/
char *
-logger_get_filename (void *buffer)
+logger_get_filename (struct t_gui_buffer *buffer)
{
struct t_plugin_infolist *ptr_infolist;
char *res;
@@ -136,7 +176,8 @@ logger_get_filename (void *buffer)
dir_separator = weechat_info_get ("dir_separator");
weechat_dir = weechat_info_get ("weechat_dir");
- log_path = weechat_string_replace (logger_path, "~", getenv ("HOME"));
+ log_path = weechat_string_replace (logger_option_path, "~",
+ getenv ("HOME"));
log_path2 = weechat_string_replace (log_path, "%h", weechat_dir);
if (dir_separator && weechat_dir && log_path && log_path2)
@@ -230,22 +271,25 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
free (charset);
return;
}
-
- seconds = time (NULL);
- date_tmp = localtime (&seconds);
- buf_time[0] = '\0';
- if (date_tmp)
- strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
- snprintf (buf, sizeof (buf) - 1,
- _("**** Beginning of log %s ****"),
- buf_time);
- message = (charset) ?
- weechat_iconv_from_internal (charset, buf) : NULL;
- fprintf (logger_buffer->log_file,
- "%s\n", (message) ? message : buf);
- if (message)
- free (message);
+
+ if (logger_option_info_lines)
+ {
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ buf_time[0] = '\0';
+ if (date_tmp)
+ strftime (buf_time, sizeof (buf_time) - 1,
+ logger_option_time_format, date_tmp);
+ snprintf (buf, sizeof (buf) - 1,
+ _("%s\t**** Beginning of log ****"),
+ buf_time);
+ message = (charset) ?
+ weechat_iconv_from_internal (charset, buf) : NULL;
+ fprintf (logger_buffer->log_file,
+ "%s\n", (message) ? message : buf);
+ if (message)
+ free (message);
+ }
}
va_start (argptr, format);
@@ -270,7 +314,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
*/
void
-logger_start_buffer (void *buffer)
+logger_start_buffer (struct t_gui_buffer *buffer)
{
struct t_logger_buffer *ptr_logger_buffer;
char *log_filename;
@@ -333,18 +377,21 @@ logger_end (struct t_logger_buffer *logger_buffer)
if (logger_buffer->log_file)
{
- seconds = time (NULL);
- date_tmp = localtime (&seconds);
- buf_time[0] = '\0';
- if (date_tmp)
- strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
- logger_write_line (logger_buffer,
- _("**** End of log %s ****"),
- buf_time);
+ if (logger_option_info_lines)
+ {
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ buf_time[0] = '\0';
+ if (date_tmp)
+ strftime (buf_time, sizeof (buf_time) - 1,
+ logger_option_time_format, date_tmp);
+ logger_write_line (logger_buffer,
+ _("%s\t**** End of log ****"),
+ buf_time);
+ }
fclose (logger_buffer->log_file);
logger_buffer->log_file = NULL;
- logger_buffer_remove (logger_buffer);
+ logger_buffer_free (logger_buffer);
}
}
@@ -356,7 +403,7 @@ void
logger_end_all ()
{
struct t_logger_buffer *ptr_logger_buffer;
-
+
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
{
@@ -365,7 +412,7 @@ logger_end_all ()
}
/*
- * logger_buffer_open_signal_cb: callback for buffer_open signal
+ * logger_buffer_open_signal_cb: callback for "buffer_open" signal
*/
int
@@ -382,7 +429,7 @@ logger_buffer_open_signal_cb (void *data, char *signal, void *pointer)
}
/*
- * logger_buffer_close_signal_cb: callback for buffer_close signal
+ * logger_buffer_close_signal_cb: callback for "buffer_close" signal
*/
int
@@ -399,12 +446,95 @@ logger_buffer_close_signal_cb (void *data, char *signal, void *pointer)
}
/*
+ * logger_backlog: display backlog for a buffer (by reading end of log file)
+ */
+
+void
+logger_backlog (struct t_gui_buffer *buffer, char *filename, int lines)
+{
+ struct t_logger_line *last_lines, *ptr_lines;
+ char *pos_message, *error;
+ time_t datetime;
+ struct tm tm_line;
+ int num_lines;
+
+ num_lines = 0;
+ last_lines = logger_tail_file (filename, lines);
+ ptr_lines = last_lines;
+ while (ptr_lines)
+ {
+ datetime = 0;
+ pos_message = strchr (ptr_lines->data, '\t');
+ if (pos_message)
+ {
+ pos_message[0] = '\0';
+ error = strptime (ptr_lines->data, logger_option_time_format,
+ &tm_line);
+ if (error && !error[0])
+ datetime = mktime (&tm_line);
+ pos_message[0] = '\t';
+ }
+ if (pos_message)
+ {
+ if (datetime != 0)
+ weechat_printf_date (buffer, datetime, pos_message + 1);
+ else
+ weechat_printf (buffer, ptr_lines->data);
+ }
+ else
+ {
+ weechat_printf (buffer, ptr_lines->data);
+ }
+ num_lines++;
+ ptr_lines = ptr_lines->next_line;
+ }
+ if (last_lines)
+ logger_tail_free (last_lines);
+ if (num_lines > 0)
+ weechat_printf (buffer,
+ _("===\t========== End of backlog (%d lines) =========="),
+ num_lines);
+}
+
+/*
+ * logger_backlog_signal_cb: callback for "logger_backlog" signal
+ */
+
+int
+logger_backlog_signal_cb (void *data, char *signal, void *pointer)
+{
+ struct t_logger_buffer *ptr_logger_buffer;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+
+ if (logger_option_backlog >= 0)
+ {
+ ptr_logger_buffer = logger_buffer_search (pointer);
+ if (ptr_logger_buffer && ptr_logger_buffer->log_filename
+ && ptr_logger_buffer->log_enabled)
+ {
+ ptr_logger_buffer->log_enabled = 0;
+
+ logger_backlog (pointer,
+ ptr_logger_buffer->log_filename,
+ logger_option_backlog);
+
+ ptr_logger_buffer->log_enabled = 1;
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* logger_print_cb: callback for print hook
*/
int
-logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
- char *message)
+logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
+ char *prefix, char *message)
{
struct t_logger_buffer *ptr_logger_buffer;
struct tm *date_tmp;
@@ -414,20 +544,19 @@ logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
(void) data;
ptr_logger_buffer = logger_buffer_search (buffer);
- if (ptr_logger_buffer && ptr_logger_buffer->log_filename)
+ if (ptr_logger_buffer && ptr_logger_buffer->log_filename
+ && ptr_logger_buffer->log_enabled)
{
date_tmp = localtime (&date);
buf_time[0] = '\0';
if (date_tmp)
strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
+ logger_option_time_format, date_tmp);
logger_write_line (ptr_logger_buffer,
- "%s%s%s%s%s",
+ "%s\t%s\t%s",
buf_time,
- (buf_time[0]) ? " " : "",
(prefix) ? prefix : "",
- (prefix && prefix[0]) ? " " : "",
message);
}
@@ -435,6 +564,24 @@ logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
}
/*
+ * logger_config_cb: callback for config hook
+ */
+
+int
+logger_config_cb (void *data, char *type, char *option, char *value)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) type;
+ (void) option;
+ (void) value;
+
+ logger_config_read ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* weechat_plugin_init: initialize logger plugin
*/
@@ -443,8 +590,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
{
weechat_plugin = plugin;
- logger_config_read ();
- if (!logger_path || !logger_time_format)
+ if (!logger_config_read ())
return WEECHAT_RC_ERROR;
if (!logger_create_directory ())
return WEECHAT_RC_ERROR;
@@ -453,9 +599,19 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("buffer_open", &logger_buffer_open_signal_cb, NULL);
weechat_hook_signal ("buffer_close", &logger_buffer_close_signal_cb, NULL);
+ weechat_hook_signal ("logger_backlog", &logger_backlog_signal_cb, NULL);
weechat_hook_print (NULL, NULL, 1, &logger_print_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_PATH,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_TIME_FORMAT,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_INFO_LINES,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_BACKLOG,
+ &logger_config_cb, NULL);
+
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/logger/logger.h b/src/plugins/logger/logger.h
new file mode 100644
index 000000000..7bb466549
--- /dev/null
+++ b/src/plugins/logger/logger.h
@@ -0,0 +1,29 @@
+/*
+ * 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_LOGGER_H
+#define __WEECHAT_LOGGER_H 1
+
+#include "../weechat-plugin.h"
+
+#define weechat_plugin weechat_logger_plugin
+
+extern struct t_weechat_plugin *weechat_logger_plugin;
+
+#endif /* logger.h */
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index d2afc619f..278659024 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -33,20 +33,13 @@
#include "../core/weechat.h"
#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"
-#include "../core/wee-util.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-infobar.h"
-#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
-#include "../gui/gui-nicklist.h"
-#include "../gui/gui-status.h"
#include "../gui/gui-window.h"
#include "plugin.h"
#include "plugin-config.h"
@@ -70,51 +63,12 @@ plugin_api_charset_set (struct t_weechat_plugin *plugin, char *charset)
}
/*
- * plugin_api_iconv_to_internal: encode string from a charset to WeeChat
- * internal charset
- */
-
-char *
-plugin_api_iconv_to_internal (struct t_weechat_plugin *plugin,
- char *charset, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string)
- return NULL;
-
- return string_iconv_to_internal (charset, string);
-}
-
-/*
- * plugin_api_iconv_from_internal: encode string from WeeChat internal
- * charset to another
- */
-
-char *
-plugin_api_iconv_from_internal (struct t_weechat_plugin *plugin,
- char *charset, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string)
- return NULL;
-
- return string_iconv_from_internal (charset, string);
-}
-
-/*
* plugin_api_gettext: translate a string using gettext
*/
char *
-plugin_api_gettext (struct t_weechat_plugin *plugin, char *string)
+plugin_api_gettext (char *string)
{
- /* make C compiler happy */
- (void) plugin;
-
return _(string);
}
@@ -123,353 +77,28 @@ plugin_api_gettext (struct t_weechat_plugin *plugin, char *string)
*/
char *
-plugin_api_ngettext (struct t_weechat_plugin *plugin, char *single,
- char *plural, int count)
+plugin_api_ngettext (char *single, char *plural, int count)
{
- /* make C compiler happy */
- (void) plugin;
-
return NG_(single, plural, count);
}
/*
- * plugin_api_strcasecmp: locale and case independent string comparison
- */
-
-int
-plugin_api_strcasecmp (struct t_weechat_plugin *plugin,
- char *string1, char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strcasecmp (string1, string2);
-}
-
-/*
- * plugin_api_strncasecmp: locale and case independent string comparison
- * with max length
- */
-
-int
-plugin_api_strncasecmp (struct t_weechat_plugin *plugin,
- char *string1, char *string2, int max)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strncasecmp (string1, string2, max);
-}
-
-/*
- * plugin_api_strcasestr: locale and case independent string search
- */
-
-char *
-plugin_api_strcasestr (struct t_weechat_plugin *plugin,
- char *string1, char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strcasestr (string1, string2);
-}
-
-/*
- * plugin_api_string_replace: replace a string by new one in a string
- */
-
-char *
-plugin_api_string_replace (struct t_weechat_plugin *plugin,
- char *string, char *search, char *replace)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_replace (string, search, replace);
-}
-
-/*
- * plugin_api_string_explode: explode a string
- */
-
-char **
-plugin_api_string_explode (struct t_weechat_plugin *plugin, char *string,
- char *separators, int keep_eol,
- int num_items_max, int *num_items)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string || !separators || !num_items)
- return NULL;
-
- return string_explode (string, separators, keep_eol,
- num_items_max, num_items);
-}
-
-/*
- * plugin_api_string_free_exploded: free exploded string
- */
-
-void
-plugin_api_string_free_exploded (struct t_weechat_plugin *plugin,
- char **exploded_string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- string_free_exploded (exploded_string);
-}
-
-/*
- * plugin_api_string_split_command: split a ocmmanc
- */
-
-char **
-plugin_api_string_split_command (struct t_weechat_plugin *plugin, char *string,
- char separator)
-{
- if (!plugin || !string)
- return NULL;
-
- return string_split_command (string, separator);
-}
-
-/*
- * plugin_api_string_free_splitted_command: free splitted command
- */
-
-void
-plugin_api_string_free_splitted_command (struct t_weechat_plugin *plugin,
- char **splitted_command)
-{
- /* make C compiler happy */
- (void) plugin;
-
- string_free_splitted_command (splitted_command);
-}
-
-/*
- * plugin_api_utf8_has_8bits: return 1 if string has 8-bits chars, 0 if only
- * 7-bits chars
- */
-
-int
-plugin_api_utf8_has_8bits (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_has_8bits (string);
-}
-
-/*
- * plugin_api_utf8_is_valid: return 1 if UTF-8 string is valid, 0 otherwise
- * if error is not NULL, it's set with first non
- * valid UTF-8 char in string, if any
- */
-
-int
-plugin_api_utf8_is_valid (struct t_weechat_plugin *plugin, char *string,
- char **error)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_is_valid (string, error);
-}
-
-/*
- * plugin_api_utf8_normalize: normalize UTF-8 string: remove non UTF-8 chars
- * and replace them by a char
- */
-
-void
-plugin_api_utf8_normalize (struct t_weechat_plugin *plugin, char *string,
- char replacement)
-{
- /* make C compiler happy */
- (void) plugin;
-
- utf8_normalize (string, replacement);
-}
-
-/*
- * plugin_api_utf8_prev_char: return previous UTF-8 char in a string
- */
-
-char *
-plugin_api_utf8_prev_char (struct t_weechat_plugin *plugin, char *string_start,
- char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_prev_char (string_start, string);
-}
-
-/*
- * plugin_api_utf8_next_char: return next UTF-8 char in a string
- */
-
-char *
-plugin_api_utf8_next_char (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_next_char (string);
-}
-
-/*
- * plugin_api_utf8_char_size: return UTF-8 char size (in bytes)
- */
-
-int
-plugin_api_utf8_char_size (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_char_size (string);
-}
-
-/*
- * plugin_api_utf8_strlen: return length of an UTF-8 string (<= strlen(string))
- */
-
-int
-plugin_api_utf8_strlen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strlen (string);
-}
-
-/*
- * plugin_api_utf8_strnlen: return length of an UTF-8 string, for N bytes max
- * in string
- */
-
-int
-plugin_api_utf8_strnlen (struct t_weechat_plugin *plugin, char *string,
- int bytes)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strnlen (string, bytes);
-}
-
-/*
- * plugin_api_utf8_strlen_screen: return number of chars needed on screen to
- * display UTF-8 string
- */
-
-int
-plugin_api_utf8_strlen_screen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strlen_screen (string);
-}
-
-/*
- * plugin_api_utf8_charcasecmp: compare two utf8 chars (case is ignored)
- */
-
-int
-plugin_api_utf8_charcasecmp (struct t_weechat_plugin *plugin, char *string1,
- char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_charcasecmp (string1, string2);
-}
-
-/*
- * plugin_api_utf8_char_size_screen: return number of chars needed on screen
- * to display UTF-8 char
- */
-
-int
-plugin_api_utf8_char_size_screen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_char_size_screen (string);
-}
-
-/*
- * plugin_api_utf8_add_offset: moves forward N chars in an UTF-8 string
- */
-
-char *
-plugin_api_utf8_add_offset (struct t_weechat_plugin *plugin, char *string,
- int offset)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_add_offset (string, offset);
-}
-
-/*
- * plugin_api_utf8_real_pos: get real position in UTF-8
- * for example: ("aébc", 2) returns 3
- */
-
-int
-plugin_api_utf8_real_pos (struct t_weechat_plugin *plugin, char *string,
- int pos)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_real_pos (string, pos);
-}
-
-/*
- * plugin_api_utf8_pos: get position in UTF-8
- * for example: ("aébc", 3) returns 2
- */
-
-int
-plugin_api_utf8_pos (struct t_weechat_plugin *plugin, char *string,
- int real_pos)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_real_pos (string, real_pos);
-}
-
-/*
* plugin_api_mkdir_home: create a directory in WeeChat home
*/
int
-plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory,
- int mode)
+plugin_api_mkdir_home (char *directory, int mode)
{
char *dir_name;
int dir_length;
- /* make C compiler happy */
- (void) plugin;
-
if (!directory)
return 0;
/* build directory, adding WeeChat home */
dir_length = strlen (weechat_home) + strlen (directory) + 2;
dir_name =
- (char *) malloc (dir_length * sizeof (char));
+ (char *)malloc (dir_length * sizeof (char));
if (!dir_name)
return 0;
@@ -493,12 +122,8 @@ plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory,
*/
int
-plugin_api_mkdir (struct t_weechat_plugin *plugin, char *directory,
- int mode)
+plugin_api_mkdir (char *directory, int mode)
{
- /* make C compiler happy */
- (void) plugin;
-
if (!directory)
return 0;
@@ -512,611 +137,46 @@ plugin_api_mkdir (struct t_weechat_plugin *plugin, char *directory,
}
/*
- * plugin_api_exec_on_files: find files in a directory and execute a
- * function on each file
- */
-
-void
-plugin_api_exec_on_files (struct t_weechat_plugin *plugin, char *directory,
- int (*callback)(char *))
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (directory && callback)
- util_exec_on_files (directory, callback);
-}
-
-/*
- * 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
- */
-
-struct t_config_file *
-plugin_api_config_new (struct t_weechat_plugin *plugin, char *filename)
-{
- return config_file_new (plugin, filename);
-}
-
-/*
- * plugin_api_config_new_section: create new section in a config
- */
-
-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 *, char *),
- void (*callback_write_default)(void *, char *))
-{
- 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;
-}
-
-/*
- * plugin_api_config_new_option: create new option in a config section
- */
-
-struct t_config_option *
-plugin_api_config_new_option (struct t_weechat_plugin *plugin,
- void *section, char *name, char *type,
- char *description, char *string_values,
- int min, int max, char *default_value,
- void (*callback_change)())
-
-{
- 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 (plugin && config_file_option_valid_for_plugin (plugin, option))
- {
- 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;
-
- if (config_file_string_to_boolean (string) == CONFIG_OPTION_BOOLEAN)
- return CONFIG_BOOLEAN_TRUE;
- else
- return CONFIG_BOOLEAN_FALSE;
-}
-
-/*
- * plugin_api_config_boolean: return boolean value of an option
- */
-
-char
-plugin_api_config_boolean (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_BOOLEAN))
- return CONFIG_BOOLEAN((struct t_config_option *)option);
- else
- return 0;
-}
-
-/*
- * plugin_api_config_integer: return integer value of an option
- */
-
-int
-plugin_api_config_integer (struct t_weechat_plugin *plugin, void *option)
-{
- 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;
-}
-
-/*
- * plugin_api_config_string: return string value of an option
- */
-
-char *
-plugin_api_config_string (struct t_weechat_plugin *plugin, void *option)
-{
- 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;
-}
-
-/*
- * plugin_api_config_color: return color value of an option
- */
-
-int
-plugin_api_config_color (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_COLOR))
- return CONFIG_COLOR((struct t_config_option *)option);
- else
- return 0;
-}
-
-/*
- * plugin_api_config_read: read a configuration file
- */
-
-int
-plugin_api_config_read (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_read ((struct t_config_file *)config_file);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_reload: reload a configuration file
- */
-
-int
-plugin_api_config_reload (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_reload ((struct t_config_file *)config_file);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_write: write a configuration file
- */
-
-int
-plugin_api_config_write (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_write ((struct t_config_file *)config_file, 0);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_write_line: write a line in configuration file
- */
-
-void
-plugin_api_config_write_line (struct t_weechat_plugin *plugin,
- void *config_file, char *option_name,
- 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, buf);
- }
-}
-
-/*
- * plugin_api_config_free: free a configuration file
- */
-
-void
-plugin_api_config_free (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- config_file_free ((struct t_config_file *)config_file);
-}
-
-/*
- * plugin_api_get_config_str_value: return string value for any option
- * This function should never be called directly
- * (only used by weechat_get_config)
- */
-
-char *
-plugin_api_get_config_str_value (struct t_config_option *option)
-{
- char buf_temp[1024], *color_name;
-
- switch (option->type)
- {
- case CONFIG_OPTION_BOOLEAN:
- return (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
- strdup ("on") : strdup ("off");
- case CONFIG_OPTION_INTEGER:
- if (option->string_values)
- snprintf (buf_temp, sizeof (buf_temp), "%s",
- option->string_values[CONFIG_INTEGER(option)]);
- else
- snprintf (buf_temp, sizeof (buf_temp), "%d",
- CONFIG_INTEGER(option));
- return strdup (buf_temp);
- case CONFIG_OPTION_STRING:
- return strdup (CONFIG_STRING(option));
- case CONFIG_OPTION_COLOR:
- color_name = gui_color_get_name (CONFIG_INTEGER(option));
- return (color_name) ? strdup (color_name) : strdup ("");
- }
-
- /* should never be executed! */
- return NULL;
-}
-
-/*
- * plugin_api_config_get: get value of a WeeChat config option
+ * plugin_api_config_get_weechat: get value of a WeeChat config option
*/
struct t_config_option *
-plugin_api_config_get (struct t_weechat_plugin *plugin, char *option_name)
+plugin_api_config_get_weechat (char *option_name)
{
- /* make C compiler happy */
- (void) plugin;
-
return config_file_search_option (weechat_config_file, NULL,
option_name);
}
/*
- * plugin_api_config_set: set value of a config option
- */
-
-int
-plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
- char *value)
-{
- struct t_config_option *ptr_option;
- int rc;
-
- /* make C compiler happy */
- (void) plugin;
-
- if (!option_name || !value)
- return 0;
-
- /* search and set WeeChat config option if found */
- ptr_option = config_file_search_option (weechat_config_file, NULL,
- option_name);
- if (ptr_option)
- {
- rc = config_file_option_set (ptr_option, value);
- if ((rc == 2) && (ptr_option->callback_change))
- (void) (ptr_option->callback_change) ();
- if (rc == 0)
- return 0;
- return 1;
- }
-
- /* failed to set config option */
- return 0;
-}
-
-/*
- * plugin_api_plugin_config_get: get value of a plugin config option
+ * plugin_api_config_get_plugin: get value of a plugin config option
*/
char *
-plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option_name)
+plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
+ char *option_name)
{
struct t_config_option *ptr_option;
- if (!option_name)
+ if (!plugin || !option_name)
return NULL;
ptr_option = plugin_config_search (plugin->name, option_name);
if (ptr_option)
- return (ptr_option->value) ? strdup (ptr_option->value) : NULL;
+ return ptr_option->value;
/* option not found */
return NULL;
}
/*
- * plugin_api_plugin_config_set: set value of a plugin config option
+ * plugin_api_config_set_plugin: set value of a plugin config option
*/
int
-plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
+plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
char *option_name, char *value)
{
- if (!option_name)
+ if (!plugin || !option_name)
return 0;
if (plugin_config_set (plugin->name, option_name, value))
@@ -1130,9 +190,9 @@ plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
*/
char *
-plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
+plugin_api_prefix (char *prefix)
{
- if (!plugin || !prefix)
+ if (!prefix)
return gui_chat_prefix_empty;
if (string_strcasecmp (prefix, "info") == 0)
@@ -1156,11 +216,11 @@ plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
*/
char *
-plugin_api_color (struct t_weechat_plugin *plugin, char *color_name)
+plugin_api_color (char *color_name)
{
int num_color;
- if (!plugin || !color_name)
+ if (!color_name)
return GUI_NO_COLOR;
num_color = gui_color_search_config (color_name);
@@ -1171,75 +231,11 @@ plugin_api_color (struct t_weechat_plugin *plugin, char *color_name)
}
/*
- * plugin_api_printf: print a message on a buffer
- */
-
-void
-plugin_api_printf (struct t_weechat_plugin *plugin,
- void *buffer, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format
- || !gui_buffer_valid ((struct t_gui_buffer *)buffer))
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- gui_chat_printf ((struct t_gui_buffer *)buffer, "%s", buf);
-}
-
-/*
- * plugin_api_printf_date: print a message on a buffer with a specific date
- */
-
-void
-plugin_api_printf_date (struct t_weechat_plugin *plugin,
- void *buffer, time_t date, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format
- || !gui_buffer_valid ((struct t_gui_buffer *)buffer))
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- gui_chat_printf_date ((struct t_gui_buffer *)buffer, date, buf);
-}
-
-/*
- * plugin_api_log_printf: print a message in WeeChat log file
- */
-
-void
-plugin_api_log_printf (struct t_weechat_plugin *plugin, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format)
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- log_printf ("%s", buf);
-}
-
-/*
* plugin_api_infobar_printf: print a message in infobar
*/
void
-plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
+plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int delay,
char *color_name, char *format, ...)
{
va_list argptr;
@@ -1247,7 +243,7 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
char *buf2;
int num_color;
- if (!plugin || (time_displayed < 0) || !format)
+ if (!plugin || !format)
return;
va_start (argptr, format);
@@ -1264,8 +260,7 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
else
num_color = GUI_COLOR_INFOBAR;
- gui_infobar_printf (time_displayed,
- num_color,
+ gui_infobar_printf (delay, num_color,
"%s",
(buf2) ? buf2 : buf);
if (buf2)
@@ -1277,11 +272,8 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
*/
void
-plugin_api_infobar_remove (struct t_weechat_plugin *plugin, int how_many)
+plugin_api_infobar_remove (int how_many)
{
- if (!plugin)
- return;
-
if (how_many <= 0)
gui_infobar_remove_all ();
else
@@ -1292,294 +284,7 @@ plugin_api_infobar_remove (struct t_weechat_plugin *plugin, int how_many)
how_many--;
}
}
- //gui_infobar_draw (gui_current_window->buffer, 1);
-}
-
-/*
- * plugin_api_hook_command: hook a command
- */
-
-struct t_hook *
-plugin_api_hook_command (struct t_weechat_plugin *plugin, char *command,
- char *description, char *args,
- char *args_desc, char *completion,
- int (*callback)(void *, void *, int, char **, char **),
- void *data)
-{
- if (plugin && callback)
- return hook_command (plugin, command, description, args,
- args_desc, completion,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_timer: hook a timer
- */
-
-struct t_hook *
-plugin_api_hook_timer (struct t_weechat_plugin *plugin, long interval,
- int align_second, int max_calls,
- int (*callback)(void *), void *data)
-{
- if (plugin && (interval > 0) && callback)
- return hook_timer (plugin, interval, align_second, max_calls,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_fd: hook a file descriptor
- */
-
-struct t_hook *
-plugin_api_hook_fd (struct t_weechat_plugin *plugin, int fd,
- int flag_read, int flag_write, int flag_exception,
- int (*callback)(void *), void *data)
-{
- int flags;
-
- if (plugin && (fd >= 0) && callback)
- {
- flags = 0;
- if (flag_read)
- flags |= HOOK_FD_FLAG_READ;
- if (flag_write)
- flags |= HOOK_FD_FLAG_WRITE;
- if (flag_exception)
- flags |= HOOK_FD_FLAG_EXCEPTION;
- return hook_fd (plugin, fd, flags, callback, data);
- }
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_print: hook a printed message
- */
-
-struct t_hook *
-plugin_api_hook_print (struct t_weechat_plugin *plugin, void *buffer,
- char *message, int strip_colors,
- int (*callback)(void *, void *, time_t, char *, char *),
- void *data)
-{
- if (plugin && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && callback)
- return hook_print (plugin, buffer, message, strip_colors,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_signal: hook a signal
- */
-
-struct t_hook *
-plugin_api_hook_signal (struct t_weechat_plugin *plugin, char *signal,
- int (*callback)(void *, char *, void *),
- void *data)
-{
- if (plugin && signal && signal[0] && callback)
- return hook_signal (plugin, signal, callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_signal_send: send a signal
- */
-
-void
-plugin_api_hook_signal_send (struct t_weechat_plugin *plugin, char *signal,
- void *pointer)
-{
- if (plugin && signal && signal[0])
- hook_signal_exec (signal, pointer);
-}
-
-/*
- * plugin_api_hook_config: hook a config option
- */
-
-struct t_hook *
-plugin_api_hook_config (struct t_weechat_plugin *plugin, char *config_type,
- char *config_option,
- int (*callback)(void *, char *, char *, char *),
- void *data)
-{
- if (plugin && callback)
- return hook_config (plugin, config_type, config_option,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_completion: hook a completion
- */
-
-struct t_hook *
-plugin_api_hook_completion (struct t_weechat_plugin *plugin, char *completion,
- int (*callback)(void *, char *, void *, void *),
- void *data)
-{
- if (plugin && callback)
- return hook_completion (plugin, completion, callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_unhook: unhook something
- */
-
-void
-plugin_api_unhook (struct t_weechat_plugin *plugin, void *hook)
-{
- if (plugin && hook
- && (hook_valid_for_plugin (plugin, (struct t_hook *)hook)))
- unhook ((struct t_hook *)hook);
-}
-
-/*
- * plugin_api_unhook_all: unhook all for a plugin
- */
-
-void
-plugin_api_unhook_all (struct t_weechat_plugin *plugin)
-{
- if (plugin)
- unhook_all (plugin);
-}
-
-/*
- * plugin_api_buffer_new: create a new buffer
- */
-
-struct t_gui_buffer *
-plugin_api_buffer_new (struct t_weechat_plugin *plugin, char *category,
- char *name,
- void (*input_data_cb)(struct t_gui_buffer *, char *))
-{
- if (plugin && name && name[0])
- return gui_buffer_new (plugin, category, name, input_data_cb);
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_search: search a buffer
- */
-
-struct t_gui_buffer *
-plugin_api_buffer_search (struct t_weechat_plugin *plugin, char *category,
- char *name)
-{
- struct t_gui_buffer *ptr_buffer;
-
- if (plugin)
- {
- ptr_buffer = gui_buffer_search_by_category_name (category, name);
- if (ptr_buffer)
- return ptr_buffer;
- return gui_current_window->buffer;
- }
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_close: close a buffer
- */
-
-void
-plugin_api_buffer_close (struct t_weechat_plugin *plugin, void *buffer)
-{
- if (plugin && buffer
- && gui_buffer_valid ((struct t_gui_buffer *)buffer))
- gui_buffer_free ((struct t_gui_buffer *)buffer, 1);
-}
-
-/*
- * plugin_api_buffer_get: get a buffer property
- */
-
-void *
-plugin_api_buffer_get (struct t_weechat_plugin *plugin, void *buffer,
- char *property)
-{
- if (plugin && buffer && property && property[0])
- return gui_buffer_get ((struct t_gui_buffer *)buffer, property);
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_set: set a buffer property
- */
-
-void
-plugin_api_buffer_set (struct t_weechat_plugin *plugin, void *buffer,
- char *property, char *value)
-{
- if (plugin && buffer && property && property[0])
- gui_buffer_set ((struct t_gui_buffer *)buffer, property, value);
-}
-
-/*
- * plugin_api_buffer_nick_add: add a nick to a buffer nicklist
- */
-
-void
-plugin_api_buffer_nick_add (struct t_weechat_plugin *plugin, void *buffer,
- char *nick, int sort_index, char *color_nick,
- char prefix, char *color_prefix)
-{
- int num_color_nick, num_color_prefix;
- struct t_gui_nick *ptr_nick;
-
- if (plugin && buffer && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && nick && nick[0])
- {
- num_color_nick = gui_color_search_config (color_nick);
- if (num_color_nick < 0)
- num_color_nick = GUI_COLOR_NICKLIST;
-
- num_color_prefix = gui_color_search_config (color_prefix);
- if (num_color_prefix < 0)
- num_color_prefix = GUI_COLOR_NICKLIST;
-
- ptr_nick = gui_nicklist_search ((struct t_gui_buffer *)buffer, nick);
- if (ptr_nick)
- gui_nicklist_update ((struct t_gui_buffer *)buffer,
- ptr_nick, nick, sort_index, num_color_nick,
- prefix, num_color_prefix);
- else
- gui_nicklist_add ((struct t_gui_buffer *)buffer,
- nick, sort_index, num_color_nick,
- prefix, num_color_prefix);
- }
-}
-
-/*
- * plugin_api_buffer_nick_remove: remove a nick from a buffer nicklist
- */
-
-void
-plugin_api_buffer_nick_remove (struct t_weechat_plugin *plugin, void *buffer,
- char *nick)
-{
- if (plugin && buffer && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && nick && nick[0])
- {
- if (gui_nicklist_remove ((struct t_gui_buffer *)buffer, nick))
- gui_nicklist_draw ((struct t_gui_buffer *)buffer, 0);
- //gui_nicklist_remove ((struct t_gui_buffer *)buffer, nick);
- }
+ gui_infobar_draw (gui_current_window->buffer, 1);
}
/*
@@ -1587,8 +292,8 @@ plugin_api_buffer_nick_remove (struct t_weechat_plugin *plugin, void *buffer,
*/
void
-plugin_api_command (struct t_weechat_plugin *plugin, void *buffer,
- char *command)
+plugin_api_command (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command)
{
char *command2;
@@ -1612,8 +317,6 @@ plugin_api_command (struct t_weechat_plugin *plugin, void *buffer,
char *
plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
{
- //t_irc_server *ptr_server;
- //t_irc_channel *ptr_channel;
time_t inactivity;
char *return_str;
@@ -1656,7 +359,7 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
inactivity = 0;
else
inactivity = time (NULL) - gui_keyboard_last_activity_time;
- return_str = (char *) malloc (32);
+ return_str = (char *)malloc (32);
if (!return_str)
return NULL;
snprintf (return_str, 32, "%ld", (long int)inactivity);
@@ -1684,7 +387,7 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
{
if (gui_current_window->buffer->input)
{
- return_str = (char *) malloc (32);
+ return_str = (char *)malloc (32);
if (!return_str)
return NULL;
snprintf (return_str, 32, "%d",
@@ -1695,43 +398,6 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
return strdup ("");
}
- /* below are infos that need server to return value */
-
- /*plugin_find_server_channel (server, NULL, &ptr_server, &ptr_channel);
-
- if (string_strcasecmp (info, "nick") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->nick)
- return strdup (ptr_server->nick);
- }
- else if (string_strcasecmp (info, "channel") == 0)
- {
- if (GUI_BUFFER_IS_CHANNEL(gui_current_window->buffer)
- || GUI_BUFFER_IS_PRIVATE(gui_current_window->buffer))
- return strdup (GUI_CHANNEL(gui_current_window->buffer)->name);
- }
- else if (string_strcasecmp (info, "server") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->name)
- return strdup (ptr_server->name);
- }
- else if (string_strcasecmp (info, "type") == 0)
- {
- return_str = (char *) malloc (32);
- if (!return_str)
- return NULL;
- snprintf (return_str, 32, "%d",
- gui_current_window->buffer->type);
- return return_str;
- }
- else if (string_strcasecmp (info, "away") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->is_away)
- return strdup ("1");
- else
- return strdup ("0");
- }*/
-
/* info not found */
return NULL;
}
@@ -1815,18 +481,17 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
/*
* 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()
+ * by this function after use, with weechat_infolist_free()
*/
struct t_plugin_infolist *
-plugin_api_infolist_get (struct t_weechat_plugin *plugin, char *name,
- void *pointer)
+plugin_api_infolist_get (char *name, void *pointer)
{
struct t_plugin_infolist *ptr_infolist;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
- if (!plugin || !name || !name[0])
+ if (!name || !name[0])
return NULL;
if (string_strcasecmp (name, "buffer") == 0)
@@ -1904,9 +569,9 @@ plugin_api_infolist_get (struct t_weechat_plugin *plugin, char *name,
*/
int
-plugin_api_infolist_next (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_next (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return 0;
return (plugin_infolist_next_item (infolist)) ? 1 : 0;
@@ -1919,9 +584,9 @@ plugin_api_infolist_next (struct t_weechat_plugin *plugin, void *infolist)
*/
int
-plugin_api_infolist_prev (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return 0;
return (plugin_infolist_prev_item (infolist)) ? 1 : 0;
@@ -1932,9 +597,9 @@ plugin_api_infolist_prev (struct t_weechat_plugin *plugin, void *infolist)
*/
char *
-plugin_api_infolist_fields (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return NULL;
return plugin_infolist_get_fields (infolist);
@@ -1945,10 +610,9 @@ plugin_api_infolist_fields (struct t_weechat_plugin *plugin, void *infolist)
*/
int
-plugin_api_infolist_integer (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_integer (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
@@ -1960,10 +624,9 @@ plugin_api_infolist_integer (struct t_weechat_plugin *plugin, void *infolist,
*/
char *
-plugin_api_infolist_string (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_string (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
@@ -1975,10 +638,9 @@ plugin_api_infolist_string (struct t_weechat_plugin *plugin, void *infolist,
*/
void *
-plugin_api_infolist_pointer (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
@@ -1990,10 +652,9 @@ plugin_api_infolist_pointer (struct t_weechat_plugin *plugin, void *infolist,
*/
time_t
-plugin_api_infolist_time (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_time (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
@@ -2005,43 +666,8 @@ plugin_api_infolist_time (struct t_weechat_plugin *plugin, void *infolist,
*/
void
-plugin_api_infolist_free (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_free (struct t_plugin_infolist *infolist)
{
- if (plugin && infolist && plugin_infolist_valid (infolist))
+ if (infolist && plugin_infolist_valid (infolist))
plugin_infolist_free (infolist);
}
-
-/*
- * plugin_api_log: add a message in buffer log file
- */
-
-void
-plugin_api_log (struct t_weechat_plugin *plugin,
- char *server, char *channel, char *message, ...)
-{
- (void) plugin;
- (void) server;
- (void) channel;
- (void) message;
-
- /*t_gui_buffer *ptr_buffer;
- va_list argptr;
- static char buf[8192];
- char *buf2;
-
- if (!plugin || !message)
- return;
-
- ptr_buffer = gui_buffer_search (server, channel);
- if (ptr_buffer)
- {
- va_start (argptr, message);
- vsnprintf (buf, sizeof (buf) - 1, message, argptr);
- va_end (argptr);
-
- buf2 = string_iconv_to_internal (plugin->charset, buf);
- gui_log_write_line (ptr_buffer, (buf2) ? buf2 : buf);
- if (buf2)
- free (buf2);
- }*/
-}
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index ef1c31553..7f9fb66c7 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -21,193 +21,50 @@
#define __WEECHAT_PLUGIN_API_H 1
/* strings */
-extern void plugin_api_charset_set (struct t_weechat_plugin *, char *);
-extern char *plugin_api_iconv_to_internal (struct t_weechat_plugin *, char *,
- char *);
-extern char *plugin_api_iconv_from_internal (struct t_weechat_plugin *, char *,
- char *);
-extern char *plugin_api_gettext (struct t_weechat_plugin *, char *);
-extern char *plugin_api_ngettext (struct t_weechat_plugin *, char *, char *,
- int);
-extern int plugin_api_strcasecmp (struct t_weechat_plugin *,char *, char *);
-extern int plugin_api_strncasecmp (struct t_weechat_plugin *,char *, char *,
- int);
-extern char *plugin_api_strcasestr (struct t_weechat_plugin *,char *, char *);
-extern char *plugin_api_string_replace (struct t_weechat_plugin *,char *,
- char *, char *);
-extern char **plugin_api_string_explode (struct t_weechat_plugin *, char *,
- char *, int, int, int *);
-extern void plugin_api_string_free_exploded (struct t_weechat_plugin *,
- char **);
-extern char **plugin_api_string_split_command (struct t_weechat_plugin *,
- char *, char);
-extern void plugin_api_string_free_splitted_command (struct t_weechat_plugin *,
- char **);
-
-/* UTF-8 strings */
-extern int plugin_api_utf8_has_8bits (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_is_valid (struct t_weechat_plugin *, char *, char **);
-extern void plugin_api_utf8_normalize (struct t_weechat_plugin *, char *, char);
-extern char *plugin_api_utf8_prev_char (struct t_weechat_plugin *, char *, char *);
-extern char *plugin_api_utf8_next_char (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_char_size (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_strlen (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_strnlen (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_strlen_screen (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_charcasecmp (struct t_weechat_plugin *, char *, char *);
-extern int plugin_api_utf8_char_size_screen (struct t_weechat_plugin *, char *);
-extern char *plugin_api_utf8_add_offset (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_real_pos (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_pos (struct t_weechat_plugin *, char *, int);
+extern void plugin_api_charset_set (struct t_weechat_plugin *plugin,
+ char *charset);
+extern char *plugin_api_gettext (char *string);
+extern char *plugin_api_ngettext (char *single, char *plural, int count);
/* directories */
-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 *);
+extern int plugin_api_mkdir_home (char *directory, int mode);
+extern int plugin_api_mkdir (char *directory, int mode);
/* 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 *, 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 *);
-extern int plugin_api_config_color (struct t_weechat_plugin *, void *);
-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 *, ...);
-extern void plugin_api_config_free (struct t_weechat_plugin *, void *);
-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 *);
+extern struct t_config_option *plugin_api_config_get_weechat (char *option_name);
+extern char *plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
+ char *option_name);
+extern int plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
+ char *option_name, char *value);
/* display */
-extern char *plugin_api_prefix (struct t_weechat_plugin *, char *);
-extern char *plugin_api_color (struct t_weechat_plugin *, char *);
-extern void plugin_api_printf (struct t_weechat_plugin *, void *,
- char *, ...);
-extern void plugin_api_printf_date (struct t_weechat_plugin *, void *,
- time_t, char *, ...);
-extern void plugin_api_log_printf (struct t_weechat_plugin *, char *, ...);
-extern void plugin_api_infobar_printf (struct t_weechat_plugin *, int, char *,
- char *, ...);
-extern void plugin_api_infobar_remove (struct t_weechat_plugin *, int);
-
-/* hooks */
-extern struct t_hook *plugin_api_hook_command (struct t_weechat_plugin *,
- char *, char *, char *, char *,
- char *,
- int (*)(void *, void *, int, char **, char **),
- void *);
-extern struct t_hook *plugin_api_hook_timer (struct t_weechat_plugin *,
- long, int, int,
- int (*)(void *), void *);
-extern struct t_hook *plugin_api_hook_fd (struct t_weechat_plugin *,
- int, int, int, int,
- int (*)(void *), void *);
-extern struct t_hook *plugin_api_hook_print (struct t_weechat_plugin *,
- void *, char *, int,
- int (*)(void *, void *, time_t, char *, char *),
- void *);
-extern struct t_hook *plugin_api_hook_signal (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *),
- void *);
-extern void plugin_api_hook_signal_send (struct t_weechat_plugin *, char *,
- void *);
-extern struct t_hook *plugin_api_hook_config (struct t_weechat_plugin *,
- char *, char *,
- int (*)(void *, char *, char *, char *),
- void *);
-extern struct t_hook *plugin_api_hook_completion (struct t_weechat_plugin *,
- char *,
- int (*)(void *, char *, void *, void *),
- void *);
-extern void plugin_api_unhook (struct t_weechat_plugin *, void *);
-extern void plugin_api_unhook_all (struct t_weechat_plugin *);
-
-/* buffers */
-extern struct t_gui_buffer *plugin_api_buffer_new (struct t_weechat_plugin *,
- char *, char *,
- void (*)(struct t_gui_buffer *, char *));
-extern struct t_gui_buffer *plugin_api_buffer_search (struct t_weechat_plugin *,
- char *, char *);
-extern void plugin_api_buffer_close (struct t_weechat_plugin *, void *);
-extern void *plugin_api_buffer_get (struct t_weechat_plugin *, void *, char *);
-extern void plugin_api_buffer_set (struct t_weechat_plugin *, void *, char *,
- char *);
-extern void plugin_api_buffer_nick_add (struct t_weechat_plugin *, void *,
- char *, int, char *, char, char *);
-extern void plugin_api_buffer_nick_remove (struct t_weechat_plugin *, char *);
+extern char *plugin_api_prefix (char *prefix);
+extern char *plugin_api_color (char *color_name);
+extern void plugin_api_infobar_printf (int delay, char *color_name,
+ char *format, ...);
+extern void plugin_api_infobar_remove (int how_many);
/* command */
-extern void plugin_api_command (struct t_weechat_plugin *, void *, char *);
+extern void plugin_api_command (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command);
/* infos */
-extern char *plugin_api_info_get (struct t_weechat_plugin *, char *);
+extern char *plugin_api_info_get (struct t_weechat_plugin *plugin, char *info);
/* 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 *,
- char *, ...);
+extern struct t_plugin_infolist *plugin_api_infolist_get (char *name,
+ void *pointer);
+extern int plugin_api_infolist_next (struct t_plugin_infolist *infolist);
+extern int plugin_api_infolist_prev (struct t_plugin_infolist *infolist);
+extern char *plugin_api_infolist_fields (struct t_plugin_infolist *infolist);
+extern int plugin_api_infolist_integer (struct t_plugin_infolist *infolist,
+ char *var);
+extern char *plugin_api_infolist_string (struct t_plugin_infolist *infolist,
+ char *var);
+extern void *plugin_api_infolist_pointer (struct t_plugin_infolist *infolist,
+ char *var);
+extern time_t plugin_api_infolist_time (struct t_plugin_infolist *infolist,
+ char *var);
+extern void plugin_api_infolist_free (struct t_plugin_infolist *infolist);
#endif /* plugin-api.h */
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c
index 5ff41be75..3694aa558 100644
--- a/src/plugins/plugin-config.c
+++ b/src/plugins/plugin-config.c
@@ -289,7 +289,8 @@ plugin_config_free_all ()
*/
void
-plugin_config_read_option (void *config_file, char *option_name, char *value)
+plugin_config_read_option (struct t_config_file *config_file,
+ char *option_name, char *value)
{
char *value2;
@@ -311,7 +312,8 @@ plugin_config_read_option (void *config_file, char *option_name, char *value)
*/
void
-plugin_config_write_options (void *config_file, char *section_name)
+plugin_config_write_options (struct t_config_file *config_file,
+ char *section_name)
{
struct t_config_option *ptr_option;
@@ -383,5 +385,5 @@ int
plugin_config_write ()
{
log_printf (_("Saving plugins configuration to disk"));
- return config_file_write (plugin_config, 0);
+ return config_file_write (plugin_config);
}
diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h
index 24e67101d..bb9a99b97 100644
--- a/src/plugins/plugin-config.h
+++ b/src/plugins/plugin-config.h
@@ -25,10 +25,12 @@
extern struct t_config_file *plugin_config;
extern struct t_config_option *plugin_options;
-extern struct t_config_option *plugin_config_search_internal (char *);
-extern struct t_config_option *plugin_config_search (char *, char *);
-extern int plugin_config_set_internal (char *, char *);
-extern int plugin_config_set (char *, char *, char *);
+extern struct t_config_option *plugin_config_search_internal (char *option_name);
+extern struct t_config_option *plugin_config_search (char *plugin_name,
+ char *option_name);
+extern int plugin_config_set_internal (char *option, char *value);
+extern int plugin_config_set (char *plugin_name, char *option_name,
+ char *value);
extern void plugin_config_init ();
extern int plugin_config_read ();
extern int plugin_config_reload ();
diff --git a/src/plugins/plugin-infolist.c b/src/plugins/plugin-infolist.c
index a12d4c379..59d6e1481 100644
--- a/src/plugins/plugin-infolist.c
+++ b/src/plugins/plugin-infolist.c
@@ -98,7 +98,7 @@ plugin_infolist_new_item (struct t_plugin_infolist *list)
struct t_plugin_infolist_var *
plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
- char *name, int value)
+ char *name, int value)
{
struct t_plugin_infolist_var *new_var;
@@ -131,7 +131,7 @@ plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
- char *name, char *value)
+ char *name, char *value)
{
struct t_plugin_infolist_var *new_var;
@@ -163,7 +163,7 @@ plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
- char *name, void *pointer)
+ char *name, void *pointer)
{
struct t_plugin_infolist_var *new_var;
@@ -195,7 +195,7 @@ plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
- char *name, time_t time)
+ char *name, time_t time)
{
struct t_plugin_infolist_var *new_var;
@@ -447,7 +447,7 @@ plugin_infolist_get_time (struct t_plugin_infolist *list, char *var)
void
plugin_infolist_var_free (struct t_plugin_infolist_item *item,
- struct t_plugin_infolist_var *var)
+ struct t_plugin_infolist_var *var)
{
struct t_plugin_infolist_var *new_vars;
@@ -485,7 +485,7 @@ plugin_infolist_var_free (struct t_plugin_infolist_item *item,
void
plugin_infolist_item_free (struct t_plugin_infolist *list,
- struct t_plugin_infolist_item *item)
+ struct t_plugin_infolist_item *item)
{
struct t_plugin_infolist_item *new_items;
diff --git a/src/plugins/plugin-infolist.h b/src/plugins/plugin-infolist.h
index 567c8b9b0..3a0a2620e 100644
--- a/src/plugins/plugin-infolist.h
+++ b/src/plugins/plugin-infolist.h
@@ -51,11 +51,11 @@ struct t_plugin_infolist_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 */
+ 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 */
@@ -66,24 +66,32 @@ 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 struct t_plugin_infolist_item *plugin_infolist_new_item (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
+ char *name,
+ int value);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
+ char *name,
+ char *value);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
+ char *name,
+ void *pointer);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
+ char *name,
+ time_t time);
+extern int plugin_infolist_valid (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_item *plugin_infolist_next_item (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_item *plugin_infolist_prev_item (struct t_plugin_infolist *list);
+extern char *plugin_infolist_get_fields (struct t_plugin_infolist *list);
+extern int plugin_infolist_get_integer (struct t_plugin_infolist *list,
+ char *var);
+extern char *plugin_infolist_get_string (struct t_plugin_infolist *list,
+ char *var);
+extern void *plugin_infolist_get_pointer (struct t_plugin_infolist *list,
+ char *var);
+extern time_t plugin_infolist_get_time (struct t_plugin_infolist *list,
+ char *var);
+extern void plugin_infolist_free (struct t_plugin_infolist *list);
extern void plugin_infolist_print_log ();
#endif /* plugin-infolist.h */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 9ad3cce15..330d1cbda 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -36,10 +36,14 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-list.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
#include "../core/wee-util.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-nicklist.h"
#include "plugin.h"
#include "plugin-api.h"
#include "plugin-config.h"
@@ -51,37 +55,6 @@ struct t_weechat_plugin *last_weechat_plugin = NULL;
/*
- * plugin_exec_on_files: find files in a directory and execute a
- * function on each file
- */
-
-void
-plugin_exec_on_files (struct t_weechat_plugin *plugin, char *directory,
- int (*callback)(struct t_weechat_plugin *, char *))
-{
- char complete_filename[1024];
- DIR *dir;
- struct dirent *entry;
- struct stat statbuf;
-
- dir = opendir (directory);
- if (dir)
- {
- while ((entry = readdir (dir)))
- {
- snprintf (complete_filename, sizeof (complete_filename) - 1,
- "%s/%s", directory, entry->d_name);
- lstat (complete_filename, &statbuf);
- if (!S_ISDIR(statbuf.st_mode))
- {
- (int) (*callback) (plugin, complete_filename);
- }
- }
- closedir (dir);
- }
-}
-
-/*
* plugin_search: search a plugin by name
*/
@@ -224,99 +197,100 @@ plugin_load (char *filename)
/* functions */
new_plugin->charset_set = &plugin_api_charset_set;
- new_plugin->iconv_to_internal = &plugin_api_iconv_to_internal;
- new_plugin->iconv_from_internal = &plugin_api_iconv_from_internal;
+ new_plugin->iconv_to_internal = &string_iconv_to_internal;
+ new_plugin->iconv_from_internal = &string_iconv_from_internal;
new_plugin->gettext = &plugin_api_gettext;
new_plugin->ngettext = &plugin_api_ngettext;
- new_plugin->strcasecmp = &plugin_api_strcasecmp;
- new_plugin->strncasecmp = &plugin_api_strncasecmp;
- new_plugin->strcasestr = &plugin_api_strcasestr;
- new_plugin->string_replace = &plugin_api_string_replace;
- new_plugin->string_explode = &plugin_api_string_explode;
- new_plugin->string_free_exploded = &plugin_api_string_free_exploded;
- new_plugin->string_split_command = &plugin_api_string_split_command;
- new_plugin->string_free_splitted_command = &plugin_api_string_free_splitted_command;
-
- new_plugin->utf8_has_8bits = &plugin_api_utf8_has_8bits;
- new_plugin->utf8_is_valid = &plugin_api_utf8_is_valid;
- new_plugin->utf8_normalize = &plugin_api_utf8_normalize;
- new_plugin->utf8_prev_char = &plugin_api_utf8_prev_char;
- new_plugin->utf8_next_char = &plugin_api_utf8_next_char;
- new_plugin->utf8_char_size = &plugin_api_utf8_char_size;
- new_plugin->utf8_strlen = &plugin_api_utf8_strlen;
- new_plugin->utf8_strnlen = &plugin_api_utf8_strnlen;
- new_plugin->utf8_strlen_screen = &plugin_api_utf8_strlen_screen;
- new_plugin->utf8_charcasecmp = &plugin_api_utf8_charcasecmp;
- new_plugin->utf8_char_size_screen = &plugin_api_utf8_char_size_screen;
- new_plugin->utf8_add_offset = &plugin_api_utf8_add_offset;
- new_plugin->utf8_real_pos = &plugin_api_utf8_real_pos;
- new_plugin->utf8_pos = &plugin_api_utf8_pos;
+ new_plugin->strcasecmp = &string_strcasecmp;
+ new_plugin->strncasecmp = &string_strncasecmp;
+ new_plugin->strcasestr = &string_strcasestr;
+ new_plugin->string_replace = &string_replace;
+ new_plugin->string_explode = &string_explode;
+ new_plugin->string_free_exploded = &string_free_exploded;
+ new_plugin->string_split_command = &string_split_command;
+ new_plugin->string_free_splitted_command = &string_free_splitted_command;
+
+ new_plugin->utf8_has_8bits = &utf8_has_8bits;
+ new_plugin->utf8_is_valid = &utf8_is_valid;
+ new_plugin->utf8_normalize = &utf8_normalize;
+ new_plugin->utf8_prev_char = &utf8_prev_char;
+ new_plugin->utf8_next_char = &utf8_next_char;
+ new_plugin->utf8_char_size = &utf8_char_size;
+ new_plugin->utf8_strlen = &utf8_strlen;
+ new_plugin->utf8_strnlen = &utf8_strnlen;
+ new_plugin->utf8_strlen_screen = &utf8_strlen_screen;
+ new_plugin->utf8_charcasecmp = &utf8_charcasecmp;
+ new_plugin->utf8_char_size_screen = &utf8_char_size_screen;
+ new_plugin->utf8_add_offset = &utf8_add_offset;
+ new_plugin->utf8_real_pos = &utf8_real_pos;
+ new_plugin->utf8_pos = &utf8_pos;
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->exec_on_files = &util_exec_on_files;
- new_plugin->timeval_diff = &plugin_api_timeval_diff;
+ new_plugin->timeval_cmp = &util_timeval_cmp;
+ new_plugin->timeval_diff = &util_timeval_diff;
+ new_plugin->timeval_add = &util_timeval_add;
- 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->list_new = &weelist_new;
+ new_plugin->list_add = &weelist_add;
+ new_plugin->list_search = &weelist_search;
+ new_plugin->list_casesearch = &weelist_casesearch;
+ new_plugin->list_get = &weelist_get;
+ new_plugin->list_next = &weelist_next;
+ new_plugin->list_prev = &weelist_prev;
+ new_plugin->list_string = &weelist_string;
+ new_plugin->list_size = &weelist_size;
+ new_plugin->list_remove = &weelist_remove;
+ new_plugin->list_remove_all = &weelist_remove_all;
+ new_plugin->list_free = &weelist_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;
- new_plugin->config_color = &plugin_api_config_color;
- new_plugin->config_read = &plugin_api_config_read;
- new_plugin->config_reload = &plugin_api_config_reload;
- new_plugin->config_write = &plugin_api_config_write;
- 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->plugin_config_get = &plugin_api_plugin_config_get;
- new_plugin->plugin_config_set = &plugin_api_plugin_config_set;
+ new_plugin->config_new = &config_file_new;
+ new_plugin->config_new_section = &config_file_new_section;
+ new_plugin->config_search_section = &config_file_search_section;
+ new_plugin->config_new_option = &config_file_new_option;
+ new_plugin->config_search_option = &config_file_search_option;
+ new_plugin->config_option_set = &config_file_option_set;
+ new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
+ new_plugin->config_boolean = &config_file_option_boolean;
+ new_plugin->config_integer = &config_file_option_integer;
+ new_plugin->config_string = &config_file_option_string;
+ new_plugin->config_color = &config_file_option_color;
+ new_plugin->config_write_line = &config_file_write_line;
+ new_plugin->config_write = &config_file_write;
+ new_plugin->config_read = &config_file_read;
+ new_plugin->config_reload = &config_file_reload;
+ new_plugin->config_free = &config_file_free;
+ new_plugin->config_get_weechat = &plugin_api_config_get_weechat;
+ new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
+ new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
new_plugin->prefix = &plugin_api_prefix;
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->printf_date = &gui_chat_printf_date;
+ new_plugin->log_printf = &log_printf;
new_plugin->infobar_printf = &plugin_api_infobar_printf;
new_plugin->infobar_remove = &plugin_api_infobar_remove;
- new_plugin->hook_command = &plugin_api_hook_command;
- new_plugin->hook_timer = &plugin_api_hook_timer;
- new_plugin->hook_fd = &plugin_api_hook_fd;
- new_plugin->hook_print = &plugin_api_hook_print;
- new_plugin->hook_signal = &plugin_api_hook_signal;
- new_plugin->hook_signal_send = &plugin_api_hook_signal_send;
- new_plugin->hook_config = &plugin_api_hook_config;
- new_plugin->hook_completion = &plugin_api_hook_completion;
- new_plugin->unhook = &plugin_api_unhook;
- new_plugin->unhook_all = &plugin_api_unhook_all;
+ new_plugin->hook_command = &hook_command;
+ new_plugin->hook_timer = &hook_timer;
+ new_plugin->hook_fd = &hook_fd;
+ new_plugin->hook_print = &hook_print;
+ new_plugin->hook_signal = &hook_signal;
+ new_plugin->hook_signal_send = &hook_signal_send;
+ new_plugin->hook_config = &hook_config;
+ new_plugin->hook_completion = &hook_completion;
+ new_plugin->unhook = &unhook;
+ new_plugin->unhook_all = &unhook_all_plugin;
- new_plugin->buffer_new = &plugin_api_buffer_new;
- new_plugin->buffer_search = &plugin_api_buffer_search;
- new_plugin->buffer_close = &plugin_api_buffer_close;
- new_plugin->buffer_get = &plugin_api_buffer_get;
- new_plugin->buffer_set = &plugin_api_buffer_set;
- new_plugin->buffer_nick_add = &plugin_api_buffer_nick_add;
- new_plugin->buffer_nick_remove = &plugin_api_buffer_nick_remove;
+ new_plugin->buffer_new = &gui_buffer_new;
+ new_plugin->buffer_search = &gui_buffer_search_by_category_name;
+ new_plugin->buffer_close = &gui_buffer_close;
+ new_plugin->buffer_get = &gui_buffer_get;
+ new_plugin->buffer_set = &gui_buffer_set;
+ new_plugin->buffer_nick_add = &gui_nicklist_add;
+ new_plugin->buffer_nick_remove = &gui_nicklist_remove;
new_plugin->command = &plugin_api_command;
@@ -332,8 +306,6 @@ plugin_load (char *filename)
new_plugin->infolist_time = &plugin_api_infolist_time;
new_plugin->infolist_free = &plugin_api_infolist_free;
- new_plugin->log = &plugin_api_log;
-
/* add new plugin to list */
new_plugin->prev_plugin = last_weechat_plugin;
new_plugin->next_plugin = NULL;
@@ -383,7 +355,7 @@ plugin_load (char *filename)
*/
int
-plugin_auto_load_file (struct t_weechat_plugin *plugin, char *filename)
+plugin_auto_load_file (void *plugin, char *filename)
{
char *pos;
@@ -432,11 +404,11 @@ plugin_auto_load ()
plugins_path2 = string_replace ((plugins_path) ?
plugins_path : CONFIG_STRING(config_plugins_path),
"%h", weechat_home);
- plugin_exec_on_files (NULL,
- (plugins_path2) ?
- plugins_path2 : ((plugins_path) ?
- plugins_path : CONFIG_STRING(config_plugins_path)),
- &plugin_auto_load_file);
+ util_exec_on_files ((plugins_path2) ?
+ plugins_path2 : ((plugins_path) ?
+ plugins_path : CONFIG_STRING(config_plugins_path)),
+ NULL,
+ &plugin_auto_load_file);
if (plugins_path)
free (plugins_path);
if (plugins_path2)
@@ -449,7 +421,7 @@ plugin_auto_load ()
{
snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16,
"%s/plugins", WEECHAT_LIBDIR);
- plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file);
+ util_exec_on_files (dir_name, NULL, &plugin_auto_load_file);
free (dir_name);
}
}
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index 63e725d7c..cff9183fa 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -22,25 +22,23 @@
#include "weechat-plugin.h"
-typedef int (t_weechat_init_func) (struct t_weechat_plugin *);
-typedef void (t_weechat_end_func) (struct t_weechat_plugin *);
+typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin);
+typedef void (t_weechat_end_func) (struct t_weechat_plugin *plugin);
extern struct t_weechat_plugin *weechat_plugins;
extern struct t_weechat_plugin *last_weechat_plugin;
//extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
-extern void plugin_exec_on_files (struct t_weechat_plugin *, char *,
- int (*)(struct t_weechat_plugin *, char *));
-extern struct t_weechat_plugin *plugin_search (char *);
-extern struct t_weechat_plugin *plugin_load (char *);
+extern struct t_weechat_plugin *plugin_search (char *name);
+extern struct t_weechat_plugin *plugin_load (char *filename);
extern void plugin_auto_load ();
-extern void plugin_remove (struct t_weechat_plugin *);
-extern void plugin_unload (struct t_weechat_plugin *);
-extern void plugin_unload_name (char *);
+extern void plugin_remove (struct t_weechat_plugin *plugin);
+extern void plugin_unload (struct t_weechat_plugin *plugin);
+extern void plugin_unload_name (char *name);
extern void plugin_unload_all ();
-extern void plugin_reload_name (char *);
-extern void plugin_init (int);
+extern void plugin_reload_name (char *name);
+extern void plugin_init (int auto_load);
extern void plugin_end ();
extern void plugin_print_log ();
diff --git a/src/plugins/scripts/lua/lua.c b/src/plugins/scripts/lua/lua.c
index 572f71269..d3034b628 100644
--- a/src/plugins/scripts/lua/lua.c
+++ b/src/plugins/scripts/lua/lua.c
@@ -95,7 +95,7 @@ weechat_lua_exec (t_weechat_plugin *plugin,
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
else if (ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = lua_tonumber (lua_current_interpreter, -1);
ret_value = ret_i;
diff --git a/src/plugins/scripts/perl/perl.c b/src/plugins/scripts/perl/perl.c
index 867257545..b4018d85d 100644
--- a/src/plugins/scripts/perl/perl.c
+++ b/src/plugins/scripts/perl/perl.c
@@ -131,7 +131,7 @@ weechat_perl_exec (t_weechat_plugin *plugin,
#ifndef MULTIPLICITY
int size = strlen (script->interpreter) + strlen(function) + 3;
- func = (char *) malloc ( size * sizeof(char));
+ func = (char *)malloc (size * sizeof(char));
if (!func)
return NULL;
snprintf (func, size, "%s::%s", (char *) script->interpreter, function);
@@ -199,7 +199,7 @@ weechat_perl_exec (t_weechat_plugin *plugin,
}
else if (ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = POPi;
ret_value = ret_i;
diff --git a/src/plugins/scripts/python/python.c b/src/plugins/scripts/python/python.c
index ab939ec36..383d90e30 100644
--- a/src/plugins/scripts/python/python.c
+++ b/src/plugins/scripts/python/python.c
@@ -121,7 +121,7 @@ weechat_python_exec (t_weechat_plugin *plugin,
else if (PyInt_Check (rc) && (ret_type == SCRIPT_EXEC_INT))
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = (int) PyInt_AsLong(rc);
ret_value = ret_i;
@@ -2279,7 +2279,7 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename)
if (w_home)
{
len = strlen (w_home) + 1 + strlen("python") + 1;
- p_home = (char *) malloc (len * sizeof(char));
+ p_home = (char *)malloc (len * sizeof(char));
if (p_home)
{
snprintf (p_home, len, "%s/python", w_home);
diff --git a/src/plugins/scripts/ruby/ruby.c b/src/plugins/scripts/ruby/ruby.c
index c17c8c43e..a05535af7 100644
--- a/src/plugins/scripts/ruby/ruby.c
+++ b/src/plugins/scripts/ruby/ruby.c
@@ -168,7 +168,7 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
}
else if ((TYPE(rc) == T_FIXNUM) && ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = NUM2INT(rc);
ret_value = ret_i;
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index b091f4d33..c01380626 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -29,7 +29,7 @@
#include <dirent.h>
#include "../weechat-plugin.h"
-#include "weechat-script.h"
+#include "script.h"
/*
@@ -37,8 +37,8 @@
*/
void
-weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
- int (*callback)(t_weechat_plugin *, char *))
+weechat_script_auto_load (struct t_weechat_plugin *plugin, char *language,
+ int (*callback)(void *data, char *filename))
{
char *dir_home, *dir_name;
int dir_length;
@@ -49,7 +49,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
return;
dir_length = strlen (dir_home) + strlen (language) + 16;
dir_name =
- (char *) malloc (dir_length * sizeof (char));
+ (char *)malloc (dir_length * sizeof (char));
if (!dir_name)
{
free (dir_home);
@@ -57,7 +57,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
}
snprintf (dir_name, dir_length, "%s/%s/autoload", dir_home, language);
- plugin->exec_on_files (plugin, dir_name, callback);
+ plugin->exec_on_files (dir_name, plugin, callback);
free (dir_name);
free (dir_home);
@@ -68,7 +68,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
*/
t_plugin_script *
-weechat_script_search (t_weechat_plugin *plugin,
+weechat_script_search (struct t_weechat_plugin *plugin,
t_plugin_script **list, char *name)
{
t_plugin_script *ptr_script;
@@ -89,7 +89,7 @@ weechat_script_search (t_weechat_plugin *plugin,
*/
char *
-weechat_script_search_full_name (t_weechat_plugin *plugin,
+weechat_script_search_full_name (struct t_weechat_plugin *plugin,
char *language, char *filename)
{
char *final_name, *dir_home, *dir_system;
@@ -102,7 +102,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (!dir_home)
return NULL;
length = strlen (dir_home) + strlen (filename + 1) + 1;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s%s", dir_home, filename + 1);
@@ -116,7 +116,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (language) + 8 + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s/autoload/%s", dir_home, language, filename);
@@ -135,7 +135,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (language) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s/%s", dir_home, language, filename);
@@ -154,7 +154,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s", dir_home, filename);
@@ -173,7 +173,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_system)
{
length = strlen (dir_system) + strlen (dir_system) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name,length, "%s/%s/%s", dir_system, language, filename);
@@ -195,7 +195,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
*/
t_plugin_script *
-weechat_script_add (t_weechat_plugin *plugin,
+weechat_script_add (struct t_weechat_plugin *plugin,
t_plugin_script **script_list,
char *filename,
char *name, char *version,
@@ -245,7 +245,7 @@ weechat_script_add (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove (t_weechat_plugin *plugin,
+weechat_script_remove (struct t_weechat_plugin *plugin,
t_plugin_script **script_list, t_plugin_script *script)
{
t_plugin_handler *ptr_handler, *next_handler;
@@ -310,7 +310,7 @@ weechat_script_remove (t_weechat_plugin *plugin,
*/
void
-weechat_script_print (t_weechat_plugin *plugin,
+weechat_script_print (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel,
char *message, ...)
@@ -335,7 +335,7 @@ weechat_script_print (t_weechat_plugin *plugin,
*/
void
-weechat_script_print_server (t_weechat_plugin *plugin,
+weechat_script_print_server (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *message, ...)
{
@@ -359,9 +359,9 @@ weechat_script_print_server (t_weechat_plugin *plugin,
*/
void
-weechat_script_print_infobar (t_weechat_plugin *plugin,
+weechat_script_print_infobar (struct t_weechat_plugin *plugin,
t_plugin_script *script,
- int time_displayed, char *message, ...)
+ int delay, char *message, ...)
{
va_list argptr;
static char buf[1024];
@@ -373,7 +373,7 @@ weechat_script_print_infobar (t_weechat_plugin *plugin,
buf2 = (script->charset && script->charset[0]) ?
plugin->iconv_to_internal (plugin, script->charset, buf) : NULL;
- plugin->print_infobar (plugin, time_displayed, "%s", (buf2) ? buf2 : buf);
+ plugin->print_infobar (plugin, delay, "%s", (buf2) ? buf2 : buf);
if (buf2)
free (buf2);
}
@@ -383,7 +383,7 @@ weechat_script_print_infobar (t_weechat_plugin *plugin,
*/
void
-weechat_script_log (t_weechat_plugin *plugin,
+weechat_script_log (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel, char *message, ...)
{
@@ -407,7 +407,7 @@ weechat_script_log (t_weechat_plugin *plugin,
*/
void
-weechat_script_exec_command (t_weechat_plugin *plugin,
+weechat_script_exec_command (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel, char *command)
{
@@ -428,7 +428,7 @@ weechat_script_exec_command (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_handler (t_weechat_plugin *plugin,
+weechat_script_remove_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *arg1, char *arg2)
{
@@ -464,7 +464,7 @@ weechat_script_remove_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
+weechat_script_remove_timer_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -492,7 +492,7 @@ weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
+weechat_script_remove_keyboard_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -520,7 +520,7 @@ weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_event_handler (t_weechat_plugin *plugin,
+weechat_script_remove_event_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -549,7 +549,7 @@ weechat_script_remove_event_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_modifier (t_weechat_plugin *plugin,
+weechat_script_remove_modifier (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *arg1, char *arg2, char *arg3)
{
@@ -594,7 +594,7 @@ weechat_script_remove_modifier (t_weechat_plugin *plugin,
*/
char *
-weechat_script_get_plugin_config (t_weechat_plugin *plugin,
+weechat_script_get_plugin_config (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *option)
{
@@ -621,7 +621,7 @@ weechat_script_get_plugin_config (t_weechat_plugin *plugin,
*/
int
-weechat_script_set_plugin_config (t_weechat_plugin *plugin,
+weechat_script_set_plugin_config (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *option, char *value)
{
@@ -648,7 +648,7 @@ weechat_script_set_plugin_config (t_weechat_plugin *plugin,
*/
void
-weechat_script_set_charset (t_weechat_plugin *plugin,
+weechat_script_set_charset (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *charset)
{
diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h
index 87b1cad97..1de9f1288 100644
--- a/src/plugins/scripts/script.h
+++ b/src/plugins/scripts/script.h
@@ -26,72 +26,80 @@
#define SCRIPT_EXEC_INT 1
#define SCRIPT_EXEC_STRING 2
-typedef struct t_plugin_script t_plugin_script;
-
struct t_plugin_script
{
/* script variables */
- char *filename; /* name of script on disk */
- void *interpreter; /* interpreter for script */
- char *name; /* script name */
- char *description; /* plugin description */
- char *version; /* plugin version */
- char *shutdown_func; /* function when script is unloaded */
- char *charset; /* script charset */
+ char *filename; /* name of script on disk */
+ void *interpreter; /* interpreter for script */
+ char *name; /* script name */
+ char *description; /* plugin description */
+ char *version; /* plugin version */
+ char *shutdown_func; /* function when script is unloaded*/
+ char *charset; /* script charset */
- t_plugin_script *prev_script; /* link to previous script */
- t_plugin_script *next_script; /* link to next script */
+ struct t_plugin_script *prev_script; /* link to previous script */
+ struct t_plugin_script *next_script; /* link to next script */
};
-extern void weechat_script_auto_load (t_weechat_plugin *, char *,
- int (*)(t_weechat_plugin *, char *));
-extern t_plugin_script *weechat_script_search (t_weechat_plugin *,
- t_plugin_script **, char *);
-extern char *weechat_script_search_full_name (t_weechat_plugin *,
- char *, char *);
-extern t_plugin_script *weechat_script_add (t_weechat_plugin *,
- t_plugin_script **, char *, char *,
- char *, char *, char *, char *);
-extern void weechat_script_remove (t_weechat_plugin *,
- t_plugin_script **, t_plugin_script *);
-extern void weechat_script_print (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *, ...);
-extern void weechat_script_print_server (t_weechat_plugin *,
- t_plugin_script *,
- char *, ...);
-extern void weechat_script_print_infobar (t_weechat_plugin *,
- t_plugin_script *,
- int, char *, ...);
-extern void weechat_script_log (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *, ...);
-extern void weechat_script_exec_command (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *);
-extern void weechat_script_remove_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *);
-extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_event_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_modifier (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *);
-extern char *weechat_script_get_plugin_config (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern int weechat_script_set_plugin_config (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *);
-extern void weechat_script_set_charset (t_weechat_plugin *,
- t_plugin_script *,
- char *);
+extern void weechat_script_auto_load (struct t_weechat_plugin *plugin, char *language,
+ int (*callback)(void *data, char *filename));
+extern struct t_plugin_script *weechat_script_search (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **list,
+ char *name);
+extern char *weechat_script_search_full_name (struct t_weechat_plugin *plugin,
+ char *language, char *filename);
+extern struct t_plugin_script *weechat_script_add (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **script_list,
+ char *filename, char *name,
+ char *version,
+ char *shutdown_func,
+ char *description,
+ char *charset);
+extern void weechat_script_remove (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **script_list,
+ struct t_plugin_script *script);
+extern void weechat_script_print (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *message, ...);
+extern void weechat_script_print_server (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *message, ...);
+extern void weechat_script_print_infobar (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ int delay, char *message, ...);
+extern void weechat_script_log (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *message, ...);
+extern void weechat_script_exec_command (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *command);
+extern void weechat_script_remove_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *arg1, char *arg2);
+extern void weechat_script_remove_timer_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_keyboard_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_event_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_modifier (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *arg1, char *arg2,
+ char *arg3);
+extern char *weechat_script_get_plugin_config (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *option);
+extern int weechat_script_set_plugin_config (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *option, char *value);
+extern void weechat_script_set_charset (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *charset);
#endif /* weechat-script.h */
diff --git a/src/plugins/trigger/trigger-libc.c b/src/plugins/trigger/trigger-libc.c
index d8b278660..d34c3871a 100644
--- a/src/plugins/trigger/trigger-libc.c
+++ b/src/plugins/trigger/trigger-libc.c
@@ -217,8 +217,8 @@ c_explode_string (char *string, char *separators, int num_items_max,
}
array =
- (char **) malloc ((num_items_max ? n_items : n_items + 1) *
- sizeof (char *));
+ (char **)malloc ((num_items_max ? n_items : n_items + 1) *
+ sizeof (char *));
ptr1 = string;
ptr2 = string;
@@ -241,7 +241,7 @@ c_explode_string (char *string, char *separators, int num_items_max,
if (ptr2 - ptr1 > 0)
{
array[i] =
- (char *) malloc ((ptr2 - ptr1 + 1) * sizeof (char));
+ (char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char));
array[i] = strncpy (array[i], ptr1, ptr2 - ptr1);
array[i][ptr2 - ptr1] = '\0';
ptr1 = ++ptr2;
@@ -310,11 +310,11 @@ c_split_multi_command (char *command, char sep)
ptr = ++p;
}
- array = (char **) malloc ((nb_substr + 1) * sizeof(char *));
+ array = (char **)malloc ((nb_substr + 1) * sizeof(char *));
if (!array)
return NULL;
- buffer = (char *) malloc ( (strlen(command) + 1) * sizeof (char));
+ buffer = (char *)malloc ((strlen(command) + 1) * sizeof (char));
if (!buffer)
{
free (array);
@@ -364,7 +364,7 @@ c_split_multi_command (char *command, char sep)
free (buffer);
- array = (char **) realloc (array, (arr_idx + 1) * sizeof(char *));
+ array = (char **)realloc (array, (arr_idx + 1) * sizeof(char *));
return array;
}
@@ -406,7 +406,7 @@ c_join_string(char **list, char *sep)
len += strlen (list[i]);
len += i*strlen (sep) + 1;
- str = (char *) malloc (len * sizeof(char));
+ str = (char *)malloc (len * sizeof(char));
if (str)
{
for (i = 0; list[i]; i++)
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index 44b410af3..2fc7a1851 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -37,7 +37,7 @@ t_weechat_trigger *weechat_trigger_alloc (char *pattern, char *domain, char *com
{
t_weechat_trigger *new;
- new = (t_weechat_trigger *) malloc (sizeof (t_weechat_trigger));
+ new = (t_weechat_trigger *)malloc (sizeof (t_weechat_trigger));
if (new)
{
new->pattern = strdup (pattern);
@@ -725,7 +725,7 @@ weechat_trigger_edit (t_weechat_plugin *plugin, int todo)
return -1;
len = strlen (weechat_dir) + strlen(DIR_SEP) + strlen(CONF_FILE) + 1;
- triggerrc = (char *) malloc (len * sizeof(char));
+ triggerrc = (char *)malloc (len * sizeof(char));
if (!triggerrc)
return -1;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index d03d0535f..0cd9cacc1 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -23,6 +23,9 @@
#include <sys/types.h>
+struct t_gui_buffer;
+struct t_weelist;
+
/* return codes for plugin functions */
#define WEECHAT_RC_ERROR -1 /* function failed with an error */
#define WEECHAT_RC_OK 0 /* function ok */
@@ -37,6 +40,10 @@
#define WEECHAT_RC_WITH_HIGHLIGHT 4 /* ok and ask for highlight */
/* (for message handler only) */
+#define WEELIST_POS_SORT "sort"
+#define WEELIST_POS_BEGINNING "beginning"
+#define WEELIST_POS_END "end"
+
struct t_weechat_plugin
{
/* plugin variables */
@@ -56,163 +63,204 @@ struct t_weechat_plugin
existing plugins */
/* strings */
- void (*charset_set) (struct t_weechat_plugin *, char *);
- char *(*iconv_to_internal) (struct t_weechat_plugin *, char *, char *);
- char *(*iconv_from_internal) (struct t_weechat_plugin *, char *, char *);
- char *(*gettext) (struct t_weechat_plugin *, char *);
- char *(*ngettext) (struct t_weechat_plugin *, char *, char *, int);
- int (*strcasecmp) (struct t_weechat_plugin *, char *, char *);
- int (*strncasecmp) (struct t_weechat_plugin *, char *, char *, int);
- char *(*strcasestr) (struct t_weechat_plugin *, char *, char *);
- char *(*string_replace) (struct t_weechat_plugin *, char *, char *, char *);
- char **(*string_explode) (struct t_weechat_plugin *, char *, char *, int,
- int, int *);
- void (*string_free_exploded) (struct t_weechat_plugin *, char **);
- char **(*string_split_command) (struct t_weechat_plugin *, char *, char);
- void (*string_free_splitted_command) (struct t_weechat_plugin *, char **);
+ void (*charset_set) (struct t_weechat_plugin *plugin, char *charset);
+ char *(*iconv_to_internal) (char *charset, char *string);
+ char *(*iconv_from_internal) (char *charset, char *string);
+ char *(*gettext) (char *string);
+ char *(*ngettext) (char *single, char *plural, int count);
+ int (*strcasecmp) (char *string1, char *string2);
+ int (*strncasecmp) (char *string1, char *string2, int max);
+ char *(*strcasestr) (char *string1, char *string2);
+ char *(*string_replace) (char *string, char *search, char *replace);
+ char **(*string_explode) (char *string, char *separators, int keep_eol,
+ int num_items_max, int *num_items);
+ void (*string_free_exploded) (char **exploded_string);
+ char **(*string_split_command) (char *command, char separator);
+ void (*string_free_splitted_command) (char **splitted_command);
/* UTF-8 strings */
- int (*utf8_has_8bits) (struct t_weechat_plugin *, char *);
- int (*utf8_is_valid) (struct t_weechat_plugin *, char *, char **);
- void (*utf8_normalize) (struct t_weechat_plugin *, char *, char);
- char *(*utf8_prev_char) (struct t_weechat_plugin *, char *, char *);
- char *(*utf8_next_char) (struct t_weechat_plugin *, char *);
- int (*utf8_char_size) (struct t_weechat_plugin *, char *);
- int (*utf8_strlen) (struct t_weechat_plugin *, char *);
- int (*utf8_strnlen) (struct t_weechat_plugin *, char *, int);
- int (*utf8_strlen_screen) (struct t_weechat_plugin *, char *);
- int (*utf8_charcasecmp) (struct t_weechat_plugin *, char *, char *);
- int (*utf8_char_size_screen) (struct t_weechat_plugin *, char *);
- char *(*utf8_add_offset) (struct t_weechat_plugin *, char *, int);
- int (*utf8_real_pos) (struct t_weechat_plugin *, char *, int);
- int (*utf8_pos) (struct t_weechat_plugin *, char *, int);
+ int (*utf8_has_8bits) (char *string);
+ int (*utf8_is_valid) (char *string, char **error);
+ void (*utf8_normalize) (char *string, char replacement);
+ char *(*utf8_prev_char) (char *string_start, char *string);
+ char *(*utf8_next_char) (char *string);
+ int (*utf8_char_size) (char *string);
+ int (*utf8_strlen) (char *string);
+ int (*utf8_strnlen) (char *string, int bytes);
+ int (*utf8_strlen_screen) (char *string);
+ int (*utf8_charcasecmp) (char *string1, char *string2);
+ int (*utf8_char_size_screen) (char *string);
+ char *(*utf8_add_offset) (char *string, int offset);
+ int (*utf8_real_pos) (char *string, int pos);
+ int (*utf8_pos) (char *string, int real_pos);
/* directories */
- 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 *));
+ int (*mkdir_home) (char *directory, int mode);
+ int (*mkdir) (char *directory, int mode);
+ void (*exec_on_files) (char *directory, void *data,
+ int (*callback)(void *data, char *filename));
/* util */
- long (*timeval_diff) (struct t_weechat_plugin *, void *, void *);
+ int (*timeval_cmp) (struct timeval *tv1, struct timeval *tv2);
+ long (*timeval_diff) (struct timeval *tv1, struct timeval *tv2);
+ void (*timeval_add) (struct timeval *tv, long interval);
/* 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 *);
+ struct t_weelist *(*list_new) ();
+ struct t_weelist_item *(*list_add) (struct t_weelist *weelist, char *data,
+ char *where);
+ struct t_weelist_item *(*list_search) (struct t_weelist *weelist,
+ char *data);
+ struct t_weelist_item *(*list_casesearch) (struct t_weelist *weelist,
+ char *data);
+ struct t_weelist_item *(*list_get) (struct t_weelist *weelist,
+ int position);
+ struct t_weelist_item *(*list_next) (struct t_weelist_item *item);
+ struct t_weelist_item *(*list_prev) (struct t_weelist_item *item);
+ char *(*list_string) (struct t_weelist_item *item);
+ int (*list_size) (struct t_weelist *weelist);
+ void (*list_remove) (struct t_weelist *weelist,
+ struct t_weelist_item *item);
+ void (*list_remove_all) (struct t_weelist *weelist);
+ void (*list_free) (struct t_weelist *weelist);
/* 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 *, 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 *);
- int (*config_color) (struct t_weechat_plugin *, void *);
- int (*config_read) (struct t_weechat_plugin *, void *);
- 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 *, ...);
- void (*config_free) (struct t_weechat_plugin *, void *);
- 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 *);
+ struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin,
+ char *filename);
+ struct t_config_section *(*config_new_section) (struct t_config_file *config_file,
+ char *name,
+ void (*callback_read)
+ (struct t_config_file *config_file,
+ char *option_name,
+ char *value),
+ void (*callback_write)
+ (struct t_config_file *config_file,
+ char *section_name),
+ void (*callback_write_default)
+ (struct t_config_file *config_file,
+ char *section_name));
+ struct t_config_section *(*config_search_section) (struct t_config_file *config_file,
+ char *section_name);
+ struct t_config_option *(*config_new_option) (struct t_config_section *config_file,
+ char *name, char *type,
+ char *description,
+ char *string_values,
+ int min, int max,
+ char *default_value,
+ void (*callback_change)());
+ struct t_config_option *(*config_search_option) (struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name);
+ int (*config_string_to_boolean) (char *text);
+ int (*config_option_set) (struct t_config_option *option, char *new_value,
+ int run_callback);
+ int (*config_boolean) (struct t_config_option *option);
+ int (*config_integer) (struct t_config_option *option);
+ char *(*config_string) (struct t_config_option *option);
+ int (*config_color) (struct t_config_option *option);
+ void (*config_write_line) (struct t_config_file *config_file,
+ char *option_name, char *value, ...);
+ int (*config_write) (struct t_config_file *config_file);
+ int (*config_read) (struct t_config_file *config_file);
+ int (*config_reload) (struct t_config_file *config_file);
+ void (*config_free) (struct t_config_file *config_file);
+ struct t_config_option *(*config_get_weechat) (char *option_name);
+ char *(*config_get_plugin) (struct t_weechat_plugin *plugin,
+ char *option_name);
+ int (*config_set_plugin) (struct t_weechat_plugin *plugin,
+ char *option_name, char *value);
/* display */
- char *(*prefix) (struct t_weechat_plugin *, char *);
- char *(*color) (struct t_weechat_plugin *, char *);
- void (*printf) (struct t_weechat_plugin *, void *, char *, ...);
- void (*printf_date) (struct t_weechat_plugin *, void *, time_t,
- char *, ...);
- void (*log_printf) (struct t_weechat_plugin *, char *, ...);
- void (*infobar_printf) (struct t_weechat_plugin *, int, char *,
- char *, ...);
- void (*infobar_remove) (struct t_weechat_plugin *, int);
+ char *(*prefix) (char *prefix);
+ char *(*color) (char *color_name);
+ void (*printf_date) (struct t_gui_buffer *buffer, time_t date,
+ char *message, ...);
+ void (*log_printf) (char *message, ...);
+ void (*infobar_printf) (int delay, char *color_name, char *format, ...);
+ void (*infobar_remove) (int how_many);
/* hooks */
- struct t_hook *(*hook_command) (struct t_weechat_plugin *, char *, char *,
- char *, char *, char *,
- int (*)(void *, void *, int, char **, char **),
- void *);
- struct t_hook *(*hook_timer) (struct t_weechat_plugin *, long, int, int,
- int (*)(void *), void *);
- struct t_hook *(*hook_fd) (struct t_weechat_plugin *, int, int, int, int,
- int (*)(void *), void *);
- struct t_hook *(*hook_print) (struct t_weechat_plugin *, void *, char *,
- int,
- int (*)(void *, void *, time_t, char *, char *),
- void *);
- struct t_hook *(*hook_signal) (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *), void *);
- void (*hook_signal_send) (struct t_weechat_plugin *, char *, void *);
- struct t_hook *(*hook_config) (struct t_weechat_plugin *, char *, char *,
- int (*)(void *, char *, char *, char *),
- void *);
- struct t_hook *(*hook_completion) (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *, void *),
- void *);
- void (*unhook) (struct t_weechat_plugin *, void *);
- void (*unhook_all) (struct t_weechat_plugin *);
+ struct t_hook *(*hook_command) (struct t_weechat_plugin *plugin,
+ char *command, char *description,
+ char *args, char *args_description,
+ char *completion,
+ int (*callback)(void *data,
+ struct t_gui_buffer *buffer,
+ int argc, char **argv,
+ char **argv_eol),
+ void *callback_data);
+ struct t_hook *(*hook_timer) (struct t_weechat_plugin *plugin,
+ long interval, int align_second,
+ int max_calls,
+ int (*callback)(void *data),
+ void *callback_data);
+ struct t_hook *(*hook_fd) (struct t_weechat_plugin *plugin,
+ int fd, int flag_read, int flag_write,
+ int flag_exception,
+ int (*callback)(void *data),
+ void *callback_data);
+ struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer,
+ char *message, int strip_colors,
+ int (*callback)(void *data,
+ struct t_gui_buffer *buffer,
+ time_t date, char *prefix,
+ char *message),
+ void *callback_data);
+ struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin,
+ char *signal,
+ int (*callback)(void *data, char *signal,
+ void *signal_data),
+ void *callback_data);
+ void (*hook_signal_send) (char *signal, void *signal_data);
+ struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin,
+ char *type, char *option,
+ int (*callback)(void *data, char *type,
+ char *option, char *value),
+ void *callback_data);
+ struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
+ char *completion,
+ int (*callback)(void *data,
+ char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list),
+ void *callback_data);
+ void (*unhook) (struct t_hook *hook);
+ void (*unhook_all) (struct t_weechat_plugin *plugin);
/* buffers */
- struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *,
- char *, char *,
- void (*)(struct t_gui_buffer *, char *));
- struct t_gui_buffer *(*buffer_search) (struct t_weechat_plugin *,
- char *, char *);
- void (*buffer_close) (struct t_weechat_plugin *, void *);
- void *(*buffer_get) (struct t_weechat_plugin *, void *, char *);
- void (*buffer_set) (struct t_weechat_plugin *, void *, char *, char *);
- void (*buffer_nick_add) (struct t_weechat_plugin *, void *, char *, int,
- char *, char, char *);
- void (*buffer_nick_remove) (struct t_weechat_plugin *, char *);
+ struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin,
+ char *category, char *name,
+ void (*callback_input_data)(struct t_gui_buffer *buffer,
+ char *data));
+ struct t_gui_buffer *(*buffer_search) (char *category, char *name);
+ void (*buffer_close) (struct t_gui_buffer *buffer, int switch_to_another);
+ void *(*buffer_get) (struct t_gui_buffer *buffer, char *property);
+ void (*buffer_set) (struct t_gui_buffer *buffer, char *property,
+ char *value);
+ struct t_gui_nick *(*buffer_nick_add) (struct t_gui_buffer *buffer,
+ char *nick, int sort_index,
+ char *color_nick, char prefix,
+ char *color_prefix);
+ int (*buffer_nick_remove) (struct t_gui_buffer *buffer, char *nick);
/* command */
- void (*command) (struct t_weechat_plugin *, void *, char *);
+ void (*command) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command);
/* infos */
- char *(*info_get) (struct t_weechat_plugin *, char *);
+ char *(*info_get) (struct t_weechat_plugin *plugin, char *info);
/* 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 *, ...);
+ struct t_plugin_infolist *(*infolist_get) (char *name, void *pointer);
+ int (*infolist_next) (struct t_plugin_infolist *infolist);
+ int (*infolist_prev) (struct t_plugin_infolist *infolist);
+ char *(*infolist_fields) (struct t_plugin_infolist *infolist);
+ int (*infolist_integer) (struct t_plugin_infolist *infolist, char *var);
+ char *(*infolist_string) (struct t_plugin_infolist *infolist, char *var);
+ void *(*infolist_pointer) (struct t_plugin_infolist *infolist, char *var);
+ time_t (*infolist_time) (struct t_plugin_infolist *infolist, char *var);
+ void (*infolist_free) (struct t_plugin_infolist *infolist);
/* WeeChat developers: ALWAYS add new functions at the end */
};
@@ -222,183 +270,174 @@ struct t_weechat_plugin
/* strings */
#define weechat_charset_set(__charset) \
weechat_plugin->charset_set(weechat_plugin, __charset)
-#define weechat_iconv_to_internal(__charset, __string) \
- weechat_plugin->iconv_to_internal(weechat_plugin, \
- __charset, __string)
-#define weechat_iconv_from_internal(__charset, __string) \
- weechat_plugin->iconv_from_internal(weechat_plugin, \
- __charset, __string)
+#define weechat_iconv_to_internal(__charset, __string) \
+ weechat_plugin->iconv_to_internal(__charset, __string)
+#define weechat_iconv_from_internal(__charset, __string) \
+ weechat_plugin->iconv_from_internal(__charset, __string)
#ifndef __WEECHAT_H
-#define _(string) weechat_plugin->gettext(weechat_plugin, string)
+#define _(string) weechat_plugin->gettext(string)
#define N_(string) (string)
-#define NG_(single,plural,number) \
- weechat_plugin->ngettext(weechat_plugin, single, plural, number)
+#define NG_(single,plural,number) \
+ weechat_plugin->ngettext(single, plural, number)
#endif
-#define weechat_strcasecmp(__string1, __string2) \
- weechat_plugin->strcasecmp(weechat_plugin, __string1, __string2)
-#define weechat_strncasecmp(__string1, __string2, __max) \
- weechat_plugin->strncasecmp(weechat_plugin, __string1, \
- __string2, __max)
-#define weechat_strcasestr(__string1, __string2) \
- weechat_plugin->strcasestr(weechat_plugin, __string1, __string2)
-#define weechat_string_replace(__string1, __search1, __replace1) \
- weechat_plugin->string_replace(weechat_plugin, __string1, \
- __search1, __replace1)
-#define weechat_string_explode(__string1, __separator, __eol, __max, \
+#define weechat_strcasecmp(__string1, __string2) \
+ weechat_plugin->strcasecmp(__string1, __string2)
+#define weechat_strncasecmp(__string1, __string2, __max) \
+ weechat_plugin->strncasecmp(__string1, __string2, __max)
+#define weechat_strcasestr(__string1, __string2) \
+ weechat_plugin->strcasestr(__string1, __string2)
+#define weechat_string_replace(__string, __search, __replace) \
+ weechat_plugin->string_replace(__string, __search, __replace)
+#define weechat_string_explode(__string, __separator, __eol, __max, \
__num_items) \
- weechat_plugin->string_explode(weechat_plugin, __string1, \
- __separator, __eol, __max, \
- __num_items)
-#define weechat_string_free_exploded(__array_str) \
- weechat_plugin->string_free_exploded(weechat_plugin, __array_str)
-#define weechat_string_split_command(__string1, __separator) \
- weechat_plugin->string_split_command(weechat_plugin, __string1, \
- __separator)
-#define weechat_string_free_splitted_command(__array_str) \
- weechat_plugin->string_free_splitted_command(weechat_plugin, \
- __array_str)
+ weechat_plugin->string_explode(__string, __separator, __eol, \
+ __max, __num_items)
+#define weechat_string_free_exploded(__exploded_string) \
+ weechat_plugin->string_free_exploded(__exploded_string)
+#define weechat_string_split_command(__command, __separator) \
+ weechat_plugin->string_split_command(__command, __separator)
+#define weechat_string_free_splitted_command(__splitted_command) \
+ weechat_plugin->string_free_splitted_command(__splitted_command)
/* UTF-8 strings */
-#define weechat_utf8_has_8bits(__string) \
- weechat_plugin->utf8_has_8bits(weechat_plugin, __string)
-#define weechat_utf8_is_valid(__string, __error) \
- weechat_plugin->utf8_is_valid(weechat_plugin, __string, __error)
-#define weechat_utf8_normalize(__string, __char) \
- weechat_plugin->utf8_normalize(weechat_plugin, __string, __char)
-#define weechat_utf8_prev_char(__start, __string) \
- weechat_plugin->utf8_prev_char(weechat_plugin, __start, __string)
-#define weechat_utf8_next_char(__string) \
- weechat_plugin->utf8_next_char(weechat_plugin, __string)
-#define weechat_utf8_char_size(__string) \
- weechat_plugin->utf8_char_size(weechat_plugin, __string)
-#define weechat_utf8_strlen(__string) \
- weechat_plugin->utf8_strlen(weechat_plugin, __string)
-#define weechat_utf8_strnlen(__string, __bytes) \
- weechat_plugin->utf8_strnlen(weechat_plugin, __string, __bytes)
-#define weechat_utf8_strlen_screen(__string) \
- weechat_plugin->utf8_strlen_screen(weechat_plugin, __string)
-#define weechat_utf8_charcasecmp(__string) \
- weechat_plugin->utf8_charcasecmp(weechat_plugin, __string)
-#define weechat_utf8_char_size_screen(__string) \
- weechat_plugin->utf8_char_size_screen(weechat_plugin, __string)
-#define weechat_utf8_add_offset(__string, __offset) \
- weechat_plugin->utf8_add_offset(weechat_plugin, __string, __offset)
-#define weechat_utf8_real_pos(__string, __pos) \
- weechat_plugin->utf8_real_pos(weechat_plugin, __string, __pos)
-#define weechat_utf8_pos(__string, __real_pos) \
- weechat_plugin->utf8_pos(weechat_plugin, __string, __real_pos)
+#define weechat_utf8_has_8bits(__string) \
+ weechat_plugin->utf8_has_8bits(__string)
+#define weechat_utf8_is_valid(__string, __error) \
+ weechat_plugin->utf8_is_valid(__string, __error)
+#define weechat_utf8_normalize(__string, __char) \
+ weechat_plugin->utf8_normalize(__string, __char)
+#define weechat_utf8_prev_char(__start, __string) \
+ weechat_plugin->utf8_prev_char(__start, __string)
+#define weechat_utf8_next_char(__string) \
+ weechat_plugin->utf8_next_char(__string)
+#define weechat_utf8_char_size(__string) \
+ weechat_plugin->utf8_char_size(__string)
+#define weechat_utf8_strlen(__string) \
+ weechat_plugin->utf8_strlen(__string)
+#define weechat_utf8_strnlen(__string, __bytes) \
+ weechat_plugin->utf8_strnlen(__string, __bytes)
+#define weechat_utf8_strlen_screen(__string) \
+ weechat_plugin->utf8_strlen_screen(__string)
+#define weechat_utf8_charcasecmp(__string) \
+ weechat_plugin->utf8_charcasecmp(__string)
+#define weechat_utf8_char_size_screen(__string) \
+ weechat_plugin->utf8_char_size_screen(__string)
+#define weechat_utf8_add_offset(__string, __offset) \
+ weechat_plugin->utf8_add_offset(__string, __offset)
+#define weechat_utf8_real_pos(__string, __pos) \
+ weechat_plugin->utf8_real_pos(__string, __pos)
+#define weechat_utf8_pos(__string, __real_pos) \
+ weechat_plugin->utf8_pos(__string, __real_pos)
/* directories */
-#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)
+#define weechat_mkdir_home(__directory, __mode) \
+ weechat_plugin->mkdir_home(__directory, __mode)
+#define weechat_mkdir(__directory, __mode) \
+ weechat_plugin->mkdir(__directory, __mode)
+#define weechat_exec_on_files(__directory, __data, __callback) \
+ weechat_plugin->exec_on_files(__directory, __data, __callback)
/* util */
-#define weechat_timeval_diff(__time1, __time2) \
- weechat_plugin->timeval_diff(weechat_plugin, __time1, __time2)
+#define weechat_timeval_cmp(__time1, __time2) \
+ weechat_plugin->timeval_cmp(__time1, __time2)
+#define weechat_timeval_diff(__time1, __time2) \
+ weechat_plugin->timeval_diff(__time1, __time2)
+#define weechat_timeval_add(__time, __interval) \
+ weechat_plugin->timeval_add(__time, __interval)
/* 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)
+ weechat_plugin->list_new()
+#define weechat_list_add(__list, __string, __where) \
+ weechat_plugin->list_add(__list, __string, __where)
+#define weechat_list_search(__list, __string) \
+ weechat_plugin->list_search(__list, __string)
+#define weechat_list_casesearch(__list, __string) \
+ weechat_plugin->list_casesearch(__list, __string)
+#define weechat_list_get(__list, __index) \
+ weechat_plugin->list_get(__list, __index)
+#define weechat_list_next(__item) \
+ weechat_plugin->list_next(__item)
+#define weechat_list_prev(__item) \
+ weechat_plugin->list_prev(__item)
+#define weechat_list_string(__item) \
+ weechat_plugin->list_string(__item)
+#define weechat_list_size(__list) \
+ weechat_plugin->list_size(__list)
+#define weechat_list_remove(__list, __item) \
+ weechat_plugin->list_remove(__list, __item)
+#define weechat_list_remove_all(__list) \
+ weechat_plugin->list_remove_all(__list)
+#define weechat_list_free(__list) \
+ weechat_plugin->list_free(__list)
/* config files */
#define weechat_config_new(__filename) \
weechat_plugin->config_new(weechat_plugin, __filename)
#define weechat_config_new_section(__config, __name, __cb_read, \
__cb_write_std, __cb_write_def) \
- weechat_plugin->config_new_section(weechat_plugin, \
- __config, __name, __cb_read, \
+ weechat_plugin->config_new_section(__config, __name, __cb_read, \
__cb_write_std, __cb_write_def)
-#define weechat_config_search_section(__config, __name) \
- weechat_plugin->config_search_section(weechat_plugin, \
- __config, __name)
+#define weechat_config_search_section(__config, __name) \
+ weechat_plugin->config_search_section(__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, __type, \
+ weechat_plugin->config_new_option(__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) \
- weechat_plugin->config_integer(weechat_plugin, __option)
-#define weechat_config_string(__option) \
- weechat_plugin->config_string(weechat_plugin, __option)
-#define weechat_config_color(__option) \
- weechat_plugin->config_color(weechat_plugin, __option)
-#define weechat_config_read(__config) \
- weechat_plugin->config_read(weechat_plugin, __config)
-#define weechat_config_reload(__config) \
- weechat_plugin->config_reload(weechat_plugin, __config)
-#define weechat_config_write(__config) \
- weechat_plugin->config_write(weechat_plugin, __config)
+#define weechat_config_search_option(__config, __section, __name) \
+ weechat_plugin->config_search_option(__config, __section, __name)
+#define weechat_config_string_to_boolean(__string) \
+ weechat_plugin->config_string_to_boolean(__string)
+#define weechat_config_option_set(__option, __value, __run_callback) \
+ weechat_plugin->config_option_set(__option, __value, \
+ __run_callback)
+#define weechat_config_boolean(__option) \
+ weechat_plugin->config_boolean(__option)
+#define weechat_config_integer(__option) \
+ weechat_plugin->config_integer(__option)
+#define weechat_config_string(__option) \
+ weechat_plugin->config_string(__option)
+#define weechat_config_color(__option) \
+ weechat_plugin->config_color(__option)
#define weechat_config_write_line(__config, __option, \
__value...) \
- weechat_plugin->config_write_line(weechat_plugin, \
- __config, __option, \
+ weechat_plugin->config_write_line(__config, __option, \
##__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_plugin_config_get(__option) \
- weechat_plugin->plugin_config_get(weechat_plugin, __option)
-#define weechat_plugin_config_set(__option, __value) \
- weechat_plugin->plugin_config_set(weechat_plugin, __option, __value)
+#define weechat_config_write(__config) \
+ weechat_plugin->config_write(__config)
+#define weechat_config_read(__config) \
+ weechat_plugin->config_read(__config)
+#define weechat_config_reload(__config) \
+ weechat_plugin->config_reload(__config)
+#define weechat_config_free(__config) \
+ weechat_plugin->config_free(__config)
+#define weechat_config_get_weechat(__option) \
+ weechat_plugin->config_get_weechat(__option)
+#define weechat_config_get_plugin(__option) \
+ weechat_plugin->config_get_plugin(weechat_plugin, __option)
+#define weechat_config_set_plugin(__option, __value) \
+ weechat_plugin->config_set_plugin(weechat_plugin, __option, __value)
/* display */
-#define weechat_prefix(__prefix_name) \
- weechat_plugin->prefix(weechat_plugin, __prefix_name)
-#define weechat_color(__color_name) \
- weechat_plugin->color(weechat_plugin, __color_name)
-#define weechat_printf(__buffer, __argz...) \
- weechat_plugin->printf(weechat_plugin, __buffer, ##__argz)
-#define weechat_printf_date(__buffer, __datetime, __argz...) \
- weechat_plugin->printf_date(weechat_plugin, __buffer, __datetime, \
- ##__argz)
-#define weechat_log_printf(__argz...) \
- weechat_plugin->log_printf(weechat_plugin, ##__argz)
-#define weechat_infobar_printf(__delay, __color, __argz...) \
- weechat_plugin->infobar_printf(weechat_plugin, __delay, __color, \
+#define weechat_prefix(__prefix) \
+ weechat_plugin->prefix(__prefix)
+#define weechat_color(__color_name) \
+ weechat_plugin->color(__color_name)
+#define weechat_printf(__buffer, __message, __argz...) \
+ weechat_plugin->printf_date(__buffer, 0, __message, ##__argz)
+#define weechat_printf_date(__buffer, __date, __message, __argz...) \
+ weechat_plugin->printf_date(__buffer, __date, __message, ##__argz)
+#define weechat_log_printf(__message, __argz...) \
+ weechat_plugin->log_printf(__message, ##__argz)
+#define weechat_infobar_printf(__delay, __color_name, __message, \
+ __argz...) \
+ weechat_plugin->infobar_printf(__delay, __color_name, __message, \
##__argz)
-#define weechat_infobar_remove(__number) \
- weechat_plugin->infobar_remove(weechat_plugin, __number)
+#define weechat_infobar_remove(__how_many) \
+ weechat_plugin->infobar_remove(__how_many)
/* hooks */
#define weechat_hook_command(__command, __description, __args, \
@@ -425,34 +464,32 @@ struct t_weechat_plugin
weechat_plugin->hook_signal(weechat_plugin, __signal, __callback, \
__data)
#define weechat_hook_signal_send(__signal, __pointer) \
- weechat_plugin->hook_signal_send(weechat_plugin, __signal, \
- __pointer)
+ weechat_plugin->hook_signal_send(__signal, __pointer)
#define weechat_hook_config(__type, __option, __callback, __data) \
weechat_plugin->hook_config(weechat_plugin, __type, __option, \
__callback, __data)
#define weechat_hook_completion(__completion, __callback, __data) \
weechat_plugin->hook_completion(weechat_plugin, __completion, \
__callback, __data)
-#define weechat_unhook(__hook) \
- weechat_plugin->unhook(weechat_plugin, __hook)
-#define weechat_unhook_all() \
- weechat_plugin->unhook(weechat_plugin)
+#define weechat_unhook(__hook) \
+ weechat_plugin->unhook( __hook)
+#define weechat_unhook_all() \
+ weechat_plugin->unhook_all_plugin(weechat_plugin)
/* buffers */
-#define weechat_buffer_new(__category, __name, __input_data_cb) \
+#define weechat_buffer_new(__category, __name, __callback_input_data) \
weechat_plugin->buffer_new(weechat_plugin, __category, __name, \
- __input_data_cb)
-#define weechat_buffer_search(__category, __name) \
- weechat_plugin->buffer_search(weechat_plugin, __category, __name)
-#define weechat_current_buffer \
- weechat_plugin->buffer_search(weechat_plugin, NULL, NULL)
-#define weechat_buffer_close(__buffer) \
- weechat_plugin->buffer_close(weechat_plugin, __buffer)
-#define weechat_buffer_get(__buffer, __property) \
- weechat_plugin->buffer_get(weechat_plugin, __buffer, __property)
-#define weechat_buffer_set(__buffer, __property, __value) \
- weechat_plugin->buffer_set(weechat_plugin, __buffer, __property, \
- __value)
+ __callback_input_data)
+#define weechat_buffer_search(__category, __name) \
+ weechat_plugin->buffer_search(__category, __name)
+#define weechat_current_buffer \
+ weechat_plugin->buffer_search(NULL, NULL)
+#define weechat_buffer_close(__buffer, __switch_to_another) \
+ weechat_plugin->buffer_close(__buffer, __switch_to_another)
+#define weechat_buffer_get(__buffer, __property) \
+ weechat_plugin->buffer_get(__buffer, __property)
+#define weechat_buffer_set(__buffer, __property, __value) \
+ weechat_plugin->buffer_set(__buffer, __property, __value)
/* command */
#define weechat_command(__buffer, __command) \
@@ -463,23 +500,23 @@ struct t_weechat_plugin
weechat_plugin->info_get(weechat_plugin, __name)
/* 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)
+#define weechat_infolist_get(__name, __pointer) \
+ weechat_plugin->infolist_get(__name, __pointer)
+#define weechat_infolist_next(__list) \
+ weechat_plugin->infolist_next(__list)
+#define weechat_infolist_prev(__list) \
+ weechat_plugin->infolist_prev(__list)
+#define weechat_infolist_fields(__list) \
+ weechat_plugin->infolist_fields(__list)
+#define weechat_infolist_integer(__item, __var) \
+ weechat_plugin->infolist_integer(__item, __var)
+#define weechat_infolist_string(__item, __var) \
+ weechat_plugin->infolist_string(__item, __var)
+#define weechat_infolist_pointer(__item, __var) \
+ weechat_plugin->infolist_pointer(__item, __var)
+#define weechat_infolist_time(__item, __var) \
+ weechat_plugin->infolist_time(__item, __var)
+#define weechat_infolist_free(__list) \
+ weechat_plugin->infolist_free(__list)
#endif /* weechat-plugin.h */