11844Swollman/** 250476Speter * D header file for POSIX. 31638Srgrimes * 438183Speter * Copyright: Copyright Sean Kelly 2005 - 2009. 538183Speter * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 61844Swollman * Authors: Sean Kelly, Alex R��nne Petersen 71638Srgrimes * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 81638Srgrimes */ 938183Speter 101638Srgrimes/* Copyright Sean Kelly 2005 - 2009. 1136673Sdt * Distributed under the Boost Software License, Version 1.0. 121638Srgrimes * (See accompanying file LICENSE or copy at 132827Sjkh * http://www.boost.org/LICENSE_1_0.txt) 141844Swollman */ 151844Swollmanmodule core.sys.posix.pwd; 1626051Sasami 171844Swollmanimport core.sys.posix.config; 181638Srgrimespublic import core.sys.posix.sys.types; // for gid_t, uid_t 192827Sjkh 201638Srgrimesversion (OSX) 212827Sjkh version = Darwin; 221638Srgrimeselse version (iOS) 2327028Spst version = Darwin; 241844Swollmanelse version (TVOS) 251844Swollman version = Darwin; 261638Srgrimeselse version (WatchOS) 271638Srgrimes version = Darwin; 281638Srgrimes 291638Srgrimesversion (Posix): 3036054Sbdeextern (C): 3136054Sbdenothrow: 3236054Sbde@nogc: 3336054Sbde@system: 3436054Sbde 3536054Sbde// 361844Swollman// Required 371638Srgrimes// 3834081Sbde/* 391844Swollmanstruct passwd 401844Swollman{ 418321Sbde char* pw_name; 421844Swollman uid_t pw_uid; 4333624Seivind gid_t pw_gid; 442351Sbde char* pw_dir; 451638Srgrimes char* pw_shell; 462351Sbde} 472351Sbde 482351Sbdepasswd* getpwnam(const scope char*); 492351Sbdepasswd* getpwuid(uid_t); 502351Sbde*/ 512351Sbde 5233624Seivindversion (CRuntime_Glibc) 5334081Sbde{ 542351Sbde struct passwd 5533624Seivind { 561638Srgrimes char* pw_name; 571638Srgrimes char* pw_passwd; 581638Srgrimes uid_t pw_uid; 5974806Sru gid_t pw_gid; 6074806Sru char* pw_gecos; 611638Srgrimes char* pw_dir; 6258493Sru char* pw_shell; 6374806Sru } 6474941Sru} 6574941Sruelse version (Darwin) 661638Srgrimes{ 671638Srgrimes struct passwd 681638Srgrimes { 691638Srgrimes char* pw_name; 7074806Sru char* pw_passwd; 7175284Sru uid_t pw_uid; 7274806Sru gid_t pw_gid; 7375284Sru time_t pw_change; 7474806Sru char* pw_class; 751638Srgrimes char* pw_gecos; 7633816Sbde char* pw_dir; 771638Srgrimes char* pw_shell; 7855670Sbde time_t pw_expire; 7924750Sbde } 8038655Sjb} 8124750Sbdeelse version (FreeBSD) 8225110Sbde{ 8328945Speter struct passwd 8446541Sbde { 8524750Sbde char* pw_name; /* user name */ 8628945Speter char* pw_passwd; /* encrypted password */ 8724750Sbde uid_t pw_uid; /* user uid */ 881638Srgrimes gid_t pw_gid; /* user gid */ 891638Srgrimes time_t pw_change; /* password change time */ 901638Srgrimes char* pw_class; /* user access class */ 911638Srgrimes char* pw_gecos; /* Honeywell login info */ 921638Srgrimes char* pw_dir; /* home directory */ 9349328Shoek char* pw_shell; /* default shell */ 9449328Shoek time_t pw_expire; /* account expiration */ 9549328Shoek int pw_fields; /* internal: fields filled in */ 9649328Shoek } 9749328Shoek} 9816663Sjkhelse version (NetBSD) 991638Srgrimes{ 10075083Sru struct passwd 1011844Swollman { 10275083Sru char* pw_name; /* user name */ 10375083Sru char* pw_passwd; /* encrypted password */ 10475083Sru uid_t pw_uid; /* user uid */ 10549328Shoek gid_t pw_gid; /* user gid */ 1061638Srgrimes time_t pw_change; /* password change time */ 10775083Sru char* pw_class; /* user access class */ 1081638Srgrimes char* pw_gecos; /* Honeywell login info */ 10940505Sobrien char* pw_dir; /* home directory */ 11023542Sbde char* pw_shell; /* default shell */ 1111638Srgrimes time_t pw_expire; /* account expiration */ 1121638Srgrimes } 1131638Srgrimes} 1141638Srgrimeselse version (OpenBSD) 1151638Srgrimes{ 1161638Srgrimes struct passwd 1171638Srgrimes { 1181638Srgrimes char* pw_name; /* user name */ 1192351Sbde char* pw_passwd; /* encrypted password */ 12044946Sbde uid_t pw_uid; /* user uid */ 1211638Srgrimes gid_t pw_gid; /* user gid */ 1221638Srgrimes time_t pw_change; /* password change time */ 12344946Sbde char* pw_class; /* user access class */ 12444946Sbde char* pw_gecos; /* Honeywell login info */ 12544946Sbde char* pw_dir; /* home directory */ 12644946Sbde char* pw_shell; /* default shell */ 12744946Sbde time_t pw_expire; /* account expiration */ 12844946Sbde } 12944946Sbde} 13044946Sbdeelse version (DragonFlyBSD) 13144946Sbde{ 13244946Sbde struct passwd 13344946Sbde { 1341638Srgrimes char* pw_name; /* user name */ 13575284Sru char* pw_passwd; /* encrypted password */ 13675284Sru uid_t pw_uid; /* user uid */ 13775284Sru gid_t pw_gid; /* user gid */ 13875284Sru time_t pw_change; /* password change time */ 13975284Sru char* pw_class; /* user access class */ 14075284Sru char* pw_gecos; /* Honeywell login info */ 14175284Sru char* pw_dir; /* home directory */ 14275284Sru char* pw_shell; /* default shell */ 14375284Sru time_t pw_expire; /* account expiration */ 14475284Sru int pw_fields; /* internal: fields filled in */ 14575284Sru } 14675284Sru} 14775284Sruelse version (Solaris) 14875284Sru{ 14975284Sru struct passwd 15075284Sru { 15175284Sru char* pw_name; 15275284Sru char* pw_passwd; 15375284Sru uid_t pw_uid; 15475284Sru gid_t pw_gid; 15575284Sru char* pw_age; 15675284Sru char* pw_comment; 15775284Sru char* pw_gecos; 15875284Sru char* pw_dir; 15975284Sru char* pw_shell; 16075284Sru } 16175284Sru} 16216663Sjkhelse version (CRuntime_Bionic) 1631844Swollman{ 1641844Swollman struct passwd 1651844Swollman { 1661638Srgrimes char* pw_name; 1671844Swollman char* pw_passwd; 1681638Srgrimes uid_t pw_uid; 1691638Srgrimes gid_t pw_gid; 1705585Sjkh char* pw_dir; 1714442Sphk char* pw_shell; 17216663Sjkh } 17326760Sjkh} 17426760Sjkhelse version (CRuntime_Musl) 17526760Sjkh{ 1764442Sphk struct passwd 1774442Sphk { 1781638Srgrimes char *pw_name; 17916663Sjkh char *pw_passwd; 1801638Srgrimes uid_t pw_uid; 18175713Sasmodai gid_t pw_gid; 1821638Srgrimes char *pw_gecos; 1831638Srgrimes char *pw_dir; 1841638Srgrimes char *pw_shell; 18524861Sjkh } 18624861Sjkh} 18724861Sjkhelse version (CRuntime_UClibc) 18824861Sjkh{ 1891638Srgrimes struct passwd 19016663Sjkh { 1911638Srgrimes char* pw_name; 19234829Seivind char* pw_passwd; 19324861Sjkh uid_t pw_uid; 19434829Seivind gid_t pw_gid; 1951638Srgrimes char* pw_gecos; 1961638Srgrimes char* pw_dir; 19724861Sjkh char* pw_shell; 1981638Srgrimes } 1991638Srgrimes} 2001638Srgrimeselse 20174842Sru{ 20274842Sru static assert(false, "Unsupported platform"); 20374842Sru} 20474842Sru 20574842Srupasswd* getpwnam(const scope char*); 2061638Srgrimespasswd* getpwuid(uid_t); 2071638Srgrimes 20874842Sru// 2091844Swollman// Thread-Safe Functions (TSF) 21034528Seivind// 21134528Seivind/* 21234528Seivindint getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 21334528Seivindint getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 21443055Sjdp*/ 21528945Speter 21628945Speterversion (CRuntime_Glibc) 21728945Speter{ 2181844Swollman int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 21934081Sbde int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 22034081Sbde} 22134087Sbdeelse version (Darwin) 22234081Sbde{ 22334081Sbde int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 22416663Sjkh int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 225} 226else version (FreeBSD) 227{ 228 int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 229 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 230} 231else version (NetBSD) 232{ 233 int __getpwnam_r50(const scope char*, passwd*, char*, size_t, passwd**); 234 alias __getpwnam_r50 getpwnam_r; 235 int __getpwuid_r50(uid_t, passwd*, char*, size_t, passwd**); 236 alias __getpwuid_r50 getpwuid_r; 237} 238else version (OpenBSD) 239{ 240 int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 241 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 242} 243else version (DragonFlyBSD) 244{ 245 int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 246 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 247} 248else version (Solaris) 249{ 250 alias getpwnam_r = __posix_getpwnam_r; 251 alias getpwuid_r = __posix_getpwuid_r; 252 253 // POSIX.1c standard version of the functions 254 int __posix_getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 255 int __posix_getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 256} 257else version (CRuntime_Bionic) 258{ 259} 260else version (CRuntime_Musl) 261{ 262 int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 263 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 264} 265else version (CRuntime_UClibc) 266{ 267 int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**); 268 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); 269} 270else 271{ 272 static assert(false, "Unsupported platform"); 273} 274 275// 276// XOpen (XSI) 277// 278/* 279void endpwent(); 280passwd* getpwent(); 281void setpwent(); 282*/ 283 284version (CRuntime_Glibc) 285{ 286 void endpwent(); 287 passwd* getpwent(); 288 void setpwent(); 289} 290else version (Darwin) 291{ 292 void endpwent(); 293 passwd* getpwent(); 294 void setpwent(); 295} 296else version (FreeBSD) 297{ 298 void endpwent(); 299 passwd* getpwent(); 300 void setpwent(); 301} 302else version (NetBSD) 303{ 304 void endpwent(); 305 passwd* getpwent(); 306 void setpwent(); 307} 308else version (OpenBSD) 309{ 310 void endpwent(); 311 passwd* getpwent(); 312 void setpwent(); 313} 314else version (DragonFlyBSD) 315{ 316 void endpwent(); 317 passwd* getpwent(); 318 void setpwent(); 319} 320else version (Solaris) 321{ 322 void endpwent(); 323 passwd* getpwent(); 324 void setpwent(); 325} 326else version (CRuntime_Bionic) 327{ 328 void endpwent(); 329} 330else version (CRuntime_Musl) 331{ 332 void endpwent(); 333 passwd* getpwent(); 334 void setpwent(); 335} 336else version (CRuntime_UClibc) 337{ 338 void endpwent(); 339 passwd* getpwent(); 340 void setpwent(); 341} 342else 343{ 344 static assert(false, "Unsupported platform"); 345} 346