hstrerror.c 530 B

12345678910111213141516171819202122
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <netdb.h>
  4. const char *githstrerror(int err)
  5. {
  6. static char buffer[48];
  7. switch (err)
  8. {
  9. case HOST_NOT_FOUND:
  10. return "Authoritative answer: host not found";
  11. case NO_DATA:
  12. return "Valid name, no data record of requested type";
  13. case NO_RECOVERY:
  14. return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
  15. case TRY_AGAIN:
  16. return "Non-authoritative \"host not found\", or SERVERFAIL";
  17. }
  18. snprintf(buffer, sizeof(buffer), "Name resolution error %d", err);
  19. return buffer;
  20. }