1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.0.prerelease.0
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).gel_liste_variables = d_faux;
1863: (*s_etat_processus).pointeur_variable_courante = NULL;
1864: (*s_etat_processus).s_liste_variables_statiques = NULL;
1865: (*s_etat_processus).nombre_variables_statiques = 0;
1866: (*s_etat_processus).nombre_variables_statiques_allouees = 0;
1867: (*s_etat_processus).niveau_courant = 0;
1868: (*s_etat_processus).niveau_initial = 0;
1869: (*s_etat_processus).creation_variables_statiques = d_faux;
1870: (*s_etat_processus).creation_variables_partagees = d_faux;
1871: (*s_etat_processus).position_variable_statique_courante = 0;
1872:
1873: (*s_etat_processus).s_bibliotheques = NULL;
1874: (*s_etat_processus).s_instructions_externes = NULL;
1875: (*s_etat_processus).nombre_instructions_externes = 0;
1876:
1877: (*s_etat_processus).systeme_axes = 0;
1878:
1879: (*s_etat_processus).x_min = -10.;
1880: (*s_etat_processus).x_max = 10.;
1881: (*s_etat_processus).y_min = -10.;
1882: (*s_etat_processus).y_max = 10.;
1883: (*s_etat_processus).z_min = -10.;
1884: (*s_etat_processus).z_max = 10.;
1885:
1886: (*s_etat_processus).x2_min = -10.;
1887: (*s_etat_processus).x2_max = 10.;
1888: (*s_etat_processus).y2_min = -10.;
1889: (*s_etat_processus).y2_max = 10.;
1890: (*s_etat_processus).z2_min = -10.;
1891: (*s_etat_processus).z2_max = 10.;
1892:
1893: (*s_etat_processus).resolution = .01;
1894:
1895: (*s_etat_processus).souris_active = d_faux;
1896:
1897: (*s_etat_processus).echelle_automatique_x = d_faux;
1898: (*s_etat_processus).echelle_automatique_y = d_faux;
1899: (*s_etat_processus).echelle_automatique_z = d_faux;
1900:
1901: (*s_etat_processus).echelle_automatique_x2 = d_faux;
1902: (*s_etat_processus).echelle_automatique_y2 = d_faux;
1903: (*s_etat_processus).echelle_automatique_z2 = d_faux;
1904:
1905: (*s_etat_processus).echelle_log_x = d_faux;
1906: (*s_etat_processus).echelle_log_y = d_faux;
1907: (*s_etat_processus).echelle_log_z = d_faux;
1908:
1909: (*s_etat_processus).echelle_log_x2 = d_faux;
1910: (*s_etat_processus).echelle_log_y2 = d_faux;
1911: (*s_etat_processus).echelle_log_z2 = d_faux;
1912:
1913: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
1914: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
1915: (*s_etat_processus).echelle_3D = 1;
1916:
1917: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
1918: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
1919: (*s_etat_processus).fichiers_graphiques = NULL;
1920: (*s_etat_processus).nom_fichier_impression = NULL;
1921: strcpy((*s_etat_processus).format_papier, "a4paper");
1922: (*s_etat_processus).entree_standard = NULL;
1923: (*s_etat_processus).s_marques = NULL;
1924: (*s_etat_processus).requete_nouveau_plan = d_vrai;
1925: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
1926:
1927: (*s_etat_processus).l_base_pile = NULL;
1928: (*s_etat_processus).hauteur_pile_operationnelle = 0;
1929: (*s_etat_processus).l_base_pile_contextes = NULL;
1930: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
1931:
1932: (*s_etat_processus).position_courante = 0;
1933:
1934: (*s_etat_processus).l_base_pile_systeme = NULL;
1935: (*s_etat_processus).hauteur_pile_systeme = 0;
1936:
1937: (*s_etat_processus).l_base_pile_processus = NULL;
1938: (*s_etat_processus).presence_pipes = d_faux;
1939: (*s_etat_processus).pipe_donnees = 0;
1940: (*s_etat_processus).pipe_acquittement = 0;
1941: (*s_etat_processus).pipe_injections = 0;
1942: (*s_etat_processus).pipe_nombre_injections = 0;
1943: (*s_etat_processus).nombre_objets_injectes = 0;
1944: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
1945: (*s_etat_processus).pourcentage_maximal_cpu = 100;
1946: (*s_etat_processus).temps_maximal_cpu = 0;
1947: (*s_etat_processus).thread_fusible = 0;
1948: (*s_etat_processus).presence_fusible = d_faux;
1949:
1950: (*s_etat_processus).niveau_recursivite = 0;
1951: (*s_etat_processus).generateur_aleatoire = NULL;
1952: (*s_etat_processus).type_generateur_aleatoire = NULL;
1953:
1954: (*s_etat_processus).colonne_statistique_1 = 1;
1955: (*s_etat_processus).colonne_statistique_2 = 2;
1956:
1957: (*s_etat_processus).debug_programme = d_faux;
1958: (*s_etat_processus).execution_pas_suivant = d_faux;
1959: (*s_etat_processus).traitement_instruction_halt = d_faux;
1960:
1961: (*s_etat_processus).derniere_exception = d_ep;
1962: (*s_etat_processus).derniere_erreur_systeme = d_es;
1963: (*s_etat_processus).derniere_erreur_execution = d_ex;
1964: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
1965: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
1966:
1967: (*s_etat_processus).erreur_processus_fils = d_faux;
1968: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
1969: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
1970: (*s_etat_processus).pid_erreur_processus_fils = 0;
1971: (*s_etat_processus).exception_processus_fils = d_ep;
1972: (*s_etat_processus).core = core;
1973: (*s_etat_processus).invalidation_message_erreur = d_faux;
1974: (*s_etat_processus).s_objet_errone = NULL;
1975: (*s_etat_processus).s_objet_erreur = NULL;
1976:
1977: (*s_etat_processus).retour_routine_evaluation = 'N';
1978:
1979: (*s_etat_processus).traitement_interruption = 'N';
1980: (*s_etat_processus).traitement_interruptible = 'Y';
1981: (*s_etat_processus).nombre_interruptions_en_queue = 0;
1982: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
1983:
1984: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
1985: {
1986: (*s_etat_processus).masque_interruptions[i] = 'N';
1987: (*s_etat_processus).queue_interruptions[i] = 0;
1988: (*s_etat_processus).corps_interruptions[i] = NULL;
1989: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
1990: }
1991:
1992: (*s_etat_processus).at_exit = NULL;
1993: (*s_etat_processus).at_poke = NULL;
1994: (*s_etat_processus).traitement_at_poke = 'N';
1995:
1996: (*s_etat_processus).pointeurs_caracteres = NULL;
1997: (*s_etat_processus).arbre_instructions = NULL;
1998:
1999: (*s_etat_processus).tid_processus_pere = pthread_self();
2000: (*s_etat_processus).pid_processus_pere = getpid();
2001: (*s_etat_processus).processus_detache = d_vrai;
2002: (*s_etat_processus).var_volatile_processus_pere = -1;
2003: (*s_etat_processus).var_volatile_processus_racine = -1;
2004: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
2005: (*s_etat_processus).var_volatile_alarme = 0;
2006: (*s_etat_processus).var_volatile_requete_arret = 0;
2007: (*s_etat_processus).var_volatile_requete_arret2 = 0;
2008: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
2009: (*s_etat_processus).var_volatile_traitement_sigint = 0;
2010: (*s_etat_processus).var_volatile_recursivite = 0;
2011: (*s_etat_processus).var_volatile_exception_gsl = 0;
2012: (*s_etat_processus).arret_depuis_abort = 0;
2013:
2014: initialisation_allocateur(s_etat_processus);
2015: initialisation_drapeaux(s_etat_processus);
2016:
2017: if ((*s_etat_processus).erreur_systeme != d_es)
2018: {
2019: if ((*s_etat_processus).langue == 'F')
2020: {
2021: printf("+++Système : Mémoire insuffisante\n");
2022: }
2023: else
2024: {
2025: printf("+++System : Not enough memory\n");
2026: }
2027:
2028: return(EXIT_FAILURE);
2029: }
2030:
2031: if (((*s_etat_processus).instruction_derniere_erreur =
2032: malloc(sizeof(unsigned char))) == NULL)
2033: {
2034: erreur = d_es_allocation_memoire;
2035:
2036: if ((*s_etat_processus).langue == 'F')
2037: {
2038: printf("+++Système : Mémoire insuffisante\n");
2039: }
2040: else
2041: {
2042: printf("+++System : Not enough memory\n");
2043: }
2044:
2045: return(EXIT_FAILURE);
2046: }
2047:
2048: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
2049: (*s_etat_processus).niveau_derniere_erreur = 0;
2050:
2051: if (traitement_fichier_temporaire == 'Y')
2052: {
2053: (*s_etat_processus).mode_interactif = 'Y';
2054: }
2055: else
2056: {
2057: (*s_etat_processus).mode_interactif = 'N';
2058: }
2059:
2060: if (((*s_etat_processus).instruction_courante = (unsigned char *)
2061: malloc(sizeof(unsigned char))) == NULL)
2062: {
2063: erreur = d_es_allocation_memoire;
2064:
2065: if ((*s_etat_processus).langue == 'F')
2066: {
2067: printf("+++Système : Mémoire insuffisante\n");
2068: }
2069: else
2070: {
2071: printf("+++System : Not enough memory\n");
2072: }
2073:
2074: return(EXIT_FAILURE);
2075: }
2076:
2077: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
2078:
2079: empilement_pile_systeme(s_etat_processus);
2080:
2081: free((*s_etat_processus).instruction_courante);
2082:
2083: if ((*s_etat_processus).erreur_systeme != d_es)
2084: {
2085: erreur = d_es_allocation_memoire;
2086: }
2087: else
2088: {
2089: (*((*s_etat_processus).l_base_pile_systeme))
2090: .retour_definition = 'Y';
2091:
2092: (*s_etat_processus).indep = (struct_objet *) malloc(
2093: sizeof(struct_objet));
2094: (*s_etat_processus).depend = (struct_objet *) malloc(
2095: sizeof(struct_objet));
2096: (*s_etat_processus).parametres_courbes_de_niveau =
2097: (struct_objet *) malloc(sizeof(struct_objet));
2098:
2099: if (((*s_etat_processus).indep != NULL) &&
2100: ((*s_etat_processus).depend != NULL) &&
2101: ((*s_etat_processus).parametres_courbes_de_niveau
2102: != NULL))
2103: {
2104: (*((*s_etat_processus).indep)).type = NOM;
2105: (*((*s_etat_processus).depend)).type = NOM;
2106: (*((*s_etat_processus).
2107: parametres_courbes_de_niveau)).type = LST;
2108:
2109: initialisation_objet((*s_etat_processus).indep);
2110: initialisation_objet((*s_etat_processus).depend);
2111: initialisation_objet((*s_etat_processus)
2112: .parametres_courbes_de_niveau);
2113:
2114: (*((*s_etat_processus).indep)).objet = (struct_nom *)
2115: malloc(sizeof(struct_nom));
2116: (*((*s_etat_processus).depend)).objet = (struct_nom *)
2117: malloc(sizeof(struct_nom));
2118: (*((*s_etat_processus).parametres_courbes_de_niveau))
2119: .objet = (struct_liste_chainee *)
2120: malloc(sizeof(struct_liste_chainee));
2121:
2122: if (((*((*s_etat_processus).depend)).objet == NULL) ||
2123: ((*((*s_etat_processus).depend)).objet == NULL) ||
2124: ((*((*s_etat_processus).
2125: parametres_courbes_de_niveau)).objet == NULL))
2126: {
2127: erreur = d_es_allocation_memoire;
2128:
2129: if ((*s_etat_processus).langue == 'F')
2130: {
2131: printf("+++Système : Mémoire insuffisante\n");
2132: }
2133: else
2134: {
2135: printf("+++System : Not enough memory\n");
2136: }
2137:
2138: return(EXIT_FAILURE);
2139: }
2140:
2141: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
2142: .nom = malloc(2 * sizeof(unsigned char));
2143: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
2144: .nom = malloc(2 * sizeof(unsigned char));
2145:
2146: if (((*((struct_nom *) (*((*s_etat_processus).indep))
2147: .objet)).nom == NULL) || ((*((struct_nom *)
2148: (*((*s_etat_processus).depend)).objet)).nom ==
2149: NULL))
2150: {
2151: erreur = d_es_allocation_memoire;
2152:
2153: if ((*s_etat_processus).langue == 'F')
2154: {
2155: printf("+++Système : Mémoire insuffisante\n");
2156: }
2157: else
2158: {
2159: printf("+++System : Not enough memory\n");
2160: }
2161:
2162: return(EXIT_FAILURE);
2163: }
2164:
2165: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
2166: .objet)).nom, "X");
2167: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
2168: .objet)).nom, "Y");
2169:
2170: (*((struct_nom *) (*((*s_etat_processus).indep))
2171: .objet)).symbole = d_vrai;
2172: (*((struct_nom *) (*((*s_etat_processus).depend))
2173: .objet)).symbole = d_vrai;
2174:
2175: (*((struct_liste_chainee *) (*((*s_etat_processus)
2176: .parametres_courbes_de_niveau)).objet)).suivant
2177: = NULL;
2178:
2179: (*((struct_liste_chainee *) (*((*s_etat_processus)
2180: .parametres_courbes_de_niveau)).objet)).donnee
2181: = malloc(sizeof(struct_objet));
2182:
2183: (*s_etat_processus).legende =
2184: malloc(sizeof(unsigned char));
2185: (*s_etat_processus).label_x =
2186: malloc(sizeof(unsigned char));
2187: (*s_etat_processus).label_y =
2188: malloc(sizeof(unsigned char));
2189: (*s_etat_processus).label_z =
2190: malloc(sizeof(unsigned char));
2191: (*s_etat_processus).titre =
2192: malloc(sizeof(unsigned char));
2193:
2194: if (((*s_etat_processus).label_x == NULL) ||
2195: ((*s_etat_processus).label_y == NULL) ||
2196: ((*s_etat_processus).label_z == NULL) ||
2197: ((*s_etat_processus).titre == NULL) ||
2198: ((*s_etat_processus).legende == NULL) ||
2199: ((*((struct_liste_chainee *) (*((*s_etat_processus)
2200: .parametres_courbes_de_niveau)).objet)).donnee
2201: == NULL))
2202: {
2203: erreur = d_es_allocation_memoire;
2204:
2205: if ((*s_etat_processus).langue == 'F')
2206: {
2207: printf("+++Système : Mémoire insuffisante\n");
2208: }
2209: else
2210: {
2211: printf("+++System : Not enough memory\n");
2212: }
2213:
2214: return(EXIT_FAILURE);
2215: }
2216:
2217: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
2218: .parametres_courbes_de_niveau)).objet)).donnee)
2219: .type = CHN;
2220:
2221: initialisation_objet((*((struct_liste_chainee *)
2222: (*((*s_etat_processus)
2223: .parametres_courbes_de_niveau))
2224: .objet)).donnee);
2225:
2226: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
2227: .parametres_courbes_de_niveau)).objet)).donnee)
2228: .objet = malloc(10 * sizeof(unsigned char)))
2229: == NULL)
2230: {
2231: erreur = d_es_allocation_memoire;
2232:
2233: if ((*s_etat_processus).langue == 'F')
2234: {
2235: printf("+++Système : Mémoire insuffisante\n");
2236: }
2237: else
2238: {
2239: printf("+++System : Not enough memory\n");
2240: }
2241:
2242: return(EXIT_FAILURE);
2243: }
2244:
2245: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
2246: (*((*s_etat_processus)
2247: .parametres_courbes_de_niveau))
2248: .objet)).donnee).objet, "AUTOMATIC");
2249:
2250: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
2251: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
2252: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
2253: (*s_etat_processus).titre[0] = d_code_fin_chaine;
2254: (*s_etat_processus).legende[0] = d_code_fin_chaine;
2255:
2256: (*s_etat_processus).nom_fichier_gnuplot = NULL;
2257: (*s_etat_processus).type_fichier_gnuplot = NULL;
2258:
2259: (*s_etat_processus).x_tics = 0;
2260: (*s_etat_processus).y_tics = 0;
2261: (*s_etat_processus).z_tics = 0;
2262:
2263: (*s_etat_processus).x_lines = d_vrai;
2264: (*s_etat_processus).y_lines = d_vrai;
2265: (*s_etat_processus).z_lines = d_vrai;
2266:
2267: (*s_etat_processus).mx_tics = -1;
2268: (*s_etat_processus).my_tics = -1;
2269: (*s_etat_processus).mz_tics = -1;
2270:
2271: (*s_etat_processus).mx_lines = d_faux;
2272: (*s_etat_processus).my_lines = d_faux;
2273: (*s_etat_processus).mz_lines = d_faux;
2274:
2275: (*s_etat_processus).x2_tics = -1;
2276: (*s_etat_processus).y2_tics = -1;
2277: (*s_etat_processus).z2_tics = -1;
2278:
2279: (*s_etat_processus).x2_lines = d_faux;
2280: (*s_etat_processus).y2_lines = d_faux;
2281: (*s_etat_processus).z2_lines = d_faux;
2282:
2283: (*s_etat_processus).mx2_tics = -1;
2284: (*s_etat_processus).my2_tics = -1;
2285: (*s_etat_processus).mz2_tics = -1;
2286:
2287: (*s_etat_processus).mx2_lines = d_faux;
2288: (*s_etat_processus).my2_lines = d_faux;
2289: (*s_etat_processus).mz2_lines = d_faux;
2290:
2291: if ((*s_etat_processus).erreur_systeme != d_es)
2292: {
2293: if ((*s_etat_processus).langue == 'F')
2294: {
2295: printf("+++Système : Mémoire insuffisante\n");
2296: }
2297: else
2298: {
2299: printf("+++System : Not enough memory\n");
2300: }
2301:
2302: return(EXIT_FAILURE);
2303: }
2304:
2305: (*s_etat_processus).mode_evaluation_expression = 'N';
2306: (*s_etat_processus).mode_execution_programme = 'Y';
2307:
2308: if ((*s_etat_processus).definitions_chainees == NULL)
2309: {
2310: if ((erreur = chainage(s_etat_processus)) !=
2311: d_absence_erreur)
2312: {
2313: if ((*s_etat_processus).langue == 'F')
2314: {
2315: printf("+++Fatal :"
2316: " Chaînage des définitions"
2317: " impossible\n");
2318: }
2319: else
2320: {
2321: printf("+++Fatal : Error in "
2322: "compilation\n");
2323: }
2324:
2325: if (traitement_fichier_temporaire == 'Y')
2326: {
2327: if (destruction_fichier(
2328: nom_fichier_temporaire)
2329: == d_erreur)
2330: {
2331: return(EXIT_FAILURE);
2332: }
2333:
2334: free(nom_fichier_temporaire);
2335: }
2336:
2337: return(EXIT_FAILURE);
2338: }
2339: }
2340:
2341: if ((erreur = compilation(s_etat_processus)) !=
2342: d_absence_erreur)
2343: {
2344: if (traitement_fichier_temporaire == 'Y')
2345: {
2346: if (destruction_fichier(nom_fichier_temporaire)
2347: == d_erreur)
2348: {
2349: return(EXIT_FAILURE);
2350: }
2351:
2352: free(nom_fichier_temporaire);
2353: }
2354:
2355: printf("%s [%d]\n", message =
2356: messages(s_etat_processus), (int) getpid());
2357: free(message);
2358:
2359: if (test_cfsf(s_etat_processus, 51) == d_faux)
2360: {
2361: printf("%s", ds_beep);
2362: }
2363:
2364: if ((*s_etat_processus).core == d_vrai)
2365: {
2366: printf("\n");
2367:
2368: if ((*s_etat_processus).langue == 'F')
2369: {
2370: printf("+++Information : Génération du fichier "
2371: "rpl-core [%d]\n", (int) getpid());
2372: }
2373: else
2374: {
2375: printf("+++Information : Writing rpl-core "
2376: "file [%d]\n", (int) getpid());
2377: }
2378:
2379: rplcore(s_etat_processus);
2380:
2381: if ((*s_etat_processus).langue == 'F')
2382: {
2383: printf("+++Information : Processus tracé "
2384: "[%d]\n", (int) getpid());
2385: }
2386: else
2387: {
2388: printf("+++Information : Done [%d]\n",
2389: (int) getpid());
2390: }
2391:
2392: printf("\n");
2393: }
2394:
2395: return(EXIT_FAILURE);
2396: }
2397:
2398: (*s_etat_processus).position_courante = 0;
2399: (*s_etat_processus).traitement_cycle_exit = 'N';
2400:
2401: if ((*s_etat_processus).s_arbre_variables == NULL)
2402: {
2403: if ((*s_etat_processus).langue == 'F')
2404: {
2405: printf("+++Fatal : Aucun point d'entrée\n");
2406: }
2407: else
2408: {
2409: printf("+++Fatal : Any entry point\n");
2410: }
2411:
2412: if (test_cfsf(s_etat_processus, 51) == d_faux)
2413: {
2414: printf("%s", ds_beep);
2415: }
2416:
2417: return(EXIT_FAILURE);
2418: }
2419:
2420: if (recherche_instruction_suivante(s_etat_processus)
2421: == d_erreur)
2422: {
2423: if ((*s_etat_processus).langue == 'F')
2424: {
2425: printf("+++Fatal : Aucun point d'entrée\n");
2426: }
2427: else
2428: {
2429: printf("+++Fatal : Any entry point\n");
2430: }
2431:
2432: if (test_cfsf(s_etat_processus, 51) == d_faux)
2433: {
2434: printf("%s", ds_beep);
2435: }
2436:
2437: return(EXIT_FAILURE);
2438: }
2439:
2440: if (recherche_variable(s_etat_processus,
2441: (*s_etat_processus)
2442: .instruction_courante) == d_faux)
2443: {
2444: if ((*s_etat_processus).langue == 'F')
2445: {
2446: printf("+++Fatal : Aucun point d'entrée\n");
2447: }
2448: else
2449: {
2450: printf("+++Fatal : Any entry point\n");
2451: }
2452:
2453: if (test_cfsf(s_etat_processus, 51) == d_faux)
2454: {
2455: printf("%s", ds_beep);
2456: }
2457:
2458: return(EXIT_FAILURE);
2459: }
2460:
2461: if ((*(*s_etat_processus).pointeur_variable_courante)
2462: .niveau != 0)
2463: {
2464: if ((*s_etat_processus).langue == 'F')
2465: {
2466: printf("+++Fatal : Aucun point d'entrée\n");
2467: }
2468: else
2469: {
2470: printf("+++Fatal : Any entry point\n");
2471: }
2472:
2473: if (test_cfsf(s_etat_processus, 51) == d_faux)
2474: {
2475: printf("%s", ds_beep);
2476: }
2477:
2478: return(EXIT_FAILURE);
2479: }
2480:
2481: free((*s_etat_processus).instruction_courante);
2482: (*s_etat_processus).position_courante = 0;
2483:
2484: if (((*s_etat_processus).nom_fichier_historique =
2485: malloc((strlen(home) +
2486: strlen(ds_fichier_historique) + 2) *
2487: sizeof(unsigned char))) == NULL)
2488: {
2489: erreur = d_es_allocation_memoire;
2490:
2491: if ((*s_etat_processus).langue == 'F')
2492: {
2493: printf("+++Système : Mémoire insuffisante\n");
2494: }
2495: else
2496: {
2497: printf("+++System : Not enough memory\n");
2498: }
2499:
2500: return(EXIT_FAILURE);
2501: }
2502:
2503: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
2504: home, ds_fichier_historique);
2505:
2506: using_history();
2507: erreur_historique = read_history(
2508: (*s_etat_processus).nom_fichier_historique);
2509:
2510: gsl_set_error_handler(&traitement_exceptions_gsl);
2511:
2512: if (drapeau_encart == 'Y')
2513: {
2514: (*s_etat_processus).erreur_systeme = d_es;
2515: encart(s_etat_processus,
2516: (unsigned long) (5 * 1000000));
2517:
2518: if ((*s_etat_processus).erreur_systeme != d_es)
2519: {
2520: if ((message = messages(s_etat_processus))
2521: == NULL)
2522: {
2523: erreur = d_es_allocation_memoire;
2524:
2525: if ((*s_etat_processus).langue == 'F')
2526: {
2527: printf("+++Système : Mémoire "
2528: "insuffisante\n");
2529: }
2530: else
2531: {
2532: printf("+++System : Not enough "
2533: "memory\n");
2534: }
2535:
2536: return(EXIT_FAILURE);
2537: }
2538:
2539: printf("%s [%d]\n", message, (int) getpid());
2540: free(message);
2541:
2542: return(EXIT_FAILURE);
2543: }
2544: }
2545:
2546: fflush(stdout);
2547:
2548: initialisation_instructions(s_etat_processus);
2549: initialisation_variables(s_etat_processus);
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: #if 0
3220: for(i = 0; i < (*s_etat_processus).nombre_variables; i++)
3221: {
3222: liberation(s_etat_processus,
3223: (*s_etat_processus).s_liste_variables[i].objet);
3224: free((*s_etat_processus).s_liste_variables[i].nom);
3225: }
3226:
3227: free((*s_etat_processus).s_liste_variables);
3228: #endif
3229:
3230: for(i = 0; i < (*s_etat_processus)
3231: .nombre_variables_statiques; i++)
3232: {
3233: liberation(s_etat_processus, (*s_etat_processus)
3234: .s_liste_variables_statiques[i].objet);
3235: free((*s_etat_processus)
3236: .s_liste_variables_statiques[i].nom);
3237: }
3238:
3239: free((*s_etat_processus).s_liste_variables_statiques);
3240:
3241: for(i = 0; i < (*((*s_etat_processus)
3242: .s_liste_variables_partagees)).nombre_variables;
3243: i++)
3244: {
3245: liberation(s_etat_processus, (*((*s_etat_processus)
3246: .s_liste_variables_partagees)).table[i].objet);
3247: free((*((*s_etat_processus)
3248: .s_liste_variables_partagees)).table[i].nom);
3249: }
3250:
3251: free((struct_variable_partagee *)
3252: (*((*s_etat_processus).s_liste_variables_partagees))
3253: .table);
3254:
3255: /*
3256: * Si resultats est non nul, rplinit a été appelé
3257: * depuis rpl() [librpl] et non main().
3258: * On copie alors le contenu de la * pile dans un
3259: * tableau **resultats dont le pointeur de base a
3260: * été alloué dans rpl().
3261: */
3262:
3263: if (resultats != NULL)
3264: {
3265: if ((*resultats) != NULL)
3266: {
3267: free((*resultats));
3268:
3269: if (((*resultats) = malloc(((*s_etat_processus)
3270: .hauteur_pile_operationnelle + 1)
3271: * sizeof(unsigned char **))) != NULL)
3272: {
3273: (*resultats)[(*s_etat_processus)
3274: .hauteur_pile_operationnelle] = NULL;
3275: l_element_courant = (void *) (*s_etat_processus)
3276: .l_base_pile;
3277:
3278: for(i = 0; i < (*s_etat_processus)
3279: .hauteur_pile_operationnelle; i++)
3280: {
3281: if (l_element_courant != NULL)
3282: {
3283: (*resultats)[i] =
3284: formateur(s_etat_processus,
3285: 0, (*((struct_liste_chainee *)
3286: l_element_courant)).donnee);
3287:
3288: if ((*resultats)[i] == NULL)
3289: {
3290: i = (*s_etat_processus).
3291: hauteur_pile_operationnelle;
3292: }
3293: else
3294: {
3295: l_element_suivant =
3296: (*((struct_liste_chainee *)
3297: l_element_courant)).suivant;
3298: }
3299: }
3300: }
3301: }
3302: else
3303: {
3304: (*resultats) = NULL;
3305: erreur = d_es_allocation_memoire;
3306: }
3307: }
3308: }
3309:
3310: l_element_courant = (void *) (*s_etat_processus)
3311: .l_base_pile;
3312: while(l_element_courant != NULL)
3313: {
3314: l_element_suivant = (*((struct_liste_chainee *)
3315: l_element_courant)).suivant;
3316:
3317: liberation(s_etat_processus,
3318: (*((struct_liste_chainee *)
3319: l_element_courant)).donnee);
3320: free((struct_liste_chainee *) l_element_courant);
3321:
3322: l_element_courant = l_element_suivant;
3323: }
3324:
3325: l_element_courant = (void *) (*s_etat_processus)
3326: .l_base_pile_contextes;
3327: while(l_element_courant != NULL)
3328: {
3329: l_element_suivant = (*((struct_liste_chainee *)
3330: l_element_courant)).suivant;
3331:
3332: liberation(s_etat_processus,
3333: (*((struct_liste_chainee *)
3334: l_element_courant)).donnee);
3335: free((struct_liste_chainee *) l_element_courant);
3336:
3337: l_element_courant = l_element_suivant;
3338: }
3339:
3340: l_element_courant = (void *) (*s_etat_processus)
3341: .l_base_pile_taille_contextes;
3342: while(l_element_courant != NULL)
3343: {
3344: l_element_suivant = (*((struct_liste_chainee *)
3345: l_element_courant)).suivant;
3346:
3347: liberation(s_etat_processus,
3348: (*((struct_liste_chainee *)
3349: l_element_courant)).donnee);
3350: free((struct_liste_chainee *) l_element_courant);
3351:
3352: l_element_courant = l_element_suivant;
3353: }
3354:
3355: for(i = 0; i < (*s_etat_processus)
3356: .nombre_instructions_externes; i++)
3357: {
3358: free((*s_etat_processus).s_instructions_externes[i]
3359: .nom);
3360: free((*s_etat_processus).s_instructions_externes[i]
3361: .nom_bibliotheque);
3362: }
3363:
3364: if ((*s_etat_processus).nombre_instructions_externes != 0)
3365: {
3366: free((*s_etat_processus).s_instructions_externes);
3367: }
3368:
3369: l_element_courant = (void *) (*s_etat_processus)
3370: .s_bibliotheques;
3371:
3372: while(l_element_courant != NULL)
3373: {
3374: l_element_suivant = (*((struct_liste_chainee *)
3375: l_element_courant)).suivant;
3376:
3377: free((*((struct_bibliotheque *)
3378: (*((struct_liste_chainee *)
3379: l_element_courant)).donnee)).nom);
3380: dlclose((*((struct_bibliotheque *)
3381: (*((struct_liste_chainee *)
3382: l_element_courant)).donnee)).descripteur);
3383: free((*((struct_liste_chainee *) l_element_courant))
3384: .donnee);
3385: free(l_element_courant);
3386:
3387: l_element_courant = l_element_suivant;
3388: }
3389:
3390: l_element_courant = (void *) (*s_etat_processus)
3391: .l_base_pile_last;
3392: while(l_element_courant != NULL)
3393: {
3394: l_element_suivant = (*((struct_liste_chainee *)
3395: l_element_courant)).suivant;
3396:
3397: liberation(s_etat_processus,
3398: (*((struct_liste_chainee *)
3399: l_element_courant)).donnee);
3400: free((struct_liste_chainee *) l_element_courant);
3401:
3402: l_element_courant = l_element_suivant;
3403: }
3404:
3405: l_element_courant = (void *) (*s_etat_processus)
3406: .l_base_pile_systeme;
3407: while(l_element_courant != NULL)
3408: {
3409: l_element_suivant = (*((struct_liste_pile_systeme *)
3410: l_element_courant)).suivant;
3411:
3412: liberation(s_etat_processus,
3413: (*((struct_liste_pile_systeme *)
3414: l_element_courant)).indice_boucle);
3415: liberation(s_etat_processus,
3416: (*((struct_liste_pile_systeme *)
3417: l_element_courant)).limite_indice_boucle);
3418: liberation(s_etat_processus,
3419: (*((struct_liste_pile_systeme *)
3420: l_element_courant)).objet_de_test);
3421:
3422: if ((*((struct_liste_pile_systeme *)
3423: l_element_courant)).nom_variable != NULL)
3424: {
3425: free((*((struct_liste_pile_systeme *)
3426: l_element_courant)).nom_variable);
3427: }
3428:
3429: free((struct_liste_pile_systeme *)
3430: l_element_courant);
3431:
3432: l_element_courant = l_element_suivant;
3433: }
3434:
3435: l_element_courant = (void *)
3436: (*s_etat_processus).s_fichiers;
3437: while(l_element_courant != NULL)
3438: {
3439: l_element_suivant = (*((struct_liste_chainee *)
3440: l_element_courant)).suivant;
3441:
3442: fclose((*((struct_descripteur_fichier *)
3443: (*((struct_liste_chainee *)
3444: l_element_courant)).donnee))
3445: .descripteur_c);
3446:
3447: if ((*((struct_descripteur_fichier *)
3448: (*((struct_liste_chainee *)
3449: l_element_courant)).donnee)).type != 'C')
3450: {
3451: sqlite3_close((*((struct_descripteur_fichier *)
3452: (*((struct_liste_chainee *)
3453: l_element_courant)).donnee))
3454: .descripteur_sqlite);
3455: }
3456:
3457: if ((*((struct_descripteur_fichier *)
3458: (*((struct_liste_chainee *)
3459: l_element_courant)).donnee))
3460: .effacement == 'Y')
3461: {
3462: unlink((*((struct_descripteur_fichier *)
3463: (*((struct_liste_chainee *)
3464: l_element_courant)).donnee))
3465: .nom);
3466: }
3467:
3468: free((*((struct_descripteur_fichier *)
3469: (*((struct_liste_chainee *)
3470: l_element_courant)).donnee)).nom);
3471: free((struct_descripteur_fichier *)
3472: (*((struct_liste_chainee *)
3473: l_element_courant)).donnee);
3474: free(l_element_courant);
3475:
3476: l_element_courant = l_element_suivant;
3477: }
3478:
3479: l_element_courant = (void *)
3480: (*s_etat_processus).s_sockets;
3481: while(l_element_courant != NULL)
3482: {
3483: l_element_suivant = (*((struct_liste_chainee *)
3484: l_element_courant)).suivant;
3485:
3486: if ((*((struct_socket *)
3487: (*(*((struct_liste_chainee *)
3488: l_element_courant)).donnee).objet))
3489: .socket_connectee == d_vrai)
3490: {
3491: shutdown((*((struct_socket *)
3492: (*(*((struct_liste_chainee *)
3493: l_element_courant)).donnee).objet))
3494: .socket, SHUT_RDWR);
3495: }
3496:
3497: close((*((struct_socket *)
3498: (*(*((struct_liste_chainee *)
3499: l_element_courant)).donnee).objet)).socket);
3500:
3501: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
3502: l_element_courant)).donnee).objet)).effacement
3503: == 'Y')
3504: {
3505: unlink((*((struct_socket *)
3506: (*(*((struct_liste_chainee *)
3507: l_element_courant)).donnee).objet))
3508: .adresse);
3509: }
3510:
3511: liberation(s_etat_processus,
3512: (*((struct_liste_chainee *)
3513: l_element_courant)).donnee);
3514: free(l_element_courant);
3515:
3516: l_element_courant = l_element_suivant;
3517: }
3518:
3519: l_element_courant = (void *)
3520: (*s_etat_processus).s_connecteurs_sql;
3521: while(l_element_courant != NULL)
3522: {
3523: l_element_suivant = (*((struct_liste_chainee *)
3524: l_element_courant)).suivant;
3525:
3526: sqlclose((*((struct_liste_chainee *)
3527: l_element_courant)).donnee);
3528: liberation(s_etat_processus,
3529: (*((struct_liste_chainee *)
3530: l_element_courant)).donnee);
3531: free(l_element_courant);
3532:
3533: l_element_courant = l_element_suivant;
3534: }
3535:
3536: l_element_courant = (*s_etat_processus).s_marques;
3537: while(l_element_courant != NULL)
3538: {
3539: free((*((struct_marque *) l_element_courant)).label);
3540: free((*((struct_marque *) l_element_courant)).position);
3541: l_element_suivant = (*((struct_marque *)
3542: l_element_courant)).suivant;
3543: free(l_element_courant);
3544: l_element_courant = l_element_suivant;
3545: }
3546: }
3547: else
3548: {
3549: erreur = d_es_allocation_memoire;
3550:
3551: if (test_cfsf(s_etat_processus, 51) == d_faux)
3552: {
3553: printf("%s", ds_beep);
3554: }
3555:
3556: if ((*s_etat_processus).langue == 'F')
3557: {
3558: printf("+++Système : Mémoire insuffisante\n");
3559: }
3560: else
3561: {
3562: printf("+++System : Not enough memory\n");
3563: }
3564: }
3565: }
3566:
3567: liberation_allocateur(s_etat_processus);
3568: }
3569:
3570: if (traitement_fichier_temporaire == 'Y')
3571: {
3572: if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
3573: {
3574: return(EXIT_FAILURE);
3575: }
3576:
3577: free(nom_fichier_temporaire);
3578: }
3579:
3580: if ((*s_etat_processus).profilage == d_vrai)
3581: {
3582: ecriture_profil(s_etat_processus);
3583: liberation_profil(s_etat_processus);
3584: }
3585: }
3586:
3587: closelog();
3588:
3589: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
3590: pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
3591: .mutex));
3592:
3593: retrait_thread(s_etat_processus);
3594:
3595: pthread_mutex_destroy(&((*s_etat_processus).mutex));
3596: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
3597:
3598: # ifndef SEMAPHORES_NOMMES
3599: sem_post(&((*s_etat_processus).semaphore_fork));
3600: sem_destroy(&((*s_etat_processus).semaphore_fork));
3601: # else
3602: sem_post((*s_etat_processus).semaphore_fork);
3603: sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork);
3604: # endif
3605:
3606: free((*s_etat_processus).localisation);
3607:
3608: # ifndef SEMAPHORES_NOMMES
3609: sem_destroy(&semaphore_liste_threads);
3610: # else
3611: sem_destroy2(semaphore_liste_threads, sem_liste_threads);
3612: # endif
3613: # ifndef SEMAPHORES_NOMMES
3614: sem_post(&semaphore_gestionnaires_signaux);
3615: sem_destroy(&semaphore_gestionnaires_signaux);
3616: sem_destroy(&semaphore_gestionnaires_signaux_atomique);
3617: # else
3618: sem_post(semaphore_gestionnaires_signaux);
3619: sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux);
3620: sem_destroy2(semaphore_gestionnaires_signaux_atomique,
3621: sem_gestionnaires_signaux_atomique);
3622: # endif
3623:
3624: # ifdef _BROKEN_SIGINFO
3625: destruction_fifos_signaux(s_etat_processus);
3626: # undef return
3627: # endif
3628:
3629: free((*s_etat_processus).chemin_fichiers_temporaires);
3630: free(s_etat_processus);
3631:
3632: # ifdef DEBUG_MEMOIRE
3633: debug_memoire_verification();
3634: analyse_post_mortem();
3635: # endif
3636:
3637: return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
3638: }
3639:
3640:
3641: void
3642: informations(struct_processus *s_etat_processus)
3643: {
3644: printf("\n");
3645:
3646: if ((*s_etat_processus).langue == 'F')
3647: {
3648: printf(" rpl [-options] [programme]\n");
3649: printf(" -a : analyse du code\n");
3650: printf(" -A : paramètres passés au programme principal\n");
3651: printf(" -c : génération de fichier de débogage (rpl-core)\n");
3652: printf(" -d : option de déverminage interne\n");
3653: printf(" -D : lancement d'un daemon\n");
3654: printf(" -h : aide sur la ligne de commande\n");
3655: printf(" -i : fonctionnement interactif\n");
3656: printf(" -l : licence d'utilisation\n");
3657: printf(" -n : ignorance du signal HUP\n");
3658: printf(" -p : précompilation du script avant exécution\n");
3659: printf(" -P : profilage\n");
3660: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
3661: printf(" -S : exécution du script passé en ligne de commande\n");
3662: printf(" -t : trace\n");
3663: printf(" -v : version\n");
3664: }
3665: else
3666: {
3667: printf(" rpl [-options] [program]\n");
3668: printf(" -a : analyzes program\n");
3669: printf(" -A : sends parameters to main program\n");
3670: printf(" -c : allows creation of a rpl-core file, providing a way"
3671: "\n"
3672: " to debug a program\n");
3673: printf(" -d : internal debug process\n");
3674: printf(" -D : starts in daemon mode\n");
3675: printf(" -h : shows a summary of available options\n");
3676: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
3677: printf(" -l : prints the user licence of the software\n");
3678: printf(" -n : ignores HUP signal\n");
3679: printf(" -p : precompiles script\n");
3680: printf(" -P : computes profile data\n");
3681: printf(" -s : disables splash screen\n");
3682: printf(" -S : executes script written in command line\n");
3683: printf(" -t : enables tracing mode\n");
3684: printf(" -v : prints the version number\n");
3685: }
3686:
3687: printf("\n");
3688:
3689: return;
3690: }
3691:
3692: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>