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

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

CVSweb interface <joel.bertrand@systella.fr>