1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
24 .\"*******************************************************************
26 .\" This file was generated with po4a. Translate the source file.
28 .\"*******************************************************************
30 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
31 .\" all rights reserved.
32 .\" Translated Sun Aug 8 00:53:40 JST 2004
33 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
35 .TH GETPWENT_R 3 2010\-10\-21 GNU "Linux Programmer's Manual"
37 getpwent_r, fgetpwent_r \- パスワードファイルのエントリを リエントラントで取り出す
40 \fB#include <pwd.h>\fP
42 \fBint getpwent_r(struct passwd *\fP\fIpwbuf\fP\fB, char *\fP\fIbuf\fP\fB,\fP
44 \fB size_t \fP\fIbuflen\fP\fB, struct passwd **\fP\fIpwbufp\fP\fB);\fP
46 \fBint fgetpwent_r(FILE *\fP\fIfp\fP\fB, struct passwd *\fP\fIpwbuf\fP\fB, char *\fP\fIbuf\fP\fB,\fP
48 \fB size_t \fP\fIbuflen\fP\fB, struct passwd **\fP\fIpwbufp\fP\fB);\fP
52 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
55 \fBgetpwent_r\fP(), _BSD_SOURCE || _SVID_SOURCE
57 \fBfgetpwent_r\fP(): _SVID_SOURCE
59 関数 \fBgetpwent_r\fP() と \fBfgetpwent_r\fP() は \fBgetpwent\fP(3) と \fBfgetpwent\fP(3)
60 のリエントラント (reentrant) 版である。 前者は、 \fBsetpwent\fP(3)
61 によって初期化されたストリームから、次のパスワードエントリを読み込む。 後者は、ストリーム \fIfp\fP から次のパスワードエントリを読み込む。
63 \fIpasswd\fP 構造体は、\fI<pwd.h>\fP で以下のように定義されている:
68 char *pw_name; /* ユーザ名 */
69 char *pw_passwd; /* ユーザのパスワード */
70 uid_t pw_uid; /* ユーザ ID */
71 gid_t pw_gid; /* グループ ID */
72 char *pw_gecos; /* ユーザ情報 */
73 char *pw_dir; /* ホームディレクトリ */
74 char *pw_shell; /* シェルプログラム */
79 この構造体のフィールドの詳細は \fBpasswd\fP(5) を参照のこと。
81 リエントラントでない関数は静的な格納領域へのポインタを返す。 この静的な格納領域には、更にユーザ名・パスワード・gecos フィールド・
82 ホームディレクトリ・シェルへのポインタが含まれる。 ここで説明されているリエントラント版の関数は、
83 呼び出し側から提供されるバッファにユーザ名など全てを返す。 最初の引き数として \fIstruct passwd\fP を保持できるバッファ \fIpwbuf\fP
84 がある。 次にその他の文字列を保持できるサイズ \fIbuflen\fP のバッファ \fIbuf\fP がある。 これらの関数の結果 (ストリームから読み込まれた
85 \fIstruct passwd\fP) は、 提供されたバッファ \fI*pwbuf\fP に格納され、この \fIstruct passwd\fP へのポインタは
88 成功した場合、これらの関数は 0 を返し、 \fI*pwbufp\fP は \fIstruct passwd\fP へのポインタとなる。
89 エラーの場合、これらの関数はエラー値を返し、 \fI*pwbufp\fP は NULL になる。
96 十分なバッファ空間が与えられていない。 もっと大きなバッファで再度実行すること。
98 これらの関数は GNU 拡張であり、POSIX 版の関数 \fBgetpwnam_r\fP(3) の形式に似せてある。
99 他のシステムでは以下のプロトタイプが使われている。
104 getpwent_r(struct passwd *pwd, char *buf, int buflen);
108 より良いものでは、以下のようになっている。
113 getpwent_r(struct passwd *pwd, char *buf, int buflen,
118 関数 \fBgetpwent_r\fP() は本当のリエントラントではない。 なぜなら、ストリームの読み込み位置を
119 他の全てのスレッドと共有しているためである。
130 struct passwd pw, *pwp;
136 i = getpwent_r(&pw, buf, BUFLEN, &pwp);
139 printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
140 pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
146 .\" perhaps add error checking - should use strerror_r
147 .\" #include <errno.h>
148 .\" #include <stdlib.h>
152 .\" printf("getpwent_r: %s", strerror(i));
153 .\" exit(EXIT_SUCCESS);
156 \fBfgetpwent\fP(3), \fBgetpw\fP(3), \fBgetpwent\fP(3), \fBgetpwnam\fP(3),
157 \fBgetpwuid\fP(3), \fBputpwent\fP(3), \fBpasswd\fP(5)
159 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.68 の一部
160 である。プロジェクトの説明とバグ報告に関する情報は
161 http://www.kernel.org/doc/man\-pages/ に書かれている。