.\" -*- coding: UTF-8 -*- '\" t .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl) .\" .\" SPDX-License-Identifier: GPL-2.0-or-later .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH getgrent_r 3 "31 октября 2023 г." "Linux man\-pages 6.06" .SH ИМЯ getgrent_r, fgetgrent_r \- возвращает запись из файла групп (реентерабельные версии) .SH LIBRARY Standard C library (\fIlibc\fP, \fI\-lc\fP) .SH СИНТАКСИС .nf \fB#include \fP .P \fBint getgrent_r(struct group *restrict \fP\fIgbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict .\fP\fIbuflen\fP\fB], size_t \fP\fIbuflen\fP\fB,\fP \fB struct group **restrict \fP\fIgbufp\fP\fB);\fP \fBint fgetgrent_r(FILE *restrict \fP\fIstream\fP\fB, struct group *restrict \fP\fIgbuf\fP\fB,\fP \fB char \fP\fIbuf\fP\fB[restrict .\fP\fIbuflen\fP\fB], size_t \fP\fIbuflen\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 \fIbuflen\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 "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" При успешном выполнении эти функции возвращают 0 и \fI*gbufp\fP указывает на \fIstruct group\fP. При ошибке возвращается значение ошибки и \fI*gbufp\fP равен 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, int buflen); .EE .in .P или, лучше, .P .in +4n .EX int getgrent_r(struct group *grp, char *buf, int buflen, FILE **gr_fp); .EE .in .SH СТАНДАРТЫ GNU. .SH ИСТОРИЯ These functions are done in a style resembling the POSIX version of functions like \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("\en"); } 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 Этот перевод является бесплатной документацией; прочитайте .UR https://www.gnu.org/licenses/gpl-3.0.html Стандартную общественную лицензию GNU версии 3 .UE или более позднюю, чтобы узнать об условиях авторского права. Мы не несем НИКАКОЙ ОТВЕТСТВЕННОСТИ. .PP Если вы обнаружите ошибки в переводе этой страницы руководства, пожалуйста, отправьте электронное письмо на .MT man-pages-ru-talks@lists.sourceforge.net .ME .