File:  [local] / rpl / src / instructions_w1.c
Revision 1.50: download - view: text, annotated - select for diffs - revision graph
Tue Sep 20 09:51:43 2011 UTC (12 years, 7 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
Typo.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.3
    4:   Copyright (C) 1989-2011 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) || ((*s_objet).type == REL))
  230:     {
  231:         if ((*s_objet).type == INT)
  232:         {
  233:             attente = (real8) (*((integer8 *) (*s_objet).objet));
  234:         }
  235:         else
  236:         {
  237:             attente = (*((real8 *) (*s_objet).objet));
  238:         }
  239: 
  240:         if (attente < 0)
  241:         {
  242:             liberation(s_etat_processus, s_objet);
  243: 
  244:             (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
  245:             return;
  246:         }
  247: 
  248:         temporisation.tv_sec = (long) floor((double) attente);
  249:         temporisation.tv_nsec = (attente - temporisation.tv_sec) *
  250:                 (long) 1000000000;
  251: 
  252:         if ((*s_etat_processus).profilage == d_vrai)
  253:         {
  254:             profilage(s_etat_processus, "Sleep function (WAIT)");
  255: 
  256:             if ((*s_etat_processus).erreur_systeme != d_es)
  257:             {
  258:                 return;
  259:             }
  260:         }
  261: 
  262:         do
  263:         {
  264:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
  265:             {
  266:                 (*s_etat_processus).erreur_systeme = d_es_processus;
  267:                 return;
  268:             }
  269: 
  270:             code_retour = nanosleep(&temporisation, &temporisation);
  271:             erreur = errno;
  272: 
  273:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
  274:             {
  275:                 if (errno != EINTR)
  276:                 {
  277:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  278:                     return;
  279:                 }
  280:             }
  281: 
  282:             scrutation_injection(s_etat_processus);
  283: 
  284:             if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
  285:             {
  286:                 affectation_interruptions_logicielles(s_etat_processus);
  287:             }
  288: 
  289:             if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
  290:             {
  291:                 traitement_interruptions_logicielles(s_etat_processus);
  292:             }
  293:         } while(((code_retour == -1) && (erreur == EINTR))
  294:                 && ((*s_etat_processus).var_volatile_requete_arret == 0));
  295: 
  296:         if ((*s_etat_processus).profilage == d_vrai)
  297:         {
  298:             profilage(s_etat_processus, NULL);
  299:         }
  300:     }
  301:     else
  302:     {
  303:         liberation(s_etat_processus, s_objet);
  304: 
  305:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  306:         return;
  307:     }
  308: 
  309:     liberation(s_etat_processus, s_objet);
  310: 
  311:     return;
  312: }
  313: 
  314: 
  315: /*
  316: ================================================================================
  317:   Fonction 'wireframe' (passe en mode d'affichage échantillonné)
  318: ================================================================================
  319:   Entrées : structure processus
  320: --------------------------------------------------------------------------------
  321:   Sorties :
  322: --------------------------------------------------------------------------------
  323:   Effets de bord : néant
  324: ================================================================================
  325: */
  326: 
  327: void
  328: instruction_wireframe(struct_processus *s_etat_processus)
  329: {
  330:     (*s_etat_processus).erreur_execution = d_ex;
  331: 
  332:     if ((*s_etat_processus).affichage_arguments == 'Y')
  333:     {
  334:         printf("\n  WIREFRAME ");
  335: 
  336:         if ((*s_etat_processus).langue == 'F')
  337:         {
  338:             printf("(graphique tridimensionnel grillagé)\n\n");
  339:             printf("  Aucun argument\n");
  340:         }
  341:         else
  342:         {
  343:             printf("(wireframe 3D graph)\n\n");
  344:             printf("  No argument\n");
  345:         }
  346: 
  347:         return;
  348:     }
  349:     else if ((*s_etat_processus).test_instruction == 'Y')
  350:     {
  351:         (*s_etat_processus).nombre_arguments = -1;
  352:         return;
  353:     }
  354: 
  355:     strcpy((*s_etat_processus).type_trace_eq, "GRILLE 3D");
  356: 
  357:     return;
  358: }
  359: 
  360: 
  361: /*
  362: ================================================================================
  363:   Fonction 'write'
  364: ================================================================================
  365:   Entrées : structure processus
  366: --------------------------------------------------------------------------------
  367:   Sorties :
  368: --------------------------------------------------------------------------------
  369:   Effets de bord : néant
  370: ================================================================================
  371: */
  372: 
  373: void
  374: instruction_write(struct_processus *s_etat_processus)
  375: {
  376:     const char                          *queue;
  377: 
  378:     int                                 adresse[16];
  379:     int                                 port;
  380: 
  381:     integer8                            clef;
  382:     integer8                            compteur;
  383:     integer8                            id;
  384:     integer8                            ordre;
  385: 
  386:     logical1                            mise_a_jour;
  387: 
  388:     long                                longueur_effective;
  389:     long                                recursivite;
  390: 
  391:     sqlite3_stmt                        *ppStmt;
  392: 
  393:     ssize_t                             ios;
  394: 
  395:     struct_descripteur_fichier          *descripteur;
  396: 
  397:     struct_liste_chainee                *l_element_courant;
  398:     struct_liste_chainee                *l_element_courant_format;
  399: 
  400:     struct_objet                        *s_format;
  401:     struct_objet                        *s_element;
  402:     struct_objet                        *s_objet_argument_1;
  403:     struct_objet                        *s_objet_argument_2;
  404:     struct_objet                        *s_objet_argument_3;
  405: 
  406:     struct sigaction                    action;
  407:     struct sigaction                    registre;
  408: 
  409:     struct sockaddr_in                  adresse_ipv4;
  410: #   ifdef IPV6
  411:     struct sockaddr_in6                 adresse_ipv6;
  412: #   endif
  413:     struct sockaddr_un                  adresse_unix;
  414: 
  415:     struct flock                        lock;
  416: 
  417:     uint32_t                            calcul_adresse;
  418: 
  419:     unsigned char                       *chaine;
  420:     unsigned char                       *chaine_utf8;
  421:     unsigned char                       *clef_utf8;
  422:     unsigned char                       *commande;
  423: 
  424:     unsigned long                       i;
  425: 
  426:     (*s_etat_processus).erreur_execution = d_ex;
  427: 
  428:     if ((*s_etat_processus).affichage_arguments == 'Y')
  429:     {
  430:         printf("\n  WRITE ");
  431: 
  432:         if ((*s_etat_processus).langue == 'F')
  433:         {
  434:             printf("(écriture d'un enregistrement d'un fichier)\n\n");
  435:         }
  436:         else
  437:         {
  438:             printf("(write a record of a file)\n\n");
  439:         }
  440: 
  441:         printf("    2: %s\n", d_LST);
  442:         printf("    1: %s, %s\n\n", d_FCH, d_SCK);
  443: 
  444:         printf("    3: %s\n", d_LST);
  445:         printf("    2: %s\n", d_INT);
  446:         printf("    1: %s\n", d_FCH);
  447:         return;
  448:     }
  449:     else if ((*s_etat_processus).test_instruction == 'Y')
  450:     {
  451:         (*s_etat_processus).nombre_arguments = -1;
  452:         return;
  453:     }
  454: 
  455:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  456:     {
  457:         if ((*s_etat_processus).l_base_pile == NULL)
  458:         {
  459:             (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  460:             return;
  461:         }
  462: 
  463:         if ((*(*(*s_etat_processus).l_base_pile).donnee).type == FCH)
  464:         {
  465:             if ((*((struct_fichier *) (*(*(*s_etat_processus).l_base_pile)
  466:                     .donnee).objet)).acces == 'D')
  467:             {
  468:                 if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
  469:                 {
  470:                     return;
  471:                 }
  472:             }
  473:             else
  474:             {
  475:                 if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  476:                 {
  477:                     return;
  478:                 }
  479:             }
  480:         }
  481:         else
  482:         {
  483:             if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  484:             {
  485:                 return;
  486:             }
  487:         }
  488:     }
  489: 
  490:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  491:             &s_objet_argument_1) == d_erreur)
  492:     {
  493:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  494:         return;
  495:     }
  496:     
  497:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  498:             &s_objet_argument_2) == d_erreur)
  499:     {
  500:         liberation(s_etat_processus, s_objet_argument_1);
  501: 
  502:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  503:         return;
  504:     }
  505:     
  506:     if ((*s_objet_argument_1).type == FCH)
  507:     {
  508:         if ((descripteur = descripteur_fichier(s_etat_processus,
  509:                 (struct_fichier *) (*s_objet_argument_1).objet)) == NULL)
  510:         {
  511:             return;
  512:         }
  513: 
  514:         /*
  515:          * Vérification des verrous
  516:          */
  517: 
  518:         lock.l_type = F_WRLCK;
  519:         lock.l_whence = SEEK_SET;
  520:         lock.l_start = 0;
  521:         lock.l_len = 0;
  522:         lock.l_pid = getpid();
  523:         recursivite = 0;
  524: 
  525:         if (fcntl(fileno((*descripteur).descripteur_c), F_GETLK, &lock)
  526:                 == -1)
  527:         {
  528:             liberation(s_etat_processus, s_objet_argument_2);
  529:             liberation(s_etat_processus, s_objet_argument_1);
  530: 
  531:             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  532:             return;
  533:         }
  534: 
  535:         if (lock.l_type != F_UNLCK)
  536:         {
  537:             liberation(s_etat_processus, s_objet_argument_2);
  538:             liberation(s_etat_processus, s_objet_argument_1);
  539: 
  540:             (*s_etat_processus).erreur_execution =
  541:                     d_ex_fichier_verrouille;
  542:             return;
  543:         }
  544: 
  545:         /*
  546:          * Vérification de l'autorisation d'écriture
  547:          */
  548: 
  549:         if ((*((struct_fichier *) (*s_objet_argument_1).objet))
  550:                 .protection == 'R')
  551:         {
  552:             liberation(s_etat_processus, s_objet_argument_2);
  553:             liberation(s_etat_processus, s_objet_argument_1);
  554: 
  555:             (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
  556:             return;
  557:         }
  558: 
  559:         if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire == 'N')
  560:         {
  561:             /*
  562:              * Fichiers formatés
  563:              */
  564: 
  565:             if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
  566:                     == 'S')
  567:             {
  568:                 if ((*s_objet_argument_2).type != LST)
  569:                 {
  570:                     liberation(s_etat_processus, s_objet_argument_2);
  571:                     liberation(s_etat_processus, s_objet_argument_1);
  572: 
  573:                     (*s_etat_processus).erreur_execution =
  574:                             d_ex_erreur_type_argument;
  575:                     return;
  576:                 }
  577: 
  578:                 if ((chaine = formateur_fichier(s_etat_processus,
  579:                         s_objet_argument_2, (*((struct_fichier *)
  580:                         (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
  581:                         &longueur_effective, &recursivite)) == NULL)
  582:                 {
  583:                     liberation(s_etat_processus, s_objet_argument_2);
  584:                     liberation(s_etat_processus, s_objet_argument_1);
  585: 
  586:                     return;
  587:                 }
  588: 
  589:                 BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
  590: 
  591:                 if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END)
  592:                         != 0)
  593:                 {
  594:                     liberation(s_etat_processus, s_objet_argument_2);
  595:                     liberation(s_etat_processus, s_objet_argument_1);
  596: 
  597:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  598:                     return;
  599:                 }
  600: 
  601:                 if ((chaine_utf8 = transliteration(s_etat_processus,
  602:                         chaine, d_locale, "UTF-8")) == NULL)
  603:                 {
  604:                     free(chaine);
  605: 
  606:                     liberation(s_etat_processus, s_objet_argument_2);
  607:                     liberation(s_etat_processus, s_objet_argument_1);
  608: 
  609:                     return;
  610:                 }
  611: 
  612:                 free(chaine);
  613: 
  614:                 if (fprintf((*descripteur).descripteur_c, "%s\n", chaine_utf8)
  615:                         < 0)
  616:                 {
  617:                     free(chaine_utf8);
  618: 
  619:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  620:                     return;
  621:                 }
  622: 
  623:                 free(chaine_utf8);
  624:             }
  625:             else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
  626:                     == 'D')
  627:             {
  628:                 BUG(((*descripteur).type != 'S'), uprintf("Bad filetype !\n"));
  629: 
  630:                 if ((*s_objet_argument_2).type != INT)
  631:                 {
  632:                     liberation(s_etat_processus, s_objet_argument_2);
  633:                     liberation(s_etat_processus, s_objet_argument_1);
  634: 
  635:                     (*s_etat_processus).erreur_execution =
  636:                             d_ex_erreur_type_argument;
  637:                     return;
  638:                 }
  639: 
  640:                 if (depilement(s_etat_processus, &((*s_etat_processus)
  641:                         .l_base_pile), &s_objet_argument_3) == d_erreur)
  642:                 {
  643:                     (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  644:                     return;
  645:                 }
  646: 
  647:                 if ((*s_objet_argument_3).type != LST)
  648:                 {
  649:                     liberation(s_etat_processus, s_objet_argument_3);
  650:                     liberation(s_etat_processus, s_objet_argument_2);
  651:                     liberation(s_etat_processus, s_objet_argument_1);
  652: 
  653:                     (*s_etat_processus).erreur_execution =
  654:                             d_ex_erreur_type_argument;
  655:                     return;
  656:                 }
  657: 
  658:                 // Modification ou création d'un nouvel enregistrement
  659: 
  660:                 if ((chaine = formateur_fichier(s_etat_processus,
  661:                         s_objet_argument_3, (*((struct_fichier *)
  662:                         (*s_objet_argument_1).objet)).format, 0, 0, ' ',
  663:                         'F', &longueur_effective, &recursivite)) == NULL)
  664:                 {
  665:                     liberation(s_etat_processus, s_objet_argument_3);
  666:                     liberation(s_etat_processus, s_objet_argument_2);
  667:                     liberation(s_etat_processus, s_objet_argument_1);
  668: 
  669:                     return;
  670:                 }
  671: 
  672:                 if ((chaine_utf8 = transliteration(s_etat_processus,
  673:                         chaine, d_locale, "UTF-8")) == NULL)
  674:                 {
  675:                     free(chaine);
  676: 
  677:                     liberation(s_etat_processus, s_objet_argument_3);
  678:                     liberation(s_etat_processus, s_objet_argument_2);
  679:                     liberation(s_etat_processus, s_objet_argument_1);
  680: 
  681:                     return;
  682:                 }
  683: 
  684:                 free(chaine);
  685: 
  686:                 if (alsprintf(&commande, "insert or replace into data "
  687:                         "(id, data) values (%lld, '%s')", (*((integer8 *)
  688:                         (*s_objet_argument_2).objet)), chaine_utf8) < 0)
  689:                 {
  690:                     (*s_etat_processus).erreur_systeme =
  691:                             d_es_allocation_memoire;
  692:                     return;
  693:                 }
  694: 
  695:                 free(chaine_utf8);
  696: 
  697:                 if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
  698:                         commande, strlen(commande), &ppStmt, &queue)
  699:                         != SQLITE_OK)
  700:                 {
  701:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  702:                     return;
  703:                 }
  704: 
  705:                 if (sqlite3_step(ppStmt) != SQLITE_DONE)
  706:                 {
  707:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  708:                     return;
  709:                 }
  710: 
  711:                 if (sqlite3_finalize(ppStmt) != SQLITE_OK)
  712:                 {
  713:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  714:                     return;
  715:                 }
  716: 
  717:                 liberation(s_etat_processus, s_objet_argument_3);
  718:                 free(commande);
  719:             }
  720:             else // Fichiers indexés
  721:             {
  722:                 BUG(((*descripteur).type != 'S'), uprintf("Bad filetype !\n"));
  723: 
  724:                 if ((*s_objet_argument_2).type != LST)
  725:                 {
  726:                     liberation(s_etat_processus, s_objet_argument_2);
  727:                     liberation(s_etat_processus, s_objet_argument_1);
  728: 
  729:                     (*s_etat_processus).erreur_execution =
  730:                             d_ex_erreur_type_argument;
  731:                     return;
  732:                 }
  733: 
  734:                 // Récupération de la position de la clef
  735: 
  736:                 if (alsprintf(&commande, "select key from control "
  737:                         "where id = 1") < 0)
  738:                 {
  739:                     (*s_etat_processus).erreur_systeme =
  740:                             d_es_allocation_memoire;
  741:                     return;
  742:                 }
  743: 
  744:                 if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
  745:                         commande, strlen(commande), &ppStmt, &queue)
  746:                         != SQLITE_OK)
  747:                 {
  748:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  749:                     return;
  750:                 }
  751: 
  752:                 if (sqlite3_step(ppStmt) != SQLITE_ROW)
  753:                 {
  754:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  755:                     return;
  756:                 }
  757: 
  758:                 if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER)
  759:                 {
  760:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  761:                     return;
  762:                 }
  763: 
  764:                 clef = sqlite3_column_int64(ppStmt, 0);
  765: 
  766:                 if (sqlite3_step(ppStmt) != SQLITE_DONE)
  767:                 {
  768:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  769:                     return;
  770:                 }
  771: 
  772:                 if (sqlite3_finalize(ppStmt) != SQLITE_OK)
  773:                 {
  774:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  775:                     return;
  776:                 }
  777: 
  778:                 free(commande);
  779: 
  780:                 l_element_courant = (struct_liste_chainee *)
  781:                         (*s_objet_argument_2).objet;
  782:                 l_element_courant_format = (struct_liste_chainee *)
  783:                         (*(*((struct_fichier *) (*s_objet_argument_1).objet))
  784:                         .format).objet;
  785:                 compteur = 1;
  786: 
  787:                 while((l_element_courant != NULL) &&
  788:                         (l_element_courant_format != NULL))
  789:                 {
  790:                     if (compteur == clef)
  791:                     {
  792:                         break;
  793:                     }
  794: 
  795:                     l_element_courant = (*l_element_courant).suivant;
  796:                     l_element_courant_format = (*l_element_courant_format)
  797:                             .suivant;
  798:                     compteur++;
  799:                 }
  800: 
  801:                 if ((l_element_courant == NULL) ||
  802:                         (l_element_courant_format == NULL))
  803:                 {
  804:                     (*s_etat_processus).erreur_execution =
  805:                             d_ex_clef_inexistante;
  806:                         
  807:                     liberation(s_etat_processus, s_objet_argument_2);
  808:                     liberation(s_etat_processus, s_objet_argument_1);
  809: 
  810:                     return;
  811:                 }
  812: 
  813:                 if ((s_element = allocation(s_etat_processus, LST)) == NULL)
  814:                 {
  815:                     (*s_etat_processus).erreur_systeme =
  816:                             d_es_allocation_memoire;
  817:                     return;
  818:                 }
  819: 
  820:                 if (((*s_element).objet = allocation_maillon(s_etat_processus))
  821:                         == NULL)
  822:                 {
  823:                     (*s_etat_processus).erreur_systeme =
  824:                             d_es_allocation_memoire;
  825:                     return;
  826:                 }
  827: 
  828:                 (*((struct_liste_chainee *) (*s_element).objet)).suivant = NULL;
  829: 
  830:                 if (((*((struct_liste_chainee *) (*s_element).objet))
  831:                         .donnee = copie_objet(s_etat_processus,
  832:                         (*l_element_courant).donnee, 'N')) == NULL)
  833:                 {
  834:                     (*s_etat_processus).erreur_systeme =
  835:                             d_es_allocation_memoire;
  836:                     return;
  837:                 }
  838: 
  839:                 if ((s_format = allocation(s_etat_processus, LST)) == NULL)
  840:                 {
  841:                     (*s_etat_processus).erreur_systeme =
  842:                             d_es_allocation_memoire;
  843:                     return;
  844:                 }
  845: 
  846:                 if (((*s_format).objet = allocation_maillon(s_etat_processus))
  847:                         == NULL)
  848:                 {
  849:                     (*s_etat_processus).erreur_systeme =
  850:                             d_es_allocation_memoire;
  851:                     return;
  852:                 }
  853: 
  854:                 (*((struct_liste_chainee *) (*s_format).objet)).suivant = NULL;
  855: 
  856:                 if (((*((struct_liste_chainee *) (*s_format).objet))
  857:                         .donnee = copie_objet(s_etat_processus,
  858:                         (*l_element_courant_format).donnee, 'N')) == NULL)
  859:                 {
  860:                     (*s_etat_processus).erreur_systeme =
  861:                             d_es_allocation_memoire;
  862:                     return;
  863:                 }
  864: 
  865:                 if ((chaine = formateur_fichier(s_etat_processus,
  866:                         s_element, s_format, 0, 0, ' ',
  867:                         'F', &longueur_effective, &recursivite)) == NULL)
  868:                 {
  869:                     liberation(s_etat_processus, s_element);
  870:                     liberation(s_etat_processus, s_format);
  871:                     liberation(s_etat_processus, s_objet_argument_2);
  872:                     liberation(s_etat_processus, s_objet_argument_1);
  873: 
  874:                     return;
  875:                 }
  876: 
  877:                 liberation(s_etat_processus, s_element);
  878:                 liberation(s_etat_processus, s_format);
  879: 
  880:                 if ((clef_utf8 = transliteration(s_etat_processus,
  881:                         chaine, d_locale, "UTF-8")) == NULL)
  882:                 {
  883:                     liberation(s_etat_processus, s_objet_argument_2);
  884:                     liberation(s_etat_processus, s_objet_argument_1);
  885: 
  886:                     return;
  887:                 }
  888: 
  889:                 free(chaine);
  890: 
  891:                 // Récupération de l'identifiant de la clef
  892: 
  893:                 if (alsprintf(&commande, "select id from key where key = "
  894:                         "'%s'", clef_utf8) < 0)
  895:                 {
  896:                     (*s_etat_processus).erreur_systeme =
  897:                             d_es_allocation_memoire;
  898:                     return;
  899:                 }
  900: 
  901:                 if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
  902:                         commande, strlen(commande), &ppStmt, &queue)
  903:                         != SQLITE_OK)
  904:                 {
  905:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  906:                     return;
  907:                 }
  908: 
  909:                 switch(sqlite3_step(ppStmt))
  910:                 {
  911:                     case SQLITE_ROW:
  912:                     {
  913:                         // Une clef existe.
  914: 
  915:                         mise_a_jour = d_vrai;
  916:                         break;
  917:                     }
  918: 
  919:                     case SQLITE_DONE:
  920:                     {
  921:                         // Aucune clef n'existe.
  922: 
  923:                         mise_a_jour = d_faux;
  924: 
  925:                         if (sqlite3_finalize(ppStmt) != SQLITE_OK)
  926:                         {
  927:                             (*s_etat_processus).erreur_systeme =
  928:                                     d_es_erreur_fichier;
  929:                             return;
  930:                         }
  931: 
  932:                         free(commande);
  933: 
  934:                         if (alsprintf(&commande, "insert into key "
  935:                                 "(key) values ('%s')", clef_utf8) < 0)
  936:                         {
  937:                             (*s_etat_processus).erreur_systeme =
  938:                                     d_es_allocation_memoire;
  939:                             return;
  940:                         }
  941: 
  942:                         if (sqlite3_prepare_v2((*descripteur)
  943:                                 .descripteur_sqlite,
  944:                                 commande, strlen(commande), &ppStmt, &queue)
  945:                                 != SQLITE_OK)
  946:                         {
  947:                             (*s_etat_processus).erreur_systeme =
  948:                                     d_es_erreur_fichier;
  949:                             return;
  950:                         }
  951: 
  952:                         if (sqlite3_step(ppStmt) != SQLITE_DONE)
  953:                         {
  954:                             (*s_etat_processus).erreur_systeme =
  955:                                     d_es_erreur_fichier;
  956:                             return;
  957:                         }
  958: 
  959:                         if (sqlite3_finalize(ppStmt) != SQLITE_OK)
  960:                         {
  961:                             (*s_etat_processus).erreur_systeme =
  962:                                     d_es_erreur_fichier;
  963:                             return;
  964:                         }
  965: 
  966:                         free(commande);
  967: 
  968:                         if (alsprintf(&commande, "select id from key "
  969:                                 "where key = '%s'", clef_utf8) < 0)
  970:                         {
  971:                             (*s_etat_processus).erreur_systeme =
  972:                                     d_es_allocation_memoire;
  973:                             return;
  974:                         }
  975: 
  976:                         if (sqlite3_prepare_v2((*descripteur)
  977:                                 .descripteur_sqlite,
  978:                                 commande, strlen(commande), &ppStmt, &queue)
  979:                                 != SQLITE_OK)
  980:                         {
  981:                             (*s_etat_processus).erreur_systeme =
  982:                                     d_es_erreur_fichier;
  983:                             return;
  984:                         }
  985: 
  986:                         if (sqlite3_step(ppStmt) != SQLITE_ROW)
  987:                         {
  988:                             (*s_etat_processus).erreur_systeme =
  989:                                     d_es_erreur_fichier;
  990:                             return;
  991:                         }
  992: 
  993:                         break;
  994:                     }
  995: 
  996:                     default:
  997:                     {
  998:                         (*s_etat_processus).erreur_systeme =
  999:                                 d_es_erreur_fichier;
 1000:                         return;
 1001:                     }
 1002:                 }
 1003: 
 1004:                 if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER)
 1005:                 {
 1006:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1007:                     return;
 1008:                 }
 1009: 
 1010:                 id = sqlite3_column_int64(ppStmt, 0);
 1011: 
 1012:                 if (sqlite3_step(ppStmt) != SQLITE_DONE)
 1013:                 {
 1014:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1015:                     return;
 1016:                 }
 1017: 
 1018:                 if (sqlite3_finalize(ppStmt) != SQLITE_OK)
 1019:                 {
 1020:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1021:                     return;
 1022:                 }
 1023: 
 1024:                 free(commande);
 1025: 
 1026:                 // Modification de la clef
 1027: 
 1028:                 if (mise_a_jour == d_vrai)
 1029:                 {
 1030:                     if (alsprintf(&commande, "update key set key = '%s' where "
 1031:                             "id = %lld", clef_utf8, id) < 0)
 1032:                     {
 1033:                         (*s_etat_processus).erreur_systeme =
 1034:                                 d_es_allocation_memoire;
 1035:                         return;
 1036:                     }
 1037: 
 1038:                     if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
 1039:                             commande, strlen(commande), &ppStmt, &queue)
 1040:                             != SQLITE_OK)
 1041:                     {
 1042:                         (*s_etat_processus).erreur_systeme =
 1043:                                 d_es_erreur_fichier;
 1044:                         return;
 1045:                     }
 1046: 
 1047:                     if (sqlite3_step(ppStmt) != SQLITE_DONE)
 1048:                     {
 1049:                         (*s_etat_processus).erreur_systeme =
 1050:                                 d_es_erreur_fichier;
 1051:                         return;
 1052:                     }
 1053: 
 1054:                     if (sqlite3_finalize(ppStmt) != SQLITE_OK)
 1055:                     {
 1056:                         (*s_etat_processus).erreur_systeme =
 1057:                                 d_es_erreur_fichier;
 1058:                         return;
 1059:                     }
 1060: 
 1061:                     free(commande);
 1062:                 }
 1063: 
 1064:                 // Effacement de l'enregistrement existant
 1065: 
 1066:                 if (alsprintf(&commande, "delete from data where "
 1067:                         "key_id = %lld", id) < 0)
 1068:                 {
 1069:                     (*s_etat_processus).erreur_systeme =
 1070:                             d_es_allocation_memoire;
 1071:                     return;
 1072:                 }
 1073: 
 1074:                 if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
 1075:                         commande, strlen(commande), &ppStmt, &queue)
 1076:                         != SQLITE_OK)
 1077:                 {
 1078:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1079:                     return;
 1080:                 }
 1081: 
 1082:                 if (sqlite3_step(ppStmt) != SQLITE_DONE)
 1083:                 {
 1084:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1085:                     return;
 1086:                 }
 1087: 
 1088:                 if (sqlite3_finalize(ppStmt) != SQLITE_OK)
 1089:                 {
 1090:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1091:                     return;
 1092:                 }
 1093: 
 1094:                 free(commande);
 1095: 
 1096:                 // Modification ou création d'un nouvel enregistrement
 1097: 
 1098:                 l_element_courant = (struct_liste_chainee *)
 1099:                         (*s_objet_argument_2).objet;
 1100:                 l_element_courant_format = (struct_liste_chainee *)
 1101:                         (*(*((struct_fichier *) (*s_objet_argument_1).objet))
 1102:                         .format).objet;
 1103:                 compteur = 1;
 1104:                 ordre = 1;
 1105: 
 1106:                 while((l_element_courant != NULL) &&
 1107:                         (l_element_courant_format != NULL))
 1108:                 {
 1109:                     if (compteur == clef)
 1110:                     {
 1111:                         l_element_courant = (*l_element_courant).suivant;
 1112:                         l_element_courant_format = (*l_element_courant_format)
 1113:                                 .suivant;
 1114:                         compteur++;
 1115:                         continue;
 1116:                     }
 1117: 
 1118:                     if ((s_element = allocation(s_etat_processus, LST)) == NULL)
 1119:                     {
 1120:                         (*s_etat_processus).erreur_systeme =
 1121:                                 d_es_allocation_memoire;
 1122:                         return;
 1123:                     }
 1124: 
 1125:                     if (((*s_element).objet =
 1126:                             allocation_maillon(s_etat_processus)) == NULL)
 1127:                     {
 1128:                         (*s_etat_processus).erreur_systeme =
 1129:                                 d_es_allocation_memoire;
 1130:                         return;
 1131:                     }
 1132: 
 1133:                     (*((struct_liste_chainee *) (*s_element).objet)).suivant
 1134:                             = NULL;
 1135: 
 1136:                     if ((s_format = allocation(s_etat_processus, LST)) == NULL)
 1137:                     {
 1138:                         (*s_etat_processus).erreur_systeme =
 1139:                                 d_es_allocation_memoire;
 1140:                         return;
 1141:                     }
 1142: 
 1143:                     if (((*s_format).objet =
 1144:                             allocation_maillon(s_etat_processus)) == NULL)
 1145:                     {
 1146:                         (*s_etat_processus).erreur_systeme =
 1147:                                 d_es_allocation_memoire;
 1148:                         return;
 1149:                     }
 1150: 
 1151:                     (*((struct_liste_chainee *) (*s_format).objet)).suivant
 1152:                             = NULL;
 1153: 
 1154:                     if (((*((struct_liste_chainee *) (*s_element).objet))
 1155:                             .donnee = copie_objet(s_etat_processus,
 1156:                             (*l_element_courant).donnee, 'N')) == NULL)
 1157:                     {
 1158:                         (*s_etat_processus).erreur_systeme =
 1159:                                 d_es_allocation_memoire;
 1160:                         return;
 1161:                     }
 1162: 
 1163:                     if (((*((struct_liste_chainee *) (*s_format).objet))
 1164:                             .donnee = copie_objet(s_etat_processus,
 1165:                             (*l_element_courant_format).donnee, 'N')) == NULL)
 1166:                     {
 1167:                         (*s_etat_processus).erreur_systeme =
 1168:                                 d_es_allocation_memoire;
 1169:                         return;
 1170:                     }
 1171: 
 1172:                     if ((chaine = formateur_fichier(s_etat_processus,
 1173:                             s_element, s_format, 0, 0, ' ',
 1174:                             'F', &longueur_effective, &recursivite)) == NULL)
 1175:                     {
 1176:                         free(clef_utf8);
 1177: 
 1178:                         liberation(s_etat_processus, s_element);
 1179:                         liberation(s_etat_processus, s_format);
 1180:                         liberation(s_etat_processus, s_objet_argument_2);
 1181:                         liberation(s_etat_processus, s_objet_argument_1);
 1182: 
 1183:                         return;
 1184:                     }
 1185: 
 1186:                     if ((chaine_utf8 = transliteration(s_etat_processus,
 1187:                             chaine, d_locale, "UTF-8")) == NULL)
 1188:                     {
 1189:                         free(clef_utf8);
 1190:                         free(chaine);
 1191: 
 1192:                         liberation(s_etat_processus, s_objet_argument_2);
 1193:                         liberation(s_etat_processus, s_objet_argument_1);
 1194: 
 1195:                         return;
 1196:                     }
 1197: 
 1198:                     free(chaine);
 1199: 
 1200:                     if (alsprintf(&commande, "insert into data "
 1201:                             "(data, key_id, sequence) values "
 1202:                             "('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0)
 1203:                     {
 1204:                         (*s_etat_processus).erreur_systeme =
 1205:                                 d_es_allocation_memoire;
 1206:                         return;
 1207:                     }
 1208: 
 1209:                     if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
 1210:                             commande, strlen(commande), &ppStmt, &queue)
 1211:                             != SQLITE_OK)
 1212:                     {
 1213:                         (*s_etat_processus).erreur_systeme =
 1214:                                 d_es_erreur_fichier;
 1215:                         return;
 1216:                     }
 1217: 
 1218:                     if (sqlite3_step(ppStmt) != SQLITE_DONE)
 1219:                     {
 1220:                         (*s_etat_processus).erreur_systeme =
 1221:                                 d_es_erreur_fichier;
 1222:                         return;
 1223:                     }
 1224: 
 1225:                     if (sqlite3_finalize(ppStmt) != SQLITE_OK)
 1226:                     {
 1227:                         (*s_etat_processus).erreur_systeme =
 1228:                                 d_es_erreur_fichier;
 1229:                         return;
 1230:                     }
 1231: 
 1232:                     free(commande);
 1233:                     free(chaine_utf8);
 1234: 
 1235:                     liberation(s_etat_processus, s_element);
 1236:                     liberation(s_etat_processus, s_format);
 1237: 
 1238:                     l_element_courant = (*l_element_courant).suivant;
 1239:                     l_element_courant_format = (*l_element_courant_format)
 1240:                             .suivant;
 1241: 
 1242:                     compteur++;
 1243:                     ordre++;
 1244:                 }
 1245: 
 1246:                 free(clef_utf8);
 1247: 
 1248:                 if ((l_element_courant != NULL) ||
 1249:                         (l_element_courant_format != NULL))
 1250:                 {
 1251:                     liberation(s_etat_processus, s_objet_argument_1);
 1252:                     liberation(s_etat_processus, s_objet_argument_2);
 1253: 
 1254:                     (*s_etat_processus).erreur_execution =
 1255:                             d_ex_erreur_format_fichier;
 1256:                     return;
 1257:                 }
 1258:             }
 1259:         }
 1260:         else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire
 1261:                 == 'Y')
 1262:         {
 1263:             /*
 1264:              * Fichiers non formatés
 1265:              */
 1266: 
 1267:             if ((chaine = formateur_fichier(s_etat_processus,
 1268:                     s_objet_argument_2, (*((struct_fichier *)
 1269:                     (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U',
 1270:                     &longueur_effective, &recursivite)) == NULL)
 1271:             {
 1272:                 liberation(s_etat_processus, s_objet_argument_2);
 1273:                 liberation(s_etat_processus, s_objet_argument_1);
 1274: 
 1275:                 return;
 1276:             }
 1277: 
 1278:             if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
 1279:                     == 'S')
 1280:             {
 1281:                 BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
 1282: 
 1283:                 if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END)
 1284:                         != 0)
 1285:                 {
 1286:                     liberation(s_etat_processus, s_objet_argument_2);
 1287:                     liberation(s_etat_processus, s_objet_argument_1);
 1288: 
 1289:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1290:                     return;
 1291:                 }
 1292: 
 1293:                 if (fwrite(chaine, sizeof(unsigned char), longueur_effective,
 1294:                         (*descripteur).descripteur_c) !=
 1295:                         (size_t) longueur_effective)
 1296:                 {
 1297:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1298:                     return;
 1299:                 }
 1300:             }
 1301:             else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
 1302:                     == 'D')
 1303:             {
 1304:             }
 1305:             else
 1306:             {
 1307:                 /* Fichiers indexés : panique totale ! */
 1308:             }
 1309: 
 1310:             free(chaine);
 1311:         }
 1312:         else
 1313:         {
 1314:             /*
 1315:              * Fichiers de type FLOW
 1316:              */
 1317: 
 1318:             if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
 1319:                     == 'S')
 1320:             {
 1321:                 BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
 1322: 
 1323:                 if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet))
 1324:                         .donnee)).type != CHN)
 1325:                 {
 1326:                     liberation(s_etat_processus, s_objet_argument_2);
 1327:                     liberation(s_etat_processus, s_objet_argument_1);
 1328: 
 1329:                     (*s_etat_processus).erreur_execution =
 1330:                             d_ex_erreur_type_argument;
 1331:                     return;
 1332:                 }
 1333: 
 1334:                 if ((chaine = formateur_flux(s_etat_processus, (unsigned char *)
 1335:                         (*((*((struct_liste_chainee *) (*s_objet_argument_2)
 1336:                         .objet)).donnee)).objet, &longueur_effective)) == NULL)
 1337:                 {
 1338:                     (*s_etat_processus).erreur_systeme =
 1339:                             d_es_allocation_memoire;
 1340:                     return;
 1341:                 }
 1342: 
 1343:                 if (fwrite(chaine, sizeof(unsigned char), longueur_effective,
 1344:                         (*descripteur).descripteur_c) !=
 1345:                         (size_t) longueur_effective)
 1346:                 {
 1347:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1348:                     return;
 1349:                 }
 1350: 
 1351:                 free(chaine);
 1352:             }
 1353:             else
 1354:             {
 1355:                 liberation(s_etat_processus, s_objet_argument_1);
 1356:                 liberation(s_etat_processus, s_objet_argument_2);
 1357: 
 1358:                 (*s_etat_processus).erreur_execution =
 1359:                         d_ex_erreur_type_fichier;
 1360:                 return;
 1361:             }
 1362:         }
 1363:     }
 1364:     else if (((*s_objet_argument_2).type == LST) &&
 1365:             ((*s_objet_argument_1).type == SCK))
 1366:     {
 1367:         /*
 1368:          * Vérification de l'autorisation d'écriture
 1369:          */
 1370: 
 1371:         if ((*((struct_socket *) (*s_objet_argument_1).objet))
 1372:                 .protection == 'R')
 1373:         {
 1374:             liberation(s_etat_processus, s_objet_argument_2);
 1375:             liberation(s_etat_processus, s_objet_argument_1);
 1376: 
 1377:             (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
 1378:             return;
 1379:         }
 1380: 
 1381:         if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire == 'N')
 1382:         {
 1383:             /*
 1384:              * Sockets formatées
 1385:              */
 1386: 
 1387:             if ((chaine = formateur_fichier(s_etat_processus,
 1388:                     s_objet_argument_2, (*((struct_socket *)
 1389:                     (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
 1390:                     &longueur_effective, &recursivite)) == NULL)
 1391:             {
 1392:                 liberation(s_etat_processus, s_objet_argument_2);
 1393:                 liberation(s_etat_processus, s_objet_argument_1);
 1394: 
 1395:                 return;
 1396:             }
 1397:         }
 1398:         else if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire
 1399:                 == 'Y')
 1400:         {
 1401:             /*
 1402:              * Sockets non formatées
 1403:              */
 1404: 
 1405:             chaine = NULL;
 1406:         }
 1407:         else
 1408:         {
 1409:             /*
 1410:              *  Sockets de type FLOW
 1411:              */
 1412: 
 1413:             if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet))
 1414:                     .donnee)).type != CHN)
 1415:             {
 1416:                 liberation(s_etat_processus, s_objet_argument_2);
 1417:                 liberation(s_etat_processus, s_objet_argument_1);
 1418: 
 1419:                 (*s_etat_processus).erreur_execution =
 1420:                         d_ex_erreur_type_argument;
 1421:                 return;
 1422:             }
 1423: 
 1424:             if ((chaine = formateur_flux(s_etat_processus, (unsigned char *)
 1425:                     (*((*((struct_liste_chainee *) (*s_objet_argument_2)
 1426:                     .objet)).donnee)).objet, &longueur_effective)) == NULL)
 1427:             {
 1428:                 liberation(s_etat_processus, s_objet_argument_2);
 1429:                 liberation(s_etat_processus, s_objet_argument_1);
 1430: 
 1431:                 return;
 1432:             }
 1433:         }
 1434: 
 1435:         if ((strcmp((*((struct_socket *) (*s_objet_argument_1).objet)).type,
 1436:                 "STREAM") == 0) || (strcmp((*((struct_socket *)
 1437:                 (*s_objet_argument_1).objet)).type,
 1438:                 "SEQUENTIAL DATAGRAM") == 0))
 1439:         { // Sockets connectées
 1440: 
 1441:             action.sa_handler = SIG_IGN;
 1442:             action.sa_flags = SA_ONSTACK;
 1443: 
 1444:             if (sigaction(SIGPIPE, &action, &registre) != 0)
 1445:             {
 1446:                 (*s_etat_processus).erreur_systeme = d_es_signal;
 1447:                 return;
 1448:             }
 1449: 
 1450:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1451:             {
 1452:                 if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1453:                 {
 1454:                     (*s_etat_processus).erreur_systeme = d_es_signal;
 1455:                     return;
 1456:                 }
 1457: 
 1458:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1459:                 return;
 1460:             }
 1461: 
 1462:             if (send((*((struct_socket *) (*s_objet_argument_1).objet))
 1463:                     .socket, chaine, longueur_effective, 0) < 0)
 1464:             {
 1465:                 ios = errno;
 1466: 
 1467:                 if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1468:                 {
 1469:                     (*s_etat_processus).erreur_systeme = d_es_signal;
 1470:                     return;
 1471:                 }
 1472: 
 1473:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1474:                 {
 1475:                     if (errno != EINTR)
 1476:                     {
 1477:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1478:                         return;
 1479:                     }
 1480:                 }
 1481: 
 1482:                 if ((ios == EPIPE) || (ios == ECONNRESET))
 1483:                 {
 1484:                     (*s_etat_processus).erreur_execution =
 1485:                             d_ex_erreur_acces_fichier;
 1486:                     return;
 1487:                 }
 1488: 
 1489:                 (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1490:                 return;
 1491:             }
 1492: 
 1493:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1494:             {
 1495:                 if (errno != EINTR)
 1496:                 {
 1497:                     if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1498:                     {
 1499:                         (*s_etat_processus).erreur_systeme = d_es_signal;
 1500:                         return;
 1501:                     }
 1502: 
 1503:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1504:                     return;
 1505:                 }
 1506:             }
 1507: 
 1508:             if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1509:             {
 1510:                 (*s_etat_processus).erreur_systeme = d_es_signal;
 1511:                 return;
 1512:             }
 1513:         }
 1514:         else
 1515:         { // Sockets non connectées
 1516: 
 1517:             /*
 1518:              * Vérification de l'adresse distante
 1519:              */
 1520: 
 1521:             if (strcmp((*((struct_socket *) (*s_objet_argument_1).objet))
 1522:                     .adresse_distante, "") == 0)
 1523:             {
 1524:                 liberation(s_etat_processus, s_objet_argument_1);
 1525:                 liberation(s_etat_processus, s_objet_argument_2);
 1526: 
 1527:                 (*s_etat_processus).erreur_execution =
 1528:                         d_ex_erreur_acces_fichier;
 1529:                 return;
 1530:             }
 1531: 
 1532:             /*
 1533:              * Création de l'adresse logique
 1534:              */
 1535: 
 1536:             if ((*((struct_socket *) (*s_objet_argument_1).objet))
 1537:                     .domaine == PF_UNIX)
 1538:             {
 1539:                 adresse_unix.sun_family = AF_UNIX;
 1540:                 strncpy(adresse_unix.sun_path, (*((struct_socket *)
 1541:                         (*s_objet_argument_1).objet)).adresse_distante,
 1542:                         UNIX_PATH_MAX);
 1543:                 adresse_unix.sun_path[UNIX_PATH_MAX - 1] =
 1544:                         d_code_fin_chaine;
 1545: 
 1546:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1547:                 {
 1548:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1549:                     return;
 1550:                 }
 1551: 
 1552:                 if (sendto((*((struct_socket *)
 1553:                         (*s_objet_argument_1).objet)).socket, chaine,
 1554:                         longueur_effective, 0, (struct sockaddr *)
 1555:                         &adresse_unix, sizeof(adresse_unix)) < 0)
 1556:                 {
 1557:                     ios = errno;
 1558: 
 1559:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1560:                     {
 1561:                         if (errno != EINTR)
 1562:                         {
 1563:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 1564:                             return;
 1565:                         }
 1566:                     }
 1567: 
 1568:                     if ((ios == EPIPE) || (ios == ECONNRESET))
 1569:                     {
 1570:                         (*s_etat_processus).erreur_execution =
 1571:                                 d_ex_erreur_acces_fichier;
 1572:                         return;
 1573:                     }
 1574: 
 1575: 
 1576:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
 1577:                     return;
 1578:                 }
 1579: 
 1580:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1581:                 {
 1582:                     if (errno != EINTR)
 1583:                     {
 1584:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1585:                         return;
 1586:                     }
 1587:                 }
 1588:             }
 1589:             else if ((*((struct_socket *) (*s_objet_argument_1).objet))
 1590:                     .domaine == PF_INET)
 1591:             {
 1592:                 if (sscanf((*((struct_socket *)
 1593:                         (*s_objet_argument_1).objet))
 1594:                         .adresse_distante, "%d.%d.%d.%d(%d)",
 1595:                         &(adresse[0]), &(adresse[1]), &(adresse[2]),
 1596:                         &(adresse[3]), &port) == 5)
 1597:                 { // Adresse IPv4
 1598:                     calcul_adresse = 0;
 1599:                     for(i = 0; i < 4; calcul_adresse =
 1600:                             (256 * calcul_adresse) + adresse[i++]);
 1601: 
 1602:                     memset(&adresse_ipv4, 0, sizeof(adresse_ipv4));
 1603:                     adresse_ipv4.sin_family = AF_INET;
 1604:                     adresse_ipv4.sin_port = htons(port);
 1605:                     adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse);
 1606: 
 1607:                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1608:                     {
 1609:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1610:                         return;
 1611:                     }
 1612: 
 1613:                     if (sendto((*((struct_socket *)
 1614:                             (*s_objet_argument_1).objet)).socket, chaine,
 1615:                             longueur_effective, 0, (struct sockaddr *)
 1616:                             &adresse_ipv4, sizeof(adresse_ipv4)) < 0)
 1617:                     {
 1618:                         while(sem_wait(&((*s_etat_processus)
 1619:                                 .semaphore_fork)) != 0)
 1620:                         {
 1621:                             if (errno != EINTR)
 1622:                             {
 1623:                                 (*s_etat_processus).erreur_systeme =
 1624:                                         d_es_processus;
 1625:                                 return;
 1626:                             }
 1627:                         }
 1628: 
 1629:                         (*s_etat_processus).erreur_systeme =
 1630:                                 d_es_erreur_fichier;
 1631:                         return;
 1632:                     }
 1633: 
 1634:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1635:                     {
 1636:                         if (errno != EINTR)
 1637:                         {
 1638:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 1639:                             return;
 1640:                         }
 1641:                     }
 1642:                 }
 1643:                 else
 1644:                 {
 1645:                     liberation(s_etat_processus, s_objet_argument_1);
 1646:                     liberation(s_etat_processus, s_objet_argument_2);
 1647: 
 1648:                     (*s_etat_processus).erreur_execution =
 1649:                             d_ex_erreur_parametre_fichier;
 1650:                     return;
 1651:                 }
 1652:             }
 1653:             else if ((*((struct_socket *) (*s_objet_argument_1).objet))
 1654:                     .domaine == PF_INET6)
 1655:             {
 1656:                 if (sscanf((*((struct_socket *) (*s_objet_argument_1)
 1657:                         .objet)).adresse_distante, "%X:%X:%X:%X:%X:"
 1658:                         "%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X(%d)",
 1659:                         &(adresse[0]), &(adresse[1]), &(adresse[2]),
 1660:                         &(adresse[3]), &(adresse[4]), &(adresse[5]),
 1661:                         &(adresse[6]), &(adresse[7]), &(adresse[8]),
 1662:                         &(adresse[9]), &(adresse[10]), &(adresse[11]),
 1663:                         &(adresse[12]), &(adresse[13]), &(adresse[14]),
 1664:                         &(adresse[15]), &port)== 17)
 1665:                 { // Adresse IPv6
 1666: #                   ifdef IPV6
 1667:                     memset(&adresse_ipv6, 0, sizeof(adresse_ipv6));
 1668:                     adresse_ipv6.sin6_family = AF_INET6;
 1669:                     adresse_ipv6.sin6_port = htons((uint16_t) port);
 1670: 
 1671:                     for(i = 0; i < 16;
 1672:                             adresse_ipv6.sin6_addr.s6_addr[i] =
 1673:                             adresse[i], i++);
 1674: 
 1675:                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1676:                     {
 1677:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1678:                         return;
 1679:                     }
 1680: 
 1681:                     if (sendto((*((struct_socket *)
 1682:                             (*s_objet_argument_1).objet)).socket, chaine,
 1683:                             longueur_effective, 0, (struct sockaddr *)
 1684:                             &adresse_ipv6, sizeof(adresse_ipv6)) < 0)
 1685:                     {
 1686:                         while(sem_wait(&((*s_etat_processus)
 1687:                                 .semaphore_fork)) != 0)
 1688:                         {
 1689:                             if (errno != EINTR)
 1690:                             {
 1691:                                 (*s_etat_processus).erreur_systeme =
 1692:                                         d_es_processus;
 1693:                                 return;
 1694:                             }
 1695:                         }
 1696: 
 1697:                         (*s_etat_processus).erreur_systeme =
 1698:                                 d_es_erreur_fichier;
 1699:                         return;
 1700:                     }
 1701: 
 1702:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1703:                     {
 1704:                         if (errno != EINTR)
 1705:                         {
 1706:                             (*s_etat_processus).erreur_systeme =
 1707:                                     d_es_processus;
 1708:                             return;
 1709:                         }
 1710:                     }
 1711: #                   else
 1712:                     if ((*s_etat_processus).langue == 'F')
 1713:                     {
 1714:                         printf("+++Attention : Support du protocole"
 1715:                                 " IPv6 indisponible\n");
 1716:                     }
 1717:                     else
 1718:                     {
 1719:                         printf("+++Warning : IPv6 support "
 1720:                                 "unavailable\n");
 1721:                     }
 1722: #                   endif
 1723:                 }
 1724:                 else
 1725:                 {
 1726:                     liberation(s_etat_processus, s_objet_argument_1);
 1727:                     liberation(s_etat_processus, s_objet_argument_2);
 1728: 
 1729:                     (*s_etat_processus).erreur_execution =
 1730:                             d_ex_erreur_parametre_fichier;
 1731:                     return;
 1732:                 }
 1733:             }
 1734:             else 
 1735:             {
 1736:                 liberation(s_etat_processus, s_objet_argument_1);
 1737:                 liberation(s_etat_processus, s_objet_argument_2);
 1738: 
 1739:                 (*s_etat_processus).erreur_execution =
 1740:                         d_ex_erreur_parametre_fichier;
 1741:                 return;
 1742:             }
 1743:         }
 1744: 
 1745:         free(chaine);
 1746:     }
 1747:     else
 1748:     {
 1749:         liberation(s_etat_processus, s_objet_argument_2);
 1750:         liberation(s_etat_processus, s_objet_argument_1);
 1751: 
 1752:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1753:         return;
 1754:     }
 1755: 
 1756:     liberation(s_etat_processus, s_objet_argument_2);
 1757:     liberation(s_etat_processus, s_objet_argument_1);
 1758: 
 1759:     return;
 1760: }
 1761: 
 1762: 
 1763: /*
 1764: ================================================================================
 1765:   Fonction 'wflock'
 1766: ================================================================================
 1767:   Entrées : pointeur sur une structure struct_processus
 1768: --------------------------------------------------------------------------------
 1769:   Sorties :
 1770: --------------------------------------------------------------------------------
 1771:   Effets de bord : néant
 1772: ================================================================================
 1773: */
 1774: 
 1775: void
 1776: instruction_wflock(struct_processus *s_etat_processus)
 1777: {
 1778:     logical1                    drapeau;
 1779: 
 1780:     struct flock                lock;
 1781: 
 1782:     struct timespec             attente;
 1783: 
 1784:     struct_descripteur_fichier  *descripteur;
 1785: 
 1786:     struct_objet                *s_objet_argument_1;
 1787:     struct_objet                *s_objet_argument_2;
 1788: 
 1789:     unsigned char               *chaine;
 1790:     unsigned char               registre_instruction_valide;
 1791: 
 1792:     attente.tv_sec = 0;
 1793:     attente.tv_nsec = GRANULARITE_us * 1000;
 1794: 
 1795:     (*s_etat_processus).erreur_execution = d_ex;
 1796: 
 1797:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1798:     {
 1799:         printf("\n  WFLOCK ");
 1800:         
 1801:         if ((*s_etat_processus).langue == 'F')
 1802:         {
 1803:             printf("(attente du positionnement d'un verrou sur un fichier)"
 1804:                     "\n\n");
 1805:         }
 1806:         else
 1807:         {
 1808:             printf("(wait for file lock)\n\n");
 1809:         }
 1810: 
 1811:         printf("    2: %s\n", d_FCH);
 1812:         printf("    1: %s (READ/WRITE/NONE)\n", d_CHN);
 1813: 
 1814:         return;
 1815:     }
 1816:     else if ((*s_etat_processus).test_instruction == 'Y')
 1817:     {
 1818:         (*s_etat_processus).nombre_arguments = -1;
 1819:         return;
 1820:     }
 1821: 
 1822:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1823:     {
 1824:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
 1825:         {
 1826:             return;
 1827:         }
 1828:     }
 1829: 
 1830:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1831:             &s_objet_argument_1) == d_erreur)
 1832:     {
 1833:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1834:         return;
 1835:     }
 1836: 
 1837:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1838:             &s_objet_argument_2) == d_erreur)
 1839:     {
 1840:         liberation(s_etat_processus, s_objet_argument_1);
 1841: 
 1842:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1843:         return;
 1844:     }
 1845: 
 1846:     if (((*s_objet_argument_2).type == FCH) &&
 1847:             ((*s_objet_argument_1).type == CHN))
 1848:     {
 1849:         drapeau = d_faux;
 1850: 
 1851:         do
 1852:         {
 1853:             if ((chaine = conversion_majuscule((unsigned char *)
 1854:                     (*s_objet_argument_1).objet)) == NULL)
 1855:             {
 1856:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1857:                 return;
 1858:             }
 1859: 
 1860:             if (strcmp(chaine, "WRITE") == 0)
 1861:             {
 1862:                 lock.l_type = F_WRLCK;
 1863:             }
 1864:             else if (strcmp(chaine, "READ") == 0)
 1865:             {
 1866:                 lock.l_type = F_RDLCK;
 1867:             }
 1868:             else if (strcmp(chaine, "NONE") == 0)
 1869:             {
 1870:                 lock.l_type = F_UNLCK;
 1871:             }
 1872:             else
 1873:             {
 1874:                 free(chaine);
 1875: 
 1876:                 liberation(s_etat_processus, s_objet_argument_1);
 1877:                 liberation(s_etat_processus, s_objet_argument_2);
 1878: 
 1879:                 (*s_etat_processus).erreur_execution = d_ex_verrou_indefini;
 1880:                 return;
 1881:             }
 1882: 
 1883:             free(chaine);
 1884: 
 1885:             lock.l_whence = SEEK_SET;
 1886:             lock.l_start = 0;
 1887:             lock.l_len = 0;
 1888:             lock.l_pid = getpid();
 1889: 
 1890:             if ((descripteur = descripteur_fichier(s_etat_processus,
 1891:                     (struct_fichier *) (*s_objet_argument_2).objet)) == NULL)
 1892:             {
 1893:                 return;
 1894:             }
 1895: 
 1896:             if (fcntl(fileno((*descripteur).descripteur_c), F_GETLK, &lock)
 1897:                     == -1)
 1898:             {
 1899:                 liberation(s_etat_processus, s_objet_argument_1);
 1900:                 liberation(s_etat_processus, s_objet_argument_2);
 1901: 
 1902:                 (*s_etat_processus).erreur_execution = d_ex_fichier_verrouille;
 1903:                 return;
 1904:             }
 1905: 
 1906:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1907:             {
 1908:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1909:                 return;
 1910:             }
 1911: 
 1912:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 1913:             {
 1914:                 if (errno != EINTR)
 1915:                 {
 1916:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1917:                     return;
 1918:                 }
 1919:             }
 1920: 
 1921:             if (lock.l_type == F_UNLCK)
 1922:             {
 1923:                 drapeau = d_vrai;
 1924:             }
 1925:             else
 1926:             {
 1927:                 if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
 1928:                 {
 1929:                     affectation_interruptions_logicielles(s_etat_processus);
 1930:                 }
 1931: 
 1932:                 if ((*s_etat_processus).nombre_interruptions_en_queue
 1933:                         != 0)
 1934:                 {
 1935:                     registre_instruction_valide =
 1936:                             (*s_etat_processus).instruction_valide;
 1937:                     traitement_interruptions_logicielles(
 1938:                             s_etat_processus);
 1939:                     (*s_etat_processus).instruction_valide =
 1940:                             registre_instruction_valide;
 1941:                 }
 1942: 
 1943:                 nanosleep(&attente, NULL);
 1944:                 scrutation_injection(s_etat_processus);
 1945: 
 1946:                 INCR_GRANULARITE(attente.tv_nsec);
 1947:             }
 1948:         } while((drapeau == d_faux) && ((*s_etat_processus)
 1949:                 .var_volatile_requete_arret != -1));
 1950:     }
 1951:     else
 1952:     {
 1953:         liberation(s_etat_processus, s_objet_argument_1);
 1954:         liberation(s_etat_processus, s_objet_argument_2);
 1955: 
 1956:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1957:         return;
 1958:     }
 1959: 
 1960:     return;
 1961: }
 1962: 
 1963: 
 1964: /*
 1965: ================================================================================
 1966:   Fonction 'wfproc'
 1967: ================================================================================
 1968:   Entrées : pointeur sur une structure struct_processus
 1969: --------------------------------------------------------------------------------
 1970:   Sorties :
 1971: --------------------------------------------------------------------------------
 1972:   Effets de bord : néant
 1973: ================================================================================
 1974: */
 1975: 
 1976: void
 1977: instruction_wfproc(struct_processus *s_etat_processus)
 1978: {
 1979:     logical1                    drapeau_fin;
 1980: 
 1981:     struct_liste_chainee        *l_element_courant;
 1982: 
 1983:     struct_objet                *s_objet_argument;
 1984: 
 1985:     struct timespec             attente;
 1986: 
 1987:     unsigned char               registre_instruction_valide;
 1988: 
 1989:     (*s_etat_processus).erreur_execution = d_ex;
 1990: 
 1991:     attente.tv_sec = 0;
 1992:     attente.tv_nsec = GRANULARITE_us * 1000;
 1993: 
 1994:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1995:     {
 1996:         printf("\n  WFPROC ");
 1997: 
 1998:         if ((*s_etat_processus).langue == 'F')
 1999:         {
 2000:             printf("(attente de la fin d'un processus fils)\n\n");
 2001:         }
 2002:         else
 2003:         {
 2004:             printf("(wait for child process end)\n\n");
 2005:         }
 2006: 
 2007:         printf("    1: %s\n", d_PRC);
 2008: 
 2009:         return;
 2010:     }
 2011:     else if ((*s_etat_processus).test_instruction == 'Y')
 2012:     {
 2013:         (*s_etat_processus).nombre_arguments = -1;
 2014:         return;
 2015:     }
 2016: 
 2017:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2018:     {
 2019:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2020:         {
 2021:             return;
 2022:         }
 2023:     }
 2024: 
 2025:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2026:             &s_objet_argument) == d_erreur)
 2027:     {
 2028:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2029:         return;
 2030:     }
 2031: 
 2032:     if ((*s_objet_argument).type == PRC)
 2033:     {
 2034:         drapeau_fin = d_faux;
 2035: 
 2036:         if ((*s_etat_processus).profilage == d_vrai)
 2037:         {
 2038:             profilage(s_etat_processus, "Interprocess or interthread "
 2039:                     "communications (WFPROC)");
 2040: 
 2041:             if ((*s_etat_processus).erreur_systeme != d_es)
 2042:             {
 2043:                 return;
 2044:             }
 2045:         }
 2046: 
 2047:         if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
 2048:         {
 2049:             if ((*s_etat_processus).profilage == d_vrai)
 2050:             {
 2051:                 profilage(s_etat_processus, NULL);
 2052:             }
 2053: 
 2054:             (*s_etat_processus).erreur_systeme = d_es_processus;
 2055:             return;
 2056:         }
 2057: 
 2058:         while(drapeau_fin == d_faux)
 2059:         {
 2060:             l_element_courant = (struct_liste_chainee *)
 2061:                     (*s_etat_processus).l_base_pile_processus;
 2062: 
 2063:             while(l_element_courant != NULL)
 2064:             {
 2065:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
 2066:                         .donnee).objet)).thread).processus_detache == d_vrai)
 2067:                 {
 2068:                     if ((*(*((struct_processus_fils *)
 2069:                             (*s_objet_argument).objet)).thread)
 2070:                             .processus_detache == d_vrai)
 2071:                     {
 2072:                         if ((*(*((struct_processus_fils *)
 2073:                                 (*(*l_element_courant)
 2074:                                 .donnee).objet)).thread).pid ==
 2075:                                 (*(*((struct_processus_fils *)
 2076:                                 (*s_objet_argument).objet)).thread).pid)
 2077:                         {
 2078:                             break;
 2079:                         }
 2080:                     }
 2081:                 }
 2082:                 else
 2083:                 {
 2084:                     if ((*(*((struct_processus_fils *)
 2085:                             (*s_objet_argument).objet)).thread)
 2086:                             .processus_detache == d_faux)
 2087:                     {
 2088:                         if ((pthread_equal((*(*((struct_processus_fils *)
 2089:                                 (*(*l_element_courant).donnee).objet)).thread)
 2090:                                 .tid, (*(*((struct_processus_fils *)
 2091:                                 (*s_objet_argument).objet)).thread).tid) != 0)
 2092:                                 && ((*(*((struct_processus_fils *)
 2093:                                 (*(*l_element_courant).donnee).objet)).thread)
 2094:                                 .pid == (*(*((struct_processus_fils *)
 2095:                                 (*s_objet_argument).objet)).thread).pid))
 2096:                         {
 2097:                             break;
 2098:                         }
 2099:                     }
 2100:                 }
 2101: 
 2102:                 l_element_courant = (*l_element_courant).suivant;
 2103:             }
 2104: 
 2105:             if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2106:             {
 2107:                 if ((*s_etat_processus).profilage == d_vrai)
 2108:                 {
 2109:                     profilage(s_etat_processus, NULL);
 2110:                 }
 2111: 
 2112:                 if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2113:                 {
 2114:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2115:                     return;
 2116:                 }
 2117: 
 2118:                 liberation(s_etat_processus, s_objet_argument);
 2119:                 return;
 2120:             }
 2121: 
 2122:             if (l_element_courant == NULL)
 2123:             {
 2124:                 /*
 2125:                  * Si l_element_courant vaut NULL, le processus n'existe plus.
 2126:                  */
 2127: 
 2128:                 drapeau_fin = d_vrai;
 2129:             }
 2130:             else
 2131:             {
 2132:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
 2133:                         .donnee).objet)).thread).processus_detache == d_vrai)
 2134:                 {
 2135:                     if (envoi_signal_processus((*(*((struct_processus_fils *)
 2136:                             (*(*l_element_courant).donnee).objet)).thread).pid,
 2137:                             rpl_signull) != 0)
 2138:                     {
 2139:                         drapeau_fin = d_vrai;
 2140:                     }
 2141:                     else
 2142:                     {
 2143:                         drapeau_fin = d_faux;
 2144:                     }
 2145:                 }
 2146:                 else
 2147:                 {
 2148:                     if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
 2149:                             (*(*l_element_courant).donnee).objet)).thread)
 2150:                             .mutex)) != 0)
 2151:                     {
 2152:                         if ((*s_etat_processus).profilage == d_vrai)
 2153:                         {
 2154:                             profilage(s_etat_processus, NULL);
 2155:                         }
 2156: 
 2157:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2158:                         return;
 2159:                     }
 2160: 
 2161:                     if ((*(*((struct_processus_fils *)
 2162:                             (*(*l_element_courant).donnee).objet)).thread)
 2163:                             .thread_actif == d_faux)
 2164:                     {
 2165:                         drapeau_fin = d_vrai;
 2166:                     }
 2167:                     else
 2168:                     {
 2169:                         drapeau_fin = d_faux;
 2170:                     }
 2171: 
 2172:                     if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
 2173:                             (*(*l_element_courant).donnee).objet)).thread)
 2174:                             .mutex)) != 0)
 2175:                     {
 2176:                         if ((*s_etat_processus).profilage == d_vrai)
 2177:                         {
 2178:                             profilage(s_etat_processus, NULL);
 2179:                         }
 2180: 
 2181:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2182:                         return;
 2183:                     }
 2184:                 }
 2185: 
 2186:                 if (drapeau_fin == d_faux)
 2187:                 {
 2188:                     /*
 2189:                      * Le processus n'est pas terminé
 2190:                      */
 2191: 
 2192:                     if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2193:                     {
 2194:                         if ((*s_etat_processus).profilage == d_vrai)
 2195:                         {
 2196:                             profilage(s_etat_processus, NULL);
 2197:                         }
 2198: 
 2199:                         (*s_etat_processus).erreur_systeme =
 2200:                                 d_es_processus;
 2201:                         return;
 2202:                     }
 2203: 
 2204:                     if ((*s_etat_processus).nombre_interruptions_non_affectees
 2205:                             != 0)
 2206:                     {
 2207:                         affectation_interruptions_logicielles(s_etat_processus);
 2208:                     }
 2209: 
 2210:                     if ((*s_etat_processus).nombre_interruptions_en_queue
 2211:                             != 0)
 2212:                     {
 2213:                         registre_instruction_valide =
 2214:                                 (*s_etat_processus).instruction_valide;
 2215:                         traitement_interruptions_logicielles(
 2216:                                 s_etat_processus);
 2217:                         (*s_etat_processus).instruction_valide =
 2218:                                 registre_instruction_valide;
 2219:                     }
 2220: 
 2221:                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 2222:                     {
 2223:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2224:                         return;
 2225:                     }
 2226: 
 2227:                     nanosleep(&attente, NULL);
 2228: 
 2229:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2230:                     {
 2231:                         if (errno != EINTR)
 2232:                         {
 2233:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2234:                             return;
 2235:                         }
 2236:                     }
 2237: 
 2238:                     scrutation_injection(s_etat_processus);
 2239: 
 2240:                     if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
 2241:                     {
 2242:                         if ((*s_etat_processus).profilage == d_vrai)
 2243:                         {
 2244:                             profilage(s_etat_processus, NULL);
 2245:                         }
 2246: 
 2247:                         (*s_etat_processus).erreur_systeme =
 2248:                                 d_es_processus;
 2249:                         return;
 2250:                     }
 2251:                 }
 2252:             }
 2253: 
 2254:             INCR_GRANULARITE(attente.tv_nsec);
 2255:         }
 2256: 
 2257:         if ((*s_etat_processus).profilage == d_vrai)
 2258:         {
 2259:             profilage(s_etat_processus, NULL);
 2260:         }
 2261: 
 2262:         if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2263:         {
 2264:             (*s_etat_processus).erreur_systeme = d_es_processus;
 2265:             return;
 2266:         }
 2267:     }
 2268:     else
 2269:     {
 2270:         liberation(s_etat_processus, s_objet_argument);
 2271: 
 2272:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2273:         return;
 2274:     }
 2275: 
 2276:     liberation(s_etat_processus, s_objet_argument);
 2277: 
 2278:     return;
 2279: }
 2280: 
 2281: 
 2282: /*
 2283: ================================================================================
 2284:   Fonction 'wfdata'
 2285: ================================================================================
 2286:   Entrées : pointeur sur une structure struct_processus
 2287: --------------------------------------------------------------------------------
 2288:   Sorties :
 2289: --------------------------------------------------------------------------------
 2290:   Effets de bord : néant
 2291: ================================================================================
 2292: */
 2293: 
 2294: void
 2295: instruction_wfdata(struct_processus *s_etat_processus)
 2296: {
 2297:     logical1                    drapeau_fin;
 2298: 
 2299:     struct_liste_chainee        *l_element_courant;
 2300: 
 2301:     struct_objet                *s_objet_argument;
 2302: 
 2303:     struct timespec             attente;
 2304: 
 2305:     unsigned char               registre_instruction_valide;
 2306: 
 2307:     (*s_etat_processus).erreur_execution = d_ex;
 2308: 
 2309:     attente.tv_sec = 0;
 2310:     attente.tv_nsec = GRANULARITE_us * 1000;
 2311: 
 2312:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2313:     {
 2314:         printf("\n  WFDATA ");
 2315: 
 2316:         if ((*s_etat_processus).langue == 'F')
 2317:         {
 2318:             printf("(attente de données d'un processus fils)\n\n");
 2319:         }
 2320:         else
 2321:         {
 2322:             printf("(wait for data from child process)\n\n");
 2323:         }
 2324: 
 2325:         printf("    1: %s\n", d_PRC);
 2326: 
 2327:         return;
 2328:     }
 2329:     else if ((*s_etat_processus).test_instruction == 'Y')
 2330:     {
 2331:         (*s_etat_processus).nombre_arguments = -1;
 2332:         return;
 2333:     }
 2334: 
 2335:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2336:     {
 2337:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2338:         {
 2339:             return;
 2340:         }
 2341:     }
 2342: 
 2343:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2344:             &s_objet_argument) == d_erreur)
 2345:     {
 2346:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2347:         return;
 2348:     }
 2349: 
 2350:     if ((*s_objet_argument).type == PRC)
 2351:     {
 2352:         drapeau_fin = d_faux;
 2353: 
 2354:         if ((*s_etat_processus).profilage == d_vrai)
 2355:         {
 2356:             profilage(s_etat_processus, "Interprocess or interthread "
 2357:                     "communications (WFDATA)");
 2358: 
 2359:             if ((*s_etat_processus).erreur_systeme != d_es)
 2360:             {
 2361:                 return;
 2362:             }
 2363:         }
 2364: 
 2365:         if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
 2366:         {
 2367:             if ((*s_etat_processus).profilage == d_vrai)
 2368:             {
 2369:                 profilage(s_etat_processus, NULL);
 2370:             }
 2371: 
 2372:             (*s_etat_processus).erreur_systeme = d_es_processus;
 2373:             return;
 2374:         }
 2375: 
 2376:         while(drapeau_fin == d_faux)
 2377:         {
 2378:             l_element_courant = (struct_liste_chainee *)
 2379:                     (*s_etat_processus).l_base_pile_processus;
 2380: 
 2381:             while(l_element_courant != NULL)
 2382:             {
 2383:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
 2384:                         .donnee).objet)).thread).processus_detache == d_vrai)
 2385:                 {
 2386:                     if (((*(*((struct_processus_fils *) (*(*l_element_courant)
 2387:                             .donnee).objet)).thread).pid ==
 2388:                             (*(*((struct_processus_fils *)
 2389:                             (*s_objet_argument).objet)).thread).pid)
 2390:                             && ((*(*((struct_processus_fils *)
 2391:                             (*s_objet_argument).objet)).thread)
 2392:                             .processus_detache == d_vrai))
 2393:                     {
 2394:                         break;
 2395:                     }
 2396:                 }
 2397:                 else
 2398:                 {
 2399:                     if ((pthread_equal((*(*((struct_processus_fils *)
 2400:                             (*(*l_element_courant).donnee).objet)).thread).tid,
 2401:                             (*(*((struct_processus_fils *) (*s_objet_argument)
 2402:                             .objet)).thread).tid) != 0) &&
 2403:                             ((*(*((struct_processus_fils *)
 2404:                             (*(*l_element_courant).donnee).objet)).thread).pid
 2405:                             == (*(*((struct_processus_fils *)
 2406:                             (*s_objet_argument).objet)).thread).pid) &&
 2407:                             ((*(*((struct_processus_fils *)
 2408:                             (*s_objet_argument).objet)).thread)
 2409:                             .processus_detache == d_faux))
 2410:                     {
 2411:                         break;
 2412:                     }
 2413:                 }
 2414: 
 2415:                 l_element_courant = (*l_element_courant).suivant;
 2416:             }
 2417: 
 2418:             if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2419:             {
 2420:                 if ((*s_etat_processus).profilage == d_vrai)
 2421:                 {
 2422:                     profilage(s_etat_processus, NULL);
 2423:                 }
 2424: 
 2425:                 if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2426:                 {
 2427:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2428:                     return;
 2429:                 }
 2430: 
 2431:                 liberation(s_etat_processus, s_objet_argument);
 2432:                 return;
 2433:             }
 2434: 
 2435:             if (l_element_courant != NULL)
 2436:             {
 2437:                 if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
 2438:                         (*(*l_element_courant).donnee).objet)).thread).mutex))
 2439:                         != 0)
 2440:                 {
 2441:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2442:                     return;
 2443:                 }
 2444: 
 2445:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
 2446:                         .donnee).objet)).thread).nombre_objets_dans_pipe != 0)
 2447:                 {
 2448:                     if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
 2449:                             (*(*l_element_courant).donnee).objet)).thread)
 2450:                             .mutex)) != 0)
 2451:                     {
 2452:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2453:                         return;
 2454:                     }
 2455: 
 2456:                     drapeau_fin = d_vrai;
 2457:                 }
 2458:                 else
 2459:                 {
 2460:                     if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
 2461:                             (*(*l_element_courant).donnee).objet)).thread)
 2462:                             .mutex)) != 0)
 2463:                     {
 2464:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2465:                         return;
 2466:                     }
 2467: 
 2468:                     if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2469:                     {
 2470:                         if ((*s_etat_processus).profilage == d_vrai)
 2471:                         {
 2472:                             profilage(s_etat_processus, NULL);
 2473:                         }
 2474: 
 2475:                         (*s_etat_processus).erreur_systeme =
 2476:                                 d_es_processus;
 2477:                         return;
 2478:                     }
 2479: 
 2480:                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 2481:                     {
 2482:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 2483:                         return;
 2484:                     }
 2485: 
 2486:                     nanosleep(&attente, NULL);
 2487: 
 2488:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2489:                     {
 2490:                         if (errno != EINTR)
 2491:                         {
 2492:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2493:                             return;
 2494:                         }
 2495:                     }
 2496: 
 2497:                     scrutation_injection(s_etat_processus);
 2498: 
 2499:                     if ((*s_etat_processus).nombre_interruptions_non_affectees
 2500:                             != 0)
 2501:                     {
 2502:                         affectation_interruptions_logicielles(s_etat_processus);
 2503:                     }
 2504: 
 2505:                     if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
 2506:                     {
 2507:                         registre_instruction_valide =
 2508:                                 (*s_etat_processus).instruction_valide;
 2509:                         traitement_interruptions_logicielles(s_etat_processus);
 2510:                         (*s_etat_processus).instruction_valide =
 2511:                                 registre_instruction_valide;
 2512:                     }
 2513: 
 2514:                     if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2515:                     {
 2516:                         if ((*s_etat_processus).profilage == d_vrai)
 2517:                         {
 2518:                             profilage(s_etat_processus, NULL);
 2519:                         }
 2520: 
 2521:                         return;
 2522:                     }
 2523: 
 2524:                     if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
 2525:                     {
 2526:                         if ((*s_etat_processus).profilage == d_vrai)
 2527:                         {
 2528:                             profilage(s_etat_processus, NULL);
 2529:                         }
 2530: 
 2531:                         (*s_etat_processus).erreur_systeme =
 2532:                                 d_es_processus;
 2533:                         return;
 2534:                     }
 2535:                 }
 2536:             }
 2537:             else
 2538:             {
 2539:                 drapeau_fin = d_vrai;
 2540:                 (*s_etat_processus).erreur_execution = d_ex_processus;
 2541:             }
 2542: 
 2543:             INCR_GRANULARITE(attente.tv_nsec);
 2544:         }
 2545: 
 2546:         if ((*s_etat_processus).profilage == d_vrai)
 2547:         {
 2548:             profilage(s_etat_processus, NULL);
 2549:         }
 2550: 
 2551:         if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
 2552:         {
 2553:             (*s_etat_processus).erreur_systeme = d_es_processus;
 2554:             return;
 2555:         }
 2556:     }
 2557:     else
 2558:     {
 2559:         liberation(s_etat_processus, s_objet_argument);
 2560: 
 2561:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2562:         return;
 2563:     }
 2564: 
 2565:     liberation(s_etat_processus, s_objet_argument);
 2566: 
 2567:     return;
 2568: }
 2569: 
 2570: 
 2571: /*
 2572: ================================================================================
 2573:   Fonction 'wfsock'
 2574: ================================================================================
 2575:   Entrées : pointeur sur une structure struct_processus
 2576: --------------------------------------------------------------------------------
 2577:   Sorties :
 2578: --------------------------------------------------------------------------------
 2579:   Effets de bord : néant
 2580: ================================================================================
 2581: */
 2582: 
 2583: void
 2584: instruction_wfsock(struct_processus *s_etat_processus)
 2585: {
 2586:     int                     erreur;
 2587: 
 2588:     logical1                drapeau;
 2589: 
 2590:     socklen_t               longueur;
 2591: 
 2592:     struct_liste_chainee    *l_element_courant;
 2593: 
 2594:     struct_objet            *s_objet_argument;
 2595:     struct_objet            *s_objet_resultat;
 2596: 
 2597:     struct sockaddr_in      adresse_ipv4;
 2598: #   ifdef IPV6
 2599:     struct sockaddr_in6     adresse_ipv6;
 2600: #   endif
 2601: 
 2602:     unsigned long           i;
 2603: 
 2604:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2605:     {
 2606:         printf("\n  WFSOCK ");
 2607: 
 2608:         if ((*s_etat_processus).langue == 'F')
 2609:         {
 2610:             printf("(attente d'une connexion sur une socket)\n\n");
 2611:         }
 2612:         else
 2613:         {
 2614:             printf("(wait for connection on a socket)\n\n");
 2615:         }
 2616: 
 2617:         printf("    1: %s\n", d_SCK);
 2618:         printf("->  2: %s\n", d_SCK);
 2619:         printf("    1: %s\n", d_SCK);
 2620: 
 2621:         return;
 2622:     }
 2623:     else if ((*s_etat_processus).test_instruction == 'Y')
 2624:     {
 2625:         (*s_etat_processus).nombre_arguments = -1;
 2626:         return;
 2627:     }
 2628: 
 2629:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2630:     {
 2631:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2632:         {
 2633:             return;
 2634:         }
 2635:     }
 2636: 
 2637:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2638:             &s_objet_argument) == d_erreur)
 2639:     {
 2640:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2641:         return;
 2642:     }
 2643: 
 2644:     if ((*s_objet_argument).type == SCK)
 2645:     {
 2646:         if ((strcmp((*((struct_socket *) (*s_objet_argument).objet)).type,
 2647:                 "STREAM") != 0) && (strcmp((*((struct_socket *)
 2648:                 (*s_objet_argument).objet)).type, "SEQUENTIAL DATAGRAM") != 0))
 2649:         {
 2650:             liberation(s_etat_processus, s_objet_argument);
 2651: 
 2652:             (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
 2653:             return;
 2654:         }
 2655: 
 2656:         if ((s_objet_resultat = copie_objet(s_etat_processus, s_objet_argument,
 2657:                 'O')) == NULL)
 2658:         {
 2659:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2660:             return;
 2661:         }
 2662: 
 2663:         (*((struct_socket *) (*s_objet_resultat).objet)).socket_en_ecoute = 'N';
 2664:         (*((struct_socket *) (*s_objet_resultat).objet)).effacement = 'N';
 2665: 
 2666:         if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine == PF_INET)
 2667:         {
 2668:             longueur = sizeof(adresse_ipv4);
 2669: 
 2670:             do
 2671:             {
 2672:                 drapeau = d_vrai;
 2673: 
 2674:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 2675:                 {
 2676:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2677:                     return;
 2678:                 }
 2679: 
 2680:                 if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
 2681:                         accept((*((struct_socket *) (*s_objet_argument).objet))
 2682:                         .socket, (struct sockaddr *) &adresse_ipv4, &longueur))
 2683:                         < 0)
 2684:                 {
 2685:                     erreur = errno;
 2686: 
 2687:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2688:                     {
 2689:                         if (errno != EINTR)
 2690:                         {
 2691:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2692:                             return;
 2693:                         }
 2694:                     }
 2695: 
 2696:                     if (erreur != EINTR)
 2697:                     {
 2698:                         liberation(s_etat_processus, s_objet_argument);
 2699:                         liberation(s_etat_processus, s_objet_resultat);
 2700: 
 2701:                         (*s_etat_processus).erreur_execution =
 2702:                                 d_ex_erreur_acces_fichier;
 2703:                         return;
 2704:                     }
 2705: 
 2706:                     scrutation_injection(s_etat_processus);
 2707: 
 2708:                     if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2709:                     {
 2710:                         drapeau = d_vrai;
 2711:                     }
 2712:                     else
 2713:                     {
 2714:                         drapeau = d_faux;
 2715:                     }
 2716:                 }
 2717:                 else
 2718:                 {
 2719:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2720:                     {
 2721:                         if (errno != EINTR)
 2722:                         {
 2723:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2724:                             return;
 2725:                         }
 2726:                     }
 2727:                 }
 2728:             } while(drapeau == d_faux);
 2729: 
 2730:             if (((*((struct_socket *) (*s_objet_resultat).objet))
 2731:                     .adresse_distante = malloc(22 *
 2732:                     sizeof(unsigned char))) == NULL)
 2733:             {
 2734:                 (*s_etat_processus).erreur_systeme =
 2735:                         d_es_allocation_memoire;
 2736:                 return;
 2737:             }
 2738: 
 2739:             sprintf((*((struct_socket *) (*s_objet_resultat).objet))
 2740:                     .adresse_distante, "%d.%d.%d.%d(%d)",
 2741:                     (ntohl(adresse_ipv4.sin_addr.s_addr) >> 24) & 0xFF,
 2742:                     (ntohl(adresse_ipv4.sin_addr.s_addr) >> 16) & 0xFF,
 2743:                     (ntohl(adresse_ipv4.sin_addr.s_addr) >> 8) & 0xFF,
 2744:                     ntohl(adresse_ipv4.sin_addr.s_addr) & 0xFF,
 2745:                     ntohs(adresse_ipv4.sin_port));
 2746:         }
 2747:         else if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine ==
 2748:                 PF_INET6)
 2749:         {
 2750: #           ifdef IPV6
 2751:             longueur = sizeof(adresse_ipv6);
 2752: 
 2753:             do
 2754:             {
 2755:                 drapeau = d_vrai;
 2756: 
 2757:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 2758:                 {
 2759:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2760:                     return;
 2761:                 }
 2762: 
 2763:                 if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
 2764:                         accept((*((struct_socket *) (*s_objet_argument).objet))
 2765:                         .socket, (struct sockaddr *) &adresse_ipv6, &longueur))
 2766:                         < 0)
 2767:                 {
 2768:                     erreur = errno;
 2769: 
 2770:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2771:                     {
 2772:                         if (errno != EINTR)
 2773:                         {
 2774:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2775:                             return;
 2776:                         }
 2777:                     }
 2778: 
 2779:                     if (erreur != EINTR)
 2780:                     {
 2781:                         liberation(s_etat_processus, s_objet_argument);
 2782:                         liberation(s_etat_processus, s_objet_resultat);
 2783: 
 2784:                         (*s_etat_processus).erreur_execution =
 2785:                                 d_ex_erreur_acces_fichier;
 2786:                         return;
 2787:                     }
 2788: 
 2789:                     scrutation_injection(s_etat_processus);
 2790: 
 2791:                     if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2792:                     {
 2793:                         drapeau = d_vrai;
 2794:                     }
 2795:                     else
 2796:                     {
 2797:                         drapeau = d_faux;
 2798:                     }
 2799:                 }
 2800:                 else
 2801:                 {
 2802:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2803:                     {
 2804:                         if (errno != EINTR)
 2805:                         {
 2806:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2807:                             return;
 2808:                         }
 2809:                     }
 2810:                 }
 2811:             } while(drapeau == d_faux);
 2812: 
 2813:             if (((*((struct_socket *) (*s_objet_resultat).objet))
 2814:                     .adresse_distante = malloc(55 *
 2815:                     sizeof(unsigned char))) == NULL)
 2816:             {
 2817:                 (*s_etat_processus).erreur_systeme =
 2818:                         d_es_allocation_memoire;
 2819:                 return;
 2820:             }
 2821: 
 2822:             (*((struct_socket *) (*s_objet_resultat).objet))
 2823:                     .adresse_distante = d_code_fin_chaine;
 2824: 
 2825:             for(i = 0; i < 16; i++)
 2826:             {
 2827:                 sprintf((*((struct_socket *) (*s_objet_resultat)
 2828:                         .objet)).adresse_distante, (i == 0) ? "%s%X" : "%s:%X",
 2829:                         (*((struct_socket *) (*s_objet_resultat)
 2830:                         .objet)).adresse_distante,
 2831:                         adresse_ipv6.sin6_addr.s6_addr[i]);
 2832:             }
 2833: 
 2834:             sprintf((*((struct_socket *) (*s_objet_resultat)
 2835:                     .objet)).adresse_distante, "%s(%u)",
 2836:                     (*((struct_socket *) (*s_objet_resultat)
 2837:                     .objet)).adresse_distante, ntohs(adresse_ipv6.sin6_port));
 2838: #           else
 2839:             if ((*s_etat_processus).langue == 'F')
 2840:             {
 2841:                 printf("+++Attention : Support du protocole"
 2842:                         " IPv6 indisponible\n");
 2843:             }
 2844:             else
 2845:             {
 2846:                 printf("+++Warning : IPv6 support "
 2847:                         "unavailable\n");
 2848:             }
 2849: #           endif
 2850:         }
 2851:         else
 2852:         {
 2853:             longueur = 0;
 2854: 
 2855:             do
 2856:             {
 2857:                 drapeau = d_vrai;
 2858: 
 2859:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 2860:                 {
 2861:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 2862:                     return;
 2863:                 }
 2864: 
 2865:                 if (((*((struct_socket *) (*s_objet_resultat).objet)).socket =
 2866:                         accept((*((struct_socket *) (*s_objet_argument).objet))
 2867:                         .socket, NULL, &longueur)) < 0)
 2868:                 {
 2869:                     erreur = errno;
 2870: 
 2871:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2872:                     {
 2873:                         if (errno != EINTR)
 2874:                         {
 2875:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2876:                             return;
 2877:                         }
 2878:                     }
 2879: 
 2880:                     if (erreur != EINTR)
 2881:                     {
 2882:                         liberation(s_etat_processus, s_objet_argument);
 2883:                         liberation(s_etat_processus, s_objet_resultat);
 2884: 
 2885:                         (*s_etat_processus).erreur_execution =
 2886:                                 d_ex_erreur_acces_fichier;
 2887:                         return;
 2888:                     }
 2889: 
 2890:                     scrutation_injection(s_etat_processus);
 2891: 
 2892:                     if ((*s_etat_processus).var_volatile_requete_arret != 0)
 2893:                     {
 2894:                         drapeau = d_vrai;
 2895:                     }
 2896:                     else
 2897:                     {
 2898:                         drapeau = d_faux;
 2899:                     }
 2900:                 }
 2901:                 else
 2902:                 {
 2903:                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 2904:                     {
 2905:                         if (errno != EINTR)
 2906:                         {
 2907:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 2908:                             return;
 2909:                         }
 2910:                     }
 2911:                 }
 2912:             } while(drapeau == d_faux);
 2913:         }
 2914: 
 2915:         // Si accept() renvoie une erreur non récupérée, il ne peut s'agir
 2916:         // que de EINTR sachant qu'une requête d'arrêt est en court de
 2917:         // traitement.
 2918: 
 2919:         if ((*((struct_socket *) (*s_objet_resultat).objet)).socket >= 0)
 2920:         {
 2921:             l_element_courant = (*s_etat_processus).s_sockets;
 2922: 
 2923:             if (l_element_courant == NULL)
 2924:             {
 2925:                 if (((*s_etat_processus).s_sockets =
 2926:                         allocation_maillon(s_etat_processus)) == NULL)
 2927:                 {
 2928:                     (*s_etat_processus).erreur_systeme =
 2929:                             d_es_allocation_memoire;
 2930:                     return;
 2931:                 }
 2932: 
 2933:                 (*(*s_etat_processus).s_sockets).suivant = NULL;
 2934:                 l_element_courant = (*s_etat_processus).s_sockets;
 2935:             }
 2936:             else
 2937:             {
 2938:                 /*
 2939:                  * Ajout d'un élément à la fin de la liste chaînée
 2940:                  */
 2941: 
 2942:                 while((*l_element_courant).suivant != NULL)
 2943:                 {
 2944:                     l_element_courant = (*l_element_courant).suivant;
 2945:                 }
 2946: 
 2947:                 if (((*l_element_courant).suivant =
 2948:                         allocation_maillon(s_etat_processus)) == NULL)
 2949:                 {
 2950:                     (*s_etat_processus).erreur_systeme =
 2951:                             d_es_allocation_memoire;
 2952:                     return;
 2953:                 }
 2954: 
 2955:                 l_element_courant = (*l_element_courant).suivant;
 2956:                 (*l_element_courant).suivant = NULL;
 2957:             }
 2958: 
 2959:             if (((*l_element_courant).donnee = copie_objet(s_etat_processus,
 2960:                     s_objet_resultat, 'O')) == NULL)
 2961:             {
 2962:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2963:                 return;
 2964:             }
 2965:         }
 2966: 
 2967:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2968:                 s_objet_argument) == d_erreur)
 2969:         {
 2970:             return;
 2971:         }
 2972: 
 2973:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2974:                 s_objet_resultat) == d_erreur)
 2975:         {
 2976:             return;
 2977:         }
 2978:     }
 2979:     else
 2980:     {
 2981:         liberation(s_etat_processus, s_objet_argument);
 2982: 
 2983:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2984:         return;
 2985:     }
 2986: 
 2987:     return;
 2988: }
 2989: 
 2990: 
 2991: /*
 2992: ================================================================================
 2993:   Fonction 'wfswi'
 2994: ================================================================================
 2995:   Entrées : pointeur sur une structure struct_processus
 2996: --------------------------------------------------------------------------------
 2997:   Sorties :
 2998: --------------------------------------------------------------------------------
 2999:   Effets de bord : néant
 3000: ================================================================================
 3001: */
 3002: 
 3003: void
 3004: instruction_wfswi(struct_processus *s_etat_processus)
 3005: {
 3006:     integer8                    interruption;
 3007: 
 3008:     logical1                    drapeau_fin;
 3009: 
 3010:     struct_objet                *s_objet_argument;
 3011: 
 3012:     struct timespec             attente;
 3013: 
 3014:     (*s_etat_processus).erreur_execution = d_ex;
 3015: 
 3016:     attente.tv_sec = 0;
 3017:     attente.tv_nsec = GRANULARITE_us * 1000;
 3018: 
 3019:     if ((*s_etat_processus).affichage_arguments == 'Y')
 3020:     {
 3021:         printf("\n  WFSWI ");
 3022: 
 3023:         if ((*s_etat_processus).langue == 'F')
 3024:         {
 3025:             printf("(attente d'une interruption)\n\n");
 3026:         }
 3027:         else
 3028:         {
 3029:             printf("(wait for interrupt)\n\n");
 3030:         }
 3031: 
 3032:         printf("    1: %s\n", d_INT);
 3033: 
 3034:         return;
 3035:     }
 3036:     else if ((*s_etat_processus).test_instruction == 'Y')
 3037:     {
 3038:         (*s_etat_processus).nombre_arguments = -1;
 3039:         return;
 3040:     }
 3041: 
 3042:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 3043:     {
 3044:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 3045:         {
 3046:             return;
 3047:         }
 3048:     }
 3049: 
 3050:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 3051:             &s_objet_argument) == d_erreur)
 3052:     {
 3053:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 3054:         return;
 3055:     }
 3056: 
 3057:     if ((*s_objet_argument).type == INT)
 3058:     {
 3059:         drapeau_fin = d_faux;
 3060: 
 3061:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 3062: 
 3063:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 3064:         {
 3065:             liberation(s_etat_processus, s_objet_argument);
 3066: 
 3067:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 3068:             return;
 3069:         }
 3070: 
 3071:         while(drapeau_fin == d_faux)
 3072:         {
 3073:             if ((*s_etat_processus).var_volatile_requete_arret != 0)
 3074:             {
 3075:                 liberation(s_etat_processus, s_objet_argument);
 3076:                 return;
 3077:             }
 3078: 
 3079:             if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
 3080:             {
 3081:                 affectation_interruptions_logicielles(s_etat_processus);
 3082:             }
 3083: 
 3084:             if ((*s_etat_processus).queue_interruptions[interruption - 1] > 0)
 3085:             {
 3086:                 drapeau_fin = d_vrai;
 3087:             }
 3088:             else
 3089:             {
 3090:                 nanosleep(&attente, NULL);
 3091:                 scrutation_injection(s_etat_processus);
 3092:                 INCR_GRANULARITE(attente.tv_nsec);
 3093:             }
 3094:         }
 3095:     }
 3096:     else
 3097:     {
 3098:         liberation(s_etat_processus, s_objet_argument);
 3099: 
 3100:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 3101:         return;
 3102:     }
 3103: 
 3104:     liberation(s_etat_processus, s_objet_argument);
 3105: 
 3106:     return;
 3107: }
 3108: 
 3109: 
 3110: /*
 3111: ================================================================================
 3112:   Fonction 'wfpoke'
 3113: ================================================================================
 3114:   Entrées : pointeur sur une structure struct_processus
 3115: --------------------------------------------------------------------------------
 3116:   Sorties :
 3117: --------------------------------------------------------------------------------
 3118:   Effets de bord : néant
 3119: ================================================================================
 3120: */
 3121: 
 3122: void
 3123: instruction_wfpoke(struct_processus *s_etat_processus)
 3124: {
 3125:     struct timespec             attente;
 3126: 
 3127:     unsigned char               registre_instruction_valide;
 3128: 
 3129:     (*s_etat_processus).erreur_execution = d_ex;
 3130: 
 3131:     attente.tv_sec = 0;
 3132:     attente.tv_nsec = GRANULARITE_us * 1000;
 3133: 
 3134:     if ((*s_etat_processus).affichage_arguments == 'Y')
 3135:     {
 3136:         printf("\n  WFPOKE ");
 3137: 
 3138:         if ((*s_etat_processus).langue == 'F')
 3139:         {
 3140:             printf("(attente de données en provenance du processus père)\n\n");
 3141:             printf("  Aucun argument\n");
 3142:         }
 3143:         else
 3144:         {
 3145:             printf("(wait for data from parent process)\n\n");
 3146:             printf("  No argument\n");
 3147:         }
 3148: 
 3149:         return;
 3150:     }
 3151:     else if ((*s_etat_processus).test_instruction == 'Y')
 3152:     {
 3153:         (*s_etat_processus).nombre_arguments = -1;
 3154:         return;
 3155:     }
 3156: 
 3157:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 3158:     {
 3159:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 3160:         {
 3161:             return;
 3162:         }
 3163:     }
 3164: 
 3165:     if ((*s_etat_processus).presence_pipes == d_faux)
 3166:     {
 3167:         (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
 3168:         return;
 3169:     }
 3170: 
 3171:     if ((*s_etat_processus).nombre_objets_injectes > 0)
 3172:     {
 3173:         return;
 3174:     }
 3175: 
 3176:     if ((*s_etat_processus).profilage == d_vrai)
 3177:     {
 3178:         profilage(s_etat_processus, "Interprocess or interthread "
 3179:                 "communications (WFPOKE)");
 3180: 
 3181:         if ((*s_etat_processus).erreur_systeme != d_es)
 3182:         {
 3183:             return;
 3184:         }
 3185:     }
 3186: 
 3187:     do
 3188:     {
 3189:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 3190:         {
 3191:             (*s_etat_processus).erreur_systeme = d_es_processus;
 3192:             return;
 3193:         }
 3194: 
 3195:         nanosleep(&attente, NULL);
 3196: 
 3197:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 3198:         {
 3199:             if (errno != EINTR)
 3200:             {
 3201:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 3202:                 return;
 3203:             }
 3204:         }
 3205: 
 3206:         scrutation_injection(s_etat_processus);
 3207: 
 3208:         if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
 3209:         {
 3210:             affectation_interruptions_logicielles(s_etat_processus);
 3211:         }
 3212: 
 3213:         if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
 3214:         {
 3215:             registre_instruction_valide =
 3216:                     (*s_etat_processus).instruction_valide;
 3217:             traitement_interruptions_logicielles(s_etat_processus);
 3218:             (*s_etat_processus).instruction_valide =
 3219:                     registre_instruction_valide;
 3220:         }
 3221: 
 3222:         if ((*s_etat_processus).var_volatile_requete_arret != 0)
 3223:         {
 3224:             if ((*s_etat_processus).profilage == d_vrai)
 3225:             {
 3226:                 profilage(s_etat_processus, NULL);
 3227:             }
 3228: 
 3229:             return;
 3230:         }
 3231: 
 3232:         INCR_GRANULARITE(attente.tv_nsec);
 3233:     } while((*s_etat_processus).nombre_objets_injectes == 0);
 3234: 
 3235:     return;
 3236: }
 3237: 
 3238: 
 3239: /*
 3240: ================================================================================
 3241:   Fonction 'wfack'
 3242: ================================================================================
 3243:   Entrées : pointeur sur une structure struct_processus
 3244: --------------------------------------------------------------------------------
 3245:   Sorties :
 3246: --------------------------------------------------------------------------------
 3247:   Effets de bord : néant
 3248: ================================================================================
 3249: */
 3250: 
 3251: void
 3252: instruction_wfack(struct_processus *s_etat_processus)
 3253: {
 3254:     struct timespec             attente;
 3255: 
 3256:     unsigned char               registre_instruction_valide;
 3257: 
 3258:     (*s_etat_processus).erreur_execution = d_ex;
 3259: 
 3260:     attente.tv_sec = 0;
 3261:     attente.tv_nsec = GRANULARITE_us * 1000;
 3262: 
 3263:     if ((*s_etat_processus).affichage_arguments == 'Y')
 3264:     {
 3265:         printf("\n  WFACK ");
 3266: 
 3267:         if ((*s_etat_processus).langue == 'F')
 3268:         {
 3269:             printf("(attente des acquittements de lecture)\n\n");
 3270:             printf("  Aucun argument\n");
 3271:         }
 3272:         else
 3273:         {
 3274:             printf("(wait for reading of data acknowledgement)\n\n");
 3275:             printf("  No argument\n");
 3276:         }
 3277: 
 3278:         return;
 3279:     }
 3280:     else if ((*s_etat_processus).test_instruction == 'Y')
 3281:     {
 3282:         (*s_etat_processus).nombre_arguments = -1;
 3283:         return;
 3284:     }
 3285: 
 3286:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 3287:     {
 3288:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 3289:         {
 3290:             return;
 3291:         }
 3292:     }
 3293: 
 3294:     if ((*s_etat_processus).presence_pipes == d_faux)
 3295:     {
 3296:         (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
 3297:         return;
 3298:     }
 3299: 
 3300:     if ((*s_etat_processus).profilage == d_vrai)
 3301:     {
 3302:         profilage(s_etat_processus, "Interprocess or interthread communications"
 3303:                 " (WFACK)");
 3304: 
 3305:         if ((*s_etat_processus).erreur_systeme != d_es)
 3306:         {
 3307:             return;
 3308:         }
 3309:     }
 3310: 
 3311:     while((*s_etat_processus).nombre_objets_envoyes_non_lus != 0)
 3312:     {
 3313:         scrutation_injection(s_etat_processus);
 3314: 
 3315:         if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
 3316:         {
 3317:             affectation_interruptions_logicielles(s_etat_processus);
 3318:         }
 3319: 
 3320:         if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
 3321:         {
 3322:             registre_instruction_valide =
 3323:                     (*s_etat_processus).instruction_valide;
 3324:             traitement_interruptions_logicielles(s_etat_processus);
 3325:             (*s_etat_processus).instruction_valide =
 3326:                     registre_instruction_valide;
 3327:         }
 3328: 
 3329:         if ((*s_etat_processus).var_volatile_requete_arret != 0)
 3330:         {
 3331:             if ((*s_etat_processus).profilage == d_vrai)
 3332:             {
 3333:                 profilage(s_etat_processus, NULL);
 3334:             }
 3335: 
 3336:             return;
 3337:         }
 3338: 
 3339:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 3340:         {
 3341:             (*s_etat_processus).erreur_systeme = d_es_processus;
 3342:             return;
 3343:         }
 3344: 
 3345:         nanosleep(&attente, NULL);
 3346:         INCR_GRANULARITE(attente.tv_nsec);
 3347: 
 3348:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
 3349:         {
 3350:             if (errno != EINTR)
 3351:             {
 3352:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 3353:                 return;
 3354:             }
 3355:         }
 3356:     }
 3357: 
 3358:     if ((*s_etat_processus).profilage == d_vrai)
 3359:     {
 3360:         profilage(s_etat_processus, NULL);
 3361:     }
 3362: 
 3363:     return;
 3364: }
 3365: 
 3366: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>