getprotoname.c (51295a4d3e4c551df85249433c490208dc7fd23d) getprotoname.c (8fb3f3f68288ae2b1b53dd65e3dd673d83c80f4c)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 20 unchanged lines hidden (view full) ---

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 20 unchanged lines hidden (view full) ---

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD$");
37
38#include <netdb.h>
39#include <string.h>
40
41extern int _proto_stayopen;
42
43struct protoent *
44getprotobyname(name)
39
40#include <netdb.h>
41#include <string.h>
42
43extern int _proto_stayopen;
44
45struct protoent *
46getprotobyname(name)
45 register const char *name;
47 const char *name;
46{
48{
47 register struct protoent *p;
48 register char **cp;
49 struct protoent *p;
50 char **cp;
49
50 setprotoent(_proto_stayopen);
51 while ( (p = getprotoent()) ) {
52 if (strcmp(p->p_name, name) == 0)
53 break;
54 for (cp = p->p_aliases; *cp != 0; cp++)
55 if (strcmp(*cp, name) == 0)
56 goto found;
57 }
58found:
59 if (!_proto_stayopen)
60 endprotoent();
61 return (p);
62}
51
52 setprotoent(_proto_stayopen);
53 while ( (p = getprotoent()) ) {
54 if (strcmp(p->p_name, name) == 0)
55 break;
56 for (cp = p->p_aliases; *cp != 0; cp++)
57 if (strcmp(*cp, name) == 0)
58 goto found;
59 }
60found:
61 if (!_proto_stayopen)
62 endprotoent();
63 return (p);
64}