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