1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.36
4: Copyright (C) 1989-2025 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: // Bug de gcc à partir de gcc 4.6 (bug 48544)
27: #pragma GCC diagnostic push
28: #pragma GCC diagnostic ignored "-Wclobbered"
29:
30:
31: /*
32: ================================================================================
33: Programme principal
34: ================================================================================
35: */
36:
37: int
38: rplinit(int argc, char *argv[], char *envp[],
39: unsigned char ***resultats, char *rpl_home)
40: {
41: # include "copyright-conv.h"
42: # include "licence-conv.h"
43:
44: char **arg_exec;
45:
46: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
47: char pile_signaux[SIGSTKSZ];
48: # endif
49:
50: # define RPL_PATH_MAX 1024
51: char repertoire_initial[RPL_PATH_MAX];
52:
53: file *f_source;
54:
55: int erreur_historique;
56: int option_P;
57:
58: integer8 i;
59:
60: logical1 core;
61: logical1 debug;
62: logical1 erreur_fichier;
63: logical1 existence;
64: logical1 mode_interactif;
65: logical1 option_a;
66: logical1 option_A;
67: logical1 option_c;
68: logical1 option_d;
69: logical1 option_D;
70: logical1 option_h;
71: logical1 option_i;
72: logical1 option_l;
73: logical1 option_n;
74: logical1 option_p;
75: logical1 option_s;
76: logical1 option_S;
77: logical1 option_t;
78: logical1 option_v;
79: logical1 ouverture;
80:
81: pthread_mutexattr_t attributs_mutex;
82:
83: ssize_t longueur_ecriture;
84:
85: struct_objet *s_objet;
86:
87: struct_processus *s_etat_processus;
88:
89: struct_liste_chainee *l_bibliotheques;
90: struct_liste_chainee *l_bibliotheque_courante;
91: struct_liste_chainee *l_nouvelle_bibliotheque;
92:
93: struct_liste_variables_partagees *l_element_partage_courant;
94: struct_liste_variables_partagees *l_element_partage_suivant;
95:
96: struct_liste_variables_statiques *l_element_statique_courant;
97: struct_liste_variables_statiques *l_element_statique_suivant;
98:
99: struct_arbre_variables_partagees *s_arbre_variables_partagees;
100: struct_liste_variables_partagees *l_liste_variables_partagees;
101:
102: struct sigaction action;
103: struct sigaction registre;
104:
105: struct timespec attente;
106:
107: unsigned char *arguments;
108: unsigned char drapeau_encart;
109: unsigned char *type_debug;
110: unsigned char *home;
111: unsigned char *langue;
112: unsigned char *message;
113: unsigned char *nom_fichier_temporaire;
114: unsigned char option;
115: unsigned char presence_definition;
116: unsigned char *ptr;
117: unsigned char *tampon;
118:
119: unsigned long unite_fichier;
120:
121: void *l_element_courant;
122: void *l_element_suivant;
123:
124: volatile int erreur;
125: volatile unsigned char traitement_fichier_temporaire;
126:
127: errno = 0;
128: s_queue_signaux = NULL;
129: routine_recursive = 0;
130: nombre_threads_surveillance_processus = 0;
131: pid_processus_pere = getpid();
132:
133: # ifdef DEBUG_PROC
134: __proc = 0;
135: # endif
136:
137: # ifdef DEBUG_MEMOIRE
138: debug_memoire_initialisation();
139: # endif
140:
141: setvbuf(stdout, NULL, _IOLBF, 0);
142: setvbuf(stderr, NULL, _IOLBF, 0);
143:
144: if ((s_etat_processus = sys_malloc(sizeof(struct_processus))) == NULL)
145: {
146: erreur = d_es_allocation_memoire;
147:
148: if ((langue = getenv("LANG")) != NULL)
149: {
150: if (strncmp(langue, "fr", 2) == 0)
151: {
152: uprintf("+++Système : Mémoire insuffisante\n");
153: }
154: else
155: {
156: uprintf("+++System : Not enough memory\n");
157: }
158: }
159: else
160: {
161: uprintf("+++System : Not enough memory\n");
162: }
163:
164: return(EXIT_FAILURE);
165: }
166:
167: (*s_etat_processus).erreur_systeme = d_es;
168:
169: initialisation_allocateur_buffer(s_etat_processus);
170:
171: if ((*s_etat_processus).erreur_systeme != d_es)
172: {
173: erreur = d_es_allocation_memoire;
174:
175: if ((langue = getenv("LANG")) != NULL)
176: {
177: if (strncmp(langue, "fr", 2) == 0)
178: {
179: uprintf("+++Système : Mémoire insuffisante\n");
180: }
181: else
182: {
183: uprintf("+++System : Not enough memory\n");
184: }
185: }
186: else
187: {
188: uprintf("+++System : Not enough memory\n");
189: }
190:
191: return(EXIT_FAILURE);
192: }
193:
194: if (initialisation_etat_processus_readline() != 0)
195: {
196: erreur = d_es_allocation_memoire;
197:
198: if ((langue = getenv("LANG")) != NULL)
199: {
200: if (strncmp(langue, "fr", 2) == 0)
201: {
202: uprintf("+++Système : Mémoire insuffisante\n");
203: }
204: else
205: {
206: uprintf("+++System : Not enough memory\n");
207: }
208: }
209: else
210: {
211: uprintf("+++System : Not enough memory\n");
212: }
213:
214: return(EXIT_FAILURE);
215: }
216:
217: if ((langue = getenv("LANG")) != NULL)
218: {
219: (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0)
220: ? 'F' : 'E';
221: }
222: else
223: {
224: (*s_etat_processus).langue = 'E';
225: }
226:
227: if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL)
228: {
229: if ((*s_etat_processus).langue == 'F')
230: {
231: uprintf("+++Système : Mémoire insuffisante\n");
232: }
233: else
234: {
235: uprintf("+++System : Not enough memory\n");
236: }
237:
238: return(EXIT_FAILURE);
239: }
240:
241: if ((arg_exec = sys_malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL)
242: {
243: if ((*s_etat_processus).langue == 'F')
244: {
245: uprintf("+++Système : Mémoire insuffisante\n");
246: }
247: else
248: {
249: uprintf("+++System : Not enough memory\n");
250: }
251:
252: return(EXIT_FAILURE);
253: }
254:
255: for(i = 0; i < argc; i++)
256: {
257: arg_exec[i] = argv[i];
258: }
259:
260: arg_exec[argc] = NULL;
261:
262: initialisation_contexte_cas(s_etat_processus);
263:
264: (*s_etat_processus).exception = d_ep;
265: (*s_etat_processus).erreur_systeme = d_es;
266: (*s_etat_processus).erreur_execution = d_ex;
267:
268: (*s_etat_processus).requete_redemarrage = d_faux;
269: (*s_etat_processus).rpl_home = rpl_home;
270:
271: pthread_mutexattr_init(&attributs_mutex);
272: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
273: pthread_mutex_init(&((*s_etat_processus).mutex_pile_processus),
274: &attributs_mutex);
275: pthread_mutexattr_destroy(&attributs_mutex);
276:
277: pthread_mutexattr_init(&attributs_mutex);
278: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
279: pthread_mutex_init(&((*s_etat_processus).mutex_interruptions),
280: &attributs_mutex);
281: pthread_mutexattr_destroy(&attributs_mutex);
282:
283: pthread_mutexattr_init(&attributs_mutex);
284: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
285: pthread_mutex_init(&((*s_etat_processus).mutex_signaux),
286: &attributs_mutex);
287: pthread_mutexattr_destroy(&attributs_mutex);
288:
289: pthread_mutexattr_init(&attributs_mutex);
290: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
291: pthread_mutex_init(&((*s_etat_processus).mutex_allocation),
292: &attributs_mutex);
293: pthread_mutexattr_destroy(&attributs_mutex);
294:
295: pthread_mutexattr_init(&attributs_mutex);
296: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
297: pthread_mutex_init(&((*s_etat_processus).mutex_allocation_buffer),
298: &attributs_mutex);
299: pthread_mutexattr_destroy(&attributs_mutex);
300:
301: pthread_mutexattr_init(&attributs_mutex);
302: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
303: pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex);
304: pthread_mutexattr_destroy(&attributs_mutex);
305:
306: pthread_mutexattr_init(&attributs_mutex);
307: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
308: pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex);
309: pthread_mutexattr_destroy(&attributs_mutex);
310:
311: pthread_mutexattr_init(&attributs_mutex);
312: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
313: pthread_mutex_init(&mutex_liste_threads, &attributs_mutex);
314: pthread_mutexattr_destroy(&attributs_mutex);
315:
316: pthread_mutexattr_init(&attributs_mutex);
317: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
318: pthread_mutex_init(&mutex_liste_threads_surveillance, &attributs_mutex);
319: pthread_mutexattr_destroy(&attributs_mutex);
320:
321: pthread_mutexattr_init(&attributs_mutex);
322: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
323: pthread_mutex_init(&mutex_sigaction, &attributs_mutex);
324: pthread_mutexattr_destroy(&attributs_mutex);
325:
326: # ifndef SEMAPHORES_NOMMES
327: if (sem_init(&((*s_etat_processus).semaphore_fork), 0, 0) != 0)
328: # else
329: if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(),
330: pthread_self(), SEM_FORK)) == SEM_FAILED)
331: # endif
332: {
333: liberation_contexte_cas(s_etat_processus);
334:
335: if ((*s_etat_processus).langue == 'F')
336: {
337: uprintf("+++Système : Mémoire insuffisante\n");
338: }
339: else
340: {
341: uprintf("+++System : Not enough memory\n");
342: }
343:
344: return(EXIT_FAILURE);
345: }
346:
347: pthread_mutexattr_init(&attributs_mutex);
348: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
349: pthread_mutex_init(&((*s_etat_processus).protection_liste_mutexes),
350: &attributs_mutex);
351: pthread_mutexattr_destroy(&attributs_mutex);
352:
353: (*s_etat_processus).chemin_fichiers_temporaires =
354: recherche_chemin_fichiers_temporaires(s_etat_processus);
355:
356: insertion_thread(s_etat_processus, d_vrai);
357: creation_queue_signaux(s_etat_processus);
358:
359: if ((*s_etat_processus).erreur_systeme != d_es)
360: {
361: # ifndef SEMAPHORES_NOMMES
362: sem_post(&((*s_etat_processus).semaphore_fork));
363: sem_destroy(&((*s_etat_processus).semaphore_fork));
364: # else
365: sem_post((*s_etat_processus).semaphore_fork);
366: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
367: pthread_self(), SEM_FORK);
368: # endif
369:
370: liberation_contexte_cas(s_etat_processus);
371:
372: if ((*s_etat_processus).langue == 'F')
373: {
374: uprintf("+++Système : Mémoire insuffisante\n");
375: }
376: else
377: {
378: uprintf("+++System : Not enough memory\n");
379: }
380:
381: return(EXIT_FAILURE);
382: }
383:
384: if (d_forced_locale == 0)
385: {
386: localisation_courante(s_etat_processus);
387: }
388: else
389: {
390: if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
391: + 1) * sizeof(unsigned char))) == NULL)
392: {
393: # ifndef SEMAPHORES_NOMMES
394: sem_post(&((*s_etat_processus).semaphore_fork));
395: sem_destroy(&((*s_etat_processus).semaphore_fork));
396: # else
397: sem_post((*s_etat_processus).semaphore_fork);
398: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
399: pthread_self(), SEM_FORK);
400: # endif
401:
402: liberation_contexte_cas(s_etat_processus);
403: destruction_queue_signaux(s_etat_processus);
404:
405: if ((*s_etat_processus).langue == 'F')
406: {
407: uprintf("+++Système : Mémoire insuffisante\n");
408: }
409: else
410: {
411: uprintf("+++System : Not enough memory\n");
412: }
413:
414: return(EXIT_FAILURE);
415: }
416:
417: strcpy((*s_etat_processus).localisation, d_locale);
418: }
419:
420: (*s_etat_processus).erreur_systeme = d_es;
421:
422: if ((*s_etat_processus).localisation == NULL)
423: {
424: if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) *
425: sizeof(unsigned char))) == NULL)
426: {
427: # ifndef SEMAPHORES_NOMMES
428: sem_post(&((*s_etat_processus).semaphore_fork));
429: sem_destroy(&((*s_etat_processus).semaphore_fork));
430: # else
431: sem_post((*s_etat_processus).semaphore_fork);
432: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
433: pthread_self(), SEM_FORK);
434: # endif
435:
436: liberation_contexte_cas(s_etat_processus);
437: destruction_queue_signaux(s_etat_processus);
438:
439: if ((*s_etat_processus).langue == 'F')
440: {
441: uprintf("+++Système : Mémoire insuffisante\n");
442: }
443: else
444: {
445: uprintf("+++System : Not enough memory\n");
446: }
447:
448: return(EXIT_FAILURE);
449: }
450:
451: strcpy((*s_etat_processus).localisation, d_locale);
452: }
453:
454: if (resultats == NULL) // Appel direct
455: {
456: printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl,
457: ((*s_etat_processus).langue == 'F')
458: ? d_date_rpl : d_date_en_rpl);
459:
460: if ((*s_etat_processus).langue == 'F')
461: {
462: printf("+++Copyright (C) 1989 à 2024, 2025 BERTRAND Joël\n");
463: }
464: else
465: {
466: printf("+++Copyright (C) 1989 to 2024, 2025 BERTRAND Joel\n");
467: }
468: }
469:
470: if (getenv("HOME") != NULL)
471: {
472: home = getenv("HOME");
473: }
474: else if ((getenv("USER") != NULL) && (getpwnam(getenv("USER")) != NULL))
475: {
476: home = getpwnam(getenv("USER"))->pw_dir;
477: }
478: else if ((getenv("LOGNAME") != NULL) && (getpwnam(getenv("LOGNAME"))
479: != NULL))
480: {
481: home = getpwnam(getenv("LOGNAME"))->pw_dir;
482: }
483: else if ((getuid() != ((uid_t) -1)) && (getpwuid(getuid()) != NULL))
484: {
485: home = getpwuid(getuid())->pw_dir;
486: }
487: else
488: {
489: home = "";
490: }
491:
492: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
493: if (stackoverflow_install_handler(interruption_depassement_pile,
494: pile_signaux, sizeof(pile_signaux)) != 0)
495: {
496: # ifndef SEMAPHORES_NOMMES
497: sem_post(&((*s_etat_processus).semaphore_fork));
498: sem_destroy(&((*s_etat_processus).semaphore_fork));
499: # else
500: sem_post((*s_etat_processus).semaphore_fork);
501: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
502: pthread_self(), SEM_FORK);
503: # endif
504:
505: liberation_contexte_cas(s_etat_processus);
506: destruction_queue_signaux(s_etat_processus);
507:
508: erreur = d_es_signal;
509:
510: if ((*s_etat_processus).langue == 'F')
511: {
512: printf("+++Système : Initialisation de la pile alternative "
513: "impossible\n");
514: }
515: else
516: {
517: printf("+++System : Initialization of alternate "
518: "stack failed\n");
519: }
520:
521: return(EXIT_FAILURE);
522: }
523: # else
524: if ((*s_etat_processus).langue == 'F')
525: {
526: printf("+++Attention : Le système ne supporte pas de pile "
527: "alternative\n");
528: }
529: else
530: {
531: printf("+++Warning : Operating system does not support alternate "
532: "stack\n");
533: }
534: # endif
535:
536: action.sa_handler = interruption1;
537: action.sa_flags = 0;
538:
539: if (sigaction(SIGINT, &action, NULL) != 0)
540: {
541: # ifndef SEMAPHORES_NOMMES
542: sem_post(&((*s_etat_processus).semaphore_fork));
543: sem_destroy(&((*s_etat_processus).semaphore_fork));
544: # else
545: sem_post((*s_etat_processus).semaphore_fork);
546: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
547: pthread_self(), SEM_FORK);
548: # endif
549:
550: liberation_contexte_cas(s_etat_processus);
551: destruction_queue_signaux(s_etat_processus);
552:
553: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
554: stackoverflow_deinstall_handler();
555: # endif
556:
557: erreur = d_es_signal;
558:
559: if ((*s_etat_processus).langue == 'F')
560: {
561: printf("+++Système : Initialisation des signaux POSIX "
562: "impossible\n");
563: }
564: else
565: {
566: printf("+++System : Initialization of POSIX signals failed\n");
567: }
568:
569: return(EXIT_FAILURE);
570: }
571:
572: signal_test = SIGTEST;
573: raise(SIGINT);
574:
575: attente.tv_sec = 0;
576: attente.tv_nsec = 1000000;
577:
578: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
579: {
580: nanosleep(&attente, NULL);
581: }
582:
583: if (signal_test != SIGINT)
584: {
585: # ifndef SEMAPHORES_NOMMES
586: sem_post(&((*s_etat_processus).semaphore_fork));
587: sem_destroy(&((*s_etat_processus).semaphore_fork));
588: # else
589: sem_post((*s_etat_processus).semaphore_fork);
590: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
591: pthread_self(), SEM_FORK);
592: # endif
593:
594: liberation_contexte_cas(s_etat_processus);
595: destruction_queue_signaux(s_etat_processus);
596:
597: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
598: stackoverflow_deinstall_handler();
599: # endif
600:
601: erreur = d_es_signal;
602:
603: if ((*s_etat_processus).langue == 'F')
604: {
605: printf("+++Système : Initialisation des signaux POSIX "
606: "impossible\n");
607: }
608: else
609: {
610: printf("+++System : Initialization of POSIX signals failed\n");
611: }
612:
613: return(EXIT_FAILURE);
614: }
615:
616: if (sigaction(SIGTERM, &action, NULL) != 0)
617: {
618: # ifndef SEMAPHORES_NOMMES
619: sem_post(&((*s_etat_processus).semaphore_fork));
620: sem_destroy(&((*s_etat_processus).semaphore_fork));
621: # else
622: sem_post((*s_etat_processus).semaphore_fork);
623: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
624: pthread_self(), SEM_FORK);
625: # endif
626:
627: liberation_contexte_cas(s_etat_processus);
628: destruction_queue_signaux(s_etat_processus);
629:
630: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
631: stackoverflow_deinstall_handler();
632: # endif
633:
634: erreur = d_es_signal;
635:
636: if ((*s_etat_processus).langue == 'F')
637: {
638: printf("+++Système : Initialisation des signaux POSIX "
639: "impossible\n");
640: }
641: else
642: {
643: printf("+++System : Initialization of POSIX signals failed\n");
644: }
645:
646: return(EXIT_FAILURE);
647: }
648:
649: signal_test = SIGTEST;
650: raise(SIGTERM);
651:
652: attente.tv_sec = 0;
653: attente.tv_nsec = 1000000;
654:
655: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
656: {
657: nanosleep(&attente, NULL);
658: }
659:
660: if (signal_test != SIGTERM)
661: {
662: # ifndef SEMAPHORES_NOMMES
663: sem_post(&((*s_etat_processus).semaphore_fork));
664: sem_destroy(&((*s_etat_processus).semaphore_fork));
665: # else
666: sem_post((*s_etat_processus).semaphore_fork);
667: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
668: pthread_self(), SEM_FORK);
669: # endif
670:
671: liberation_contexte_cas(s_etat_processus);
672: destruction_queue_signaux(s_etat_processus);
673:
674: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
675: stackoverflow_deinstall_handler();
676: # endif
677:
678: erreur = d_es_signal;
679:
680: if ((*s_etat_processus).langue == 'F')
681: {
682: printf("+++Système : Initialisation des signaux POSIX "
683: "impossible\n");
684: }
685: else
686: {
687: printf("+++System : Initialization of POSIX signals failed\n");
688: }
689:
690: return(EXIT_FAILURE);
691: }
692:
693: if (sigaction(SIGUSR2, &action, NULL) != 0)
694: {
695: # ifndef SEMAPHORES_NOMMES
696: sem_post(&((*s_etat_processus).semaphore_fork));
697: sem_destroy(&((*s_etat_processus).semaphore_fork));
698: # else
699: sem_post((*s_etat_processus).semaphore_fork);
700: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
701: pthread_self(), SEM_FORK);
702: # endif
703:
704: liberation_contexte_cas(s_etat_processus);
705: destruction_queue_signaux(s_etat_processus);
706:
707: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
708: stackoverflow_deinstall_handler();
709: # endif
710:
711: erreur = d_es_signal;
712:
713: if ((*s_etat_processus).langue == 'F')
714: {
715: printf("+++Système : Initialisation des signaux POSIX "
716: "impossible\n");
717: }
718: else
719: {
720: printf("+++System : Initialization of POSIX signals failed\n");
721: }
722:
723: return(EXIT_FAILURE);
724: }
725:
726: signal_test = SIGTEST;
727: raise(SIGUSR2);
728:
729: attente.tv_sec = 0;
730: attente.tv_nsec = 1000000;
731:
732: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
733: {
734: nanosleep(&attente, NULL);
735: }
736:
737: if (signal_test != SIGUSR2)
738: {
739: # ifndef SEMAPHORES_NOMMES
740: sem_post(&((*s_etat_processus).semaphore_fork));
741: sem_destroy(&((*s_etat_processus).semaphore_fork));
742: # else
743: sem_post((*s_etat_processus).semaphore_fork);
744: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
745: pthread_self(), SEM_FORK);
746: # endif
747:
748: liberation_contexte_cas(s_etat_processus);
749: destruction_queue_signaux(s_etat_processus);
750:
751: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
752: stackoverflow_deinstall_handler();
753: # endif
754:
755: erreur = d_es_signal;
756:
757: if ((*s_etat_processus).langue == 'F')
758: {
759: printf("+++Système : Initialisation des signaux POSIX "
760: "impossible\n");
761: }
762: else
763: {
764: printf("+++System : Initialization of POSIX signals failed\n");
765: }
766:
767: return(EXIT_FAILURE);
768: }
769:
770: action.sa_handler = interruption2;
771: action.sa_flags = 0;
772:
773: if (sigaction(SIGTSTP, &action, NULL) != 0)
774: {
775: # ifndef SEMAPHORES_NOMMES
776: sem_post(&((*s_etat_processus).semaphore_fork));
777: sem_destroy(&((*s_etat_processus).semaphore_fork));
778: # else
779: sem_post((*s_etat_processus).semaphore_fork);
780: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
781: pthread_self(), SEM_FORK);
782: # endif
783:
784: liberation_contexte_cas(s_etat_processus);
785: destruction_queue_signaux(s_etat_processus);
786:
787: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
788: stackoverflow_deinstall_handler();
789: # endif
790:
791: if ((*s_etat_processus).langue == 'F')
792: {
793: printf("+++Système : Initialisation des signaux POSIX "
794: "impossible\n");
795: }
796: else
797: {
798: printf("+++System : Initialization of POSIX signals failed\n");
799: }
800:
801: return(EXIT_FAILURE);
802: }
803:
804: signal_test = SIGTEST;
805: raise(SIGTSTP);
806:
807: attente.tv_sec = 0;
808: attente.tv_nsec = 1000000;
809:
810: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
811: {
812: nanosleep(&attente, NULL);
813: }
814:
815: if (signal_test != SIGTSTP)
816: {
817: # ifndef SEMAPHORES_NOMMES
818: sem_post(&((*s_etat_processus).semaphore_fork));
819: sem_destroy(&((*s_etat_processus).semaphore_fork));
820: # else
821: sem_post((*s_etat_processus).semaphore_fork);
822: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
823: pthread_self(), SEM_FORK);
824: # endif
825:
826: liberation_contexte_cas(s_etat_processus);
827: destruction_queue_signaux(s_etat_processus);
828:
829: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
830: stackoverflow_deinstall_handler();
831: # endif
832:
833: erreur = d_es_signal;
834:
835: if ((*s_etat_processus).langue == 'F')
836: {
837: printf("+++Système : Initialisation des signaux POSIX "
838: "impossible\n");
839: }
840: else
841: {
842: printf("+++System : Initialization of POSIX signals failed\n");
843: }
844:
845: return(EXIT_FAILURE);
846: }
847:
848: action.sa_handler = interruption5;
849: action.sa_flags = 0;
850:
851: #if 0
852: if (sigaction(SIGPIPE, &action, NULL) != 0)
853: {
854: # ifndef SEMAPHORES_NOMMES
855: sem_post(&((*s_etat_processus).semaphore_fork));
856: sem_destroy(&((*s_etat_processus).semaphore_fork));
857: # else
858: sem_post((*s_etat_processus).semaphore_fork);
859: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
860: pthread_self(), SEM_FORK);
861: # endif
862:
863: liberation_contexte_cas(s_etat_processus);
864: destruction_queue_signaux(s_etat_processus);
865:
866: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
867: stackoverflow_deinstall_handler();
868: # endif
869:
870: erreur = d_es_signal;
871:
872: if ((*s_etat_processus).langue == 'F')
873: {
874: printf("+++Système : Initialisation des signaux POSIX "
875: "impossible\n");
876: }
877: else
878: {
879: printf("+++System : Initialization of POSIX signals failed\n");
880: }
881:
882: return(EXIT_FAILURE);
883: }
884:
885: signal_test = SIGTEST;
886: raise(SIGPIPE);
887:
888: attente.tv_sec = 0;
889: attente.tv_nsec = 1000000;
890:
891: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
892: {
893: nanosleep(&attente, NULL);
894: }
895:
896: if (signal_test != SIGPIPE)
897: {
898: # ifndef SEMAPHORES_NOMMES
899: sem_post(&((*s_etat_processus).semaphore_fork));
900: sem_destroy(&((*s_etat_processus).semaphore_fork));
901: # else
902: sem_post((*s_etat_processus).semaphore_fork);
903: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
904: pthread_self(), SEM_FORK);
905: # endif
906:
907: liberation_contexte_cas(s_etat_processus);
908: destruction_queue_signaux(s_etat_processus);
909:
910: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
911: stackoverflow_deinstall_handler();
912: # endif
913:
914: erreur = d_es_signal;
915:
916: if ((*s_etat_processus).langue == 'F')
917: {
918: printf("+++Système : Initialisation des signaux POSIX "
919: "impossible\n");
920: }
921: else
922: {
923: printf("+++System : Initialization of POSIX signals failed\n");
924: }
925:
926: return(EXIT_FAILURE);
927: }
928: #endif
929:
930: action.sa_handler = interruption1;
931: action.sa_flags = 0;
932:
933: if (sigaction(SIGUSR1, &action, NULL) != 0)
934: {
935: # ifndef SEMAPHORES_NOMMES
936: sem_post(&((*s_etat_processus).semaphore_fork));
937: sem_destroy(&((*s_etat_processus).semaphore_fork));
938: # else
939: sem_post((*s_etat_processus).semaphore_fork);
940: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
941: pthread_self(), SEM_FORK);
942: # endif
943:
944: liberation_contexte_cas(s_etat_processus);
945: destruction_queue_signaux(s_etat_processus);
946:
947: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
948: stackoverflow_deinstall_handler();
949: # endif
950:
951: erreur = d_es_signal;
952:
953: if ((*s_etat_processus).langue == 'F')
954: {
955: printf("+++Système : Initialisation des signaux POSIX "
956: "impossible\n");
957: }
958: else
959: {
960: printf("+++System : Initialization of POSIX signals failed\n");
961: }
962:
963: return(EXIT_FAILURE);
964: }
965:
966: signal_test = SIGTEST;
967: raise(SIGUSR1);
968:
969: attente.tv_sec = 0;
970: attente.tv_nsec = 1000000;
971:
972: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
973: {
974: nanosleep(&attente, NULL);
975: }
976:
977: if (signal_test != SIGUSR1)
978: {
979: # ifndef SEMAPHORES_NOMMES
980: sem_post(&((*s_etat_processus).semaphore_fork));
981: sem_destroy(&((*s_etat_processus).semaphore_fork));
982: # else
983: sem_post((*s_etat_processus).semaphore_fork);
984: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
985: pthread_self(), SEM_FORK);
986: # endif
987:
988: liberation_contexte_cas(s_etat_processus);
989: destruction_queue_signaux(s_etat_processus);
990:
991: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
992: stackoverflow_deinstall_handler();
993: # endif
994:
995: erreur = d_es_signal;
996:
997: if ((*s_etat_processus).langue == 'F')
998: {
999: printf("+++Système : Initialisation des signaux POSIX "
1000: "impossible\n");
1001: }
1002: else
1003: {
1004: printf("+++System : Initialization of POSIX signals failed\n");
1005: }
1006:
1007: return(EXIT_FAILURE);
1008: }
1009:
1010: signal_test = SIGTEST + 1;
1011:
1012: erreur = d_absence_erreur;
1013: core = d_faux;
1014: mode_interactif = d_faux;
1015: (*s_etat_processus).nom_fichier_source = NULL;
1016: (*s_etat_processus).definitions_chainees = NULL;
1017: (*s_etat_processus).type_debug = 0;
1018: traitement_fichier_temporaire = 'N';
1019: option = ' ';
1020: drapeau_encart = 'Y';
1021: debug = d_faux;
1022: arguments = NULL;
1023: l_bibliotheques = NULL;
1024:
1025: (*s_etat_processus).s_fichiers = NULL;
1026: (*s_etat_processus).s_sockets = NULL;
1027: (*s_etat_processus).s_connecteurs_sql = NULL;
1028:
1029: setlogmask(LOG_MASK(LOG_NOTICE));
1030: openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_USER);
1031:
1032: if (argc == 1)
1033: {
1034: erreur = d_erreur;
1035: informations(s_etat_processus);
1036: }
1037: else
1038: {
1039: presence_definition = 'N';
1040: (*s_etat_processus).debug = d_faux;
1041: (*s_etat_processus).lancement_interactif = d_faux;
1042:
1043: option_a = d_faux;
1044: option_A = d_faux;
1045: option_c = d_faux;
1046: option_d = d_faux;
1047: option_D = d_faux;
1048: option_h = d_faux;
1049: option_i = d_faux;
1050: option_l = d_faux;
1051: option_n = d_faux;
1052: option_p = d_faux;
1053: option_P = 0;
1054: option_s = d_faux;
1055: option_S = d_faux;
1056: option_t = d_faux;
1057: option_v = d_faux;
1058:
1059: // Lorsque le programme est appelé depuis un shebang, argv[0] contient
1060: // le chemin du programme et argv[1] tous les arguments.
1061: // argv[2] contient quant à lui le nom du script RPL/2.
1062: //
1063: // Exemple :
1064: // argv[0] : /usr/local/bin/rpl
1065: // argv[1] : -csdp -t 800
1066: // argv[2] : ./on_exit.rpl
1067:
1068: while((--argc) > 0)
1069: {
1070: if ((*(++argv))[0] == '-')
1071: {
1072: while((option = *(++argv[0])) != '\0')
1073: {
1074: switch(option)
1075: {
1076: case 'a' :
1077: {
1078: if (option_a == d_vrai)
1079: {
1080: # ifndef SEMAPHORES_NOMMES
1081: sem_post(&((*s_etat_processus).semaphore_fork));
1082: sem_destroy(&((*s_etat_processus)
1083: .semaphore_fork));
1084: # else
1085: sem_post((*s_etat_processus).semaphore_fork);
1086: sem_destroy3((*s_etat_processus).semaphore_fork,
1087: getpid(), pthread_self(), SEM_FORK);
1088: # endif
1089:
1090: liberation_contexte_cas(s_etat_processus);
1091: destruction_queue_signaux(s_etat_processus);
1092:
1093: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1094: stackoverflow_deinstall_handler();
1095: # endif
1096:
1097: if ((*s_etat_processus).langue == 'F')
1098: {
1099: printf("+++Erreur : option -a présente "
1100: "plus d'une fois\n");
1101: }
1102: else
1103: {
1104: printf("+++Error : more than one -a "
1105: "on command line");
1106: }
1107:
1108: return(EXIT_FAILURE);
1109: }
1110:
1111: option_a = d_vrai;
1112: break;
1113: }
1114:
1115: case 'A' :
1116: {
1117: if (option_A == d_vrai)
1118: {
1119: # ifndef SEMAPHORES_NOMMES
1120: sem_post(&((*s_etat_processus).semaphore_fork));
1121: sem_destroy(&((*s_etat_processus)
1122: .semaphore_fork));
1123: # else
1124: sem_post((*s_etat_processus).semaphore_fork);
1125: sem_destroy3((*s_etat_processus).semaphore_fork,
1126: getpid(), pthread_self(), SEM_FORK);
1127: # endif
1128:
1129: liberation_contexte_cas(s_etat_processus);
1130: destruction_queue_signaux(s_etat_processus);
1131:
1132: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1133: stackoverflow_deinstall_handler();
1134: # endif
1135:
1136: if ((*s_etat_processus).langue == 'F')
1137: {
1138: printf("+++Erreur : option -A présente "
1139: "plus d'une fois\n");
1140: }
1141: else
1142: {
1143: printf("+++Error : more than one -A "
1144: "on command line");
1145: }
1146:
1147: return(EXIT_FAILURE);
1148: }
1149:
1150: option_A = d_vrai;
1151:
1152: while(*(++argv[0]) == ' ');
1153: argv[0]--;
1154:
1155: if ((*(++argv[0])) != '\0')
1156: {
1157: if ((arguments = malloc((strlen(argv[0]) + 7) *
1158: sizeof(unsigned char))) == NULL)
1159: {
1160: # ifndef SEMAPHORES_NOMMES
1161: sem_post(&((*s_etat_processus)
1162: .semaphore_fork));
1163: sem_destroy(&((*s_etat_processus)
1164: .semaphore_fork));
1165: # else
1166: sem_post((*s_etat_processus)
1167: .semaphore_fork);
1168: sem_destroy3((*s_etat_processus)
1169: .semaphore_fork, getpid(),
1170: pthread_self(), SEM_FORK);
1171: # endif
1172:
1173: liberation_contexte_cas(s_etat_processus);
1174: destruction_queue_signaux(s_etat_processus);
1175:
1176: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1177: stackoverflow_deinstall_handler();
1178: # endif
1179:
1180: if ((*s_etat_processus).langue == 'F')
1181: {
1182: printf("+++Système : Mémoire "
1183: "insuffisante\n");
1184: }
1185: else
1186: {
1187: printf("+++System : Not enough "
1188: "memory\n");
1189: }
1190:
1191: return(EXIT_FAILURE);
1192: }
1193:
1194: ptr = arguments;
1195: (*ptr) = d_code_fin_chaine;
1196: strcat(ptr, "<< ");
1197: ptr += 3;
1198:
1199: while(*(argv[0]) != '\0')
1200: {
1201: *(ptr++) = *(argv[0]++);
1202: }
1203:
1204: (*ptr) = '\0';
1205:
1206: strcat(arguments, " >>");
1207: argv[0]--;
1208: }
1209: else if ((--argc) > 0)
1210: {
1211: argv++;
1212:
1213: if ((arguments = malloc((strlen(argv[0]) + 7) *
1214: sizeof(unsigned char))) == NULL)
1215: {
1216: # ifndef SEMAPHORES_NOMMES
1217: sem_post(&((*s_etat_processus)
1218: .semaphore_fork));
1219: sem_destroy(&((*s_etat_processus)
1220: .semaphore_fork));
1221: # else
1222: sem_post((*s_etat_processus)
1223: .semaphore_fork);
1224: sem_destroy3((*s_etat_processus)
1225: .semaphore_fork, getpid(),
1226: pthread_self(), SEM_FORK);
1227: # endif
1228:
1229: liberation_contexte_cas(s_etat_processus);
1230: destruction_queue_signaux(s_etat_processus);
1231:
1232: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1233: stackoverflow_deinstall_handler();
1234: # endif
1235:
1236: if ((*s_etat_processus).langue == 'F')
1237: {
1238: printf("+++Système : Mémoire "
1239: "insuffisante\n");
1240: }
1241: else
1242: {
1243: printf("+++System : Not enough "
1244: "memory\n");
1245: }
1246:
1247: return(EXIT_FAILURE);
1248: }
1249:
1250: ptr = arguments;
1251: (*ptr) = d_code_fin_chaine;
1252: strcat(ptr, "<< ");
1253: ptr += 3;
1254:
1255: while(*(argv[0]) != '\0')
1256: {
1257: *(ptr++) = *(argv[0]++);
1258: }
1259:
1260: (*ptr) = '\0';
1261:
1262: strcat(arguments, " >>");
1263: argv[0]--;
1264: }
1265: else
1266: {
1267: # ifndef SEMAPHORES_NOMMES
1268: sem_post(&((*s_etat_processus).semaphore_fork));
1269: sem_destroy(&((*s_etat_processus)
1270: .semaphore_fork));
1271: # else
1272: sem_post((*s_etat_processus).semaphore_fork);
1273: sem_destroy3((*s_etat_processus).semaphore_fork,
1274: getpid(), pthread_self(), SEM_FORK);
1275: # endif
1276:
1277: liberation_contexte_cas(s_etat_processus);
1278: destruction_queue_signaux(s_etat_processus);
1279:
1280: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1281: stackoverflow_deinstall_handler();
1282: # endif
1283:
1284: if ((*s_etat_processus).langue == 'F')
1285: {
1286: printf("+++Erreur : Aucune donnée "
1287: "spécifié après l'option -A\n");
1288: }
1289: else
1290: {
1291: printf("+++Error : Data required after "
1292: "-A option\n");
1293: }
1294:
1295: return(EXIT_FAILURE);
1296: }
1297:
1298: break;
1299: }
1300:
1301: case 'c' :
1302: {
1303: if (option_c == d_vrai)
1304: {
1305: # ifndef SEMAPHORES_NOMMES
1306: sem_post(&((*s_etat_processus).semaphore_fork));
1307: sem_destroy(&((*s_etat_processus)
1308: .semaphore_fork));
1309: # else
1310: sem_post((*s_etat_processus).semaphore_fork);
1311: sem_destroy3((*s_etat_processus).semaphore_fork,
1312: getpid(), pthread_self(), SEM_FORK);
1313: # endif
1314:
1315: liberation_contexte_cas(s_etat_processus);
1316: destruction_queue_signaux(s_etat_processus);
1317:
1318: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1319: stackoverflow_deinstall_handler();
1320: # endif
1321:
1322: if ((*s_etat_processus).langue == 'F')
1323: {
1324: printf("+++Erreur : option -c présente "
1325: "plus d'une fois\n");
1326: }
1327: else
1328: {
1329: printf("+++Error : more than one -c "
1330: "on command line");
1331: }
1332:
1333: return(EXIT_FAILURE);
1334: }
1335:
1336: option_c = d_vrai;
1337: core = d_vrai;
1338: break;
1339: }
1340:
1341: case 'd' :
1342: {
1343: if (option_d == d_vrai)
1344: {
1345: # ifndef SEMAPHORES_NOMMES
1346: sem_post(&((*s_etat_processus).semaphore_fork));
1347: sem_destroy(&((*s_etat_processus)
1348: .semaphore_fork));
1349: # else
1350: sem_post((*s_etat_processus).semaphore_fork);
1351: sem_destroy3((*s_etat_processus).semaphore_fork,
1352: getpid(), pthread_self(), SEM_FORK);
1353: # endif
1354:
1355: liberation_contexte_cas(s_etat_processus);
1356: destruction_queue_signaux(s_etat_processus);
1357:
1358: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1359: stackoverflow_deinstall_handler();
1360: # endif
1361:
1362: if ((*s_etat_processus).langue == 'F')
1363: {
1364: printf("+++Erreur : option -d présente "
1365: "plus d'une fois\n");
1366: }
1367: else
1368: {
1369: printf("+++Error : more than one -d "
1370: "on command line");
1371: }
1372:
1373: return(EXIT_FAILURE);
1374: }
1375:
1376: option_d = d_vrai;
1377: debug = d_vrai;
1378: break;
1379: }
1380:
1381: case 'D' :
1382: {
1383: if (option_D == d_vrai)
1384: {
1385: # ifndef SEMAPHORES_NOMMES
1386: sem_post(&((*s_etat_processus).semaphore_fork));
1387: sem_destroy(&((*s_etat_processus)
1388: .semaphore_fork));
1389: # else
1390: sem_post((*s_etat_processus).semaphore_fork);
1391: sem_destroy3((*s_etat_processus).semaphore_fork,
1392: getpid(), pthread_self(), SEM_FORK);
1393: # endif
1394:
1395: liberation_contexte_cas(s_etat_processus);
1396: destruction_queue_signaux(s_etat_processus);
1397:
1398: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1399: stackoverflow_deinstall_handler();
1400: # endif
1401:
1402: if ((*s_etat_processus).langue == 'F')
1403: {
1404: printf("+++Erreur : option -D présente "
1405: "plus d'une fois\n");
1406: }
1407: else
1408: {
1409: printf("+++Error : more than one -D "
1410: "on command line");
1411: }
1412:
1413: return(EXIT_FAILURE);
1414: }
1415:
1416: option_D = d_vrai;
1417: break;
1418: }
1419:
1420: case 'h' :
1421: {
1422: if (option_h == d_vrai)
1423: {
1424: # ifndef SEMAPHORES_NOMMES
1425: sem_post(&((*s_etat_processus).semaphore_fork));
1426: sem_destroy(&((*s_etat_processus)
1427: .semaphore_fork));
1428: # else
1429: sem_post((*s_etat_processus).semaphore_fork);
1430: sem_destroy3((*s_etat_processus).semaphore_fork,
1431: getpid(), pthread_self(), SEM_FORK);
1432: # endif
1433:
1434: liberation_contexte_cas(s_etat_processus);
1435: destruction_queue_signaux(s_etat_processus);
1436:
1437: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1438: stackoverflow_deinstall_handler();
1439: # endif
1440:
1441: if ((*s_etat_processus).langue == 'F')
1442: {
1443: printf("+++Erreur : option -h présente "
1444: "plus d'une fois\n");
1445: }
1446: else
1447: {
1448: printf("+++Error : more than one -h "
1449: "on command line");
1450: }
1451:
1452: return(EXIT_FAILURE);
1453: }
1454:
1455: option_h = d_vrai;
1456: informations(s_etat_processus);
1457: break;
1458: }
1459:
1460: case 'i' :
1461: {
1462: if (option_i == d_vrai)
1463: {
1464: # ifndef SEMAPHORES_NOMMES
1465: sem_post(&((*s_etat_processus).semaphore_fork));
1466: sem_destroy(&((*s_etat_processus)
1467: .semaphore_fork));
1468: # else
1469: sem_post((*s_etat_processus).semaphore_fork);
1470: sem_destroy3((*s_etat_processus).semaphore_fork,
1471: getpid(), pthread_self(), SEM_FORK);
1472: # endif
1473:
1474: liberation_contexte_cas(s_etat_processus);
1475: destruction_queue_signaux(s_etat_processus);
1476:
1477: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1478: stackoverflow_deinstall_handler();
1479: # endif
1480:
1481: if ((*s_etat_processus).langue == 'F')
1482: {
1483: printf("+++Erreur : option -i présente "
1484: "plus d'une fois\n");
1485: }
1486: else
1487: {
1488: printf("+++Error : more than one -i "
1489: "on command line");
1490: }
1491:
1492: return(EXIT_FAILURE);
1493: }
1494: else if (option_S == d_vrai)
1495: {
1496: # ifndef SEMAPHORES_NOMMES
1497: sem_post(&((*s_etat_processus).semaphore_fork));
1498: sem_destroy(&((*s_etat_processus)
1499: .semaphore_fork));
1500: # else
1501: sem_post((*s_etat_processus).semaphore_fork);
1502: sem_destroy3((*s_etat_processus).semaphore_fork,
1503: getpid(), pthread_self(), SEM_FORK);
1504: # endif
1505:
1506: liberation_contexte_cas(s_etat_processus);
1507: destruction_queue_signaux(s_etat_processus);
1508:
1509: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1510: stackoverflow_deinstall_handler();
1511: # endif
1512:
1513: if ((*s_etat_processus).langue == 'F')
1514: {
1515: printf("+++Erreur : options -i et -S "
1516: "incompatibles\n");
1517: }
1518: else
1519: {
1520: printf("+++Error : incompatible options -i "
1521: "and -S\n");
1522: }
1523:
1524: return(EXIT_FAILURE);
1525: }
1526: else if (option_p == d_vrai)
1527: {
1528: # ifndef SEMAPHORES_NOMMES
1529: sem_post(&((*s_etat_processus).semaphore_fork));
1530: sem_destroy(&((*s_etat_processus)
1531: .semaphore_fork));
1532: # else
1533: sem_post((*s_etat_processus).semaphore_fork);
1534: sem_destroy3((*s_etat_processus).semaphore_fork,
1535: getpid(), pthread_self(), SEM_FORK);
1536: # endif
1537:
1538: liberation_contexte_cas(s_etat_processus);
1539: destruction_queue_signaux(s_etat_processus);
1540:
1541: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1542: stackoverflow_deinstall_handler();
1543: # endif
1544:
1545: if ((*s_etat_processus).langue == 'F')
1546: {
1547: printf("+++Erreur : options -i et -p "
1548: "incompatibles\n");
1549: }
1550: else
1551: {
1552: printf("+++Error : incompatible options -i "
1553: "and -p\n");
1554: }
1555:
1556: return(EXIT_FAILURE);
1557: }
1558:
1559: option_i = d_vrai;
1560: mode_interactif = d_vrai;
1561: presence_definition = 'O';
1562: break;
1563: }
1564:
1565: case 'l' :
1566: {
1567: if (option_l == d_vrai)
1568: {
1569: # ifndef SEMAPHORES_NOMMES
1570: sem_post(&((*s_etat_processus).semaphore_fork));
1571: sem_destroy(&((*s_etat_processus)
1572: .semaphore_fork));
1573: # else
1574: sem_post((*s_etat_processus).semaphore_fork);
1575: sem_destroy3((*s_etat_processus).semaphore_fork,
1576: getpid(), pthread_self(), SEM_FORK);
1577: # endif
1578:
1579: liberation_contexte_cas(s_etat_processus);
1580: destruction_queue_signaux(s_etat_processus);
1581:
1582: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1583: stackoverflow_deinstall_handler();
1584: # endif
1585:
1586: if ((*s_etat_processus).langue == 'F')
1587: {
1588: printf("+++Erreur : option -l présente "
1589: "plus d'une fois\n");
1590: }
1591: else
1592: {
1593: printf("+++Error : more than one -l "
1594: "on command line");
1595: }
1596:
1597: return(EXIT_FAILURE);
1598: }
1599:
1600: option_l = d_vrai;
1601:
1602: if ((*s_etat_processus).langue == 'F')
1603: {
1604: printf("%s\n\n", CeCILL_fr);
1605: }
1606: else
1607: {
1608: printf("%s\n\n", CeCILL_en);
1609: }
1610:
1611: break;
1612: }
1613:
1614: case 'm' :
1615: {
1616: while(*(++argv[0]) == ' ');
1617: argv[0]--;
1618:
1619: if ((*(++argv[0])) != '\0')
1620: {
1621: if ((l_nouvelle_bibliotheque = malloc(
1622: sizeof(struct_liste_chainee))) == NULL)
1623: {
1624: # ifndef SEMAPHORES_NOMMES
1625: sem_post(&((*s_etat_processus)
1626: .semaphore_fork));
1627: sem_destroy(&((*s_etat_processus)
1628: .semaphore_fork));
1629: # else
1630: sem_post((*s_etat_processus)
1631: .semaphore_fork);
1632: sem_destroy3((*s_etat_processus)
1633: .semaphore_fork, getpid(),
1634: pthread_self(), SEM_FORK);
1635: # endif
1636:
1637: liberation_contexte_cas(s_etat_processus);
1638: destruction_queue_signaux(s_etat_processus);
1639:
1640: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1641: stackoverflow_deinstall_handler();
1642: # endif
1643:
1644: if ((*s_etat_processus).langue == 'F')
1645: {
1646: printf("+++Système : Mémoire "
1647: "insuffisante\n");
1648: }
1649: else
1650: {
1651: printf("+++System : Not enough "
1652: "memory\n");
1653: }
1654:
1655: return(EXIT_FAILURE);
1656: }
1657:
1658: (*l_nouvelle_bibliotheque).suivant =
1659: l_bibliotheques;
1660:
1661: if (((*l_nouvelle_bibliotheque).donnee =
1662: allocation(s_etat_processus, CHN))
1663: == NULL)
1664: {
1665: # ifndef SEMAPHORES_NOMMES
1666: sem_post(&((*s_etat_processus)
1667: .semaphore_fork));
1668: sem_destroy(&((*s_etat_processus)
1669: .semaphore_fork));
1670: # else
1671: sem_post((*s_etat_processus)
1672: .semaphore_fork);
1673: sem_destroy3((*s_etat_processus)
1674: .semaphore_fork, getpid(),
1675: pthread_self(), SEM_FORK);
1676: # endif
1677:
1678: liberation_contexte_cas(s_etat_processus);
1679: destruction_queue_signaux(s_etat_processus);
1680:
1681: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1682: stackoverflow_deinstall_handler();
1683: # endif
1684:
1685: if ((*s_etat_processus).langue == 'F')
1686: {
1687: printf("+++Système : Mémoire "
1688: "insuffisante\n");
1689: }
1690: else
1691: {
1692: printf("+++System : Not enough "
1693: "memory\n");
1694: }
1695:
1696: return(EXIT_FAILURE);
1697: }
1698:
1699: if (((*(*l_nouvelle_bibliotheque).donnee)
1700: .objet = malloc((strlen(argv[0]) + 1) *
1701: sizeof(unsigned char))) == NULL)
1702: {
1703: # ifndef SEMAPHORES_NOMMES
1704: sem_post(&((*s_etat_processus)
1705: .semaphore_fork));
1706: sem_destroy(&((*s_etat_processus)
1707: .semaphore_fork));
1708: # else
1709: sem_post((*s_etat_processus)
1710: .semaphore_fork);
1711: sem_destroy3((*s_etat_processus)
1712: .semaphore_fork, getpid(),
1713: pthread_self(), SEM_FORK);
1714: # endif
1715:
1716: liberation_contexte_cas(s_etat_processus);
1717: destruction_queue_signaux(s_etat_processus);
1718:
1719: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1720: stackoverflow_deinstall_handler();
1721: # endif
1722:
1723: if ((*s_etat_processus).langue == 'F')
1724: {
1725: printf("+++Système : Mémoire "
1726: "insuffisante\n");
1727: }
1728: else
1729: {
1730: printf("+++System : Not enough "
1731: "memory\n");
1732: }
1733:
1734: return(EXIT_FAILURE);
1735: }
1736:
1737: strcpy((*(*l_nouvelle_bibliotheque).donnee)
1738: .objet, argv[0]);
1739: argv[0] += strlen((unsigned char *)
1740: (*(*l_nouvelle_bibliotheque).donnee)
1741: .objet) - 1;
1742:
1743: l_bibliotheques = l_nouvelle_bibliotheque;
1744: }
1745: else if ((--argc) > 0)
1746: {
1747: argv++;
1748:
1749: if ((l_nouvelle_bibliotheque = malloc(
1750: sizeof(struct_liste_chainee))) == NULL)
1751: {
1752: # ifndef SEMAPHORES_NOMMES
1753: sem_post(&((*s_etat_processus)
1754: .semaphore_fork));
1755: sem_destroy(&((*s_etat_processus)
1756: .semaphore_fork));
1757: # else
1758: sem_post((*s_etat_processus)
1759: .semaphore_fork);
1760: sem_destroy3((*s_etat_processus)
1761: .semaphore_fork, getpid(),
1762: pthread_self(), SEM_FORK);
1763: # endif
1764:
1765: liberation_contexte_cas(s_etat_processus);
1766: destruction_queue_signaux(s_etat_processus);
1767:
1768: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1769: stackoverflow_deinstall_handler();
1770: # endif
1771:
1772: if ((*s_etat_processus).langue == 'F')
1773: {
1774: printf("+++Système : Mémoire "
1775: "insuffisante\n");
1776: }
1777: else
1778: {
1779: printf("+++System : Not enough "
1780: "memory\n");
1781: }
1782:
1783: return(EXIT_FAILURE);
1784: }
1785:
1786: (*l_nouvelle_bibliotheque).suivant =
1787: l_bibliotheques;
1788:
1789: if (((*l_nouvelle_bibliotheque).donnee =
1790: allocation(s_etat_processus, CHN))
1791: == NULL)
1792: {
1793: # ifndef SEMAPHORES_NOMMES
1794: sem_post(&((*s_etat_processus)
1795: .semaphore_fork));
1796: sem_destroy(&((*s_etat_processus)
1797: .semaphore_fork));
1798: # else
1799: sem_post((*s_etat_processus)
1800: .semaphore_fork);
1801: sem_destroy3((*s_etat_processus)
1802: .semaphore_fork, getpid(),
1803: pthread_self(), SEM_FORK);
1804: # endif
1805:
1806: liberation_contexte_cas(s_etat_processus);
1807: destruction_queue_signaux(s_etat_processus);
1808:
1809: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1810: stackoverflow_deinstall_handler();
1811: # endif
1812:
1813: if ((*s_etat_processus).langue == 'F')
1814: {
1815: printf("+++Système : Mémoire "
1816: "insuffisante\n");
1817: }
1818: else
1819: {
1820: printf("+++System : Not enough "
1821: "memory\n");
1822: }
1823:
1824: return(EXIT_FAILURE);
1825: }
1826:
1827: if (((*(*l_nouvelle_bibliotheque).donnee)
1828: .objet = malloc((strlen(argv[0]) + 1) *
1829: sizeof(unsigned char))) == NULL)
1830: {
1831: # ifndef SEMAPHORES_NOMMES
1832: sem_post(&((*s_etat_processus)
1833: .semaphore_fork));
1834: sem_destroy(&((*s_etat_processus)
1835: .semaphore_fork));
1836: # else
1837: sem_post((*s_etat_processus)
1838: .semaphore_fork);
1839: sem_destroy3((*s_etat_processus)
1840: .semaphore_fork, getpid(),
1841: pthread_self(), SEM_FORK);
1842: # endif
1843:
1844: liberation_contexte_cas(s_etat_processus);
1845: destruction_queue_signaux(s_etat_processus);
1846:
1847: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1848: stackoverflow_deinstall_handler();
1849: # endif
1850:
1851: if ((*s_etat_processus).langue == 'F')
1852: {
1853: printf("+++Système : Mémoire "
1854: "insuffisante\n");
1855: }
1856: else
1857: {
1858: printf("+++System : Not enough "
1859: "memory\n");
1860: }
1861:
1862: return(EXIT_FAILURE);
1863: }
1864:
1865: strcpy((*(*l_nouvelle_bibliotheque).donnee)
1866: .objet, argv[0]);
1867: argv[0] += strlen((unsigned char *)
1868: (*(*l_nouvelle_bibliotheque).donnee)
1869: .objet) - 1;
1870:
1871: l_bibliotheques = l_nouvelle_bibliotheque;
1872: }
1873: else
1874: {
1875: # ifndef SEMAPHORES_NOMMES
1876: sem_post(&((*s_etat_processus).semaphore_fork));
1877: sem_destroy(&((*s_etat_processus)
1878: .semaphore_fork));
1879: # else
1880: sem_post((*s_etat_processus).semaphore_fork);
1881: sem_destroy3((*s_etat_processus).semaphore_fork,
1882: getpid(), pthread_self(), SEM_FORK);
1883: # endif
1884:
1885: liberation_contexte_cas(s_etat_processus);
1886: destruction_queue_signaux(s_etat_processus);
1887:
1888: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1889: stackoverflow_deinstall_handler();
1890: # endif
1891:
1892: if ((*s_etat_processus).langue == 'F')
1893: {
1894: printf("+++Erreur : Aucune bibliothèque "
1895: "spécifiée après l'option -A\n");
1896: }
1897: else
1898: {
1899: printf("+++Error : Library required after "
1900: "-m option\n");
1901: }
1902:
1903: return(EXIT_FAILURE);
1904: }
1905:
1906: break;
1907: }
1908:
1909: case 'n' :
1910: {
1911: if (option_n == d_vrai)
1912: {
1913: # ifndef SEMAPHORES_NOMMES
1914: sem_post(&((*s_etat_processus).semaphore_fork));
1915: sem_destroy(&((*s_etat_processus)
1916: .semaphore_fork));
1917: # else
1918: sem_post((*s_etat_processus).semaphore_fork);
1919: sem_destroy3((*s_etat_processus).semaphore_fork,
1920: getpid(), pthread_self(), SEM_FORK);
1921: # endif
1922:
1923: liberation_contexte_cas(s_etat_processus);
1924: destruction_queue_signaux(s_etat_processus);
1925:
1926: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1927: stackoverflow_deinstall_handler();
1928: # endif
1929:
1930: if ((*s_etat_processus).langue == 'F')
1931: {
1932: printf("+++Erreur : option -n présente "
1933: "plus d'une fois\n");
1934: }
1935: else
1936: {
1937: printf("+++Error : more than one -n "
1938: "on command line");
1939: }
1940:
1941: return(EXIT_FAILURE);
1942: }
1943:
1944: option_n = d_vrai;
1945:
1946: break;
1947: }
1948:
1949: case 'p' :
1950: {
1951: if (option_p == d_vrai)
1952: {
1953: # ifndef SEMAPHORES_NOMMES
1954: sem_post(&((*s_etat_processus).semaphore_fork));
1955: sem_destroy(&((*s_etat_processus)
1956: .semaphore_fork));
1957: # else
1958: sem_post((*s_etat_processus).semaphore_fork);
1959: sem_destroy3((*s_etat_processus).semaphore_fork,
1960: getpid(), pthread_self(), SEM_FORK);
1961: # endif
1962:
1963: liberation_contexte_cas(s_etat_processus);
1964: destruction_queue_signaux(s_etat_processus);
1965:
1966: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1967: stackoverflow_deinstall_handler();
1968: # endif
1969:
1970: if ((*s_etat_processus).langue == 'F')
1971: {
1972: printf("+++Erreur : option -p présente "
1973: "plus d'une fois\n");
1974: }
1975: else
1976: {
1977: printf("+++Error : more than one -p "
1978: "on command line");
1979: }
1980:
1981: return(EXIT_FAILURE);
1982: }
1983: else if (option_i == d_vrai)
1984: {
1985: # ifndef SEMAPHORES_NOMMES
1986: sem_post(&((*s_etat_processus).semaphore_fork));
1987: sem_destroy(&((*s_etat_processus)
1988: .semaphore_fork));
1989: # else
1990: sem_post((*s_etat_processus).semaphore_fork);
1991: sem_destroy3((*s_etat_processus).semaphore_fork,
1992: getpid(), pthread_self(), SEM_FORK);
1993: # endif
1994:
1995: liberation_contexte_cas(s_etat_processus);
1996: destruction_queue_signaux(s_etat_processus);
1997:
1998: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1999: stackoverflow_deinstall_handler();
2000: # endif
2001:
2002: if ((*s_etat_processus).langue == 'F')
2003: {
2004: printf("+++Erreur : options -i et -p "
2005: "incompatibles\n");
2006: }
2007: else
2008: {
2009: printf("+++Error : incompatible options -i "
2010: "and -p\n");
2011: }
2012:
2013: return(EXIT_FAILURE);
2014: }
2015:
2016: option_p = d_vrai;
2017:
2018: break;
2019: }
2020:
2021: case 'P' :
2022: {
2023: if (option_P > 2)
2024: {
2025: # ifndef SEMAPHORES_NOMMES
2026: sem_post(&((*s_etat_processus).semaphore_fork));
2027: sem_destroy(&((*s_etat_processus)
2028: .semaphore_fork));
2029: # else
2030: sem_post((*s_etat_processus).semaphore_fork);
2031: sem_destroy3((*s_etat_processus).semaphore_fork,
2032: getpid(), pthread_self(), SEM_FORK);
2033: # endif
2034:
2035: liberation_contexte_cas(s_etat_processus);
2036: destruction_queue_signaux(s_etat_processus);
2037:
2038: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2039: stackoverflow_deinstall_handler();
2040: # endif
2041:
2042: if ((*s_etat_processus).langue == 'F')
2043: {
2044: printf("+++Erreur : option -P présente "
2045: "plus de deux fois\n");
2046: }
2047: else
2048: {
2049: printf("+++Error : more than two -P "
2050: "on command line");
2051: }
2052:
2053: return(EXIT_FAILURE);
2054: }
2055:
2056: option_P++;
2057:
2058: break;
2059: }
2060:
2061: case 's' :
2062: {
2063: if (option_s == d_vrai)
2064: {
2065: # ifndef SEMAPHORES_NOMMES
2066: sem_post(&((*s_etat_processus).semaphore_fork));
2067: sem_destroy(&((*s_etat_processus)
2068: .semaphore_fork));
2069: # else
2070: sem_post((*s_etat_processus).semaphore_fork);
2071: sem_destroy3((*s_etat_processus).semaphore_fork,
2072: getpid(), pthread_self(), SEM_FORK);
2073: # endif
2074:
2075: liberation_contexte_cas(s_etat_processus);
2076: destruction_queue_signaux(s_etat_processus);
2077:
2078: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2079: stackoverflow_deinstall_handler();
2080: # endif
2081:
2082: if ((*s_etat_processus).langue == 'F')
2083: {
2084: printf("+++Erreur : option -s présente "
2085: "plus d'une fois\n");
2086: }
2087: else
2088: {
2089: printf("+++Error : more than one -s "
2090: "on command line");
2091: }
2092:
2093: return(EXIT_FAILURE);
2094: }
2095:
2096: option_s = d_vrai;
2097: drapeau_encart = 'N';
2098: break;
2099: }
2100:
2101: case 'S' :
2102: {
2103: if (option_S == d_vrai)
2104: {
2105: # ifndef SEMAPHORES_NOMMES
2106: sem_post(&((*s_etat_processus).semaphore_fork));
2107: sem_destroy(&((*s_etat_processus)
2108: .semaphore_fork));
2109: # else
2110: sem_post((*s_etat_processus).semaphore_fork);
2111: sem_destroy3((*s_etat_processus).semaphore_fork,
2112: getpid(), pthread_self(), SEM_FORK);
2113: # endif
2114:
2115: liberation_contexte_cas(s_etat_processus);
2116: destruction_queue_signaux(s_etat_processus);
2117:
2118: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2119: stackoverflow_deinstall_handler();
2120: # endif
2121:
2122: if ((*s_etat_processus).langue == 'F')
2123: {
2124: printf("+++Erreur : option -S présente "
2125: "plus d'une fois\n");
2126: }
2127: else
2128: {
2129: printf("+++Error : more than one -S "
2130: "on command line");
2131: }
2132:
2133: return(EXIT_FAILURE);
2134: }
2135: else if (option_i == d_vrai)
2136: {
2137: # ifndef SEMAPHORES_NOMMES
2138: sem_post(&((*s_etat_processus).semaphore_fork));
2139: sem_destroy(&((*s_etat_processus)
2140: .semaphore_fork));
2141: # else
2142: sem_post((*s_etat_processus).semaphore_fork);
2143: sem_destroy3((*s_etat_processus).semaphore_fork,
2144: getpid(), pthread_self(), SEM_FORK);
2145: # endif
2146:
2147: liberation_contexte_cas(s_etat_processus);
2148: destruction_queue_signaux(s_etat_processus);
2149:
2150: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2151: stackoverflow_deinstall_handler();
2152: # endif
2153:
2154: if ((*s_etat_processus).langue == 'F')
2155: {
2156: printf("+++Erreur : options -i et -S "
2157: "incompatibles\n");
2158: }
2159: else
2160: {
2161: printf("+++Error : incompatible options -S "
2162: "and -i\n");
2163: }
2164:
2165: return(EXIT_FAILURE);
2166: }
2167:
2168: option_S = d_vrai;
2169:
2170: while(*(++argv[0]) == ' ');
2171: argv[0]--;
2172:
2173: if ((*(++argv[0])) != '\0')
2174: {
2175: if (((*s_etat_processus).definitions_chainees =
2176: malloc((strlen(argv[0]) + 1) *
2177: sizeof(unsigned char))) == NULL)
2178: {
2179: # ifndef SEMAPHORES_NOMMES
2180: sem_post(&((*s_etat_processus)
2181: .semaphore_fork));
2182: sem_destroy(&((*s_etat_processus)
2183: .semaphore_fork));
2184: # else
2185: sem_post((*s_etat_processus)
2186: .semaphore_fork);
2187: sem_destroy3((*s_etat_processus)
2188: .semaphore_fork, getpid(),
2189: pthread_self(), SEM_FORK);
2190: # endif
2191:
2192: liberation_contexte_cas(s_etat_processus);
2193: destruction_queue_signaux(s_etat_processus);
2194:
2195: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2196: stackoverflow_deinstall_handler();
2197: # endif
2198:
2199: if ((*s_etat_processus).langue == 'F')
2200: {
2201: printf("+++Système : Mémoire "
2202: "insuffisante\n");
2203: }
2204: else
2205: {
2206: printf("+++System : Not enough "
2207: "memory\n");
2208: }
2209:
2210: return(EXIT_FAILURE);
2211: }
2212:
2213: ptr = (*s_etat_processus).definitions_chainees;
2214:
2215: while(*(argv[0]) != '\0')
2216: {
2217: *(ptr++) = *(argv[0]++);
2218: }
2219:
2220: (*ptr) = '\0';
2221:
2222: argv[0]--;
2223: presence_definition = 'O';
2224: }
2225: else if ((--argc) > 0)
2226: {
2227: argv++;
2228:
2229: if (((*s_etat_processus).definitions_chainees =
2230: malloc((strlen(argv[0]) + 1) *
2231: sizeof(unsigned char))) == NULL)
2232: {
2233: # ifndef SEMAPHORES_NOMMES
2234: sem_post(&((*s_etat_processus)
2235: .semaphore_fork));
2236: sem_destroy(&((*s_etat_processus)
2237: .semaphore_fork));
2238: # else
2239: sem_post((*s_etat_processus)
2240: .semaphore_fork);
2241: sem_destroy3((*s_etat_processus)
2242: .semaphore_fork, getpid(),
2243: pthread_self(), SEM_FORK);
2244: # endif
2245:
2246: liberation_contexte_cas(s_etat_processus);
2247: destruction_queue_signaux(s_etat_processus);
2248:
2249: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2250: stackoverflow_deinstall_handler();
2251: # endif
2252:
2253: if ((*s_etat_processus).langue == 'F')
2254: {
2255: printf("+++Système : Mémoire "
2256: "insuffisante\n");
2257: }
2258: else
2259: {
2260: printf("+++System : Not enough "
2261: "memory\n");
2262: }
2263:
2264: return(EXIT_FAILURE);
2265: }
2266:
2267: ptr = (*s_etat_processus).definitions_chainees;
2268:
2269: while(*(argv[0]) != '\0')
2270: {
2271: *(ptr++) = *(argv[0]++);
2272: }
2273:
2274: (*ptr) = '\0';
2275:
2276: argv[0]--;
2277: presence_definition = 'O';
2278: }
2279: else
2280: {
2281: # ifndef SEMAPHORES_NOMMES
2282: sem_post(&((*s_etat_processus).semaphore_fork));
2283: sem_destroy(&((*s_etat_processus)
2284: .semaphore_fork));
2285: # else
2286: sem_post((*s_etat_processus).semaphore_fork);
2287: sem_destroy3((*s_etat_processus).semaphore_fork,
2288: getpid(), pthread_self(), SEM_FORK);
2289: # endif
2290:
2291: liberation_contexte_cas(s_etat_processus);
2292: destruction_queue_signaux(s_etat_processus);
2293:
2294: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2295: stackoverflow_deinstall_handler();
2296: # endif
2297:
2298: if ((*s_etat_processus).langue == 'F')
2299: {
2300: printf("+++Erreur : Aucun script "
2301: "spécifié après l'option -S\n");
2302: }
2303: else
2304: {
2305: printf("+++Error : Script required after "
2306: "-S option\n");
2307: }
2308:
2309: return(EXIT_FAILURE);
2310: }
2311:
2312: if (((*s_etat_processus).definitions_chainees =
2313: compactage(s_etat_processus,
2314: (*s_etat_processus).definitions_chainees))
2315: == NULL)
2316: {
2317: # ifndef SEMAPHORES_NOMMES
2318: sem_post(&((*s_etat_processus).semaphore_fork));
2319: sem_destroy(&((*s_etat_processus)
2320: .semaphore_fork));
2321: # else
2322: sem_post((*s_etat_processus).semaphore_fork);
2323: sem_destroy3((*s_etat_processus).semaphore_fork,
2324: getpid(), pthread_self(), SEM_FORK);
2325: # endif
2326:
2327: liberation_contexte_cas(s_etat_processus);
2328: destruction_queue_signaux(s_etat_processus);
2329:
2330: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2331: stackoverflow_deinstall_handler();
2332: # endif
2333:
2334: if ((*s_etat_processus).langue == 'F')
2335: {
2336: printf("+++Système : Mémoire "
2337: "insuffisante\n");
2338: }
2339: else
2340: {
2341: printf("+++System : Not enough "
2342: "memory\n");
2343: }
2344:
2345: return(EXIT_FAILURE);
2346: }
2347:
2348: (*s_etat_processus).longueur_definitions_chainees =
2349: (integer8) strlen((*s_etat_processus)
2350: .definitions_chainees);
2351:
2352: break;
2353: }
2354:
2355: case 't' :
2356: {
2357: if (option_t == d_vrai)
2358: {
2359: # ifndef SEMAPHORES_NOMMES
2360: sem_post(&((*s_etat_processus).semaphore_fork));
2361: sem_destroy(&((*s_etat_processus)
2362: .semaphore_fork));
2363: # else
2364: sem_post((*s_etat_processus).semaphore_fork);
2365: sem_destroy3((*s_etat_processus).semaphore_fork,
2366: getpid(), pthread_self(), SEM_FORK);
2367: # endif
2368:
2369: liberation_contexte_cas(s_etat_processus);
2370: destruction_queue_signaux(s_etat_processus);
2371:
2372: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2373: stackoverflow_deinstall_handler();
2374: # endif
2375:
2376: if ((*s_etat_processus).langue == 'F')
2377: {
2378: printf("+++Erreur : option -t présente "
2379: "plus d'une fois\n");
2380: }
2381: else
2382: {
2383: printf("+++Error : more than one -t "
2384: "on command line");
2385: }
2386:
2387: return(EXIT_FAILURE);
2388: }
2389:
2390: option_t = d_vrai;
2391: (*s_etat_processus).debug = d_vrai;
2392:
2393: while(*(++argv[0]) == ' ');
2394: argv[0]--;
2395:
2396: if ((*(++argv[0])) != '\0')
2397: {
2398: if ((type_debug = malloc((strlen(argv[0]) + 1) *
2399: sizeof(unsigned char))) == NULL)
2400: {
2401: # ifndef SEMAPHORES_NOMMES
2402: sem_post(&((*s_etat_processus)
2403: .semaphore_fork));
2404: sem_destroy(&((*s_etat_processus)
2405: .semaphore_fork));
2406: # else
2407: sem_post((*s_etat_processus)
2408: .semaphore_fork);
2409: sem_destroy3((*s_etat_processus)
2410: .semaphore_fork, getpid(),
2411: pthread_self(), SEM_FORK);
2412: # endif
2413:
2414: liberation_contexte_cas(s_etat_processus);
2415: destruction_queue_signaux(s_etat_processus);
2416:
2417: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2418: stackoverflow_deinstall_handler();
2419: # endif
2420:
2421: if ((*s_etat_processus).langue == 'F')
2422: {
2423: printf("+++Système : Mémoire "
2424: "insuffisante\n");
2425: }
2426: else
2427: {
2428: printf("+++System : Not enough "
2429: "memory\n");
2430: }
2431:
2432: return(EXIT_FAILURE);
2433: }
2434:
2435: ptr = type_debug;
2436:
2437: while((*(argv[0]) != '\0') &&
2438: (*(argv[0]) != ' '))
2439: {
2440: *(ptr++) = *(argv[0]++);
2441: }
2442:
2443: (*ptr) = '\0';
2444:
2445: argv[0]--;
2446: }
2447: else if ((--argc) > 0)
2448: {
2449: argv++;
2450:
2451: if ((type_debug =
2452: malloc((strlen(argv[0]) + 1) *
2453: sizeof(unsigned char))) == NULL)
2454: {
2455: # ifndef SEMAPHORES_NOMMES
2456: sem_post(&((*s_etat_processus)
2457: .semaphore_fork));
2458: sem_destroy(&((*s_etat_processus)
2459: .semaphore_fork));
2460: # else
2461: sem_post((*s_etat_processus)
2462: .semaphore_fork);
2463: sem_destroy3((*s_etat_processus)
2464: .semaphore_fork, getpid(),
2465: pthread_self(), SEM_FORK);
2466: # endif
2467:
2468: liberation_contexte_cas(s_etat_processus);
2469: destruction_queue_signaux(s_etat_processus);
2470:
2471: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2472: stackoverflow_deinstall_handler();
2473: # endif
2474:
2475: if ((*s_etat_processus).langue == 'F')
2476: {
2477: printf("+++Système : Mémoire "
2478: "insuffisante\n");
2479: }
2480: else
2481: {
2482: printf("+++System : Not enough "
2483: "memory\n");
2484: }
2485:
2486: return(EXIT_FAILURE);
2487: }
2488:
2489: ptr = type_debug;
2490:
2491: while(*(argv[0]) != '\0')
2492: {
2493: *(ptr++) = *(argv[0]++);
2494: }
2495:
2496: (*ptr) = '\0';
2497:
2498: argv[0]--;
2499: }
2500: else
2501: {
2502: # ifndef SEMAPHORES_NOMMES
2503: sem_post(&((*s_etat_processus).semaphore_fork));
2504: sem_destroy(&((*s_etat_processus)
2505: .semaphore_fork));
2506: # else
2507: sem_post((*s_etat_processus).semaphore_fork);
2508: sem_destroy3((*s_etat_processus).semaphore_fork,
2509: getpid(), pthread_self(), SEM_FORK);
2510: # endif
2511:
2512: liberation_contexte_cas(s_etat_processus);
2513: destruction_queue_signaux(s_etat_processus);
2514:
2515: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2516: stackoverflow_deinstall_handler();
2517: # endif
2518:
2519: if ((*s_etat_processus).langue == 'F')
2520: {
2521: printf("+++Erreur : Aucun niveau "
2522: "de débogage spécifié après "
2523: "l'option -t\n");
2524: }
2525: else
2526: {
2527: printf("+++Error : Debug level not "
2528: "specified after -t option\n");
2529: }
2530:
2531: return(EXIT_FAILURE);
2532: }
2533:
2534: ptr = type_debug;
2535:
2536: while(*ptr != '\0')
2537: {
2538: switch(*ptr)
2539: {
2540: case '0':
2541: case '1':
2542: case '2':
2543: case '3':
2544: case '4':
2545: case '5':
2546: case '6':
2547: case '7':
2548: case '8':
2549: case '9':
2550: case 'A':
2551: case 'B':
2552: case 'C':
2553: case 'D':
2554: case 'E':
2555: case 'F':
2556: {
2557: break;
2558: }
2559:
2560: default:
2561: {
2562: # ifndef SEMAPHORES_NOMMES
2563: sem_post(&((*s_etat_processus)
2564: .semaphore_fork));
2565: sem_destroy(&((*s_etat_processus)
2566: .semaphore_fork));
2567: # else
2568: sem_post((*s_etat_processus)
2569: .semaphore_fork);
2570: sem_destroy3((*s_etat_processus)
2571: .semaphore_fork, getpid(),
2572: pthread_self(), SEM_FORK);
2573: # endif
2574:
2575: liberation_contexte_cas(
2576: s_etat_processus);
2577: destruction_queue_signaux(
2578: s_etat_processus);
2579:
2580: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2581: stackoverflow_deinstall_handler();
2582: # endif
2583:
2584: if ((*s_etat_processus).langue == 'F')
2585: {
2586: printf("+++Erreur : Niveau "
2587: "de débogage non "
2588: "hexadécimal\n");
2589: }
2590: else
2591: {
2592: printf("+++Error : Debug level must"
2593: " be hexadecimal "
2594: "integer\n");
2595: }
2596:
2597: return(EXIT_FAILURE);
2598: }
2599: }
2600:
2601: ptr++;
2602: }
2603:
2604: if (sscanf(type_debug, "%llX",
2605: &((*s_etat_processus).type_debug)) != 1)
2606: {
2607: # ifndef SEMAPHORES_NOMMES
2608: sem_post(&((*s_etat_processus).semaphore_fork));
2609: sem_destroy(&((*s_etat_processus)
2610: .semaphore_fork));
2611: # else
2612: sem_post((*s_etat_processus).semaphore_fork);
2613: sem_destroy3((*s_etat_processus).semaphore_fork,
2614: getpid(), pthread_self(), SEM_FORK);
2615: # endif
2616:
2617: liberation_contexte_cas(s_etat_processus);
2618: destruction_queue_signaux(s_etat_processus);
2619:
2620: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2621: stackoverflow_deinstall_handler();
2622: # endif
2623:
2624: if ((*s_etat_processus).langue == 'F')
2625: {
2626: printf("+++Erreur : Niveau "
2627: "de débogage non entier\n");
2628: }
2629: else
2630: {
2631: printf("+++Error : Debug level must"
2632: " be integer\n");
2633: }
2634:
2635: return(EXIT_FAILURE);
2636: }
2637:
2638: free(type_debug);
2639: break;
2640: }
2641:
2642: case 'v' :
2643: {
2644: if (option_v == d_vrai)
2645: {
2646: # ifndef SEMAPHORES_NOMMES
2647: sem_post(&((*s_etat_processus).semaphore_fork));
2648: sem_destroy(&((*s_etat_processus)
2649: .semaphore_fork));
2650: # else
2651: sem_post((*s_etat_processus).semaphore_fork);
2652: sem_destroy3((*s_etat_processus).semaphore_fork,
2653: getpid(), pthread_self(), SEM_FORK);
2654: # endif
2655:
2656: liberation_contexte_cas(s_etat_processus);
2657: destruction_queue_signaux(s_etat_processus);
2658:
2659: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2660: stackoverflow_deinstall_handler();
2661: # endif
2662:
2663: if ((*s_etat_processus).langue == 'F')
2664: {
2665: printf("+++Erreur : option -v présente "
2666: "plus d'une fois\n");
2667: }
2668: else
2669: {
2670: printf("+++Error : more than one -v "
2671: "on command line");
2672: }
2673:
2674: return(EXIT_FAILURE);
2675: }
2676:
2677: option_v = d_vrai;
2678: printf("\n");
2679:
2680: if ((*s_etat_processus).langue == 'F')
2681: {
2682: printf(" Reverse Polish Lisp/2 version %s "
2683: "pour systèmes "
2684: "POSIX\n", d_version_rpl);
2685: printf(" Langage procédural de très haut "
2686: "niveau, semi-compilé, "
2687: "extensible,\n");
2688: printf(" destiné principalement aux "
2689: "calculs scientifiques et "
2690: "symboliques\n");
2691: printf("%s\n", copyright);
2692: }
2693: else
2694: {
2695: printf(" Reverse Polish Lisp/2 version %s "
2696: "for POSIX operating systems\n",
2697: d_version_rpl);
2698: printf(" Half-compiled, high-level "
2699: "procedural language,\n");
2700: printf(" mainly aiming at scientific "
2701: "calculations\n");
2702: printf("%s\n", copyright_anglais);
2703: }
2704:
2705: printf("\n");
2706: break;
2707: }
2708:
2709: case '-':
2710: case ' ':
2711: {
2712: break;
2713: }
2714:
2715: default :
2716: {
2717: if ((*s_etat_processus).langue == 'F')
2718: {
2719: printf("+++Information : Option -%c inconnue\n",
2720: option);
2721: }
2722: else
2723: {
2724: printf("+++Warning : -%c option unknown\n",
2725: option);
2726: }
2727:
2728: informations(s_etat_processus);
2729: break;
2730: }
2731: }
2732: }
2733: }
2734: else
2735: {
2736: if (presence_definition == 'O')
2737: {
2738: argc = 0;
2739:
2740: if ((*s_etat_processus).langue == 'F')
2741: {
2742: printf("+++Erreur : Plusieurs définitions\n");
2743: }
2744: else
2745: {
2746: printf("+++Error : More than one definition\n");
2747: }
2748:
2749: erreur = d_erreur;
2750: }
2751: else
2752: {
2753: (*s_etat_processus).nom_fichier_source = argv[0];
2754: presence_definition = 'O';
2755: }
2756: }
2757: }
2758:
2759: /*
2760: * Dans le cas où le programme est appelé avec l'option -d,
2761: * on ne récupère par les signaux de violation d'accès. On
2762: * tente simplement la récupération des dépassements de pile.
2763: */
2764:
2765: if (debug == d_faux)
2766: {
2767: # ifdef HAVE_SIGSEGV_RECOVERY
2768: if (sigsegv_install_handler(interruption_violation_access) != 0)
2769: {
2770: # ifndef SEMAPHORES_NOMMES
2771: sem_post(&((*s_etat_processus).semaphore_fork));
2772: sem_destroy(&((*s_etat_processus)
2773: .semaphore_fork));
2774: # else
2775: sem_post((*s_etat_processus).semaphore_fork);
2776: sem_destroy3((*s_etat_processus).semaphore_fork,
2777: getpid(), pthread_self(), SEM_FORK);
2778: # endif
2779:
2780: liberation_contexte_cas(s_etat_processus);
2781: destruction_queue_signaux(s_etat_processus);
2782:
2783: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2784: stackoverflow_deinstall_handler();
2785: # endif
2786:
2787: erreur = d_es_signal;
2788:
2789: if ((*s_etat_processus).langue == 'F')
2790: {
2791: printf("+++Système : Initialisation de la pile alternative "
2792: "impossible\n");
2793: }
2794: else
2795: {
2796: printf("+++System : Initialization of alternate "
2797: "stack failed\n");
2798: }
2799:
2800: return(EXIT_FAILURE);
2801: }
2802: # else
2803: action.sa_handler = interruption3;
2804: action.sa_flags = 0;
2805:
2806: if (sigaction(SIGSEGV, &action, NULL) != 0)
2807: {
2808: # ifndef SEMAPHORES_NOMMES
2809: sem_post(&((*s_etat_processus).semaphore_fork));
2810: sem_destroy(&((*s_etat_processus)
2811: .semaphore_fork));
2812: # else
2813: sem_post((*s_etat_processus).semaphore_fork);
2814: sem_destroy3((*s_etat_processus).semaphore_fork,
2815: getpid(), pthread_self(), SEM_FORK);
2816: # endif
2817:
2818: liberation_contexte_cas(s_etat_processus);
2819: destruction_queue_signaux(s_etat_processus);
2820:
2821: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2822: stackoverflow_deinstall_handler();
2823: # endif
2824:
2825: if ((*s_etat_processus).langue == 'F')
2826: {
2827: printf("+++Système : Initialisation des signaux POSIX "
2828: "impossible\n");
2829: }
2830: else
2831: {
2832: printf("+++System : Initialization of POSIX signals "
2833: "failed\n");
2834: }
2835:
2836: return(EXIT_FAILURE);
2837: }
2838:
2839: signal_test = SIGTEST;
2840: raise(SIGSEGV);
2841:
2842: attente.tv_sec = 0;
2843: attente.tv_nsec = 1000000;
2844:
2845: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
2846: {
2847: nanosleep(&attente, NULL);
2848: }
2849:
2850: if (signal_test != SIGSEGV)
2851: {
2852: # ifndef SEMAPHORES_NOMMES
2853: sem_post(&((*s_etat_processus).semaphore_fork));
2854: sem_destroy(&((*s_etat_processus)
2855: .semaphore_fork));
2856: # else
2857: sem_post((*s_etat_processus).semaphore_fork);
2858: sem_destroy3((*s_etat_processus).semaphore_fork,
2859: getpid(), pthread_self(), SEM_FORK);
2860: # endif
2861:
2862: liberation_contexte_cas(s_etat_processus);
2863: destruction_queue_signaux(s_etat_processus);
2864:
2865: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2866: stackoverflow_deinstall_handler();
2867: # endif
2868:
2869: erreur = d_es_signal;
2870:
2871: if ((*s_etat_processus).langue == 'F')
2872: {
2873: printf("+++Système : Initialisation des signaux POSIX "
2874: "impossible\n");
2875: }
2876: else
2877: {
2878: printf("+++System : Initialization of POSIX signals "
2879: "failed\n");
2880: }
2881:
2882: return(EXIT_FAILURE);
2883: }
2884: # endif
2885:
2886: action.sa_handler = interruption3;
2887: action.sa_flags = 0;
2888:
2889: if (sigaction(SIGBUS, &action, NULL) != 0)
2890: {
2891: # ifndef SEMAPHORES_NOMMES
2892: sem_post(&((*s_etat_processus).semaphore_fork));
2893: sem_destroy(&((*s_etat_processus)
2894: .semaphore_fork));
2895: # else
2896: sem_post((*s_etat_processus).semaphore_fork);
2897: sem_destroy3((*s_etat_processus).semaphore_fork,
2898: getpid(), pthread_self(), SEM_FORK);
2899: # endif
2900:
2901: liberation_contexte_cas(s_etat_processus);
2902: destruction_queue_signaux(s_etat_processus);
2903:
2904: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2905: stackoverflow_deinstall_handler();
2906: # endif
2907:
2908: # ifdef HAVE_SIGSEGV_RECOVERY
2909: if (debug == d_faux)
2910: {
2911: sigsegv_deinstall_handler();
2912: }
2913: # endif
2914:
2915: if ((*s_etat_processus).langue == 'F')
2916: {
2917: printf("+++Système : Initialisation des signaux POSIX "
2918: "impossible\n");
2919: }
2920: else
2921: {
2922: printf("+++System : Initialization of POSIX signals "
2923: "failed\n");
2924: }
2925:
2926: return(EXIT_FAILURE);
2927: }
2928:
2929: signal_test = SIGTEST;
2930: raise(SIGBUS);
2931:
2932: attente.tv_sec = 0;
2933: attente.tv_nsec = 1000000;
2934:
2935: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
2936: {
2937: nanosleep(&attente, NULL);
2938: }
2939:
2940: if (signal_test != SIGBUS)
2941: {
2942: # ifndef SEMAPHORES_NOMMES
2943: sem_post(&((*s_etat_processus).semaphore_fork));
2944: sem_destroy(&((*s_etat_processus)
2945: .semaphore_fork));
2946: # else
2947: sem_post((*s_etat_processus).semaphore_fork);
2948: sem_destroy3((*s_etat_processus).semaphore_fork,
2949: getpid(), pthread_self(), SEM_FORK);
2950: # endif
2951:
2952: liberation_contexte_cas(s_etat_processus);
2953: destruction_queue_signaux(s_etat_processus);
2954:
2955: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2956: stackoverflow_deinstall_handler();
2957: # endif
2958:
2959: # ifdef HAVE_SIGSEGV_RECOVERY
2960: if (debug == d_faux)
2961: {
2962: sigsegv_deinstall_handler();
2963: }
2964: # endif
2965:
2966: erreur = d_es_signal;
2967:
2968: if ((*s_etat_processus).langue == 'F')
2969: {
2970: printf("+++Système : Initialisation des signaux POSIX "
2971: "impossible\n");
2972: }
2973: else
2974: {
2975: printf("+++System : Initialization of POSIX signals "
2976: "failed\n");
2977: }
2978:
2979: return(EXIT_FAILURE);
2980: }
2981:
2982: }
2983:
2984: if (option_n == d_vrai)
2985: {
2986: action.sa_handler = interruption4;
2987: action.sa_flags = 0;
2988:
2989: if (sigaction(SIGHUP, &action, NULL) != 0)
2990: {
2991: # ifndef SEMAPHORES_NOMMES
2992: sem_post(&((*s_etat_processus).semaphore_fork));
2993: sem_destroy(&((*s_etat_processus)
2994: .semaphore_fork));
2995: # else
2996: sem_post((*s_etat_processus).semaphore_fork);
2997: sem_destroy3((*s_etat_processus).semaphore_fork,
2998: getpid(), pthread_self(), SEM_FORK);
2999: # endif
3000:
3001: liberation_contexte_cas(s_etat_processus);
3002: destruction_queue_signaux(s_etat_processus);
3003:
3004: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3005: stackoverflow_deinstall_handler();
3006: # endif
3007:
3008: # ifdef HAVE_SIGSEGV_RECOVERY
3009: if (debug == d_faux)
3010: {
3011: sigsegv_deinstall_handler();
3012: }
3013: # endif
3014:
3015: if ((*s_etat_processus).langue == 'F')
3016: {
3017: printf("+++Système : Initialisation des signaux POSIX "
3018: "impossible\n");
3019: }
3020: else
3021: {
3022: printf("+++System : Initialization of POSIX signals "
3023: "failed\n");
3024: }
3025:
3026: return(EXIT_FAILURE);
3027: }
3028: }
3029:
3030: if (mode_interactif == d_vrai)
3031: {
3032: printf("\n");
3033:
3034: if ((*s_etat_processus).langue == 'F')
3035: {
3036: printf("+++Ce logiciel est un logiciel libre"
3037: " sans aucune garantie de "
3038: "fonctionnement.\n");
3039: printf("+++Pour plus de détails, utilisez la "
3040: "commande 'warranty'.\n");
3041: }
3042: else
3043: {
3044: printf("+++This is a free software with "
3045: "absolutely no warranty.\n");
3046: printf("+++For details, type 'warranty'.\n");
3047: }
3048:
3049: printf("\n");
3050:
3051: traitement_fichier_temporaire = 'Y';
3052:
3053: if ((nom_fichier_temporaire =
3054: creation_nom_fichier(s_etat_processus, (*s_etat_processus)
3055: .chemin_fichiers_temporaires)) == NULL)
3056: {
3057: # ifndef SEMAPHORES_NOMMES
3058: sem_post(&((*s_etat_processus).semaphore_fork));
3059: sem_destroy(&((*s_etat_processus)
3060: .semaphore_fork));
3061: # else
3062: sem_post((*s_etat_processus).semaphore_fork);
3063: sem_destroy3((*s_etat_processus).semaphore_fork,
3064: getpid(), pthread_self(), SEM_FORK);
3065: # endif
3066:
3067: liberation_contexte_cas(s_etat_processus);
3068: destruction_queue_signaux(s_etat_processus);
3069:
3070: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3071: stackoverflow_deinstall_handler();
3072: # endif
3073:
3074: # ifdef HAVE_SIGSEGV_RECOVERY
3075: if (debug == d_faux)
3076: {
3077: sigsegv_deinstall_handler();
3078: }
3079: # endif
3080:
3081: if ((*s_etat_processus).langue == 'F')
3082: {
3083: printf("+++Système : Fichier indisponible\n");
3084: }
3085: else
3086: {
3087: printf("+++System : File unavailable\n");
3088: }
3089:
3090: return(EXIT_FAILURE);
3091: }
3092:
3093: if ((f_source = fopen(nom_fichier_temporaire, "w"))
3094: == NULL)
3095: {
3096: # ifndef SEMAPHORES_NOMMES
3097: sem_post(&((*s_etat_processus).semaphore_fork));
3098: sem_destroy(&((*s_etat_processus)
3099: .semaphore_fork));
3100: # else
3101: sem_post((*s_etat_processus).semaphore_fork);
3102: sem_destroy3((*s_etat_processus).semaphore_fork,
3103: getpid(), pthread_self(), SEM_FORK);
3104: # endif
3105:
3106: liberation_contexte_cas(s_etat_processus);
3107: destruction_queue_signaux(s_etat_processus);
3108:
3109: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3110: stackoverflow_deinstall_handler();
3111: # endif
3112:
3113: # ifdef HAVE_SIGSEGV_RECOVERY
3114: if (debug == d_faux)
3115: {
3116: sigsegv_deinstall_handler();
3117: }
3118: # endif
3119:
3120: if ((*s_etat_processus).langue == 'F')
3121: {
3122: printf("+++Système : Fichier introuvable\n");
3123: }
3124: else
3125: {
3126: printf("+++System : File not found\n");
3127: }
3128:
3129: return(EXIT_FAILURE);
3130: }
3131:
3132: if (fprintf(f_source, "MODE_INTERACTIF\n") < 0)
3133: {
3134: # ifndef SEMAPHORES_NOMMES
3135: sem_post(&((*s_etat_processus).semaphore_fork));
3136: sem_destroy(&((*s_etat_processus)
3137: .semaphore_fork));
3138: # else
3139: sem_post((*s_etat_processus).semaphore_fork);
3140: sem_destroy3((*s_etat_processus).semaphore_fork,
3141: getpid(), pthread_self(), SEM_FORK);
3142: # endif
3143:
3144: liberation_contexte_cas(s_etat_processus);
3145: destruction_queue_signaux(s_etat_processus);
3146:
3147: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3148: stackoverflow_deinstall_handler();
3149: # endif
3150:
3151: # ifdef HAVE_SIGSEGV_RECOVERY
3152: if (debug == d_faux)
3153: {
3154: sigsegv_deinstall_handler();
3155: }
3156: # endif
3157:
3158: if ((*s_etat_processus).langue == 'F')
3159: {
3160: printf("+++Système : Erreur d'écriture dans un fichier\n");
3161: }
3162: else
3163: {
3164: printf("+++System : Cannot write in file\n");
3165: }
3166:
3167: return(EXIT_FAILURE);
3168: }
3169:
3170: if (fprintf(f_source,
3171: "<< DO HALT UNTIL FALSE END >>\n") < 0)
3172: {
3173: # ifndef SEMAPHORES_NOMMES
3174: sem_post(&((*s_etat_processus).semaphore_fork));
3175: sem_destroy(&((*s_etat_processus)
3176: .semaphore_fork));
3177: # else
3178: sem_post((*s_etat_processus).semaphore_fork);
3179: sem_destroy3((*s_etat_processus).semaphore_fork,
3180: getpid(), pthread_self(), SEM_FORK);
3181: # endif
3182:
3183: liberation_contexte_cas(s_etat_processus);
3184: destruction_queue_signaux(s_etat_processus);
3185:
3186: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3187: stackoverflow_deinstall_handler();
3188: # endif
3189:
3190: # ifdef HAVE_SIGSEGV_RECOVERY
3191: if (debug == d_faux)
3192: {
3193: sigsegv_deinstall_handler();
3194: }
3195: # endif
3196:
3197: if ((*s_etat_processus).langue == 'F')
3198: {
3199: printf("+++Système : Erreur d'écriture dans un fichier\n");
3200: }
3201: else
3202: {
3203: printf("+++System : Cannot write in file\n");
3204: }
3205:
3206: return(EXIT_FAILURE);
3207: }
3208:
3209: if (fclose(f_source) != 0)
3210: {
3211: # ifndef SEMAPHORES_NOMMES
3212: sem_post(&((*s_etat_processus).semaphore_fork));
3213: sem_destroy(&((*s_etat_processus)
3214: .semaphore_fork));
3215: # else
3216: sem_post((*s_etat_processus).semaphore_fork);
3217: sem_destroy3((*s_etat_processus).semaphore_fork,
3218: getpid(), pthread_self(), SEM_FORK);
3219: # endif
3220:
3221: liberation_contexte_cas(s_etat_processus);
3222: destruction_queue_signaux(s_etat_processus);
3223:
3224: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3225: stackoverflow_deinstall_handler();
3226: # endif
3227:
3228: # ifdef HAVE_SIGSEGV_RECOVERY
3229: if (debug == d_faux)
3230: {
3231: sigsegv_deinstall_handler();
3232: }
3233: # endif
3234:
3235: if ((*s_etat_processus).langue == 'F')
3236: {
3237: printf("+++Système : Fichier indisponible\n");
3238: }
3239: else
3240: {
3241: printf("+++System : File unavailable\n");
3242: }
3243:
3244: return(EXIT_FAILURE);
3245: }
3246:
3247: (*s_etat_processus).lancement_interactif = d_vrai;
3248: (*s_etat_processus).nom_fichier_source =
3249: nom_fichier_temporaire;
3250:
3251: presence_definition = 'O';
3252: }
3253: else
3254: {
3255: nom_fichier_temporaire = NULL;
3256: }
3257:
3258: if ((*s_etat_processus).nom_fichier_source == NULL)
3259: {
3260: erreur_fichier = d_erreur;
3261: }
3262: else
3263: {
3264: erreur_fichier = caracteristiques_fichier(s_etat_processus,
3265: (*s_etat_processus).nom_fichier_source,
3266: &existence, &ouverture, &unite_fichier);
3267: }
3268:
3269: if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
3270: (option_S == d_faux))
3271: {
3272: # ifndef SEMAPHORES_NOMMES
3273: sem_post(&((*s_etat_processus).semaphore_fork));
3274: sem_destroy(&((*s_etat_processus).semaphore_fork));
3275: # else
3276: sem_post((*s_etat_processus).semaphore_fork);
3277: sem_destroy3((*s_etat_processus).semaphore_fork,
3278: getpid(), pthread_self(), SEM_FORK);
3279: # endif
3280:
3281: liberation_contexte_cas(s_etat_processus);
3282: destruction_queue_signaux(s_etat_processus);
3283:
3284: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3285: stackoverflow_deinstall_handler();
3286: # endif
3287:
3288: # ifdef HAVE_SIGSEGV_RECOVERY
3289: if (debug == d_faux)
3290: {
3291: sigsegv_deinstall_handler();
3292: }
3293: # endif
3294:
3295: if (presence_definition == 'O')
3296: {
3297: if ((*s_etat_processus).langue == 'F')
3298: {
3299: printf("+++Erreur : Fichier %s inexistant\n",
3300: (*s_etat_processus).nom_fichier_source);
3301: }
3302: else
3303: {
3304: printf("+++Error : File %s not found\n",
3305: (*s_etat_processus).nom_fichier_source);
3306: }
3307:
3308: erreur = d_erreur;
3309: }
3310: else
3311: {
3312: if ((*s_etat_processus).langue == 'F')
3313: {
3314: printf("+++Erreur : Absence de définition à exécuter\n");
3315: }
3316: else
3317: {
3318: printf("+++Error : Any executable definition\n");
3319: }
3320: }
3321:
3322: return(EXIT_FAILURE);
3323: }
3324:
3325: if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
3326: {
3327: # ifndef SEMAPHORES_NOMMES
3328: sem_post(&((*s_etat_processus).semaphore_fork));
3329: sem_destroy(&((*s_etat_processus).semaphore_fork));
3330: # else
3331: sem_post((*s_etat_processus).semaphore_fork);
3332: sem_destroy3((*s_etat_processus).semaphore_fork,
3333: getpid(), pthread_self(), SEM_FORK);
3334: # endif
3335:
3336: liberation_contexte_cas(s_etat_processus);
3337: destruction_queue_signaux(s_etat_processus);
3338:
3339: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3340: stackoverflow_deinstall_handler();
3341: # endif
3342:
3343: # ifdef HAVE_SIGSEGV_RECOVERY
3344: if (debug == d_faux)
3345: {
3346: sigsegv_deinstall_handler();
3347: }
3348: # endif
3349:
3350: if ((*s_etat_processus).langue == 'F')
3351: {
3352: printf("+++Système : Chemin des fichiers temporaires nul\n");
3353: }
3354: else
3355: {
3356: printf("+++System : Null temporary files path\n");
3357: }
3358:
3359: return(EXIT_FAILURE);
3360: }
3361:
3362: if ((*s_etat_processus).debug == d_vrai)
3363: {
3364: if ((*s_etat_processus).langue == 'F')
3365: {
3366: printf("[%d] Chemin des fichiers temporaires %s\n\n",
3367: (int) getpid(),
3368: (*s_etat_processus).chemin_fichiers_temporaires);
3369: }
3370: else
3371: {
3372: printf("[%d] Temporary files path %s\n\n",
3373: (int) getpid(),
3374: (*s_etat_processus).chemin_fichiers_temporaires);
3375: }
3376: }
3377:
3378: if ((erreur == d_absence_erreur) && (presence_definition == 'O'))
3379: {
3380: (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
3381: (*s_etat_processus).niveau_profilage = option_P;
3382: (*s_etat_processus).pile_profilage = NULL;
3383: (*s_etat_processus).pile_profilage_fonctions = NULL;
3384: gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
3385:
3386: (*s_etat_processus).liste_mutexes = NULL;
3387: (*s_etat_processus).sections_critiques = 0;
3388: (*s_etat_processus).initialisation_scheduler = d_faux;
3389:
3390: (*s_etat_processus).test_instruction = 'N';
3391: (*s_etat_processus).nombre_arguments = 0;
3392: (*s_etat_processus).affichage_arguments = 'N';
3393: (*s_etat_processus).autorisation_conversion_chaine = 'Y';
3394: (*s_etat_processus).autorisation_evaluation_nom = 'Y';
3395:
3396: if (mode_interactif == d_vrai)
3397: {
3398: (*s_etat_processus).autorisation_nom_implicite = 'Y';
3399: }
3400: else
3401: {
3402: (*s_etat_processus).autorisation_nom_implicite = 'N';
3403: }
3404:
3405: (*s_etat_processus).autorisation_empilement_programme = 'N';
3406: (*s_etat_processus).requete_arret = 'N';
3407: (*s_etat_processus).evaluation_forcee = 'N';
3408: (*s_etat_processus).recherche_type = 'N';
3409:
3410: (*s_etat_processus).constante_symbolique = 'N';
3411: (*s_etat_processus).traitement_symbolique = 'N';
3412:
3413: (*s_etat_processus).expression_courante = NULL;
3414: (*s_etat_processus).objet_courant = NULL;
3415: (*s_etat_processus).evaluation_expression_compilee = 'N';
3416:
3417: (*s_etat_processus).l_base_pile = NULL;
3418: (*s_etat_processus).l_base_pile_last = NULL;
3419:
3420: (*s_etat_processus).s_arbre_variables = NULL;
3421: (*s_etat_processus).l_liste_variables_par_niveau = NULL;
3422: (*s_etat_processus).l_liste_variables_statiques = NULL;
3423: (*s_etat_processus).gel_liste_variables = d_faux;
3424: s_arbre_variables_partagees = NULL;
3425: l_liste_variables_partagees = NULL;
3426: (*s_etat_processus).s_arbre_variables_partagees =
3427: &s_arbre_variables_partagees;
3428: (*s_etat_processus).l_liste_variables_partagees =
3429: &l_liste_variables_partagees;
3430: (*s_etat_processus).pointeur_variable_courante = NULL;
3431: (*s_etat_processus).pointeur_variable_statique_courante = NULL;
3432: (*s_etat_processus).pointeur_variable_partagee_courante = NULL;
3433: (*s_etat_processus).niveau_courant = 0;
3434: (*s_etat_processus).niveau_initial = 0;
3435: (*s_etat_processus).creation_variables_statiques = d_faux;
3436: (*s_etat_processus).creation_variables_partagees = d_faux;
3437:
3438: (*s_etat_processus).s_bibliotheques = NULL;
3439: (*s_etat_processus).s_instructions_externes = NULL;
3440: (*s_etat_processus).nombre_instructions_externes = 0;
3441:
3442: (*s_etat_processus).systeme_axes = 0;
3443:
3444: (*s_etat_processus).x_min = -10.;
3445: (*s_etat_processus).x_max = 10.;
3446: (*s_etat_processus).y_min = -10.;
3447: (*s_etat_processus).y_max = 10.;
3448: (*s_etat_processus).z_min = -10.;
3449: (*s_etat_processus).z_max = 10.;
3450:
3451: (*s_etat_processus).x2_min = -10.;
3452: (*s_etat_processus).x2_max = 10.;
3453: (*s_etat_processus).y2_min = -10.;
3454: (*s_etat_processus).y2_max = 10.;
3455: (*s_etat_processus).z2_min = -10.;
3456: (*s_etat_processus).z2_max = 10.;
3457:
3458: (*s_etat_processus).resolution = .01;
3459:
3460: (*s_etat_processus).souris_active = d_faux;
3461:
3462: (*s_etat_processus).echelle_automatique_x = d_faux;
3463: (*s_etat_processus).echelle_automatique_y = d_faux;
3464: (*s_etat_processus).echelle_automatique_z = d_faux;
3465:
3466: (*s_etat_processus).echelle_automatique_x2 = d_faux;
3467: (*s_etat_processus).echelle_automatique_y2 = d_faux;
3468: (*s_etat_processus).echelle_automatique_z2 = d_faux;
3469:
3470: (*s_etat_processus).echelle_log_x = d_faux;
3471: (*s_etat_processus).echelle_log_y = d_faux;
3472: (*s_etat_processus).echelle_log_z = d_faux;
3473:
3474: (*s_etat_processus).echelle_log_x2 = d_faux;
3475: (*s_etat_processus).echelle_log_y2 = d_faux;
3476: (*s_etat_processus).echelle_log_z2 = d_faux;
3477:
3478: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
3479: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
3480: (*s_etat_processus).echelle_3D = 1;
3481:
3482: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
3483: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
3484: (*s_etat_processus).fichiers_graphiques = NULL;
3485: (*s_etat_processus).nom_fichier_impression = NULL;
3486: strcpy((*s_etat_processus).format_papier, "a4paper");
3487: (*s_etat_processus).entree_standard = NULL;
3488: (*s_etat_processus).s_marques = NULL;
3489: (*s_etat_processus).requete_nouveau_plan = d_vrai;
3490: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
3491:
3492: (*s_etat_processus).l_base_pile = NULL;
3493: (*s_etat_processus).hauteur_pile_operationnelle = 0;
3494: (*s_etat_processus).l_base_pile_contextes = NULL;
3495: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
3496:
3497: (*s_etat_processus).position_courante = 0;
3498:
3499: (*s_etat_processus).l_base_pile_systeme = NULL;
3500: (*s_etat_processus).hauteur_pile_systeme = 0;
3501:
3502: (*s_etat_processus).l_base_pile_processus = NULL;
3503: (*s_etat_processus).presence_pipes = d_faux;
3504: (*s_etat_processus).pipe_donnees = 0;
3505: (*s_etat_processus).pipe_acquittement = 0;
3506: (*s_etat_processus).pipe_injections = 0;
3507: (*s_etat_processus).pipe_nombre_injections = 0;
3508: (*s_etat_processus).nombre_objets_injectes = 0;
3509: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
3510: (*s_etat_processus).pourcentage_maximal_cpu = 100;
3511: (*s_etat_processus).temps_maximal_cpu = 0;
3512: (*s_etat_processus).thread_fusible = 0;
3513: (*s_etat_processus).presence_fusible = d_faux;
3514:
3515: (*s_etat_processus).niveau_recursivite = 0;
3516: (*s_etat_processus).generateur_aleatoire = NULL;
3517: (*s_etat_processus).type_generateur_aleatoire = NULL;
3518:
3519: (*s_etat_processus).colonne_statistique_1 = 1;
3520: (*s_etat_processus).colonne_statistique_2 = 2;
3521:
3522: (*s_etat_processus).debug_programme = d_faux;
3523: (*s_etat_processus).execution_pas_suivant = d_faux;
3524: (*s_etat_processus).traitement_instruction_halt = d_faux;
3525:
3526: (*s_etat_processus).derniere_exception = d_ep;
3527: (*s_etat_processus).derniere_erreur_systeme = d_es;
3528: (*s_etat_processus).derniere_erreur_execution = d_ex;
3529: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
3530: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
3531:
3532: (*s_etat_processus).erreur_processus_fils = d_faux;
3533: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
3534: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
3535: (*s_etat_processus).pid_erreur_processus_fils = 0;
3536: (*s_etat_processus).exception_processus_fils = d_ep;
3537: (*s_etat_processus).core = core;
3538: (*s_etat_processus).invalidation_message_erreur = d_faux;
3539: (*s_etat_processus).s_objet_errone = NULL;
3540: (*s_etat_processus).s_objet_erreur = NULL;
3541:
3542: (*s_etat_processus).retour_routine_evaluation = 'N';
3543:
3544: (*s_etat_processus).traitement_interruption = 'N';
3545: (*s_etat_processus).traitement_interruptible = 'Y';
3546: (*s_etat_processus).nombre_interruptions_en_queue = 0;
3547: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
3548:
3549: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
3550: {
3551: (*s_etat_processus).masque_interruptions[i] = 'N';
3552: (*s_etat_processus).queue_interruptions[i] = 0;
3553: (*s_etat_processus).corps_interruptions[i] = NULL;
3554: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
3555: }
3556:
3557: (*s_etat_processus).at_exit = NULL;
3558: (*s_etat_processus).at_poke = NULL;
3559: (*s_etat_processus).traitement_at_poke = 'N';
3560:
3561: (*s_etat_processus).pointeurs_caracteres = NULL;
3562: (*s_etat_processus).arbre_instructions = NULL;
3563:
3564: (*s_etat_processus).tid_processus_pere = pthread_self();
3565: (*s_etat_processus).tid = pthread_self();
3566: (*s_etat_processus).pid_processus_pere = getpid();
3567: (*s_etat_processus).processus_detache = d_vrai;
3568: (*s_etat_processus).var_volatile_processus_pere = -1;
3569: (*s_etat_processus).var_volatile_processus_racine = -1;
3570: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
3571: (*s_etat_processus).var_volatile_alarme = 0;
3572: (*s_etat_processus).var_volatile_requete_arret = 0;
3573: (*s_etat_processus).var_volatile_requete_arret2 = 0;
3574: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
3575: (*s_etat_processus).var_volatile_traitement_sigint = 0;
3576: (*s_etat_processus).var_volatile_recursivite = 0;
3577: (*s_etat_processus).var_volatile_exception_gsl = 0;
3578: (*s_etat_processus).arret_depuis_abort = 0;
3579: (*s_etat_processus).pointeur_signal_lecture = 0;
3580: (*s_etat_processus).pointeur_signal_ecriture = 0;
3581:
3582: initialisation_allocateur(s_etat_processus);
3583: initialisation_drapeaux(s_etat_processus);
3584: initialisation_variables(s_etat_processus);
3585: initialisation_instructions(s_etat_processus);
3586:
3587: if ((*s_etat_processus).erreur_systeme != d_es)
3588: {
3589: # ifndef SEMAPHORES_NOMMES
3590: sem_post(&((*s_etat_processus).semaphore_fork));
3591: sem_destroy(&((*s_etat_processus).semaphore_fork));
3592: # else
3593: sem_post((*s_etat_processus).semaphore_fork);
3594: sem_destroy3((*s_etat_processus).semaphore_fork,
3595: getpid(), pthread_self(), SEM_FORK);
3596: # endif
3597:
3598: liberation_contexte_cas(s_etat_processus);
3599: destruction_queue_signaux(s_etat_processus);
3600:
3601: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3602: stackoverflow_deinstall_handler();
3603: # endif
3604:
3605: # ifdef HAVE_SIGSEGV_RECOVERY
3606: if (debug == d_faux)
3607: {
3608: sigsegv_deinstall_handler();
3609: }
3610: # endif
3611:
3612: if ((*s_etat_processus).langue == 'F')
3613: {
3614: printf("+++Système : Mémoire insuffisante\n");
3615: }
3616: else
3617: {
3618: printf("+++System : Not enough memory\n");
3619: }
3620:
3621: return(EXIT_FAILURE);
3622: }
3623:
3624: if (((*s_etat_processus).instruction_derniere_erreur =
3625: malloc(sizeof(unsigned char))) == NULL)
3626: {
3627: # ifndef SEMAPHORES_NOMMES
3628: sem_post(&((*s_etat_processus).semaphore_fork));
3629: sem_destroy(&((*s_etat_processus).semaphore_fork));
3630: # else
3631: sem_post((*s_etat_processus).semaphore_fork);
3632: sem_destroy3((*s_etat_processus).semaphore_fork,
3633: getpid(), pthread_self(), SEM_FORK);
3634: # endif
3635:
3636: liberation_contexte_cas(s_etat_processus);
3637: destruction_queue_signaux(s_etat_processus);
3638:
3639: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3640: stackoverflow_deinstall_handler();
3641: # endif
3642:
3643: # ifdef HAVE_SIGSEGV_RECOVERY
3644: if (debug == d_faux)
3645: {
3646: sigsegv_deinstall_handler();
3647: }
3648: # endif
3649:
3650: erreur = d_es_allocation_memoire;
3651:
3652: if ((*s_etat_processus).langue == 'F')
3653: {
3654: printf("+++Système : Mémoire insuffisante\n");
3655: }
3656: else
3657: {
3658: printf("+++System : Not enough memory\n");
3659: }
3660:
3661: return(EXIT_FAILURE);
3662: }
3663:
3664: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
3665: (*s_etat_processus).niveau_derniere_erreur = 0;
3666:
3667: if (traitement_fichier_temporaire == 'Y')
3668: {
3669: (*s_etat_processus).mode_interactif = 'Y';
3670: }
3671: else
3672: {
3673: (*s_etat_processus).mode_interactif = 'N';
3674: }
3675:
3676: if (((*s_etat_processus).instruction_courante = (unsigned char *)
3677: malloc(sizeof(unsigned char))) == NULL)
3678: {
3679: # ifndef SEMAPHORES_NOMMES
3680: sem_post(&((*s_etat_processus).semaphore_fork));
3681: sem_destroy(&((*s_etat_processus).semaphore_fork));
3682: # else
3683: sem_post((*s_etat_processus).semaphore_fork);
3684: sem_destroy3((*s_etat_processus).semaphore_fork,
3685: getpid(), pthread_self(), SEM_FORK);
3686: # endif
3687:
3688: liberation_contexte_cas(s_etat_processus);
3689: destruction_queue_signaux(s_etat_processus);
3690:
3691: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3692: stackoverflow_deinstall_handler();
3693: # endif
3694:
3695: # ifdef HAVE_SIGSEGV_RECOVERY
3696: if (debug == d_faux)
3697: {
3698: sigsegv_deinstall_handler();
3699: }
3700: # endif
3701:
3702: erreur = d_es_allocation_memoire;
3703:
3704: if ((*s_etat_processus).langue == 'F')
3705: {
3706: printf("+++Système : Mémoire insuffisante\n");
3707: }
3708: else
3709: {
3710: printf("+++System : Not enough memory\n");
3711: }
3712:
3713: return(EXIT_FAILURE);
3714: }
3715:
3716: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
3717:
3718: empilement_pile_systeme(s_etat_processus);
3719:
3720: free((*s_etat_processus).instruction_courante);
3721:
3722: if ((*s_etat_processus).erreur_systeme != d_es)
3723: {
3724: erreur = d_es_allocation_memoire;
3725: }
3726: else
3727: {
3728: (*((*s_etat_processus).l_base_pile_systeme))
3729: .retour_definition = 'Y';
3730:
3731: (*s_etat_processus).indep = allocation(s_etat_processus, NON);
3732: (*s_etat_processus).depend = allocation(s_etat_processus, NON);
3733: (*s_etat_processus).parametres_courbes_de_niveau =
3734: allocation(s_etat_processus, NON);
3735:
3736: if (((*s_etat_processus).indep != NULL) &&
3737: ((*s_etat_processus).depend != NULL) &&
3738: ((*s_etat_processus).parametres_courbes_de_niveau
3739: != NULL))
3740: {
3741: (*((*s_etat_processus).indep)).type = NOM;
3742: (*((*s_etat_processus).depend)).type = NOM;
3743: (*((*s_etat_processus).
3744: parametres_courbes_de_niveau)).type = LST;
3745:
3746: initialisation_objet((*s_etat_processus).indep);
3747: initialisation_objet((*s_etat_processus).depend);
3748: initialisation_objet((*s_etat_processus)
3749: .parametres_courbes_de_niveau);
3750:
3751: (*((*s_etat_processus).indep)).objet = (struct_nom *)
3752: malloc(sizeof(struct_nom));
3753: (*((*s_etat_processus).depend)).objet = (struct_nom *)
3754: malloc(sizeof(struct_nom));
3755: (*((*s_etat_processus).parametres_courbes_de_niveau))
3756: .objet = (struct_liste_chainee *)
3757: malloc(sizeof(struct_liste_chainee));
3758:
3759: if (((*((*s_etat_processus).depend)).objet == NULL) ||
3760: ((*((*s_etat_processus).depend)).objet == NULL) ||
3761: ((*((*s_etat_processus).
3762: parametres_courbes_de_niveau)).objet == NULL))
3763: {
3764: # ifndef SEMAPHORES_NOMMES
3765: sem_post(&((*s_etat_processus).semaphore_fork));
3766: sem_destroy(&((*s_etat_processus).semaphore_fork));
3767: # else
3768: sem_post((*s_etat_processus).semaphore_fork);
3769: sem_destroy3((*s_etat_processus).semaphore_fork,
3770: getpid(), pthread_self(), SEM_FORK);
3771: # endif
3772:
3773: liberation_contexte_cas(s_etat_processus);
3774: destruction_queue_signaux(s_etat_processus);
3775:
3776: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3777: stackoverflow_deinstall_handler();
3778: # endif
3779:
3780: # ifdef HAVE_SIGSEGV_RECOVERY
3781: if (debug == d_faux)
3782: {
3783: sigsegv_deinstall_handler();
3784: }
3785: # endif
3786:
3787: erreur = d_es_allocation_memoire;
3788:
3789: if ((*s_etat_processus).langue == 'F')
3790: {
3791: printf("+++Système : Mémoire insuffisante\n");
3792: }
3793: else
3794: {
3795: printf("+++System : Not enough memory\n");
3796: }
3797:
3798: return(EXIT_FAILURE);
3799: }
3800:
3801: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
3802: .nom = malloc(2 * sizeof(unsigned char));
3803: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
3804: .nom = malloc(2 * sizeof(unsigned char));
3805:
3806: if (((*((struct_nom *) (*((*s_etat_processus).indep))
3807: .objet)).nom == NULL) || ((*((struct_nom *)
3808: (*((*s_etat_processus).depend)).objet)).nom ==
3809: NULL))
3810: {
3811: # ifndef SEMAPHORES_NOMMES
3812: sem_post(&((*s_etat_processus).semaphore_fork));
3813: sem_destroy(&((*s_etat_processus).semaphore_fork));
3814: # else
3815: sem_post((*s_etat_processus).semaphore_fork);
3816: sem_destroy3((*s_etat_processus).semaphore_fork,
3817: getpid(), pthread_self(), SEM_FORK);
3818: # endif
3819:
3820: liberation_contexte_cas(s_etat_processus);
3821: destruction_queue_signaux(s_etat_processus);
3822:
3823: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3824: stackoverflow_deinstall_handler();
3825: # endif
3826:
3827: # ifdef HAVE_SIGSEGV_RECOVERY
3828: if (debug == d_faux)
3829: {
3830: sigsegv_deinstall_handler();
3831: }
3832: # endif
3833:
3834: erreur = d_es_allocation_memoire;
3835:
3836: if ((*s_etat_processus).langue == 'F')
3837: {
3838: printf("+++Système : Mémoire insuffisante\n");
3839: }
3840: else
3841: {
3842: printf("+++System : Not enough memory\n");
3843: }
3844:
3845: return(EXIT_FAILURE);
3846: }
3847:
3848: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
3849: .objet)).nom, "X");
3850: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
3851: .objet)).nom, "Y");
3852:
3853: (*((struct_nom *) (*((*s_etat_processus).indep))
3854: .objet)).symbole = d_vrai;
3855: (*((struct_nom *) (*((*s_etat_processus).depend))
3856: .objet)).symbole = d_vrai;
3857:
3858: (*((struct_liste_chainee *) (*((*s_etat_processus)
3859: .parametres_courbes_de_niveau)).objet)).suivant
3860: = NULL;
3861:
3862: (*((struct_liste_chainee *) (*((*s_etat_processus)
3863: .parametres_courbes_de_niveau)).objet)).donnee
3864: = malloc(sizeof(struct_objet));
3865:
3866: (*s_etat_processus).legende =
3867: malloc(sizeof(unsigned char));
3868: (*s_etat_processus).label_x =
3869: malloc(sizeof(unsigned char));
3870: (*s_etat_processus).label_y =
3871: malloc(sizeof(unsigned char));
3872: (*s_etat_processus).label_z =
3873: malloc(sizeof(unsigned char));
3874: (*s_etat_processus).titre =
3875: malloc(sizeof(unsigned char));
3876:
3877: if (((*s_etat_processus).label_x == NULL) ||
3878: ((*s_etat_processus).label_y == NULL) ||
3879: ((*s_etat_processus).label_z == NULL) ||
3880: ((*s_etat_processus).titre == NULL) ||
3881: ((*s_etat_processus).legende == NULL) ||
3882: ((*((struct_liste_chainee *) (*((*s_etat_processus)
3883: .parametres_courbes_de_niveau)).objet)).donnee
3884: == NULL))
3885: {
3886: # ifndef SEMAPHORES_NOMMES
3887: sem_post(&((*s_etat_processus).semaphore_fork));
3888: sem_destroy(&((*s_etat_processus).semaphore_fork));
3889: # else
3890: sem_post((*s_etat_processus).semaphore_fork);
3891: sem_destroy3((*s_etat_processus).semaphore_fork,
3892: getpid(), pthread_self(), SEM_FORK);
3893: # endif
3894:
3895: liberation_contexte_cas(s_etat_processus);
3896: destruction_queue_signaux(s_etat_processus);
3897:
3898: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3899: stackoverflow_deinstall_handler();
3900: # endif
3901:
3902: # ifdef HAVE_SIGSEGV_RECOVERY
3903: if (debug == d_faux)
3904: {
3905: sigsegv_deinstall_handler();
3906: }
3907: # endif
3908:
3909: erreur = d_es_allocation_memoire;
3910:
3911: if ((*s_etat_processus).langue == 'F')
3912: {
3913: printf("+++Système : Mémoire insuffisante\n");
3914: }
3915: else
3916: {
3917: printf("+++System : Not enough memory\n");
3918: }
3919:
3920: return(EXIT_FAILURE);
3921: }
3922:
3923: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
3924: .parametres_courbes_de_niveau)).objet)).donnee)
3925: .type = CHN;
3926:
3927: initialisation_objet((*((struct_liste_chainee *)
3928: (*((*s_etat_processus)
3929: .parametres_courbes_de_niveau))
3930: .objet)).donnee);
3931:
3932: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
3933: .parametres_courbes_de_niveau)).objet)).donnee)
3934: .objet = malloc(10 * sizeof(unsigned char)))
3935: == NULL)
3936: {
3937: # ifndef SEMAPHORES_NOMMES
3938: sem_post(&((*s_etat_processus).semaphore_fork));
3939: sem_destroy(&((*s_etat_processus).semaphore_fork));
3940: # else
3941: sem_post((*s_etat_processus).semaphore_fork);
3942: sem_destroy3((*s_etat_processus).semaphore_fork,
3943: getpid(), pthread_self(), SEM_FORK);
3944: # endif
3945:
3946: liberation_contexte_cas(s_etat_processus);
3947: destruction_queue_signaux(s_etat_processus);
3948:
3949: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3950: stackoverflow_deinstall_handler();
3951: # endif
3952:
3953: # ifdef HAVE_SIGSEGV_RECOVERY
3954: if (debug == d_faux)
3955: {
3956: sigsegv_deinstall_handler();
3957: }
3958: # endif
3959:
3960: erreur = d_es_allocation_memoire;
3961:
3962: if ((*s_etat_processus).langue == 'F')
3963: {
3964: printf("+++Système : Mémoire insuffisante\n");
3965: }
3966: else
3967: {
3968: printf("+++System : Not enough memory\n");
3969: }
3970:
3971: return(EXIT_FAILURE);
3972: }
3973:
3974: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
3975: (*((*s_etat_processus)
3976: .parametres_courbes_de_niveau))
3977: .objet)).donnee).objet, "AUTOMATIC");
3978:
3979: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
3980: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
3981: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
3982: (*s_etat_processus).titre[0] = d_code_fin_chaine;
3983: (*s_etat_processus).legende[0] = d_code_fin_chaine;
3984:
3985: (*s_etat_processus).nom_fichier_gnuplot = NULL;
3986: (*s_etat_processus).type_fichier_gnuplot = NULL;
3987:
3988: (*s_etat_processus).x_tics = 0;
3989: (*s_etat_processus).y_tics = 0;
3990: (*s_etat_processus).z_tics = 0;
3991:
3992: (*s_etat_processus).x_lines = d_vrai;
3993: (*s_etat_processus).y_lines = d_vrai;
3994: (*s_etat_processus).z_lines = d_vrai;
3995:
3996: (*s_etat_processus).mx_tics = -1;
3997: (*s_etat_processus).my_tics = -1;
3998: (*s_etat_processus).mz_tics = -1;
3999:
4000: (*s_etat_processus).mx_lines = d_faux;
4001: (*s_etat_processus).my_lines = d_faux;
4002: (*s_etat_processus).mz_lines = d_faux;
4003:
4004: (*s_etat_processus).x2_tics = -1;
4005: (*s_etat_processus).y2_tics = -1;
4006: (*s_etat_processus).z2_tics = -1;
4007:
4008: (*s_etat_processus).x2_lines = d_faux;
4009: (*s_etat_processus).y2_lines = d_faux;
4010: (*s_etat_processus).z2_lines = d_faux;
4011:
4012: (*s_etat_processus).mx2_tics = -1;
4013: (*s_etat_processus).my2_tics = -1;
4014: (*s_etat_processus).mz2_tics = -1;
4015:
4016: (*s_etat_processus).mx2_lines = d_faux;
4017: (*s_etat_processus).my2_lines = d_faux;
4018: (*s_etat_processus).mz2_lines = d_faux;
4019:
4020: (*s_etat_processus).mode_evaluation_expression = 'N';
4021: (*s_etat_processus).mode_execution_programme = 'Y';
4022:
4023: if ((*s_etat_processus).definitions_chainees == NULL)
4024: {
4025: if ((erreur = chainage(s_etat_processus)) !=
4026: d_absence_erreur)
4027: {
4028: # ifndef SEMAPHORES_NOMMES
4029: sem_post(&((*s_etat_processus).semaphore_fork));
4030: sem_destroy(&((*s_etat_processus)
4031: .semaphore_fork));
4032: # else
4033: sem_post((*s_etat_processus).semaphore_fork);
4034: sem_destroy3((*s_etat_processus).semaphore_fork,
4035: getpid(), pthread_self(), SEM_FORK);
4036: # endif
4037:
4038: liberation_contexte_cas(s_etat_processus);
4039: destruction_queue_signaux(s_etat_processus);
4040:
4041: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4042: stackoverflow_deinstall_handler();
4043: # endif
4044:
4045: # ifdef HAVE_SIGSEGV_RECOVERY
4046: if (debug == d_faux)
4047: {
4048: sigsegv_deinstall_handler();
4049: }
4050: # endif
4051:
4052: if ((*s_etat_processus).langue == 'F')
4053: {
4054: printf("+++Fatal :"
4055: " Chaînage des définitions"
4056: " impossible\n");
4057: }
4058: else
4059: {
4060: printf("+++Fatal : Error in "
4061: "compilation\n");
4062: }
4063:
4064: if (traitement_fichier_temporaire == 'Y')
4065: {
4066: if (destruction_fichier(
4067: nom_fichier_temporaire)
4068: == d_erreur)
4069: {
4070: return(EXIT_FAILURE);
4071: }
4072:
4073: free(nom_fichier_temporaire);
4074: }
4075:
4076: return(EXIT_FAILURE);
4077: }
4078: }
4079:
4080: /*
4081: * Chargement des bibliothèques pour gérer des
4082: * types externes lors des l'analyse syntaxique et
4083: * compilation.
4084: */
4085:
4086: l_bibliotheque_courante = l_bibliotheques;
4087:
4088: while(l_bibliotheque_courante != NULL)
4089: {
4090: if (empilement(s_etat_processus, &((*s_etat_processus)
4091: .l_base_pile), (*l_bibliotheque_courante)
4092: .donnee) == d_erreur)
4093: {
4094: # ifndef SEMAPHORES_NOMMES
4095: sem_post(&((*s_etat_processus).semaphore_fork));
4096: sem_destroy(&((*s_etat_processus)
4097: .semaphore_fork));
4098: # else
4099: sem_post((*s_etat_processus).semaphore_fork);
4100: sem_destroy3((*s_etat_processus).semaphore_fork,
4101: getpid(), pthread_self(), SEM_FORK);
4102: # endif
4103:
4104: liberation_contexte_cas(s_etat_processus);
4105: destruction_queue_signaux(s_etat_processus);
4106:
4107: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4108: stackoverflow_deinstall_handler();
4109: # endif
4110:
4111: # ifdef HAVE_SIGSEGV_RECOVERY
4112: if (debug == d_faux)
4113: {
4114: sigsegv_deinstall_handler();
4115: }
4116: # endif
4117:
4118: if ((*s_etat_processus).langue == 'F')
4119: {
4120: printf("+++Fatal :"
4121: " Chargement de la bibliothèse %s"
4122: " impossible\n", (unsigned char *)
4123: (*(*l_bibliotheque_courante).donnee)
4124: .objet);
4125: }
4126: else
4127: {
4128: printf("+++Fatal : Cannot load library %s\n",
4129: (*(*l_bibliotheque_courante).donnee)
4130: .objet);
4131: }
4132:
4133: if (traitement_fichier_temporaire == 'Y')
4134: {
4135: if (destruction_fichier(
4136: nom_fichier_temporaire)
4137: == d_erreur)
4138: {
4139: return(EXIT_FAILURE);
4140: }
4141:
4142: free(nom_fichier_temporaire);
4143: }
4144:
4145: return(EXIT_FAILURE);
4146: }
4147:
4148: instruction_use(s_etat_processus);
4149:
4150: if (depilement(s_etat_processus, &((*s_etat_processus)
4151: .l_base_pile), &((*l_bibliotheque_courante)
4152: .donnee)) == d_erreur)
4153: {
4154: # ifndef SEMAPHORES_NOMMES
4155: sem_post(&((*s_etat_processus).semaphore_fork));
4156: sem_destroy(&((*s_etat_processus)
4157: .semaphore_fork));
4158: # else
4159: sem_post((*s_etat_processus).semaphore_fork);
4160: sem_destroy3((*s_etat_processus).semaphore_fork,
4161: getpid(), pthread_self(), SEM_FORK);
4162: # endif
4163:
4164: liberation_contexte_cas(s_etat_processus);
4165: destruction_queue_signaux(s_etat_processus);
4166:
4167: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4168: stackoverflow_deinstall_handler();
4169: # endif
4170:
4171: # ifdef HAVE_SIGSEGV_RECOVERY
4172: if (debug == d_faux)
4173: {
4174: sigsegv_deinstall_handler();
4175: }
4176: # endif
4177:
4178: if ((*s_etat_processus).langue == 'F')
4179: {
4180: printf("+++Fatal :"
4181: " Chargement de la bibliothèse %s"
4182: " impossible\n", (unsigned char *)
4183: (*(*l_bibliotheque_courante).donnee)
4184: .objet);
4185: }
4186: else
4187: {
4188: printf("+++Fatal : Cannot load library %s\n",
4189: (*(*l_bibliotheque_courante).donnee)
4190: .objet);
4191: }
4192:
4193: if (traitement_fichier_temporaire == 'Y')
4194: {
4195: if (destruction_fichier(
4196: nom_fichier_temporaire)
4197: == d_erreur)
4198: {
4199: return(EXIT_FAILURE);
4200: }
4201:
4202: free(nom_fichier_temporaire);
4203: }
4204:
4205: return(EXIT_FAILURE);
4206: }
4207:
4208: l_bibliotheque_courante =
4209: (*l_bibliotheque_courante).suivant;
4210: }
4211:
4212: if ((erreur = compilation(s_etat_processus)) !=
4213: d_absence_erreur)
4214: {
4215: # ifndef SEMAPHORES_NOMMES
4216: sem_post(&((*s_etat_processus).semaphore_fork));
4217: sem_destroy(&((*s_etat_processus).semaphore_fork));
4218: # else
4219: sem_post((*s_etat_processus).semaphore_fork);
4220: sem_destroy3((*s_etat_processus).semaphore_fork,
4221: getpid(), pthread_self(), SEM_FORK);
4222: # endif
4223:
4224: liberation_contexte_cas(s_etat_processus);
4225: destruction_queue_signaux(s_etat_processus);
4226:
4227: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4228: stackoverflow_deinstall_handler();
4229: # endif
4230:
4231: # ifdef HAVE_SIGSEGV_RECOVERY
4232: if (debug == d_faux)
4233: {
4234: sigsegv_deinstall_handler();
4235: }
4236: # endif
4237:
4238: if (traitement_fichier_temporaire == 'Y')
4239: {
4240: if (destruction_fichier(nom_fichier_temporaire)
4241: == d_erreur)
4242: {
4243: return(EXIT_FAILURE);
4244: }
4245:
4246: free(nom_fichier_temporaire);
4247: }
4248:
4249: printf("%s [%d]\n", message =
4250: messages(s_etat_processus), (int) getpid());
4251: free(message);
4252:
4253: if (test_cfsf(s_etat_processus, 51) == d_faux)
4254: {
4255: printf("%s", ds_beep);
4256: }
4257:
4258: if ((*s_etat_processus).core == d_vrai)
4259: {
4260: printf("\n");
4261:
4262: if ((*s_etat_processus).langue == 'F')
4263: {
4264: printf("+++Information : Génération du fichier "
4265: "rpl-core [%d]\n", (int) getpid());
4266: }
4267: else
4268: {
4269: printf("+++Information : Writing rpl-core "
4270: "file [%d]\n", (int) getpid());
4271: }
4272:
4273: rplcore(s_etat_processus);
4274:
4275: if ((*s_etat_processus).langue == 'F')
4276: {
4277: printf("+++Information : Processus tracé "
4278: "[%d]\n", (int) getpid());
4279: }
4280: else
4281: {
4282: printf("+++Information : Done [%d]\n",
4283: (int) getpid());
4284: }
4285:
4286: printf("\n");
4287: }
4288:
4289: return(EXIT_FAILURE);
4290: }
4291:
4292: (*s_etat_processus).position_courante = 0;
4293: (*s_etat_processus).traitement_cycle_exit = 'N';
4294:
4295: if ((*s_etat_processus).s_arbre_variables == NULL)
4296: {
4297: # ifndef SEMAPHORES_NOMMES
4298: sem_post(&((*s_etat_processus).semaphore_fork));
4299: sem_destroy(&((*s_etat_processus).semaphore_fork));
4300: # else
4301: sem_post((*s_etat_processus).semaphore_fork);
4302: sem_destroy3((*s_etat_processus).semaphore_fork,
4303: getpid(), pthread_self(), SEM_FORK);
4304: # endif
4305:
4306: liberation_contexte_cas(s_etat_processus);
4307: destruction_queue_signaux(s_etat_processus);
4308:
4309: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4310: stackoverflow_deinstall_handler();
4311: # endif
4312:
4313: # ifdef HAVE_SIGSEGV_RECOVERY
4314: if (debug == d_faux)
4315: {
4316: sigsegv_deinstall_handler();
4317: }
4318: # endif
4319:
4320: if ((*s_etat_processus).langue == 'F')
4321: {
4322: printf("+++Fatal : Aucun point d'entrée\n");
4323: }
4324: else
4325: {
4326: printf("+++Fatal : Any entry point\n");
4327: }
4328:
4329: if (test_cfsf(s_etat_processus, 51) == d_faux)
4330: {
4331: printf("%s", ds_beep);
4332: }
4333:
4334: return(EXIT_FAILURE);
4335: }
4336:
4337: if (recherche_instruction_suivante(s_etat_processus)
4338: == d_erreur)
4339: {
4340: # ifndef SEMAPHORES_NOMMES
4341: sem_post(&((*s_etat_processus).semaphore_fork));
4342: sem_destroy(&((*s_etat_processus).semaphore_fork));
4343: # else
4344: sem_post((*s_etat_processus).semaphore_fork);
4345: sem_destroy3((*s_etat_processus).semaphore_fork,
4346: getpid(), pthread_self(), SEM_FORK);
4347: # endif
4348:
4349: liberation_contexte_cas(s_etat_processus);
4350: destruction_queue_signaux(s_etat_processus);
4351:
4352: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4353: stackoverflow_deinstall_handler();
4354: # endif
4355:
4356: # ifdef HAVE_SIGSEGV_RECOVERY
4357: if (debug == d_faux)
4358: {
4359: sigsegv_deinstall_handler();
4360: }
4361: # endif
4362:
4363: if ((*s_etat_processus).langue == 'F')
4364: {
4365: printf("+++Fatal : Aucun point d'entrée\n");
4366: }
4367: else
4368: {
4369: printf("+++Fatal : Any entry point\n");
4370: }
4371:
4372: if (test_cfsf(s_etat_processus, 51) == d_faux)
4373: {
4374: printf("%s", ds_beep);
4375: }
4376:
4377: return(EXIT_FAILURE);
4378: }
4379:
4380: if (recherche_variable(s_etat_processus,
4381: (*s_etat_processus)
4382: .instruction_courante) == d_faux)
4383: {
4384: # ifndef SEMAPHORES_NOMMES
4385: sem_post(&((*s_etat_processus).semaphore_fork));
4386: sem_destroy(&((*s_etat_processus).semaphore_fork));
4387: # else
4388: sem_post((*s_etat_processus).semaphore_fork);
4389: sem_destroy3((*s_etat_processus).semaphore_fork,
4390: getpid(), pthread_self(), SEM_FORK);
4391: # endif
4392:
4393: liberation_contexte_cas(s_etat_processus);
4394: destruction_queue_signaux(s_etat_processus);
4395:
4396: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4397: stackoverflow_deinstall_handler();
4398: # endif
4399:
4400: # ifdef HAVE_SIGSEGV_RECOVERY
4401: if (debug == d_faux)
4402: {
4403: sigsegv_deinstall_handler();
4404: }
4405: # endif
4406:
4407: if ((*s_etat_processus).langue == 'F')
4408: {
4409: printf("+++Fatal : Aucun point d'entrée\n");
4410: }
4411: else
4412: {
4413: printf("+++Fatal : Any entry point\n");
4414: }
4415:
4416: if (test_cfsf(s_etat_processus, 51) == d_faux)
4417: {
4418: printf("%s", ds_beep);
4419: }
4420:
4421: return(EXIT_FAILURE);
4422: }
4423:
4424: if ((*(*s_etat_processus).pointeur_variable_courante)
4425: .niveau != 0)
4426: {
4427: # ifndef SEMAPHORES_NOMMES
4428: sem_post(&((*s_etat_processus).semaphore_fork));
4429: sem_destroy(&((*s_etat_processus).semaphore_fork));
4430: # else
4431: sem_post((*s_etat_processus).semaphore_fork);
4432: sem_destroy3((*s_etat_processus).semaphore_fork,
4433: getpid(), pthread_self(), SEM_FORK);
4434: # endif
4435:
4436: liberation_contexte_cas(s_etat_processus);
4437: destruction_queue_signaux(s_etat_processus);
4438:
4439: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4440: stackoverflow_deinstall_handler();
4441: # endif
4442:
4443: # ifdef HAVE_SIGSEGV_RECOVERY
4444: if (debug == d_faux)
4445: {
4446: sigsegv_deinstall_handler();
4447: }
4448: # endif
4449:
4450: if ((*s_etat_processus).langue == 'F')
4451: {
4452: printf("+++Fatal : Aucun point d'entrée\n");
4453: }
4454: else
4455: {
4456: printf("+++Fatal : Any entry point\n");
4457: }
4458:
4459: if (test_cfsf(s_etat_processus, 51) == d_faux)
4460: {
4461: printf("%s", ds_beep);
4462: }
4463:
4464: return(EXIT_FAILURE);
4465: }
4466:
4467: free((*s_etat_processus).instruction_courante);
4468: (*s_etat_processus).position_courante = 0;
4469:
4470: if (((*s_etat_processus).nom_fichier_historique =
4471: malloc((strlen(home) +
4472: strlen(ds_fichier_historique) + 2) *
4473: sizeof(unsigned char))) == NULL)
4474: {
4475: # ifndef SEMAPHORES_NOMMES
4476: sem_post(&((*s_etat_processus).semaphore_fork));
4477: sem_destroy(&((*s_etat_processus).semaphore_fork));
4478: # else
4479: sem_post((*s_etat_processus).semaphore_fork);
4480: sem_destroy3((*s_etat_processus).semaphore_fork,
4481: getpid(), pthread_self(), SEM_FORK);
4482: # endif
4483:
4484: liberation_contexte_cas(s_etat_processus);
4485: destruction_queue_signaux(s_etat_processus);
4486:
4487: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4488: stackoverflow_deinstall_handler();
4489: # endif
4490:
4491: # ifdef HAVE_SIGSEGV_RECOVERY
4492: if (debug == d_faux)
4493: {
4494: sigsegv_deinstall_handler();
4495: }
4496: # endif
4497:
4498: erreur = d_es_allocation_memoire;
4499:
4500: if ((*s_etat_processus).langue == 'F')
4501: {
4502: printf("+++Système : Mémoire insuffisante\n");
4503: }
4504: else
4505: {
4506: printf("+++System : Not enough memory\n");
4507: }
4508:
4509: return(EXIT_FAILURE);
4510: }
4511:
4512: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
4513: home, ds_fichier_historique);
4514:
4515: using_history();
4516:
4517: // Pour pouvoir utiliser le keymap avant le premier
4518: // appel à readline().
4519: rl_initialize();
4520:
4521: erreur_historique = read_history(
4522: (*s_etat_processus).nom_fichier_historique);
4523:
4524: gsl_set_error_handler(&traitement_exceptions_gsl);
4525:
4526: if (drapeau_encart == 'Y')
4527: {
4528: (*s_etat_processus).erreur_systeme = d_es;
4529: encart(s_etat_processus,
4530: (integer8) (5 * 1000000));
4531:
4532: if ((*s_etat_processus).erreur_systeme != d_es)
4533: {
4534: if ((message = messages(s_etat_processus))
4535: == NULL)
4536: {
4537: # ifndef SEMAPHORES_NOMMES
4538: sem_post(&((*s_etat_processus)
4539: .semaphore_fork));
4540: sem_destroy(&((*s_etat_processus)
4541: .semaphore_fork));
4542: # else
4543: sem_post((*s_etat_processus)
4544: .semaphore_fork);
4545: sem_destroy3((*s_etat_processus)
4546: .semaphore_fork,
4547: getpid(), pthread_self(), SEM_FORK);
4548: # endif
4549:
4550: liberation_contexte_cas(s_etat_processus);
4551: destruction_queue_signaux(s_etat_processus);
4552:
4553: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4554: stackoverflow_deinstall_handler();
4555: # endif
4556:
4557: # ifdef HAVE_SIGSEGV_RECOVERY
4558: if (debug == d_faux)
4559: {
4560: sigsegv_deinstall_handler();
4561: }
4562: # endif
4563:
4564: erreur = d_es_allocation_memoire;
4565:
4566: if ((*s_etat_processus).langue == 'F')
4567: {
4568: printf("+++Système : Mémoire "
4569: "insuffisante\n");
4570: }
4571: else
4572: {
4573: printf("+++System : Not enough "
4574: "memory\n");
4575: }
4576:
4577: return(EXIT_FAILURE);
4578: }
4579:
4580: printf("%s [%d]\n", message, (int) getpid());
4581: free(message);
4582:
4583: return(EXIT_FAILURE);
4584: }
4585: }
4586:
4587: fflush(stdout);
4588:
4589: if (arguments != NULL)
4590: {
4591: tampon = (*s_etat_processus).definitions_chainees;
4592: (*s_etat_processus).definitions_chainees =
4593: arguments;
4594:
4595: if (analyse_syntaxique(s_etat_processus) ==
4596: d_erreur)
4597: {
4598: if ((*s_etat_processus).erreur_systeme != d_es)
4599: {
4600: # ifndef SEMAPHORES_NOMMES
4601: sem_post(&((*s_etat_processus)
4602: .semaphore_fork));
4603: sem_destroy(&((*s_etat_processus)
4604: .semaphore_fork));
4605: # else
4606: sem_post((*s_etat_processus)
4607: .semaphore_fork);
4608: sem_destroy3((*s_etat_processus)
4609: .semaphore_fork,
4610: getpid(), pthread_self(), SEM_FORK);
4611: # endif
4612:
4613: liberation_contexte_cas(s_etat_processus);
4614: destruction_queue_signaux(s_etat_processus);
4615:
4616: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4617: stackoverflow_deinstall_handler();
4618: # endif
4619:
4620: # ifdef HAVE_SIGSEGV_RECOVERY
4621: if (debug == d_faux)
4622: {
4623: sigsegv_deinstall_handler();
4624: }
4625: # endif
4626:
4627: erreur = d_es_allocation_memoire;
4628:
4629: if ((*s_etat_processus).langue == 'F')
4630: {
4631: printf("+++Système : Mémoire "
4632: "insuffisante\n");
4633: }
4634: else
4635: {
4636: printf("+++System : Not enough "
4637: "memory\n");
4638: }
4639:
4640: return(EXIT_FAILURE);
4641: }
4642: else
4643: {
4644: # ifndef SEMAPHORES_NOMMES
4645: sem_post(&((*s_etat_processus)
4646: .semaphore_fork));
4647: sem_destroy(&((*s_etat_processus)
4648: .semaphore_fork));
4649: # else
4650: sem_post((*s_etat_processus)
4651: .semaphore_fork);
4652: sem_destroy3((*s_etat_processus)
4653: .semaphore_fork,
4654: getpid(), pthread_self(), SEM_FORK);
4655: # endif
4656:
4657: liberation_contexte_cas(s_etat_processus);
4658: destruction_queue_signaux(s_etat_processus);
4659:
4660: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4661: stackoverflow_deinstall_handler();
4662: # endif
4663:
4664: # ifdef HAVE_SIGSEGV_RECOVERY
4665: if (debug == d_faux)
4666: {
4667: sigsegv_deinstall_handler();
4668: }
4669: # endif
4670:
4671: if ((*s_etat_processus).langue == 'F')
4672: {
4673: printf("+++Erreur : Erreur de "
4674: "syntaxe\n");
4675: }
4676: else
4677: {
4678: printf("+++Error : Syntax error\n");
4679: }
4680:
4681: return(EXIT_FAILURE);
4682: }
4683: }
4684:
4685: (*s_etat_processus).instruction_courante
4686: = arguments;
4687: (*s_etat_processus).definitions_chainees = tampon;
4688: (*s_etat_processus).position_courante = 0;
4689:
4690: (*s_etat_processus).type_en_cours = NON;
4691: recherche_type(s_etat_processus);
4692:
4693: if ((*s_etat_processus).erreur_systeme != d_es)
4694: {
4695: # ifndef SEMAPHORES_NOMMES
4696: sem_post(&((*s_etat_processus).semaphore_fork));
4697: sem_destroy(&((*s_etat_processus)
4698: .semaphore_fork));
4699: # else
4700: sem_post((*s_etat_processus).semaphore_fork);
4701: sem_destroy3((*s_etat_processus).semaphore_fork,
4702: getpid(), pthread_self(), SEM_FORK);
4703: # endif
4704:
4705: liberation_contexte_cas(s_etat_processus);
4706: destruction_queue_signaux(s_etat_processus);
4707:
4708: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4709: stackoverflow_deinstall_handler();
4710: # endif
4711:
4712: # ifdef HAVE_SIGSEGV_RECOVERY
4713: if (debug == d_faux)
4714: {
4715: sigsegv_deinstall_handler();
4716: }
4717: # endif
4718:
4719: if ((message = messages(s_etat_processus))
4720: == NULL)
4721: {
4722: erreur = d_es_allocation_memoire;
4723:
4724: if ((*s_etat_processus).langue == 'F')
4725: {
4726: printf("+++Système : Mémoire "
4727: "insuffisante\n");
4728: }
4729: else
4730: {
4731: printf("+++System : Not enough "
4732: "memory\n");
4733: }
4734:
4735: return(EXIT_FAILURE);
4736: }
4737:
4738: printf("%s [%d]\n", message, (int) getpid());
4739: free(message);
4740:
4741: return(EXIT_FAILURE);
4742: }
4743:
4744: if ((*s_etat_processus).erreur_execution != d_ex)
4745: {
4746: if ((message = messages(s_etat_processus))
4747: == NULL)
4748: {
4749: # ifndef SEMAPHORES_NOMMES
4750: sem_post(&((*s_etat_processus)
4751: .semaphore_fork));
4752: sem_destroy(&((*s_etat_processus)
4753: .semaphore_fork));
4754: # else
4755: sem_post((*s_etat_processus)
4756: .semaphore_fork);
4757: sem_destroy3((*s_etat_processus)
4758: .semaphore_fork,
4759: getpid(), pthread_self(), SEM_FORK);
4760: # endif
4761:
4762: liberation_contexte_cas(s_etat_processus);
4763: destruction_queue_signaux(s_etat_processus);
4764:
4765: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4766: stackoverflow_deinstall_handler();
4767: # endif
4768:
4769: # ifdef HAVE_SIGSEGV_RECOVERY
4770: if (debug == d_faux)
4771: {
4772: sigsegv_deinstall_handler();
4773: }
4774: # endif
4775:
4776: erreur = d_es_allocation_memoire;
4777:
4778: if ((*s_etat_processus).langue == 'F')
4779: {
4780: printf("+++Erreur : Mémoire "
4781: "insuffisante\n");
4782: }
4783: else
4784: {
4785: printf("+++Error : Not enough "
4786: "memory\n");
4787: }
4788:
4789: return(EXIT_FAILURE);
4790: }
4791:
4792: printf("%s [%d]\n", message, (int) getpid());
4793: free(message);
4794:
4795: # ifndef SEMAPHORES_NOMMES
4796: sem_post(&((*s_etat_processus).semaphore_fork));
4797: sem_destroy(&((*s_etat_processus)
4798: .semaphore_fork));
4799: # else
4800: sem_post((*s_etat_processus).semaphore_fork);
4801: sem_destroy3((*s_etat_processus).semaphore_fork,
4802: getpid(), pthread_self(), SEM_FORK);
4803: # endif
4804:
4805: liberation_contexte_cas(s_etat_processus);
4806: destruction_queue_signaux(s_etat_processus);
4807:
4808: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4809: stackoverflow_deinstall_handler();
4810: # endif
4811:
4812: # ifdef HAVE_SIGSEGV_RECOVERY
4813: if (debug == d_faux)
4814: {
4815: sigsegv_deinstall_handler();
4816: }
4817: # endif
4818:
4819: return(EXIT_FAILURE);
4820: }
4821:
4822: if (depilement(s_etat_processus,
4823: &((*s_etat_processus).l_base_pile),
4824: &s_objet) == d_erreur)
4825: {
4826: if ((message = messages(s_etat_processus))
4827: == NULL)
4828: {
4829: # ifndef SEMAPHORES_NOMMES
4830: sem_post(&((*s_etat_processus)
4831: .semaphore_fork));
4832: sem_destroy(&((*s_etat_processus)
4833: .semaphore_fork));
4834: # else
4835: sem_post((*s_etat_processus)
4836: .semaphore_fork);
4837: sem_destroy3((*s_etat_processus)
4838: .semaphore_fork,
4839: getpid(), pthread_self(), SEM_FORK);
4840: # endif
4841:
4842: liberation_contexte_cas(s_etat_processus);
4843: destruction_queue_signaux(s_etat_processus);
4844:
4845: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4846: stackoverflow_deinstall_handler();
4847: # endif
4848:
4849: # ifdef HAVE_SIGSEGV_RECOVERY
4850: if (debug == d_faux)
4851: {
4852: sigsegv_deinstall_handler();
4853: }
4854: # endif
4855:
4856: erreur = d_es_allocation_memoire;
4857: erreur = d_es_allocation_memoire;
4858:
4859: if ((*s_etat_processus).langue == 'F')
4860: {
4861: printf("+++Erreur : Mémoire "
4862: "insuffisante\n");
4863: }
4864: else
4865: {
4866: printf("+++Error : Not enough "
4867: "memory\n");
4868: }
4869:
4870: return(EXIT_FAILURE);
4871: }
4872:
4873: printf("%s [%d]\n", message, (int) getpid());
4874: free(message);
4875:
4876: # ifndef SEMAPHORES_NOMMES
4877: sem_post(&((*s_etat_processus).semaphore_fork));
4878: sem_destroy(&((*s_etat_processus)
4879: .semaphore_fork));
4880: # else
4881: sem_post((*s_etat_processus).semaphore_fork);
4882: sem_destroy3((*s_etat_processus).semaphore_fork,
4883: getpid(), pthread_self(), SEM_FORK);
4884: # endif
4885:
4886: liberation_contexte_cas(s_etat_processus);
4887: destruction_queue_signaux(s_etat_processus);
4888:
4889: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4890: stackoverflow_deinstall_handler();
4891: # endif
4892:
4893: # ifdef HAVE_SIGSEGV_RECOVERY
4894: if (debug == d_faux)
4895: {
4896: sigsegv_deinstall_handler();
4897: }
4898: # endif
4899:
4900: return(EXIT_FAILURE);
4901: }
4902:
4903: empilement_pile_systeme(s_etat_processus);
4904:
4905: if (evaluation(s_etat_processus, s_objet, 'E')
4906: == d_erreur)
4907: {
4908: if ((*s_etat_processus).erreur_systeme != d_es)
4909: {
4910: if ((message = messages(s_etat_processus))
4911: == NULL)
4912: {
4913: # ifndef SEMAPHORES_NOMMES
4914: sem_post(&((*s_etat_processus)
4915: .semaphore_fork));
4916: sem_destroy(&((*s_etat_processus)
4917: .semaphore_fork));
4918: # else
4919: sem_post((*s_etat_processus)
4920: .semaphore_fork);
4921: sem_destroy3((*s_etat_processus)
4922: .semaphore_fork, getpid(),
4923: pthread_self(), SEM_FORK);
4924: # endif
4925:
4926: liberation_contexte_cas(s_etat_processus);
4927: destruction_queue_signaux(s_etat_processus);
4928:
4929: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4930: stackoverflow_deinstall_handler();
4931: # endif
4932:
4933: # ifdef HAVE_SIGSEGV_RECOVERY
4934: if (debug == d_faux)
4935: {
4936: sigsegv_deinstall_handler();
4937: }
4938: # endif
4939:
4940: erreur = d_es_allocation_memoire;
4941:
4942: if ((*s_etat_processus).langue == 'F')
4943: {
4944: printf("+++Système : Mémoire "
4945: "insuffisante\n");
4946: }
4947: else
4948: {
4949: printf("+++System : Not enough "
4950: "memory\n");
4951: }
4952:
4953: return(EXIT_FAILURE);
4954: }
4955:
4956: printf("%s [%d]\n", message,
4957: (int) getpid());
4958: free(message);
4959:
4960: # ifndef SEMAPHORES_NOMMES
4961: sem_post(&((*s_etat_processus)
4962: .semaphore_fork));
4963: sem_destroy(&((*s_etat_processus)
4964: .semaphore_fork));
4965: # else
4966: sem_post((*s_etat_processus)
4967: .semaphore_fork);
4968: sem_destroy3((*s_etat_processus)
4969: .semaphore_fork,
4970: getpid(), pthread_self(), SEM_FORK);
4971: # endif
4972:
4973: liberation_contexte_cas(s_etat_processus);
4974: destruction_queue_signaux(s_etat_processus);
4975:
4976: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4977: stackoverflow_deinstall_handler();
4978: # endif
4979:
4980: # ifdef HAVE_SIGSEGV_RECOVERY
4981: if (debug == d_faux)
4982: {
4983: sigsegv_deinstall_handler();
4984: }
4985: # endif
4986:
4987: erreur = d_es_allocation_memoire;
4988: return(EXIT_FAILURE);
4989: }
4990:
4991: if ((*s_etat_processus).erreur_execution
4992: != d_ex)
4993: {
4994: if ((message = messages(s_etat_processus))
4995: == NULL)
4996: {
4997: # ifndef SEMAPHORES_NOMMES
4998: sem_post(&((*s_etat_processus)
4999: .semaphore_fork));
5000: sem_destroy(&((*s_etat_processus)
5001: .semaphore_fork));
5002: # else
5003: sem_post((*s_etat_processus)
5004: .semaphore_fork);
5005: sem_destroy3((*s_etat_processus)
5006: .semaphore_fork, getpid(),
5007: pthread_self(), SEM_FORK);
5008: # endif
5009:
5010: liberation_contexte_cas(s_etat_processus);
5011: destruction_queue_signaux(s_etat_processus);
5012:
5013: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5014: stackoverflow_deinstall_handler();
5015: # endif
5016:
5017: # ifdef HAVE_SIGSEGV_RECOVERY
5018: if (debug == d_faux)
5019: {
5020: sigsegv_deinstall_handler();
5021: }
5022: # endif
5023:
5024: erreur = d_es_allocation_memoire;
5025:
5026: if ((*s_etat_processus).langue == 'F')
5027: {
5028: printf("+++Erreur : Mémoire "
5029: "insuffisante\n");
5030: }
5031: else
5032: {
5033: printf("+++Error : Not enough "
5034: "memory\n");
5035: }
5036:
5037: return(EXIT_FAILURE);
5038: }
5039:
5040: printf("%s [%d]\n", message,
5041: (int) getpid());
5042: free(message);
5043:
5044: # ifndef SEMAPHORES_NOMMES
5045: sem_post(&((*s_etat_processus)
5046: .semaphore_fork));
5047: sem_destroy(&((*s_etat_processus)
5048: .semaphore_fork));
5049: # else
5050: sem_post((*s_etat_processus)
5051: .semaphore_fork);
5052: sem_destroy3((*s_etat_processus)
5053: .semaphore_fork,
5054: getpid(), pthread_self(), SEM_FORK);
5055: # endif
5056:
5057: liberation_contexte_cas(s_etat_processus);
5058: destruction_queue_signaux(s_etat_processus);
5059:
5060: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5061: stackoverflow_deinstall_handler();
5062: # endif
5063:
5064: # ifdef HAVE_SIGSEGV_RECOVERY
5065: if (debug == d_faux)
5066: {
5067: sigsegv_deinstall_handler();
5068: }
5069: # endif
5070:
5071: return(EXIT_FAILURE);
5072: }
5073: }
5074:
5075: (*s_etat_processus).instruction_courante = NULL;
5076: liberation(s_etat_processus, s_objet);
5077:
5078: free(arguments);
5079: }
5080:
5081: if (option_a == d_vrai)
5082: {
5083: fprintf(stdout, "%s\n", (*s_etat_processus)
5084: .definitions_chainees);
5085: }
5086: else
5087: {
5088: if (option_D == d_vrai)
5089: {
5090: lancement_daemon(s_etat_processus);
5091: }
5092:
5093: if (option_p == d_faux)
5094: {
5095: if (setjmp(contexte_initial) == 0)
5096: {
5097: erreur = sequenceur(s_etat_processus);
5098:
5099: if (erreur == d_absence_erreur)
5100: {
5101: if (((*s_etat_processus)
5102: .arret_depuis_abort == 0) &&
5103: ((*s_etat_processus).at_exit
5104: != NULL))
5105: {
5106: // Permet de traiter ATEXIT
5107: // même après réception d'un SIGINT.
5108: (*s_etat_processus)
5109: .var_volatile_alarme = 0;
5110: (*s_etat_processus)
5111: .var_volatile_requete_arret = 0;
5112:
5113: if ((*s_etat_processus).profilage ==
5114: d_vrai)
5115: {
5116: profilage(s_etat_processus,
5117: "ATEXIT");
5118: }
5119:
5120: erreur = evaluation(s_etat_processus,
5121: (*s_etat_processus).at_exit,
5122: 'E');
5123:
5124: if ((*s_etat_processus).profilage ==
5125: d_vrai)
5126: {
5127: profilage(s_etat_processus, NULL);
5128: }
5129:
5130: if (((*s_etat_processus)
5131: .erreur_execution != d_ex) ||
5132: ((*s_etat_processus).exception
5133: != d_ep) || ((*s_etat_processus)
5134: .erreur_systeme != d_es))
5135: {
5136: printf("%s [%d]\n", message =
5137: messages(s_etat_processus),
5138: (int) getpid());
5139: free(message);
5140:
5141: if (test_cfsf(s_etat_processus, 51)
5142: == d_faux)
5143: {
5144: printf("%s", ds_beep);
5145: }
5146:
5147: if ((*s_etat_processus).core ==
5148: d_vrai)
5149: {
5150: printf("\n");
5151:
5152: if ((*s_etat_processus).langue
5153: == 'F')
5154: {
5155: printf("+++Information : Gé"
5156: "nération du fichie"
5157: "r rpl-core "
5158: "[%d]\n", (int)
5159: getpid());
5160: }
5161: else
5162: {
5163: printf("+++Information : Wr"
5164: "iting rpl-core fil"
5165: "e [%d]\n",
5166: (int) getpid());
5167: }
5168:
5169: rplcore(s_etat_processus);
5170:
5171: if ((*s_etat_processus).langue
5172: == 'F')
5173: {
5174: printf("+++Information : Pr"
5175: "ocessus tracé [%d]"
5176: "\n",
5177: (int) getpid());
5178: }
5179: else
5180: {
5181: printf("+++Information : Do"
5182: "ne [%d]\n", (int)
5183: getpid());
5184: }
5185:
5186: printf("\n");
5187: fflush(stdout);
5188: }
5189: }
5190: }
5191: }
5192: }
5193: }
5194: else
5195: {
5196: if (setjmp(contexte_initial) == 0)
5197: {
5198: erreur = sequenceur_optimise(s_etat_processus,
5199: l_bibliotheques);
5200:
5201: if (erreur == d_absence_erreur)
5202: {
5203: if (((*s_etat_processus)
5204: .arret_depuis_abort == 0) &&
5205: ((*s_etat_processus).at_exit
5206: != NULL))
5207: {
5208: // Permet de traiter ATEXIT
5209: // même après réception d'un SIGINT.
5210: (*s_etat_processus)
5211: .var_volatile_alarme = 0;
5212: (*s_etat_processus)
5213: .var_volatile_requete_arret = 0;
5214:
5215: if ((*s_etat_processus).profilage ==
5216: d_vrai)
5217: {
5218: profilage(s_etat_processus,
5219: "ATEXIT");
5220: }
5221:
5222: erreur = evaluation(s_etat_processus,
5223: (*s_etat_processus).at_exit,
5224: 'E');
5225:
5226: if ((*s_etat_processus).profilage ==
5227: d_vrai)
5228: {
5229: profilage(s_etat_processus, NULL);
5230: }
5231:
5232: if (((*s_etat_processus)
5233: .erreur_execution != d_ex) ||
5234: ((*s_etat_processus).exception
5235: != d_ep) || ((*s_etat_processus)
5236: .erreur_systeme != d_es))
5237: {
5238: printf("%s [%d]\n", message =
5239: messages(s_etat_processus),
5240: (int) getpid());
5241: free(message);
5242:
5243: if (test_cfsf(s_etat_processus, 51)
5244: == d_faux)
5245: {
5246: printf("%s", ds_beep);
5247: }
5248:
5249: if ((*s_etat_processus).core ==
5250: d_vrai)
5251: {
5252: printf("\n");
5253:
5254: if ((*s_etat_processus).langue
5255: == 'F')
5256: {
5257: printf("+++Information : Gé"
5258: "nération du fichie"
5259: "r rpl-core "
5260: "[%d]\n", (int)
5261: getpid());
5262: }
5263: else
5264: {
5265: printf("+++Information : Wr"
5266: "iting rpl-core fil"
5267: "e [%d]\n",
5268: (int) getpid());
5269: }
5270:
5271: rplcore(s_etat_processus);
5272:
5273: if ((*s_etat_processus).langue
5274: == 'F')
5275: {
5276: printf("+++Information : Pr"
5277: "ocessus tracé [%d]"
5278: "\n",
5279: (int) getpid());
5280: }
5281: else
5282: {
5283: printf("+++Information : Do"
5284: "ne [%d]\n", (int)
5285: getpid());
5286: }
5287:
5288: printf("\n");
5289: fflush(stdout);
5290: }
5291: }
5292: }
5293: }
5294: }
5295: }
5296: }
5297:
5298: for(i = 0; i < (*s_etat_processus).sections_critiques; i++)
5299: {
5300: pthread_mutex_unlock(&mutex_sections_critiques);
5301: }
5302:
5303: liberation(s_etat_processus, (*s_etat_processus).at_exit);
5304: liberation(s_etat_processus, (*s_etat_processus).at_poke);
5305:
5306: if ((*s_etat_processus).generateur_aleatoire != NULL)
5307: {
5308: liberation_generateur_aleatoire(s_etat_processus);
5309: }
5310:
5311: l_element_courant = (*s_etat_processus).liste_mutexes;
5312: while(l_element_courant != NULL)
5313: {
5314: liberation(s_etat_processus,
5315: (*((struct_liste_chainee *)
5316: l_element_courant)).donnee);
5317: l_element_suivant = (*((struct_liste_chainee *)
5318: l_element_courant)).suivant;
5319: free((struct_liste_chainee *) l_element_courant);
5320: l_element_courant = l_element_suivant;
5321: }
5322:
5323: /*
5324: * Arrêt des processus fils
5325: */
5326:
5327: if ((*s_etat_processus).presence_fusible == d_vrai)
5328: {
5329: pthread_cancel((*s_etat_processus).thread_fusible);
5330: }
5331:
5332: pthread_mutex_lock(&((*s_etat_processus)
5333: .mutex_pile_processus));
5334:
5335: l_element_courant = (void *) (*s_etat_processus)
5336: .l_base_pile_processus;
5337:
5338: while(l_element_courant != NULL)
5339: {
5340: if ((*s_etat_processus).debug == d_vrai)
5341: {
5342: if (((*s_etat_processus).type_debug &
5343: d_debug_processus) != 0)
5344: {
5345: if ((*(*((struct_processus_fils *)
5346: (*(*((struct_liste_chainee *)
5347: l_element_courant)).donnee)
5348: .objet)).thread)
5349: .processus_detache == d_vrai)
5350: {
5351: if ((*s_etat_processus).langue == 'F')
5352: {
5353: printf("[%d] Signalement pour arrêt du "
5354: "processus %d\n",
5355: (int) getpid(), (int)
5356: (*(*((struct_processus_fils *)
5357: (*(*((struct_liste_chainee *)
5358: l_element_courant)).donnee)
5359: .objet)).thread).pid);
5360: }
5361: else
5362: {
5363: printf("[%d] Send stop signal to "
5364: "process %d\n",
5365: (int) getpid(), (int)
5366: (*(*((struct_processus_fils *)
5367: (*(*((struct_liste_chainee *)
5368: l_element_courant)).donnee)
5369: .objet)).thread).pid);
5370: }
5371: }
5372: else
5373: {
5374: if ((*s_etat_processus).langue == 'F')
5375: {
5376: printf("[%d] Signalement pour arrêt du "
5377: "thread %llu\n", (int) getpid(),
5378: (unsigned long long)
5379: (*(*((struct_processus_fils *)
5380: (*(*((struct_liste_chainee *)
5381: l_element_courant)).donnee)
5382: .objet)).thread).tid);
5383: }
5384: else
5385: {
5386: printf("[%d] Send stop signal to "
5387: "thread %llu\n",
5388: (int) getpid(),
5389: (unsigned long long)
5390: (*(*((struct_processus_fils *)
5391: (*(*((struct_liste_chainee *)
5392: l_element_courant)).donnee)
5393: .objet)).thread).tid);
5394: }
5395: }
5396: }
5397: }
5398:
5399: if ((*(*((struct_processus_fils *)
5400: (*(*((struct_liste_chainee *)
5401: l_element_courant)).donnee).objet))
5402: .thread).processus_detache == d_vrai)
5403: {
5404: if ((*s_etat_processus).var_volatile_alarme != 0)
5405: {
5406: envoi_signal_processus(
5407: (*(*((struct_processus_fils *)
5408: (*(*((struct_liste_chainee *)
5409: l_element_courant)).donnee).objet))
5410: .thread).pid, rpl_sigurg, d_faux);
5411: }
5412: else
5413: {
5414: if ((*s_etat_processus).arret_depuis_abort
5415: == -1)
5416: {
5417: envoi_signal_processus(
5418: (*(*((struct_processus_fils *)
5419: (*(*((struct_liste_chainee *)
5420: l_element_courant)).donnee).objet))
5421: .thread).pid, rpl_sigabort, d_faux);
5422: }
5423: else
5424: {
5425: envoi_signal_processus(
5426: (*(*((struct_processus_fils *)
5427: (*(*((struct_liste_chainee *)
5428: l_element_courant)).donnee).objet))
5429: .thread).pid, rpl_sigstop, d_faux);
5430: }
5431: }
5432: }
5433: else
5434: {
5435: pthread_mutex_lock(&((*(*((struct_processus_fils *)
5436: (*(*((struct_liste_chainee *)
5437: l_element_courant)).donnee).objet)).thread)
5438: .mutex));
5439:
5440: if ((*(*((struct_processus_fils *)
5441: (*(*((struct_liste_chainee *)
5442: l_element_courant)).donnee).objet)).thread)
5443: .thread_actif == d_vrai)
5444: {
5445: if ((*s_etat_processus).var_volatile_alarme
5446: != 0)
5447: {
5448: envoi_signal_thread(s_etat_processus,
5449: (*(*((struct_processus_fils *)
5450: (*(*((struct_liste_chainee *)
5451: l_element_courant)).donnee).objet))
5452: .thread).tid, rpl_sigurg);
5453: }
5454: else
5455: {
5456: if ((*s_etat_processus).arret_depuis_abort
5457: == -1)
5458: {
5459: envoi_signal_thread(s_etat_processus,
5460: (*(*((struct_processus_fils *)
5461: (*(*((struct_liste_chainee *)
5462: l_element_courant)).donnee)
5463: .objet)).thread).tid,
5464: rpl_sigabort);
5465: }
5466: else
5467: {
5468: envoi_signal_thread(s_etat_processus,
5469: (*(*((struct_processus_fils *)
5470: (*(*((struct_liste_chainee *)
5471: l_element_courant)).donnee)
5472: .objet)).thread).tid,
5473: rpl_sigstop);
5474: }
5475: }
5476: }
5477:
5478: pthread_mutex_unlock(
5479: &((*(*((struct_processus_fils *)
5480: (*(*((struct_liste_chainee *)
5481: l_element_courant)).donnee).objet)).thread)
5482: .mutex));
5483: }
5484:
5485: l_element_courant = (*((struct_liste_chainee *)
5486: l_element_courant)).suivant;
5487: }
5488:
5489: /*
5490: * Attente de la fin de tous les processus fils
5491: */
5492:
5493: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
5494: (*s_etat_processus).masque_interruptions[i++]
5495: = 'I');
5496:
5497: attente.tv_sec = 0;
5498: attente.tv_nsec = GRANULARITE_us * 1000;
5499:
5500: while((*s_etat_processus).l_base_pile_processus != NULL)
5501: {
5502: l_element_courant = (void *)
5503: (*s_etat_processus).l_base_pile_processus;
5504:
5505: for(i = 0; i < (*(*((struct_processus_fils *)
5506: (*(*((struct_liste_chainee *)
5507: l_element_courant)).donnee).objet)).thread)
5508: .nombre_objets_dans_pipe; i++)
5509: {
5510: if ((s_objet = lecture_pipe(
5511: s_etat_processus,
5512: (*(*((struct_processus_fils *)
5513: (*(*((struct_liste_chainee *)
5514: l_element_courant)).donnee).objet)).thread)
5515: .pipe_objets[0])) != NULL)
5516: {
5517: liberation(s_etat_processus, s_objet);
5518:
5519: (*(*((struct_processus_fils *)
5520: (*(*((struct_liste_chainee *)
5521: l_element_courant)).donnee).objet))
5522: .thread).nombre_objets_dans_pipe--;
5523:
5524: action.sa_handler = SIG_IGN;
5525: action.sa_flags = 0;
5526:
5527: if (sigaction(SIGPIPE, &action, ®istre)
5528: != 0)
5529: {
5530: # ifndef SEMAPHORES_NOMMES
5531: sem_post(&((*s_etat_processus)
5532: .semaphore_fork));
5533: sem_destroy(&((*s_etat_processus)
5534: .semaphore_fork));
5535: # else
5536: sem_post((*s_etat_processus)
5537: .semaphore_fork);
5538: sem_destroy3((*s_etat_processus)
5539: .semaphore_fork, getpid(),
5540: pthread_self(), SEM_FORK);
5541: # endif
5542:
5543: liberation_contexte_cas(s_etat_processus);
5544: destruction_queue_signaux(s_etat_processus);
5545:
5546: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5547: stackoverflow_deinstall_handler();
5548: # endif
5549:
5550: # ifdef HAVE_SIGSEGV_RECOVERY
5551: if (debug == d_faux)
5552: {
5553: sigsegv_deinstall_handler();
5554: }
5555: # endif
5556:
5557: pthread_mutex_unlock(&((*s_etat_processus)
5558: .mutex_pile_processus));
5559: return(EXIT_FAILURE);
5560: }
5561:
5562: while((longueur_ecriture =
5563: write_atomic(s_etat_processus,
5564: (*(*((struct_processus_fils *)
5565: (*(*((struct_liste_chainee *)
5566: l_element_courant)).donnee).objet))
5567: .thread).pipe_nombre_injections[1], "+",
5568: sizeof(unsigned char))) !=
5569: sizeof(unsigned char))
5570: {
5571: if (longueur_ecriture == -1)
5572: {
5573: // Le processus n'existe plus.
5574: break;
5575: }
5576: }
5577:
5578: if (sigaction(SIGPIPE, ®istre, NULL)
5579: != 0)
5580: {
5581: # ifndef SEMAPHORES_NOMMES
5582: sem_post(&((*s_etat_processus)
5583: .semaphore_fork));
5584: sem_destroy(&((*s_etat_processus)
5585: .semaphore_fork));
5586: # else
5587: sem_post((*s_etat_processus)
5588: .semaphore_fork);
5589: sem_destroy3((*s_etat_processus)
5590: .semaphore_fork, getpid(),
5591: pthread_self(), SEM_FORK);
5592: # endif
5593:
5594: liberation_contexte_cas(s_etat_processus);
5595: destruction_queue_signaux(s_etat_processus);
5596:
5597: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5598: stackoverflow_deinstall_handler();
5599: # endif
5600:
5601: # ifdef HAVE_SIGSEGV_RECOVERY
5602: if (debug == d_faux)
5603: {
5604: sigsegv_deinstall_handler();
5605: }
5606: # endif
5607:
5608: pthread_mutex_unlock(&((*s_etat_processus)
5609: .mutex_pile_processus));
5610: return(EXIT_FAILURE);
5611: }
5612: }
5613: }
5614:
5615: pthread_mutex_lock(&((*s_etat_processus)
5616: .mutex_interruptions));
5617:
5618: if ((*s_etat_processus)
5619: .nombre_interruptions_non_affectees != 0)
5620: {
5621: affectation_interruptions_logicielles(
5622: s_etat_processus);
5623: }
5624:
5625: pthread_mutex_unlock(&((*s_etat_processus)
5626: .mutex_interruptions));
5627: pthread_mutex_unlock(&((*s_etat_processus)
5628: .mutex_pile_processus));
5629: nanosleep(&attente, NULL);
5630: scrutation_interruptions(s_etat_processus);
5631: pthread_mutex_lock(&((*s_etat_processus)
5632: .mutex_pile_processus));
5633: }
5634:
5635: pthread_mutex_unlock(&((*s_etat_processus)
5636: .mutex_pile_processus));
5637:
5638: erreur_historique = write_history(
5639: (*s_etat_processus).nom_fichier_historique);
5640: clear_history();
5641:
5642: if (erreur_historique != 0)
5643: {
5644: if ((*s_etat_processus).langue == 'F')
5645: {
5646: printf("+++Erreur : L'historique ne peut être "
5647: "écrit\n");
5648: }
5649: else
5650: {
5651: printf("+++Error : History cannot be "
5652: "written\n");
5653: }
5654:
5655: if (test_cfsf(s_etat_processus, 51) == d_faux)
5656: {
5657: printf("%s", ds_beep);
5658: }
5659: }
5660:
5661: free((*s_etat_processus).nom_fichier_historique);
5662:
5663: if (((*s_etat_processus).core == d_vrai) &&
5664: (erreur == d_erreur) &&
5665: ((*s_etat_processus).var_volatile_traitement_sigint
5666: == 0))
5667: {
5668: printf("\n");
5669:
5670: if ((*s_etat_processus).langue == 'F')
5671: {
5672: printf("+++Information : Génération du fichier "
5673: "rpl-core [%d]\n", (int) getpid());
5674: }
5675: else
5676: {
5677: printf("+++Information : Writing rpl-core "
5678: "file [%d]\n", (int) getpid());
5679: }
5680:
5681: rplcore(s_etat_processus);
5682:
5683: if ((*s_etat_processus).langue == 'F')
5684: {
5685: printf("+++Information : Processus tracé [%d]\n",
5686: (int) getpid());
5687: }
5688: else
5689: {
5690: printf("+++Information : Done [%d]\n",
5691: (int) getpid());
5692: }
5693:
5694: printf("\n");
5695: }
5696:
5697: free((*s_etat_processus).definitions_chainees);
5698:
5699: /*
5700: * Libération de l'arbre des instructions
5701: */
5702:
5703: liberation_arbre_instructions(s_etat_processus,
5704: (*s_etat_processus).arbre_instructions);
5705: free((*s_etat_processus).pointeurs_caracteres);
5706:
5707: if ((*s_etat_processus).entree_standard != NULL)
5708: {
5709: pclose((*s_etat_processus).entree_standard);
5710: (*s_etat_processus).entree_standard = NULL;
5711: }
5712:
5713: if ((*s_etat_processus).nom_fichier_impression != NULL)
5714: {
5715: if (test_cfsf(s_etat_processus, 51) == d_faux)
5716: {
5717: printf("%s", ds_beep);
5718: }
5719:
5720: if ((*s_etat_processus).langue == 'F')
5721: {
5722: printf("+++Attention : Queue d'impression "
5723: "non vide !\n");
5724: }
5725: else
5726: {
5727: printf("+++Warning : Non empty printing "
5728: "spool queue !\n");
5729: }
5730:
5731: instruction_erase(s_etat_processus);
5732: }
5733:
5734: if ((*s_etat_processus).fichiers_graphiques != NULL)
5735: {
5736: instruction_cllcd(s_etat_processus);
5737: }
5738:
5739: liberation(s_etat_processus, (*s_etat_processus).indep);
5740: liberation(s_etat_processus, (*s_etat_processus).depend);
5741:
5742: free((*s_etat_processus).label_x);
5743: free((*s_etat_processus).label_y);
5744: free((*s_etat_processus).label_z);
5745: free((*s_etat_processus).titre);
5746: free((*s_etat_processus).legende);
5747:
5748: liberation(s_etat_processus, (*s_etat_processus)
5749: .parametres_courbes_de_niveau);
5750:
5751: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
5752: {
5753: liberation(s_etat_processus,
5754: (*s_etat_processus).corps_interruptions[i]);
5755:
5756: l_element_courant = (*s_etat_processus)
5757: .pile_origine_interruptions[i];
5758:
5759: while(l_element_courant != NULL)
5760: {
5761: l_element_suivant = (*((struct_liste_chainee *)
5762: l_element_courant)).suivant;
5763:
5764: liberation(s_etat_processus,
5765: (*((struct_liste_chainee *)
5766: l_element_courant)).donnee);
5767: free(l_element_courant);
5768:
5769: l_element_courant = l_element_suivant;
5770: }
5771: }
5772:
5773: if ((*s_etat_processus).instruction_derniere_erreur
5774: != NULL)
5775: {
5776: free((*s_etat_processus).instruction_derniere_erreur);
5777: (*s_etat_processus).instruction_derniere_erreur = NULL;
5778: }
5779:
5780: /*
5781: * Le pointeur s_etat_processus.nom_fichier_source est
5782: * alloué par le système. Il ne faut donc pas
5783: * le libérer...
5784: */
5785:
5786: liberation_arbre_variables_partagees(s_etat_processus,
5787: (*(*s_etat_processus).s_arbre_variables_partagees));
5788: liberation_arbre_variables(s_etat_processus,
5789: (*s_etat_processus).s_arbre_variables, d_vrai);
5790: free((*s_etat_processus).pointeurs_caracteres_variables);
5791:
5792: l_element_statique_courant = (*s_etat_processus)
5793: .l_liste_variables_statiques;
5794:
5795: while(l_element_statique_courant != NULL)
5796: {
5797: l_element_statique_suivant =
5798: (*l_element_statique_courant).suivant;
5799: free(l_element_statique_courant);
5800: l_element_statique_courant = l_element_statique_suivant;
5801: }
5802:
5803: l_element_partage_courant = (*(*s_etat_processus)
5804: .l_liste_variables_partagees);
5805:
5806: while(l_element_partage_courant != NULL)
5807: {
5808: l_element_partage_suivant =
5809: (*l_element_partage_courant).suivant;
5810: free(l_element_partage_courant);
5811: l_element_partage_courant = l_element_partage_suivant;
5812: }
5813:
5814: /*
5815: * Si resultats est non nul, rplinit a été appelé
5816: * depuis rpl() [librpl] et non main().
5817: * On copie alors le contenu de la * pile dans un
5818: * tableau **resultats dont le pointeur de base a
5819: * été alloué dans rpl().
5820: */
5821:
5822: if (resultats != NULL)
5823: {
5824: if ((*resultats) != NULL)
5825: {
5826: sys_free((*resultats));
5827:
5828: if (((*resultats) = sys_malloc(((size_t)
5829: ((*s_etat_processus)
5830: .hauteur_pile_operationnelle + 1))
5831: * sizeof(unsigned char **))) != NULL)
5832: {
5833: (*resultats)[(*s_etat_processus)
5834: .hauteur_pile_operationnelle] = NULL;
5835: l_element_courant = (void *) (*s_etat_processus)
5836: .l_base_pile;
5837:
5838: for(i = 0; i < (*s_etat_processus)
5839: .hauteur_pile_operationnelle; i++)
5840: {
5841: if (l_element_courant != NULL)
5842: {
5843: (*resultats)[i] =
5844: formateur(s_etat_processus,
5845: 0, (*((struct_liste_chainee *)
5846: l_element_courant)).donnee);
5847:
5848: if ((*resultats)[i] == NULL)
5849: {
5850: i = (*s_etat_processus).
5851: hauteur_pile_operationnelle;
5852: }
5853: else
5854: {
5855: l_element_suivant =
5856: (*((struct_liste_chainee *)
5857: l_element_courant)).suivant;
5858: }
5859: }
5860: }
5861: }
5862: else
5863: {
5864: (*resultats) = NULL;
5865: erreur = d_es_allocation_memoire;
5866: }
5867: }
5868: }
5869:
5870: l_element_courant = (void *) (*s_etat_processus)
5871: .l_base_pile;
5872: while(l_element_courant != NULL)
5873: {
5874: l_element_suivant = (*((struct_liste_chainee *)
5875: l_element_courant)).suivant;
5876:
5877: liberation(s_etat_processus,
5878: (*((struct_liste_chainee *)
5879: l_element_courant)).donnee);
5880: free((struct_liste_chainee *) l_element_courant);
5881:
5882: l_element_courant = l_element_suivant;
5883: }
5884:
5885: l_element_courant = (void *) (*s_etat_processus)
5886: .l_base_pile_contextes;
5887: while(l_element_courant != NULL)
5888: {
5889: l_element_suivant = (*((struct_liste_chainee *)
5890: l_element_courant)).suivant;
5891:
5892: liberation(s_etat_processus,
5893: (*((struct_liste_chainee *)
5894: l_element_courant)).donnee);
5895: free((struct_liste_chainee *) l_element_courant);
5896:
5897: l_element_courant = l_element_suivant;
5898: }
5899:
5900: l_element_courant = (void *) (*s_etat_processus)
5901: .l_base_pile_taille_contextes;
5902: while(l_element_courant != NULL)
5903: {
5904: l_element_suivant = (*((struct_liste_chainee *)
5905: l_element_courant)).suivant;
5906:
5907: liberation(s_etat_processus,
5908: (*((struct_liste_chainee *)
5909: l_element_courant)).donnee);
5910: free((struct_liste_chainee *) l_element_courant);
5911:
5912: l_element_courant = l_element_suivant;
5913: }
5914:
5915: l_element_courant = (void *) (*s_etat_processus)
5916: .l_base_pile_last;
5917: while(l_element_courant != NULL)
5918: {
5919: l_element_suivant = (*((struct_liste_chainee *)
5920: l_element_courant)).suivant;
5921:
5922: liberation(s_etat_processus,
5923: (*((struct_liste_chainee *)
5924: l_element_courant)).donnee);
5925: free((struct_liste_chainee *) l_element_courant);
5926:
5927: l_element_courant = l_element_suivant;
5928: }
5929:
5930: while((*s_etat_processus).s_bibliotheques != NULL)
5931: {
5932: retrait_bibliotheque(s_etat_processus,
5933: (struct_bibliotheque *)
5934: (*((struct_liste_chainee *)
5935: (*s_etat_processus).s_bibliotheques)).donnee);
5936: }
5937:
5938: l_element_courant = (void *) (*s_etat_processus)
5939: .l_base_pile_systeme;
5940: while(l_element_courant != NULL)
5941: {
5942: l_element_suivant = (*((struct_liste_pile_systeme *)
5943: l_element_courant)).suivant;
5944:
5945: liberation(s_etat_processus,
5946: (*((struct_liste_pile_systeme *)
5947: l_element_courant)).indice_boucle);
5948: liberation(s_etat_processus,
5949: (*((struct_liste_pile_systeme *)
5950: l_element_courant)).limite_indice_boucle);
5951: liberation(s_etat_processus,
5952: (*((struct_liste_pile_systeme *)
5953: l_element_courant)).objet_de_test);
5954:
5955: if ((*((struct_liste_pile_systeme *)
5956: l_element_courant)).nom_variable != NULL)
5957: {
5958: free((*((struct_liste_pile_systeme *)
5959: l_element_courant)).nom_variable);
5960: }
5961:
5962: free((struct_liste_pile_systeme *)
5963: l_element_courant);
5964:
5965: l_element_courant = l_element_suivant;
5966: }
5967:
5968: l_element_courant = (void *)
5969: (*s_etat_processus).s_fichiers;
5970: while(l_element_courant != NULL)
5971: {
5972: l_element_suivant = (*((struct_liste_chainee *)
5973: l_element_courant)).suivant;
5974:
5975: fclose((*((struct_descripteur_fichier *)
5976: (*((struct_liste_chainee *)
5977: l_element_courant)).donnee))
5978: .descripteur_c);
5979:
5980: if ((*((struct_descripteur_fichier *)
5981: (*((struct_liste_chainee *)
5982: l_element_courant)).donnee)).type != 'C')
5983: {
5984: sqlite3_close((*((struct_descripteur_fichier *)
5985: (*((struct_liste_chainee *)
5986: l_element_courant)).donnee))
5987: .descripteur_sqlite);
5988: }
5989:
5990: if ((*((struct_descripteur_fichier *)
5991: (*((struct_liste_chainee *)
5992: l_element_courant)).donnee))
5993: .effacement == 'Y')
5994: {
5995: unlink((*((struct_descripteur_fichier *)
5996: (*((struct_liste_chainee *)
5997: l_element_courant)).donnee))
5998: .nom);
5999: }
6000:
6001: free((*((struct_descripteur_fichier *)
6002: (*((struct_liste_chainee *)
6003: l_element_courant)).donnee)).nom);
6004: free((struct_descripteur_fichier *)
6005: (*((struct_liste_chainee *)
6006: l_element_courant)).donnee);
6007: free(l_element_courant);
6008:
6009: l_element_courant = l_element_suivant;
6010: }
6011:
6012: l_element_courant = (void *)
6013: (*s_etat_processus).s_sockets;
6014: while(l_element_courant != NULL)
6015: {
6016: l_element_suivant = (*((struct_liste_chainee *)
6017: l_element_courant)).suivant;
6018:
6019: if ((*((struct_socket *)
6020: (*(*((struct_liste_chainee *)
6021: l_element_courant)).donnee).objet))
6022: .socket_connectee == d_vrai)
6023: {
6024: shutdown((*((struct_socket *)
6025: (*(*((struct_liste_chainee *)
6026: l_element_courant)).donnee).objet))
6027: .socket, SHUT_RDWR);
6028: }
6029:
6030: close((*((struct_socket *)
6031: (*(*((struct_liste_chainee *)
6032: l_element_courant)).donnee).objet)).socket);
6033:
6034: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
6035: l_element_courant)).donnee).objet)).effacement
6036: == 'Y')
6037: {
6038: unlink((*((struct_socket *)
6039: (*(*((struct_liste_chainee *)
6040: l_element_courant)).donnee).objet))
6041: .adresse);
6042: }
6043:
6044: liberation(s_etat_processus,
6045: (*((struct_liste_chainee *)
6046: l_element_courant)).donnee);
6047: free(l_element_courant);
6048:
6049: l_element_courant = l_element_suivant;
6050: }
6051:
6052: l_element_courant = (void *)
6053: (*s_etat_processus).s_connecteurs_sql;
6054: while(l_element_courant != NULL)
6055: {
6056: l_element_suivant = (*((struct_liste_chainee *)
6057: l_element_courant)).suivant;
6058:
6059: sqlclose((*((struct_liste_chainee *)
6060: l_element_courant)).donnee);
6061: liberation(s_etat_processus,
6062: (*((struct_liste_chainee *)
6063: l_element_courant)).donnee);
6064: free(l_element_courant);
6065:
6066: l_element_courant = l_element_suivant;
6067: }
6068:
6069: l_element_courant = (*s_etat_processus).s_marques;
6070: while(l_element_courant != NULL)
6071: {
6072: free((*((struct_marque *) l_element_courant)).label);
6073: free((*((struct_marque *) l_element_courant)).position);
6074: l_element_suivant = (*((struct_marque *)
6075: l_element_courant)).suivant;
6076: free(l_element_courant);
6077: l_element_courant = l_element_suivant;
6078: }
6079: }
6080: else
6081: {
6082: erreur = d_es_allocation_memoire;
6083:
6084: if (test_cfsf(s_etat_processus, 51) == d_faux)
6085: {
6086: printf("%s", ds_beep);
6087: }
6088:
6089: if ((*s_etat_processus).langue == 'F')
6090: {
6091: printf("+++Système : Mémoire insuffisante\n");
6092: }
6093: else
6094: {
6095: printf("+++System : Not enough memory\n");
6096: }
6097: }
6098: }
6099:
6100: liberation_allocateur(s_etat_processus);
6101: }
6102:
6103: if (traitement_fichier_temporaire == 'Y')
6104: {
6105: destruction_fichier(nom_fichier_temporaire);
6106: free(nom_fichier_temporaire);
6107: }
6108:
6109: if ((*s_etat_processus).profilage == d_vrai)
6110: {
6111: ecriture_profil(s_etat_processus);
6112: liberation_profil(s_etat_processus);
6113: }
6114: }
6115:
6116: closelog();
6117:
6118: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
6119:
6120: retrait_thread(s_etat_processus);
6121:
6122: attente.tv_sec = 0;
6123: attente.tv_nsec = GRANULARITE_us * 1000;
6124:
6125: pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus));
6126:
6127: while(nombre_threads_surveillance_processus != 0)
6128: {
6129: pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus));
6130: nanosleep(&attente, NULL);
6131: INCR_GRANULARITE(attente.tv_nsec);
6132: pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus));
6133: }
6134:
6135: pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus));
6136:
6137: attente.tv_sec = 0;
6138: attente.tv_nsec = GRANULARITE_us * 1000;
6139:
6140: while(pthread_mutex_trylock(&((*s_etat_processus).mutex_pile_processus))
6141: == EBUSY)
6142: {
6143: nanosleep(&attente, NULL);
6144: INCR_GRANULARITE(attente.tv_nsec);
6145: }
6146:
6147: pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus));
6148: pthread_mutex_destroy(&((*s_etat_processus).mutex_pile_processus));
6149: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
6150: pthread_mutex_destroy(&((*s_etat_processus).mutex_interruptions));
6151: pthread_mutex_destroy(&mutex_sections_critiques);
6152: pthread_mutex_destroy(&mutex_liste_variables_partagees);
6153:
6154: free((*s_etat_processus).localisation);
6155:
6156: destruction_queue_signaux(s_etat_processus);
6157: pthread_mutex_destroy(&((*s_etat_processus).mutex_signaux));
6158: liberation_contexte_cas(s_etat_processus);
6159:
6160: # ifndef SEMAPHORES_NOMMES
6161: sem_post(&((*s_etat_processus).semaphore_fork));
6162: sem_destroy(&((*s_etat_processus).semaphore_fork));
6163: # else
6164: sem_post((*s_etat_processus).semaphore_fork);
6165: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(),
6166: SEM_FORK);
6167: # endif
6168:
6169: free((*s_etat_processus).chemin_fichiers_temporaires);
6170:
6171: if ((*s_etat_processus).requete_redemarrage == d_vrai)
6172: {
6173: if (chdir(repertoire_initial) == 0)
6174: {
6175: execvp(arg_exec[0], &(arg_exec[0]));
6176: }
6177:
6178: erreur = d_erreur;
6179: }
6180:
6181: liberation_etat_processus_readline();
6182:
6183: liberation_allocateur_buffer(s_etat_processus);
6184: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation_buffer));
6185: pthread_mutex_destroy(&mutex_liste_threads);
6186: pthread_mutex_destroy(&mutex_liste_threads_surveillance);
6187: pthread_mutex_destroy(&mutex_sigaction);
6188:
6189: sys_free(s_etat_processus);
6190: sys_free(arg_exec);
6191:
6192: # ifdef DEBUG_MEMOIRE
6193: debug_memoire_verification();
6194: analyse_post_mortem();
6195: # endif
6196:
6197: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
6198: stackoverflow_deinstall_handler();
6199: # endif
6200:
6201: # ifdef HAVE_SIGSEGV_RECOVERY
6202: if (debug == d_faux)
6203: {
6204: sigsegv_deinstall_handler();
6205: }
6206: # endif
6207:
6208: return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
6209: }
6210:
6211:
6212: void
6213: informations(struct_processus *s_etat_processus)
6214: {
6215: printf("\n");
6216:
6217: if ((*s_etat_processus).langue == 'F')
6218: {
6219: printf(" rpl [-options] [programme]\n");
6220: printf(" -a : analyse du code\n");
6221: printf(" -A : paramètres passés au programme principal\n");
6222: printf(" -c : génération de fichier de débogage (rpl-core)\n");
6223: printf(" -d : option de déverminage interne\n");
6224: printf(" -D : lancement d'un daemon\n");
6225: printf(" -h : aide sur la ligne de commande\n");
6226: printf(" -i : fonctionnement interactif\n");
6227: printf(" -l : licence d'utilisation\n");
6228: printf(" -n : ignorance du signal HUP\n");
6229: printf(" -m : chargement d'un module RPL/SO avant la "
6230: "compilation\n");
6231: printf(" -p : précompilation du script avant exécution\n");
6232: printf(" -P : profilage (-P ou -PP)\n");
6233: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
6234: printf(" -S : exécution du script passé en ligne de commande\n");
6235: printf(" -t : trace\n");
6236: printf(" -v : version\n");
6237: }
6238: else
6239: {
6240: printf(" rpl [-options] [program]\n");
6241: printf(" -a : analyzes program\n");
6242: printf(" -A : sends parameters to main program\n");
6243: printf(" -c : allows creation of a rpl-core file, providing a way"
6244: "\n"
6245: " to debug a program\n");
6246: printf(" -d : internal debug process\n");
6247: printf(" -D : starts in daemon mode\n");
6248: printf(" -h : shows a summary of available options\n");
6249: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
6250: printf(" -l : prints the user licence of the software\n");
6251: printf(" -n : ignores HUP signal\n");
6252: printf(" -m : loads RPL/SO object before compilation\n");
6253: printf(" -p : precompiles script\n");
6254: printf(" -P : computes profile data (-P or -PP)\n");
6255: printf(" -s : disables splash screen\n");
6256: printf(" -S : executes script written in command line\n");
6257: printf(" -t : enables tracing mode\n");
6258: printf(" -v : prints the version number\n");
6259: }
6260:
6261: printf("\n");
6262:
6263: return;
6264: }
6265:
6266:
6267: logical1
6268: controle_integrite(struct_processus *s_etat_processus,
6269: unsigned char *executable_candidat, unsigned char *executable)
6270: {
6271: unsigned char *md5;
6272: unsigned char *sha1;
6273:
6274: if (strcmp(executable, "rplpp") == 0)
6275: {
6276: md5 = rplpp_md5;
6277: sha1 = rplpp_sha1;
6278: }
6279: else if (strcmp(executable, "rplfile") == 0)
6280: {
6281: md5 = rplfile_md5;
6282: sha1 = rplfile_sha1;
6283: }
6284: else if (strcmp(executable, "rpliconv") == 0)
6285: {
6286: md5 = rpliconv_md5;
6287: sha1 = rpliconv_sha1;
6288: }
6289: else if (strcmp(executable, "rplawk") == 0)
6290: {
6291: md5 = rplawk_md5;
6292: sha1 = rplawk_sha1;
6293: }
6294: else if (strcmp(executable, "rplconvert") == 0)
6295: {
6296: md5 = rplconvert_md5;
6297: sha1 = rplconvert_sha1;
6298: }
6299: else
6300: {
6301: return(d_faux);
6302: }
6303:
6304: if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai)
6305: {
6306: return(d_faux);
6307: }
6308:
6309: if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai)
6310: {
6311: return(d_faux);
6312: }
6313:
6314: return(d_vrai);
6315: }
6316:
6317:
6318: unsigned char *
6319: date_compilation(struct_processus *s_etat_processus)
6320: {
6321: unsigned char *date;
6322:
6323: if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char)))
6324: == NULL)
6325: {
6326: return(NULL);
6327: }
6328:
6329: strcpy(date, d_date_en_rpl);
6330:
6331: return(date);
6332: }
6333:
6334: #pragma GCC diagnostic pop
6335:
6336: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>