diff options
author | Jan Djärv <jan.h.d@swipnet.se> | 2007-11-19 11:09:20 +0000 |
---|---|---|
committer | Jan Djärv <jan.h.d@swipnet.se> | 2007-11-19 11:09:20 +0000 |
commit | ee15f3125e20e9b0fe246690e8b9b7a72d382d86 (patch) | |
tree | 49f1f5c49b43d57ef872915f7ca04452801b1168 /lib-src/pop.c | |
parent | 004a00f4ae0d64a86265c0fa6d6d52f0fa3d9434 (diff) | |
download | emacs-ee15f3125e20e9b0fe246690e8b9b7a72d382d86.tar.gz emacs-ee15f3125e20e9b0fe246690e8b9b7a72d382d86.tar.bz2 emacs-ee15f3125e20e9b0fe246690e8b9b7a72d382d86.zip |
(socket_connection): Move realhost out of #ifdefs.
Set realhost both for HAVE_GETADDRINFO and !HAVE_GETADDRINFO.
Diffstat (limited to 'lib-src/pop.c')
-rw-r--r-- | lib-src/pop.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib-src/pop.c b/lib-src/pop.c index df9e41f6457..ea057713234 100644 --- a/lib-src/pop.c +++ b/lib-src/pop.c @@ -1022,6 +1022,7 @@ socket_connection (host, flags) char found_port = 0; char *service; int sock; + char *realhost; #ifdef KERBEROS #ifdef KERBEROS5 krb5_error_code rem; @@ -1037,7 +1038,6 @@ socket_connection (host, flags) CREDENTIALS cred; Key_schedule schedule; int rem; - char *realhost; #endif /* KERBEROS5 */ #endif /* KERBEROS */ @@ -1107,7 +1107,7 @@ socket_connection (host, flags) #ifdef HAVE_GETADDRINFO memset (&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG; + hints.ai_flags = AI_ADDRCONFIG | AI_CANONNAME; hints.ai_family = AF_INET; do { @@ -1136,6 +1136,11 @@ socket_connection (host, flags) it = it->ai_next; } connect_ok = it != NULL; + if (connect_ok) + { + realhost = alloca (strlen (it->ai_canonname) + 1); + strcpy (realhost, it->ai_canonname); + } freeaddrinfo (res); } #else /* !HAVE_GETADDRINFO */ @@ -1159,6 +1164,12 @@ socket_connection (host, flags) hostent->h_addr_list++; } connect_ok = *hostent->h_addr_list != NULL; + if (! connect_ok) + { + realhost = alloca (strlen (hostent->h_name) + 1); + strcpy (realhost, hostent->h_name); + } + #endif /* !HAVE_GETADDRINFO */ #define CONNECT_ERROR "Could not connect to POP server: " @@ -1175,9 +1186,6 @@ socket_connection (host, flags) #ifdef KERBEROS - realhost = alloca (strlen (hostent->h_name) + 1); - strcpy (realhost, hostent->h_name); - #define KRB_ERROR "Kerberos error connecting to POP server: " if (! (flags & POP_NO_KERBEROS)) { |