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