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