OSDN Git Service

(split) LDP: Release some pages.
[linuxjm/LDP_man-pages.git] / release / man3 / getgrnam.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\"
28 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
29 .\" Modified 2003-11-15 by aeb
30 .\"
31 .\"*******************************************************************
32 .\"
33 .\" This file was generated with po4a. Translate the source file.
34 .\"
35 .\"*******************************************************************
36 .TH GETGRNAM 3 2012\-04\-23 "" "Linux Programmer's Manual"
37 .SH 名前
38 getgrnam, getgrnam_r, getgrgid, getgrgid_r \- グループファイルエントリの取り出し
39 .SH 書式
40 .nf
41 \fB#include <sys/types.h>\fP
42 \fB#include <grp.h>\fP
43 .sp
44 \fBstruct group *getgrnam(const char *\fP\fIname\fP\fB);\fP
45 .sp
46 \fBstruct group *getgrgid(gid_t \fP\fIgid\fP\fB);\fP
47 .sp
48 \fBint getgrnam_r(const char *\fP\fIname\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
49 .br
50 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
51 .sp
52 \fBint getgrgid_r(gid_t \fP\fIgid\fP\fB, struct group *\fP\fIgrp\fP\fB,\fP
53 .br
54 \fB          char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIresult\fP\fB);\fP
55 .fi
56 .sp
57 .in -4n
58 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
59 .ad l
60 .in
61 .sp
62 \fBgetgrnam_r\fP(), \fBgetgrgid_r\fP():
63 .RS 4
64 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE
65 || _POSIX_SOURCE
66 .RE
67 .ad b
68 .SH 説明
69 \fBgetgrnam\fP()  関数は、グループ名 \fIname\fP にマッチするグループ・データベースのエントリを
70 要素毎に分解し、各要素を格納した構造体へのポインタを返す (パスワード・データベースの例: ローカルのグループファイル \fI/etc/group\fP,
71 NIS, LDAP)。
72 .PP
73 \fBgetgrgid\fP()  関数は、グループ ID \fIuid\fP にマッチするグループ・データベースのエントリを
74 要素毎に分解し、各要素を格納した構造体へのポインタを返す。
75 .PP
76 \fIgroup\fP 構造体は \fI<grp.h>\fP で以下のように定義されている:
77 .sp
78 .in +4n
79 .nf
80 struct group {
81     char   *gr_name;       /* グループ名 */
82     char   *gr_passwd;     /* グループのパスワード */
83     gid_t   gr_gid;        /* グループ ID */
84     char  **gr_mem;        /* グループのメンバ */
85 };
86 .fi
87 .in
88 .PP
89 この構造体のフィールドの詳細は \fBgroup\fP(5)  を参照のこと。
90 .PP
91 \fBgetgrnam_r\fP() と \fBgetgrgid_r\fP() 関数は、それぞれ \fBgetgrnam\fP() と
92 \fBgetgrgid\fP() と同じ情報を取得するが、取得した \fIgroup\fP 構造体を
93 \fIgrp\fP が指す領域に格納する。\fIgroup\fP 構造体のメンバーが指す文字列は、
94 サイズ \fIbuflen\fP のバッファ \fIbuf\fP に格納される。成功した場合
95 \fI*gbufp\fP には結果へのポインタが格納される。エントリが見つからなかった
96 場合やエラーが発生した場合には \fI*result\fP には NULL が入る。
97 .PP
98 呼び出し
99
100     sysconf(_SC_GETGR_R_SIZE_MAX)
101
102 は、 \fIerrno\fP を変更せずに \-1 を返すか、 \fIbuf\fP の初期サイズの推奨値を
103 返す。(このサイズが小さすぎる場合、呼び出しは \fBERANGE\fP で失敗し、この
104 場合には呼び出し側はバッファを大きくしてから再度呼び出すことができる。)
105 .SH 返り値
106 \fBgetgrnam\fP()  と \fBgetgrgid\fP()  関数は、 \fIgroup\fP 構造体へのポインタを返す。
107 マッチするエントリが見つからなかった場合や、 エラーが発生した場合は NULL を返す。 エラーが起こった場合、 \fIerrno\fP が適切に設定される。
108 呼び出しの後で \fIerrno\fP をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。
109 .LP
110 返り値は静的な領域を指しており、その後の \fBgetgrent\fP(3), \fBgetgrgid\fP(), \fBgetgrnam\fP()
111 の呼び出しで上書きされるかもしれない。 (返されたポインタを \fBfree\fP(3)  に渡さないこと。)
112 .LP
113 成功すると、 \fBgetgrnam_r\fP()  と \fBgetgrgid_r\fP()  は 0 を返し、 \fI*result\fP に \fIgrp\fP
114 を設定する。 マッチするグループ・エントリが見つからなかった場合には、 0 を返し、 \fI*result\fP に NULL を設定する。
115 エラーの場合、エラー番号を返し、 \fI*result\fP に NULL を設定する。
116 .SH エラー
117 .TP 
118 \fB0\fP または \fBENOENT\fP または \fBESRCH\fP または \fBEBADF\fP または \fBEPERM\fP または ... 
119 指定された \fIname\fP または \fIgid\fP が見つからなかった。
120 .TP 
121 \fBEINTR\fP
122 シグナルが捕捉された。
123 .TP 
124 \fBEIO\fP
125 I/O エラー。
126 .TP 
127 \fBEMFILE\fP
128 呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\fP)  であった。
129 .TP 
130 \fBENFILE\fP
131 システムでオープンされているファイル数がすでに上限であった。
132 .TP 
133 \fBENOMEM\fP
134 .\" not in POSIX
135 .\" to allocate the group structure, or to allocate buffers
136 \fIgroup\fP 構造体を割り当てるためのメモリが不十分。
137 .TP 
138 \fBERANGE\fP
139 与えられたバッファ空間が不十分である。
140 .SH ファイル
141 .TP 
142 \fI/etc/group\fP
143 ローカルのグループ・データベースファイル
144 .SH 準拠
145 SVr4, 4.3BSD, POSIX.1\-2001.
146 .SH 注意
147 .\" more precisely:
148 .\" AIX 5.1 - gives ESRCH
149 .\" OSF1 4.0g - gives EWOULDBLOCK
150 .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
151 .\" glibc since version 2.7 - give 0
152 .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
153 .\" SunOS 5.8 - gives EBADF
154 .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
155 上記の「返り値」以下の記述は POSIX.1\-2001 に拠る。 この標準は「(エントリが) 見つからないこと」をエラーとしていないので、
156 そのような場合に \fIerrno\fP がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX
157 に準拠して、エントリが見つからない場合は \fIerrno\fP を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX
158 系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM
159 といった様々な値が返される。 他の値が返されるかもしれない。
160 .SH 関連項目
161 \fBendgrent\fP(3), \fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetpwnam\fP(3),
162 \fBsetgrent\fP(3), \fBgroup\fP(5)
163 .SH この文書について
164 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部
165 である。プロジェクトの説明とバグ報告に関する情報は
166 http://www.kernel.org/doc/man\-pages/ に書かれている。