/* herror.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */

#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>

extern int h_errno;

void herror (const char *string)
{
  int e = h_errno;
  const char *msg;

  if (string != NULL && *string != 0)
    {
      fputs (string, stderr);
      fputs (": ", stderr);
    }
  switch (e)
    {
    case 0:
      msg = "Error 0";
      break;
    case HOST_NOT_FOUND:
      msg = "Host not found";
      break;
    case TRY_AGAIN:
      msg = "Host name lookup failure";
      break;
    case NO_RECOVERY:
      msg = "Unknown server error";
      break;
    case NO_DATA:
      msg = "No address associated with name";
      break;
    default:
      fprintf (stderr, "Unknown error %d\n", e);
      return;
    }
  fputs (msg, stderr);
  fputc ('\n', stderr);
}
