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