1.\" $NetBSD: getprotoent.3,v 1.9 2002/02/07 07:00:20 ross Exp $ 2.\" 3.\" Copyright (c) 1983, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 35.\" 36.Dd June 4, 1993 37.Dt GETPROTOENT 3 38.Os 39.Sh NAME 40.Nm getprotoent , 41.Nm getprotobynumber , 42.Nm getprotobyname , 43.Nm setprotoent , 44.Nm endprotoent 45.Nd get protocol entry 46.Sh LIBRARY 47.Lb libc 48.Sh SYNOPSIS 49.Fd #include \*[Lt]netdb.h\*[Gt] 50.Ft struct protoent * 51.Fn getprotoent 52.Ft struct protoent * 53.Fn getprotobyname "const char *name" 54.Ft struct protoent * 55.Fn getprotobynumber "int proto" 56.Fn setprotoent "int stayopen" 57.Fn endprotoent 58.Sh DESCRIPTION 59The 60.Fn getprotoent , 61.Fn getprotobyname , 62and 63.Fn getprotobynumber 64functions 65each return a pointer to an object with the 66following structure 67containing the broken-out 68fields of a line in the network protocol data base, 69.Pa /etc/protocols . 70.Bd -literal -offset indent 71.Pp 72struct protoent { 73 char *p_name; /* official name of protocol */ 74 char **p_aliases; /* alias list */ 75 int p_proto; /* protocol number */ 76}; 77.Ed 78.Pp 79The members of this structure are: 80.Bl -tag -width p_aliases 81.It Fa p_name 82The official name of the protocol. 83.It Fa p_aliases 84A zero terminated list of alternative names for the protocol. 85.It Fa p_proto 86The protocol number. 87.El 88.Pp 89The 90.Fn getprotoent 91function 92reads the next line of the file, opening the file if necessary. 93.Pp 94The 95.Fn setprotoent 96function 97opens and rewinds the file. If the 98.Fa stayopen 99flag is non-zero, 100the net data base will not be closed after each call to 101.Fn getprotobyname 102or 103.Fn getprotobynumber . 104.Pp 105The 106.Fn endprotoent 107function 108closes the file. 109.Pp 110The 111.Fn getprotobyname 112function 113and 114.Fn getprotobynumber 115sequentially search from the beginning 116of the file until a matching 117protocol name or 118protocol number is found, 119or until 120.Dv EOF 121is encountered. 122.Sh RETURN VALUES 123Null pointer 124(0) returned on 125.Dv EOF 126or error. 127.Sh FILES 128.Bl -tag -width /etc/protocols -compact 129.It Pa /etc/protocols 130.El 131.Sh SEE ALSO 132.Xr protocols 5 133.Sh HISTORY 134The 135.Fn getprotoent , 136.Fn getprotobynumber , 137.Fn getprotobyname , 138.Fn setprotoent , 139and 140.Fn endprotoent 141functions appeared in 142.Bx 4.2 . 143.Sh BUGS 144These functions use a static data space; 145if the data is needed for future use, it should be 146copied before any subsequent calls overwrite it. 147Only the Internet 148protocols are currently understood. 149