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