.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton) .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. .\" Translated Fri Mar 15 1998 by NAKANO Takeo .\" Updated Thu 16 Aug 2001 by NAKANO Takeo .\" Updated 2008-09-19, Akihiro MOTOKI .\" .TH GETSERVENT 3 2008\-08\-19 GNU "Linux Programmer's Manual" .SH 名前 getservent, getservbyname, getservbyport, setservent, endservent \- サービスのエントリーを取得する .SH 書式 .nf \fB#include \fP .sp \fBstruct servent *getservent(void);\fP .sp \fBstruct servent *getservbyname(const char *\fP\fIname\fP\fB, const char *\fP\fIproto\fP\fB);\fP .sp \fBstruct servent *getservbyport(int \fP\fIport\fP\fB, const char *\fP\fIproto\fP\fB);\fP .sp \fBvoid setservent(int \fP\fIstayopen\fP\fB);\fP .sp \fBvoid endservent(void);\fP .fi .SH 説明 \fBgetservent\fP() 関数はサービスのデータベース (\fBservices\fP(5) 参照) から次のエントリーを読み込み、 そのエントリーを \fIservent\fP 構造体の要素別のフィールドに格納し、 その構造体を返す。 必要であれば、データベースへの接続がオープンされる。 .PP \fBgetservbyname\fP() 関数は、 プロトコル \fIproto\fP を用いるサービスの名前 \fIname\fP にマッチするエントリーをデータベースから探し、 そのエントリーを収めた \fIservent\fP 構造体を返す。 \fIproto\fP が NULL の場合は、任意のプロトコルにマッチする。 必要であれば、データベースへの接続がオープンされる。 .PP \fBgetservbyport\fP() 関数は、 プロトコル \fIproto\fP を用いるサービスのポート番号 \fIport\fP にマッチするエントリーをデータベースから探し、 そのエントリーの内容を収めた \fIservent\fP 構造体を返す (ポート番号 \fIport\fP はネットワークバイトオーダで指定する)。 \fIproto\fP が NULL の場合は任意のプロトコルにマッチする。 必要であれば、データベースへの接続がオープンされる。 .PP \fBsetservent\fP() 関数はデータベースへの接続をオープンし、 次の読み込みエントリーを先頭のエントリーに設定する。 \fIstayopen\fP が 0 でない場合、 一つ一つの \fBgetserv*\fP() 関数の呼び出し間でデータベースへの接続をクローズしない。 .PP \fBendservent\fP() 関数はデータベースへの接続をクローズする。 .PP \fIservent\fP 構造体は \fI\fP で以下のように定義されている。 .sp .in +4n .nf struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port number */ char *s_proto; /* protocol to use */ } .fi .in .PP \fIservent\fP 構造体のメンバーは以下の通り。 .TP \fIs_name\fP サービスの正式名 (official name)。 .TP \fIs_aliases\fP サービスの別名のリスト。 リストはヌルで終端される。 .TP \fIs_port\fP サービスのポート番号。ネットワークバイトオーダで指定される。 .TP \fIs_proto\fP このサービスと共に用いるプロトコルの名前。 .SH 返り値 \fBgetservent\fP(), \fBgetservbyname\fP(), \fBgetservbyport\fP() 関数は、 静的に割り当てられた \fIservent\fP 構造体へのポインターを返す。 エラーが起こったり、ファイルの末尾に達した場合は NULL を返す。 .SH ファイル .TP \fI/etc/services\fP サービスのデータベースファイル .SH 準拠 4.3BSD, POSIX.1\-2001. .SH 関連項目 \fBgetnetent\fP(3), \fBgetprotoent\fP(3), \fBgetservent_r\fP(3), \fBservices\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。