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