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