.\" -*- coding: UTF-8 -*-
.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, see
.\" .
.\" %%%LICENSE_END
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH GETGRENT_R 3 "15 septembre 2017" GNU "Manuel du programmeur Linux"
.SH NOM
getgrent_r, fgetgrent_r \- Obtenir un enregistrement du fichier group de
manière réentrante
.SH SYNOPSIS
.nf
\fB#include \fP
.PP
\fBint getgrent_r(struct group *\fP\fIgbuf\fP\fB, char *\fP\fIbuf\fP\fB,\fP
\fB size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIgbufp\fP\fB);\fP
.PP
\fBint fgetgrent_r(FILE *\fP\fIstream\fP\fB, struct group *\fP\fIgbuf\fP\fB, char *\fP\fIbuf\fP\fB,\fP
\fB size_t \fP\fIbuflen\fP\fB, struct group **\fP\fIgbufp\fP\fB);\fP
.fi
.PP
.in -4n
Exigences de macros de test de fonctionnalités pour la glibc (consulter
\fBfeature_test_macros\fP(7))\ :
.in
.PP
.\" FIXME . The FTM requirements seem inconsistent here. File a glibc bug?
\fBgetgrent_r\fP()\ : _GNU_SOURCE
.br
\fBfgetgrent_r\fP():
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_SVID_SOURCE
.SH DESCRIPTION
The functions \fBgetgrent_r\fP() and \fBfgetgrent_r\fP() are the reentrant
versions of \fBgetgrent\fP(3) and \fBfgetgrent\fP(3). The former reads the next
group entry from the stream initialized by \fBsetgrent\fP(3). The latter reads
the next group entry from \fIstream\fP.
.PP
La structure \fIgroup\fP est définie dans \fI\fP comme ceci\ :
.PP
.in +4n
.EX
struct group {
char *gr_name; /* nom de groupe */
char *gr_passwd; /* mot de passe de groupe */
gid_t gr_gid; /* identifiant de groupe */
char **gr_mem; /* tableau de pointeurs de nom des membres de groupe
terminé par un pointeur NULL */
};
.EE
.in
.PP
Pour plus d'informations à propos des champs de cette structure, consultez
\fBgroup\fP(5).
.PP
Les fonctions non réentrantes renvoient un pointeur sur une zone statique,
zone qui contient d'autres pointeurs vers le nom, le mot de passe et les
membres du groupe. Les fonctions réentrantes décrites ici renvoient tout
ceci dans des tampons fournis par l'appelant. Il y a tout d'abord le tampon
\fIgbuf\fP qui contient une structure \fIgroup\fP. Puis le tampon \fIbuf\fP de taille
\fIbuflen\fP qui contient les chaînes supplémentaires. Le résultat de ces
fonctions, la structure \fIgroup\fP lue dans le flux, est enregistré dans le
tampon \fI*gbuf\fP fourni, et un pointeur vers cette structure \fIgroup\fP est
renvoyé dans \fI*gbufp\fP.
.SH "VALEUR RENVOYÉE"
Si elles réussissent, ces fonctions renvoient 0 et \fI*gbufp\fP est un pointeur
vers la structure \fIgroup\fP. Si elles échouent, ces fonctions renvoient une
valeur d'erreur et \fI*gbufp\fP est NULL.
.SH ERREURS
.TP
\fBENOENT\fP
Plus d'entrées.
.TP
\fBERANGE\fP
L'espace tampon fourni est insuffisant. Veuillez essayer à nouveau avec un
tampon plus grand.
.SH ATTRIBUTS
Pour une explication des termes utilisés dans cette section, consulter
\fBattributes\fP(7).
.TS
allbox;
lb lb lbw27
l l l.
Interface Attribut Valeur
T{
\fBgetgrent_r\fP()
T} Sécurité des threads MT\-Unsafe race:grent locale
T{
\fBfgetgrent_r\fP()
T} Sécurité des threads MT\-Safe
.TE
.sp 1
In the above table, \fIgrent\fP in \fIrace:grent\fP signifies that if any of the
functions \fBsetgrent\fP(), \fBgetgrent\fP(), \fBendgrent\fP(), or \fBgetgrent_r\fP()
are used in parallel in different threads of a program, then data races
could occur.
.SH CONFORMITÉ
These functions are GNU extensions, done in a style resembling the POSIX
version of functions like \fBgetpwnam_r\fP(3). Other systems use the prototype
.PP
.in +4n
.EX
struct group *getgrent_r(struct group *grp, char *buf,
int buflen);
.EE
.in
.PP
ou mieux,
.PP
.in +4n
.EX
int getgrent_r(struct group *grp, char *buf, int buflen,
FILE **gr_fp);
.EE
.in
.SH NOTES
La fonction \fBgetgrent_r\fP() n'est pas vraiment réentrante puisqu'elle
partage la position de lecture dans le flux avec tous les autres fils
(threads).
.SH EXEMPLE
.EX
#define _GNU_SOURCE
#include
#include
#include
#define BUFLEN 4096
int
main(void)
{
struct group grp, *grpp;
char buf[BUFLEN];
int i;
setgrent();
while (1) {
i = getgrent_r(&grp, buf, BUFLEN, &grpp);
if (i)
break;
printf("%s (%d):", grpp\->gr_name, grpp\->gr_gid);
for (i = 0; ; i++) {
if (grpp\->gr_mem[i] == NULL)
break;
printf(" %s", grpp\->gr_mem[i]);
}
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);
.\" }
.SH "VOIR AUSSI"
\fBfgetgrent\fP(3), \fBgetgrent\fP(3), \fBgetgrgid\fP(3), \fBgetgrnam\fP(3),
\fBputgrent\fP(3), \fBgroup\fP(5)
.SH COLOPHON
Cette page fait partie de la publication\ 5.04 du projet \fIman\-pages\fP
Linux. Une description du projet et des instructions pour signaler des
anomalies et la dernière version de cette page peuvent être trouvées à
l'adresse \%https://www.kernel.org/doc/man\-pages/.
.SH TRADUCTION
La traduction française de cette page de manuel a été créée par
Christophe Blaess ,
Stéphan Rafin ,
Thierry Vignaud ,
François Micaux,
Alain Portal ,
Jean-Philippe Guérard ,
Jean-Luc Coulon (f5ibh) ,
Julien Cristau ,
Thomas Huriaux ,
Nicolas François ,
Florentin Duneau ,
Simon Paillard ,
Denis Barbier
et
David Prévot
.
Cette traduction est une documentation libre ; veuillez vous reporter à la
.UR https://www.gnu.org/licenses/gpl-3.0.html
GNU General Public License version 3
.UE
concernant les conditions de copie et
de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.
Si vous découvrez un bogue dans la traduction de cette page de manuel,
veuillez envoyer un message à
.MT
debian-l10n-french@lists.debian.org
.ME .