OSDN Git Service

028c9207c9e50225ab5095a8acece60c9a239fbb
[linuxjm/LDP_man-pages.git] / release / man3 / getpwent_r.3
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
24 .\"         all rights reserved.
25 .\" Translated Sun Aug  8 00:53:40 JST 2004
26 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
27 .\"
28 .TH GETPWENT_R 3 2010-10-21 "GNU" "Linux Programmer's Manual"
29 .SH Ì¾Á°
30 getpwent_r, fgetpwent_r \- ¥Ñ¥¹¥ï¡¼¥É¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤ò
31 ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¼è¤ê½Ð¤¹
32 .SH ½ñ¼°
33 .nf
34 .B #include <pwd.h>
35 .sp
36 .BI "int getpwent_r(struct passwd *" pwbuf ", char *" buf ,
37 .br
38 .BI "               size_t " buflen ", struct passwd **" pwbufp );
39 .sp
40 .BI "int fgetpwent_r(FILE *" fp ", struct passwd *" pwbuf ", char *" buf ,
41 .br
42 .BI "                size_t " buflen ", struct passwd **" pwbufp );
43 .fi
44 .sp
45 .in -4n
46 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
47 .RB ( feature_test_macros (7)
48 »²¾È):
49 .in
50 .sp
51 .BR getpwent_r (),
52 _BSD_SOURCE || _SVID_SOURCE
53 .br
54 .BR fgetpwent_r ():
55 _SVID_SOURCE
56 .SH ÀâÌÀ
57 ´Ø¿ô
58 .BR getpwent_r ()
59 ¤È
60 .BR fgetpwent_r ()
61 ¤Ï
62 .BR getpwent (3)
63 ¤È
64 .BR fgetpwent (3)
65 ¤Î¥ê¥¨¥ó¥È¥é¥ó¥È (reentrant) ÈǤǤ¢¤ë¡£
66 Á°¼Ô¤Ï¡¢
67 .BR setpwent (3)
68 ¤Ë¤è¤Ã¤Æ½é´ü²½¤µ¤ì¤¿¥¹¥È¥ê¡¼¥à¤«¤é¡¢¼¡¤Î¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£
69 ¸å¼Ô¤Ï¡¢¥¹¥È¥ê¡¼¥à
70 .I fp
71 ¤«¤é¼¡¤Î¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£
72 .PP
73 \fIpasswd\fP ¹½Â¤ÂΤÏ
74 .I <pwd.h>
75 ¤Ë¤ª¤¤¤Æ°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
76 .sp
77 .in +4n
78 .nf
79 struct passwd {
80     char    *pw_name;      /* ¥æ¡¼¥¶Ì¾ */
81     char    *pw_passwd;    /* ¥æ¡¼¥¶¤Î¥Ñ¥¹¥ï¡¼¥É */
82     uid_t    pw_uid;       /* ¥æ¡¼¥¶ ID */
83     gid_t    pw_gid;       /* ¥°¥ë¡¼¥× ID */
84     char    *pw_gecos;     /* ¥æ¡¼¥¶¾ðÊó */
85     char    *pw_dir;       /* ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê */
86     char    *pw_shell;     /* ¥·¥§¥ë¥×¥í¥°¥é¥à */
87 };
88 .fi
89 .in
90 .PP
91 ¤³¤Î¹½Â¤ÂΤΥե£¡¼¥ë¥É¤Î¾ÜºÙ¤Ï
92 .BR passwd (5)
93 ¤ò»²¾È¤Î¤³¤È¡£
94
95 ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ê¤¤´Ø¿ô¤ÏÀÅŪ¤Ê³ÊǼÎΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
96 ¤³¤ÎÀÅŪ¤Ê³ÊǼÎΰè¤Ë¤Ï¡¢¹¹¤Ë¥æ¡¼¥¶Ì¾¡¦¥Ñ¥¹¥ï¡¼¥É¡¦gecos ¥Õ¥£¡¼¥ë¥É¡¦
97 ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¡¦¥·¥§¥ë¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¤ë¡£
98 ¤³¤³¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤδؿô¤Ï¡¢
99 ¸Æ¤Ó½Ð¤·Â¦¤«¤éÄ󶡤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë¥æ¡¼¥¶Ì¾¤Ê¤ÉÁ´¤Æ¤òÊÖ¤¹¡£
100 ºÇ½é¤Î°ú¤­¿ô¤È¤·¤Æ \fIstruct passwd\fP ¤òÊÝ»ý¤Ç¤­¤ë¥Ð¥Ã¥Õ¥¡
101 .I pwbuf
102 ¤¬¤¢¤ë¡£
103 ¼¡¤Ë¤½¤Î¾¤Îʸ»úÎó¤òÊÝ»ý¤Ç¤­¤ë¥µ¥¤¥º
104 .I buflen
105 ¤Î¥Ð¥Ã¥Õ¥¡
106 .I buf
107 ¤¬¤¢¤ë¡£
108 ¤³¤ì¤é¤Î´Ø¿ô¤Î·ë²Ì (¥¹¥È¥ê¡¼¥à¤«¤éÆɤ߹þ¤Þ¤ì¤¿ \fIstruct passwd\fP) ¤Ï¡¢
109 Ä󶡤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡
110 .I *pwbuf
111 ¤Ë³ÊǼ¤µ¤ì¡¢¤³¤Î \fIstruct passwd\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ï
112 .I *pwbufp
113 ¤ËÊÖ¤µ¤ì¤ë¡£
114 .SH ÊÖ¤êÃÍ
115 À®¸ù¤·¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï 0 ¤òÊÖ¤·¡¢
116 .I *pwbufp
117 ¤Ï \fIstruct passwd\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤È¤Ê¤ë¡£
118 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï¥¨¥é¡¼ÃͤòÊÖ¤·¡¢
119 .I *pwbufp
120 ¤Ï NULL ¤Ë¤Ê¤ë¡£
121 .SH ¥¨¥é¡¼
122 .TP
123 .B ENOENT
124 ¼¡¤Î¥¨¥ó¥È¥ê¤¬¤Ê¤¤¡£
125 .TP
126 .B ERANGE
127 ½½Ê¬¤Ê¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£
128 ¤â¤Ã¤ÈÂ礭¤Ê¥Ð¥Ã¥Õ¥¡¤ÇºÆÅټ¹Ԥ¹¤ë¤³¤È¡£
129 .SH ½àµò
130 ¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ê¡¢POSIX ÈǤδؿô
131 .BR getpwnam_r (3)
132 ¤Î·Á¼°¤Ë»÷¤»¤Æ¤¢¤ë¡£
133 ¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï°Ê²¼¤Î¥×¥í¥È¥¿¥¤¥×¤¬»È¤ï¤ì¤Æ¤¤¤ë¡£
134 .sp
135 .nf
136 .in +4n
137 struct passwd *
138 getpwent_r(struct passwd *pwd, char *buf, int buflen);
139 .in
140 .fi
141 .sp
142 ¤è¤êÎɤ¤¤â¤Î¤Ç¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
143 .sp
144 .nf
145 .in +4n
146 int
147 getpwent_r(struct passwd *pwd, char *buf, int buflen,
148            FILE **pw_fp);
149 .in
150 .fi
151 .SH Ãí°Õ
152 ´Ø¿ô
153 .BR getpwent_r ()
154 ¤ÏËÜÅö¤Î¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ï¤Ê¤¤¡£
155 ¤Ê¤¼¤Ê¤é¡¢¥¹¥È¥ê¡¼¥à¤ÎÆɤ߹þ¤ß°ÌÃÖ¤ò
156 ¾¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤È¶¦Í­¤·¤Æ¤¤¤ë¤¿¤á¤Ç¤¢¤ë¡£
157 .SH Îã
158 .nf
159 #define _GNU_SOURCE
160 #include <pwd.h>
161 #include <stdio.h>
162 #define BUFLEN 4096
163
164 int
165 main(void)
166 {
167     struct passwd pw, *pwp;
168     char buf[BUFLEN];
169     int i;
170
171     setpwent();
172     while (1) {
173         i = getpwent_r(&pw, buf, BUFLEN, &pwp);
174         if (i)
175             break;
176         printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
177                pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
178     }
179     endpwent();
180     exit(EXIT_SUCCESS);
181 }
182 .fi
183 .\" ¤¿¤Ö¤ó¥¨¥é¡¼¥Á¥§¥Ã¥¯¤òÄɲ䷤ơ¢strerror_r ¤ò»È¤¦¤Ù¤­¤À¤í¤¦¡£
184 .\" #include <errno.h>
185 .\" #include <stdlib.h>
186 .\"         if (i) {
187 .\"               if (i == ENOENT)
188 .\"                     break;
189 .\"               printf("getpwent_r: %s", strerror(i));
190 .\"               exit(EXIT_SUCCESS);
191 .\"         }
192 .SH ´ØÏ¢¹àÌÜ
193 .BR fgetpwent (3),
194 .BR getpw (3),
195 .BR getpwent (3),
196 .BR getpwnam (3),
197 .BR getpwuid (3),
198 .BR putpwent (3),
199 .BR passwd (5)