.\" -*- coding: UTF-8 -*- .\" peter memishian -- meem@gnu.ai.mit.edu .\" $Id: insque.3,v 1.2 1996/10/30 21:03:39 meem Exp meem $ .\" and Copyright (c) 2010, Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code (5.4.7) .\" Solaris 2.x, OSF/1, and HP-UX manpages .\" Curry's "UNIX Systems Programming for SVR4" (O'Reilly & Associates 1996) .\" .\" Changed to POSIX, 2003-08-11, aeb+wh .\" mtk, 2010-09-09: Noted glibc 2.4 bug, added info on circular .\" lists, added example program .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH INSQUE 3 "1 novembre 2020" "" "Manuel du programmeur Linux" .SH NOM insque, remque \- Ajouter ou supprimer un élément d'une file .SH SYNOPSIS .nf \fB#include \fP .PP \fBvoid insque(void *\fP\fIelem\fP\fB, void *\fP\fIprev\fP\fB);\fP .PP \fBvoid remque(void *\fP\fIelem\fP\fB);\fP .fi .PP .RS -4 Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .RE .PP .ad l \fBinsque\fP(), \fBremque\fP()\ : .RS 4 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE\ >=\ 500 || /* Depuis la version 2.19 de la glibc: */ _DEFAULT_SOURCE || /* Pour les versions de la glibc <= 2.19: */ _SVID_SOURCE .RE .ad .SH DESCRIPTION The \fBinsque\fP() and \fBremque\fP() functions manipulate doubly linked lists. Each element in the list is a structure of which the first two elements are a forward and a backward pointer. The linked list may be linear (i.e., NULL forward pointer at the end of the list and NULL backward pointer at the start of the list) or circular. .PP \fBinsque\fP() insère l'élément pointé par \fIelem\fP immédiatement après l'élément pointé par \fIprev\fP. .PP Si la liste est linéaire, alors l'appel \fIinsque(elem, NULL)\fP peut être utilisé pour insérer l'élément initial de la liste et l'appel définit les pointeurs avant et arrière à NULL. .PP Si la liste est circulaire, l'appelant doit s'assurer que les pointeurs avant et arrière du premier élément sont initialisés pour pointer vers cet élément, et que l'argument \fIprev\fP de \fBinsque\fP() doit aussi pointer vers cet élément. .PP The \fBremque\fP() function removes the element pointed to by \fIelem\fP from the doubly linked list. .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lb lb lb l l l. Interface Attribut Valeur T{ \fBinsque\fP(), \fBremque\fP() T} Sécurité des threads MT\-Safe .TE .sp 1 .SH CONFORMITÉ POSIX.1\-2001, POSIX.1\-2008. .SH NOTES .\" e.g., SunOS, Linux libc4 and libc5 Sur d'anciens systèmes, les paramètres de ces fonctions étaient du type \fIstruct qelem *\fP, défini comme ceci\ : .PP .in +4n .EX struct qelem { struct qelem *q_forw; struct qelem *q_back; char q_data[1]; }; .EE .in .PP C'est ce que vous obtiendrez si \fB_GNU_SOURCE\fP est définie avant l'inclusion de \fI\fP. .PP .\" Linux libc4 and libc 5 placed them .\" in \fI\fP. L'emplacement des prototypes de ces fonctions varie suivant les différentes versions d'UNIX. Celui précisé ci\-dessus correspond à la version POSIX. Certains systèmes les placent dans \fI\fP. .SH BOGUES Dans la glibc\ 2.4 et les versions précédentes, il n'était pas possible de spécifier \fIprev\fP à NULL. En conséquence, pour construire une liste linéaire, l'appelant devait construire une liste avec un appel initial contenant les deux premiers éléments de la liste, avec les pointeurs avant et arrière correctement définis pour chaque élément. .SH EXEMPLES Le programme suivant montre une utilisation de \fBinsque\fP(). Ci\-dessous la sortie de l'exécution du programme\ : .PP .in +4n .EX $ \fB./a.out \-c a b c\fP Traversing completed list: a b c That was a circular list .EE .in .SS "Source du programme" \& .EX #include #include #include #include struct element { struct element *forward; struct element *backward; char *name; }; static struct element * new_element(void) { struct element *e = malloc(sizeof(*e)); if (e == NULL) { fprintf(stderr, "malloc() failed\en"); exit(EXIT_FAILURE); } return e; } int main(int argc, char *argv[]) { struct element *first, *elem, *prev; int circular, opt, errfnd; /* The "\-c" command\-line option can be used to specify that the list is circular */ errfnd = 0; circular = 0; while ((opt = getopt(argc, argv, "c")) != \-1) { switch (opt) { case \(aqc\(aq: circular = 1; break; default: errfnd = 1; break; } } if (errfnd || optind >= argc) { fprintf(stderr, "Usage: %s [\-c] string...\en", argv[0]); exit(EXIT_FAILURE); } /* Create first element and place it in the linked list */ elem = new_element(); first = elem; elem\->name = argv[optind]; if (circular) { elem\->forward = elem; elem\->backward = elem; insque(elem, elem); } else { insque(elem, NULL); } /* Add remaining command\-line arguments as list elements */ while (++optind < argc) { prev = elem; elem = new_element(); elem\->name = argv[optind]; insque(elem, prev); } /* Traverse the list from the start, printing element names */ printf("Traversing completed list:\en"); elem = first; do { printf(" %s\en", elem\->name); elem = elem\->forward; } while (elem != NULL && elem != first); if (elem == first) printf("That was a circular list\en"); exit(EXIT_SUCCESS); } .EE .SH "VOIR AUSSI" \fBqueue\fP(7) .SH COLOPHON Cette page fait partie de la publication\ 5.10 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 , David Prévot , Jean-Baptiste Holcroft et Grégoire Scano . 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 .