]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/herror.c
2 * Copyright (c) 1987, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Portions copyright (c) 1999, 2000
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley, Intel Corporation, and its contributors.
26 * 4. Neither the name of University, Intel Corporation, or their respective
27 * contributors may be used to endorse or promote products derived from
28 * this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND
31 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
32 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS,
34 * INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 * Portions Copyright (c) 1996 by Internet Software Consortium.
47 * Permission to use, copy, modify, and distribute this software for any
48 * purpose with or without fee is hereby granted, provided that the above
49 * copyright notice and this permission notice appear in all copies.
51 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
52 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
54 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
55 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
56 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
57 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
60 herror.c 8.1 (Berkeley) 6/4/93
61 herror.c,v 1.1.1.1 2003/11/19 01:51:28 kyu3 Exp
64 #include <sys/types.h>
71 const char *h_errlist
[] = {
72 "Resolver Error 0 (no error)",
73 "Unknown host", /* 1 HOST_NOT_FOUND */
74 "Host name lookup failure", /* 2 TRY_AGAIN */
75 "Unknown server error", /* 3 NO_RECOVERY */
76 "No address associated with name", /* 4 NO_ADDRESS */
78 int h_nerr
= { sizeof h_errlist
/ sizeof h_errlist
[0] };
89 * print the error indicated by the h_errno value.
97 register struct iovec
*v
= iov
;
100 v
->iov_base
= (char *)s
;
101 v
->iov_len
= strlen(s
);
107 v
->iov_base
= (char *)hstrerror(h_errno
);
108 v
->iov_len
= strlen(v
->iov_base
);
112 #if defined(_ORG_FREEBSD_) || defined(__GNUC__)
113 writev(STDERR_FILENO
, iov
, (v
- iov
) + 1);
117 for (i
= 0; i
< (v
- iov
) + 1; i
++)
118 fprintf( stderr
, iov
[i
].iov_base
);
130 return ("Resolver internal error");
131 else if (err
< h_nerr
)
132 return (h_errlist
[err
]);
133 return ("Unknown resolver error");