5
/* name service lookup error code to string
9
/* const char *dns_strerror(code)
12
/* dns_strerror() maps a name service lookup error to printable string.
13
/* The result is for read-only purposes, and unknown codes share a
14
/* common string buffer.
18
/* The Secure Mailer license must be distributed with this software.
21
/* IBM T.J. Watson Research
23
/* Yorktown Heights, NY 10598, USA
31
/* Utility library. */
40
* Mapping from error code to printable string. The herror() routine does
41
* something similar, but has output only to the stderr stream.
43
struct dns_error_map {
48
static struct dns_error_map dns_error_map[] = {
49
HOST_NOT_FOUND, "Host not found",
50
TRY_AGAIN, "Host not found, try again",
51
NO_RECOVERY, "Non-recoverable error",
52
NO_DATA, "Host found but no data record of requested type",
55
/* dns_strerror - map resolver error code to printable string */
57
const char *dns_strerror(unsigned error)
59
static VSTRING *unknown = 0;
62
for (i = 0; i < sizeof(dns_error_map) / sizeof(dns_error_map[0]); i++)
63
if (dns_error_map[i].error == error)
64
return (dns_error_map[i].text);
66
unknown = vstring_alloc(sizeof("Unknown error XXXXXX"));
67
vstring_sprintf(unknown, "Unknown error %u", error);
68
return (vstring_str(unknown));