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