.\" 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 .\" %FreeBSD: src/lib/libc/net/getprotoent.3,v 1.4.2.4 2001/12/14 18:33:55 ru Exp % .\" $FreeBSD$ .\" .Dd June 4, 1993 .Dt GETPROTOENT 3 .Os .Sh 名称 .Nm getprotoent , .Nm getprotobynumber , .Nm getprotobyname , .Nm setprotoent , .Nm endprotoent .Nd プロトコルエントリの取得 .Sh ライブラリ .Lb libc .Sh 書式 .In netdb.h .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 プロトコルの別名 (エイリアス) の 0 で終わるリスト。 .It Fa p_proto プロトコル番号。 .El .Pp .Fn getprotoent 関数は、ファイルの次の行を読み込みます。 この際、必要ならばファイルをオープンします。 .Pp .Fn setprotoent 関数は、ファイルをオープンしてリワインドします。 .Fa stayopen フラグが 0 でなければ、 .Fn getprotobyname または .Fn getprotobynumber のそれぞれの呼び出しの後でも、ネットデータベースはクローズされません。 .Pp .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 バグ これらの関数は静的データ空間を使用します。 後でこのデータを使用する必要があれば、以後のこれらの関数の呼び出しで データが上書きされる前に、コピーして保存する必要があります。 なお、プロトコルデータとして受け入れるのは現在、 インターネットプロトコルだけです。