gethostbyaddr.c 340 B

123456789101112131415
  1. #define _GNU_SOURCE
  2. #include <netdb.h>
  3. #include <string.h>
  4. #include <netinet/in.h>
  5. struct hostent *gethostbyaddr(const void *a, socklen_t l, int af)
  6. {
  7. static struct hostent h;
  8. static long buf[512/sizeof(long)];
  9. struct hostent *res;
  10. if (gethostbyaddr_r(a, l, af, &h,
  11. (void *)buf, sizeof buf, &res, &h_errno)) return 0;
  12. return &h;
  13. }