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