diff options
Diffstat (limited to 'src/lib/libc/net/getservent.3')
| -rw-r--r-- | src/lib/libc/net/getservent.3 | 163 |
1 files changed, 113 insertions, 50 deletions
diff --git a/src/lib/libc/net/getservent.3 b/src/lib/libc/net/getservent.3 index 9e0656be00..7888b5f1b8 100644 --- a/src/lib/libc/net/getservent.3 +++ b/src/lib/libc/net/getservent.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $NetBSD: getservent.3,v 1.3 1995/02/25 06:20:38 cgd Exp $ | 1 | .\" $OpenBSD: getservent.3,v 1.20 2007/05/31 19:19:30 jmc Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 1983, 1991, 1993 | 3 | .\" Copyright (c) 1983, 1991, 1993 |
| 4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. |
| @@ -11,11 +11,7 @@ | |||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the |
| 13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. |
| 14 | .\" 3. All advertising materials mentioning features or use of this software | 14 | .\" 3. Neither the name of the University nor the names of its contributors |
| 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 | 15 | .\" may be used to endorse or promote products derived from this software |
| 20 | .\" without specific prior written permission. | 16 | .\" without specific prior written permission. |
| 21 | .\" | 17 | .\" |
| @@ -31,41 +27,51 @@ | |||
| 31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. |
| 33 | .\" | 29 | .\" |
| 34 | .\" @(#)getservent.3 8.3 (Berkeley) 1/12/94 | 30 | .Dd $Mdocdate: May 31 2007 $ |
| 35 | .\" | ||
| 36 | .Dd January 12, 1994 | ||
| 37 | .Dt GETSERVENT 3 | 31 | .Dt GETSERVENT 3 |
| 38 | .Os BSD 4.2 | 32 | .Os |
| 39 | .Sh NAME | 33 | .Sh NAME |
| 40 | .Nm getservent , | 34 | .Nm getservent , |
| 35 | .Nm getservent_r , | ||
| 41 | .Nm getservbyport , | 36 | .Nm getservbyport , |
| 37 | .Nm getservbyport_r , | ||
| 42 | .Nm getservbyname , | 38 | .Nm getservbyname , |
| 39 | .Nm getservbyname_r , | ||
| 43 | .Nm setservent , | 40 | .Nm setservent , |
| 44 | .Nm endservent | 41 | .Nm setservent_r , |
| 42 | .Nm endservent , | ||
| 43 | .Nm endservent_r | ||
| 45 | .Nd get service entry | 44 | .Nd get service entry |
| 46 | .Sh SYNOPSIS | 45 | .Sh SYNOPSIS |
| 47 | .Fd #include <netdb.h> | 46 | .Fd #include <netdb.h> |
| 48 | .Ft struct servent * | 47 | .Ft struct servent * |
| 49 | .Fn getservent | 48 | .Fn getservent "void" |
| 49 | .Ft int | ||
| 50 | .Fn getservent_r "struct servent *servent" "struct servent_data *servent_data" | ||
| 50 | .Ft struct servent * | 51 | .Ft struct servent * |
| 51 | .Fn getservbyname "char *name" "char *proto" | 52 | .Fn getservbyname "const char *name" "const char *proto" |
| 53 | .Ft int | ||
| 54 | .Fn getservbyname_r "const char *name" "const char *proto" "struct servent *servent" "struct servent_data *servent_data" | ||
| 52 | .Ft struct servent * | 55 | .Ft struct servent * |
| 53 | .Fn getservbyport "int port" proto | 56 | .Fn getservbyport "int port" "const char *proto" |
| 57 | .Ft int | ||
| 58 | .Fn getservbyport_r "int port" "const char *proto" "struct servent *servent" "struct servent_data *servent_data" | ||
| 54 | .Ft void | 59 | .Ft void |
| 55 | .Fn setservent "int stayopen" | 60 | .Fn setservent "int stayopen" |
| 56 | .Ft void | 61 | .Ft void |
| 57 | .Fn endservent void | 62 | .Fn setservent_r "int stayopen" "struct servent_data *servent_data" |
| 63 | .Ft void | ||
| 64 | .Fn endservent "void" | ||
| 65 | .Ft void | ||
| 66 | .Fn endservent_r "struct servent_data *servent_data" | ||
| 58 | .Sh DESCRIPTION | 67 | .Sh DESCRIPTION |
| 59 | The | 68 | The |
| 60 | .Fn getservent , | 69 | .Fn getservent , |
| 61 | .Fn getservbyname , | 70 | .Fn getservbyname , |
| 62 | and | 71 | and |
| 63 | .Fn getservbyport | 72 | .Fn getservbyport |
| 64 | functions | 73 | functions each return a pointer to an object with the following structure |
| 65 | each return a pointer to an object with the | 74 | containing the broken-out fields of a line in the network services database, |
| 66 | following structure | ||
| 67 | containing the broken-out | ||
| 68 | fields of a line in the network services data base, | ||
| 69 | .Pa /etc/services . | 75 | .Pa /etc/services . |
| 70 | .Bd -literal -offset indent | 76 | .Bd -literal -offset indent |
| 71 | struct servent { | 77 | struct servent { |
| @@ -81,64 +87,113 @@ The members of this structure are: | |||
| 81 | .It Fa s_name | 87 | .It Fa s_name |
| 82 | The official name of the service. | 88 | The official name of the service. |
| 83 | .It Fa s_aliases | 89 | .It Fa s_aliases |
| 84 | A zero terminated list of alternate names for the service. | 90 | A null-terminated list of alternate names for the service. |
| 85 | .It Fa s_port | 91 | .It Fa s_port |
| 86 | The port number at which the service resides. | 92 | The port number at which the service resides. |
| 87 | Port numbers are returned in network byte order. | 93 | Port numbers are returned in network byte order. |
| 88 | .It Fa s_proto | 94 | .It Fa s_proto |
| 89 | The name of the protocol to use when contacting the | 95 | The name of the protocol to use when contacting the service. |
| 90 | service. | ||
| 91 | .El | 96 | .El |
| 92 | .Pp | 97 | .Pp |
| 93 | The | 98 | The |
| 94 | .Fn getservent | 99 | .Fn getservent |
| 95 | function | 100 | function reads the next line of the file, opening the file if necessary. |
| 96 | reads the next line of the file, opening the file if necessary. | ||
| 97 | .Pp | 101 | .Pp |
| 98 | The | 102 | The |
| 99 | .Fn setservent | 103 | .Fn setservent |
| 100 | function | 104 | function opens and rewinds the file. |
| 101 | opens and rewinds the file. If the | 105 | If the |
| 102 | .Fa stayopen | 106 | .Fa stayopen |
| 103 | flag is non-zero, | 107 | flag is non-zero, |
| 104 | the net data base will not be closed after each call to | 108 | the services database will not be closed after each call to |
| 105 | .Fn getservbyname | 109 | .Fn getservbyname |
| 106 | or | 110 | or |
| 107 | .Fn getservbyport . | 111 | .Fn getservbyport . |
| 108 | .Pp | 112 | .Pp |
| 109 | The | 113 | The |
| 110 | .Fn endservent | 114 | .Fn endservent |
| 111 | function | 115 | function closes the file. |
| 112 | closes the file. | ||
| 113 | .Pp | 116 | .Pp |
| 114 | The | 117 | The |
| 115 | .Fn getservbyname | 118 | .Fn getservbyname |
| 116 | and | 119 | and |
| 117 | .Fn getservbyport | 120 | .Fn getservbyport |
| 118 | functions | 121 | functions sequentially search from the beginning of the file until a |
| 119 | sequentially search from the beginning | 122 | matching protocol name or port number (specified in network byte order) |
| 120 | of the file until a matching | 123 | is found, or until |
| 121 | protocol name or | ||
| 122 | port number is found, | ||
| 123 | or until | ||
| 124 | .Dv EOF | 124 | .Dv EOF |
| 125 | is encountered. | 125 | is encountered. |
| 126 | If a protocol name is also supplied (non- | 126 | If a protocol name is also supplied (non-null), |
| 127 | .Dv NULL ) , | ||
| 128 | searches must also match the protocol. | 127 | searches must also match the protocol. |
| 129 | .ne 1i | 128 | .Pp |
| 129 | The | ||
| 130 | .Fn getservent_r , | ||
| 131 | .Fn getservbyport_r , | ||
| 132 | .Fn getservbyname_r , | ||
| 133 | .Fn setservent_r , | ||
| 134 | and | ||
| 135 | .Fn endservent_r | ||
| 136 | functions are reentrant versions of the above functions that take a | ||
| 137 | pointer to a | ||
| 138 | .Fa servent_data | ||
| 139 | structure which is used to store state information. | ||
| 140 | The structure must be zero-filled before it is used | ||
| 141 | and should be considered opaque for the sake of portability. | ||
| 142 | .Pp | ||
| 143 | The | ||
| 144 | .Fn getservent_r , | ||
| 145 | .Fn getservbyport_r , | ||
| 146 | and | ||
| 147 | .Fn getservbyname_r | ||
| 148 | functions | ||
| 149 | also take a pointer to a | ||
| 150 | .Fa servent | ||
| 151 | structure which is used to store the results of the database lookup. | ||
| 152 | .Sh RETURN VALUES | ||
| 153 | The | ||
| 154 | .Fn getservent , | ||
| 155 | .Fn getservbyport , | ||
| 156 | and | ||
| 157 | .Fn getservbyname | ||
| 158 | functions return a pointer to a | ||
| 159 | .Fa servent | ||
| 160 | structure on success or a null pointer if end-of-file | ||
| 161 | is reached or an error occurs. | ||
| 162 | .Pp | ||
| 163 | The | ||
| 164 | .Fn getservent_r , | ||
| 165 | .Fn getservbyport_r , | ||
| 166 | and | ||
| 167 | .Fn getservbyname_r | ||
| 168 | functions return 0 on success or \-1 if end-of-file | ||
| 169 | is reached or an error occurs. | ||
| 130 | .Sh FILES | 170 | .Sh FILES |
| 131 | .Bl -tag -width /etc/services -compact | 171 | .Bl -tag -width /etc/services -compact |
| 132 | .It Pa /etc/services | 172 | .It Pa /etc/services |
| 133 | .El | 173 | .El |
| 134 | .Sh DIAGNOSTICS | ||
| 135 | Null pointer | ||
| 136 | (0) returned on | ||
| 137 | .Dv EOF | ||
| 138 | or error. | ||
| 139 | .Sh SEE ALSO | 174 | .Sh SEE ALSO |
| 140 | .Xr getprotoent 3 , | 175 | .Xr getprotoent 3 , |
| 141 | .Xr services 5 | 176 | .Xr services 5 |
| 177 | .Sh STANDARDS | ||
| 178 | The | ||
| 179 | .Fn getservent , | ||
| 180 | .Fn getservbynumber , | ||
| 181 | .Fn getservbyname , | ||
| 182 | .Fn setservent , | ||
| 183 | and | ||
| 184 | .Fn endservent | ||
| 185 | functions conform to | ||
| 186 | .St -p1003.1-2004 . | ||
| 187 | .Pp | ||
| 188 | The | ||
| 189 | .Fn getservent_r , | ||
| 190 | .Fn getservbyport_r , | ||
| 191 | .Fn getservbyname_r , | ||
| 192 | .Fn setservent_r , | ||
| 193 | and | ||
| 194 | .Fn endservent_r | ||
| 195 | functions are not currently standardized. | ||
| 196 | This implementation follows the API used by HP, IBM, and Digital. | ||
| 142 | .Sh HISTORY | 197 | .Sh HISTORY |
| 143 | The | 198 | The |
| 144 | .Fn getservent , | 199 | .Fn getservent , |
| @@ -147,11 +202,19 @@ The | |||
| 147 | .Fn setservent , | 202 | .Fn setservent , |
| 148 | and | 203 | and |
| 149 | .Fn endservent | 204 | .Fn endservent |
| 150 | functions appeared in | 205 | functions appeared in |
| 151 | .Bx 4.2 . | 206 | .Bx 4.2 . |
| 207 | .Pp | ||
| 208 | The | ||
| 209 | .Fn getservent_r , | ||
| 210 | .Fn getservbyport_r , | ||
| 211 | .Fn getservbyname_r , | ||
| 212 | .Fn setservent_r , | ||
| 213 | and | ||
| 214 | .Fn endservent_r | ||
| 215 | functions appeared in | ||
| 216 | .Ox 3.7 . | ||
| 152 | .Sh BUGS | 217 | .Sh BUGS |
| 153 | These functions use static data storage; | 218 | The non-reentrant functions use static data storage; if the data is needed |
| 154 | if the data is needed for future use, it should be | 219 | for future use, it should be copied before any subsequent calls overwrite it. |
| 155 | copied before any subsequent calls overwrite it. | 220 | Expecting port numbers to fit in a 32-bit quantity is probably naive. |
| 156 | Expecting port numbers to fit in a 32 bit | ||
| 157 | quantity is probably naive. | ||
