File:  [local] / rpl / src / rpl.c
Revision 1.117: download - view: text, annotated - select for diffs - revision graph
Sat Sep 15 12:57:09 2012 UTC (11 years, 7 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_10, HEAD
Ajout de l'instruction CRITICAL qui fonctionne comme un bloc
CRITICAL <expression> END.

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

CVSweb interface <joel.bertrand@systella.fr>