Mercurial > notdcc
view 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 |
line wrap: on
line source
/* compatibility hack for old systems that don't have hstrerror() */ #include "dcc_defs.h" #include <stdio.h> static const char *h_errlist[] = { "Resolver Error 0 (no error)", "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 */ }; #define H_NERR ((int)(sizeof(h_errlist)/sizeof( h_errlist[0]))) const char * dcc_hstrerror(int err) { static char buf[64]; if (err < 0 || err > H_NERR || h_errlist[err] == NULL) { snprintf(buf, sizeof(buf), "Error %d", err); return buf; } return h_errlist[err]; }