summaryrefslogtreecommitdiffstats
path: root/gl/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/getaddrinfo.c')
-rw-r--r--gl/getaddrinfo.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 6aa676c..58d2811 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,5 +1,5 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001-2002, 2004-2010 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc.
3 Contributed by Simon Josefsson <simon@josefsson.org>. 3 Contributed by Simon Josefsson <simon@josefsson.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -13,15 +13,14 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19#include <config.h>
20 17
21/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
22 optimizes away the sa == NULL test below. */ 19 optimizes away the sa == NULL test below. */
23#define _GL_ARG_NONNULL(params) 20#define _GL_ARG_NONNULL(params)
24 21
22#include <config.h>
23
25#include <netdb.h> 24#include <netdb.h>
26 25
27#if HAVE_NETINET_IN_H 26#if HAVE_NETINET_IN_H
@@ -56,10 +55,13 @@
56#endif 55#endif
57 56
58#if defined _WIN32 || defined __WIN32__ 57#if defined _WIN32 || defined __WIN32__
59# define WIN32_NATIVE 58# define WINDOWS_NATIVE
60#endif 59#endif
61 60
62#ifdef WIN32_NATIVE 61/* gl_sockets_startup */
62#include "sockets.h"
63
64#ifdef WINDOWS_NATIVE
63typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, 65typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
64 const struct addrinfo*, 66 const struct addrinfo*,
65 struct addrinfo**); 67 struct addrinfo**);
@@ -101,11 +103,13 @@ use_win32_p (void)
101 return 0; 103 return 0;
102 } 104 }
103 105
106 gl_sockets_startup (SOCKETS_1_1);
107
104 return 1; 108 return 1;
105} 109}
106#endif 110#endif
107 111
108static inline bool 112static bool
109validate_family (int family) 113validate_family (int family)
110{ 114{
111 /* FIXME: Support more families. */ 115 /* FIXME: Support more families. */
@@ -148,7 +152,7 @@ getaddrinfo (const char *restrict nodename,
148 }; 152 };
149#endif 153#endif
150 154
151#ifdef WIN32_NATIVE 155#ifdef WINDOWS_NATIVE
152 if (use_win32_p ()) 156 if (use_win32_p ())
153 return getaddrinfo_ptr (nodename, servname, hints, res); 157 return getaddrinfo_ptr (nodename, servname, hints, res);
154#endif 158#endif
@@ -327,11 +331,11 @@ getaddrinfo (const char *restrict nodename,
327 return 0; 331 return 0;
328} 332}
329 333
330/* Free `addrinfo' structure AI including associated storage. */ 334/* Free 'addrinfo' structure AI including associated storage. */
331void 335void
332freeaddrinfo (struct addrinfo *ai) 336freeaddrinfo (struct addrinfo *ai)
333{ 337{
334#ifdef WIN32_NATIVE 338#ifdef WINDOWS_NATIVE
335 if (use_win32_p ()) 339 if (use_win32_p ())
336 { 340 {
337 freeaddrinfo_ptr (ai); 341 freeaddrinfo_ptr (ai);
@@ -357,7 +361,7 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
357 char *restrict service, socklen_t servicelen, 361 char *restrict service, socklen_t servicelen,
358 int flags) 362 int flags)
359{ 363{
360#ifdef WIN32_NATIVE 364#ifdef WINDOWS_NATIVE
361 if (use_win32_p ()) 365 if (use_win32_p ())
362 return getnameinfo_ptr (sa, salen, node, nodelen, 366 return getnameinfo_ptr (sa, salen, node, nodelen,
363 service, servicelen, flags); 367 service, servicelen, flags);