hstrerror.c 319 B

12345678910111213141516
  1. #define _GNU_SOURCE
  2. #include <netdb.h>
  3. static const char msgs[] =
  4. "Host not found\0"
  5. "Try again\0"
  6. "Non-recoverable error\0"
  7. "Address not available\0"
  8. "\0Unknown error";
  9. const char *hstrerror(int ecode)
  10. {
  11. const char *s;
  12. for (s=msgs, ecode--; ecode && *s; ecode--, s++) for (; *s; s++);
  13. return *s ? s : s+1;
  14. }