Annotation of rpl/src/formateur.c, revision 1.82

1.1       bertrand    1: /*
                      2: ================================================================================
1.82    ! bertrand    3:   RPL/2 (R) version 4.1.27
1.81      bertrand    4:   Copyright (C) 1989-2017 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: 
1.16      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: 
                     26: /*
                     27: ================================================================================
                     28:   Routine de formation des données pour l'affichage
                     29: ================================================================================
                     30:   Entrées : structure sur l'état du processus et objet à afficher
                     31: --------------------------------------------------------------------------------
                     32:   Sorties : chaine de caractères
                     33: --------------------------------------------------------------------------------
                     34:   Effets de bord : néant
                     35: ================================================================================
                     36: */
                     37: 
                     38: unsigned char *
                     39: formateur(struct_processus *s_etat_processus, long offset_initial,
                     40:        struct_objet *s_objet)
                     41: {
                     42:    int                         parentheses_groupe_gauche;
                     43:    int                         parentheses_groupe_droit;
                     44: 
                     45:    logical1                    registre45;
                     46: 
                     47:    logical4                    autorisation_parenthese;
                     48:    logical4                    presence_signe;
                     49: 
1.58      bertrand   50:    logical8                    masque_binaire;
1.41      bertrand   51: 
1.1       bertrand   52:    struct_liste_chainee        *l_atome;
                     53:    struct_liste_chainee        *l_element_courant;
                     54:    struct_liste_chainee        *l_liste1;
                     55:    struct_liste_chainee        *l_liste2;
                     56: 
                     57:    struct_objet                *s_sous_objet;
                     58:    struct_objet                *s_sous_objet_1;
                     59:    struct_objet                *s_sous_objet_2;
                     60:    struct_objet                *s_sous_objet_3;
                     61: 
                     62:    unsigned char               base[1 + 1];
                     63:    unsigned char               *chaine;
                     64:    unsigned char               *chaine_fonction;
                     65:    unsigned char               *chaine_formatee;
                     66:    unsigned char               *chaine_tampon;
                     67:    unsigned char               *chaine_sauvegarde;
                     68:    unsigned char               *format;
                     69:    unsigned char               *format_majuscule;
                     70:    unsigned char               *ptre;
                     71:    unsigned char               *ptrl;
                     72:    unsigned char               *registre;
                     73:    unsigned char               tampon[1024 + 1];
                     74: 
1.58      bertrand   75:    integer8                    i;
                     76:    integer8                    j;
                     77:    integer8                    k;
                     78:    integer8                    longueur_chaine;
                     79:    integer8                    longueur_courante;
                     80:    integer8                    longueur_decimale_courante;
                     81:    integer8                    *longueurs_maximales;
                     82:    integer8                    nombre_arguments;
                     83:    integer8                    nombre_arguments_fonction;
                     84:    integer8                    nombre_colonnes;
                     85:    integer8                    nombre_elements;
                     86:    integer8                    nombre_lignes;
                     87:    integer8                    offset;
1.1       bertrand   88: 
                     89:    chaine = NULL;
                     90:    chaine_formatee = NULL;
                     91:    chaine_sauvegarde = NULL;
                     92: 
                     93:    strcpy(base, " ");
                     94: 
                     95:    masque_binaire = 0;
                     96: 
                     97:    if ((*s_objet).type == ADR)
                     98:    {
                     99: 
                    100: /*
                    101: --------------------------------------------------------------------------------
                    102:   Adresse
                    103: --------------------------------------------------------------------------------
                    104: */
                    105: 
1.74      bertrand  106:        if (alsprintf(s_etat_processus, &chaine,
                    107:                "@ %016llX", (*((unsigned long long *)
1.3       bertrand  108:                ((*s_objet).objet)))) < 0)
1.1       bertrand  109:        {
                    110:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    111:            return(NULL);
                    112:        }
                    113:    }
                    114:    else if ((*s_objet).type == SLB)
                    115:    {
                    116: 
                    117: /*
                    118: --------------------------------------------------------------------------------
                    119:   Bibliothèque partagée
                    120: --------------------------------------------------------------------------------
                    121: */
                    122: 
1.69      bertrand  123: #      pragma GCC diagnostic push
                    124: #      pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
                    125: 
1.74      bertrand  126:        if (alsprintf(s_etat_processus, &chaine, "Library $ %016llX [%s]",
1.63      bertrand  127:                (unsigned long long) (*((struct_bibliotheque *)
1.3       bertrand  128:                (*s_objet).objet)).descripteur, (*((struct_bibliotheque *)
                    129:                (*s_objet).objet)).nom) < 0)
1.1       bertrand  130:        {
                    131:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    132:            return(NULL);
                    133:        }
1.69      bertrand  134: 
                    135: #      pragma GCC diagnostic pop
                    136: 
1.1       bertrand  137:    }
                    138:    else if ((*s_objet).type == SPH)
                    139:    {
                    140: 
                    141: /*
                    142: --------------------------------------------------------------------------------
                    143:   Sémaphore
                    144: --------------------------------------------------------------------------------
                    145: */
                    146: 
1.69      bertrand  147: #      pragma GCC diagnostic push
                    148: #      pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
                    149: 
1.74      bertrand  150:        if (alsprintf(s_etat_processus,
                    151:                &chaine, "Semaphore $ %016llX '%s'", (unsigned long long)
1.3       bertrand  152:                &((*((struct_semaphore *) (*s_objet).objet)).semaphore),
                    153:                (*((struct_semaphore *) (*s_objet).objet)).nom) < 0)
1.1       bertrand  154:        {
                    155:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    156:            return(NULL);
                    157:        }
1.69      bertrand  158: 
                    159: #      pragma GCC diagnostic pop
                    160: 
1.1       bertrand  161:    }
                    162:    else if ((*s_objet).type == SQL)
                    163:    {
                    164: 
                    165: /*
                    166: --------------------------------------------------------------------------------
                    167:   Connecteur SQL
                    168: --------------------------------------------------------------------------------
                    169: */
                    170: 
                    171:        if (strcmp((*((struct_connecteur_sql *) (*s_objet).objet)).type,
                    172:                "MYSQL") == 0)
                    173:        {
                    174: #          ifdef MYSQL_SUPPORT
1.74      bertrand  175:            if (alsprintf(s_etat_processus, &chaine, "Sql $ %016llX (%s)",
1.63      bertrand  176:                    (unsigned long long) (*((struct_connecteur_sql *)
1.1       bertrand  177:                    (*s_objet).objet)).descripteur.mysql,
1.3       bertrand  178:                    (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0)
                    179:            {
                    180:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    181:                return(NULL);
                    182:            }
1.1       bertrand  183: #          else
                    184:            if ((*s_etat_processus).langue == 'F')
                    185:            {
                    186:                printf("+++Attention : Support de MySQL "
                    187:                        "non compilé !\n");
                    188:            }
                    189:            else
                    190:            {
                    191:                printf("+++Warning : MySQL support "
                    192:                        "not available !\n");
                    193:            }
                    194: 
                    195:            fflush(stdout);
                    196: #          endif
                    197:        }
                    198:        else if (strcmp((*((struct_connecteur_sql *) (*s_objet).objet)).type,
                    199:                "POSTGRESQL") == 0)
                    200:        {
                    201: #          ifdef POSTGRESQL_SUPPORT
1.74      bertrand  202:            if (alsprintf(s_etat_processus, &chaine, "Sql $ %016llX (%s)",
1.63      bertrand  203:                    (unsigned long long) (*((struct_connecteur_sql *)
1.9       bertrand  204:                    (*s_objet).objet)).descripteur.postgresql,
1.3       bertrand  205:                    (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0)
                    206:            {
                    207:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    208:                return(NULL);
                    209:            }
1.1       bertrand  210: #          else
                    211:            if ((*s_etat_processus).langue == 'F')
                    212:            {
                    213:                printf("+++Attention : Support de PostgreSQL "
                    214:                        "non compilé !\n");
                    215:            }
                    216:            else
                    217:            {
                    218:                printf("+++Warning : PostgreSQL support "
                    219:                        "not available !\n");
                    220:            }
                    221: 
                    222:            fflush(stdout);
                    223: #          endif
                    224:        }
                    225:        else
                    226:        {
                    227:            BUG(1, printf("SQL type '%s' not allowed!",
                    228:                    (*((struct_connecteur_sql *) (*s_objet).objet))
                    229:                    .type));
                    230:        }
                    231:    }
                    232:    else if ((*s_objet).type == PRC)
                    233:    {
                    234: 
                    235: /*
                    236: --------------------------------------------------------------------------------
                    237:   Processus
                    238: --------------------------------------------------------------------------------
                    239: */
                    240: 
                    241:        if ((*(*((struct_processus_fils *) (*s_objet).objet)).thread)
                    242:                .processus_detache == d_vrai)
                    243:        {
1.74      bertrand  244:            if (alsprintf(s_etat_processus, &chaine,
                    245:                    "Process $ %016llX", (unsigned long long)
1.1       bertrand  246:                    (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
1.3       bertrand  247:                    .pid) < 0)
1.1       bertrand  248:            {
                    249:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    250:                return(NULL);
                    251:            }
                    252:        }
                    253:        else
                    254:        {
1.74      bertrand  255:            if (alsprintf(s_etat_processus, &chaine,
                    256:                    "Light weight process $ %016llX/%016llX",
1.63      bertrand  257:                    (unsigned long long) (*(*((struct_processus_fils *)
1.1       bertrand  258:                    (*s_objet).objet)).thread).pid,
1.63      bertrand  259:                    (unsigned long long) (*(*((struct_processus_fils *)
1.3       bertrand  260:                    (*s_objet).objet)).thread).tid) < 0)
1.1       bertrand  261:            {
                    262:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    263:                return(NULL);
                    264:            }
                    265:        }
                    266:    }
                    267:    else if ((*s_objet).type == FCH)
                    268:    {
                    269: 
                    270: /*
                    271: --------------------------------------------------------------------------------
                    272:   Fichier
                    273: --------------------------------------------------------------------------------
                    274: */
                    275: 
1.74      bertrand  276:        if (alsprintf(s_etat_processus,
                    277:                &chaine, "File $ %016llX", (unsigned long long)
1.3       bertrand  278:                (*((struct_fichier *) ((*s_objet).objet))).descripteur) < 0)
1.1       bertrand  279:        {
                    280:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    281:            return(NULL);
                    282:        }
                    283: 
                    284:        registre45 = test_cfsf(s_etat_processus, 45);
                    285:        cf(s_etat_processus, 45);
                    286: 
                    287:        if ((format = formateur(s_etat_processus, 0, (*((struct_fichier *)
                    288:                ((*s_objet).objet))).format)) == NULL)
                    289:        {
                    290:            return(NULL);
                    291:        }
                    292: 
                    293:        if (registre45 == d_vrai)
                    294:        {
                    295:            sf(s_etat_processus, 45);
                    296:        }
                    297:        else
                    298:        {
                    299:            cf(s_etat_processus, 45);
                    300:        }
                    301: 
1.74      bertrand  302:        if ((format_majuscule = conversion_majuscule(s_etat_processus,
                    303:                format)) == NULL)
1.1       bertrand  304:        {
1.74      bertrand  305:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1.1       bertrand  306:            return(NULL);
                    307:        }
                    308: 
                    309:        free(format);
                    310: 
                    311:        registre = chaine;
                    312: 
                    313:        if ((chaine = malloc((strlen(registre) + 1 +
                    314:                strlen(format_majuscule) + 1) * sizeof(unsigned char)))
                    315:                == NULL)
                    316:        {
                    317:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    318:            return(NULL);
                    319:        }
                    320: 
                    321:        sprintf(chaine, "%s %s", registre, format_majuscule);
                    322:        free(registre);
                    323: 
                    324:        tampon[0] = d_code_fin_chaine;
                    325: 
                    326:        if ((*((struct_fichier *) ((*s_objet).objet))).acces == 'S')
                    327:        {
                    328:            strcat(tampon, "SEQUENTIAL, ");
                    329:        }
                    330:        else if ((*((struct_fichier *) ((*s_objet).objet))).acces == 'D')
                    331:        {
                    332:            strcat(tampon, "DIRECT, ");
                    333:        }
                    334:        else
                    335:        {
                    336:            strcat(tampon, "KEYED, ");
                    337:        }
                    338: 
                    339:        if ((*((struct_fichier *) ((*s_objet).objet))).binaire == 'N')
                    340:        {
                    341:            strcat(tampon, "FORMATTED, ");
                    342:        }
                    343:        else if ((*((struct_fichier *) ((*s_objet).objet))).binaire == 'Y')
                    344:        {
                    345:            strcat(tampon, "UNFORMATTED, ");
                    346:        }
                    347:        else
                    348:        {
                    349:            strcat(tampon, "FLOW, ");
                    350:        }
                    351: 
                    352:        if ((*((struct_fichier *) ((*s_objet).objet))).ouverture == 'N')
                    353:        {
                    354:            strcat(tampon, "NEW, ");
                    355:        }
                    356:        else if ((*((struct_fichier *) ((*s_objet).objet))).ouverture == 'O')
                    357:        {
                    358:            strcat(tampon, "OLD, ");
                    359:        }
                    360:        else if ((*((struct_fichier *) ((*s_objet).objet))).ouverture == 'R')
                    361:        {
                    362:            strcat(tampon, "REPLACE, ");
                    363:        }
                    364:        else if ((*((struct_fichier *) ((*s_objet).objet))).ouverture == 'U')
                    365:        {
                    366:            strcat(tampon, "UNKNOWN, ");
                    367:        }
                    368:        else
                    369:        {
                    370:            strcat(tampon, "SCRATCH, ");
                    371:        }
                    372: 
                    373:        if ((*((struct_fichier *) ((*s_objet).objet))).protection == 'R')
                    374:        {
                    375:            strcat(tampon, "READONLY");
                    376:        }
                    377:        else if ((*((struct_fichier *) ((*s_objet).objet))).protection == 'W')
                    378:        {
                    379:            strcat(tampon, "WRITEONLY");
                    380:        }
                    381:        else
                    382:        {
                    383:            strcat(tampon, "READWRITE");
                    384:        }
                    385: 
                    386:        registre = chaine;
                    387: 
                    388:        if ((chaine = malloc((strlen(chaine) + 6 + strlen(tampon) +
                    389:                strlen((*((struct_fichier *) ((*s_objet).objet))).nom) + 1) *
                    390:                sizeof(unsigned char))) == NULL)
                    391:        {
                    392:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    393:            return(NULL);
                    394:        }
                    395: 
                    396:        sprintf(chaine, "%s [%s <%s>]", registre, (*((struct_fichier *)
                    397:                ((*s_objet).objet))).nom, tampon);
                    398:        free(registre);
                    399: 
                    400:        free(format_majuscule);
                    401:    }
                    402:    else if ((*s_objet).type == SCK)
                    403:    {
                    404: 
                    405: /*
                    406: --------------------------------------------------------------------------------
                    407:   Socket
                    408: --------------------------------------------------------------------------------
                    409: */
                    410: 
1.74      bertrand  411:        if (alsprintf(s_etat_processus, &chaine,
                    412:                "Socket $ %016llX", (unsigned long long)
1.59      bertrand  413:                (*((struct_socket *) ((*s_objet).objet))).socket) < 0)
1.1       bertrand  414:        {
                    415:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    416:            return(NULL);
                    417:        }
                    418: 
                    419:        registre45 = test_cfsf(s_etat_processus, 45);
                    420:        cf(s_etat_processus, 45);
                    421: 
                    422:        if ((format = formateur(s_etat_processus, 0, (*((struct_socket *)
                    423:                ((*s_objet).objet))).format)) == NULL)
                    424:        {
                    425:            return(NULL);
                    426:        }
                    427: 
                    428:        if (registre45 == d_vrai)
                    429:        {
                    430:            sf(s_etat_processus, 45);
                    431:        }
                    432:        else
                    433:        {
                    434:            cf(s_etat_processus, 45);
                    435:        }
                    436: 
1.74      bertrand  437:        if ((format_majuscule = conversion_majuscule(s_etat_processus,
                    438:                format)) == NULL)
1.1       bertrand  439:        {
                    440:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    441:            return(NULL);
                    442:        }
                    443: 
                    444:        free(format);
                    445: 
                    446:        registre = chaine;
                    447: 
                    448:        if ((chaine = malloc((strlen(registre) + 1 +
                    449:                strlen(format_majuscule) + 1) * sizeof(unsigned char)))
                    450:                == NULL)
                    451:        {
                    452:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    453:            return(NULL);
                    454:        }
                    455: 
                    456:        sprintf(chaine, "%s %s", registre, format_majuscule);
                    457:        free(registre);
                    458: 
                    459:        tampon[0] = d_code_fin_chaine;
                    460: 
                    461:        strcat(tampon, (*((struct_socket *) ((*s_objet).objet))).type);
                    462:        strcat(tampon, ", ");
                    463: 
                    464:        if ((*((struct_socket *) ((*s_objet).objet))).domaine == PF_UNIX)
                    465:        {
                    466:            strcat(tampon, "UNIX, ");
                    467:        }
                    468:        else if ((*((struct_socket *) ((*s_objet).objet))).domaine == PF_INET)
                    469:        {
                    470:            strcat(tampon, "IPV4, ");
                    471:        }
                    472:        else if ((*((struct_socket *) ((*s_objet).objet))).domaine == PF_INET6)
                    473:        {
                    474:            strcat(tampon, "IPV6, ");
                    475:        }
                    476: 
                    477:        if ((*((struct_socket *) ((*s_objet).objet))).localisation == 'L')
                    478:        {
                    479:            strcat(tampon, "LOCAL, ");
                    480:        }
                    481:        else
                    482:        {
                    483:            strcat(tampon, "FOREIGN, ");
                    484:        }
                    485: 
                    486:        if ((*((struct_socket *) ((*s_objet).objet))).binaire == 'N')
                    487:        {
                    488:            strcat(tampon, "FORMATTED, ");
                    489:        }
                    490:        else if ((*((struct_socket *) ((*s_objet).objet))).binaire == 'Y')
                    491:        {
                    492:            strcat(tampon, "UNFORMATTED, ");
                    493:        }
                    494:        else
                    495:        {
                    496:            strcat(tampon, "FLOW, ");
                    497:        }
                    498: 
                    499:        if ((*((struct_socket *) ((*s_objet).objet))).protection == 'R')
                    500:        {
                    501:            strcat(tampon, "READONLY");
                    502:        }
                    503:        else if ((*((struct_fichier *) ((*s_objet).objet))).protection == 'W')
                    504:        {
                    505:            strcat(tampon, "WRITEONLY");
                    506:        }
                    507:        else
                    508:        {
                    509:            strcat(tampon, "READWRITE");
                    510:        }
                    511: 
                    512:        registre = chaine;
                    513: 
                    514:        if ((*((struct_socket *) ((*s_objet).objet))).localisation == 'L')
                    515:        { // Socket locale
                    516:            if ((strcmp((*((struct_socket *) ((*s_objet).objet))).type,
                    517:                    "STREAM") == 0) || (strcmp((*((struct_socket *)
                    518:                    ((*s_objet).objet))).type, "SEQUENTIAL DATAGRAM") == 0))
                    519:            {
                    520:                if (strcmp((*((struct_socket *) ((*s_objet).objet)))
                    521:                        .adresse_distante, "") == 0)
                    522:                { // Socket connectée en écoute
                    523:                    if ((chaine = malloc((strlen(registre) + 16 +
                    524:                            strlen(tampon) + strlen((*((struct_socket *)
                    525:                            ((*s_objet).objet))).adresse) +
                    526:                            + 1) * sizeof(unsigned char))) == NULL)
                    527:                    {
                    528:                        (*s_etat_processus).erreur_systeme =
                    529:                                d_es_allocation_memoire;
                    530:                        return(NULL);
                    531:                    }
                    532: 
                    533:                    sprintf(chaine, "%s [%s LISTENING <%s>]", registre,
                    534:                            (*((struct_socket *) ((*s_objet).objet))).adresse,
                    535:                            tampon);
                    536:                }
                    537:                else
                    538:                { // Socket connecté
                    539:                    if ((chaine = malloc((strlen(registre) + 12 +
                    540:                            strlen(tampon) + strlen((*((struct_socket *)
                    541:                            ((*s_objet).objet))).adresse) +
                    542:                            strlen((*((struct_socket *) ((*s_objet).objet)))
                    543:                            .adresse_distante)
                    544:                            + 1) * sizeof(unsigned char))) == NULL)
                    545:                    {
                    546:                        (*s_etat_processus).erreur_systeme =
                    547:                                d_es_allocation_memoire;
                    548:                        return(NULL);
                    549:                    }
                    550: 
                    551:                    sprintf(chaine, "%s [%s FROM %s <%s>]", registre,
                    552:                            (*((struct_socket *) ((*s_objet).objet))).adresse,
                    553:                            (*((struct_socket *) ((*s_objet).objet)))
                    554:                            .adresse_distante, tampon);
                    555:                }
                    556:            }
                    557:            else // Socket non connectée
                    558:            {
                    559:                if ((chaine = malloc((strlen(registre) + 6 +
                    560:                        strlen(tampon) + strlen((*((struct_socket *)
                    561:                        ((*s_objet).objet))).adresse) +
                    562:                        + 1) * sizeof(unsigned char))) == NULL)
                    563:                {
                    564:                    (*s_etat_processus).erreur_systeme =
                    565:                            d_es_allocation_memoire;
                    566:                    return(NULL);
                    567:                }
                    568: 
                    569:                sprintf(chaine, "%s [%s <%s>]", registre,
                    570:                        (*((struct_socket *) ((*s_objet).objet))).adresse,
                    571:                        tampon);
                    572:            }
                    573:        }
                    574:        else
                    575:        { // Socket distante
                    576:            if ((strcmp((*((struct_socket *) ((*s_objet).objet))).type,
                    577:                    "STREAM") == 0) || (strcmp((*((struct_socket *)
                    578:                    ((*s_objet).objet))).type, "SEQUENTIAL DATAGRAM") == 0))
                    579:            {
                    580:                if ((chaine = malloc((strlen(registre) + 9 +
                    581:                        strlen((*((struct_socket *) ((*s_objet).objet)))
                    582:                        .adresse) + strlen(tampon)
                    583:                        + 1) * sizeof(unsigned char))) == NULL)
                    584:                {
                    585:                    (*s_etat_processus).erreur_systeme =
                    586:                            d_es_allocation_memoire;
                    587:                    return(NULL);
                    588:                }
                    589: 
                    590:                sprintf(chaine, "%s [TO %s <%s>]", registre,
                    591:                        (*((struct_socket *) ((*s_objet).objet)))
                    592:                        .adresse, tampon);
                    593:            }
                    594:            else
                    595:            {
                    596:                if (strcmp((*((struct_socket *) ((*s_objet).objet)))
                    597:                        .adresse_distante, "") == 0)
                    598:                {
                    599:                    if ((chaine = malloc((strlen(registre) + 5 +
                    600:                            strlen(tampon) + 1) * sizeof(unsigned char)))
                    601:                            == NULL)
                    602:                    {
                    603:                        (*s_etat_processus).erreur_systeme =
                    604:                                d_es_allocation_memoire;
                    605:                        return(NULL);
                    606:                    }
                    607: 
                    608:                    sprintf(chaine, "%s [<%s>]", registre, tampon);
                    609:                }
                    610:                else
                    611:                {
                    612:                    if ((chaine = malloc((strlen(registre) + 9 +
                    613:                            strlen((*((struct_socket *) ((*s_objet).objet)))
                    614:                            .adresse_distante) + strlen(tampon)
                    615:                            + 1) * sizeof(unsigned char))) == NULL)
                    616:                    {
                    617:                        (*s_etat_processus).erreur_systeme =
                    618:                                d_es_allocation_memoire;
                    619:                        return(NULL);
                    620:                    }
                    621: 
                    622:                    sprintf(chaine, "%s [TO %s <%s>]", registre,
                    623:                            (*((struct_socket *) ((*s_objet).objet)))
                    624:                            .adresse_distante, tampon);
                    625:                }
                    626:            }
                    627:        }
                    628: 
                    629:        free(registre);
                    630:        free(format_majuscule);
                    631:    }
                    632:    else if ((*s_objet).type == ALG)
                    633:    {
                    634: 
                    635: /*
                    636: --------------------------------------------------------------------------------
                    637:   Expression algébrique
                    638: --------------------------------------------------------------------------------
                    639: */
                    640: 
                    641:        l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
                    642: 
                    643:        while(l_element_courant != NULL)
                    644:        {
                    645:            if ((*(*l_element_courant).donnee).type == FCT)
                    646:            {
                    647:                if ((strcmp((*((struct_fonction *) (*(*l_element_courant)
                    648:                        .donnee).objet)).nom_fonction, "<<") != 0) &&
                    649:                        (strcmp((*((struct_fonction *) (*(*l_element_courant)
                    650:                        .donnee).objet)).nom_fonction, ">>") != 0))
                    651:                {
                    652:                    if ((strcmp((*((struct_fonction *) (*(*l_element_courant)
                    653:                            .donnee).objet)).nom_fonction, "+") == 0) ||
                    654:                            (strcmp((*((struct_fonction *)
                    655:                            (*(*l_element_courant).donnee).objet))
                    656:                            .nom_fonction, "-") == 0) || (strcmp(
                    657:                            (*((struct_fonction *) (*(*l_element_courant)
                    658:                            .donnee).objet)).nom_fonction, "*") == 0) ||
                    659:                            (strcmp((*((struct_fonction *)
                    660:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    661:                            "/") == 0) || (strcmp((*((struct_fonction *)
                    662:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    663:                            "^") == 0) || (strcmp((*((struct_fonction *)
                    664:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    665:                            "<") == 0) || (strcmp((*((struct_fonction *)
                    666:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    667:                            ">") == 0) || (strcmp((*((struct_fonction *)
                    668:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    669:                            "==") == 0) || (strcmp((*((struct_fonction *)
                    670:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    671:                            "<>") == 0) || (strcmp((*((struct_fonction *)
                    672:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    673:                            "<=") == 0) || (strcmp((*((struct_fonction *)
                    674:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    675:                            "=<") == 0) || (strcmp((*((struct_fonction *)
                    676:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    677:                            ">=") == 0) || (strcmp((*((struct_fonction *)
                    678:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                    679:                            "=>") == 0))
                    680:                    {
                    681:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                    682:                                .l_base_pile), &s_sous_objet_2) == d_erreur)
                    683:                        {
                    684:                            return(NULL);
                    685:                        }
                    686: 
                    687:                        chaine_sauvegarde = (*s_etat_processus)
                    688:                                .instruction_courante;
                    689: 
                    690:                        if (((*s_etat_processus).instruction_courante =
                    691:                                (unsigned char *) malloc((strlen(
                    692:                                (unsigned char *) (*s_sous_objet_2).objet) + 2
                    693:                                + 1) * sizeof(unsigned char))) == NULL)
                    694:                        {
                    695:                            (*s_etat_processus).instruction_courante =
                    696:                                    chaine_sauvegarde;
                    697:                            (*s_etat_processus).erreur_systeme =
                    698:                                    d_es_allocation_memoire;
                    699:                            return(NULL);
                    700:                        }
                    701: 
                    702:                        sprintf((*s_etat_processus).instruction_courante,
                    703:                                "'%s'", (unsigned char *)
                    704:                                (*s_sous_objet_2).objet);
                    705: 
                    706:                        presence_signe = (((*s_etat_processus)
                    707:                                .instruction_courante[1] == '+')
                    708:                                || ((*s_etat_processus).instruction_courante[1]
                    709:                                == '-')) ? d_vrai : d_faux;
                    710: 
1.71      bertrand  711:                        (*s_etat_processus).type_en_cours = NON;
1.1       bertrand  712:                        recherche_type(s_etat_processus);
                    713: 
                    714:                        if ((*s_etat_processus).erreur_execution != d_ex)
                    715:                        {
                    716:                            // Aucune erreur d'exécution ne peut être
                    717:                            // retournée, car l'argument est cohérent.
                    718: 
                    719:                            return(NULL);
                    720:                        }
                    721: 
                    722:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                    723:                                .l_base_pile), &s_sous_objet_3) == d_erreur)
                    724:                        {
                    725:                            return(NULL);
                    726:                        }
                    727: 
                    728:                        free((*s_etat_processus).instruction_courante);
                    729: 
                    730:                        (*s_etat_processus).instruction_courante =
                    731:                                chaine_sauvegarde;
                    732: 
                    733:                        autorisation_parenthese = d_faux;
                    734: 
                    735:                        if ((*s_sous_objet_3).type == ALG)
                    736:                        {
                    737:                            l_atome = (struct_liste_chainee *)
                    738:                                    (*s_sous_objet_3).objet;
                    739:                            chaine_fonction = "";
                    740:                            nombre_arguments_fonction = 0;
                    741: 
                    742:                            while(l_atome != NULL)
                    743:                            {
                    744:                                if ((*(*l_atome).donnee).type == FCT)
                    745:                                {
                    746:                                    if (strcmp((*((struct_fonction *)
                    747:                                            (*(*l_atome).donnee).objet))
                    748:                                            .nom_fonction, ">>") != 0)
                    749:                                    {
                    750:                                        chaine_fonction = (*((struct_fonction *)
                    751:                                                (*(*l_atome).donnee).objet))
                    752:                                                .nom_fonction;
                    753:                                        nombre_arguments_fonction =
                    754:                                                (*((struct_fonction *)
                    755:                                                (*(*l_atome).donnee).objet))
                    756:                                                .nombre_arguments;
                    757:                                    }
                    758:                                }
                    759: 
                    760:                                l_atome = (*l_atome).suivant;
                    761:                            }
                    762: 
                    763:                            if (strcmp((*((struct_fonction *)
                    764:                                    (*(*l_element_courant).donnee).objet))
                    765:                                    .nom_fonction, "+") == 0)
                    766:                            {
                    767:                                if ((strcmp(chaine_fonction, "AND") == 0) ||
                    768:                                        (strcmp(chaine_fonction, "XOR") == 0) ||
1.72      bertrand  769:                                        (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand  770:                                        (strcmp(chaine_fonction, "OR") == 0))
                    771:                                {
                    772:                                    autorisation_parenthese = d_vrai;
                    773:                                }
                    774:                            }
                    775:                            else if (strcmp((*((struct_fonction *)
                    776:                                    (*(*l_element_courant).donnee).objet))
                    777:                                    .nom_fonction, "-") == 0)
                    778:                            {
                    779:                                if (nombre_arguments_fonction != 0)
                    780:                                {
                    781:                                    autorisation_parenthese = d_faux;
                    782:                                }
                    783:                                else
                    784:                                {
                    785:                                    autorisation_parenthese = d_vrai;
                    786:                                }
                    787:                            }
                    788:                            else if (strcmp((*((struct_fonction *)
                    789:                                    (*(*l_element_courant).donnee).objet))
                    790:                                    .nom_fonction, "*") == 0)
                    791:                            {
                    792:                                if ((strcmp(chaine_fonction, "+") == 0) ||
                    793:                                        (strcmp(chaine_fonction, "-") == 0) ||
                    794:                                        (strcmp(chaine_fonction, "AND") == 0) ||
                    795:                                        (strcmp(chaine_fonction, "XOR") == 0) ||
1.72      bertrand  796:                                        (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand  797:                                        (strcmp(chaine_fonction, "OR") == 0))
                    798:                                {
                    799:                                    autorisation_parenthese = d_vrai;
                    800:                                }
                    801:                            }
                    802:                            else if (strcmp((*((struct_fonction *)
                    803:                                    (*(*l_element_courant).donnee).objet))
                    804:                                    .nom_fonction, "/") == 0)
                    805:                            {
                    806:                                if (nombre_arguments_fonction != 0)
                    807:                                {
                    808:                                    autorisation_parenthese = d_faux;
                    809:                                }
                    810:                                else
                    811:                                {
                    812:                                    autorisation_parenthese = d_vrai;
                    813:                                }
                    814:                            }
                    815:                            else if ((strcmp((*((struct_fonction *)
                    816:                                    (*(*l_element_courant).donnee).objet))
                    817:                                    .nom_fonction, "^") == 0))
                    818:                            {
                    819:                                if (nombre_arguments_fonction != 0)
                    820:                                {
                    821:                                    autorisation_parenthese = d_faux;
                    822:                                }
                    823:                                else
                    824:                                {
                    825:                                    autorisation_parenthese = d_vrai;
                    826:                                }
                    827:                            }
                    828:                        }
                    829: 
                    830:                        if ((autorisation_parenthese == d_vrai) ||
                    831:                                (presence_signe == d_vrai))
                    832:                        {
                    833:                            chaine_sauvegarde = (unsigned char *)
                    834:                                    (*s_sous_objet_2).objet;
                    835: 
1.58      bertrand  836:                            if (((*s_sous_objet_2).objet =
1.1       bertrand  837:                                    malloc((strlen(chaine_sauvegarde) + 2 + 1)
                    838:                                    * sizeof(unsigned char))) == NULL)
                    839:                            {
                    840:                                (*s_etat_processus).erreur_systeme =
                    841:                                        d_es_allocation_memoire;
                    842:                                return(NULL);
                    843:                            }
                    844: 
                    845:                            sprintf((unsigned char *) (*s_sous_objet_2).objet,
                    846:                                    "(%s)", chaine_sauvegarde);
                    847:                            free(chaine_sauvegarde);
                    848:                        }
                    849: 
                    850:                        liberation(s_etat_processus, s_sous_objet_3);
                    851: 
                    852:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                    853:                                .l_base_pile), &s_sous_objet_1) == d_erreur)
                    854:                        {
                    855:                            return(NULL);
                    856:                        }
                    857: 
                    858:                        chaine_sauvegarde = (*s_etat_processus)
                    859:                                .instruction_courante;
                    860: 
                    861:                        if (((*s_etat_processus).instruction_courante =
                    862:                                (unsigned char *) malloc((strlen(
                    863:                                (unsigned char *) (*s_sous_objet_1).objet) + 2
                    864:                                + 1) * sizeof(unsigned char))) == NULL)
                    865:                        {
                    866:                            (*s_etat_processus).instruction_courante =
                    867:                                    chaine_sauvegarde;
                    868:                            (*s_etat_processus).erreur_systeme =
                    869:                                    d_es_allocation_memoire;
                    870:                            return(NULL);
                    871:                        }
                    872: 
                    873:                        sprintf((*s_etat_processus).instruction_courante,
                    874:                                "'%s'", (unsigned char *)
                    875:                                (*s_sous_objet_1).objet);
                    876: 
1.71      bertrand  877:                        (*s_etat_processus).type_en_cours = NON;
1.1       bertrand  878:                        recherche_type(s_etat_processus);
                    879: 
                    880:                        if ((*s_etat_processus).erreur_execution != d_ex)
                    881:                        {
                    882:                            // Aucune erreur d'exécution ne peut être
                    883:                            // retournée, car l'argument est cohérent.
                    884: 
                    885:                            return(NULL);
                    886:                        }
                    887: 
                    888:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                    889:                                .l_base_pile), &s_sous_objet_3) == d_erreur)
                    890:                        {
                    891:                            return(NULL);
                    892:                        }
                    893: 
                    894:                        free((*s_etat_processus).instruction_courante);
                    895: 
                    896:                        (*s_etat_processus).instruction_courante =
                    897:                                chaine_sauvegarde;
                    898: 
                    899:                        autorisation_parenthese = d_faux;
                    900: 
                    901:                        if ((*s_sous_objet_3).type == ALG)
                    902:                        {
                    903:                            l_atome = (struct_liste_chainee *)
                    904:                                    (*s_sous_objet_3).objet;
                    905:                            chaine_fonction = "";
                    906: 
                    907:                            while(l_atome != NULL)
                    908:                            {
                    909:                                if ((*(*l_atome).donnee).type == FCT)
                    910:                                {
                    911:                                    if (strcmp((*((struct_fonction *)
                    912:                                            (*(*l_atome).donnee).objet))
                    913:                                            .nom_fonction, ">>") != 0)
                    914:                                    {
                    915:                                        chaine_fonction = (*((struct_fonction *)
                    916:                                                (*(*l_atome).donnee).objet))
                    917:                                                .nom_fonction;
                    918:                                    }
                    919:                                }
                    920: 
                    921:                                l_atome = (*l_atome).suivant;
                    922:                            }
                    923: 
                    924:                            if ((strcmp((*((struct_fonction *)
                    925:                                    (*(*l_element_courant).donnee).objet))
                    926:                                    .nom_fonction, "+") == 0) ||
                    927:                                    (strcmp((*((struct_fonction *)
                    928:                                    (*(*l_element_courant).donnee).objet))
                    929:                                    .nom_fonction, "-") == 0))
                    930:                            {
                    931:                                if ((strcmp(chaine_fonction, "AND") == 0) ||
                    932:                                        (strcmp(chaine_fonction, "XOR") == 0) ||
1.72      bertrand  933:                                        (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand  934:                                        (strcmp(chaine_fonction, "OR") == 0))
                    935:                                {
                    936:                                    autorisation_parenthese = d_vrai;
                    937:                                }
                    938:                            }
                    939:                            else if ((strcmp((*((struct_fonction *)
                    940:                                    (*(*l_element_courant).donnee).objet))
                    941:                                    .nom_fonction, "*") == 0) ||
                    942:                                    (strcmp((*((struct_fonction *)
                    943:                                    (*(*l_element_courant).donnee).objet))
                    944:                                    .nom_fonction, "/") == 0))
                    945:                            {
                    946:                                if ((strcmp(chaine_fonction, "+") == 0) ||
                    947:                                        (strcmp(chaine_fonction, "-") == 0) ||
                    948:                                        (strcmp(chaine_fonction, "AND") == 0) ||
                    949:                                        (strcmp(chaine_fonction, "XOR") == 0) ||
1.72      bertrand  950:                                        (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand  951:                                        (strcmp(chaine_fonction, "OR") == 0))
                    952:                                {
                    953:                                    autorisation_parenthese = d_vrai;
                    954:                                }
                    955:                            }
                    956:                            else if ((strcmp((*((struct_fonction *)
                    957:                                    (*(*l_element_courant).donnee).objet))
                    958:                                    .nom_fonction, "^") == 0))
                    959:                            {
                    960:                                autorisation_parenthese = d_vrai;
                    961:                            }
                    962:                        }
                    963: 
                    964:                        if (autorisation_parenthese == d_vrai)
                    965:                        {
                    966:                            chaine_sauvegarde = (unsigned char *)
                    967:                                    (*s_sous_objet_1).objet;
                    968: 
1.58      bertrand  969:                            if (((*s_sous_objet_1).objet =
1.1       bertrand  970:                                    malloc((strlen(chaine_sauvegarde) + 2 + 1)
                    971:                                    * sizeof(unsigned char))) == NULL)
                    972:                            {
                    973:                                (*s_etat_processus).erreur_systeme =
                    974:                                        d_es_allocation_memoire;
                    975:                                return(NULL);
                    976:                            }
                    977: 
                    978:                            sprintf((unsigned char *) (*s_sous_objet_1).objet,
                    979:                                    "(%s)", chaine_sauvegarde);
                    980:                            free(chaine_sauvegarde);
                    981:                        }
                    982: 
                    983:                        liberation(s_etat_processus, s_sous_objet_3);
                    984: 
                    985:                        if ((s_sous_objet = allocation(s_etat_processus, CHN))
                    986:                                == NULL)
                    987:                        {
                    988:                            (*s_etat_processus).erreur_systeme =
                    989:                                    d_es_allocation_memoire;
                    990:                            return(NULL);
                    991:                        }
                    992: 
1.58      bertrand  993:                        if (((*s_sous_objet).objet = malloc((strlen(
1.1       bertrand  994:                                (unsigned char *) (*s_sous_objet_1).objet) +
                    995:                                strlen((*((struct_fonction *)
                    996:                                (*(*l_element_courant).donnee).objet))
                    997:                                .nom_fonction) + strlen((unsigned char *)
                    998:                                (*s_sous_objet_2).objet) + 1) *
                    999:                                sizeof(unsigned char))) == NULL)
                   1000:                        {
                   1001:                            (*s_etat_processus).erreur_systeme =
                   1002:                                    d_es_allocation_memoire;
                   1003:                            return(NULL);
                   1004:                        }
                   1005: 
                   1006:                        sprintf((unsigned char *) (*s_sous_objet).objet,
                   1007:                                "%s%s%s", (unsigned char *)
                   1008:                                (*s_sous_objet_1)
                   1009:                                .objet, (*((struct_fonction *)
                   1010:                                (*(*l_element_courant).donnee).objet))
                   1011:                                .nom_fonction, (unsigned char *)
                   1012:                                (*s_sous_objet_2).objet);
                   1013: 
                   1014:                        liberation(s_etat_processus, s_sous_objet_1);
                   1015:                        liberation(s_etat_processus, s_sous_objet_2);
                   1016: 
                   1017:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   1018:                                .l_base_pile), s_sous_objet) == d_erreur)
                   1019:                        {
                   1020:                            return(NULL);
                   1021:                        }
                   1022:                    }
                   1023:                    else if (strcmp((*((struct_fonction *)
                   1024:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                   1025:                            "=") == 0)
                   1026:                    {
                   1027:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1028:                                .l_base_pile), &s_sous_objet_2) == d_erreur)
                   1029:                        {
                   1030:                            return(NULL);
                   1031:                        }
                   1032: 
                   1033:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1034:                                .l_base_pile), &s_sous_objet_1) == d_erreur)
                   1035:                        {
                   1036:                            return(NULL);
                   1037:                        }
                   1038: 
                   1039:                        if ((s_sous_objet = allocation(s_etat_processus, CHN))
                   1040:                                == NULL)
                   1041:                        {
                   1042:                            (*s_etat_processus).erreur_systeme =
                   1043:                                    d_es_allocation_memoire;
                   1044:                            return(NULL);
                   1045:                        }
                   1046: 
                   1047:                        autorisation_parenthese = d_vrai;
                   1048:                        l_atome = l_element_courant;
                   1049: 
                   1050:                        if (l_atome != NULL)
                   1051:                        {
                   1052:                            if ((*l_atome).suivant != NULL)
                   1053:                            {
                   1054:                                l_atome = (*l_atome).suivant;
                   1055: 
                   1056:                                if ((*(*l_atome).donnee).type == FCT)
                   1057:                                {
                   1058:                                    if (strcmp((*((struct_fonction *)
                   1059:                                            (*(*l_atome).donnee).objet))
                   1060:                                            .nom_fonction, ">>") == 0)
                   1061:                                    {
                   1062:                                        if ((*l_atome).suivant == NULL)
                   1063:                                        {
                   1064:                                            autorisation_parenthese = d_faux;
                   1065:                                        }
                   1066:                                    }
                   1067:                                }
                   1068:                            }
                   1069:                        }
                   1070: 
                   1071:                        if (autorisation_parenthese == d_vrai)
                   1072:                        {
                   1073:                            if (((*s_sous_objet).objet =
1.58      bertrand 1074:                                    malloc((strlen(
1.1       bertrand 1075:                                    (unsigned char *) (*s_sous_objet_1).objet) +
                   1076:                                    strlen((*((struct_fonction *)
                   1077:                                    (*(*l_element_courant).donnee).objet))
                   1078:                                    .nom_fonction) + strlen((unsigned char *)
                   1079:                                    (*s_sous_objet_2).objet) + 2 + 1) *
                   1080:                                    sizeof(unsigned char))) == NULL)
                   1081:                            {
                   1082:                                (*s_etat_processus).erreur_systeme =
                   1083:                                        d_es_allocation_memoire;
                   1084:                                return(NULL);
                   1085:                            }
                   1086: 
                   1087:                            sprintf((unsigned char *) (*s_sous_objet).objet,
                   1088:                                    "(%s%s%s)", (unsigned char *)
                   1089:                                    (*s_sous_objet_1)
                   1090:                                    .objet, (*((struct_fonction *)
                   1091:                                    (*(*l_element_courant).donnee).objet))
                   1092:                                    .nom_fonction, (unsigned char *)
                   1093:                                    (*s_sous_objet_2).objet);
                   1094:                        }
                   1095:                        else
                   1096:                        {
                   1097:                            if (((*s_sous_objet).objet =
1.58      bertrand 1098:                                    malloc((strlen(
1.1       bertrand 1099:                                    (unsigned char *) (*s_sous_objet_1).objet) +
                   1100:                                    strlen((*((struct_fonction *)
                   1101:                                    (*(*l_element_courant).donnee).objet))
                   1102:                                    .nom_fonction) + strlen((unsigned char *)
                   1103:                                    (*s_sous_objet_2).objet) + 1) *
                   1104:                                    sizeof(unsigned char))) == NULL)
                   1105:                            {
                   1106:                                (*s_etat_processus).erreur_systeme =
                   1107:                                        d_es_allocation_memoire;
                   1108:                                return(NULL);
                   1109:                            }
                   1110: 
                   1111:                            sprintf((unsigned char *) (*s_sous_objet).objet,
                   1112:                                    "%s%s%s", (unsigned char *)
                   1113:                                    (*s_sous_objet_1)
                   1114:                                    .objet, (*((struct_fonction *)
                   1115:                                    (*(*l_element_courant).donnee).objet))
                   1116:                                    .nom_fonction, (unsigned char *)
                   1117:                                    (*s_sous_objet_2).objet);
                   1118:                        }
                   1119: 
                   1120:                        liberation(s_etat_processus, s_sous_objet_1);
                   1121:                        liberation(s_etat_processus, s_sous_objet_2);
                   1122: 
                   1123:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   1124:                                .l_base_pile), s_sous_objet) == d_erreur)
                   1125:                        {
                   1126:                            return(NULL);
                   1127:                        }
                   1128:                    }
                   1129:                    else if (strcmp((*((struct_fonction *)
                   1130:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                   1131:                            "NOT") == 0)
                   1132:                    {
                   1133:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1134:                                .l_base_pile), &s_sous_objet_1) == d_erreur)
                   1135:                        {
                   1136:                            return(NULL);
                   1137:                        }
                   1138: 
                   1139:                        if ((s_sous_objet = allocation(s_etat_processus, CHN))
                   1140:                                == NULL)
                   1141:                        {
                   1142:                            (*s_etat_processus).erreur_systeme =
                   1143:                                    d_es_allocation_memoire;
                   1144:                            return(NULL);
                   1145:                        }
                   1146: 
                   1147:                        if (((*s_sous_objet).objet = (unsigned char *) malloc(
                   1148:                                (strlen((unsigned char *) (*s_sous_objet_1)
                   1149:                                .objet) + 5 + 1) * sizeof(unsigned char))) ==
                   1150:                                NULL)
                   1151:                        {
                   1152:                            (*s_etat_processus).erreur_systeme =
                   1153:                                    d_es_allocation_memoire;
                   1154:                            return(NULL);
                   1155:                        }
                   1156: 
                   1157:                        sprintf((unsigned char *) (*s_sous_objet).objet,
                   1158:                                "%s(%s)", (*((struct_fonction *)
                   1159:                                (*(*l_element_courant).donnee).objet))
                   1160:                                .nom_fonction, (unsigned char *)
                   1161:                                (*s_sous_objet_1).objet );
                   1162: 
                   1163:                        liberation(s_etat_processus, s_sous_objet_1);
                   1164: 
                   1165:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   1166:                                .l_base_pile), s_sous_objet) == d_erreur)
                   1167:                        {
                   1168:                            return(NULL);
                   1169:                        }
                   1170:                    }
                   1171:                    else if ((strcmp((*((struct_fonction *)
                   1172:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                   1173:                            "OR") == 0) || (strcmp((*((struct_fonction *)
                   1174:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
                   1175:                            "XOR") == 0) || (strcmp((*((struct_fonction *)
                   1176:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
1.72      bertrand 1177:                            "EQV") == 0) || (strcmp((*((struct_fonction *)
                   1178:                            (*(*l_element_courant).donnee).objet)).nom_fonction,
1.1       bertrand 1179:                            "AND") == 0))
                   1180:                    {
                   1181:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1182:                                .l_base_pile), &s_sous_objet_2) == d_erreur)
                   1183:                        {
                   1184:                            return(NULL);
                   1185:                        }
                   1186: 
                   1187:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1188:                                .l_base_pile), &s_sous_objet_1) == d_erreur)
                   1189:                        {
                   1190:                            return(NULL);
                   1191:                        }
                   1192: 
                   1193:                        if ((s_sous_objet = allocation(s_etat_processus, CHN))
                   1194:                                == NULL)
                   1195:                        {
                   1196:                            (*s_etat_processus).erreur_systeme =
                   1197:                                    d_es_allocation_memoire;
                   1198:                            return(NULL);
                   1199:                        }
                   1200: 
                   1201:                        parentheses_groupe_gauche = 0;
                   1202:                        parentheses_groupe_droit = 0;
                   1203: 
                   1204:                        chaine_sauvegarde = (*s_etat_processus)
                   1205:                                .instruction_courante;
                   1206: 
                   1207:                        if (((*s_etat_processus).instruction_courante =
                   1208:                                (unsigned char *) malloc((strlen(
                   1209:                                (unsigned char *) (*s_sous_objet_1).objet) + 2
                   1210:                                + 1) * sizeof(unsigned char))) == NULL)
                   1211:                        {
                   1212:                            (*s_etat_processus).instruction_courante =
                   1213:                                    chaine_sauvegarde;
                   1214:                            (*s_etat_processus).erreur_systeme =
                   1215:                                    d_es_allocation_memoire;
                   1216:                            return(NULL);
                   1217:                        }
                   1218: 
                   1219:                        sprintf((*s_etat_processus).instruction_courante,
                   1220:                                "'%s'", (unsigned char *)
                   1221:                                (*s_sous_objet_1).objet);
                   1222: 
1.71      bertrand 1223:                        (*s_etat_processus).type_en_cours = NON;
1.1       bertrand 1224:                        recherche_type(s_etat_processus);
                   1225: 
                   1226:                        if ((*s_etat_processus).erreur_execution != d_ex)
                   1227:                        {
                   1228:                            // Aucune erreur d'exécution ne peut être
                   1229:                            // retournée, car l'argument est cohérent.
                   1230: 
                   1231:                            return(NULL);
                   1232:                        }
                   1233: 
                   1234:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1235:                                .l_base_pile), &s_sous_objet_3) == d_erreur)
                   1236:                        {
                   1237:                            return(NULL);
                   1238:                        }
                   1239: 
                   1240:                        free((*s_etat_processus).instruction_courante);
                   1241: 
                   1242:                        (*s_etat_processus).instruction_courante =
                   1243:                                chaine_sauvegarde;
                   1244: 
                   1245:                        if ((*s_sous_objet_3).type == ALG)
                   1246:                        {
                   1247:                            l_atome = (struct_liste_chainee *)
                   1248:                                    (*s_sous_objet_3).objet;
                   1249:                            chaine_fonction = "";
                   1250: 
                   1251:                            while(l_atome != NULL)
                   1252:                            {
                   1253:                                if ((*(*l_atome).donnee).type == FCT)
                   1254:                                {
                   1255:                                    if (strcmp((*((struct_fonction *)
                   1256:                                            (*(*l_atome).donnee).objet))
                   1257:                                            .nom_fonction, ">>") != 0)
                   1258:                                    {
                   1259:                                        chaine_fonction = (*((struct_fonction *)
                   1260:                                                (*(*l_atome).donnee).objet))
                   1261:                                                .nom_fonction;
                   1262:                                    }
                   1263:                                }
                   1264: 
                   1265:                                l_atome = (*l_atome).suivant;
                   1266:                            }
                   1267: 
                   1268:                            if (((strcmp(chaine_fonction, "OR") == 0) ||
1.72      bertrand 1269:                                    (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand 1270:                                    (strcmp(chaine_fonction, "XOR") == 0)) &&
                   1271:                                    (strcmp((*((struct_fonction *)
                   1272:                                    (*(*l_element_courant).donnee).objet))
                   1273:                                    .nom_fonction, "AND") == 0))
                   1274:                            {
                   1275:                                parentheses_groupe_gauche = 2;
                   1276:                            }
                   1277:                        }
                   1278: 
                   1279:                        liberation(s_etat_processus, s_sous_objet_3);
                   1280: 
                   1281:                        chaine_sauvegarde = (*s_etat_processus)
                   1282:                                .instruction_courante;
                   1283: 
                   1284:                        if (((*s_etat_processus).instruction_courante =
                   1285:                                (unsigned char *) malloc((strlen(
                   1286:                                (unsigned char *) (*s_sous_objet_2).objet) + 2
                   1287:                                + 1) * sizeof(unsigned char))) == NULL)
                   1288:                        {
                   1289:                            (*s_etat_processus).instruction_courante =
                   1290:                                    chaine_sauvegarde;
                   1291:                            (*s_etat_processus).erreur_systeme =
                   1292:                                    d_es_allocation_memoire;
                   1293:                            return(NULL);
                   1294:                        }
                   1295: 
                   1296:                        sprintf((*s_etat_processus).instruction_courante,
                   1297:                                "'%s'", (unsigned char *)
                   1298:                                (*s_sous_objet_2).objet);
                   1299: 
1.71      bertrand 1300:                        (*s_etat_processus).type_en_cours = NON;
1.1       bertrand 1301:                        recherche_type(s_etat_processus);
                   1302: 
                   1303:                        if ((*s_etat_processus).erreur_execution != d_ex)
                   1304:                        {
                   1305:                            // Aucune erreur d'exécution ne peut être
                   1306:                            // retournée, car l'argument est cohérent.
                   1307: 
                   1308:                            return(NULL);
                   1309:                        }
                   1310: 
                   1311:                        if (depilement(s_etat_processus, &((*s_etat_processus)
                   1312:                                .l_base_pile), &s_sous_objet_3) == d_erreur)
                   1313:                        {
                   1314:                            return(NULL);
                   1315:                        }
                   1316: 
                   1317:                        free((*s_etat_processus).instruction_courante);
                   1318: 
                   1319:                        (*s_etat_processus).instruction_courante =
                   1320:                                chaine_sauvegarde;
                   1321: 
                   1322:                        if ((*s_sous_objet_3).type == ALG)
                   1323:                        {
                   1324:                            l_atome = (struct_liste_chainee *)
                   1325:                                    (*s_sous_objet_3).objet;
                   1326:                            chaine_fonction = "";
                   1327: 
                   1328:                            while(l_atome != NULL)
                   1329:                            {
                   1330:                                if ((*(*l_atome).donnee).type == FCT)
                   1331:                                {
                   1332:                                    if (strcmp((*((struct_fonction *)
                   1333:                                            (*(*l_atome).donnee).objet))
                   1334:                                            .nom_fonction, ">>") != 0)
                   1335:                                    {
                   1336:                                        chaine_fonction = (*((struct_fonction *)
                   1337:                                                (*(*l_atome).donnee).objet))
                   1338:                                                .nom_fonction;
                   1339:                                    }
                   1340:                                }
                   1341: 
                   1342:                                l_atome = (*l_atome).suivant;
                   1343:                            }
                   1344: 
                   1345:                            if (((strcmp(chaine_fonction, "OR") == 0) ||
1.72      bertrand 1346:                                    (strcmp(chaine_fonction, "EQV") == 0) ||
1.1       bertrand 1347:                                    (strcmp(chaine_fonction, "XOR") == 0)) &&
                   1348:                                    (strcmp((*((struct_fonction *)
                   1349:                                    (*(*l_element_courant).donnee).objet))
                   1350:                                    .nom_fonction, "AND") == 0))
                   1351:                            {
                   1352:                                parentheses_groupe_droit = 2;
                   1353:                            }
                   1354:                        }
                   1355: 
                   1356:                        liberation(s_etat_processus, s_sous_objet_3);
                   1357: 
1.58      bertrand 1358:                        if (((*s_sous_objet).objet = malloc((strlen(
1.1       bertrand 1359:                                (unsigned char *) (*s_sous_objet_1).objet) +
                   1360:                                strlen((*((struct_fonction *)
                   1361:                                (*(*l_element_courant).donnee).objet))
                   1362:                                .nom_fonction) + strlen((unsigned char *)
                   1363:                                (*s_sous_objet_2).objet) + 2 + 1 +
1.58      bertrand 1364:                                ((size_t) parentheses_groupe_gauche) +
                   1365:                                ((size_t) parentheses_groupe_droit)) *
1.1       bertrand 1366:                                sizeof(unsigned char))) == NULL)
                   1367:                        {
                   1368:                            (*s_etat_processus).erreur_systeme =
                   1369:                                    d_es_allocation_memoire;
                   1370:                            return(NULL);
                   1371:                        }
                   1372: 
                   1373:                        sprintf((unsigned char *) (*s_sous_objet).objet,
                   1374:                                (parentheses_groupe_gauche == 0)
                   1375:                                ? ((parentheses_groupe_droit == 0)
                   1376:                                    ? "%s %s %s"
                   1377:                                    : "%s %s (%s)")
                   1378:                                : ((parentheses_groupe_droit == 0)
                   1379:                                    ? "(%s) %s %s"
                   1380:                                    : "(%s) %s (%s)"),
                   1381:                                (unsigned char *) (*s_sous_objet_1)
                   1382:                                .objet, (*((struct_fonction *)
                   1383:                                (*(*l_element_courant).donnee).objet))
                   1384:                                .nom_fonction, (unsigned char *)
                   1385:                                (*s_sous_objet_2).objet);
                   1386: 
                   1387:                        liberation(s_etat_processus, s_sous_objet_1);
                   1388:                        liberation(s_etat_processus, s_sous_objet_2);
                   1389: 
                   1390:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   1391:                                .l_base_pile), s_sous_objet) == d_erreur)
                   1392:                        {
                   1393:                            (*s_etat_processus).erreur_systeme =
                   1394:                                    d_es_allocation_memoire;
                   1395:                            return(NULL);
                   1396:                        }
                   1397:                    }
                   1398:                    else
                   1399:                    {
                   1400:                        nombre_arguments = (*((struct_fonction *)
                   1401:                                (*(*l_element_courant).donnee).objet))
                   1402:                                .nombre_arguments;
                   1403: 
                   1404:                        if ((chaine = (unsigned char *)
                   1405:                                malloc(sizeof(unsigned char))) == NULL)
                   1406:                        {
                   1407:                            (*s_etat_processus).erreur_systeme =
                   1408:                                    d_es_allocation_memoire;
                   1409:                            return(NULL);
                   1410:                        }
                   1411:                        
                   1412:                        chaine[0] = d_code_fin_chaine;
                   1413: 
                   1414:                        for(i = 0; i < nombre_arguments; i++)
                   1415:                        {
                   1416:                            if ((nombre_arguments - i) > 1)
                   1417:                            {
                   1418:                                l_liste1 = (*s_etat_processus).l_base_pile;
                   1419: 
                   1420:                                for(j = 2; j < (nombre_arguments - i); j++)
                   1421:                                {
                   1422:                                    l_liste1 = (*l_liste1).suivant;
                   1423:                                }
                   1424: 
                   1425:                                l_liste2 = (*l_liste1).suivant;
                   1426:                                (*l_liste1).suivant = (*l_liste2).suivant;
                   1427:                                (*l_liste2).suivant = (*s_etat_processus)
                   1428:                                        .l_base_pile;
                   1429:                                (*s_etat_processus).l_base_pile = l_liste2;
                   1430:                            }
                   1431:                            
                   1432:                            if (depilement(s_etat_processus,
                   1433:                                    &((*s_etat_processus).l_base_pile),
                   1434:                                    &s_sous_objet) == d_erreur)
                   1435:                            {
                   1436:                                return(NULL);
                   1437:                            }
                   1438: 
                   1439:                            chaine_sauvegarde = chaine;
                   1440: 
                   1441:                            if (strlen(chaine_sauvegarde) == 0)
                   1442:                            {
                   1443:                                if ((chaine = (unsigned char *) malloc((strlen(
                   1444:                                        (unsigned char *) (*s_sous_objet).objet)
                   1445:                                        + 1) * sizeof(unsigned char))) == NULL)
                   1446:                                {
                   1447:                                    (*s_etat_processus).erreur_systeme =
                   1448:                                            d_es_allocation_memoire;
                   1449:                                    return(NULL);
                   1450:                                }
                   1451: 
                   1452:                                sprintf(chaine, "%s", (unsigned char *)
                   1453:                                        (*s_sous_objet).objet);
                   1454:                            }
                   1455:                            else
                   1456:                            {
                   1457:                                if ((chaine = (unsigned char *) malloc((strlen(
                   1458:                                        chaine_sauvegarde) + 1 + strlen(
                   1459:                                        (unsigned char *) (*s_sous_objet).objet)
                   1460:                                        + 1) * sizeof(unsigned char))) == NULL)
                   1461:                                {
                   1462:                                    (*s_etat_processus).erreur_systeme =
                   1463:                                            d_es_allocation_memoire;
                   1464:                                    return(NULL);
                   1465:                                }
                   1466: 
                   1467:                                sprintf(chaine, "%s,%s", chaine_sauvegarde,
                   1468:                                        (unsigned char *) (*s_sous_objet)
                   1469:                                        .objet);
                   1470:                            }
                   1471: 
                   1472:                            free(chaine_sauvegarde);
                   1473:                            liberation(s_etat_processus, s_sous_objet);
                   1474:                        }
                   1475: 
                   1476:                        chaine_sauvegarde = chaine;
                   1477: 
                   1478:                        if ((chaine = (unsigned char *) malloc((strlen(
                   1479:                                (*((struct_fonction *) (*(*l_element_courant)
                   1480:                                .donnee).objet)).nom_fonction) + 2 +
                   1481:                                strlen(chaine_sauvegarde) + 1) *
                   1482:                                sizeof(unsigned char))) == NULL)
                   1483:                        {
                   1484:                            (*s_etat_processus).erreur_systeme =
                   1485:                                    d_es_allocation_memoire;
                   1486:                            return(NULL);
                   1487:                        }
                   1488: 
                   1489:                        sprintf(chaine, "%s(%s)", (*((struct_fonction *)
                   1490:                                (*(*l_element_courant).donnee).objet))
                   1491:                                .nom_fonction, chaine_sauvegarde);
                   1492:                        free(chaine_sauvegarde);
                   1493: 
                   1494:                        if ((s_sous_objet = allocation(s_etat_processus, CHN))
                   1495:                                == NULL)
                   1496:                        {
                   1497:                            (*s_etat_processus).erreur_systeme =
                   1498:                                    d_es_allocation_memoire;
                   1499:                            return(NULL);
                   1500:                        }
                   1501: 
1.58      bertrand 1502:                        (*s_sous_objet).objet = chaine;
1.1       bertrand 1503: 
                   1504:                        if (empilement(s_etat_processus, &((*s_etat_processus)
                   1505:                                .l_base_pile), s_sous_objet) == d_erreur)
                   1506:                        {
                   1507:                            return(NULL);
                   1508:                        }
                   1509:                    }
                   1510:                }
                   1511:            }
                   1512:            else
                   1513:            {
                   1514:                if ((s_sous_objet = allocation(s_etat_processus, CHN))
                   1515:                        == NULL)
                   1516:                {
                   1517:                    (*s_etat_processus).erreur_systeme =
                   1518:                            d_es_allocation_memoire;
                   1519:                    return(NULL);
                   1520:                }
                   1521: 
1.58      bertrand 1522:                if (((*s_sous_objet).objet = formateur(
1.1       bertrand 1523:                        s_etat_processus, 0, (*l_element_courant).donnee))
                   1524:                        == NULL)
                   1525:                {
                   1526:                    (*s_etat_processus).erreur_systeme =
                   1527:                            d_es_allocation_memoire;
                   1528:                    return(NULL);
                   1529:                }
                   1530: 
                   1531:                if (((*(*l_element_courant).donnee).type == ALG)
                   1532:                        || (((*(*l_element_courant).donnee).type == NOM)
                   1533:                        && ((*((struct_nom *) (*(*l_element_courant)
                   1534:                        .donnee).objet)).symbole == d_vrai)))
                   1535:                {
                   1536:                    chaine_sauvegarde = (unsigned char *) (*s_sous_objet).objet;
                   1537: 
                   1538:                    if (((*s_sous_objet).objet = malloc((strlen(
                   1539:                            chaine_sauvegarde) - 1) *
                   1540:                            sizeof(unsigned char))) == NULL)
                   1541:                    {
                   1542:                        (*s_etat_processus).erreur_systeme =
                   1543:                                d_es_allocation_memoire;
                   1544:                        return(NULL);
                   1545:                    }
                   1546: 
                   1547:                    ptrl = chaine_sauvegarde;
                   1548:                    ptre = (unsigned char *) (*s_sous_objet).objet;
                   1549: 
1.58      bertrand 1550:                    for(ptrl++, i = ((integer8) strlen(chaine_sauvegarde)) - 2;
                   1551:                            i > 0; i--, *ptre++ = *ptrl++);
1.1       bertrand 1552: 
                   1553:                    (*ptre) = d_code_fin_chaine;
                   1554: 
                   1555:                    free(chaine_sauvegarde);
                   1556:                }
                   1557:                else if ((*(*l_element_courant).donnee).type == CHN)
                   1558:                {
                   1559:                    chaine_sauvegarde = (unsigned char *) (*s_sous_objet).objet;
                   1560: 
                   1561:                    if (((*s_sous_objet).objet = malloc((strlen(
                   1562:                            chaine_sauvegarde) + 3) *
                   1563:                            sizeof(unsigned char))) == NULL)
                   1564:                    {
                   1565:                        (*s_etat_processus).erreur_systeme =
                   1566:                                d_es_allocation_memoire;
                   1567:                        return(NULL);
                   1568:                    }
                   1569: 
                   1570:                    sprintf((unsigned char *) (*s_sous_objet).objet,
                   1571:                            "\"%s\"", chaine_sauvegarde);
                   1572: 
                   1573:                    free(chaine_sauvegarde);
                   1574:                }
                   1575: 
                   1576:                if (empilement(s_etat_processus, &((*s_etat_processus)
                   1577:                        .l_base_pile), s_sous_objet) == d_erreur)
                   1578:                {
                   1579:                    return(NULL);
                   1580:                }
                   1581:            }
                   1582: 
                   1583:            l_element_courant = (*l_element_courant).suivant;
                   1584:        }
                   1585: 
                   1586:        if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
                   1587:                &s_sous_objet) == d_erreur)
                   1588:        {
                   1589:            return(NULL);
                   1590:        }
                   1591: 
                   1592:        if ((chaine = (unsigned char *) malloc((strlen((unsigned char *)
                   1593:                (*s_sous_objet).objet) + 2 + 1) * sizeof(unsigned char)))
                   1594:                == NULL)
                   1595:        {
                   1596:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1597:            return(NULL);
                   1598:        }
                   1599: 
                   1600:        sprintf(chaine, "'%s'", (unsigned char *) (*s_sous_objet).objet);
                   1601:        liberation(s_etat_processus, s_sous_objet);
                   1602:    }
                   1603:    else if ((*s_objet).type == BIN)
                   1604:    {
                   1605: 
                   1606: /*
                   1607: --------------------------------------------------------------------------------
                   1608:   Entier binaire en base 2, 8, 10 ou 16
                   1609: --------------------------------------------------------------------------------
                   1610: */
                   1611: 
                   1612:        masque_binaire = masque_entiers_binaires(s_etat_processus);
                   1613: 
                   1614:        if ((test_cfsf(s_etat_processus, 43) == d_faux) &&
                   1615:                (test_cfsf(s_etat_processus, 44) == d_faux))
                   1616:        {
                   1617: 
                   1618: /*
                   1619: -- Base décimale ---------------------------------------------------------------
                   1620: */
                   1621: 
1.63      bertrand 1622:            sprintf(tampon, "%llu", (*((unsigned long long *)
1.1       bertrand 1623:                    ((*s_objet).objet))) & masque_binaire);
                   1624:            strcpy(base, "d");
                   1625:        }
                   1626:        else if ((test_cfsf(s_etat_processus, 43) == d_vrai) &&
                   1627:                (test_cfsf(s_etat_processus, 44) == d_faux))
                   1628:        {
                   1629: 
                   1630: /*
                   1631: -- Base octale -----------------------------------------------------------------
                   1632: */
                   1633: 
1.63      bertrand 1634:            sprintf(tampon, "%llo", (*((unsigned long long *)
1.1       bertrand 1635:                    ((*s_objet).objet))) & masque_binaire);
                   1636:            strcpy(base, "o");
                   1637:        }
                   1638:        else if (test_cfsf(s_etat_processus, 44) == d_vrai)
                   1639:        {
                   1640: 
                   1641: /*
                   1642: -- Bases hexadécimale et binaire -----------------------------------------------
                   1643: */
                   1644: 
1.63      bertrand 1645:            sprintf(tampon, "%llX", (*((unsigned long long *)
1.1       bertrand 1646:                    ((*s_objet).objet))) & masque_binaire);
                   1647: 
                   1648:            if (test_cfsf(s_etat_processus, 43) == d_vrai)
                   1649:            {
                   1650:                strcpy(base, "h");
                   1651:            }
                   1652:            else
                   1653:            {
                   1654:                chaine = (unsigned char *) malloc((strlen(tampon) + 1)
                   1655:                        * sizeof(unsigned char));
                   1656: 
                   1657:                if (chaine == NULL)
                   1658:                {
                   1659:                    (*s_etat_processus).erreur_systeme =
                   1660:                            d_es_allocation_memoire;
                   1661:                    return(NULL);
                   1662:                }
                   1663: 
                   1664:                strcpy(chaine, tampon);
                   1665:                tampon[0] = 0;
                   1666: 
1.58      bertrand 1667:                for(i = 0; i < (integer8) strlen(chaine); i++)
1.1       bertrand 1668:                {
                   1669:                    switch(chaine[i])
                   1670:                    {
                   1671:                        case '0' :
                   1672:                        {
                   1673:                            strcat(tampon, (i != 0) ? "0000" : "0");
                   1674:                            break;
                   1675:                        }
                   1676:                        case '1' :
                   1677:                        {
                   1678:                                strcat(tampon, (i != 0) ? "0001" : "1");
                   1679:                            break;
                   1680:                        }
                   1681:                        case '2' :
                   1682:                        {
                   1683:                            strcat(tampon, (i != 0) ? "0010" : "10");
                   1684:                            break;
                   1685:                        }
                   1686:                        case '3' :
                   1687:                        {
                   1688:                            strcat(tampon, (i != 0) ? "0011" : "11");
                   1689:                            break;
                   1690:                        }
                   1691:                        case '4' :
                   1692:                        {
                   1693:                            strcat(tampon, (i != 0) ? "0100" : "100");
                   1694:                            break;
                   1695:                        }
                   1696:                        case '5' :
                   1697:                        {
                   1698:                            strcat(tampon, (i != 0) ? "0101" : "101");
                   1699:                            break;
                   1700:                        }
                   1701:                        case '6' :
                   1702:                        {
                   1703:                            strcat(tampon, (i != 0) ? "0110" : "110");
                   1704:                            break;
                   1705:                        }
                   1706:                        case '7' :
                   1707:                        {
                   1708:                            strcat(tampon, (i != 0) ? "0111" : "111");
                   1709:                            break;
                   1710:                        }
                   1711:                        case '8' :
                   1712:                        {
                   1713:                            strcat(tampon, "1000");
                   1714:                            break;
                   1715:                        }
                   1716:                        case '9' :
                   1717:                        {
                   1718:                            strcat(tampon, "1001");
                   1719:                            break;
                   1720:                        }
                   1721:                        case 'A' :
                   1722:                        {
                   1723:                            strcat(tampon, "1010");
                   1724:                            break;
                   1725:                        }
                   1726:                        case 'B' :
                   1727:                        {
                   1728:                            strcat(tampon, "1011");
                   1729:                            break;
                   1730:                        }
                   1731:                        case 'C' :
                   1732:                        {
                   1733:                            strcat(tampon, "1100");
                   1734:                            break;
                   1735:                        }
                   1736:                        case 'D' :
                   1737:                        {
                   1738:                            strcat(tampon, "1101");
                   1739:                            break;
                   1740:                        }
                   1741:                        case 'E' :
                   1742:                        {
                   1743:                            strcat(tampon, "1110");
                   1744:                            break;
                   1745:                        }
                   1746:                        case 'F' :
                   1747:                        {
                   1748:                            strcat(tampon, "1111");
                   1749:                            break;
                   1750:                        }
                   1751:                    }
                   1752:                }
                   1753: 
                   1754:                free(chaine);
                   1755:                strcpy(base, "b");
                   1756:            }
                   1757:        }
                   1758: 
                   1759:        chaine = (unsigned char *) malloc((strlen(tampon) + 4)
                   1760:                * sizeof(unsigned char));
                   1761: 
                   1762:        if (chaine == NULL)
                   1763:        {
                   1764:            (*s_etat_processus).erreur_systeme =
                   1765:                    d_es_allocation_memoire;
                   1766:            return(NULL);
                   1767:        }
                   1768: 
                   1769:        strcpy(chaine, "# ");
                   1770: 
                   1771:        strcat(chaine, tampon);
                   1772:        strcat(chaine, base);
                   1773:    }
                   1774:    else if ((*s_objet).type == CHN)
                   1775:    {
                   1776: 
                   1777: /*
                   1778: --------------------------------------------------------------------------------
                   1779:   Chaîne de caractères
                   1780: --------------------------------------------------------------------------------
                   1781: */
                   1782: 
1.23      bertrand 1783:        if (((*s_etat_processus).autorisation_conversion_chaine == 'Y') &&
                   1784:                (test_cfsf(s_etat_processus, 34) == d_vrai))
1.5       bertrand 1785:        {
1.41      bertrand 1786:            if ((chaine = formateur_flux(s_etat_processus,
                   1787:                    (unsigned char *) (*s_objet).objet, &longueur_chaine))
                   1788:                    == NULL)
1.5       bertrand 1789:            {
1.41      bertrand 1790:                return(NULL);
1.5       bertrand 1791:            }
1.41      bertrand 1792:        }
                   1793:        else
                   1794:        {
                   1795:            if ((chaine = malloc((strlen((unsigned char *)
                   1796:                    ((*s_objet).objet)) + 1) * sizeof(unsigned char))) == NULL)
1.5       bertrand 1797:            {
                   1798:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1799:                return(NULL);
                   1800:            }
1.41      bertrand 1801: 
1.5       bertrand 1802:            strcpy(chaine, (unsigned char *) ((*s_objet).objet));
                   1803:        }
1.1       bertrand 1804:    }
                   1805:    else if ((*s_objet).type == CPL)
                   1806:    {
                   1807: 
                   1808: /*
                   1809: --------------------------------------------------------------------------------
                   1810:   Complexe
                   1811: --------------------------------------------------------------------------------
                   1812: */
                   1813: 
1.58      bertrand 1814:        chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 1815:                ((struct_complexe16 *) ((*s_objet).objet)), 'C');
                   1816: 
                   1817:        if (chaine_formatee == NULL)
                   1818:        {
                   1819:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1820:            return(NULL);
                   1821:        }
                   1822: 
                   1823:        chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   1824:                + 1) * sizeof(unsigned char));
                   1825: 
                   1826:        if (chaine == NULL)
                   1827:        {
                   1828:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1829:            return(NULL);
                   1830:        }
                   1831: 
                   1832:        strcpy(chaine, chaine_formatee);
                   1833:        free(chaine_formatee);
                   1834:    }
                   1835:    else if ((*s_objet).type == RPN)
                   1836:    {
                   1837: 
                   1838: /*
                   1839: --------------------------------------------------------------------------------
                   1840:   Définition
                   1841: --------------------------------------------------------------------------------
                   1842: */
                   1843: 
                   1844:        l_element_courant = (struct_liste_chainee *) ((*s_objet).objet);
                   1845:        chaine_sauvegarde = chaine;
                   1846: 
                   1847:        while(l_element_courant != NULL)
                   1848:        {
1.57      bertrand 1849:            if ((chaine_formatee = formateur(s_etat_processus, offset_initial,
1.1       bertrand 1850:                    (*l_element_courant).donnee)) == NULL)
                   1851:            {
                   1852:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1853:                return(NULL);
                   1854:            }
                   1855: 
                   1856:            if ((*(*l_element_courant).donnee).type == CHN)
                   1857:            {
                   1858:                chaine_tampon = chaine_formatee;
                   1859: 
                   1860:                if ((chaine_formatee = (unsigned char *) malloc((strlen(
                   1861:                        chaine_tampon) + 3) * sizeof(unsigned char))) == NULL)
                   1862:                {
                   1863:                    (*s_etat_processus).erreur_systeme =
                   1864:                            d_es_allocation_memoire;
                   1865:                    return(NULL);
                   1866:                }
                   1867: 
                   1868:                sprintf(chaine_formatee, "\"%s\"", chaine_tampon);
                   1869:                free(chaine_tampon);
                   1870:            }
                   1871: 
                   1872:            l_element_courant = (*l_element_courant).suivant;
                   1873: 
                   1874:            if (chaine != NULL)
                   1875:            {
                   1876:                chaine_sauvegarde = chaine;
                   1877: 
                   1878:                if ((chaine = (unsigned char *) malloc((strlen(
                   1879:                        chaine_sauvegarde) + strlen(chaine_formatee) + 2) *
                   1880:                        sizeof(unsigned char))) == NULL)
                   1881:                {
                   1882:                    (*s_etat_processus).erreur_systeme =
                   1883:                            d_es_allocation_memoire;
                   1884:                    return(NULL);
                   1885:                }
                   1886: 
                   1887:                strcpy(chaine, chaine_sauvegarde);
                   1888:                free(chaine_sauvegarde);
                   1889:                strcat(chaine, " ");
                   1890:                strcat(chaine, chaine_formatee);
                   1891:                free(chaine_formatee);
                   1892:            }
                   1893:            else
                   1894:            {
                   1895:                chaine = chaine_formatee;
                   1896:            }
                   1897:        }
                   1898: 
                   1899:        chaine_sauvegarde = chaine;
                   1900:        chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde) + 1) *
                   1901:                sizeof(unsigned char));
                   1902: 
                   1903:        if (chaine == NULL)
                   1904:        {
                   1905:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1906:            return(NULL);
                   1907:        }
                   1908: 
                   1909:        chaine_sauvegarde[strlen(chaine_sauvegarde)] = d_code_fin_chaine;
                   1910:        strcpy(chaine, chaine_sauvegarde);
                   1911:        free(chaine_sauvegarde);
                   1912:    }
                   1913:    else if ((*s_objet).type == INT)
                   1914:    {
                   1915: 
                   1916: /*
                   1917: --------------------------------------------------------------------------------
                   1918:   Entier
                   1919: --------------------------------------------------------------------------------
                   1920: */
                   1921: 
1.58      bertrand 1922:        chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 1923:                ((integer8 *) ((*s_objet).objet)), 'I');
                   1924: 
                   1925:        if (chaine_formatee == NULL)
                   1926:        {
                   1927:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1928:            return(NULL);
                   1929:        }
                   1930: 
                   1931:        chaine = (unsigned char *) malloc((strlen(chaine_formatee) + 1)
                   1932:                * sizeof(unsigned char));
                   1933: 
                   1934:        if (chaine == NULL)
                   1935:        {
                   1936:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1937:            return(NULL);
                   1938:        }
                   1939: 
                   1940:        strcpy(chaine, chaine_formatee);
                   1941:        free(chaine_formatee);
                   1942:    }
                   1943:    else if ((*s_objet).type == FCT)
                   1944:    {
                   1945: 
                   1946: /*
                   1947: --------------------------------------------------------------------------------
                   1948:   Fonction
                   1949: --------------------------------------------------------------------------------
                   1950: */
                   1951: 
                   1952:        chaine = (unsigned char *) malloc((strlen((*((struct_fonction *)
                   1953:                ((*s_objet).objet))).nom_fonction) + 1) *
                   1954:                sizeof(unsigned char));
                   1955: 
                   1956:        if (chaine == NULL)
                   1957:        {
                   1958:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1959:            return(NULL);
                   1960:        }
                   1961: 
                   1962:        strcpy(chaine, (unsigned char *) (*((struct_fonction *)
                   1963:                ((*s_objet).objet))).nom_fonction);
                   1964:    }
                   1965:    else if ((*s_objet).type == TBL)
                   1966:    {
                   1967: 
                   1968: /*
                   1969: --------------------------------------------------------------------------------
                   1970:   Tableau
                   1971: --------------------------------------------------------------------------------
                   1972: */
                   1973: 
                   1974:        chaine = (unsigned char *) malloc(4 * sizeof(unsigned char));
                   1975: 
                   1976:        if (chaine == NULL)
                   1977:        {
                   1978:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1979:            return(NULL);
                   1980:        }
                   1981: 
                   1982:        strcpy(chaine, "<[ ");
1.58      bertrand 1983:        offset = ((integer8) strlen(chaine)) + offset_initial;
1.1       bertrand 1984: 
                   1985:        for(i = 0; i < (*((struct_tableau *) (*s_objet).objet))
                   1986:                .nombre_elements; i++)
                   1987:        {
                   1988:            chaine_sauvegarde = chaine;
1.60      bertrand 1989:            chaine_formatee = formateur(s_etat_processus, (long) offset,
1.1       bertrand 1990:                    (*((struct_tableau *) (*s_objet).objet)).elements[i]);
                   1991: 
                   1992:            if (chaine_formatee == NULL)
                   1993:            {
                   1994:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1995:                return(NULL);
                   1996:            }
                   1997: 
                   1998:            if ((*(*((struct_tableau *) (*s_objet).objet)).elements[i])
                   1999:                    .type == CHN)
                   2000:            {
                   2001:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2002:                        + strlen(chaine_sauvegarde) + 3)
                   2003:                        * sizeof(unsigned char));
                   2004: 
                   2005:                if (chaine == NULL)
                   2006:                {
                   2007:                    (*s_etat_processus).erreur_systeme =
                   2008:                            d_es_allocation_memoire;
                   2009:                    return(NULL);
                   2010:                }
                   2011: 
                   2012:                strcpy(chaine, chaine_sauvegarde);
                   2013:                free(chaine_sauvegarde);
                   2014:                strcat(chaine, "\"");
                   2015:                strcat(chaine, chaine_formatee);
                   2016:                free(chaine_formatee);
                   2017:                strcat(chaine, "\"");
                   2018:            }
                   2019:            else if ((*(*((struct_tableau *) (*s_objet).objet))
                   2020:                    .elements[i]).type == CHN)
                   2021:            {
                   2022:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2023:                        + strlen(chaine_sauvegarde) + 1)
                   2024:                        * sizeof(unsigned char));
                   2025: 
                   2026:                if (chaine == NULL)
                   2027:                {
                   2028:                    (*s_etat_processus).erreur_systeme =
                   2029:                            d_es_allocation_memoire;
                   2030:                    return(NULL);
                   2031:                }
                   2032: 
                   2033:                sprintf(chaine, "%s%s", chaine_sauvegarde, chaine_formatee);
                   2034:                free(chaine_sauvegarde);
                   2035:                free(chaine_formatee);
                   2036:            }
                   2037:            else
                   2038:            {
                   2039:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2040:                        + strlen(chaine_sauvegarde) + 1)
                   2041:                        * sizeof(unsigned char));
                   2042: 
                   2043:                if (chaine == NULL)
                   2044:                {
                   2045:                    (*s_etat_processus).erreur_systeme =
                   2046:                            d_es_allocation_memoire;
                   2047:                    return(NULL);
                   2048:                }
                   2049: 
                   2050:                sprintf(chaine, "%s%s", chaine_sauvegarde, chaine_formatee);
                   2051:                free(chaine_sauvegarde);
                   2052:                free(chaine_formatee);
                   2053:            }
                   2054: 
                   2055:            if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2056:            {
                   2057:                chaine_sauvegarde = chaine;
                   2058: 
                   2059:                chaine = (unsigned char *) malloc(
                   2060:                        (strlen(chaine_sauvegarde) + 2)
                   2061:                        * sizeof(unsigned char));
                   2062: 
                   2063:                if (chaine == NULL)
                   2064:                {
                   2065:                    (*s_etat_processus).erreur_systeme =
                   2066:                            d_es_allocation_memoire;
                   2067:                    return(NULL);
                   2068:                }
                   2069: 
                   2070:                strcpy(chaine, chaine_sauvegarde);
                   2071:                free(chaine_sauvegarde);
                   2072:                strcat(chaine, "\n");
                   2073: 
                   2074:                if ((*((struct_tableau *) (*s_objet).objet))
                   2075:                        .nombre_elements != (i + 1))
                   2076:                {
                   2077:                    chaine_sauvegarde = chaine;
                   2078: 
                   2079:                    chaine = (unsigned char *) malloc(
1.58      bertrand 2080:                            (strlen(chaine_sauvegarde) + 1 + ((size_t) offset))
1.1       bertrand 2081:                            * sizeof(unsigned char));
                   2082: 
                   2083:                    if (chaine == NULL)
                   2084:                    {
                   2085:                        (*s_etat_processus).erreur_systeme =
                   2086:                                d_es_allocation_memoire;
                   2087:                        return(NULL);
                   2088:                    }
                   2089: 
                   2090:                    strcpy(chaine, chaine_sauvegarde);
                   2091:                    free(chaine_sauvegarde);
                   2092:                    ptre = &(chaine[strlen(chaine)]);
                   2093: 
                   2094:                    for(k = 0; k < offset; k++, *(ptre++) = ' ');
                   2095: 
                   2096:                    (*ptre) = d_code_fin_chaine;
                   2097:                }
                   2098:            }
                   2099:            else
                   2100:            {
                   2101:                if ((*((struct_tableau *) (*s_objet).objet))
                   2102:                        .nombre_elements != (i + 1))
                   2103:                {
                   2104:                    chaine_sauvegarde = chaine;
                   2105: 
                   2106:                    chaine = (unsigned char *) malloc(
                   2107:                            (strlen(chaine_sauvegarde) + 2)
                   2108:                            * sizeof(unsigned char));
                   2109: 
                   2110:                    if (chaine == NULL)
                   2111:                    {
                   2112:                        (*s_etat_processus).erreur_systeme =
                   2113:                                d_es_allocation_memoire;
                   2114:                        return(NULL);
                   2115:                    }
                   2116: 
                   2117:                    strcpy(chaine, chaine_sauvegarde);
                   2118:                    free(chaine_sauvegarde);
                   2119:                    strcat(chaine, " ");
                   2120:                }
                   2121:            }
                   2122:        }
                   2123: 
                   2124:        if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2125:        {
                   2126:            if (chaine[strlen(chaine) - 1] == '\n')
                   2127:            {
                   2128:                chaine[strlen(chaine) - 1] = d_code_fin_chaine;
                   2129:            }
                   2130:        }
                   2131: 
                   2132:        if ((*((struct_tableau *) (*s_objet).objet)).nombre_elements != 0)
                   2133:        {
                   2134:            chaine_sauvegarde = chaine;
                   2135:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde) + 4)
                   2136:                    * sizeof(unsigned char));
                   2137: 
                   2138:            if (chaine == NULL)
                   2139:            {
                   2140:                (*s_etat_processus).erreur_systeme =
                   2141:                        d_es_allocation_memoire;
                   2142:                return(NULL);
                   2143:            }
                   2144: 
                   2145:            strcpy(chaine, chaine_sauvegarde);
                   2146:            free(chaine_sauvegarde);
                   2147:            strcat(chaine, " ]>");
                   2148:        }
                   2149:        else
                   2150:        {
                   2151:            chaine_sauvegarde = chaine;
                   2152:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde) + 3)
                   2153:                    * sizeof(unsigned char));
                   2154: 
                   2155:            if (chaine == NULL)
                   2156:            {
                   2157:                (*s_etat_processus).erreur_systeme =
                   2158:                        d_es_allocation_memoire;
                   2159:                return(NULL);
                   2160:            }
                   2161: 
                   2162:            strcpy(chaine, chaine_sauvegarde);
                   2163:            free(chaine_sauvegarde);
                   2164:            strcat(chaine, "]>");
                   2165:        }
                   2166:    }
                   2167:    else if ((*s_objet).type == LST)
                   2168:    {
                   2169: 
                   2170: /*
                   2171: --------------------------------------------------------------------------------
                   2172:   Liste
                   2173: --------------------------------------------------------------------------------
                   2174: */
                   2175: 
                   2176:        chaine = (unsigned char *) malloc(3 * sizeof(unsigned char));
                   2177: 
                   2178:        if (chaine == NULL)
                   2179:        {
                   2180:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   2181:            return(NULL);
                   2182:        }
                   2183: 
                   2184:        strcpy(chaine, "{ ");
                   2185: 
                   2186:        l_element_courant = (struct_liste_chainee *) ((*s_objet).objet);
                   2187:        nombre_elements = 0;
1.58      bertrand 2188:        offset = ((integer8) strlen(chaine)) + offset_initial;
1.1       bertrand 2189: 
                   2190:        while(l_element_courant != NULL)
                   2191:        {
                   2192:            chaine_sauvegarde = chaine;
1.60      bertrand 2193:            chaine_formatee = formateur(s_etat_processus, (long) offset,
1.1       bertrand 2194:                    (*l_element_courant).donnee);
                   2195: 
                   2196:            if (chaine_formatee == NULL)
                   2197:            {
                   2198:                (*s_etat_processus).erreur_systeme =
                   2199:                        d_es_allocation_memoire;
                   2200:                return(NULL);
                   2201:            }
                   2202: 
                   2203:            if ((*(*l_element_courant).donnee).type == CHN)
                   2204:            {
                   2205:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2206:                        + strlen(chaine_sauvegarde) + 3)
                   2207:                        * sizeof(unsigned char));
                   2208: 
                   2209:                if (chaine == NULL)
                   2210:                {
                   2211:                    (*s_etat_processus).erreur_systeme =
                   2212:                            d_es_allocation_memoire;
                   2213:                    return(NULL);
                   2214:                }
                   2215: 
                   2216:                strcpy(chaine, chaine_sauvegarde);
                   2217:                free(chaine_sauvegarde);
                   2218:                strcat(chaine, "\"");
                   2219:                strcat(chaine, chaine_formatee);
                   2220:                free(chaine_formatee);
                   2221:                strcat(chaine, "\"");
                   2222:            }
                   2223:            else if ((*(*l_element_courant).donnee).type == NOM)
                   2224:            {
                   2225:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2226:                        + strlen(chaine_sauvegarde) + 1)
                   2227:                        * sizeof(unsigned char));
                   2228: 
                   2229:                if (chaine == NULL)
                   2230:                {
                   2231:                    (*s_etat_processus).erreur_systeme =
                   2232:                            d_es_allocation_memoire;
                   2233:                    return(NULL);
                   2234:                }
                   2235: 
                   2236:                sprintf(chaine, "%s%s", chaine_sauvegarde, chaine_formatee);
                   2237:                free(chaine_sauvegarde);
                   2238:                free(chaine_formatee);
                   2239:            }
                   2240:            else
                   2241:            {
                   2242:                chaine = (unsigned char *) malloc((strlen(chaine_formatee)
                   2243:                        + strlen(chaine_sauvegarde) + 1)
                   2244:                        * sizeof(unsigned char));
                   2245: 
                   2246:                if (chaine == NULL)
                   2247:                {
                   2248:                    (*s_etat_processus).erreur_systeme =
                   2249:                            d_es_allocation_memoire;
                   2250:                    return(NULL);
                   2251:                }
                   2252: 
                   2253:                sprintf(chaine, "%s%s", chaine_sauvegarde, chaine_formatee);
                   2254:                free(chaine_sauvegarde);
                   2255:                free(chaine_formatee);
                   2256:            }
                   2257: 
                   2258:            if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2259:            {
                   2260:                chaine_sauvegarde = chaine;
                   2261: 
                   2262:                chaine = (unsigned char *) malloc(
                   2263:                        (strlen(chaine_sauvegarde) + 2)
                   2264:                        * sizeof(unsigned char));
                   2265: 
                   2266:                if (chaine == NULL)
                   2267:                {
                   2268:                    (*s_etat_processus).erreur_systeme =
                   2269:                            d_es_allocation_memoire;
                   2270:                    return(NULL);
                   2271:                }
                   2272: 
                   2273:                strcpy(chaine, chaine_sauvegarde);
                   2274:                free(chaine_sauvegarde);
                   2275:                strcat(chaine, "\n");
                   2276: 
                   2277:                if ((*l_element_courant).suivant != NULL)
                   2278:                {
                   2279:                    chaine_sauvegarde = chaine;
                   2280: 
                   2281:                    chaine = (unsigned char *) malloc(
1.58      bertrand 2282:                            (strlen(chaine_sauvegarde) + 1 + ((size_t) offset))
1.1       bertrand 2283:                            * sizeof(unsigned char));
                   2284: 
                   2285:                    if (chaine == NULL)
                   2286:                    {
                   2287:                        (*s_etat_processus).erreur_systeme =
                   2288:                                d_es_allocation_memoire;
                   2289:                        return(NULL);
                   2290:                    }
                   2291: 
                   2292:                    strcpy(chaine, chaine_sauvegarde);
                   2293:                    free(chaine_sauvegarde);
                   2294:                    ptre = &(chaine[strlen(chaine)]);
                   2295: 
                   2296:                    for(k = 0; k < offset; k++, *(ptre++) = ' ');
                   2297: 
                   2298:                    (*ptre) = d_code_fin_chaine;
                   2299:                }
                   2300:            }
                   2301:            else
                   2302:            {
                   2303:                if ((*l_element_courant).suivant != NULL)
                   2304:                {
                   2305:                    chaine_sauvegarde = chaine;
                   2306: 
                   2307:                    chaine = (unsigned char *) malloc(
                   2308:                            (strlen(chaine_sauvegarde) + 2)
                   2309:                            * sizeof(unsigned char));
                   2310: 
                   2311:                    if (chaine == NULL)
                   2312:                    {
                   2313:                        (*s_etat_processus).erreur_systeme =
                   2314:                                d_es_allocation_memoire;
                   2315:                        return(NULL);
                   2316:                    }
                   2317: 
                   2318:                    strcpy(chaine, chaine_sauvegarde);
                   2319:                    free(chaine_sauvegarde);
                   2320:                    strcat(chaine, " ");
                   2321:                }
                   2322:            }
                   2323: 
                   2324:            nombre_elements++;
                   2325:            l_element_courant = (*l_element_courant).suivant;
                   2326:        }
                   2327: 
                   2328:        if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2329:        {
                   2330:            if (chaine[strlen(chaine) - 1] == '\n')
                   2331:            {
                   2332:                chaine[strlen(chaine) - 1] = d_code_fin_chaine;
                   2333:            }
                   2334:        }
                   2335: 
                   2336:        if (nombre_elements != 0)
                   2337:        {
                   2338:            chaine_sauvegarde = chaine;
                   2339:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde) + 3)
                   2340:                    * sizeof(unsigned char));
                   2341: 
                   2342:            if (chaine == NULL)
                   2343:            {
                   2344:                (*s_etat_processus).erreur_systeme =
                   2345:                        d_es_allocation_memoire;
                   2346:                return(NULL);
                   2347:            }
                   2348: 
                   2349:            strcpy(chaine, chaine_sauvegarde);
                   2350:            free(chaine_sauvegarde);
                   2351:            strcat(chaine, " }");
                   2352:        }
                   2353:        else
                   2354:        {
                   2355:            chaine_sauvegarde = chaine;
                   2356:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde) + 2)
                   2357:                    * sizeof(unsigned char));
                   2358: 
                   2359:            if (chaine == NULL)
                   2360:            {
                   2361:                (*s_etat_processus).erreur_systeme =
                   2362:                        d_es_allocation_memoire;
                   2363:                return(NULL);
                   2364:            }
                   2365: 
                   2366:            strcpy(chaine, chaine_sauvegarde);
                   2367:            free(chaine_sauvegarde);
                   2368:            strcat(chaine, "}");
                   2369:        }
                   2370:    }
                   2371:    else if ((*s_objet).type == MCX)
                   2372:    {
                   2373: 
                   2374: /*
                   2375: --------------------------------------------------------------------------------
                   2376:   Matrice complexe
                   2377: --------------------------------------------------------------------------------
                   2378: */
                   2379: 
                   2380:        nombre_lignes = (*((struct_matrice *) ((*s_objet).objet)))
                   2381:                .nombre_lignes;
                   2382:        nombre_colonnes = (*((struct_matrice *) ((*s_objet).objet)))
                   2383:                .nombre_colonnes;
                   2384: 
                   2385:        chaine = (unsigned char *) malloc(3 * sizeof(unsigned char));
                   2386: 
                   2387:        if (chaine != NULL)
                   2388:        {
                   2389:            strcpy(chaine, "[[");
1.58      bertrand 2390:            offset = ((integer8) strlen(chaine)) + offset_initial - 1;
1.1       bertrand 2391: 
1.59      bertrand 2392:            if ((longueurs_maximales = malloc(sizeof(integer8) * 2 *
1.58      bertrand 2393:                    ((size_t) nombre_colonnes))) == NULL)
1.1       bertrand 2394:            {
                   2395:                (*s_etat_processus).erreur_systeme =
                   2396:                        d_es_allocation_memoire;
                   2397:                return(NULL);
                   2398:            }
                   2399: 
                   2400:            if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2401:            {
                   2402:                for(j = 0; j < (2 * nombre_colonnes); j++)
                   2403:                {
                   2404:                    longueurs_maximales[j] = 0;
                   2405:                }
                   2406: 
                   2407:                for(i = 0; i < nombre_lignes; i++)
                   2408:                {
                   2409:                    for(j = 0; j < nombre_colonnes; j++)
                   2410:                    {
                   2411:                        chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2412:                                &(((struct_complexe16 **)
1.1       bertrand 2413:                                ((*((struct_matrice *)
                   2414:                                ((*s_objet).objet))).tableau))[i][j]), 'C');
                   2415: 
                   2416:                        if (chaine_formatee == NULL)
                   2417:                        {
                   2418:                            (*s_etat_processus).erreur_systeme =
                   2419:                                    d_es_allocation_memoire;
                   2420:                            return(NULL);
                   2421:                        }
                   2422: 
1.58      bertrand 2423:                        longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2424:                        longueur_decimale_courante = 0;
                   2425: 
                   2426:                        if ((ptrl = index(chaine_formatee,
                   2427:                                (test_cfsf(s_etat_processus, 48) == d_vrai)
                   2428:                                ? '.' : ',')) != NULL)
                   2429:                        {
                   2430:                            longueur_decimale_courante = longueur_courante
                   2431:                                    - (ptrl - chaine_formatee);
                   2432:                            longueur_courante = ptrl - chaine_formatee;
                   2433:                        }
                   2434: 
                   2435:                        free(chaine_formatee);
                   2436: 
                   2437:                        if (longueurs_maximales[2 * j] < longueur_courante)
                   2438:                        {
                   2439:                            longueurs_maximales[2 * j] = longueur_courante;
                   2440:                        }
                   2441: 
                   2442:                        if (longueurs_maximales[(2 * j) + 1] <
                   2443:                                longueur_decimale_courante)
                   2444:                        {
                   2445:                            longueurs_maximales[(2 * j) + 1] =
                   2446:                                    longueur_decimale_courante;
                   2447:                        }
                   2448:                    }
                   2449:                }
                   2450:            }
                   2451: 
                   2452:            for(i = 0; i < nombre_lignes; i++)
                   2453:            {
                   2454:                for(j = 0; j < nombre_colonnes; j++)
                   2455:                {
                   2456:                    chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2457:                            &(((struct_complexe16 **)
1.1       bertrand 2458:                            ((*((struct_matrice *)
                   2459:                            ((*s_objet).objet))).tableau))[i][j]), 'C');
                   2460: 
                   2461:                    if (chaine_formatee == NULL)
                   2462:                    {
                   2463:                        (*s_etat_processus).erreur_systeme =
                   2464:                                d_es_allocation_memoire;
                   2465:                        return(NULL);
                   2466:                    }
                   2467: 
1.58      bertrand 2468:                    longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2469:                    longueur_decimale_courante = 0;
                   2470: 
                   2471:                    if ((ptrl = index(chaine_formatee,
                   2472:                            (test_cfsf(s_etat_processus, 48) == d_vrai)
                   2473:                            ? '.' : ',')) != NULL)
                   2474:                    {
                   2475:                        longueur_decimale_courante = longueur_courante
                   2476:                                - (ptrl - chaine_formatee);
                   2477:                        longueur_courante = ptrl - chaine_formatee;
                   2478:                    }
                   2479: 
                   2480:                    chaine_sauvegarde = chaine;
                   2481: 
                   2482:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2483:                    {
                   2484: 
                   2485:                        chaine = (unsigned char *) malloc(
                   2486:                                (strlen(chaine_sauvegarde) +
1.58      bertrand 2487:                                ((size_t) longueur_courante) +
                   2488:                                ((size_t) longueur_decimale_courante) +
                   2489:                                ((size_t) longueurs_maximales[2 * j]) +
                   2490:                                ((size_t) longueurs_maximales[(2 * j) + 1]) + 2)
1.1       bertrand 2491:                                * sizeof(unsigned char));
                   2492: 
                   2493:                        if (chaine == NULL)
                   2494:                        {
                   2495:                            (*s_etat_processus).erreur_systeme =
                   2496:                                    d_es_allocation_memoire;
                   2497:                            return(NULL);
                   2498:                        }
                   2499: 
                   2500:                        strcpy(chaine, chaine_sauvegarde);
                   2501:                        free(chaine_sauvegarde);
                   2502:                        strcat(chaine, " ");
                   2503: 
                   2504:                        ptre = &(chaine[strlen(chaine)]);
                   2505: 
                   2506:                        for (k = 0; k < (longueurs_maximales[2 * j]
                   2507:                                - longueur_courante); k++, *(ptre++) = ' ');
                   2508: 
                   2509:                        (*ptre) = d_code_fin_chaine;
                   2510:                        strcat(chaine, chaine_formatee);
                   2511:                        ptre = &(chaine[strlen(chaine)]);
                   2512: 
                   2513:                        for(k = 0; k < (longueurs_maximales[(2 * j) + 1]
                   2514:                                - longueur_decimale_courante);
                   2515:                                k++, *(ptre++) = ' ');
                   2516: 
                   2517:                        (*ptre) = d_code_fin_chaine;
                   2518:                    }
                   2519:                    else
                   2520:                    {
                   2521:                        chaine = (unsigned char *) malloc(
                   2522:                                (strlen(chaine_sauvegarde) +
1.58      bertrand 2523:                                ((size_t) longueur_courante) +
                   2524:                                ((size_t) longueur_decimale_courante)
1.1       bertrand 2525:                                + 2) * sizeof(unsigned char));
                   2526: 
                   2527:                        if (chaine == NULL)
                   2528:                        {
                   2529:                            (*s_etat_processus).erreur_systeme =
                   2530:                                    d_es_allocation_memoire;
                   2531:                            return(NULL);
                   2532:                        }
                   2533: 
                   2534:                        strcpy(chaine, chaine_sauvegarde);
                   2535:                        free(chaine_sauvegarde);
                   2536:                        strcat(chaine, " ");
                   2537:                        strcat(chaine, chaine_formatee);
                   2538:                    }
                   2539: 
                   2540:                    free(chaine_formatee);
                   2541:                }
                   2542: 
                   2543:                chaine_sauvegarde = chaine;
                   2544: 
                   2545:                if (i != (nombre_lignes - 1))
                   2546:                {
                   2547:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2548:                    {
                   2549:                        chaine = (unsigned char *) malloc(
1.58      bertrand 2550:                                (strlen(chaine_sauvegarde) + 5 +
                   2551:                                ((size_t) offset)) * sizeof(unsigned char));
1.1       bertrand 2552: 
                   2553:                        if (chaine == NULL)
                   2554:                        {
                   2555:                            (*s_etat_processus).erreur_systeme =
                   2556:                                    d_es_allocation_memoire;
                   2557:                            return(NULL);
                   2558:                        }
                   2559: 
                   2560:                        strcpy(chaine, chaine_sauvegarde);
                   2561:                        free(chaine_sauvegarde);
                   2562:                        strcat(chaine, " ]\n");
                   2563:                        ptre = &(chaine[strlen(chaine)]);
                   2564: 
                   2565:                        for(k = 0; k < offset; k++, *(ptre++) = ' ');
                   2566: 
                   2567:                        (*ptre) = d_code_fin_chaine;
                   2568:                        strcat(chaine, "[");
                   2569:                    }
                   2570:                    else
                   2571:                    {
                   2572:                        chaine = (unsigned char *) malloc(
                   2573:                                (strlen(chaine_sauvegarde) + 4)
                   2574:                                * sizeof(unsigned char));
                   2575: 
                   2576:                        if (chaine == NULL)
                   2577:                        {
                   2578:                            (*s_etat_processus).erreur_systeme =
                   2579:                                    d_es_allocation_memoire;
                   2580:                            return(NULL);
                   2581:                        }
                   2582: 
                   2583:                        strcpy(chaine, chaine_sauvegarde);
                   2584:                        free(chaine_sauvegarde);
                   2585:                        strcat(chaine, " ][");
                   2586:                    }
                   2587:                }
                   2588:            }
                   2589: 
                   2590:            free(longueurs_maximales);
                   2591: 
                   2592:            chaine_sauvegarde = chaine;
                   2593:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde)
                   2594:                    + 4) * sizeof(unsigned char));
                   2595: 
                   2596:            if (chaine == NULL)
                   2597:            {
                   2598:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   2599:                return(NULL);
                   2600:            }
                   2601: 
                   2602:            strcpy(chaine, chaine_sauvegarde);
                   2603:            free(chaine_sauvegarde);
                   2604:            strcat(chaine, " ]]");
                   2605:        }
                   2606:    }
                   2607:    else if ((*s_objet).type == MIN)
                   2608:    {
                   2609: 
                   2610: /*
                   2611: --------------------------------------------------------------------------------
                   2612:   Matrice entière
                   2613: --------------------------------------------------------------------------------
                   2614: */
                   2615: 
                   2616:        nombre_lignes = (*((struct_matrice *) ((*s_objet).objet)))
                   2617:                .nombre_lignes;
                   2618:        nombre_colonnes = (*((struct_matrice *) ((*s_objet).objet)))
                   2619:                .nombre_colonnes;
                   2620: 
                   2621:        chaine = (unsigned char *) malloc(3 * sizeof(unsigned char));
                   2622: 
                   2623:        if (chaine != NULL)
                   2624:        {
                   2625:            strcpy(chaine, "[[");
1.58      bertrand 2626:            offset = ((integer8) strlen(chaine)) + offset_initial - 1;
1.1       bertrand 2627: 
1.59      bertrand 2628:            if ((longueurs_maximales = malloc(sizeof(integer8) *
1.58      bertrand 2629:                    ((size_t) nombre_colonnes))) == NULL)
1.1       bertrand 2630:            {
                   2631:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   2632:                return(NULL);
                   2633:            }
                   2634: 
                   2635:            if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2636:            {
                   2637:                for(j = 0; j < nombre_colonnes; j++)
                   2638:                {
                   2639:                    longueurs_maximales[j] = 0;
                   2640:                }
                   2641: 
                   2642:                for(i = 0; i < nombre_lignes; i++)
                   2643:                {
                   2644:                    for(j = 0; j < nombre_colonnes; j++)
                   2645:                    {
                   2646:                        chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2647:                                &(((integer8 **) ((*((struct_matrice *)
1.1       bertrand 2648:                                ((*s_objet).objet))).tableau))[i][j]), 'I');
                   2649: 
                   2650:                        if (chaine_formatee == NULL)
                   2651:                        {
                   2652:                            (*s_etat_processus).erreur_systeme =
                   2653:                                    d_es_allocation_memoire;
                   2654:                            return(NULL);
                   2655:                        }
                   2656: 
1.58      bertrand 2657:                        longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2658:                        free(chaine_formatee);
                   2659: 
                   2660:                        if (longueurs_maximales[j] < longueur_courante)
                   2661:                        {
                   2662:                            longueurs_maximales[j] = longueur_courante;
                   2663:                        }
                   2664:                    }
                   2665:                }
                   2666:            }
                   2667: 
                   2668:            for(i = 0; i < nombre_lignes; i++)
                   2669:            {
                   2670:                for(j = 0; j < nombre_colonnes; j++)
                   2671:                {
                   2672:                    chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2673:                            &(((integer8 **) ((*((struct_matrice *)
1.1       bertrand 2674:                            ((*s_objet).objet))).tableau))[i][j]), 'I');
                   2675: 
                   2676:                    if (chaine_formatee == NULL)
                   2677:                    {
                   2678:                        (*s_etat_processus).erreur_systeme =
                   2679:                                d_es_allocation_memoire;
                   2680:                        return(NULL);
                   2681:                    }
                   2682: 
1.58      bertrand 2683:                    longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2684:                    chaine_sauvegarde = chaine;
                   2685: 
                   2686:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2687:                    {
                   2688:                        chaine = (unsigned char *) malloc(
1.58      bertrand 2689:                                (strlen(chaine_sauvegarde) +
                   2690:                                ((size_t) longueur_courante)
                   2691:                                + ((size_t) longueurs_maximales[j]) + 2)
1.1       bertrand 2692:                                * sizeof(unsigned char));
                   2693: 
                   2694:                        if (chaine == NULL)
                   2695:                        {
                   2696:                            (*s_etat_processus).erreur_systeme =
                   2697:                                    d_es_allocation_memoire;
                   2698:                            return(NULL);
                   2699:                        }
                   2700: 
                   2701:                        strcpy(chaine, chaine_sauvegarde);
                   2702:                        free(chaine_sauvegarde);
                   2703:                        strcat(chaine, " ");
                   2704: 
                   2705:                        ptre = &(chaine[strlen(chaine)]);
                   2706: 
                   2707:                        for(k = 0; k < (longueurs_maximales[j]
                   2708:                                - longueur_courante); k++, *(ptre++) = ' ');
                   2709: 
                   2710:                        (*ptre) = d_code_fin_chaine;
                   2711:                    }
                   2712:                    else
                   2713:                    {
                   2714:                        chaine = (unsigned char *) malloc(
1.58      bertrand 2715:                                (strlen(chaine_sauvegarde) +
                   2716:                                ((size_t) longueur_courante)
1.1       bertrand 2717:                                + 2) * sizeof(unsigned char));
                   2718: 
                   2719:                        if (chaine == NULL)
                   2720:                        {
                   2721:                            (*s_etat_processus).erreur_systeme =
                   2722:                                    d_es_allocation_memoire;
                   2723:                            return(NULL);
                   2724:                        }
                   2725: 
                   2726:                        strcpy(chaine, chaine_sauvegarde);
                   2727:                        free(chaine_sauvegarde);
                   2728:                        strcat(chaine, " ");
                   2729:                    }
                   2730: 
                   2731:                    strcat(chaine, chaine_formatee);
                   2732:                    free(chaine_formatee);
                   2733:                }
                   2734: 
                   2735:                chaine_sauvegarde = chaine;
                   2736: 
                   2737:                if (i != (nombre_lignes - 1))
                   2738:                {
                   2739:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2740:                    {
                   2741:                        chaine = (unsigned char *) malloc(
1.58      bertrand 2742:                                (strlen(chaine_sauvegarde) + 5 +
                   2743:                                ((size_t) offset)) * sizeof(unsigned char));
1.1       bertrand 2744: 
                   2745:                        if (chaine == NULL)
                   2746:                        {
                   2747:                            (*s_etat_processus).erreur_systeme =
                   2748:                                    d_es_allocation_memoire;
                   2749:                            return(NULL);
                   2750:                        }
                   2751: 
                   2752:                        strcpy(chaine, chaine_sauvegarde);
                   2753:                        free(chaine_sauvegarde);
                   2754:                        strcat(chaine, " ]\n");
                   2755:                        ptre = &(chaine[strlen(chaine)]);
                   2756: 
                   2757:                        for(k = 0; k < offset; k++, *(ptre++) = ' ');
                   2758: 
                   2759:                        (*ptre) = d_code_fin_chaine;
                   2760:                        strcat(chaine, "[");
                   2761:                    }
                   2762:                    else
                   2763:                    {
                   2764:                        chaine = (unsigned char *) malloc(
                   2765:                                (strlen(chaine_sauvegarde) + 4)
                   2766:                                * sizeof(unsigned char));
                   2767: 
                   2768:                        if (chaine == NULL)
                   2769:                        {
                   2770:                            (*s_etat_processus).erreur_systeme =
                   2771:                                    d_es_allocation_memoire;
                   2772:                            return(NULL);
                   2773:                        }
                   2774: 
                   2775:                        strcpy(chaine, chaine_sauvegarde);
                   2776:                        free(chaine_sauvegarde);
                   2777:                        strcat(chaine, " ][");
                   2778:                    }
                   2779:                }
                   2780:            }
                   2781: 
                   2782:            free(longueurs_maximales);
                   2783: 
                   2784:            chaine_sauvegarde = chaine;
                   2785:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde)
                   2786:                    + 4) * sizeof(unsigned char));
                   2787: 
                   2788:            if (chaine == NULL)
                   2789:            {
                   2790:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   2791:                return(NULL);
                   2792:            }
                   2793: 
                   2794:            strcpy(chaine, chaine_sauvegarde);
                   2795:            free(chaine_sauvegarde);
                   2796:            strcat(chaine, " ]]");
                   2797:        }
                   2798:    }
                   2799:    else if ((*s_objet).type == MRL)
                   2800:    {
                   2801: 
                   2802: /*
                   2803: --------------------------------------------------------------------------------
                   2804:   Matrice réelle
                   2805: --------------------------------------------------------------------------------
                   2806: */
                   2807: 
                   2808:        nombre_lignes = (*((struct_matrice *) ((*s_objet).objet)))
                   2809:                .nombre_lignes;
                   2810:        nombre_colonnes = (*((struct_matrice *) ((*s_objet).objet)))
                   2811:                .nombre_colonnes;
                   2812: 
                   2813:        chaine = (unsigned char *) malloc(3 * sizeof(unsigned char));
                   2814: 
                   2815:        if (chaine != NULL)
                   2816:        {
                   2817:            strcpy(chaine, "[[");
1.58      bertrand 2818:            offset = ((integer8) strlen(chaine)) + offset_initial - 1;
1.1       bertrand 2819: 
1.59      bertrand 2820:            if ((longueurs_maximales = malloc(sizeof(integer8) * 2 *
1.58      bertrand 2821:                    ((size_t) nombre_colonnes))) == NULL)
1.1       bertrand 2822:            {
                   2823:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   2824:                return(NULL);
                   2825:            }
                   2826: 
                   2827:            if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2828:            {
                   2829:                for(j = 0; j < (2 * nombre_colonnes); j++)
                   2830:                {
                   2831:                    longueurs_maximales[j] = 0;
                   2832:                }
                   2833: 
                   2834:                for(i = 0; i < nombre_lignes; i++)
                   2835:                {
                   2836:                    for(j = 0; j < nombre_colonnes; j++)
                   2837:                    {
                   2838:                        chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2839:                                &(((real8 **) ((*((struct_matrice *)
1.1       bertrand 2840:                                ((*s_objet).objet))).tableau))[i][j]), 'R');
                   2841: 
                   2842:                        if (chaine_formatee == NULL)
                   2843:                        {
                   2844:                            (*s_etat_processus).erreur_systeme =
                   2845:                                    d_es_allocation_memoire;
                   2846:                            return(NULL);
                   2847:                        }
                   2848: 
1.58      bertrand 2849:                        longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2850:                        longueur_decimale_courante = 0;
                   2851: 
                   2852:                        if ((ptrl = index(chaine_formatee,
                   2853:                                (test_cfsf(s_etat_processus, 48) == d_vrai)
                   2854:                                ? ',' : '.')) != NULL)
                   2855:                        {
                   2856:                            longueur_decimale_courante = longueur_courante
                   2857:                                    - (ptrl - chaine_formatee);
                   2858:                            longueur_courante = ptrl - chaine_formatee;
                   2859:                        }
                   2860: 
                   2861:                        free(chaine_formatee);
                   2862: 
                   2863:                        if (longueurs_maximales[2 * j] < longueur_courante)
                   2864:                        {
                   2865:                            longueurs_maximales[2 * j] = longueur_courante;
                   2866:                        }
                   2867: 
                   2868:                        if (longueurs_maximales[(2 * j) + 1] <
                   2869:                                longueur_decimale_courante)
                   2870:                        {
                   2871:                            longueurs_maximales[(2 * j) + 1] =
                   2872:                                    longueur_decimale_courante;
                   2873:                        }
                   2874:                    }
                   2875:                }
                   2876:            }
                   2877: 
                   2878:            for(i = 0; i < nombre_lignes; i++)
                   2879:            {
                   2880:                for(j = 0; j < nombre_colonnes; j++)
                   2881:                {
                   2882:                    chaine_formatee = formateur_nombre(s_etat_processus,
1.58      bertrand 2883:                            &(((real8 **) ((*((struct_matrice *)
1.1       bertrand 2884:                            ((*s_objet).objet))).tableau))[i][j]), 'R');
                   2885: 
                   2886:                    if (chaine_formatee == NULL)
                   2887:                    {
                   2888:                        (*s_etat_processus).erreur_systeme =
                   2889:                                d_es_allocation_memoire;
                   2890:                        return(NULL);
                   2891:                    }
                   2892: 
1.58      bertrand 2893:                    longueur_courante = (integer8) strlen(chaine_formatee);
1.1       bertrand 2894:                    longueur_decimale_courante = 0;
                   2895: 
                   2896:                    if ((ptrl = index(chaine_formatee,
                   2897:                            (test_cfsf(s_etat_processus, 48) == d_vrai)
                   2898:                            ? ',' : '.')) != NULL)
                   2899:                    {
                   2900:                        longueur_decimale_courante = longueur_courante
                   2901:                                - (ptrl - chaine_formatee);
                   2902:                        longueur_courante = ptrl - chaine_formatee;
                   2903:                    }
                   2904: 
                   2905:                    chaine_sauvegarde = chaine;
                   2906: 
                   2907:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2908:                    {
                   2909:                        chaine = (unsigned char *) malloc(
                   2910:                                (strlen(chaine_sauvegarde) +
1.58      bertrand 2911:                                ((size_t) longueur_courante) +
                   2912:                                ((size_t) longueur_decimale_courante) +
                   2913:                                ((size_t) longueurs_maximales[2 * j]) +
                   2914:                                ((size_t) longueurs_maximales[(2 * j) + 1]) + 2)
1.1       bertrand 2915:                                * sizeof(unsigned char));
                   2916: 
                   2917:                        if (chaine == NULL)
                   2918:                        {
                   2919:                            (*s_etat_processus).erreur_systeme =
                   2920:                                    d_es_allocation_memoire;
                   2921:                            return(NULL);
                   2922:                        }
                   2923: 
                   2924:                        strcpy(chaine, chaine_sauvegarde);
                   2925:                        free(chaine_sauvegarde);
                   2926:                        strcat(chaine, " ");
                   2927: 
                   2928:                        ptre = &(chaine[strlen(chaine)]);
                   2929: 
                   2930:                        for(k = 0; k < (longueurs_maximales[2 * j]
                   2931:                                - longueur_courante); k++, *(ptre++) = ' ');
                   2932: 
                   2933:                        (*ptre) = d_code_fin_chaine;
                   2934:                        strcat(chaine, chaine_formatee);
                   2935:                        ptre = &(chaine[strlen(chaine)]);
                   2936: 
                   2937:                        for(k = 0; k < (longueurs_maximales[(2 * j) + 1]
                   2938:                                - longueur_decimale_courante);
                   2939:                                k++, *(ptre++) = ' ');
                   2940: 
                   2941:                        (*ptre) = d_code_fin_chaine;
                   2942:                    }
                   2943:                    else
                   2944:                    {
                   2945:                        chaine = (unsigned char *) malloc(
                   2946:                                (strlen(chaine_sauvegarde) +
1.58      bertrand 2947:                                ((size_t) longueur_courante) +
                   2948:                                ((size_t) longueur_decimale_courante)
1.1       bertrand 2949:                                + 2) * sizeof(unsigned char));
                   2950: 
                   2951:                        if (chaine == NULL)
                   2952:                        {
                   2953:                            (*s_etat_processus).erreur_systeme =
                   2954:                                    d_es_allocation_memoire;
                   2955:                            return(NULL);
                   2956:                        }
                   2957: 
                   2958:                        strcpy(chaine, chaine_sauvegarde);
                   2959:                        free(chaine_sauvegarde);
                   2960:                        strcat(chaine, " ");
                   2961:                        strcat(chaine, chaine_formatee);
                   2962:                    }
                   2963:                    
                   2964:                    free(chaine_formatee);
                   2965:                }
                   2966: 
                   2967:                chaine_sauvegarde = chaine;
                   2968: 
                   2969:                if (i != (nombre_lignes - 1))
                   2970:                {
                   2971:                    if (test_cfsf(s_etat_processus, 45) == d_vrai)
                   2972:                    {
                   2973:                        chaine = (unsigned char *) malloc(
1.58      bertrand 2974:                                (strlen(chaine_sauvegarde) + 5 +
                   2975:                                ((size_t) offset)) * sizeof(unsigned char));
1.1       bertrand 2976:                        
                   2977:                        if (chaine == NULL)
                   2978:                        {
                   2979:                            (*s_etat_processus).erreur_systeme =
                   2980:                                    d_es_allocation_memoire;
                   2981:                            return(NULL);
                   2982:                        }
                   2983: 
                   2984:                        strcpy(chaine, chaine_sauvegarde);
                   2985:                        free(chaine_sauvegarde);
                   2986:                        strcat(chaine, " ]\n");
                   2987:                        ptre = &(chaine[strlen(chaine)]);
                   2988: 
                   2989:                        for(k = 0; k < offset; k++, *(ptre++) = ' ');
                   2990: 
                   2991:                        (*ptre) = d_code_fin_chaine;
                   2992:                        strcat(chaine, "[");
                   2993:                    }
                   2994:                    else
                   2995:                    {
                   2996:                        chaine = (unsigned char *) malloc(
                   2997:                                (strlen(chaine_sauvegarde) + 4)
                   2998:                                * sizeof(unsigned char));
                   2999: 
                   3000:                        if (chaine == NULL)
                   3001:                        {
                   3002:                            (*s_etat_processus).erreur_systeme =
                   3003:                                    d_es_allocation_memoire;
                   3004:                            return(NULL);
                   3005:                        }
                   3006: 
                   3007:                        strcpy(chaine, chaine_sauvegarde);
                   3008:                        free(chaine_sauvegarde);
                   3009:                        strcat(chaine, " ][");
                   3010:                    }
                   3011:                }
                   3012:            }
                   3013: 
                   3014:            free(longueurs_maximales);
                   3015: 
                   3016:            chaine_sauvegarde = chaine;
                   3017:            chaine = (unsigned char *) malloc((strlen(chaine_sauvegarde)
                   3018:                    + 4) * sizeof(unsigned char));
                   3019: 
                   3020:            if (chaine == NULL)
                   3021:            {
                   3022:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3023:                return(NULL);
                   3024:            }
                   3025: 
                   3026:            strcpy(chaine, chaine_sauvegarde);
                   3027:            free(chaine_sauvegarde);
                   3028:            strcat(chaine, " ]]");
                   3029:        }
                   3030:    }
                   3031:    else if ((*s_objet).type == MTX)
                   3032:    {
1.74      bertrand 3033:        if (alsprintf(s_etat_processus, &chaine,
                   3034:                "Mutex $ %016llX owned by $ %016llX",
1.60      bertrand 3035:                &((*((struct_mutex *) (*s_objet).objet)).mutex),
1.59      bertrand 3036:                (logical8) (*((struct_mutex *) (*s_objet).objet)).tid) < 0)
1.1       bertrand 3037:        {
                   3038:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3039:            return(NULL);
                   3040:        }
                   3041:    }
                   3042:    else if ((*s_objet).type == NOM)
                   3043:    {
                   3044: 
                   3045: /*
                   3046: --------------------------------------------------------------------------------
                   3047:   Nom
                   3048: --------------------------------------------------------------------------------
                   3049: */
                   3050: 
                   3051:        if ((*((struct_nom *) (*s_objet).objet)).symbole == d_vrai)
                   3052:        {
                   3053:            chaine = (unsigned char *) malloc((strlen((*((struct_nom *)
                   3054:                    (*s_objet).objet)).nom) + 3) * sizeof(unsigned char));
                   3055: 
                   3056:            if (chaine == NULL)
                   3057:            {
                   3058:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3059:                return(NULL);
                   3060:            }
                   3061: 
                   3062:            sprintf(chaine, "'%s'", (*((struct_nom *) (*s_objet).objet)).nom);
                   3063:        }
                   3064:        else
                   3065:        {
                   3066:            chaine = (unsigned char *) malloc((strlen((*((struct_nom *)
                   3067:                    (*s_objet).objet)).nom) + 1) * sizeof(unsigned char));
                   3068: 
                   3069:            if (chaine == NULL)
                   3070:            {
                   3071:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3072:                return(NULL);
                   3073:            }
                   3074: 
                   3075:            sprintf(chaine, "%s", (*((struct_nom *) (*s_objet).objet)).nom);
                   3076:        }
                   3077:    }
                   3078:    else if ((*s_objet).type == REL)
                   3079:    {
                   3080: 
                   3081: /*
                   3082: --------------------------------------------------------------------------------
                   3083:   Réel
                   3084: --------------------------------------------------------------------------------
                   3085: */
                   3086: 
1.58      bertrand 3087:        chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 3088:                ((real8 *) ((*s_objet).objet)), 'R');
                   3089: 
                   3090:        if (chaine_formatee == NULL)
                   3091:        {
                   3092:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3093:            return(NULL);
                   3094:        }
                   3095: 
                   3096:        chaine = (unsigned char *) malloc((strlen(chaine_formatee) + 1)
                   3097:                * sizeof(unsigned char));
                   3098: 
                   3099:        if (chaine == NULL)
                   3100:        {
                   3101:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   3102:            return(NULL);
                   3103:        }
                   3104: 
                   3105:        strcpy(chaine, chaine_formatee);
                   3106:        free(chaine_formatee);
                   3107:    }
                   3108:    else if ((*s_objet).type == VCX)
                   3109:    {
                   3110: 
                   3111: /*
                   3112: --------------------------------------------------------------------------------
                   3113:   Vecteur complexe
                   3114: --------------------------------------------------------------------------------
                   3115: */
                   3116: 
                   3117:        nombre_colonnes = (*((struct_vecteur *) ((*s_objet).objet)))
                   3118:                .taille;
                   3119: 
                   3120:        chaine = (unsigned char *) malloc(2 * sizeof(unsigned char));
                   3121: 
                   3122:        if (chaine != NULL)
                   3123:        {
                   3124:            strcpy(chaine, "[");
                   3125: 
                   3126:            for(i = 0; i < nombre_colonnes; i++)
                   3127:            {
1.58      bertrand 3128:                chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 3129:                        &(((struct_complexe16 *) ((*((struct_vecteur *)
                   3130:                        ((*s_objet).objet))).tableau))[i]), 'C');
                   3131: 
                   3132:                if (chaine_formatee == NULL)
                   3133:                {
                   3134:                    (*s_etat_processus).erreur_systeme =
                   3135:                            d_es_allocation_memoire;
                   3136:                    return(NULL);
                   3137:                }
                   3138: 
                   3139:                chaine_sauvegarde = chaine;
                   3140:                chaine = (unsigned char *) malloc(
                   3141:                        (strlen(chaine_sauvegarde) + strlen(chaine_formatee)
                   3142:                        + 2) * sizeof(unsigned char));
                   3143: 
                   3144:                if (chaine == NULL)
                   3145:                {
                   3146:                    (*s_etat_processus).erreur_systeme =
                   3147:                            d_es_allocation_memoire;
                   3148:                    return(NULL);
                   3149:                }
                   3150: 
                   3151:                strcpy(chaine, chaine_sauvegarde);
                   3152:                free(chaine_sauvegarde);
                   3153:                strcat(chaine, " ");
                   3154:                strcat(chaine, chaine_formatee);
                   3155:                free(chaine_formatee);
                   3156:            }
                   3157: 
                   3158:            chaine_sauvegarde = chaine;
                   3159:            chaine = (unsigned char *) malloc(
                   3160:                    (strlen(chaine_sauvegarde) + 3)
                   3161:                    * sizeof(unsigned char));
                   3162: 
                   3163:            if (chaine == NULL)
                   3164:            {
                   3165:                (*s_etat_processus).erreur_systeme =
                   3166:                        d_es_allocation_memoire;
                   3167:                return(NULL);
                   3168:            }
                   3169: 
                   3170:            strcpy(chaine, chaine_sauvegarde);
                   3171:            free(chaine_sauvegarde);
                   3172:            strcat(chaine, " ]");
                   3173:        }
                   3174:    }
                   3175:    else if ((*s_objet).type == VIN)
                   3176:    {
                   3177: 
                   3178: /*
                   3179: --------------------------------------------------------------------------------
                   3180:   Vecteur entier
                   3181: --------------------------------------------------------------------------------
                   3182: */
                   3183: 
                   3184:        nombre_colonnes = (*((struct_vecteur *) ((*s_objet).objet)))
                   3185:                .taille;
                   3186: 
                   3187:        chaine = (unsigned char *) malloc(2 * sizeof(unsigned char));
                   3188: 
                   3189:        if (chaine != NULL)
                   3190:        {
                   3191:            strcpy(chaine, "[");
                   3192: 
                   3193:            for(i = 0; i < nombre_colonnes; i++)
                   3194:            {
1.58      bertrand 3195:                chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 3196:                        &(((integer8 *) ((*((struct_vecteur *)
                   3197:                        ((*s_objet).objet))).tableau))[i]), 'I');
                   3198: 
                   3199:                if (chaine_formatee == NULL)
                   3200:                {
                   3201:                    (*s_etat_processus).erreur_systeme =
                   3202:                            d_es_allocation_memoire;
                   3203:                    return(NULL);
                   3204:                }
                   3205: 
                   3206:                chaine_sauvegarde = chaine;
                   3207:                chaine = (unsigned char *) malloc(
                   3208:                        (strlen(chaine_sauvegarde) + strlen(chaine_formatee)
                   3209:                        + 2) * sizeof(unsigned char));
                   3210: 
                   3211:                if (chaine == NULL)
                   3212:                {
                   3213:                    (*s_etat_processus).erreur_systeme =
                   3214:                            d_es_allocation_memoire;
                   3215:                    return(NULL);
                   3216:                }
                   3217: 
                   3218:                strcpy(chaine, chaine_sauvegarde);
                   3219:                free(chaine_sauvegarde);
                   3220:                strcat(chaine, " ");
                   3221:                strcat(chaine, chaine_formatee);
                   3222:                free(chaine_formatee);
                   3223:            }
                   3224: 
                   3225:            chaine_sauvegarde = chaine;
                   3226:            chaine = (unsigned char *) malloc(
                   3227:                    (strlen(chaine_sauvegarde) + 3)
                   3228:                    * sizeof(unsigned char));
                   3229: 
                   3230:            if (chaine == NULL)
                   3231:            {
                   3232:                (*s_etat_processus).erreur_systeme =
                   3233:                        d_es_allocation_memoire;
                   3234:                return(NULL);
                   3235:            }
                   3236: 
                   3237:            strcpy(chaine, chaine_sauvegarde);
                   3238:            free(chaine_sauvegarde);
                   3239:            strcat(chaine, " ]");
                   3240:        }
                   3241:    }
                   3242:    else if ((*s_objet).type == VRL)
                   3243:    {
                   3244: 
                   3245: /*
                   3246: --------------------------------------------------------------------------------
                   3247:   Vecteur réel
                   3248: --------------------------------------------------------------------------------
                   3249: */
                   3250: 
                   3251:        nombre_colonnes = (*((struct_vecteur *) ((*s_objet).objet)))
                   3252:                .taille;
                   3253: 
                   3254:        chaine = (unsigned char *) malloc(2 * sizeof(unsigned char));
                   3255: 
                   3256:        if (chaine != NULL)
                   3257:        {
                   3258:            strcpy(chaine, "[");
                   3259: 
                   3260:            for(i = 0; i < nombre_colonnes; i++)
                   3261:            {
1.58      bertrand 3262:                chaine_formatee = formateur_nombre(s_etat_processus,
1.1       bertrand 3263:                        &(((real8 *) ((*((struct_vecteur *)
                   3264:                        ((*s_objet).objet))).tableau))[i]), 'R');
                   3265: 
                   3266:                if (chaine_formatee == NULL)
                   3267:                {
                   3268:                    (*s_etat_processus).erreur_systeme =
                   3269:                            d_es_allocation_memoire;
                   3270:                    return(NULL);
                   3271:                }
                   3272: 
                   3273:                chaine_sauvegarde = chaine;
                   3274:                chaine = (unsigned char *) malloc(
                   3275:                        (strlen(chaine_sauvegarde) + strlen(chaine_formatee)
                   3276:                        + 2) * sizeof(unsigned char));
                   3277: 
                   3278:                if (chaine == NULL)
                   3279:                {
                   3280:                    (*s_etat_processus).erreur_systeme =
                   3281:                            d_es_allocation_memoire;
                   3282:                    return(NULL);
                   3283:                }
                   3284: 
                   3285:                strcpy(chaine, chaine_sauvegarde);
                   3286:                free(chaine_sauvegarde);
                   3287:                strcat(chaine, " ");
                   3288:                strcat(chaine, chaine_formatee);
                   3289:                free(chaine_formatee);
                   3290:            }
                   3291: 
                   3292:            chaine_sauvegarde = chaine;
                   3293:            chaine = (unsigned char *) malloc(
                   3294:                    (strlen(chaine_sauvegarde) + 3)
                   3295:                    * sizeof(unsigned char));
                   3296: 
                   3297:            if (chaine == NULL)
                   3298:            {
                   3299:                (*s_etat_processus).erreur_systeme =
                   3300:                        d_es_allocation_memoire;
                   3301:                return(NULL);
                   3302:            }
                   3303: 
                   3304:            strcpy(chaine, chaine_sauvegarde);
                   3305:            free(chaine_sauvegarde);
                   3306:            strcat(chaine, " ]");
                   3307:        }
                   3308:    }
                   3309: 
                   3310:    return(chaine);
                   3311: }
                   3312: 
                   3313: 
                   3314: /*
                   3315: ================================================================================
                   3316:   Routines qui transforment un nombre entier, réel ou complexe en chaîne de
                   3317:   caractères suivant le format courant
                   3318: ================================================================================
                   3319:   Entrées : pointeur générique sur la donnée numérique à convertir,
                   3320:   type de l'entité (I, R ou C).
                   3321: --------------------------------------------------------------------------------
                   3322:   Sorties : chaîne de caractères allouée dans la routine
                   3323: --------------------------------------------------------------------------------
                   3324:   Effets de bord : néant
                   3325: ================================================================================
                   3326: */
                   3327: 
                   3328: /*
                   3329: --------------------------------------------------------------------------------
                   3330:   Formatage des complexes, réels et entiers
                   3331: --------------------------------------------------------------------------------
                   3332: */
                   3333: 
                   3334: unsigned char *
                   3335: formateur_nombre(struct_processus *s_etat_processus,
                   3336:        void *valeur_numerique, unsigned char type)
                   3337: {
                   3338:    unsigned char               *chaine;
                   3339:    unsigned char               *construction_chaine;
                   3340:    unsigned char               *sauvegarde;
                   3341:    unsigned char               *tampon;
                   3342: 
                   3343:    chaine = NULL;
                   3344: 
                   3345:    switch(type)
                   3346:    {
                   3347:        case 'C' :
                   3348:        {
                   3349:            construction_chaine = (unsigned char *) malloc(
                   3350:                    2 * sizeof(unsigned char));
                   3351: 
                   3352:            if (construction_chaine == NULL)
                   3353:            {
                   3354:                (*s_etat_processus).erreur_systeme =
                   3355:                        d_es_allocation_memoire;
                   3356:                return(NULL);
                   3357:            }
                   3358: 
                   3359:            strcpy(construction_chaine, "(");
                   3360: 
                   3361:            tampon = formateur_reel(s_etat_processus,
1.58      bertrand 3362:                    &((*((struct_complexe16 *)
1.1       bertrand 3363:                    valeur_numerique)).partie_reelle), 'R');
                   3364: 
                   3365:            if (tampon == NULL)
                   3366:            {
                   3367:                (*s_etat_processus).erreur_systeme =
                   3368:                        d_es_allocation_memoire;
                   3369:                return(NULL);
                   3370:            }
                   3371: 
                   3372:            sauvegarde = construction_chaine;
                   3373: 
                   3374:            construction_chaine = (unsigned char *) malloc(
                   3375:                    (strlen(sauvegarde) + strlen(tampon) + 2)
                   3376:                    * sizeof(unsigned char));
                   3377: 
                   3378:            if (construction_chaine == NULL)
                   3379:            {
                   3380:                (*s_etat_processus).erreur_systeme =
                   3381:                        d_es_allocation_memoire;
                   3382:                return(NULL);
                   3383:            }
                   3384: 
                   3385:            strcpy(construction_chaine, sauvegarde);
                   3386:            free(sauvegarde);
                   3387:            strcat(construction_chaine, tampon);
                   3388:            free(tampon);
                   3389: 
                   3390:            if (test_cfsf(s_etat_processus, 48) == d_faux)
                   3391:            {
                   3392:                strcat(construction_chaine, ",");
                   3393:            }
                   3394:            else
                   3395:            {
                   3396:                strcat(construction_chaine, ".");
                   3397:            }
                   3398: 
                   3399:            tampon = formateur_reel(s_etat_processus,
1.58      bertrand 3400:                    &((*((struct_complexe16 *)
1.1       bertrand 3401:                    valeur_numerique)).partie_imaginaire), 'R');
                   3402: 
                   3403:            if (tampon == NULL)
                   3404:            {
                   3405:                (*s_etat_processus).erreur_systeme =
                   3406:                        d_es_allocation_memoire;
                   3407:                return(NULL);
                   3408:            }
                   3409: 
                   3410:            sauvegarde = construction_chaine;
                   3411: 
                   3412:            construction_chaine = (unsigned char *) malloc(
                   3413:                    (strlen(sauvegarde) + strlen(tampon) + 2)
                   3414:                    * sizeof(unsigned char));
                   3415: 
                   3416:            if (construction_chaine == NULL)
                   3417:            {
                   3418:                (*s_etat_processus).erreur_systeme =
                   3419:                        d_es_allocation_memoire;
                   3420:                return(NULL);
                   3421:            }
                   3422: 
                   3423:            strcpy(construction_chaine, sauvegarde);
                   3424:            free(sauvegarde);
                   3425:            strcat(construction_chaine, tampon);
                   3426:            free(tampon);
                   3427:            strcat(construction_chaine, ")");
                   3428: 
                   3429:            chaine = construction_chaine;
                   3430: 
                   3431:            break;
                   3432:        }
                   3433: 
                   3434:        case 'R' :
                   3435:        {
                   3436:            chaine = formateur_reel(s_etat_processus, valeur_numerique, 'R');
                   3437: 
                   3438:            if (chaine == NULL)
                   3439:            {
                   3440:                (*s_etat_processus).erreur_systeme =
                   3441:                        d_es_allocation_memoire;
                   3442:                return(NULL);
                   3443:            }
                   3444: 
                   3445:            break;
                   3446:        }
                   3447: 
                   3448:        default :
                   3449:        case 'I' :
                   3450:        {
                   3451:            chaine = formateur_reel(s_etat_processus, valeur_numerique, 'I');
                   3452: 
                   3453:            if (chaine == NULL)
                   3454:            {
                   3455:                (*s_etat_processus).erreur_systeme =
                   3456:                        d_es_allocation_memoire;
                   3457:                return(NULL);
                   3458:            }
                   3459: 
                   3460:            break;
                   3461:        }
                   3462:    }
                   3463: 
                   3464:    return(chaine);
                   3465: }
                   3466: 
                   3467: 
                   3468: /*
                   3469: --------------------------------------------------------------------------------
                   3470:   Formateur des réels et entiers
                   3471: --------------------------------------------------------------------------------
                   3472: */
                   3473: 
                   3474: unsigned char *
                   3475: formateur_reel(struct_processus *s_etat_processus,
                   3476:        void *valeur_numerique, unsigned char type)
                   3477: {
                   3478:    real8                   mantisse;
                   3479:    real8                   tampon_reel;
                   3480: 
                   3481:    integer8                tampon_entier;
                   3482: 
                   3483:    logical1                i49;
                   3484:    logical1                i50;
                   3485: 
                   3486:    long                    correction;
1.4       bertrand 3487:    long                    dernier_chiffre_significatif;
1.1       bertrand 3488:    long                    exposant;
1.58      bertrand 3489:    long                    i;
                   3490:    long                    j;
1.1       bertrand 3491:    long                    longueur_utile;
                   3492:    long                    longueur_utile_limite;
                   3493: 
                   3494:    unsigned char           *chaine;
1.3       bertrand 3495:    unsigned char           format[32 + 1];
1.1       bertrand 3496:    unsigned char           mode[3 + 1];
                   3497:    unsigned char           *ptr;
1.3       bertrand 3498:    unsigned char           tampon[32 + 1];
1.1       bertrand 3499: 
                   3500:    chaine = (unsigned char *) malloc((32 + 1) * sizeof(unsigned char));
                   3501: 
                   3502:    if (chaine == NULL)
                   3503:    {
                   3504:        (*s_etat_processus).erreur_systeme =
                   3505:                d_es_allocation_memoire;
                   3506:        return(NULL);
                   3507:    }
                   3508: 
                   3509:    if (type == 'R')
                   3510:    {
1.36      bertrand 3511: #      ifdef FP_INFINITE
1.38      bertrand 3512:        int     signe;
                   3513: 
                   3514:        if ((signe = isinf((*((real8 *) valeur_numerique)))) != 0)
1.36      bertrand 3515:        {
1.38      bertrand 3516:            if (signe > 0)
                   3517:            {
                   3518:                strcpy(chaine, "infinity");
                   3519:            }
                   3520:            else
                   3521:            {
                   3522:                strcpy(chaine, "-infinity");
                   3523:            }
                   3524: 
1.36      bertrand 3525:            return(chaine);
                   3526:        }
                   3527: #      endif
                   3528: 
1.37      bertrand 3529:        if (isnan((*((real8 *) valeur_numerique))))
                   3530:        {
                   3531:            strcpy(chaine, "undef");
                   3532:            return(chaine);
                   3533:        }
                   3534: 
1.1       bertrand 3535:        tampon_reel = *((real8 *) valeur_numerique);
                   3536: 
                   3537:        if (tampon_reel > ((real8) 0))
                   3538:        {
                   3539:            exposant = (long) floor(log10(tampon_reel));
                   3540:        }
                   3541:        else if (tampon_reel < ((real8) 0))
                   3542:        {
                   3543:            exposant = (long) floor(log10(-tampon_reel));
                   3544:        }
                   3545:        else
                   3546:        {
                   3547:            exposant = 0;
                   3548:        }
                   3549: 
1.58      bertrand 3550:        mantisse = (*((real8 *) valeur_numerique)) / pow(10, (double) exposant);
1.1       bertrand 3551:    }
                   3552:    else
                   3553:    {
                   3554:        tampon_entier = *((integer8 *) valeur_numerique);
                   3555: 
                   3556:        if (tampon_entier > ((integer8) 0))
                   3557:        {
1.58      bertrand 3558:            exposant = (long) floor(log10((double) tampon_entier));
1.1       bertrand 3559:        }
                   3560:        else if (tampon_entier < ((integer8) 0))
                   3561:        {
1.56      bertrand 3562:            if (tampon_entier != INT64_MIN)
                   3563:            {
1.58      bertrand 3564:                exposant = (long) floor(log10((double) -tampon_entier));
1.56      bertrand 3565:            }
                   3566:            else
                   3567:            {
                   3568:                tampon_reel = (real8) tampon_entier;
                   3569:                exposant = (long) floor(log10(-tampon_reel));
                   3570:            }
1.1       bertrand 3571:        }
                   3572:        else
                   3573:        {
                   3574:            exposant = 0;
                   3575:        }
                   3576: 
1.58      bertrand 3577:        mantisse = ((real8) (*((integer8 *) valeur_numerique))) /
                   3578:                pow(10, (double) exposant);
1.1       bertrand 3579:    }
                   3580: 
                   3581:    longueur_utile = 0;
                   3582:    j = 1;
                   3583: 
                   3584:    for(i = 53; i <= 56; i++)
                   3585:    {
                   3586:        longueur_utile += (test_cfsf(s_etat_processus, (unsigned char) i)
                   3587:                == d_vrai) ? j : 0;
                   3588:        j *= 2;
                   3589:    }
                   3590: 
                   3591:    longueur_utile_limite = 15;
                   3592: 
                   3593:    if (longueur_utile > longueur_utile_limite)
                   3594:    {
                   3595:        longueur_utile = longueur_utile_limite;
                   3596:    }
                   3597: 
                   3598:    i49 = test_cfsf(s_etat_processus, 49);
                   3599:    i50 = test_cfsf(s_etat_processus, 50);
                   3600: 
                   3601:    if (i49 == d_faux)
                   3602:    {
                   3603:        if (i50 == d_faux)
                   3604:        {
                   3605: 
                   3606: /*
                   3607: --------------------------------------------------------------------------------
                   3608:   Mode standard
                   3609: --------------------------------------------------------------------------------
                   3610: */
                   3611: 
                   3612:            strcpy(mode, "STD");
                   3613:        }
                   3614:        else
                   3615:        {
                   3616: 
                   3617: /*
                   3618: --------------------------------------------------------------------------------
                   3619:   Mode scientifique
                   3620: --------------------------------------------------------------------------------
                   3621: */
                   3622: 
                   3623:            strcpy(mode, "SCI");
                   3624:        }
                   3625:    }
                   3626:    else
                   3627:    {
                   3628:        if (i50 == d_faux)
                   3629:        {
                   3630: 
                   3631: /*
                   3632: --------------------------------------------------------------------------------
                   3633:   Mode fixe
                   3634: --------------------------------------------------------------------------------
                   3635: */
                   3636: 
                   3637:            strcpy(mode, "FIX");
                   3638:        }
                   3639:        else
                   3640:        {
                   3641: 
                   3642: /*
                   3643: --------------------------------------------------------------------------------
                   3644:   Mode ingénieur
                   3645: --------------------------------------------------------------------------------
                   3646: */
                   3647: 
                   3648:            strcpy(mode, "ENG");
                   3649:        }
                   3650:    }
                   3651: 
1.4       bertrand 3652:    // Test portant sur le nombre de chiffres significatifs dans
                   3653:    // le cas du format STD pour que 1.2E-15 apparaisse en notation
                   3654:    // SCI car il y a une perte de précision dans l'affichage.
                   3655: 
                   3656:    if ((strcmp(mode, "STD") == 0) && (type == 'R'))
                   3657:    {
                   3658:        if (abs(*((real8 *) valeur_numerique)) < 1)
                   3659:        {
                   3660:            dernier_chiffre_significatif = -exposant;
                   3661:            sprintf(tampon, ".%f", mantisse);
                   3662: 
                   3663:            ptr = &(tampon[strlen(tampon) - 1]);
                   3664: 
                   3665:            while((*ptr) != '.')
                   3666:            {
                   3667:                if ((*ptr) != '0')
                   3668:                {
                   3669:                    dernier_chiffre_significatif++;
                   3670:                }
                   3671: 
                   3672:                ptr--;
                   3673:            }
                   3674:        }
                   3675:        else
                   3676:        {
                   3677:            dernier_chiffre_significatif = 0;
                   3678:        }
                   3679:    }
                   3680:    else
                   3681:    {
                   3682:        dernier_chiffre_significatif = 0;
                   3683:    }
                   3684: 
1.1       bertrand 3685:    if ((strcmp(mode, "SCI") == 0) ||
                   3686:            ((strcmp(mode, "STD") == 0) && ((exposant >
1.4       bertrand 3687:            longueur_utile_limite) || (dernier_chiffre_significatif > 15) ||
1.1       bertrand 3688:            (exposant < -longueur_utile_limite))) ||
                   3689:            ((strcmp(mode, "FIX") == 0) &&
                   3690:            ((exposant >= longueur_utile_limite) ||
                   3691:            (exposant < -longueur_utile))))
                   3692:    {
                   3693:        chaine[0] = d_code_fin_chaine;
                   3694:        format[0] = d_code_fin_chaine;
                   3695: 
                   3696:        if (strcmp(mode, "STD") == 0)
                   3697:        {
                   3698:            longueur_utile = longueur_utile_limite - 1;
                   3699:        }
                   3700: 
                   3701:        sprintf(format, "%%.%luf", longueur_utile);
                   3702:        sprintf(tampon, format, mantisse);
                   3703:        strcpy(chaine, tampon);
                   3704: 
                   3705:        if (strcmp(mode, "STD") == 0)
                   3706:        {
                   3707:            ptr = &(chaine[strlen(chaine) - 1]);
                   3708:            while(((*ptr) == '0') || ((*ptr) == '.'))
                   3709:            {
                   3710:                (*ptr) = d_code_fin_chaine;
                   3711:                ptr--;
                   3712:            }
                   3713:        }
                   3714: 
                   3715:        strcat(chaine, "E");
                   3716:        sprintf(tampon, "%ld", exposant);
                   3717:        strcat(chaine, tampon);
                   3718:    }
                   3719:    else if (strcmp(mode, "FIX") == 0)
                   3720:    {
                   3721:        chaine[0] = d_code_fin_chaine;
                   3722:        format[0] = d_code_fin_chaine;
                   3723: 
                   3724:        if (longueur_utile + exposant >= longueur_utile_limite)
                   3725:        {
                   3726:            longueur_utile = longueur_utile_limite - (exposant + 1);
                   3727:        }
                   3728: 
                   3729:        sprintf(format, "%%.%luf", longueur_utile);
                   3730: 
1.58      bertrand 3731:        sprintf(tampon, format, (mantisse * pow(10, (double) exposant)));
1.1       bertrand 3732:        strcpy(chaine, tampon);
                   3733:    }
                   3734:    else if (strcmp(mode, "ENG") == 0)
                   3735:    {
                   3736:        chaine[0] = d_code_fin_chaine;
                   3737:        format[0] = d_code_fin_chaine;
                   3738: 
                   3739:        correction = labs(exposant) % 3;
                   3740: 
                   3741:        if (exposant < 0)
                   3742:        {
                   3743:            if (correction == 0)
                   3744:            {
                   3745:                correction = 3;
                   3746:            }
                   3747: 
                   3748:            correction =  3 - correction;
                   3749:        }
                   3750: 
                   3751:        longueur_utile -= correction;
                   3752:        sprintf(format, "%%.%luf", longueur_utile);
                   3753: 
1.58      bertrand 3754:        sprintf(tampon, format, (mantisse * pow(10, (double) correction)));
1.1       bertrand 3755:        strcpy(chaine, tampon);
                   3756:        strcat(chaine, "E");
                   3757:        sprintf(tampon, "%ld", (exposant - correction));
                   3758:        strcat(chaine, tampon);
                   3759:    }
                   3760:    else
                   3761:    {
                   3762:        if (type == 'I')
                   3763:        {
                   3764:            chaine[0] = d_code_fin_chaine;
                   3765:            sprintf(tampon, "%lld", *((integer8 *) valeur_numerique));
                   3766:        }
                   3767:        else
                   3768:        {
                   3769:            chaine[0] = d_code_fin_chaine;
                   3770:            format[0] = d_code_fin_chaine;
                   3771: 
                   3772:            if (exposant >= 0)
                   3773:            {
1.27      bertrand 3774:                if ((exposant + 1) < longueur_utile_limite)
                   3775:                {
                   3776:                    sprintf(format, "%%.%luf", (longueur_utile_limite - exposant
                   3777:                            - 1));
                   3778:                }
                   3779:                else
                   3780:                {
                   3781:                    strcpy(format, "%.0f.");
                   3782:                }
1.1       bertrand 3783:            }
                   3784:            else
                   3785:            {
                   3786:                sprintf(format, "%%.%luf", longueur_utile_limite);
                   3787:            }
                   3788: 
                   3789:            sprintf(tampon, format, *((real8 *) valeur_numerique));
                   3790: 
1.58      bertrand 3791:            i = ((long) strlen(tampon)) - 1;
1.1       bertrand 3792:            while(tampon[i] == '0')
                   3793:            {
                   3794:                tampon[i] = d_code_fin_chaine;
                   3795:                i--;
                   3796:            }
                   3797: 
                   3798:            if (ds_imposition_separateur_decimal == d_faux)
                   3799:            {
1.58      bertrand 3800:                i = ((long) strlen(tampon)) - 1;
1.1       bertrand 3801:                if (tampon[i] == '.')
                   3802:                {
                   3803:                    tampon[i] = d_code_fin_chaine;
                   3804:                }
                   3805:            }
                   3806:        }
1.4       bertrand 3807: 
1.1       bertrand 3808:        strcpy(chaine, tampon);
                   3809:    }
                   3810: 
                   3811:    if (test_cfsf(s_etat_processus, 48) == d_vrai)
                   3812:    {
1.58      bertrand 3813:        for(i = 0; i < (long) strlen(chaine); i++)
1.1       bertrand 3814:        {
                   3815:            if (chaine[i] == '.')
                   3816:            {
                   3817:                chaine[i] = ',';
                   3818:            }
                   3819:        }
                   3820:    }
                   3821: 
                   3822:    return(chaine);
                   3823: }
                   3824: 
                   3825: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>