File:  [local] / rpl / src / rpl.c
Revision 1.123: download - view: text, annotated - select for diffs - revision graph
Wed Oct 17 14:27:06 2012 UTC (11 years, 6 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
Utilisation de la localisation forcée.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.11
    4:   Copyright (C) 1989-2012 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: #define  MAIN_RPL
   24: #include "rpl-conv.h"
   25: 
   26: 
   27: /*
   28: ================================================================================
   29:   Programme principal
   30: ================================================================================
   31: */
   32: 
   33: int
   34: rplinit(int argc, char *argv[], char *envp[],
   35:         unsigned char ***resultats, char *rpl_home)
   36: {
   37: #   include                             "copyright-conv.h"
   38: #   include                             "licence-conv.h"
   39: 
   40:     char                                **arg_exec;
   41: 
   42: #   ifdef HAVE_STACK_OVERFLOW_RECOVERY
   43:     char                                pile_signaux[SIGSTKSZ];
   44: #   endif
   45: 
   46: #   define RPL_PATH_MAX                 1024
   47:     char                                repertoire_initial[RPL_PATH_MAX];
   48: 
   49:     file                                *f_source;
   50: 
   51:     int                                 erreur_historique;
   52:     int                                 option_P;
   53: 
   54:     logical1                            core;
   55:     logical1                            debug;
   56:     logical1                            erreur_fichier;
   57:     logical1                            existence;
   58:     logical1                            mode_interactif;
   59:     logical1                            option_a;
   60:     logical1                            option_A;
   61:     logical1                            option_c;
   62:     logical1                            option_d;
   63:     logical1                            option_D;
   64:     logical1                            option_h;
   65:     logical1                            option_i;
   66:     logical1                            option_l;
   67:     logical1                            option_n;
   68:     logical1                            option_p;
   69:     logical1                            option_s;
   70:     logical1                            option_S;
   71:     logical1                            option_t;
   72:     logical1                            option_v;
   73:     logical1                            ouverture;
   74: 
   75:     pthread_mutexattr_t                 attributs_mutex;
   76: 
   77:     ssize_t                             longueur_ecriture;
   78: 
   79:     struct_objet                        *s_objet;
   80: 
   81:     struct_processus                    *s_etat_processus;
   82: 
   83:     struct_liste_variables_statiques    *l_element_statique_courant;
   84:     struct_liste_variables_statiques    *l_element_statique_suivant;
   85: 
   86:     struct_table_variables_partagees    s_variables_partagees;
   87: 
   88:     struct sigaction                    action;
   89:     struct sigaction                    registre;
   90: 
   91:     struct timespec                     attente;
   92: 
   93:     unsigned char                       *arguments;
   94:     unsigned char                       drapeau_encart;
   95:     unsigned char                       *type_debug;
   96:     unsigned char                       *home;
   97:     unsigned char                       *langue;
   98:     unsigned char                       *message;
   99:     unsigned char                       *nom_fichier_temporaire;
  100:     unsigned char                       option;
  101:     unsigned char                       presence_definition;
  102:     unsigned char                       *ptr;
  103:     unsigned char                       *tampon;
  104: 
  105:     unsigned long                       i;
  106:     unsigned long                       unite_fichier;
  107: 
  108:     void                                *l_element_courant;
  109:     void                                *l_element_suivant;
  110: 
  111:     volatile int                        erreur;
  112:     volatile unsigned char              traitement_fichier_temporaire;
  113: 
  114:     errno = 0;
  115:     s_queue_signaux = NULL;
  116:     routine_recursive = 0;
  117:     pid_processus_pere = getpid();
  118: 
  119: #   ifdef DEBUG_MEMOIRE
  120:     debug_memoire_initialisation();
  121: #   endif
  122: 
  123:     setvbuf(stdout, NULL, _IOLBF, 0);
  124:     setvbuf(stderr, NULL, _IOLBF, 0);
  125: 
  126: #   ifndef SEMAPHORES_NOMMES
  127:     sem_init(&semaphore_gestionnaires_signaux, 0, 0);
  128: #   else
  129:     semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX);
  130:     
  131:     if (semaphore_gestionnaires_signaux == SEM_FAILED)
  132:     {
  133:         erreur = d_es_allocation_memoire;
  134: 
  135:         if ((langue = getenv("LANG")) != NULL)
  136:         {
  137:             if (strncmp(langue, "fr", 2) == 0)
  138:             {
  139:                 uprintf("+++Système : Mémoire insuffisante\n");
  140:             }
  141:             else
  142:             {
  143:                 uprintf("+++System : Not enough memory\n");
  144:             }
  145:         }
  146:         else
  147:         {
  148:             uprintf("+++System : Not enough memory\n");
  149:         }
  150: 
  151:         return(EXIT_FAILURE);
  152:     }
  153: #   endif
  154: 
  155:     if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL)
  156:     {
  157:         erreur = d_es_allocation_memoire;
  158: 
  159:         if ((langue = getenv("LANG")) != NULL)
  160:         {
  161:             if (strncmp(langue, "fr", 2) == 0)
  162:             {
  163:                 uprintf("+++Système : Mémoire insuffisante\n");
  164:             }
  165:             else
  166:             {
  167:                 uprintf("+++System : Not enough memory\n");
  168:             }
  169:         }
  170:         else
  171:         {
  172:             uprintf("+++System : Not enough memory\n");
  173:         }
  174: 
  175:         return(EXIT_FAILURE);
  176:     }
  177: 
  178:     if ((langue = getenv("LANG")) != NULL)
  179:     {
  180:         (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0)
  181:                 ? 'F' : 'E';
  182:     }
  183:     else
  184:     {
  185:         (*s_etat_processus).langue = 'E';
  186:     }
  187: 
  188:     if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL)
  189:     {
  190:         if ((langue = getenv("LANG")) != NULL)
  191:         {
  192:             if (strncmp(langue, "fr", 2) == 0)
  193:             {
  194:                 uprintf("+++Système : Mémoire insuffisante\n");
  195:             }
  196:             else
  197:             {
  198:                 uprintf("+++System : Not enough memory\n");
  199:             }
  200:         }
  201:         else
  202:         {
  203:             uprintf("+++System : Not enough memory\n");
  204:         }
  205: 
  206:         return(EXIT_FAILURE);
  207:     }
  208: 
  209:     if ((arg_exec = malloc((argc + 1) * sizeof(char *))) == NULL)
  210:     {
  211:         if ((langue = getenv("LANG")) != NULL)
  212:         {
  213:             if (strncmp(langue, "fr", 2) == 0)
  214:             {
  215:                 uprintf("+++Système : Mémoire insuffisante\n");
  216:             }
  217:             else
  218:             {
  219:                 uprintf("+++System : Not enough memory\n");
  220:             }
  221:         }
  222:         else
  223:         {
  224:             uprintf("+++System : Not enough memory\n");
  225:         }
  226: 
  227:         return(EXIT_FAILURE);
  228:     }
  229: 
  230:     for(i = 0; i < (unsigned long) argc; i++)
  231:     {
  232:         arg_exec[i] = argv[i];
  233:     }
  234: 
  235:     argv[argc] = NULL;
  236: 
  237:     initialisation_contexte_cas(s_etat_processus);
  238: 
  239:     (*s_etat_processus).exception = d_ep;
  240:     (*s_etat_processus).erreur_systeme = d_es;
  241:     (*s_etat_processus).erreur_execution = d_ex;
  242: 
  243:     (*s_etat_processus).requete_redemarrage = d_faux;
  244:     (*s_etat_processus).rpl_home = rpl_home;
  245: 
  246:     pthread_mutexattr_init(&attributs_mutex);
  247:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
  248:     pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex);
  249:     pthread_mutexattr_destroy(&attributs_mutex);
  250: 
  251:     pthread_mutexattr_init(&attributs_mutex);
  252:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
  253:     pthread_mutex_init(&((*s_etat_processus).mutex_allocation),
  254:             &attributs_mutex);
  255:     pthread_mutexattr_destroy(&attributs_mutex);
  256: 
  257:     pthread_mutexattr_init(&attributs_mutex);
  258:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
  259:     pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex);
  260:     pthread_mutexattr_destroy(&attributs_mutex);
  261: 
  262: #   ifndef SEMAPHORES_NOMMES
  263:         sem_init(&((*s_etat_processus).semaphore_fork), 0, 0);
  264: #   else
  265:         if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(),
  266:                 pthread_self(), SEM_FORK)) == SEM_FAILED)
  267:         {
  268:             if ((*s_etat_processus).langue == 'F')
  269:             {
  270:                 uprintf("+++Système : Mémoire insuffisante\n");
  271:             }
  272:             else
  273:             {
  274:                 uprintf("+++System : Not enough memory\n");
  275:             }
  276: 
  277:             return(EXIT_FAILURE);
  278:         }
  279: #   endif
  280: 
  281:     pthread_mutexattr_init(&attributs_mutex);
  282:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
  283:     pthread_mutex_init(&((*s_etat_processus).protection_liste_mutexes),
  284:             &attributs_mutex);
  285:     pthread_mutexattr_destroy(&attributs_mutex);
  286: 
  287:     (*s_etat_processus).s_liste_variables_partagees = &s_variables_partagees;
  288: 
  289:     s_variables_partagees.nombre_variables = 0;
  290:     s_variables_partagees.nombre_variables_allouees = 0;
  291:     s_variables_partagees.table = NULL;
  292: 
  293:     pthread_mutexattr_init(&attributs_mutex);
  294:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
  295:     pthread_mutex_init(&((*((*s_etat_processus).s_liste_variables_partagees))
  296:             .mutex), &attributs_mutex);
  297:     pthread_mutexattr_destroy(&attributs_mutex);
  298: 
  299:     (*s_etat_processus).chemin_fichiers_temporaires =
  300:             recherche_chemin_fichiers_temporaires(s_etat_processus);
  301: 
  302:     insertion_thread(s_etat_processus, d_vrai);
  303:     creation_queue_signaux(s_etat_processus);
  304: 
  305:     if (d_forced_locale == 0)
  306:     {
  307:         localisation_courante(s_etat_processus);
  308:     }
  309:     else
  310:     {
  311:         if ((*s_etat_processus).erreur_systeme != d_es)
  312:         {
  313:             if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
  314:                     + 1) * sizeof(unsigned char))) == NULL)
  315:             {
  316:                 if ((*s_etat_processus).langue == 'F')
  317:                 {
  318:                     uprintf("+++Système : Mémoire insuffisante\n");
  319:                 }
  320:                 else
  321:                 {
  322:                     uprintf("+++System : Not enough memory\n");
  323:                 }
  324: 
  325:                 return(EXIT_FAILURE);
  326:             }
  327: 
  328:             strcpy((*s_etat_processus).localisation, d_locale);
  329:         }
  330:     }
  331: 
  332:     (*s_etat_processus).erreur_systeme = d_es;
  333: 
  334:     if ((*s_etat_processus).localisation == NULL)
  335:     {
  336:         if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) *
  337:                 sizeof(unsigned char))) == NULL)
  338:         {
  339:             if ((*s_etat_processus).langue == 'F')
  340:             {
  341:                 uprintf("+++Système : Mémoire insuffisante\n");
  342:             }
  343:             else
  344:             {
  345:                 uprintf("+++System : Not enough memory\n");
  346:             }
  347: 
  348:             return(EXIT_FAILURE);
  349:         }
  350: 
  351:         strcpy((*s_etat_processus).localisation, d_locale);
  352:     }
  353: 
  354:     printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl,
  355:             ((*s_etat_processus).langue == 'F') ? d_date_rpl : d_date_en_rpl);
  356: 
  357:     if ((*s_etat_processus).langue == 'F')
  358:     {
  359:         printf("+++Copyright (C) 1989 à 2011, 2012 BERTRAND Joël\n");
  360:     }
  361:     else
  362:     {
  363:         printf("+++Copyright (C) 1989 to 2011, 2012 BERTRAND Joel\n");
  364:     }
  365: 
  366:     if (getenv("HOME") != NULL)
  367:     {
  368:         home = getenv("HOME");
  369:     }
  370:     else if ((getenv("USER") != NULL) && (getpwnam(getenv("USER")) != NULL))
  371:     {
  372:         home = getpwnam(getenv("USER"))->pw_dir;
  373:     }
  374:     else if ((getenv("LOGNAME") != NULL) && (getpwnam(getenv("LOGNAME"))
  375:             != NULL))
  376:     {
  377:         home = getpwnam(getenv("LOGNAME"))->pw_dir;
  378:     }
  379:     else if ((getuid() != ((uid_t) -1)) && (getpwuid(getuid()) != NULL))
  380:     {
  381:         home = getpwuid(getuid())->pw_dir;
  382:     }
  383:     else
  384:     {
  385:         home = "";
  386:     }
  387: 
  388: #   ifdef HAVE_STACK_OVERFLOW_RECOVERY
  389:         if (stackoverflow_install_handler(interruption_depassement_pile,
  390:                 pile_signaux, sizeof(pile_signaux)) != 0)
  391:         {
  392:             erreur = d_es_signal;
  393: 
  394:             if ((*s_etat_processus).langue == 'F')
  395:             {
  396:                 printf("+++Système : Initialisation de la pile alternative "
  397:                         "impossible\n");
  398:             }
  399:             else
  400:             {
  401:                 printf("+++System : Initialization of alternate "
  402:                         "stack failed\n");
  403:             }
  404: 
  405:             return(EXIT_FAILURE);
  406:         }
  407: #   else
  408:         if ((*s_etat_processus).langue == 'F')
  409:         {
  410:             printf("+++Attention : Le système ne supporte pas de pile "
  411:                     "alternative\n");
  412:         }
  413:         else
  414:         {
  415:             printf("+++Warning : Operating system does not support alternate "
  416:                     "stack\n");
  417:         }
  418: #   endif
  419: 
  420:     if (lancement_thread_signaux(s_etat_processus) != d_absence_erreur)
  421:     {
  422:         erreur = d_es_signal;
  423: 
  424:         if ((*s_etat_processus).langue == 'F')
  425:         {
  426:             printf("+++Système : Initialisation des signaux POSIX "
  427:                     "impossible\n");
  428:         }
  429:         else
  430:         {
  431:             printf("+++System : Initialization of POSIX signals failed\n");
  432:         }
  433: 
  434:         return(EXIT_FAILURE);
  435:     }
  436: 
  437:     action.sa_handler = interruption1;
  438:     action.sa_flags = 0;
  439: 
  440:     if (sigaction(SIGINT, &action, NULL) != 0)
  441:     {
  442:         erreur = d_es_signal;
  443: 
  444:         if ((*s_etat_processus).langue == 'F')
  445:         {
  446:             printf("+++Système : Initialisation des signaux POSIX "
  447:                     "impossible\n");
  448:         }
  449:         else
  450:         {
  451:             printf("+++System : Initialization of POSIX signals failed\n");
  452:         }
  453: 
  454:         return(EXIT_FAILURE);
  455:     }
  456: 
  457:     signal_test = SIGTEST;
  458:     kill(getpid(), SIGINT);
  459: 
  460:     attente.tv_sec = 0;
  461:     attente.tv_nsec = 1000000;
  462: 
  463:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  464:     {
  465:         nanosleep(&attente, NULL);
  466:     }
  467: 
  468:     if (signal_test != SIGINT)
  469:     {
  470:         erreur = d_es_signal;
  471: 
  472:         if ((*s_etat_processus).langue == 'F')
  473:         {
  474:             printf("+++Système : Initialisation des signaux POSIX "
  475:                     "impossible\n");
  476:         }
  477:         else
  478:         {
  479:             printf("+++System : Initialization of POSIX signals failed\n");
  480:         }
  481: 
  482:         return(EXIT_FAILURE);
  483:     }
  484: 
  485:     if (sigaction(SIGTERM, &action, NULL) != 0)
  486:     {
  487:         erreur = d_es_signal;
  488: 
  489:         if ((*s_etat_processus).langue == 'F')
  490:         {
  491:             printf("+++Système : Initialisation des signaux POSIX "
  492:                     "impossible\n");
  493:         }
  494:         else
  495:         {
  496:             printf("+++System : Initialization of POSIX signals failed\n");
  497:         }
  498: 
  499:         return(EXIT_FAILURE);
  500:     }
  501: 
  502:     signal_test = SIGTEST;
  503:     kill(getpid(), SIGTERM);
  504: 
  505:     attente.tv_sec = 0;
  506:     attente.tv_nsec = 1000000;
  507: 
  508:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  509:     {
  510:         nanosleep(&attente, NULL);
  511:     }
  512: 
  513:     if (signal_test != SIGTERM)
  514:     {
  515:         erreur = d_es_signal;
  516: 
  517:         if ((*s_etat_processus).langue == 'F')
  518:         {
  519:             printf("+++Système : Initialisation des signaux POSIX "
  520:                     "impossible\n");
  521:         }
  522:         else
  523:         {
  524:             printf("+++System : Initialization of POSIX signals failed\n");
  525:         }
  526: 
  527:         return(EXIT_FAILURE);
  528:     }
  529: 
  530:     if (sigaction(SIGALRM, &action, NULL) != 0)
  531:     {
  532:         erreur = d_es_signal;
  533: 
  534:         if ((*s_etat_processus).langue == 'F')
  535:         {
  536:             printf("+++Système : Initialisation des signaux POSIX "
  537:                     "impossible\n");
  538:         }
  539:         else
  540:         {
  541:             printf("+++System : Initialization of POSIX signals failed\n");
  542:         }
  543: 
  544:         return(EXIT_FAILURE);
  545:     }
  546: 
  547:     signal_test = SIGTEST;
  548:     kill(getpid(), SIGALRM);
  549: 
  550:     attente.tv_sec = 0;
  551:     attente.tv_nsec = 1000000;
  552: 
  553:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  554:     {
  555:         nanosleep(&attente, NULL);
  556:     }
  557: 
  558:     if (signal_test != SIGALRM)
  559:     {
  560:         erreur = d_es_signal;
  561: 
  562:         if ((*s_etat_processus).langue == 'F')
  563:         {
  564:             printf("+++Système : Initialisation des signaux POSIX "
  565:                     "impossible\n");
  566:         }
  567:         else
  568:         {
  569:             printf("+++System : Initialization of POSIX signals failed\n");
  570:         }
  571: 
  572:         return(EXIT_FAILURE);
  573:     }
  574: 
  575:     action.sa_handler = interruption2;
  576:     action.sa_flags = 0;
  577: 
  578:     if (sigaction(SIGTSTP, &action, NULL) != 0)
  579:     {
  580:         if ((*s_etat_processus).langue == 'F')
  581:         {
  582:             printf("+++Système : Initialisation des signaux POSIX "
  583:                     "impossible\n");
  584:         }
  585:         else
  586:         {
  587:             printf("+++System : Initialization of POSIX signals failed\n");
  588:         }
  589: 
  590:         return(EXIT_FAILURE);
  591:     }
  592: 
  593:     signal_test = SIGTEST;
  594:     kill(getpid(), SIGTSTP);
  595: 
  596:     attente.tv_sec = 0;
  597:     attente.tv_nsec = 1000000;
  598: 
  599:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  600:     {
  601:         nanosleep(&attente, NULL);
  602:     }
  603: 
  604:     if (signal_test != SIGTSTP)
  605:     {
  606:         erreur = d_es_signal;
  607: 
  608:         if ((*s_etat_processus).langue == 'F')
  609:         {
  610:             printf("+++Système : Initialisation des signaux POSIX "
  611:                     "impossible\n");
  612:         }
  613:         else
  614:         {
  615:             printf("+++System : Initialization of POSIX signals failed\n");
  616:         }
  617: 
  618:         return(EXIT_FAILURE);
  619:     }
  620: 
  621:     action.sa_handler = interruption5;
  622:     action.sa_flags = 0;
  623: 
  624:     if (sigaction(SIGPIPE, &action, NULL) != 0)
  625:     {
  626:         erreur = d_es_signal;
  627: 
  628:         if ((*s_etat_processus).langue == 'F')
  629:         {
  630:             printf("+++Système : Initialisation des signaux POSIX "
  631:                     "impossible\n");
  632:         }
  633:         else
  634:         {
  635:             printf("+++System : Initialization of POSIX signals failed\n");
  636:         }
  637: 
  638:         return(EXIT_FAILURE);
  639:     }
  640: 
  641:     signal_test = SIGTEST;
  642:     kill(getpid(), SIGPIPE);
  643: 
  644:     attente.tv_sec = 0;
  645:     attente.tv_nsec = 1000000;
  646: 
  647:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  648:     {
  649:         nanosleep(&attente, NULL);
  650:     }
  651: 
  652:     if (signal_test != SIGPIPE)
  653:     {
  654:         erreur = d_es_signal;
  655: 
  656:         if ((*s_etat_processus).langue == 'F')
  657:         {
  658:             printf("+++Système : Initialisation des signaux POSIX "
  659:                     "impossible\n");
  660:         }
  661:         else
  662:         {
  663:             printf("+++System : Initialization of POSIX signals failed\n");
  664:         }
  665: 
  666:         return(EXIT_FAILURE);
  667:     }
  668: 
  669:     action.sa_handler = interruption1;
  670:     action.sa_flags = 0;
  671: 
  672:     if (sigaction(SIGUSR1, &action, NULL) != 0)
  673:     {
  674:         erreur = d_es_signal;
  675: 
  676:         if ((*s_etat_processus).langue == 'F')
  677:         {
  678:             printf("+++Système : Initialisation des signaux POSIX "
  679:                     "impossible\n");
  680:         }
  681:         else
  682:         {
  683:             printf("+++System : Initialization of POSIX signals failed\n");
  684:         }
  685: 
  686:         return(EXIT_FAILURE);
  687:     }
  688: 
  689:     signal_test = SIGTEST;
  690:     kill(getpid(), SIGUSR1);
  691: 
  692:     attente.tv_sec = 0;
  693:     attente.tv_nsec = 1000000;
  694: 
  695:     for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
  696:     {
  697:         nanosleep(&attente, NULL);
  698:     }
  699: 
  700:     if (signal_test != SIGUSR1)
  701:     {
  702:         erreur = d_es_signal;
  703: 
  704:         if ((*s_etat_processus).langue == 'F')
  705:         {
  706:             printf("+++Système : Initialisation des signaux POSIX "
  707:                     "impossible\n");
  708:         }
  709:         else
  710:         {
  711:             printf("+++System : Initialization of POSIX signals failed\n");
  712:         }
  713: 
  714:         return(EXIT_FAILURE);
  715:     }
  716: 
  717:     signal_test = SIGTEST + 1;
  718: 
  719:     erreur = d_absence_erreur;
  720:     core = d_faux;
  721:     mode_interactif = d_faux;
  722:     (*s_etat_processus).nom_fichier_source = NULL;
  723:     (*s_etat_processus).definitions_chainees = NULL;
  724:     (*s_etat_processus).type_debug = 0;
  725:     traitement_fichier_temporaire = 'N';
  726:     option = ' ';
  727:     drapeau_encart = 'Y';
  728:     debug = d_faux;
  729:     arguments = NULL;
  730: 
  731:     (*s_etat_processus).s_fichiers = NULL;
  732:     (*s_etat_processus).s_sockets = NULL;
  733:     (*s_etat_processus).s_connecteurs_sql = NULL;
  734: 
  735:     setlogmask(LOG_MASK(LOG_NOTICE));
  736:     openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_USER);
  737: 
  738:     if (argc == 1)
  739:     {
  740:         erreur = d_erreur;
  741:         informations(s_etat_processus);
  742:     }
  743:     else
  744:     {
  745:         presence_definition = 'N';
  746:         (*s_etat_processus).debug = d_faux;
  747:         (*s_etat_processus).lancement_interactif = d_faux;
  748: 
  749:         option_a = d_faux;
  750:         option_A = d_faux;
  751:         option_c = d_faux;
  752:         option_d = d_faux;
  753:         option_D = d_faux;
  754:         option_h = d_faux;
  755:         option_i = d_faux;
  756:         option_l = d_faux;
  757:         option_n = d_faux;
  758:         option_p = d_faux;
  759:         option_P = 0;
  760:         option_s = d_faux;
  761:         option_S = d_faux;
  762:         option_t = d_faux;
  763:         option_v = d_faux;
  764: 
  765:         // Lorsque le programme est appelé depuis un shebang, argv[0] contient
  766:         // le chemin du programme et argv[1] tous les arguments.
  767:         // argv[2] contient quant à lui le nom du script RPL/2.
  768:         //
  769:         // Exemple :
  770:         // argv[0] : /usr/local/bin/rpl
  771:         // argv[1] : -csdp -t 800
  772:         // argv[2] : ./on_exit.rpl
  773: 
  774:         while((--argc) > 0)
  775:         {
  776:             if ((*(++argv))[0] == '-')
  777:             {
  778:                 while((option = *(++argv[0])) != '\0')
  779:                 {
  780:                     switch(option)
  781:                     {
  782:                         case 'a' :
  783:                         {
  784:                             if (option_a == d_vrai)
  785:                             {
  786:                                 if ((*s_etat_processus).langue == 'F')
  787:                                 {
  788:                                     printf("+++Erreur : option -a présente "
  789:                                             "plus d'une fois\n");
  790:                                 }
  791:                                 else
  792:                                 {
  793:                                     printf("+++Error : more than one -a "
  794:                                             "on command line");
  795:                                 }
  796: 
  797:                                 return(EXIT_FAILURE);
  798:                             }
  799: 
  800:                             option_a = d_vrai;
  801:                             break;
  802:                         }
  803: 
  804:                         case 'A' :
  805:                         {
  806:                             if (option_A == d_vrai)
  807:                             {
  808:                                 if ((*s_etat_processus).langue == 'F')
  809:                                 {
  810:                                     printf("+++Erreur : option -A présente "
  811:                                             "plus d'une fois\n");
  812:                                 }
  813:                                 else
  814:                                 {
  815:                                     printf("+++Error : more than one -A "
  816:                                             "on command line");
  817:                                 }
  818: 
  819:                                 return(EXIT_FAILURE);
  820:                             }
  821: 
  822:                             option_A = d_vrai;
  823: 
  824:                             while(*(++argv[0]) == ' ');
  825:                             argv[0]--;
  826: 
  827:                             if ((*(++argv[0])) != '\0')
  828:                             {
  829:                                 if ((arguments = malloc((strlen(argv[0]) + 7) *
  830:                                         sizeof(unsigned char))) == NULL)
  831:                                 {
  832:                                     if ((*s_etat_processus).langue == 'F')
  833:                                     {
  834:                                         printf("+++Système : Mémoire "
  835:                                                 "insuffisante\n");
  836:                                     }
  837:                                     else
  838:                                     {
  839:                                         printf("+++System : Not enough "
  840:                                                 "memory\n");
  841:                                     }
  842: 
  843:                                     return(EXIT_FAILURE);
  844:                                 }
  845: 
  846:                                 ptr = arguments;
  847:                                 (*ptr) = d_code_fin_chaine;
  848:                                 strcat(ptr, "<< ");
  849:                                 ptr += 3;
  850: 
  851:                                 while(*(argv[0]) != '\0')
  852:                                 {
  853:                                     *(ptr++) = *(argv[0]++);
  854:                                 }
  855: 
  856:                                 (*ptr) = '\0';
  857: 
  858:                                 strcat(arguments, " >>");
  859:                                 argv[0]--;
  860:                             }
  861:                             else if ((--argc) > 0)
  862:                             {
  863:                                 argv++;
  864: 
  865:                                 if ((arguments = malloc((strlen(argv[0]) + 7) *
  866:                                         sizeof(unsigned char))) == NULL)
  867:                                 {
  868:                                     if ((*s_etat_processus).langue == 'F')
  869:                                     {
  870:                                         printf("+++Système : Mémoire "
  871:                                                 "insuffisante\n");
  872:                                     }
  873:                                     else
  874:                                     {
  875:                                         printf("+++System : Not enough "
  876:                                                 "memory\n");
  877:                                     }
  878: 
  879:                                     return(EXIT_FAILURE);
  880:                                 }
  881: 
  882:                                 ptr = arguments;
  883:                                 (*ptr) = d_code_fin_chaine;
  884:                                 strcat(ptr, "<< ");
  885:                                 ptr += 3;
  886: 
  887:                                 while(*(argv[0]) != '\0')
  888:                                 {
  889:                                     *(ptr++) = *(argv[0]++);
  890:                                 }
  891: 
  892:                                 (*ptr) = '\0';
  893: 
  894:                                 strcat(arguments, " >>");
  895:                                 argv[0]--;
  896:                             }
  897:                             else
  898:                             {
  899:                                 if ((*s_etat_processus).langue == 'F')
  900:                                 {
  901:                                     printf("+++Erreur : Aucune donnée "
  902:                                             "spécifié après l'option -A\n");
  903:                                 }
  904:                                 else
  905:                                 {
  906:                                     printf("+++Error : Data required after "
  907:                                             "-A option\n");
  908:                                 }
  909: 
  910:                                 return(EXIT_FAILURE);
  911:                             }
  912: 
  913:                             break;
  914:                         }
  915: 
  916:                         case 'c' :
  917:                         {
  918:                             if (option_c == d_vrai)
  919:                             {
  920:                                 if ((*s_etat_processus).langue == 'F')
  921:                                 {
  922:                                     printf("+++Erreur : option -c présente "
  923:                                             "plus d'une fois\n");
  924:                                 }
  925:                                 else
  926:                                 {
  927:                                     printf("+++Error : more than one -c "
  928:                                             "on command line");
  929:                                 }
  930: 
  931:                                 return(EXIT_FAILURE);
  932:                             }
  933: 
  934:                             option_c = d_vrai;
  935:                             core = d_vrai;
  936:                             break;
  937:                         }
  938: 
  939:                         case 'd' :
  940:                         {
  941:                             if (option_d == d_vrai)
  942:                             {
  943:                                 if ((*s_etat_processus).langue == 'F')
  944:                                 {
  945:                                     printf("+++Erreur : option -d présente "
  946:                                             "plus d'une fois\n");
  947:                                 }
  948:                                 else
  949:                                 {
  950:                                     printf("+++Error : more than one -d "
  951:                                             "on command line");
  952:                                 }
  953: 
  954:                                 return(EXIT_FAILURE);
  955:                             }
  956: 
  957:                             option_d = d_vrai;
  958:                             debug = d_vrai;
  959:                             break;
  960:                         }
  961: 
  962:                         case 'D' :
  963:                         {
  964:                             if (option_D == d_vrai)
  965:                             {
  966:                                 if ((*s_etat_processus).langue == 'F')
  967:                                 {
  968:                                     printf("+++Erreur : option -D présente "
  969:                                             "plus d'une fois\n");
  970:                                 }
  971:                                 else
  972:                                 {
  973:                                     printf("+++Error : more than one -D "
  974:                                             "on command line");
  975:                                 }
  976: 
  977:                                 return(EXIT_FAILURE);
  978:                             }
  979: 
  980:                             option_D = d_vrai;
  981:                             break;
  982:                         }
  983: 
  984:                         case 'h' :
  985:                         {
  986:                             if (option_h == d_vrai)
  987:                             {
  988:                                 if ((*s_etat_processus).langue == 'F')
  989:                                 {
  990:                                     printf("+++Erreur : option -h présente "
  991:                                             "plus d'une fois\n");
  992:                                 }
  993:                                 else
  994:                                 {
  995:                                     printf("+++Error : more than one -h "
  996:                                             "on command line");
  997:                                 }
  998: 
  999:                                 return(EXIT_FAILURE);
 1000:                             }
 1001: 
 1002:                             option_h = d_vrai;
 1003:                             informations(s_etat_processus);
 1004:                             break;
 1005:                         }
 1006: 
 1007:                         case 'i' :
 1008:                         {
 1009:                             if (option_i == d_vrai) 
 1010:                             {
 1011:                                 if ((*s_etat_processus).langue == 'F')
 1012:                                 {
 1013:                                     printf("+++Erreur : option -i présente "
 1014:                                             "plus d'une fois\n");
 1015:                                 }
 1016:                                 else
 1017:                                 {
 1018:                                     printf("+++Error : more than one -i "
 1019:                                             "on command line");
 1020:                                 }
 1021: 
 1022:                                 return(EXIT_FAILURE);
 1023:                             }
 1024:                             else if (option_S == d_vrai)
 1025:                             {
 1026:                                 if ((*s_etat_processus).langue == 'F')
 1027:                                 {
 1028:                                     printf("+++Erreur : options -i et -S "
 1029:                                             "incompatibles\n");
 1030:                                 }
 1031:                                 else
 1032:                                 {
 1033:                                     printf("+++Error : incompatible options -i "
 1034:                                             "and -S\n");
 1035:                                 }
 1036: 
 1037:                                 return(EXIT_FAILURE);
 1038:                             }
 1039:                             else if (option_p == d_vrai)
 1040:                             {
 1041:                                 if ((*s_etat_processus).langue == 'F')
 1042:                                 {
 1043:                                     printf("+++Erreur : options -i et -p "
 1044:                                             "incompatibles\n");
 1045:                                 }
 1046:                                 else
 1047:                                 {
 1048:                                     printf("+++Error : incompatible options -i "
 1049:                                             "and -p\n");
 1050:                                 }
 1051: 
 1052:                                 return(EXIT_FAILURE);
 1053:                             }
 1054: 
 1055:                             option_i = d_vrai;
 1056:                             mode_interactif = d_vrai;
 1057:                             presence_definition = 'O';
 1058:                             break;
 1059:                         }
 1060: 
 1061:                         case 'l' :
 1062:                         {
 1063:                             if (option_l == d_vrai)
 1064:                             {
 1065:                                 if ((*s_etat_processus).langue == 'F')
 1066:                                 {
 1067:                                     printf("+++Erreur : option -l présente "
 1068:                                             "plus d'une fois\n");
 1069:                                 }
 1070:                                 else
 1071:                                 {
 1072:                                     printf("+++Error : more than one -l "
 1073:                                             "on command line");
 1074:                                 }
 1075: 
 1076:                                 return(EXIT_FAILURE);
 1077:                             }
 1078: 
 1079:                             option_l = d_vrai;
 1080: 
 1081:                             if ((*s_etat_processus).langue == 'F')
 1082:                             {
 1083:                                 printf("%s\n\n", CeCILL_fr);
 1084:                             }
 1085:                             else
 1086:                             {
 1087:                                 printf("%s\n\n", CeCILL_en);
 1088:                             }
 1089: 
 1090:                             break;
 1091:                         }
 1092: 
 1093:                         case 'n' :
 1094:                         {
 1095:                             if (option_n == d_vrai)
 1096:                             {
 1097:                                 if ((*s_etat_processus).langue == 'F')
 1098:                                 {
 1099:                                     printf("+++Erreur : option -n présente "
 1100:                                             "plus d'une fois\n");
 1101:                                 }
 1102:                                 else
 1103:                                 {
 1104:                                     printf("+++Error : more than one -n "
 1105:                                             "on command line");
 1106:                                 }
 1107: 
 1108:                                 return(EXIT_FAILURE);
 1109:                             }
 1110: 
 1111:                             option_n = d_vrai;
 1112: 
 1113:                             break;
 1114:                         }
 1115: 
 1116:                         case 'p' :
 1117:                         {
 1118:                             if (option_p == d_vrai)
 1119:                             {
 1120:                                 if ((*s_etat_processus).langue == 'F')
 1121:                                 {
 1122:                                     printf("+++Erreur : option -p présente "
 1123:                                             "plus d'une fois\n");
 1124:                                 }
 1125:                                 else
 1126:                                 {
 1127:                                     printf("+++Error : more than one -p "
 1128:                                             "on command line");
 1129:                                 }
 1130: 
 1131:                                 return(EXIT_FAILURE);
 1132:                             }
 1133:                             else if (option_i == d_vrai)
 1134:                             {
 1135:                                 if ((*s_etat_processus).langue == 'F')
 1136:                                 {
 1137:                                     printf("+++Erreur : options -i et -p "
 1138:                                             "incompatibles\n");
 1139:                                 }
 1140:                                 else
 1141:                                 {
 1142:                                     printf("+++Error : incompatible options -i "
 1143:                                             "and -p\n");
 1144:                                 }
 1145: 
 1146:                                 return(EXIT_FAILURE);
 1147:                             }
 1148: 
 1149:                             option_p = d_vrai;
 1150: 
 1151:                             break;
 1152:                         }
 1153: 
 1154:                         case 'P' :
 1155:                         {
 1156:                             if (option_P > 2)
 1157:                             {
 1158:                                 if ((*s_etat_processus).langue == 'F')
 1159:                                 {
 1160:                                     printf("+++Erreur : option -P présente "
 1161:                                             "plus de deux fois\n");
 1162:                                 }
 1163:                                 else
 1164:                                 {
 1165:                                     printf("+++Error : more than two -P "
 1166:                                             "on command line");
 1167:                                 }
 1168: 
 1169:                                 return(EXIT_FAILURE);
 1170:                             }
 1171: 
 1172:                             option_P++;
 1173: 
 1174:                             break;
 1175:                         }
 1176: 
 1177:                         case 's' :
 1178:                         {
 1179:                             if (option_s == d_vrai)
 1180:                             {
 1181:                                 if ((*s_etat_processus).langue == 'F')
 1182:                                 {
 1183:                                     printf("+++Erreur : option -s présente "
 1184:                                             "plus d'une fois\n");
 1185:                                 }
 1186:                                 else
 1187:                                 {
 1188:                                     printf("+++Error : more than one -s "
 1189:                                             "on command line");
 1190:                                 }
 1191: 
 1192:                                 return(EXIT_FAILURE);
 1193:                             }
 1194: 
 1195:                             option_s = d_vrai;
 1196:                             drapeau_encart = 'N';
 1197:                             break;
 1198:                         }
 1199: 
 1200:                         case 'S' :
 1201:                         {
 1202:                             if (option_S == d_vrai)
 1203:                             {
 1204:                                 if ((*s_etat_processus).langue == 'F')
 1205:                                 {
 1206:                                     printf("+++Erreur : option -S présente "
 1207:                                             "plus d'une fois\n");
 1208:                                 }
 1209:                                 else
 1210:                                 {
 1211:                                     printf("+++Error : more than one -S "
 1212:                                             "on command line");
 1213:                                 }
 1214: 
 1215:                                 return(EXIT_FAILURE);
 1216:                             }
 1217:                             else if (option_i == d_vrai)
 1218:                             {
 1219:                                 if ((*s_etat_processus).langue == 'F')
 1220:                                 {
 1221:                                     printf("+++Erreur : options -i et -S "
 1222:                                             "incompatibles\n");
 1223:                                 }
 1224:                                 else
 1225:                                 {
 1226:                                     printf("+++Error : incompatible options -S "
 1227:                                             "and -i\n");
 1228:                                 }
 1229: 
 1230:                                 return(EXIT_FAILURE);
 1231:                             }
 1232: 
 1233:                             option_S = d_vrai;
 1234: 
 1235:                             while(*(++argv[0]) == ' ');
 1236:                             argv[0]--;
 1237: 
 1238:                             if ((*(++argv[0])) != '\0')
 1239:                             {
 1240:                                 if (((*s_etat_processus).definitions_chainees =
 1241:                                         malloc((strlen(argv[0]) + 1) *
 1242:                                         sizeof(unsigned char))) == NULL)
 1243:                                 {
 1244:                                     if ((*s_etat_processus).langue == 'F')
 1245:                                     {
 1246:                                         printf("+++Système : Mémoire "
 1247:                                                 "insuffisante\n");
 1248:                                     }
 1249:                                     else
 1250:                                     {
 1251:                                         printf("+++System : Not enough "
 1252:                                                 "memory\n");
 1253:                                     }
 1254: 
 1255:                                     return(EXIT_FAILURE);
 1256:                                 }
 1257: 
 1258:                                 ptr = (*s_etat_processus).definitions_chainees;
 1259: 
 1260:                                 while(*(argv[0]) != '\0')
 1261:                                 {
 1262:                                     *(ptr++) = *(argv[0]++);
 1263:                                 }
 1264: 
 1265:                                 (*ptr) = '\0';
 1266: 
 1267:                                 argv[0]--;
 1268:                                 presence_definition = 'O';
 1269:                             }
 1270:                             else if ((--argc) > 0)
 1271:                             {
 1272:                                 argv++;
 1273: 
 1274:                                 if (((*s_etat_processus).definitions_chainees =
 1275:                                         malloc((strlen(argv[0]) + 1) *
 1276:                                         sizeof(unsigned char))) == NULL)
 1277:                                 {
 1278:                                     if ((*s_etat_processus).langue == 'F')
 1279:                                     {
 1280:                                         printf("+++Système : Mémoire "
 1281:                                                 "insuffisante\n");
 1282:                                     }
 1283:                                     else
 1284:                                     {
 1285:                                         printf("+++System : Not enough "
 1286:                                                 "memory\n");
 1287:                                     }
 1288: 
 1289:                                     return(EXIT_FAILURE);
 1290:                                 }
 1291: 
 1292:                                 ptr = (*s_etat_processus).definitions_chainees;
 1293: 
 1294:                                 while(*(argv[0]) != '\0')
 1295:                                 {
 1296:                                     *(ptr++) = *(argv[0]++);
 1297:                                 }
 1298: 
 1299:                                 (*ptr) = '\0';
 1300: 
 1301:                                 argv[0]--;
 1302:                                 presence_definition = 'O';
 1303:                             }
 1304:                             else
 1305:                             {
 1306:                                 if ((*s_etat_processus).langue == 'F')
 1307:                                 {
 1308:                                     printf("+++Erreur : Aucun script "
 1309:                                             "spécifié après l'option -S\n");
 1310:                                 }
 1311:                                 else
 1312:                                 {
 1313:                                     printf("+++Error : Script required after "
 1314:                                             "-S option\n");
 1315:                                 }
 1316: 
 1317:                                 return(EXIT_FAILURE);
 1318:                             }
 1319: 
 1320:                             if (((*s_etat_processus).definitions_chainees =
 1321:                                     compactage((*s_etat_processus)
 1322:                                     .definitions_chainees)) == NULL)
 1323:                             {
 1324:                                 if ((*s_etat_processus).langue == 'F')
 1325:                                 {
 1326:                                     printf("+++Système : Mémoire "
 1327:                                             "insuffisante\n");
 1328:                                 }
 1329:                                 else
 1330:                                 {
 1331:                                     printf("+++System : Not enough "
 1332:                                             "memory\n");
 1333:                                 }
 1334: 
 1335:                                 return(EXIT_FAILURE);
 1336:                             }
 1337: 
 1338:                             (*s_etat_processus).longueur_definitions_chainees =
 1339:                                     strlen((*s_etat_processus)
 1340:                                     .definitions_chainees);
 1341: 
 1342:                             break;
 1343:                         }
 1344: 
 1345:                         case 't' :
 1346:                         {
 1347:                             if (option_t == d_vrai)
 1348:                             {
 1349:                                 if ((*s_etat_processus).langue == 'F')
 1350:                                 {
 1351:                                     printf("+++Erreur : option -t présente "
 1352:                                             "plus d'une fois\n");
 1353:                                 }
 1354:                                 else
 1355:                                 {
 1356:                                     printf("+++Error : more than one -t "
 1357:                                             "on command line");
 1358:                                 }
 1359: 
 1360:                                 return(EXIT_FAILURE);
 1361:                             }
 1362: 
 1363:                             option_t = d_vrai;
 1364:                             (*s_etat_processus).debug = d_vrai;
 1365: 
 1366:                             while(*(++argv[0]) == ' ');
 1367:                             argv[0]--;
 1368: 
 1369:                             if ((*(++argv[0])) != '\0')
 1370:                             {
 1371:                                 if ((type_debug = malloc((strlen(argv[0]) + 1) *
 1372:                                         sizeof(unsigned char))) == NULL)
 1373:                                 {
 1374:                                     if ((*s_etat_processus).langue == 'F')
 1375:                                     {
 1376:                                         printf("+++Système : Mémoire "
 1377:                                                 "insuffisante\n");
 1378:                                     }
 1379:                                     else
 1380:                                     {
 1381:                                         printf("+++System : Not enough "
 1382:                                                 "memory\n");
 1383:                                     }
 1384: 
 1385:                                     return(EXIT_FAILURE);
 1386:                                 }
 1387: 
 1388:                                 ptr = type_debug;
 1389: 
 1390:                                 while((*(argv[0]) != '\0') &&
 1391:                                         (*(argv[0]) != ' '))
 1392:                                 {
 1393:                                     *(ptr++) = *(argv[0]++);
 1394:                                 }
 1395: 
 1396:                                 (*ptr) = '\0';
 1397: 
 1398:                                 argv[0]--;
 1399:                             }
 1400:                             else if ((--argc) > 0)
 1401:                             {
 1402:                                 argv++;
 1403: 
 1404:                                 if ((type_debug =
 1405:                                         malloc((strlen(argv[0]) + 1) *
 1406:                                         sizeof(unsigned char))) == NULL)
 1407:                                 {
 1408:                                     if ((*s_etat_processus).langue == 'F')
 1409:                                     {
 1410:                                         printf("+++Système : Mémoire "
 1411:                                                 "insuffisante\n");
 1412:                                     }
 1413:                                     else
 1414:                                     {
 1415:                                         printf("+++System : Not enough "
 1416:                                                 "memory\n");
 1417:                                     }
 1418: 
 1419:                                     return(EXIT_FAILURE);
 1420:                                 }
 1421: 
 1422:                                 ptr = type_debug;
 1423: 
 1424:                                 while(*(argv[0]) != '\0')
 1425:                                 {
 1426:                                     *(ptr++) = *(argv[0]++);
 1427:                                 }
 1428: 
 1429:                                 (*ptr) = '\0';
 1430: 
 1431:                                 argv[0]--;
 1432:                             }
 1433:                             else
 1434:                             {
 1435:                                 if ((*s_etat_processus).langue == 'F')
 1436:                                 {
 1437:                                     printf("+++Erreur : Aucun niveau "
 1438:                                             "de débogage spécifié après "
 1439:                                             "l'option -t\n");
 1440:                                 }
 1441:                                 else
 1442:                                 {
 1443:                                     printf("+++Error : Debug level not "
 1444:                                             "specified after -t option\n");
 1445:                                 }
 1446: 
 1447:                                 return(EXIT_FAILURE);
 1448:                             }
 1449: 
 1450:                             ptr = type_debug;
 1451: 
 1452:                             while(*ptr != '\0')
 1453:                             {
 1454:                                 switch(*ptr)
 1455:                                 {
 1456:                                     case '0':
 1457:                                     case '1':
 1458:                                     case '2':
 1459:                                     case '3':
 1460:                                     case '4':
 1461:                                     case '5':
 1462:                                     case '6':
 1463:                                     case '7':
 1464:                                     case '8':
 1465:                                     case '9':
 1466:                                     case 'A':
 1467:                                     case 'B':
 1468:                                     case 'C':
 1469:                                     case 'D':
 1470:                                     case 'E':
 1471:                                     case 'F':
 1472:                                     {
 1473:                                         break;
 1474:                                     }
 1475: 
 1476:                                     default:
 1477:                                     {
 1478:                                         if ((*s_etat_processus).langue == 'F')
 1479:                                         {
 1480:                                             printf("+++Erreur : Niveau "
 1481:                                                     "de débogage non "
 1482:                                                     "hexadécimal\n");
 1483:                                         }
 1484:                                         else
 1485:                                         {
 1486:                                             printf("+++Error : Debug level must"
 1487:                                                     " be hexadecimal "
 1488:                                                     "integer\n");
 1489:                                         }
 1490: 
 1491:                                         return(EXIT_FAILURE);
 1492:                                     }
 1493:                                 }
 1494: 
 1495:                                 ptr++;
 1496:                             }
 1497: 
 1498:                             if (sscanf(type_debug, "%llX",
 1499:                                     &((*s_etat_processus).type_debug)) != 1)
 1500:                             {
 1501:                                 if ((*s_etat_processus).langue == 'F')
 1502:                                 {
 1503:                                     printf("+++Erreur : Niveau "
 1504:                                             "de débogage non entier\n");
 1505:                                 }
 1506:                                 else
 1507:                                 {
 1508:                                     printf("+++Error : Debug level must"
 1509:                                             " be integer\n");
 1510:                                 }
 1511: 
 1512:                                 return(EXIT_FAILURE);
 1513:                             }
 1514: 
 1515:                             free(type_debug);
 1516:                             break;
 1517:                         }
 1518: 
 1519:                         case 'v' :
 1520:                         {
 1521:                             if (option_v == d_vrai)
 1522:                             {
 1523:                                 if ((*s_etat_processus).langue == 'F')
 1524:                                 {
 1525:                                     printf("+++Erreur : option -v présente "
 1526:                                             "plus d'une fois\n");
 1527:                                 }
 1528:                                 else
 1529:                                 {
 1530:                                     printf("+++Error : more than one -v "
 1531:                                             "on command line");
 1532:                                 }
 1533: 
 1534:                                 return(EXIT_FAILURE);
 1535:                             }
 1536: 
 1537:                             option_v = d_vrai;
 1538:                             printf("\n");
 1539: 
 1540:                             if ((*s_etat_processus).langue == 'F')
 1541:                             {
 1542:                                 printf("  Reverse Polish Lisp/2 version %s "
 1543:                                         "pour systèmes "
 1544:                                         "POSIX\n", d_version_rpl);
 1545:                                 printf("      Langage procédural de très haut "
 1546:                                         "niveau, semi-compilé, "
 1547:                                         "extensible,\n");
 1548:                                 printf("      destiné principalement aux "
 1549:                                         "calculs scientifiques et "
 1550:                                         "symboliques\n");
 1551:                                 printf("%s\n", copyright);
 1552:                             }
 1553:                             else
 1554:                             {
 1555:                                 printf("  Reverse Polish Lisp/2 version %s "
 1556:                                         "for POSIX operating systems\n",
 1557:                                         d_version_rpl);
 1558:                                 printf("      Half-compiled, high-level "
 1559:                                         "procedural language,\n");
 1560:                                 printf("      mainly aiming at scientific "
 1561:                                         "calculations\n");
 1562:                                 printf("%s\n", copyright_anglais);
 1563:                             }
 1564: 
 1565:                             printf("\n");
 1566:                             break;
 1567:                         }
 1568: 
 1569:                         case '-':
 1570:                         case ' ':
 1571:                         {
 1572:                             break;
 1573:                         }
 1574: 
 1575:                         default :
 1576:                         {
 1577:                             if ((*s_etat_processus).langue == 'F')
 1578:                             {
 1579:                                 printf("+++Information : Option -%c inconnue\n",
 1580:                                         option);
 1581:                             }
 1582:                             else
 1583:                             {
 1584:                                 printf("+++Warning : -%c option unknown\n",
 1585:                                         option);
 1586:                             }
 1587: 
 1588:                             informations(s_etat_processus);
 1589:                             break;
 1590:                         }
 1591:                     }
 1592:                 }
 1593:             }
 1594:             else
 1595:             {
 1596:                 if (presence_definition == 'O')
 1597:                 {
 1598:                     argc = 0;
 1599: 
 1600:                     if ((*s_etat_processus).langue == 'F')
 1601:                     {
 1602:                         printf("+++Erreur : Plusieurs définitions\n");
 1603:                     }
 1604:                     else
 1605:                     {
 1606:                         printf("+++Error : More than one definition\n");
 1607:                     }
 1608: 
 1609:                     erreur = d_erreur;
 1610:                 }
 1611:                 else
 1612:                 {
 1613:                     (*s_etat_processus).nom_fichier_source = argv[0];
 1614:                     presence_definition = 'O';
 1615:                 }
 1616:             }
 1617:         }
 1618: 
 1619:         /*
 1620:          * Dans le cas où le programme est appelé avec l'option -d,
 1621:          * on ne récupère par les signaux de violation d'accès. On
 1622:          * tente simplement la récupération des dépassements de pile.
 1623:          */
 1624: 
 1625:         if (debug == d_faux)
 1626:         {
 1627: 
 1628: #   ifdef HAVE_SIGSEGV_RECOVERY
 1629:             if (sigsegv_install_handler(interruption_violation_access) != 0)
 1630:             {
 1631:                 erreur = d_es_signal;
 1632: 
 1633:                 if ((*s_etat_processus).langue == 'F')
 1634:                 {
 1635:                     printf("+++Système : Initialisation de la pile alternative "
 1636:                             "impossible\n");
 1637:                 }
 1638:                 else
 1639:                 {
 1640:                     printf("+++System : Initialization of alternate "
 1641:                             "stack failed\n");
 1642:                 }
 1643: 
 1644:                 return(EXIT_FAILURE);
 1645:             }
 1646: #   else
 1647:             action.sa_handler = interruption3;
 1648:             action.sa_flags = 0;
 1649: 
 1650:             if (sigaction(SIGSEGV, &action, NULL) != 0)
 1651:             {
 1652:                 if ((*s_etat_processus).langue == 'F')
 1653:                 {
 1654:                     printf("+++Système : Initialisation des signaux POSIX "
 1655:                             "impossible\n");
 1656:                 }
 1657:                 else
 1658:                 {
 1659:                     printf("+++System : Initialization of POSIX signals "
 1660:                             "failed\n");
 1661:                 }
 1662: 
 1663:                 return(EXIT_FAILURE);
 1664:             }
 1665: 
 1666:             signal_test = SIGTEST;
 1667:             kill(getpid(), SIGSEGV);
 1668: 
 1669:             attente.tv_sec = 0;
 1670:             attente.tv_nsec = 1000000;
 1671: 
 1672:             for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
 1673:             {
 1674:                 nanosleep(&attente, NULL);
 1675:             }
 1676: 
 1677:             if (signal_test != SIGSEGV)
 1678:             {
 1679:                 erreur = d_es_signal;
 1680: 
 1681:                 if ((*s_etat_processus).langue == 'F')
 1682:                 {
 1683:                     printf("+++Système : Initialisation des signaux POSIX "
 1684:                             "impossible\n");
 1685:                 }
 1686:                 else
 1687:                 {
 1688:                     printf("+++System : Initialization of POSIX signals "
 1689:                             "failed\n");
 1690:                 }
 1691: 
 1692:                 return(EXIT_FAILURE);
 1693:             }
 1694: #   endif
 1695: 
 1696:             action.sa_handler = interruption3;
 1697:             action.sa_flags = 0;
 1698: 
 1699:             if (sigaction(SIGBUS, &action, NULL) != 0)
 1700:             {
 1701:                 if ((*s_etat_processus).langue == 'F')
 1702:                 {
 1703:                     printf("+++Système : Initialisation des signaux POSIX "
 1704:                             "impossible\n");
 1705:                 }
 1706:                 else
 1707:                 {
 1708:                     printf("+++System : Initialization of POSIX signals "
 1709:                             "failed\n");
 1710:                 }
 1711: 
 1712:                 return(EXIT_FAILURE);
 1713:             }
 1714: 
 1715:             signal_test = SIGTEST;
 1716:             kill(getpid(), SIGBUS);
 1717: 
 1718:             attente.tv_sec = 0;
 1719:             attente.tv_nsec = 1000000;
 1720: 
 1721:             for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
 1722:             {
 1723:                 nanosleep(&attente, NULL);
 1724:             }
 1725: 
 1726:             if (signal_test != SIGBUS)
 1727:             {
 1728:                 erreur = d_es_signal;
 1729: 
 1730:                 if ((*s_etat_processus).langue == 'F')
 1731:                 {
 1732:                     printf("+++Système : Initialisation des signaux POSIX "
 1733:                             "impossible\n");
 1734:                 }
 1735:                 else
 1736:                 {
 1737:                     printf("+++System : Initialization of POSIX signals "
 1738:                             "failed\n");
 1739:                 }
 1740: 
 1741:                 return(EXIT_FAILURE);
 1742:             }
 1743: 
 1744:         }
 1745: 
 1746:         if (option_n == d_vrai)
 1747:         {
 1748:             action.sa_handler = interruption4;
 1749:             action.sa_flags = 0;
 1750: 
 1751:             if (sigaction(SIGHUP, &action, NULL) != 0)
 1752:             {
 1753:                 if ((*s_etat_processus).langue == 'F')
 1754:                 {
 1755:                     printf("+++Système : Initialisation des signaux POSIX "
 1756:                             "impossible\n");
 1757:                 }
 1758:                 else
 1759:                 {
 1760:                     printf("+++System : Initialization of POSIX signals "
 1761:                             "failed\n");
 1762:                 }
 1763: 
 1764:                 return(EXIT_FAILURE);
 1765:             }
 1766:         }
 1767: 
 1768:         if (mode_interactif == d_vrai)
 1769:         {
 1770:             printf("\n");
 1771: 
 1772:             if ((*s_etat_processus).langue == 'F')
 1773:             {
 1774:                 printf("+++Ce logiciel est un logiciel libre"
 1775:                         " sans aucune garantie de "
 1776:                         "fonctionnement.\n");
 1777:                 printf("+++Pour plus de détails, utilisez la "
 1778:                         "commande 'warranty'.\n");
 1779:             }
 1780:             else
 1781:             {
 1782:                 printf("+++This is a free software with "
 1783:                         "absolutely no warranty.\n");
 1784:                 printf("+++For details, type 'warranty'.\n");
 1785:             }
 1786: 
 1787:             printf("\n");
 1788: 
 1789:             traitement_fichier_temporaire = 'Y';
 1790: 
 1791:             if ((nom_fichier_temporaire =
 1792:                     creation_nom_fichier(s_etat_processus, (*s_etat_processus)
 1793:                     .chemin_fichiers_temporaires)) == NULL)
 1794:             {
 1795:                 if ((*s_etat_processus).langue == 'F')
 1796:                 {
 1797:                     printf("+++Système : Fichier indisponible\n");
 1798:                 }
 1799:                 else
 1800:                 {
 1801:                     printf("+++System : File unavailable\n");
 1802:                 }
 1803: 
 1804:                 return(EXIT_FAILURE);
 1805:             }
 1806: 
 1807:             if ((f_source = fopen(nom_fichier_temporaire, "w"))
 1808:                     == NULL)
 1809:             {
 1810:                 if ((*s_etat_processus).langue == 'F')
 1811:                 {
 1812:                     printf("+++Système : Fichier introuvable\n");
 1813:                 }
 1814:                 else
 1815:                 {
 1816:                     printf("+++System : File not found\n");
 1817:                 }
 1818: 
 1819:                 return(EXIT_FAILURE);
 1820:             }
 1821: 
 1822:             if (fprintf(f_source, "MODE_INTERACTIF\n") < 0)
 1823:             {
 1824:                 if ((*s_etat_processus).langue == 'F')
 1825:                 {
 1826:                     printf("+++Système : Erreur d'écriture dans un fichier\n");
 1827:                 }
 1828:                 else
 1829:                 {
 1830:                     printf("+++System : Cannot write in file\n");
 1831:                 }
 1832: 
 1833:                 return(EXIT_FAILURE);
 1834:             }
 1835: 
 1836:             if (fprintf(f_source,
 1837:                     "<< DO HALT UNTIL FALSE END >>\n") < 0)
 1838:             {
 1839:                 if ((*s_etat_processus).langue == 'F')
 1840:                 {
 1841:                     printf("+++Système : Erreur d'écriture dans un fichier\n");
 1842:                 }
 1843:                 else
 1844:                 {
 1845:                     printf("+++System : Cannot write in file\n");
 1846:                 }
 1847: 
 1848:                 return(EXIT_FAILURE);
 1849:             }
 1850: 
 1851:             if (fclose(f_source) != 0)
 1852:             {
 1853:                 if ((*s_etat_processus).langue == 'F')
 1854:                 {
 1855:                     printf("+++Système : Fichier indisponible\n");
 1856:                 }
 1857:                 else
 1858:                 {
 1859:                     printf("+++System : File unavailable\n");
 1860:                 }
 1861: 
 1862:                 return(EXIT_FAILURE);
 1863:             }
 1864: 
 1865:             (*s_etat_processus).lancement_interactif = d_vrai;
 1866:             (*s_etat_processus).nom_fichier_source =
 1867:                     nom_fichier_temporaire;
 1868: 
 1869:             presence_definition = 'O';
 1870:         }
 1871:         else
 1872:         {
 1873:             nom_fichier_temporaire = NULL;
 1874:         }
 1875: 
 1876:         if ((*s_etat_processus).nom_fichier_source == NULL)
 1877:         {
 1878:             erreur_fichier = d_erreur;
 1879:         }
 1880:         else
 1881:         {
 1882:             erreur_fichier = caracteristiques_fichier(s_etat_processus,
 1883:                     (*s_etat_processus).nom_fichier_source,
 1884:                     &existence, &ouverture, &unite_fichier);
 1885:         }
 1886: 
 1887:         if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
 1888:                 (option_S == d_faux))
 1889:         {
 1890:             if (presence_definition == 'O')
 1891:             {
 1892:                 if ((*s_etat_processus).langue == 'F')
 1893:                 {
 1894:                     printf("+++Erreur : Fichier %s inexistant\n",
 1895:                             (*s_etat_processus).nom_fichier_source);
 1896:                 }
 1897:                 else
 1898:                 {
 1899:                     printf("+++Error : File %s not found\n",
 1900:                             (*s_etat_processus).nom_fichier_source);
 1901:                 }
 1902: 
 1903:                 erreur = d_erreur;
 1904:             }
 1905:             else
 1906:             {
 1907:                 if ((*s_etat_processus).langue == 'F')
 1908:                 {
 1909:                     printf("+++Erreur : Absence de définition à exécuter\n");
 1910:                 }
 1911:                 else
 1912:                 {
 1913:                     printf("+++Error : Any executable definition\n");
 1914:                 }
 1915:             }
 1916: 
 1917:             return(EXIT_FAILURE);
 1918:         }
 1919: 
 1920:         if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
 1921:         {
 1922:             if ((*s_etat_processus).langue == 'F')
 1923:             {
 1924:                 printf("+++Système : Chemin des fichiers temporaires nul\n");
 1925:             }
 1926:             else
 1927:             {
 1928:                 printf("+++System : Null temporary files path\n");
 1929:             }
 1930: 
 1931:             return(EXIT_FAILURE);
 1932:         }
 1933: 
 1934:         if ((*s_etat_processus).debug == d_vrai)
 1935:         {
 1936:             if ((*s_etat_processus).langue == 'F')
 1937:             {
 1938:                 printf("[%d] Chemin des fichiers temporaires %s\n\n",
 1939:                         (int) getpid(),
 1940:                         (*s_etat_processus).chemin_fichiers_temporaires);
 1941:             }
 1942:             else
 1943:             {
 1944:                 printf("[%d] Temporary files path %s\n\n",
 1945:                         (int) getpid(),
 1946:                         (*s_etat_processus).chemin_fichiers_temporaires);
 1947:             }
 1948:         }
 1949: 
 1950:         if ((erreur == d_absence_erreur) && (presence_definition == 'O'))
 1951:         {
 1952:             (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
 1953:             (*s_etat_processus).niveau_profilage = option_P;
 1954:             (*s_etat_processus).pile_profilage = NULL;
 1955:             (*s_etat_processus).pile_profilage_fonctions = NULL;
 1956:             gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
 1957: 
 1958:             (*s_etat_processus).liste_mutexes = NULL;
 1959:             (*s_etat_processus).sections_critiques = 0;
 1960: 
 1961:             (*s_etat_processus).test_instruction = 'N';
 1962:             (*s_etat_processus).nombre_arguments = 0;
 1963:             (*s_etat_processus).affichage_arguments = 'N';
 1964:             (*s_etat_processus).autorisation_conversion_chaine = 'Y';
 1965:             (*s_etat_processus).autorisation_evaluation_nom = 'Y';
 1966: 
 1967:             if (mode_interactif == d_vrai)
 1968:             {
 1969:                 (*s_etat_processus).autorisation_nom_implicite = 'Y';
 1970:             }
 1971:             else
 1972:             {
 1973:                 (*s_etat_processus).autorisation_nom_implicite = 'N';
 1974:             }
 1975: 
 1976:             (*s_etat_processus).autorisation_empilement_programme = 'N';
 1977:             (*s_etat_processus).requete_arret = 'N';
 1978:             (*s_etat_processus).evaluation_forcee = 'N';
 1979:             (*s_etat_processus).recherche_type = 'N';
 1980: 
 1981:             (*s_etat_processus).constante_symbolique = 'N';
 1982:             (*s_etat_processus).traitement_symbolique = 'N';
 1983: 
 1984:             (*s_etat_processus).expression_courante = NULL;
 1985:             (*s_etat_processus).objet_courant = NULL;
 1986:             (*s_etat_processus).evaluation_expression_compilee = 'N';
 1987: 
 1988:             (*s_etat_processus).l_base_pile = NULL;
 1989:             (*s_etat_processus).l_base_pile_last = NULL;
 1990: 
 1991:             (*s_etat_processus).s_arbre_variables = NULL;
 1992:             (*s_etat_processus).l_liste_variables_par_niveau = NULL;
 1993:             (*s_etat_processus).gel_liste_variables = d_faux;
 1994:             (*s_etat_processus).pointeur_variable_courante = NULL;
 1995:             (*s_etat_processus).pointeur_variable_statique_courante = NULL;
 1996:             (*s_etat_processus).l_liste_variables_statiques = NULL;
 1997:             (*s_etat_processus).niveau_courant = 0;
 1998:             (*s_etat_processus).niveau_initial = 0;
 1999:             (*s_etat_processus).creation_variables_statiques = d_faux;
 2000:             (*s_etat_processus).creation_variables_partagees = d_faux;
 2001: 
 2002:             (*s_etat_processus).s_bibliotheques = NULL;
 2003:             (*s_etat_processus).s_instructions_externes = NULL;
 2004:             (*s_etat_processus).nombre_instructions_externes = 0;
 2005: 
 2006:             (*s_etat_processus).systeme_axes = 0;
 2007: 
 2008:             (*s_etat_processus).x_min = -10.;
 2009:             (*s_etat_processus).x_max = 10.;
 2010:             (*s_etat_processus).y_min = -10.;
 2011:             (*s_etat_processus).y_max = 10.;
 2012:             (*s_etat_processus).z_min = -10.;
 2013:             (*s_etat_processus).z_max = 10.;
 2014: 
 2015:             (*s_etat_processus).x2_min = -10.;
 2016:             (*s_etat_processus).x2_max = 10.;
 2017:             (*s_etat_processus).y2_min = -10.;
 2018:             (*s_etat_processus).y2_max = 10.;
 2019:             (*s_etat_processus).z2_min = -10.;
 2020:             (*s_etat_processus).z2_max = 10.;
 2021: 
 2022:             (*s_etat_processus).resolution = .01;
 2023: 
 2024:             (*s_etat_processus).souris_active = d_faux;
 2025: 
 2026:             (*s_etat_processus).echelle_automatique_x = d_faux;
 2027:             (*s_etat_processus).echelle_automatique_y = d_faux;
 2028:             (*s_etat_processus).echelle_automatique_z = d_faux;
 2029: 
 2030:             (*s_etat_processus).echelle_automatique_x2 = d_faux;
 2031:             (*s_etat_processus).echelle_automatique_y2 = d_faux;
 2032:             (*s_etat_processus).echelle_automatique_z2 = d_faux;
 2033: 
 2034:             (*s_etat_processus).echelle_log_x = d_faux;
 2035:             (*s_etat_processus).echelle_log_y = d_faux;
 2036:             (*s_etat_processus).echelle_log_z = d_faux;
 2037: 
 2038:             (*s_etat_processus).echelle_log_x2 = d_faux;
 2039:             (*s_etat_processus).echelle_log_y2 = d_faux;
 2040:             (*s_etat_processus).echelle_log_z2 = d_faux;
 2041: 
 2042:             (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
 2043:             (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
 2044:             (*s_etat_processus).echelle_3D = 1;
 2045: 
 2046:             strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
 2047:             strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
 2048:             (*s_etat_processus).fichiers_graphiques = NULL;
 2049:             (*s_etat_processus).nom_fichier_impression = NULL;
 2050:             strcpy((*s_etat_processus).format_papier, "a4paper");
 2051:             (*s_etat_processus).entree_standard = NULL;
 2052:             (*s_etat_processus).s_marques = NULL;
 2053:             (*s_etat_processus).requete_nouveau_plan = d_vrai;
 2054:             (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
 2055: 
 2056:             (*s_etat_processus).l_base_pile = NULL;
 2057:             (*s_etat_processus).hauteur_pile_operationnelle = 0;
 2058:             (*s_etat_processus).l_base_pile_contextes = NULL;
 2059:             (*s_etat_processus).l_base_pile_taille_contextes = NULL;
 2060: 
 2061:             (*s_etat_processus).position_courante = 0;
 2062: 
 2063:             (*s_etat_processus).l_base_pile_systeme = NULL;
 2064:             (*s_etat_processus).hauteur_pile_systeme = 0;
 2065: 
 2066:             (*s_etat_processus).l_base_pile_processus = NULL;
 2067:             (*s_etat_processus).presence_pipes = d_faux;
 2068:             (*s_etat_processus).pipe_donnees = 0;
 2069:             (*s_etat_processus).pipe_acquittement = 0;
 2070:             (*s_etat_processus).pipe_injections = 0;
 2071:             (*s_etat_processus).pipe_nombre_injections = 0;
 2072:             (*s_etat_processus).nombre_objets_injectes = 0;
 2073:             (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
 2074:             (*s_etat_processus).pourcentage_maximal_cpu = 100;
 2075:             (*s_etat_processus).temps_maximal_cpu = 0;
 2076:             (*s_etat_processus).thread_fusible = 0;
 2077:             (*s_etat_processus).presence_fusible = d_faux;
 2078: 
 2079:             (*s_etat_processus).niveau_recursivite = 0;
 2080:             (*s_etat_processus).generateur_aleatoire = NULL;
 2081:             (*s_etat_processus).type_generateur_aleatoire = NULL;
 2082: 
 2083:             (*s_etat_processus).colonne_statistique_1 = 1; 
 2084:             (*s_etat_processus).colonne_statistique_2 = 2; 
 2085: 
 2086:             (*s_etat_processus).debug_programme = d_faux;
 2087:             (*s_etat_processus).execution_pas_suivant = d_faux;
 2088:             (*s_etat_processus).traitement_instruction_halt = d_faux;
 2089: 
 2090:             (*s_etat_processus).derniere_exception = d_ep;
 2091:             (*s_etat_processus).derniere_erreur_systeme = d_es;
 2092:             (*s_etat_processus).derniere_erreur_execution = d_ex;
 2093:             (*s_etat_processus).derniere_erreur_evaluation = d_ex;
 2094:             (*s_etat_processus).derniere_erreur_fonction_externe = 0;
 2095: 
 2096:             (*s_etat_processus).erreur_processus_fils = d_faux;
 2097:             (*s_etat_processus).erreur_systeme_processus_fils = d_es;
 2098:             (*s_etat_processus).erreur_execution_processus_fils = d_ex;
 2099:             (*s_etat_processus).pid_erreur_processus_fils = 0;
 2100:             (*s_etat_processus).exception_processus_fils = d_ep;
 2101:             (*s_etat_processus).core = core;
 2102:             (*s_etat_processus).invalidation_message_erreur = d_faux;
 2103:             (*s_etat_processus).s_objet_errone = NULL;
 2104:             (*s_etat_processus).s_objet_erreur = NULL;
 2105: 
 2106:             (*s_etat_processus).retour_routine_evaluation = 'N';
 2107: 
 2108:             (*s_etat_processus).traitement_interruption = 'N';
 2109:             (*s_etat_processus).traitement_interruptible = 'Y';
 2110:             (*s_etat_processus).nombre_interruptions_en_queue = 0;
 2111:             (*s_etat_processus).nombre_interruptions_non_affectees = 0;
 2112: 
 2113:             for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2114:             {
 2115:                 (*s_etat_processus).masque_interruptions[i] = 'N';
 2116:                 (*s_etat_processus).queue_interruptions[i] = 0;
 2117:                 (*s_etat_processus).corps_interruptions[i] = NULL;
 2118:                 (*s_etat_processus).pile_origine_interruptions[i] = NULL;
 2119:             }
 2120: 
 2121:             (*s_etat_processus).at_exit = NULL;
 2122:             (*s_etat_processus).at_poke = NULL;
 2123:             (*s_etat_processus).traitement_at_poke = 'N';
 2124: 
 2125:             (*s_etat_processus).pointeurs_caracteres = NULL;
 2126:             (*s_etat_processus).arbre_instructions = NULL;
 2127: 
 2128:             (*s_etat_processus).tid_processus_pere = pthread_self();
 2129:             (*s_etat_processus).tid = pthread_self();
 2130:             (*s_etat_processus).pid_processus_pere = getpid();
 2131:             (*s_etat_processus).processus_detache = d_vrai;
 2132:             (*s_etat_processus).var_volatile_processus_pere = -1;
 2133:             (*s_etat_processus).var_volatile_processus_racine = -1;
 2134:             (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
 2135:             (*s_etat_processus).var_volatile_alarme = 0;
 2136:             (*s_etat_processus).var_volatile_requete_arret = 0;
 2137:             (*s_etat_processus).var_volatile_requete_arret2 = 0;
 2138:             (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
 2139:             (*s_etat_processus).var_volatile_traitement_sigint = 0;
 2140:             (*s_etat_processus).var_volatile_recursivite = 0;
 2141:             (*s_etat_processus).var_volatile_exception_gsl = 0;
 2142:             (*s_etat_processus).arret_depuis_abort = 0;
 2143:             (*s_etat_processus).pointeur_signal_lecture = 0;
 2144:             (*s_etat_processus).pointeur_signal_ecriture = 0;
 2145: 
 2146:             initialisation_allocateur(s_etat_processus);
 2147:             initialisation_drapeaux(s_etat_processus);
 2148:             initialisation_variables(s_etat_processus);
 2149:             initialisation_instructions(s_etat_processus);
 2150: 
 2151:             if ((*s_etat_processus).erreur_systeme != d_es)
 2152:             {
 2153:                 if ((*s_etat_processus).langue == 'F')
 2154:                 {
 2155:                     printf("+++Système : Mémoire insuffisante\n");
 2156:                 }
 2157:                 else
 2158:                 {
 2159:                     printf("+++System : Not enough memory\n");
 2160:                 }
 2161: 
 2162:                 return(EXIT_FAILURE);
 2163:             }
 2164: 
 2165:             if (((*s_etat_processus).instruction_derniere_erreur =
 2166:                     malloc(sizeof(unsigned char))) == NULL)
 2167:             {
 2168:                 erreur = d_es_allocation_memoire;
 2169: 
 2170:                 if ((*s_etat_processus).langue == 'F')
 2171:                 {
 2172:                     printf("+++Système : Mémoire insuffisante\n");
 2173:                 }
 2174:                 else
 2175:                 {
 2176:                     printf("+++System : Not enough memory\n");
 2177:                 }
 2178: 
 2179:                 return(EXIT_FAILURE);
 2180:             }
 2181: 
 2182:             strcpy((*s_etat_processus).instruction_derniere_erreur, "");
 2183:             (*s_etat_processus).niveau_derniere_erreur = 0;
 2184: 
 2185:             if (traitement_fichier_temporaire == 'Y')
 2186:             {
 2187:                 (*s_etat_processus).mode_interactif = 'Y';
 2188:             }
 2189:             else
 2190:             {
 2191:                 (*s_etat_processus).mode_interactif = 'N';
 2192:             }
 2193: 
 2194:             if (((*s_etat_processus).instruction_courante = (unsigned char *)
 2195:                     malloc(sizeof(unsigned char))) == NULL)
 2196:             {
 2197:                 erreur = d_es_allocation_memoire;
 2198: 
 2199:                 if ((*s_etat_processus).langue == 'F')
 2200:                 {
 2201:                     printf("+++Système : Mémoire insuffisante\n");
 2202:                 }
 2203:                 else
 2204:                 {
 2205:                     printf("+++System : Not enough memory\n");
 2206:                 }
 2207: 
 2208:                 return(EXIT_FAILURE);
 2209:             }
 2210: 
 2211:             (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
 2212: 
 2213:             empilement_pile_systeme(s_etat_processus);
 2214: 
 2215:             free((*s_etat_processus).instruction_courante);
 2216: 
 2217:             if ((*s_etat_processus).erreur_systeme != d_es)
 2218:             {
 2219:                 erreur = d_es_allocation_memoire;
 2220:             }
 2221:             else
 2222:             {
 2223:                 (*((*s_etat_processus).l_base_pile_systeme))
 2224:                         .retour_definition = 'Y';
 2225: 
 2226:                 (*s_etat_processus).indep = allocation(s_etat_processus, NON);
 2227:                 (*s_etat_processus).depend = allocation(s_etat_processus, NON);
 2228:                 (*s_etat_processus).parametres_courbes_de_niveau =
 2229:                         allocation(s_etat_processus, NON);
 2230: 
 2231:                 if (((*s_etat_processus).indep != NULL) &&
 2232:                         ((*s_etat_processus).depend != NULL) &&
 2233:                         ((*s_etat_processus).parametres_courbes_de_niveau
 2234:                         != NULL))
 2235:                 {
 2236:                     (*((*s_etat_processus).indep)).type = NOM;
 2237:                     (*((*s_etat_processus).depend)).type = NOM;
 2238:                     (*((*s_etat_processus).
 2239:                             parametres_courbes_de_niveau)).type = LST;
 2240: 
 2241:                     initialisation_objet((*s_etat_processus).indep);
 2242:                     initialisation_objet((*s_etat_processus).depend);
 2243:                     initialisation_objet((*s_etat_processus)
 2244:                             .parametres_courbes_de_niveau);
 2245: 
 2246:                     (*((*s_etat_processus).indep)).objet = (struct_nom *)
 2247:                             malloc(sizeof(struct_nom));
 2248:                     (*((*s_etat_processus).depend)).objet = (struct_nom *)
 2249:                             malloc(sizeof(struct_nom));
 2250:                     (*((*s_etat_processus).parametres_courbes_de_niveau))
 2251:                             .objet = (struct_liste_chainee *)
 2252:                             malloc(sizeof(struct_liste_chainee));
 2253: 
 2254:                     if (((*((*s_etat_processus).depend)).objet == NULL) ||
 2255:                             ((*((*s_etat_processus).depend)).objet == NULL) ||
 2256:                             ((*((*s_etat_processus).
 2257:                             parametres_courbes_de_niveau)).objet == NULL))
 2258:                     {
 2259:                         erreur = d_es_allocation_memoire;
 2260:                         
 2261:                         if ((*s_etat_processus).langue == 'F')
 2262:                         {
 2263:                             printf("+++Système : Mémoire insuffisante\n");
 2264:                         }
 2265:                         else
 2266:                         {
 2267:                             printf("+++System : Not enough memory\n");
 2268:                         }
 2269: 
 2270:                         return(EXIT_FAILURE);
 2271:                     }
 2272: 
 2273:                     (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
 2274:                             .nom = malloc(2 * sizeof(unsigned char));
 2275:                     (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
 2276:                             .nom = malloc(2 * sizeof(unsigned char));
 2277: 
 2278:                     if (((*((struct_nom *) (*((*s_etat_processus).indep))
 2279:                             .objet)).nom == NULL) || ((*((struct_nom *)
 2280:                             (*((*s_etat_processus).depend)).objet)).nom ==
 2281:                             NULL))
 2282:                     {
 2283:                         erreur = d_es_allocation_memoire;
 2284: 
 2285:                         if ((*s_etat_processus).langue == 'F')
 2286:                         {
 2287:                             printf("+++Système : Mémoire insuffisante\n");
 2288:                         }
 2289:                         else
 2290:                         {
 2291:                             printf("+++System : Not enough memory\n");
 2292:                         }
 2293: 
 2294:                         return(EXIT_FAILURE);
 2295:                     }
 2296: 
 2297:                     strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
 2298:                             .objet)).nom, "X");
 2299:                     strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
 2300:                             .objet)).nom, "Y");
 2301: 
 2302:                     (*((struct_nom *) (*((*s_etat_processus).indep))
 2303:                             .objet)).symbole = d_vrai;
 2304:                     (*((struct_nom *) (*((*s_etat_processus).depend))
 2305:                             .objet)).symbole = d_vrai;
 2306: 
 2307:                     (*((struct_liste_chainee *) (*((*s_etat_processus)
 2308:                             .parametres_courbes_de_niveau)).objet)).suivant
 2309:                             = NULL;
 2310: 
 2311:                     (*((struct_liste_chainee *) (*((*s_etat_processus)
 2312:                             .parametres_courbes_de_niveau)).objet)).donnee
 2313:                             = malloc(sizeof(struct_objet));
 2314: 
 2315:                     (*s_etat_processus).legende =
 2316:                             malloc(sizeof(unsigned char));
 2317:                     (*s_etat_processus).label_x =
 2318:                             malloc(sizeof(unsigned char));
 2319:                     (*s_etat_processus).label_y =
 2320:                             malloc(sizeof(unsigned char));
 2321:                     (*s_etat_processus).label_z =
 2322:                             malloc(sizeof(unsigned char));
 2323:                     (*s_etat_processus).titre =
 2324:                             malloc(sizeof(unsigned char));
 2325: 
 2326:                     if (((*s_etat_processus).label_x == NULL) ||
 2327:                             ((*s_etat_processus).label_y == NULL) ||
 2328:                             ((*s_etat_processus).label_z == NULL) ||
 2329:                             ((*s_etat_processus).titre == NULL) ||
 2330:                             ((*s_etat_processus).legende == NULL) ||
 2331:                             ((*((struct_liste_chainee *) (*((*s_etat_processus)
 2332:                             .parametres_courbes_de_niveau)).objet)).donnee
 2333:                             == NULL))
 2334:                     {
 2335:                         erreur = d_es_allocation_memoire;
 2336: 
 2337:                         if ((*s_etat_processus).langue == 'F')
 2338:                         {
 2339:                             printf("+++Système : Mémoire insuffisante\n");
 2340:                         }
 2341:                         else
 2342:                         {
 2343:                             printf("+++System : Not enough memory\n");
 2344:                         }
 2345: 
 2346:                         return(EXIT_FAILURE);
 2347:                     }
 2348: 
 2349:                     (*(*((struct_liste_chainee *) (*((*s_etat_processus)
 2350:                             .parametres_courbes_de_niveau)).objet)).donnee)
 2351:                             .type = CHN;
 2352: 
 2353:                     initialisation_objet((*((struct_liste_chainee *)
 2354:                             (*((*s_etat_processus)
 2355:                             .parametres_courbes_de_niveau))
 2356:                             .objet)).donnee);
 2357: 
 2358:                     if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
 2359:                             .parametres_courbes_de_niveau)).objet)).donnee)
 2360:                             .objet = malloc(10 * sizeof(unsigned char)))
 2361:                             == NULL)
 2362:                     {
 2363:                         erreur = d_es_allocation_memoire;
 2364: 
 2365:                         if ((*s_etat_processus).langue == 'F')
 2366:                         {
 2367:                             printf("+++Système : Mémoire insuffisante\n");
 2368:                         }
 2369:                         else
 2370:                         {
 2371:                             printf("+++System : Not enough memory\n");
 2372:                         }
 2373: 
 2374:                         return(EXIT_FAILURE);
 2375:                     }
 2376: 
 2377:                     strcpy((unsigned char *) (*(*((struct_liste_chainee *)
 2378:                             (*((*s_etat_processus)
 2379:                             .parametres_courbes_de_niveau))
 2380:                             .objet)).donnee).objet, "AUTOMATIC");
 2381: 
 2382:                     (*s_etat_processus).label_x[0] = d_code_fin_chaine;
 2383:                     (*s_etat_processus).label_y[0] = d_code_fin_chaine;
 2384:                     (*s_etat_processus).label_z[0] = d_code_fin_chaine;
 2385:                     (*s_etat_processus).titre[0] = d_code_fin_chaine;
 2386:                     (*s_etat_processus).legende[0] = d_code_fin_chaine;
 2387: 
 2388:                     (*s_etat_processus).nom_fichier_gnuplot = NULL;
 2389:                     (*s_etat_processus).type_fichier_gnuplot = NULL;
 2390: 
 2391:                     (*s_etat_processus).x_tics = 0;
 2392:                     (*s_etat_processus).y_tics = 0;
 2393:                     (*s_etat_processus).z_tics = 0;
 2394: 
 2395:                     (*s_etat_processus).x_lines = d_vrai;
 2396:                     (*s_etat_processus).y_lines = d_vrai;
 2397:                     (*s_etat_processus).z_lines = d_vrai;
 2398: 
 2399:                     (*s_etat_processus).mx_tics = -1;
 2400:                     (*s_etat_processus).my_tics = -1;
 2401:                     (*s_etat_processus).mz_tics = -1;
 2402: 
 2403:                     (*s_etat_processus).mx_lines = d_faux;
 2404:                     (*s_etat_processus).my_lines = d_faux;
 2405:                     (*s_etat_processus).mz_lines = d_faux;
 2406: 
 2407:                     (*s_etat_processus).x2_tics = -1;
 2408:                     (*s_etat_processus).y2_tics = -1;
 2409:                     (*s_etat_processus).z2_tics = -1;
 2410: 
 2411:                     (*s_etat_processus).x2_lines = d_faux;
 2412:                     (*s_etat_processus).y2_lines = d_faux;
 2413:                     (*s_etat_processus).z2_lines = d_faux;
 2414: 
 2415:                     (*s_etat_processus).mx2_tics = -1;
 2416:                     (*s_etat_processus).my2_tics = -1;
 2417:                     (*s_etat_processus).mz2_tics = -1;
 2418: 
 2419:                     (*s_etat_processus).mx2_lines = d_faux;
 2420:                     (*s_etat_processus).my2_lines = d_faux;
 2421:                     (*s_etat_processus).mz2_lines = d_faux;
 2422: 
 2423:                     if ((*s_etat_processus).erreur_systeme != d_es)
 2424:                     {
 2425:                         if ((*s_etat_processus).langue == 'F')
 2426:                         {
 2427:                             printf("+++Système : Mémoire insuffisante\n");
 2428:                         }
 2429:                         else
 2430:                         {
 2431:                             printf("+++System : Not enough memory\n");
 2432:                         }
 2433: 
 2434:                         return(EXIT_FAILURE);
 2435:                     }
 2436: 
 2437:                     (*s_etat_processus).mode_evaluation_expression = 'N';
 2438:                     (*s_etat_processus).mode_execution_programme = 'Y';
 2439: 
 2440:                     if ((*s_etat_processus).definitions_chainees == NULL)
 2441:                     {
 2442:                         if ((erreur = chainage(s_etat_processus)) !=
 2443:                                 d_absence_erreur)
 2444:                         {
 2445:                             if ((*s_etat_processus).langue == 'F')
 2446:                             {
 2447:                                 printf("+++Fatal :"
 2448:                                         " Chaînage des définitions"
 2449:                                         " impossible\n");
 2450:                             }
 2451:                             else
 2452:                             {
 2453:                                 printf("+++Fatal : Error in "
 2454:                                         "compilation\n");
 2455:                             }
 2456: 
 2457:                             if (traitement_fichier_temporaire == 'Y')
 2458:                             {
 2459:                                 if (destruction_fichier(
 2460:                                         nom_fichier_temporaire)
 2461:                                         == d_erreur)
 2462:                                 {
 2463:                                     return(EXIT_FAILURE);
 2464:                                 }
 2465: 
 2466:                                 free(nom_fichier_temporaire);
 2467:                             }
 2468: 
 2469:                             return(EXIT_FAILURE);
 2470:                         }
 2471:                     }
 2472: 
 2473:                     if ((erreur = compilation(s_etat_processus)) !=
 2474:                             d_absence_erreur)
 2475:                     {
 2476:                         if (traitement_fichier_temporaire == 'Y')
 2477:                         {
 2478:                             if (destruction_fichier(nom_fichier_temporaire)
 2479:                                     == d_erreur)
 2480:                             {
 2481:                                 return(EXIT_FAILURE);
 2482:                             }
 2483: 
 2484:                             free(nom_fichier_temporaire);
 2485:                         }
 2486: 
 2487:                         printf("%s [%d]\n", message =
 2488:                                 messages(s_etat_processus), (int) getpid());
 2489:                         free(message);
 2490: 
 2491:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 2492:                         {
 2493:                             printf("%s", ds_beep);
 2494:                         }
 2495: 
 2496:                         if ((*s_etat_processus).core == d_vrai)
 2497:                         {
 2498:                             printf("\n");
 2499:                             
 2500:                             if ((*s_etat_processus).langue == 'F')
 2501:                             {
 2502:                                 printf("+++Information : Génération du fichier "
 2503:                                         "rpl-core [%d]\n", (int) getpid());
 2504:                             }
 2505:                             else
 2506:                             {
 2507:                                 printf("+++Information : Writing rpl-core "
 2508:                                         "file [%d]\n", (int) getpid());
 2509:                             }
 2510: 
 2511:                             rplcore(s_etat_processus);
 2512: 
 2513:                             if ((*s_etat_processus).langue == 'F')
 2514:                             {
 2515:                                 printf("+++Information : Processus tracé "
 2516:                                         "[%d]\n", (int) getpid());
 2517:                             }
 2518:                             else
 2519:                             {
 2520:                                 printf("+++Information : Done [%d]\n",
 2521:                                         (int) getpid());
 2522:                             }
 2523: 
 2524:                             printf("\n");
 2525:                         }
 2526: 
 2527:                         return(EXIT_FAILURE);
 2528:                     }
 2529: 
 2530:                     (*s_etat_processus).position_courante = 0;
 2531:                     (*s_etat_processus).traitement_cycle_exit = 'N';
 2532: 
 2533:                     if ((*s_etat_processus).s_arbre_variables == NULL)
 2534:                     {
 2535:                         if ((*s_etat_processus).langue == 'F')
 2536:                         {
 2537:                             printf("+++Fatal : Aucun point d'entrée\n");
 2538:                         }
 2539:                         else
 2540:                         {
 2541:                             printf("+++Fatal : Any entry point\n");
 2542:                         }
 2543: 
 2544:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 2545:                         {
 2546:                             printf("%s", ds_beep);
 2547:                         }
 2548: 
 2549:                         return(EXIT_FAILURE);
 2550:                     }
 2551: 
 2552:                     if (recherche_instruction_suivante(s_etat_processus)
 2553:                             == d_erreur)
 2554:                     {
 2555:                         if ((*s_etat_processus).langue == 'F')
 2556:                         {
 2557:                             printf("+++Fatal : Aucun point d'entrée\n");
 2558:                         }
 2559:                         else
 2560:                         {
 2561:                             printf("+++Fatal : Any entry point\n");
 2562:                         }
 2563: 
 2564:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 2565:                         {
 2566:                             printf("%s", ds_beep);
 2567:                         }
 2568: 
 2569:                         return(EXIT_FAILURE);
 2570:                     }
 2571: 
 2572:                     if (recherche_variable(s_etat_processus,
 2573:                             (*s_etat_processus)
 2574:                             .instruction_courante) == d_faux)
 2575:                     {
 2576:                         if ((*s_etat_processus).langue == 'F')
 2577:                         {
 2578:                             printf("+++Fatal : Aucun point d'entrée\n");
 2579:                         }
 2580:                         else
 2581:                         {
 2582:                             printf("+++Fatal : Any entry point\n");
 2583:                         }
 2584: 
 2585:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 2586:                         {
 2587:                             printf("%s", ds_beep);
 2588:                         }
 2589: 
 2590:                         return(EXIT_FAILURE);
 2591:                     }
 2592: 
 2593:                     if ((*(*s_etat_processus).pointeur_variable_courante)
 2594:                             .niveau != 0)
 2595:                     {
 2596:                         if ((*s_etat_processus).langue == 'F')
 2597:                         {
 2598:                             printf("+++Fatal : Aucun point d'entrée\n");
 2599:                         }
 2600:                         else
 2601:                         {
 2602:                             printf("+++Fatal : Any entry point\n");
 2603:                         }
 2604: 
 2605:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 2606:                         {
 2607:                             printf("%s", ds_beep);
 2608:                         }
 2609: 
 2610:                         return(EXIT_FAILURE);
 2611:                     }
 2612: 
 2613:                     free((*s_etat_processus).instruction_courante);
 2614:                     (*s_etat_processus).position_courante = 0;
 2615: 
 2616:                     if (((*s_etat_processus).nom_fichier_historique =
 2617:                             malloc((strlen(home) +
 2618:                             strlen(ds_fichier_historique) + 2) *
 2619:                             sizeof(unsigned char))) == NULL)
 2620:                     {
 2621:                         erreur = d_es_allocation_memoire;
 2622: 
 2623:                         if ((*s_etat_processus).langue == 'F')
 2624:                         {
 2625:                             printf("+++Système : Mémoire insuffisante\n");
 2626:                         }
 2627:                         else
 2628:                         {
 2629:                             printf("+++System : Not enough memory\n");
 2630:                         }
 2631: 
 2632:                         return(EXIT_FAILURE);
 2633:                     }
 2634: 
 2635:                     sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
 2636:                             home, ds_fichier_historique);
 2637: 
 2638:                     using_history();
 2639: 
 2640:                     // Pour pouvoir utiliser le keymap avant le premier
 2641:                     // appel à readline().
 2642:                     rl_initialize();
 2643: 
 2644:                     erreur_historique = read_history(
 2645:                             (*s_etat_processus).nom_fichier_historique);
 2646: 
 2647:                     gsl_set_error_handler(&traitement_exceptions_gsl);
 2648: 
 2649:                     if (drapeau_encart == 'Y')
 2650:                     {
 2651:                         (*s_etat_processus).erreur_systeme = d_es;
 2652:                         encart(s_etat_processus,
 2653:                                 (unsigned long) (5 * 1000000));
 2654: 
 2655:                         if ((*s_etat_processus).erreur_systeme != d_es)
 2656:                         {
 2657:                             if ((message = messages(s_etat_processus))
 2658:                                     == NULL)
 2659:                             {
 2660:                                 erreur = d_es_allocation_memoire;
 2661: 
 2662:                                 if ((*s_etat_processus).langue == 'F')
 2663:                                 {
 2664:                                     printf("+++Système : Mémoire "
 2665:                                             "insuffisante\n");
 2666:                                 }
 2667:                                 else
 2668:                                 {
 2669:                                     printf("+++System : Not enough "
 2670:                                             "memory\n");
 2671:                                 }
 2672: 
 2673:                                 return(EXIT_FAILURE);
 2674:                             }
 2675: 
 2676:                             printf("%s [%d]\n", message, (int) getpid());
 2677:                             free(message);
 2678: 
 2679:                             return(EXIT_FAILURE);
 2680:                         }
 2681:                     }
 2682: 
 2683:                     fflush(stdout);
 2684: 
 2685:                     if (arguments != NULL)
 2686:                     {
 2687:                         tampon = (*s_etat_processus).definitions_chainees;
 2688:                         (*s_etat_processus).definitions_chainees =
 2689:                                 arguments;
 2690: 
 2691:                         if (analyse_syntaxique(s_etat_processus) ==
 2692:                                 d_erreur)
 2693:                         {
 2694:                             if ((*s_etat_processus).erreur_systeme != d_es)
 2695:                             {
 2696:                                 erreur = d_es_allocation_memoire;
 2697: 
 2698:                                 if ((*s_etat_processus).langue == 'F')
 2699:                                 {
 2700:                                     printf("+++Système : Mémoire "
 2701:                                             "insuffisante\n");
 2702:                                 }
 2703:                                 else
 2704:                                 {
 2705:                                     printf("+++System : Not enough "
 2706:                                             "memory\n");
 2707:                                 }
 2708: 
 2709:                                 return(EXIT_FAILURE);
 2710:                             }
 2711:                             else
 2712:                             {
 2713:                                 if ((*s_etat_processus).langue == 'F')
 2714:                                 {
 2715:                                     printf("+++Erreur : Erreur de "
 2716:                                             "syntaxe\n");
 2717:                                 }
 2718:                                 else
 2719:                                 {
 2720:                                     printf("+++Error : Syntax error\n");
 2721:                                 }
 2722: 
 2723:                                 return(EXIT_FAILURE);
 2724:                             }
 2725:                         }
 2726: 
 2727:                         (*s_etat_processus).instruction_courante
 2728:                                 = arguments;
 2729:                         (*s_etat_processus).definitions_chainees = tampon;
 2730:                         (*s_etat_processus).position_courante = 0;
 2731: 
 2732:                         recherche_type(s_etat_processus);
 2733: 
 2734:                         if ((*s_etat_processus).erreur_systeme != d_es)
 2735:                         {
 2736:                             if ((message = messages(s_etat_processus))
 2737:                                     == NULL)
 2738:                             {
 2739:                                 erreur = d_es_allocation_memoire;
 2740: 
 2741:                                 if ((*s_etat_processus).langue == 'F')
 2742:                                 {
 2743:                                     printf("+++Système : Mémoire "
 2744:                                             "insuffisante\n");
 2745:                                 }
 2746:                                 else
 2747:                                 {
 2748:                                     printf("+++System : Not enough "
 2749:                                             "memory\n");
 2750:                                 }
 2751: 
 2752:                                 return(EXIT_FAILURE);
 2753:                             }
 2754: 
 2755:                             printf("%s [%d]\n", message, (int) getpid());
 2756:                             free(message);
 2757: 
 2758:                             return(EXIT_FAILURE);
 2759:                         }
 2760: 
 2761:                         if ((*s_etat_processus).erreur_execution != d_ex)
 2762:                         {
 2763:                             if ((message = messages(s_etat_processus))
 2764:                                     == NULL)
 2765:                             {
 2766:                                 erreur = d_es_allocation_memoire;
 2767: 
 2768:                                 if ((*s_etat_processus).langue == 'F')
 2769:                                 {
 2770:                                     printf("+++Erreur : Mémoire "
 2771:                                             "insuffisante\n");
 2772:                                 }
 2773:                                 else
 2774:                                 {
 2775:                                     printf("+++Error : Not enough "
 2776:                                             "memory\n");
 2777:                                 }
 2778: 
 2779:                                 return(EXIT_FAILURE);
 2780:                             }
 2781: 
 2782:                             printf("%s [%d]\n", message, (int) getpid());
 2783:                             free(message);
 2784: 
 2785:                             return(EXIT_FAILURE);
 2786:                         }
 2787: 
 2788:                         if (depilement(s_etat_processus,
 2789:                                 &((*s_etat_processus).l_base_pile),
 2790:                                 &s_objet) == d_erreur)
 2791:                         {
 2792:                             if ((message = messages(s_etat_processus))
 2793:                                     == NULL)
 2794:                             {
 2795:                                 erreur = d_es_allocation_memoire;
 2796: 
 2797:                                 if ((*s_etat_processus).langue == 'F')
 2798:                                 {
 2799:                                     printf("+++Erreur : Mémoire "
 2800:                                             "insuffisante\n");
 2801:                                 }
 2802:                                 else
 2803:                                 {
 2804:                                     printf("+++Error : Not enough "
 2805:                                             "memory\n");
 2806:                                 }
 2807: 
 2808:                                 return(EXIT_FAILURE);
 2809:                             }
 2810: 
 2811:                             printf("%s [%d]\n", message, (int) getpid());
 2812:                             free(message);
 2813: 
 2814:                             return(EXIT_FAILURE);
 2815:                         }
 2816: 
 2817:                         if (evaluation(s_etat_processus, s_objet, 'E')
 2818:                                 == d_erreur)
 2819:                         {
 2820:                             if ((*s_etat_processus).erreur_systeme != d_es)
 2821:                             {
 2822:                                 if ((message = messages(s_etat_processus))
 2823:                                         == NULL)
 2824:                                 {
 2825:                                     erreur = d_es_allocation_memoire;
 2826: 
 2827:                                     if ((*s_etat_processus).langue == 'F')
 2828:                                     {
 2829:                                         printf("+++Système : Mémoire "
 2830:                                                 "insuffisante\n");
 2831:                                     }
 2832:                                     else
 2833:                                     {
 2834:                                         printf("+++System : Not enough "
 2835:                                                 "memory\n");
 2836:                                     }
 2837: 
 2838:                                     return(EXIT_FAILURE);
 2839:                                 }
 2840: 
 2841:                                 printf("%s [%d]\n", message,
 2842:                                         (int) getpid());
 2843:                                 free(message);
 2844: 
 2845:                                 return(EXIT_FAILURE);
 2846:                             }
 2847: 
 2848:                             if ((*s_etat_processus).erreur_execution
 2849:                                     != d_ex)
 2850:                             {
 2851:                                 if ((message = messages(s_etat_processus))
 2852:                                         == NULL)
 2853:                                 {
 2854:                                     erreur = d_es_allocation_memoire;
 2855: 
 2856:                                     if ((*s_etat_processus).langue == 'F')
 2857:                                     {
 2858:                                         printf("+++Erreur : Mémoire "
 2859:                                                 "insuffisante\n");
 2860:                                     }
 2861:                                     else
 2862:                                     {
 2863:                                         printf("+++Error : Not enough "
 2864:                                                 "memory\n");
 2865:                                     }
 2866: 
 2867:                                     return(EXIT_FAILURE);
 2868:                                 }
 2869: 
 2870:                                 printf("%s [%d]\n", message,
 2871:                                         (int) getpid());
 2872:                                 free(message);
 2873: 
 2874:                                 return(EXIT_FAILURE);
 2875:                             }
 2876:                         }
 2877: 
 2878:                         (*s_etat_processus).instruction_courante = NULL;
 2879:                         liberation(s_etat_processus, s_objet);
 2880: 
 2881:                         free(arguments);
 2882:                     }
 2883: 
 2884:                     if (option_a == d_vrai)
 2885:                     {
 2886:                         fprintf(stdout, "%s\n", (*s_etat_processus)
 2887:                                 .definitions_chainees);
 2888:                     }
 2889:                     else
 2890:                     {
 2891:                         if (option_D == d_vrai)
 2892:                         {
 2893:                             lancement_daemon(s_etat_processus);
 2894:                         }
 2895: 
 2896:                         if (option_p == d_faux)
 2897:                         {
 2898:                             if (setjmp(contexte_initial) == 0)
 2899:                             {
 2900:                                 erreur = sequenceur(s_etat_processus);
 2901: 
 2902:                                 if (erreur == d_absence_erreur)
 2903:                                 {
 2904:                                     if (((*s_etat_processus).var_volatile_alarme
 2905:                                             == 0) && ((*s_etat_processus)
 2906:                                             .arret_depuis_abort == 0) &&
 2907:                                             ((*s_etat_processus).at_exit
 2908:                                             != NULL))
 2909:                                     {
 2910:                                         erreur = evaluation(s_etat_processus,
 2911:                                                 (*s_etat_processus).at_exit,
 2912:                                                 'E');
 2913:                                     }
 2914:                                 }
 2915:                             }
 2916:                         }
 2917:                         else
 2918:                         {
 2919:                             if (setjmp(contexte_initial) == 0)
 2920:                             {
 2921:                                 erreur = sequenceur_optimise(s_etat_processus);
 2922: 
 2923:                                 if (erreur == d_absence_erreur)
 2924:                                 {
 2925:                                     if (((*s_etat_processus).var_volatile_alarme
 2926:                                             == 0) && ((*s_etat_processus)
 2927:                                             .arret_depuis_abort == 0) &&
 2928:                                             ((*s_etat_processus).at_exit
 2929:                                             != NULL))
 2930:                                     {
 2931:                                         erreur = evaluation(s_etat_processus,
 2932:                                                 (*s_etat_processus).at_exit,
 2933:                                                 'E');
 2934:                                     }
 2935:                                 }
 2936:                             }
 2937:                         }
 2938:                     }
 2939: 
 2940:                     for(i = 0; i < (*s_etat_processus).sections_critiques; i++)
 2941:                     {
 2942:                         pthread_mutex_unlock(&mutex_sections_critiques);
 2943:                     }
 2944: 
 2945:                     liberation(s_etat_processus, (*s_etat_processus).at_exit);
 2946:                     liberation(s_etat_processus, (*s_etat_processus).at_poke);
 2947: 
 2948:                     if ((*s_etat_processus).generateur_aleatoire != NULL)
 2949:                     {
 2950:                         liberation_generateur_aleatoire(s_etat_processus);
 2951:                     }
 2952: 
 2953:                     l_element_courant = (*s_etat_processus).liste_mutexes;
 2954:                     while(l_element_courant != NULL)
 2955:                     {
 2956:                         liberation(s_etat_processus,
 2957:                                 (*((struct_liste_chainee *)
 2958:                                 l_element_courant)).donnee);
 2959:                         l_element_suivant = (*((struct_liste_chainee *)
 2960:                                 l_element_courant)).suivant;
 2961:                         free((struct_liste_chainee *) l_element_courant);
 2962:                         l_element_courant = l_element_suivant;
 2963:                     }
 2964: 
 2965:                     /*
 2966:                      * Arrêt des processus fils
 2967:                      */
 2968: 
 2969:                     if ((*s_etat_processus).presence_fusible == d_vrai)
 2970:                     {
 2971:                         pthread_cancel((*s_etat_processus).thread_fusible);
 2972:                     }
 2973: 
 2974:                     pthread_mutex_lock(&((*s_etat_processus).mutex));
 2975: 
 2976:                     l_element_courant = (void *) (*s_etat_processus)
 2977:                             .l_base_pile_processus;
 2978: 
 2979:                     while(l_element_courant != NULL)
 2980:                     {
 2981:                         if ((*s_etat_processus).debug == d_vrai)
 2982:                         {
 2983:                             if (((*s_etat_processus).type_debug &
 2984:                                     d_debug_processus) != 0)
 2985:                             {
 2986:                                 if ((*(*((struct_processus_fils *)
 2987:                                         (*(*((struct_liste_chainee *)
 2988:                                         l_element_courant)).donnee)
 2989:                                         .objet)).thread)
 2990:                                         .processus_detache == d_vrai)
 2991:                                 {
 2992:                                     if ((*s_etat_processus).langue == 'F')
 2993:                                     {
 2994:                                         printf("[%d] Signalement pour arrêt du "
 2995:                                                 "processus %d\n",
 2996:                                                 (int) getpid(), (int)
 2997:                                                 (*(*((struct_processus_fils *)
 2998:                                                 (*(*((struct_liste_chainee *)
 2999:                                                 l_element_courant)).donnee)
 3000:                                                 .objet)).thread).pid);
 3001:                                     }
 3002:                                     else
 3003:                                     {
 3004:                                         printf("[%d] Send stop signal to "
 3005:                                                 "process %d\n",
 3006:                                                 (int) getpid(), (int)
 3007:                                                 (*(*((struct_processus_fils *)
 3008:                                                 (*(*((struct_liste_chainee *)
 3009:                                                 l_element_courant)).donnee)
 3010:                                                 .objet)).thread).pid);
 3011:                                     }
 3012:                                 }
 3013:                                 else
 3014:                                 {
 3015:                                     if ((*s_etat_processus).langue == 'F')
 3016:                                     {
 3017:                                         printf("[%d] Signalement pour arrêt du "
 3018:                                                 "thread %llu\n", (int) getpid(),
 3019:                                                 (unsigned long long)
 3020:                                                 (*(*((struct_processus_fils *)
 3021:                                                 (*(*((struct_liste_chainee *)
 3022:                                                 l_element_courant)).donnee)
 3023:                                                 .objet)).thread).tid);
 3024:                                     }
 3025:                                     else
 3026:                                     {
 3027:                                         printf("[%d] Send stop signal to "
 3028:                                                 "thread %llu\n",
 3029:                                                 (int) getpid(),
 3030:                                                 (unsigned long long)
 3031:                                                 (*(*((struct_processus_fils *)
 3032:                                                 (*(*((struct_liste_chainee *)
 3033:                                                 l_element_courant)).donnee)
 3034:                                                 .objet)).thread).tid);
 3035:                                     }
 3036:                                 }
 3037:                             }
 3038:                         }
 3039: 
 3040:                         if ((*(*((struct_processus_fils *)
 3041:                                 (*(*((struct_liste_chainee *)
 3042:                                 l_element_courant)).donnee).objet))
 3043:                                 .thread).processus_detache == d_vrai)
 3044:                         {
 3045:                             if ((*s_etat_processus).var_volatile_alarme != 0)
 3046:                             {
 3047:                                 envoi_signal_processus(
 3048:                                         (*(*((struct_processus_fils *)
 3049:                                         (*(*((struct_liste_chainee *)
 3050:                                         l_element_courant)).donnee).objet))
 3051:                                         .thread).pid, rpl_sigurg);
 3052:                             }
 3053:                             else
 3054:                             {
 3055:                                 if ((*s_etat_processus).arret_depuis_abort
 3056:                                         == -1)
 3057:                                 {
 3058:                                     envoi_signal_processus(
 3059:                                             (*(*((struct_processus_fils *)
 3060:                                             (*(*((struct_liste_chainee *)
 3061:                                             l_element_courant)).donnee).objet))
 3062:                                             .thread).pid, rpl_sigabort);
 3063:                                 }
 3064:                                 else
 3065:                                 {
 3066:                                     envoi_signal_processus(
 3067:                                             (*(*((struct_processus_fils *)
 3068:                                             (*(*((struct_liste_chainee *)
 3069:                                             l_element_courant)).donnee).objet))
 3070:                                             .thread).pid, rpl_sigstop);
 3071:                                 }
 3072:                             }
 3073:                         }
 3074:                         else
 3075:                         {
 3076:                             pthread_mutex_lock(&((*(*((struct_processus_fils *)
 3077:                                     (*(*((struct_liste_chainee *)
 3078:                                     l_element_courant)).donnee).objet)).thread)
 3079:                                     .mutex));
 3080: 
 3081:                             if ((*(*((struct_processus_fils *)
 3082:                                     (*(*((struct_liste_chainee *)
 3083:                                     l_element_courant)).donnee).objet)).thread)
 3084:                                     .thread_actif == d_vrai)
 3085:                             {
 3086:                                 if ((*s_etat_processus).var_volatile_alarme
 3087:                                         != 0)
 3088:                                 {
 3089:                                     envoi_signal_thread(
 3090:                                             (*(*((struct_processus_fils *)
 3091:                                             (*(*((struct_liste_chainee *)
 3092:                                             l_element_courant)).donnee).objet))
 3093:                                             .thread).tid, rpl_sigurg);
 3094:                                 }
 3095:                                 else
 3096:                                 {
 3097:                                     if ((*s_etat_processus).arret_depuis_abort
 3098:                                             == -1)
 3099:                                     {
 3100:                                         envoi_signal_thread(
 3101:                                                 (*(*((struct_processus_fils *)
 3102:                                                 (*(*((struct_liste_chainee *)
 3103:                                                 l_element_courant)).donnee)
 3104:                                                 .objet)).thread).tid,
 3105:                                                 rpl_sigabort);
 3106:                                     }
 3107:                                     else
 3108:                                     {
 3109:                                         envoi_signal_thread(
 3110:                                                 (*(*((struct_processus_fils *)
 3111:                                                 (*(*((struct_liste_chainee *)
 3112:                                                 l_element_courant)).donnee)
 3113:                                                 .objet)).thread).tid,
 3114:                                                 rpl_sigstop);
 3115:                                     }
 3116:                                 }
 3117:                             }
 3118: 
 3119:                             pthread_mutex_unlock(
 3120:                                     &((*(*((struct_processus_fils *)
 3121:                                     (*(*((struct_liste_chainee *)
 3122:                                     l_element_courant)).donnee).objet)).thread)
 3123:                                     .mutex));
 3124:                         }
 3125: 
 3126:                         l_element_courant = (*((struct_liste_chainee *)
 3127:                                 l_element_courant)).suivant;
 3128:                     }
 3129: 
 3130:                     /*
 3131:                      * Attente de la fin de tous les processus fils
 3132:                      */
 3133: 
 3134:                     for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
 3135:                             (*s_etat_processus).masque_interruptions[i++]
 3136:                             = 'I');
 3137: 
 3138:                     attente.tv_sec = 0;
 3139:                     attente.tv_nsec = GRANULARITE_us * 1000;
 3140: 
 3141:                     while((*s_etat_processus).l_base_pile_processus != NULL)
 3142:                     {
 3143:                         l_element_courant = (void *)
 3144:                                 (*s_etat_processus).l_base_pile_processus;
 3145: 
 3146:                         for(i = 0; i < (unsigned long)
 3147:                                 (*(*((struct_processus_fils *)
 3148:                                 (*(*((struct_liste_chainee *)
 3149:                                 l_element_courant)).donnee).objet)).thread)
 3150:                                 .nombre_objets_dans_pipe; i++)
 3151:                         {
 3152:                             if ((s_objet = lecture_pipe(
 3153:                                     s_etat_processus,
 3154:                                     (*(*((struct_processus_fils *)
 3155:                                     (*(*((struct_liste_chainee *)
 3156:                                     l_element_courant)).donnee).objet)).thread)
 3157:                                     .pipe_objets[0])) != NULL)
 3158:                             {
 3159:                                 liberation(s_etat_processus, s_objet);
 3160: 
 3161:                                 (*(*((struct_processus_fils *)
 3162:                                         (*(*((struct_liste_chainee *)
 3163:                                         l_element_courant)).donnee).objet))
 3164:                                         .thread).nombre_objets_dans_pipe--;
 3165: 
 3166:                                 action.sa_handler = SIG_IGN;
 3167:                                 action.sa_flags = 0;
 3168: 
 3169:                                 if (sigaction(SIGPIPE, &action, &registre)
 3170:                                         != 0)
 3171:                                 {
 3172:                                     pthread_mutex_unlock(
 3173:                                             &((*s_etat_processus).mutex));
 3174:                                     return(EXIT_FAILURE);
 3175:                                 }
 3176: 
 3177:                                 while((longueur_ecriture =
 3178:                                         write_atomic(s_etat_processus,
 3179:                                         (*(*((struct_processus_fils *)
 3180:                                         (*(*((struct_liste_chainee *)
 3181:                                         l_element_courant)).donnee).objet))
 3182:                                         .thread).pipe_nombre_injections[1], "+",
 3183:                                         sizeof(unsigned char))) !=
 3184:                                         sizeof(unsigned char))
 3185:                                 {
 3186:                                     if (longueur_ecriture == -1)
 3187:                                     {
 3188:                                         // Le processus n'existe plus.
 3189:                                         break;
 3190:                                     }
 3191:                                 }
 3192: 
 3193:                                 if (sigaction(SIGPIPE, &registre, NULL)
 3194:                                         != 0)
 3195:                                 {
 3196:                                     pthread_mutex_unlock(
 3197:                                             &((*s_etat_processus).mutex));
 3198:                                     return(EXIT_FAILURE);
 3199:                                 }
 3200:                             }
 3201:                         }
 3202: 
 3203:                         pthread_mutex_unlock(&((*s_etat_processus).mutex));
 3204: 
 3205:                         if ((*s_etat_processus)
 3206:                                 .nombre_interruptions_non_affectees != 0)
 3207:                         {
 3208:                             affectation_interruptions_logicielles(
 3209:                                     s_etat_processus);
 3210:                         }
 3211: 
 3212:                         nanosleep(&attente, NULL);
 3213:                         scrutation_interruptions(s_etat_processus);
 3214:                         pthread_mutex_lock(&((*s_etat_processus).mutex));
 3215:                     }
 3216: 
 3217:                     pthread_mutex_unlock(&((*s_etat_processus).mutex));
 3218: 
 3219:                     erreur_historique = write_history(
 3220:                             (*s_etat_processus).nom_fichier_historique);
 3221:                     clear_history();
 3222: 
 3223:                     if (erreur_historique != 0)
 3224:                     {
 3225:                         if ((*s_etat_processus).langue == 'F')
 3226:                         {
 3227:                             printf("+++Erreur : L'historique ne peut être "
 3228:                                     "écrit\n");
 3229:                         }
 3230:                         else
 3231:                         {
 3232:                             printf("+++Error : History cannot be "
 3233:                                     "written\n");
 3234:                         }
 3235: 
 3236:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 3237:                         {
 3238:                             printf("%s", ds_beep);
 3239:                         }
 3240:                     }
 3241: 
 3242:                     free((*s_etat_processus).nom_fichier_historique);
 3243: 
 3244:                     if (((*s_etat_processus).core == d_vrai) &&
 3245:                             (erreur == d_erreur) &&
 3246:                             ((*s_etat_processus).var_volatile_traitement_sigint
 3247:                             == 0))
 3248:                     {
 3249:                         printf("\n");
 3250:                         
 3251:                         if ((*s_etat_processus).langue == 'F')
 3252:                         {
 3253:                             printf("+++Information : Génération du fichier "
 3254:                                     "rpl-core [%d]\n", (int) getpid());
 3255:                         }
 3256:                         else
 3257:                         {
 3258:                             printf("+++Information : Writing rpl-core "
 3259:                                     "file [%d]\n", (int) getpid());
 3260:                         }
 3261: 
 3262:                         rplcore(s_etat_processus);
 3263: 
 3264:                         if ((*s_etat_processus).langue == 'F')
 3265:                         {
 3266:                             printf("+++Information : Processus tracé [%d]\n",
 3267:                                     (int) getpid());
 3268:                         }
 3269:                         else
 3270:                         {
 3271:                             printf("+++Information : Done [%d]\n",
 3272:                                     (int) getpid());
 3273:                         }
 3274: 
 3275:                         printf("\n");
 3276:                     }
 3277: 
 3278:                     free((*s_etat_processus).definitions_chainees);
 3279: 
 3280:                     /*
 3281:                      * Libération de l'arbre des instructions
 3282:                      */
 3283: 
 3284:                     liberation_arbre_instructions(s_etat_processus,
 3285:                             (*s_etat_processus).arbre_instructions);
 3286:                     free((*s_etat_processus).pointeurs_caracteres);
 3287: 
 3288:                     if ((*s_etat_processus).entree_standard != NULL)
 3289:                     {
 3290:                         pclose((*s_etat_processus).entree_standard);
 3291:                         (*s_etat_processus).entree_standard = NULL;
 3292:                     }
 3293: 
 3294:                     if ((*s_etat_processus).nom_fichier_impression != NULL)
 3295:                     {
 3296:                         if (test_cfsf(s_etat_processus, 51) == d_faux)
 3297:                         {
 3298:                             printf("%s", ds_beep);
 3299:                         }
 3300: 
 3301:                         if ((*s_etat_processus).langue == 'F')
 3302:                         {
 3303:                             printf("+++Attention : Queue d'impression "
 3304:                                     "non vide !\n");
 3305:                         }
 3306:                         else
 3307:                         {
 3308:                             printf("+++Warning : Non empty printing "
 3309:                                     "spool queue !\n");
 3310:                         }
 3311: 
 3312:                         instruction_erase(s_etat_processus);
 3313:                     }
 3314: 
 3315:                     if ((*s_etat_processus).fichiers_graphiques != NULL)
 3316:                     {
 3317:                         instruction_cllcd(s_etat_processus);
 3318:                     }
 3319: 
 3320:                     liberation(s_etat_processus, (*s_etat_processus).indep);
 3321:                     liberation(s_etat_processus, (*s_etat_processus).depend);
 3322: 
 3323:                     free((*s_etat_processus).label_x);
 3324:                     free((*s_etat_processus).label_y);
 3325:                     free((*s_etat_processus).label_z);
 3326:                     free((*s_etat_processus).titre);
 3327:                     free((*s_etat_processus).legende);
 3328: 
 3329:                     liberation(s_etat_processus, (*s_etat_processus)
 3330:                             .parametres_courbes_de_niveau);
 3331: 
 3332:                     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 3333:                     {
 3334:                         liberation(s_etat_processus,
 3335:                                 (*s_etat_processus).corps_interruptions[i]);
 3336: 
 3337:                         l_element_courant = (*s_etat_processus)
 3338:                                 .pile_origine_interruptions[i];
 3339: 
 3340:                         while(l_element_courant != NULL)
 3341:                         {
 3342:                             l_element_suivant = (*((struct_liste_chainee *)
 3343:                                     l_element_courant)).suivant;
 3344: 
 3345:                             liberation(s_etat_processus,
 3346:                                     (*((struct_liste_chainee *)
 3347:                                     l_element_courant)).donnee);
 3348:                             free(l_element_courant);
 3349: 
 3350:                             l_element_courant = l_element_suivant;
 3351:                         }
 3352:                     }
 3353: 
 3354:                     if ((*s_etat_processus).instruction_derniere_erreur
 3355:                             != NULL)
 3356:                     {
 3357:                         free((*s_etat_processus).instruction_derniere_erreur);
 3358:                         (*s_etat_processus).instruction_derniere_erreur = NULL;
 3359:                     }
 3360: 
 3361:                     /*
 3362:                      * Le pointeur s_etat_processus.nom_fichier_source est
 3363:                      * alloué par le système. Il ne faut donc pas
 3364:                      * le libérer...
 3365:                      */
 3366: 
 3367:                     liberation_arbre_variables(s_etat_processus,
 3368:                             (*s_etat_processus).s_arbre_variables, d_vrai);
 3369:                     free((*s_etat_processus).pointeurs_caracteres_variables);
 3370: 
 3371:                     l_element_statique_courant = (*s_etat_processus)
 3372:                             .l_liste_variables_statiques;
 3373: 
 3374:                     while(l_element_statique_courant != NULL)
 3375:                     {
 3376:                         l_element_statique_suivant =
 3377:                             (*l_element_statique_courant).suivant;
 3378:                         free(l_element_statique_courant);
 3379:                         l_element_statique_courant = l_element_statique_suivant;
 3380:                     }
 3381: 
 3382:                     for(i = 0; i < (*((*s_etat_processus)
 3383:                             .s_liste_variables_partagees)).nombre_variables;
 3384:                             i++)
 3385:                     {
 3386:                         liberation(s_etat_processus, (*((*s_etat_processus)
 3387:                                 .s_liste_variables_partagees)).table[i].objet);
 3388:                         free((*((*s_etat_processus)
 3389:                                 .s_liste_variables_partagees)).table[i].nom);
 3390:                     }
 3391: 
 3392:                     free((struct_variable_partagee *)
 3393:                             (*((*s_etat_processus).s_liste_variables_partagees))
 3394:                             .table);
 3395: 
 3396:                     /*
 3397:                      * Si resultats est non nul, rplinit a été appelé
 3398:                      * depuis rpl() [librpl] et non main().
 3399:                      * On copie alors le contenu de la * pile dans un
 3400:                      * tableau **resultats dont le pointeur de base a
 3401:                      * été alloué dans rpl().
 3402:                      */
 3403: 
 3404:                     if (resultats != NULL)
 3405:                     {
 3406:                         if ((*resultats) != NULL)
 3407:                         {
 3408:                             free((*resultats));
 3409: 
 3410:                             if (((*resultats) = malloc(((*s_etat_processus)
 3411:                                     .hauteur_pile_operationnelle + 1)
 3412:                                     * sizeof(unsigned char **))) != NULL)
 3413:                             {
 3414:                                 (*resultats)[(*s_etat_processus)
 3415:                                         .hauteur_pile_operationnelle] = NULL;
 3416:                                 l_element_courant = (void *) (*s_etat_processus)
 3417:                                         .l_base_pile;
 3418: 
 3419:                                 for(i = 0; i < (*s_etat_processus)
 3420:                                         .hauteur_pile_operationnelle; i++)
 3421:                                 {
 3422:                                     if (l_element_courant != NULL)
 3423:                                     {
 3424:                                         (*resultats)[i] =
 3425:                                                 formateur(s_etat_processus,
 3426:                                                 0, (*((struct_liste_chainee *)
 3427:                                                 l_element_courant)).donnee);
 3428: 
 3429:                                         if ((*resultats)[i] == NULL)
 3430:                                         {
 3431:                                             i = (*s_etat_processus).
 3432:                                                     hauteur_pile_operationnelle;
 3433:                                         }
 3434:                                         else
 3435:                                         {
 3436:                                             l_element_suivant =
 3437:                                                     (*((struct_liste_chainee *)
 3438:                                                     l_element_courant)).suivant;
 3439:                                         }
 3440:                                     }
 3441:                                 }
 3442:                             }
 3443:                             else
 3444:                             {
 3445:                                 (*resultats) = NULL;
 3446:                                 erreur = d_es_allocation_memoire;
 3447:                             }
 3448:                         }
 3449:                     }
 3450: 
 3451:                     l_element_courant = (void *) (*s_etat_processus)
 3452:                             .l_base_pile;
 3453:                     while(l_element_courant != NULL)
 3454:                     {
 3455:                         l_element_suivant = (*((struct_liste_chainee *)
 3456:                                 l_element_courant)).suivant;
 3457: 
 3458:                         liberation(s_etat_processus,
 3459:                                 (*((struct_liste_chainee *)
 3460:                                 l_element_courant)).donnee);
 3461:                         free((struct_liste_chainee *) l_element_courant);
 3462: 
 3463:                         l_element_courant = l_element_suivant;
 3464:                     }
 3465: 
 3466:                     l_element_courant = (void *) (*s_etat_processus)
 3467:                             .l_base_pile_contextes;
 3468:                     while(l_element_courant != NULL)
 3469:                     {
 3470:                         l_element_suivant = (*((struct_liste_chainee *)
 3471:                                 l_element_courant)).suivant;
 3472: 
 3473:                         liberation(s_etat_processus,
 3474:                                 (*((struct_liste_chainee *)
 3475:                                 l_element_courant)).donnee);
 3476:                         free((struct_liste_chainee *) l_element_courant);
 3477: 
 3478:                         l_element_courant = l_element_suivant;
 3479:                     }
 3480: 
 3481:                     l_element_courant = (void *) (*s_etat_processus)
 3482:                             .l_base_pile_taille_contextes;
 3483:                     while(l_element_courant != NULL)
 3484:                     {
 3485:                         l_element_suivant = (*((struct_liste_chainee *)
 3486:                                 l_element_courant)).suivant;
 3487: 
 3488:                         liberation(s_etat_processus,
 3489:                                 (*((struct_liste_chainee *)
 3490:                                 l_element_courant)).donnee);
 3491:                         free((struct_liste_chainee *) l_element_courant);
 3492: 
 3493:                         l_element_courant = l_element_suivant;
 3494:                     }
 3495: 
 3496:                     for(i = 0; i < (*s_etat_processus)
 3497:                             .nombre_instructions_externes; i++)
 3498:                     {
 3499:                         free((*s_etat_processus).s_instructions_externes[i]
 3500:                                 .nom);
 3501:                         free((*s_etat_processus).s_instructions_externes[i]
 3502:                                 .nom_bibliotheque);
 3503:                     }
 3504: 
 3505:                     if ((*s_etat_processus).nombre_instructions_externes != 0)
 3506:                     {
 3507:                         free((*s_etat_processus).s_instructions_externes);
 3508:                     }
 3509: 
 3510:                     l_element_courant = (void *) (*s_etat_processus)
 3511:                             .s_bibliotheques;
 3512:                     
 3513:                     while(l_element_courant != NULL)
 3514:                     {
 3515:                         l_element_suivant = (*((struct_liste_chainee *)
 3516:                                 l_element_courant)).suivant;
 3517: 
 3518:                         free((*((struct_bibliotheque *)
 3519:                                 (*((struct_liste_chainee *)
 3520:                                 l_element_courant)).donnee)).nom);
 3521:                         dlclose((*((struct_bibliotheque *)
 3522:                                 (*((struct_liste_chainee *)
 3523:                                 l_element_courant)).donnee)).descripteur);
 3524:                         free((*((struct_liste_chainee *) l_element_courant))
 3525:                                 .donnee);
 3526:                         free(l_element_courant);
 3527: 
 3528:                         l_element_courant = l_element_suivant;
 3529:                     }
 3530: 
 3531:                     l_element_courant = (void *) (*s_etat_processus)
 3532:                             .l_base_pile_last;
 3533:                     while(l_element_courant != NULL)
 3534:                     {
 3535:                         l_element_suivant = (*((struct_liste_chainee *)
 3536:                                 l_element_courant)).suivant;
 3537: 
 3538:                         liberation(s_etat_processus,
 3539:                                 (*((struct_liste_chainee *)
 3540:                                 l_element_courant)).donnee);
 3541:                         free((struct_liste_chainee *) l_element_courant);
 3542: 
 3543:                         l_element_courant = l_element_suivant;
 3544:                     }
 3545: 
 3546:                     l_element_courant = (void *) (*s_etat_processus)
 3547:                             .l_base_pile_systeme;
 3548:                     while(l_element_courant != NULL)
 3549:                     {
 3550:                         l_element_suivant = (*((struct_liste_pile_systeme *)
 3551:                                 l_element_courant)).suivant;
 3552: 
 3553:                         liberation(s_etat_processus,
 3554:                                 (*((struct_liste_pile_systeme *)
 3555:                                 l_element_courant)).indice_boucle);
 3556:                         liberation(s_etat_processus,
 3557:                                 (*((struct_liste_pile_systeme *)
 3558:                                 l_element_courant)).limite_indice_boucle);
 3559:                         liberation(s_etat_processus,
 3560:                                 (*((struct_liste_pile_systeme *)
 3561:                                 l_element_courant)).objet_de_test);
 3562: 
 3563:                         if ((*((struct_liste_pile_systeme *)
 3564:                                 l_element_courant)).nom_variable != NULL)
 3565:                         {
 3566:                             free((*((struct_liste_pile_systeme *)
 3567:                                     l_element_courant)).nom_variable);
 3568:                         }
 3569: 
 3570:                         free((struct_liste_pile_systeme *)
 3571:                                 l_element_courant);
 3572: 
 3573:                         l_element_courant = l_element_suivant;
 3574:                     }
 3575: 
 3576:                     l_element_courant = (void *)
 3577:                             (*s_etat_processus).s_fichiers;
 3578:                     while(l_element_courant != NULL)
 3579:                     {
 3580:                         l_element_suivant = (*((struct_liste_chainee *)
 3581:                                 l_element_courant)).suivant;
 3582: 
 3583:                         fclose((*((struct_descripteur_fichier *)
 3584:                                 (*((struct_liste_chainee *)
 3585:                                 l_element_courant)).donnee))
 3586:                                 .descripteur_c);
 3587: 
 3588:                         if ((*((struct_descripteur_fichier *)
 3589:                                 (*((struct_liste_chainee *)
 3590:                                 l_element_courant)).donnee)).type != 'C')
 3591:                         {
 3592:                             sqlite3_close((*((struct_descripteur_fichier *)
 3593:                                     (*((struct_liste_chainee *)
 3594:                                     l_element_courant)).donnee))
 3595:                                     .descripteur_sqlite);
 3596:                         }
 3597: 
 3598:                         if ((*((struct_descripteur_fichier *)
 3599:                                 (*((struct_liste_chainee *)
 3600:                                 l_element_courant)).donnee))
 3601:                                 .effacement == 'Y')
 3602:                         {
 3603:                             unlink((*((struct_descripteur_fichier *)
 3604:                                     (*((struct_liste_chainee *)
 3605:                                     l_element_courant)).donnee))
 3606:                                     .nom);
 3607:                         }
 3608: 
 3609:                         free((*((struct_descripteur_fichier *)
 3610:                                 (*((struct_liste_chainee *)
 3611:                                 l_element_courant)).donnee)).nom);
 3612:                         free((struct_descripteur_fichier *)
 3613:                                 (*((struct_liste_chainee *)
 3614:                                 l_element_courant)).donnee);
 3615:                         free(l_element_courant);
 3616: 
 3617:                         l_element_courant = l_element_suivant;
 3618:                     }
 3619: 
 3620:                     l_element_courant = (void *)
 3621:                             (*s_etat_processus).s_sockets;
 3622:                     while(l_element_courant != NULL)
 3623:                     {
 3624:                         l_element_suivant = (*((struct_liste_chainee *)
 3625:                                 l_element_courant)).suivant;
 3626: 
 3627:                         if ((*((struct_socket *)
 3628:                                 (*(*((struct_liste_chainee *)
 3629:                                 l_element_courant)).donnee).objet))
 3630:                                 .socket_connectee == d_vrai)
 3631:                         {
 3632:                             shutdown((*((struct_socket *)
 3633:                                     (*(*((struct_liste_chainee *)
 3634:                                     l_element_courant)).donnee).objet))
 3635:                                     .socket, SHUT_RDWR);
 3636:                         }
 3637: 
 3638:                         close((*((struct_socket *)
 3639:                                 (*(*((struct_liste_chainee *)
 3640:                                 l_element_courant)).donnee).objet)).socket);
 3641: 
 3642:                         if ((*((struct_socket *) (*(*((struct_liste_chainee *)
 3643:                                 l_element_courant)).donnee).objet)).effacement
 3644:                                 == 'Y')
 3645:                         {
 3646:                             unlink((*((struct_socket *)
 3647:                                     (*(*((struct_liste_chainee *)
 3648:                                     l_element_courant)).donnee).objet))
 3649:                                     .adresse);
 3650:                         }
 3651: 
 3652:                         liberation(s_etat_processus,
 3653:                                 (*((struct_liste_chainee *)
 3654:                                 l_element_courant)).donnee);
 3655:                         free(l_element_courant);
 3656: 
 3657:                         l_element_courant = l_element_suivant;
 3658:                     }
 3659: 
 3660:                     l_element_courant = (void *)
 3661:                             (*s_etat_processus).s_connecteurs_sql;
 3662:                     while(l_element_courant != NULL)
 3663:                     {
 3664:                         l_element_suivant = (*((struct_liste_chainee *)
 3665:                                 l_element_courant)).suivant;
 3666: 
 3667:                         sqlclose((*((struct_liste_chainee *)
 3668:                                 l_element_courant)).donnee);
 3669:                         liberation(s_etat_processus,
 3670:                                 (*((struct_liste_chainee *)
 3671:                                 l_element_courant)).donnee);
 3672:                         free(l_element_courant);
 3673: 
 3674:                         l_element_courant = l_element_suivant;
 3675:                     }
 3676: 
 3677:                     l_element_courant = (*s_etat_processus).s_marques;
 3678:                     while(l_element_courant != NULL)
 3679:                     {
 3680:                         free((*((struct_marque *) l_element_courant)).label);
 3681:                         free((*((struct_marque *) l_element_courant)).position);
 3682:                         l_element_suivant = (*((struct_marque *)
 3683:                                 l_element_courant)).suivant;
 3684:                         free(l_element_courant);
 3685:                         l_element_courant = l_element_suivant;
 3686:                     }
 3687:                 }
 3688:                 else
 3689:                 {
 3690:                     erreur = d_es_allocation_memoire;
 3691: 
 3692:                     if (test_cfsf(s_etat_processus, 51) == d_faux)
 3693:                     {
 3694:                         printf("%s", ds_beep);
 3695:                     }
 3696: 
 3697:                     if ((*s_etat_processus).langue == 'F')
 3698:                     {
 3699:                         printf("+++Système : Mémoire insuffisante\n");
 3700:                     }
 3701:                     else
 3702:                     {
 3703:                         printf("+++System : Not enough memory\n");
 3704:                     }
 3705:                 }
 3706:             }
 3707: 
 3708:             liberation_allocateur(s_etat_processus);
 3709:         }
 3710: 
 3711:         if (traitement_fichier_temporaire == 'Y')
 3712:         {
 3713:             if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
 3714:             {
 3715:                 return(EXIT_FAILURE);
 3716:             }
 3717: 
 3718:             free(nom_fichier_temporaire);
 3719:         }
 3720: 
 3721:         if ((*s_etat_processus).profilage == d_vrai)
 3722:         {
 3723:             ecriture_profil(s_etat_processus);
 3724:             liberation_profil(s_etat_processus);
 3725:         }
 3726:     }
 3727: 
 3728:     closelog();
 3729: 
 3730:     pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
 3731:     pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
 3732:             .mutex));
 3733: 
 3734:     retrait_thread(s_etat_processus);
 3735: 
 3736:     pthread_mutex_destroy(&((*s_etat_processus).mutex));
 3737:     pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
 3738:     pthread_mutex_destroy(&mutex_sections_critiques);
 3739: 
 3740: #   ifndef SEMAPHORES_NOMMES
 3741:     sem_post(&((*s_etat_processus).semaphore_fork));
 3742:     sem_destroy(&((*s_etat_processus).semaphore_fork));
 3743: #   else
 3744:     sem_post((*s_etat_processus).semaphore_fork);
 3745:     sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(),
 3746:             SEM_FORK);
 3747: #   endif
 3748: 
 3749:     free((*s_etat_processus).localisation);
 3750: 
 3751: #   ifndef SEMAPHORES_NOMMES
 3752:     sem_post(&semaphore_gestionnaires_signaux);
 3753:     sem_destroy(&semaphore_gestionnaires_signaux);
 3754: #   else
 3755:     sem_post(semaphore_gestionnaires_signaux);
 3756:     sem_destroy2(semaphore_gestionnaires_signaux, getpid(), SEM_SIGNAUX);
 3757: #   endif
 3758: 
 3759:     destruction_queue_signaux(s_etat_processus);
 3760:     liberation_contexte_cas(s_etat_processus);
 3761: 
 3762:     free((*s_etat_processus).chemin_fichiers_temporaires);
 3763: 
 3764:     if ((*s_etat_processus).requete_redemarrage == d_vrai)
 3765:     {
 3766:         chdir(repertoire_initial);
 3767:         execvp(arg_exec[0], &(arg_exec[0]));
 3768:         erreur = d_erreur;
 3769:     }
 3770: 
 3771:     free(arg_exec);
 3772:     arret_thread_signaux(s_etat_processus);
 3773:     free(s_etat_processus);
 3774: 
 3775: #   ifdef DEBUG_MEMOIRE
 3776:     debug_memoire_verification();
 3777:     analyse_post_mortem();
 3778: #   endif
 3779: 
 3780: #   ifdef HAVE_STACK_OVERFLOW_RECOVERY
 3781:     stackoverflow_deinstall_handler();
 3782: #   endif
 3783: 
 3784: #   ifdef HAVE_SIGSEGV_RECOVERY
 3785:     if (debug == d_faux)
 3786:     {
 3787:         sigsegv_deinstall_handler();
 3788:     }
 3789: #   endif
 3790: 
 3791:     return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
 3792: }
 3793: 
 3794: 
 3795: void
 3796: informations(struct_processus *s_etat_processus)
 3797: {
 3798:     printf("\n");
 3799: 
 3800:     if ((*s_etat_processus).langue == 'F')
 3801:     {
 3802:         printf("  rpl [-options] [programme]\n");
 3803:         printf("      -a : analyse du code\n");
 3804:         printf("      -A : paramètres passés au programme principal\n");
 3805:         printf("      -c : génération de fichier de débogage (rpl-core)\n");
 3806:         printf("      -d : option de déverminage interne\n");
 3807:         printf("      -D : lancement d'un daemon\n");
 3808:         printf("      -h : aide sur la ligne de commande\n");
 3809:         printf("      -i : fonctionnement interactif\n");
 3810:         printf("      -l : licence d'utilisation\n");
 3811:         printf("      -n : ignorance du signal HUP\n");
 3812:         printf("      -p : précompilation du script avant exécution\n");
 3813:         printf("      -P : profilage\n");
 3814:         printf("      -s : empêchement de l'ouverture de l'écran initial\n");
 3815:         printf("      -S : exécution du script passé en ligne de commande\n");
 3816:         printf("      -t : trace\n");
 3817:         printf("      -v : version\n");
 3818:     }
 3819:     else
 3820:     {
 3821:         printf("  rpl [-options] [program]\n");
 3822:         printf("      -a : analyzes program\n");
 3823:         printf("      -A : sends parameters to main program\n");
 3824:         printf("      -c : allows creation of a rpl-core file, providing a way"
 3825:                 "\n"
 3826:                 "           to debug a program\n");
 3827:         printf("      -d : internal debug process\n");
 3828:         printf("      -D : starts in daemon mode\n");
 3829:         printf("      -h : shows a summary of available options\n");
 3830:         printf("      -i : runs the RPL/2 sequencer in interactive mode\n");
 3831:         printf("      -l : prints the user licence of the software\n");
 3832:         printf("      -n : ignores HUP signal\n");
 3833:         printf("      -p : precompiles script\n");
 3834:         printf("      -P : computes profile data\n");
 3835:         printf("      -s : disables splash screen\n");
 3836:         printf("      -S : executes script written in command line\n");
 3837:         printf("      -t : enables tracing mode\n");
 3838:         printf("      -v : prints the version number\n");
 3839:     }
 3840: 
 3841:     printf("\n");
 3842: 
 3843:     return;
 3844: }
 3845: 
 3846: 
 3847: logical1
 3848: controle_integrite(struct_processus *s_etat_processus,
 3849:         unsigned char *executable_candidat, unsigned char *executable)
 3850: {
 3851:     unsigned char       *md5;
 3852:     unsigned char       *sha1;
 3853: 
 3854:     if (strcmp(executable, "rplpp") == 0)
 3855:     {
 3856:         md5 = rplpp_md5;
 3857:         sha1 = rplpp_sha1;
 3858:     }
 3859:     else if (strcmp(executable, "rplfile") == 0)
 3860:     {
 3861:         md5 = rplfile_md5;
 3862:         sha1 = rplfile_sha1;
 3863:     }
 3864:     else if (strcmp(executable, "rpliconv") == 0)
 3865:     {
 3866:         md5 = rpliconv_md5;
 3867:         sha1 = rpliconv_sha1;
 3868:     }
 3869:     else if (strcmp(executable, "rplawk") == 0)
 3870:     {
 3871:         md5 = rplawk_md5;
 3872:         sha1 = rplawk_sha1;
 3873:     }
 3874:     else if (strcmp(executable, "rplconvert") == 0)
 3875:     {
 3876:         md5 = rplconvert_md5;
 3877:         sha1 = rplconvert_sha1;
 3878:     }
 3879:     else
 3880:     {
 3881:         return(d_faux);
 3882:     }
 3883: 
 3884:     if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai)
 3885:     {
 3886:         return(d_faux);
 3887:     }
 3888: 
 3889:     if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai)
 3890:     {
 3891:         return(d_faux);
 3892:     }
 3893: 
 3894:     return(d_vrai);
 3895: }
 3896: 
 3897: 
 3898: unsigned char *
 3899: date_compilation()
 3900: {
 3901:     unsigned char       *date;
 3902: 
 3903:     if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char)))
 3904:             == NULL)
 3905:     {
 3906:         return(NULL);
 3907:     }
 3908: 
 3909:     strcpy(date, d_date_en_rpl);
 3910: 
 3911:     return(date);
 3912: }
 3913: 
 3914: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>