getservbyname_r.c 933 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. ** Copyright 2002 University of Illinois Board of Trustees
  3. ** Copyright 2002 Mark D. Roth
  4. ** All rights reserved.
  5. **
  6. ** getservbyname_r.c - getservbyname_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_getservbyname_r(const char *name, const char *proto,
  18. struct servent *sp, char *buf, size_t buflen,
  19. struct servent **spp)
  20. {
  21. #if GETSERVBYNAME_R_NUM_ARGS == 5
  22. *spp = getservbyname_r(name, proto, sp, buf, buflen);
  23. if (*spp == NULL)
  24. return -1;
  25. return 0;
  26. #elif GETSERVBYNAME_R_NUM_ARGS == 4
  27. struct servent_data sdata;
  28. if (getservbyname_r(name, proto, sp, &sdata) == -1)
  29. return -1;
  30. *spp = sp;
  31. return 0;
  32. #endif /* GETSERVBYNAME_R_NUM_ARGS == 5 */
  33. }