OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man3 / getgrent_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 Thu Jul 29 02:26:07 JST 2004
26 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
27 .\"
28 .TH GETGRENT_R 3 2007-07-26 "GNU" "Linux Programmer's Manual"
29 .SH Ì¾Á°
30 getgrent_r, fgetgrent_r \- ¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¥¨¥ó¥È¥ê¤ò¥ê¥¨¥ó¥È¥é¥ó¥È (reentrant) ¤Ë¼è¤ê½Ð¤¹
31 .SH ½ñ¼°
32 .nf
33 .B #include <grp.h>
34 .sp
35 .BI "int getgrent_r(struct group *" gbuf ", char *" buf ,
36 .br
37 .BI "               size_t " buflen ", struct group **" gbufp );
38 .sp
39 .BI "int fgetgrent_r(FILE *" fp ", struct group *" gbuf ", char *" buf ,
40 .br
41 .BI "                size_t " buflen ", struct group **" gbufp );
42 .fi
43 .sp
44 .in -4n
45 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
46 .RB ( feature_test_macros (7)
47 »²¾È):
48 .in
49 .sp
50 .BR getgrent_r ():
51 _GNU_SOURCE
52 .\" FIXME . The FTM requirements seem inconsistent here.  File a glibc bug?
53 .br
54 .BR fgetgrent_r ():
55 _SVID_SOURCE
56 .SH ÀâÌÀ
57 ´Ø¿ô
58 .BR getgrent_r ()
59 ¤È
60 .BR fgetgrent_r ()
61 ¤Ï
62 .BR getgrent (3)
63 ¤È
64 .BR fgetgrent (3)
65 ¤Î¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë¡£
66 Á°¼Ô¤Ï¡¢
67 .BR setgrent (3)
68 ¤Ë¤è¤Ã¤Æ½é´ü²½¤µ¤ì¤¿¥¹¥È¥ê¡¼¥à¤«¤é¡¢¼¡¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£
69 ¸å¼Ô¤Ï¡¢¥¹¥È¥ê¡¼¥à
70 .I fp
71 ¤«¤é¼¡¤Î¥°¥ë¡¼¥×¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à¡£
72 .PP
73 \fIgroup\fP ¹½Â¤ÂΤÏ
74 .I <grp.h>
75 ¤Ë¤ª¤¤¤Æ°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
76 .sp
77 .in +4n
78 .nf
79 struct group {
80     char    *gr_name;     /* ¥°¥ë¡¼¥×̾ */
81     char    *gr_passwd;   /* ¥°¥ë¡¼¥×¥Ñ¥¹¥ï¡¼¥É */
82     gid_t    gr_gid;      /* ¥°¥ë¡¼¥× ID */
83     char   **gr_mem;      /* ¥°¥ë¡¼¥×¥á¥ó¥Ð */
84 };
85 .fi
86 .in
87 .sp
88 ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ê¤¤´Ø¿ô¤ÏÀÅŪ¤Ê³ÊǼÎΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
89 ¤³¤ÎÀÅŪ¤Ê³ÊǼÎΰè¤Ë¤Ï¡¢¹¹¤Ë¥°¥ë¡¼¥×̾¡¦¥Ñ¥¹¥ï¡¼¥É¡¦
90 ¥á¥ó¥Ð¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¤ë¡£
91 ¤³¤³¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥ê¥¨¥ó¥È¥é¥ó¥È¤Ê´Ø¿ô¤Ï¡¢
92 ¸Æ¤Ó½Ð¤·Â¦¤«¤éÄ󶡤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¤Ë¥°¥ë¡¼¥×̾¤Ê¤ÉÁ´¤Æ¤òÊÖ¤¹¡£
93 ºÇ½é¤Î°ú¤­¿ô¤È¤·¤Æ \fIstruct group\fP ¤òÊÝ»ý¤Ç¤­¤ë¥Ð¥Ã¥Õ¥¡
94 .I gbuf
95 ¤¬¤¢¤ë¡£
96 ¼¡¤Ë¤½¤Î¾¤Îʸ»úÎó¤òÊÝ»ý¤Ç¤­¤ë¥µ¥¤¥º
97 .I buflen
98 ¤Î¥Ð¥Ã¥Õ¥¡
99 .I buf
100 ¤¬¤¢¤ë¡£
101 ¤³¤ì¤é¤Î´Ø¿ô¤Î·ë²Ì (¥¹¥È¥ê¡¼¥à¤«¤éÆɤ߹þ¤Þ¤ì¤¿ \fIstruct group\fP) ¤Ï¡¢
102 Ä󶡤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡
103 .IR *gbuf
104 ¤Ë³ÊǼ¤µ¤ì¡¢¤³¤Î \fIstruct group\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ï
105 .IR *gbufp
106 ¤ËÊÖ¤µ¤ì¤ë¡£
107 .SH ÊÖ¤êÃÍ
108 À®¸ù¤·¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï 0 ¤òÊÖ¤·¡¢
109 .RI * gbufp
110 ¤Ï \fIstruct group\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤È¤Ê¤ë¡£
111 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï¥¨¥é¡¼ÃͤòÊÖ¤·¡¢
112 .RI * gbufp
113 ¤Ï NULL ¤Ë¤Ê¤ë¡£
114 .SH ¥¨¥é¡¼
115 .TP
116 .B ENOENT
117 ¼¡¤Î¥¨¥ó¥È¥ê¤¬¤Ê¤¤¡£
118 .TP
119 .B ERANGE
120 ½½Ê¬¤Ê¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£
121 ¤â¤Ã¤ÈÂ礭¤Ê¥Ð¥Ã¥Õ¥¡¤ÇºÆÅټ¹Ԥ¹¤ë¤³¤È¡£
122 .SH ½àµò
123 ¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ê¡¢POSIX ÈǤδؿô
124 .BR getpwnam_r (3)
125 ¤Î·Á¼°¤Ë»÷¤»¤Æ¤¢¤ë¡£
126 ¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï°Ê²¼¤Î¥×¥í¥È¥¿¥¤¥×¤¬»È¤ï¤ì¤Æ¤¤¤ë¡£
127 .sp
128 .nf
129 .in +4n
130 struct group *getgrent_r(struct group *grp, char *buf,
131                          int buflen);
132 .in
133 .fi
134 .sp
135 ¤è¤êÎɤ¤¤â¤Î¤Ç¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
136 .sp
137 .nf
138 .in +4n
139 int getgrent_r(struct group *grp, char *buf, int buflen,
140                FILE **gr_fp);
141 .in
142 .fi
143 .SH Ãí°Õ
144 ´Ø¿ô
145 .BR getgrent_r ()
146 ¤ÏËÜÅö¤Î¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ï¤Ê¤¤¡£
147 ¤Ê¤¼¤Ê¤é¡¢¥¹¥È¥ê¡¼¥à¤ÎÆɤ߹þ¤ß°ÌÃÖ¤ò
148 ¾¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤È¶¦Í­¤·¤Æ¤¤¤ë¤¿¤á¤Ç¤¢¤ë¡£
149 .SH Îã
150 .nf
151 #define _GNU_SOURCE
152 #include <grp.h>
153 #include <stdio.h>
154 #include <stdlib.h>
155 #define BUFLEN 4096
156
157 int
158 main(void)
159 {
160     struct group grp, *grpp;
161     char buf[BUFLEN];
162     int i;
163
164     setgrent();
165     while (1) {
166         i = getgrent_r(&grp, buf, BUFLEN, &grpp);
167         if (i)
168             break;
169         printf("%s (%d):", grpp\->gr_name, grpp\->gr_gid);
170         for (i = 0; ; i++) {
171             if (grpp\->gr_mem[i] == NULL)
172                 break;
173             printf(" %s", grpp\->gr_mem[i]);
174         }
175         printf("\en");
176     }
177     endgrent();
178     exit(EXIT_SUCCESS);
179 }
180 .fi
181 .\" ¤¿¤Ö¤ó¥¨¥é¡¼¥Á¥§¥Ã¥¯¤òÄɲ䷤ơ¢strerror_r ¤ò»È¤¦¤Ù¤­¤À¤í¤¦¡£
182 .\" #include <errno.h>
183 .\" #include <stdlib.h>
184 .\"         if (i) {
185 .\"               if (i == ENOENT)
186 .\"                     break;
187 .\"               printf("getgrent_r: %s", strerror(i));
188 .\"               exit(EXIT_FAILURE);
189 .\"         }
190 .SH ´ØÏ¢¹àÌÜ
191 .BR fgetgrent (3),
192 .BR getgrent (3),
193 .BR getgrgid (3),
194 .BR getgrnam (3),
195 .BR putgrent (3),
196 .BR group (5)