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