diff options
Diffstat (limited to 'src/lib/libc/net/getprotoent.3')
| -rw-r--r-- | src/lib/libc/net/getprotoent.3 | 153 |
1 files changed, 110 insertions, 43 deletions
diff --git a/src/lib/libc/net/getprotoent.3 b/src/lib/libc/net/getprotoent.3 index 8d607199ef..df4cd0c323 100644 --- a/src/lib/libc/net/getprotoent.3 +++ b/src/lib/libc/net/getprotoent.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $NetBSD: getprotoent.3,v 1.3 1995/02/25 06:20:34 cgd Exp $ | 1 | .\" $OpenBSD: getprotoent.3,v 1.17 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,39 +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 | .\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 | 30 | .Dd $Mdocdate: May 31 2007 $ |
| 35 | .\" | ||
| 36 | .Dd June 4, 1993 | ||
| 37 | .Dt GETPROTOENT 3 | 31 | .Dt GETPROTOENT 3 |
| 38 | .Os BSD 4.2 | 32 | .Os |
| 39 | .Sh NAME | 33 | .Sh NAME |
| 40 | .Nm getprotoent , | 34 | .Nm getprotoent , |
| 35 | .Nm getprotoent_r , | ||
| 41 | .Nm getprotobynumber , | 36 | .Nm getprotobynumber , |
| 37 | .Nm getprotobynumber_r , | ||
| 42 | .Nm getprotobyname , | 38 | .Nm getprotobyname , |
| 39 | .Nm getprotobyname_r , | ||
| 43 | .Nm setprotoent , | 40 | .Nm setprotoent , |
| 44 | .Nm endprotoent | 41 | .Nm setprotoent_r , |
| 42 | .Nm endprotoent , | ||
| 43 | .Nm endprotoent_r | ||
| 45 | .Nd get protocol entry | 44 | .Nd get protocol entry |
| 46 | .Sh SYNOPSIS | 45 | .Sh SYNOPSIS |
| 47 | .Fd #include <netdb.h> | 46 | .Fd #include <netdb.h> |
| 48 | .Ft struct protoent * | 47 | .Ft struct protoent * |
| 49 | .Fn getprotoent | 48 | .Fn getprotoent "void" |
| 49 | .Ft int | ||
| 50 | .Fn getprotoent_r "struct protoent *protoent" "struct protoent_data *protoent_data" | ||
| 50 | .Ft struct protoent * | 51 | .Ft struct protoent * |
| 51 | .Fn getprotobyname "char *name" | 52 | .Fn getprotobyname "const char *name" |
| 53 | .Ft int | ||
| 54 | .Fn getprotobyname_r "const char *name" "struct protoent *protoent" "struct protoent_data *protoent_data" | ||
| 52 | .Ft struct protoent * | 55 | .Ft struct protoent * |
| 53 | .Fn getprotobynumber "int proto" | 56 | .Fn getprotobynumber "int proto" |
| 57 | .Ft int | ||
| 58 | .Fn getprotobynumber_r "int proto" "struct protoent *protoent" "struct protoent_data *protoent_data" | ||
| 59 | .Ft void | ||
| 54 | .Fn setprotoent "int stayopen" | 60 | .Fn setprotoent "int stayopen" |
| 55 | .Fn endprotoent | 61 | .Ft void |
| 62 | .Fn setprotoent_r "int stayopen" "struct protoent_data *protoent_data" | ||
| 63 | .Ft void | ||
| 64 | .Fn endprotoent "void" | ||
| 65 | .Ft void | ||
| 66 | .Fn endprotoent_r "struct protoent_data *protoent_data" | ||
| 56 | .Sh DESCRIPTION | 67 | .Sh DESCRIPTION |
| 57 | The | 68 | The |
| 58 | .Fn getprotoent , | 69 | .Fn getprotoent , |
| 59 | .Fn getprotobyname , | 70 | .Fn getprotobyname , |
| 60 | and | 71 | and |
| 61 | .Fn getprotobynumber | 72 | .Fn getprotobynumber |
| 62 | functions | 73 | functions each return a pointer to an object with the following structure |
| 63 | each return a pointer to an object with the | 74 | containing the broken-out fields of a line in the network protocol database, |
| 64 | following structure | ||
| 65 | containing the broken-out | ||
| 66 | fields of a line in the network protocol data base, | ||
| 67 | .Pa /etc/protocols . | 75 | .Pa /etc/protocols . |
| 68 | .Bd -literal -offset indent | 76 | .Bd -literal -offset indent |
| 69 | .Pp | 77 | .Pp |
| @@ -79,55 +87,106 @@ The members of this structure are: | |||
| 79 | .It Fa p_name | 87 | .It Fa p_name |
| 80 | The official name of the protocol. | 88 | The official name of the protocol. |
| 81 | .It Fa p_aliases | 89 | .It Fa p_aliases |
| 82 | A zero terminated list of alternate names for the protocol. | 90 | A null-terminated list of alternate names for the protocol. |
| 83 | .It Fa p_proto | 91 | .It Fa p_proto |
| 84 | The protocol number. | 92 | The protocol number. |
| 85 | .El | 93 | .El |
| 86 | .Pp | 94 | .Pp |
| 87 | The | 95 | The |
| 88 | .Fn getprotoent | 96 | .Fn getprotoent |
| 89 | function | 97 | function reads the next line of the file, opening the file if necessary. |
| 90 | reads the next line of the file, opening the file if necessary. | ||
| 91 | .Pp | 98 | .Pp |
| 92 | The | 99 | The |
| 93 | .Fn setprotoent | 100 | .Fn setprotoent |
| 94 | function | 101 | function opens and rewinds the file. |
| 95 | opens and rewinds the file. If the | 102 | If the |
| 96 | .Fa stayopen | 103 | .Fa stayopen |
| 97 | flag is non-zero, | 104 | flag is non-zero, |
| 98 | the net data base will not be closed after each call to | 105 | the protocol database will not be closed after each call to |
| 99 | .Fn getprotobyname | 106 | .Fn getprotobyname |
| 100 | or | 107 | or |
| 101 | .Fn getprotobynumber . | 108 | .Fn getprotobynumber . |
| 102 | .Pp | 109 | .Pp |
| 103 | The | 110 | The |
| 104 | .Fn endprotoent | 111 | .Fn endprotoent |
| 105 | function | 112 | function closes the file. |
| 106 | closes the file. | ||
| 107 | .Pp | 113 | .Pp |
| 108 | The | 114 | The |
| 109 | .Fn getprotobyname | 115 | .Fn getprotobyname |
| 110 | function | ||
| 111 | and | 116 | and |
| 112 | .Fn getprotobynumber | 117 | .Fn getprotobynumber |
| 113 | sequentially search from the beginning | 118 | functions sequentially search from the beginning of the file until a |
| 114 | of the file until a matching | 119 | matching protocol name or protocol number is found, or until |
| 115 | protocol name or | ||
| 116 | protocol number is found, | ||
| 117 | or until | ||
| 118 | .Dv EOF | 120 | .Dv EOF |
| 119 | is encountered. | 121 | is encountered. |
| 122 | .Pp | ||
| 123 | The | ||
| 124 | .Fn getprotoent_r , | ||
| 125 | .Fn getprotobyport_r , | ||
| 126 | .Fn getprotobyname_r , | ||
| 127 | .Fn setprotoent_r , | ||
| 128 | and | ||
| 129 | .Fn endprotoent_r | ||
| 130 | functions are reentrant versions of the above functions that take a | ||
| 131 | pointer to a | ||
| 132 | .Vt protoent_data | ||
| 133 | structure which is used to store state information. | ||
| 134 | The structure must be zero-filled before it is used | ||
| 135 | and should be considered opaque for the sake of portability. | ||
| 136 | .Pp | ||
| 137 | The | ||
| 138 | .Fn getprotoent_r , | ||
| 139 | .Fn getprotobyport_r , | ||
| 140 | and | ||
| 141 | .Fn getprotobyname_r | ||
| 142 | functions | ||
| 143 | also take a pointer to a | ||
| 144 | .Vt protoent | ||
| 145 | structure which is used to store the results of the database lookup. | ||
| 120 | .Sh RETURN VALUES | 146 | .Sh RETURN VALUES |
| 121 | Null pointer | 147 | The |
| 122 | (0) returned on | 148 | .Fn getprotoent , |
| 123 | .Dv EOF | 149 | .Fn getprotobyport , |
| 124 | or error. | 150 | and |
| 151 | .Fn getprotobyname | ||
| 152 | functions return a pointer to a | ||
| 153 | .Vt protoent | ||
| 154 | structure on success or a null pointer if end-of-file | ||
| 155 | is reached or an error occurs. | ||
| 156 | .Pp | ||
| 157 | The | ||
| 158 | .Fn getprotoent_r , | ||
| 159 | .Fn getprotobyport_r , | ||
| 160 | and | ||
| 161 | .Fn getprotobyname_r | ||
| 162 | functions return 0 on success or \-1 if end-of-file | ||
| 163 | is reached or an error occurs. | ||
| 125 | .Sh FILES | 164 | .Sh FILES |
| 126 | .Bl -tag -width /etc/protocols -compact | 165 | .Bl -tag -width /etc/protocols -compact |
| 127 | .It Pa /etc/protocols | 166 | .It Pa /etc/protocols |
| 128 | .El | 167 | .El |
| 129 | .Sh SEE ALSO | 168 | .Sh SEE ALSO |
| 130 | .Xr protocols 5 | 169 | .Xr protocols 5 |
| 170 | .Sh STANDARDS | ||
| 171 | The | ||
| 172 | .Fn getprotoent , | ||
| 173 | .Fn getprotobynumber , | ||
| 174 | .Fn getprotobyname , | ||
| 175 | .Fn setprotoent , | ||
| 176 | and | ||
| 177 | .Fn endprotoent | ||
| 178 | functions conform to | ||
| 179 | .St -p1003.1-2004 . | ||
| 180 | .Pp | ||
| 181 | The | ||
| 182 | .Fn getprotoent_r , | ||
| 183 | .Fn getprotobyport_r , | ||
| 184 | .Fn getprotobyname_r , | ||
| 185 | .Fn setprotoent_r , | ||
| 186 | and | ||
| 187 | .Fn endprotoent_r | ||
| 188 | functions are not currently standardized. | ||
| 189 | This implementation follows the API used by HP, IBM, and Digital. | ||
| 131 | .Sh HISTORY | 190 | .Sh HISTORY |
| 132 | The | 191 | The |
| 133 | .Fn getprotoent , | 192 | .Fn getprotoent , |
| @@ -136,11 +195,19 @@ The | |||
| 136 | .Fn setprotoent , | 195 | .Fn setprotoent , |
| 137 | and | 196 | and |
| 138 | .Fn endprotoent | 197 | .Fn endprotoent |
| 139 | functions appeared in | 198 | functions appeared in |
| 140 | .Bx 4.2 . | 199 | .Bx 4.2 . |
| 200 | .Pp | ||
| 201 | The | ||
| 202 | .Fn getprotoent_r , | ||
| 203 | .Fn getprotobyport_r , | ||
| 204 | .Fn getprotobyname_r , | ||
| 205 | .Fn setprotoent_r , | ||
| 206 | and | ||
| 207 | .Fn endprotoent_r | ||
| 208 | functions appeared in | ||
| 209 | .Ox 3.7 . | ||
| 141 | .Sh BUGS | 210 | .Sh BUGS |
| 142 | These functions use a static data space; | 211 | The non-reentrant functions use a static data space; if the data is needed |
| 143 | if the data is needed for future use, it should be | 212 | for future use, it should be copied before any subsequent calls overwrite it. |
| 144 | copied before any subsequent calls overwrite it. | 213 | Only the Internet protocols are currently understood. |
| 145 | Only the Internet | ||
| 146 | protocols are currently understood. | ||
