1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Copyright Sean Kelly 2005 - 2009, Sönke Ludwig 2013.
5  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6  * Authors:   Sean Kelly, Alex Rønne Petersen, Sönke Ludwig
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 
10 /*          Copyright Sean Kelly 2005 - 2009.
11  * Distributed under the Boost Software License, Version 1.0.
12  *    (See accompanying file LICENSE or copy at
13  *          http://www.boost.org/LICENSE_1_0.txt)
14  */
15 module core.sys.posix.grp;
16 
17 import core.sys.posix.config;
18 public import core.sys.posix.sys.types; // for gid_t, uid_t
19 
20 version (OSX)
21     version = Darwin;
22 else version (iOS)
23     version = Darwin;
24 else version (TVOS)
25     version = Darwin;
26 else version (WatchOS)
27     version = Darwin;
28 
29 version (Posix):
30 extern (C):
31 nothrow:
32 @nogc:
33 
34 //
35 // Required
36 //
37 /*
38 struct group
39 {
40     char*   gr_name;
41     char*   gr_passwd;
42     gid_t   gr_gid;
43     char**  gr_mem;
44 }
45 
46 group* getgrnam(const scope char*);
47 group* getgrgid(gid_t);
48 */
49 
50 version (CRuntime_Glibc)
51 {
52     struct group
53     {
54         char*   gr_name;
55         char*   gr_passwd;
56         gid_t   gr_gid;
57         char**  gr_mem;
58     }
59 }
60 else version (Darwin)
61 {
62     struct group
63     {
64         char*   gr_name;
65         char*   gr_passwd;
66         gid_t   gr_gid;
67         char**  gr_mem;
68     }
69 }
70 else version (FreeBSD)
71 {
72     struct group
73     {
74         char*   gr_name;
75         char*   gr_passwd;
76         gid_t   gr_gid;
77         char**  gr_mem;
78     }
79 }
80 else version (NetBSD)
81 {
82     struct group
83     {
84         char*   gr_name;
85         char*   gr_passwd;
86         gid_t   gr_gid;
87         char**  gr_mem;
88     }
89 }
90 else version (OpenBSD)
91 {
92     struct group
93     {
94         char*   gr_name;
95         char*   gr_passwd;
96         gid_t   gr_gid;
97         char**  gr_mem;
98     }
99 }
100 else version (DragonFlyBSD)
101 {
102     struct group
103     {
104         char*   gr_name;
105         char*   gr_passwd;
106         gid_t   gr_gid;
107         char**  gr_mem;
108     }
109 }
110 else version (Solaris)
111 {
112     struct group
113     {
114         char*   gr_name;
115         char*   gr_passwd;
116         gid_t   gr_gid;
117         char**  gr_mem;
118     }
119 }
120 else version (CRuntime_Bionic)
121 {
122     struct group
123     {
124         char*   gr_name;
125         char*   gr_passwd;
126         gid_t   gr_gid;
127         char**  gr_mem;
128     }
129 }
130 else version (CRuntime_UClibc)
131 {
132     struct group
133     {
134         char*   gr_name;
135         char*   gr_passwd;
136         gid_t   gr_gid;
137         char**  gr_mem;
138     }
139 }
140 else version (CRuntime_Musl)
141 {
142     struct group
143     {
144         char*   gr_name;
145         char*   gr_passwd;
146         gid_t   gr_gid;
147         char**  gr_mem;
148     }
149 }
150 else
151 {
152     static assert(false, "Unsupported platform");
153 }
154 
155 group* getgrnam(const scope char*);
156 group* getgrgid(gid_t);
157 
158 //
159 // Thread-Safe Functions (TSF)
160 //
161 /*
162 int getgrnam_r(const scope char*, group*, char*, size_t, group**);
163 int getgrgid_r(gid_t, group*, char*, size_t, group**);
164 */
165 
166 version (CRuntime_Glibc)
167 {
168     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
169     int getgrgid_r(gid_t, group*, char*, size_t, group**);
170 }
171 else version (Darwin)
172 {
173     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
174     int getgrgid_r(gid_t, group*, char*, size_t, group**);
175 }
176 else version (FreeBSD)
177 {
178     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
179     int getgrgid_r(gid_t, group*, char*, size_t, group**);
180 }
181 else version (NetBSD)
182 {
183     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
184     int getgrgid_r(gid_t, group*, char*, size_t, group**);
185 }
186 else version (OpenBSD)
187 {
188     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
189     int getgrgid_r(gid_t, group*, char*, size_t, group**);
190 }
191 else version (DragonFlyBSD)
192 {
193     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
194     int getgrgid_r(gid_t, group*, char*, size_t, group**);
195 }
196 else version (Solaris)
197 {
198     int getgrnam_r(const scope char*, group*, char*, int, group**);
199     int getgrgid_r(gid_t, group*, char*, int, group**);
200 }
201 else version (CRuntime_Bionic)
202 {
203 }
204 else version (CRuntime_UClibc)
205 {
206     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
207     int getgrgid_r(gid_t, group*, char*, size_t, group**);
208 }
209 else version (CRuntime_Musl)
210 {
211     int getgrnam_r(const scope char*, group*, char*, size_t, group**);
212     int getgrgid_r(gid_t, group*, char*, size_t, group**);
213 }
214 else
215 {
216     static assert(false, "Unsupported platform");
217 }
218 
219 //
220 // XOpen (XSI)
221 //
222 /*
223 struct group  *getgrent(void);
224 void           endgrent(void);
225 void           setgrent(void);
226 */
227 
228 version (CRuntime_Glibc)
229 {
230     group* getgrent();
231     @trusted void endgrent();
232     @trusted void setgrent();
233 }
234 else version (Darwin)
235 {
236     group* getgrent();
237     @trusted void endgrent();
238     @trusted void setgrent();
239 }
240 else version (FreeBSD)
241 {
242     group* getgrent();
243     @trusted void endgrent();
244     @trusted void setgrent();
245 }
246 else version (NetBSD)
247 {
248     group* getgrent();
249     @trusted void endgrent();
250     @trusted void setgrent();
251 }
252 else version (OpenBSD)
253 {
254     group* getgrent();
255     @trusted void endgrent();
256     @trusted void setgrent();
257 }
258 else version (DragonFlyBSD)
259 {
260     group* getgrent();
261     @trusted void endgrent();
262     @trusted void setgrent();
263 }
264 else version (Solaris)
265 {
266     group* getgrent();
267     @trusted void endgrent();
268     @trusted void setgrent();
269 }
270 else version (CRuntime_Bionic)
271 {
272 }
273 else version (CRuntime_UClibc)
274 {
275     group* getgrent();
276     @trusted void endgrent();
277     @trusted void setgrent();
278 }
279 else version (CRuntime_Musl)
280 {
281     group* getgrent();
282     @trusted void endgrent();
283     @trusted void setgrent();
284 }
285 else
286 {
287     static assert(false, "Unsupported platform");
288 }