.\" -*- coding: UTF-8 -*- '\" t .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: GPL-2.0-or-later .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH getpwent_r 3 "28 июня 2025 г." "Справочные страницы Linux 6.15" .SH НАИМЕНОВАНИЕ getpwent_r, fgetpwent_r \- получает запись из файла паролей (реентерабельные версии) .SH БИБЛИОТЕКА Стандартная библиотека языка C (\fIlibc\fP,\ \fI\-lc\fP) .SH ОБЗОР .nf \fB#include \fP .P \fBint getpwent_r(\fPsize_t size; \fB struct passwd *restrict \fP\fIpwbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct passwd **restrict \fP\fIpwbufp\fP\fB);\fP \fBint fgetpwent_r(\fPsize_t size; \fB FILE *restrict \fP\fIstream\fP\fB, struct passwd *restrict \fP\fIpwbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct passwd **restrict \fP\fIpwbufp\fP\fB);\fP .fi .P .RS -4 Требования макроса тестирования свойств для glibc (см. \fBfeature_test_macros\fP(7)): .RE .P \fBgetpwent_r\fP(), .nf начиная с glibc 2.19: _DEFAULT_SOURCE в glibc 2.19 и старее: _BSD_SOURCE || _SVID_SOURCE .fi .P \fBfgetpwent_r\fP(): .nf начиная с glibc 2.19: _DEFAULT_SOURCE glibc 2.19 и старее: _SVID_SOURCE .fi .SH ОПИСАНИЕ Функции \fBgetpwent_r\fP() и \fBfgetpwent_r\fP() являются реентерабельными версиями \fBgetpwent\fP(3) и \fBfgetpwent\fP(3). Первая читает следующую запись паролей из потока, инициализированного \fBsetpwent\fP(3). Последняя читает следующую запись паролей из потока \fIstream\fP. .P Структура \fIpasswd\fP определена в \fI\fP таким образом: .P .in +4n .EX 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; /* программная оболочка */ }; .EE .in .P Подробней о полях этой структуры смотрите в \fBpasswd\fP(5). .P The nonreentrant functions return a pointer to static storage, where this static storage contains further pointers to user name, password, gecos field, home directory and shell. The reentrant functions described here return all of that in caller\-provided buffers. First of all there is the buffer \fIpwbuf\fP that can hold a \fIstruct\ passwd\fP. And next the buffer \fIbuf\fP of size \fIsize\fP that can hold additional strings. The result of these functions, the \fIstruct\ passwd\fP read from the stream, is stored in the provided buffer \fI*pwbuf\fP, and a pointer to this \fIstruct\ passwd\fP is returned in \fI*pwbufp\fP. .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" On success, these functions return 0 and \fI*pwbufp\fP is a pointer to the \fIstruct\ passwd\fP. On error, these functions return an error value and \fI*pwbufp\fP is NULL. .SH ОШИБКИ .TP \fBENOENT\fP Больше записей нет. .TP \fBERANGE\fP Недостаточно места в буфере. Попробуйте ещё раз с большим буфером. .SH АТРИБУТЫ Описание терминов данного раздела смотрите в \fBattributes\fP(7). .TS allbox; lb lb lbx l l l. Интерфейс Атрибут Значение T{ .na .nh \fBgetpwent_r\fP() T} Безвредность в нитях T{ .na .nh MT\-Unsafe race:pwent locale T} T{ .na .nh \fBfgetpwent_r\fP() T} Безвредность в нитях MT\-Safe .TE .P В приведённой выше таблице \fIpwent\fP в \fIrace:pwent\fP означает, что если в нескольких нитях программы одновременно используются функции \fBsetpwent\fP(), \fBgetpwent\fP(), \fBendpwent\fP() или \fBgetpwent_r\fP(), то может возникнуть состязательность по данным. .SH ВЕРСИИ Other systems use the prototype .P .in +4n .EX struct passwd * getpwent_r(struct passwd *pwd, char buf[.size], int size); .EE .in .P или, лучше, .P .in +4n .EX int getpwent_r(struct passwd *pwd, char buf[.size], int size, FILE **pw_fp); .EE .in .SH СТАНДАРТЫ Отсутствуют. .SH ИСТОРИЯ Эти функции выполнены в стиле, напоминающем версию POSIX функций типа \fBgetpwnam_r\fP(3). .SH ПРИМЕЧАНИЯ Функция \fBgetpwent_r\fP() не совсем реентерабельна, так как она использует общую позицию чтения в потоке с другими нитями. .SH ПРИМЕРЫ .\" SRC BEGIN (getpwent_r.c) .EX #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)\[rs]tHOME %s\[rs]tSHELL %s\[rs]n", pwp\->pw_name, (intmax_t) pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell); } endpwent(); exit(EXIT_SUCCESS); } .EE .\" perhaps add error checking - should use strerror_r .\" #include .\" #include .\" if (i) { .\" if (i == ENOENT) .\" break; .\" printf("getpwent_r: %s", strerror(i)); .\" exit(EXIT_SUCCESS); .\" } .\" SRC END .SH "СМОТРИТЕ ТАКЖЕ" \fBfgetpwent\fP(3), \fBgetpw\fP(3), \fBgetpwent\fP(3), \fBgetpwnam\fP(3), \fBgetpwuid\fP(3), \fBputpwent\fP(3), \fBpasswd\fP(5) .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства разработал(и) Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov , Иван Павлов и Kirill Rekhov . .PP Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, .UR https://www.gnu.org/licenses/gpl-3.0.html .UE версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. .PP Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу .MT списка рассылки русских переводчиков .ME .