Annotation of rpl/src/rpl.c, revision 1.120

1.1       bertrand    1: /*
                      2: ================================================================================
1.118     bertrand    3:   RPL/2 (R) version 4.1.11
1.107     bertrand    4:   Copyright (C) 1989-2012 Dr. BERTRAND Joël
1.1       bertrand    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
1.35      bertrand   24: #include "rpl-conv.h"
1.1       bertrand   25: 
1.37      bertrand   26: 
1.1       bertrand   27: /*
                     28: ================================================================================
                     29:   Programme principal
                     30: ================================================================================
                     31: */
                     32: 
                     33: int
1.101     bertrand   34: rplinit(int argc, char *argv[], char *envp[],
                     35:        unsigned char ***resultats, char *rpl_home)
1.1       bertrand   36: {
1.35      bertrand   37: #  include                             "copyright-conv.h"
                     38: #  include                             "licence-conv.h"
1.1       bertrand   39: 
1.104     bertrand   40:    char                                **arg_exec;
                     41: 
1.97      bertrand   42: #  ifdef HAVE_STACK_OVERFLOW_RECOVERY
1.94      bertrand   43:    char                                pile_signaux[SIGSTKSZ];
1.97      bertrand   44: #  endif
1.94      bertrand   45: 
1.103     bertrand   46: #  define RPL_PATH_MAX                 1024
                     47:    char                                repertoire_initial[RPL_PATH_MAX];
                     48: 
1.1       bertrand   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: 
1.37      bertrand  111:    errno = 0;
1.85      bertrand  112:    s_queue_signaux = NULL;
1.94      bertrand  113:    routine_recursive = 0;
1.82      bertrand  114:    pid_processus_pere = getpid();
1.37      bertrand  115: 
1.27      bertrand  116: #  ifdef DEBUG_MEMOIRE
                    117:    debug_memoire_initialisation();
                    118: #  endif
                    119: 
1.1       bertrand  120:    setvbuf(stdout, NULL, _IOLBF, 0);
                    121:    setvbuf(stderr, NULL, _IOLBF, 0);
                    122: 
1.17      bertrand  123: #  ifndef SEMAPHORES_NOMMES
1.1       bertrand  124:    sem_init(&semaphore_gestionnaires_signaux, 0, 0);
1.17      bertrand  125: #  else
1.92      bertrand  126:    semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX);
1.84      bertrand  127:    
                    128:    if (semaphore_gestionnaires_signaux == SEM_FAILED)
1.17      bertrand  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
1.1       bertrand  151: 
                    152:    if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL)
                    153:    {
                    154:        erreur = d_es_allocation_memoire;
                    155: 
1.17      bertrand  156:        if ((langue = getenv("LANG")) != NULL)
1.1       bertrand  157:        {
1.17      bertrand  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:            }
1.1       bertrand  166:        }
                    167:        else
                    168:        {
1.17      bertrand  169:            uprintf("+++System : Not enough memory\n");
1.1       bertrand  170:        }
                    171: 
                    172:        return(EXIT_FAILURE);
                    173:    }
                    174: 
1.17      bertrand  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: 
1.103     bertrand  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: 
1.104     bertrand  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: 
1.76      bertrand  234:    initialisation_contexte_cas(s_etat_processus);
                    235: 
1.1       bertrand  236:    (*s_etat_processus).exception = d_ep;
                    237:    (*s_etat_processus).erreur_systeme = d_es;
                    238:    (*s_etat_processus).erreur_execution = d_ex;
                    239: 
1.102     bertrand  240:    (*s_etat_processus).requete_redemarrage = d_faux;
1.11      bertrand  241:    (*s_etat_processus).rpl_home = rpl_home;
                    242: 
1.1       bertrand  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: 
1.30      bertrand  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: 
1.117     bertrand  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: 
1.91      bertrand  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(),
1.92      bertrand  263:                pthread_self(), SEM_FORK)) == SEM_FAILED)
1.91      bertrand  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
1.1       bertrand  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: 
1.40      bertrand  296:    (*s_etat_processus).chemin_fichiers_temporaires =
                    297:            recherche_chemin_fichiers_temporaires(s_etat_processus);
                    298: 
1.43      bertrand  299:    insertion_thread(s_etat_processus, d_vrai);
1.83      bertrand  300:    creation_queue_signaux(s_etat_processus);
1.40      bertrand  301: 
1.43      bertrand  302: #  ifndef OS2
                    303:    localisation_courante(s_etat_processus);
                    304: #  else
1.42      bertrand  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:    }
1.40      bertrand  324: #  endif
                    325: 
1.17      bertrand  326:    (*s_etat_processus).erreur_systeme = d_es;
1.1       bertrand  327: 
1.17      bertrand  328:    if ((*s_etat_processus).localisation == NULL)
1.1       bertrand  329:    {
1.17      bertrand  330:        if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) *
                    331:                sizeof(unsigned char))) == NULL)
1.1       bertrand  332:        {
1.17      bertrand  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);
1.1       bertrand  343:        }
                    344: 
1.17      bertrand  345:        strcpy((*s_etat_processus).localisation, d_locale);
1.1       bertrand  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:    {
1.107     bertrand  353:        printf("+++Copyright (C) 1989 à 2011, 2012 BERTRAND Joël\n");
1.1       bertrand  354:    }
                    355:    else
                    356:    {
1.107     bertrand  357:        printf("+++Copyright (C) 1989 to 2011, 2012 BERTRAND Joel\n");
1.1       bertrand  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: 
1.94      bertrand  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;
1.1       bertrand  387: 
1.94      bertrand  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:            }
1.1       bertrand  398: 
1.94      bertrand  399:            return(EXIT_FAILURE);
1.1       bertrand  400:        }
1.94      bertrand  401: #  else
1.1       bertrand  402:        if ((*s_etat_processus).langue == 'F')
                    403:        {
1.94      bertrand  404:            printf("+++Attention : Le système ne supporte pas de pile "
                    405:                    "alternative\n");
1.1       bertrand  406:        }
                    407:        else
                    408:        {
1.94      bertrand  409:            printf("+++Warning : Operating system does not support alternate "
                    410:                    "stack\n");
1.1       bertrand  411:        }
1.9       bertrand  412: #  endif
1.1       bertrand  413: 
1.40      bertrand  414:    action.sa_handler = interruption1;
1.94      bertrand  415:    action.sa_flags = 0;
1.1       bertrand  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: 
1.81      bertrand  434:    signal_test = SIGTEST;
                    435:    kill(getpid(), SIGINT);
                    436: 
1.115     bertrand  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: 
1.81      bertrand  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: 
1.54      bertrand  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: 
1.81      bertrand  479:    signal_test = SIGTEST;
                    480:    kill(getpid(), SIGTERM);
                    481: 
1.115     bertrand  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: 
1.81      bertrand  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: 
1.106     bertrand  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: 
1.115     bertrand  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: 
1.106     bertrand  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: 
1.40      bertrand  552:    action.sa_handler = interruption2;
1.94      bertrand  553:    action.sa_flags = 0;
1.1       bertrand  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: 
1.81      bertrand  570:    signal_test = SIGTEST;
                    571:    kill(getpid(), SIGTSTP);
                    572: 
1.115     bertrand  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: 
1.81      bertrand  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: 
1.40      bertrand  598:    action.sa_handler = interruption5;
1.94      bertrand  599:    action.sa_flags = 0;
1.1       bertrand  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: 
1.81      bertrand  618:    signal_test = SIGTEST;
                    619:    kill(getpid(), SIGPIPE);
                    620: 
1.115     bertrand  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: 
1.81      bertrand  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: 
1.40      bertrand  646:    action.sa_handler = interruption1;
1.94      bertrand  647:    action.sa_flags = 0;
1.1       bertrand  648: 
1.94      bertrand  649:    if (sigaction(SIGUSR1, &action, NULL) != 0)
1.1       bertrand  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: 
1.81      bertrand  666:    signal_test = SIGTEST;
1.94      bertrand  667:    kill(getpid(), SIGUSR1);
1.81      bertrand  668: 
1.115     bertrand  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: 
1.94      bertrand  677:    if (signal_test != SIGUSR1)
1.81      bertrand  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: 
1.82      bertrand  694:    signal_test = SIGTEST + 1;
1.1       bertrand  695: 
1.13      bertrand  696:    erreur = d_absence_erreur;
1.1       bertrand  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:    {
1.13      bertrand  717:        erreur = d_erreur;
1.1       bertrand  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: 
1.86      bertrand  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: 
1.1       bertrand  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: 
1.17      bertrand 1492:                            free(type_debug);
1.1       bertrand 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: 
1.86      bertrand 1546:                        case '-':
                   1547:                        case ' ':
                   1548:                        {
                   1549:                            break;
                   1550:                        }
                   1551: 
1.1       bertrand 1552:                        default :
                   1553:                        {
                   1554:                            if ((*s_etat_processus).langue == 'F')
                   1555:                            {
1.3       bertrand 1556:                                printf("+++Information : Option -%c inconnue\n",
1.1       bertrand 1557:                                        option);
                   1558:                            }
                   1559:                            else
                   1560:                            {
1.3       bertrand 1561:                                printf("+++Warning : -%c option unknown\n",
1.1       bertrand 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: 
1.13      bertrand 1586:                    erreur = d_erreur;
1.1       bertrand 1587:                }
                   1588:                else
                   1589:                {
                   1590:                    (*s_etat_processus).nom_fichier_source = argv[0];
                   1591:                    presence_definition = 'O';
                   1592:                }
                   1593:            }
                   1594:        }
                   1595: 
1.94      bertrand 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: 
1.1       bertrand 1602:        if (debug == d_faux)
                   1603:        {
1.94      bertrand 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
1.82      bertrand 1624:            action.sa_handler = interruption3;
1.94      bertrand 1625:            action.sa_flags = 0;
1.82      bertrand 1626: 
1.1       bertrand 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: 
1.94      bertrand 1643:            signal_test = SIGTEST;
                   1644:            kill(getpid(), SIGSEGV);
                   1645: 
1.115     bertrand 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: 
1.94      bertrand 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: 
1.115     bertrand 1673:            action.sa_handler = interruption3;
                   1674:            action.sa_flags = 0;
                   1675: 
1.1       bertrand 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:            }
1.94      bertrand 1691: 
                   1692:            signal_test = SIGTEST;
                   1693:            kill(getpid(), SIGBUS);
                   1694: 
1.115     bertrand 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: 
1.94      bertrand 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: 
1.1       bertrand 1721:        }
                   1722: 
                   1723:        if (option_n == d_vrai)
                   1724:        {
1.83      bertrand 1725:            action.sa_handler = interruption4;
1.94      bertrand 1726:            action.sa_flags = 0;
1.1       bertrand 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: 
1.13      bertrand 1880:                erreur = d_erreur;
1.1       bertrand 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:            }
1.3       bertrand 1893: 
                   1894:            return(EXIT_FAILURE);
1.1       bertrand 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: 
1.13      bertrand 1927:        if ((erreur == d_absence_erreur) && (presence_definition == 'O'))
1.1       bertrand 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;
1.117     bertrand 1936:            (*s_etat_processus).sections_critiques = 0;
1.1       bertrand 1937: 
                   1938:            (*s_etat_processus).test_instruction = 'N';
                   1939:            (*s_etat_processus).nombre_arguments = 0;
                   1940:            (*s_etat_processus).affichage_arguments = 'N';
1.6       bertrand 1941:            (*s_etat_processus).autorisation_conversion_chaine = 'Y';
1.1       bertrand 1942:            (*s_etat_processus).autorisation_evaluation_nom = 'Y';
1.62      bertrand 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: 
1.1       bertrand 1953:            (*s_etat_processus).autorisation_empilement_programme = 'N';
                   1954:            (*s_etat_processus).requete_arret = 'N';
1.4       bertrand 1955:            (*s_etat_processus).evaluation_forcee = 'N';
1.51      bertrand 1956:            (*s_etat_processus).recherche_type = 'N';
1.1       bertrand 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: 
1.64      bertrand 1968:            (*s_etat_processus).s_arbre_variables = NULL;
1.65      bertrand 1969:            (*s_etat_processus).l_liste_variables_par_niveau = NULL;
1.1       bertrand 1970:            (*s_etat_processus).gel_liste_variables = d_faux;
1.64      bertrand 1971:            (*s_etat_processus).pointeur_variable_courante = NULL;
1.119     bertrand 1972:            (*s_etat_processus).pointeur_variable_statique_courante = NULL;
                   1973:            (*s_etat_processus).l_liste_variables_statiques = NULL;
1.1       bertrand 1974:            (*s_etat_processus).niveau_courant = 0;
                   1975:            (*s_etat_processus).niveau_initial = 0;
                   1976:            (*s_etat_processus).creation_variables_statiques = d_faux;
                   1977:            (*s_etat_processus).creation_variables_partagees = d_faux;
                   1978: 
                   1979:            (*s_etat_processus).s_bibliotheques = NULL;
                   1980:            (*s_etat_processus).s_instructions_externes = NULL;
                   1981:            (*s_etat_processus).nombre_instructions_externes = 0;
                   1982: 
                   1983:            (*s_etat_processus).systeme_axes = 0;
                   1984: 
                   1985:            (*s_etat_processus).x_min = -10.;
                   1986:            (*s_etat_processus).x_max = 10.;
                   1987:            (*s_etat_processus).y_min = -10.;
                   1988:            (*s_etat_processus).y_max = 10.;
                   1989:            (*s_etat_processus).z_min = -10.;
                   1990:            (*s_etat_processus).z_max = 10.;
                   1991: 
                   1992:            (*s_etat_processus).x2_min = -10.;
                   1993:            (*s_etat_processus).x2_max = 10.;
                   1994:            (*s_etat_processus).y2_min = -10.;
                   1995:            (*s_etat_processus).y2_max = 10.;
                   1996:            (*s_etat_processus).z2_min = -10.;
                   1997:            (*s_etat_processus).z2_max = 10.;
                   1998: 
                   1999:            (*s_etat_processus).resolution = .01;
                   2000: 
                   2001:            (*s_etat_processus).souris_active = d_faux;
                   2002: 
                   2003:            (*s_etat_processus).echelle_automatique_x = d_faux;
                   2004:            (*s_etat_processus).echelle_automatique_y = d_faux;
                   2005:            (*s_etat_processus).echelle_automatique_z = d_faux;
                   2006: 
                   2007:            (*s_etat_processus).echelle_automatique_x2 = d_faux;
                   2008:            (*s_etat_processus).echelle_automatique_y2 = d_faux;
                   2009:            (*s_etat_processus).echelle_automatique_z2 = d_faux;
                   2010: 
                   2011:            (*s_etat_processus).echelle_log_x = d_faux;
                   2012:            (*s_etat_processus).echelle_log_y = d_faux;
                   2013:            (*s_etat_processus).echelle_log_z = d_faux;
                   2014: 
                   2015:            (*s_etat_processus).echelle_log_x2 = d_faux;
                   2016:            (*s_etat_processus).echelle_log_y2 = d_faux;
                   2017:            (*s_etat_processus).echelle_log_z2 = d_faux;
                   2018: 
                   2019:            (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
                   2020:            (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
                   2021:            (*s_etat_processus).echelle_3D = 1;
                   2022: 
                   2023:            strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
                   2024:            strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
                   2025:            (*s_etat_processus).fichiers_graphiques = NULL;
                   2026:            (*s_etat_processus).nom_fichier_impression = NULL;
                   2027:            strcpy((*s_etat_processus).format_papier, "a4paper");
                   2028:            (*s_etat_processus).entree_standard = NULL;
                   2029:            (*s_etat_processus).s_marques = NULL;
                   2030:            (*s_etat_processus).requete_nouveau_plan = d_vrai;
                   2031:            (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
                   2032: 
                   2033:            (*s_etat_processus).l_base_pile = NULL;
                   2034:            (*s_etat_processus).hauteur_pile_operationnelle = 0;
                   2035:            (*s_etat_processus).l_base_pile_contextes = NULL;
                   2036:            (*s_etat_processus).l_base_pile_taille_contextes = NULL;
                   2037: 
                   2038:            (*s_etat_processus).position_courante = 0;
                   2039: 
                   2040:            (*s_etat_processus).l_base_pile_systeme = NULL;
                   2041:            (*s_etat_processus).hauteur_pile_systeme = 0;
                   2042: 
                   2043:            (*s_etat_processus).l_base_pile_processus = NULL;
                   2044:            (*s_etat_processus).presence_pipes = d_faux;
                   2045:            (*s_etat_processus).pipe_donnees = 0;
                   2046:            (*s_etat_processus).pipe_acquittement = 0;
                   2047:            (*s_etat_processus).pipe_injections = 0;
                   2048:            (*s_etat_processus).pipe_nombre_injections = 0;
                   2049:            (*s_etat_processus).nombre_objets_injectes = 0;
                   2050:            (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
                   2051:            (*s_etat_processus).pourcentage_maximal_cpu = 100;
                   2052:            (*s_etat_processus).temps_maximal_cpu = 0;
                   2053:            (*s_etat_processus).thread_fusible = 0;
                   2054:            (*s_etat_processus).presence_fusible = d_faux;
                   2055: 
                   2056:            (*s_etat_processus).niveau_recursivite = 0;
                   2057:            (*s_etat_processus).generateur_aleatoire = NULL;
                   2058:            (*s_etat_processus).type_generateur_aleatoire = NULL;
                   2059: 
                   2060:            (*s_etat_processus).colonne_statistique_1 = 1; 
                   2061:            (*s_etat_processus).colonne_statistique_2 = 2; 
                   2062: 
                   2063:            (*s_etat_processus).debug_programme = d_faux;
                   2064:            (*s_etat_processus).execution_pas_suivant = d_faux;
                   2065:            (*s_etat_processus).traitement_instruction_halt = d_faux;
                   2066: 
                   2067:            (*s_etat_processus).derniere_exception = d_ep;
                   2068:            (*s_etat_processus).derniere_erreur_systeme = d_es;
                   2069:            (*s_etat_processus).derniere_erreur_execution = d_ex;
                   2070:            (*s_etat_processus).derniere_erreur_evaluation = d_ex;
                   2071:            (*s_etat_processus).derniere_erreur_fonction_externe = 0;
                   2072: 
                   2073:            (*s_etat_processus).erreur_processus_fils = d_faux;
                   2074:            (*s_etat_processus).erreur_systeme_processus_fils = d_es;
                   2075:            (*s_etat_processus).erreur_execution_processus_fils = d_ex;
                   2076:            (*s_etat_processus).pid_erreur_processus_fils = 0;
                   2077:            (*s_etat_processus).exception_processus_fils = d_ep;
                   2078:            (*s_etat_processus).core = core;
                   2079:            (*s_etat_processus).invalidation_message_erreur = d_faux;
                   2080:            (*s_etat_processus).s_objet_errone = NULL;
                   2081:            (*s_etat_processus).s_objet_erreur = NULL;
                   2082: 
                   2083:            (*s_etat_processus).retour_routine_evaluation = 'N';
                   2084: 
                   2085:            (*s_etat_processus).traitement_interruption = 'N';
                   2086:            (*s_etat_processus).traitement_interruptible = 'Y';
                   2087:            (*s_etat_processus).nombre_interruptions_en_queue = 0;
                   2088:            (*s_etat_processus).nombre_interruptions_non_affectees = 0;
                   2089: 
                   2090:            for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
                   2091:            {
                   2092:                (*s_etat_processus).masque_interruptions[i] = 'N';
                   2093:                (*s_etat_processus).queue_interruptions[i] = 0;
                   2094:                (*s_etat_processus).corps_interruptions[i] = NULL;
                   2095:                (*s_etat_processus).pile_origine_interruptions[i] = NULL;
                   2096:            }
                   2097: 
1.20      bertrand 2098:            (*s_etat_processus).at_exit = NULL;
1.34      bertrand 2099:            (*s_etat_processus).at_poke = NULL;
                   2100:            (*s_etat_processus).traitement_at_poke = 'N';
1.19      bertrand 2101: 
1.1       bertrand 2102:            (*s_etat_processus).pointeurs_caracteres = NULL;
                   2103:            (*s_etat_processus).arbre_instructions = NULL;
                   2104: 
                   2105:            (*s_etat_processus).tid_processus_pere = pthread_self();
1.113     bertrand 2106:            (*s_etat_processus).tid = pthread_self();
1.1       bertrand 2107:            (*s_etat_processus).pid_processus_pere = getpid();
                   2108:            (*s_etat_processus).processus_detache = d_vrai;
                   2109:            (*s_etat_processus).var_volatile_processus_pere = -1;
1.45      bertrand 2110:            (*s_etat_processus).var_volatile_processus_racine = -1;
1.1       bertrand 2111:            (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
                   2112:            (*s_etat_processus).var_volatile_alarme = 0;
                   2113:            (*s_etat_processus).var_volatile_requete_arret = 0;
                   2114:            (*s_etat_processus).var_volatile_requete_arret2 = 0;
                   2115:            (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
                   2116:            (*s_etat_processus).var_volatile_traitement_sigint = 0;
                   2117:            (*s_etat_processus).var_volatile_recursivite = 0;
                   2118:            (*s_etat_processus).var_volatile_exception_gsl = 0;
1.22      bertrand 2119:            (*s_etat_processus).arret_depuis_abort = 0;
1.83      bertrand 2120:            (*s_etat_processus).pointeur_signal_lecture = 0;
                   2121:            (*s_etat_processus).pointeur_signal_ecriture = 0;
1.1       bertrand 2122: 
                   2123:            initialisation_allocateur(s_etat_processus);
                   2124:            initialisation_drapeaux(s_etat_processus);
1.65      bertrand 2125:            initialisation_variables(s_etat_processus);
                   2126:            initialisation_instructions(s_etat_processus);
1.1       bertrand 2127: 
                   2128:            if ((*s_etat_processus).erreur_systeme != d_es)
                   2129:            {
                   2130:                if ((*s_etat_processus).langue == 'F')
                   2131:                {
                   2132:                    printf("+++Système : Mémoire insuffisante\n");
                   2133:                }
                   2134:                else
                   2135:                {
                   2136:                    printf("+++System : Not enough memory\n");
                   2137:                }
                   2138: 
                   2139:                return(EXIT_FAILURE);
                   2140:            }
                   2141: 
                   2142:            if (((*s_etat_processus).instruction_derniere_erreur =
1.32      bertrand 2143:                    malloc(sizeof(unsigned char))) == NULL)
1.1       bertrand 2144:            {
                   2145:                erreur = d_es_allocation_memoire;
                   2146: 
                   2147:                if ((*s_etat_processus).langue == 'F')
                   2148:                {
                   2149:                    printf("+++Système : Mémoire insuffisante\n");
                   2150:                }
                   2151:                else
                   2152:                {
                   2153:                    printf("+++System : Not enough memory\n");
                   2154:                }
                   2155: 
                   2156:                return(EXIT_FAILURE);
                   2157:            }
                   2158: 
                   2159:            strcpy((*s_etat_processus).instruction_derniere_erreur, "");
                   2160:            (*s_etat_processus).niveau_derniere_erreur = 0;
                   2161: 
                   2162:            if (traitement_fichier_temporaire == 'Y')
                   2163:            {
                   2164:                (*s_etat_processus).mode_interactif = 'Y';
                   2165:            }
                   2166:            else
                   2167:            {
                   2168:                (*s_etat_processus).mode_interactif = 'N';
                   2169:            }
                   2170: 
                   2171:            if (((*s_etat_processus).instruction_courante = (unsigned char *)
                   2172:                    malloc(sizeof(unsigned char))) == NULL)
                   2173:            {
                   2174:                erreur = d_es_allocation_memoire;
                   2175: 
                   2176:                if ((*s_etat_processus).langue == 'F')
                   2177:                {
                   2178:                    printf("+++Système : Mémoire insuffisante\n");
                   2179:                }
                   2180:                else
                   2181:                {
                   2182:                    printf("+++System : Not enough memory\n");
                   2183:                }
                   2184: 
                   2185:                return(EXIT_FAILURE);
                   2186:            }
                   2187: 
                   2188:            (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
                   2189: 
                   2190:            empilement_pile_systeme(s_etat_processus);
                   2191: 
                   2192:            free((*s_etat_processus).instruction_courante);
                   2193: 
1.41      bertrand 2194:            if ((*s_etat_processus).erreur_systeme != d_es)
1.1       bertrand 2195:            {
                   2196:                erreur = d_es_allocation_memoire;
                   2197:            }
                   2198:            else
                   2199:            {
                   2200:                (*((*s_etat_processus).l_base_pile_systeme))
                   2201:                        .retour_definition = 'Y';
                   2202: 
1.111     bertrand 2203:                (*s_etat_processus).indep = allocation(s_etat_processus, NON);
                   2204:                (*s_etat_processus).depend = allocation(s_etat_processus, NON);
1.1       bertrand 2205:                (*s_etat_processus).parametres_courbes_de_niveau =
1.111     bertrand 2206:                        allocation(s_etat_processus, NON);
1.1       bertrand 2207: 
                   2208:                if (((*s_etat_processus).indep != NULL) &&
                   2209:                        ((*s_etat_processus).depend != NULL) &&
                   2210:                        ((*s_etat_processus).parametres_courbes_de_niveau
                   2211:                        != NULL))
                   2212:                {
                   2213:                    (*((*s_etat_processus).indep)).type = NOM;
                   2214:                    (*((*s_etat_processus).depend)).type = NOM;
                   2215:                    (*((*s_etat_processus).
                   2216:                            parametres_courbes_de_niveau)).type = LST;
                   2217: 
                   2218:                    initialisation_objet((*s_etat_processus).indep);
                   2219:                    initialisation_objet((*s_etat_processus).depend);
                   2220:                    initialisation_objet((*s_etat_processus)
                   2221:                            .parametres_courbes_de_niveau);
                   2222: 
                   2223:                    (*((*s_etat_processus).indep)).objet = (struct_nom *)
                   2224:                            malloc(sizeof(struct_nom));
                   2225:                    (*((*s_etat_processus).depend)).objet = (struct_nom *)
                   2226:                            malloc(sizeof(struct_nom));
                   2227:                    (*((*s_etat_processus).parametres_courbes_de_niveau))
                   2228:                            .objet = (struct_liste_chainee *)
                   2229:                            malloc(sizeof(struct_liste_chainee));
                   2230: 
                   2231:                    if (((*((*s_etat_processus).depend)).objet == NULL) ||
                   2232:                            ((*((*s_etat_processus).depend)).objet == NULL) ||
                   2233:                            ((*((*s_etat_processus).
                   2234:                            parametres_courbes_de_niveau)).objet == NULL))
                   2235:                    {
                   2236:                        erreur = d_es_allocation_memoire;
                   2237:                        
                   2238:                        if ((*s_etat_processus).langue == 'F')
                   2239:                        {
                   2240:                            printf("+++Système : Mémoire insuffisante\n");
                   2241:                        }
                   2242:                        else
                   2243:                        {
                   2244:                            printf("+++System : Not enough memory\n");
                   2245:                        }
                   2246: 
                   2247:                        return(EXIT_FAILURE);
                   2248:                    }
                   2249: 
                   2250:                    (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
                   2251:                            .nom = malloc(2 * sizeof(unsigned char));
                   2252:                    (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
                   2253:                            .nom = malloc(2 * sizeof(unsigned char));
                   2254: 
                   2255:                    if (((*((struct_nom *) (*((*s_etat_processus).indep))
                   2256:                            .objet)).nom == NULL) || ((*((struct_nom *)
                   2257:                            (*((*s_etat_processus).depend)).objet)).nom ==
                   2258:                            NULL))
                   2259:                    {
                   2260:                        erreur = d_es_allocation_memoire;
                   2261: 
                   2262:                        if ((*s_etat_processus).langue == 'F')
                   2263:                        {
                   2264:                            printf("+++Système : Mémoire insuffisante\n");
                   2265:                        }
                   2266:                        else
                   2267:                        {
                   2268:                            printf("+++System : Not enough memory\n");
                   2269:                        }
                   2270: 
                   2271:                        return(EXIT_FAILURE);
                   2272:                    }
                   2273: 
                   2274:                    strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
                   2275:                            .objet)).nom, "X");
                   2276:                    strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
                   2277:                            .objet)).nom, "Y");
                   2278: 
                   2279:                    (*((struct_nom *) (*((*s_etat_processus).indep))
                   2280:                            .objet)).symbole = d_vrai;
                   2281:                    (*((struct_nom *) (*((*s_etat_processus).depend))
                   2282:                            .objet)).symbole = d_vrai;
                   2283: 
                   2284:                    (*((struct_liste_chainee *) (*((*s_etat_processus)
                   2285:                            .parametres_courbes_de_niveau)).objet)).suivant
                   2286:                            = NULL;
                   2287: 
                   2288:                    (*((struct_liste_chainee *) (*((*s_etat_processus)
                   2289:                            .parametres_courbes_de_niveau)).objet)).donnee
                   2290:                            = malloc(sizeof(struct_objet));
                   2291: 
                   2292:                    (*s_etat_processus).legende =
                   2293:                            malloc(sizeof(unsigned char));
                   2294:                    (*s_etat_processus).label_x =
                   2295:                            malloc(sizeof(unsigned char));
                   2296:                    (*s_etat_processus).label_y =
                   2297:                            malloc(sizeof(unsigned char));
                   2298:                    (*s_etat_processus).label_z =
                   2299:                            malloc(sizeof(unsigned char));
                   2300:                    (*s_etat_processus).titre =
                   2301:                            malloc(sizeof(unsigned char));
                   2302: 
                   2303:                    if (((*s_etat_processus).label_x == NULL) ||
                   2304:                            ((*s_etat_processus).label_y == NULL) ||
                   2305:                            ((*s_etat_processus).label_z == NULL) ||
                   2306:                            ((*s_etat_processus).titre == NULL) ||
                   2307:                            ((*s_etat_processus).legende == NULL) ||
                   2308:                            ((*((struct_liste_chainee *) (*((*s_etat_processus)
                   2309:                            .parametres_courbes_de_niveau)).objet)).donnee
                   2310:                            == NULL))
                   2311:                    {
                   2312:                        erreur = d_es_allocation_memoire;
                   2313: 
                   2314:                        if ((*s_etat_processus).langue == 'F')
                   2315:                        {
                   2316:                            printf("+++Système : Mémoire insuffisante\n");
                   2317:                        }
                   2318:                        else
                   2319:                        {
                   2320:                            printf("+++System : Not enough memory\n");
                   2321:                        }
                   2322: 
                   2323:                        return(EXIT_FAILURE);
                   2324:                    }
                   2325: 
                   2326:                    (*(*((struct_liste_chainee *) (*((*s_etat_processus)
                   2327:                            .parametres_courbes_de_niveau)).objet)).donnee)
                   2328:                            .type = CHN;
                   2329: 
                   2330:                    initialisation_objet((*((struct_liste_chainee *)
                   2331:                            (*((*s_etat_processus)
                   2332:                            .parametres_courbes_de_niveau))
                   2333:                            .objet)).donnee);
                   2334: 
                   2335:                    if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
                   2336:                            .parametres_courbes_de_niveau)).objet)).donnee)
                   2337:                            .objet = malloc(10 * sizeof(unsigned char)))
                   2338:                            == NULL)
                   2339:                    {
                   2340:                        erreur = d_es_allocation_memoire;
                   2341: 
                   2342:                        if ((*s_etat_processus).langue == 'F')
                   2343:                        {
                   2344:                            printf("+++Système : Mémoire insuffisante\n");
                   2345:                        }
                   2346:                        else
                   2347:                        {
                   2348:                            printf("+++System : Not enough memory\n");
                   2349:                        }
                   2350: 
                   2351:                        return(EXIT_FAILURE);
                   2352:                    }
                   2353: 
                   2354:                    strcpy((unsigned char *) (*(*((struct_liste_chainee *)
                   2355:                            (*((*s_etat_processus)
                   2356:                            .parametres_courbes_de_niveau))
                   2357:                            .objet)).donnee).objet, "AUTOMATIC");
                   2358: 
                   2359:                    (*s_etat_processus).label_x[0] = d_code_fin_chaine;
                   2360:                    (*s_etat_processus).label_y[0] = d_code_fin_chaine;
                   2361:                    (*s_etat_processus).label_z[0] = d_code_fin_chaine;
                   2362:                    (*s_etat_processus).titre[0] = d_code_fin_chaine;
                   2363:                    (*s_etat_processus).legende[0] = d_code_fin_chaine;
                   2364: 
                   2365:                    (*s_etat_processus).nom_fichier_gnuplot = NULL;
                   2366:                    (*s_etat_processus).type_fichier_gnuplot = NULL;
                   2367: 
                   2368:                    (*s_etat_processus).x_tics = 0;
                   2369:                    (*s_etat_processus).y_tics = 0;
                   2370:                    (*s_etat_processus).z_tics = 0;
                   2371: 
                   2372:                    (*s_etat_processus).x_lines = d_vrai;
                   2373:                    (*s_etat_processus).y_lines = d_vrai;
                   2374:                    (*s_etat_processus).z_lines = d_vrai;
                   2375: 
                   2376:                    (*s_etat_processus).mx_tics = -1;
                   2377:                    (*s_etat_processus).my_tics = -1;
                   2378:                    (*s_etat_processus).mz_tics = -1;
                   2379: 
                   2380:                    (*s_etat_processus).mx_lines = d_faux;
                   2381:                    (*s_etat_processus).my_lines = d_faux;
                   2382:                    (*s_etat_processus).mz_lines = d_faux;
                   2383: 
                   2384:                    (*s_etat_processus).x2_tics = -1;
                   2385:                    (*s_etat_processus).y2_tics = -1;
                   2386:                    (*s_etat_processus).z2_tics = -1;
                   2387: 
                   2388:                    (*s_etat_processus).x2_lines = d_faux;
                   2389:                    (*s_etat_processus).y2_lines = d_faux;
                   2390:                    (*s_etat_processus).z2_lines = d_faux;
                   2391: 
                   2392:                    (*s_etat_processus).mx2_tics = -1;
                   2393:                    (*s_etat_processus).my2_tics = -1;
                   2394:                    (*s_etat_processus).mz2_tics = -1;
                   2395: 
                   2396:                    (*s_etat_processus).mx2_lines = d_faux;
                   2397:                    (*s_etat_processus).my2_lines = d_faux;
                   2398:                    (*s_etat_processus).mz2_lines = d_faux;
                   2399: 
                   2400:                    if ((*s_etat_processus).erreur_systeme != d_es)
                   2401:                    {
                   2402:                        if ((*s_etat_processus).langue == 'F')
                   2403:                        {
                   2404:                            printf("+++Système : Mémoire insuffisante\n");
                   2405:                        }
                   2406:                        else
                   2407:                        {
                   2408:                            printf("+++System : Not enough memory\n");
                   2409:                        }
                   2410: 
                   2411:                        return(EXIT_FAILURE);
                   2412:                    }
                   2413: 
                   2414:                    (*s_etat_processus).mode_evaluation_expression = 'N';
                   2415:                    (*s_etat_processus).mode_execution_programme = 'Y';
                   2416: 
                   2417:                    if ((*s_etat_processus).definitions_chainees == NULL)
                   2418:                    {
                   2419:                        if ((erreur = chainage(s_etat_processus)) !=
                   2420:                                d_absence_erreur)
                   2421:                        {
                   2422:                            if ((*s_etat_processus).langue == 'F')
                   2423:                            {
                   2424:                                printf("+++Fatal :"
                   2425:                                        " Chaînage des définitions"
                   2426:                                        " impossible\n");
                   2427:                            }
                   2428:                            else
                   2429:                            {
                   2430:                                printf("+++Fatal : Error in "
                   2431:                                        "compilation\n");
                   2432:                            }
                   2433: 
                   2434:                            if (traitement_fichier_temporaire == 'Y')
                   2435:                            {
                   2436:                                if (destruction_fichier(
                   2437:                                        nom_fichier_temporaire)
                   2438:                                        == d_erreur)
                   2439:                                {
                   2440:                                    return(EXIT_FAILURE);
                   2441:                                }
                   2442: 
                   2443:                                free(nom_fichier_temporaire);
                   2444:                            }
                   2445: 
                   2446:                            return(EXIT_FAILURE);
                   2447:                        }
                   2448:                    }
                   2449: 
                   2450:                    if ((erreur = compilation(s_etat_processus)) !=
                   2451:                            d_absence_erreur)
                   2452:                    {
                   2453:                        if (traitement_fichier_temporaire == 'Y')
                   2454:                        {
                   2455:                            if (destruction_fichier(nom_fichier_temporaire)
                   2456:                                    == d_erreur)
                   2457:                            {
                   2458:                                return(EXIT_FAILURE);
                   2459:                            }
                   2460: 
                   2461:                            free(nom_fichier_temporaire);
                   2462:                        }
                   2463: 
                   2464:                        printf("%s [%d]\n", message =
                   2465:                                messages(s_etat_processus), (int) getpid());
                   2466:                        free(message);
                   2467: 
                   2468:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   2469:                        {
                   2470:                            printf("%s", ds_beep);
                   2471:                        }
                   2472: 
                   2473:                        if ((*s_etat_processus).core == d_vrai)
                   2474:                        {
                   2475:                            printf("\n");
                   2476:                            
                   2477:                            if ((*s_etat_processus).langue == 'F')
                   2478:                            {
                   2479:                                printf("+++Information : Génération du fichier "
                   2480:                                        "rpl-core [%d]\n", (int) getpid());
                   2481:                            }
                   2482:                            else
                   2483:                            {
                   2484:                                printf("+++Information : Writing rpl-core "
                   2485:                                        "file [%d]\n", (int) getpid());
                   2486:                            }
                   2487: 
                   2488:                            rplcore(s_etat_processus);
                   2489: 
                   2490:                            if ((*s_etat_processus).langue == 'F')
                   2491:                            {
                   2492:                                printf("+++Information : Processus tracé "
                   2493:                                        "[%d]\n", (int) getpid());
                   2494:                            }
                   2495:                            else
                   2496:                            {
                   2497:                                printf("+++Information : Done [%d]\n",
                   2498:                                        (int) getpid());
                   2499:                            }
                   2500: 
                   2501:                            printf("\n");
                   2502:                        }
                   2503: 
                   2504:                        return(EXIT_FAILURE);
                   2505:                    }
                   2506: 
                   2507:                    (*s_etat_processus).position_courante = 0;
                   2508:                    (*s_etat_processus).traitement_cycle_exit = 'N';
                   2509: 
1.64      bertrand 2510:                    if ((*s_etat_processus).s_arbre_variables == NULL)
1.1       bertrand 2511:                    {
                   2512:                        if ((*s_etat_processus).langue == 'F')
                   2513:                        {
                   2514:                            printf("+++Fatal : Aucun point d'entrée\n");
                   2515:                        }
                   2516:                        else
                   2517:                        {
                   2518:                            printf("+++Fatal : Any entry point\n");
                   2519:                        }
                   2520: 
                   2521:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   2522:                        {
                   2523:                            printf("%s", ds_beep);
                   2524:                        }
                   2525: 
                   2526:                        return(EXIT_FAILURE);
                   2527:                    }
                   2528: 
                   2529:                    if (recherche_instruction_suivante(s_etat_processus)
                   2530:                            == d_erreur)
                   2531:                    {
                   2532:                        if ((*s_etat_processus).langue == 'F')
                   2533:                        {
                   2534:                            printf("+++Fatal : Aucun point d'entrée\n");
                   2535:                        }
                   2536:                        else
                   2537:                        {
                   2538:                            printf("+++Fatal : Any entry point\n");
                   2539:                        }
                   2540: 
                   2541:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   2542:                        {
                   2543:                            printf("%s", ds_beep);
                   2544:                        }
                   2545: 
                   2546:                        return(EXIT_FAILURE);
                   2547:                    }
                   2548: 
                   2549:                    if (recherche_variable(s_etat_processus,
                   2550:                            (*s_etat_processus)
                   2551:                            .instruction_courante) == d_faux)
                   2552:                    {
                   2553:                        if ((*s_etat_processus).langue == 'F')
                   2554:                        {
                   2555:                            printf("+++Fatal : Aucun point d'entrée\n");
                   2556:                        }
                   2557:                        else
                   2558:                        {
                   2559:                            printf("+++Fatal : Any entry point\n");
                   2560:                        }
                   2561: 
                   2562:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   2563:                        {
                   2564:                            printf("%s", ds_beep);
                   2565:                        }
                   2566: 
                   2567:                        return(EXIT_FAILURE);
                   2568:                    }
                   2569: 
1.64      bertrand 2570:                    if ((*(*s_etat_processus).pointeur_variable_courante)
                   2571:                            .niveau != 0)
1.1       bertrand 2572:                    {
                   2573:                        if ((*s_etat_processus).langue == 'F')
                   2574:                        {
                   2575:                            printf("+++Fatal : Aucun point d'entrée\n");
                   2576:                        }
                   2577:                        else
                   2578:                        {
                   2579:                            printf("+++Fatal : Any entry point\n");
                   2580:                        }
                   2581: 
                   2582:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   2583:                        {
                   2584:                            printf("%s", ds_beep);
                   2585:                        }
                   2586: 
                   2587:                        return(EXIT_FAILURE);
                   2588:                    }
                   2589: 
                   2590:                    free((*s_etat_processus).instruction_courante);
                   2591:                    (*s_etat_processus).position_courante = 0;
                   2592: 
                   2593:                    if (((*s_etat_processus).nom_fichier_historique =
                   2594:                            malloc((strlen(home) +
                   2595:                            strlen(ds_fichier_historique) + 2) *
                   2596:                            sizeof(unsigned char))) == NULL)
                   2597:                    {
                   2598:                        erreur = d_es_allocation_memoire;
                   2599: 
                   2600:                        if ((*s_etat_processus).langue == 'F')
                   2601:                        {
                   2602:                            printf("+++Système : Mémoire insuffisante\n");
                   2603:                        }
                   2604:                        else
                   2605:                        {
                   2606:                            printf("+++System : Not enough memory\n");
                   2607:                        }
                   2608: 
                   2609:                        return(EXIT_FAILURE);
                   2610:                    }
                   2611: 
                   2612:                    sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
                   2613:                            home, ds_fichier_historique);
                   2614: 
                   2615:                    using_history();
1.109     bertrand 2616: 
                   2617:                    // Pour pouvoir utiliser le keymap avant le premier
                   2618:                    // appel à readline().
                   2619:                    rl_initialize();
                   2620: 
1.1       bertrand 2621:                    erreur_historique = read_history(
                   2622:                            (*s_etat_processus).nom_fichier_historique);
                   2623: 
                   2624:                    gsl_set_error_handler(&traitement_exceptions_gsl);
                   2625: 
                   2626:                    if (drapeau_encart == 'Y')
                   2627:                    {
                   2628:                        (*s_etat_processus).erreur_systeme = d_es;
                   2629:                        encart(s_etat_processus,
                   2630:                                (unsigned long) (5 * 1000000));
                   2631: 
                   2632:                        if ((*s_etat_processus).erreur_systeme != d_es)
                   2633:                        {
                   2634:                            if ((message = messages(s_etat_processus))
                   2635:                                    == NULL)
                   2636:                            {
                   2637:                                erreur = d_es_allocation_memoire;
                   2638: 
                   2639:                                if ((*s_etat_processus).langue == 'F')
                   2640:                                {
                   2641:                                    printf("+++Système : Mémoire "
                   2642:                                            "insuffisante\n");
                   2643:                                }
                   2644:                                else
                   2645:                                {
                   2646:                                    printf("+++System : Not enough "
                   2647:                                            "memory\n");
                   2648:                                }
                   2649: 
                   2650:                                return(EXIT_FAILURE);
                   2651:                            }
                   2652: 
                   2653:                            printf("%s [%d]\n", message, (int) getpid());
                   2654:                            free(message);
                   2655: 
                   2656:                            return(EXIT_FAILURE);
                   2657:                        }
                   2658:                    }
                   2659: 
                   2660:                    fflush(stdout);
                   2661: 
                   2662:                    if (arguments != NULL)
                   2663:                    {
                   2664:                        tampon = (*s_etat_processus).definitions_chainees;
                   2665:                        (*s_etat_processus).definitions_chainees =
                   2666:                                arguments;
                   2667: 
                   2668:                        if (analyse_syntaxique(s_etat_processus) ==
                   2669:                                d_erreur)
                   2670:                        {
                   2671:                            if ((*s_etat_processus).erreur_systeme != d_es)
                   2672:                            {
                   2673:                                erreur = d_es_allocation_memoire;
                   2674: 
                   2675:                                if ((*s_etat_processus).langue == 'F')
                   2676:                                {
                   2677:                                    printf("+++Système : Mémoire "
                   2678:                                            "insuffisante\n");
                   2679:                                }
                   2680:                                else
                   2681:                                {
                   2682:                                    printf("+++System : Not enough "
                   2683:                                            "memory\n");
                   2684:                                }
                   2685: 
                   2686:                                return(EXIT_FAILURE);
                   2687:                            }
                   2688:                            else
                   2689:                            {
                   2690:                                if ((*s_etat_processus).langue == 'F')
                   2691:                                {
                   2692:                                    printf("+++Erreur : Erreur de "
                   2693:                                            "syntaxe\n");
                   2694:                                }
                   2695:                                else
                   2696:                                {
                   2697:                                    printf("+++Error : Syntax error\n");
                   2698:                                }
                   2699: 
                   2700:                                return(EXIT_FAILURE);
                   2701:                            }
                   2702:                        }
                   2703: 
                   2704:                        (*s_etat_processus).instruction_courante
                   2705:                                = arguments;
                   2706:                        (*s_etat_processus).definitions_chainees = tampon;
                   2707:                        (*s_etat_processus).position_courante = 0;
                   2708: 
                   2709:                        recherche_type(s_etat_processus);
                   2710: 
                   2711:                        if ((*s_etat_processus).erreur_systeme != d_es)
                   2712:                        {
                   2713:                            if ((message = messages(s_etat_processus))
                   2714:                                    == NULL)
                   2715:                            {
                   2716:                                erreur = d_es_allocation_memoire;
                   2717: 
                   2718:                                if ((*s_etat_processus).langue == 'F')
                   2719:                                {
                   2720:                                    printf("+++Système : Mémoire "
                   2721:                                            "insuffisante\n");
                   2722:                                }
                   2723:                                else
                   2724:                                {
                   2725:                                    printf("+++System : Not enough "
                   2726:                                            "memory\n");
                   2727:                                }
                   2728: 
                   2729:                                return(EXIT_FAILURE);
                   2730:                            }
                   2731: 
                   2732:                            printf("%s [%d]\n", message, (int) getpid());
                   2733:                            free(message);
                   2734: 
                   2735:                            return(EXIT_FAILURE);
                   2736:                        }
                   2737: 
                   2738:                        if ((*s_etat_processus).erreur_execution != d_ex)
                   2739:                        {
                   2740:                            if ((message = messages(s_etat_processus))
                   2741:                                    == NULL)
                   2742:                            {
                   2743:                                erreur = d_es_allocation_memoire;
                   2744: 
                   2745:                                if ((*s_etat_processus).langue == 'F')
                   2746:                                {
                   2747:                                    printf("+++Erreur : Mémoire "
                   2748:                                            "insuffisante\n");
                   2749:                                }
                   2750:                                else
                   2751:                                {
                   2752:                                    printf("+++Error : Not enough "
                   2753:                                            "memory\n");
                   2754:                                }
                   2755: 
                   2756:                                return(EXIT_FAILURE);
                   2757:                            }
                   2758: 
                   2759:                            printf("%s [%d]\n", message, (int) getpid());
                   2760:                            free(message);
                   2761: 
                   2762:                            return(EXIT_FAILURE);
                   2763:                        }
                   2764: 
                   2765:                        if (depilement(s_etat_processus,
                   2766:                                &((*s_etat_processus).l_base_pile),
                   2767:                                &s_objet) == d_erreur)
                   2768:                        {
                   2769:                            if ((message = messages(s_etat_processus))
                   2770:                                    == NULL)
                   2771:                            {
                   2772:                                erreur = d_es_allocation_memoire;
                   2773: 
                   2774:                                if ((*s_etat_processus).langue == 'F')
                   2775:                                {
                   2776:                                    printf("+++Erreur : Mémoire "
                   2777:                                            "insuffisante\n");
                   2778:                                }
                   2779:                                else
                   2780:                                {
                   2781:                                    printf("+++Error : Not enough "
                   2782:                                            "memory\n");
                   2783:                                }
                   2784: 
                   2785:                                return(EXIT_FAILURE);
                   2786:                            }
                   2787: 
                   2788:                            printf("%s [%d]\n", message, (int) getpid());
                   2789:                            free(message);
                   2790: 
                   2791:                            return(EXIT_FAILURE);
                   2792:                        }
                   2793: 
                   2794:                        if (evaluation(s_etat_processus, s_objet, 'E')
                   2795:                                == d_erreur)
                   2796:                        {
                   2797:                            if ((*s_etat_processus).erreur_systeme != d_es)
                   2798:                            {
                   2799:                                if ((message = messages(s_etat_processus))
                   2800:                                        == NULL)
                   2801:                                {
                   2802:                                    erreur = d_es_allocation_memoire;
                   2803: 
                   2804:                                    if ((*s_etat_processus).langue == 'F')
                   2805:                                    {
                   2806:                                        printf("+++Système : Mémoire "
                   2807:                                                "insuffisante\n");
                   2808:                                    }
                   2809:                                    else
                   2810:                                    {
                   2811:                                        printf("+++System : Not enough "
                   2812:                                                "memory\n");
                   2813:                                    }
                   2814: 
                   2815:                                    return(EXIT_FAILURE);
                   2816:                                }
                   2817: 
                   2818:                                printf("%s [%d]\n", message,
                   2819:                                        (int) getpid());
                   2820:                                free(message);
                   2821: 
                   2822:                                return(EXIT_FAILURE);
                   2823:                            }
                   2824: 
                   2825:                            if ((*s_etat_processus).erreur_execution
                   2826:                                    != d_ex)
                   2827:                            {
                   2828:                                if ((message = messages(s_etat_processus))
                   2829:                                        == NULL)
                   2830:                                {
                   2831:                                    erreur = d_es_allocation_memoire;
                   2832: 
                   2833:                                    if ((*s_etat_processus).langue == 'F')
                   2834:                                    {
                   2835:                                        printf("+++Erreur : Mémoire "
                   2836:                                                "insuffisante\n");
                   2837:                                    }
                   2838:                                    else
                   2839:                                    {
                   2840:                                        printf("+++Error : Not enough "
                   2841:                                                "memory\n");
                   2842:                                    }
                   2843: 
                   2844:                                    return(EXIT_FAILURE);
                   2845:                                }
                   2846: 
                   2847:                                printf("%s [%d]\n", message,
                   2848:                                        (int) getpid());
                   2849:                                free(message);
                   2850: 
                   2851:                                return(EXIT_FAILURE);
                   2852:                            }
                   2853:                        }
                   2854: 
                   2855:                        (*s_etat_processus).instruction_courante = NULL;
                   2856:                        liberation(s_etat_processus, s_objet);
                   2857: 
                   2858:                        free(arguments);
                   2859:                    }
                   2860: 
1.13      bertrand 2861:                    if (option_a == d_vrai)
1.1       bertrand 2862:                    {
1.13      bertrand 2863:                        fprintf(stdout, "%s\n", (*s_etat_processus)
                   2864:                                .definitions_chainees);
1.1       bertrand 2865:                    }
1.13      bertrand 2866:                    else
                   2867:                    {
                   2868:                        if (option_D == d_vrai)
                   2869:                        {
                   2870:                            lancement_daemon(s_etat_processus);
                   2871:                        }
1.1       bertrand 2872: 
1.13      bertrand 2873:                        if (option_p == d_faux)
1.1       bertrand 2874:                        {
1.13      bertrand 2875:                            if (setjmp(contexte_initial) == 0)
                   2876:                            {
                   2877:                                erreur = sequenceur(s_etat_processus);
1.80      bertrand 2878: 
                   2879:                                if (erreur == d_absence_erreur)
                   2880:                                {
                   2881:                                    if (((*s_etat_processus).var_volatile_alarme
                   2882:                                            == 0) && ((*s_etat_processus)
                   2883:                                            .arret_depuis_abort == 0) &&
                   2884:                                            ((*s_etat_processus).at_exit
                   2885:                                            != NULL))
                   2886:                                    {
                   2887:                                        erreur = evaluation(s_etat_processus,
                   2888:                                                (*s_etat_processus).at_exit,
                   2889:                                                'E');
                   2890:                                    }
                   2891:                                }
1.13      bertrand 2892:                            }
1.1       bertrand 2893:                        }
1.13      bertrand 2894:                        else
1.1       bertrand 2895:                        {
1.13      bertrand 2896:                            if (setjmp(contexte_initial) == 0)
                   2897:                            {
                   2898:                                erreur = sequenceur_optimise(s_etat_processus);
1.19      bertrand 2899: 
1.80      bertrand 2900:                                if (erreur == d_absence_erreur)
                   2901:                                {
                   2902:                                    if (((*s_etat_processus).var_volatile_alarme
                   2903:                                            == 0) && ((*s_etat_processus)
                   2904:                                            .arret_depuis_abort == 0) &&
                   2905:                                            ((*s_etat_processus).at_exit
                   2906:                                            != NULL))
                   2907:                                    {
                   2908:                                        erreur = evaluation(s_etat_processus,
                   2909:                                                (*s_etat_processus).at_exit,
                   2910:                                                'E');
                   2911:                                    }
                   2912:                                }
1.21      bertrand 2913:                            }
1.19      bertrand 2914:                        }
1.34      bertrand 2915:                    }
1.19      bertrand 2916: 
1.117     bertrand 2917:                    for(i = 0; i < (*s_etat_processus).sections_critiques; i++)
                   2918:                    {
                   2919:                        pthread_mutex_unlock(&mutex_sections_critiques);
                   2920:                    }
                   2921: 
1.34      bertrand 2922:                    liberation(s_etat_processus, (*s_etat_processus).at_exit);
                   2923:                    liberation(s_etat_processus, (*s_etat_processus).at_poke);
1.1       bertrand 2924: 
                   2925:                    if ((*s_etat_processus).generateur_aleatoire != NULL)
                   2926:                    {
                   2927:                        liberation_generateur_aleatoire(s_etat_processus);
                   2928:                    }
                   2929: 
                   2930:                    l_element_courant = (*s_etat_processus).liste_mutexes;
                   2931:                    while(l_element_courant != NULL)
                   2932:                    {
                   2933:                        liberation(s_etat_processus,
                   2934:                                (*((struct_liste_chainee *)
                   2935:                                l_element_courant)).donnee);
                   2936:                        l_element_suivant = (*((struct_liste_chainee *)
                   2937:                                l_element_courant)).suivant;
                   2938:                        free((struct_liste_chainee *) l_element_courant);
                   2939:                        l_element_courant = l_element_suivant;
                   2940:                    }
                   2941: 
                   2942:                    /*
                   2943:                     * Arrêt des processus fils
                   2944:                     */
                   2945: 
                   2946:                    if ((*s_etat_processus).presence_fusible == d_vrai)
                   2947:                    {
                   2948:                        pthread_cancel((*s_etat_processus).thread_fusible);
                   2949:                    }
                   2950: 
                   2951:                    pthread_mutex_lock(&((*s_etat_processus).mutex));
                   2952: 
                   2953:                    l_element_courant = (void *) (*s_etat_processus)
                   2954:                            .l_base_pile_processus;
                   2955: 
                   2956:                    while(l_element_courant != NULL)
                   2957:                    {
                   2958:                        if ((*s_etat_processus).debug == d_vrai)
                   2959:                        {
                   2960:                            if (((*s_etat_processus).type_debug &
                   2961:                                    d_debug_processus) != 0)
                   2962:                            {
                   2963:                                if ((*(*((struct_processus_fils *)
                   2964:                                        (*(*((struct_liste_chainee *)
                   2965:                                        l_element_courant)).donnee)
                   2966:                                        .objet)).thread)
                   2967:                                        .processus_detache == d_vrai)
                   2968:                                {
                   2969:                                    if ((*s_etat_processus).langue == 'F')
                   2970:                                    {
                   2971:                                        printf("[%d] Signalement pour arrêt du "
                   2972:                                                "processus %d\n",
                   2973:                                                (int) getpid(), (int)
                   2974:                                                (*(*((struct_processus_fils *)
                   2975:                                                (*(*((struct_liste_chainee *)
                   2976:                                                l_element_courant)).donnee)
                   2977:                                                .objet)).thread).pid);
                   2978:                                    }
                   2979:                                    else
                   2980:                                    {
                   2981:                                        printf("[%d] Send stop signal to "
                   2982:                                                "process %d\n",
                   2983:                                                (int) getpid(), (int)
                   2984:                                                (*(*((struct_processus_fils *)
                   2985:                                                (*(*((struct_liste_chainee *)
                   2986:                                                l_element_courant)).donnee)
                   2987:                                                .objet)).thread).pid);
                   2988:                                    }
                   2989:                                }
                   2990:                                else
                   2991:                                {
                   2992:                                    if ((*s_etat_processus).langue == 'F')
                   2993:                                    {
                   2994:                                        printf("[%d] Signalement pour arrêt du "
                   2995:                                                "thread %llu\n", (int) getpid(),
                   2996:                                                (unsigned long long)
                   2997:                                                (*(*((struct_processus_fils *)
                   2998:                                                (*(*((struct_liste_chainee *)
                   2999:                                                l_element_courant)).donnee)
                   3000:                                                .objet)).thread).tid);
                   3001:                                    }
                   3002:                                    else
                   3003:                                    {
                   3004:                                        printf("[%d] Send stop signal to "
                   3005:                                                "thread %llu\n",
                   3006:                                                (int) getpid(),
                   3007:                                                (unsigned long long)
                   3008:                                                (*(*((struct_processus_fils *)
                   3009:                                                (*(*((struct_liste_chainee *)
                   3010:                                                l_element_courant)).donnee)
                   3011:                                                .objet)).thread).tid);
                   3012:                                    }
                   3013:                                }
                   3014:                            }
                   3015:                        }
                   3016: 
                   3017:                        if ((*(*((struct_processus_fils *)
                   3018:                                (*(*((struct_liste_chainee *)
                   3019:                                l_element_courant)).donnee).objet))
                   3020:                                .thread).processus_detache == d_vrai)
                   3021:                        {
                   3022:                            if ((*s_etat_processus).var_volatile_alarme != 0)
                   3023:                            {
1.83      bertrand 3024:                                envoi_signal_processus(
                   3025:                                        (*(*((struct_processus_fils *)
1.1       bertrand 3026:                                        (*(*((struct_liste_chainee *)
                   3027:                                        l_element_courant)).donnee).objet))
1.83      bertrand 3028:                                        .thread).pid, rpl_sigurg);
1.1       bertrand 3029:                            }
                   3030:                            else
                   3031:                            {
1.22      bertrand 3032:                                if ((*s_etat_processus).arret_depuis_abort
                   3033:                                        == -1)
                   3034:                                {
1.83      bertrand 3035:                                    envoi_signal_processus(
                   3036:                                            (*(*((struct_processus_fils *)
1.22      bertrand 3037:                                            (*(*((struct_liste_chainee *)
                   3038:                                            l_element_courant)).donnee).objet))
1.83      bertrand 3039:                                            .thread).pid, rpl_sigabort);
1.22      bertrand 3040:                                }
                   3041:                                else
                   3042:                                {
1.83      bertrand 3043:                                    envoi_signal_processus(
                   3044:                                            (*(*((struct_processus_fils *)
1.22      bertrand 3045:                                            (*(*((struct_liste_chainee *)
                   3046:                                            l_element_courant)).donnee).objet))
1.83      bertrand 3047:                                            .thread).pid, rpl_sigstop);
1.22      bertrand 3048:                                }
1.1       bertrand 3049:                            }
                   3050:                        }
                   3051:                        else
                   3052:                        {
                   3053:                            pthread_mutex_lock(&((*(*((struct_processus_fils *)
                   3054:                                    (*(*((struct_liste_chainee *)
                   3055:                                    l_element_courant)).donnee).objet)).thread)
                   3056:                                    .mutex));
                   3057: 
                   3058:                            if ((*(*((struct_processus_fils *)
                   3059:                                    (*(*((struct_liste_chainee *)
                   3060:                                    l_element_courant)).donnee).objet)).thread)
                   3061:                                    .thread_actif == d_vrai)
                   3062:                            {
                   3063:                                if ((*s_etat_processus).var_volatile_alarme
                   3064:                                        != 0)
                   3065:                                {
1.83      bertrand 3066:                                    envoi_signal_thread(
                   3067:                                            (*(*((struct_processus_fils *)
1.1       bertrand 3068:                                            (*(*((struct_liste_chainee *)
                   3069:                                            l_element_courant)).donnee).objet))
1.83      bertrand 3070:                                            .thread).tid, rpl_sigurg);
1.1       bertrand 3071:                                }
                   3072:                                else
                   3073:                                {
1.22      bertrand 3074:                                    if ((*s_etat_processus).arret_depuis_abort
                   3075:                                            == -1)
                   3076:                                    {
1.83      bertrand 3077:                                        envoi_signal_thread(
1.22      bertrand 3078:                                                (*(*((struct_processus_fils *)
                   3079:                                                (*(*((struct_liste_chainee *)
                   3080:                                                l_element_courant)).donnee)
                   3081:                                                .objet)).thread).tid,
1.83      bertrand 3082:                                                rpl_sigabort);
1.22      bertrand 3083:                                    }
                   3084:                                    else
                   3085:                                    {
1.83      bertrand 3086:                                        envoi_signal_thread(
1.22      bertrand 3087:                                                (*(*((struct_processus_fils *)
                   3088:                                                (*(*((struct_liste_chainee *)
                   3089:                                                l_element_courant)).donnee)
                   3090:                                                .objet)).thread).tid,
1.83      bertrand 3091:                                                rpl_sigstop);
1.22      bertrand 3092:                                    }
1.1       bertrand 3093:                                }
                   3094:                            }
                   3095: 
                   3096:                            pthread_mutex_unlock(
                   3097:                                    &((*(*((struct_processus_fils *)
                   3098:                                    (*(*((struct_liste_chainee *)
                   3099:                                    l_element_courant)).donnee).objet)).thread)
                   3100:                                    .mutex));
                   3101:                        }
                   3102: 
                   3103:                        l_element_courant = (*((struct_liste_chainee *)
                   3104:                                l_element_courant)).suivant;
                   3105:                    }
                   3106: 
                   3107:                    /*
                   3108:                     * Attente de la fin de tous les processus fils
                   3109:                     */
                   3110: 
                   3111:                    for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
                   3112:                            (*s_etat_processus).masque_interruptions[i++]
                   3113:                            = 'I');
                   3114: 
                   3115:                    attente.tv_sec = 0;
                   3116:                    attente.tv_nsec = GRANULARITE_us * 1000;
                   3117: 
                   3118:                    while((*s_etat_processus).l_base_pile_processus != NULL)
                   3119:                    {
                   3120:                        l_element_courant = (void *)
                   3121:                                (*s_etat_processus).l_base_pile_processus;
                   3122: 
                   3123:                        for(i = 0; i < (unsigned long)
                   3124:                                (*(*((struct_processus_fils *)
                   3125:                                (*(*((struct_liste_chainee *)
                   3126:                                l_element_courant)).donnee).objet)).thread)
                   3127:                                .nombre_objets_dans_pipe; i++)
                   3128:                        {
                   3129:                            if ((s_objet = lecture_pipe(
                   3130:                                    s_etat_processus,
                   3131:                                    (*(*((struct_processus_fils *)
                   3132:                                    (*(*((struct_liste_chainee *)
                   3133:                                    l_element_courant)).donnee).objet)).thread)
                   3134:                                    .pipe_objets[0])) != NULL)
                   3135:                            {
                   3136:                                liberation(s_etat_processus, s_objet);
                   3137: 
                   3138:                                (*(*((struct_processus_fils *)
                   3139:                                        (*(*((struct_liste_chainee *)
                   3140:                                        l_element_courant)).donnee).objet))
                   3141:                                        .thread).nombre_objets_dans_pipe--;
                   3142: 
                   3143:                                action.sa_handler = SIG_IGN;
1.94      bertrand 3144:                                action.sa_flags = 0;
1.1       bertrand 3145: 
                   3146:                                if (sigaction(SIGPIPE, &action, &registre)
                   3147:                                        != 0)
                   3148:                                {
                   3149:                                    pthread_mutex_unlock(
                   3150:                                            &((*s_etat_processus).mutex));
                   3151:                                    return(EXIT_FAILURE);
                   3152:                                }
                   3153: 
                   3154:                                while((longueur_ecriture =
                   3155:                                        write_atomic(s_etat_processus,
                   3156:                                        (*(*((struct_processus_fils *)
                   3157:                                        (*(*((struct_liste_chainee *)
                   3158:                                        l_element_courant)).donnee).objet))
                   3159:                                        .thread).pipe_nombre_injections[1], "+",
                   3160:                                        sizeof(unsigned char))) !=
                   3161:                                        sizeof(unsigned char))
                   3162:                                {
                   3163:                                    if (longueur_ecriture == -1)
                   3164:                                    {
                   3165:                                        // Le processus n'existe plus.
                   3166:                                        break;
                   3167:                                    }
                   3168:                                }
                   3169: 
                   3170:                                if (sigaction(SIGPIPE, &registre, NULL)
                   3171:                                        != 0)
                   3172:                                {
                   3173:                                    pthread_mutex_unlock(
                   3174:                                            &((*s_etat_processus).mutex));
                   3175:                                    return(EXIT_FAILURE);
                   3176:                                }
                   3177:                            }
                   3178:                        }
                   3179: 
                   3180:                        pthread_mutex_unlock(&((*s_etat_processus).mutex));
1.23      bertrand 3181: 
                   3182:                        if ((*s_etat_processus)
                   3183:                                .nombre_interruptions_non_affectees != 0)
                   3184:                        {
                   3185:                            affectation_interruptions_logicielles(
                   3186:                                    s_etat_processus);
                   3187:                        }
                   3188: 
1.1       bertrand 3189:                        nanosleep(&attente, NULL);
1.85      bertrand 3190:                        scrutation_interruptions(s_etat_processus);
1.1       bertrand 3191:                        pthread_mutex_lock(&((*s_etat_processus).mutex));
                   3192:                    }
                   3193: 
                   3194:                    pthread_mutex_unlock(&((*s_etat_processus).mutex));
                   3195: 
                   3196:                    erreur_historique = write_history(
                   3197:                            (*s_etat_processus).nom_fichier_historique);
                   3198:                    clear_history();
                   3199: 
                   3200:                    if (erreur_historique != 0)
                   3201:                    {
                   3202:                        if ((*s_etat_processus).langue == 'F')
                   3203:                        {
                   3204:                            printf("+++Erreur : L'historique ne peut être "
                   3205:                                    "écrit\n");
                   3206:                        }
                   3207:                        else
                   3208:                        {
                   3209:                            printf("+++Error : History cannot be "
                   3210:                                    "written\n");
                   3211:                        }
                   3212: 
                   3213:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   3214:                        {
                   3215:                            printf("%s", ds_beep);
                   3216:                        }
                   3217:                    }
                   3218: 
                   3219:                    free((*s_etat_processus).nom_fichier_historique);
                   3220: 
                   3221:                    if (((*s_etat_processus).core == d_vrai) &&
                   3222:                            (erreur == d_erreur) &&
                   3223:                            ((*s_etat_processus).var_volatile_traitement_sigint
                   3224:                            == 0))
                   3225:                    {
                   3226:                        printf("\n");
                   3227:                        
                   3228:                        if ((*s_etat_processus).langue == 'F')
                   3229:                        {
                   3230:                            printf("+++Information : Génération du fichier "
                   3231:                                    "rpl-core [%d]\n", (int) getpid());
                   3232:                        }
                   3233:                        else
                   3234:                        {
                   3235:                            printf("+++Information : Writing rpl-core "
                   3236:                                    "file [%d]\n", (int) getpid());
                   3237:                        }
                   3238: 
                   3239:                        rplcore(s_etat_processus);
                   3240: 
                   3241:                        if ((*s_etat_processus).langue == 'F')
                   3242:                        {
                   3243:                            printf("+++Information : Processus tracé [%d]\n",
                   3244:                                    (int) getpid());
                   3245:                        }
                   3246:                        else
                   3247:                        {
                   3248:                            printf("+++Information : Done [%d]\n",
                   3249:                                    (int) getpid());
                   3250:                        }
                   3251: 
                   3252:                        printf("\n");
                   3253:                    }
                   3254: 
                   3255:                    free((*s_etat_processus).definitions_chainees);
                   3256: 
                   3257:                    /*
                   3258:                     * Libération de l'arbre des instructions
                   3259:                     */
                   3260: 
                   3261:                    liberation_arbre_instructions(s_etat_processus,
                   3262:                            (*s_etat_processus).arbre_instructions);
                   3263:                    free((*s_etat_processus).pointeurs_caracteres);
                   3264: 
                   3265:                    if ((*s_etat_processus).entree_standard != NULL)
                   3266:                    {
                   3267:                        pclose((*s_etat_processus).entree_standard);
                   3268:                        (*s_etat_processus).entree_standard = NULL;
                   3269:                    }
                   3270: 
                   3271:                    if ((*s_etat_processus).nom_fichier_impression != NULL)
                   3272:                    {
                   3273:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   3274:                        {
                   3275:                            printf("%s", ds_beep);
                   3276:                        }
                   3277: 
                   3278:                        if ((*s_etat_processus).langue == 'F')
                   3279:                        {
                   3280:                            printf("+++Attention : Queue d'impression "
                   3281:                                    "non vide !\n");
                   3282:                        }
                   3283:                        else
                   3284:                        {
                   3285:                            printf("+++Warning : Non empty printing "
                   3286:                                    "spool queue !\n");
                   3287:                        }
                   3288: 
                   3289:                        instruction_erase(s_etat_processus);
                   3290:                    }
                   3291: 
                   3292:                    if ((*s_etat_processus).fichiers_graphiques != NULL)
                   3293:                    {
                   3294:                        instruction_cllcd(s_etat_processus);
                   3295:                    }
                   3296: 
                   3297:                    liberation(s_etat_processus, (*s_etat_processus).indep);
                   3298:                    liberation(s_etat_processus, (*s_etat_processus).depend);
                   3299: 
                   3300:                    free((*s_etat_processus).label_x);
                   3301:                    free((*s_etat_processus).label_y);
                   3302:                    free((*s_etat_processus).label_z);
                   3303:                    free((*s_etat_processus).titre);
                   3304:                    free((*s_etat_processus).legende);
                   3305: 
                   3306:                    liberation(s_etat_processus, (*s_etat_processus)
                   3307:                            .parametres_courbes_de_niveau);
                   3308: 
                   3309:                    for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
                   3310:                    {
                   3311:                        liberation(s_etat_processus,
                   3312:                                (*s_etat_processus).corps_interruptions[i]);
                   3313: 
                   3314:                        l_element_courant = (*s_etat_processus)
                   3315:                                .pile_origine_interruptions[i];
                   3316: 
                   3317:                        while(l_element_courant != NULL)
                   3318:                        {
                   3319:                            l_element_suivant = (*((struct_liste_chainee *)
                   3320:                                    l_element_courant)).suivant;
                   3321: 
                   3322:                            liberation(s_etat_processus,
                   3323:                                    (*((struct_liste_chainee *)
                   3324:                                    l_element_courant)).donnee);
                   3325:                            free(l_element_courant);
                   3326: 
                   3327:                            l_element_courant = l_element_suivant;
                   3328:                        }
                   3329:                    }
                   3330: 
                   3331:                    if ((*s_etat_processus).instruction_derniere_erreur
                   3332:                            != NULL)
                   3333:                    {
                   3334:                        free((*s_etat_processus).instruction_derniere_erreur);
                   3335:                        (*s_etat_processus).instruction_derniere_erreur = NULL;
                   3336:                    }
                   3337: 
                   3338:                    /*
                   3339:                     * Le pointeur s_etat_processus.nom_fichier_source est
                   3340:                     * alloué par le système. Il ne faut donc pas
                   3341:                     * le libérer...
                   3342:                     */
                   3343: 
1.66      bertrand 3344:                    liberation_arbre_variables(s_etat_processus,
                   3345:                            (*s_etat_processus).s_arbre_variables, d_vrai);
                   3346:                    free((*s_etat_processus).pointeurs_caracteres_variables);
1.1       bertrand 3347: 
                   3348:                    for(i = 0; i < (*((*s_etat_processus)
                   3349:                            .s_liste_variables_partagees)).nombre_variables;
                   3350:                            i++)
                   3351:                    {
                   3352:                        liberation(s_etat_processus, (*((*s_etat_processus)
                   3353:                                .s_liste_variables_partagees)).table[i].objet);
                   3354:                        free((*((*s_etat_processus)
                   3355:                                .s_liste_variables_partagees)).table[i].nom);
                   3356:                    }
                   3357: 
                   3358:                    free((struct_variable_partagee *)
                   3359:                            (*((*s_etat_processus).s_liste_variables_partagees))
                   3360:                            .table);
                   3361: 
                   3362:                    /*
                   3363:                     * Si resultats est non nul, rplinit a été appelé
                   3364:                     * depuis rpl() [librpl] et non main().
                   3365:                     * On copie alors le contenu de la * pile dans un
                   3366:                     * tableau **resultats dont le pointeur de base a
                   3367:                     * été alloué dans rpl().
                   3368:                     */
                   3369: 
                   3370:                    if (resultats != NULL)
                   3371:                    {
                   3372:                        if ((*resultats) != NULL)
                   3373:                        {
                   3374:                            free((*resultats));
                   3375: 
                   3376:                            if (((*resultats) = malloc(((*s_etat_processus)
                   3377:                                    .hauteur_pile_operationnelle + 1)
                   3378:                                    * sizeof(unsigned char **))) != NULL)
                   3379:                            {
                   3380:                                (*resultats)[(*s_etat_processus)
                   3381:                                        .hauteur_pile_operationnelle] = NULL;
                   3382:                                l_element_courant = (void *) (*s_etat_processus)
                   3383:                                        .l_base_pile;
                   3384: 
                   3385:                                for(i = 0; i < (*s_etat_processus)
                   3386:                                        .hauteur_pile_operationnelle; i++)
                   3387:                                {
                   3388:                                    if (l_element_courant != NULL)
                   3389:                                    {
                   3390:                                        (*resultats)[i] =
                   3391:                                                formateur(s_etat_processus,
                   3392:                                                0, (*((struct_liste_chainee *)
                   3393:                                                l_element_courant)).donnee);
                   3394: 
                   3395:                                        if ((*resultats)[i] == NULL)
                   3396:                                        {
                   3397:                                            i = (*s_etat_processus).
                   3398:                                                    hauteur_pile_operationnelle;
                   3399:                                        }
                   3400:                                        else
                   3401:                                        {
                   3402:                                            l_element_suivant =
                   3403:                                                    (*((struct_liste_chainee *)
                   3404:                                                    l_element_courant)).suivant;
                   3405:                                        }
                   3406:                                    }
                   3407:                                }
                   3408:                            }
                   3409:                            else
                   3410:                            {
                   3411:                                (*resultats) = NULL;
                   3412:                                erreur = d_es_allocation_memoire;
                   3413:                            }
                   3414:                        }
                   3415:                    }
                   3416: 
                   3417:                    l_element_courant = (void *) (*s_etat_processus)
                   3418:                            .l_base_pile;
                   3419:                    while(l_element_courant != NULL)
                   3420:                    {
                   3421:                        l_element_suivant = (*((struct_liste_chainee *)
                   3422:                                l_element_courant)).suivant;
                   3423: 
                   3424:                        liberation(s_etat_processus,
                   3425:                                (*((struct_liste_chainee *)
                   3426:                                l_element_courant)).donnee);
                   3427:                        free((struct_liste_chainee *) l_element_courant);
                   3428: 
                   3429:                        l_element_courant = l_element_suivant;
                   3430:                    }
                   3431: 
                   3432:                    l_element_courant = (void *) (*s_etat_processus)
                   3433:                            .l_base_pile_contextes;
                   3434:                    while(l_element_courant != NULL)
                   3435:                    {
                   3436:                        l_element_suivant = (*((struct_liste_chainee *)
                   3437:                                l_element_courant)).suivant;
                   3438: 
                   3439:                        liberation(s_etat_processus,
                   3440:                                (*((struct_liste_chainee *)
                   3441:                                l_element_courant)).donnee);
                   3442:                        free((struct_liste_chainee *) l_element_courant);
                   3443: 
                   3444:                        l_element_courant = l_element_suivant;
                   3445:                    }
                   3446: 
                   3447:                    l_element_courant = (void *) (*s_etat_processus)
                   3448:                            .l_base_pile_taille_contextes;
                   3449:                    while(l_element_courant != NULL)
                   3450:                    {
                   3451:                        l_element_suivant = (*((struct_liste_chainee *)
                   3452:                                l_element_courant)).suivant;
                   3453: 
                   3454:                        liberation(s_etat_processus,
                   3455:                                (*((struct_liste_chainee *)
                   3456:                                l_element_courant)).donnee);
                   3457:                        free((struct_liste_chainee *) l_element_courant);
                   3458: 
                   3459:                        l_element_courant = l_element_suivant;
                   3460:                    }
                   3461: 
                   3462:                    for(i = 0; i < (*s_etat_processus)
                   3463:                            .nombre_instructions_externes; i++)
                   3464:                    {
                   3465:                        free((*s_etat_processus).s_instructions_externes[i]
                   3466:                                .nom);
                   3467:                        free((*s_etat_processus).s_instructions_externes[i]
                   3468:                                .nom_bibliotheque);
                   3469:                    }
                   3470: 
                   3471:                    if ((*s_etat_processus).nombre_instructions_externes != 0)
                   3472:                    {
                   3473:                        free((*s_etat_processus).s_instructions_externes);
                   3474:                    }
                   3475: 
                   3476:                    l_element_courant = (void *) (*s_etat_processus)
                   3477:                            .s_bibliotheques;
                   3478:                    
                   3479:                    while(l_element_courant != NULL)
                   3480:                    {
                   3481:                        l_element_suivant = (*((struct_liste_chainee *)
                   3482:                                l_element_courant)).suivant;
                   3483: 
                   3484:                        free((*((struct_bibliotheque *)
                   3485:                                (*((struct_liste_chainee *)
                   3486:                                l_element_courant)).donnee)).nom);
                   3487:                        dlclose((*((struct_bibliotheque *)
                   3488:                                (*((struct_liste_chainee *)
                   3489:                                l_element_courant)).donnee)).descripteur);
                   3490:                        free((*((struct_liste_chainee *) l_element_courant))
                   3491:                                .donnee);
                   3492:                        free(l_element_courant);
                   3493: 
                   3494:                        l_element_courant = l_element_suivant;
                   3495:                    }
                   3496: 
                   3497:                    l_element_courant = (void *) (*s_etat_processus)
                   3498:                            .l_base_pile_last;
                   3499:                    while(l_element_courant != NULL)
                   3500:                    {
                   3501:                        l_element_suivant = (*((struct_liste_chainee *)
                   3502:                                l_element_courant)).suivant;
                   3503: 
                   3504:                        liberation(s_etat_processus,
                   3505:                                (*((struct_liste_chainee *)
                   3506:                                l_element_courant)).donnee);
                   3507:                        free((struct_liste_chainee *) l_element_courant);
                   3508: 
                   3509:                        l_element_courant = l_element_suivant;
                   3510:                    }
                   3511: 
                   3512:                    l_element_courant = (void *) (*s_etat_processus)
                   3513:                            .l_base_pile_systeme;
                   3514:                    while(l_element_courant != NULL)
                   3515:                    {
                   3516:                        l_element_suivant = (*((struct_liste_pile_systeme *)
                   3517:                                l_element_courant)).suivant;
                   3518: 
                   3519:                        liberation(s_etat_processus,
                   3520:                                (*((struct_liste_pile_systeme *)
                   3521:                                l_element_courant)).indice_boucle);
                   3522:                        liberation(s_etat_processus,
                   3523:                                (*((struct_liste_pile_systeme *)
                   3524:                                l_element_courant)).limite_indice_boucle);
                   3525:                        liberation(s_etat_processus,
                   3526:                                (*((struct_liste_pile_systeme *)
                   3527:                                l_element_courant)).objet_de_test);
                   3528: 
                   3529:                        if ((*((struct_liste_pile_systeme *)
                   3530:                                l_element_courant)).nom_variable != NULL)
                   3531:                        {
                   3532:                            free((*((struct_liste_pile_systeme *)
                   3533:                                    l_element_courant)).nom_variable);
                   3534:                        }
                   3535: 
                   3536:                        free((struct_liste_pile_systeme *)
                   3537:                                l_element_courant);
                   3538: 
                   3539:                        l_element_courant = l_element_suivant;
                   3540:                    }
                   3541: 
                   3542:                    l_element_courant = (void *)
                   3543:                            (*s_etat_processus).s_fichiers;
                   3544:                    while(l_element_courant != NULL)
                   3545:                    {
                   3546:                        l_element_suivant = (*((struct_liste_chainee *)
                   3547:                                l_element_courant)).suivant;
                   3548: 
                   3549:                        fclose((*((struct_descripteur_fichier *)
                   3550:                                (*((struct_liste_chainee *)
                   3551:                                l_element_courant)).donnee))
1.12      bertrand 3552:                                .descripteur_c);
                   3553: 
                   3554:                        if ((*((struct_descripteur_fichier *)
                   3555:                                (*((struct_liste_chainee *)
                   3556:                                l_element_courant)).donnee)).type != 'C')
                   3557:                        {
                   3558:                            sqlite3_close((*((struct_descripteur_fichier *)
                   3559:                                    (*((struct_liste_chainee *)
                   3560:                                    l_element_courant)).donnee))
                   3561:                                    .descripteur_sqlite);
                   3562:                        }
1.1       bertrand 3563: 
                   3564:                        if ((*((struct_descripteur_fichier *)
                   3565:                                (*((struct_liste_chainee *)
                   3566:                                l_element_courant)).donnee))
                   3567:                                .effacement == 'Y')
                   3568:                        {
                   3569:                            unlink((*((struct_descripteur_fichier *)
                   3570:                                    (*((struct_liste_chainee *)
                   3571:                                    l_element_courant)).donnee))
                   3572:                                    .nom);
                   3573:                        }
                   3574: 
                   3575:                        free((*((struct_descripteur_fichier *)
                   3576:                                (*((struct_liste_chainee *)
                   3577:                                l_element_courant)).donnee)).nom);
                   3578:                        free((struct_descripteur_fichier *)
                   3579:                                (*((struct_liste_chainee *)
                   3580:                                l_element_courant)).donnee);
                   3581:                        free(l_element_courant);
                   3582: 
                   3583:                        l_element_courant = l_element_suivant;
                   3584:                    }
                   3585: 
                   3586:                    l_element_courant = (void *)
                   3587:                            (*s_etat_processus).s_sockets;
                   3588:                    while(l_element_courant != NULL)
                   3589:                    {
                   3590:                        l_element_suivant = (*((struct_liste_chainee *)
                   3591:                                l_element_courant)).suivant;
                   3592: 
                   3593:                        if ((*((struct_socket *)
                   3594:                                (*(*((struct_liste_chainee *)
                   3595:                                l_element_courant)).donnee).objet))
                   3596:                                .socket_connectee == d_vrai)
                   3597:                        {
                   3598:                            shutdown((*((struct_socket *)
                   3599:                                    (*(*((struct_liste_chainee *)
                   3600:                                    l_element_courant)).donnee).objet))
                   3601:                                    .socket, SHUT_RDWR);
                   3602:                        }
                   3603: 
                   3604:                        close((*((struct_socket *)
                   3605:                                (*(*((struct_liste_chainee *)
                   3606:                                l_element_courant)).donnee).objet)).socket);
                   3607: 
                   3608:                        if ((*((struct_socket *) (*(*((struct_liste_chainee *)
                   3609:                                l_element_courant)).donnee).objet)).effacement
                   3610:                                == 'Y')
                   3611:                        {
                   3612:                            unlink((*((struct_socket *)
                   3613:                                    (*(*((struct_liste_chainee *)
                   3614:                                    l_element_courant)).donnee).objet))
                   3615:                                    .adresse);
                   3616:                        }
                   3617: 
                   3618:                        liberation(s_etat_processus,
                   3619:                                (*((struct_liste_chainee *)
                   3620:                                l_element_courant)).donnee);
                   3621:                        free(l_element_courant);
                   3622: 
                   3623:                        l_element_courant = l_element_suivant;
                   3624:                    }
                   3625: 
                   3626:                    l_element_courant = (void *)
                   3627:                            (*s_etat_processus).s_connecteurs_sql;
                   3628:                    while(l_element_courant != NULL)
                   3629:                    {
                   3630:                        l_element_suivant = (*((struct_liste_chainee *)
                   3631:                                l_element_courant)).suivant;
                   3632: 
                   3633:                        sqlclose((*((struct_liste_chainee *)
                   3634:                                l_element_courant)).donnee);
                   3635:                        liberation(s_etat_processus,
                   3636:                                (*((struct_liste_chainee *)
                   3637:                                l_element_courant)).donnee);
                   3638:                        free(l_element_courant);
                   3639: 
                   3640:                        l_element_courant = l_element_suivant;
                   3641:                    }
                   3642: 
                   3643:                    l_element_courant = (*s_etat_processus).s_marques;
                   3644:                    while(l_element_courant != NULL)
                   3645:                    {
                   3646:                        free((*((struct_marque *) l_element_courant)).label);
                   3647:                        free((*((struct_marque *) l_element_courant)).position);
                   3648:                        l_element_suivant = (*((struct_marque *)
                   3649:                                l_element_courant)).suivant;
                   3650:                        free(l_element_courant);
                   3651:                        l_element_courant = l_element_suivant;
                   3652:                    }
                   3653:                }
                   3654:                else
                   3655:                {
                   3656:                    erreur = d_es_allocation_memoire;
                   3657: 
                   3658:                    if (test_cfsf(s_etat_processus, 51) == d_faux)
                   3659:                    {
                   3660:                        printf("%s", ds_beep);
                   3661:                    }
                   3662: 
                   3663:                    if ((*s_etat_processus).langue == 'F')
                   3664:                    {
                   3665:                        printf("+++Système : Mémoire insuffisante\n");
                   3666:                    }
                   3667:                    else
                   3668:                    {
                   3669:                        printf("+++System : Not enough memory\n");
                   3670:                    }
                   3671:                }
                   3672:            }
                   3673: 
                   3674:            liberation_allocateur(s_etat_processus);
                   3675:        }
                   3676: 
                   3677:        if (traitement_fichier_temporaire == 'Y')
                   3678:        {
                   3679:            if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
                   3680:            {
                   3681:                return(EXIT_FAILURE);
                   3682:            }
                   3683: 
                   3684:            free(nom_fichier_temporaire);
                   3685:        }
                   3686: 
                   3687:        if ((*s_etat_processus).profilage == d_vrai)
                   3688:        {
                   3689:            ecriture_profil(s_etat_processus);
                   3690:            liberation_profil(s_etat_processus);
                   3691:        }
                   3692:    }
                   3693: 
                   3694:    closelog();
                   3695: 
                   3696:    pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
                   3697:    pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
                   3698:            .mutex));
                   3699: 
                   3700:    retrait_thread(s_etat_processus);
                   3701: 
                   3702:    pthread_mutex_destroy(&((*s_etat_processus).mutex));
1.30      bertrand 3703:    pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
1.117     bertrand 3704:    pthread_mutex_destroy(&mutex_sections_critiques);
1.29      bertrand 3705: 
1.91      bertrand 3706: #  ifndef SEMAPHORES_NOMMES
1.93      bertrand 3707:    sem_post(&((*s_etat_processus).semaphore_fork));
                   3708:    sem_destroy(&((*s_etat_processus).semaphore_fork));
1.91      bertrand 3709: #  else
                   3710:    sem_post((*s_etat_processus).semaphore_fork);
1.92      bertrand 3711:    sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(),
                   3712:            SEM_FORK);
1.91      bertrand 3713: #  endif
1.1       bertrand 3714: 
                   3715:    free((*s_etat_processus).localisation);
                   3716: 
1.17      bertrand 3717: #  ifndef SEMAPHORES_NOMMES
1.1       bertrand 3718:    sem_post(&semaphore_gestionnaires_signaux);
                   3719:    sem_destroy(&semaphore_gestionnaires_signaux);
1.17      bertrand 3720: #  else
                   3721:    sem_post(semaphore_gestionnaires_signaux);
1.92      bertrand 3722:    sem_destroy2(semaphore_gestionnaires_signaux, getpid(), SEM_SIGNAUX);
1.17      bertrand 3723: #  endif
1.1       bertrand 3724: 
1.83      bertrand 3725:    destruction_queue_signaux(s_etat_processus);
1.76      bertrand 3726:    liberation_contexte_cas(s_etat_processus);
                   3727: 
1.40      bertrand 3728:    free((*s_etat_processus).chemin_fichiers_temporaires);
1.103     bertrand 3729: 
                   3730:    if ((*s_etat_processus).requete_redemarrage == d_vrai)
                   3731:    {
                   3732:        chdir(repertoire_initial);
1.105     bertrand 3733:        execvp(arg_exec[0], &(arg_exec[0]));
1.103     bertrand 3734:        erreur = d_erreur;
                   3735:    }
                   3736: 
1.104     bertrand 3737:    free(arg_exec);
1.24      bertrand 3738:    free(s_etat_processus);
                   3739: 
1.8       bertrand 3740: #  ifdef DEBUG_MEMOIRE
1.24      bertrand 3741:    debug_memoire_verification();
                   3742:    analyse_post_mortem();
1.8       bertrand 3743: #  endif
                   3744: 
1.94      bertrand 3745: #  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3746:    stackoverflow_deinstall_handler();
                   3747: #  endif
                   3748: 
                   3749: #  ifdef HAVE_SIGSEGV_RECOVERY
                   3750:    if (debug == d_faux)
                   3751:    {
                   3752:        sigsegv_deinstall_handler();
                   3753:    }
                   3754: #  endif
                   3755: 
1.13      bertrand 3756:    return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
1.1       bertrand 3757: }
                   3758: 
                   3759: 
                   3760: void
                   3761: informations(struct_processus *s_etat_processus)
                   3762: {
                   3763:    printf("\n");
                   3764: 
                   3765:    if ((*s_etat_processus).langue == 'F')
                   3766:    {
                   3767:        printf("  rpl [-options] [programme]\n");
1.13      bertrand 3768:        printf("      -a : analyse du code\n");
1.1       bertrand 3769:        printf("      -A : paramètres passés au programme principal\n");
                   3770:        printf("      -c : génération de fichier de débogage (rpl-core)\n");
                   3771:        printf("      -d : option de déverminage interne\n");
                   3772:        printf("      -D : lancement d'un daemon\n");
                   3773:        printf("      -h : aide sur la ligne de commande\n");
                   3774:        printf("      -i : fonctionnement interactif\n");
                   3775:        printf("      -l : licence d'utilisation\n");
                   3776:        printf("      -n : ignorance du signal HUP\n");
                   3777:        printf("      -p : précompilation du script avant exécution\n");
                   3778:        printf("      -P : profilage\n");
                   3779:        printf("      -s : empêchement de l'ouverture de l'écran initial\n");
                   3780:        printf("      -S : exécution du script passé en ligne de commande\n");
                   3781:        printf("      -t : trace\n");
                   3782:        printf("      -v : version\n");
                   3783:    }
                   3784:    else
                   3785:    {
                   3786:        printf("  rpl [-options] [program]\n");
1.13      bertrand 3787:        printf("      -a : analyzes program\n");
1.1       bertrand 3788:        printf("      -A : sends parameters to main program\n");
                   3789:        printf("      -c : allows creation of a rpl-core file, providing a way"
                   3790:                "\n"
                   3791:                "           to debug a program\n");
                   3792:        printf("      -d : internal debug process\n");
                   3793:        printf("      -D : starts in daemon mode\n");
                   3794:        printf("      -h : shows a summary of available options\n");
                   3795:        printf("      -i : runs the RPL/2 sequencer in interactive mode\n");
                   3796:        printf("      -l : prints the user licence of the software\n");
                   3797:        printf("      -n : ignores HUP signal\n");
                   3798:        printf("      -p : precompiles script\n");
                   3799:        printf("      -P : computes profile data\n");
                   3800:        printf("      -s : disables splash screen\n");
                   3801:        printf("      -S : executes script written in command line\n");
                   3802:        printf("      -t : enables tracing mode\n");
                   3803:        printf("      -v : prints the version number\n");
                   3804:    }
                   3805: 
                   3806:    printf("\n");
                   3807: 
                   3808:    return;
                   3809: }
                   3810: 
1.96      bertrand 3811: 
1.100     bertrand 3812: logical1
                   3813: controle_integrite(struct_processus *s_etat_processus,
                   3814:        unsigned char *executable_candidat, unsigned char *executable)
                   3815: {
                   3816:    unsigned char       *md5;
                   3817:    unsigned char       *sha1;
                   3818: 
                   3819:    if (strcmp(executable, "rplpp") == 0)
                   3820:    {
                   3821:        md5 = rplpp_md5;
                   3822:        sha1 = rplpp_sha1;
                   3823:    }
                   3824:    else if (strcmp(executable, "rplfile") == 0)
                   3825:    {
                   3826:        md5 = rplfile_md5;
                   3827:        sha1 = rplfile_sha1;
                   3828:    }
                   3829:    else if (strcmp(executable, "rpliconv") == 0)
                   3830:    {
                   3831:        md5 = rpliconv_md5;
                   3832:        sha1 = rpliconv_sha1;
                   3833:    }
                   3834:    else if (strcmp(executable, "rplawk") == 0)
                   3835:    {
                   3836:        md5 = rplawk_md5;
                   3837:        sha1 = rplawk_sha1;
                   3838:    }
                   3839:    else if (strcmp(executable, "rplconvert") == 0)
                   3840:    {
                   3841:        md5 = rplconvert_md5;
                   3842:        sha1 = rplconvert_sha1;
                   3843:    }
                   3844:    else
                   3845:    {
                   3846:        return(d_faux);
                   3847:    }
                   3848: 
                   3849:    if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai)
                   3850:    {
                   3851:        return(d_faux);
                   3852:    }
                   3853: 
                   3854:    if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai)
                   3855:    {
                   3856:        return(d_faux);
                   3857:    }
                   3858: 
                   3859:    return(d_vrai);
                   3860: }
                   3861: 
                   3862: 
1.96      bertrand 3863: unsigned char *
                   3864: date_compilation()
                   3865: {
                   3866:    unsigned char       *date;
                   3867: 
                   3868:    if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char)))
                   3869:            == NULL)
                   3870:    {
                   3871:        return(NULL);
                   3872:    }
                   3873: 
                   3874:    strcpy(date, d_date_en_rpl);
                   3875: 
                   3876:    return(date);
                   3877: }
                   3878: 
1.1       bertrand 3879: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>