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