Watt-32 tcp/ip  2.2 dev-rel.10
res_data.c
Go to the documentation of this file.
1 
5 /* ++Copyright++ 1995
6  * -
7  * Copyright (c) 1995
8  * The Regents of the University of California. All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  * must display the following acknowledgement:
20  * This product includes software developed by the University of
21  * California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  * may be used to endorse or promote products derived from this software
24  * without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  * -
38  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
39  *
40  * Permission to use, copy, modify, and distribute this software for any
41  * purpose with or without fee is hereby granted, provided that the above
42  * copyright notice and this permission notice appear in all copies, and that
43  * the name of Digital Equipment Corporation not be used in advertising or
44  * publicity pertaining to distribution of the document or software without
45  * specific, written prior permission.
46  *
47  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
48  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
49  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
50  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
51  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
52  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
53  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
54  * SOFTWARE.
55  * -
56  * --Copyright--
57  */
58 
59 #include "resolver.h"
60 
61 #if defined(USE_BSD_API) || defined(USE_BIND)
62 
63 const char *_res_opcodes[] = {
64  "QUERY",
65  "IQUERY",
66  "CQUERYM",
67  "CQUERYU", /* experimental */
68  "NOTIFY", /* experimental */
69  "5",
70  "6",
71  "7",
72  "8",
73  "UPDATEA",
74  "UPDATED",
75  "UPDATEDA",
76  "UPDATEM",
77  "UPDATEMA",
78  "ZONEINIT",
79  "ZONEREF"
80  };
81 
82 const char *_res_resultcodes[] = {
83  "NOERROR",
84  "FORMERR",
85  "SERVFAIL",
86  "NXDOMAIN",
87  "NOTIMP",
88  "REFUSED",
89  "6",
90  "7",
91  "8",
92  "9",
93  "10",
94  "11",
95  "12",
96  "13",
97  "14",
98  "NOCHANGE"
99  };
100 
101 const char *h_errlist[] = {
102  "Error 0", /* 0 NETDB_SUCCESS */
103  "Unknown host", /* 1 HOST_NOT_FOUND */
104  "Host name lookup failure", /* 2 TRY_AGAIN */
105  "Unknown server error", /* 3 NO_RECOVERY */
106  "No address associated with name", /* 4 NO_ADDRESS / NO_DATA */
107  };
108 
109 int h_nerr = DIM (h_errlist);
110 
111 /*
112  * herror --
113  * print the error indicated by the h_errno value.
114  */
115 void W32_CALL herror (const char *prefix)
116 {
117  if (prefix && *prefix)
118  fprintf (stderr, "%s :", prefix);
119 
120  fputs (hstrerror(h_errno), stderr);
121 
122 #ifdef __DJGPP__
123  fputc ('\n', stderr); /* only djgpp(?) use newline, ref. perror() */
124 #endif
125 }
126 
127 const char * W32_CALL hstrerror (int err)
128 {
129  if (err < 0)
130  return ("Resolver internal error");
131  if (err < h_nerr)
132  return (h_errlist[err]);
133  return ("Unknown resolver error");
134 }
135 #endif /* USE_BSD_API || USE_BIND */
136