Annotation of rpl/src/instructions_w1.c, revision 1.1

1.1     ! bertrand    1: /*
        !             2: ================================================================================
        !             3:   RPL/2 (R) version 4.0.9
        !             4:   Copyright (C) 1989-2010 Dr. BERTRAND Joël
        !             5: 
        !             6:   This file is part of RPL/2.
        !             7: 
        !             8:   RPL/2 is free software; you can redistribute it and/or modify it
        !             9:   under the terms of the CeCILL V2 License as published by the french
        !            10:   CEA, CNRS and INRIA.
        !            11:  
        !            12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
        !            13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
        !            14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
        !            15:   for more details.
        !            16:  
        !            17:   You should have received a copy of the CeCILL License
        !            18:   along with RPL/2. If not, write to info@cecill.info.
        !            19: ================================================================================
        !            20: */
        !            21: 
        !            22: 
        !            23: #include "rpl.conv.h"
        !            24: 
        !            25: 
        !            26: /*
        !            27: ================================================================================
        !            28:   Fonction 'while'
        !            29: ================================================================================
        !            30:   Entrées :
        !            31: --------------------------------------------------------------------------------
        !            32:   Sorties :
        !            33: --------------------------------------------------------------------------------
        !            34:   Effets de bord : néant
        !            35: ================================================================================
        !            36: */
        !            37: 
        !            38: void
        !            39: instruction_while(struct_processus *s_etat_processus)
        !            40: {
        !            41:    (*s_etat_processus).erreur_execution = d_ex;
        !            42: 
        !            43:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !            44:    {
        !            45:        printf("\n  WHILE ");
        !            46: 
        !            47:        if ((*s_etat_processus).langue == 'F')
        !            48:        {
        !            49:            printf("(structure de contrôle)\n\n");
        !            50:            printf("  Utilisation :\n\n");
        !            51:        }
        !            52:        else
        !            53:        {
        !            54:            printf("(control statement)\n\n");
        !            55:            printf("  Usage:\n\n");
        !            56:        }
        !            57: 
        !            58:        printf("    WHILE\n");
        !            59:        printf("        (clause)\n");
        !            60:        printf("    REPEAT\n");
        !            61:        printf("        (expression 1)\n");
        !            62:        printf("        EXIT\n");
        !            63:        printf("        (expression 2)\n");
        !            64:        printf("    END\n\n");
        !            65: 
        !            66:        printf("    WHILE\n");
        !            67:        printf("        (clause)\n");
        !            68:        printf("    REPEAT\n");
        !            69:        printf("        (expression)\n");
        !            70:        printf("    END\n");
        !            71: 
        !            72:        return;
        !            73:    }
        !            74:    else if ((*s_etat_processus).test_instruction == 'Y')
        !            75:    {
        !            76:        (*s_etat_processus).nombre_arguments = -1;
        !            77:        return;
        !            78:    }
        !            79: 
        !            80:    empilement_pile_systeme(s_etat_processus);
        !            81: 
        !            82:    if ((*s_etat_processus).erreur_systeme != d_es)
        !            83:    {
        !            84:        return;
        !            85:    }
        !            86: 
        !            87:    (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'W';
        !            88:    (*(*s_etat_processus).l_base_pile_systeme).clause = 'W';
        !            89: 
        !            90:    if ((*s_etat_processus).mode_execution_programme == 'Y')
        !            91:    {
        !            92:        (*(*s_etat_processus).l_base_pile_systeme).adresse_retour =
        !            93:                (*s_etat_processus).position_courante;
        !            94:    }
        !            95:    else
        !            96:    {
        !            97:        if ((*s_etat_processus).expression_courante == NULL)
        !            98:        {
        !            99:            (*s_etat_processus).erreur_execution =
        !           100:                    d_ex_erreur_traitement_boucle;
        !           101:            return;
        !           102:        }
        !           103: 
        !           104:        (*(*s_etat_processus).l_base_pile_systeme).pointeur_objet_retour =
        !           105:                (*s_etat_processus).expression_courante;
        !           106:    }
        !           107: 
        !           108:    return;
        !           109: }
        !           110: 
        !           111: 
        !           112: /*
        !           113: ================================================================================
        !           114:   Fonction 'warranty'
        !           115: ================================================================================
        !           116:   Entrées :
        !           117: --------------------------------------------------------------------------------
        !           118:   Sorties :
        !           119: --------------------------------------------------------------------------------
        !           120:   Effets de bord : néant
        !           121: ================================================================================
        !           122: */
        !           123: 
        !           124: void
        !           125: instruction_warranty(struct_processus *s_etat_processus)
        !           126: {
        !           127: #  include                 "garanties.conv.h"
        !           128: 
        !           129:    (*s_etat_processus).erreur_execution = d_ex;
        !           130: 
        !           131:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !           132:    {
        !           133:        printf("\n  WARRANTY ");
        !           134: 
        !           135:        if ((*s_etat_processus).langue == 'F')
        !           136:        {
        !           137:            printf("(garantie)\n\n");
        !           138:            printf("  Aucun argument\n");
        !           139:        }
        !           140:        else
        !           141:        {
        !           142:            printf("(warranty)\n\n");
        !           143:            printf("  No argument\n");
        !           144:        }
        !           145: 
        !           146:        return;
        !           147:    }
        !           148:    else if ((*s_etat_processus).test_instruction == 'Y')
        !           149:    {
        !           150:        (*s_etat_processus).nombre_arguments = -1;
        !           151:        return;
        !           152:    }
        !           153: 
        !           154:    printf("%s\n", warranty);
        !           155: 
        !           156:    if ((*s_etat_processus).hauteur_pile_operationnelle == 0)
        !           157:    {
        !           158:        printf("\n");
        !           159:    }
        !           160: 
        !           161:    return;
        !           162: }
        !           163: 
        !           164: 
        !           165: /*
        !           166: ================================================================================
        !           167:   Fonction 'wait'
        !           168: ================================================================================
        !           169:   Entrées :
        !           170: --------------------------------------------------------------------------------
        !           171:   Sorties :
        !           172: --------------------------------------------------------------------------------
        !           173:   Effets de bord : néant
        !           174: ================================================================================
        !           175: */
        !           176: 
        !           177: void
        !           178: instruction_wait(struct_processus *s_etat_processus)
        !           179: {
        !           180:    int                         code_retour;
        !           181:    int                         erreur;
        !           182: 
        !           183:    real8                       attente;
        !           184: 
        !           185:    struct_objet                *s_objet;
        !           186: 
        !           187:    struct timespec             temporisation;
        !           188: 
        !           189:    (*s_etat_processus).erreur_execution = d_ex;
        !           190: 
        !           191:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !           192:    {
        !           193:        printf("\n  WAIT ");
        !           194: 
        !           195:        if ((*s_etat_processus).langue == 'F')
        !           196:        {
        !           197:            printf("(attente exprimée en secondes)\n\n");
        !           198:        }
        !           199:        else
        !           200:        {
        !           201:            printf("(wait a number of seconds)\n\n");
        !           202:        }
        !           203: 
        !           204:        printf("    1: %s, %s\n", d_INT, d_REL);
        !           205: 
        !           206:        return;
        !           207:    }
        !           208:    else if ((*s_etat_processus).test_instruction == 'Y')
        !           209:    {
        !           210:        (*s_etat_processus).nombre_arguments = -1;
        !           211:        return;
        !           212:    }
        !           213: 
        !           214:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !           215:    {
        !           216:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
        !           217:        {
        !           218:            return;
        !           219:        }
        !           220:    }
        !           221: 
        !           222:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !           223:            &s_objet) == d_erreur)
        !           224:    {
        !           225:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !           226:        return;
        !           227:    }
        !           228:    
        !           229:    if (((*s_objet).type == INT) ||
        !           230:            ((*s_objet).type == REL))
        !           231:    {
        !           232:        if ((*s_objet).type == INT)
        !           233:        {
        !           234:            attente = (real8) (*((integer8 *) (*s_objet).objet));
        !           235:        }
        !           236:        else
        !           237:        {
        !           238:            attente = (*((real8 *) (*s_objet).objet));
        !           239:        }
        !           240: 
        !           241:        if (attente < 0)
        !           242:        {
        !           243:            liberation(s_etat_processus, s_objet);
        !           244: 
        !           245:            (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
        !           246:            return;
        !           247:        }
        !           248: 
        !           249:        temporisation.tv_sec = (long) floor((double) attente);
        !           250:        temporisation.tv_nsec = (attente - temporisation.tv_sec) *
        !           251:                (long) 1000000000;
        !           252: 
        !           253:        if ((*s_etat_processus).profilage == d_vrai)
        !           254:        {
        !           255:            profilage(s_etat_processus, "Sleep function (WAIT)");
        !           256: 
        !           257:            if ((*s_etat_processus).erreur_systeme != d_es)
        !           258:            {
        !           259:                return;
        !           260:            }
        !           261:        }
        !           262: 
        !           263:        do
        !           264:        {
        !           265:            if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !           266:            {
        !           267:                (*s_etat_processus).erreur_systeme = d_es_processus;
        !           268:                return;
        !           269:            }
        !           270: 
        !           271:            code_retour = nanosleep(&temporisation, &temporisation);
        !           272:            erreur = errno;
        !           273: 
        !           274:            while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !           275:            {
        !           276:                if (errno != EINTR)
        !           277:                {
        !           278:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !           279:                    return;
        !           280:                }
        !           281:            }
        !           282: 
        !           283:            scrutation_injection(s_etat_processus);
        !           284: 
        !           285:            if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
        !           286:            {
        !           287:                affectation_interruptions_logicielles(s_etat_processus);
        !           288:            }
        !           289: 
        !           290:            if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
        !           291:            {
        !           292:                traitement_interruptions_logicielles(s_etat_processus);
        !           293:            }
        !           294:        } while(((code_retour == -1) && (erreur == EINTR))
        !           295:                && ((*s_etat_processus).var_volatile_requete_arret == 0));
        !           296: 
        !           297:        if ((*s_etat_processus).profilage == d_vrai)
        !           298:        {
        !           299:            profilage(s_etat_processus, NULL);
        !           300:        }
        !           301:    }
        !           302:    else
        !           303:    {
        !           304:        liberation(s_etat_processus, s_objet);
        !           305: 
        !           306:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !           307:        return;
        !           308:    }
        !           309: 
        !           310:    liberation(s_etat_processus, s_objet);
        !           311: 
        !           312:    return;
        !           313: }
        !           314: 
        !           315: 
        !           316: /*
        !           317: ================================================================================
        !           318:   Fonction 'wireframe' (passe en mode d'affichage échantillonné)
        !           319: ================================================================================
        !           320:   Entrées : structure processus
        !           321: --------------------------------------------------------------------------------
        !           322:   Sorties :
        !           323: --------------------------------------------------------------------------------
        !           324:   Effets de bord : néant
        !           325: ================================================================================
        !           326: */
        !           327: 
        !           328: void
        !           329: instruction_wireframe(struct_processus *s_etat_processus)
        !           330: {
        !           331:    (*s_etat_processus).erreur_execution = d_ex;
        !           332: 
        !           333:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !           334:    {
        !           335:        printf("\n  WIREFRAME ");
        !           336: 
        !           337:        if ((*s_etat_processus).langue == 'F')
        !           338:        {
        !           339:            printf("(graphique tridimensionnel grillagé)\n\n");
        !           340:            printf("  Aucun argument\n");
        !           341:        }
        !           342:        else
        !           343:        {
        !           344:            printf("(wireframe 3D graph)\n\n");
        !           345:            printf("  No argument\n");
        !           346:        }
        !           347: 
        !           348:        return;
        !           349:    }
        !           350:    else if ((*s_etat_processus).test_instruction == 'Y')
        !           351:    {
        !           352:        (*s_etat_processus).nombre_arguments = -1;
        !           353:        return;
        !           354:    }
        !           355: 
        !           356:    strcpy((*s_etat_processus).type_trace_eq, "GRILLE 3D");
        !           357: 
        !           358:    return;
        !           359: }
        !           360: 
        !           361: 
        !           362: /*
        !           363: ================================================================================
        !           364:   Fonction 'write'
        !           365: ================================================================================
        !           366:   Entrées : structure processus
        !           367: --------------------------------------------------------------------------------
        !           368:   Sorties :
        !           369: --------------------------------------------------------------------------------
        !           370:   Effets de bord : néant
        !           371: ================================================================================
        !           372: */
        !           373: 
        !           374: void
        !           375: instruction_write(struct_processus *s_etat_processus)
        !           376: {
        !           377:    file                                *descripteur;
        !           378: 
        !           379:    int                                 adresse[16];
        !           380:    int                                 port;
        !           381: 
        !           382:    long                                longueur_effective;
        !           383:    long                                recursivite;
        !           384: 
        !           385:    ssize_t                             ios;
        !           386: 
        !           387:    struct_objet                        *s_objet_argument_2;
        !           388:    struct_objet                        *s_objet_argument_1;
        !           389: 
        !           390:    struct sigaction                    action;
        !           391:    struct sigaction                    registre;
        !           392: 
        !           393:    struct sockaddr_in                  adresse_ipv4;
        !           394:    struct sockaddr_in6                 adresse_ipv6;
        !           395:    struct sockaddr_un                  adresse_unix;
        !           396: 
        !           397:    struct flock                        lock;
        !           398: 
        !           399:    uint32_t                            calcul_adresse;
        !           400: 
        !           401:    unsigned char                       *chaine;
        !           402: 
        !           403:    unsigned long                       i;
        !           404: 
        !           405:    (*s_etat_processus).erreur_execution = d_ex;
        !           406: 
        !           407:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !           408:    {
        !           409:        printf("\n  WRITE ");
        !           410: 
        !           411:        if ((*s_etat_processus).langue == 'F')
        !           412:        {
        !           413:            printf("(écriture d'un enregistrement d'un fichier)\n\n");
        !           414:        }
        !           415:        else
        !           416:        {
        !           417:            printf("(write a record of a file)\n\n");
        !           418:        }
        !           419: 
        !           420:        printf("    2: %s\n", d_LST);
        !           421:        printf("    1: %s, %s\n", d_FCH, d_SCK);
        !           422: 
        !           423:        return;
        !           424:    }
        !           425:    else if ((*s_etat_processus).test_instruction == 'Y')
        !           426:    {
        !           427:        (*s_etat_processus).nombre_arguments = -1;
        !           428:        return;
        !           429:    }
        !           430: 
        !           431:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !           432:    {
        !           433:        if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
        !           434:        {
        !           435:            return;
        !           436:        }
        !           437:    }
        !           438: 
        !           439:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !           440:            &s_objet_argument_1) == d_erreur)
        !           441:    {
        !           442:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !           443:        return;
        !           444:    }
        !           445:    
        !           446:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !           447:            &s_objet_argument_2) == d_erreur)
        !           448:    {
        !           449:        liberation(s_etat_processus, s_objet_argument_1);
        !           450: 
        !           451:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !           452:        return;
        !           453:    }
        !           454:    
        !           455:    if (((*s_objet_argument_2).type == LST) &&
        !           456:            ((*s_objet_argument_1).type == FCH))
        !           457:    {
        !           458:        /*
        !           459:         * Vérification des verrous
        !           460:         */
        !           461: 
        !           462:        lock.l_type = F_WRLCK;
        !           463:        lock.l_whence = SEEK_SET;
        !           464:        lock.l_start = 0;
        !           465:        lock.l_len = 0;
        !           466:        lock.l_pid = getpid();
        !           467:        recursivite = 0;
        !           468: 
        !           469:        if ((descripteur = descripteur_fichier(s_etat_processus,
        !           470:                (struct_fichier *) (*s_objet_argument_1).objet)) == NULL)
        !           471:        {
        !           472:            return;
        !           473:        }
        !           474: 
        !           475:        if (fcntl(fileno(descripteur), F_GETLK, &lock) == -1)
        !           476:        {
        !           477:            liberation(s_etat_processus, s_objet_argument_2);
        !           478:            liberation(s_etat_processus, s_objet_argument_1);
        !           479: 
        !           480:            (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           481:            return;
        !           482:        }
        !           483: 
        !           484:        if (lock.l_type != F_UNLCK)
        !           485:        {
        !           486:            liberation(s_etat_processus, s_objet_argument_2);
        !           487:            liberation(s_etat_processus, s_objet_argument_1);
        !           488: 
        !           489:            (*s_etat_processus).erreur_execution =
        !           490:                    d_ex_fichier_verrouille;
        !           491:            return;
        !           492:        }
        !           493: 
        !           494:        /*
        !           495:         * Vérification de l'autorisation d'écriture
        !           496:         */
        !           497: 
        !           498:        if ((*((struct_fichier *) (*s_objet_argument_1).objet))
        !           499:                .protection == 'R')
        !           500:        {
        !           501:            liberation(s_etat_processus, s_objet_argument_2);
        !           502:            liberation(s_etat_processus, s_objet_argument_1);
        !           503: 
        !           504:            (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
        !           505:            return;
        !           506:        }
        !           507: 
        !           508:        if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire == 'N')
        !           509:        {
        !           510:            /*
        !           511:             * Fichiers formatés
        !           512:             */
        !           513: 
        !           514:            if ((chaine = formateur_fichier(s_etat_processus,
        !           515:                    s_objet_argument_2, (*((struct_fichier *)
        !           516:                    (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
        !           517:                    &longueur_effective, &recursivite)) == NULL)
        !           518:            {
        !           519:                liberation(s_etat_processus, s_objet_argument_2);
        !           520:                liberation(s_etat_processus, s_objet_argument_1);
        !           521: 
        !           522:                return;
        !           523:            }
        !           524: 
        !           525:            if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
        !           526:                    == 'S')
        !           527:            {
        !           528:                if (fseek(descripteur, (long) 0, SEEK_END) != 0)
        !           529:                {
        !           530:                    liberation(s_etat_processus, s_objet_argument_2);
        !           531:                    liberation(s_etat_processus, s_objet_argument_1);
        !           532: 
        !           533:                    (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           534:                    return;
        !           535:                }
        !           536: 
        !           537:                if (fprintf(descripteur, "%s\n", chaine) < 0)
        !           538:                {
        !           539:                    (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           540:                    return;
        !           541:                }
        !           542:            }
        !           543:            else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
        !           544:                    == 'D')
        !           545:            {
        !           546:            }
        !           547:            else
        !           548:            {
        !           549:                /* Fichiers indexés : panique totale ! */
        !           550:            }
        !           551: 
        !           552:            free(chaine);
        !           553:        }
        !           554:        else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire
        !           555:                == 'Y')
        !           556:        {
        !           557:            /*
        !           558:             * Fichiers non formatés
        !           559:             */
        !           560: 
        !           561:            if ((chaine = formateur_fichier(s_etat_processus,
        !           562:                    s_objet_argument_2, (*((struct_fichier *)
        !           563:                    (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U',
        !           564:                    &longueur_effective, &recursivite)) == NULL)
        !           565:            {
        !           566:                liberation(s_etat_processus, s_objet_argument_2);
        !           567:                liberation(s_etat_processus, s_objet_argument_1);
        !           568: 
        !           569:                return;
        !           570:            }
        !           571: 
        !           572:            if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
        !           573:                    == 'S')
        !           574:            {
        !           575:                if (fseek(descripteur, (long) 0, SEEK_END) != 0)
        !           576:                {
        !           577:                    liberation(s_etat_processus, s_objet_argument_2);
        !           578:                    liberation(s_etat_processus, s_objet_argument_1);
        !           579: 
        !           580:                    (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           581:                    return;
        !           582:                }
        !           583: 
        !           584:                if (fwrite(chaine, sizeof(unsigned char), longueur_effective,
        !           585:                        descripteur) != (size_t) longueur_effective)
        !           586:                {
        !           587:                    (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           588:                    return;
        !           589:                }
        !           590:            }
        !           591:            else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
        !           592:                    == 'D')
        !           593:            {
        !           594:            }
        !           595:            else
        !           596:            {
        !           597:                /* Fichiers indexés : panique totale ! */
        !           598:            }
        !           599: 
        !           600:            free(chaine);
        !           601:        }
        !           602:        else
        !           603:        {
        !           604:            /*
        !           605:             * Fichiers de type FLOW
        !           606:             */
        !           607:        }
        !           608:    }
        !           609:    else if (((*s_objet_argument_2).type == LST) &&
        !           610:            ((*s_objet_argument_1).type == SCK))
        !           611:    {
        !           612:        /*
        !           613:         * Vérification de l'autorisation d'écriture
        !           614:         */
        !           615: 
        !           616:        if ((*((struct_socket *) (*s_objet_argument_1).objet))
        !           617:                .protection == 'R')
        !           618:        {
        !           619:            liberation(s_etat_processus, s_objet_argument_2);
        !           620:            liberation(s_etat_processus, s_objet_argument_1);
        !           621: 
        !           622:            (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
        !           623:            return;
        !           624:        }
        !           625: 
        !           626:        if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire == 'N')
        !           627:        {
        !           628:            /*
        !           629:             * Sockets formatées
        !           630:             */
        !           631: 
        !           632:            if ((chaine = formateur_fichier(s_etat_processus,
        !           633:                    s_objet_argument_2, (*((struct_socket *)
        !           634:                    (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
        !           635:                    &longueur_effective, &recursivite)) == NULL)
        !           636:            {
        !           637:                liberation(s_etat_processus, s_objet_argument_2);
        !           638:                liberation(s_etat_processus, s_objet_argument_1);
        !           639: 
        !           640:                return;
        !           641:            }
        !           642: 
        !           643:            if ((strcmp((*((struct_socket *) (*s_objet_argument_1).objet)).type,
        !           644:                    "STREAM") == 0) || (strcmp((*((struct_socket *)
        !           645:                    (*s_objet_argument_1).objet)).type,
        !           646:                    "SEQUENTIAL DATAGRAM") == 0))
        !           647:            { // Sockets connectées
        !           648: 
        !           649:                action.sa_handler = SIG_IGN;
        !           650:                action.sa_flags = SA_ONSTACK;
        !           651: 
        !           652:                if (sigaction(SIGPIPE, &action, &registre) != 0)
        !           653:                {
        !           654:                    (*s_etat_processus).erreur_systeme = d_es_signal;
        !           655:                    return;
        !           656:                }
        !           657: 
        !           658:                if (sem_post(&((*s_etat_processus).semaphore_fork))
        !           659:                        != 0)
        !           660:                {
        !           661:                    if (sigaction(SIGPIPE, &registre, NULL) != 0)
        !           662:                    {
        !           663:                        (*s_etat_processus).erreur_systeme = d_es_signal;
        !           664:                        return;
        !           665:                    }
        !           666: 
        !           667:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !           668:                    return;
        !           669:                }
        !           670: 
        !           671:                if (send((*((struct_socket *) (*s_objet_argument_1).objet))
        !           672:                        .socket, chaine, strlen(chaine), 0) < 0)
        !           673:                {
        !           674:                    ios = errno;
        !           675: 
        !           676:                    if (sigaction(SIGPIPE, &registre, NULL) != 0)
        !           677:                    {
        !           678:                        (*s_etat_processus).erreur_systeme = d_es_signal;
        !           679:                        return;
        !           680:                    }
        !           681: 
        !           682:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !           683:                    {
        !           684:                        if (errno != EINTR)
        !           685:                        {
        !           686:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !           687:                            return;
        !           688:                        }
        !           689:                    }
        !           690: 
        !           691:                    if (ios == EPIPE)
        !           692:                    {
        !           693:                        (*s_etat_processus).erreur_execution =
        !           694:                                d_ex_erreur_acces_fichier;
        !           695:                        return;
        !           696:                    }
        !           697: 
        !           698:                    (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
        !           699:                    return;
        !           700:                }
        !           701: 
        !           702:                while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !           703:                {
        !           704:                    if (errno != EINTR)
        !           705:                    {
        !           706:                        if (sigaction(SIGPIPE, &registre, NULL) != 0)
        !           707:                        {
        !           708:                            (*s_etat_processus).erreur_systeme = d_es_signal;
        !           709:                            return;
        !           710:                        }
        !           711: 
        !           712:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !           713:                        return;
        !           714:                    }
        !           715:                }
        !           716: 
        !           717:                if (sigaction(SIGPIPE, &registre, NULL) != 0)
        !           718:                {
        !           719:                    (*s_etat_processus).erreur_systeme = d_es_signal;
        !           720:                    return;
        !           721:                }
        !           722:            }
        !           723:            else
        !           724:            { // Sockets non connectées
        !           725: 
        !           726:                /*
        !           727:                 * Vérification de l'adresse distante
        !           728:                 */
        !           729: 
        !           730:                if (strcmp((*((struct_socket *) (*s_objet_argument_1).objet))
        !           731:                        .adresse_distante, "") == 0)
        !           732:                {
        !           733:                    liberation(s_etat_processus, s_objet_argument_1);
        !           734:                    liberation(s_etat_processus, s_objet_argument_2);
        !           735: 
        !           736:                    (*s_etat_processus).erreur_execution =
        !           737:                            d_ex_erreur_acces_fichier;
        !           738:                    return;
        !           739:                }
        !           740: 
        !           741:                /*
        !           742:                 * Création de l'adresse logique
        !           743:                 */
        !           744: 
        !           745:                if ((*((struct_socket *) (*s_objet_argument_1).objet))
        !           746:                        .domaine == PF_UNIX)
        !           747:                {
        !           748:                    adresse_unix.sun_family = AF_UNIX;
        !           749:                    strncpy(adresse_unix.sun_path, (*((struct_socket *)
        !           750:                            (*s_objet_argument_1).objet)).adresse_distante,
        !           751:                            108);
        !           752:                    adresse_unix.sun_path[108 - 1] = d_code_fin_chaine;
        !           753: 
        !           754:                    if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !           755:                    {
        !           756:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !           757:                        return;
        !           758:                    }
        !           759: 
        !           760:                    if (sendto((*((struct_socket *)
        !           761:                            (*s_objet_argument_1).objet)).socket, chaine,
        !           762:                            strlen(chaine), 0, (struct sockaddr *)
        !           763:                            &adresse_unix, sizeof(adresse_unix)) < 0)
        !           764:                    {
        !           765:                        while(sem_wait(&((*s_etat_processus)
        !           766:                                .semaphore_fork)) == -1)
        !           767:                        {
        !           768:                            if (errno != EINTR)
        !           769:                            {
        !           770:                                (*s_etat_processus).erreur_systeme =
        !           771:                                        d_es_processus;
        !           772:                                return;
        !           773:                            }
        !           774:                        }
        !           775: 
        !           776:                        (*s_etat_processus).erreur_systeme =
        !           777:                                d_es_erreur_fichier;
        !           778:                        return;
        !           779:                    }
        !           780: 
        !           781:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !           782:                    {
        !           783:                        if (errno != EINTR)
        !           784:                        {
        !           785:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !           786:                            return;
        !           787:                        }
        !           788:                    }
        !           789:                }
        !           790:                else if ((*((struct_socket *) (*s_objet_argument_1).objet))
        !           791:                        .domaine == PF_INET)
        !           792:                {
        !           793:                    if (sscanf((*((struct_socket *)
        !           794:                            (*s_objet_argument_1).objet))
        !           795:                            .adresse_distante, "%d.%d.%d.%d(%d)",
        !           796:                            &(adresse[0]), &(adresse[1]), &(adresse[2]),
        !           797:                            &(adresse[3]), &port) == 5)
        !           798:                    { // Adresse IPv4
        !           799:                        calcul_adresse = 0;
        !           800:                        for(i = 0; i < 4; calcul_adresse =
        !           801:                                (256 * calcul_adresse) + adresse[i++]);
        !           802: 
        !           803:                        memset(&adresse_ipv4, 0, sizeof(adresse_ipv4));
        !           804:                        adresse_ipv4.sin_family = AF_INET;
        !           805:                        adresse_ipv4.sin_port = htons(port);
        !           806:                        adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse);
        !           807: 
        !           808:                        if (sem_post(&((*s_etat_processus)
        !           809:                                .semaphore_fork)) != 0)
        !           810:                        {
        !           811:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !           812:                            return;
        !           813:                        }
        !           814: 
        !           815:                        if (sendto((*((struct_socket *)
        !           816:                                (*s_objet_argument_1).objet)).socket, chaine,
        !           817:                                strlen(chaine), 0, (struct sockaddr *)
        !           818:                                &adresse_ipv4, sizeof(adresse_ipv4)) < 0)
        !           819:                        {
        !           820:                            while(sem_wait(&((*s_etat_processus)
        !           821:                                    .semaphore_fork)) == -1)
        !           822:                            {
        !           823:                                if (errno != EINTR)
        !           824:                                {
        !           825:                                    (*s_etat_processus).erreur_systeme =
        !           826:                                            d_es_processus;
        !           827:                                    return;
        !           828:                                }
        !           829:                            }
        !           830: 
        !           831:                            (*s_etat_processus).erreur_systeme =
        !           832:                                    d_es_erreur_fichier;
        !           833:                            return;
        !           834:                        }
        !           835: 
        !           836:                        while(sem_wait(&((*s_etat_processus)
        !           837:                                .semaphore_fork)) == -1)
        !           838:                        {
        !           839:                            if (errno != EINTR)
        !           840:                            {
        !           841:                                (*s_etat_processus).erreur_systeme =
        !           842:                                        d_es_processus;
        !           843:                                return;
        !           844:                            }
        !           845:                        }
        !           846:                    }
        !           847:                    else
        !           848:                    {
        !           849:                        liberation(s_etat_processus, s_objet_argument_1);
        !           850:                        liberation(s_etat_processus, s_objet_argument_2);
        !           851: 
        !           852:                        (*s_etat_processus).erreur_execution =
        !           853:                                d_ex_erreur_parametre_fichier;
        !           854:                        return;
        !           855:                    }
        !           856:                }
        !           857:                else if ((*((struct_socket *) (*s_objet_argument_1).objet))
        !           858:                        .domaine == PF_INET6)
        !           859:                {
        !           860:                    if (sscanf((*((struct_socket *) (*s_objet_argument_1)
        !           861:                            .objet)).adresse_distante, "%X:%X:%X:%X:%X:"
        !           862:                            "%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X(%d)",
        !           863:                            &(adresse[0]), &(adresse[1]), &(adresse[2]),
        !           864:                            &(adresse[3]), &(adresse[4]), &(adresse[5]),
        !           865:                            &(adresse[6]), &(adresse[7]), &(adresse[8]),
        !           866:                            &(adresse[9]), &(adresse[10]), &(adresse[11]),
        !           867:                            &(adresse[12]), &(adresse[13]), &(adresse[14]),
        !           868:                            &(adresse[15]), &port)== 17)
        !           869:                    { // Adresse IPv6
        !           870:                        memset(&adresse_ipv6, 0, sizeof(adresse_ipv6));
        !           871:                        adresse_ipv6.sin6_family = AF_INET6;
        !           872:                        adresse_ipv6.sin6_port = htons((uint16_t) port);
        !           873: 
        !           874:                        for(i = 0; i < 16;
        !           875:                                adresse_ipv6.sin6_addr.s6_addr[i] =
        !           876:                                adresse[i], i++);
        !           877: 
        !           878:                        if (sem_post(&((*s_etat_processus)
        !           879:                                .semaphore_fork)) != 0)
        !           880:                        {
        !           881:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !           882:                            return;
        !           883:                        }
        !           884: 
        !           885:                        if (sendto((*((struct_socket *)
        !           886:                                (*s_objet_argument_1).objet)).socket, chaine,
        !           887:                                strlen(chaine), 0, (struct sockaddr *)
        !           888:                                &adresse_ipv6, sizeof(adresse_ipv6)) < 0)
        !           889:                        {
        !           890:                            while(sem_wait(&((*s_etat_processus)
        !           891:                                    .semaphore_fork)) == -1)
        !           892:                            {
        !           893:                                if (errno != EINTR)
        !           894:                                {
        !           895:                                    (*s_etat_processus).erreur_systeme =
        !           896:                                            d_es_processus;
        !           897:                                    return;
        !           898:                                }
        !           899:                            }
        !           900: 
        !           901:                            (*s_etat_processus).erreur_systeme =
        !           902:                                    d_es_erreur_fichier;
        !           903:                            return;
        !           904:                        }
        !           905: 
        !           906:                        while(sem_wait(&((*s_etat_processus)
        !           907:                                .semaphore_fork)) == -1)
        !           908:                        {
        !           909:                            if (errno != EINTR)
        !           910:                            {
        !           911:                                (*s_etat_processus).erreur_systeme =
        !           912:                                        d_es_processus;
        !           913:                                return;
        !           914:                            }
        !           915:                        }
        !           916:                    }
        !           917:                    else
        !           918:                    {
        !           919:                        liberation(s_etat_processus, s_objet_argument_1);
        !           920:                        liberation(s_etat_processus, s_objet_argument_2);
        !           921: 
        !           922:                        (*s_etat_processus).erreur_execution =
        !           923:                                d_ex_erreur_parametre_fichier;
        !           924:                        return;
        !           925:                    }
        !           926:                }
        !           927:                else 
        !           928:                {
        !           929:                    liberation(s_etat_processus, s_objet_argument_1);
        !           930:                    liberation(s_etat_processus, s_objet_argument_2);
        !           931: 
        !           932:                    (*s_etat_processus).erreur_execution =
        !           933:                            d_ex_erreur_parametre_fichier;
        !           934:                    return;
        !           935:                }
        !           936:            }
        !           937: 
        !           938:            free(chaine);
        !           939:        }
        !           940:        else if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire
        !           941:                == 'Y')
        !           942:        {
        !           943:            /*
        !           944:             * Sockets non formatées
        !           945:             */
        !           946:        }
        !           947:        else
        !           948:        {
        !           949:            /*
        !           950:             *  Sockets de type FLOW
        !           951:             */
        !           952:        }
        !           953:    }
        !           954:    else
        !           955:    {
        !           956:        liberation(s_etat_processus, s_objet_argument_2);
        !           957:        liberation(s_etat_processus, s_objet_argument_1);
        !           958: 
        !           959:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !           960:        return;
        !           961:    }
        !           962: 
        !           963:    liberation(s_etat_processus, s_objet_argument_2);
        !           964:    liberation(s_etat_processus, s_objet_argument_1);
        !           965: 
        !           966:    return;
        !           967: }
        !           968: 
        !           969: 
        !           970: /*
        !           971: ================================================================================
        !           972:   Fonction 'wflock'
        !           973: ================================================================================
        !           974:   Entrées : pointeur sur une structure struct_processus
        !           975: --------------------------------------------------------------------------------
        !           976:   Sorties :
        !           977: --------------------------------------------------------------------------------
        !           978:   Effets de bord : néant
        !           979: ================================================================================
        !           980: */
        !           981: 
        !           982: void
        !           983: instruction_wflock(struct_processus *s_etat_processus)
        !           984: {
        !           985:    file                        *descripteur;
        !           986: 
        !           987:    logical1                    drapeau;
        !           988: 
        !           989:    struct flock                lock;
        !           990: 
        !           991:    struct timespec             attente;
        !           992: 
        !           993:    struct_objet                *s_objet_argument_1;
        !           994:    struct_objet                *s_objet_argument_2;
        !           995: 
        !           996:    unsigned char               *chaine;
        !           997:    unsigned char               registre_instruction_valide;
        !           998: 
        !           999:    attente.tv_sec = 0;
        !          1000:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          1001: 
        !          1002:    (*s_etat_processus).erreur_execution = d_ex;
        !          1003: 
        !          1004:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          1005:    {
        !          1006:        printf("\n  WFLOCK ");
        !          1007:        
        !          1008:        if ((*s_etat_processus).langue == 'F')
        !          1009:        {
        !          1010:            printf("(attente du positionnement d'un verrou sur un fichier)"
        !          1011:                    "\n\n");
        !          1012:        }
        !          1013:        else
        !          1014:        {
        !          1015:            printf("(wait for file lock)\n\n");
        !          1016:        }
        !          1017: 
        !          1018:        printf("    2: %s\n", d_FCH);
        !          1019:        printf("    1: %s (READ/WRITE/NONE)\n", d_CHN);
        !          1020: 
        !          1021:        return;
        !          1022:    }
        !          1023:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          1024:    {
        !          1025:        (*s_etat_processus).nombre_arguments = -1;
        !          1026:        return;
        !          1027:    }
        !          1028: 
        !          1029:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          1030:    {
        !          1031:        if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
        !          1032:        {
        !          1033:            return;
        !          1034:        }
        !          1035:    }
        !          1036: 
        !          1037:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          1038:            &s_objet_argument_1) == d_erreur)
        !          1039:    {
        !          1040:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          1041:        return;
        !          1042:    }
        !          1043: 
        !          1044:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          1045:            &s_objet_argument_2) == d_erreur)
        !          1046:    {
        !          1047:        liberation(s_etat_processus, s_objet_argument_1);
        !          1048: 
        !          1049:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          1050:        return;
        !          1051:    }
        !          1052: 
        !          1053:    if (((*s_objet_argument_2).type == FCH) &&
        !          1054:            ((*s_objet_argument_1).type == CHN))
        !          1055:    {
        !          1056:        drapeau = d_faux;
        !          1057: 
        !          1058:        do
        !          1059:        {
        !          1060:            if ((chaine = conversion_majuscule((unsigned char *)
        !          1061:                    (*s_objet_argument_1).objet)) == NULL)
        !          1062:            {
        !          1063:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !          1064:                return;
        !          1065:            }
        !          1066: 
        !          1067:            if (strcmp(chaine, "WRITE") == 0)
        !          1068:            {
        !          1069:                lock.l_type = F_WRLCK;
        !          1070:            }
        !          1071:            else if (strcmp(chaine, "READ") == 0)
        !          1072:            {
        !          1073:                lock.l_type = F_RDLCK;
        !          1074:            }
        !          1075:            else if (strcmp(chaine, "NONE") == 0)
        !          1076:            {
        !          1077:                lock.l_type = F_UNLCK;
        !          1078:            }
        !          1079:            else
        !          1080:            {
        !          1081:                free(chaine);
        !          1082: 
        !          1083:                liberation(s_etat_processus, s_objet_argument_1);
        !          1084:                liberation(s_etat_processus, s_objet_argument_2);
        !          1085: 
        !          1086:                (*s_etat_processus).erreur_execution = d_ex_verrou_indefini;
        !          1087:                return;
        !          1088:            }
        !          1089: 
        !          1090:            free(chaine);
        !          1091: 
        !          1092:            lock.l_whence = SEEK_SET;
        !          1093:            lock.l_start = 0;
        !          1094:            lock.l_len = 0;
        !          1095:            lock.l_pid = getpid();
        !          1096: 
        !          1097:            if ((descripteur = descripteur_fichier(s_etat_processus,
        !          1098:                    (struct_fichier *) (*s_objet_argument_2).objet)) == NULL)
        !          1099:            {
        !          1100:                return;
        !          1101:            }
        !          1102: 
        !          1103:            if (fcntl(fileno(descripteur), F_GETLK, &lock) == -1)
        !          1104:            {
        !          1105:                liberation(s_etat_processus, s_objet_argument_1);
        !          1106:                liberation(s_etat_processus, s_objet_argument_2);
        !          1107: 
        !          1108:                (*s_etat_processus).erreur_execution = d_ex_fichier_verrouille;
        !          1109:                return;
        !          1110:            }
        !          1111: 
        !          1112:            if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          1113:            {
        !          1114:                (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1115:                return;
        !          1116:            }
        !          1117: 
        !          1118:            while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1119:            {
        !          1120:                if (errno != EINTR)
        !          1121:                {
        !          1122:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1123:                    return;
        !          1124:                }
        !          1125:            }
        !          1126: 
        !          1127:            if (lock.l_type == F_UNLCK)
        !          1128:            {
        !          1129:                drapeau = d_vrai;
        !          1130:            }
        !          1131:            else
        !          1132:            {
        !          1133:                if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
        !          1134:                {
        !          1135:                    affectation_interruptions_logicielles(s_etat_processus);
        !          1136:                }
        !          1137: 
        !          1138:                if ((*s_etat_processus).nombre_interruptions_en_queue
        !          1139:                        != 0)
        !          1140:                {
        !          1141:                    registre_instruction_valide =
        !          1142:                            (*s_etat_processus).instruction_valide;
        !          1143:                    traitement_interruptions_logicielles(
        !          1144:                            s_etat_processus);
        !          1145:                    (*s_etat_processus).instruction_valide =
        !          1146:                            registre_instruction_valide;
        !          1147:                }
        !          1148: 
        !          1149:                nanosleep(&attente, NULL);
        !          1150:                scrutation_injection(s_etat_processus);
        !          1151: 
        !          1152:                INCR_GRANULARITE(attente.tv_nsec);
        !          1153:            }
        !          1154:        } while((drapeau == d_faux) && ((*s_etat_processus)
        !          1155:                .var_volatile_requete_arret != -1));
        !          1156:    }
        !          1157:    else
        !          1158:    {
        !          1159:        liberation(s_etat_processus, s_objet_argument_1);
        !          1160:        liberation(s_etat_processus, s_objet_argument_2);
        !          1161: 
        !          1162:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !          1163:        return;
        !          1164:    }
        !          1165: 
        !          1166:    return;
        !          1167: }
        !          1168: 
        !          1169: 
        !          1170: /*
        !          1171: ================================================================================
        !          1172:   Fonction 'wfproc'
        !          1173: ================================================================================
        !          1174:   Entrées : pointeur sur une structure struct_processus
        !          1175: --------------------------------------------------------------------------------
        !          1176:   Sorties :
        !          1177: --------------------------------------------------------------------------------
        !          1178:   Effets de bord : néant
        !          1179: ================================================================================
        !          1180: */
        !          1181: 
        !          1182: void
        !          1183: instruction_wfproc(struct_processus *s_etat_processus)
        !          1184: {
        !          1185:    logical1                    drapeau_fin;
        !          1186: 
        !          1187:    struct_liste_chainee        *l_element_courant;
        !          1188: 
        !          1189:    struct_objet                *s_objet_argument;
        !          1190: 
        !          1191:    struct timespec             attente;
        !          1192: 
        !          1193:    unsigned char               registre_instruction_valide;
        !          1194: 
        !          1195:    (*s_etat_processus).erreur_execution = d_ex;
        !          1196: 
        !          1197:    attente.tv_sec = 0;
        !          1198:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          1199: 
        !          1200:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          1201:    {
        !          1202:        printf("\n  WFPROC ");
        !          1203: 
        !          1204:        if ((*s_etat_processus).langue == 'F')
        !          1205:        {
        !          1206:            printf("(attente de la fin d'un processus fils)\n\n");
        !          1207:        }
        !          1208:        else
        !          1209:        {
        !          1210:            printf("(wait for child process end)\n\n");
        !          1211:        }
        !          1212: 
        !          1213:        printf("    1: %s\n", d_PRC);
        !          1214: 
        !          1215:        return;
        !          1216:    }
        !          1217:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          1218:    {
        !          1219:        (*s_etat_processus).nombre_arguments = -1;
        !          1220:        return;
        !          1221:    }
        !          1222: 
        !          1223:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          1224:    {
        !          1225:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
        !          1226:        {
        !          1227:            return;
        !          1228:        }
        !          1229:    }
        !          1230: 
        !          1231:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          1232:            &s_objet_argument) == d_erreur)
        !          1233:    {
        !          1234:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          1235:        return;
        !          1236:    }
        !          1237: 
        !          1238:    if ((*s_objet_argument).type == PRC)
        !          1239:    {
        !          1240:        drapeau_fin = d_faux;
        !          1241: 
        !          1242:        if ((*s_etat_processus).profilage == d_vrai)
        !          1243:        {
        !          1244:            profilage(s_etat_processus, "Interprocess or interthread "
        !          1245:                    "communications (WFPROC)");
        !          1246: 
        !          1247:            if ((*s_etat_processus).erreur_systeme != d_es)
        !          1248:            {
        !          1249:                return;
        !          1250:            }
        !          1251:        }
        !          1252: 
        !          1253:        if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
        !          1254:        {
        !          1255:            if ((*s_etat_processus).profilage == d_vrai)
        !          1256:            {
        !          1257:                profilage(s_etat_processus, NULL);
        !          1258:            }
        !          1259: 
        !          1260:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1261:            return;
        !          1262:        }
        !          1263: 
        !          1264:        while(drapeau_fin == d_faux)
        !          1265:        {
        !          1266:            l_element_courant = (struct_liste_chainee *)
        !          1267:                    (*s_etat_processus).l_base_pile_processus;
        !          1268: 
        !          1269:            while(l_element_courant != NULL)
        !          1270:            {
        !          1271:                if ((*(*((struct_processus_fils *) (*(*l_element_courant)
        !          1272:                        .donnee).objet)).thread).processus_detache == d_vrai)
        !          1273:                {
        !          1274:                    if ((*(*((struct_processus_fils *)
        !          1275:                            (*s_objet_argument).objet)).thread)
        !          1276:                            .processus_detache == d_vrai)
        !          1277:                    {
        !          1278:                        if ((*(*((struct_processus_fils *)
        !          1279:                                (*(*l_element_courant)
        !          1280:                                .donnee).objet)).thread).pid ==
        !          1281:                                (*(*((struct_processus_fils *)
        !          1282:                                (*s_objet_argument).objet)).thread).pid)
        !          1283:                        {
        !          1284:                            break;
        !          1285:                        }
        !          1286:                    }
        !          1287:                }
        !          1288:                else
        !          1289:                {
        !          1290:                    if ((*(*((struct_processus_fils *)
        !          1291:                            (*s_objet_argument).objet)).thread)
        !          1292:                            .processus_detache == d_faux)
        !          1293:                    {
        !          1294:                        if ((pthread_equal((*(*((struct_processus_fils *)
        !          1295:                                (*(*l_element_courant).donnee).objet)).thread)
        !          1296:                                .tid, (*(*((struct_processus_fils *)
        !          1297:                                (*s_objet_argument).objet)).thread).tid) != 0)
        !          1298:                                && ((*(*((struct_processus_fils *)
        !          1299:                                (*(*l_element_courant).donnee).objet)).thread)
        !          1300:                                .pid == (*(*((struct_processus_fils *)
        !          1301:                                (*s_objet_argument).objet)).thread).pid))
        !          1302:                        {
        !          1303:                            break;
        !          1304:                        }
        !          1305:                    }
        !          1306:                }
        !          1307: 
        !          1308:                l_element_courant = (*l_element_courant).suivant;
        !          1309:            }
        !          1310: 
        !          1311:            if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          1312:            {
        !          1313:                if ((*s_etat_processus).profilage == d_vrai)
        !          1314:                {
        !          1315:                    profilage(s_etat_processus, NULL);
        !          1316:                }
        !          1317: 
        !          1318:                if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1319:                {
        !          1320:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1321:                    return;
        !          1322:                }
        !          1323: 
        !          1324:                liberation(s_etat_processus, s_objet_argument);
        !          1325:                return;
        !          1326:            }
        !          1327: 
        !          1328:            if (l_element_courant == NULL)
        !          1329:            {
        !          1330:                /*
        !          1331:                 * Si l_element_courant vaut NULL, le processus n'existe plus.
        !          1332:                 */
        !          1333: 
        !          1334:                drapeau_fin = d_vrai;
        !          1335:            }
        !          1336:            else
        !          1337:            {
        !          1338:                if ((*(*((struct_processus_fils *) (*(*l_element_courant)
        !          1339:                        .donnee).objet)).thread).processus_detache == d_vrai)
        !          1340:                {
        !          1341:                    if (kill((*(*((struct_processus_fils *)
        !          1342:                            (*(*l_element_courant).donnee).objet)).thread).pid,
        !          1343:                            0) != 0)
        !          1344:                    {
        !          1345:                        drapeau_fin = d_vrai;
        !          1346:                    }
        !          1347:                    else
        !          1348:                    {
        !          1349:                        drapeau_fin = d_faux;
        !          1350:                    }
        !          1351:                }
        !          1352:                else
        !          1353:                {
        !          1354:                    if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
        !          1355:                            (*(*l_element_courant).donnee).objet)).thread)
        !          1356:                            .mutex)) != 0)
        !          1357:                    {
        !          1358:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1359:                        {
        !          1360:                            profilage(s_etat_processus, NULL);
        !          1361:                        }
        !          1362: 
        !          1363:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1364:                        return;
        !          1365:                    }
        !          1366: 
        !          1367:                    if ((*(*((struct_processus_fils *)
        !          1368:                            (*(*l_element_courant).donnee).objet)).thread)
        !          1369:                            .thread_actif == d_faux)
        !          1370:                    {
        !          1371:                        drapeau_fin = d_vrai;
        !          1372:                    }
        !          1373:                    else
        !          1374:                    {
        !          1375:                        drapeau_fin = d_faux;
        !          1376:                    }
        !          1377: 
        !          1378:                    if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
        !          1379:                            (*(*l_element_courant).donnee).objet)).thread)
        !          1380:                            .mutex)) != 0)
        !          1381:                    {
        !          1382:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1383:                        {
        !          1384:                            profilage(s_etat_processus, NULL);
        !          1385:                        }
        !          1386: 
        !          1387:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1388:                        return;
        !          1389:                    }
        !          1390:                }
        !          1391: 
        !          1392:                if (drapeau_fin == d_faux)
        !          1393:                {
        !          1394:                    /*
        !          1395:                     * Le processus n'est pas terminé
        !          1396:                     */
        !          1397: 
        !          1398:                    if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1399:                    {
        !          1400:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1401:                        {
        !          1402:                            profilage(s_etat_processus, NULL);
        !          1403:                        }
        !          1404: 
        !          1405:                        (*s_etat_processus).erreur_systeme =
        !          1406:                                d_es_processus;
        !          1407:                        return;
        !          1408:                    }
        !          1409: 
        !          1410:                    if ((*s_etat_processus).nombre_interruptions_non_affectees
        !          1411:                            != 0)
        !          1412:                    {
        !          1413:                        affectation_interruptions_logicielles(s_etat_processus);
        !          1414:                    }
        !          1415: 
        !          1416:                    if ((*s_etat_processus).nombre_interruptions_en_queue
        !          1417:                            != 0)
        !          1418:                    {
        !          1419:                        registre_instruction_valide =
        !          1420:                                (*s_etat_processus).instruction_valide;
        !          1421:                        traitement_interruptions_logicielles(
        !          1422:                                s_etat_processus);
        !          1423:                        (*s_etat_processus).instruction_valide =
        !          1424:                                registre_instruction_valide;
        !          1425:                    }
        !          1426: 
        !          1427:                    if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          1428:                    {
        !          1429:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1430:                        return;
        !          1431:                    }
        !          1432: 
        !          1433:                    nanosleep(&attente, NULL);
        !          1434: 
        !          1435:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1436:                    {
        !          1437:                        if (errno != EINTR)
        !          1438:                        {
        !          1439:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1440:                            return;
        !          1441:                        }
        !          1442:                    }
        !          1443: 
        !          1444:                    scrutation_injection(s_etat_processus);
        !          1445: 
        !          1446:                    if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
        !          1447:                    {
        !          1448:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1449:                        {
        !          1450:                            profilage(s_etat_processus, NULL);
        !          1451:                        }
        !          1452: 
        !          1453:                        (*s_etat_processus).erreur_systeme =
        !          1454:                                d_es_processus;
        !          1455:                        return;
        !          1456:                    }
        !          1457:                }
        !          1458:            }
        !          1459: 
        !          1460:            INCR_GRANULARITE(attente.tv_nsec);
        !          1461:        }
        !          1462: 
        !          1463:        if ((*s_etat_processus).profilage == d_vrai)
        !          1464:        {
        !          1465:            profilage(s_etat_processus, NULL);
        !          1466:        }
        !          1467: 
        !          1468:        if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1469:        {
        !          1470:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1471:            return;
        !          1472:        }
        !          1473:    }
        !          1474:    else
        !          1475:    {
        !          1476:        liberation(s_etat_processus, s_objet_argument);
        !          1477: 
        !          1478:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !          1479:        return;
        !          1480:    }
        !          1481: 
        !          1482:    liberation(s_etat_processus, s_objet_argument);
        !          1483: 
        !          1484:    return;
        !          1485: }
        !          1486: 
        !          1487: 
        !          1488: /*
        !          1489: ================================================================================
        !          1490:   Fonction 'wfdata'
        !          1491: ================================================================================
        !          1492:   Entrées : pointeur sur une structure struct_processus
        !          1493: --------------------------------------------------------------------------------
        !          1494:   Sorties :
        !          1495: --------------------------------------------------------------------------------
        !          1496:   Effets de bord : néant
        !          1497: ================================================================================
        !          1498: */
        !          1499: 
        !          1500: void
        !          1501: instruction_wfdata(struct_processus *s_etat_processus)
        !          1502: {
        !          1503:    logical1                    drapeau_fin;
        !          1504: 
        !          1505:    struct_liste_chainee        *l_element_courant;
        !          1506: 
        !          1507:    struct_objet                *s_objet_argument;
        !          1508: 
        !          1509:    struct timespec             attente;
        !          1510: 
        !          1511:    unsigned char               registre_instruction_valide;
        !          1512: 
        !          1513:    (*s_etat_processus).erreur_execution = d_ex;
        !          1514: 
        !          1515:    attente.tv_sec = 0;
        !          1516:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          1517: 
        !          1518:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          1519:    {
        !          1520:        printf("\n  WFDATA ");
        !          1521: 
        !          1522:        if ((*s_etat_processus).langue == 'F')
        !          1523:        {
        !          1524:            printf("(attente de données d'un processus fils)\n\n");
        !          1525:        }
        !          1526:        else
        !          1527:        {
        !          1528:            printf("(wait for data from child process)\n\n");
        !          1529:        }
        !          1530: 
        !          1531:        printf("    1: %s\n", d_PRC);
        !          1532: 
        !          1533:        return;
        !          1534:    }
        !          1535:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          1536:    {
        !          1537:        (*s_etat_processus).nombre_arguments = -1;
        !          1538:        return;
        !          1539:    }
        !          1540: 
        !          1541:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          1542:    {
        !          1543:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
        !          1544:        {
        !          1545:            return;
        !          1546:        }
        !          1547:    }
        !          1548: 
        !          1549:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          1550:            &s_objet_argument) == d_erreur)
        !          1551:    {
        !          1552:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          1553:        return;
        !          1554:    }
        !          1555: 
        !          1556:    if ((*s_objet_argument).type == PRC)
        !          1557:    {
        !          1558:        drapeau_fin = d_faux;
        !          1559: 
        !          1560:        if ((*s_etat_processus).profilage == d_vrai)
        !          1561:        {
        !          1562:            profilage(s_etat_processus, "Interprocess or interthread "
        !          1563:                    "communications (WFDATA)");
        !          1564: 
        !          1565:            if ((*s_etat_processus).erreur_systeme != d_es)
        !          1566:            {
        !          1567:                return;
        !          1568:            }
        !          1569:        }
        !          1570: 
        !          1571:        if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
        !          1572:        {
        !          1573:            if ((*s_etat_processus).profilage == d_vrai)
        !          1574:            {
        !          1575:                profilage(s_etat_processus, NULL);
        !          1576:            }
        !          1577: 
        !          1578:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1579:            return;
        !          1580:        }
        !          1581: 
        !          1582:        while(drapeau_fin == d_faux)
        !          1583:        {
        !          1584:            l_element_courant = (struct_liste_chainee *)
        !          1585:                    (*s_etat_processus).l_base_pile_processus;
        !          1586: 
        !          1587:            while(l_element_courant != NULL)
        !          1588:            {
        !          1589:                if ((*(*((struct_processus_fils *) (*(*l_element_courant)
        !          1590:                        .donnee).objet)).thread).processus_detache == d_vrai)
        !          1591:                {
        !          1592:                    if (((*(*((struct_processus_fils *) (*(*l_element_courant)
        !          1593:                            .donnee).objet)).thread).pid ==
        !          1594:                            (*(*((struct_processus_fils *)
        !          1595:                            (*s_objet_argument).objet)).thread).pid)
        !          1596:                            && ((*(*((struct_processus_fils *)
        !          1597:                            (*s_objet_argument).objet)).thread)
        !          1598:                            .processus_detache == d_vrai))
        !          1599:                    {
        !          1600:                        break;
        !          1601:                    }
        !          1602:                }
        !          1603:                else
        !          1604:                {
        !          1605:                    if ((pthread_equal((*(*((struct_processus_fils *)
        !          1606:                            (*(*l_element_courant).donnee).objet)).thread).tid,
        !          1607:                            (*(*((struct_processus_fils *) (*s_objet_argument)
        !          1608:                            .objet)).thread).tid) != 0) &&
        !          1609:                            ((*(*((struct_processus_fils *)
        !          1610:                            (*(*l_element_courant).donnee).objet)).thread).pid
        !          1611:                            == (*(*((struct_processus_fils *)
        !          1612:                            (*s_objet_argument).objet)).thread).pid) &&
        !          1613:                            ((*(*((struct_processus_fils *)
        !          1614:                            (*s_objet_argument).objet)).thread)
        !          1615:                            .processus_detache == d_faux))
        !          1616:                    {
        !          1617:                        break;
        !          1618:                    }
        !          1619:                }
        !          1620: 
        !          1621:                l_element_courant = (*l_element_courant).suivant;
        !          1622:            }
        !          1623: 
        !          1624:            if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          1625:            {
        !          1626:                if ((*s_etat_processus).profilage == d_vrai)
        !          1627:                {
        !          1628:                    profilage(s_etat_processus, NULL);
        !          1629:                }
        !          1630: 
        !          1631:                if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1632:                {
        !          1633:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1634:                    return;
        !          1635:                }
        !          1636: 
        !          1637:                liberation(s_etat_processus, s_objet_argument);
        !          1638:                return;
        !          1639:            }
        !          1640: 
        !          1641:            if (l_element_courant != NULL)
        !          1642:            {
        !          1643:                if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
        !          1644:                        (*(*l_element_courant).donnee).objet)).thread).mutex))
        !          1645:                        != 0)
        !          1646:                {
        !          1647:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1648:                    return;
        !          1649:                }
        !          1650: 
        !          1651:                if ((*(*((struct_processus_fils *) (*(*l_element_courant)
        !          1652:                        .donnee).objet)).thread).nombre_objets_dans_pipe != 0)
        !          1653:                {
        !          1654:                    if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
        !          1655:                            (*(*l_element_courant).donnee).objet)).thread)
        !          1656:                            .mutex)) != 0)
        !          1657:                    {
        !          1658:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1659:                        return;
        !          1660:                    }
        !          1661: 
        !          1662:                    drapeau_fin = d_vrai;
        !          1663:                }
        !          1664:                else
        !          1665:                {
        !          1666:                    if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
        !          1667:                            (*(*l_element_courant).donnee).objet)).thread)
        !          1668:                            .mutex)) != 0)
        !          1669:                    {
        !          1670:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1671:                        return;
        !          1672:                    }
        !          1673: 
        !          1674:                    if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1675:                    {
        !          1676:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1677:                        {
        !          1678:                            profilage(s_etat_processus, NULL);
        !          1679:                        }
        !          1680: 
        !          1681:                        (*s_etat_processus).erreur_systeme =
        !          1682:                                d_es_processus;
        !          1683:                        return;
        !          1684:                    }
        !          1685: 
        !          1686:                    if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          1687:                    {
        !          1688:                        (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1689:                        return;
        !          1690:                    }
        !          1691: 
        !          1692:                    nanosleep(&attente, NULL);
        !          1693: 
        !          1694:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1695:                    {
        !          1696:                        if (errno != EINTR)
        !          1697:                        {
        !          1698:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1699:                            return;
        !          1700:                        }
        !          1701:                    }
        !          1702: 
        !          1703:                    scrutation_injection(s_etat_processus);
        !          1704: 
        !          1705:                    if ((*s_etat_processus).nombre_interruptions_non_affectees
        !          1706:                            != 0)
        !          1707:                    {
        !          1708:                        affectation_interruptions_logicielles(s_etat_processus);
        !          1709:                    }
        !          1710: 
        !          1711:                    if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
        !          1712:                    {
        !          1713:                        registre_instruction_valide =
        !          1714:                                (*s_etat_processus).instruction_valide;
        !          1715:                        traitement_interruptions_logicielles(s_etat_processus);
        !          1716:                        (*s_etat_processus).instruction_valide =
        !          1717:                                registre_instruction_valide;
        !          1718:                    }
        !          1719: 
        !          1720:                    if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          1721:                    {
        !          1722:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1723:                        {
        !          1724:                            profilage(s_etat_processus, NULL);
        !          1725:                        }
        !          1726: 
        !          1727:                        return;
        !          1728:                    }
        !          1729: 
        !          1730:                    if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
        !          1731:                    {
        !          1732:                        if ((*s_etat_processus).profilage == d_vrai)
        !          1733:                        {
        !          1734:                            profilage(s_etat_processus, NULL);
        !          1735:                        }
        !          1736: 
        !          1737:                        (*s_etat_processus).erreur_systeme =
        !          1738:                                d_es_processus;
        !          1739:                        return;
        !          1740:                    }
        !          1741:                }
        !          1742:            }
        !          1743:            else
        !          1744:            {
        !          1745:                drapeau_fin = d_vrai;
        !          1746:                (*s_etat_processus).erreur_execution = d_ex_processus;
        !          1747:            }
        !          1748: 
        !          1749:            INCR_GRANULARITE(attente.tv_nsec);
        !          1750:        }
        !          1751: 
        !          1752:        if ((*s_etat_processus).profilage == d_vrai)
        !          1753:        {
        !          1754:            profilage(s_etat_processus, NULL);
        !          1755:        }
        !          1756: 
        !          1757:        if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
        !          1758:        {
        !          1759:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1760:            return;
        !          1761:        }
        !          1762:    }
        !          1763:    else
        !          1764:    {
        !          1765:        liberation(s_etat_processus, s_objet_argument);
        !          1766: 
        !          1767:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !          1768:        return;
        !          1769:    }
        !          1770: 
        !          1771:    liberation(s_etat_processus, s_objet_argument);
        !          1772: 
        !          1773:    return;
        !          1774: }
        !          1775: 
        !          1776: 
        !          1777: /*
        !          1778: ================================================================================
        !          1779:   Fonction 'wfsock'
        !          1780: ================================================================================
        !          1781:   Entrées : pointeur sur une structure struct_processus
        !          1782: --------------------------------------------------------------------------------
        !          1783:   Sorties :
        !          1784: --------------------------------------------------------------------------------
        !          1785:   Effets de bord : néant
        !          1786: ================================================================================
        !          1787: */
        !          1788: 
        !          1789: void
        !          1790: instruction_wfsock(struct_processus *s_etat_processus)
        !          1791: {
        !          1792:    int                     erreur;
        !          1793: 
        !          1794:    logical1                drapeau;
        !          1795: 
        !          1796:    socklen_t               longueur;
        !          1797: 
        !          1798:    struct_liste_chainee    *l_element_courant;
        !          1799: 
        !          1800:    struct_objet            *s_objet_argument;
        !          1801:    struct_objet            *s_objet_resultat;
        !          1802: 
        !          1803:    struct sockaddr_in      adresse_ipv4;
        !          1804:    struct sockaddr_in6     adresse_ipv6;
        !          1805: 
        !          1806:    unsigned long           i;
        !          1807: 
        !          1808:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          1809:    {
        !          1810:        printf("\n  WFSOCK ");
        !          1811: 
        !          1812:        if ((*s_etat_processus).langue == 'F')
        !          1813:        {
        !          1814:            printf("(attente d'une connexion sur une socket)\n\n");
        !          1815:        }
        !          1816:        else
        !          1817:        {
        !          1818:            printf("(wait for connection on a socket)\n\n");
        !          1819:        }
        !          1820: 
        !          1821:        printf("    1: %s\n", d_SCK);
        !          1822:        printf("->  2: %s\n", d_SCK);
        !          1823:        printf("    1: %s\n", d_SCK);
        !          1824: 
        !          1825:        return;
        !          1826:    }
        !          1827:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          1828:    {
        !          1829:        (*s_etat_processus).nombre_arguments = -1;
        !          1830:        return;
        !          1831:    }
        !          1832: 
        !          1833:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          1834:    {
        !          1835:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
        !          1836:        {
        !          1837:            return;
        !          1838:        }
        !          1839:    }
        !          1840: 
        !          1841:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          1842:            &s_objet_argument) == d_erreur)
        !          1843:    {
        !          1844:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          1845:        return;
        !          1846:    }
        !          1847: 
        !          1848:    if ((*s_objet_argument).type == SCK)
        !          1849:    {
        !          1850:        if ((strcmp((*((struct_socket *) (*s_objet_argument).objet)).type,
        !          1851:                "STREAM") != 0) && (strcmp((*((struct_socket *)
        !          1852:                (*s_objet_argument).objet)).type, "SEQUENTIAL DATAGRAM") != 0))
        !          1853:        {
        !          1854:            liberation(s_etat_processus, s_objet_argument);
        !          1855: 
        !          1856:            (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
        !          1857:            return;
        !          1858:        }
        !          1859: 
        !          1860:        if ((s_objet_resultat = copie_objet(s_etat_processus, s_objet_argument,
        !          1861:                'O')) == NULL)
        !          1862:        {
        !          1863:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !          1864:            return;
        !          1865:        }
        !          1866: 
        !          1867:        (*((struct_socket *) (*s_objet_resultat).objet)).socket_en_ecoute = 'N';
        !          1868:        (*((struct_socket *) (*s_objet_resultat).objet)).effacement = 'N';
        !          1869: 
        !          1870:        if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine == PF_INET)
        !          1871:        {
        !          1872:            longueur = sizeof(adresse_ipv4);
        !          1873: 
        !          1874:            do
        !          1875:            {
        !          1876:                drapeau = d_vrai;
        !          1877: 
        !          1878:                if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          1879:                {
        !          1880:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1881:                    return;
        !          1882:                }
        !          1883: 
        !          1884:                if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
        !          1885:                        accept((*((struct_socket *) (*s_objet_argument).objet))
        !          1886:                        .socket, (struct sockaddr *) &adresse_ipv4, &longueur))
        !          1887:                        < 0)
        !          1888:                {
        !          1889:                    erreur = errno;
        !          1890: 
        !          1891:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1892:                    {
        !          1893:                        if (errno != EINTR)
        !          1894:                        {
        !          1895:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1896:                            return;
        !          1897:                        }
        !          1898:                    }
        !          1899: 
        !          1900:                    if (erreur != EINTR)
        !          1901:                    {
        !          1902:                        liberation(s_etat_processus, s_objet_argument);
        !          1903:                        liberation(s_etat_processus, s_objet_resultat);
        !          1904: 
        !          1905:                        (*s_etat_processus).erreur_execution =
        !          1906:                                d_ex_erreur_acces_fichier;
        !          1907:                        return;
        !          1908:                    }
        !          1909: 
        !          1910:                    scrutation_injection(s_etat_processus);
        !          1911: 
        !          1912:                    if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          1913:                    {
        !          1914:                        drapeau = d_vrai;
        !          1915:                    }
        !          1916:                    else
        !          1917:                    {
        !          1918:                        drapeau = d_faux;
        !          1919:                    }
        !          1920:                }
        !          1921:                else
        !          1922:                {
        !          1923:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1924:                    {
        !          1925:                        if (errno != EINTR)
        !          1926:                        {
        !          1927:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1928:                            return;
        !          1929:                        }
        !          1930:                    }
        !          1931:                }
        !          1932:            } while(drapeau == d_faux);
        !          1933: 
        !          1934:            if (((*((struct_socket *) (*s_objet_resultat).objet))
        !          1935:                    .adresse_distante = malloc(22 *
        !          1936:                    sizeof(unsigned char))) == NULL)
        !          1937:            {
        !          1938:                (*s_etat_processus).erreur_systeme =
        !          1939:                        d_es_allocation_memoire;
        !          1940:                return;
        !          1941:            }
        !          1942: 
        !          1943:            sprintf((*((struct_socket *) (*s_objet_resultat).objet))
        !          1944:                    .adresse_distante, "%d.%d.%d.%d(%d)",
        !          1945:                    (ntohl(adresse_ipv4.sin_addr.s_addr) >> 24) & 0xFF,
        !          1946:                    (ntohl(adresse_ipv4.sin_addr.s_addr) >> 16) & 0xFF,
        !          1947:                    (ntohl(adresse_ipv4.sin_addr.s_addr) >> 8) & 0xFF,
        !          1948:                    ntohl(adresse_ipv4.sin_addr.s_addr) & 0xFF,
        !          1949:                    ntohs(adresse_ipv4.sin_port));
        !          1950:        }
        !          1951:        else if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine ==
        !          1952:                PF_INET6)
        !          1953:        {
        !          1954:            longueur = sizeof(adresse_ipv6);
        !          1955: 
        !          1956:            do
        !          1957:            {
        !          1958:                drapeau = d_vrai;
        !          1959: 
        !          1960:                if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          1961:                {
        !          1962:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1963:                    return;
        !          1964:                }
        !          1965: 
        !          1966:                if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
        !          1967:                        accept((*((struct_socket *) (*s_objet_argument).objet))
        !          1968:                        .socket, (struct sockaddr *) &adresse_ipv6, &longueur))
        !          1969:                        < 0)
        !          1970:                {
        !          1971:                    erreur = errno;
        !          1972: 
        !          1973:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          1974:                    {
        !          1975:                        if (errno != EINTR)
        !          1976:                        {
        !          1977:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          1978:                            return;
        !          1979:                        }
        !          1980:                    }
        !          1981: 
        !          1982:                    if (erreur != EINTR)
        !          1983:                    {
        !          1984:                        liberation(s_etat_processus, s_objet_argument);
        !          1985:                        liberation(s_etat_processus, s_objet_resultat);
        !          1986: 
        !          1987:                        (*s_etat_processus).erreur_execution =
        !          1988:                                d_ex_erreur_acces_fichier;
        !          1989:                        return;
        !          1990:                    }
        !          1991: 
        !          1992:                    scrutation_injection(s_etat_processus);
        !          1993: 
        !          1994:                    if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          1995:                    {
        !          1996:                        drapeau = d_vrai;
        !          1997:                    }
        !          1998:                    else
        !          1999:                    {
        !          2000:                        drapeau = d_faux;
        !          2001:                    }
        !          2002:                }
        !          2003:                else
        !          2004:                {
        !          2005:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          2006:                    {
        !          2007:                        if (errno != EINTR)
        !          2008:                        {
        !          2009:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2010:                            return;
        !          2011:                        }
        !          2012:                    }
        !          2013:                }
        !          2014:            } while(drapeau == d_faux);
        !          2015: 
        !          2016:            if (((*((struct_socket *) (*s_objet_resultat).objet))
        !          2017:                    .adresse_distante = malloc(55 *
        !          2018:                    sizeof(unsigned char))) == NULL)
        !          2019:            {
        !          2020:                (*s_etat_processus).erreur_systeme =
        !          2021:                        d_es_allocation_memoire;
        !          2022:                return;
        !          2023:            }
        !          2024: 
        !          2025:            (*((struct_socket *) (*s_objet_resultat).objet))
        !          2026:                    .adresse_distante = d_code_fin_chaine;
        !          2027: 
        !          2028:            for(i = 0; i < 16; i++)
        !          2029:            {
        !          2030:                sprintf((*((struct_socket *) (*s_objet_resultat)
        !          2031:                        .objet)).adresse_distante, (i == 0) ? "%s%X" : "%s:%X",
        !          2032:                        (*((struct_socket *) (*s_objet_resultat)
        !          2033:                        .objet)).adresse_distante,
        !          2034:                        adresse_ipv6.sin6_addr.s6_addr[i]);
        !          2035:            }
        !          2036: 
        !          2037:            sprintf((*((struct_socket *) (*s_objet_resultat)
        !          2038:                    .objet)).adresse_distante, "%s(%u)",
        !          2039:                    (*((struct_socket *) (*s_objet_resultat)
        !          2040:                    .objet)).adresse_distante, ntohs(adresse_ipv6.sin6_port));
        !          2041:        }
        !          2042:        else
        !          2043:        {
        !          2044:            longueur = 0;
        !          2045: 
        !          2046:            do
        !          2047:            {
        !          2048:                drapeau = d_vrai;
        !          2049: 
        !          2050:                if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          2051:                {
        !          2052:                    (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2053:                    return;
        !          2054:                }
        !          2055: 
        !          2056:                if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
        !          2057:                        accept((*((struct_socket *) (*s_objet_argument).objet))
        !          2058:                        .socket, NULL, &longueur)) < 0)
        !          2059:                {
        !          2060:                    erreur = errno;
        !          2061: 
        !          2062:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          2063:                    {
        !          2064:                        if (errno != EINTR)
        !          2065:                        {
        !          2066:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2067:                            return;
        !          2068:                        }
        !          2069:                    }
        !          2070: 
        !          2071:                    if (erreur != EINTR)
        !          2072:                    {
        !          2073:                        liberation(s_etat_processus, s_objet_argument);
        !          2074:                        liberation(s_etat_processus, s_objet_resultat);
        !          2075: 
        !          2076:                        (*s_etat_processus).erreur_execution =
        !          2077:                                d_ex_erreur_acces_fichier;
        !          2078:                        return;
        !          2079:                    }
        !          2080: 
        !          2081:                    scrutation_injection(s_etat_processus);
        !          2082: 
        !          2083:                    if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          2084:                    {
        !          2085:                        drapeau = d_vrai;
        !          2086:                    }
        !          2087:                    else
        !          2088:                    {
        !          2089:                        drapeau = d_faux;
        !          2090:                    }
        !          2091:                }
        !          2092:                else
        !          2093:                {
        !          2094:                    while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          2095:                    {
        !          2096:                        if (errno != EINTR)
        !          2097:                        {
        !          2098:                            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2099:                            return;
        !          2100:                        }
        !          2101:                    }
        !          2102:                }
        !          2103:            } while(drapeau == d_faux);
        !          2104:        }
        !          2105: 
        !          2106:        // Si accept() renvoie une erreur non récupérée, il ne peut s'agir
        !          2107:        // que de EINTR sachant qu'une requête d'arrêt est en court de
        !          2108:        // traitement.
        !          2109: 
        !          2110:        if ((*((struct_socket *) (*s_objet_resultat).objet)).socket >= 0)
        !          2111:        {
        !          2112:            l_element_courant = (*s_etat_processus).s_sockets;
        !          2113: 
        !          2114:            if (l_element_courant == NULL)
        !          2115:            {
        !          2116:                if (((*s_etat_processus).s_sockets =
        !          2117:                        allocation_maillon(s_etat_processus)) == NULL)
        !          2118:                {
        !          2119:                    (*s_etat_processus).erreur_systeme =
        !          2120:                            d_es_allocation_memoire;
        !          2121:                    return;
        !          2122:                }
        !          2123: 
        !          2124:                (*(*s_etat_processus).s_sockets).suivant = NULL;
        !          2125:                l_element_courant = (*s_etat_processus).s_sockets;
        !          2126:            }
        !          2127:            else
        !          2128:            {
        !          2129:                /*
        !          2130:                 * Ajout d'un élément à la fin de la liste chaînée
        !          2131:                 */
        !          2132: 
        !          2133:                while((*l_element_courant).suivant != NULL)
        !          2134:                {
        !          2135:                    l_element_courant = (*l_element_courant).suivant;
        !          2136:                }
        !          2137: 
        !          2138:                if (((*l_element_courant).suivant =
        !          2139:                        allocation_maillon(s_etat_processus)) == NULL)
        !          2140:                {
        !          2141:                    (*s_etat_processus).erreur_systeme =
        !          2142:                            d_es_allocation_memoire;
        !          2143:                    return;
        !          2144:                }
        !          2145: 
        !          2146:                l_element_courant = (*l_element_courant).suivant;
        !          2147:                (*l_element_courant).suivant = NULL;
        !          2148:            }
        !          2149: 
        !          2150:            if (((*l_element_courant).donnee = copie_objet(s_etat_processus,
        !          2151:                    s_objet_resultat, 'O')) == NULL)
        !          2152:            {
        !          2153:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !          2154:                return;
        !          2155:            }
        !          2156:        }
        !          2157: 
        !          2158:        if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          2159:                s_objet_argument) == d_erreur)
        !          2160:        {
        !          2161:            return;
        !          2162:        }
        !          2163: 
        !          2164:        if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          2165:                s_objet_resultat) == d_erreur)
        !          2166:        {
        !          2167:            return;
        !          2168:        }
        !          2169:    }
        !          2170:    else
        !          2171:    {
        !          2172:        liberation(s_etat_processus, s_objet_argument);
        !          2173: 
        !          2174:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !          2175:        return;
        !          2176:    }
        !          2177: 
        !          2178:    return;
        !          2179: }
        !          2180: 
        !          2181: 
        !          2182: /*
        !          2183: ================================================================================
        !          2184:   Fonction 'wfswi'
        !          2185: ================================================================================
        !          2186:   Entrées : pointeur sur une structure struct_processus
        !          2187: --------------------------------------------------------------------------------
        !          2188:   Sorties :
        !          2189: --------------------------------------------------------------------------------
        !          2190:   Effets de bord : néant
        !          2191: ================================================================================
        !          2192: */
        !          2193: 
        !          2194: void
        !          2195: instruction_wfswi(struct_processus *s_etat_processus)
        !          2196: {
        !          2197:    integer8                    interruption;
        !          2198: 
        !          2199:    logical1                    drapeau_fin;
        !          2200: 
        !          2201:    struct_objet                *s_objet_argument;
        !          2202: 
        !          2203:    struct timespec             attente;
        !          2204: 
        !          2205:    (*s_etat_processus).erreur_execution = d_ex;
        !          2206: 
        !          2207:    attente.tv_sec = 0;
        !          2208:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          2209: 
        !          2210:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          2211:    {
        !          2212:        printf("\n  WFSWI ");
        !          2213: 
        !          2214:        if ((*s_etat_processus).langue == 'F')
        !          2215:        {
        !          2216:            printf("(attente d'une interruption)\n\n");
        !          2217:        }
        !          2218:        else
        !          2219:        {
        !          2220:            printf("(wait for interrupt)\n\n");
        !          2221:        }
        !          2222: 
        !          2223:        printf("    1: %s\n", d_INT);
        !          2224: 
        !          2225:        return;
        !          2226:    }
        !          2227:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          2228:    {
        !          2229:        (*s_etat_processus).nombre_arguments = -1;
        !          2230:        return;
        !          2231:    }
        !          2232: 
        !          2233:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          2234:    {
        !          2235:        if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
        !          2236:        {
        !          2237:            return;
        !          2238:        }
        !          2239:    }
        !          2240: 
        !          2241:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !          2242:            &s_objet_argument) == d_erreur)
        !          2243:    {
        !          2244:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !          2245:        return;
        !          2246:    }
        !          2247: 
        !          2248:    if ((*s_objet_argument).type == INT)
        !          2249:    {
        !          2250:        drapeau_fin = d_faux;
        !          2251: 
        !          2252:        interruption = (*((integer8 *) (*s_objet_argument).objet));
        !          2253: 
        !          2254:        if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
        !          2255:        {
        !          2256:            liberation(s_etat_processus, s_objet_argument);
        !          2257: 
        !          2258:            (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
        !          2259:            return;
        !          2260:        }
        !          2261: 
        !          2262:        while(drapeau_fin == d_faux)
        !          2263:        {
        !          2264:            if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          2265:            {
        !          2266:                liberation(s_etat_processus, s_objet_argument);
        !          2267:                return;
        !          2268:            }
        !          2269: 
        !          2270:            if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
        !          2271:            {
        !          2272:                affectation_interruptions_logicielles(s_etat_processus);
        !          2273:            }
        !          2274: 
        !          2275:            if ((*s_etat_processus).queue_interruptions[interruption - 1] > 0)
        !          2276:            {
        !          2277:                drapeau_fin = d_vrai;
        !          2278:            }
        !          2279:            else
        !          2280:            {
        !          2281:                nanosleep(&attente, NULL);
        !          2282:                scrutation_injection(s_etat_processus);
        !          2283:                INCR_GRANULARITE(attente.tv_nsec);
        !          2284:            }
        !          2285:        }
        !          2286:    }
        !          2287:    else
        !          2288:    {
        !          2289:        liberation(s_etat_processus, s_objet_argument);
        !          2290: 
        !          2291:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !          2292:        return;
        !          2293:    }
        !          2294: 
        !          2295:    liberation(s_etat_processus, s_objet_argument);
        !          2296: 
        !          2297:    return;
        !          2298: }
        !          2299: 
        !          2300: 
        !          2301: /*
        !          2302: ================================================================================
        !          2303:   Fonction 'wfpoke'
        !          2304: ================================================================================
        !          2305:   Entrées : pointeur sur une structure struct_processus
        !          2306: --------------------------------------------------------------------------------
        !          2307:   Sorties :
        !          2308: --------------------------------------------------------------------------------
        !          2309:   Effets de bord : néant
        !          2310: ================================================================================
        !          2311: */
        !          2312: 
        !          2313: void
        !          2314: instruction_wfpoke(struct_processus *s_etat_processus)
        !          2315: {
        !          2316:    struct timespec             attente;
        !          2317: 
        !          2318:    unsigned char               registre_instruction_valide;
        !          2319: 
        !          2320:    (*s_etat_processus).erreur_execution = d_ex;
        !          2321: 
        !          2322:    attente.tv_sec = 0;
        !          2323:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          2324: 
        !          2325:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          2326:    {
        !          2327:        printf("\n  WFPOKE ");
        !          2328: 
        !          2329:        if ((*s_etat_processus).langue == 'F')
        !          2330:        {
        !          2331:            printf("(attente de données en provenance du processus père)\n\n");
        !          2332:            printf("  Aucun argument\n");
        !          2333:        }
        !          2334:        else
        !          2335:        {
        !          2336:            printf("(wait for data from parent process)\n\n");
        !          2337:            printf("  No argument\n");
        !          2338:        }
        !          2339: 
        !          2340:        return;
        !          2341:    }
        !          2342:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          2343:    {
        !          2344:        (*s_etat_processus).nombre_arguments = -1;
        !          2345:        return;
        !          2346:    }
        !          2347: 
        !          2348:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          2349:    {
        !          2350:        if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
        !          2351:        {
        !          2352:            return;
        !          2353:        }
        !          2354:    }
        !          2355: 
        !          2356:    if ((*s_etat_processus).presence_pipes == d_faux)
        !          2357:    {
        !          2358:        (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
        !          2359:        return;
        !          2360:    }
        !          2361: 
        !          2362:    if ((*s_etat_processus).nombre_objets_injectes > 0)
        !          2363:    {
        !          2364:        return;
        !          2365:    }
        !          2366: 
        !          2367:    if ((*s_etat_processus).profilage == d_vrai)
        !          2368:    {
        !          2369:        profilage(s_etat_processus, "Interprocess or interthread "
        !          2370:                "communications (WFPOKE)");
        !          2371: 
        !          2372:        if ((*s_etat_processus).erreur_systeme != d_es)
        !          2373:        {
        !          2374:            return;
        !          2375:        }
        !          2376:    }
        !          2377: 
        !          2378:    do
        !          2379:    {
        !          2380:        if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          2381:        {
        !          2382:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2383:            return;
        !          2384:        }
        !          2385: 
        !          2386:        nanosleep(&attente, NULL);
        !          2387: 
        !          2388:        while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          2389:        {
        !          2390:            if (errno != EINTR)
        !          2391:            {
        !          2392:                (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2393:                return;
        !          2394:            }
        !          2395:        }
        !          2396: 
        !          2397:        scrutation_injection(s_etat_processus);
        !          2398: 
        !          2399:        if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
        !          2400:        {
        !          2401:            affectation_interruptions_logicielles(s_etat_processus);
        !          2402:        }
        !          2403: 
        !          2404:        if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
        !          2405:        {
        !          2406:            registre_instruction_valide =
        !          2407:                    (*s_etat_processus).instruction_valide;
        !          2408:            traitement_interruptions_logicielles(s_etat_processus);
        !          2409:            (*s_etat_processus).instruction_valide =
        !          2410:                    registre_instruction_valide;
        !          2411:        }
        !          2412: 
        !          2413:        if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          2414:        {
        !          2415:            if ((*s_etat_processus).profilage == d_vrai)
        !          2416:            {
        !          2417:                profilage(s_etat_processus, NULL);
        !          2418:            }
        !          2419: 
        !          2420:            return;
        !          2421:        }
        !          2422: 
        !          2423:        INCR_GRANULARITE(attente.tv_nsec);
        !          2424:    } while((*s_etat_processus).nombre_objets_injectes == 0);
        !          2425: 
        !          2426:    return;
        !          2427: }
        !          2428: 
        !          2429: 
        !          2430: /*
        !          2431: ================================================================================
        !          2432:   Fonction 'wfack'
        !          2433: ================================================================================
        !          2434:   Entrées : pointeur sur une structure struct_processus
        !          2435: --------------------------------------------------------------------------------
        !          2436:   Sorties :
        !          2437: --------------------------------------------------------------------------------
        !          2438:   Effets de bord : néant
        !          2439: ================================================================================
        !          2440: */
        !          2441: 
        !          2442: void
        !          2443: instruction_wfack(struct_processus *s_etat_processus)
        !          2444: {
        !          2445:    struct timespec             attente;
        !          2446: 
        !          2447:    unsigned char               registre_instruction_valide;
        !          2448: 
        !          2449:    (*s_etat_processus).erreur_execution = d_ex;
        !          2450: 
        !          2451:    attente.tv_sec = 0;
        !          2452:    attente.tv_nsec = GRANULARITE_us * 1000;
        !          2453: 
        !          2454:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !          2455:    {
        !          2456:        printf("\n  WFACK ");
        !          2457: 
        !          2458:        if ((*s_etat_processus).langue == 'F')
        !          2459:        {
        !          2460:            printf("(attente des acquittements de lecture)\n\n");
        !          2461:            printf("  Aucun argument\n");
        !          2462:        }
        !          2463:        else
        !          2464:        {
        !          2465:            printf("(wait for reading of data acknowledgement)\n\n");
        !          2466:            printf("  No argument\n");
        !          2467:        }
        !          2468: 
        !          2469:        return;
        !          2470:    }
        !          2471:    else if ((*s_etat_processus).test_instruction == 'Y')
        !          2472:    {
        !          2473:        (*s_etat_processus).nombre_arguments = -1;
        !          2474:        return;
        !          2475:    }
        !          2476: 
        !          2477:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !          2478:    {
        !          2479:        if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
        !          2480:        {
        !          2481:            return;
        !          2482:        }
        !          2483:    }
        !          2484: 
        !          2485:    if ((*s_etat_processus).presence_pipes == d_faux)
        !          2486:    {
        !          2487:        (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
        !          2488:        return;
        !          2489:    }
        !          2490: 
        !          2491:    if ((*s_etat_processus).profilage == d_vrai)
        !          2492:    {
        !          2493:        profilage(s_etat_processus, "Interprocess or interthread communications"
        !          2494:                " (WFACK)");
        !          2495: 
        !          2496:        if ((*s_etat_processus).erreur_systeme != d_es)
        !          2497:        {
        !          2498:            return;
        !          2499:        }
        !          2500:    }
        !          2501: 
        !          2502:    while((*s_etat_processus).nombre_objets_envoyes_non_lus != 0)
        !          2503:    {
        !          2504:        scrutation_injection(s_etat_processus);
        !          2505: 
        !          2506:        if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
        !          2507:        {
        !          2508:            affectation_interruptions_logicielles(s_etat_processus);
        !          2509:        }
        !          2510: 
        !          2511:        if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
        !          2512:        {
        !          2513:            registre_instruction_valide =
        !          2514:                    (*s_etat_processus).instruction_valide;
        !          2515:            traitement_interruptions_logicielles(s_etat_processus);
        !          2516:            (*s_etat_processus).instruction_valide =
        !          2517:                    registre_instruction_valide;
        !          2518:        }
        !          2519: 
        !          2520:        if ((*s_etat_processus).var_volatile_requete_arret != 0)
        !          2521:        {
        !          2522:            if ((*s_etat_processus).profilage == d_vrai)
        !          2523:            {
        !          2524:                profilage(s_etat_processus, NULL);
        !          2525:            }
        !          2526: 
        !          2527:            return;
        !          2528:        }
        !          2529: 
        !          2530:        if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
        !          2531:        {
        !          2532:            (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2533:            return;
        !          2534:        }
        !          2535: 
        !          2536:        nanosleep(&attente, NULL);
        !          2537:        INCR_GRANULARITE(attente.tv_nsec);
        !          2538: 
        !          2539:        while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
        !          2540:        {
        !          2541:            if (errno != EINTR)
        !          2542:            {
        !          2543:                (*s_etat_processus).erreur_systeme = d_es_processus;
        !          2544:                return;
        !          2545:            }
        !          2546:        }
        !          2547:    }
        !          2548: 
        !          2549:    if ((*s_etat_processus).profilage == d_vrai)
        !          2550:    {
        !          2551:        profilage(s_etat_processus, NULL);
        !          2552:    }
        !          2553: 
        !          2554:    return;
        !          2555: }
        !          2556: 
        !          2557: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>