BSD 4_3_Tahoe release
[unix-history] / usr / src / man / man3 / getprotoent.3
CommitLineData
d148e37f
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
95f51977 5.\" @(#)getprotoent.3n 6.3 (Berkeley) 5/19/86
d148e37f 6.\"
95f51977 7.TH GETPROTOENT 3N "May 19, 1986"
d148e37f
KM
8.UC 5
9.SH NAME
10getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent \- get protocol entry
11.SH SYNOPSIS
12.nf
13.ft B
14.B #include <netdb.h>
15.PP
16.ft B
17struct protoent *getprotoent()
18.PP
19.ft B
20struct protoent *getprotobyname(name)
21char *name;
22.PP
23.ft B
24struct protoent *getprotobynumber(proto)
25int proto;
26.PP
27.ft B
28setprotoent(stayopen)
29int stayopen
30.PP
31.ft B
32endprotoent()
33.fi
34.SH DESCRIPTION
35.IR Getprotoent ,
36.IR getprotobyname ,
37and
38.I getprotobynumber
39each return a pointer to an object with the
40following structure
41containing the broken-out
42fields of a line in the network protocol data base,
43.IR /etc/protocols .
44.RS
45.PP
46.nf
47struct protoent {
48 char *p_name; /* official name of protocol */
49 char **p_aliases; /* alias list */
50159ed7 50 int p_proto; /* protocol number */
d148e37f
KM
51};
52.ft R
53.ad
54.fi
55.RE
56.PP
57The members of this structure are:
58.TP \w'p_aliases'u+2n
59p_name
60The official name of the protocol.
61.TP \w'p_aliases'u+2n
62p_aliases
63A zero terminated list of alternate names for the protocol.
64.TP \w'p_aliases'u+2n
65p_proto
66The protocol number.
67.PP
68.I Getprotoent
69reads the next line of the file, opening the file if necessary.
70.PP
71.I Setprotoent
72opens and rewinds the file. If the
73.I stayopen
74flag is non-zero,
75the net data base will not be closed after each call to
ec178508
JL
76.I getprotobyname
77or
78.IR getprotobynumber .
d148e37f
KM
79.PP
80.I Endprotoent
81closes the file.
82.PP
83.I Getprotobyname
84and
85.I getprotobynumber
86sequentially search from the beginning
87of the file until a matching
88protocol name or
89protocol number is found,
90or until EOF is encountered.
91.SH FILES
92/etc/protocols
93.SH "SEE ALSO"
94protocols(5)
95.SH DIAGNOSTICS
96Null pointer
97(0) returned on EOF or error.
98.SH BUGS
99All information
100is contained in a static area
101so it must be copied if it is
102to be saved. Only the Internet
103protocols are currently understood.