new copyright notice
[unix-history] / usr / src / lib / libc / net / getservbyport.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#if defined(LIBC_SCCS) && !defined(lint)
9static char sccsid[] = "@(#)getservbyport.c 5.6 (Berkeley) %G%";
10#endif /* LIBC_SCCS and not lint */
11
12#include <netdb.h>
13
14extern int _serv_stayopen;
15
16struct servent *
17getservbyport(port, proto)
18 int port;
19 char *proto;
20{
21 register struct servent *p;
22
23 setservent(_serv_stayopen);
24 while (p = getservent()) {
25 if (p->s_port != port)
26 continue;
27 if (proto == 0 || strcmp(p->s_proto, proto) == 0)
28 break;
29 }
30 if (!_serv_stayopen)
31 endservent();
32 return (p);
33}