diff options
Diffstat (limited to 'src/lib/libc/net/getservent.3')
-rw-r--r-- | src/lib/libc/net/getservent.3 | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/lib/libc/net/getservent.3 b/src/lib/libc/net/getservent.3 new file mode 100644 index 0000000000..72201126f8 --- /dev/null +++ b/src/lib/libc/net/getservent.3 | |||
@@ -0,0 +1,137 @@ | |||
1 | .\" $OpenBSD: getservent.3,v 1.12 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 January 12, 1994 | ||
31 | .Dt GETSERVENT 3 | ||
32 | .Os | ||
33 | .Sh NAME | ||
34 | .Nm getservent , | ||
35 | .Nm getservbyport , | ||
36 | .Nm getservbyname , | ||
37 | .Nm setservent , | ||
38 | .Nm endservent | ||
39 | .Nd get service entry | ||
40 | .Sh SYNOPSIS | ||
41 | .Fd #include <netdb.h> | ||
42 | .Ft struct servent * | ||
43 | .Fn getservent "void" | ||
44 | .Ft struct servent * | ||
45 | .Fn getservbyname "char *name" "char *proto" | ||
46 | .Ft struct servent * | ||
47 | .Fn getservbyport "int port" "char *proto" | ||
48 | .Ft void | ||
49 | .Fn setservent "int stayopen" | ||
50 | .Ft void | ||
51 | .Fn endservent "void" | ||
52 | .Sh DESCRIPTION | ||
53 | The | ||
54 | .Fn getservent , | ||
55 | .Fn getservbyname , | ||
56 | and | ||
57 | .Fn getservbyport | ||
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 services database, | ||
60 | .Pa /etc/services . | ||
61 | .Bd -literal -offset indent | ||
62 | struct servent { | ||
63 | char *s_name; /* official name of service */ | ||
64 | char **s_aliases; /* alias list */ | ||
65 | int s_port; /* port service resides at */ | ||
66 | char *s_proto; /* protocol to use */ | ||
67 | }; | ||
68 | .Ed | ||
69 | .Pp | ||
70 | The members of this structure are: | ||
71 | .Bl -tag -width s_aliases | ||
72 | .It Fa s_name | ||
73 | The official name of the service. | ||
74 | .It Fa s_aliases | ||
75 | A zero-terminated list of alternate names for the service. | ||
76 | .It Fa s_port | ||
77 | The port number at which the service resides. | ||
78 | Port numbers are returned in network byte order. | ||
79 | .It Fa s_proto | ||
80 | The name of the protocol to use when contacting the service. | ||
81 | .El | ||
82 | .Pp | ||
83 | The | ||
84 | .Fn getservent | ||
85 | function reads the next line of the file, opening the file if necessary. | ||
86 | .Pp | ||
87 | The | ||
88 | .Fn setservent | ||
89 | function opens and rewinds the file. | ||
90 | If the | ||
91 | .Fa stayopen | ||
92 | flag is non-zero, | ||
93 | the net database will not be closed after each call to | ||
94 | .Fn getservbyname | ||
95 | or | ||
96 | .Fn getservbyport . | ||
97 | .Pp | ||
98 | The | ||
99 | .Fn endservent | ||
100 | function closes the file. | ||
101 | .Pp | ||
102 | The | ||
103 | .Fn getservbyname | ||
104 | and | ||
105 | .Fn getservbyport | ||
106 | functions sequentially search from the beginning of the file until a | ||
107 | matching protocol name or port number (specified in network byte order) | ||
108 | is found, or until | ||
109 | .Dv EOF | ||
110 | is encountered. | ||
111 | If a protocol name is also supplied (non-null), | ||
112 | searches must also match the protocol. | ||
113 | .Sh FILES | ||
114 | .Bl -tag -width /etc/services -compact | ||
115 | .It Pa /etc/services | ||
116 | .El | ||
117 | .Sh DIAGNOSTICS | ||
118 | Null pointer (0) returned on | ||
119 | .Dv EOF | ||
120 | or error. | ||
121 | .Sh SEE ALSO | ||
122 | .Xr getprotoent 3 , | ||
123 | .Xr services 5 | ||
124 | .Sh HISTORY | ||
125 | The | ||
126 | .Fn getservent , | ||
127 | .Fn getservbyport , | ||
128 | .Fn getservbyname , | ||
129 | .Fn setservent , | ||
130 | and | ||
131 | .Fn endservent | ||
132 | functions appeared in | ||
133 | .Bx 4.2 . | ||
134 | .Sh BUGS | ||
135 | These functions use static data storage; if the data is needed for future use, | ||
136 | it should be copied before any subsequent calls overwrite it. | ||
137 | Expecting port numbers to fit in a 32-bit quantity is probably naive. | ||