summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libugly/getservbyport_r.c
blob: 9c0f21bdfe5dbb6e28db5c25a3062d3844c6cca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string.h>
#include <netdb.h>

extern int getservbyport_r(int port,const char* proto,
			   struct servent *res, char *buf, size_t buflen,
			   struct servent **res_sig) {
  while (!getservent_r(res,buf,buflen,res_sig))
    if (port==res->s_port && !strcmp(res->s_proto,proto)) goto ok;
  *res_sig=0;
ok:
  endservent();
  return *res_sig?0:-1;
}