getservbyname.c 278 B

123456789101112
  1. #define _GNU_SOURCE
  2. #include <netdb.h>
  3. struct servent *getservbyname(const char *name, const char *prots)
  4. {
  5. static struct servent se;
  6. static char *buf[2];
  7. struct servent *res;
  8. if (getservbyname_r(name, prots, &se, (void *)buf, sizeof buf, &res))
  9. return 0;
  10. return &se;
  11. }