wraplib.c 766 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Wrapper functions for our own library functions.
  3. * Most are included in the source file for the function itself.
  4. */
  5. #include "unp.h"
  6. const char *
  7. Inet_ntop(int family, const void *addrptr, char *strptr, size_t len)
  8. {
  9. const char *ptr;
  10. if (strptr == NULL) /* check for old code */
  11. err_quit("NULL 3rd argument to inet_ntop");
  12. if ( (ptr = inet_ntop(family, addrptr, strptr, len)) == NULL)
  13. err_sys("inet_ntop error"); /* sets errno */
  14. return(ptr);
  15. }
  16. void
  17. Inet_pton(int family, const char *strptr, void *addrptr)
  18. {
  19. int n;
  20. if ( (n = inet_pton(family, strptr, addrptr)) < 0)
  21. err_sys("inet_pton error for %s", strptr); /* errno set */
  22. else if (n == 0)
  23. err_quit("inet_pton error for %s", strptr); /* errno not set */
  24. /* nothing to return */
  25. }