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