getpwent_r(3) Library Functions Manual getpwent_r(3) getpwent_r, fgetpwent_r - ( ) LIBRARY Standard C library (libc, -lc) #include int getpwent_r(struct passwd *restrict pwbuf, char buf[restrict .buflen], size_t buflen, struct passwd **restrict pwbufp); int fgetpwent_r(FILE *restrict stream, struct passwd *restrict pwbuf, char buf[restrict .buflen], size_t buflen, struct passwd **restrict pwbufp); glibc (. feature_test_macros(7)): getpwent_r(), glibc 2.19: _DEFAULT_SOURCE glibc 2.19 : _BSD_SOURCE || _SVID_SOURCE fgetpwent_r(): glibc 2.19: _DEFAULT_SOURCE glibc 2.19 : _SVID_SOURCE getpwent_r() fgetpwent_r() getpwent(3) fgetpwent(3). , setpwent(3). stream. passwd : struct passwd { char *pw_name; /* */ char *pw_passwd; /* */ uid_t pw_uid; /* */ gid_t pw_gid; /* */ char *pw_gecos; /* */ char *pw_dir; /* */ char *pw_shell; /* */ }; passwd(5). , , , gecos, . , , , . pwbuf, struct passwd. buf buflen . , struct passwd, *pwbuf, struct passwd *pwbufp. 0 *pwbufp struct passwd. *pwbufp NULL. ENOENT . ERANGE . . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |getpwent_r() | | MT-Unsafe race:pwent | | | | locale | +----------------------------+----------------------------------------------------------+--------------------------+ |fgetpwent_r() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ pwent race:pwent , setpwent(), getpwent(), endpwent() getpwent_r(), . Other systems use the prototype struct passwd * getpwent_r(struct passwd *pwd, char *buf, int buflen); , , int getpwent_r(struct passwd *pwd, char *buf, int buflen, FILE **pw_fp); None. These functions are done in a style resembling the POSIX version of functions like getpwnam_r(3). getpwent_r() , . #define _GNU_SOURCE #include #include #include #include #define BUFLEN 4096 int main(void) { struct passwd pw; struct passwd *pwp; char buf[BUFLEN]; int i; setpwent(); while (1) { i = getpwent_r(&pw, buf, sizeof(buf), &pwp); if (i) break; printf("%s (%jd)\tHOME %s\tSHELL %s\n", pwp->pw_name, (intmax_t) pwp->pw_uid, pwp->pw_dir, pwp->pw_shell); } endpwent(); exit(EXIT_SUCCESS); } . fgetpwent(3), getpw(3), getpwent(3), getpwnam(3), getpwuid(3), putpwent(3), passwd(5) Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . getpwent_r(3)