getserventのヘルプ・マニュアル
日本語 英語
getservent --help
man getservent
GETSERVENT(3) Linux Programmer’s Manual GETSERVENT(3)
名前
getservent, getservbyname, getservbyport, setservent, endservent - サー
ビスのエントリを取得する
書式
#include
struct servent *getservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int port, const char *proto);
void setservent(int stayopen);
void endservent(void);
説明
getservent() 関数はサービスのデータベース (services(5) 参照) から次のエ
ントリを読み込み、そのエントリを servent 構造体の要素別のフィールドに格
納し、その構造体を返す。必要であれば、データベースへの接続がオープン さ
れる。
getservbyname() 関数は、プロトコル proto を用いるサービスの名前 name に
マッチするエントリをデータベースから探し、そのエントリを収めた servent
構造体を返す。 proto が NULL の場合は、任意のプロトコルにマッチする。必
要であれば、データベースへの接続がオープンされる。
getservbyport() 関数は、プロトコル proto を用いるサービスのポート 番 号
port にマッチするエントリをデータベースから探し、そのエントリの内容を収
めた servent 構造体を返す (ポート番号 port はネットワーク・バイトオーダ
で 指定する)。 proto が NULL の場合は任意のプロトコルにマッチする。必要
であれば、データベースへの接続がオープンされる。
setservent() 関数はデータベースへの接続をオープンし、次の読み込みエント
リ を 先 頭 のエントリに設定する。 stayopen が 0 でない場合、一つ一つの
getserv*() 関数の呼び出し間でデータベースへの接続をクローズしない。
endservent() 関数はデータベースへの接続をクローズする。
servent 構造体は で以下のように定義されている。
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
servent 構造体のメンバーは以下の通り。
s_name サービスの正式名 (official name)。
s_aliases サービスの別名のリスト。リストは NULL で終端される。
s_port サービスのポート番号。ネットワークバイトオーダで指定
される。
s_proto このサービスと共に用いるプロトコルの名前。
返り値
getservent(), getservbyname(), getservbyport() 関数は、静的に割り当てら
れた servent 構造体へのポインタを返す。エラーが起こったり、ファイルの末
尾に達した場合は NULL ポインタを返す。
ファイル
/etc/services
サービスのデータベースファイル
準拠
4.3BSD, POSIX.1-2001.
関連項目
getnetent(3), getprotoent(3), getservent_r(3), services(5)
GNU 2008-08-19 GETSERVENT(3)
GETSERVENT(3) Linux Programmer’s Manual GETSERVENT(3)
NAME
getservent, getservbyname, getservbyport, setservent, endservent - get
service entry
SYNOPSIS
#include
struct servent *getservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int port, const char *proto);
void setservent(int stayopen);
void endservent(void);
DESCRIPTION
The getservent() function reads the next entry from the services
database (see services(5)) and returns a servent structure containing
the broken-out fields from the entry. A connection is opened to the
database if necessary.
The getservbyname() function returns a servent structure for the entry
from the database that matches the service name using protocol proto.
If proto is NULL, any protocol will be matched. A connection is opened
to the database if necessary.
The getservbyport() function returns a servent structure for the entry
from the database that matches the port port (given in network byte
order) using protocol proto. If proto is NULL, any protocol will be
matched. A connection is opened to the database if necessary.
The setservent() function opens a connection to the database, and sets
the next entry to the first entry. If stayopen is non-zero, then the
connection to the database will not be closed between calls to one of
the getserv*() functions.
The endservent() function closes the connection to the database.
The servent structure is defined in as follows:
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
The members of the servent structure are:
s_name The official name of the service.
s_aliases
A NULL-terminated list of alternative names for the service.
s_port The port number for the service given in network byte order.
s_proto
The name of the protocol to use with this service.
RETURN VALUE
The getservent(), getservbyname() and getservbyport() functions return
a pointer to a statically allocated servent structure, or a NULL
pointer if an error occurs or the end of the file is reached.
FILES
/etc/services
services database file
CONFORMING TO
4.3BSD, POSIX.1-2001.
SEE ALSO
getnetent(3), getprotoent(3), getservent_r(3), services(5)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-08-19 GETSERVENT(3)