from the ANSI standard
[unix-history] / usr / src / lib / libc / net / getprotoent.3
CommitLineData
56e6bd55
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
d148e37f 3.\"
56e6bd55
KB
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
d148e37f 15.\"
56e6bd55
KB
16.\" @(#)getprotoent.3 6.4 (Berkeley) %G%
17.\"
18.TH GETPROTOENT 3 ""
d148e37f
KM
19.UC 5
20.SH NAME
56e6bd55
KB
21getprotoent, getprotobynumber, getprotobyname, setprotoent,
22endprotoent \- get protocol entry
d148e37f
KM
23.SH SYNOPSIS
24.nf
25.ft B
26.B #include <netdb.h>
27.PP
28.ft B
29struct protoent *getprotoent()
30.PP
31.ft B
32struct protoent *getprotobyname(name)
33char *name;
34.PP
35.ft B
36struct protoent *getprotobynumber(proto)
37int proto;
38.PP
39.ft B
40setprotoent(stayopen)
41int stayopen
42.PP
43.ft B
44endprotoent()
45.fi
46.SH DESCRIPTION
47.IR Getprotoent ,
48.IR getprotobyname ,
49and
50.I getprotobynumber
51each return a pointer to an object with the
52following structure
53containing the broken-out
54fields of a line in the network protocol data base,
55.IR /etc/protocols .
56.RS
57.PP
58.nf
59struct protoent {
60 char *p_name; /* official name of protocol */
61 char **p_aliases; /* alias list */
50159ed7 62 int p_proto; /* protocol number */
d148e37f
KM
63};
64.ft R
65.ad
66.fi
67.RE
68.PP
69The members of this structure are:
70.TP \w'p_aliases'u+2n
71p_name
72The official name of the protocol.
73.TP \w'p_aliases'u+2n
74p_aliases
75A zero terminated list of alternate names for the protocol.
76.TP \w'p_aliases'u+2n
77p_proto
78The protocol number.
79.PP
80.I Getprotoent
81reads the next line of the file, opening the file if necessary.
82.PP
83.I Setprotoent
84opens and rewinds the file. If the
85.I stayopen
86flag is non-zero,
87the net data base will not be closed after each call to
ec178508
JL
88.I getprotobyname
89or
90.IR getprotobynumber .
d148e37f
KM
91.PP
92.I Endprotoent
93closes the file.
94.PP
95.I Getprotobyname
96and
97.I getprotobynumber
98sequentially search from the beginning
99of the file until a matching
100protocol name or
101protocol number is found,
102or until EOF is encountered.
103.SH FILES
104/etc/protocols
105.SH "SEE ALSO"
106protocols(5)
107.SH DIAGNOSTICS
108Null pointer
109(0) returned on EOF or error.
110.SH BUGS
111All information
112is contained in a static area
113so it must be copied if it is
114to be saved. Only the Internet
115protocols are currently understood.