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