.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 2003, Andries E. Brouwer .\" 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 getgrent_r 3 "8 февраля 2026 г." "Справочные страницы Linux 6.17" .SH НАИМЕНОВАНИЕ getgrent_r, fgetgrent_r \- возвращает запись из файла групп (реентерабельные версии) .SH БИБЛИОТЕКА Стандартная библиотека языка C (\fIlibc\fP,\ \fI\-lc\fP) .SH ОБЗОР .nf \fB#include \fP .P \fBint getgrent_r(\fPsize_t size; \fB struct group *restrict \fP\fIgbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct group **restrict \fP\fIgbufp\fP\fB);\fP \fBint fgetgrent_r(\fPsize_t size; \fB FILE *restrict \fP\fIstream\fP\fB, struct group *restrict \fP\fIgbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict \fP\fIsize\fP\fB], size_t \fP\fIsize\fP\fB,\fP \fB struct group **restrict \fP\fIgbufp\fP\fB);\fP .fi .P .RS -4 Требования макроса тестирования свойств для glibc (см. \fBfeature_test_macros\fP(7)): .RE .P \fBgetgrent_r\fP(): .nf _GNU_SOURCE .fi .\" FIXME . The FTM requirements seem inconsistent here. File a glibc bug? .P \fBfgetgrent_r\fP(): .nf начиная с glibc 2.19: _DEFAULT_SOURCE glibc 2.19 и старее: _SVID_SOURCE .fi .SH ОПИСАНИЕ Функции \fBgetgrent_r\fP() и \fBfgetgrent_r\fP() являются реентерабельными версиями \fBgetgrent\fP(3) и \fBfgetgrent\fP(3). Первая читает следующую запись группы из потока, инициализированного \fBsetgrent\fP(3). Последняя читает следующую запись группы из \fIstream\fP. .P Структура \fIgroup\fP определена в \fI\fP следующим образом: .P .in +4n .EX struct group { char *gr_name; /* имя группы */ char *gr_passwd; /* пароль группы */ gid_t gr_gid; /* ID группы */ char **gr_mem; /* массив, указателей имён членов группы, оканчивающийся NULL */ }; .EE .in .P Подробней о полях этой структуры смотрите в \fBgroup\fP(5). .P The nonreentrant functions return a pointer to static storage, where this static storage contains further pointers to group name, password, and members. The reentrant functions described here return all of that in caller\-provided buffers. First of all there is the buffer \fIgbuf\fP that can hold a \fIstruct\ group\fP. And next the buffer \fIbuf\fP of size \fIsize\fP that can hold additional strings. The result of these functions, the \fIstruct\ group\fP read from the stream, is stored in the provided buffer \fI*gbuf\fP, and a pointer to this \fIstruct\ group\fP is returned in \fI*gbufp\fP. .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" On success, these functions return 0 and \fI*gbufp\fP is a pointer to the \fIstruct\ group\fP. On error, these functions return an error value and \fI*gbufp\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 \fBgetgrent_r\fP() T} Безвредность в нитях T{ .na .nh MT\-Unsafe race:grent locale T} T{ .na .nh \fBfgetgrent_r\fP() T} Безвредность в нитях T{ .na .nh MT\-Safe T} .TE .P In the above table, \fIgrent\fP in \fIrace:grent\fP signifies that if any of the functions \fBsetgrent\fP(3), \fBgetgrent\fP(3), \fBendgrent\fP(3), or \fBgetgrent_r\fP() are used in parallel in different threads of a program, then data races could occur. .SH ВЕРСИИ Other systems use the prototype .P .in +4n .EX struct group *getgrent_r(struct group *grp, char buf[.size], int size); .EE .in .P или, лучше, .P .in +4n .EX int getgrent_r(struct group *grp, char buf[.size], int size, FILE **gr_fp); .EE .in .SH СТАНДАРТЫ GNU. .SH ИСТОРИЯ Эти функции выполнены в стиле, напоминающем версию POSIX функций типа \fBgetpwnam_r\fP(3). .SH ПРИМЕЧАНИЯ Функция \fBgetgrent_r\fP() не совсем реентерабельна, так как она использует общую позицию чтения в потоке с другими нитями. .SH ПРИМЕРЫ .\" SRC BEGIN (getgrent_r.c) .EX #define _GNU_SOURCE #include #include #include #include #define BUFLEN 4096 \& int main(void) { struct group grp; struct group *grpp; char buf[BUFLEN]; int i; \& setgrent(); while (1) { i = getgrent_r(&grp, buf, sizeof(buf), &grpp); if (i) break; printf("%s (%jd):", grpp\->gr_name, (intmax_t) grpp\->gr_gid); for (size_t j = 0; ; j++) { if (grpp\->gr_mem[j] == NULL) break; printf(" %s", grpp\->gr_mem[j]); } printf("\[rs]n"); } endgrent(); exit(EXIT_SUCCESS); } .EE .\" perhaps add error checking - should use strerror_r .\" #include .\" #include .\" if (i) { .\" if (i == ENOENT) .\" break; .\" printf("getgrent_r: %s", strerror(i)); .\" exit(EXIT_FAILURE); .\" } .\" SRC END .SH "СМОТРИТЕ ТАКЖЕ" \fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetgrgid\fP(3), \fBgetgrnam\fP(3), \fBputgrent\fP(3), \fBgroup\fP(5) .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства разработал(и) Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov и Иван Павлов . .PP Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, .UR https://www.gnu.org/licenses/gpl-3.0.html .UE версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. .PP Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу .MT списка рассылки русских переводчиков .ME .