![]() ![]() | ![]() |
Passage de la branche 4.1 en branche stable.
1: /* 2: ================================================================================ 3: RPL/2 (R) version 4.1.0 4: Copyright (C) 1989-2011 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: const char *queue; 42: 43: file *fichier; 44: 45: integer8 lecture_i64; 46: 47: logical1 erreur; 48: logical1 existence; 49: logical1 ouverture; 50: 51: sqlite3_stmt *ppStmt; 52: 53: struct_descripteur_fichier *descripteur; 54: 55: struct_objet *s_objet_argument; 56: struct_objet *s_objet_indice; 57: 58: struct flock lock; 59: 60: struct stat requete; 61: 62: unsigned char *commande; 63: unsigned char *nom; 64: unsigned char *utf8; 65: 66: unsigned long unite; 67: 68: (*s_etat_processus).erreur_execution = d_ex; 69: 70: if ((*s_etat_processus).affichage_arguments == 'Y') 71: { 72: printf("\n DELETE "); 73: 74: if ((*s_etat_processus).langue == 'F') 75: { 76: printf("(effacement d'un fichier ou d'un enregistrement)\n\n"); 77: } 78: else 79: { 80: printf("(delete file or record)\n\n"); 81: } 82: 83: printf(" 1: %s\n\n", d_CHN); 84: 85: printf(" 2: %s, %s\n", d_CHN, d_INT); 86: printf(" 1: %s\n", d_FCH); 87: return; 88: } 89: else if ((*s_etat_processus).test_instruction == 'Y') 90: { 91: (*s_etat_processus).nombre_arguments = -1; 92: return; 93: } 94: 95: if (test_cfsf(s_etat_processus, 31) == d_vrai) 96: { 97: if ((*s_etat_processus).l_base_pile == NULL) 98: { 99: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 100: return; 101: } 102: 103: if ((*(*(*s_etat_processus).l_base_pile).donnee).type == FCH) 104: { 105: if (empilement_pile_last(s_etat_processus, 2) == d_erreur) 106: { 107: return; 108: } 109: } 110: else 111: { 112: if (empilement_pile_last(s_etat_processus, 1) == d_erreur) 113: { 114: return; 115: } 116: } 117: } 118: 119: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 120: &s_objet_argument) == d_erreur) 121: { 122: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 123: return; 124: } 125: 126: if ((*s_objet_argument).type == CHN) 127: { 128: if ((nom = transliteration(s_etat_processus, 129: (unsigned char *) (*s_objet_argument).objet, 130: d_locale, "UTF-8")) == NULL) 131: { 132: liberation(s_etat_processus, s_objet_argument); 133: return; 134: } 135: 136: if (stat(nom, &requete) != 0) 137: { 138: liberation(s_etat_processus, s_objet_argument); 139: free(nom); 140: 141: (*s_etat_processus).erreur_execution = 142: d_ex_erreur_acces_fichier; 143: return; 144: } 145: 146: if (S_ISREG(requete.st_mode)) // Fichier régulier 147: { 148: if ((fichier = fopen(nom, "r+")) == NULL) 149: { 150: liberation(s_etat_processus, s_objet_argument); 151: free(nom); 152: 153: (*s_etat_processus).erreur_execution = 154: d_ex_erreur_acces_fichier; 155: return; 156: } 157: 158: lock.l_type = F_WRLCK; 159: lock.l_whence = SEEK_SET; 160: lock.l_start = 0; 161: lock.l_len = 0; 162: lock.l_pid = getpid(); 163: 164: if (fcntl(fileno(fichier), F_GETLK, &lock) == -1) 165: { 166: free(nom); 167: 168: if (fclose(fichier) != 0) 169: { 170: liberation(s_etat_processus, s_objet_argument); 171: 172: (*s_etat_processus).erreur_execution = 173: d_ex_erreur_acces_fichier; 174: return; 175: } 176: 177: liberation(s_etat_processus, s_objet_argument); 178: 179: (*s_etat_processus).erreur_execution = 180: d_ex_erreur_acces_fichier; 181: return; 182: } 183: 184: if (lock.l_type != F_UNLCK) 185: { 186: liberation(s_etat_processus, s_objet_argument); 187: free(nom); 188: 189: (*s_etat_processus).erreur_execution = 190: d_ex_erreur_acces_fichier; 191: return; 192: } 193: 194: erreur = caracteristiques_fichier(s_etat_processus, nom, 195: &existence, &ouverture, &unite); 196: 197: if ((erreur != d_absence_erreur) || (ouverture == d_vrai)) 198: { 199: liberation(s_etat_processus, s_objet_argument); 200: free(nom); 201: 202: (*s_etat_processus).erreur_execution = 203: d_ex_erreur_acces_fichier; 204: return; 205: } 206: 207: if (destruction_fichier(nom) == d_erreur) 208: { 209: liberation(s_etat_processus, s_objet_argument); 210: free(nom); 211: 212: (*s_etat_processus).erreur_execution = 213: d_ex_erreur_acces_fichier; 214: return; 215: } 216: } 217: else // Socket 218: { 219: if (unlink(nom) != 0) 220: { 221: liberation(s_etat_processus, s_objet_argument); 222: free(nom); 223: 224: (*s_etat_processus).erreur_execution = 225: d_ex_erreur_acces_fichier; 226: return; 227: } 228: } 229: 230: free(nom); 231: } 232: else if ((*s_objet_argument).type == FCH) 233: { 234: if ((descripteur = descripteur_fichier(s_etat_processus, 235: (struct_fichier *) (*s_objet_argument).objet)) == NULL) 236: { 237: return; 238: } 239: 240: /* 241: * Vérification des verrous 242: */ 243: 244: lock.l_type = F_RDLCK; 245: lock.l_whence = SEEK_SET; 246: lock.l_start = 0; 247: lock.l_len = 0; 248: lock.l_pid = getpid(); 249: 250: if (fcntl(fileno((*descripteur).descripteur_c), F_GETLK, &lock) 251: == -1) 252: { 253: liberation(s_etat_processus, s_objet_argument); 254: 255: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 256: return; 257: } 258: 259: if (lock.l_type != F_UNLCK) 260: { 261: liberation(s_etat_processus, s_objet_argument); 262: 263: (*s_etat_processus).erreur_execution = 264: d_ex_fichier_verrouille; 265: return; 266: } 267: 268: if ((*((struct_fichier *) (*s_objet_argument).objet)) 269: .protection == 'R') 270: { 271: liberation(s_etat_processus, s_objet_argument); 272: 273: (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier; 274: return; 275: } 276: 277: if ((*((struct_fichier *) (*s_objet_argument).objet)).binaire == 'N') 278: { 279: if ((*((struct_fichier *) (*s_objet_argument).objet)).acces 280: == 'S') 281: { 282: liberation(s_etat_processus, s_objet_argument); 283: 284: (*s_etat_processus).erreur_execution = d_ex_erreur_type_fichier; 285: return; 286: } 287: else if ((*((struct_fichier *) (*s_objet_argument).objet)).acces 288: == 'D') 289: { 290: BUG(((*descripteur).type == 'C'), uprintf("Bad filtype !\n")); 291: 292: if (depilement(s_etat_processus, &((*s_etat_processus) 293: .l_base_pile), &s_objet_indice) == d_erreur) 294: { 295: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 296: return; 297: } 298: 299: if ((*s_objet_indice).type != INT) 300: { 301: liberation(s_etat_processus, s_objet_argument); 302: liberation(s_etat_processus, s_objet_indice); 303: 304: (*s_etat_processus).erreur_execution = 305: d_ex_erreur_type_argument; 306: return; 307: } 308: 309: if (alsprintf(&commande, "select count(*) from data where " 310: "id = %lld", (*((integer8 *) (*s_objet_indice).objet))) 311: < 0) 312: { 313: (*s_etat_processus).erreur_systeme = 314: d_es_allocation_memoire; 315: return; 316: } 317: 318: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, 319: commande, strlen(commande), &ppStmt, &queue) 320: != SQLITE_OK) 321: { 322: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 323: return; 324: } 325: 326: if (sqlite3_step(ppStmt) != SQLITE_ROW) 327: { 328: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 329: return; 330: } 331: 332: lecture_i64 = sqlite3_column_int64(ppStmt, 0); 333: 334: if (sqlite3_step(ppStmt) != SQLITE_DONE) 335: { 336: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 337: return; 338: } 339: 340: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 341: { 342: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 343: return; 344: } 345: 346: free(commande); 347: 348: if (lecture_i64 == 0) 349: { 350: liberation(s_etat_processus, s_objet_argument); 351: liberation(s_etat_processus, s_objet_indice); 352: 353: (*s_etat_processus).erreur_execution = 354: d_ex_enregistrement_inexistant; 355: return; 356: } 357: 358: if (alsprintf(&commande, "delete from data where id = %lld", 359: (*((integer8 *) (*s_objet_indice).objet))) < 0) 360: { 361: (*s_etat_processus).erreur_systeme = 362: d_es_allocation_memoire; 363: return; 364: } 365: 366: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, 367: commande, strlen(commande), &ppStmt, &queue) 368: != SQLITE_OK) 369: { 370: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 371: return; 372: } 373: 374: if (sqlite3_step(ppStmt) != SQLITE_DONE) 375: { 376: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 377: return; 378: } 379: 380: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 381: { 382: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 383: return; 384: } 385: 386: free(commande); 387: liberation(s_etat_processus, s_objet_indice); 388: } 389: else 390: { 391: BUG(((*descripteur).type == 'C'), uprintf("Bad filtype !\n")); 392: 393: if (depilement(s_etat_processus, &((*s_etat_processus) 394: .l_base_pile), &s_objet_indice) == d_erreur) 395: { 396: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 397: return; 398: } 399: 400: if ((*s_objet_indice).type != CHN) 401: { 402: liberation(s_etat_processus, s_objet_argument); 403: liberation(s_etat_processus, s_objet_indice); 404: 405: (*s_etat_processus).erreur_execution = 406: d_ex_erreur_type_argument; 407: return; 408: } 409: 410: // Récupération de l'identifiant de la clef 411: 412: if ((utf8 = transliteration(s_etat_processus, 413: (unsigned char *) (*s_objet_indice).objet, d_locale, 414: "UTF-8")) == NULL) 415: { 416: liberation(s_etat_processus, s_objet_argument); 417: liberation(s_etat_processus, s_objet_indice); 418: 419: return; 420: } 421: 422: if (alsprintf(&commande, "select id from key where key = " 423: "'{ \"%s\" }'", utf8) < 0) 424: { 425: (*s_etat_processus).erreur_systeme = 426: d_es_allocation_memoire; 427: return; 428: } 429: 430: free(utf8); 431: 432: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, 433: commande, strlen(commande), &ppStmt, &queue) 434: != SQLITE_OK) 435: { 436: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 437: return; 438: } 439: 440: switch(sqlite3_step(ppStmt)) 441: { 442: case SQLITE_ROW: 443: { 444: // Correspondance 445: break; 446: } 447: 448: case SQLITE_DONE: 449: { 450: // Aucune correspondance 451: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 452: { 453: (*s_etat_processus).erreur_systeme = 454: d_es_erreur_fichier; 455: return; 456: } 457: 458: free(commande); 459: 460: liberation(s_etat_processus, s_objet_argument); 461: liberation(s_etat_processus, s_objet_indice); 462: 463: (*s_etat_processus).erreur_execution = 464: d_ex_enregistrement_inexistant; 465: return; 466: } 467: 468: default: 469: { 470: (*s_etat_processus).erreur_systeme = 471: d_es_erreur_fichier; 472: return; 473: } 474: } 475: 476: if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) 477: { 478: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 479: return; 480: } 481: 482: lecture_i64 = sqlite3_column_int64(ppStmt, 0); 483: 484: if (sqlite3_step(ppStmt) != SQLITE_DONE) 485: { 486: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 487: return; 488: } 489: 490: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 491: { 492: (*s_etat_processus).erreur_systeme = 493: d_es_erreur_fichier; 494: return; 495: } 496: 497: free(commande); 498: 499: if (alsprintf(&commande, "delete from data where key_id = %lld", 500: lecture_i64) < 0) 501: { 502: (*s_etat_processus).erreur_systeme = 503: d_es_allocation_memoire; 504: return; 505: } 506: 507: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, 508: commande, strlen(commande), &ppStmt, &queue) 509: != SQLITE_OK) 510: { 511: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 512: return; 513: } 514: 515: if (sqlite3_step(ppStmt) != SQLITE_DONE) 516: { 517: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 518: return; 519: } 520: 521: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 522: { 523: (*s_etat_processus).erreur_systeme = 524: d_es_erreur_fichier; 525: return; 526: } 527: 528: free(commande); 529: 530: if (alsprintf(&commande, "delete from key where id = %lld", 531: lecture_i64) < 0) 532: { 533: (*s_etat_processus).erreur_systeme = 534: d_es_allocation_memoire; 535: return; 536: } 537: 538: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, 539: commande, strlen(commande), &ppStmt, &queue) 540: != SQLITE_OK) 541: { 542: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 543: return; 544: } 545: 546: if (sqlite3_step(ppStmt) != SQLITE_DONE) 547: { 548: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 549: return; 550: } 551: 552: if (sqlite3_finalize(ppStmt) != SQLITE_OK) 553: { 554: (*s_etat_processus).erreur_systeme = 555: d_es_erreur_fichier; 556: return; 557: } 558: 559: free(commande); 560: liberation(s_etat_processus, s_objet_indice); 561: } 562: } 563: else // Fichiers non formatés 564: { 565: } 566: } 567: else 568: { 569: liberation(s_etat_processus, s_objet_argument); 570: 571: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 572: return; 573: } 574: 575: liberation(s_etat_processus, s_objet_argument); 576: 577: return; 578: } 579: 580: 581: /* 582: ================================================================================ 583: Fonction 'date' 584: ================================================================================ 585: Entrées : pointeur sur une structure struct_processus 586: -------------------------------------------------------------------------------- 587: Sorties : 588: -------------------------------------------------------------------------------- 589: Effets de bord : néant 590: ================================================================================ 591: */ 592: 593: void 594: instruction_date(struct_processus *s_etat_processus) 595: { 596: struct_objet *s_objet; 597: 598: struct timeval horodatage; 599: 600: (*s_etat_processus).erreur_execution = d_ex; 601: 602: if ((*s_etat_processus).affichage_arguments == 'Y') 603: { 604: printf("\n DATE "); 605: 606: if ((*s_etat_processus).langue == 'F') 607: { 608: printf("(information sur la date et l'heure)\n\n"); 609: } 610: else 611: { 612: printf("(date and time)\n\n"); 613: } 614: 615: printf("-> 1: %s\n", d_LST); 616: 617: return; 618: } 619: else if ((*s_etat_processus).test_instruction == 'Y') 620: { 621: (*s_etat_processus).nombre_arguments = -1; 622: return; 623: } 624: 625: if (test_cfsf(s_etat_processus, 31) == d_vrai) 626: { 627: if (empilement_pile_last(s_etat_processus, 0) == d_erreur) 628: { 629: return; 630: } 631: } 632: 633: gettimeofday(&horodatage, NULL); 634: 635: if ((s_objet = formateur_date(s_etat_processus, &horodatage)) == NULL) 636: { 637: return; 638: } 639: 640: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 641: s_objet) == d_erreur) 642: { 643: return; 644: } 645: 646: return; 647: } 648: 649: 650: /* 651: ================================================================================ 652: Fonction 'drws' 653: ================================================================================ 654: Entrées : pointeur sur une structure struct_processus 655: -------------------------------------------------------------------------------- 656: Sorties : 657: -------------------------------------------------------------------------------- 658: Effets de bord : néant 659: ================================================================================ 660: */ 661: 662: void 663: instruction_drws(struct_processus *s_etat_processus) 664: { 665: file *fichier; 666: 667: int dimensions; 668: 669: logical1 matrice_entiere; 670: 671: struct_objet *s_objet_statistique; 672: 673: unsigned char *nom_fichier; 674: 675: unsigned long j; 676: 677: struct_fichier_graphique *l_fichier_courant; 678: struct_fichier_graphique *l_fichier_precedent; 679: 680: (*s_etat_processus).erreur_execution = d_ex; 681: 682: if ((*s_etat_processus).affichage_arguments == 'Y') 683: { 684: printf("\n DRWS "); 685: 686: if ((*s_etat_processus).langue == 'F') 687: { 688: printf("(affiche une série statistique)\n\n"); 689: printf(" Aucun argument\n"); 690: } 691: else 692: { 693: printf("(draw statistical data)\n\n"); 694: printf(" No argument\n"); 695: } 696: 697: return; 698: } 699: else if ((*s_etat_processus).test_instruction == 'Y') 700: { 701: (*s_etat_processus).nombre_arguments = -1; 702: return; 703: } 704: 705: if (test_cfsf(s_etat_processus, 31) == d_vrai) 706: { 707: if (empilement_pile_last(s_etat_processus, 0) == d_erreur) 708: { 709: return; 710: } 711: } 712: 713: /* 714: * Vérification de la présence de la matrice statistique 715: */ 716: 717: if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) 718: { 719: /* 720: * Aucune variable ds_sdat n'existe. 721: */ 722: 723: if ((*s_etat_processus).erreur_execution == d_ex) 724: { 725: (*s_etat_processus).erreur_execution = d_ex_absence_observations; 726: } 727: 728: (*s_etat_processus).erreur_systeme = d_es; 729: 730: return; 731: } 732: 733: if ((*s_objet_statistique).type == MIN) 734: { 735: matrice_entiere = d_vrai; 736: } 737: else if ((*s_objet_statistique).type == MRL) 738: { 739: matrice_entiere = d_faux; 740: } 741: else 742: { 743: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 744: return; 745: } 746: 747: /* 748: * Création du fichier graphique temporaire 749: */ 750: 751: if ((nom_fichier = creation_nom_fichier(s_etat_processus, 752: (*s_etat_processus).chemin_fichiers_temporaires)) == NULL) 753: { 754: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 755: return; 756: } 757: 758: if ((fichier = fopen(nom_fichier, "w+")) == NULL) 759: { 760: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 761: return; 762: } 763: 764: switch((*((struct_matrice *) (*s_objet_statistique).objet)).nombre_colonnes) 765: { 766: 767: /* 768: * Une seule colonne 769: */ 770: 771: case 1 : 772: { 773: dimensions = 2; 774: 775: for(j = 0; j < (*((struct_matrice *) (*s_objet_statistique).objet)) 776: .nombre_lignes; j++) 777: { 778: if (matrice_entiere == d_vrai) 779: { 780: if (fprintf(fichier, "%f %f\n", (double) j, (double) 781: ((integer8 **) (*((struct_matrice *) 782: (*s_objet_statistique).objet)).tableau)[j][0]) < 0) 783: { 784: (*s_etat_processus).erreur_systeme = 785: d_es_erreur_fichier; 786: return; 787: } 788: } 789: else 790: { 791: if (fprintf(fichier, "%f %f\n", (double) j, (double) 792: ((real8 **) (*((struct_matrice *) 793: (*s_objet_statistique).objet)).tableau)[j][0]) < 0) 794: { 795: (*s_etat_processus).erreur_systeme = 796: d_es_erreur_fichier; 797: return; 798: } 799: } 800: } 801: 802: break; 803: } 804: 805: /* 806: * Deux colonnes ou plus 807: */ 808: 809: default : 810: { 811: dimensions = 2; 812: 813: if (((*s_etat_processus).colonne_statistique_1 < 1) || 814: ((*s_etat_processus).colonne_statistique_2 < 1) || 815: ((*s_etat_processus).colonne_statistique_1 > (signed long) 816: (*((struct_matrice *) (*s_objet_statistique).objet)) 817: .nombre_colonnes) || 818: ((*s_etat_processus).colonne_statistique_2 > (signed long) 819: (*((struct_matrice *) (*s_objet_statistique).objet)) 820: .nombre_colonnes)) 821: { 822: if (fclose(fichier) != 0) 823: { 824: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 825: return; 826: } 827: 828: if (destruction_fichier(nom_fichier) == d_erreur) 829: { 830: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 831: return; 832: } 833: 834: free(nom_fichier); 835: 836: (*s_etat_processus).erreur_execution = 837: d_ex_observations_inexistantes; 838: return; 839: } 840: 841: for(j = 0; j < (*((struct_matrice *) (*s_objet_statistique).objet)) 842: .nombre_lignes; j++) 843: { 844: if (matrice_entiere == d_vrai) 845: { 846: if (fprintf(fichier, "%f %f\n", (double) ((integer8 **) 847: (*((struct_matrice *) (*s_objet_statistique).objet)) 848: .tableau)[j][(*s_etat_processus) 849: .colonne_statistique_1 - 1], (double) ((integer8 **) 850: (*((struct_matrice *) (*s_objet_statistique).objet)) 851: .tableau)[j][(*s_etat_processus) 852: .colonne_statistique_2 - 1]) < 0) 853: { 854: (*s_etat_processus).erreur_systeme = 855: d_es_erreur_fichier; 856: return; 857: } 858: } 859: else 860: { 861: if (fprintf(fichier, "%f %f\n", (double) ((real8 **) 862: (*((struct_matrice *) (*s_objet_statistique).objet)) 863: .tableau)[j][(*s_etat_processus) 864: .colonne_statistique_1 - 1], (double) ((real8 **) 865: (*((struct_matrice *) (*s_objet_statistique).objet)) 866: .tableau)[j][(*s_etat_processus) 867: .colonne_statistique_2 - 1]) < 0) 868: { 869: (*s_etat_processus).erreur_systeme = 870: d_es_erreur_fichier; 871: return; 872: } 873: } 874: } 875: 876: break; 877: } 878: } 879: 880: /* 881: * Fermeture du fichier graphique 882: */ 883: 884: if (fclose(fichier) != 0) 885: { 886: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; 887: return; 888: } 889: 890: /* 891: * Chaînage du fichier temporaire à la liste des fichiers graphiques 892: */ 893: 894: l_fichier_courant = (*s_etat_processus).fichiers_graphiques; 895: 896: if (l_fichier_courant == NULL) 897: { 898: if (((*s_etat_processus).fichiers_graphiques = malloc( 899: sizeof(struct_fichier_graphique))) == NULL) 900: { 901: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 902: return; 903: } 904: 905: (*(*s_etat_processus).fichiers_graphiques).suivant = NULL; 906: (*(*s_etat_processus).fichiers_graphiques).nom = nom_fichier; 907: (*(*s_etat_processus).fichiers_graphiques).legende = NULL; 908: (*(*s_etat_processus).fichiers_graphiques).dimensions = dimensions; 909: (*(*s_etat_processus).fichiers_graphiques).presence_axes = d_faux; 910: (*(*s_etat_processus).fichiers_graphiques).systeme_axes = 911: (*s_etat_processus).systeme_axes; 912: strcpy((*(*s_etat_processus).fichiers_graphiques).type, 913: (*s_etat_processus).type_trace_sigma); 914: } 915: else 916: { 917: while(l_fichier_courant != NULL) 918: { 919: if ((*l_fichier_courant).dimensions != dimensions) 920: { 921: (*s_etat_processus).erreur_execution = 922: d_ex_dimensions_differentes; 923: return; 924: } 925: 926: l_fichier_precedent = l_fichier_courant; 927: l_fichier_courant = (*l_fichier_courant).suivant; 928: } 929: 930: l_fichier_courant = l_fichier_precedent; 931: 932: if (((*l_fichier_courant).suivant = malloc( 933: sizeof(struct_fichier_graphique))) == NULL) 934: { 935: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 936: return; 937: } 938: 939: l_fichier_courant = (*l_fichier_courant).suivant; 940: 941: (*l_fichier_courant).suivant = NULL; 942: (*l_fichier_courant).nom = nom_fichier; 943: (*l_fichier_courant).legende = NULL; 944: (*l_fichier_courant).dimensions = dimensions; 945: (*l_fichier_courant).presence_axes = d_faux; 946: (*l_fichier_courant).systeme_axes = (*s_etat_processus).systeme_axes; 947: strcpy((*l_fichier_courant).type, (*s_etat_processus).type_trace_sigma); 948: } 949: 950: /* 951: * Affichage du graphique 952: */ 953: 954: appel_gnuplot(s_etat_processus, 'N'); 955: (*s_etat_processus).erreur_execution = d_ex; 956: (*s_etat_processus).exception = d_ep; 957: 958: return; 959: } 960: 961: 962: /* 963: ================================================================================ 964: Fonction 'decr' 965: ================================================================================ 966: Entrées : 967: -------------------------------------------------------------------------------- 968: Sorties : 969: -------------------------------------------------------------------------------- 970: Effets de bord : néant 971: ================================================================================ 972: */ 973: 974: void 975: instruction_decr(struct_processus *s_etat_processus) 976: { 977: logical1 variable_partagee; 978: 979: struct_objet *s_copie_argument; 980: struct_objet *s_objet_argument; 981: 982: (*s_etat_processus).erreur_execution = d_ex; 983: 984: if ((*s_etat_processus).affichage_arguments == 'Y') 985: { 986: printf("\n DECR "); 987: 988: if ((*s_etat_processus).langue == 'F') 989: { 990: printf("(décrémentation)\n\n"); 991: } 992: else 993: { 994: printf("(decrementation)\n\n"); 995: } 996: 997: printf(" 1: %s\n", d_INT); 998: printf("-> 1: %s\n\n", d_INT); 999: 1000: printf(" 1: %s\n", d_NOM); 1001: 1002: return; 1003: } 1004: else if ((*s_etat_processus).test_instruction == 'Y') 1005: { 1006: (*s_etat_processus).nombre_arguments = -1; 1007: return; 1008: } 1009: 1010: if (test_cfsf(s_etat_processus, 31) == d_vrai) 1011: { 1012: if (empilement_pile_last(s_etat_processus, 1) == d_erreur) 1013: { 1014: return; 1015: } 1016: } 1017: 1018: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1019: &s_objet_argument) == d_erreur) 1020: { 1021: (*s_etat_processus).erreur_execution = d_ex_manque_argument; 1022: return; 1023: } 1024: 1025: if ((*s_objet_argument).type == INT) 1026: { 1027: if ((s_copie_argument = copie_objet(s_etat_processus, 1028: s_objet_argument, 'O')) == NULL) 1029: { 1030: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1031: return; 1032: } 1033: 1034: liberation(s_etat_processus, s_objet_argument); 1035: s_objet_argument = s_copie_argument; 1036: 1037: (*((integer8 *) (*s_objet_argument).objet))--; 1038: 1039: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 1040: s_objet_argument) == d_erreur) 1041: { 1042: return; 1043: } 1044: } 1045: else if ((*s_objet_argument).type == NOM) 1046: { 1047: if (recherche_variable(s_etat_processus, (*((struct_nom *) 1048: (*s_objet_argument).objet)).nom) == d_faux) 1049: { 1050: (*s_etat_processus).erreur_systeme = d_es; 1051: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; 1052: 1053: return; 1054: } 1055: 1056: liberation(s_etat_processus, s_objet_argument); 1057: 1058: if ((*(*s_etat_processus).pointeur_variable_courante) 1059: .variable_verrouillee == d_vrai) 1060: { 1061: (*s_etat_processus).erreur_execution = 1062: d_ex_variable_verrouillee; 1063: return; 1064: } 1065: 1066: if ((*(*s_etat_processus).pointeur_variable_courante).objet 1067: == NULL) 1068: { 1069: if (pthread_mutex_lock(&((*(*s_etat_processus) 1070: .s_liste_variables_partagees).mutex)) != 0) 1071: { 1072: (*s_etat_processus).erreur_systeme = d_es_processus; 1073: return; 1074: } 1075: 1076: if (recherche_variable_partagee(s_etat_processus, 1077: (*(*s_etat_processus).pointeur_variable_courante).nom, 1078: (*(*s_etat_processus).pointeur_variable_courante) 1079: .variable_partagee, (*(*s_etat_processus) 1080: .pointeur_variable_courante).origine) == d_faux) 1081: { 1082: (*s_etat_processus).erreur_systeme = d_es; 1083: (*s_etat_processus).erreur_execution = 1084: d_ex_variable_non_definie; 1085: 1086: return; 1087: } 1088: 1089: s_objet_argument = (*(*s_etat_processus) 1090: .s_liste_variables_partagees).table 1091: [(*(*s_etat_processus).s_liste_variables_partagees) 1092: .position_variable].objet; 1093: variable_partagee = d_vrai; 1094: } 1095: else 1096: { 1097: s_objet_argument = (*(*s_etat_processus).pointeur_variable_courante) 1098: .objet; 1099: variable_partagee = d_faux; 1100: } 1101: 1102: if ((s_copie_argument = copie_objet(s_etat_processus, 1103: s_objet_argument, 'O')) == NULL) 1104: { 1105: if (variable_partagee == d_vrai) 1106: { 1107: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1108: .s_liste_variables_partagees).mutex)) != 0) 1109: { 1110: (*s_etat_processus).erreur_systeme = d_es_processus; 1111: return; 1112: } 1113: } 1114: 1115: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 1116: return; 1117: } 1118: 1119: liberation(s_etat_processus, s_objet_argument); 1120: 1121: if (variable_partagee == d_vrai) 1122: { 1123: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL; 1124: (*(*s_etat_processus) 1125: .s_liste_variables_partagees).table 1126: [(*(*s_etat_processus).s_liste_variables_partagees) 1127: .position_variable].objet = s_copie_argument; 1128: } 1129: else 1130: { 1131: (*(*s_etat_processus).pointeur_variable_courante).objet = 1132: s_copie_argument; 1133: } 1134: 1135: if ((*s_copie_argument).type == INT) 1136: { 1137: (*((integer8 *) (*s_copie_argument).objet))--; 1138: 1139: if (variable_partagee == d_vrai) 1140: { 1141: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1142: .s_liste_variables_partagees).mutex)) != 0) 1143: { 1144: (*s_etat_processus).erreur_systeme = d_es_processus; 1145: return; 1146: } 1147: } 1148: } 1149: else 1150: { 1151: if (variable_partagee == d_vrai) 1152: { 1153: if (pthread_mutex_unlock(&((*(*s_etat_processus) 1154: .s_liste_variables_partagees).mutex)) != 0) 1155: { 1156: (*s_etat_processus).erreur_systeme = d_es_processus; 1157: return; 1158: } 1159: } 1160: 1161: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 1162: return; 1163: } 1164: } 1165: else 1166: { 1167: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument; 1168: 1169: liberation(s_etat_processus, s_objet_argument); 1170: return; 1171: } 1172: 1173: return; 1174: } 1175: 1176: // vim: ts=4