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

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

CVSweb interface <joel.bertrand@systella.fr>