名前


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() 関数はファイル /etc/protocols の次の行を一行読み込んでフィールドに分割し、 その内容を構造体 protoent に収めて返す。 ファイル /etc/protocols は必要に応じてオープンされる。

getprotobyname() 関数は、 プロトコルの名前 name にマッチする行を /etc/protocols から探し、 その行の内容を収めた protoent 構造体を返す。

getprotobynumber() 関数はプロトコルの番号 number にマッチする行を /etc/protocols から探し、 その行の内容を収めた protoent 構造体を返す。

setprotoent() 関数は /etc/protocols ファイルをオープンして、 ファイルポインタを先頭に移動する。 stayopen が真 (1) の場合には、 getprotobyname() や getprotobynumber() 関数の呼び出しの間にファイルはクローズされない。

endprotoent() 関数は /etc/protocols ファイルをクローズする。

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
 プロトコルの別名のリスト。 0 で終端する。
p_proto
 プロトコルの番号

返り値


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

ファイル


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

準拠


4.3BSD, POSIX.1-2001.

関連項目


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

openSUSE Logo

コンテンツ