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: (*s_etat_processus).autorisation_nom_implicite = 'Y';
1837: (*s_etat_processus).autorisation_empilement_programme = 'N';
1838: (*s_etat_processus).requete_arret = 'N';
1839: (*s_etat_processus).evaluation_forcee = 'N';
1840: (*s_etat_processus).recherche_type = 'N';
1841:
1842: (*s_etat_processus).constante_symbolique = 'N';
1843: (*s_etat_processus).traitement_symbolique = 'N';
1844:
1845: (*s_etat_processus).expression_courante = NULL;
1846: (*s_etat_processus).objet_courant = NULL;
1847: (*s_etat_processus).evaluation_expression_compilee = 'N';
1848:
1849: (*s_etat_processus).l_base_pile = NULL;
1850: (*s_etat_processus).l_base_pile_last = NULL;
1851:
1852: (*s_etat_processus).s_liste_variables = NULL;
1853: (*s_etat_processus).gel_liste_variables = d_faux;
1854: (*s_etat_processus).nombre_variables = 0;
1855: (*s_etat_processus).nombre_variables_allouees = 0;
1856: (*s_etat_processus).s_liste_variables_statiques = NULL;
1857: (*s_etat_processus).nombre_variables_statiques = 0;
1858: (*s_etat_processus).nombre_variables_statiques_allouees = 0;
1859: (*s_etat_processus).niveau_courant = 0;
1860: (*s_etat_processus).niveau_initial = 0;
1861: (*s_etat_processus).creation_variables_statiques = d_faux;
1862: (*s_etat_processus).creation_variables_partagees = d_faux;
1863: (*s_etat_processus).position_variable_courante = 0;
1864: (*s_etat_processus).position_variable_statique_courante = 0;
1865:
1866: (*s_etat_processus).s_bibliotheques = NULL;
1867: (*s_etat_processus).s_instructions_externes = NULL;
1868: (*s_etat_processus).nombre_instructions_externes = 0;
1869:
1870: (*s_etat_processus).systeme_axes = 0;
1871:
1872: (*s_etat_processus).x_min = -10.;
1873: (*s_etat_processus).x_max = 10.;
1874: (*s_etat_processus).y_min = -10.;
1875: (*s_etat_processus).y_max = 10.;
1876: (*s_etat_processus).z_min = -10.;
1877: (*s_etat_processus).z_max = 10.;
1878:
1879: (*s_etat_processus).x2_min = -10.;
1880: (*s_etat_processus).x2_max = 10.;
1881: (*s_etat_processus).y2_min = -10.;
1882: (*s_etat_processus).y2_max = 10.;
1883: (*s_etat_processus).z2_min = -10.;
1884: (*s_etat_processus).z2_max = 10.;
1885:
1886: (*s_etat_processus).resolution = .01;
1887:
1888: (*s_etat_processus).souris_active = d_faux;
1889:
1890: (*s_etat_processus).echelle_automatique_x = d_faux;
1891: (*s_etat_processus).echelle_automatique_y = d_faux;
1892: (*s_etat_processus).echelle_automatique_z = d_faux;
1893:
1894: (*s_etat_processus).echelle_automatique_x2 = d_faux;
1895: (*s_etat_processus).echelle_automatique_y2 = d_faux;
1896: (*s_etat_processus).echelle_automatique_z2 = d_faux;
1897:
1898: (*s_etat_processus).echelle_log_x = d_faux;
1899: (*s_etat_processus).echelle_log_y = d_faux;
1900: (*s_etat_processus).echelle_log_z = d_faux;
1901:
1902: (*s_etat_processus).echelle_log_x2 = d_faux;
1903: (*s_etat_processus).echelle_log_y2 = d_faux;
1904: (*s_etat_processus).echelle_log_z2 = d_faux;
1905:
1906: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
1907: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
1908: (*s_etat_processus).echelle_3D = 1;
1909:
1910: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
1911: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
1912: (*s_etat_processus).fichiers_graphiques = NULL;
1913: (*s_etat_processus).nom_fichier_impression = NULL;
1914: strcpy((*s_etat_processus).format_papier, "a4paper");
1915: (*s_etat_processus).entree_standard = NULL;
1916: (*s_etat_processus).s_marques = NULL;
1917: (*s_etat_processus).requete_nouveau_plan = d_vrai;
1918: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
1919:
1920: (*s_etat_processus).l_base_pile = NULL;
1921: (*s_etat_processus).hauteur_pile_operationnelle = 0;
1922: (*s_etat_processus).l_base_pile_contextes = NULL;
1923: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
1924:
1925: (*s_etat_processus).position_courante = 0;
1926:
1927: (*s_etat_processus).l_base_pile_systeme = NULL;
1928: (*s_etat_processus).hauteur_pile_systeme = 0;
1929:
1930: (*s_etat_processus).l_base_pile_processus = NULL;
1931: (*s_etat_processus).presence_pipes = d_faux;
1932: (*s_etat_processus).pipe_donnees = 0;
1933: (*s_etat_processus).pipe_acquittement = 0;
1934: (*s_etat_processus).pipe_injections = 0;
1935: (*s_etat_processus).pipe_nombre_injections = 0;
1936: (*s_etat_processus).nombre_objets_injectes = 0;
1937: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
1938: (*s_etat_processus).pourcentage_maximal_cpu = 100;
1939: (*s_etat_processus).temps_maximal_cpu = 0;
1940: (*s_etat_processus).thread_fusible = 0;
1941: (*s_etat_processus).presence_fusible = d_faux;
1942:
1943: (*s_etat_processus).niveau_recursivite = 0;
1944: (*s_etat_processus).generateur_aleatoire = NULL;
1945: (*s_etat_processus).type_generateur_aleatoire = NULL;
1946:
1947: (*s_etat_processus).colonne_statistique_1 = 1;
1948: (*s_etat_processus).colonne_statistique_2 = 2;
1949:
1950: (*s_etat_processus).debug_programme = d_faux;
1951: (*s_etat_processus).execution_pas_suivant = d_faux;
1952: (*s_etat_processus).traitement_instruction_halt = d_faux;
1953:
1954: (*s_etat_processus).derniere_exception = d_ep;
1955: (*s_etat_processus).derniere_erreur_systeme = d_es;
1956: (*s_etat_processus).derniere_erreur_execution = d_ex;
1957: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
1958: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
1959:
1960: (*s_etat_processus).erreur_processus_fils = d_faux;
1961: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
1962: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
1963: (*s_etat_processus).pid_erreur_processus_fils = 0;
1964: (*s_etat_processus).exception_processus_fils = d_ep;
1965: (*s_etat_processus).core = core;
1966: (*s_etat_processus).invalidation_message_erreur = d_faux;
1967: (*s_etat_processus).s_objet_errone = NULL;
1968: (*s_etat_processus).s_objet_erreur = NULL;
1969:
1970: (*s_etat_processus).retour_routine_evaluation = 'N';
1971:
1972: (*s_etat_processus).traitement_interruption = 'N';
1973: (*s_etat_processus).traitement_interruptible = 'Y';
1974: (*s_etat_processus).nombre_interruptions_en_queue = 0;
1975: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
1976:
1977: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
1978: {
1979: (*s_etat_processus).masque_interruptions[i] = 'N';
1980: (*s_etat_processus).queue_interruptions[i] = 0;
1981: (*s_etat_processus).corps_interruptions[i] = NULL;
1982: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
1983: }
1984:
1985: (*s_etat_processus).at_exit = NULL;
1986: (*s_etat_processus).at_poke = NULL;
1987: (*s_etat_processus).traitement_at_poke = 'N';
1988:
1989: (*s_etat_processus).pointeurs_caracteres = NULL;
1990: (*s_etat_processus).arbre_instructions = NULL;
1991:
1992: (*s_etat_processus).tid_processus_pere = pthread_self();
1993: (*s_etat_processus).pid_processus_pere = getpid();
1994: (*s_etat_processus).processus_detache = d_vrai;
1995: (*s_etat_processus).var_volatile_processus_pere = -1;
1996: (*s_etat_processus).var_volatile_processus_racine = -1;
1997: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1998: (*s_etat_processus).var_volatile_alarme = 0;
1999: (*s_etat_processus).var_volatile_requete_arret = 0;
2000: (*s_etat_processus).var_volatile_requete_arret2 = 0;
2001: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
2002: (*s_etat_processus).var_volatile_traitement_sigint = 0;
2003: (*s_etat_processus).var_volatile_recursivite = 0;
2004: (*s_etat_processus).var_volatile_exception_gsl = 0;
2005: (*s_etat_processus).arret_depuis_abort = 0;
2006:
2007: initialisation_allocateur(s_etat_processus);
2008: initialisation_drapeaux(s_etat_processus);
2009:
2010: if ((*s_etat_processus).erreur_systeme != d_es)
2011: {
2012: if ((*s_etat_processus).langue == 'F')
2013: {
2014: printf("+++Système : Mémoire insuffisante\n");
2015: }
2016: else
2017: {
2018: printf("+++System : Not enough memory\n");
2019: }
2020:
2021: return(EXIT_FAILURE);
2022: }
2023:
2024: if (((*s_etat_processus).instruction_derniere_erreur =
2025: malloc(sizeof(unsigned char))) == NULL)
2026: {
2027: erreur = d_es_allocation_memoire;
2028:
2029: if ((*s_etat_processus).langue == 'F')
2030: {
2031: printf("+++Système : Mémoire insuffisante\n");
2032: }
2033: else
2034: {
2035: printf("+++System : Not enough memory\n");
2036: }
2037:
2038: return(EXIT_FAILURE);
2039: }
2040:
2041: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
2042: (*s_etat_processus).niveau_derniere_erreur = 0;
2043:
2044: if (traitement_fichier_temporaire == 'Y')
2045: {
2046: (*s_etat_processus).mode_interactif = 'Y';
2047: }
2048: else
2049: {
2050: (*s_etat_processus).mode_interactif = 'N';
2051: }
2052:
2053: if (((*s_etat_processus).instruction_courante = (unsigned char *)
2054: malloc(sizeof(unsigned char))) == NULL)
2055: {
2056: erreur = d_es_allocation_memoire;
2057:
2058: if ((*s_etat_processus).langue == 'F')
2059: {
2060: printf("+++Système : Mémoire insuffisante\n");
2061: }
2062: else
2063: {
2064: printf("+++System : Not enough memory\n");
2065: }
2066:
2067: return(EXIT_FAILURE);
2068: }
2069:
2070: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
2071:
2072: empilement_pile_systeme(s_etat_processus);
2073:
2074: free((*s_etat_processus).instruction_courante);
2075:
2076: if ((*s_etat_processus).erreur_systeme != d_es)
2077: {
2078: erreur = d_es_allocation_memoire;
2079: }
2080: else
2081: {
2082: (*((*s_etat_processus).l_base_pile_systeme))
2083: .retour_definition = 'Y';
2084:
2085: (*s_etat_processus).indep = (struct_objet *) malloc(
2086: sizeof(struct_objet));
2087: (*s_etat_processus).depend = (struct_objet *) malloc(
2088: sizeof(struct_objet));
2089: (*s_etat_processus).parametres_courbes_de_niveau =
2090: (struct_objet *) malloc(sizeof(struct_objet));
2091:
2092: if (((*s_etat_processus).indep != NULL) &&
2093: ((*s_etat_processus).depend != NULL) &&
2094: ((*s_etat_processus).parametres_courbes_de_niveau
2095: != NULL))
2096: {
2097: (*((*s_etat_processus).indep)).type = NOM;
2098: (*((*s_etat_processus).depend)).type = NOM;
2099: (*((*s_etat_processus).
2100: parametres_courbes_de_niveau)).type = LST;
2101:
2102: initialisation_objet((*s_etat_processus).indep);
2103: initialisation_objet((*s_etat_processus).depend);
2104: initialisation_objet((*s_etat_processus)
2105: .parametres_courbes_de_niveau);
2106:
2107: (*((*s_etat_processus).indep)).objet = (struct_nom *)
2108: malloc(sizeof(struct_nom));
2109: (*((*s_etat_processus).depend)).objet = (struct_nom *)
2110: malloc(sizeof(struct_nom));
2111: (*((*s_etat_processus).parametres_courbes_de_niveau))
2112: .objet = (struct_liste_chainee *)
2113: malloc(sizeof(struct_liste_chainee));
2114:
2115: if (((*((*s_etat_processus).depend)).objet == NULL) ||
2116: ((*((*s_etat_processus).depend)).objet == NULL) ||
2117: ((*((*s_etat_processus).
2118: parametres_courbes_de_niveau)).objet == NULL))
2119: {
2120: erreur = d_es_allocation_memoire;
2121:
2122: if ((*s_etat_processus).langue == 'F')
2123: {
2124: printf("+++Système : Mémoire insuffisante\n");
2125: }
2126: else
2127: {
2128: printf("+++System : Not enough memory\n");
2129: }
2130:
2131: return(EXIT_FAILURE);
2132: }
2133:
2134: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
2135: .nom = malloc(2 * sizeof(unsigned char));
2136: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
2137: .nom = malloc(2 * sizeof(unsigned char));
2138:
2139: if (((*((struct_nom *) (*((*s_etat_processus).indep))
2140: .objet)).nom == NULL) || ((*((struct_nom *)
2141: (*((*s_etat_processus).depend)).objet)).nom ==
2142: NULL))
2143: {
2144: erreur = d_es_allocation_memoire;
2145:
2146: if ((*s_etat_processus).langue == 'F')
2147: {
2148: printf("+++Système : Mémoire insuffisante\n");
2149: }
2150: else
2151: {
2152: printf("+++System : Not enough memory\n");
2153: }
2154:
2155: return(EXIT_FAILURE);
2156: }
2157:
2158: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
2159: .objet)).nom, "X");
2160: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
2161: .objet)).nom, "Y");
2162:
2163: (*((struct_nom *) (*((*s_etat_processus).indep))
2164: .objet)).symbole = d_vrai;
2165: (*((struct_nom *) (*((*s_etat_processus).depend))
2166: .objet)).symbole = d_vrai;
2167:
2168: (*((struct_liste_chainee *) (*((*s_etat_processus)
2169: .parametres_courbes_de_niveau)).objet)).suivant
2170: = NULL;
2171:
2172: (*((struct_liste_chainee *) (*((*s_etat_processus)
2173: .parametres_courbes_de_niveau)).objet)).donnee
2174: = malloc(sizeof(struct_objet));
2175:
2176: (*s_etat_processus).legende =
2177: malloc(sizeof(unsigned char));
2178: (*s_etat_processus).label_x =
2179: malloc(sizeof(unsigned char));
2180: (*s_etat_processus).label_y =
2181: malloc(sizeof(unsigned char));
2182: (*s_etat_processus).label_z =
2183: malloc(sizeof(unsigned char));
2184: (*s_etat_processus).titre =
2185: malloc(sizeof(unsigned char));
2186:
2187: if (((*s_etat_processus).label_x == NULL) ||
2188: ((*s_etat_processus).label_y == NULL) ||
2189: ((*s_etat_processus).label_z == NULL) ||
2190: ((*s_etat_processus).titre == NULL) ||
2191: ((*s_etat_processus).legende == NULL) ||
2192: ((*((struct_liste_chainee *) (*((*s_etat_processus)
2193: .parametres_courbes_de_niveau)).objet)).donnee
2194: == NULL))
2195: {
2196: erreur = d_es_allocation_memoire;
2197:
2198: if ((*s_etat_processus).langue == 'F')
2199: {
2200: printf("+++Système : Mémoire insuffisante\n");
2201: }
2202: else
2203: {
2204: printf("+++System : Not enough memory\n");
2205: }
2206:
2207: return(EXIT_FAILURE);
2208: }
2209:
2210: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
2211: .parametres_courbes_de_niveau)).objet)).donnee)
2212: .type = CHN;
2213:
2214: initialisation_objet((*((struct_liste_chainee *)
2215: (*((*s_etat_processus)
2216: .parametres_courbes_de_niveau))
2217: .objet)).donnee);
2218:
2219: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
2220: .parametres_courbes_de_niveau)).objet)).donnee)
2221: .objet = malloc(10 * sizeof(unsigned char)))
2222: == NULL)
2223: {
2224: erreur = d_es_allocation_memoire;
2225:
2226: if ((*s_etat_processus).langue == 'F')
2227: {
2228: printf("+++Système : Mémoire insuffisante\n");
2229: }
2230: else
2231: {
2232: printf("+++System : Not enough memory\n");
2233: }
2234:
2235: return(EXIT_FAILURE);
2236: }
2237:
2238: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
2239: (*((*s_etat_processus)
2240: .parametres_courbes_de_niveau))
2241: .objet)).donnee).objet, "AUTOMATIC");
2242:
2243: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
2244: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
2245: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
2246: (*s_etat_processus).titre[0] = d_code_fin_chaine;
2247: (*s_etat_processus).legende[0] = d_code_fin_chaine;
2248:
2249: (*s_etat_processus).nom_fichier_gnuplot = NULL;
2250: (*s_etat_processus).type_fichier_gnuplot = NULL;
2251:
2252: (*s_etat_processus).x_tics = 0;
2253: (*s_etat_processus).y_tics = 0;
2254: (*s_etat_processus).z_tics = 0;
2255:
2256: (*s_etat_processus).x_lines = d_vrai;
2257: (*s_etat_processus).y_lines = d_vrai;
2258: (*s_etat_processus).z_lines = d_vrai;
2259:
2260: (*s_etat_processus).mx_tics = -1;
2261: (*s_etat_processus).my_tics = -1;
2262: (*s_etat_processus).mz_tics = -1;
2263:
2264: (*s_etat_processus).mx_lines = d_faux;
2265: (*s_etat_processus).my_lines = d_faux;
2266: (*s_etat_processus).mz_lines = d_faux;
2267:
2268: (*s_etat_processus).x2_tics = -1;
2269: (*s_etat_processus).y2_tics = -1;
2270: (*s_etat_processus).z2_tics = -1;
2271:
2272: (*s_etat_processus).x2_lines = d_faux;
2273: (*s_etat_processus).y2_lines = d_faux;
2274: (*s_etat_processus).z2_lines = d_faux;
2275:
2276: (*s_etat_processus).mx2_tics = -1;
2277: (*s_etat_processus).my2_tics = -1;
2278: (*s_etat_processus).mz2_tics = -1;
2279:
2280: (*s_etat_processus).mx2_lines = d_faux;
2281: (*s_etat_processus).my2_lines = d_faux;
2282: (*s_etat_processus).mz2_lines = d_faux;
2283:
2284: if ((*s_etat_processus).erreur_systeme != d_es)
2285: {
2286: if ((*s_etat_processus).langue == 'F')
2287: {
2288: printf("+++Système : Mémoire insuffisante\n");
2289: }
2290: else
2291: {
2292: printf("+++System : Not enough memory\n");
2293: }
2294:
2295: return(EXIT_FAILURE);
2296: }
2297:
2298: (*s_etat_processus).mode_evaluation_expression = 'N';
2299: (*s_etat_processus).mode_execution_programme = 'Y';
2300:
2301: if ((*s_etat_processus).definitions_chainees == NULL)
2302: {
2303: if ((erreur = chainage(s_etat_processus)) !=
2304: d_absence_erreur)
2305: {
2306: if ((*s_etat_processus).langue == 'F')
2307: {
2308: printf("+++Fatal :"
2309: " Chaînage des définitions"
2310: " impossible\n");
2311: }
2312: else
2313: {
2314: printf("+++Fatal : Error in "
2315: "compilation\n");
2316: }
2317:
2318: if (traitement_fichier_temporaire == 'Y')
2319: {
2320: if (destruction_fichier(
2321: nom_fichier_temporaire)
2322: == d_erreur)
2323: {
2324: return(EXIT_FAILURE);
2325: }
2326:
2327: free(nom_fichier_temporaire);
2328: }
2329:
2330: return(EXIT_FAILURE);
2331: }
2332: }
2333:
2334: if ((erreur = compilation(s_etat_processus)) !=
2335: d_absence_erreur)
2336: {
2337: if (traitement_fichier_temporaire == 'Y')
2338: {
2339: if (destruction_fichier(nom_fichier_temporaire)
2340: == d_erreur)
2341: {
2342: return(EXIT_FAILURE);
2343: }
2344:
2345: free(nom_fichier_temporaire);
2346: }
2347:
2348: printf("%s [%d]\n", message =
2349: messages(s_etat_processus), (int) getpid());
2350: free(message);
2351:
2352: if (test_cfsf(s_etat_processus, 51) == d_faux)
2353: {
2354: printf("%s", ds_beep);
2355: }
2356:
2357: if ((*s_etat_processus).core == d_vrai)
2358: {
2359: printf("\n");
2360:
2361: if ((*s_etat_processus).langue == 'F')
2362: {
2363: printf("+++Information : Génération du fichier "
2364: "rpl-core [%d]\n", (int) getpid());
2365: }
2366: else
2367: {
2368: printf("+++Information : Writing rpl-core "
2369: "file [%d]\n", (int) getpid());
2370: }
2371:
2372: rplcore(s_etat_processus);
2373:
2374: if ((*s_etat_processus).langue == 'F')
2375: {
2376: printf("+++Information : Processus tracé "
2377: "[%d]\n", (int) getpid());
2378: }
2379: else
2380: {
2381: printf("+++Information : Done [%d]\n",
2382: (int) getpid());
2383: }
2384:
2385: printf("\n");
2386: }
2387:
2388: return(EXIT_FAILURE);
2389: }
2390:
2391: (*s_etat_processus).position_courante = 0;
2392: (*s_etat_processus).traitement_cycle_exit = 'N';
2393:
2394: if ((*s_etat_processus).nombre_variables == 0)
2395: {
2396: if ((*s_etat_processus).langue == 'F')
2397: {
2398: printf("+++Fatal : Aucun point d'entrée\n");
2399: }
2400: else
2401: {
2402: printf("+++Fatal : Any entry point\n");
2403: }
2404:
2405: if (test_cfsf(s_etat_processus, 51) == d_faux)
2406: {
2407: printf("%s", ds_beep);
2408: }
2409:
2410: return(EXIT_FAILURE);
2411: }
2412:
2413: if (recherche_instruction_suivante(s_etat_processus)
2414: == d_erreur)
2415: {
2416: if ((*s_etat_processus).langue == 'F')
2417: {
2418: printf("+++Fatal : Aucun point d'entrée\n");
2419: }
2420: else
2421: {
2422: printf("+++Fatal : Any entry point\n");
2423: }
2424:
2425: if (test_cfsf(s_etat_processus, 51) == d_faux)
2426: {
2427: printf("%s", ds_beep);
2428: }
2429:
2430: return(EXIT_FAILURE);
2431: }
2432:
2433: if (recherche_variable(s_etat_processus,
2434: (*s_etat_processus)
2435: .instruction_courante) == d_faux)
2436: {
2437: if ((*s_etat_processus).langue == 'F')
2438: {
2439: printf("+++Fatal : Aucun point d'entrée\n");
2440: }
2441: else
2442: {
2443: printf("+++Fatal : Any entry point\n");
2444: }
2445:
2446: if (test_cfsf(s_etat_processus, 51) == d_faux)
2447: {
2448: printf("%s", ds_beep);
2449: }
2450:
2451: return(EXIT_FAILURE);
2452: }
2453:
2454: if ((*s_etat_processus).s_liste_variables
2455: [(*s_etat_processus)
2456: .position_variable_courante].niveau != 0)
2457: {
2458: if ((*s_etat_processus).langue == 'F')
2459: {
2460: printf("+++Fatal : Aucun point d'entrée\n");
2461: }
2462: else
2463: {
2464: printf("+++Fatal : Any entry point\n");
2465: }
2466:
2467: if (test_cfsf(s_etat_processus, 51) == d_faux)
2468: {
2469: printf("%s", ds_beep);
2470: }
2471:
2472: return(EXIT_FAILURE);
2473: }
2474:
2475: free((*s_etat_processus).instruction_courante);
2476: (*s_etat_processus).position_courante = 0;
2477:
2478: if (((*s_etat_processus).nom_fichier_historique =
2479: malloc((strlen(home) +
2480: strlen(ds_fichier_historique) + 2) *
2481: sizeof(unsigned char))) == NULL)
2482: {
2483: erreur = d_es_allocation_memoire;
2484:
2485: if ((*s_etat_processus).langue == 'F')
2486: {
2487: printf("+++Système : Mémoire insuffisante\n");
2488: }
2489: else
2490: {
2491: printf("+++System : Not enough memory\n");
2492: }
2493:
2494: return(EXIT_FAILURE);
2495: }
2496:
2497: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
2498: home, ds_fichier_historique);
2499:
2500: using_history();
2501: erreur_historique = read_history(
2502: (*s_etat_processus).nom_fichier_historique);
2503:
2504: gsl_set_error_handler(&traitement_exceptions_gsl);
2505:
2506: if (drapeau_encart == 'Y')
2507: {
2508: (*s_etat_processus).erreur_systeme = d_es;
2509: encart(s_etat_processus,
2510: (unsigned long) (5 * 1000000));
2511:
2512: if ((*s_etat_processus).erreur_systeme != d_es)
2513: {
2514: if ((message = messages(s_etat_processus))
2515: == NULL)
2516: {
2517: erreur = d_es_allocation_memoire;
2518:
2519: if ((*s_etat_processus).langue == 'F')
2520: {
2521: printf("+++Système : Mémoire "
2522: "insuffisante\n");
2523: }
2524: else
2525: {
2526: printf("+++System : Not enough "
2527: "memory\n");
2528: }
2529:
2530: return(EXIT_FAILURE);
2531: }
2532:
2533: printf("%s [%d]\n", message, (int) getpid());
2534: free(message);
2535:
2536: return(EXIT_FAILURE);
2537: }
2538: }
2539:
2540: fflush(stdout);
2541:
2542: initialisation_instructions(s_etat_processus);
2543: initialisation_variables(s_etat_processus);
2544:
2545: if (arguments != NULL)
2546: {
2547: tampon = (*s_etat_processus).definitions_chainees;
2548: (*s_etat_processus).definitions_chainees =
2549: arguments;
2550:
2551: if (analyse_syntaxique(s_etat_processus) ==
2552: d_erreur)
2553: {
2554: if ((*s_etat_processus).erreur_systeme != d_es)
2555: {
2556: erreur = d_es_allocation_memoire;
2557:
2558: if ((*s_etat_processus).langue == 'F')
2559: {
2560: printf("+++Système : Mémoire "
2561: "insuffisante\n");
2562: }
2563: else
2564: {
2565: printf("+++System : Not enough "
2566: "memory\n");
2567: }
2568:
2569: return(EXIT_FAILURE);
2570: }
2571: else
2572: {
2573: if ((*s_etat_processus).langue == 'F')
2574: {
2575: printf("+++Erreur : Erreur de "
2576: "syntaxe\n");
2577: }
2578: else
2579: {
2580: printf("+++Error : Syntax error\n");
2581: }
2582:
2583: return(EXIT_FAILURE);
2584: }
2585: }
2586:
2587: (*s_etat_processus).instruction_courante
2588: = arguments;
2589: (*s_etat_processus).definitions_chainees = tampon;
2590: (*s_etat_processus).position_courante = 0;
2591:
2592: recherche_type(s_etat_processus);
2593:
2594: if ((*s_etat_processus).erreur_systeme != d_es)
2595: {
2596: if ((message = messages(s_etat_processus))
2597: == NULL)
2598: {
2599: erreur = d_es_allocation_memoire;
2600:
2601: if ((*s_etat_processus).langue == 'F')
2602: {
2603: printf("+++Système : Mémoire "
2604: "insuffisante\n");
2605: }
2606: else
2607: {
2608: printf("+++System : Not enough "
2609: "memory\n");
2610: }
2611:
2612: return(EXIT_FAILURE);
2613: }
2614:
2615: printf("%s [%d]\n", message, (int) getpid());
2616: free(message);
2617:
2618: return(EXIT_FAILURE);
2619: }
2620:
2621: if ((*s_etat_processus).erreur_execution != d_ex)
2622: {
2623: if ((message = messages(s_etat_processus))
2624: == NULL)
2625: {
2626: erreur = d_es_allocation_memoire;
2627:
2628: if ((*s_etat_processus).langue == 'F')
2629: {
2630: printf("+++Erreur : Mémoire "
2631: "insuffisante\n");
2632: }
2633: else
2634: {
2635: printf("+++Error : Not enough "
2636: "memory\n");
2637: }
2638:
2639: return(EXIT_FAILURE);
2640: }
2641:
2642: printf("%s [%d]\n", message, (int) getpid());
2643: free(message);
2644:
2645: return(EXIT_FAILURE);
2646: }
2647:
2648: if (depilement(s_etat_processus,
2649: &((*s_etat_processus).l_base_pile),
2650: &s_objet) == d_erreur)
2651: {
2652: if ((message = messages(s_etat_processus))
2653: == NULL)
2654: {
2655: erreur = d_es_allocation_memoire;
2656:
2657: if ((*s_etat_processus).langue == 'F')
2658: {
2659: printf("+++Erreur : Mémoire "
2660: "insuffisante\n");
2661: }
2662: else
2663: {
2664: printf("+++Error : Not enough "
2665: "memory\n");
2666: }
2667:
2668: return(EXIT_FAILURE);
2669: }
2670:
2671: printf("%s [%d]\n", message, (int) getpid());
2672: free(message);
2673:
2674: return(EXIT_FAILURE);
2675: }
2676:
2677: if (evaluation(s_etat_processus, s_objet, 'E')
2678: == d_erreur)
2679: {
2680: if ((*s_etat_processus).erreur_systeme != d_es)
2681: {
2682: if ((message = messages(s_etat_processus))
2683: == NULL)
2684: {
2685: erreur = d_es_allocation_memoire;
2686:
2687: if ((*s_etat_processus).langue == 'F')
2688: {
2689: printf("+++Système : Mémoire "
2690: "insuffisante\n");
2691: }
2692: else
2693: {
2694: printf("+++System : Not enough "
2695: "memory\n");
2696: }
2697:
2698: return(EXIT_FAILURE);
2699: }
2700:
2701: printf("%s [%d]\n", message,
2702: (int) getpid());
2703: free(message);
2704:
2705: return(EXIT_FAILURE);
2706: }
2707:
2708: if ((*s_etat_processus).erreur_execution
2709: != d_ex)
2710: {
2711: if ((message = messages(s_etat_processus))
2712: == NULL)
2713: {
2714: erreur = d_es_allocation_memoire;
2715:
2716: if ((*s_etat_processus).langue == 'F')
2717: {
2718: printf("+++Erreur : Mémoire "
2719: "insuffisante\n");
2720: }
2721: else
2722: {
2723: printf("+++Error : Not enough "
2724: "memory\n");
2725: }
2726:
2727: return(EXIT_FAILURE);
2728: }
2729:
2730: printf("%s [%d]\n", message,
2731: (int) getpid());
2732: free(message);
2733:
2734: return(EXIT_FAILURE);
2735: }
2736: }
2737:
2738: (*s_etat_processus).instruction_courante = NULL;
2739: liberation(s_etat_processus, s_objet);
2740:
2741: free(arguments);
2742: }
2743:
2744: if (option_a == d_vrai)
2745: {
2746: fprintf(stdout, "%s\n", (*s_etat_processus)
2747: .definitions_chainees);
2748: }
2749: else
2750: {
2751: if (option_D == d_vrai)
2752: {
2753: lancement_daemon(s_etat_processus);
2754: }
2755:
2756: if (option_p == d_faux)
2757: {
2758: if (setjmp(contexte_initial) == 0)
2759: {
2760: erreur = sequenceur(s_etat_processus);
2761: }
2762: }
2763: else
2764: {
2765: if (setjmp(contexte_initial) == 0)
2766: {
2767: erreur = sequenceur_optimise(s_etat_processus);
2768: }
2769: }
2770:
2771: if (erreur == d_absence_erreur)
2772: {
2773: if (((*s_etat_processus).var_volatile_alarme == 0)
2774: && ((*s_etat_processus).arret_depuis_abort
2775: == 0) && ((*s_etat_processus).at_exit
2776: != NULL))
2777: {
2778: erreur = evaluation(s_etat_processus,
2779: (*s_etat_processus).at_exit, 'E');
2780: }
2781: }
2782: }
2783:
2784: liberation(s_etat_processus, (*s_etat_processus).at_exit);
2785: liberation(s_etat_processus, (*s_etat_processus).at_poke);
2786:
2787: if ((*s_etat_processus).generateur_aleatoire != NULL)
2788: {
2789: liberation_generateur_aleatoire(s_etat_processus);
2790: }
2791:
2792: l_element_courant = (*s_etat_processus).liste_mutexes;
2793: while(l_element_courant != NULL)
2794: {
2795: pthread_mutex_trylock(&((*((struct_mutex *)
2796: (*(*((struct_liste_chainee *)
2797: l_element_courant)).donnee).objet)).mutex));
2798: pthread_mutex_unlock(&((*((struct_mutex *)
2799: (*(*((struct_liste_chainee *)
2800: l_element_courant)).donnee).objet)).mutex));
2801: pthread_mutex_destroy(&((*((struct_mutex *)
2802: (*(*((struct_liste_chainee *)
2803: l_element_courant)).donnee).objet)).mutex));
2804:
2805: liberation(s_etat_processus,
2806: (*((struct_liste_chainee *)
2807: l_element_courant)).donnee);
2808: l_element_suivant = (*((struct_liste_chainee *)
2809: l_element_courant)).suivant;
2810: free((struct_liste_chainee *) l_element_courant);
2811: l_element_courant = l_element_suivant;
2812: }
2813:
2814: /*
2815: * Arrêt des processus fils
2816: */
2817:
2818: if ((*s_etat_processus).presence_fusible == d_vrai)
2819: {
2820: pthread_cancel((*s_etat_processus).thread_fusible);
2821: }
2822:
2823: pthread_mutex_lock(&((*s_etat_processus).mutex));
2824:
2825: l_element_courant = (void *) (*s_etat_processus)
2826: .l_base_pile_processus;
2827:
2828: while(l_element_courant != NULL)
2829: {
2830: if ((*s_etat_processus).debug == d_vrai)
2831: {
2832: if (((*s_etat_processus).type_debug &
2833: d_debug_processus) != 0)
2834: {
2835: if ((*(*((struct_processus_fils *)
2836: (*(*((struct_liste_chainee *)
2837: l_element_courant)).donnee)
2838: .objet)).thread)
2839: .processus_detache == d_vrai)
2840: {
2841: if ((*s_etat_processus).langue == 'F')
2842: {
2843: printf("[%d] Signalement pour arrêt du "
2844: "processus %d\n",
2845: (int) getpid(), (int)
2846: (*(*((struct_processus_fils *)
2847: (*(*((struct_liste_chainee *)
2848: l_element_courant)).donnee)
2849: .objet)).thread).pid);
2850: }
2851: else
2852: {
2853: printf("[%d] Send stop signal to "
2854: "process %d\n",
2855: (int) getpid(), (int)
2856: (*(*((struct_processus_fils *)
2857: (*(*((struct_liste_chainee *)
2858: l_element_courant)).donnee)
2859: .objet)).thread).pid);
2860: }
2861: }
2862: else
2863: {
2864: if ((*s_etat_processus).langue == 'F')
2865: {
2866: printf("[%d] Signalement pour arrêt du "
2867: "thread %llu\n", (int) getpid(),
2868: (unsigned long long)
2869: (*(*((struct_processus_fils *)
2870: (*(*((struct_liste_chainee *)
2871: l_element_courant)).donnee)
2872: .objet)).thread).tid);
2873: }
2874: else
2875: {
2876: printf("[%d] Send stop signal to "
2877: "thread %llu\n",
2878: (int) getpid(),
2879: (unsigned long long)
2880: (*(*((struct_processus_fils *)
2881: (*(*((struct_liste_chainee *)
2882: l_element_courant)).donnee)
2883: .objet)).thread).tid);
2884: }
2885: }
2886: }
2887: }
2888:
2889: if ((*(*((struct_processus_fils *)
2890: (*(*((struct_liste_chainee *)
2891: l_element_courant)).donnee).objet))
2892: .thread).processus_detache == d_vrai)
2893: {
2894: if ((*s_etat_processus).var_volatile_alarme != 0)
2895: {
2896: kill((*(*((struct_processus_fils *)
2897: (*(*((struct_liste_chainee *)
2898: l_element_courant)).donnee).objet))
2899: .thread).pid, SIGURG);
2900: }
2901: else
2902: {
2903: if ((*s_etat_processus).arret_depuis_abort
2904: == -1)
2905: {
2906: kill((*(*((struct_processus_fils *)
2907: (*(*((struct_liste_chainee *)
2908: l_element_courant)).donnee).objet))
2909: .thread).pid, SIGFABORT);
2910: }
2911: else
2912: {
2913: kill((*(*((struct_processus_fils *)
2914: (*(*((struct_liste_chainee *)
2915: l_element_courant)).donnee).objet))
2916: .thread).pid, SIGFSTOP);
2917: }
2918: }
2919: }
2920: else
2921: {
2922: pthread_mutex_lock(&((*(*((struct_processus_fils *)
2923: (*(*((struct_liste_chainee *)
2924: l_element_courant)).donnee).objet)).thread)
2925: .mutex));
2926:
2927: if ((*(*((struct_processus_fils *)
2928: (*(*((struct_liste_chainee *)
2929: l_element_courant)).donnee).objet)).thread)
2930: .thread_actif == d_vrai)
2931: {
2932: if ((*s_etat_processus).var_volatile_alarme
2933: != 0)
2934: {
2935: pthread_kill((*(*((struct_processus_fils *)
2936: (*(*((struct_liste_chainee *)
2937: l_element_courant)).donnee).objet))
2938: .thread).tid, SIGURG);
2939: }
2940: else
2941: {
2942: if ((*s_etat_processus).arret_depuis_abort
2943: == -1)
2944: {
2945: pthread_kill(
2946: (*(*((struct_processus_fils *)
2947: (*(*((struct_liste_chainee *)
2948: l_element_courant)).donnee)
2949: .objet)).thread).tid,
2950: SIGFABORT);
2951: }
2952: else
2953: {
2954: pthread_kill(
2955: (*(*((struct_processus_fils *)
2956: (*(*((struct_liste_chainee *)
2957: l_element_courant)).donnee)
2958: .objet)).thread).tid,
2959: SIGFSTOP);
2960: }
2961: }
2962: }
2963:
2964: pthread_mutex_unlock(
2965: &((*(*((struct_processus_fils *)
2966: (*(*((struct_liste_chainee *)
2967: l_element_courant)).donnee).objet)).thread)
2968: .mutex));
2969: }
2970:
2971: l_element_courant = (*((struct_liste_chainee *)
2972: l_element_courant)).suivant;
2973: }
2974:
2975: /*
2976: * Attente de la fin de tous les processus fils
2977: */
2978:
2979: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
2980: (*s_etat_processus).masque_interruptions[i++]
2981: = 'I');
2982:
2983: attente.tv_sec = 0;
2984: attente.tv_nsec = GRANULARITE_us * 1000;
2985:
2986: while((*s_etat_processus).l_base_pile_processus != NULL)
2987: {
2988: status = 0;
2989:
2990: l_element_courant = (void *)
2991: (*s_etat_processus).l_base_pile_processus;
2992:
2993: for(i = 0; i < (unsigned long)
2994: (*(*((struct_processus_fils *)
2995: (*(*((struct_liste_chainee *)
2996: l_element_courant)).donnee).objet)).thread)
2997: .nombre_objets_dans_pipe; i++)
2998: {
2999: if ((s_objet = lecture_pipe(
3000: s_etat_processus,
3001: (*(*((struct_processus_fils *)
3002: (*(*((struct_liste_chainee *)
3003: l_element_courant)).donnee).objet)).thread)
3004: .pipe_objets[0])) != NULL)
3005: {
3006: liberation(s_etat_processus, s_objet);
3007:
3008: (*(*((struct_processus_fils *)
3009: (*(*((struct_liste_chainee *)
3010: l_element_courant)).donnee).objet))
3011: .thread).nombre_objets_dans_pipe--;
3012:
3013: action.sa_handler = SIG_IGN;
3014: action.sa_flags = SA_ONSTACK;
3015:
3016: if (sigaction(SIGPIPE, &action, ®istre)
3017: != 0)
3018: {
3019: pthread_mutex_unlock(
3020: &((*s_etat_processus).mutex));
3021: return(EXIT_FAILURE);
3022: }
3023:
3024: while((longueur_ecriture =
3025: write_atomic(s_etat_processus,
3026: (*(*((struct_processus_fils *)
3027: (*(*((struct_liste_chainee *)
3028: l_element_courant)).donnee).objet))
3029: .thread).pipe_nombre_injections[1], "+",
3030: sizeof(unsigned char))) !=
3031: sizeof(unsigned char))
3032: {
3033: if (longueur_ecriture == -1)
3034: {
3035: // Le processus n'existe plus.
3036: break;
3037: }
3038: }
3039:
3040: if (sigaction(SIGPIPE, ®istre, NULL)
3041: != 0)
3042: {
3043: pthread_mutex_unlock(
3044: &((*s_etat_processus).mutex));
3045: return(EXIT_FAILURE);
3046: }
3047: }
3048: }
3049:
3050: pthread_mutex_unlock(&((*s_etat_processus).mutex));
3051:
3052: if ((*s_etat_processus)
3053: .nombre_interruptions_non_affectees != 0)
3054: {
3055: affectation_interruptions_logicielles(
3056: s_etat_processus);
3057: }
3058:
3059: nanosleep(&attente, NULL);
3060: pthread_mutex_lock(&((*s_etat_processus).mutex));
3061: }
3062:
3063: pthread_mutex_unlock(&((*s_etat_processus).mutex));
3064:
3065: erreur_historique = write_history(
3066: (*s_etat_processus).nom_fichier_historique);
3067: clear_history();
3068:
3069: if (erreur_historique != 0)
3070: {
3071: if ((*s_etat_processus).langue == 'F')
3072: {
3073: printf("+++Erreur : L'historique ne peut être "
3074: "écrit\n");
3075: }
3076: else
3077: {
3078: printf("+++Error : History cannot be "
3079: "written\n");
3080: }
3081:
3082: if (test_cfsf(s_etat_processus, 51) == d_faux)
3083: {
3084: printf("%s", ds_beep);
3085: }
3086: }
3087:
3088: free((*s_etat_processus).nom_fichier_historique);
3089:
3090: if (((*s_etat_processus).core == d_vrai) &&
3091: (erreur == d_erreur) &&
3092: ((*s_etat_processus).var_volatile_traitement_sigint
3093: == 0))
3094: {
3095: printf("\n");
3096:
3097: if ((*s_etat_processus).langue == 'F')
3098: {
3099: printf("+++Information : Génération du fichier "
3100: "rpl-core [%d]\n", (int) getpid());
3101: }
3102: else
3103: {
3104: printf("+++Information : Writing rpl-core "
3105: "file [%d]\n", (int) getpid());
3106: }
3107:
3108: rplcore(s_etat_processus);
3109:
3110: if ((*s_etat_processus).langue == 'F')
3111: {
3112: printf("+++Information : Processus tracé [%d]\n",
3113: (int) getpid());
3114: }
3115: else
3116: {
3117: printf("+++Information : Done [%d]\n",
3118: (int) getpid());
3119: }
3120:
3121: printf("\n");
3122: }
3123:
3124: free((*s_etat_processus).definitions_chainees);
3125:
3126: /*
3127: * Libération de l'arbre des instructions
3128: */
3129:
3130: liberation_arbre_instructions(s_etat_processus,
3131: (*s_etat_processus).arbre_instructions);
3132: free((*s_etat_processus).pointeurs_caracteres);
3133:
3134: if ((*s_etat_processus).entree_standard != NULL)
3135: {
3136: pclose((*s_etat_processus).entree_standard);
3137: (*s_etat_processus).entree_standard = NULL;
3138: }
3139:
3140: if ((*s_etat_processus).nom_fichier_impression != NULL)
3141: {
3142: if (test_cfsf(s_etat_processus, 51) == d_faux)
3143: {
3144: printf("%s", ds_beep);
3145: }
3146:
3147: if ((*s_etat_processus).langue == 'F')
3148: {
3149: printf("+++Attention : Queue d'impression "
3150: "non vide !\n");
3151: }
3152: else
3153: {
3154: printf("+++Warning : Non empty printing "
3155: "spool queue !\n");
3156: }
3157:
3158: instruction_erase(s_etat_processus);
3159: }
3160:
3161: if ((*s_etat_processus).fichiers_graphiques != NULL)
3162: {
3163: instruction_cllcd(s_etat_processus);
3164: }
3165:
3166: liberation(s_etat_processus, (*s_etat_processus).indep);
3167: liberation(s_etat_processus, (*s_etat_processus).depend);
3168:
3169: free((*s_etat_processus).label_x);
3170: free((*s_etat_processus).label_y);
3171: free((*s_etat_processus).label_z);
3172: free((*s_etat_processus).titre);
3173: free((*s_etat_processus).legende);
3174:
3175: liberation(s_etat_processus, (*s_etat_processus)
3176: .parametres_courbes_de_niveau);
3177:
3178: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
3179: {
3180: liberation(s_etat_processus,
3181: (*s_etat_processus).corps_interruptions[i]);
3182:
3183: l_element_courant = (*s_etat_processus)
3184: .pile_origine_interruptions[i];
3185:
3186: while(l_element_courant != NULL)
3187: {
3188: l_element_suivant = (*((struct_liste_chainee *)
3189: l_element_courant)).suivant;
3190:
3191: liberation(s_etat_processus,
3192: (*((struct_liste_chainee *)
3193: l_element_courant)).donnee);
3194: free(l_element_courant);
3195:
3196: l_element_courant = l_element_suivant;
3197: }
3198: }
3199:
3200: if ((*s_etat_processus).instruction_derniere_erreur
3201: != NULL)
3202: {
3203: free((*s_etat_processus).instruction_derniere_erreur);
3204: (*s_etat_processus).instruction_derniere_erreur = NULL;
3205: }
3206:
3207: /*
3208: * Le pointeur s_etat_processus.nom_fichier_source est
3209: * alloué par le système. Il ne faut donc pas
3210: * le libérer...
3211: */
3212:
3213: for(i = 0; i < (*s_etat_processus).nombre_variables; i++)
3214: {
3215: liberation(s_etat_processus,
3216: (*s_etat_processus).s_liste_variables[i].objet);
3217: free((*s_etat_processus).s_liste_variables[i].nom);
3218: }
3219:
3220: free((*s_etat_processus).s_liste_variables);
3221:
3222: for(i = 0; i < (*s_etat_processus)
3223: .nombre_variables_statiques; i++)
3224: {
3225: liberation(s_etat_processus, (*s_etat_processus)
3226: .s_liste_variables_statiques[i].objet);
3227: free((*s_etat_processus)
3228: .s_liste_variables_statiques[i].nom);
3229: }
3230:
3231: free((*s_etat_processus).s_liste_variables_statiques);
3232:
3233: for(i = 0; i < (*((*s_etat_processus)
3234: .s_liste_variables_partagees)).nombre_variables;
3235: i++)
3236: {
3237: liberation(s_etat_processus, (*((*s_etat_processus)
3238: .s_liste_variables_partagees)).table[i].objet);
3239: free((*((*s_etat_processus)
3240: .s_liste_variables_partagees)).table[i].nom);
3241: }
3242:
3243: free((struct_variable_partagee *)
3244: (*((*s_etat_processus).s_liste_variables_partagees))
3245: .table);
3246:
3247: /*
3248: * Si resultats est non nul, rplinit a été appelé
3249: * depuis rpl() [librpl] et non main().
3250: * On copie alors le contenu de la * pile dans un
3251: * tableau **resultats dont le pointeur de base a
3252: * été alloué dans rpl().
3253: */
3254:
3255: if (resultats != NULL)
3256: {
3257: if ((*resultats) != NULL)
3258: {
3259: free((*resultats));
3260:
3261: if (((*resultats) = malloc(((*s_etat_processus)
3262: .hauteur_pile_operationnelle + 1)
3263: * sizeof(unsigned char **))) != NULL)
3264: {
3265: (*resultats)[(*s_etat_processus)
3266: .hauteur_pile_operationnelle] = NULL;
3267: l_element_courant = (void *) (*s_etat_processus)
3268: .l_base_pile;
3269:
3270: for(i = 0; i < (*s_etat_processus)
3271: .hauteur_pile_operationnelle; i++)
3272: {
3273: if (l_element_courant != NULL)
3274: {
3275: (*resultats)[i] =
3276: formateur(s_etat_processus,
3277: 0, (*((struct_liste_chainee *)
3278: l_element_courant)).donnee);
3279:
3280: if ((*resultats)[i] == NULL)
3281: {
3282: i = (*s_etat_processus).
3283: hauteur_pile_operationnelle;
3284: }
3285: else
3286: {
3287: l_element_suivant =
3288: (*((struct_liste_chainee *)
3289: l_element_courant)).suivant;
3290: }
3291: }
3292: }
3293: }
3294: else
3295: {
3296: (*resultats) = NULL;
3297: erreur = d_es_allocation_memoire;
3298: }
3299: }
3300: }
3301:
3302: l_element_courant = (void *) (*s_etat_processus)
3303: .l_base_pile;
3304: while(l_element_courant != NULL)
3305: {
3306: l_element_suivant = (*((struct_liste_chainee *)
3307: l_element_courant)).suivant;
3308:
3309: liberation(s_etat_processus,
3310: (*((struct_liste_chainee *)
3311: l_element_courant)).donnee);
3312: free((struct_liste_chainee *) l_element_courant);
3313:
3314: l_element_courant = l_element_suivant;
3315: }
3316:
3317: l_element_courant = (void *) (*s_etat_processus)
3318: .l_base_pile_contextes;
3319: while(l_element_courant != NULL)
3320: {
3321: l_element_suivant = (*((struct_liste_chainee *)
3322: l_element_courant)).suivant;
3323:
3324: liberation(s_etat_processus,
3325: (*((struct_liste_chainee *)
3326: l_element_courant)).donnee);
3327: free((struct_liste_chainee *) l_element_courant);
3328:
3329: l_element_courant = l_element_suivant;
3330: }
3331:
3332: l_element_courant = (void *) (*s_etat_processus)
3333: .l_base_pile_taille_contextes;
3334: while(l_element_courant != NULL)
3335: {
3336: l_element_suivant = (*((struct_liste_chainee *)
3337: l_element_courant)).suivant;
3338:
3339: liberation(s_etat_processus,
3340: (*((struct_liste_chainee *)
3341: l_element_courant)).donnee);
3342: free((struct_liste_chainee *) l_element_courant);
3343:
3344: l_element_courant = l_element_suivant;
3345: }
3346:
3347: for(i = 0; i < (*s_etat_processus)
3348: .nombre_instructions_externes; i++)
3349: {
3350: free((*s_etat_processus).s_instructions_externes[i]
3351: .nom);
3352: free((*s_etat_processus).s_instructions_externes[i]
3353: .nom_bibliotheque);
3354: }
3355:
3356: if ((*s_etat_processus).nombre_instructions_externes != 0)
3357: {
3358: free((*s_etat_processus).s_instructions_externes);
3359: }
3360:
3361: l_element_courant = (void *) (*s_etat_processus)
3362: .s_bibliotheques;
3363:
3364: while(l_element_courant != NULL)
3365: {
3366: l_element_suivant = (*((struct_liste_chainee *)
3367: l_element_courant)).suivant;
3368:
3369: free((*((struct_bibliotheque *)
3370: (*((struct_liste_chainee *)
3371: l_element_courant)).donnee)).nom);
3372: dlclose((*((struct_bibliotheque *)
3373: (*((struct_liste_chainee *)
3374: l_element_courant)).donnee)).descripteur);
3375: free((*((struct_liste_chainee *) l_element_courant))
3376: .donnee);
3377: free(l_element_courant);
3378:
3379: l_element_courant = l_element_suivant;
3380: }
3381:
3382: l_element_courant = (void *) (*s_etat_processus)
3383: .l_base_pile_last;
3384: while(l_element_courant != NULL)
3385: {
3386: l_element_suivant = (*((struct_liste_chainee *)
3387: l_element_courant)).suivant;
3388:
3389: liberation(s_etat_processus,
3390: (*((struct_liste_chainee *)
3391: l_element_courant)).donnee);
3392: free((struct_liste_chainee *) l_element_courant);
3393:
3394: l_element_courant = l_element_suivant;
3395: }
3396:
3397: l_element_courant = (void *) (*s_etat_processus)
3398: .l_base_pile_systeme;
3399: while(l_element_courant != NULL)
3400: {
3401: l_element_suivant = (*((struct_liste_pile_systeme *)
3402: l_element_courant)).suivant;
3403:
3404: liberation(s_etat_processus,
3405: (*((struct_liste_pile_systeme *)
3406: l_element_courant)).indice_boucle);
3407: liberation(s_etat_processus,
3408: (*((struct_liste_pile_systeme *)
3409: l_element_courant)).limite_indice_boucle);
3410: liberation(s_etat_processus,
3411: (*((struct_liste_pile_systeme *)
3412: l_element_courant)).objet_de_test);
3413:
3414: if ((*((struct_liste_pile_systeme *)
3415: l_element_courant)).nom_variable != NULL)
3416: {
3417: free((*((struct_liste_pile_systeme *)
3418: l_element_courant)).nom_variable);
3419: }
3420:
3421: free((struct_liste_pile_systeme *)
3422: l_element_courant);
3423:
3424: l_element_courant = l_element_suivant;
3425: }
3426:
3427: l_element_courant = (void *)
3428: (*s_etat_processus).s_fichiers;
3429: while(l_element_courant != NULL)
3430: {
3431: l_element_suivant = (*((struct_liste_chainee *)
3432: l_element_courant)).suivant;
3433:
3434: fclose((*((struct_descripteur_fichier *)
3435: (*((struct_liste_chainee *)
3436: l_element_courant)).donnee))
3437: .descripteur_c);
3438:
3439: if ((*((struct_descripteur_fichier *)
3440: (*((struct_liste_chainee *)
3441: l_element_courant)).donnee)).type != 'C')
3442: {
3443: sqlite3_close((*((struct_descripteur_fichier *)
3444: (*((struct_liste_chainee *)
3445: l_element_courant)).donnee))
3446: .descripteur_sqlite);
3447: }
3448:
3449: if ((*((struct_descripteur_fichier *)
3450: (*((struct_liste_chainee *)
3451: l_element_courant)).donnee))
3452: .effacement == 'Y')
3453: {
3454: unlink((*((struct_descripteur_fichier *)
3455: (*((struct_liste_chainee *)
3456: l_element_courant)).donnee))
3457: .nom);
3458: }
3459:
3460: free((*((struct_descripteur_fichier *)
3461: (*((struct_liste_chainee *)
3462: l_element_courant)).donnee)).nom);
3463: free((struct_descripteur_fichier *)
3464: (*((struct_liste_chainee *)
3465: l_element_courant)).donnee);
3466: free(l_element_courant);
3467:
3468: l_element_courant = l_element_suivant;
3469: }
3470:
3471: l_element_courant = (void *)
3472: (*s_etat_processus).s_sockets;
3473: while(l_element_courant != NULL)
3474: {
3475: l_element_suivant = (*((struct_liste_chainee *)
3476: l_element_courant)).suivant;
3477:
3478: if ((*((struct_socket *)
3479: (*(*((struct_liste_chainee *)
3480: l_element_courant)).donnee).objet))
3481: .socket_connectee == d_vrai)
3482: {
3483: shutdown((*((struct_socket *)
3484: (*(*((struct_liste_chainee *)
3485: l_element_courant)).donnee).objet))
3486: .socket, SHUT_RDWR);
3487: }
3488:
3489: close((*((struct_socket *)
3490: (*(*((struct_liste_chainee *)
3491: l_element_courant)).donnee).objet)).socket);
3492:
3493: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
3494: l_element_courant)).donnee).objet)).effacement
3495: == 'Y')
3496: {
3497: unlink((*((struct_socket *)
3498: (*(*((struct_liste_chainee *)
3499: l_element_courant)).donnee).objet))
3500: .adresse);
3501: }
3502:
3503: liberation(s_etat_processus,
3504: (*((struct_liste_chainee *)
3505: l_element_courant)).donnee);
3506: free(l_element_courant);
3507:
3508: l_element_courant = l_element_suivant;
3509: }
3510:
3511: l_element_courant = (void *)
3512: (*s_etat_processus).s_connecteurs_sql;
3513: while(l_element_courant != NULL)
3514: {
3515: l_element_suivant = (*((struct_liste_chainee *)
3516: l_element_courant)).suivant;
3517:
3518: sqlclose((*((struct_liste_chainee *)
3519: l_element_courant)).donnee);
3520: liberation(s_etat_processus,
3521: (*((struct_liste_chainee *)
3522: l_element_courant)).donnee);
3523: free(l_element_courant);
3524:
3525: l_element_courant = l_element_suivant;
3526: }
3527:
3528: l_element_courant = (*s_etat_processus).s_marques;
3529: while(l_element_courant != NULL)
3530: {
3531: free((*((struct_marque *) l_element_courant)).label);
3532: free((*((struct_marque *) l_element_courant)).position);
3533: l_element_suivant = (*((struct_marque *)
3534: l_element_courant)).suivant;
3535: free(l_element_courant);
3536: l_element_courant = l_element_suivant;
3537: }
3538: }
3539: else
3540: {
3541: erreur = d_es_allocation_memoire;
3542:
3543: if (test_cfsf(s_etat_processus, 51) == d_faux)
3544: {
3545: printf("%s", ds_beep);
3546: }
3547:
3548: if ((*s_etat_processus).langue == 'F')
3549: {
3550: printf("+++Système : Mémoire insuffisante\n");
3551: }
3552: else
3553: {
3554: printf("+++System : Not enough memory\n");
3555: }
3556: }
3557: }
3558:
3559: liberation_allocateur(s_etat_processus);
3560: }
3561:
3562: if (traitement_fichier_temporaire == 'Y')
3563: {
3564: if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
3565: {
3566: return(EXIT_FAILURE);
3567: }
3568:
3569: free(nom_fichier_temporaire);
3570: }
3571:
3572: if ((*s_etat_processus).profilage == d_vrai)
3573: {
3574: ecriture_profil(s_etat_processus);
3575: liberation_profil(s_etat_processus);
3576: }
3577: }
3578:
3579: closelog();
3580:
3581: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
3582: pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
3583: .mutex));
3584:
3585: retrait_thread(s_etat_processus);
3586:
3587: pthread_mutex_destroy(&((*s_etat_processus).mutex));
3588: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
3589:
3590: # ifndef SEMAPHORES_NOMMES
3591: sem_post(&((*s_etat_processus).semaphore_fork));
3592: sem_destroy(&((*s_etat_processus).semaphore_fork));
3593: # else
3594: sem_post((*s_etat_processus).semaphore_fork);
3595: sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork);
3596: # endif
3597:
3598: free((*s_etat_processus).localisation);
3599:
3600: # ifndef SEMAPHORES_NOMMES
3601: sem_destroy(&semaphore_liste_threads);
3602: # else
3603: sem_destroy2(semaphore_liste_threads, sem_liste_threads);
3604: # endif
3605: # ifndef SEMAPHORES_NOMMES
3606: sem_post(&semaphore_gestionnaires_signaux);
3607: sem_destroy(&semaphore_gestionnaires_signaux);
3608: sem_destroy(&semaphore_gestionnaires_signaux_atomique);
3609: # else
3610: sem_post(semaphore_gestionnaires_signaux);
3611: sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux);
3612: sem_destroy2(semaphore_gestionnaires_signaux_atomique,
3613: sem_gestionnaires_signaux_atomique);
3614: # endif
3615:
3616: # ifdef _BROKEN_SIGINFO
3617: destruction_fifos_signaux(s_etat_processus);
3618: # undef return
3619: # endif
3620:
3621: free((*s_etat_processus).chemin_fichiers_temporaires);
3622: free(s_etat_processus);
3623:
3624: # ifdef DEBUG_MEMOIRE
3625: debug_memoire_verification();
3626: analyse_post_mortem();
3627: # endif
3628:
3629: return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
3630: }
3631:
3632:
3633: void
3634: informations(struct_processus *s_etat_processus)
3635: {
3636: printf("\n");
3637:
3638: if ((*s_etat_processus).langue == 'F')
3639: {
3640: printf(" rpl [-options] [programme]\n");
3641: printf(" -a : analyse du code\n");
3642: printf(" -A : paramètres passés au programme principal\n");
3643: printf(" -c : génération de fichier de débogage (rpl-core)\n");
3644: printf(" -d : option de déverminage interne\n");
3645: printf(" -D : lancement d'un daemon\n");
3646: printf(" -h : aide sur la ligne de commande\n");
3647: printf(" -i : fonctionnement interactif\n");
3648: printf(" -l : licence d'utilisation\n");
3649: printf(" -n : ignorance du signal HUP\n");
3650: printf(" -p : précompilation du script avant exécution\n");
3651: printf(" -P : profilage\n");
3652: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
3653: printf(" -S : exécution du script passé en ligne de commande\n");
3654: printf(" -t : trace\n");
3655: printf(" -v : version\n");
3656: }
3657: else
3658: {
3659: printf(" rpl [-options] [program]\n");
3660: printf(" -a : analyzes program\n");
3661: printf(" -A : sends parameters to main program\n");
3662: printf(" -c : allows creation of a rpl-core file, providing a way"
3663: "\n"
3664: " to debug a program\n");
3665: printf(" -d : internal debug process\n");
3666: printf(" -D : starts in daemon mode\n");
3667: printf(" -h : shows a summary of available options\n");
3668: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
3669: printf(" -l : prints the user licence of the software\n");
3670: printf(" -n : ignores HUP signal\n");
3671: printf(" -p : precompiles script\n");
3672: printf(" -P : computes profile data\n");
3673: printf(" -s : disables splash screen\n");
3674: printf(" -S : executes script written in command line\n");
3675: printf(" -t : enables tracing mode\n");
3676: printf(" -v : prints the version number\n");
3677: }
3678:
3679: printf("\n");
3680:
3681: return;
3682: }
3683:
3684: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>