diff options
author | dm <> | 1996-02-19 19:53:30 +0000 |
---|---|---|
committer | dm <> | 1996-02-19 19:53:30 +0000 |
commit | 543eeae2382e5de0b9518bdd9f7a75e5686fd056 (patch) | |
tree | 094165ba891a348ad41b10f58ccb57f1a01f8e74 /src/lib/libc/net/herror.c | |
parent | 4a12c1341f3a7e10bd98cebfe52fc96867f82baf (diff) | |
download | openbsd-543eeae2382e5de0b9518bdd9f7a75e5686fd056.tar.gz openbsd-543eeae2382e5de0b9518bdd9f7a75e5686fd056.tar.bz2 openbsd-543eeae2382e5de0b9518bdd9f7a75e5686fd056.zip |
netbsd: bind 4.9.3
Diffstat (limited to 'src/lib/libc/net/herror.c')
-rw-r--r-- | src/lib/libc/net/herror.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/libc/net/herror.c b/src/lib/libc/net/herror.c index 41adbf1055..f2d241385d 100644 --- a/src/lib/libc/net/herror.c +++ b/src/lib/libc/net/herror.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $NetBSD: herror.c,v 1.5 1995/02/25 06:20:39 cgd Exp $ */ | 1 | /* $NetBSD: herror.c,v 1.6 1996/02/02 15:22:22 mrg Exp $ */ |
2 | 2 | ||
3 | /*- | 3 | /*- |
4 | * Copyright (c) 1987, 1993 | 4 | * Copyright (c) 1987, 1993 |
@@ -56,9 +56,9 @@ | |||
56 | #if defined(LIBC_SCCS) && !defined(lint) | 56 | #if defined(LIBC_SCCS) && !defined(lint) |
57 | #if 0 | 57 | #if 0 |
58 | static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; | 58 | static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; |
59 | static char rcsid[] = "$Id: herror.c,v 4.9.1.1 1993/05/02 23:14:35 vixie Rel "; | 59 | static char rcsid[] = "$Id: herror.c,v 8.2 1995/06/19 08:35:01 vixie Exp "; |
60 | #else | 60 | #else |
61 | static char rcsid[] = "$NetBSD: herror.c,v 1.5 1995/02/25 06:20:39 cgd Exp $"; | 61 | static char rcsid[] = "$NetBSD: herror.c,v 1.6 1996/02/02 15:22:22 mrg Exp $"; |
62 | #endif | 62 | #endif |
63 | #endif /* LIBC_SCCS and not lint */ | 63 | #endif /* LIBC_SCCS and not lint */ |
64 | 64 | ||
@@ -68,14 +68,14 @@ static char rcsid[] = "$NetBSD: herror.c,v 1.5 1995/02/25 06:20:39 cgd Exp $"; | |||
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | #include <string.h> | 69 | #include <string.h> |
70 | 70 | ||
71 | char *h_errlist[] = { | 71 | const char *h_errlist[] = { |
72 | "Error 0", | 72 | "Resolver Error 0 (no error)", |
73 | "Unknown host", /* 1 HOST_NOT_FOUND */ | 73 | "Unknown host", /* 1 HOST_NOT_FOUND */ |
74 | "Host name lookup failure", /* 2 TRY_AGAIN */ | 74 | "Host name lookup failure", /* 2 TRY_AGAIN */ |
75 | "Unknown server error", /* 3 NO_RECOVERY */ | 75 | "Unknown server error", /* 3 NO_RECOVERY */ |
76 | "No address associated with name", /* 4 NO_ADDRESS */ | 76 | "No address associated with name", /* 4 NO_ADDRESS */ |
77 | }; | 77 | }; |
78 | int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; | 78 | int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; |
79 | 79 | ||
80 | extern int h_errno; | 80 | extern int h_errno; |
81 | 81 | ||
@@ -98,8 +98,7 @@ herror(s) | |||
98 | v->iov_len = 2; | 98 | v->iov_len = 2; |
99 | v++; | 99 | v++; |
100 | } | 100 | } |
101 | v->iov_base = (u_int)h_errno < h_nerr ? | 101 | v->iov_base = (char *)hstrerror(h_errno); |
102 | h_errlist[h_errno] : "Unknown error"; | ||
103 | v->iov_len = strlen(v->iov_base); | 102 | v->iov_len = strlen(v->iov_base); |
104 | v++; | 103 | v++; |
105 | v->iov_base = "\n"; | 104 | v->iov_base = "\n"; |
@@ -107,9 +106,13 @@ herror(s) | |||
107 | writev(STDERR_FILENO, iov, (v - iov) + 1); | 106 | writev(STDERR_FILENO, iov, (v - iov) + 1); |
108 | } | 107 | } |
109 | 108 | ||
110 | char * | 109 | const char * |
111 | hstrerror(err) | 110 | hstrerror(err) |
112 | int err; | 111 | int err; |
113 | { | 112 | { |
114 | return (u_int)err < h_nerr ? h_errlist[err] : "Unknown resolver error"; | 113 | if (err < 0) |
114 | return ("Resolver internal error"); | ||
115 | else if (err < h_nerr) | ||
116 | return (h_errlist[err]); | ||
117 | return ("Unknown resolver error"); | ||
115 | } | 118 | } |