File:  [local] / rpl / src / instructions_d4.c
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Sat Mar 6 18:29:07 2010 UTC (14 years, 2 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
Tous les noms de fichiers sont maintenant en UTF-8. Le contenu
des fichiers formatés est converti en UTF-8. Ces modifications sont
faites pour avoir un fonctionnement cohérent avec la bibliothèque sqlite.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.0.12
    4:   Copyright (C) 1989-2010 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl.conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Fonction 'delete'
   29: ================================================================================
   30:   Entrées : pointeur sur une structure struct_processus
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_delete(struct_processus *s_etat_processus)
   40: {
   41:     file                        *fichier;
   42: 
   43:     logical1                    erreur;
   44:     logical1                    existence;
   45:     logical1                    ouverture;
   46: 
   47:     struct_objet                *s_objet_argument;
   48: 
   49:     struct flock                lock;
   50: 
   51:     struct stat                 requete;
   52: 
   53:     unsigned char               *nom;
   54: 
   55:     unsigned long               unite;
   56: 
   57:     (*s_etat_processus).erreur_execution = d_ex;
   58: 
   59:     if ((*s_etat_processus).affichage_arguments == 'Y')
   60:     {
   61:         printf("\n  DELETE ");
   62: 
   63:         if ((*s_etat_processus).langue == 'F')
   64:         {
   65:             printf("(effacement d'un fichier)\n\n");
   66:         }
   67:         else
   68:         {
   69:             printf("(delete a file)\n\n");
   70:         }
   71: 
   72:         printf("    1: %s\n", d_CHN);
   73: 
   74:         return;
   75:     }
   76:     else if ((*s_etat_processus).test_instruction == 'Y')
   77:     {
   78:         (*s_etat_processus).nombre_arguments = -1;
   79:         return;
   80:     }
   81: 
   82:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
   83:     {
   84:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
   85:         {
   86:             return;
   87:         }
   88:     }
   89: 
   90:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
   91:             &s_objet_argument) == d_erreur)
   92:     {
   93:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
   94:         return;
   95:     }
   96: 
   97:     if ((*s_objet_argument).type == CHN)
   98:     {
   99:         if ((nom = transliteration(s_etat_processus,
  100:                 (unsigned char *) (*s_objet_argument).objet,
  101:                 d_locale, "UTF-8")) == NULL)
  102:         {
  103:             liberation(s_etat_processus, s_objet_argument);
  104:             return;
  105:         }
  106: 
  107:         if (stat(nom, &requete) != 0)
  108:         {
  109:             liberation(s_etat_processus, s_objet_argument);
  110:             free(nom);
  111: 
  112:             (*s_etat_processus).erreur_execution =
  113:                     d_ex_erreur_acces_fichier;
  114:             return;
  115:         }
  116: 
  117:         if (S_ISREG(requete.st_mode)) // Fichier régulier
  118:         {
  119:             if ((fichier = fopen(nom, "r+")) == NULL)
  120:             {
  121:                 liberation(s_etat_processus, s_objet_argument);
  122:                 free(nom);
  123: 
  124:                 (*s_etat_processus).erreur_execution =
  125:                         d_ex_erreur_acces_fichier;
  126:                 return;
  127:             }
  128: 
  129:             lock.l_type = F_WRLCK;
  130:             lock.l_whence = SEEK_SET;
  131:             lock.l_start = 0;
  132:             lock.l_len = 0;
  133:             lock.l_pid = getpid();
  134: 
  135:             if (fcntl(fileno(fichier), F_GETLK, &lock) == -1)
  136:             {
  137:                 free(nom);
  138: 
  139:                 if (fclose(fichier) != 0)
  140:                 {
  141:                     liberation(s_etat_processus, s_objet_argument);
  142: 
  143:                     (*s_etat_processus).erreur_execution =
  144:                             d_ex_erreur_acces_fichier;
  145:                     return;
  146:                 }
  147: 
  148:                 liberation(s_etat_processus, s_objet_argument);
  149: 
  150:                 (*s_etat_processus).erreur_execution =
  151:                         d_ex_erreur_acces_fichier;
  152:                 return;
  153:             }
  154: 
  155:             if (lock.l_type != F_UNLCK)
  156:             {
  157:                 liberation(s_etat_processus, s_objet_argument);
  158:                 free(nom);
  159: 
  160:                 (*s_etat_processus).erreur_execution =
  161:                         d_ex_erreur_acces_fichier;
  162:                 return;
  163:             }
  164: 
  165:             erreur = caracteristiques_fichier(s_etat_processus, nom,
  166:                     &existence, &ouverture, &unite);
  167: 
  168:             if ((erreur != d_absence_erreur) || (ouverture == d_vrai))
  169:             {
  170:                 liberation(s_etat_processus, s_objet_argument);
  171:                 free(nom);
  172: 
  173:                 (*s_etat_processus).erreur_execution =
  174:                         d_ex_erreur_acces_fichier;
  175:                 return;
  176:             }
  177: 
  178:             if (destruction_fichier(nom) == d_erreur)
  179:             {
  180:                 liberation(s_etat_processus, s_objet_argument);
  181:                 free(nom);
  182: 
  183:                 (*s_etat_processus).erreur_execution =
  184:                         d_ex_erreur_acces_fichier;
  185:                 return;
  186:             }
  187:         }
  188:         else // Socket
  189:         {
  190:             if (unlink(nom) != 0)
  191:             {
  192:                 liberation(s_etat_processus, s_objet_argument);
  193:                 free(nom);
  194: 
  195:                 (*s_etat_processus).erreur_execution =
  196:                         d_ex_erreur_acces_fichier;
  197:                 return;
  198:             }
  199:         }
  200: 
  201:         free(nom);
  202:     }
  203:     else
  204:     {
  205:         liberation(s_etat_processus, s_objet_argument);
  206: 
  207:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  208:         return;
  209:     }
  210: 
  211:     liberation(s_etat_processus, s_objet_argument);
  212: 
  213:     return;
  214: }
  215: 
  216: 
  217: /*
  218: ================================================================================
  219:   Fonction 'date'
  220: ================================================================================
  221:   Entrées : pointeur sur une structure struct_processus
  222: --------------------------------------------------------------------------------
  223:   Sorties :
  224: --------------------------------------------------------------------------------
  225:   Effets de bord : néant
  226: ================================================================================
  227: */
  228: 
  229: void
  230: instruction_date(struct_processus *s_etat_processus)
  231: {
  232:     struct_objet            *s_objet;
  233: 
  234:     struct timeval          horodatage;
  235: 
  236:     (*s_etat_processus).erreur_execution = d_ex;
  237: 
  238:     if ((*s_etat_processus).affichage_arguments == 'Y')
  239:     {
  240:         printf("\n  DATE ");
  241: 
  242:         if ((*s_etat_processus).langue == 'F')
  243:         {
  244:             printf("(information sur la date et l'heure)\n\n");
  245:         }
  246:         else
  247:         {
  248:             printf("(date and time)\n\n");
  249:         }
  250: 
  251:         printf("->  1: %s\n", d_LST);
  252: 
  253:         return;
  254:     }
  255:     else if ((*s_etat_processus).test_instruction == 'Y')
  256:     {
  257:         (*s_etat_processus).nombre_arguments = -1;
  258:         return;
  259:     }
  260: 
  261:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  262:     {
  263:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  264:         {
  265:             return;
  266:         }
  267:     }
  268: 
  269:     gettimeofday(&horodatage, NULL);
  270: 
  271:     if ((s_objet = formateur_date(s_etat_processus, &horodatage)) == NULL)
  272:     {
  273:         return;
  274:     }
  275: 
  276:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  277:             s_objet) == d_erreur)
  278:     {
  279:         return;
  280:     }
  281: 
  282:     return;
  283: }
  284: 
  285: 
  286: /*
  287: ================================================================================
  288:   Fonction 'drws'
  289: ================================================================================
  290:   Entrées : pointeur sur une structure struct_processus
  291: --------------------------------------------------------------------------------
  292:   Sorties :
  293: --------------------------------------------------------------------------------
  294:   Effets de bord : néant
  295: ================================================================================
  296: */
  297: 
  298: void
  299: instruction_drws(struct_processus *s_etat_processus)
  300: {
  301:     file                        *fichier;
  302: 
  303:     int                         dimensions;
  304: 
  305:     logical1                    presence_variable;
  306:     logical1                    matrice_entiere;
  307: 
  308:     long                        i;
  309: 
  310:     struct_objet                *s_objet_statistique;
  311: 
  312:     unsigned char               *nom_fichier;
  313: 
  314:     unsigned long               j;
  315: 
  316:     struct_fichier_graphique    *l_fichier_courant;
  317:     struct_fichier_graphique    *l_fichier_precedent;
  318: 
  319:     (*s_etat_processus).erreur_execution = d_ex;
  320: 
  321:     if ((*s_etat_processus).affichage_arguments == 'Y')
  322:     {
  323:         printf("\n  DRWS ");
  324: 
  325:         if ((*s_etat_processus).langue == 'F')
  326:         {
  327:             printf("(affiche une série statistique)\n\n");
  328:             printf("  Aucun argument\n");
  329:         }
  330:         else
  331:         {
  332:             printf("(draw statistical data)\n\n");
  333:             printf("  No argument\n");
  334:         }
  335: 
  336:         return;
  337:     }
  338:     else if ((*s_etat_processus).test_instruction == 'Y')
  339:     {
  340:         (*s_etat_processus).nombre_arguments = -1;
  341:         return;
  342:     }
  343: 
  344:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  345:     {
  346:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  347:         {
  348:             return;
  349:         }
  350:     }
  351: 
  352:     /*
  353:      * Vérification de la présence de la matrice statistique
  354:      */
  355: 
  356:     if (recherche_variable(s_etat_processus, ds_sdat) == d_faux)
  357:     {
  358:         /*
  359:          * Aucune variable ds_sdat n'existe.
  360:          */
  361: 
  362:         (*s_etat_processus).erreur_execution = d_ex_absence_observations;
  363:         (*s_etat_processus).erreur_systeme = d_es;
  364: 
  365:         return;
  366:     }
  367: 
  368:     i = (*s_etat_processus).position_variable_courante;
  369:     presence_variable = d_faux;
  370: 
  371:     while(i >= 0)
  372:     {
  373:         if ((strcmp((*s_etat_processus).s_liste_variables[i].nom,
  374:                 ds_sdat) == 0) && ((*s_etat_processus)
  375:                 .s_liste_variables[i].niveau == 1))
  376:         {
  377:             presence_variable = d_vrai;
  378:             break;
  379:         }
  380: 
  381:         i--;
  382:     }
  383: 
  384:     if (presence_variable == d_faux)
  385:     {
  386:         (*s_etat_processus).erreur_execution = d_ex_absence_observations;
  387:         return;
  388:     }
  389: 
  390:     if ((s_objet_statistique = (*s_etat_processus).s_liste_variables[i].objet)
  391:             == NULL)
  392:     {
  393:         (*s_etat_processus).erreur_execution = d_ex_variable_partagee;
  394:         return;
  395:     }
  396: 
  397:     if ((*s_objet_statistique).type == MIN)
  398:     {
  399:         matrice_entiere = d_vrai;
  400:     }
  401:     else if ((*s_objet_statistique).type == MRL)
  402:     {
  403:         matrice_entiere = d_faux;
  404:     }
  405:     else
  406:     {
  407:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  408:         return;
  409:     }
  410: 
  411:     /*
  412:      * Création du fichier graphique temporaire
  413:      */
  414: 
  415:     if ((nom_fichier = creation_nom_fichier(s_etat_processus,
  416:             (*s_etat_processus).chemin_fichiers_temporaires)) == NULL)
  417:     {
  418:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  419:         return;
  420:     }
  421: 
  422:     if ((fichier = fopen(nom_fichier, "w+")) == NULL)
  423:     {
  424:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  425:         return;
  426:     }
  427: 
  428:     switch((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_colonnes)
  429:     {
  430: 
  431:     /*
  432:      * Une seule colonne
  433:      */
  434: 
  435:         case 1 :
  436:         {
  437:             dimensions = 2;
  438: 
  439:             for(j = 0; j < (*((struct_matrice *) (*s_objet_statistique).objet))
  440:                     .nombre_lignes; j++)
  441:             {
  442:                 if (matrice_entiere == d_vrai)
  443:                 {
  444:                     if (fprintf(fichier, "%f %f\n", (double) j, (double)
  445:                             ((integer8 **) (*((struct_matrice *)
  446:                             (*s_objet_statistique).objet)).tableau)[j][0]) < 0)
  447:                     {
  448:                         (*s_etat_processus).erreur_systeme =
  449:                                 d_es_erreur_fichier;
  450:                         return;
  451:                     }
  452:                 }
  453:                 else
  454:                 {
  455:                     if (fprintf(fichier, "%f %f\n", (double) j, (double)
  456:                             ((real8 **) (*((struct_matrice *)
  457:                             (*s_objet_statistique).objet)).tableau)[j][0]) < 0)
  458:                     {
  459:                         (*s_etat_processus).erreur_systeme =
  460:                                 d_es_erreur_fichier;
  461:                         return;
  462:                     }
  463:                 }
  464:             }
  465: 
  466:             break;
  467:         }
  468: 
  469:     /*
  470:      * Deux colonnes ou plus
  471:      */
  472: 
  473:         default :
  474:         {
  475:             dimensions = 2;
  476: 
  477:             if (((*s_etat_processus).colonne_statistique_1 < 1) ||
  478:                     ((*s_etat_processus).colonne_statistique_2 < 1) ||
  479:                     ((*s_etat_processus).colonne_statistique_1 > (signed long)
  480:                     (*((struct_matrice *) (*s_objet_statistique).objet))
  481:                     .nombre_colonnes) ||
  482:                     ((*s_etat_processus).colonne_statistique_2 > (signed long)
  483:                     (*((struct_matrice *) (*s_objet_statistique).objet))
  484:                     .nombre_colonnes))
  485:             {
  486:                 if (fclose(fichier) != 0)
  487:                 {
  488:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  489:                     return;
  490:                 }
  491: 
  492:                 if (destruction_fichier(nom_fichier) == d_erreur)
  493:                 {
  494:                     (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  495:                     return;
  496:                 }
  497: 
  498:                 free(nom_fichier);
  499: 
  500:                 (*s_etat_processus).erreur_execution =
  501:                         d_ex_observations_inexistantes;
  502:                 return;
  503:             }
  504: 
  505:             for(j = 0; j < (*((struct_matrice *) (*s_objet_statistique).objet))
  506:                     .nombre_lignes; j++)
  507:             {
  508:                 if (matrice_entiere == d_vrai)
  509:                 {
  510:                     if (fprintf(fichier, "%f %f\n", (double) ((integer8 **)
  511:                             (*((struct_matrice *) (*s_objet_statistique).objet))
  512:                             .tableau)[j][(*s_etat_processus)
  513:                             .colonne_statistique_1 - 1], (double) ((integer8 **)
  514:                             (*((struct_matrice *) (*s_objet_statistique).objet))
  515:                             .tableau)[j][(*s_etat_processus)
  516:                             .colonne_statistique_2 - 1]) < 0)
  517:                     {
  518:                         (*s_etat_processus).erreur_systeme =
  519:                                 d_es_erreur_fichier;
  520:                         return;
  521:                     }
  522:                 }
  523:                 else
  524:                 {
  525:                     if (fprintf(fichier, "%f %f\n", (double) ((real8 **)
  526:                             (*((struct_matrice *) (*s_objet_statistique).objet))
  527:                             .tableau)[j][(*s_etat_processus)
  528:                             .colonne_statistique_1 - 1], (double) ((real8 **)
  529:                             (*((struct_matrice *) (*s_objet_statistique).objet))
  530:                             .tableau)[j][(*s_etat_processus)
  531:                             .colonne_statistique_2 - 1]) < 0)
  532:                     {
  533:                         (*s_etat_processus).erreur_systeme =
  534:                                 d_es_erreur_fichier;
  535:                         return;
  536:                     }
  537:                 }
  538:             }
  539: 
  540:             break;
  541:         }
  542:     }
  543: 
  544:     /*
  545:      * Fermeture du fichier graphique
  546:      */
  547: 
  548:     if (fclose(fichier) != 0)
  549:     {
  550:         (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
  551:         return;
  552:     }
  553: 
  554:     /*
  555:      * Chaînage du fichier temporaire à la liste des fichiers graphiques
  556:      */
  557: 
  558:     l_fichier_courant = (*s_etat_processus).fichiers_graphiques;
  559: 
  560:     if (l_fichier_courant == NULL)
  561:     {
  562:         if (((*s_etat_processus).fichiers_graphiques = malloc(
  563:                 sizeof(struct_fichier_graphique))) == NULL)
  564:         {
  565:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  566:             return;
  567:         }
  568: 
  569:         (*(*s_etat_processus).fichiers_graphiques).suivant = NULL;
  570:         (*(*s_etat_processus).fichiers_graphiques).nom = nom_fichier;
  571:         (*(*s_etat_processus).fichiers_graphiques).legende = NULL;
  572:         (*(*s_etat_processus).fichiers_graphiques).dimensions = dimensions;
  573:         (*(*s_etat_processus).fichiers_graphiques).presence_axes = d_faux;
  574:         (*(*s_etat_processus).fichiers_graphiques).systeme_axes =
  575:                 (*s_etat_processus).systeme_axes;
  576:         strcpy((*(*s_etat_processus).fichiers_graphiques).type,
  577:                 (*s_etat_processus).type_trace_sigma);
  578:     }
  579:     else
  580:     {
  581:         while(l_fichier_courant != NULL)
  582:         {
  583:             if ((*l_fichier_courant).dimensions != dimensions)
  584:             {
  585:                 (*s_etat_processus).erreur_execution =
  586:                         d_ex_dimensions_differentes;
  587:                 return;
  588:             }
  589: 
  590:             l_fichier_precedent = l_fichier_courant;
  591:             l_fichier_courant = (*l_fichier_courant).suivant;
  592:         }
  593: 
  594:         l_fichier_courant = l_fichier_precedent;
  595: 
  596:         if (((*l_fichier_courant).suivant = malloc(
  597:                 sizeof(struct_fichier_graphique))) == NULL)
  598:         {
  599:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  600:             return;
  601:         }
  602: 
  603:         l_fichier_courant = (*l_fichier_courant).suivant;
  604: 
  605:         (*l_fichier_courant).suivant = NULL;
  606:         (*l_fichier_courant).nom = nom_fichier;
  607:         (*l_fichier_courant).legende = NULL;
  608:         (*l_fichier_courant).dimensions = dimensions;
  609:         (*l_fichier_courant).presence_axes = d_faux;
  610:         (*l_fichier_courant).systeme_axes = (*s_etat_processus).systeme_axes;
  611:         strcpy((*l_fichier_courant).type, (*s_etat_processus).type_trace_sigma);
  612:     }
  613: 
  614:     /*
  615:      * Affichage du graphique
  616:      */
  617: 
  618:     appel_gnuplot(s_etat_processus, 'N');
  619:     (*s_etat_processus).erreur_execution = d_ex;
  620:     (*s_etat_processus).exception = d_ep;
  621: 
  622:     return;
  623: }
  624: 
  625: 
  626: /*
  627: ================================================================================
  628:   Fonction 'decr'
  629: ================================================================================
  630:   Entrées :
  631: --------------------------------------------------------------------------------
  632:   Sorties :
  633: --------------------------------------------------------------------------------
  634:   Effets de bord : néant
  635: ================================================================================
  636: */
  637: 
  638: void
  639: instruction_decr(struct_processus *s_etat_processus)
  640: {
  641:     logical1                    variable_partagee;
  642: 
  643:     struct_objet                *s_copie_argument;
  644:     struct_objet                *s_objet_argument;
  645: 
  646:     (*s_etat_processus).erreur_execution = d_ex;
  647: 
  648:     if ((*s_etat_processus).affichage_arguments == 'Y')
  649:     {
  650:         printf("\n  DECR ");
  651: 
  652:         if ((*s_etat_processus).langue == 'F')
  653:         {
  654:             printf("(décrémentation)\n\n");
  655:         }
  656:         else
  657:         {
  658:             printf("(decrementation)\n\n");
  659:         }
  660: 
  661:         printf("    1: %s\n", d_INT);
  662:         printf("->  1: %s\n\n", d_INT);
  663: 
  664:         printf("    1: %s\n", d_NOM);
  665: 
  666:         return;
  667:     }
  668:     else if ((*s_etat_processus).test_instruction == 'Y')
  669:     {
  670:         (*s_etat_processus).nombre_arguments = -1;
  671:         return;
  672:     }
  673: 
  674:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  675:     {
  676:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
  677:         {
  678:             return;
  679:         }
  680:     }
  681: 
  682:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  683:             &s_objet_argument) == d_erreur)
  684:     {
  685:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  686:         return;
  687:     }
  688: 
  689:     if ((*s_objet_argument).type == INT)
  690:     {
  691:         if ((s_copie_argument = copie_objet(s_etat_processus,
  692:                 s_objet_argument, 'O')) == NULL)
  693:         {
  694:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  695:             return;
  696:         }
  697: 
  698:         liberation(s_etat_processus, s_objet_argument);
  699:         s_objet_argument = s_copie_argument;
  700: 
  701:         (*((integer8 *) (*s_objet_argument).objet))--;
  702: 
  703:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  704:                 s_objet_argument) == d_erreur)
  705:         {
  706:             return;
  707:         }
  708:     }
  709:     else if ((*s_objet_argument).type == NOM)
  710:     {
  711:         if (recherche_variable(s_etat_processus, (*((struct_nom *)
  712:                 (*s_objet_argument).objet)).nom) == d_faux)
  713:         {
  714:             (*s_etat_processus).erreur_systeme = d_es;
  715:             (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
  716: 
  717:             return;
  718:         }
  719: 
  720:         liberation(s_etat_processus, s_objet_argument);
  721: 
  722:         if ((*s_etat_processus).s_liste_variables
  723:                 [(*s_etat_processus).position_variable_courante]
  724:                 .variable_verrouillee == d_vrai)
  725:         {
  726:             (*s_etat_processus).erreur_execution =
  727:                     d_ex_variable_verrouillee;
  728:             return;
  729:         }
  730: 
  731:         if ((*s_etat_processus).s_liste_variables
  732:                 [(*s_etat_processus).position_variable_courante].objet
  733:                 == NULL)
  734:         {
  735:             if (pthread_mutex_lock(&((*(*s_etat_processus)
  736:                     .s_liste_variables_partagees).mutex)) != 0)
  737:             {
  738:                 (*s_etat_processus).erreur_systeme = d_es_processus;
  739:                 return;
  740:             }
  741: 
  742:             if (recherche_variable_partagee(s_etat_processus,
  743:                     (*s_etat_processus).s_liste_variables
  744:                     [(*s_etat_processus).position_variable_courante].nom,
  745:                     (*s_etat_processus).s_liste_variables
  746:                     [(*s_etat_processus).position_variable_courante]
  747:                     .variable_partagee, (*s_etat_processus).s_liste_variables
  748:                     [(*s_etat_processus).position_variable_courante]
  749:                     .origine) == d_faux)
  750:             {
  751:                 (*s_etat_processus).erreur_systeme = d_es;
  752:                 (*s_etat_processus).erreur_execution =
  753:                         d_ex_variable_non_definie;
  754: 
  755:                 return;
  756:             }
  757: 
  758:             s_objet_argument = (*(*s_etat_processus)
  759:                     .s_liste_variables_partagees).table
  760:                     [(*(*s_etat_processus).s_liste_variables_partagees)
  761:                     .position_variable].objet;
  762:             variable_partagee = d_vrai;
  763:         }
  764:         else
  765:         {
  766:             s_objet_argument = (*s_etat_processus).s_liste_variables
  767:                     [(*s_etat_processus).position_variable_courante].objet;
  768:             variable_partagee = d_faux;
  769:         }
  770: 
  771:         if ((s_copie_argument = copie_objet(s_etat_processus,
  772:                 s_objet_argument, 'O')) == NULL)
  773:         {
  774:             if (variable_partagee == d_vrai)
  775:             {
  776:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  777:                         .s_liste_variables_partagees).mutex)) != 0)
  778:                 {
  779:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  780:                     return;
  781:                 }
  782:             }
  783: 
  784:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  785:             return;
  786:         }
  787: 
  788:         liberation(s_etat_processus, s_objet_argument);
  789: 
  790:         if (variable_partagee == d_vrai)
  791:         {
  792:             (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  793:                     .position_variable_courante].objet = NULL;
  794:             (*(*s_etat_processus)
  795:                     .s_liste_variables_partagees).table
  796:                     [(*(*s_etat_processus).s_liste_variables_partagees)
  797:                     .position_variable].objet = s_copie_argument;
  798:         }
  799:         else
  800:         {
  801:             (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  802:                     .position_variable_courante].objet = s_copie_argument;
  803:         }
  804: 
  805:         if ((*s_copie_argument).type == INT)
  806:         {
  807:             (*((integer8 *) (*s_copie_argument).objet))--;
  808: 
  809:             if (variable_partagee == d_vrai)
  810:             {
  811:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  812:                         .s_liste_variables_partagees).mutex)) != 0)
  813:                 {
  814:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  815:                     return;
  816:                 }
  817:             }
  818:         }
  819:         else
  820:         {
  821:             if (variable_partagee == d_vrai)
  822:             {
  823:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  824:                         .s_liste_variables_partagees).mutex)) != 0)
  825:                 {
  826:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  827:                     return;
  828:                 }
  829:             }
  830: 
  831:             (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  832:             return;
  833:         }
  834:     }
  835:     else
  836:     {
  837:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  838: 
  839:         liberation(s_etat_processus, s_objet_argument);
  840:         return;
  841:     }
  842: 
  843:     return;
  844: }
  845: 
  846: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>