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