summaryrefslogtreecommitdiff
path: root/src/plugins/xfer
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-01-24 08:55:04 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-01-24 08:55:04 +0100
commit27b539affee5b1d8f6e88565e79e08a45417ac4a (patch)
treec52a55359558ac0637f9cc995d5620c5d6b376af /src/plugins/xfer
parent1918bd1d4e90f1540a5c1ebec9a2d4a4daca894c (diff)
downloadweechat-27b539affee5b1d8f6e88565e79e08a45417ac4a.zip
core: display error number and string in some network errors
Error number and string is now displayed when an error is returned by one of these functions: socket, setsockopt, fcntl, pipe, accept, bind, listen, mkfifo.
Diffstat (limited to 'src/plugins/xfer')
-rw-r--r--src/plugins/xfer/xfer-network.c31
-rw-r--r--src/plugins/xfer/xfer.c6
2 files changed, 24 insertions, 13 deletions
diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c
index abe5f7ec6..754e0b319 100644
--- a/src/plugins/xfer/xfer-network.c
+++ b/src/plugins/xfer/xfer-network.c
@@ -21,7 +21,9 @@
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -56,8 +58,9 @@ xfer_network_create_pipe (struct t_xfer *xfer)
if (pipe (child_pipe) < 0)
{
weechat_printf (NULL,
- _("%s%s: unable to create pipe"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ _("%s%s: unable to create pipe: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ errno, strerror (errno));
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return 0;
@@ -336,7 +339,7 @@ int
xfer_network_fd_cb (void *arg_xfer, int fd)
{
struct t_xfer *xfer;
- int sock, flags;
+ int sock, flags, error;
struct sockaddr_in addr;
socklen_t length;
@@ -353,6 +356,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
length = sizeof (addr);
sock = accept (xfer->sock,
(struct sockaddr *) &addr, &length);
+ error = errno;
weechat_unhook (xfer->hook_fd);
xfer->hook_fd = NULL;
close (xfer->sock);
@@ -361,8 +365,9 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
{
weechat_printf (NULL,
_("%s%s: unable to create socket for sending "
- "file"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ "file: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ error, strerror (error));
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
@@ -375,8 +380,9 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
{
weechat_printf (NULL,
_("%s%s: unable to set option \"nonblock\" "
- "for socket"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ "for socket: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ errno, strerror (errno));
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
@@ -395,6 +401,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
{
length = sizeof (addr);
sock = accept (xfer->sock, (struct sockaddr *) &addr, &length);
+ error = errno;
weechat_unhook (xfer->hook_fd);
xfer->hook_fd = NULL;
close (xfer->sock);
@@ -403,8 +410,9 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
{
weechat_printf (NULL,
_("%s%s: unable to create socket for sending "
- "file"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ "file: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ error, strerror (error));
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
@@ -417,8 +425,9 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
{
weechat_printf (NULL,
_("%s%s: unable to set option \"nonblock\" "
- "for socket"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ "for socket: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ errno, strerror (errno));
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index 26a2a87db..c27e52ecc 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -964,8 +965,9 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
if (sock < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot create socket for xfer"),
- weechat_prefix ("error"), XFER_PLUGIN_NAME);
+ _("%s%s: cannot create socket for xfer: error %d %s"),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ errno, strerror (errno));
if (filename2)
free (filename2);
goto error;