view dcclib/hstrerror.c @ 5:0a7a5940ee3a

Change description per license
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 15:03:24 +0100
parents c7f6b056b673
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];
}