gethostbyname_r.c 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. ** Copyright 2002 University of Illinois Board of Trustees
  3. ** Copyright 2002 Mark D. Roth
  4. ** All rights reserved.
  5. **
  6. ** gethostbyname_r.c - gethostbyname_r() function for compatibility library
  7. **
  8. ** Mark D. Roth <[email protected]>
  9. ** Campus Information Technologies and Educational Services
  10. ** University of Illinois at Urbana-Champaign
  11. */
  12. #include <config.h>
  13. #include <stdio.h>
  14. #include <sys/types.h>
  15. #include <netdb.h>
  16. int
  17. compat_gethostbyname_r(const char *name, struct hostent *hp,
  18. char *buf, size_t buflen,
  19. struct hostent **hpp, int *herr)
  20. {
  21. #if GETHOSTBYNAME_R_NUM_ARGS == 5
  22. *hpp = gethostbyname_r(name, hp, buf, buflen, herr);
  23. if (*hpp == NULL)
  24. return -1;
  25. return 0;
  26. #elif GETHOSTBYNAME_R_NUM_ARGS == 3
  27. struct hostent_data hdata;
  28. if (gethostbyname_r(name, hp, &hdata) == -1)
  29. return -1;
  30. *hpp = hp;
  31. return 0;
  32. #endif /* GETHOSTBYNAME_R_NUM_ARGS == 5 */
  33. }