- Fix indentation in VarFind()
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / lwres / gai_strerror.c
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: gai_strerror.c,v 1.14.2.2 2004/03/09 06:12:33 marka Exp $ */
19
20 #include <lwres/netdb.h>
21
22 static const char *gai_messages[] = {
23         "no error",
24         "address family for hostname not supported",
25         "temporary failure in name resolution",
26         "invalid value for ai_flags",
27         "non-recoverable failure in name resolution",
28         "ai_family not supported",
29         "memory allocation failure",
30         "no address associated with hostname",
31         "hostname nor servname provided, or not known",
32         "servname not supported for ai_socktype",
33         "ai_socktype not supported",
34         "system error returned in errno",
35         "bad hints",
36         "bad protocol"
37 };
38
39 char *
40 lwres_gai_strerror(int ecode) {
41         union {
42                 const char *const_ptr;
43                 char *deconst_ptr;
44         } ptr;
45
46         if ((ecode < 0) ||
47             (ecode >= (int)(sizeof(gai_messages)/sizeof(*gai_messages))))
48                 ptr.const_ptr = "invalid error code";
49         else
50                 ptr.const_ptr = gai_messages[ecode];
51         return (ptr.deconst_ptr);
52 }