1 /*****************************************************************************
2 * gai_strerror.c: gai_strerror() replacement function
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
5 * Copyright (C) 2002-2007 Rémi Denis-Courmont
6 * Copyright (C) 2011-2015 KO Myung-Hun
8 * Authors: KO Myung-Hun <komh@chollian.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 /* GAI error codes. See include/vlc_network.h. */
32 # define EAI_BADFLAGS -1
35 # define EAI_NONAME -2
44 # define EAI_NODATA -5
47 # define EAI_FAMILY -6
50 # define EAI_SOCKTYPE -7
53 # define EAI_SERVICE -8
55 #ifndef EAI_ADDRFAMILY
56 # define EAI_ADDRFAMILY -9
59 # define EAI_MEMORY -10
62 # define EAI_OVERFLOW -11
65 # define EAI_SYSTEM -12
75 { EAI_BADFLAGS
, "Invalid flag used" },
76 { EAI_NONAME
, "Host or service not found" },
77 { EAI_AGAIN
, "Temporary name service failure" },
78 { EAI_FAIL
, "Non-recoverable name service failure" },
79 { EAI_NODATA
, "No data for host name" },
80 { EAI_FAMILY
, "Unsupported address family" },
81 { EAI_SOCKTYPE
, "Unsupported socket type" },
82 { EAI_SERVICE
, "Incompatible service for socket type" },
83 { EAI_ADDRFAMILY
, "Unavailable address family for host name" },
84 { EAI_MEMORY
, "Memory allocation failure" },
85 { EAI_OVERFLOW
, "Buffer overflow" },
86 { EAI_SYSTEM
, "System error" },
90 static const char gai_unknownerr
[] = "Unrecognized error number";
92 /****************************************************************************
93 * Converts an EAI_* error code into human readable english text.
94 ****************************************************************************/
95 const char *gai_strerror (int errnum
)
97 for (unsigned i
= 0; *gai_errlist
[i
].msg
; i
++)
98 if (errnum
== gai_errlist
[i
].code
)
99 return gai_errlist
[i
].msg
;
101 return gai_unknownerr
;