comparison dcclib/hstrerror.c @ 0:c7f6b056b673

First import of vendor version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 13:49:58 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c7f6b056b673
1 /* compatibility hack for old systems that don't have hstrerror() */
2
3 #include "dcc_defs.h"
4
5 #include <stdio.h>
6
7 static const char *h_errlist[] = {
8 "Resolver Error 0 (no error)",
9 "Unknown host", /* 1 HOST_NOT_FOUND */
10 "Host name lookup failure", /* 2 TRY_AGAIN */
11 "Unknown server error", /* 3 NO_RECOVERY */
12 "No address associated with name", /* 4 NO_ADDRESS */
13 };
14 #define H_NERR ((int)(sizeof(h_errlist)/sizeof( h_errlist[0])))
15
16 const char *
17 dcc_hstrerror(int err)
18 {
19 static char buf[64];
20
21 if (err < 0 || err > H_NERR || h_errlist[err] == NULL) {
22 snprintf(buf, sizeof(buf), "Error %d", err);
23 return buf;
24 }
25 return h_errlist[err];
26 }