|
HOME > Linux Tips ( 目次 ) > Linux コマンド 一覧表 > g > getprotoent - ライブラリコールの説明 getprotoent - ライブラリコールの説明 - Linux コマンド集 一覧表名前getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent - プロトコルのエントリを取得する 書式
#include <netdb.h> 説明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 構造体のメンバーは以下の通り。
返り値getprotoent ()、 getprotobyname ()、 getprotobynumber () 関数は protoent 構造体を返す。エラーが起こったり、 ファイルの最後に達した場合は NULL ポインタを返す。 ファイル
準拠4.3BSD, POSIX.1-2001. 関連項目
|
|