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

1.1       bertrand    1: /*
                      2: ================================================================================
1.206     bertrand    3:   RPL/2 (R) version 4.1.31
1.205     bertrand    4:   Copyright (C) 1989-2019 Dr. BERTRAND Joël
1.1       bertrand    5: 
                      6:   This file is part of RPL/2.
                      7: 
                      8:   RPL/2 is free software; you can redistribute it and/or modify it
                      9:   under the terms of the CeCILL V2 License as published by the french
                     10:   CEA, CNRS and INRIA.
                     11:  
                     12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
                     13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                     14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
                     15:   for more details.
                     16:  
                     17:   You should have received a copy of the CeCILL License
                     18:   along with RPL/2. If not, write to info@cecill.info.
                     19: ================================================================================
                     20: */
                     21: 
                     22: 
                     23: #define  MAIN_RPL
1.35      bertrand   24: #include "rpl-conv.h"
1.1       bertrand   25: 
1.156     bertrand   26: // Bug de gcc à partir de gcc 4.6 (bug 48544)
                     27: #pragma GCC diagnostic push
                     28: #pragma GCC diagnostic ignored "-Wclobbered"
                     29: 
1.37      bertrand   30: 
1.1       bertrand   31: /*
                     32: ================================================================================
                     33:   Programme principal
                     34: ================================================================================
                     35: */
                     36: 
                     37: int
1.101     bertrand   38: rplinit(int argc, char *argv[], char *envp[],
                     39:        unsigned char ***resultats, char *rpl_home)
1.1       bertrand   40: {
1.35      bertrand   41: #  include                             "copyright-conv.h"
                     42: #  include                             "licence-conv.h"
1.1       bertrand   43: 
1.104     bertrand   44:    char                                **arg_exec;
                     45: 
1.97      bertrand   46: #  ifdef HAVE_STACK_OVERFLOW_RECOVERY
1.94      bertrand   47:    char                                pile_signaux[SIGSTKSZ];
1.97      bertrand   48: #  endif
1.94      bertrand   49: 
1.103     bertrand   50: #  define RPL_PATH_MAX                 1024
                     51:    char                                repertoire_initial[RPL_PATH_MAX];
                     52: 
1.1       bertrand   53:    file                                *f_source;
                     54: 
                     55:    int                                 erreur_historique;
                     56:    int                                 option_P;
                     57: 
1.136     bertrand   58:    integer8                            i;
                     59: 
1.1       bertrand   60:    logical1                            core;
                     61:    logical1                            debug;
                     62:    logical1                            erreur_fichier;
                     63:    logical1                            existence;
                     64:    logical1                            mode_interactif;
                     65:    logical1                            option_a;
                     66:    logical1                            option_A;
                     67:    logical1                            option_c;
                     68:    logical1                            option_d;
                     69:    logical1                            option_D;
                     70:    logical1                            option_h;
                     71:    logical1                            option_i;
                     72:    logical1                            option_l;
                     73:    logical1                            option_n;
                     74:    logical1                            option_p;
                     75:    logical1                            option_s;
                     76:    logical1                            option_S;
                     77:    logical1                            option_t;
                     78:    logical1                            option_v;
                     79:    logical1                            ouverture;
                     80: 
                     81:    pthread_mutexattr_t                 attributs_mutex;
                     82: 
                     83:    ssize_t                             longueur_ecriture;
                     84: 
                     85:    struct_objet                        *s_objet;
                     86: 
                     87:    struct_processus                    *s_etat_processus;
                     88: 
1.195     bertrand   89:    struct_liste_chainee                *l_bibliotheques;
                     90:    struct_liste_chainee                *l_bibliotheque_courante;
                     91:    struct_liste_chainee                *l_nouvelle_bibliotheque;
                     92: 
1.127     bertrand   93:    struct_liste_variables_partagees    *l_element_partage_courant;
                     94:    struct_liste_variables_partagees    *l_element_partage_suivant;
                     95: 
1.121     bertrand   96:    struct_liste_variables_statiques    *l_element_statique_courant;
                     97:    struct_liste_variables_statiques    *l_element_statique_suivant;
                     98: 
1.127     bertrand   99:    struct_arbre_variables_partagees    *s_arbre_variables_partagees;
                    100:    struct_liste_variables_partagees    *l_liste_variables_partagees;
                    101: 
1.1       bertrand  102:    struct sigaction                    action;
                    103:    struct sigaction                    registre;
                    104: 
                    105:    struct timespec                     attente;
                    106: 
                    107:    unsigned char                       *arguments;
                    108:    unsigned char                       drapeau_encart;
                    109:    unsigned char                       *type_debug;
                    110:    unsigned char                       *home;
                    111:    unsigned char                       *langue;
                    112:    unsigned char                       *message;
                    113:    unsigned char                       *nom_fichier_temporaire;
                    114:    unsigned char                       option;
                    115:    unsigned char                       presence_definition;
                    116:    unsigned char                       *ptr;
                    117:    unsigned char                       *tampon;
                    118: 
                    119:    unsigned long                       unite_fichier;
                    120: 
                    121:    void                                *l_element_courant;
                    122:    void                                *l_element_suivant;
                    123: 
                    124:    volatile int                        erreur;
                    125:    volatile unsigned char              traitement_fichier_temporaire;
                    126: 
1.37      bertrand  127:    errno = 0;
1.85      bertrand  128:    s_queue_signaux = NULL;
1.94      bertrand  129:    routine_recursive = 0;
1.183     bertrand  130:    nombre_thread_surveillance_processus = 0;
1.82      bertrand  131:    pid_processus_pere = getpid();
1.37      bertrand  132: 
1.186     bertrand  133: #  ifdef DEBUG_PROC
                    134:    __proc = 0;
                    135: #  endif
                    136: 
1.27      bertrand  137: #  ifdef DEBUG_MEMOIRE
                    138:    debug_memoire_initialisation();
                    139: #  endif
                    140: 
1.1       bertrand  141:    setvbuf(stdout, NULL, _IOLBF, 0);
                    142:    setvbuf(stderr, NULL, _IOLBF, 0);
                    143: 
1.165     bertrand  144:    if ((s_etat_processus = sys_malloc(sizeof(struct_processus))) == NULL)
1.1       bertrand  145:    {
                    146:        erreur = d_es_allocation_memoire;
                    147: 
1.17      bertrand  148:        if ((langue = getenv("LANG")) != NULL)
1.1       bertrand  149:        {
1.17      bertrand  150:            if (strncmp(langue, "fr", 2) == 0)
                    151:            {
                    152:                uprintf("+++Système : Mémoire insuffisante\n");
                    153:            }
                    154:            else
                    155:            {
                    156:                uprintf("+++System : Not enough memory\n");
                    157:            }
1.1       bertrand  158:        }
                    159:        else
                    160:        {
1.17      bertrand  161:            uprintf("+++System : Not enough memory\n");
1.1       bertrand  162:        }
                    163: 
                    164:        return(EXIT_FAILURE);
                    165:    }
                    166: 
1.164     bertrand  167:    (*s_etat_processus).erreur_systeme = d_es;
                    168: 
                    169:    initialisation_allocateur_buffer(s_etat_processus);
                    170: 
                    171:    if ((*s_etat_processus).erreur_systeme != d_es)
                    172:    {
                    173:        erreur = d_es_allocation_memoire;
                    174: 
                    175:        if ((langue = getenv("LANG")) != NULL)
                    176:        {
                    177:            if (strncmp(langue, "fr", 2) == 0)
                    178:            {
                    179:                uprintf("+++Système : Mémoire insuffisante\n");
                    180:            }
                    181:            else
                    182:            {
                    183:                uprintf("+++System : Not enough memory\n");
                    184:            }
                    185:        }
                    186:        else
                    187:        {
                    188:            uprintf("+++System : Not enough memory\n");
                    189:        }
                    190: 
                    191:        return(EXIT_FAILURE);
                    192:    }
                    193: 
1.165     bertrand  194:    if (initialisation_etat_processus_readline() != 0)
                    195:    {
                    196:        erreur = d_es_allocation_memoire;
                    197: 
                    198:        if ((langue = getenv("LANG")) != NULL)
                    199:        {
                    200:            if (strncmp(langue, "fr", 2) == 0)
                    201:            {
                    202:                uprintf("+++Système : Mémoire insuffisante\n");
                    203:            }
                    204:            else
                    205:            {
                    206:                uprintf("+++System : Not enough memory\n");
                    207:            }
                    208:        }
                    209:        else
                    210:        {
                    211:            uprintf("+++System : Not enough memory\n");
                    212:        }
                    213: 
                    214:        return(EXIT_FAILURE);
                    215:    }
                    216: 
1.17      bertrand  217:    if ((langue = getenv("LANG")) != NULL)
                    218:    {
                    219:        (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0)
                    220:                ? 'F' : 'E';
                    221:    }
                    222:    else
                    223:    {
                    224:        (*s_etat_processus).langue = 'E';
                    225:    }
                    226: 
1.103     bertrand  227:    if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL)
                    228:    {
1.124     bertrand  229:        if ((*s_etat_processus).langue == 'F')
1.103     bertrand  230:        {
1.124     bertrand  231:            uprintf("+++Système : Mémoire insuffisante\n");
1.103     bertrand  232:        }
                    233:        else
                    234:        {
                    235:            uprintf("+++System : Not enough memory\n");
                    236:        }
                    237: 
                    238:        return(EXIT_FAILURE);
                    239:    }
                    240: 
1.167     bertrand  241:    if ((arg_exec = sys_malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL)
1.104     bertrand  242:    {
1.124     bertrand  243:        if ((*s_etat_processus).langue == 'F')
1.104     bertrand  244:        {
1.124     bertrand  245:            uprintf("+++Système : Mémoire insuffisante\n");
1.104     bertrand  246:        }
                    247:        else
                    248:        {
                    249:            uprintf("+++System : Not enough memory\n");
                    250:        }
                    251: 
                    252:        return(EXIT_FAILURE);
                    253:    }
                    254: 
1.136     bertrand  255:    for(i = 0; i < argc; i++)
1.104     bertrand  256:    {
                    257:        arg_exec[i] = argv[i];
                    258:    }
                    259: 
1.167     bertrand  260:    arg_exec[argc] = NULL;
1.104     bertrand  261: 
1.76      bertrand  262:    initialisation_contexte_cas(s_etat_processus);
                    263: 
1.1       bertrand  264:    (*s_etat_processus).exception = d_ep;
                    265:    (*s_etat_processus).erreur_systeme = d_es;
                    266:    (*s_etat_processus).erreur_execution = d_ex;
                    267: 
1.102     bertrand  268:    (*s_etat_processus).requete_redemarrage = d_faux;
1.11      bertrand  269:    (*s_etat_processus).rpl_home = rpl_home;
                    270: 
1.1       bertrand  271:    pthread_mutexattr_init(&attributs_mutex);
                    272:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.146     bertrand  273:    pthread_mutex_init(&((*s_etat_processus).mutex_pile_processus),
                    274:            &attributs_mutex);
1.1       bertrand  275:    pthread_mutexattr_destroy(&attributs_mutex);
                    276: 
1.30      bertrand  277:    pthread_mutexattr_init(&attributs_mutex);
                    278:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.145     bertrand  279:    pthread_mutex_init(&((*s_etat_processus).mutex_interruptions),
                    280:            &attributs_mutex);
                    281:    pthread_mutexattr_destroy(&attributs_mutex);
                    282: 
                    283:    pthread_mutexattr_init(&attributs_mutex);
                    284:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.146     bertrand  285:    pthread_mutex_init(&((*s_etat_processus).mutex_signaux),
                    286:            &attributs_mutex);
                    287:    pthread_mutexattr_destroy(&attributs_mutex);
                    288: 
                    289:    pthread_mutexattr_init(&attributs_mutex);
                    290:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.30      bertrand  291:    pthread_mutex_init(&((*s_etat_processus).mutex_allocation),
                    292:            &attributs_mutex);
                    293:    pthread_mutexattr_destroy(&attributs_mutex);
                    294: 
1.117     bertrand  295:    pthread_mutexattr_init(&attributs_mutex);
1.166     bertrand  296:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
                    297:    pthread_mutex_init(&((*s_etat_processus).mutex_allocation_buffer),
                    298:            &attributs_mutex);
                    299:    pthread_mutexattr_destroy(&attributs_mutex);
                    300: 
                    301:    pthread_mutexattr_init(&attributs_mutex);
1.117     bertrand  302:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
                    303:    pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex);
                    304:    pthread_mutexattr_destroy(&attributs_mutex);
                    305: 
1.128     bertrand  306:    pthread_mutexattr_init(&attributs_mutex);
                    307:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
                    308:    pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex);
                    309:    pthread_mutexattr_destroy(&attributs_mutex);
                    310: 
1.173     bertrand  311:    pthread_mutexattr_init(&attributs_mutex);
                    312:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
                    313:    pthread_mutex_init(&mutex_liste_threads, &attributs_mutex);
                    314:    pthread_mutexattr_destroy(&attributs_mutex);
                    315: 
1.91      bertrand  316: #  ifndef SEMAPHORES_NOMMES
                    317:        sem_init(&((*s_etat_processus).semaphore_fork), 0, 0);
1.207   ! bertrand  318: uprintf("[%d-%llu] Semaphore fork %p (rpl.c)\n", (int) getpid(),
        !           319:        (unsigned long long) pthread_self(),
        !           320:        &((*s_etat_processus).semaphore_fork));
1.91      bertrand  321: #  else
                    322:        if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(),
1.92      bertrand  323:                pthread_self(), SEM_FORK)) == SEM_FAILED)
1.91      bertrand  324:        {
1.155     bertrand  325:            liberation_contexte_cas(s_etat_processus);
1.124     bertrand  326: 
1.91      bertrand  327:            if ((*s_etat_processus).langue == 'F')
                    328:            {
                    329:                uprintf("+++Système : Mémoire insuffisante\n");
                    330:            }
                    331:            else
                    332:            {
                    333:                uprintf("+++System : Not enough memory\n");
                    334:            }
                    335: 
                    336:            return(EXIT_FAILURE);
                    337:        }
                    338: #  endif
1.1       bertrand  339: 
                    340:    pthread_mutexattr_init(&attributs_mutex);
                    341:    pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
                    342:    pthread_mutex_init(&((*s_etat_processus).protection_liste_mutexes),
                    343:            &attributs_mutex);
                    344:    pthread_mutexattr_destroy(&attributs_mutex);
                    345: 
1.40      bertrand  346:    (*s_etat_processus).chemin_fichiers_temporaires =
                    347:            recherche_chemin_fichiers_temporaires(s_etat_processus);
                    348: 
1.43      bertrand  349:    insertion_thread(s_etat_processus, d_vrai);
1.83      bertrand  350:    creation_queue_signaux(s_etat_processus);
1.40      bertrand  351: 
1.124     bertrand  352:    if ((*s_etat_processus).erreur_systeme != d_es)
                    353:    {
                    354: #      ifndef SEMAPHORES_NOMMES
                    355:            sem_post(&((*s_etat_processus).semaphore_fork));
                    356:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    357: #      else
                    358:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  359:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  360:                    pthread_self(), SEM_FORK);
                    361: #      endif
                    362: 
                    363:        liberation_contexte_cas(s_etat_processus);
                    364: 
                    365:        if ((*s_etat_processus).langue == 'F')
                    366:        {
                    367:            uprintf("+++Système : Mémoire insuffisante\n");
                    368:        }
                    369:        else
                    370:        {
                    371:            uprintf("+++System : Not enough memory\n");
                    372:        }
                    373: 
                    374:        return(EXIT_FAILURE);
                    375:    }
                    376: 
1.123     bertrand  377:    if (d_forced_locale == 0)
                    378:    {
                    379:        localisation_courante(s_etat_processus);
                    380:    }
                    381:    else
1.42      bertrand  382:    {
1.124     bertrand  383:        if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
                    384:                + 1) * sizeof(unsigned char))) == NULL)
1.42      bertrand  385:        {
1.148     bertrand  386: #          ifndef SEMAPHORES_NOMMES
                    387:                sem_post(&((*s_etat_processus).semaphore_fork));
                    388:                sem_destroy(&((*s_etat_processus).semaphore_fork));
                    389: #          else
                    390:                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  391:                sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.148     bertrand  392:                        pthread_self(), SEM_FORK);
                    393: #          endif
                    394: 
                    395:            liberation_contexte_cas(s_etat_processus);
1.161     bertrand  396:            destruction_queue_signaux(s_etat_processus);
1.148     bertrand  397: 
1.124     bertrand  398:            if ((*s_etat_processus).langue == 'F')
                    399:            {
                    400:                uprintf("+++Système : Mémoire insuffisante\n");
                    401:            }
                    402:            else
1.42      bertrand  403:            {
1.124     bertrand  404:                uprintf("+++System : Not enough memory\n");
1.42      bertrand  405:            }
                    406: 
1.124     bertrand  407:            return(EXIT_FAILURE);
1.42      bertrand  408:        }
1.124     bertrand  409: 
                    410:        strcpy((*s_etat_processus).localisation, d_locale);
1.42      bertrand  411:    }
1.40      bertrand  412: 
1.17      bertrand  413:    (*s_etat_processus).erreur_systeme = d_es;
1.1       bertrand  414: 
1.17      bertrand  415:    if ((*s_etat_processus).localisation == NULL)
1.1       bertrand  416:    {
1.17      bertrand  417:        if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) *
                    418:                sizeof(unsigned char))) == NULL)
1.1       bertrand  419:        {
1.124     bertrand  420: #          ifndef SEMAPHORES_NOMMES
                    421:                sem_post(&((*s_etat_processus).semaphore_fork));
                    422:                sem_destroy(&((*s_etat_processus).semaphore_fork));
                    423: #          else
                    424:                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  425:                sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  426:                        pthread_self(), SEM_FORK);
                    427: #          endif
                    428: 
                    429:            liberation_contexte_cas(s_etat_processus);
1.161     bertrand  430:            destruction_queue_signaux(s_etat_processus);
1.124     bertrand  431: 
1.17      bertrand  432:            if ((*s_etat_processus).langue == 'F')
                    433:            {
                    434:                uprintf("+++Système : Mémoire insuffisante\n");
                    435:            }
                    436:            else
                    437:            {
                    438:                uprintf("+++System : Not enough memory\n");
                    439:            }
                    440: 
                    441:            return(EXIT_FAILURE);
1.1       bertrand  442:        }
                    443: 
1.17      bertrand  444:        strcpy((*s_etat_processus).localisation, d_locale);
1.1       bertrand  445:    }
                    446: 
1.150     bertrand  447:    if (resultats == NULL) // Appel direct
                    448:    {
                    449:        printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl,
                    450:                ((*s_etat_processus).langue == 'F')
                    451:                ? d_date_rpl : d_date_en_rpl);
1.1       bertrand  452: 
1.150     bertrand  453:        if ((*s_etat_processus).langue == 'F')
                    454:        {
1.204     bertrand  455:            printf("+++Copyright (C) 1989 à 2018, 2019 BERTRAND Joël\n");
1.150     bertrand  456:        }
                    457:        else
                    458:        {
1.204     bertrand  459:            printf("+++Copyright (C) 1989 to 2018, 2019 BERTRAND Joel\n");
1.150     bertrand  460:        }
1.1       bertrand  461:    }
                    462: 
                    463:    if (getenv("HOME") != NULL)
                    464:    {
                    465:        home = getenv("HOME");
                    466:    }
                    467:    else if ((getenv("USER") != NULL) && (getpwnam(getenv("USER")) != NULL))
                    468:    {
                    469:        home = getpwnam(getenv("USER"))->pw_dir;
                    470:    }
                    471:    else if ((getenv("LOGNAME") != NULL) && (getpwnam(getenv("LOGNAME"))
                    472:            != NULL))
                    473:    {
                    474:        home = getpwnam(getenv("LOGNAME"))->pw_dir;
                    475:    }
                    476:    else if ((getuid() != ((uid_t) -1)) && (getpwuid(getuid()) != NULL))
                    477:    {
                    478:        home = getpwuid(getuid())->pw_dir;
                    479:    }
                    480:    else
                    481:    {
                    482:        home = "";
                    483:    }
                    484: 
1.94      bertrand  485: #  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    486:        if (stackoverflow_install_handler(interruption_depassement_pile,
                    487:                pile_signaux, sizeof(pile_signaux)) != 0)
                    488:        {
1.124     bertrand  489: #          ifndef SEMAPHORES_NOMMES
                    490:                sem_post(&((*s_etat_processus).semaphore_fork));
                    491:                sem_destroy(&((*s_etat_processus).semaphore_fork));
                    492: #          else
                    493:                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  494:                sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  495:                        pthread_self(), SEM_FORK);
                    496: #          endif
                    497: 
                    498:            liberation_contexte_cas(s_etat_processus);
1.161     bertrand  499:            destruction_queue_signaux(s_etat_processus);
1.124     bertrand  500: 
1.94      bertrand  501:            erreur = d_es_signal;
1.1       bertrand  502: 
1.94      bertrand  503:            if ((*s_etat_processus).langue == 'F')
                    504:            {
                    505:                printf("+++Système : Initialisation de la pile alternative "
                    506:                        "impossible\n");
                    507:            }
                    508:            else
                    509:            {
                    510:                printf("+++System : Initialization of alternate "
                    511:                        "stack failed\n");
                    512:            }
1.1       bertrand  513: 
1.94      bertrand  514:            return(EXIT_FAILURE);
1.1       bertrand  515:        }
1.94      bertrand  516: #  else
1.1       bertrand  517:        if ((*s_etat_processus).langue == 'F')
                    518:        {
1.94      bertrand  519:            printf("+++Attention : Le système ne supporte pas de pile "
                    520:                    "alternative\n");
1.1       bertrand  521:        }
                    522:        else
                    523:        {
1.94      bertrand  524:            printf("+++Warning : Operating system does not support alternate "
                    525:                    "stack\n");
1.1       bertrand  526:        }
1.9       bertrand  527: #  endif
1.1       bertrand  528: 
1.40      bertrand  529:    action.sa_handler = interruption1;
1.94      bertrand  530:    action.sa_flags = 0;
1.1       bertrand  531: 
                    532:    if (sigaction(SIGINT, &action, NULL) != 0)
                    533:    {
1.124     bertrand  534: #      ifndef SEMAPHORES_NOMMES
                    535:            sem_post(&((*s_etat_processus).semaphore_fork));
                    536:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    537: #      else
                    538:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  539:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  540:                    pthread_self(), SEM_FORK);
                    541: #      endif
                    542: 
                    543:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  544:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  545: 
                    546: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    547:            stackoverflow_deinstall_handler();
                    548: #      endif
                    549: 
1.1       bertrand  550:        erreur = d_es_signal;
                    551: 
                    552:        if ((*s_etat_processus).langue == 'F')
                    553:        {
                    554:            printf("+++Système : Initialisation des signaux POSIX "
                    555:                    "impossible\n");
                    556:        }
                    557:        else
                    558:        {
                    559:            printf("+++System : Initialization of POSIX signals failed\n");
                    560:        }
                    561: 
                    562:        return(EXIT_FAILURE);
                    563:    }
                    564: 
1.81      bertrand  565:    signal_test = SIGTEST;
1.133     bertrand  566:    raise(SIGINT);
1.81      bertrand  567: 
1.115     bertrand  568:    attente.tv_sec = 0;
                    569:    attente.tv_nsec = 1000000;
                    570: 
                    571:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    572:    {
                    573:        nanosleep(&attente, NULL);
                    574:    }
                    575: 
1.81      bertrand  576:    if (signal_test != SIGINT)
                    577:    {
1.124     bertrand  578: #      ifndef SEMAPHORES_NOMMES
                    579:            sem_post(&((*s_etat_processus).semaphore_fork));
                    580:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    581: #      else
                    582:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  583:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  584:                    pthread_self(), SEM_FORK);
                    585: #      endif
                    586: 
                    587:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  588:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  589: 
                    590: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    591:            stackoverflow_deinstall_handler();
                    592: #      endif
                    593: 
1.81      bertrand  594:        erreur = d_es_signal;
                    595: 
                    596:        if ((*s_etat_processus).langue == 'F')
                    597:        {
                    598:            printf("+++Système : Initialisation des signaux POSIX "
                    599:                    "impossible\n");
                    600:        }
                    601:        else
                    602:        {
                    603:            printf("+++System : Initialization of POSIX signals failed\n");
                    604:        }
                    605: 
                    606:        return(EXIT_FAILURE);
                    607:    }
                    608: 
1.54      bertrand  609:    if (sigaction(SIGTERM, &action, NULL) != 0)
                    610:    {
1.124     bertrand  611: #      ifndef SEMAPHORES_NOMMES
                    612:            sem_post(&((*s_etat_processus).semaphore_fork));
                    613:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    614: #      else
                    615:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  616:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  617:                    pthread_self(), SEM_FORK);
                    618: #      endif
                    619: 
                    620:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  621:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  622: 
                    623: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    624:            stackoverflow_deinstall_handler();
                    625: #      endif
                    626: 
1.54      bertrand  627:        erreur = d_es_signal;
                    628: 
                    629:        if ((*s_etat_processus).langue == 'F')
                    630:        {
                    631:            printf("+++Système : Initialisation des signaux POSIX "
                    632:                    "impossible\n");
                    633:        }
                    634:        else
                    635:        {
                    636:            printf("+++System : Initialization of POSIX signals failed\n");
                    637:        }
                    638: 
                    639:        return(EXIT_FAILURE);
                    640:    }
                    641: 
1.81      bertrand  642:    signal_test = SIGTEST;
1.133     bertrand  643:    raise(SIGTERM);
1.81      bertrand  644: 
1.115     bertrand  645:    attente.tv_sec = 0;
                    646:    attente.tv_nsec = 1000000;
                    647: 
                    648:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    649:    {
                    650:        nanosleep(&attente, NULL);
                    651:    }
                    652: 
1.81      bertrand  653:    if (signal_test != SIGTERM)
                    654:    {
1.124     bertrand  655: #      ifndef SEMAPHORES_NOMMES
                    656:            sem_post(&((*s_etat_processus).semaphore_fork));
                    657:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    658: #      else
                    659:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  660:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  661:                    pthread_self(), SEM_FORK);
                    662: #      endif
                    663: 
                    664:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  665:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  666: 
                    667: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    668:            stackoverflow_deinstall_handler();
                    669: #      endif
                    670: 
1.81      bertrand  671:        erreur = d_es_signal;
                    672: 
                    673:        if ((*s_etat_processus).langue == 'F')
                    674:        {
                    675:            printf("+++Système : Initialisation des signaux POSIX "
                    676:                    "impossible\n");
                    677:        }
                    678:        else
                    679:        {
                    680:            printf("+++System : Initialization of POSIX signals failed\n");
                    681:        }
                    682: 
                    683:        return(EXIT_FAILURE);
                    684:    }
                    685: 
1.186     bertrand  686:    if (sigaction(SIGUSR2, &action, NULL) != 0)
1.106     bertrand  687:    {
1.124     bertrand  688: #      ifndef SEMAPHORES_NOMMES
                    689:            sem_post(&((*s_etat_processus).semaphore_fork));
                    690:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    691: #      else
                    692:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  693:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  694:                    pthread_self(), SEM_FORK);
                    695: #      endif
                    696: 
                    697:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  698:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  699: 
                    700: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    701:            stackoverflow_deinstall_handler();
                    702: #      endif
                    703: 
1.106     bertrand  704:        erreur = d_es_signal;
                    705: 
                    706:        if ((*s_etat_processus).langue == 'F')
                    707:        {
                    708:            printf("+++Système : Initialisation des signaux POSIX "
                    709:                    "impossible\n");
                    710:        }
                    711:        else
                    712:        {
                    713:            printf("+++System : Initialization of POSIX signals failed\n");
                    714:        }
                    715: 
                    716:        return(EXIT_FAILURE);
                    717:    }
                    718: 
                    719:    signal_test = SIGTEST;
1.186     bertrand  720:    raise(SIGUSR2);
1.106     bertrand  721: 
1.115     bertrand  722:    attente.tv_sec = 0;
                    723:    attente.tv_nsec = 1000000;
                    724: 
                    725:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    726:    {
                    727:        nanosleep(&attente, NULL);
                    728:    }
                    729: 
1.186     bertrand  730:    if (signal_test != SIGUSR2)
1.106     bertrand  731:    {
1.124     bertrand  732: #      ifndef SEMAPHORES_NOMMES
                    733:            sem_post(&((*s_etat_processus).semaphore_fork));
                    734:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    735: #      else
                    736:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  737:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  738:                    pthread_self(), SEM_FORK);
                    739: #      endif
                    740: 
                    741:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  742:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  743: 
                    744: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    745:            stackoverflow_deinstall_handler();
                    746: #      endif
                    747: 
1.106     bertrand  748:        erreur = d_es_signal;
                    749: 
                    750:        if ((*s_etat_processus).langue == 'F')
                    751:        {
                    752:            printf("+++Système : Initialisation des signaux POSIX "
                    753:                    "impossible\n");
                    754:        }
                    755:        else
                    756:        {
                    757:            printf("+++System : Initialization of POSIX signals failed\n");
                    758:        }
                    759: 
                    760:        return(EXIT_FAILURE);
                    761:    }
                    762: 
1.40      bertrand  763:    action.sa_handler = interruption2;
1.94      bertrand  764:    action.sa_flags = 0;
1.1       bertrand  765: 
                    766:    if (sigaction(SIGTSTP, &action, NULL) != 0)
                    767:    {
1.124     bertrand  768: #      ifndef SEMAPHORES_NOMMES
                    769:            sem_post(&((*s_etat_processus).semaphore_fork));
                    770:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    771: #      else
                    772:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  773:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  774:                    pthread_self(), SEM_FORK);
                    775: #      endif
                    776: 
                    777:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  778:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  779: 
                    780: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    781:            stackoverflow_deinstall_handler();
                    782: #      endif
                    783: 
1.1       bertrand  784:        if ((*s_etat_processus).langue == 'F')
                    785:        {
                    786:            printf("+++Système : Initialisation des signaux POSIX "
                    787:                    "impossible\n");
                    788:        }
                    789:        else
                    790:        {
                    791:            printf("+++System : Initialization of POSIX signals failed\n");
                    792:        }
                    793: 
                    794:        return(EXIT_FAILURE);
                    795:    }
                    796: 
1.81      bertrand  797:    signal_test = SIGTEST;
1.133     bertrand  798:    raise(SIGTSTP);
1.81      bertrand  799: 
1.115     bertrand  800:    attente.tv_sec = 0;
                    801:    attente.tv_nsec = 1000000;
                    802: 
                    803:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    804:    {
                    805:        nanosleep(&attente, NULL);
                    806:    }
                    807: 
1.81      bertrand  808:    if (signal_test != SIGTSTP)
                    809:    {
1.124     bertrand  810: #      ifndef SEMAPHORES_NOMMES
                    811:            sem_post(&((*s_etat_processus).semaphore_fork));
                    812:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    813: #      else
                    814:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  815:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  816:                    pthread_self(), SEM_FORK);
                    817: #      endif
                    818: 
                    819:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  820:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  821: 
                    822: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    823:            stackoverflow_deinstall_handler();
                    824: #      endif
                    825: 
1.81      bertrand  826:        erreur = d_es_signal;
                    827: 
                    828:        if ((*s_etat_processus).langue == 'F')
                    829:        {
                    830:            printf("+++Système : Initialisation des signaux POSIX "
                    831:                    "impossible\n");
                    832:        }
                    833:        else
                    834:        {
                    835:            printf("+++System : Initialization of POSIX signals failed\n");
                    836:        }
                    837: 
                    838:        return(EXIT_FAILURE);
                    839:    }
                    840: 
1.40      bertrand  841:    action.sa_handler = interruption5;
1.94      bertrand  842:    action.sa_flags = 0;
1.1       bertrand  843: 
                    844:    if (sigaction(SIGPIPE, &action, NULL) != 0)
                    845:    {
1.124     bertrand  846: #      ifndef SEMAPHORES_NOMMES
                    847:            sem_post(&((*s_etat_processus).semaphore_fork));
                    848:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    849: #      else
                    850:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  851:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  852:                    pthread_self(), SEM_FORK);
                    853: #      endif
                    854: 
                    855:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  856:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  857: 
                    858: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    859:            stackoverflow_deinstall_handler();
                    860: #      endif
                    861: 
1.1       bertrand  862:        erreur = d_es_signal;
                    863: 
                    864:        if ((*s_etat_processus).langue == 'F')
                    865:        {
                    866:            printf("+++Système : Initialisation des signaux POSIX "
                    867:                    "impossible\n");
                    868:        }
                    869:        else
                    870:        {
                    871:            printf("+++System : Initialization of POSIX signals failed\n");
                    872:        }
                    873: 
                    874:        return(EXIT_FAILURE);
                    875:    }
                    876: 
1.81      bertrand  877:    signal_test = SIGTEST;
1.133     bertrand  878:    raise(SIGPIPE);
1.81      bertrand  879: 
1.115     bertrand  880:    attente.tv_sec = 0;
                    881:    attente.tv_nsec = 1000000;
                    882: 
                    883:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    884:    {
                    885:        nanosleep(&attente, NULL);
                    886:    }
                    887: 
1.81      bertrand  888:    if (signal_test != SIGPIPE)
                    889:    {
1.124     bertrand  890: #      ifndef SEMAPHORES_NOMMES
                    891:            sem_post(&((*s_etat_processus).semaphore_fork));
                    892:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    893: #      else
                    894:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  895:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  896:                    pthread_self(), SEM_FORK);
                    897: #      endif
                    898: 
                    899:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  900:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  901: 
                    902: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    903:            stackoverflow_deinstall_handler();
                    904: #      endif
                    905: 
1.81      bertrand  906:        erreur = d_es_signal;
                    907: 
                    908:        if ((*s_etat_processus).langue == 'F')
                    909:        {
                    910:            printf("+++Système : Initialisation des signaux POSIX "
                    911:                    "impossible\n");
                    912:        }
                    913:        else
                    914:        {
                    915:            printf("+++System : Initialization of POSIX signals failed\n");
                    916:        }
                    917: 
                    918:        return(EXIT_FAILURE);
                    919:    }
                    920: 
1.40      bertrand  921:    action.sa_handler = interruption1;
1.94      bertrand  922:    action.sa_flags = 0;
1.1       bertrand  923: 
1.94      bertrand  924:    if (sigaction(SIGUSR1, &action, NULL) != 0)
1.1       bertrand  925:    {
1.124     bertrand  926: #      ifndef SEMAPHORES_NOMMES
                    927:            sem_post(&((*s_etat_processus).semaphore_fork));
                    928:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    929: #      else
                    930:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  931:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  932:                    pthread_self(), SEM_FORK);
                    933: #      endif
                    934: 
                    935:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  936:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  937: 
                    938: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    939:            stackoverflow_deinstall_handler();
                    940: #      endif
                    941: 
1.1       bertrand  942:        erreur = d_es_signal;
                    943: 
                    944:        if ((*s_etat_processus).langue == 'F')
                    945:        {
                    946:            printf("+++Système : Initialisation des signaux POSIX "
                    947:                    "impossible\n");
                    948:        }
                    949:        else
                    950:        {
                    951:            printf("+++System : Initialization of POSIX signals failed\n");
                    952:        }
                    953: 
                    954:        return(EXIT_FAILURE);
                    955:    }
                    956: 
1.81      bertrand  957:    signal_test = SIGTEST;
1.133     bertrand  958:    raise(SIGUSR1);
1.81      bertrand  959: 
1.115     bertrand  960:    attente.tv_sec = 0;
                    961:    attente.tv_nsec = 1000000;
                    962: 
                    963:    for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                    964:    {
                    965:        nanosleep(&attente, NULL);
                    966:    }
                    967: 
1.94      bertrand  968:    if (signal_test != SIGUSR1)
1.81      bertrand  969:    {
1.124     bertrand  970: #      ifndef SEMAPHORES_NOMMES
                    971:            sem_post(&((*s_etat_processus).semaphore_fork));
                    972:            sem_destroy(&((*s_etat_processus).semaphore_fork));
                    973: #      else
                    974:            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand  975:            sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124     bertrand  976:                    pthread_self(), SEM_FORK);
                    977: #      endif
                    978: 
                    979:        liberation_contexte_cas(s_etat_processus);
1.161     bertrand  980:        destruction_queue_signaux(s_etat_processus);
1.124     bertrand  981: 
                    982: #      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                    983:            stackoverflow_deinstall_handler();
                    984: #      endif
                    985: 
1.81      bertrand  986:        erreur = d_es_signal;
                    987: 
                    988:        if ((*s_etat_processus).langue == 'F')
                    989:        {
                    990:            printf("+++Système : Initialisation des signaux POSIX "
                    991:                    "impossible\n");
                    992:        }
                    993:        else
                    994:        {
                    995:            printf("+++System : Initialization of POSIX signals failed\n");
                    996:        }
                    997: 
                    998:        return(EXIT_FAILURE);
                    999:    }
                   1000: 
1.82      bertrand 1001:    signal_test = SIGTEST + 1;
1.1       bertrand 1002: 
1.13      bertrand 1003:    erreur = d_absence_erreur;
1.1       bertrand 1004:    core = d_faux;
                   1005:    mode_interactif = d_faux;
                   1006:    (*s_etat_processus).nom_fichier_source = NULL;
                   1007:    (*s_etat_processus).definitions_chainees = NULL;
                   1008:    (*s_etat_processus).type_debug = 0;
                   1009:    traitement_fichier_temporaire = 'N';
                   1010:    option = ' ';
                   1011:    drapeau_encart = 'Y';
                   1012:    debug = d_faux;
                   1013:    arguments = NULL;
1.195     bertrand 1014:    l_bibliotheques = NULL;
1.1       bertrand 1015: 
                   1016:    (*s_etat_processus).s_fichiers = NULL;
                   1017:    (*s_etat_processus).s_sockets = NULL;
                   1018:    (*s_etat_processus).s_connecteurs_sql = NULL;
                   1019: 
                   1020:    setlogmask(LOG_MASK(LOG_NOTICE));
                   1021:    openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_USER);
                   1022: 
                   1023:    if (argc == 1)
                   1024:    {
1.13      bertrand 1025:        erreur = d_erreur;
1.1       bertrand 1026:        informations(s_etat_processus);
                   1027:    }
                   1028:    else
                   1029:    {
                   1030:        presence_definition = 'N';
                   1031:        (*s_etat_processus).debug = d_faux;
                   1032:        (*s_etat_processus).lancement_interactif = d_faux;
                   1033: 
                   1034:        option_a = d_faux;
                   1035:        option_A = d_faux;
                   1036:        option_c = d_faux;
                   1037:        option_d = d_faux;
                   1038:        option_D = d_faux;
                   1039:        option_h = d_faux;
                   1040:        option_i = d_faux;
                   1041:        option_l = d_faux;
                   1042:        option_n = d_faux;
                   1043:        option_p = d_faux;
                   1044:        option_P = 0;
                   1045:        option_s = d_faux;
                   1046:        option_S = d_faux;
                   1047:        option_t = d_faux;
                   1048:        option_v = d_faux;
                   1049: 
1.86      bertrand 1050:        // Lorsque le programme est appelé depuis un shebang, argv[0] contient
                   1051:        // le chemin du programme et argv[1] tous les arguments.
                   1052:        // argv[2] contient quant à lui le nom du script RPL/2.
                   1053:        //
                   1054:        // Exemple :
                   1055:        // argv[0] : /usr/local/bin/rpl
                   1056:        // argv[1] : -csdp -t 800
                   1057:        // argv[2] : ./on_exit.rpl
                   1058: 
1.1       bertrand 1059:        while((--argc) > 0)
                   1060:        {
                   1061:            if ((*(++argv))[0] == '-')
                   1062:            {
                   1063:                while((option = *(++argv[0])) != '\0')
                   1064:                {
                   1065:                    switch(option)
                   1066:                    {
                   1067:                        case 'a' :
                   1068:                        {
                   1069:                            if (option_a == d_vrai)
                   1070:                            {
1.124     bertrand 1071: #                              ifndef SEMAPHORES_NOMMES
                   1072:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1073:                                sem_destroy(&((*s_etat_processus)
                   1074:                                        .semaphore_fork));
                   1075: #                              else
                   1076:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1077:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1078:                                        getpid(), pthread_self(), SEM_FORK);
                   1079: #                              endif
                   1080: 
                   1081:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1082:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1083: 
                   1084: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1085:                                stackoverflow_deinstall_handler();
                   1086: #                              endif
                   1087: 
1.1       bertrand 1088:                                if ((*s_etat_processus).langue == 'F')
                   1089:                                {
                   1090:                                    printf("+++Erreur : option -a présente "
                   1091:                                            "plus d'une fois\n");
                   1092:                                }
                   1093:                                else
                   1094:                                {
                   1095:                                    printf("+++Error : more than one -a "
                   1096:                                            "on command line");
                   1097:                                }
                   1098: 
                   1099:                                return(EXIT_FAILURE);
                   1100:                            }
                   1101: 
                   1102:                            option_a = d_vrai;
                   1103:                            break;
                   1104:                        }
                   1105: 
                   1106:                        case 'A' :
                   1107:                        {
                   1108:                            if (option_A == d_vrai)
                   1109:                            {
1.124     bertrand 1110: #                              ifndef SEMAPHORES_NOMMES
                   1111:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1112:                                sem_destroy(&((*s_etat_processus)
                   1113:                                        .semaphore_fork));
                   1114: #                              else
                   1115:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1116:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1117:                                        getpid(), pthread_self(), SEM_FORK);
                   1118: #                              endif
                   1119: 
                   1120:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1121:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1122: 
                   1123: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1124:                                stackoverflow_deinstall_handler();
                   1125: #                              endif
                   1126: 
1.1       bertrand 1127:                                if ((*s_etat_processus).langue == 'F')
                   1128:                                {
                   1129:                                    printf("+++Erreur : option -A présente "
                   1130:                                            "plus d'une fois\n");
                   1131:                                }
                   1132:                                else
                   1133:                                {
                   1134:                                    printf("+++Error : more than one -A "
                   1135:                                            "on command line");
                   1136:                                }
                   1137: 
                   1138:                                return(EXIT_FAILURE);
                   1139:                            }
                   1140: 
                   1141:                            option_A = d_vrai;
                   1142: 
                   1143:                            while(*(++argv[0]) == ' ');
                   1144:                            argv[0]--;
                   1145: 
                   1146:                            if ((*(++argv[0])) != '\0')
                   1147:                            {
                   1148:                                if ((arguments = malloc((strlen(argv[0]) + 7) *
                   1149:                                        sizeof(unsigned char))) == NULL)
                   1150:                                {
1.124     bertrand 1151: #                                  ifndef SEMAPHORES_NOMMES
                   1152:                                    sem_post(&((*s_etat_processus)
                   1153:                                            .semaphore_fork));
                   1154:                                    sem_destroy(&((*s_etat_processus)
                   1155:                                            .semaphore_fork));
                   1156: #                                  else
                   1157:                                    sem_post((*s_etat_processus)
                   1158:                                            .semaphore_fork);
                   1159:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 1160:                                            .semaphore_fork, getpid(),
1.124     bertrand 1161:                                            pthread_self(), SEM_FORK);
                   1162: #                                  endif
                   1163: 
                   1164:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1165:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1166: 
                   1167: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1168:                                    stackoverflow_deinstall_handler();
                   1169: #                                  endif
                   1170: 
1.1       bertrand 1171:                                    if ((*s_etat_processus).langue == 'F')
                   1172:                                    {
                   1173:                                        printf("+++Système : Mémoire "
                   1174:                                                "insuffisante\n");
                   1175:                                    }
                   1176:                                    else
                   1177:                                    {
                   1178:                                        printf("+++System : Not enough "
                   1179:                                                "memory\n");
                   1180:                                    }
                   1181: 
                   1182:                                    return(EXIT_FAILURE);
                   1183:                                }
                   1184: 
                   1185:                                ptr = arguments;
                   1186:                                (*ptr) = d_code_fin_chaine;
                   1187:                                strcat(ptr, "<< ");
                   1188:                                ptr += 3;
                   1189: 
                   1190:                                while(*(argv[0]) != '\0')
                   1191:                                {
                   1192:                                    *(ptr++) = *(argv[0]++);
                   1193:                                }
                   1194: 
                   1195:                                (*ptr) = '\0';
                   1196: 
                   1197:                                strcat(arguments, " >>");
                   1198:                                argv[0]--;
                   1199:                            }
                   1200:                            else if ((--argc) > 0)
                   1201:                            {
                   1202:                                argv++;
                   1203: 
                   1204:                                if ((arguments = malloc((strlen(argv[0]) + 7) *
                   1205:                                        sizeof(unsigned char))) == NULL)
                   1206:                                {
1.124     bertrand 1207: #                                  ifndef SEMAPHORES_NOMMES
                   1208:                                    sem_post(&((*s_etat_processus)
                   1209:                                            .semaphore_fork));
                   1210:                                    sem_destroy(&((*s_etat_processus)
                   1211:                                            .semaphore_fork));
                   1212: #                                  else
                   1213:                                    sem_post((*s_etat_processus)
                   1214:                                            .semaphore_fork);
                   1215:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 1216:                                            .semaphore_fork, getpid(),
1.124     bertrand 1217:                                            pthread_self(), SEM_FORK);
                   1218: #                                  endif
                   1219: 
                   1220:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1221:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1222: 
                   1223: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1224:                                    stackoverflow_deinstall_handler();
                   1225: #                                  endif
                   1226: 
1.1       bertrand 1227:                                    if ((*s_etat_processus).langue == 'F')
                   1228:                                    {
                   1229:                                        printf("+++Système : Mémoire "
                   1230:                                                "insuffisante\n");
                   1231:                                    }
                   1232:                                    else
                   1233:                                    {
                   1234:                                        printf("+++System : Not enough "
                   1235:                                                "memory\n");
                   1236:                                    }
                   1237: 
                   1238:                                    return(EXIT_FAILURE);
                   1239:                                }
                   1240: 
                   1241:                                ptr = arguments;
                   1242:                                (*ptr) = d_code_fin_chaine;
                   1243:                                strcat(ptr, "<< ");
                   1244:                                ptr += 3;
                   1245: 
                   1246:                                while(*(argv[0]) != '\0')
                   1247:                                {
                   1248:                                    *(ptr++) = *(argv[0]++);
                   1249:                                }
                   1250: 
                   1251:                                (*ptr) = '\0';
                   1252: 
                   1253:                                strcat(arguments, " >>");
                   1254:                                argv[0]--;
                   1255:                            }
                   1256:                            else
                   1257:                            {
1.124     bertrand 1258: #                              ifndef SEMAPHORES_NOMMES
                   1259:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1260:                                sem_destroy(&((*s_etat_processus)
                   1261:                                        .semaphore_fork));
                   1262: #                              else
                   1263:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1264:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1265:                                        getpid(), pthread_self(), SEM_FORK);
                   1266: #                              endif
                   1267: 
                   1268:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1269:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1270: 
                   1271: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1272:                                stackoverflow_deinstall_handler();
                   1273: #                              endif
                   1274: 
1.1       bertrand 1275:                                if ((*s_etat_processus).langue == 'F')
                   1276:                                {
                   1277:                                    printf("+++Erreur : Aucune donnée "
                   1278:                                            "spécifié après l'option -A\n");
                   1279:                                }
                   1280:                                else
                   1281:                                {
                   1282:                                    printf("+++Error : Data required after "
                   1283:                                            "-A option\n");
                   1284:                                }
                   1285: 
                   1286:                                return(EXIT_FAILURE);
                   1287:                            }
                   1288: 
                   1289:                            break;
                   1290:                        }
                   1291: 
                   1292:                        case 'c' :
                   1293:                        {
                   1294:                            if (option_c == d_vrai)
                   1295:                            {
1.124     bertrand 1296: #                              ifndef SEMAPHORES_NOMMES
                   1297:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1298:                                sem_destroy(&((*s_etat_processus)
                   1299:                                        .semaphore_fork));
                   1300: #                              else
                   1301:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1302:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1303:                                        getpid(), pthread_self(), SEM_FORK);
                   1304: #                              endif
                   1305: 
                   1306:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1307:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1308: 
                   1309: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1310:                                stackoverflow_deinstall_handler();
                   1311: #                              endif
                   1312: 
1.1       bertrand 1313:                                if ((*s_etat_processus).langue == 'F')
                   1314:                                {
                   1315:                                    printf("+++Erreur : option -c présente "
                   1316:                                            "plus d'une fois\n");
                   1317:                                }
                   1318:                                else
                   1319:                                {
                   1320:                                    printf("+++Error : more than one -c "
                   1321:                                            "on command line");
                   1322:                                }
                   1323: 
                   1324:                                return(EXIT_FAILURE);
                   1325:                            }
                   1326: 
                   1327:                            option_c = d_vrai;
                   1328:                            core = d_vrai;
                   1329:                            break;
                   1330:                        }
                   1331: 
                   1332:                        case 'd' :
                   1333:                        {
                   1334:                            if (option_d == d_vrai)
                   1335:                            {
1.124     bertrand 1336: #                              ifndef SEMAPHORES_NOMMES
                   1337:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1338:                                sem_destroy(&((*s_etat_processus)
                   1339:                                        .semaphore_fork));
                   1340: #                              else
                   1341:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1342:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1343:                                        getpid(), pthread_self(), SEM_FORK);
                   1344: #                              endif
                   1345: 
                   1346:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1347:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1348: 
                   1349: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1350:                                stackoverflow_deinstall_handler();
                   1351: #                              endif
                   1352: 
1.1       bertrand 1353:                                if ((*s_etat_processus).langue == 'F')
                   1354:                                {
                   1355:                                    printf("+++Erreur : option -d présente "
                   1356:                                            "plus d'une fois\n");
                   1357:                                }
                   1358:                                else
                   1359:                                {
                   1360:                                    printf("+++Error : more than one -d "
                   1361:                                            "on command line");
                   1362:                                }
                   1363: 
                   1364:                                return(EXIT_FAILURE);
                   1365:                            }
                   1366: 
                   1367:                            option_d = d_vrai;
                   1368:                            debug = d_vrai;
                   1369:                            break;
                   1370:                        }
                   1371: 
                   1372:                        case 'D' :
                   1373:                        {
                   1374:                            if (option_D == d_vrai)
                   1375:                            {
1.124     bertrand 1376: #                              ifndef SEMAPHORES_NOMMES
                   1377:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1378:                                sem_destroy(&((*s_etat_processus)
                   1379:                                        .semaphore_fork));
                   1380: #                              else
                   1381:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1382:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1383:                                        getpid(), pthread_self(), SEM_FORK);
                   1384: #                              endif
                   1385: 
                   1386:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1387:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1388: 
                   1389: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1390:                                stackoverflow_deinstall_handler();
                   1391: #                              endif
                   1392: 
1.1       bertrand 1393:                                if ((*s_etat_processus).langue == 'F')
                   1394:                                {
                   1395:                                    printf("+++Erreur : option -D présente "
                   1396:                                            "plus d'une fois\n");
                   1397:                                }
                   1398:                                else
                   1399:                                {
                   1400:                                    printf("+++Error : more than one -D "
                   1401:                                            "on command line");
                   1402:                                }
                   1403: 
                   1404:                                return(EXIT_FAILURE);
                   1405:                            }
                   1406: 
                   1407:                            option_D = d_vrai;
                   1408:                            break;
                   1409:                        }
                   1410: 
                   1411:                        case 'h' :
                   1412:                        {
                   1413:                            if (option_h == d_vrai)
                   1414:                            {
1.124     bertrand 1415: #                              ifndef SEMAPHORES_NOMMES
                   1416:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1417:                                sem_destroy(&((*s_etat_processus)
                   1418:                                        .semaphore_fork));
                   1419: #                              else
                   1420:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1421:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1422:                                        getpid(), pthread_self(), SEM_FORK);
                   1423: #                              endif
                   1424: 
                   1425:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1426:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1427: 
                   1428: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1429:                                stackoverflow_deinstall_handler();
                   1430: #                              endif
                   1431: 
1.1       bertrand 1432:                                if ((*s_etat_processus).langue == 'F')
                   1433:                                {
                   1434:                                    printf("+++Erreur : option -h présente "
                   1435:                                            "plus d'une fois\n");
                   1436:                                }
                   1437:                                else
                   1438:                                {
                   1439:                                    printf("+++Error : more than one -h "
                   1440:                                            "on command line");
                   1441:                                }
                   1442: 
                   1443:                                return(EXIT_FAILURE);
                   1444:                            }
                   1445: 
                   1446:                            option_h = d_vrai;
                   1447:                            informations(s_etat_processus);
                   1448:                            break;
                   1449:                        }
                   1450: 
                   1451:                        case 'i' :
                   1452:                        {
                   1453:                            if (option_i == d_vrai) 
                   1454:                            {
1.124     bertrand 1455: #                              ifndef SEMAPHORES_NOMMES
                   1456:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1457:                                sem_destroy(&((*s_etat_processus)
                   1458:                                        .semaphore_fork));
                   1459: #                              else
                   1460:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1461:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1462:                                        getpid(), pthread_self(), SEM_FORK);
                   1463: #                              endif
                   1464: 
                   1465:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1466:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1467: 
                   1468: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1469:                                stackoverflow_deinstall_handler();
                   1470: #                              endif
                   1471: 
1.1       bertrand 1472:                                if ((*s_etat_processus).langue == 'F')
                   1473:                                {
                   1474:                                    printf("+++Erreur : option -i présente "
                   1475:                                            "plus d'une fois\n");
                   1476:                                }
                   1477:                                else
                   1478:                                {
                   1479:                                    printf("+++Error : more than one -i "
                   1480:                                            "on command line");
                   1481:                                }
                   1482: 
                   1483:                                return(EXIT_FAILURE);
                   1484:                            }
                   1485:                            else if (option_S == d_vrai)
                   1486:                            {
1.124     bertrand 1487: #                              ifndef SEMAPHORES_NOMMES
                   1488:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1489:                                sem_destroy(&((*s_etat_processus)
                   1490:                                        .semaphore_fork));
                   1491: #                              else
                   1492:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1493:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1494:                                        getpid(), pthread_self(), SEM_FORK);
                   1495: #                              endif
                   1496: 
                   1497:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1498:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1499: 
                   1500: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1501:                                stackoverflow_deinstall_handler();
                   1502: #                              endif
                   1503: 
1.1       bertrand 1504:                                if ((*s_etat_processus).langue == 'F')
                   1505:                                {
                   1506:                                    printf("+++Erreur : options -i et -S "
                   1507:                                            "incompatibles\n");
                   1508:                                }
                   1509:                                else
                   1510:                                {
                   1511:                                    printf("+++Error : incompatible options -i "
                   1512:                                            "and -S\n");
                   1513:                                }
                   1514: 
                   1515:                                return(EXIT_FAILURE);
                   1516:                            }
                   1517:                            else if (option_p == d_vrai)
                   1518:                            {
1.124     bertrand 1519: #                              ifndef SEMAPHORES_NOMMES
                   1520:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1521:                                sem_destroy(&((*s_etat_processus)
                   1522:                                        .semaphore_fork));
                   1523: #                              else
                   1524:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1525:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1526:                                        getpid(), pthread_self(), SEM_FORK);
                   1527: #                              endif
                   1528: 
                   1529:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1530:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1531: 
                   1532: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1533:                                stackoverflow_deinstall_handler();
                   1534: #                              endif
                   1535: 
1.1       bertrand 1536:                                if ((*s_etat_processus).langue == 'F')
                   1537:                                {
                   1538:                                    printf("+++Erreur : options -i et -p "
                   1539:                                            "incompatibles\n");
                   1540:                                }
                   1541:                                else
                   1542:                                {
                   1543:                                    printf("+++Error : incompatible options -i "
                   1544:                                            "and -p\n");
                   1545:                                }
                   1546: 
                   1547:                                return(EXIT_FAILURE);
                   1548:                            }
                   1549: 
                   1550:                            option_i = d_vrai;
                   1551:                            mode_interactif = d_vrai;
                   1552:                            presence_definition = 'O';
                   1553:                            break;
                   1554:                        }
                   1555: 
                   1556:                        case 'l' :
                   1557:                        {
                   1558:                            if (option_l == d_vrai)
                   1559:                            {
1.124     bertrand 1560: #                              ifndef SEMAPHORES_NOMMES
                   1561:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1562:                                sem_destroy(&((*s_etat_processus)
                   1563:                                        .semaphore_fork));
                   1564: #                              else
                   1565:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1566:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1567:                                        getpid(), pthread_self(), SEM_FORK);
                   1568: #                              endif
                   1569: 
                   1570:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1571:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1572: 
                   1573: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1574:                                stackoverflow_deinstall_handler();
                   1575: #                              endif
                   1576: 
1.1       bertrand 1577:                                if ((*s_etat_processus).langue == 'F')
                   1578:                                {
                   1579:                                    printf("+++Erreur : option -l présente "
                   1580:                                            "plus d'une fois\n");
                   1581:                                }
                   1582:                                else
                   1583:                                {
                   1584:                                    printf("+++Error : more than one -l "
                   1585:                                            "on command line");
                   1586:                                }
                   1587: 
                   1588:                                return(EXIT_FAILURE);
                   1589:                            }
                   1590: 
                   1591:                            option_l = d_vrai;
                   1592: 
                   1593:                            if ((*s_etat_processus).langue == 'F')
                   1594:                            {
                   1595:                                printf("%s\n\n", CeCILL_fr);
                   1596:                            }
                   1597:                            else
                   1598:                            {
                   1599:                                printf("%s\n\n", CeCILL_en);
                   1600:                            }
                   1601: 
                   1602:                            break;
                   1603:                        }
                   1604: 
1.195     bertrand 1605:                        case 'm' :
                   1606:                        {
                   1607:                            while(*(++argv[0]) == ' ');
                   1608:                            argv[0]--;
                   1609: 
                   1610:                            if ((*(++argv[0])) != '\0')
                   1611:                            {
                   1612:                                if ((l_nouvelle_bibliotheque = malloc(
                   1613:                                        sizeof(struct_liste_chainee))) == NULL)
                   1614:                                {
                   1615: #                                  ifndef SEMAPHORES_NOMMES
                   1616:                                    sem_post(&((*s_etat_processus)
                   1617:                                            .semaphore_fork));
                   1618:                                    sem_destroy(&((*s_etat_processus)
                   1619:                                            .semaphore_fork));
                   1620: #                                  else
                   1621:                                    sem_post((*s_etat_processus)
                   1622:                                            .semaphore_fork);
                   1623:                                    sem_destroy3((*s_etat_processus)
                   1624:                                            .semaphore_fork, getpid(),
                   1625:                                            pthread_self(), SEM_FORK);
                   1626: #                                  endif
                   1627: 
                   1628:                                    liberation_contexte_cas(s_etat_processus);
                   1629:                                    destruction_queue_signaux(s_etat_processus);
                   1630: 
                   1631: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1632:                                    stackoverflow_deinstall_handler();
                   1633: #                                  endif
                   1634: 
                   1635:                                    if ((*s_etat_processus).langue == 'F')
                   1636:                                    {
                   1637:                                        printf("+++Système : Mémoire "
                   1638:                                                "insuffisante\n");
                   1639:                                    }
                   1640:                                    else
                   1641:                                    {
                   1642:                                        printf("+++System : Not enough "
                   1643:                                                "memory\n");
                   1644:                                    }
                   1645: 
                   1646:                                    return(EXIT_FAILURE);
                   1647:                                }
                   1648: 
                   1649:                                (*l_nouvelle_bibliotheque).suivant =
                   1650:                                        l_bibliotheques;
                   1651: 
                   1652:                                if (((*l_nouvelle_bibliotheque).donnee =
                   1653:                                        allocation(s_etat_processus, CHN))
                   1654:                                        == NULL)
                   1655:                                {
                   1656: #                                  ifndef SEMAPHORES_NOMMES
                   1657:                                    sem_post(&((*s_etat_processus)
                   1658:                                            .semaphore_fork));
                   1659:                                    sem_destroy(&((*s_etat_processus)
                   1660:                                            .semaphore_fork));
                   1661: #                                  else
                   1662:                                    sem_post((*s_etat_processus)
                   1663:                                            .semaphore_fork);
                   1664:                                    sem_destroy3((*s_etat_processus)
                   1665:                                            .semaphore_fork, getpid(),
                   1666:                                            pthread_self(), SEM_FORK);
                   1667: #                                  endif
                   1668: 
                   1669:                                    liberation_contexte_cas(s_etat_processus);
                   1670:                                    destruction_queue_signaux(s_etat_processus);
                   1671: 
                   1672: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1673:                                    stackoverflow_deinstall_handler();
                   1674: #                                  endif
                   1675: 
                   1676:                                    if ((*s_etat_processus).langue == 'F')
                   1677:                                    {
                   1678:                                        printf("+++Système : Mémoire "
                   1679:                                                "insuffisante\n");
                   1680:                                    }
                   1681:                                    else
                   1682:                                    {
                   1683:                                        printf("+++System : Not enough "
                   1684:                                                "memory\n");
                   1685:                                    }
                   1686: 
                   1687:                                    return(EXIT_FAILURE);
                   1688:                                }
                   1689: 
                   1690:                                if (((*(*l_nouvelle_bibliotheque).donnee)
                   1691:                                        .objet = malloc((strlen(argv[0]) + 1) *
                   1692:                                        sizeof(unsigned char))) == NULL)
                   1693:                                {
                   1694: #                                  ifndef SEMAPHORES_NOMMES
                   1695:                                    sem_post(&((*s_etat_processus)
                   1696:                                            .semaphore_fork));
                   1697:                                    sem_destroy(&((*s_etat_processus)
                   1698:                                            .semaphore_fork));
                   1699: #                                  else
                   1700:                                    sem_post((*s_etat_processus)
                   1701:                                            .semaphore_fork);
                   1702:                                    sem_destroy3((*s_etat_processus)
                   1703:                                            .semaphore_fork, getpid(),
                   1704:                                            pthread_self(), SEM_FORK);
                   1705: #                                  endif
                   1706: 
                   1707:                                    liberation_contexte_cas(s_etat_processus);
                   1708:                                    destruction_queue_signaux(s_etat_processus);
                   1709: 
                   1710: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1711:                                    stackoverflow_deinstall_handler();
                   1712: #                                  endif
                   1713: 
                   1714:                                    if ((*s_etat_processus).langue == 'F')
                   1715:                                    {
                   1716:                                        printf("+++Système : Mémoire "
                   1717:                                                "insuffisante\n");
                   1718:                                    }
                   1719:                                    else
                   1720:                                    {
                   1721:                                        printf("+++System : Not enough "
                   1722:                                                "memory\n");
                   1723:                                    }
                   1724: 
                   1725:                                    return(EXIT_FAILURE);
                   1726:                                }
                   1727: 
                   1728:                                strcpy((*(*l_nouvelle_bibliotheque).donnee)
                   1729:                                        .objet, argv[0]);
                   1730:                                argv[0] += strlen((unsigned char *)
                   1731:                                        (*(*l_nouvelle_bibliotheque).donnee)
                   1732:                                        .objet) - 1;
                   1733: 
                   1734:                                l_bibliotheques = l_nouvelle_bibliotheque;
                   1735:                            }
                   1736:                            else if ((--argc) > 0)
                   1737:                            {
                   1738:                                argv++;
                   1739: 
                   1740:                                if ((l_nouvelle_bibliotheque = malloc(
                   1741:                                        sizeof(struct_liste_chainee))) == NULL)
                   1742:                                {
                   1743: #                                  ifndef SEMAPHORES_NOMMES
                   1744:                                    sem_post(&((*s_etat_processus)
                   1745:                                            .semaphore_fork));
                   1746:                                    sem_destroy(&((*s_etat_processus)
                   1747:                                            .semaphore_fork));
                   1748: #                                  else
                   1749:                                    sem_post((*s_etat_processus)
                   1750:                                            .semaphore_fork);
                   1751:                                    sem_destroy3((*s_etat_processus)
                   1752:                                            .semaphore_fork, getpid(),
                   1753:                                            pthread_self(), SEM_FORK);
                   1754: #                                  endif
                   1755: 
                   1756:                                    liberation_contexte_cas(s_etat_processus);
                   1757:                                    destruction_queue_signaux(s_etat_processus);
                   1758: 
                   1759: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1760:                                    stackoverflow_deinstall_handler();
                   1761: #                                  endif
                   1762: 
                   1763:                                    if ((*s_etat_processus).langue == 'F')
                   1764:                                    {
                   1765:                                        printf("+++Système : Mémoire "
                   1766:                                                "insuffisante\n");
                   1767:                                    }
                   1768:                                    else
                   1769:                                    {
                   1770:                                        printf("+++System : Not enough "
                   1771:                                                "memory\n");
                   1772:                                    }
                   1773: 
                   1774:                                    return(EXIT_FAILURE);
                   1775:                                }
                   1776: 
                   1777:                                (*l_nouvelle_bibliotheque).suivant =
                   1778:                                        l_bibliotheques;
                   1779: 
                   1780:                                if (((*l_nouvelle_bibliotheque).donnee =
                   1781:                                        allocation(s_etat_processus, CHN))
                   1782:                                        == NULL)
                   1783:                                {
                   1784: #                                  ifndef SEMAPHORES_NOMMES
                   1785:                                    sem_post(&((*s_etat_processus)
                   1786:                                            .semaphore_fork));
                   1787:                                    sem_destroy(&((*s_etat_processus)
                   1788:                                            .semaphore_fork));
                   1789: #                                  else
                   1790:                                    sem_post((*s_etat_processus)
                   1791:                                            .semaphore_fork);
                   1792:                                    sem_destroy3((*s_etat_processus)
                   1793:                                            .semaphore_fork, getpid(),
                   1794:                                            pthread_self(), SEM_FORK);
                   1795: #                                  endif
                   1796: 
                   1797:                                    liberation_contexte_cas(s_etat_processus);
                   1798:                                    destruction_queue_signaux(s_etat_processus);
                   1799: 
                   1800: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1801:                                    stackoverflow_deinstall_handler();
                   1802: #                                  endif
                   1803: 
                   1804:                                    if ((*s_etat_processus).langue == 'F')
                   1805:                                    {
                   1806:                                        printf("+++Système : Mémoire "
                   1807:                                                "insuffisante\n");
                   1808:                                    }
                   1809:                                    else
                   1810:                                    {
                   1811:                                        printf("+++System : Not enough "
                   1812:                                                "memory\n");
                   1813:                                    }
                   1814: 
                   1815:                                    return(EXIT_FAILURE);
                   1816:                                }
                   1817: 
                   1818:                                if (((*(*l_nouvelle_bibliotheque).donnee)
                   1819:                                        .objet = malloc((strlen(argv[0]) + 1) *
                   1820:                                        sizeof(unsigned char))) == NULL)
                   1821:                                {
                   1822: #                                  ifndef SEMAPHORES_NOMMES
                   1823:                                    sem_post(&((*s_etat_processus)
                   1824:                                            .semaphore_fork));
                   1825:                                    sem_destroy(&((*s_etat_processus)
                   1826:                                            .semaphore_fork));
                   1827: #                                  else
                   1828:                                    sem_post((*s_etat_processus)
                   1829:                                            .semaphore_fork);
                   1830:                                    sem_destroy3((*s_etat_processus)
                   1831:                                            .semaphore_fork, getpid(),
                   1832:                                            pthread_self(), SEM_FORK);
                   1833: #                                  endif
                   1834: 
                   1835:                                    liberation_contexte_cas(s_etat_processus);
                   1836:                                    destruction_queue_signaux(s_etat_processus);
                   1837: 
                   1838: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1839:                                    stackoverflow_deinstall_handler();
                   1840: #                                  endif
                   1841: 
                   1842:                                    if ((*s_etat_processus).langue == 'F')
                   1843:                                    {
                   1844:                                        printf("+++Système : Mémoire "
                   1845:                                                "insuffisante\n");
                   1846:                                    }
                   1847:                                    else
                   1848:                                    {
                   1849:                                        printf("+++System : Not enough "
                   1850:                                                "memory\n");
                   1851:                                    }
                   1852: 
                   1853:                                    return(EXIT_FAILURE);
                   1854:                                }
                   1855: 
                   1856:                                strcpy((*(*l_nouvelle_bibliotheque).donnee)
                   1857:                                        .objet, argv[0]);
                   1858:                                argv[0] += strlen((unsigned char *)
                   1859:                                        (*(*l_nouvelle_bibliotheque).donnee)
                   1860:                                        .objet) - 1;
                   1861: 
                   1862:                                l_bibliotheques = l_nouvelle_bibliotheque;
                   1863:                            }
                   1864:                            else
                   1865:                            {
                   1866: #                              ifndef SEMAPHORES_NOMMES
                   1867:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1868:                                sem_destroy(&((*s_etat_processus)
                   1869:                                        .semaphore_fork));
                   1870: #                              else
                   1871:                                sem_post((*s_etat_processus).semaphore_fork);
                   1872:                                sem_destroy3((*s_etat_processus).semaphore_fork,
                   1873:                                        getpid(), pthread_self(), SEM_FORK);
                   1874: #                              endif
                   1875: 
                   1876:                                liberation_contexte_cas(s_etat_processus);
                   1877:                                destruction_queue_signaux(s_etat_processus);
                   1878: 
                   1879: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1880:                                stackoverflow_deinstall_handler();
                   1881: #                              endif
                   1882: 
                   1883:                                if ((*s_etat_processus).langue == 'F')
                   1884:                                {
                   1885:                                    printf("+++Erreur : Aucune bibliothèque "
                   1886:                                            "spécifiée après l'option -A\n");
                   1887:                                }
                   1888:                                else
                   1889:                                {
                   1890:                                    printf("+++Error : Library required after "
                   1891:                                            "-m option\n");
                   1892:                                }
                   1893: 
                   1894:                                return(EXIT_FAILURE);
                   1895:                            }
                   1896: 
                   1897:                            break;
                   1898:                        }
                   1899: 
1.1       bertrand 1900:                        case 'n' :
                   1901:                        {
                   1902:                            if (option_n == d_vrai)
                   1903:                            {
1.124     bertrand 1904: #                              ifndef SEMAPHORES_NOMMES
                   1905:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1906:                                sem_destroy(&((*s_etat_processus)
                   1907:                                        .semaphore_fork));
                   1908: #                              else
                   1909:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1910:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1911:                                        getpid(), pthread_self(), SEM_FORK);
                   1912: #                              endif
                   1913: 
                   1914:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1915:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1916: 
                   1917: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1918:                                stackoverflow_deinstall_handler();
                   1919: #                              endif
                   1920: 
1.1       bertrand 1921:                                if ((*s_etat_processus).langue == 'F')
                   1922:                                {
                   1923:                                    printf("+++Erreur : option -n présente "
                   1924:                                            "plus d'une fois\n");
                   1925:                                }
                   1926:                                else
                   1927:                                {
                   1928:                                    printf("+++Error : more than one -n "
                   1929:                                            "on command line");
                   1930:                                }
                   1931: 
                   1932:                                return(EXIT_FAILURE);
                   1933:                            }
                   1934: 
                   1935:                            option_n = d_vrai;
                   1936: 
                   1937:                            break;
                   1938:                        }
                   1939: 
                   1940:                        case 'p' :
                   1941:                        {
                   1942:                            if (option_p == d_vrai)
                   1943:                            {
1.124     bertrand 1944: #                              ifndef SEMAPHORES_NOMMES
                   1945:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1946:                                sem_destroy(&((*s_etat_processus)
                   1947:                                        .semaphore_fork));
                   1948: #                              else
                   1949:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1950:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1951:                                        getpid(), pthread_self(), SEM_FORK);
                   1952: #                              endif
                   1953: 
                   1954:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1955:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1956: 
                   1957: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1958:                                stackoverflow_deinstall_handler();
                   1959: #                              endif
                   1960: 
1.1       bertrand 1961:                                if ((*s_etat_processus).langue == 'F')
                   1962:                                {
                   1963:                                    printf("+++Erreur : option -p présente "
                   1964:                                            "plus d'une fois\n");
                   1965:                                }
                   1966:                                else
                   1967:                                {
                   1968:                                    printf("+++Error : more than one -p "
                   1969:                                            "on command line");
                   1970:                                }
                   1971: 
                   1972:                                return(EXIT_FAILURE);
                   1973:                            }
                   1974:                            else if (option_i == d_vrai)
                   1975:                            {
1.124     bertrand 1976: #                              ifndef SEMAPHORES_NOMMES
                   1977:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   1978:                                sem_destroy(&((*s_etat_processus)
                   1979:                                        .semaphore_fork));
                   1980: #                              else
                   1981:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 1982:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 1983:                                        getpid(), pthread_self(), SEM_FORK);
                   1984: #                              endif
                   1985: 
                   1986:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 1987:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 1988: 
                   1989: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   1990:                                stackoverflow_deinstall_handler();
                   1991: #                              endif
                   1992: 
1.1       bertrand 1993:                                if ((*s_etat_processus).langue == 'F')
                   1994:                                {
                   1995:                                    printf("+++Erreur : options -i et -p "
                   1996:                                            "incompatibles\n");
                   1997:                                }
                   1998:                                else
                   1999:                                {
                   2000:                                    printf("+++Error : incompatible options -i "
                   2001:                                            "and -p\n");
                   2002:                                }
                   2003: 
                   2004:                                return(EXIT_FAILURE);
                   2005:                            }
                   2006: 
                   2007:                            option_p = d_vrai;
                   2008: 
                   2009:                            break;
                   2010:                        }
                   2011: 
                   2012:                        case 'P' :
                   2013:                        {
                   2014:                            if (option_P > 2)
                   2015:                            {
1.124     bertrand 2016: #                              ifndef SEMAPHORES_NOMMES
                   2017:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2018:                                sem_destroy(&((*s_etat_processus)
                   2019:                                        .semaphore_fork));
                   2020: #                              else
                   2021:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2022:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2023:                                        getpid(), pthread_self(), SEM_FORK);
                   2024: #                              endif
                   2025: 
                   2026:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2027:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2028: 
                   2029: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2030:                                stackoverflow_deinstall_handler();
                   2031: #                              endif
                   2032: 
1.1       bertrand 2033:                                if ((*s_etat_processus).langue == 'F')
                   2034:                                {
                   2035:                                    printf("+++Erreur : option -P présente "
                   2036:                                            "plus de deux fois\n");
                   2037:                                }
                   2038:                                else
                   2039:                                {
                   2040:                                    printf("+++Error : more than two -P "
                   2041:                                            "on command line");
                   2042:                                }
                   2043: 
                   2044:                                return(EXIT_FAILURE);
                   2045:                            }
                   2046: 
                   2047:                            option_P++;
                   2048: 
                   2049:                            break;
                   2050:                        }
                   2051: 
                   2052:                        case 's' :
                   2053:                        {
                   2054:                            if (option_s == d_vrai)
                   2055:                            {
1.124     bertrand 2056: #                              ifndef SEMAPHORES_NOMMES
                   2057:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2058:                                sem_destroy(&((*s_etat_processus)
                   2059:                                        .semaphore_fork));
                   2060: #                              else
                   2061:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2062:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2063:                                        getpid(), pthread_self(), SEM_FORK);
                   2064: #                              endif
                   2065: 
                   2066:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2067:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2068: 
                   2069: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2070:                                stackoverflow_deinstall_handler();
                   2071: #                              endif
                   2072: 
1.1       bertrand 2073:                                if ((*s_etat_processus).langue == 'F')
                   2074:                                {
                   2075:                                    printf("+++Erreur : option -s présente "
                   2076:                                            "plus d'une fois\n");
                   2077:                                }
                   2078:                                else
                   2079:                                {
                   2080:                                    printf("+++Error : more than one -s "
                   2081:                                            "on command line");
                   2082:                                }
                   2083: 
                   2084:                                return(EXIT_FAILURE);
                   2085:                            }
                   2086: 
                   2087:                            option_s = d_vrai;
                   2088:                            drapeau_encart = 'N';
                   2089:                            break;
                   2090:                        }
                   2091: 
                   2092:                        case 'S' :
                   2093:                        {
                   2094:                            if (option_S == d_vrai)
                   2095:                            {
1.124     bertrand 2096: #                              ifndef SEMAPHORES_NOMMES
                   2097:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2098:                                sem_destroy(&((*s_etat_processus)
                   2099:                                        .semaphore_fork));
                   2100: #                              else
                   2101:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2102:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2103:                                        getpid(), pthread_self(), SEM_FORK);
                   2104: #                              endif
                   2105: 
                   2106:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2107:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2108: 
                   2109: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2110:                                stackoverflow_deinstall_handler();
                   2111: #                              endif
                   2112: 
1.1       bertrand 2113:                                if ((*s_etat_processus).langue == 'F')
                   2114:                                {
                   2115:                                    printf("+++Erreur : option -S présente "
                   2116:                                            "plus d'une fois\n");
                   2117:                                }
                   2118:                                else
                   2119:                                {
                   2120:                                    printf("+++Error : more than one -S "
                   2121:                                            "on command line");
                   2122:                                }
                   2123: 
                   2124:                                return(EXIT_FAILURE);
                   2125:                            }
                   2126:                            else if (option_i == d_vrai)
                   2127:                            {
1.124     bertrand 2128: #                              ifndef SEMAPHORES_NOMMES
                   2129:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2130:                                sem_destroy(&((*s_etat_processus)
                   2131:                                        .semaphore_fork));
                   2132: #                              else
                   2133:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2134:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2135:                                        getpid(), pthread_self(), SEM_FORK);
                   2136: #                              endif
                   2137: 
                   2138:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2139:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2140: 
                   2141: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2142:                                stackoverflow_deinstall_handler();
                   2143: #                              endif
                   2144: 
1.1       bertrand 2145:                                if ((*s_etat_processus).langue == 'F')
                   2146:                                {
                   2147:                                    printf("+++Erreur : options -i et -S "
                   2148:                                            "incompatibles\n");
                   2149:                                }
                   2150:                                else
                   2151:                                {
                   2152:                                    printf("+++Error : incompatible options -S "
                   2153:                                            "and -i\n");
                   2154:                                }
                   2155: 
                   2156:                                return(EXIT_FAILURE);
                   2157:                            }
                   2158: 
                   2159:                            option_S = d_vrai;
                   2160: 
                   2161:                            while(*(++argv[0]) == ' ');
                   2162:                            argv[0]--;
                   2163: 
                   2164:                            if ((*(++argv[0])) != '\0')
                   2165:                            {
                   2166:                                if (((*s_etat_processus).definitions_chainees =
                   2167:                                        malloc((strlen(argv[0]) + 1) *
                   2168:                                        sizeof(unsigned char))) == NULL)
                   2169:                                {
1.124     bertrand 2170: #                                  ifndef SEMAPHORES_NOMMES
                   2171:                                    sem_post(&((*s_etat_processus)
                   2172:                                            .semaphore_fork));
                   2173:                                    sem_destroy(&((*s_etat_processus)
                   2174:                                            .semaphore_fork));
                   2175: #                                  else
                   2176:                                    sem_post((*s_etat_processus)
                   2177:                                            .semaphore_fork);
                   2178:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 2179:                                            .semaphore_fork, getpid(),
1.124     bertrand 2180:                                            pthread_self(), SEM_FORK);
                   2181: #                                  endif
                   2182: 
                   2183:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2184:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2185: 
                   2186: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2187:                                    stackoverflow_deinstall_handler();
                   2188: #                                  endif
                   2189: 
1.1       bertrand 2190:                                    if ((*s_etat_processus).langue == 'F')
                   2191:                                    {
                   2192:                                        printf("+++Système : Mémoire "
                   2193:                                                "insuffisante\n");
                   2194:                                    }
                   2195:                                    else
                   2196:                                    {
                   2197:                                        printf("+++System : Not enough "
                   2198:                                                "memory\n");
                   2199:                                    }
                   2200: 
                   2201:                                    return(EXIT_FAILURE);
                   2202:                                }
                   2203: 
                   2204:                                ptr = (*s_etat_processus).definitions_chainees;
                   2205: 
                   2206:                                while(*(argv[0]) != '\0')
                   2207:                                {
                   2208:                                    *(ptr++) = *(argv[0]++);
                   2209:                                }
                   2210: 
                   2211:                                (*ptr) = '\0';
                   2212: 
                   2213:                                argv[0]--;
                   2214:                                presence_definition = 'O';
                   2215:                            }
                   2216:                            else if ((--argc) > 0)
                   2217:                            {
                   2218:                                argv++;
                   2219: 
                   2220:                                if (((*s_etat_processus).definitions_chainees =
                   2221:                                        malloc((strlen(argv[0]) + 1) *
                   2222:                                        sizeof(unsigned char))) == NULL)
                   2223:                                {
1.124     bertrand 2224: #                                  ifndef SEMAPHORES_NOMMES
                   2225:                                    sem_post(&((*s_etat_processus)
                   2226:                                            .semaphore_fork));
                   2227:                                    sem_destroy(&((*s_etat_processus)
                   2228:                                            .semaphore_fork));
                   2229: #                                  else
                   2230:                                    sem_post((*s_etat_processus)
                   2231:                                            .semaphore_fork);
                   2232:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 2233:                                            .semaphore_fork, getpid(),
1.124     bertrand 2234:                                            pthread_self(), SEM_FORK);
                   2235: #                                  endif
                   2236: 
                   2237:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2238:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2239: 
                   2240: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2241:                                    stackoverflow_deinstall_handler();
                   2242: #                                  endif
                   2243: 
1.1       bertrand 2244:                                    if ((*s_etat_processus).langue == 'F')
                   2245:                                    {
                   2246:                                        printf("+++Système : Mémoire "
                   2247:                                                "insuffisante\n");
                   2248:                                    }
                   2249:                                    else
                   2250:                                    {
                   2251:                                        printf("+++System : Not enough "
                   2252:                                                "memory\n");
                   2253:                                    }
                   2254: 
                   2255:                                    return(EXIT_FAILURE);
                   2256:                                }
                   2257: 
                   2258:                                ptr = (*s_etat_processus).definitions_chainees;
                   2259: 
                   2260:                                while(*(argv[0]) != '\0')
                   2261:                                {
                   2262:                                    *(ptr++) = *(argv[0]++);
                   2263:                                }
                   2264: 
                   2265:                                (*ptr) = '\0';
                   2266: 
                   2267:                                argv[0]--;
                   2268:                                presence_definition = 'O';
                   2269:                            }
                   2270:                            else
                   2271:                            {
1.124     bertrand 2272: #                              ifndef SEMAPHORES_NOMMES
                   2273:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2274:                                sem_destroy(&((*s_etat_processus)
                   2275:                                        .semaphore_fork));
                   2276: #                              else
                   2277:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2278:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2279:                                        getpid(), pthread_self(), SEM_FORK);
                   2280: #                              endif
                   2281: 
                   2282:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2283:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2284: 
                   2285: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2286:                                stackoverflow_deinstall_handler();
                   2287: #                              endif
                   2288: 
1.1       bertrand 2289:                                if ((*s_etat_processus).langue == 'F')
                   2290:                                {
                   2291:                                    printf("+++Erreur : Aucun script "
                   2292:                                            "spécifié après l'option -S\n");
                   2293:                                }
                   2294:                                else
                   2295:                                {
                   2296:                                    printf("+++Error : Script required after "
                   2297:                                            "-S option\n");
                   2298:                                }
                   2299: 
                   2300:                                return(EXIT_FAILURE);
                   2301:                            }
                   2302: 
                   2303:                            if (((*s_etat_processus).definitions_chainees =
1.165     bertrand 2304:                                    compactage(s_etat_processus,
                   2305:                                    (*s_etat_processus).definitions_chainees))
                   2306:                                    == NULL)
1.1       bertrand 2307:                            {
1.124     bertrand 2308: #                              ifndef SEMAPHORES_NOMMES
                   2309:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2310:                                sem_destroy(&((*s_etat_processus)
                   2311:                                        .semaphore_fork));
                   2312: #                              else
                   2313:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2314:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2315:                                        getpid(), pthread_self(), SEM_FORK);
                   2316: #                              endif
                   2317: 
                   2318:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2319:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2320: 
                   2321: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2322:                                stackoverflow_deinstall_handler();
                   2323: #                              endif
                   2324: 
1.1       bertrand 2325:                                if ((*s_etat_processus).langue == 'F')
                   2326:                                {
                   2327:                                    printf("+++Système : Mémoire "
                   2328:                                            "insuffisante\n");
                   2329:                                }
                   2330:                                else
                   2331:                                {
                   2332:                                    printf("+++System : Not enough "
                   2333:                                            "memory\n");
                   2334:                                }
                   2335: 
                   2336:                                return(EXIT_FAILURE);
                   2337:                            }
                   2338: 
                   2339:                            (*s_etat_processus).longueur_definitions_chainees =
1.136     bertrand 2340:                                    (integer8) strlen((*s_etat_processus)
1.1       bertrand 2341:                                    .definitions_chainees);
                   2342: 
                   2343:                            break;
                   2344:                        }
                   2345: 
                   2346:                        case 't' :
                   2347:                        {
                   2348:                            if (option_t == d_vrai)
                   2349:                            {
1.124     bertrand 2350: #                              ifndef SEMAPHORES_NOMMES
                   2351:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2352:                                sem_destroy(&((*s_etat_processus)
                   2353:                                        .semaphore_fork));
                   2354: #                              else
                   2355:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2356:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2357:                                        getpid(), pthread_self(), SEM_FORK);
                   2358: #                              endif
                   2359: 
                   2360:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2361:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2362: 
                   2363: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2364:                                stackoverflow_deinstall_handler();
                   2365: #                              endif
                   2366: 
1.1       bertrand 2367:                                if ((*s_etat_processus).langue == 'F')
                   2368:                                {
                   2369:                                    printf("+++Erreur : option -t présente "
                   2370:                                            "plus d'une fois\n");
                   2371:                                }
                   2372:                                else
                   2373:                                {
                   2374:                                    printf("+++Error : more than one -t "
                   2375:                                            "on command line");
                   2376:                                }
                   2377: 
                   2378:                                return(EXIT_FAILURE);
                   2379:                            }
                   2380: 
                   2381:                            option_t = d_vrai;
                   2382:                            (*s_etat_processus).debug = d_vrai;
                   2383: 
                   2384:                            while(*(++argv[0]) == ' ');
                   2385:                            argv[0]--;
                   2386: 
                   2387:                            if ((*(++argv[0])) != '\0')
                   2388:                            {
                   2389:                                if ((type_debug = malloc((strlen(argv[0]) + 1) *
                   2390:                                        sizeof(unsigned char))) == NULL)
                   2391:                                {
1.124     bertrand 2392: #                                  ifndef SEMAPHORES_NOMMES
                   2393:                                    sem_post(&((*s_etat_processus)
                   2394:                                            .semaphore_fork));
                   2395:                                    sem_destroy(&((*s_etat_processus)
                   2396:                                            .semaphore_fork));
                   2397: #                                  else
                   2398:                                    sem_post((*s_etat_processus)
                   2399:                                            .semaphore_fork);
                   2400:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 2401:                                            .semaphore_fork, getpid(),
1.124     bertrand 2402:                                            pthread_self(), SEM_FORK);
                   2403: #                                  endif
                   2404: 
                   2405:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2406:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2407: 
                   2408: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2409:                                    stackoverflow_deinstall_handler();
                   2410: #                                  endif
                   2411: 
1.1       bertrand 2412:                                    if ((*s_etat_processus).langue == 'F')
                   2413:                                    {
                   2414:                                        printf("+++Système : Mémoire "
                   2415:                                                "insuffisante\n");
                   2416:                                    }
                   2417:                                    else
                   2418:                                    {
                   2419:                                        printf("+++System : Not enough "
                   2420:                                                "memory\n");
                   2421:                                    }
                   2422: 
                   2423:                                    return(EXIT_FAILURE);
                   2424:                                }
                   2425: 
                   2426:                                ptr = type_debug;
                   2427: 
                   2428:                                while((*(argv[0]) != '\0') &&
                   2429:                                        (*(argv[0]) != ' '))
                   2430:                                {
                   2431:                                    *(ptr++) = *(argv[0]++);
                   2432:                                }
                   2433: 
                   2434:                                (*ptr) = '\0';
                   2435: 
                   2436:                                argv[0]--;
                   2437:                            }
                   2438:                            else if ((--argc) > 0)
                   2439:                            {
                   2440:                                argv++;
                   2441: 
                   2442:                                if ((type_debug =
                   2443:                                        malloc((strlen(argv[0]) + 1) *
                   2444:                                        sizeof(unsigned char))) == NULL)
                   2445:                                {
1.124     bertrand 2446: #                                  ifndef SEMAPHORES_NOMMES
                   2447:                                    sem_post(&((*s_etat_processus)
                   2448:                                            .semaphore_fork));
                   2449:                                    sem_destroy(&((*s_etat_processus)
                   2450:                                            .semaphore_fork));
                   2451: #                                  else
                   2452:                                    sem_post((*s_etat_processus)
                   2453:                                            .semaphore_fork);
                   2454:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 2455:                                            .semaphore_fork, getpid(),
1.124     bertrand 2456:                                            pthread_self(), SEM_FORK);
                   2457: #                                  endif
                   2458: 
                   2459:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2460:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2461: 
                   2462: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2463:                                    stackoverflow_deinstall_handler();
                   2464: #                                  endif
                   2465: 
1.1       bertrand 2466:                                    if ((*s_etat_processus).langue == 'F')
                   2467:                                    {
                   2468:                                        printf("+++Système : Mémoire "
                   2469:                                                "insuffisante\n");
                   2470:                                    }
                   2471:                                    else
                   2472:                                    {
                   2473:                                        printf("+++System : Not enough "
                   2474:                                                "memory\n");
                   2475:                                    }
                   2476: 
                   2477:                                    return(EXIT_FAILURE);
                   2478:                                }
                   2479: 
                   2480:                                ptr = type_debug;
                   2481: 
                   2482:                                while(*(argv[0]) != '\0')
                   2483:                                {
                   2484:                                    *(ptr++) = *(argv[0]++);
                   2485:                                }
                   2486: 
                   2487:                                (*ptr) = '\0';
                   2488: 
                   2489:                                argv[0]--;
                   2490:                            }
                   2491:                            else
                   2492:                            {
1.124     bertrand 2493: #                              ifndef SEMAPHORES_NOMMES
                   2494:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2495:                                sem_destroy(&((*s_etat_processus)
                   2496:                                        .semaphore_fork));
                   2497: #                              else
                   2498:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2499:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2500:                                        getpid(), pthread_self(), SEM_FORK);
                   2501: #                              endif
                   2502: 
                   2503:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2504:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2505: 
                   2506: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2507:                                stackoverflow_deinstall_handler();
                   2508: #                              endif
                   2509: 
1.1       bertrand 2510:                                if ((*s_etat_processus).langue == 'F')
                   2511:                                {
                   2512:                                    printf("+++Erreur : Aucun niveau "
                   2513:                                            "de débogage spécifié après "
                   2514:                                            "l'option -t\n");
                   2515:                                }
                   2516:                                else
                   2517:                                {
                   2518:                                    printf("+++Error : Debug level not "
                   2519:                                            "specified after -t option\n");
                   2520:                                }
                   2521: 
                   2522:                                return(EXIT_FAILURE);
                   2523:                            }
                   2524: 
                   2525:                            ptr = type_debug;
                   2526: 
                   2527:                            while(*ptr != '\0')
                   2528:                            {
                   2529:                                switch(*ptr)
                   2530:                                {
                   2531:                                    case '0':
                   2532:                                    case '1':
                   2533:                                    case '2':
                   2534:                                    case '3':
                   2535:                                    case '4':
                   2536:                                    case '5':
                   2537:                                    case '6':
                   2538:                                    case '7':
                   2539:                                    case '8':
                   2540:                                    case '9':
                   2541:                                    case 'A':
                   2542:                                    case 'B':
                   2543:                                    case 'C':
                   2544:                                    case 'D':
                   2545:                                    case 'E':
                   2546:                                    case 'F':
                   2547:                                    {
                   2548:                                        break;
                   2549:                                    }
                   2550: 
                   2551:                                    default:
                   2552:                                    {
1.124     bertrand 2553: #                                      ifndef SEMAPHORES_NOMMES
                   2554:                                        sem_post(&((*s_etat_processus)
                   2555:                                                .semaphore_fork));
                   2556:                                        sem_destroy(&((*s_etat_processus)
                   2557:                                                .semaphore_fork));
                   2558: #                                      else
                   2559:                                        sem_post((*s_etat_processus)
                   2560:                                                .semaphore_fork);
                   2561:                                        sem_destroy3((*s_etat_processus)
1.155     bertrand 2562:                                                .semaphore_fork, getpid(),
1.124     bertrand 2563:                                                pthread_self(), SEM_FORK);
                   2564: #                                      endif
                   2565: 
                   2566:                                        liberation_contexte_cas(
                   2567:                                                s_etat_processus);
1.161     bertrand 2568:                                        destruction_queue_signaux(
1.124     bertrand 2569:                                                s_etat_processus);
                   2570: 
                   2571: #                                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2572:                                        stackoverflow_deinstall_handler();
                   2573: #                                      endif
                   2574: 
1.1       bertrand 2575:                                        if ((*s_etat_processus).langue == 'F')
                   2576:                                        {
                   2577:                                            printf("+++Erreur : Niveau "
                   2578:                                                    "de débogage non "
                   2579:                                                    "hexadécimal\n");
                   2580:                                        }
                   2581:                                        else
                   2582:                                        {
                   2583:                                            printf("+++Error : Debug level must"
                   2584:                                                    " be hexadecimal "
                   2585:                                                    "integer\n");
                   2586:                                        }
                   2587: 
                   2588:                                        return(EXIT_FAILURE);
                   2589:                                    }
                   2590:                                }
                   2591: 
                   2592:                                ptr++;
                   2593:                            }
                   2594: 
                   2595:                            if (sscanf(type_debug, "%llX",
                   2596:                                    &((*s_etat_processus).type_debug)) != 1)
                   2597:                            {
1.124     bertrand 2598: #                              ifndef SEMAPHORES_NOMMES
                   2599:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2600:                                sem_destroy(&((*s_etat_processus)
                   2601:                                        .semaphore_fork));
                   2602: #                              else
                   2603:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2604:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2605:                                        getpid(), pthread_self(), SEM_FORK);
                   2606: #                              endif
                   2607: 
                   2608:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2609:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2610: 
                   2611: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2612:                                stackoverflow_deinstall_handler();
                   2613: #                              endif
                   2614: 
1.1       bertrand 2615:                                if ((*s_etat_processus).langue == 'F')
                   2616:                                {
                   2617:                                    printf("+++Erreur : Niveau "
                   2618:                                            "de débogage non entier\n");
                   2619:                                }
                   2620:                                else
                   2621:                                {
                   2622:                                    printf("+++Error : Debug level must"
                   2623:                                            " be integer\n");
                   2624:                                }
                   2625: 
                   2626:                                return(EXIT_FAILURE);
                   2627:                            }
                   2628: 
1.17      bertrand 2629:                            free(type_debug);
1.1       bertrand 2630:                            break;
                   2631:                        }
                   2632: 
                   2633:                        case 'v' :
                   2634:                        {
                   2635:                            if (option_v == d_vrai)
                   2636:                            {
1.124     bertrand 2637: #                              ifndef SEMAPHORES_NOMMES
                   2638:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   2639:                                sem_destroy(&((*s_etat_processus)
                   2640:                                        .semaphore_fork));
                   2641: #                              else
                   2642:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2643:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2644:                                        getpid(), pthread_self(), SEM_FORK);
                   2645: #                              endif
                   2646: 
                   2647:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2648:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2649: 
                   2650: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2651:                                stackoverflow_deinstall_handler();
                   2652: #                              endif
                   2653: 
1.1       bertrand 2654:                                if ((*s_etat_processus).langue == 'F')
                   2655:                                {
                   2656:                                    printf("+++Erreur : option -v présente "
                   2657:                                            "plus d'une fois\n");
                   2658:                                }
                   2659:                                else
                   2660:                                {
                   2661:                                    printf("+++Error : more than one -v "
                   2662:                                            "on command line");
                   2663:                                }
                   2664: 
                   2665:                                return(EXIT_FAILURE);
                   2666:                            }
                   2667: 
                   2668:                            option_v = d_vrai;
                   2669:                            printf("\n");
                   2670: 
                   2671:                            if ((*s_etat_processus).langue == 'F')
                   2672:                            {
                   2673:                                printf("  Reverse Polish Lisp/2 version %s "
                   2674:                                        "pour systèmes "
                   2675:                                        "POSIX\n", d_version_rpl);
                   2676:                                printf("      Langage procédural de très haut "
                   2677:                                        "niveau, semi-compilé, "
                   2678:                                        "extensible,\n");
                   2679:                                printf("      destiné principalement aux "
                   2680:                                        "calculs scientifiques et "
                   2681:                                        "symboliques\n");
                   2682:                                printf("%s\n", copyright);
                   2683:                            }
                   2684:                            else
                   2685:                            {
                   2686:                                printf("  Reverse Polish Lisp/2 version %s "
                   2687:                                        "for POSIX operating systems\n",
                   2688:                                        d_version_rpl);
                   2689:                                printf("      Half-compiled, high-level "
                   2690:                                        "procedural language,\n");
                   2691:                                printf("      mainly aiming at scientific "
                   2692:                                        "calculations\n");
                   2693:                                printf("%s\n", copyright_anglais);
                   2694:                            }
                   2695: 
                   2696:                            printf("\n");
                   2697:                            break;
                   2698:                        }
                   2699: 
1.86      bertrand 2700:                        case '-':
                   2701:                        case ' ':
                   2702:                        {
                   2703:                            break;
                   2704:                        }
                   2705: 
1.1       bertrand 2706:                        default :
                   2707:                        {
                   2708:                            if ((*s_etat_processus).langue == 'F')
                   2709:                            {
1.3       bertrand 2710:                                printf("+++Information : Option -%c inconnue\n",
1.1       bertrand 2711:                                        option);
                   2712:                            }
                   2713:                            else
                   2714:                            {
1.3       bertrand 2715:                                printf("+++Warning : -%c option unknown\n",
1.1       bertrand 2716:                                        option);
                   2717:                            }
                   2718: 
                   2719:                            informations(s_etat_processus);
                   2720:                            break;
                   2721:                        }
                   2722:                    }
                   2723:                }
                   2724:            }
                   2725:            else
                   2726:            {
                   2727:                if (presence_definition == 'O')
                   2728:                {
                   2729:                    argc = 0;
                   2730: 
                   2731:                    if ((*s_etat_processus).langue == 'F')
                   2732:                    {
                   2733:                        printf("+++Erreur : Plusieurs définitions\n");
                   2734:                    }
                   2735:                    else
                   2736:                    {
                   2737:                        printf("+++Error : More than one definition\n");
                   2738:                    }
                   2739: 
1.13      bertrand 2740:                    erreur = d_erreur;
1.1       bertrand 2741:                }
                   2742:                else
                   2743:                {
                   2744:                    (*s_etat_processus).nom_fichier_source = argv[0];
                   2745:                    presence_definition = 'O';
                   2746:                }
                   2747:            }
                   2748:        }
                   2749: 
1.94      bertrand 2750:        /*
                   2751:         * Dans le cas où le programme est appelé avec l'option -d,
                   2752:         * on ne récupère par les signaux de violation d'accès. On
                   2753:         * tente simplement la récupération des dépassements de pile.
                   2754:         */
                   2755: 
1.1       bertrand 2756:        if (debug == d_faux)
                   2757:        {
1.189     bertrand 2758: #  ifdef HAVE_SIGSEGV_RECOVERY
1.94      bertrand 2759:            if (sigsegv_install_handler(interruption_violation_access) != 0)
                   2760:            {
1.124     bertrand 2761: #              ifndef SEMAPHORES_NOMMES
                   2762:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2763:                    sem_destroy(&((*s_etat_processus)
                   2764:                            .semaphore_fork));
                   2765: #              else
                   2766:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2767:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2768:                            getpid(), pthread_self(), SEM_FORK);
                   2769: #              endif
                   2770: 
                   2771:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2772:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2773: 
                   2774: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2775:                    stackoverflow_deinstall_handler();
                   2776: #              endif
                   2777: 
1.94      bertrand 2778:                erreur = d_es_signal;
                   2779: 
                   2780:                if ((*s_etat_processus).langue == 'F')
                   2781:                {
                   2782:                    printf("+++Système : Initialisation de la pile alternative "
                   2783:                            "impossible\n");
                   2784:                }
                   2785:                else
                   2786:                {
                   2787:                    printf("+++System : Initialization of alternate "
                   2788:                            "stack failed\n");
                   2789:                }
                   2790: 
                   2791:                return(EXIT_FAILURE);
                   2792:            }
                   2793: #  else
1.82      bertrand 2794:            action.sa_handler = interruption3;
1.94      bertrand 2795:            action.sa_flags = 0;
1.82      bertrand 2796: 
1.1       bertrand 2797:            if (sigaction(SIGSEGV, &action, NULL) != 0)
                   2798:            {
1.124     bertrand 2799: #              ifndef SEMAPHORES_NOMMES
                   2800:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2801:                    sem_destroy(&((*s_etat_processus)
                   2802:                            .semaphore_fork));
                   2803: #              else
                   2804:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2805:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2806:                            getpid(), pthread_self(), SEM_FORK);
                   2807: #              endif
                   2808: 
                   2809:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2810:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2811: 
                   2812: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2813:                    stackoverflow_deinstall_handler();
                   2814: #              endif
                   2815: 
1.1       bertrand 2816:                if ((*s_etat_processus).langue == 'F')
                   2817:                {
                   2818:                    printf("+++Système : Initialisation des signaux POSIX "
                   2819:                            "impossible\n");
                   2820:                }
                   2821:                else
                   2822:                {
                   2823:                    printf("+++System : Initialization of POSIX signals "
                   2824:                            "failed\n");
                   2825:                }
                   2826: 
                   2827:                return(EXIT_FAILURE);
                   2828:            }
                   2829: 
1.94      bertrand 2830:            signal_test = SIGTEST;
1.133     bertrand 2831:            raise(SIGSEGV);
1.94      bertrand 2832: 
1.115     bertrand 2833:            attente.tv_sec = 0;
                   2834:            attente.tv_nsec = 1000000;
                   2835: 
                   2836:            for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                   2837:            {
                   2838:                nanosleep(&attente, NULL);
                   2839:            }
                   2840: 
1.94      bertrand 2841:            if (signal_test != SIGSEGV)
                   2842:            {
1.124     bertrand 2843: #              ifndef SEMAPHORES_NOMMES
                   2844:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2845:                    sem_destroy(&((*s_etat_processus)
                   2846:                            .semaphore_fork));
                   2847: #              else
                   2848:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2849:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2850:                            getpid(), pthread_self(), SEM_FORK);
                   2851: #              endif
                   2852: 
                   2853:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2854:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2855: 
                   2856: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2857:                    stackoverflow_deinstall_handler();
                   2858: #              endif
                   2859: 
1.94      bertrand 2860:                erreur = d_es_signal;
                   2861: 
                   2862:                if ((*s_etat_processus).langue == 'F')
                   2863:                {
                   2864:                    printf("+++Système : Initialisation des signaux POSIX "
                   2865:                            "impossible\n");
                   2866:                }
                   2867:                else
                   2868:                {
                   2869:                    printf("+++System : Initialization of POSIX signals "
                   2870:                            "failed\n");
                   2871:                }
                   2872: 
                   2873:                return(EXIT_FAILURE);
                   2874:            }
                   2875: #  endif
                   2876: 
1.115     bertrand 2877:            action.sa_handler = interruption3;
                   2878:            action.sa_flags = 0;
                   2879: 
1.1       bertrand 2880:            if (sigaction(SIGBUS, &action, NULL) != 0)
                   2881:            {
1.124     bertrand 2882: #              ifndef SEMAPHORES_NOMMES
                   2883:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2884:                    sem_destroy(&((*s_etat_processus)
                   2885:                            .semaphore_fork));
                   2886: #              else
                   2887:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2888:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2889:                            getpid(), pthread_self(), SEM_FORK);
                   2890: #              endif
                   2891: 
                   2892:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2893:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2894: 
                   2895: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2896:                    stackoverflow_deinstall_handler();
                   2897: #              endif
                   2898: 
                   2899: #              ifdef HAVE_SIGSEGV_RECOVERY
                   2900:                    if (debug == d_faux)
                   2901:                    {
                   2902:                        sigsegv_deinstall_handler();
                   2903:                    }
                   2904: #              endif
                   2905: 
1.1       bertrand 2906:                if ((*s_etat_processus).langue == 'F')
                   2907:                {
                   2908:                    printf("+++Système : Initialisation des signaux POSIX "
                   2909:                            "impossible\n");
                   2910:                }
                   2911:                else
                   2912:                {
                   2913:                    printf("+++System : Initialization of POSIX signals "
                   2914:                            "failed\n");
                   2915:                }
                   2916: 
                   2917:                return(EXIT_FAILURE);
                   2918:            }
1.94      bertrand 2919: 
                   2920:            signal_test = SIGTEST;
1.133     bertrand 2921:            raise(SIGBUS);
1.94      bertrand 2922: 
1.115     bertrand 2923:            attente.tv_sec = 0;
                   2924:            attente.tv_nsec = 1000000;
                   2925: 
                   2926:            for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
                   2927:            {
                   2928:                nanosleep(&attente, NULL);
                   2929:            }
                   2930: 
1.94      bertrand 2931:            if (signal_test != SIGBUS)
                   2932:            {
1.124     bertrand 2933: #              ifndef SEMAPHORES_NOMMES
                   2934:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2935:                    sem_destroy(&((*s_etat_processus)
                   2936:                            .semaphore_fork));
                   2937: #              else
                   2938:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2939:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2940:                            getpid(), pthread_self(), SEM_FORK);
                   2941: #              endif
                   2942: 
                   2943:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2944:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2945: 
                   2946: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2947:                    stackoverflow_deinstall_handler();
                   2948: #              endif
                   2949: 
                   2950: #              ifdef HAVE_SIGSEGV_RECOVERY
                   2951:                    if (debug == d_faux)
                   2952:                    {
                   2953:                        sigsegv_deinstall_handler();
                   2954:                    }
                   2955: #              endif
                   2956: 
1.94      bertrand 2957:                erreur = d_es_signal;
                   2958: 
                   2959:                if ((*s_etat_processus).langue == 'F')
                   2960:                {
                   2961:                    printf("+++Système : Initialisation des signaux POSIX "
                   2962:                            "impossible\n");
                   2963:                }
                   2964:                else
                   2965:                {
                   2966:                    printf("+++System : Initialization of POSIX signals "
                   2967:                            "failed\n");
                   2968:                }
                   2969: 
                   2970:                return(EXIT_FAILURE);
                   2971:            }
                   2972: 
1.1       bertrand 2973:        }
                   2974: 
                   2975:        if (option_n == d_vrai)
                   2976:        {
1.83      bertrand 2977:            action.sa_handler = interruption4;
1.94      bertrand 2978:            action.sa_flags = 0;
1.1       bertrand 2979: 
                   2980:            if (sigaction(SIGHUP, &action, NULL) != 0)
                   2981:            {
1.124     bertrand 2982: #              ifndef SEMAPHORES_NOMMES
                   2983:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   2984:                    sem_destroy(&((*s_etat_processus)
                   2985:                            .semaphore_fork));
                   2986: #              else
                   2987:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 2988:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 2989:                            getpid(), pthread_self(), SEM_FORK);
                   2990: #              endif
                   2991: 
                   2992:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 2993:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 2994: 
                   2995: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   2996:                    stackoverflow_deinstall_handler();
                   2997: #              endif
                   2998: 
                   2999: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3000:                    if (debug == d_faux)
                   3001:                    {
                   3002:                        sigsegv_deinstall_handler();
                   3003:                    }
                   3004: #              endif
                   3005: 
1.1       bertrand 3006:                if ((*s_etat_processus).langue == 'F')
                   3007:                {
                   3008:                    printf("+++Système : Initialisation des signaux POSIX "
                   3009:                            "impossible\n");
                   3010:                }
                   3011:                else
                   3012:                {
                   3013:                    printf("+++System : Initialization of POSIX signals "
                   3014:                            "failed\n");
                   3015:                }
                   3016: 
                   3017:                return(EXIT_FAILURE);
                   3018:            }
                   3019:        }
                   3020: 
                   3021:        if (mode_interactif == d_vrai)
                   3022:        {
                   3023:            printf("\n");
                   3024: 
                   3025:            if ((*s_etat_processus).langue == 'F')
                   3026:            {
                   3027:                printf("+++Ce logiciel est un logiciel libre"
                   3028:                        " sans aucune garantie de "
                   3029:                        "fonctionnement.\n");
                   3030:                printf("+++Pour plus de détails, utilisez la "
                   3031:                        "commande 'warranty'.\n");
                   3032:            }
                   3033:            else
                   3034:            {
                   3035:                printf("+++This is a free software with "
                   3036:                        "absolutely no warranty.\n");
                   3037:                printf("+++For details, type 'warranty'.\n");
                   3038:            }
                   3039: 
                   3040:            printf("\n");
                   3041: 
                   3042:            traitement_fichier_temporaire = 'Y';
                   3043: 
                   3044:            if ((nom_fichier_temporaire =
                   3045:                    creation_nom_fichier(s_etat_processus, (*s_etat_processus)
                   3046:                    .chemin_fichiers_temporaires)) == NULL)
                   3047:            {
1.124     bertrand 3048: #              ifndef SEMAPHORES_NOMMES
                   3049:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3050:                    sem_destroy(&((*s_etat_processus)
                   3051:                            .semaphore_fork));
                   3052: #              else
                   3053:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3054:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3055:                            getpid(), pthread_self(), SEM_FORK);
                   3056: #              endif
                   3057: 
                   3058:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3059:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3060: 
                   3061: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3062:                    stackoverflow_deinstall_handler();
                   3063: #              endif
                   3064: 
                   3065: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3066:                    if (debug == d_faux)
                   3067:                    {
                   3068:                        sigsegv_deinstall_handler();
                   3069:                    }
                   3070: #              endif
                   3071: 
1.1       bertrand 3072:                if ((*s_etat_processus).langue == 'F')
                   3073:                {
                   3074:                    printf("+++Système : Fichier indisponible\n");
                   3075:                }
                   3076:                else
                   3077:                {
                   3078:                    printf("+++System : File unavailable\n");
                   3079:                }
                   3080: 
                   3081:                return(EXIT_FAILURE);
                   3082:            }
                   3083: 
                   3084:            if ((f_source = fopen(nom_fichier_temporaire, "w"))
                   3085:                    == NULL)
                   3086:            {
1.124     bertrand 3087: #              ifndef SEMAPHORES_NOMMES
                   3088:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3089:                    sem_destroy(&((*s_etat_processus)
                   3090:                            .semaphore_fork));
                   3091: #              else
                   3092:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3093:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3094:                            getpid(), pthread_self(), SEM_FORK);
                   3095: #              endif
                   3096: 
                   3097:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3098:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3099: 
                   3100: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3101:                    stackoverflow_deinstall_handler();
                   3102: #              endif
                   3103: 
                   3104: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3105:                    if (debug == d_faux)
                   3106:                    {
                   3107:                        sigsegv_deinstall_handler();
                   3108:                    }
                   3109: #              endif
                   3110: 
1.1       bertrand 3111:                if ((*s_etat_processus).langue == 'F')
                   3112:                {
                   3113:                    printf("+++Système : Fichier introuvable\n");
                   3114:                }
                   3115:                else
                   3116:                {
                   3117:                    printf("+++System : File not found\n");
                   3118:                }
                   3119: 
                   3120:                return(EXIT_FAILURE);
                   3121:            }
                   3122: 
                   3123:            if (fprintf(f_source, "MODE_INTERACTIF\n") < 0)
                   3124:            {
1.124     bertrand 3125: #              ifndef SEMAPHORES_NOMMES
                   3126:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3127:                    sem_destroy(&((*s_etat_processus)
                   3128:                            .semaphore_fork));
                   3129: #              else
                   3130:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3131:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3132:                            getpid(), pthread_self(), SEM_FORK);
                   3133: #              endif
                   3134: 
                   3135:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3136:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3137: 
                   3138: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3139:                    stackoverflow_deinstall_handler();
                   3140: #              endif
                   3141: 
                   3142: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3143:                    if (debug == d_faux)
                   3144:                    {
                   3145:                        sigsegv_deinstall_handler();
                   3146:                    }
                   3147: #              endif
                   3148: 
1.1       bertrand 3149:                if ((*s_etat_processus).langue == 'F')
                   3150:                {
                   3151:                    printf("+++Système : Erreur d'écriture dans un fichier\n");
                   3152:                }
                   3153:                else
                   3154:                {
                   3155:                    printf("+++System : Cannot write in file\n");
                   3156:                }
                   3157: 
                   3158:                return(EXIT_FAILURE);
                   3159:            }
                   3160: 
                   3161:            if (fprintf(f_source,
                   3162:                    "<< DO HALT UNTIL FALSE END >>\n") < 0)
                   3163:            {
1.124     bertrand 3164: #              ifndef SEMAPHORES_NOMMES
                   3165:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3166:                    sem_destroy(&((*s_etat_processus)
                   3167:                            .semaphore_fork));
                   3168: #              else
                   3169:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3170:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3171:                            getpid(), pthread_self(), SEM_FORK);
                   3172: #              endif
                   3173: 
                   3174:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3175:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3176: 
                   3177: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3178:                    stackoverflow_deinstall_handler();
                   3179: #              endif
                   3180: 
                   3181: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3182:                    if (debug == d_faux)
                   3183:                    {
                   3184:                        sigsegv_deinstall_handler();
                   3185:                    }
                   3186: #              endif
                   3187: 
1.1       bertrand 3188:                if ((*s_etat_processus).langue == 'F')
                   3189:                {
                   3190:                    printf("+++Système : Erreur d'écriture dans un fichier\n");
                   3191:                }
                   3192:                else
                   3193:                {
                   3194:                    printf("+++System : Cannot write in file\n");
                   3195:                }
                   3196: 
                   3197:                return(EXIT_FAILURE);
                   3198:            }
                   3199: 
                   3200:            if (fclose(f_source) != 0)
                   3201:            {
1.124     bertrand 3202: #              ifndef SEMAPHORES_NOMMES
                   3203:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3204:                    sem_destroy(&((*s_etat_processus)
                   3205:                            .semaphore_fork));
                   3206: #              else
                   3207:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3208:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3209:                            getpid(), pthread_self(), SEM_FORK);
                   3210: #              endif
                   3211: 
                   3212:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3213:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3214: 
                   3215: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3216:                    stackoverflow_deinstall_handler();
                   3217: #              endif
                   3218: 
                   3219: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3220:                    if (debug == d_faux)
                   3221:                    {
                   3222:                        sigsegv_deinstall_handler();
                   3223:                    }
                   3224: #              endif
                   3225: 
1.1       bertrand 3226:                if ((*s_etat_processus).langue == 'F')
                   3227:                {
                   3228:                    printf("+++Système : Fichier indisponible\n");
                   3229:                }
                   3230:                else
                   3231:                {
                   3232:                    printf("+++System : File unavailable\n");
                   3233:                }
                   3234: 
                   3235:                return(EXIT_FAILURE);
                   3236:            }
                   3237: 
                   3238:            (*s_etat_processus).lancement_interactif = d_vrai;
                   3239:            (*s_etat_processus).nom_fichier_source =
                   3240:                    nom_fichier_temporaire;
                   3241: 
                   3242:            presence_definition = 'O';
                   3243:        }
                   3244:        else
                   3245:        {
                   3246:            nom_fichier_temporaire = NULL;
                   3247:        }
                   3248: 
                   3249:        if ((*s_etat_processus).nom_fichier_source == NULL)
                   3250:        {
                   3251:            erreur_fichier = d_erreur;
                   3252:        }
                   3253:        else
                   3254:        {
                   3255:            erreur_fichier = caracteristiques_fichier(s_etat_processus,
                   3256:                    (*s_etat_processus).nom_fichier_source,
                   3257:                    &existence, &ouverture, &unite_fichier);
                   3258:        }
                   3259: 
                   3260:        if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
                   3261:                (option_S == d_faux))
                   3262:        {
1.124     bertrand 3263: #          ifndef SEMAPHORES_NOMMES
                   3264:                sem_post(&((*s_etat_processus).semaphore_fork));
                   3265:                sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3266: #          else
                   3267:                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3268:                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3269:                        getpid(), pthread_self(), SEM_FORK);
                   3270: #          endif
                   3271: 
                   3272:            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3273:            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3274: 
                   3275: #          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3276:                stackoverflow_deinstall_handler();
                   3277: #          endif
                   3278: 
                   3279: #          ifdef HAVE_SIGSEGV_RECOVERY
                   3280:                if (debug == d_faux)
                   3281:                {
                   3282:                    sigsegv_deinstall_handler();
                   3283:                }
                   3284: #          endif
                   3285: 
1.1       bertrand 3286:            if (presence_definition == 'O')
                   3287:            {
                   3288:                if ((*s_etat_processus).langue == 'F')
                   3289:                {
                   3290:                    printf("+++Erreur : Fichier %s inexistant\n",
                   3291:                            (*s_etat_processus).nom_fichier_source);
                   3292:                }
                   3293:                else
                   3294:                {
                   3295:                    printf("+++Error : File %s not found\n",
                   3296:                            (*s_etat_processus).nom_fichier_source);
                   3297:                }
                   3298: 
1.13      bertrand 3299:                erreur = d_erreur;
1.1       bertrand 3300:            }
                   3301:            else
                   3302:            {
                   3303:                if ((*s_etat_processus).langue == 'F')
                   3304:                {
                   3305:                    printf("+++Erreur : Absence de définition à exécuter\n");
                   3306:                }
                   3307:                else
                   3308:                {
                   3309:                    printf("+++Error : Any executable definition\n");
                   3310:                }
                   3311:            }
1.3       bertrand 3312: 
                   3313:            return(EXIT_FAILURE);
1.1       bertrand 3314:        }
                   3315: 
                   3316:        if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
                   3317:        {
1.124     bertrand 3318: #          ifndef SEMAPHORES_NOMMES
                   3319:                sem_post(&((*s_etat_processus).semaphore_fork));
                   3320:                sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3321: #          else
                   3322:                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3323:                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3324:                        getpid(), pthread_self(), SEM_FORK);
                   3325: #          endif
                   3326: 
                   3327:            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3328:            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3329: 
                   3330: #          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3331:                stackoverflow_deinstall_handler();
                   3332: #          endif
                   3333: 
                   3334: #          ifdef HAVE_SIGSEGV_RECOVERY
                   3335:                if (debug == d_faux)
                   3336:                {
                   3337:                    sigsegv_deinstall_handler();
                   3338:                }
                   3339: #          endif
                   3340: 
1.1       bertrand 3341:            if ((*s_etat_processus).langue == 'F')
                   3342:            {
                   3343:                printf("+++Système : Chemin des fichiers temporaires nul\n");
                   3344:            }
                   3345:            else
                   3346:            {
                   3347:                printf("+++System : Null temporary files path\n");
                   3348:            }
                   3349: 
                   3350:            return(EXIT_FAILURE);
                   3351:        }
                   3352: 
                   3353:        if ((*s_etat_processus).debug == d_vrai)
                   3354:        {
                   3355:            if ((*s_etat_processus).langue == 'F')
                   3356:            {
                   3357:                printf("[%d] Chemin des fichiers temporaires %s\n\n",
                   3358:                        (int) getpid(),
                   3359:                        (*s_etat_processus).chemin_fichiers_temporaires);
                   3360:            }
                   3361:            else
                   3362:            {
                   3363:                printf("[%d] Temporary files path %s\n\n",
                   3364:                        (int) getpid(),
                   3365:                        (*s_etat_processus).chemin_fichiers_temporaires);
                   3366:            }
                   3367:        }
                   3368: 
1.13      bertrand 3369:        if ((erreur == d_absence_erreur) && (presence_definition == 'O'))
1.1       bertrand 3370:        {
                   3371:            (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
                   3372:            (*s_etat_processus).niveau_profilage = option_P;
                   3373:            (*s_etat_processus).pile_profilage = NULL;
                   3374:            (*s_etat_processus).pile_profilage_fonctions = NULL;
                   3375:            gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
                   3376: 
                   3377:            (*s_etat_processus).liste_mutexes = NULL;
1.117     bertrand 3378:            (*s_etat_processus).sections_critiques = 0;
1.143     bertrand 3379:            (*s_etat_processus).initialisation_scheduler = d_faux;
1.1       bertrand 3380: 
                   3381:            (*s_etat_processus).test_instruction = 'N';
                   3382:            (*s_etat_processus).nombre_arguments = 0;
                   3383:            (*s_etat_processus).affichage_arguments = 'N';
1.6       bertrand 3384:            (*s_etat_processus).autorisation_conversion_chaine = 'Y';
1.1       bertrand 3385:            (*s_etat_processus).autorisation_evaluation_nom = 'Y';
1.62      bertrand 3386: 
                   3387:            if (mode_interactif == d_vrai)
                   3388:            {
                   3389:                (*s_etat_processus).autorisation_nom_implicite = 'Y';
                   3390:            }
                   3391:            else
                   3392:            {
                   3393:                (*s_etat_processus).autorisation_nom_implicite = 'N';
                   3394:            }
                   3395: 
1.1       bertrand 3396:            (*s_etat_processus).autorisation_empilement_programme = 'N';
                   3397:            (*s_etat_processus).requete_arret = 'N';
1.4       bertrand 3398:            (*s_etat_processus).evaluation_forcee = 'N';
1.51      bertrand 3399:            (*s_etat_processus).recherche_type = 'N';
1.1       bertrand 3400: 
                   3401:            (*s_etat_processus).constante_symbolique = 'N';
                   3402:            (*s_etat_processus).traitement_symbolique = 'N';
                   3403: 
                   3404:            (*s_etat_processus).expression_courante = NULL;
                   3405:            (*s_etat_processus).objet_courant = NULL;
                   3406:            (*s_etat_processus).evaluation_expression_compilee = 'N';
                   3407: 
                   3408:            (*s_etat_processus).l_base_pile = NULL;
                   3409:            (*s_etat_processus).l_base_pile_last = NULL;
                   3410: 
1.64      bertrand 3411:            (*s_etat_processus).s_arbre_variables = NULL;
1.65      bertrand 3412:            (*s_etat_processus).l_liste_variables_par_niveau = NULL;
1.127     bertrand 3413:            (*s_etat_processus).l_liste_variables_statiques = NULL;
1.1       bertrand 3414:            (*s_etat_processus).gel_liste_variables = d_faux;
1.127     bertrand 3415:            s_arbre_variables_partagees = NULL;
                   3416:            l_liste_variables_partagees = NULL;
                   3417:            (*s_etat_processus).s_arbre_variables_partagees =
                   3418:                    &s_arbre_variables_partagees;
                   3419:            (*s_etat_processus).l_liste_variables_partagees =
                   3420:                    &l_liste_variables_partagees;
1.64      bertrand 3421:            (*s_etat_processus).pointeur_variable_courante = NULL;
1.119     bertrand 3422:            (*s_etat_processus).pointeur_variable_statique_courante = NULL;
1.127     bertrand 3423:            (*s_etat_processus).pointeur_variable_partagee_courante = NULL;
1.1       bertrand 3424:            (*s_etat_processus).niveau_courant = 0;
                   3425:            (*s_etat_processus).niveau_initial = 0;
                   3426:            (*s_etat_processus).creation_variables_statiques = d_faux;
                   3427:            (*s_etat_processus).creation_variables_partagees = d_faux;
                   3428: 
                   3429:            (*s_etat_processus).s_bibliotheques = NULL;
                   3430:            (*s_etat_processus).s_instructions_externes = NULL;
                   3431:            (*s_etat_processus).nombre_instructions_externes = 0;
                   3432: 
                   3433:            (*s_etat_processus).systeme_axes = 0;
                   3434: 
                   3435:            (*s_etat_processus).x_min = -10.;
                   3436:            (*s_etat_processus).x_max = 10.;
                   3437:            (*s_etat_processus).y_min = -10.;
                   3438:            (*s_etat_processus).y_max = 10.;
                   3439:            (*s_etat_processus).z_min = -10.;
                   3440:            (*s_etat_processus).z_max = 10.;
                   3441: 
                   3442:            (*s_etat_processus).x2_min = -10.;
                   3443:            (*s_etat_processus).x2_max = 10.;
                   3444:            (*s_etat_processus).y2_min = -10.;
                   3445:            (*s_etat_processus).y2_max = 10.;
                   3446:            (*s_etat_processus).z2_min = -10.;
                   3447:            (*s_etat_processus).z2_max = 10.;
                   3448: 
                   3449:            (*s_etat_processus).resolution = .01;
                   3450: 
                   3451:            (*s_etat_processus).souris_active = d_faux;
                   3452: 
                   3453:            (*s_etat_processus).echelle_automatique_x = d_faux;
                   3454:            (*s_etat_processus).echelle_automatique_y = d_faux;
                   3455:            (*s_etat_processus).echelle_automatique_z = d_faux;
                   3456: 
                   3457:            (*s_etat_processus).echelle_automatique_x2 = d_faux;
                   3458:            (*s_etat_processus).echelle_automatique_y2 = d_faux;
                   3459:            (*s_etat_processus).echelle_automatique_z2 = d_faux;
                   3460: 
                   3461:            (*s_etat_processus).echelle_log_x = d_faux;
                   3462:            (*s_etat_processus).echelle_log_y = d_faux;
                   3463:            (*s_etat_processus).echelle_log_z = d_faux;
                   3464: 
                   3465:            (*s_etat_processus).echelle_log_x2 = d_faux;
                   3466:            (*s_etat_processus).echelle_log_y2 = d_faux;
                   3467:            (*s_etat_processus).echelle_log_z2 = d_faux;
                   3468: 
                   3469:            (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
                   3470:            (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
                   3471:            (*s_etat_processus).echelle_3D = 1;
                   3472: 
                   3473:            strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
                   3474:            strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
                   3475:            (*s_etat_processus).fichiers_graphiques = NULL;
                   3476:            (*s_etat_processus).nom_fichier_impression = NULL;
                   3477:            strcpy((*s_etat_processus).format_papier, "a4paper");
                   3478:            (*s_etat_processus).entree_standard = NULL;
                   3479:            (*s_etat_processus).s_marques = NULL;
                   3480:            (*s_etat_processus).requete_nouveau_plan = d_vrai;
                   3481:            (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
                   3482: 
                   3483:            (*s_etat_processus).l_base_pile = NULL;
                   3484:            (*s_etat_processus).hauteur_pile_operationnelle = 0;
                   3485:            (*s_etat_processus).l_base_pile_contextes = NULL;
                   3486:            (*s_etat_processus).l_base_pile_taille_contextes = NULL;
                   3487: 
                   3488:            (*s_etat_processus).position_courante = 0;
                   3489: 
                   3490:            (*s_etat_processus).l_base_pile_systeme = NULL;
                   3491:            (*s_etat_processus).hauteur_pile_systeme = 0;
                   3492: 
                   3493:            (*s_etat_processus).l_base_pile_processus = NULL;
                   3494:            (*s_etat_processus).presence_pipes = d_faux;
                   3495:            (*s_etat_processus).pipe_donnees = 0;
                   3496:            (*s_etat_processus).pipe_acquittement = 0;
                   3497:            (*s_etat_processus).pipe_injections = 0;
                   3498:            (*s_etat_processus).pipe_nombre_injections = 0;
                   3499:            (*s_etat_processus).nombre_objets_injectes = 0;
                   3500:            (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
                   3501:            (*s_etat_processus).pourcentage_maximal_cpu = 100;
                   3502:            (*s_etat_processus).temps_maximal_cpu = 0;
                   3503:            (*s_etat_processus).thread_fusible = 0;
                   3504:            (*s_etat_processus).presence_fusible = d_faux;
                   3505: 
                   3506:            (*s_etat_processus).niveau_recursivite = 0;
                   3507:            (*s_etat_processus).generateur_aleatoire = NULL;
                   3508:            (*s_etat_processus).type_generateur_aleatoire = NULL;
                   3509: 
                   3510:            (*s_etat_processus).colonne_statistique_1 = 1; 
                   3511:            (*s_etat_processus).colonne_statistique_2 = 2; 
                   3512: 
                   3513:            (*s_etat_processus).debug_programme = d_faux;
                   3514:            (*s_etat_processus).execution_pas_suivant = d_faux;
                   3515:            (*s_etat_processus).traitement_instruction_halt = d_faux;
                   3516: 
                   3517:            (*s_etat_processus).derniere_exception = d_ep;
                   3518:            (*s_etat_processus).derniere_erreur_systeme = d_es;
                   3519:            (*s_etat_processus).derniere_erreur_execution = d_ex;
                   3520:            (*s_etat_processus).derniere_erreur_evaluation = d_ex;
                   3521:            (*s_etat_processus).derniere_erreur_fonction_externe = 0;
                   3522: 
                   3523:            (*s_etat_processus).erreur_processus_fils = d_faux;
                   3524:            (*s_etat_processus).erreur_systeme_processus_fils = d_es;
                   3525:            (*s_etat_processus).erreur_execution_processus_fils = d_ex;
                   3526:            (*s_etat_processus).pid_erreur_processus_fils = 0;
                   3527:            (*s_etat_processus).exception_processus_fils = d_ep;
                   3528:            (*s_etat_processus).core = core;
                   3529:            (*s_etat_processus).invalidation_message_erreur = d_faux;
                   3530:            (*s_etat_processus).s_objet_errone = NULL;
                   3531:            (*s_etat_processus).s_objet_erreur = NULL;
                   3532: 
                   3533:            (*s_etat_processus).retour_routine_evaluation = 'N';
                   3534: 
                   3535:            (*s_etat_processus).traitement_interruption = 'N';
                   3536:            (*s_etat_processus).traitement_interruptible = 'Y';
                   3537:            (*s_etat_processus).nombre_interruptions_en_queue = 0;
                   3538:            (*s_etat_processus).nombre_interruptions_non_affectees = 0;
                   3539: 
                   3540:            for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
                   3541:            {
                   3542:                (*s_etat_processus).masque_interruptions[i] = 'N';
                   3543:                (*s_etat_processus).queue_interruptions[i] = 0;
                   3544:                (*s_etat_processus).corps_interruptions[i] = NULL;
                   3545:                (*s_etat_processus).pile_origine_interruptions[i] = NULL;
                   3546:            }
                   3547: 
1.20      bertrand 3548:            (*s_etat_processus).at_exit = NULL;
1.34      bertrand 3549:            (*s_etat_processus).at_poke = NULL;
                   3550:            (*s_etat_processus).traitement_at_poke = 'N';
1.19      bertrand 3551: 
1.1       bertrand 3552:            (*s_etat_processus).pointeurs_caracteres = NULL;
                   3553:            (*s_etat_processus).arbre_instructions = NULL;
                   3554: 
                   3555:            (*s_etat_processus).tid_processus_pere = pthread_self();
1.113     bertrand 3556:            (*s_etat_processus).tid = pthread_self();
1.1       bertrand 3557:            (*s_etat_processus).pid_processus_pere = getpid();
                   3558:            (*s_etat_processus).processus_detache = d_vrai;
                   3559:            (*s_etat_processus).var_volatile_processus_pere = -1;
1.45      bertrand 3560:            (*s_etat_processus).var_volatile_processus_racine = -1;
1.1       bertrand 3561:            (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
                   3562:            (*s_etat_processus).var_volatile_alarme = 0;
                   3563:            (*s_etat_processus).var_volatile_requete_arret = 0;
                   3564:            (*s_etat_processus).var_volatile_requete_arret2 = 0;
                   3565:            (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
                   3566:            (*s_etat_processus).var_volatile_traitement_sigint = 0;
                   3567:            (*s_etat_processus).var_volatile_recursivite = 0;
                   3568:            (*s_etat_processus).var_volatile_exception_gsl = 0;
1.22      bertrand 3569:            (*s_etat_processus).arret_depuis_abort = 0;
1.83      bertrand 3570:            (*s_etat_processus).pointeur_signal_lecture = 0;
                   3571:            (*s_etat_processus).pointeur_signal_ecriture = 0;
1.1       bertrand 3572: 
                   3573:            initialisation_allocateur(s_etat_processus);
                   3574:            initialisation_drapeaux(s_etat_processus);
1.65      bertrand 3575:            initialisation_variables(s_etat_processus);
                   3576:            initialisation_instructions(s_etat_processus);
1.1       bertrand 3577: 
                   3578:            if ((*s_etat_processus).erreur_systeme != d_es)
                   3579:            {
1.124     bertrand 3580: #              ifndef SEMAPHORES_NOMMES
                   3581:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3582:                    sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3583: #              else
                   3584:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3585:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3586:                            getpid(), pthread_self(), SEM_FORK);
                   3587: #              endif
                   3588: 
                   3589:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3590:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3591: 
                   3592: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3593:                    stackoverflow_deinstall_handler();
                   3594: #              endif
                   3595: 
                   3596: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3597:                    if (debug == d_faux)
                   3598:                    {
                   3599:                        sigsegv_deinstall_handler();
                   3600:                    }
                   3601: #              endif
                   3602: 
1.1       bertrand 3603:                if ((*s_etat_processus).langue == 'F')
                   3604:                {
                   3605:                    printf("+++Système : Mémoire insuffisante\n");
                   3606:                }
                   3607:                else
                   3608:                {
                   3609:                    printf("+++System : Not enough memory\n");
                   3610:                }
                   3611: 
                   3612:                return(EXIT_FAILURE);
                   3613:            }
                   3614: 
                   3615:            if (((*s_etat_processus).instruction_derniere_erreur =
1.32      bertrand 3616:                    malloc(sizeof(unsigned char))) == NULL)
1.1       bertrand 3617:            {
1.124     bertrand 3618: #              ifndef SEMAPHORES_NOMMES
                   3619:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3620:                    sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3621: #              else
                   3622:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3623:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3624:                            getpid(), pthread_self(), SEM_FORK);
                   3625: #              endif
                   3626: 
                   3627:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3628:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3629: 
                   3630: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3631:                    stackoverflow_deinstall_handler();
                   3632: #              endif
                   3633: 
                   3634: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3635:                    if (debug == d_faux)
                   3636:                    {
                   3637:                        sigsegv_deinstall_handler();
                   3638:                    }
                   3639: #              endif
                   3640: 
1.1       bertrand 3641:                erreur = d_es_allocation_memoire;
                   3642: 
                   3643:                if ((*s_etat_processus).langue == 'F')
                   3644:                {
                   3645:                    printf("+++Système : Mémoire insuffisante\n");
                   3646:                }
                   3647:                else
                   3648:                {
                   3649:                    printf("+++System : Not enough memory\n");
                   3650:                }
                   3651: 
                   3652:                return(EXIT_FAILURE);
                   3653:            }
                   3654: 
                   3655:            strcpy((*s_etat_processus).instruction_derniere_erreur, "");
                   3656:            (*s_etat_processus).niveau_derniere_erreur = 0;
                   3657: 
                   3658:            if (traitement_fichier_temporaire == 'Y')
                   3659:            {
                   3660:                (*s_etat_processus).mode_interactif = 'Y';
                   3661:            }
                   3662:            else
                   3663:            {
                   3664:                (*s_etat_processus).mode_interactif = 'N';
                   3665:            }
                   3666: 
                   3667:            if (((*s_etat_processus).instruction_courante = (unsigned char *)
                   3668:                    malloc(sizeof(unsigned char))) == NULL)
                   3669:            {
1.124     bertrand 3670: #              ifndef SEMAPHORES_NOMMES
                   3671:                    sem_post(&((*s_etat_processus).semaphore_fork));
                   3672:                    sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3673: #              else
                   3674:                    sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3675:                    sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3676:                            getpid(), pthread_self(), SEM_FORK);
                   3677: #              endif
                   3678: 
                   3679:                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3680:                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3681: 
                   3682: #              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3683:                    stackoverflow_deinstall_handler();
                   3684: #              endif
                   3685: 
                   3686: #              ifdef HAVE_SIGSEGV_RECOVERY
                   3687:                    if (debug == d_faux)
                   3688:                    {
                   3689:                        sigsegv_deinstall_handler();
                   3690:                    }
                   3691: #              endif
                   3692: 
1.1       bertrand 3693:                erreur = d_es_allocation_memoire;
                   3694: 
                   3695:                if ((*s_etat_processus).langue == 'F')
                   3696:                {
                   3697:                    printf("+++Système : Mémoire insuffisante\n");
                   3698:                }
                   3699:                else
                   3700:                {
                   3701:                    printf("+++System : Not enough memory\n");
                   3702:                }
                   3703: 
                   3704:                return(EXIT_FAILURE);
                   3705:            }
                   3706: 
                   3707:            (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
                   3708: 
                   3709:            empilement_pile_systeme(s_etat_processus);
                   3710: 
                   3711:            free((*s_etat_processus).instruction_courante);
                   3712: 
1.41      bertrand 3713:            if ((*s_etat_processus).erreur_systeme != d_es)
1.1       bertrand 3714:            {
                   3715:                erreur = d_es_allocation_memoire;
                   3716:            }
                   3717:            else
                   3718:            {
                   3719:                (*((*s_etat_processus).l_base_pile_systeme))
                   3720:                        .retour_definition = 'Y';
                   3721: 
1.111     bertrand 3722:                (*s_etat_processus).indep = allocation(s_etat_processus, NON);
                   3723:                (*s_etat_processus).depend = allocation(s_etat_processus, NON);
1.1       bertrand 3724:                (*s_etat_processus).parametres_courbes_de_niveau =
1.111     bertrand 3725:                        allocation(s_etat_processus, NON);
1.1       bertrand 3726: 
                   3727:                if (((*s_etat_processus).indep != NULL) &&
                   3728:                        ((*s_etat_processus).depend != NULL) &&
                   3729:                        ((*s_etat_processus).parametres_courbes_de_niveau
                   3730:                        != NULL))
                   3731:                {
                   3732:                    (*((*s_etat_processus).indep)).type = NOM;
                   3733:                    (*((*s_etat_processus).depend)).type = NOM;
                   3734:                    (*((*s_etat_processus).
                   3735:                            parametres_courbes_de_niveau)).type = LST;
                   3736: 
                   3737:                    initialisation_objet((*s_etat_processus).indep);
                   3738:                    initialisation_objet((*s_etat_processus).depend);
                   3739:                    initialisation_objet((*s_etat_processus)
                   3740:                            .parametres_courbes_de_niveau);
                   3741: 
                   3742:                    (*((*s_etat_processus).indep)).objet = (struct_nom *)
                   3743:                            malloc(sizeof(struct_nom));
                   3744:                    (*((*s_etat_processus).depend)).objet = (struct_nom *)
                   3745:                            malloc(sizeof(struct_nom));
                   3746:                    (*((*s_etat_processus).parametres_courbes_de_niveau))
                   3747:                            .objet = (struct_liste_chainee *)
                   3748:                            malloc(sizeof(struct_liste_chainee));
                   3749: 
                   3750:                    if (((*((*s_etat_processus).depend)).objet == NULL) ||
                   3751:                            ((*((*s_etat_processus).depend)).objet == NULL) ||
                   3752:                            ((*((*s_etat_processus).
                   3753:                            parametres_courbes_de_niveau)).objet == NULL))
                   3754:                    {
1.124     bertrand 3755: #                      ifndef SEMAPHORES_NOMMES
                   3756:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   3757:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3758: #                      else
                   3759:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3760:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3761:                                    getpid(), pthread_self(), SEM_FORK);
                   3762: #                      endif
                   3763: 
                   3764:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3765:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3766: 
                   3767: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3768:                            stackoverflow_deinstall_handler();
                   3769: #                      endif
                   3770: 
                   3771: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   3772:                            if (debug == d_faux)
                   3773:                            {
                   3774:                                sigsegv_deinstall_handler();
                   3775:                            }
                   3776: #                      endif
                   3777: 
1.1       bertrand 3778:                        erreur = d_es_allocation_memoire;
                   3779:                        
                   3780:                        if ((*s_etat_processus).langue == 'F')
                   3781:                        {
                   3782:                            printf("+++Système : Mémoire insuffisante\n");
                   3783:                        }
                   3784:                        else
                   3785:                        {
                   3786:                            printf("+++System : Not enough memory\n");
                   3787:                        }
                   3788: 
                   3789:                        return(EXIT_FAILURE);
                   3790:                    }
                   3791: 
                   3792:                    (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
                   3793:                            .nom = malloc(2 * sizeof(unsigned char));
                   3794:                    (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
                   3795:                            .nom = malloc(2 * sizeof(unsigned char));
                   3796: 
                   3797:                    if (((*((struct_nom *) (*((*s_etat_processus).indep))
                   3798:                            .objet)).nom == NULL) || ((*((struct_nom *)
                   3799:                            (*((*s_etat_processus).depend)).objet)).nom ==
                   3800:                            NULL))
                   3801:                    {
1.124     bertrand 3802: #                      ifndef SEMAPHORES_NOMMES
                   3803:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   3804:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3805: #                      else
                   3806:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3807:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3808:                                    getpid(), pthread_self(), SEM_FORK);
                   3809: #                      endif
                   3810: 
                   3811:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3812:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3813: 
                   3814: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3815:                            stackoverflow_deinstall_handler();
                   3816: #                      endif
                   3817: 
                   3818: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   3819:                            if (debug == d_faux)
                   3820:                            {
                   3821:                                sigsegv_deinstall_handler();
                   3822:                            }
                   3823: #                      endif
                   3824: 
1.1       bertrand 3825:                        erreur = d_es_allocation_memoire;
                   3826: 
                   3827:                        if ((*s_etat_processus).langue == 'F')
                   3828:                        {
                   3829:                            printf("+++Système : Mémoire insuffisante\n");
                   3830:                        }
                   3831:                        else
                   3832:                        {
                   3833:                            printf("+++System : Not enough memory\n");
                   3834:                        }
                   3835: 
                   3836:                        return(EXIT_FAILURE);
                   3837:                    }
                   3838: 
                   3839:                    strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
                   3840:                            .objet)).nom, "X");
                   3841:                    strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
                   3842:                            .objet)).nom, "Y");
                   3843: 
                   3844:                    (*((struct_nom *) (*((*s_etat_processus).indep))
                   3845:                            .objet)).symbole = d_vrai;
                   3846:                    (*((struct_nom *) (*((*s_etat_processus).depend))
                   3847:                            .objet)).symbole = d_vrai;
                   3848: 
                   3849:                    (*((struct_liste_chainee *) (*((*s_etat_processus)
                   3850:                            .parametres_courbes_de_niveau)).objet)).suivant
                   3851:                            = NULL;
                   3852: 
                   3853:                    (*((struct_liste_chainee *) (*((*s_etat_processus)
                   3854:                            .parametres_courbes_de_niveau)).objet)).donnee
                   3855:                            = malloc(sizeof(struct_objet));
                   3856: 
                   3857:                    (*s_etat_processus).legende =
                   3858:                            malloc(sizeof(unsigned char));
                   3859:                    (*s_etat_processus).label_x =
                   3860:                            malloc(sizeof(unsigned char));
                   3861:                    (*s_etat_processus).label_y =
                   3862:                            malloc(sizeof(unsigned char));
                   3863:                    (*s_etat_processus).label_z =
                   3864:                            malloc(sizeof(unsigned char));
                   3865:                    (*s_etat_processus).titre =
                   3866:                            malloc(sizeof(unsigned char));
                   3867: 
                   3868:                    if (((*s_etat_processus).label_x == NULL) ||
                   3869:                            ((*s_etat_processus).label_y == NULL) ||
                   3870:                            ((*s_etat_processus).label_z == NULL) ||
                   3871:                            ((*s_etat_processus).titre == NULL) ||
                   3872:                            ((*s_etat_processus).legende == NULL) ||
                   3873:                            ((*((struct_liste_chainee *) (*((*s_etat_processus)
                   3874:                            .parametres_courbes_de_niveau)).objet)).donnee
                   3875:                            == NULL))
                   3876:                    {
1.124     bertrand 3877: #                      ifndef SEMAPHORES_NOMMES
                   3878:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   3879:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3880: #                      else
                   3881:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3882:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3883:                                    getpid(), pthread_self(), SEM_FORK);
                   3884: #                      endif
                   3885: 
                   3886:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3887:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3888: 
                   3889: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3890:                            stackoverflow_deinstall_handler();
                   3891: #                      endif
                   3892: 
                   3893: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   3894:                            if (debug == d_faux)
                   3895:                            {
                   3896:                                sigsegv_deinstall_handler();
                   3897:                            }
                   3898: #                      endif
                   3899: 
1.1       bertrand 3900:                        erreur = d_es_allocation_memoire;
                   3901: 
                   3902:                        if ((*s_etat_processus).langue == 'F')
                   3903:                        {
                   3904:                            printf("+++Système : Mémoire insuffisante\n");
                   3905:                        }
                   3906:                        else
                   3907:                        {
                   3908:                            printf("+++System : Not enough memory\n");
                   3909:                        }
                   3910: 
                   3911:                        return(EXIT_FAILURE);
                   3912:                    }
                   3913: 
                   3914:                    (*(*((struct_liste_chainee *) (*((*s_etat_processus)
                   3915:                            .parametres_courbes_de_niveau)).objet)).donnee)
                   3916:                            .type = CHN;
                   3917: 
                   3918:                    initialisation_objet((*((struct_liste_chainee *)
                   3919:                            (*((*s_etat_processus)
                   3920:                            .parametres_courbes_de_niveau))
                   3921:                            .objet)).donnee);
                   3922: 
                   3923:                    if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
                   3924:                            .parametres_courbes_de_niveau)).objet)).donnee)
                   3925:                            .objet = malloc(10 * sizeof(unsigned char)))
                   3926:                            == NULL)
                   3927:                    {
1.124     bertrand 3928: #                      ifndef SEMAPHORES_NOMMES
                   3929:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   3930:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   3931: #                      else
                   3932:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 3933:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 3934:                                    getpid(), pthread_self(), SEM_FORK);
                   3935: #                      endif
                   3936: 
                   3937:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 3938:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 3939: 
                   3940: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   3941:                            stackoverflow_deinstall_handler();
                   3942: #                      endif
                   3943: 
                   3944: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   3945:                            if (debug == d_faux)
                   3946:                            {
                   3947:                                sigsegv_deinstall_handler();
                   3948:                            }
                   3949: #                      endif
                   3950: 
1.1       bertrand 3951:                        erreur = d_es_allocation_memoire;
                   3952: 
                   3953:                        if ((*s_etat_processus).langue == 'F')
                   3954:                        {
                   3955:                            printf("+++Système : Mémoire insuffisante\n");
                   3956:                        }
                   3957:                        else
                   3958:                        {
                   3959:                            printf("+++System : Not enough memory\n");
                   3960:                        }
                   3961: 
                   3962:                        return(EXIT_FAILURE);
                   3963:                    }
                   3964: 
                   3965:                    strcpy((unsigned char *) (*(*((struct_liste_chainee *)
                   3966:                            (*((*s_etat_processus)
                   3967:                            .parametres_courbes_de_niveau))
                   3968:                            .objet)).donnee).objet, "AUTOMATIC");
                   3969: 
                   3970:                    (*s_etat_processus).label_x[0] = d_code_fin_chaine;
                   3971:                    (*s_etat_processus).label_y[0] = d_code_fin_chaine;
                   3972:                    (*s_etat_processus).label_z[0] = d_code_fin_chaine;
                   3973:                    (*s_etat_processus).titre[0] = d_code_fin_chaine;
                   3974:                    (*s_etat_processus).legende[0] = d_code_fin_chaine;
                   3975: 
                   3976:                    (*s_etat_processus).nom_fichier_gnuplot = NULL;
                   3977:                    (*s_etat_processus).type_fichier_gnuplot = NULL;
                   3978: 
                   3979:                    (*s_etat_processus).x_tics = 0;
                   3980:                    (*s_etat_processus).y_tics = 0;
                   3981:                    (*s_etat_processus).z_tics = 0;
                   3982: 
                   3983:                    (*s_etat_processus).x_lines = d_vrai;
                   3984:                    (*s_etat_processus).y_lines = d_vrai;
                   3985:                    (*s_etat_processus).z_lines = d_vrai;
                   3986: 
                   3987:                    (*s_etat_processus).mx_tics = -1;
                   3988:                    (*s_etat_processus).my_tics = -1;
                   3989:                    (*s_etat_processus).mz_tics = -1;
                   3990: 
                   3991:                    (*s_etat_processus).mx_lines = d_faux;
                   3992:                    (*s_etat_processus).my_lines = d_faux;
                   3993:                    (*s_etat_processus).mz_lines = d_faux;
                   3994: 
                   3995:                    (*s_etat_processus).x2_tics = -1;
                   3996:                    (*s_etat_processus).y2_tics = -1;
                   3997:                    (*s_etat_processus).z2_tics = -1;
                   3998: 
                   3999:                    (*s_etat_processus).x2_lines = d_faux;
                   4000:                    (*s_etat_processus).y2_lines = d_faux;
                   4001:                    (*s_etat_processus).z2_lines = d_faux;
                   4002: 
                   4003:                    (*s_etat_processus).mx2_tics = -1;
                   4004:                    (*s_etat_processus).my2_tics = -1;
                   4005:                    (*s_etat_processus).mz2_tics = -1;
                   4006: 
                   4007:                    (*s_etat_processus).mx2_lines = d_faux;
                   4008:                    (*s_etat_processus).my2_lines = d_faux;
                   4009:                    (*s_etat_processus).mz2_lines = d_faux;
                   4010: 
                   4011:                    (*s_etat_processus).mode_evaluation_expression = 'N';
                   4012:                    (*s_etat_processus).mode_execution_programme = 'Y';
                   4013: 
                   4014:                    if ((*s_etat_processus).definitions_chainees == NULL)
                   4015:                    {
                   4016:                        if ((erreur = chainage(s_etat_processus)) !=
                   4017:                                d_absence_erreur)
                   4018:                        {
1.124     bertrand 4019: #                          ifndef SEMAPHORES_NOMMES
                   4020:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4021:                                sem_destroy(&((*s_etat_processus)
                   4022:                                        .semaphore_fork));
                   4023: #                          else
                   4024:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4025:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4026:                                        getpid(), pthread_self(), SEM_FORK);
                   4027: #                          endif
                   4028: 
                   4029:                            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4030:                            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4031: 
                   4032: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4033:                                stackoverflow_deinstall_handler();
                   4034: #                          endif
                   4035: 
                   4036: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4037:                                if (debug == d_faux)
                   4038:                                {
                   4039:                                    sigsegv_deinstall_handler();
                   4040:                                }
                   4041: #                          endif
                   4042: 
1.1       bertrand 4043:                            if ((*s_etat_processus).langue == 'F')
                   4044:                            {
                   4045:                                printf("+++Fatal :"
                   4046:                                        " Chaînage des définitions"
                   4047:                                        " impossible\n");
                   4048:                            }
                   4049:                            else
                   4050:                            {
                   4051:                                printf("+++Fatal : Error in "
                   4052:                                        "compilation\n");
                   4053:                            }
                   4054: 
                   4055:                            if (traitement_fichier_temporaire == 'Y')
                   4056:                            {
                   4057:                                if (destruction_fichier(
                   4058:                                        nom_fichier_temporaire)
                   4059:                                        == d_erreur)
                   4060:                                {
                   4061:                                    return(EXIT_FAILURE);
                   4062:                                }
                   4063: 
                   4064:                                free(nom_fichier_temporaire);
                   4065:                            }
                   4066: 
                   4067:                            return(EXIT_FAILURE);
                   4068:                        }
                   4069:                    }
                   4070: 
1.195     bertrand 4071:                    /*
                   4072:                     * Chargement des bibliothèques pour gérer des
                   4073:                     * types externes lors des l'analyse syntaxique et
                   4074:                     * compilation.
                   4075:                     */
                   4076: 
                   4077:                    l_bibliotheque_courante = l_bibliotheques;
                   4078: 
                   4079:                    while(l_bibliotheque_courante != NULL)
                   4080:                    {
                   4081:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   4082:                                .l_base_pile), (*l_bibliotheque_courante)
                   4083:                                .donnee) == d_erreur)
                   4084:                        {
                   4085: #                          ifndef SEMAPHORES_NOMMES
                   4086:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4087:                                sem_destroy(&((*s_etat_processus)
                   4088:                                        .semaphore_fork));
                   4089: #                          else
                   4090:                                sem_post((*s_etat_processus).semaphore_fork);
                   4091:                                sem_destroy3((*s_etat_processus).semaphore_fork,
                   4092:                                        getpid(), pthread_self(), SEM_FORK);
                   4093: #                          endif
                   4094: 
                   4095:                            liberation_contexte_cas(s_etat_processus);
                   4096:                            destruction_queue_signaux(s_etat_processus);
                   4097: 
                   4098: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4099:                                stackoverflow_deinstall_handler();
                   4100: #                          endif
                   4101: 
                   4102: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4103:                                if (debug == d_faux)
                   4104:                                {
                   4105:                                    sigsegv_deinstall_handler();
                   4106:                                }
                   4107: #                          endif
                   4108: 
                   4109:                            if ((*s_etat_processus).langue == 'F')
                   4110:                            {
                   4111:                                printf("+++Fatal :"
                   4112:                                        " Chargement de la bibliothèse %s"
                   4113:                                        " impossible\n", (unsigned char *)
                   4114:                                        (*(*l_bibliotheque_courante).donnee)
                   4115:                                        .objet);
                   4116:                            }
                   4117:                            else
                   4118:                            {
                   4119:                                printf("+++Fatal : Cannot load library %s\n",
                   4120:                                        (*(*l_bibliotheque_courante).donnee)
                   4121:                                        .objet);
                   4122:                            }
                   4123: 
                   4124:                            if (traitement_fichier_temporaire == 'Y')
                   4125:                            {
                   4126:                                if (destruction_fichier(
                   4127:                                        nom_fichier_temporaire)
                   4128:                                        == d_erreur)
                   4129:                                {
                   4130:                                    return(EXIT_FAILURE);
                   4131:                                }
                   4132: 
                   4133:                                free(nom_fichier_temporaire);
                   4134:                            }
                   4135: 
                   4136:                            return(EXIT_FAILURE);
                   4137:                        }
                   4138: 
                   4139:                        instruction_use(s_etat_processus);
                   4140: 
                   4141:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   4142:                                .l_base_pile), &((*l_bibliotheque_courante)
                   4143:                                .donnee)) == d_erreur)
                   4144:                        {
                   4145: #                          ifndef SEMAPHORES_NOMMES
                   4146:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4147:                                sem_destroy(&((*s_etat_processus)
                   4148:                                        .semaphore_fork));
                   4149: #                          else
                   4150:                                sem_post((*s_etat_processus).semaphore_fork);
                   4151:                                sem_destroy3((*s_etat_processus).semaphore_fork,
                   4152:                                        getpid(), pthread_self(), SEM_FORK);
                   4153: #                          endif
                   4154: 
                   4155:                            liberation_contexte_cas(s_etat_processus);
                   4156:                            destruction_queue_signaux(s_etat_processus);
                   4157: 
                   4158: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4159:                                stackoverflow_deinstall_handler();
                   4160: #                          endif
                   4161: 
                   4162: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4163:                                if (debug == d_faux)
                   4164:                                {
                   4165:                                    sigsegv_deinstall_handler();
                   4166:                                }
                   4167: #                          endif
                   4168: 
                   4169:                            if ((*s_etat_processus).langue == 'F')
                   4170:                            {
                   4171:                                printf("+++Fatal :"
                   4172:                                        " Chargement de la bibliothèse %s"
                   4173:                                        " impossible\n", (unsigned char *)
                   4174:                                        (*(*l_bibliotheque_courante).donnee)
                   4175:                                        .objet);
                   4176:                            }
                   4177:                            else
                   4178:                            {
                   4179:                                printf("+++Fatal : Cannot load library %s\n",
                   4180:                                        (*(*l_bibliotheque_courante).donnee)
                   4181:                                        .objet);
                   4182:                            }
                   4183: 
                   4184:                            if (traitement_fichier_temporaire == 'Y')
                   4185:                            {
                   4186:                                if (destruction_fichier(
                   4187:                                        nom_fichier_temporaire)
                   4188:                                        == d_erreur)
                   4189:                                {
                   4190:                                    return(EXIT_FAILURE);
                   4191:                                }
                   4192: 
                   4193:                                free(nom_fichier_temporaire);
                   4194:                            }
                   4195: 
                   4196:                            return(EXIT_FAILURE);
                   4197:                        }
                   4198: 
                   4199:                        l_bibliotheque_courante =
                   4200:                                (*l_bibliotheque_courante).suivant;
                   4201:                    }
                   4202: 
1.1       bertrand 4203:                    if ((erreur = compilation(s_etat_processus)) !=
                   4204:                            d_absence_erreur)
                   4205:                    {
1.124     bertrand 4206: #                      ifndef SEMAPHORES_NOMMES
                   4207:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4208:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4209: #                      else
                   4210:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4211:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4212:                                    getpid(), pthread_self(), SEM_FORK);
                   4213: #                      endif
                   4214: 
                   4215:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4216:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4217: 
                   4218: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4219:                            stackoverflow_deinstall_handler();
                   4220: #                      endif
                   4221: 
                   4222: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4223:                            if (debug == d_faux)
                   4224:                            {
                   4225:                                sigsegv_deinstall_handler();
                   4226:                            }
                   4227: #                      endif
                   4228: 
1.1       bertrand 4229:                        if (traitement_fichier_temporaire == 'Y')
                   4230:                        {
                   4231:                            if (destruction_fichier(nom_fichier_temporaire)
                   4232:                                    == d_erreur)
                   4233:                            {
                   4234:                                return(EXIT_FAILURE);
                   4235:                            }
                   4236: 
                   4237:                            free(nom_fichier_temporaire);
                   4238:                        }
                   4239: 
                   4240:                        printf("%s [%d]\n", message =
                   4241:                                messages(s_etat_processus), (int) getpid());
                   4242:                        free(message);
                   4243: 
                   4244:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   4245:                        {
                   4246:                            printf("%s", ds_beep);
                   4247:                        }
                   4248: 
                   4249:                        if ((*s_etat_processus).core == d_vrai)
                   4250:                        {
                   4251:                            printf("\n");
                   4252:                            
                   4253:                            if ((*s_etat_processus).langue == 'F')
                   4254:                            {
                   4255:                                printf("+++Information : Génération du fichier "
                   4256:                                        "rpl-core [%d]\n", (int) getpid());
                   4257:                            }
                   4258:                            else
                   4259:                            {
                   4260:                                printf("+++Information : Writing rpl-core "
                   4261:                                        "file [%d]\n", (int) getpid());
                   4262:                            }
                   4263: 
                   4264:                            rplcore(s_etat_processus);
                   4265: 
                   4266:                            if ((*s_etat_processus).langue == 'F')
                   4267:                            {
                   4268:                                printf("+++Information : Processus tracé "
                   4269:                                        "[%d]\n", (int) getpid());
                   4270:                            }
                   4271:                            else
                   4272:                            {
                   4273:                                printf("+++Information : Done [%d]\n",
                   4274:                                        (int) getpid());
                   4275:                            }
                   4276: 
                   4277:                            printf("\n");
                   4278:                        }
                   4279: 
                   4280:                        return(EXIT_FAILURE);
                   4281:                    }
                   4282: 
                   4283:                    (*s_etat_processus).position_courante = 0;
                   4284:                    (*s_etat_processus).traitement_cycle_exit = 'N';
                   4285: 
1.64      bertrand 4286:                    if ((*s_etat_processus).s_arbre_variables == NULL)
1.1       bertrand 4287:                    {
1.124     bertrand 4288: #                      ifndef SEMAPHORES_NOMMES
                   4289:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4290:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4291: #                      else
                   4292:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4293:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4294:                                    getpid(), pthread_self(), SEM_FORK);
                   4295: #                      endif
                   4296: 
                   4297:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4298:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4299: 
                   4300: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4301:                            stackoverflow_deinstall_handler();
                   4302: #                      endif
                   4303: 
                   4304: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4305:                            if (debug == d_faux)
                   4306:                            {
                   4307:                                sigsegv_deinstall_handler();
                   4308:                            }
                   4309: #                      endif
                   4310: 
1.1       bertrand 4311:                        if ((*s_etat_processus).langue == 'F')
                   4312:                        {
                   4313:                            printf("+++Fatal : Aucun point d'entrée\n");
                   4314:                        }
                   4315:                        else
                   4316:                        {
                   4317:                            printf("+++Fatal : Any entry point\n");
                   4318:                        }
                   4319: 
                   4320:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   4321:                        {
                   4322:                            printf("%s", ds_beep);
                   4323:                        }
                   4324: 
                   4325:                        return(EXIT_FAILURE);
                   4326:                    }
                   4327: 
                   4328:                    if (recherche_instruction_suivante(s_etat_processus)
                   4329:                            == d_erreur)
                   4330:                    {
1.124     bertrand 4331: #                      ifndef SEMAPHORES_NOMMES
                   4332:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4333:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4334: #                      else
                   4335:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4336:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4337:                                    getpid(), pthread_self(), SEM_FORK);
                   4338: #                      endif
                   4339: 
                   4340:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4341:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4342: 
                   4343: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4344:                            stackoverflow_deinstall_handler();
                   4345: #                      endif
                   4346: 
                   4347: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4348:                            if (debug == d_faux)
                   4349:                            {
                   4350:                                sigsegv_deinstall_handler();
                   4351:                            }
                   4352: #                      endif
                   4353: 
1.1       bertrand 4354:                        if ((*s_etat_processus).langue == 'F')
                   4355:                        {
                   4356:                            printf("+++Fatal : Aucun point d'entrée\n");
                   4357:                        }
                   4358:                        else
                   4359:                        {
                   4360:                            printf("+++Fatal : Any entry point\n");
                   4361:                        }
                   4362: 
                   4363:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   4364:                        {
                   4365:                            printf("%s", ds_beep);
                   4366:                        }
                   4367: 
                   4368:                        return(EXIT_FAILURE);
                   4369:                    }
                   4370: 
                   4371:                    if (recherche_variable(s_etat_processus,
                   4372:                            (*s_etat_processus)
                   4373:                            .instruction_courante) == d_faux)
                   4374:                    {
1.124     bertrand 4375: #                      ifndef SEMAPHORES_NOMMES
                   4376:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4377:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4378: #                      else
                   4379:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4380:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4381:                                    getpid(), pthread_self(), SEM_FORK);
                   4382: #                      endif
                   4383: 
                   4384:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4385:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4386: 
                   4387: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4388:                            stackoverflow_deinstall_handler();
                   4389: #                      endif
                   4390: 
                   4391: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4392:                            if (debug == d_faux)
                   4393:                            {
                   4394:                                sigsegv_deinstall_handler();
                   4395:                            }
                   4396: #                      endif
                   4397: 
1.1       bertrand 4398:                        if ((*s_etat_processus).langue == 'F')
                   4399:                        {
                   4400:                            printf("+++Fatal : Aucun point d'entrée\n");
                   4401:                        }
                   4402:                        else
                   4403:                        {
                   4404:                            printf("+++Fatal : Any entry point\n");
                   4405:                        }
                   4406: 
                   4407:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   4408:                        {
                   4409:                            printf("%s", ds_beep);
                   4410:                        }
                   4411: 
                   4412:                        return(EXIT_FAILURE);
                   4413:                    }
                   4414: 
1.64      bertrand 4415:                    if ((*(*s_etat_processus).pointeur_variable_courante)
                   4416:                            .niveau != 0)
1.1       bertrand 4417:                    {
1.124     bertrand 4418: #                      ifndef SEMAPHORES_NOMMES
                   4419:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4420:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4421: #                      else
                   4422:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4423:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4424:                                    getpid(), pthread_self(), SEM_FORK);
                   4425: #                      endif
                   4426: 
                   4427:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4428:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4429: 
                   4430: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4431:                            stackoverflow_deinstall_handler();
                   4432: #                      endif
                   4433: 
                   4434: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4435:                            if (debug == d_faux)
                   4436:                            {
                   4437:                                sigsegv_deinstall_handler();
                   4438:                            }
                   4439: #                      endif
                   4440: 
1.1       bertrand 4441:                        if ((*s_etat_processus).langue == 'F')
                   4442:                        {
                   4443:                            printf("+++Fatal : Aucun point d'entrée\n");
                   4444:                        }
                   4445:                        else
                   4446:                        {
                   4447:                            printf("+++Fatal : Any entry point\n");
                   4448:                        }
                   4449: 
                   4450:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   4451:                        {
                   4452:                            printf("%s", ds_beep);
                   4453:                        }
                   4454: 
                   4455:                        return(EXIT_FAILURE);
                   4456:                    }
                   4457: 
                   4458:                    free((*s_etat_processus).instruction_courante);
                   4459:                    (*s_etat_processus).position_courante = 0;
                   4460: 
                   4461:                    if (((*s_etat_processus).nom_fichier_historique =
                   4462:                            malloc((strlen(home) +
                   4463:                            strlen(ds_fichier_historique) + 2) *
                   4464:                            sizeof(unsigned char))) == NULL)
                   4465:                    {
1.124     bertrand 4466: #                      ifndef SEMAPHORES_NOMMES
                   4467:                            sem_post(&((*s_etat_processus).semaphore_fork));
                   4468:                            sem_destroy(&((*s_etat_processus).semaphore_fork));
                   4469: #                      else
                   4470:                            sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4471:                            sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4472:                                    getpid(), pthread_self(), SEM_FORK);
                   4473: #                      endif
                   4474: 
                   4475:                        liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4476:                        destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4477: 
                   4478: #                      ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4479:                            stackoverflow_deinstall_handler();
                   4480: #                      endif
                   4481: 
                   4482: #                      ifdef HAVE_SIGSEGV_RECOVERY
                   4483:                            if (debug == d_faux)
                   4484:                            {
                   4485:                                sigsegv_deinstall_handler();
                   4486:                            }
                   4487: #                      endif
                   4488: 
1.1       bertrand 4489:                        erreur = d_es_allocation_memoire;
                   4490: 
                   4491:                        if ((*s_etat_processus).langue == 'F')
                   4492:                        {
                   4493:                            printf("+++Système : Mémoire insuffisante\n");
                   4494:                        }
                   4495:                        else
                   4496:                        {
                   4497:                            printf("+++System : Not enough memory\n");
                   4498:                        }
                   4499: 
                   4500:                        return(EXIT_FAILURE);
                   4501:                    }
                   4502: 
                   4503:                    sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
                   4504:                            home, ds_fichier_historique);
                   4505: 
                   4506:                    using_history();
1.109     bertrand 4507: 
                   4508:                    // Pour pouvoir utiliser le keymap avant le premier
                   4509:                    // appel à readline().
                   4510:                    rl_initialize();
                   4511: 
1.1       bertrand 4512:                    erreur_historique = read_history(
                   4513:                            (*s_etat_processus).nom_fichier_historique);
                   4514: 
                   4515:                    gsl_set_error_handler(&traitement_exceptions_gsl);
                   4516: 
                   4517:                    if (drapeau_encart == 'Y')
                   4518:                    {
                   4519:                        (*s_etat_processus).erreur_systeme = d_es;
                   4520:                        encart(s_etat_processus,
1.137     bertrand 4521:                                (integer8) (5 * 1000000));
1.1       bertrand 4522: 
                   4523:                        if ((*s_etat_processus).erreur_systeme != d_es)
                   4524:                        {
                   4525:                            if ((message = messages(s_etat_processus))
                   4526:                                    == NULL)
                   4527:                            {
1.124     bertrand 4528: #                              ifndef SEMAPHORES_NOMMES
                   4529:                                    sem_post(&((*s_etat_processus)
                   4530:                                            .semaphore_fork));
                   4531:                                    sem_destroy(&((*s_etat_processus)
                   4532:                                            .semaphore_fork));
                   4533: #                              else
                   4534:                                    sem_post((*s_etat_processus)
                   4535:                                            .semaphore_fork);
                   4536:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4537:                                            .semaphore_fork,
1.124     bertrand 4538:                                            getpid(), pthread_self(), SEM_FORK);
                   4539: #                              endif
                   4540: 
                   4541:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4542:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4543: 
                   4544: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4545:                                    stackoverflow_deinstall_handler();
                   4546: #                              endif
                   4547: 
                   4548: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4549:                                    if (debug == d_faux)
                   4550:                                    {
                   4551:                                        sigsegv_deinstall_handler();
                   4552:                                    }
                   4553: #                              endif
                   4554: 
1.1       bertrand 4555:                                erreur = d_es_allocation_memoire;
                   4556: 
                   4557:                                if ((*s_etat_processus).langue == 'F')
                   4558:                                {
                   4559:                                    printf("+++Système : Mémoire "
                   4560:                                            "insuffisante\n");
                   4561:                                }
                   4562:                                else
                   4563:                                {
                   4564:                                    printf("+++System : Not enough "
                   4565:                                            "memory\n");
                   4566:                                }
                   4567: 
                   4568:                                return(EXIT_FAILURE);
                   4569:                            }
                   4570: 
                   4571:                            printf("%s [%d]\n", message, (int) getpid());
                   4572:                            free(message);
                   4573: 
                   4574:                            return(EXIT_FAILURE);
                   4575:                        }
                   4576:                    }
                   4577: 
                   4578:                    fflush(stdout);
                   4579: 
                   4580:                    if (arguments != NULL)
                   4581:                    {
                   4582:                        tampon = (*s_etat_processus).definitions_chainees;
                   4583:                        (*s_etat_processus).definitions_chainees =
                   4584:                                arguments;
                   4585: 
                   4586:                        if (analyse_syntaxique(s_etat_processus) ==
                   4587:                                d_erreur)
                   4588:                        {
                   4589:                            if ((*s_etat_processus).erreur_systeme != d_es)
                   4590:                            {
1.124     bertrand 4591: #                              ifndef SEMAPHORES_NOMMES
                   4592:                                    sem_post(&((*s_etat_processus)
                   4593:                                            .semaphore_fork));
                   4594:                                    sem_destroy(&((*s_etat_processus)
                   4595:                                            .semaphore_fork));
                   4596: #                              else
                   4597:                                    sem_post((*s_etat_processus)
                   4598:                                            .semaphore_fork);
                   4599:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4600:                                            .semaphore_fork,
1.124     bertrand 4601:                                            getpid(), pthread_self(), SEM_FORK);
                   4602: #                              endif
                   4603: 
                   4604:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4605:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4606: 
                   4607: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4608:                                    stackoverflow_deinstall_handler();
                   4609: #                              endif
                   4610: 
                   4611: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4612:                                    if (debug == d_faux)
                   4613:                                    {
                   4614:                                        sigsegv_deinstall_handler();
                   4615:                                    }
                   4616: #                              endif
                   4617: 
1.1       bertrand 4618:                                erreur = d_es_allocation_memoire;
                   4619: 
                   4620:                                if ((*s_etat_processus).langue == 'F')
                   4621:                                {
                   4622:                                    printf("+++Système : Mémoire "
                   4623:                                            "insuffisante\n");
                   4624:                                }
                   4625:                                else
                   4626:                                {
                   4627:                                    printf("+++System : Not enough "
                   4628:                                            "memory\n");
                   4629:                                }
                   4630: 
                   4631:                                return(EXIT_FAILURE);
                   4632:                            }
                   4633:                            else
                   4634:                            {
1.124     bertrand 4635: #                              ifndef SEMAPHORES_NOMMES
                   4636:                                    sem_post(&((*s_etat_processus)
                   4637:                                            .semaphore_fork));
                   4638:                                    sem_destroy(&((*s_etat_processus)
                   4639:                                            .semaphore_fork));
                   4640: #                              else
                   4641:                                    sem_post((*s_etat_processus)
                   4642:                                            .semaphore_fork);
                   4643:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4644:                                            .semaphore_fork,
1.124     bertrand 4645:                                            getpid(), pthread_self(), SEM_FORK);
                   4646: #                              endif
                   4647: 
                   4648:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4649:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4650: 
                   4651: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4652:                                    stackoverflow_deinstall_handler();
                   4653: #                              endif
                   4654: 
                   4655: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4656:                                    if (debug == d_faux)
                   4657:                                    {
                   4658:                                        sigsegv_deinstall_handler();
                   4659:                                    }
                   4660: #                              endif
                   4661: 
1.1       bertrand 4662:                                if ((*s_etat_processus).langue == 'F')
                   4663:                                {
                   4664:                                    printf("+++Erreur : Erreur de "
                   4665:                                            "syntaxe\n");
                   4666:                                }
                   4667:                                else
                   4668:                                {
                   4669:                                    printf("+++Error : Syntax error\n");
                   4670:                                }
                   4671: 
                   4672:                                return(EXIT_FAILURE);
                   4673:                            }
                   4674:                        }
                   4675: 
                   4676:                        (*s_etat_processus).instruction_courante
                   4677:                                = arguments;
                   4678:                        (*s_etat_processus).definitions_chainees = tampon;
                   4679:                        (*s_etat_processus).position_courante = 0;
                   4680: 
1.160     bertrand 4681:                        (*s_etat_processus).type_en_cours = NON;
1.1       bertrand 4682:                        recherche_type(s_etat_processus);
                   4683: 
                   4684:                        if ((*s_etat_processus).erreur_systeme != d_es)
                   4685:                        {
1.124     bertrand 4686: #                          ifndef SEMAPHORES_NOMMES
                   4687:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4688:                                sem_destroy(&((*s_etat_processus)
                   4689:                                        .semaphore_fork));
                   4690: #                          else
                   4691:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4692:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4693:                                        getpid(), pthread_self(), SEM_FORK);
                   4694: #                          endif
                   4695: 
                   4696:                            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4697:                            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4698: 
                   4699: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4700:                                stackoverflow_deinstall_handler();
                   4701: #                          endif
                   4702: 
                   4703: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4704:                                if (debug == d_faux)
                   4705:                                {
                   4706:                                    sigsegv_deinstall_handler();
                   4707:                                }
                   4708: #                          endif
                   4709: 
1.1       bertrand 4710:                            if ((message = messages(s_etat_processus))
                   4711:                                    == NULL)
                   4712:                            {
                   4713:                                erreur = d_es_allocation_memoire;
                   4714: 
                   4715:                                if ((*s_etat_processus).langue == 'F')
                   4716:                                {
                   4717:                                    printf("+++Système : Mémoire "
                   4718:                                            "insuffisante\n");
                   4719:                                }
                   4720:                                else
                   4721:                                {
                   4722:                                    printf("+++System : Not enough "
                   4723:                                            "memory\n");
                   4724:                                }
                   4725: 
                   4726:                                return(EXIT_FAILURE);
                   4727:                            }
                   4728: 
                   4729:                            printf("%s [%d]\n", message, (int) getpid());
                   4730:                            free(message);
                   4731: 
                   4732:                            return(EXIT_FAILURE);
                   4733:                        }
                   4734: 
                   4735:                        if ((*s_etat_processus).erreur_execution != d_ex)
                   4736:                        {
                   4737:                            if ((message = messages(s_etat_processus))
                   4738:                                    == NULL)
                   4739:                            {
1.124     bertrand 4740: #                              ifndef SEMAPHORES_NOMMES
                   4741:                                    sem_post(&((*s_etat_processus)
                   4742:                                            .semaphore_fork));
                   4743:                                    sem_destroy(&((*s_etat_processus)
                   4744:                                            .semaphore_fork));
                   4745: #                              else
                   4746:                                    sem_post((*s_etat_processus)
                   4747:                                            .semaphore_fork);
                   4748:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4749:                                            .semaphore_fork,
1.124     bertrand 4750:                                            getpid(), pthread_self(), SEM_FORK);
                   4751: #                              endif
                   4752: 
                   4753:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4754:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4755: 
                   4756: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4757:                                    stackoverflow_deinstall_handler();
                   4758: #                              endif
                   4759: 
                   4760: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4761:                                    if (debug == d_faux)
                   4762:                                    {
                   4763:                                        sigsegv_deinstall_handler();
                   4764:                                    }
                   4765: #                              endif
                   4766: 
1.1       bertrand 4767:                                erreur = d_es_allocation_memoire;
                   4768: 
                   4769:                                if ((*s_etat_processus).langue == 'F')
                   4770:                                {
                   4771:                                    printf("+++Erreur : Mémoire "
                   4772:                                            "insuffisante\n");
                   4773:                                }
                   4774:                                else
                   4775:                                {
                   4776:                                    printf("+++Error : Not enough "
                   4777:                                            "memory\n");
                   4778:                                }
                   4779: 
                   4780:                                return(EXIT_FAILURE);
                   4781:                            }
                   4782: 
                   4783:                            printf("%s [%d]\n", message, (int) getpid());
                   4784:                            free(message);
                   4785: 
1.124     bertrand 4786: #                          ifndef SEMAPHORES_NOMMES
                   4787:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4788:                                sem_destroy(&((*s_etat_processus)
                   4789:                                        .semaphore_fork));
                   4790: #                          else
                   4791:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4792:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4793:                                        getpid(), pthread_self(), SEM_FORK);
                   4794: #                          endif
                   4795: 
                   4796:                            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4797:                            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4798: 
                   4799: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4800:                                stackoverflow_deinstall_handler();
                   4801: #                          endif
                   4802: 
                   4803: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4804:                                if (debug == d_faux)
                   4805:                                {
                   4806:                                    sigsegv_deinstall_handler();
                   4807:                                }
                   4808: #                          endif
                   4809: 
1.1       bertrand 4810:                            return(EXIT_FAILURE);
                   4811:                        }
                   4812: 
                   4813:                        if (depilement(s_etat_processus,
                   4814:                                &((*s_etat_processus).l_base_pile),
                   4815:                                &s_objet) == d_erreur)
                   4816:                        {
                   4817:                            if ((message = messages(s_etat_processus))
                   4818:                                    == NULL)
                   4819:                            {
1.124     bertrand 4820: #                              ifndef SEMAPHORES_NOMMES
                   4821:                                    sem_post(&((*s_etat_processus)
                   4822:                                            .semaphore_fork));
                   4823:                                    sem_destroy(&((*s_etat_processus)
                   4824:                                            .semaphore_fork));
                   4825: #                              else
                   4826:                                    sem_post((*s_etat_processus)
                   4827:                                            .semaphore_fork);
                   4828:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4829:                                            .semaphore_fork,
1.124     bertrand 4830:                                            getpid(), pthread_self(), SEM_FORK);
                   4831: #                              endif
                   4832: 
                   4833:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4834:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4835: 
                   4836: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4837:                                    stackoverflow_deinstall_handler();
                   4838: #                              endif
                   4839: 
                   4840: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4841:                                    if (debug == d_faux)
                   4842:                                    {
                   4843:                                        sigsegv_deinstall_handler();
                   4844:                                    }
                   4845: #                              endif
                   4846: 
                   4847:                                erreur = d_es_allocation_memoire;
1.1       bertrand 4848:                                erreur = d_es_allocation_memoire;
                   4849: 
                   4850:                                if ((*s_etat_processus).langue == 'F')
                   4851:                                {
                   4852:                                    printf("+++Erreur : Mémoire "
                   4853:                                            "insuffisante\n");
                   4854:                                }
                   4855:                                else
                   4856:                                {
                   4857:                                    printf("+++Error : Not enough "
                   4858:                                            "memory\n");
                   4859:                                }
                   4860: 
                   4861:                                return(EXIT_FAILURE);
                   4862:                            }
                   4863: 
                   4864:                            printf("%s [%d]\n", message, (int) getpid());
                   4865:                            free(message);
                   4866: 
1.124     bertrand 4867: #                          ifndef SEMAPHORES_NOMMES
                   4868:                                sem_post(&((*s_etat_processus).semaphore_fork));
                   4869:                                sem_destroy(&((*s_etat_processus)
                   4870:                                        .semaphore_fork));
                   4871: #                          else
                   4872:                                sem_post((*s_etat_processus).semaphore_fork);
1.155     bertrand 4873:                                sem_destroy3((*s_etat_processus).semaphore_fork,
1.124     bertrand 4874:                                        getpid(), pthread_self(), SEM_FORK);
                   4875: #                          endif
                   4876: 
                   4877:                            liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4878:                            destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4879: 
                   4880: #                          ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4881:                                stackoverflow_deinstall_handler();
                   4882: #                          endif
                   4883: 
                   4884: #                          ifdef HAVE_SIGSEGV_RECOVERY
                   4885:                                if (debug == d_faux)
                   4886:                                {
                   4887:                                    sigsegv_deinstall_handler();
                   4888:                                }
                   4889: #                          endif
                   4890: 
1.1       bertrand 4891:                            return(EXIT_FAILURE);
                   4892:                        }
                   4893: 
1.142     bertrand 4894:                        empilement_pile_systeme(s_etat_processus);
                   4895: 
1.1       bertrand 4896:                        if (evaluation(s_etat_processus, s_objet, 'E')
                   4897:                                == d_erreur)
                   4898:                        {
                   4899:                            if ((*s_etat_processus).erreur_systeme != d_es)
                   4900:                            {
                   4901:                                if ((message = messages(s_etat_processus))
                   4902:                                        == NULL)
                   4903:                                {
1.124     bertrand 4904: #                                  ifndef SEMAPHORES_NOMMES
                   4905:                                        sem_post(&((*s_etat_processus)
                   4906:                                                .semaphore_fork));
                   4907:                                        sem_destroy(&((*s_etat_processus)
                   4908:                                                .semaphore_fork));
                   4909: #                                  else
                   4910:                                        sem_post((*s_etat_processus)
                   4911:                                                .semaphore_fork);
                   4912:                                        sem_destroy3((*s_etat_processus)
1.155     bertrand 4913:                                                .semaphore_fork, getpid(),
1.124     bertrand 4914:                                                pthread_self(), SEM_FORK);
                   4915: #                                  endif
                   4916: 
                   4917:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4918:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4919: 
                   4920: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4921:                                        stackoverflow_deinstall_handler();
                   4922: #                                  endif
                   4923: 
                   4924: #                                  ifdef HAVE_SIGSEGV_RECOVERY
                   4925:                                        if (debug == d_faux)
                   4926:                                        {
                   4927:                                            sigsegv_deinstall_handler();
                   4928:                                        }
                   4929: #                                  endif
                   4930: 
1.1       bertrand 4931:                                    erreur = d_es_allocation_memoire;
                   4932: 
                   4933:                                    if ((*s_etat_processus).langue == 'F')
                   4934:                                    {
                   4935:                                        printf("+++Système : Mémoire "
                   4936:                                                "insuffisante\n");
                   4937:                                    }
                   4938:                                    else
                   4939:                                    {
                   4940:                                        printf("+++System : Not enough "
                   4941:                                                "memory\n");
                   4942:                                    }
                   4943: 
                   4944:                                    return(EXIT_FAILURE);
                   4945:                                }
                   4946: 
                   4947:                                printf("%s [%d]\n", message,
                   4948:                                        (int) getpid());
                   4949:                                free(message);
                   4950: 
1.124     bertrand 4951: #                              ifndef SEMAPHORES_NOMMES
                   4952:                                    sem_post(&((*s_etat_processus)
                   4953:                                            .semaphore_fork));
                   4954:                                    sem_destroy(&((*s_etat_processus)
                   4955:                                            .semaphore_fork));
                   4956: #                              else
                   4957:                                    sem_post((*s_etat_processus)
                   4958:                                            .semaphore_fork);
                   4959:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 4960:                                            .semaphore_fork,
1.124     bertrand 4961:                                            getpid(), pthread_self(), SEM_FORK);
                   4962: #                              endif
                   4963: 
                   4964:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 4965:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 4966: 
                   4967: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   4968:                                    stackoverflow_deinstall_handler();
                   4969: #                              endif
                   4970: 
                   4971: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   4972:                                    if (debug == d_faux)
                   4973:                                    {
                   4974:                                        sigsegv_deinstall_handler();
                   4975:                                    }
                   4976: #                              endif
                   4977: 
                   4978:                                erreur = d_es_allocation_memoire;
1.1       bertrand 4979:                                return(EXIT_FAILURE);
                   4980:                            }
                   4981: 
                   4982:                            if ((*s_etat_processus).erreur_execution
                   4983:                                    != d_ex)
                   4984:                            {
                   4985:                                if ((message = messages(s_etat_processus))
                   4986:                                        == NULL)
                   4987:                                {
1.124     bertrand 4988: #                                  ifndef SEMAPHORES_NOMMES
                   4989:                                        sem_post(&((*s_etat_processus)
                   4990:                                                .semaphore_fork));
                   4991:                                        sem_destroy(&((*s_etat_processus)
                   4992:                                                .semaphore_fork));
                   4993: #                                  else
                   4994:                                        sem_post((*s_etat_processus)
                   4995:                                                .semaphore_fork);
                   4996:                                        sem_destroy3((*s_etat_processus)
1.155     bertrand 4997:                                                .semaphore_fork, getpid(),
1.124     bertrand 4998:                                                pthread_self(), SEM_FORK);
                   4999: #                                  endif
                   5000: 
                   5001:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 5002:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 5003: 
                   5004: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   5005:                                        stackoverflow_deinstall_handler();
                   5006: #                                  endif
                   5007: 
                   5008: #                                  ifdef HAVE_SIGSEGV_RECOVERY
                   5009:                                        if (debug == d_faux)
                   5010:                                        {
                   5011:                                            sigsegv_deinstall_handler();
                   5012:                                        }
                   5013: #                                  endif
                   5014: 
1.1       bertrand 5015:                                    erreur = d_es_allocation_memoire;
                   5016: 
                   5017:                                    if ((*s_etat_processus).langue == 'F')
                   5018:                                    {
                   5019:                                        printf("+++Erreur : Mémoire "
                   5020:                                                "insuffisante\n");
                   5021:                                    }
                   5022:                                    else
                   5023:                                    {
                   5024:                                        printf("+++Error : Not enough "
                   5025:                                                "memory\n");
                   5026:                                    }
                   5027: 
                   5028:                                    return(EXIT_FAILURE);
                   5029:                                }
                   5030: 
                   5031:                                printf("%s [%d]\n", message,
                   5032:                                        (int) getpid());
                   5033:                                free(message);
                   5034: 
1.124     bertrand 5035: #                              ifndef SEMAPHORES_NOMMES
                   5036:                                    sem_post(&((*s_etat_processus)
                   5037:                                            .semaphore_fork));
                   5038:                                    sem_destroy(&((*s_etat_processus)
                   5039:                                            .semaphore_fork));
                   5040: #                              else
                   5041:                                    sem_post((*s_etat_processus)
                   5042:                                            .semaphore_fork);
                   5043:                                    sem_destroy3((*s_etat_processus)
1.155     bertrand 5044:                                            .semaphore_fork,
1.124     bertrand 5045:                                            getpid(), pthread_self(), SEM_FORK);
                   5046: #                              endif
                   5047: 
                   5048:                                liberation_contexte_cas(s_etat_processus);
1.161     bertrand 5049:                                destruction_queue_signaux(s_etat_processus);
1.124     bertrand 5050: 
                   5051: #                              ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   5052:                                    stackoverflow_deinstall_handler();
                   5053: #                              endif
                   5054: 
                   5055: #                              ifdef HAVE_SIGSEGV_RECOVERY
                   5056:                                    if (debug == d_faux)
                   5057:                                    {
                   5058:                                        sigsegv_deinstall_handler();
                   5059:                                    }
                   5060: #                              endif
                   5061: 
1.1       bertrand 5062:                                return(EXIT_FAILURE);
                   5063:                            }
                   5064:                        }
                   5065: 
                   5066:                        (*s_etat_processus).instruction_courante = NULL;
                   5067:                        liberation(s_etat_processus, s_objet);
                   5068: 
                   5069:                        free(arguments);
                   5070:                    }
                   5071: 
1.13      bertrand 5072:                    if (option_a == d_vrai)
1.1       bertrand 5073:                    {
1.13      bertrand 5074:                        fprintf(stdout, "%s\n", (*s_etat_processus)
                   5075:                                .definitions_chainees);
1.1       bertrand 5076:                    }
1.13      bertrand 5077:                    else
                   5078:                    {
                   5079:                        if (option_D == d_vrai)
                   5080:                        {
                   5081:                            lancement_daemon(s_etat_processus);
                   5082:                        }
1.1       bertrand 5083: 
1.13      bertrand 5084:                        if (option_p == d_faux)
1.1       bertrand 5085:                        {
1.13      bertrand 5086:                            if (setjmp(contexte_initial) == 0)
                   5087:                            {
                   5088:                                erreur = sequenceur(s_etat_processus);
1.80      bertrand 5089: 
                   5090:                                if (erreur == d_absence_erreur)
                   5091:                                {
1.138     bertrand 5092:                                    if (((*s_etat_processus)
1.80      bertrand 5093:                                            .arret_depuis_abort == 0) &&
                   5094:                                            ((*s_etat_processus).at_exit
                   5095:                                            != NULL))
                   5096:                                    {
1.138     bertrand 5097:                                        // Permet de traiter ATEXIT
                   5098:                                        // même après réception d'un SIGINT.
                   5099:                                        (*s_etat_processus)
                   5100:                                                .var_volatile_alarme = 0;
                   5101:                                        (*s_etat_processus)
                   5102:                                                .var_volatile_requete_arret = 0;
                   5103: 
1.139     bertrand 5104:                                        if ((*s_etat_processus).profilage ==
                   5105:                                                d_vrai)
                   5106:                                        {
                   5107:                                            profilage(s_etat_processus,
                   5108:                                                    "ATEXIT");
                   5109:                                        }
                   5110: 
1.80      bertrand 5111:                                        erreur = evaluation(s_etat_processus,
                   5112:                                                (*s_etat_processus).at_exit,
                   5113:                                                'E');
1.139     bertrand 5114: 
                   5115:                                        if ((*s_etat_processus).profilage ==
                   5116:                                                d_vrai)
                   5117:                                        {
                   5118:                                            profilage(s_etat_processus, NULL);
                   5119:                                        }
                   5120: 
                   5121:                                        if (((*s_etat_processus)
                   5122:                                                .erreur_execution != d_ex) ||
                   5123:                                                ((*s_etat_processus).exception
                   5124:                                                != d_ep) || ((*s_etat_processus)
                   5125:                                                .erreur_systeme != d_es))
                   5126:                                        {
                   5127:                                            printf("%s [%d]\n", message =
                   5128:                                                    messages(s_etat_processus),
                   5129:                                                    (int) getpid());
                   5130:                                            free(message);
                   5131: 
                   5132:                                            if (test_cfsf(s_etat_processus, 51)
                   5133:                                                    == d_faux)
                   5134:                                            {
                   5135:                                                printf("%s", ds_beep);
                   5136:                                            }
                   5137: 
                   5138:                                            if ((*s_etat_processus).core ==
                   5139:                                                    d_vrai)
                   5140:                                            {
                   5141:                                                printf("\n");
                   5142: 
                   5143:                                                if ((*s_etat_processus).langue
                   5144:                                                        == 'F')
                   5145:                                                {
                   5146:                                                    printf("+++Information : Gé"
                   5147:                                                            "nération du fichie"
                   5148:                                                            "r rpl-core "
                   5149:                                                            "[%d]\n", (int)
                   5150:                                                            getpid());
                   5151:                                                }
                   5152:                                                else
                   5153:                                                {
                   5154:                                                    printf("+++Information : Wr"
                   5155:                                                            "iting rpl-core fil"
                   5156:                                                            "e [%d]\n",
                   5157:                                                            (int) getpid());
                   5158:                                                }
                   5159: 
                   5160:                                                rplcore(s_etat_processus);
                   5161: 
                   5162:                                                if ((*s_etat_processus).langue
                   5163:                                                        == 'F')
                   5164:                                                {
                   5165:                                                    printf("+++Information : Pr"
                   5166:                                                            "ocessus tracé [%d]"
                   5167:                                                            "\n",
                   5168:                                                            (int) getpid());
                   5169:                                                }
                   5170:                                                else
                   5171:                                                {
                   5172:                                                    printf("+++Information : Do"
                   5173:                                                            "ne [%d]\n", (int)
                   5174:                                                            getpid());
                   5175:                                                }
                   5176: 
                   5177:                                                printf("\n");
                   5178:                                                fflush(stdout);
                   5179:                                            }
                   5180:                                        }
1.80      bertrand 5181:                                    }
                   5182:                                }
1.13      bertrand 5183:                            }
1.1       bertrand 5184:                        }
1.13      bertrand 5185:                        else
1.1       bertrand 5186:                        {
1.13      bertrand 5187:                            if (setjmp(contexte_initial) == 0)
                   5188:                            {
1.195     bertrand 5189:                                erreur = sequenceur_optimise(s_etat_processus,
                   5190:                                        l_bibliotheques);
1.19      bertrand 5191: 
1.80      bertrand 5192:                                if (erreur == d_absence_erreur)
                   5193:                                {
1.138     bertrand 5194:                                    if (((*s_etat_processus)
1.80      bertrand 5195:                                            .arret_depuis_abort == 0) &&
                   5196:                                            ((*s_etat_processus).at_exit
                   5197:                                            != NULL))
                   5198:                                    {
1.138     bertrand 5199:                                        // Permet de traiter ATEXIT
                   5200:                                        // même après réception d'un SIGINT.
                   5201:                                        (*s_etat_processus)
                   5202:                                                .var_volatile_alarme = 0;
                   5203:                                        (*s_etat_processus)
                   5204:                                                .var_volatile_requete_arret = 0;
                   5205: 
1.139     bertrand 5206:                                        if ((*s_etat_processus).profilage ==
                   5207:                                                d_vrai)
                   5208:                                        {
                   5209:                                            profilage(s_etat_processus,
                   5210:                                                    "ATEXIT");
                   5211:                                        }
                   5212: 
1.80      bertrand 5213:                                        erreur = evaluation(s_etat_processus,
                   5214:                                                (*s_etat_processus).at_exit,
                   5215:                                                'E');
1.139     bertrand 5216: 
                   5217:                                        if ((*s_etat_processus).profilage ==
                   5218:                                                d_vrai)
                   5219:                                        {
                   5220:                                            profilage(s_etat_processus, NULL);
                   5221:                                        }
                   5222: 
                   5223:                                        if (((*s_etat_processus)
                   5224:                                                .erreur_execution != d_ex) ||
                   5225:                                                ((*s_etat_processus).exception
                   5226:                                                != d_ep) || ((*s_etat_processus)
                   5227:                                                .erreur_systeme != d_es))
                   5228:                                        {
                   5229:                                            printf("%s [%d]\n", message =
                   5230:                                                    messages(s_etat_processus),
                   5231:                                                    (int) getpid());
                   5232:                                            free(message);
                   5233: 
                   5234:                                            if (test_cfsf(s_etat_processus, 51)
                   5235:                                                    == d_faux)
                   5236:                                            {
                   5237:                                                printf("%s", ds_beep);
                   5238:                                            }
                   5239: 
                   5240:                                            if ((*s_etat_processus).core ==
                   5241:                                                    d_vrai)
                   5242:                                            {
                   5243:                                                printf("\n");
                   5244: 
                   5245:                                                if ((*s_etat_processus).langue
                   5246:                                                        == 'F')
                   5247:                                                {
                   5248:                                                    printf("+++Information : Gé"
                   5249:                                                            "nération du fichie"
                   5250:                                                            "r rpl-core "
                   5251:                                                            "[%d]\n", (int)
                   5252:                                                            getpid());
                   5253:                                                }
                   5254:                                                else
                   5255:                                                {
                   5256:                                                    printf("+++Information : Wr"
                   5257:                                                            "iting rpl-core fil"
                   5258:                                                            "e [%d]\n",
                   5259:                                                            (int) getpid());
                   5260:                                                }
                   5261: 
                   5262:                                                rplcore(s_etat_processus);
                   5263: 
                   5264:                                                if ((*s_etat_processus).langue
                   5265:                                                        == 'F')
                   5266:                                                {
                   5267:                                                    printf("+++Information : Pr"
                   5268:                                                            "ocessus tracé [%d]"
                   5269:                                                            "\n",
                   5270:                                                            (int) getpid());
                   5271:                                                }
                   5272:                                                else
                   5273:                                                {
                   5274:                                                    printf("+++Information : Do"
                   5275:                                                            "ne [%d]\n", (int)
                   5276:                                                            getpid());
                   5277:                                                }
                   5278: 
                   5279:                                                printf("\n");
                   5280:                                                fflush(stdout);
                   5281:                                            }
                   5282:                                        }
1.80      bertrand 5283:                                    }
                   5284:                                }
1.21      bertrand 5285:                            }
1.19      bertrand 5286:                        }
1.34      bertrand 5287:                    }
1.19      bertrand 5288: 
1.117     bertrand 5289:                    for(i = 0; i < (*s_etat_processus).sections_critiques; i++)
                   5290:                    {
                   5291:                        pthread_mutex_unlock(&mutex_sections_critiques);
                   5292:                    }
                   5293: 
1.34      bertrand 5294:                    liberation(s_etat_processus, (*s_etat_processus).at_exit);
                   5295:                    liberation(s_etat_processus, (*s_etat_processus).at_poke);
1.1       bertrand 5296: 
                   5297:                    if ((*s_etat_processus).generateur_aleatoire != NULL)
                   5298:                    {
                   5299:                        liberation_generateur_aleatoire(s_etat_processus);
                   5300:                    }
                   5301: 
                   5302:                    l_element_courant = (*s_etat_processus).liste_mutexes;
                   5303:                    while(l_element_courant != NULL)
                   5304:                    {
                   5305:                        liberation(s_etat_processus,
                   5306:                                (*((struct_liste_chainee *)
                   5307:                                l_element_courant)).donnee);
                   5308:                        l_element_suivant = (*((struct_liste_chainee *)
                   5309:                                l_element_courant)).suivant;
                   5310:                        free((struct_liste_chainee *) l_element_courant);
                   5311:                        l_element_courant = l_element_suivant;
                   5312:                    }
                   5313: 
                   5314:                    /*
                   5315:                     * Arrêt des processus fils
                   5316:                     */
                   5317: 
                   5318:                    if ((*s_etat_processus).presence_fusible == d_vrai)
                   5319:                    {
                   5320:                        pthread_cancel((*s_etat_processus).thread_fusible);
                   5321:                    }
                   5322: 
1.146     bertrand 5323:                    pthread_mutex_lock(&((*s_etat_processus)
                   5324:                            .mutex_pile_processus));
1.1       bertrand 5325: 
                   5326:                    l_element_courant = (void *) (*s_etat_processus)
                   5327:                            .l_base_pile_processus;
                   5328: 
                   5329:                    while(l_element_courant != NULL)
                   5330:                    {
                   5331:                        if ((*s_etat_processus).debug == d_vrai)
                   5332:                        {
                   5333:                            if (((*s_etat_processus).type_debug &
                   5334:                                    d_debug_processus) != 0)
                   5335:                            {
                   5336:                                if ((*(*((struct_processus_fils *)
                   5337:                                        (*(*((struct_liste_chainee *)
                   5338:                                        l_element_courant)).donnee)
                   5339:                                        .objet)).thread)
                   5340:                                        .processus_detache == d_vrai)
                   5341:                                {
                   5342:                                    if ((*s_etat_processus).langue == 'F')
                   5343:                                    {
                   5344:                                        printf("[%d] Signalement pour arrêt du "
                   5345:                                                "processus %d\n",
                   5346:                                                (int) getpid(), (int)
                   5347:                                                (*(*((struct_processus_fils *)
                   5348:                                                (*(*((struct_liste_chainee *)
                   5349:                                                l_element_courant)).donnee)
                   5350:                                                .objet)).thread).pid);
                   5351:                                    }
                   5352:                                    else
                   5353:                                    {
                   5354:                                        printf("[%d] Send stop signal to "
                   5355:                                                "process %d\n",
                   5356:                                                (int) getpid(), (int)
                   5357:                                                (*(*((struct_processus_fils *)
                   5358:                                                (*(*((struct_liste_chainee *)
                   5359:                                                l_element_courant)).donnee)
                   5360:                                                .objet)).thread).pid);
                   5361:                                    }
                   5362:                                }
                   5363:                                else
                   5364:                                {
                   5365:                                    if ((*s_etat_processus).langue == 'F')
                   5366:                                    {
                   5367:                                        printf("[%d] Signalement pour arrêt du "
                   5368:                                                "thread %llu\n", (int) getpid(),
                   5369:                                                (unsigned long long)
                   5370:                                                (*(*((struct_processus_fils *)
                   5371:                                                (*(*((struct_liste_chainee *)
                   5372:                                                l_element_courant)).donnee)
                   5373:                                                .objet)).thread).tid);
                   5374:                                    }
                   5375:                                    else
                   5376:                                    {
                   5377:                                        printf("[%d] Send stop signal to "
                   5378:                                                "thread %llu\n",
                   5379:                                                (int) getpid(),
                   5380:                                                (unsigned long long)
                   5381:                                                (*(*((struct_processus_fils *)
                   5382:                                                (*(*((struct_liste_chainee *)
                   5383:                                                l_element_courant)).donnee)
                   5384:                                                .objet)).thread).tid);
                   5385:                                    }
                   5386:                                }
                   5387:                            }
                   5388:                        }
                   5389: 
                   5390:                        if ((*(*((struct_processus_fils *)
                   5391:                                (*(*((struct_liste_chainee *)
                   5392:                                l_element_courant)).donnee).objet))
                   5393:                                .thread).processus_detache == d_vrai)
                   5394:                        {
                   5395:                            if ((*s_etat_processus).var_volatile_alarme != 0)
                   5396:                            {
1.83      bertrand 5397:                                envoi_signal_processus(
                   5398:                                        (*(*((struct_processus_fils *)
1.1       bertrand 5399:                                        (*(*((struct_liste_chainee *)
                   5400:                                        l_element_courant)).donnee).objet))
1.180     bertrand 5401:                                        .thread).pid, rpl_sigurg, d_faux);
1.1       bertrand 5402:                            }
                   5403:                            else
                   5404:                            {
1.22      bertrand 5405:                                if ((*s_etat_processus).arret_depuis_abort
                   5406:                                        == -1)
                   5407:                                {
1.83      bertrand 5408:                                    envoi_signal_processus(
                   5409:                                            (*(*((struct_processus_fils *)
1.22      bertrand 5410:                                            (*(*((struct_liste_chainee *)
                   5411:                                            l_element_courant)).donnee).objet))
1.180     bertrand 5412:                                            .thread).pid, rpl_sigabort, d_faux);
1.22      bertrand 5413:                                }
                   5414:                                else
                   5415:                                {
1.83      bertrand 5416:                                    envoi_signal_processus(
                   5417:                                            (*(*((struct_processus_fils *)
1.22      bertrand 5418:                                            (*(*((struct_liste_chainee *)
                   5419:                                            l_element_courant)).donnee).objet))
1.180     bertrand 5420:                                            .thread).pid, rpl_sigstop, d_faux);
1.22      bertrand 5421:                                }
1.1       bertrand 5422:                            }
                   5423:                        }
                   5424:                        else
                   5425:                        {
                   5426:                            pthread_mutex_lock(&((*(*((struct_processus_fils *)
                   5427:                                    (*(*((struct_liste_chainee *)
                   5428:                                    l_element_courant)).donnee).objet)).thread)
                   5429:                                    .mutex));
                   5430: 
                   5431:                            if ((*(*((struct_processus_fils *)
                   5432:                                    (*(*((struct_liste_chainee *)
                   5433:                                    l_element_courant)).donnee).objet)).thread)
                   5434:                                    .thread_actif == d_vrai)
                   5435:                            {
                   5436:                                if ((*s_etat_processus).var_volatile_alarme
                   5437:                                        != 0)
                   5438:                                {
1.83      bertrand 5439:                                    envoi_signal_thread(
                   5440:                                            (*(*((struct_processus_fils *)
1.1       bertrand 5441:                                            (*(*((struct_liste_chainee *)
                   5442:                                            l_element_courant)).donnee).objet))
1.83      bertrand 5443:                                            .thread).tid, rpl_sigurg);
1.1       bertrand 5444:                                }
                   5445:                                else
                   5446:                                {
1.22      bertrand 5447:                                    if ((*s_etat_processus).arret_depuis_abort
                   5448:                                            == -1)
                   5449:                                    {
1.83      bertrand 5450:                                        envoi_signal_thread(
1.22      bertrand 5451:                                                (*(*((struct_processus_fils *)
                   5452:                                                (*(*((struct_liste_chainee *)
                   5453:                                                l_element_courant)).donnee)
                   5454:                                                .objet)).thread).tid,
1.83      bertrand 5455:                                                rpl_sigabort);
1.22      bertrand 5456:                                    }
                   5457:                                    else
                   5458:                                    {
1.83      bertrand 5459:                                        envoi_signal_thread(
1.22      bertrand 5460:                                                (*(*((struct_processus_fils *)
                   5461:                                                (*(*((struct_liste_chainee *)
                   5462:                                                l_element_courant)).donnee)
                   5463:                                                .objet)).thread).tid,
1.83      bertrand 5464:                                                rpl_sigstop);
1.22      bertrand 5465:                                    }
1.1       bertrand 5466:                                }
                   5467:                            }
                   5468: 
                   5469:                            pthread_mutex_unlock(
                   5470:                                    &((*(*((struct_processus_fils *)
                   5471:                                    (*(*((struct_liste_chainee *)
                   5472:                                    l_element_courant)).donnee).objet)).thread)
                   5473:                                    .mutex));
                   5474:                        }
                   5475: 
                   5476:                        l_element_courant = (*((struct_liste_chainee *)
                   5477:                                l_element_courant)).suivant;
                   5478:                    }
                   5479: 
                   5480:                    /*
                   5481:                     * Attente de la fin de tous les processus fils
                   5482:                     */
                   5483: 
                   5484:                    for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
                   5485:                            (*s_etat_processus).masque_interruptions[i++]
                   5486:                            = 'I');
                   5487: 
                   5488:                    attente.tv_sec = 0;
                   5489:                    attente.tv_nsec = GRANULARITE_us * 1000;
                   5490: 
                   5491:                    while((*s_etat_processus).l_base_pile_processus != NULL)
                   5492:                    {
                   5493:                        l_element_courant = (void *)
                   5494:                                (*s_etat_processus).l_base_pile_processus;
                   5495: 
1.136     bertrand 5496:                        for(i = 0; i < (*(*((struct_processus_fils *)
1.1       bertrand 5497:                                (*(*((struct_liste_chainee *)
                   5498:                                l_element_courant)).donnee).objet)).thread)
                   5499:                                .nombre_objets_dans_pipe; i++)
                   5500:                        {
                   5501:                            if ((s_objet = lecture_pipe(
                   5502:                                    s_etat_processus,
                   5503:                                    (*(*((struct_processus_fils *)
                   5504:                                    (*(*((struct_liste_chainee *)
                   5505:                                    l_element_courant)).donnee).objet)).thread)
                   5506:                                    .pipe_objets[0])) != NULL)
                   5507:                            {
                   5508:                                liberation(s_etat_processus, s_objet);
                   5509: 
                   5510:                                (*(*((struct_processus_fils *)
                   5511:                                        (*(*((struct_liste_chainee *)
                   5512:                                        l_element_courant)).donnee).objet))
                   5513:                                        .thread).nombre_objets_dans_pipe--;
                   5514: 
                   5515:                                action.sa_handler = SIG_IGN;
1.94      bertrand 5516:                                action.sa_flags = 0;
1.1       bertrand 5517: 
                   5518:                                if (sigaction(SIGPIPE, &action, &registre)
                   5519:                                        != 0)
                   5520:                                {
1.124     bertrand 5521: #                                  ifndef SEMAPHORES_NOMMES
                   5522:                                        sem_post(&((*s_etat_processus)
                   5523:                                                .semaphore_fork));
                   5524:                                        sem_destroy(&((*s_etat_processus)
                   5525:                                                .semaphore_fork));
                   5526: #                                  else
                   5527:                                        sem_post((*s_etat_processus)
                   5528:                                                .semaphore_fork);
                   5529:                                        sem_destroy3((*s_etat_processus)
1.155     bertrand 5530:                                                .semaphore_fork, getpid(),
1.124     bertrand 5531:                                                pthread_self(), SEM_FORK);
                   5532: #                                  endif
                   5533: 
                   5534:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 5535:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 5536: 
                   5537: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   5538:                                        stackoverflow_deinstall_handler();
                   5539: #                                  endif
                   5540: 
                   5541: #                                  ifdef HAVE_SIGSEGV_RECOVERY
                   5542:                                        if (debug == d_faux)
                   5543:                                        {
                   5544:                                            sigsegv_deinstall_handler();
                   5545:                                        }
                   5546: #                                  endif
                   5547: 
1.146     bertrand 5548:                                    pthread_mutex_unlock(&((*s_etat_processus)
                   5549:                                            .mutex_pile_processus));
1.1       bertrand 5550:                                    return(EXIT_FAILURE);
                   5551:                                }
                   5552: 
                   5553:                                while((longueur_ecriture =
                   5554:                                        write_atomic(s_etat_processus,
                   5555:                                        (*(*((struct_processus_fils *)
                   5556:                                        (*(*((struct_liste_chainee *)
                   5557:                                        l_element_courant)).donnee).objet))
                   5558:                                        .thread).pipe_nombre_injections[1], "+",
                   5559:                                        sizeof(unsigned char))) !=
                   5560:                                        sizeof(unsigned char))
                   5561:                                {
                   5562:                                    if (longueur_ecriture == -1)
                   5563:                                    {
                   5564:                                        // Le processus n'existe plus.
                   5565:                                        break;
                   5566:                                    }
                   5567:                                }
                   5568: 
                   5569:                                if (sigaction(SIGPIPE, &registre, NULL)
                   5570:                                        != 0)
                   5571:                                {
1.124     bertrand 5572: #                                  ifndef SEMAPHORES_NOMMES
                   5573:                                        sem_post(&((*s_etat_processus)
                   5574:                                                .semaphore_fork));
                   5575:                                        sem_destroy(&((*s_etat_processus)
                   5576:                                                .semaphore_fork));
                   5577: #                                  else
                   5578:                                        sem_post((*s_etat_processus)
                   5579:                                                .semaphore_fork);
                   5580:                                        sem_destroy3((*s_etat_processus)
1.155     bertrand 5581:                                                .semaphore_fork, getpid(),
1.124     bertrand 5582:                                                pthread_self(), SEM_FORK);
                   5583: #                                  endif
                   5584: 
                   5585:                                    liberation_contexte_cas(s_etat_processus);
1.161     bertrand 5586:                                    destruction_queue_signaux(s_etat_processus);
1.124     bertrand 5587: 
                   5588: #                                  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   5589:                                        stackoverflow_deinstall_handler();
                   5590: #                                  endif
                   5591: 
                   5592: #                                  ifdef HAVE_SIGSEGV_RECOVERY
                   5593:                                        if (debug == d_faux)
                   5594:                                        {
                   5595:                                            sigsegv_deinstall_handler();
                   5596:                                        }
                   5597: #                                  endif
                   5598: 
1.146     bertrand 5599:                                    pthread_mutex_unlock(&((*s_etat_processus)
                   5600:                                            .mutex_pile_processus));
1.1       bertrand 5601:                                    return(EXIT_FAILURE);
                   5602:                                }
                   5603:                            }
                   5604:                        }
                   5605: 
1.145     bertrand 5606:                        pthread_mutex_lock(&((*s_etat_processus)
                   5607:                                .mutex_interruptions));
                   5608: 
1.23      bertrand 5609:                        if ((*s_etat_processus)
                   5610:                                .nombre_interruptions_non_affectees != 0)
                   5611:                        {
                   5612:                            affectation_interruptions_logicielles(
                   5613:                                    s_etat_processus);
                   5614:                        }
                   5615: 
1.145     bertrand 5616:                        pthread_mutex_unlock(&((*s_etat_processus)
                   5617:                                .mutex_interruptions));
1.146     bertrand 5618:                        pthread_mutex_unlock(&((*s_etat_processus)
                   5619:                                .mutex_pile_processus));
1.1       bertrand 5620:                        nanosleep(&attente, NULL);
1.85      bertrand 5621:                        scrutation_interruptions(s_etat_processus);
1.146     bertrand 5622:                        pthread_mutex_lock(&((*s_etat_processus)
                   5623:                                .mutex_pile_processus));
1.1       bertrand 5624:                    }
                   5625: 
1.146     bertrand 5626:                    pthread_mutex_unlock(&((*s_etat_processus)
                   5627:                            .mutex_pile_processus));
1.1       bertrand 5628: 
                   5629:                    erreur_historique = write_history(
                   5630:                            (*s_etat_processus).nom_fichier_historique);
                   5631:                    clear_history();
                   5632: 
                   5633:                    if (erreur_historique != 0)
                   5634:                    {
                   5635:                        if ((*s_etat_processus).langue == 'F')
                   5636:                        {
                   5637:                            printf("+++Erreur : L'historique ne peut être "
                   5638:                                    "écrit\n");
                   5639:                        }
                   5640:                        else
                   5641:                        {
                   5642:                            printf("+++Error : History cannot be "
                   5643:                                    "written\n");
                   5644:                        }
                   5645: 
                   5646:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   5647:                        {
                   5648:                            printf("%s", ds_beep);
                   5649:                        }
                   5650:                    }
                   5651: 
                   5652:                    free((*s_etat_processus).nom_fichier_historique);
                   5653: 
                   5654:                    if (((*s_etat_processus).core == d_vrai) &&
                   5655:                            (erreur == d_erreur) &&
                   5656:                            ((*s_etat_processus).var_volatile_traitement_sigint
                   5657:                            == 0))
                   5658:                    {
                   5659:                        printf("\n");
                   5660:                        
                   5661:                        if ((*s_etat_processus).langue == 'F')
                   5662:                        {
                   5663:                            printf("+++Information : Génération du fichier "
                   5664:                                    "rpl-core [%d]\n", (int) getpid());
                   5665:                        }
                   5666:                        else
                   5667:                        {
                   5668:                            printf("+++Information : Writing rpl-core "
                   5669:                                    "file [%d]\n", (int) getpid());
                   5670:                        }
                   5671: 
                   5672:                        rplcore(s_etat_processus);
                   5673: 
                   5674:                        if ((*s_etat_processus).langue == 'F')
                   5675:                        {
                   5676:                            printf("+++Information : Processus tracé [%d]\n",
                   5677:                                    (int) getpid());
                   5678:                        }
                   5679:                        else
                   5680:                        {
                   5681:                            printf("+++Information : Done [%d]\n",
                   5682:                                    (int) getpid());
                   5683:                        }
                   5684: 
                   5685:                        printf("\n");
                   5686:                    }
                   5687: 
                   5688:                    free((*s_etat_processus).definitions_chainees);
                   5689: 
                   5690:                    /*
                   5691:                     * Libération de l'arbre des instructions
                   5692:                     */
                   5693: 
                   5694:                    liberation_arbre_instructions(s_etat_processus,
                   5695:                            (*s_etat_processus).arbre_instructions);
                   5696:                    free((*s_etat_processus).pointeurs_caracteres);
                   5697: 
                   5698:                    if ((*s_etat_processus).entree_standard != NULL)
                   5699:                    {
                   5700:                        pclose((*s_etat_processus).entree_standard);
                   5701:                        (*s_etat_processus).entree_standard = NULL;
                   5702:                    }
                   5703: 
                   5704:                    if ((*s_etat_processus).nom_fichier_impression != NULL)
                   5705:                    {
                   5706:                        if (test_cfsf(s_etat_processus, 51) == d_faux)
                   5707:                        {
                   5708:                            printf("%s", ds_beep);
                   5709:                        }
                   5710: 
                   5711:                        if ((*s_etat_processus).langue == 'F')
                   5712:                        {
                   5713:                            printf("+++Attention : Queue d'impression "
                   5714:                                    "non vide !\n");
                   5715:                        }
                   5716:                        else
                   5717:                        {
                   5718:                            printf("+++Warning : Non empty printing "
                   5719:                                    "spool queue !\n");
                   5720:                        }
                   5721: 
                   5722:                        instruction_erase(s_etat_processus);
                   5723:                    }
                   5724: 
                   5725:                    if ((*s_etat_processus).fichiers_graphiques != NULL)
                   5726:                    {
                   5727:                        instruction_cllcd(s_etat_processus);
                   5728:                    }
                   5729: 
                   5730:                    liberation(s_etat_processus, (*s_etat_processus).indep);
                   5731:                    liberation(s_etat_processus, (*s_etat_processus).depend);
                   5732: 
                   5733:                    free((*s_etat_processus).label_x);
                   5734:                    free((*s_etat_processus).label_y);
                   5735:                    free((*s_etat_processus).label_z);
                   5736:                    free((*s_etat_processus).titre);
                   5737:                    free((*s_etat_processus).legende);
                   5738: 
                   5739:                    liberation(s_etat_processus, (*s_etat_processus)
                   5740:                            .parametres_courbes_de_niveau);
                   5741: 
                   5742:                    for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
                   5743:                    {
                   5744:                        liberation(s_etat_processus,
                   5745:                                (*s_etat_processus).corps_interruptions[i]);
                   5746: 
                   5747:                        l_element_courant = (*s_etat_processus)
                   5748:                                .pile_origine_interruptions[i];
                   5749: 
                   5750:                        while(l_element_courant != NULL)
                   5751:                        {
                   5752:                            l_element_suivant = (*((struct_liste_chainee *)
                   5753:                                    l_element_courant)).suivant;
                   5754: 
                   5755:                            liberation(s_etat_processus,
                   5756:                                    (*((struct_liste_chainee *)
                   5757:                                    l_element_courant)).donnee);
                   5758:                            free(l_element_courant);
                   5759: 
                   5760:                            l_element_courant = l_element_suivant;
                   5761:                        }
                   5762:                    }
                   5763: 
                   5764:                    if ((*s_etat_processus).instruction_derniere_erreur
                   5765:                            != NULL)
                   5766:                    {
                   5767:                        free((*s_etat_processus).instruction_derniere_erreur);
                   5768:                        (*s_etat_processus).instruction_derniere_erreur = NULL;
                   5769:                    }
                   5770: 
                   5771:                    /*
                   5772:                     * Le pointeur s_etat_processus.nom_fichier_source est
                   5773:                     * alloué par le système. Il ne faut donc pas
                   5774:                     * le libérer...
                   5775:                     */
                   5776: 
1.125     bertrand 5777:                    liberation_arbre_variables_partagees(s_etat_processus,
1.127     bertrand 5778:                            (*(*s_etat_processus).s_arbre_variables_partagees));
1.66      bertrand 5779:                    liberation_arbre_variables(s_etat_processus,
                   5780:                            (*s_etat_processus).s_arbre_variables, d_vrai);
                   5781:                    free((*s_etat_processus).pointeurs_caracteres_variables);
1.1       bertrand 5782: 
1.121     bertrand 5783:                    l_element_statique_courant = (*s_etat_processus)
                   5784:                            .l_liste_variables_statiques;
                   5785: 
                   5786:                    while(l_element_statique_courant != NULL)
                   5787:                    {
                   5788:                        l_element_statique_suivant =
                   5789:                            (*l_element_statique_courant).suivant;
                   5790:                        free(l_element_statique_courant);
                   5791:                        l_element_statique_courant = l_element_statique_suivant;
                   5792:                    }
                   5793: 
1.127     bertrand 5794:                    l_element_partage_courant = (*(*s_etat_processus)
                   5795:                            .l_liste_variables_partagees);
                   5796: 
                   5797:                    while(l_element_partage_courant != NULL)
                   5798:                    {
                   5799:                        l_element_partage_suivant =
                   5800:                                (*l_element_partage_courant).suivant;
                   5801:                        free(l_element_partage_courant);
                   5802:                        l_element_partage_courant = l_element_partage_suivant;
                   5803:                    }
                   5804: 
1.1       bertrand 5805:                    /*
                   5806:                     * Si resultats est non nul, rplinit a été appelé
                   5807:                     * depuis rpl() [librpl] et non main().
                   5808:                     * On copie alors le contenu de la * pile dans un
                   5809:                     * tableau **resultats dont le pointeur de base a
                   5810:                     * été alloué dans rpl().
                   5811:                     */
                   5812: 
                   5813:                    if (resultats != NULL)
                   5814:                    {
                   5815:                        if ((*resultats) != NULL)
                   5816:                        {
1.171     bertrand 5817:                            sys_free((*resultats));
1.1       bertrand 5818: 
1.171     bertrand 5819:                            if (((*resultats) = sys_malloc(((size_t)
1.136     bertrand 5820:                                    ((*s_etat_processus)
                   5821:                                    .hauteur_pile_operationnelle + 1))
1.1       bertrand 5822:                                    * sizeof(unsigned char **))) != NULL)
                   5823:                            {
                   5824:                                (*resultats)[(*s_etat_processus)
                   5825:                                        .hauteur_pile_operationnelle] = NULL;
                   5826:                                l_element_courant = (void *) (*s_etat_processus)
                   5827:                                        .l_base_pile;
                   5828: 
                   5829:                                for(i = 0; i < (*s_etat_processus)
                   5830:                                        .hauteur_pile_operationnelle; i++)
                   5831:                                {
                   5832:                                    if (l_element_courant != NULL)
                   5833:                                    {
                   5834:                                        (*resultats)[i] =
                   5835:                                                formateur(s_etat_processus,
                   5836:                                                0, (*((struct_liste_chainee *)
                   5837:                                                l_element_courant)).donnee);
                   5838: 
                   5839:                                        if ((*resultats)[i] == NULL)
                   5840:                                        {
                   5841:                                            i = (*s_etat_processus).
                   5842:                                                    hauteur_pile_operationnelle;
                   5843:                                        }
                   5844:                                        else
                   5845:                                        {
                   5846:                                            l_element_suivant =
                   5847:                                                    (*((struct_liste_chainee *)
                   5848:                                                    l_element_courant)).suivant;
                   5849:                                        }
                   5850:                                    }
                   5851:                                }
                   5852:                            }
                   5853:                            else
                   5854:                            {
                   5855:                                (*resultats) = NULL;
                   5856:                                erreur = d_es_allocation_memoire;
                   5857:                            }
                   5858:                        }
                   5859:                    }
                   5860: 
                   5861:                    l_element_courant = (void *) (*s_etat_processus)
                   5862:                            .l_base_pile;
                   5863:                    while(l_element_courant != NULL)
                   5864:                    {
                   5865:                        l_element_suivant = (*((struct_liste_chainee *)
                   5866:                                l_element_courant)).suivant;
                   5867: 
                   5868:                        liberation(s_etat_processus,
                   5869:                                (*((struct_liste_chainee *)
                   5870:                                l_element_courant)).donnee);
                   5871:                        free((struct_liste_chainee *) l_element_courant);
                   5872: 
                   5873:                        l_element_courant = l_element_suivant;
                   5874:                    }
                   5875: 
                   5876:                    l_element_courant = (void *) (*s_etat_processus)
                   5877:                            .l_base_pile_contextes;
                   5878:                    while(l_element_courant != NULL)
                   5879:                    {
                   5880:                        l_element_suivant = (*((struct_liste_chainee *)
                   5881:                                l_element_courant)).suivant;
                   5882: 
                   5883:                        liberation(s_etat_processus,
                   5884:                                (*((struct_liste_chainee *)
                   5885:                                l_element_courant)).donnee);
                   5886:                        free((struct_liste_chainee *) l_element_courant);
                   5887: 
                   5888:                        l_element_courant = l_element_suivant;
                   5889:                    }
                   5890: 
                   5891:                    l_element_courant = (void *) (*s_etat_processus)
                   5892:                            .l_base_pile_taille_contextes;
                   5893:                    while(l_element_courant != NULL)
                   5894:                    {
                   5895:                        l_element_suivant = (*((struct_liste_chainee *)
                   5896:                                l_element_courant)).suivant;
                   5897: 
                   5898:                        liberation(s_etat_processus,
                   5899:                                (*((struct_liste_chainee *)
                   5900:                                l_element_courant)).donnee);
                   5901:                        free((struct_liste_chainee *) l_element_courant);
                   5902: 
                   5903:                        l_element_courant = l_element_suivant;
                   5904:                    }
                   5905: 
                   5906:                    l_element_courant = (void *) (*s_etat_processus)
1.197     bertrand 5907:                            .l_base_pile_last;
1.1       bertrand 5908:                    while(l_element_courant != NULL)
                   5909:                    {
                   5910:                        l_element_suivant = (*((struct_liste_chainee *)
                   5911:                                l_element_courant)).suivant;
                   5912: 
1.197     bertrand 5913:                        liberation(s_etat_processus,
1.1       bertrand 5914:                                (*((struct_liste_chainee *)
1.197     bertrand 5915:                                l_element_courant)).donnee);
                   5916:                        free((struct_liste_chainee *) l_element_courant);
1.1       bertrand 5917: 
                   5918:                        l_element_courant = l_element_suivant;
                   5919:                    }
                   5920: 
1.197     bertrand 5921:                    while((*s_etat_processus).s_bibliotheques != NULL)
1.1       bertrand 5922:                    {
1.197     bertrand 5923:                        retrait_bibliotheque(s_etat_processus,
                   5924:                                (struct_bibliotheque *)
1.1       bertrand 5925:                                (*((struct_liste_chainee *)
1.197     bertrand 5926:                                (*s_etat_processus).s_bibliotheques)).donnee);
1.1       bertrand 5927:                    }
                   5928: 
                   5929:                    l_element_courant = (void *) (*s_etat_processus)
                   5930:                            .l_base_pile_systeme;
                   5931:                    while(l_element_courant != NULL)
                   5932:                    {
                   5933:                        l_element_suivant = (*((struct_liste_pile_systeme *)
                   5934:                                l_element_courant)).suivant;
                   5935: 
                   5936:                        liberation(s_etat_processus,
                   5937:                                (*((struct_liste_pile_systeme *)
                   5938:                                l_element_courant)).indice_boucle);
                   5939:                        liberation(s_etat_processus,
                   5940:                                (*((struct_liste_pile_systeme *)
                   5941:                                l_element_courant)).limite_indice_boucle);
                   5942:                        liberation(s_etat_processus,
                   5943:                                (*((struct_liste_pile_systeme *)
                   5944:                                l_element_courant)).objet_de_test);
                   5945: 
                   5946:                        if ((*((struct_liste_pile_systeme *)
                   5947:                                l_element_courant)).nom_variable != NULL)
                   5948:                        {
                   5949:                            free((*((struct_liste_pile_systeme *)
                   5950:                                    l_element_courant)).nom_variable);
                   5951:                        }
                   5952: 
                   5953:                        free((struct_liste_pile_systeme *)
                   5954:                                l_element_courant);
                   5955: 
                   5956:                        l_element_courant = l_element_suivant;
                   5957:                    }
                   5958: 
                   5959:                    l_element_courant = (void *)
                   5960:                            (*s_etat_processus).s_fichiers;
                   5961:                    while(l_element_courant != NULL)
                   5962:                    {
                   5963:                        l_element_suivant = (*((struct_liste_chainee *)
                   5964:                                l_element_courant)).suivant;
                   5965: 
                   5966:                        fclose((*((struct_descripteur_fichier *)
                   5967:                                (*((struct_liste_chainee *)
                   5968:                                l_element_courant)).donnee))
1.12      bertrand 5969:                                .descripteur_c);
                   5970: 
                   5971:                        if ((*((struct_descripteur_fichier *)
                   5972:                                (*((struct_liste_chainee *)
                   5973:                                l_element_courant)).donnee)).type != 'C')
                   5974:                        {
                   5975:                            sqlite3_close((*((struct_descripteur_fichier *)
                   5976:                                    (*((struct_liste_chainee *)
                   5977:                                    l_element_courant)).donnee))
                   5978:                                    .descripteur_sqlite);
                   5979:                        }
1.1       bertrand 5980: 
                   5981:                        if ((*((struct_descripteur_fichier *)
                   5982:                                (*((struct_liste_chainee *)
                   5983:                                l_element_courant)).donnee))
                   5984:                                .effacement == 'Y')
                   5985:                        {
                   5986:                            unlink((*((struct_descripteur_fichier *)
                   5987:                                    (*((struct_liste_chainee *)
                   5988:                                    l_element_courant)).donnee))
                   5989:                                    .nom);
                   5990:                        }
                   5991: 
                   5992:                        free((*((struct_descripteur_fichier *)
                   5993:                                (*((struct_liste_chainee *)
                   5994:                                l_element_courant)).donnee)).nom);
                   5995:                        free((struct_descripteur_fichier *)
                   5996:                                (*((struct_liste_chainee *)
                   5997:                                l_element_courant)).donnee);
                   5998:                        free(l_element_courant);
                   5999: 
                   6000:                        l_element_courant = l_element_suivant;
                   6001:                    }
                   6002: 
                   6003:                    l_element_courant = (void *)
                   6004:                            (*s_etat_processus).s_sockets;
                   6005:                    while(l_element_courant != NULL)
                   6006:                    {
                   6007:                        l_element_suivant = (*((struct_liste_chainee *)
                   6008:                                l_element_courant)).suivant;
                   6009: 
                   6010:                        if ((*((struct_socket *)
                   6011:                                (*(*((struct_liste_chainee *)
                   6012:                                l_element_courant)).donnee).objet))
                   6013:                                .socket_connectee == d_vrai)
                   6014:                        {
                   6015:                            shutdown((*((struct_socket *)
                   6016:                                    (*(*((struct_liste_chainee *)
                   6017:                                    l_element_courant)).donnee).objet))
                   6018:                                    .socket, SHUT_RDWR);
                   6019:                        }
                   6020: 
                   6021:                        close((*((struct_socket *)
                   6022:                                (*(*((struct_liste_chainee *)
                   6023:                                l_element_courant)).donnee).objet)).socket);
                   6024: 
                   6025:                        if ((*((struct_socket *) (*(*((struct_liste_chainee *)
                   6026:                                l_element_courant)).donnee).objet)).effacement
                   6027:                                == 'Y')
                   6028:                        {
                   6029:                            unlink((*((struct_socket *)
                   6030:                                    (*(*((struct_liste_chainee *)
                   6031:                                    l_element_courant)).donnee).objet))
                   6032:                                    .adresse);
                   6033:                        }
                   6034: 
                   6035:                        liberation(s_etat_processus,
                   6036:                                (*((struct_liste_chainee *)
                   6037:                                l_element_courant)).donnee);
                   6038:                        free(l_element_courant);
                   6039: 
                   6040:                        l_element_courant = l_element_suivant;
                   6041:                    }
                   6042: 
                   6043:                    l_element_courant = (void *)
                   6044:                            (*s_etat_processus).s_connecteurs_sql;
                   6045:                    while(l_element_courant != NULL)
                   6046:                    {
                   6047:                        l_element_suivant = (*((struct_liste_chainee *)
                   6048:                                l_element_courant)).suivant;
                   6049: 
                   6050:                        sqlclose((*((struct_liste_chainee *)
                   6051:                                l_element_courant)).donnee);
                   6052:                        liberation(s_etat_processus,
                   6053:                                (*((struct_liste_chainee *)
                   6054:                                l_element_courant)).donnee);
                   6055:                        free(l_element_courant);
                   6056: 
                   6057:                        l_element_courant = l_element_suivant;
                   6058:                    }
                   6059: 
                   6060:                    l_element_courant = (*s_etat_processus).s_marques;
                   6061:                    while(l_element_courant != NULL)
                   6062:                    {
                   6063:                        free((*((struct_marque *) l_element_courant)).label);
                   6064:                        free((*((struct_marque *) l_element_courant)).position);
                   6065:                        l_element_suivant = (*((struct_marque *)
                   6066:                                l_element_courant)).suivant;
                   6067:                        free(l_element_courant);
                   6068:                        l_element_courant = l_element_suivant;
                   6069:                    }
                   6070:                }
                   6071:                else
                   6072:                {
                   6073:                    erreur = d_es_allocation_memoire;
                   6074: 
                   6075:                    if (test_cfsf(s_etat_processus, 51) == d_faux)
                   6076:                    {
                   6077:                        printf("%s", ds_beep);
                   6078:                    }
                   6079: 
                   6080:                    if ((*s_etat_processus).langue == 'F')
                   6081:                    {
                   6082:                        printf("+++Système : Mémoire insuffisante\n");
                   6083:                    }
                   6084:                    else
                   6085:                    {
                   6086:                        printf("+++System : Not enough memory\n");
                   6087:                    }
                   6088:                }
                   6089:            }
                   6090: 
                   6091:            liberation_allocateur(s_etat_processus);
                   6092:        }
                   6093: 
                   6094:        if (traitement_fichier_temporaire == 'Y')
                   6095:        {
1.124     bertrand 6096:            destruction_fichier(nom_fichier_temporaire);
1.1       bertrand 6097:            free(nom_fichier_temporaire);
                   6098:        }
                   6099: 
                   6100:        if ((*s_etat_processus).profilage == d_vrai)
                   6101:        {
                   6102:            ecriture_profil(s_etat_processus);
                   6103:            liberation_profil(s_etat_processus);
                   6104:        }
                   6105:    }
                   6106: 
                   6107:    closelog();
                   6108: 
                   6109:    pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
                   6110: 
                   6111:    retrait_thread(s_etat_processus);
                   6112: 
1.185     bertrand 6113:    attente.tv_sec = 0;
                   6114:    attente.tv_nsec = GRANULARITE_us * 1000;
                   6115: 
                   6116:    while(nombre_thread_surveillance_processus != 0)
                   6117:    {
                   6118:        nanosleep(&attente, NULL);
                   6119:        INCR_GRANULARITE(attente.tv_nsec);
                   6120:    }
1.184     bertrand 6121: 
1.199     bertrand 6122:    attente.tv_sec = 0;
                   6123:    attente.tv_nsec = GRANULARITE_us * 1000;
                   6124: 
                   6125:    while(pthread_mutex_trylock(&((*s_etat_processus).mutex_pile_processus))
                   6126:            == EBUSY)
                   6127:    {
                   6128:        nanosleep(&attente, NULL);
                   6129:        INCR_GRANULARITE(attente.tv_nsec);
                   6130:    }
                   6131: 
                   6132:    pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus));
1.146     bertrand 6133:    pthread_mutex_destroy(&((*s_etat_processus).mutex_pile_processus));
1.30      bertrand 6134:    pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
1.146     bertrand 6135:    pthread_mutex_destroy(&((*s_etat_processus).mutex_interruptions));
1.117     bertrand 6136:    pthread_mutex_destroy(&mutex_sections_critiques);
1.128     bertrand 6137:    pthread_mutex_destroy(&mutex_liste_variables_partagees);
1.29      bertrand 6138: 
1.199     bertrand 6139:    free((*s_etat_processus).localisation);
                   6140: 
                   6141:    destruction_queue_signaux(s_etat_processus);
                   6142:    pthread_mutex_destroy(&((*s_etat_processus).mutex_signaux));
                   6143:    liberation_contexte_cas(s_etat_processus);
                   6144: 
1.91      bertrand 6145: #  ifndef SEMAPHORES_NOMMES
1.93      bertrand 6146:    sem_post(&((*s_etat_processus).semaphore_fork));
                   6147:    sem_destroy(&((*s_etat_processus).semaphore_fork));
1.91      bertrand 6148: #  else
                   6149:    sem_post((*s_etat_processus).semaphore_fork);
1.92      bertrand 6150:    sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(),
                   6151:            SEM_FORK);
1.91      bertrand 6152: #  endif
1.1       bertrand 6153: 
1.40      bertrand 6154:    free((*s_etat_processus).chemin_fichiers_temporaires);
1.103     bertrand 6155: 
                   6156:    if ((*s_etat_processus).requete_redemarrage == d_vrai)
                   6157:    {
1.157     bertrand 6158:        if (chdir(repertoire_initial) == 0)
                   6159:        {
                   6160:            execvp(arg_exec[0], &(arg_exec[0]));
                   6161:        }
                   6162: 
1.103     bertrand 6163:        erreur = d_erreur;
                   6164:    }
                   6165: 
1.165     bertrand 6166:    liberation_etat_processus_readline();
1.181     bertrand 6167: 
1.164     bertrand 6168:    liberation_allocateur_buffer(s_etat_processus);
1.167     bertrand 6169:    pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation_buffer));
1.198     bertrand 6170:    pthread_mutex_destroy(&mutex_liste_threads);
1.181     bertrand 6171: 
1.165     bertrand 6172:    sys_free(s_etat_processus);
1.181     bertrand 6173:    sys_free(arg_exec);
1.24      bertrand 6174: 
1.8       bertrand 6175: #  ifdef DEBUG_MEMOIRE
1.24      bertrand 6176:    debug_memoire_verification();
                   6177:    analyse_post_mortem();
1.8       bertrand 6178: #  endif
                   6179: 
1.94      bertrand 6180: #  ifdef HAVE_STACK_OVERFLOW_RECOVERY
                   6181:    stackoverflow_deinstall_handler();
                   6182: #  endif
                   6183: 
                   6184: #  ifdef HAVE_SIGSEGV_RECOVERY
                   6185:    if (debug == d_faux)
                   6186:    {
                   6187:        sigsegv_deinstall_handler();
                   6188:    }
                   6189: #  endif
                   6190: 
1.13      bertrand 6191:    return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
1.1       bertrand 6192: }
                   6193: 
                   6194: 
                   6195: void
                   6196: informations(struct_processus *s_etat_processus)
                   6197: {
                   6198:    printf("\n");
                   6199: 
                   6200:    if ((*s_etat_processus).langue == 'F')
                   6201:    {
                   6202:        printf("  rpl [-options] [programme]\n");
1.13      bertrand 6203:        printf("      -a : analyse du code\n");
1.1       bertrand 6204:        printf("      -A : paramètres passés au programme principal\n");
                   6205:        printf("      -c : génération de fichier de débogage (rpl-core)\n");
                   6206:        printf("      -d : option de déverminage interne\n");
                   6207:        printf("      -D : lancement d'un daemon\n");
                   6208:        printf("      -h : aide sur la ligne de commande\n");
                   6209:        printf("      -i : fonctionnement interactif\n");
                   6210:        printf("      -l : licence d'utilisation\n");
                   6211:        printf("      -n : ignorance du signal HUP\n");
1.194     bertrand 6212:        printf("      -m : chargement d'un module RPL/SO avant la "
                   6213:                "compilation\n");
1.1       bertrand 6214:        printf("      -p : précompilation du script avant exécution\n");
1.124     bertrand 6215:        printf("      -P : profilage (-P ou -PP)\n");
1.1       bertrand 6216:        printf("      -s : empêchement de l'ouverture de l'écran initial\n");
                   6217:        printf("      -S : exécution du script passé en ligne de commande\n");
                   6218:        printf("      -t : trace\n");
                   6219:        printf("      -v : version\n");
                   6220:    }
                   6221:    else
                   6222:    {
                   6223:        printf("  rpl [-options] [program]\n");
1.13      bertrand 6224:        printf("      -a : analyzes program\n");
1.1       bertrand 6225:        printf("      -A : sends parameters to main program\n");
                   6226:        printf("      -c : allows creation of a rpl-core file, providing a way"
                   6227:                "\n"
                   6228:                "           to debug a program\n");
                   6229:        printf("      -d : internal debug process\n");
                   6230:        printf("      -D : starts in daemon mode\n");
                   6231:        printf("      -h : shows a summary of available options\n");
                   6232:        printf("      -i : runs the RPL/2 sequencer in interactive mode\n");
                   6233:        printf("      -l : prints the user licence of the software\n");
                   6234:        printf("      -n : ignores HUP signal\n");
1.194     bertrand 6235:        printf("      -m : loads RPL/SO object before compilation\n");
1.1       bertrand 6236:        printf("      -p : precompiles script\n");
1.124     bertrand 6237:        printf("      -P : computes profile data (-P or -PP)\n");
1.1       bertrand 6238:        printf("      -s : disables splash screen\n");
                   6239:        printf("      -S : executes script written in command line\n");
                   6240:        printf("      -t : enables tracing mode\n");
                   6241:        printf("      -v : prints the version number\n");
                   6242:    }
                   6243: 
                   6244:    printf("\n");
                   6245: 
                   6246:    return;
                   6247: }
                   6248: 
1.96      bertrand 6249: 
1.100     bertrand 6250: logical1
                   6251: controle_integrite(struct_processus *s_etat_processus,
                   6252:        unsigned char *executable_candidat, unsigned char *executable)
                   6253: {
                   6254:    unsigned char       *md5;
                   6255:    unsigned char       *sha1;
                   6256: 
                   6257:    if (strcmp(executable, "rplpp") == 0)
                   6258:    {
                   6259:        md5 = rplpp_md5;
                   6260:        sha1 = rplpp_sha1;
                   6261:    }
                   6262:    else if (strcmp(executable, "rplfile") == 0)
                   6263:    {
                   6264:        md5 = rplfile_md5;
                   6265:        sha1 = rplfile_sha1;
                   6266:    }
                   6267:    else if (strcmp(executable, "rpliconv") == 0)
                   6268:    {
                   6269:        md5 = rpliconv_md5;
                   6270:        sha1 = rpliconv_sha1;
                   6271:    }
                   6272:    else if (strcmp(executable, "rplawk") == 0)
                   6273:    {
                   6274:        md5 = rplawk_md5;
                   6275:        sha1 = rplawk_sha1;
                   6276:    }
                   6277:    else if (strcmp(executable, "rplconvert") == 0)
                   6278:    {
                   6279:        md5 = rplconvert_md5;
                   6280:        sha1 = rplconvert_sha1;
                   6281:    }
                   6282:    else
                   6283:    {
                   6284:        return(d_faux);
                   6285:    }
                   6286: 
                   6287:    if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai)
                   6288:    {
                   6289:        return(d_faux);
                   6290:    }
                   6291: 
                   6292:    if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai)
                   6293:    {
                   6294:        return(d_faux);
                   6295:    }
                   6296: 
                   6297:    return(d_vrai);
                   6298: }
                   6299: 
                   6300: 
1.96      bertrand 6301: unsigned char *
1.165     bertrand 6302: date_compilation(struct_processus *s_etat_processus)
1.96      bertrand 6303: {
                   6304:    unsigned char       *date;
                   6305: 
                   6306:    if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char)))
                   6307:            == NULL)
                   6308:    {
                   6309:        return(NULL);
                   6310:    }
                   6311: 
                   6312:    strcpy(date, d_date_en_rpl);
                   6313: 
                   6314:    return(date);
                   6315: }
                   6316: 
1.156     bertrand 6317: #pragma GCC diagnostic pop
                   6318: 
1.1       bertrand 6319: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>