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