.\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 .\" .Dd June 4, 1993 .Dt GETPROTOENT 3 .Os BSD 4.2 .Sh 名称 .Nm getprotoent , .Nm getprotobynumber , .Nm getprotobyname , .Nm setprotoent , .Nm endprotoent .Nd プロトコルエントリを取得 .Sh 書式 .Fd #include .Ft struct protoent * .Fn getprotoent void .Ft struct protoent * .Fn getprotobyname "const char *name" .Ft struct protoent * .Fn getprotobynumber "int proto" .Ft void .Fn setprotoent "int stayopen" .Ft void .Fn endprotoent void .Sh 解説 .Fn getprotoent 、 .Fn getprotobyname および .Fn getprotobynumber 関数はそれぞれ、 次に示す構造体を持つオブジェクトのポインタを返します。構造体には、 ネットワークプロトコルデータベース .Pa /etc/protocols にある行の内訳フィールド が含まれます。 .Bd -literal -offset indent .Pp struct protoent { char *p_name; /* プロトコルのオフィシャル名 */ char **p_aliases; /* エイリアスリスト */ int p_proto; /* プロトコル番号 */ }; .Ed .Pp この構造体のメンバは次のとおりです。 .Bl -tag -width p_aliases .It Fa p_name プロトコルのオフィシャル名。 .It Fa p_aliases プロトコルのゼロで終わる別名 (エイリアス) リスト。 .It Fa p_proto プロトコル番号。 .El .Pp .Fn getprotoent 関数は、必要ならばファイルをオープンして次の行を読み 込みます。 .Pp .Fn setprotoent 関数は、ファイルをオープンしてリワインドします。 .Fa stayopen フラグがゼロでなければ、 .Fn getprotobyname または .Fn getprotobynumber の各呼び出しの後、ネットデータベースはクローズされません。 .Fn endprotoent 関数はファイルをクローズします。 .Pp .Fn getprotobyname および .Fn getprotobynumber 関数は、適合する プロトコル名またはプロトコル番号が見付かるか、または .Dv EOF に出会うまでファイルを順次検索します。 .Sh 戻り値 .Dv EOF またはエラーで Null ポインタ (0) が返ります。 .Sh 関連ファイル .Bl -tag -width /etc/protocols -compact .It Pa /etc/protocols .El .Sh 関連項目 .Xr protocols 5 .Sh 歴史 .Fn getprotoent 、 .Fn getprotobynumber 、 .Fn getprotobyname 、 .Fn setprotoent および .Fn endprotoent 関数は .Bx 4.2 で最初に取り入れられました。 .Sh バグ これらの関数は静的データ空間を使用します。後で使用する必要があれば、以後の 呼び出しで上書きする前にデータをコピーして保存する必要があります。なお、 プロトコルデータとして受け入れるのは現在、インターネットプロトコル だけです。