xref: /original-bsd/lib/libc/net/getprotoent.3 (revision c3e32dec)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)getprotoent.3	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt GETPROTOENT 3
10.Os BSD 4.2
11.Sh NAME
12.Nm getprotoent ,
13.Nm getprotobynumber ,
14.Nm getprotobyname ,
15.Nm setprotoent ,
16.Nm endprotoent
17.Nd get protocol entry
18.Sh SYNOPSIS
19.Fd #include <netdb.h>
20.Ft struct protoent *
21.Fn getprotoent
22.Ft struct protoent *
23.Fn getprotobyname "char *name"
24.Ft struct protoent *
25.Fn getprotobynumber "int proto"
26.Fn setprotoent "int stayopen"
27.Fn endprotoent
28.Sh DESCRIPTION
29The
30.Fn getprotoent ,
31.Fn getprotobyname ,
32and
33.Fn getprotobynumber
34functions
35each return a pointer to an object with the
36following structure
37containing the broken-out
38fields of a line in the network protocol data base,
39.Pa /etc/protocols .
40.Bd -literal -offset indent
41.Pp
42struct	protoent {
43	char	*p_name;	/* official name of protocol */
44	char	**p_aliases;	/* alias list */
45	int	p_proto;	/* protocol number */
46};
47.Ed
48.Pp
49The members of this structure are:
50.Bl -tag -width p_aliases
51.It Fa p_name
52The official name of the protocol.
53.It Fa p_aliases
54A zero terminated list of alternate names for the protocol.
55.It Fa p_proto
56The protocol number.
57.El
58.Pp
59The
60.Fn getprotoent
61function
62reads the next line of the file, opening the file if necessary.
63.Pp
64The
65.Fn setprotoent
66function
67opens and rewinds the file.  If the
68.Fa stayopen
69flag is non-zero,
70the net data base will not be closed after each call to
71.Fn getprotobyname
72or
73.Fn getprotobynumber .
74.Pp
75The
76.Fn endprotoent
77function
78closes the file.
79.Pp
80The
81.Fn getprotobyname
82function
83and
84.Fn getprotobynumber
85sequentially search from the beginning
86of the file until a matching
87protocol name or
88protocol number is found,
89or until
90.Dv EOF
91is encountered.
92.Sh RETURN VALUES
93Null pointer
94(0) returned on
95.Dv EOF
96or error.
97.Sh FILES
98.Bl -tag -width /etc/protocols -compact
99.It Pa /etc/protocols
100.El
101.Sh SEE ALSO
102.Xr protocols 5
103.Sh HISTORY
104The
105.Fn getprotoent ,
106.Fn getprotobynumber ,
107.Fn getprotobyname ,
108.Fn setprotoent ,
109and
110.Fn endprotoent
111functions appeared in
112.Bx 4.2 .
113.Sh BUGS
114These functions use a static data space;
115if the data is needed for future use, it should be
116copied before any subsequent calls overwrite it.
117Only the Internet
118protocols are currently understood.
119