GETPROTOENT

Section: Linux Programmer's Manual (3)
Updated: 2020-12-21
Index JM Home Page
 

名前

getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent - プロトコルのエントリーを取得する  

書式

#include <netdb.h>

struct protoent *getprotoent(void);

struct protoent *getprotobyname(const char *name);

struct protoent *getprotobynumber(int proto);

void setprotoent(int stayopen);

void endprotoent(void);
 

説明

getprotoent() 関数は、プロトコルのデータベース (protocols(5) 参照) から次のエントリーを読み込み、 そのエントリーを protoent 構造体の要素別のフィールドに格納し、 その構造体を返す。 必要であれば、データベースへの接続がオープンされる。

getprotobyname() 関数は、プロトコル名 name にマッチするエントリーを データベースから探し、そのエントリーを収めた protoent 構造体を返す。 必要であれば、データベースへの接続がオープンされる。

getprotobynumber() 関数は、プロトコル番号 number にマッチするエントリーを データベースから探し、そのエントリーを収めた protoent 構造体を返す。 必要であれば、データベースへの接続がオープンされる。

setprotoent() 関数はデータベースへの接続をオープンし、 次の読み込みエントリーを先頭のエントリーに設定する。 stayopen が 0 でない場合、 一つ一つの getproto*() 関数の呼び出し間でデータベースへの接続をクローズしない。

endprotoent() 関数はデータベースへの接続をクローズする。

protoent 構造体は <netdb.h> で以下のように定義されている。

struct protoent {
    char  *p_name;       /* official protocol name */
    char **p_aliases;    /* alias list */
    int    p_proto;      /* protocol number */ }

protoent 構造体のメンバーは以下の通り。

p_name
プロトコルの正式名 (official name)。
p_aliases
プロトコルの別名のリスト。 リストはヌルで終端される。
p_proto
プロトコルの番号
 

返り値

getprotoent(), getprotobyname(), getprotobynumber() 関数は、静的に割り当てられた protoent 構造体へのポインターを返す。 エラーが起こったり、ファイルの最後に達した場合は NULL を返す。  

ファイル

/etc/protocols
プロトコルのデータベースファイル
 

属性

この節で使用されている用語の説明は attributes(7) を参照のこと。
Interface Attribute Value
getprotoent() Thread safety MT-Unsafe race:protoent
race:protoentbuf locale
getprotobyname() Thread safety MT-Unsafe race:protobyname
locale
getprotobynumber() Thread safety MT-Unsafe race:protobynumber
locale
setprotoent(),
endprotoent()
Thread safety MT-Unsafe race:protoent
locale

In the above table, protoent in race:protoent signifies that if any of the functions setprotoent(), getprotoent(), or endprotoent() are used in parallel in different threads of a program, then data races could occur.  

準拠

POSIX.1-2001, POSIX.1-2008, 4.3BSD.  

関連項目

getnetent(3), getprotoent_r(3), getservent(3), protocols(5)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

データベース   エントリー   プロトコル   protoent   構造体   接続   race   オープン   Thread   safety   locale   getprotoent   getprotobyname   getprotobynumber   setprotoent   endprotoent   netdb   マッチ   番号   クローズ   official   protocol   aliases   proto   格納

Linux マニュアル 一覧

関連するコマンド・関数

endprotoent.3   getprotobynumber.3   getprotoent.3   setprotoent.3   endservent.3   getservbyname.3
 

Index

名前
書式
説明
返り値
ファイル
属性
準拠
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 04:39:13 GMT, October 11, 2026