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