diff options
Diffstat (limited to 'src/lib/libc/net/getprotoent.3')
-rw-r--r-- | src/lib/libc/net/getprotoent.3 | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/lib/libc/net/getprotoent.3 b/src/lib/libc/net/getprotoent.3 new file mode 100644 index 0000000000..be257966a2 --- /dev/null +++ b/src/lib/libc/net/getprotoent.3 | |||
@@ -0,0 +1,130 @@ | |||
1 | .\" $OpenBSD: getprotoent.3,v 1.9 2003/06/02 20:18:35 millert 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. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .Dd June 4, 1993 | ||
31 | .Dt GETPROTOENT 3 | ||
32 | .Os | ||
33 | .Sh NAME | ||
34 | .Nm getprotoent , | ||
35 | .Nm getprotobynumber , | ||
36 | .Nm getprotobyname , | ||
37 | .Nm setprotoent , | ||
38 | .Nm endprotoent | ||
39 | .Nd get protocol entry | ||
40 | .Sh SYNOPSIS | ||
41 | .Fd #include <netdb.h> | ||
42 | .Ft struct protoent * | ||
43 | .Fn getprotoent "void" | ||
44 | .Ft struct protoent * | ||
45 | .Fn getprotobyname "char *name" | ||
46 | .Ft struct protoent * | ||
47 | .Fn getprotobynumber "int proto" | ||
48 | .Ft void | ||
49 | .Fn setprotoent "int stayopen" | ||
50 | .Ft void | ||
51 | .Fn endprotoent "void" | ||
52 | .Sh DESCRIPTION | ||
53 | The | ||
54 | .Fn getprotoent , | ||
55 | .Fn getprotobyname , | ||
56 | and | ||
57 | .Fn getprotobynumber | ||
58 | functions each return a pointer to an object with the following structure | ||
59 | containing the broken-out fields of a line in the network protocol database, | ||
60 | .Pa /etc/protocols . | ||
61 | .Bd -literal -offset indent | ||
62 | .Pp | ||
63 | struct protoent { | ||
64 | char *p_name; /* official name of protocol */ | ||
65 | char **p_aliases; /* alias list */ | ||
66 | int p_proto; /* protocol number */ | ||
67 | }; | ||
68 | .Ed | ||
69 | .Pp | ||
70 | The members of this structure are: | ||
71 | .Bl -tag -width p_aliases | ||
72 | .It Fa p_name | ||
73 | The official name of the protocol. | ||
74 | .It Fa p_aliases | ||
75 | A zero-terminated list of alternate names for the protocol. | ||
76 | .It Fa p_proto | ||
77 | The protocol number. | ||
78 | .El | ||
79 | .Pp | ||
80 | The | ||
81 | .Fn getprotoent | ||
82 | function reads the next line of the file, opening the file if necessary. | ||
83 | .Pp | ||
84 | The | ||
85 | .Fn setprotoent | ||
86 | function opens and rewinds the file. | ||
87 | If the | ||
88 | .Fa stayopen | ||
89 | flag is non-zero, | ||
90 | the net database will not be closed after each call to | ||
91 | .Fn getprotobyname | ||
92 | or | ||
93 | .Fn getprotobynumber . | ||
94 | .Pp | ||
95 | The | ||
96 | .Fn endprotoent | ||
97 | function closes the file. | ||
98 | .Pp | ||
99 | The | ||
100 | .Fn getprotobyname | ||
101 | and | ||
102 | .Fn getprotobynumber | ||
103 | functions sequentially search from the beginning of the file until a | ||
104 | matching protocol name or protocol number is found, or until | ||
105 | .Dv EOF | ||
106 | is encountered. | ||
107 | .Sh RETURN VALUES | ||
108 | Null pointer (0) returned on | ||
109 | .Dv EOF | ||
110 | or error. | ||
111 | .Sh FILES | ||
112 | .Bl -tag -width /etc/protocols -compact | ||
113 | .It Pa /etc/protocols | ||
114 | .El | ||
115 | .Sh SEE ALSO | ||
116 | .Xr protocols 5 | ||
117 | .Sh HISTORY | ||
118 | The | ||
119 | .Fn getprotoent , | ||
120 | .Fn getprotobynumber , | ||
121 | .Fn getprotobyname , | ||
122 | .Fn setprotoent , | ||
123 | and | ||
124 | .Fn endprotoent | ||
125 | functions appeared in | ||
126 | .Bx 4.2 . | ||
127 | .Sh BUGS | ||
128 | These functions use a static data space; if the data is needed for future use, | ||
129 | it should be copied before any subsequent calls overwrite it. | ||
130 | Only the Internet protocols are currently understood. | ||