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