From d62a439a4f32e8e2f8b9c437688b9fc7db91f437 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 2 Feb 2002 07:43:59 +0000 Subject: Fix hstrerror --- libc/inet/herror.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libc/inet') diff --git a/libc/inet/herror.c b/libc/inet/herror.c index 51b858f54..06ab6d5f8 100644 --- a/libc/inet/herror.c +++ b/libc/inet/herror.c @@ -25,12 +25,13 @@ #ifdef L_herror +static const char *error_msg = "Resolver error"; static const char *const h_errlist[] = { "Error 0", - "Unknown host", /* 1 HOST_NOT_FOUND */ - "Host name lookup failure", /* 2 TRY_AGAIN */ - "Unknown server error", /* 3 NO_RECOVERY */ - "No address associated with name", /* 4 NO_ADDRESS */ + "Unknown host", /* 1 HOST_NOT_FOUND */ + "Host name lookup failure", /* 2 TRY_AGAIN */ + "Unknown server error", /* 3 NO_RECOVERY */ + "No address associated with name", /* 4 NO_ADDRESS */ }; static const int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; @@ -47,7 +48,7 @@ void herror(const char *s) if (!s || !*s) { c += 2; } - p = "Unknown error"; + p = error_msg; if ((h_errno >= 0) && (h_errno < h_nerr)) { p = h_errlist[h_errno]; } @@ -59,6 +60,11 @@ void herror(const char *s) #ifdef L_hstrerror const char *hstrerror(int err) { - return(strerror(err)); + if (err < 0) { + return(error_msg); + } else if (err < h_nerr) { + return(h_errlist[err]); + } + return(error_msg); } #endif -- cgit v1.2.3