summaryrefslogtreecommitdiff
path: root/src/irc/irc-send.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-05-12 14:24:23 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-05-12 14:24:23 +0000
commite36b53bf74d5ea7006cd572911866bb9886a78c4 (patch)
treed79ff4e8b9877aa769603b137a83aebb382d39a9 /src/irc/irc-send.c
parent59cddf7a4057945862cb6184f0938d82faff2192 (diff)
downloadweechat-e36b53bf74d5ea7006cd572911866bb9886a78c4.zip
Fixed "hostname" option for servers (now really used to set hostname/IP for choosing local interface (ipv4 or ipv6))
Diffstat (limited to 'src/irc/irc-send.c')
-rw-r--r--src/irc/irc-send.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index 9d09b9d58..b54346eb6 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
+#include <netdb.h>
#include <time.h>
#include <sys/utsname.h>
#include <regex.h>
@@ -49,31 +50,26 @@
void
irc_login (t_irc_server *server)
{
- char hostname[128], *ptr_hostname;
-
+ char hostname[NI_MAXHOST];
+
if ((server->password) && (server->password[0]))
server_sendf (server, "PASS %s\r\n", server->password);
- if (server->hostname && server->hostname[0])
- ptr_hostname = server->hostname;
- else
- {
- gethostname (hostname, sizeof (hostname) - 1);
- hostname[sizeof (hostname) - 1] = '\0';
- if (!hostname[0])
- strcpy (hostname, _("unknown"));
- ptr_hostname = hostname;
- }
+ gethostname (hostname, sizeof (hostname) - 1);
+ hostname[sizeof (hostname) - 1] = '\0';
+ if (!hostname[0])
+ snprintf (hostname, NI_MAXHOST, "unknown");
+
irc_display_prefix (server, server->buffer, PREFIX_INFO);
gui_printf (server->buffer,
_("%s: using hostname \"%s\"\n"),
- PACKAGE_NAME, ptr_hostname);
+ PACKAGE_NAME, hostname);
if (!server->nick)
server->nick = strdup (server->nick1);
server_sendf (server,
"NICK %s\r\n"
"USER %s %s %s :%s\r\n",
- server->nick, server->username, ptr_hostname, "servername",
+ server->nick, server->username, hostname, "servername",
server->realname);
gui_input_draw (gui_current_window->buffer, 1);
}