1 /* $Id: hstrerror.c 5556 2002-08-11 22:23:14Z rra $
3 ** Replacement for a missing hstrerror.
5 ** Written by Russ Allbery <rra@stanford.edu>
6 ** This work is hereby placed in the public domain by its author.
8 ** Provides hstrerror (strerror, but for h_errno from the resolver
9 ** libraries) on those platforms that don't have it (most non-BSD). This
10 ** function is thread-safe unless called with an unknown h_errno.
17 static const char * const errors[] = {
18 "No resolver error", /* 0 NETDB_SUCCESS */
19 "Unknown host", /* 1 HOST_NOT_FOUND */
20 "Host name lookup failure", /* 2 TRY_AGAIN */
21 "Unknown server error", /* 3 NO_RECOVERY */
22 "No address associated with name", /* 4 NO_ADDRESS / NO_DATA */
24 static int nerrors = (sizeof errors / sizeof errors[0]);
26 /* If we're running the test suite, rename hstrerror to avoid conflicts with
27 the system version. */
29 # define hstrerror test_hstrerror
30 const char *test_hstrerror(int);
39 return "Internal resolver error";
40 if (error >= 0 && error < nerrors)
42 snprintf(buf, sizeof(buf), "Resolver error %d", error);