diff options
Diffstat (limited to 'src/plugins/fifo/fifo.c')
-rw-r--r-- | src/plugins/fifo/fifo.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c index 8694b57c8..e438fc4a1 100644 --- a/src/plugins/fifo/fifo.c +++ b/src/plugins/fifo/fifo.c @@ -1,7 +1,7 @@ /* * fifo.c - fifo plugin for WeeChat: remote control with FIFO pipe * - * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -32,6 +32,7 @@ #include "../weechat-plugin.h" #include "fifo.h" +#include "fifo-command.h" #include "fifo-info.h" @@ -54,7 +55,7 @@ char *fifo_filename; char *fifo_unterminated = NULL; -int fifo_read(); +int fifo_fd_cb (); /* @@ -158,11 +159,12 @@ fifo_create () if ((weechat_fifo_plugin->debug >= 1) || !fifo_quiet) { weechat_printf (NULL, - _("%s: pipe opened"), - FIFO_PLUGIN_NAME); + _("%s: pipe opened (file: %s)"), + FIFO_PLUGIN_NAME, + fifo_filename); } fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, - &fifo_read, NULL); + &fifo_fd_cb, NULL, NULL); } else weechat_printf (NULL, @@ -259,7 +261,7 @@ fifo_exec (const char *text) if (!pos_msg) { weechat_printf (NULL, - _("%s%s: error, invalid text received on pipe"), + _("%s%s: invalid text received in pipe"), weechat_prefix ("error"), FIFO_PLUGIN_NAME); free (text2); return; @@ -267,15 +269,15 @@ fifo_exec (const char *text) pos_msg[0] = '\0'; pos_msg += 2; ptr_buffer = weechat_buffer_search ("==", text2); - } - - if (!ptr_buffer) - { - weechat_printf (NULL, - _("%s%s: error, buffer not found for pipe data"), - weechat_prefix ("error"), FIFO_PLUGIN_NAME); - free (text2); - return; + if (!ptr_buffer) + { + weechat_printf (NULL, + _("%s%s: buffer \"%s\" not found"), + weechat_prefix ("error"), FIFO_PLUGIN_NAME, + text2); + free (text2); + return; + } } weechat_command (ptr_buffer, pos_msg); @@ -288,13 +290,14 @@ fifo_exec (const char *text) */ int -fifo_read (void *data, int fd) +fifo_fd_cb (const void *pointer, void *data, int fd) { static char buffer[4096 + 2]; char *buf2, *pos, *ptr_buf, *next_ptr_buf; int num_read; /* make C compiler happy */ + (void) pointer; (void) data; (void) fd; @@ -384,8 +387,10 @@ fifo_read (void *data, int fd) fifo_remove (); } else + { fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, - &fifo_read, NULL); + &fifo_fd_cb, NULL, NULL); + } } } @@ -397,9 +402,11 @@ fifo_read (void *data, int fd) */ int -fifo_config_cb (void *data, const char *option, const char *value) +fifo_config_cb (const void *pointer, void *data, + const char *option, const char *value) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -424,6 +431,8 @@ fifo_config_cb (void *data, const char *option, const char *value) int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { + char str_option[256]; + /* make C compiler happy */ (void) argc; (void) argv; @@ -434,8 +443,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) fifo_create (); - weechat_hook_config ("plugins.var.fifo.fifo", &fifo_config_cb, NULL); + snprintf (str_option, sizeof (str_option), + "plugins.var.fifo.%s", FIFO_OPTION_NAME); + weechat_hook_config (str_option, &fifo_config_cb, NULL, NULL); + fifo_command_init (); fifo_info_init (); fifo_quiet = 0; |